171 std::ostream &operator<< (std::ostream &os, const TVector<VT> &v);
193 MATHLIB
void SelfConj(
const TVector<std::complex<double> > &vec);
217 template<
class VT>
class TVector {
249 TVector (
int dim, VT *values, CopyMode cmode=DEEP_COPY);
261 TVector (
int dim,
const char *init);
331 void Copy (
const TVector &v,
int tofs,
int sofs,
int n);
375 void Relink (VT *values,
int dim);
582 void Read (std::istream &is,
int start = 0,
int n = -1);
840 #ifndef USE_CUDA_FLOAT
845 #elif (GCC_VERSION < 30404) // old-style definitions
850 #endif // !USE_CUDA_FLOAT
867 #elif (GCC_VERSION < 30404) // old-style definitions
888 #elif (GCC_VERSION < 30404) // old-style definitions
910 #elif (GCC_VERSION < 30404) // old-style definitions
935 friend std::ostream &operator<< <> (std::ostream &os,
956 friend std::istream &operator>> <> (std::istream &is,
TVector<VT> &v);
975 friend VT SparseDotp<> (
const TVector<VT> &v1, idxtype *idx1,
int nidx1,
997 void Scan (
const char *cbuf,
int nmax = 0);
1042 void Link (VT *values,
int dim);
1068 #endif // !__VECTOR_H
void Copy(const TVector &v)
Vector copy. Replaces the vector with a copy of 'v'.
int * base_size
pointer to length of linked data block
Definition: vector.h:1050
const VT * data_buffer() const
Direct access to vector data array.
Definition: vector.h:391
void ShiftRight(int n)
Move vector elements right.
VT * data_buffer()
Direct access to vector data array.
Definition: vector.h:383
friend TVector< VT > acosh(const TVector< VT > &v)
Returns element-wise inverse hyperbolic cosine vector acosh((*this)[i])
VT * base_data
pointer to linked data block
Definition: vector.h:1053
bool Clip(VT vmin, VT vmax)
Truncate vector elements to specified range.
void New(int dim)
Resize the vector.
Definition: vector.h:338
friend TVector< VT > cat(const TVector< VT > &v1, const TVector< VT > &v2)
Concatenate two vectors.
Templated vector class.
Definition: vector.h:39
TVector operator+(const TVector &v) const
Element-wise addition of vectors.
TVector & operator+=(const TVector &v)
Element-wise addition/assignment of vectors.
friend double l1norm(const TVector< VT > &v)
L1 norm of vector elements.
friend TVector< VT > inv(const TVector< VT > &v)
Returns element-wise inverse vector 1/(*this)[i].
friend TVector< VT > pow(const TVector< VT > &v, const VT &s)
Returns element-wise power vector (*this)[i]^s.
friend std::istream & operator>>(std::istream &is, TVector< VT > &v)
Read vector from input stream.
friend double l2normsq(const TVector< VT > &v)
Square of L2 norm of vector elements.
void ReadIndexed(std::istream &is, int n=-1)
Read indexed vector elements from stream.
TVector()
Constructor. Creates a vector of length 0.
friend TVector< VT > & append(TVector< VT > &v1, const TVector< VT > &v2)
Concatenate two vectors.
TVector operator*(const TVector &v) const
Element-wise multiplication of vectors.
friend VT median(const TVector< VT > &v)
Median value of elements.
friend TVector< VT > exp(const TVector< VT > &v)
Returns element-wise base-e exponential vector exp((*this)[i])
friend double length(const TVector< VT > &vec)
Length of a vector (L2 norm of elements)
Definition: vector.h:806
TVector operator-() const
Unary minus.
friend TVector< VT > cos(const TVector< VT > &v)
Returns element-wise cosine vector cos((*this)[i])
friend TVector< double > UnfoldComplex(const TVector< VT > &v)
Unfold real and imaginary parts of a complex vector.
void Relink(const TVector &v)
Link the vector to the data block of another vector.
friend double linfnorm(const TVector< VT > &v)
L-infinity norm of vector elements.
int * base_nref
pointer to data block reference counter
Definition: vector.h:1051
TVector & operator*=(const TVector &v)
Element-wise multiplication/assignment of vectors.
friend bool operator!=(const TVector< VT > &v1, const TVector< VT > &v2)
Vector comparison (relational operator)
int size
vector length
Definition: vector.h:1049
friend TVector< VT > acos(const TVector< VT > &v)
Returns element-wise arc cosine vector acos((*this)[i])
VT operator&(const TVector &v) const
Dot product of two vectors.
Definition: vector.h:512
friend TVector< VT > tan(const TVector< VT > &v)
Returns element-wise tangent vector tan((*this)[i])
TVector & operator-=(const TVector &v)
Element-wise subtraction/assignment of vectors.
void Scan(const char *cbuf, int nmax=0)
Initialise vector elements from a string.
friend TVector< VT > sinh(const TVector< VT > &v)
Returns element-wise hyperbolic sine vector sinh((*this)[i])
friend TVector< VT > tanh(const TVector< VT > &v)
Returns element-wise hyperbolic tangent vector tanh((*this)[i])
int Dim() const
Returns the size of the vector.
Definition: vector.h:295
friend VT SparseDotp(const TVector< VT > &v1, idxtype *idx1, int nidx1, const TVector< VT > &v2, idxtype *idx2, int nidx2, int from, int to)
Sparse dot product of two vectors.
~TVector()
Destructor. Delete vector and deallocate data block.
Definition: vector.h:289
friend TVector< VT > log(const TVector< VT > &v)
Returns element-wise natural logarithm vector ln((*this)[i])
friend VT mean(const TVector< VT > &v)
Mean value of elements.
void Clear()
Zeroes all elements.
void Unlink()
Unlink vector from its data block.
TVector & operator=(const TVector &v)
Assignment operator.
Definition: vector.h:309
friend TVector< VT > sin(const TVector< VT > &v)
Returns element-wise sine vector sin((*this)[i])
friend TVector< VT > vsort(const TVector< VT > &v)
Sort vector.
VT * data
pointer to first vector element
Definition: vector.h:1052
friend TVector< VT > asinh(const TVector< VT > &v)
Returns element-wise inverse hyperbolic sine vector asinh((*this)[i])
void Allocate(int dim)
Allocate data buffer.
void Read(std::istream &is, int start=0, int n=-1)
Read vector from stream.
friend VT stdv(const TVector< VT > &v)
Standard deviation of element values.
friend TVector< VT > asin(const TVector< VT > &v)
Returns element-wise arc sine vector asin((*this)[i])
friend TVector< VT > atan(const TVector< VT > &v)
Returns element-wise arc tangent vector atan((*this)[i])
TVector operator/(const TVector &v) const
Element-wise division of vectors.
void ShiftLeft(int n)
Move vector elements left.
friend VT dot(const TVector< VT > &v1, const TVector< VT > &v2)
Dot product of two vectors.
friend TVector< VT > sqr(const TVector< VT > &v)
Returns element-wise square vector (*this)[i]^2.
friend bool operator==(const TVector< VT > &v1, const TVector< VT > &v2)
Vector comparison (relational operator)
friend TVector< VT > sqrt(const TVector< VT > &v)
Returns element-wise square-root vector (*this)[i]^(1/2)
friend VT doth(const TVector< VT > &v1, const TVector< VT > &v2)
Hermitian product of two vectors.
friend TVector< VT > cosh(const TVector< VT > &v)
Returns element-wise hyperbolic cosine vector cosh((*this)[i])
void Link(const TVector< VT > &vec)
Link the vector to the data block of another vector.
friend double l2norm(const TVector< VT > &v)
L2 norm of vector elements.
friend TVector< VT > atanh(const TVector< VT > &v)
Returns element-wise inverse hyperbolic tangent vector atanh(v[i])
friend VT sum(const TVector< VT > &v)
Sum of elements.
TVector & operator/=(const TVector &v)
Element-wise division/assignment of vectors.
friend VT variance(const TVector< VT > &v)
Variance of element values.
friend VT vmax(const TVector< VT > &v)
Extract largest element in vector.
VT & operator[](int i) const
Vector element access operator (read and write)
friend TVector< VT > conj(const TVector< VT > &v)
Returns element-wise complex conjugate vector ((*this([i].re, -(*this)[i].im)
friend VT vmin(const TVector< VT > &v)
Extract smallest element in vector.