#include <HxVector.h>
Constructors | |
HxVector () | |
Empty vector. More... | |
HxVector (int n) | |
Empty vector of given size. More... | |
HxVector (int n, double *data) | |
vector with given data. More... | |
HxVector (double a0, double a1) | |
Vector of size 2, with given values. More... | |
HxVector (double a0, double a1, double a2) | |
Vector of size 3, with given values. More... | |
HxVector (double a0, double a1, double a2, double a3) | |
Vector of size 4, with given values. More... | |
HxVector (const HxVector &v) | |
Copy constructor. More... | |
HxVector (const HxMatrix &m) | |
Copy from matrix constructor. More... | |
Inquiry | |
int | nElem () const |
Number of elements. More... | |
int | valid () const |
Indicates whether the vector is valid. More... | |
Operators | |
HxVector & | operator= (double a) |
Assign constant value. More... | |
HxVector & | operator= (const HxVector &v) |
Normal assignment. More... | |
double & | operator[] (int i) const |
Subscripting, start with 0. More... | |
HxVector | operator- () const |
Unary minus. More... | |
double | operator * (const HxVector &a, const HxVector &b) |
Multiplication. More... | |
HxVector | operator * (const double a, const HxVector &b) |
Multiplication. More... | |
HxVector | operator * (const HxVector &a, const double b) |
Multiplication. More... | |
HxVector | operator/ (const HxVector &a, double b) |
Division. More... | |
HxVector | operator/ (double a, const HxVector &b) |
Division. More... | |
HxVector | operator+ (const HxVector &a, const HxVector &b) |
Addition. More... | |
HxVector | operator+ (const HxVector &a, double b) |
Addition. More... | |
HxVector | operator+ (double a, const HxVector &b) |
Addition. More... | |
HxVector | operator- (const HxVector &a, const HxVector &b) |
Subtraction. More... | |
HxVector | operator- (const HxVector &a, double b) |
Subtraction. More... | |
HxVector | operator- (double a, const HxVector &b) |
Subtraction. More... | |
int | operator== (const HxVector &a, const HxVector &b) |
Equal. More... | |
int | operator!= (const HxVector &a, const HxVector &b) |
Not equal. More... | |
Operations | |
HxMatrix | t () const |
Transpose Matrix. More... | |
HxMatrix | diag () const |
Diagonal Matrix. More... | |
HxVector | add (const HxVector &b) const |
Addition. More... | |
HxVector | add (const double val) const |
Addition. More... | |
HxVector | sub (const HxVector &b) const |
Subtraction. More... | |
HxVector | sub (const double val) const |
Subtraction. More... | |
HxVector | mul (const HxVector &b) const |
Multiplication. More... | |
HxVector | mul (const HxMatrix &m) const |
Multiplication. More... | |
HxVector | mul (const double val) const |
Multiplication. More... | |
HxVector | div (const double val) const |
Division. More... | |
HxVector | sin () const |
Apply sin to each element. More... | |
HxVector | cos () const |
Apply cos to each element. More... | |
HxVector | tan () const |
Apply tan to each element. More... | |
HxVector | sinh () const |
Apply sinh to each element. More... | |
HxVector | cosh () const |
Apply cosh to each element. More... | |
HxVector | tanh () const |
Apply tanh to each element. More... | |
HxVector | exp () const |
Apply exp to each element. More... | |
HxVector | log () const |
Apply log to each element. More... | |
HxVector | sqrt () const |
Apply sqrt to each element. More... | |
HxVector | abs () const |
Apply abs to each element. More... | |
HxVector | sgn () const |
Apply sgn to each element. More... | |
HxVector | map (double(*f)(double)) const |
Map f to each element of this. More... | |
Public Methods | |
~HxVector () | |
std::ostream & | put (std::ostream &os) const |
The vector may have arbitrary size.
|
Empty vector.
00221 { 00222 _n = 0; 00223 _data = 0; 00224 } |
|
Empty vector of given size.
00227 { 00228 _n = n; 00229 _data = new double[_n]; 00230 } |
|
vector with given data.
00233 { 00234 _n = n; 00235 _data = data; 00236 } |
|
Vector of size 2, with given values.
00239 { 00240 _n = 2; 00241 _data = new double[_n]; 00242 _data[0] = a0; 00243 _data[1] = a1; 00244 } |
|
Vector of size 3, with given values.
00247 { 00248 _n = 3; 00249 _data = new double[_n]; 00250 _data[0] = a0; 00251 _data[1] = a1; 00252 _data[2] = a2; 00253 } |
|
Vector of size 4, with given values.
00256 { 00257 _n = 4; 00258 _data = new double[_n]; 00259 _data[0] = a0; 00260 _data[1] = a1; 00261 _data[2] = a2; 00262 _data[3] = a3; 00263 } |
|
Copy constructor.
|
|
Copy from matrix constructor.
|
|
Number of elements.
00284 { 00285 return _n; 00286 } |
|
Indicates whether the vector is valid.
00290 { 00291 return (_n != 0); 00292 } |
|
Assign constant value.
|
|
Normal assignment.
|
|
Subscripting, start with 0.
00322 { 00323 return _data[i]; 00324 } |
|
Unary minus.
|
|
Transpose Matrix.
|
|
Diagonal Matrix.
|
|
Addition. Equivalent to : a+b
00138 { 00139 return *this+b; 00140 } |
|
Addition. Equivalent to : a+val
00144 { 00145 return *this+val; 00146 } |
|
Subtraction. Equivalent to : a-b
00150 { 00151 return *this-b; 00152 } |
|
Subtraction. Equivalent to : a-val
00156 { 00157 return *this-val; 00158 } |
|
Multiplication. Equivalent to : a*b
00162 { 00163 return *this*b; 00164 } |
|
Multiplication. Equivalent to : a*v
00174 { 00175 00176 if (this->nElem() != m.nRow()) { 00177 error("nonconformant HxVector * HxMatrix operands."); 00178 return HxVector(0); 00179 } 00180 HxVector v(m.nCol()); 00181 double sum; 00182 int i, j; 00183 for (i=0 ; i<m.nCol() ; i++) { 00184 sum = 0; 00185 for (j=0 ; j<m.nRow() ; j++) 00186 sum += (*this)[j] * m[j][i]; 00187 v[i] = sum; 00188 } 00189 return v; 00190 00191 00192 00193 } |
|
Multiplication. Equivalent to : a*val
00168 { 00169 return *this*val; 00170 } |
|
Division. Equivalent to : a/val
00197 { 00198 return *this/val; 00199 } |
|
Apply sin to each element.
|
|
Apply cos to each element.
|
|
Apply tan to each element.
|
|
Apply sinh to each element.
|
|
Apply cosh to each element.
|
|
Apply tanh to each element.
|
|
Apply exp to each element.
|
|
Apply log to each element.
|
|
Apply sqrt to each element.
|
|
Apply abs to each element.
00257 { 00258 return map(::fabs); 00259 } |
|
Apply sgn to each element.
|
|
Map f to each element of this.
|
|
Multiplication.
|
|
Multiplication.
|
|
Multiplication.
|
|
Division.
|
|
Division.
|
|
Addition.
|
|
Addition.
|
|
Addition.
|
|
Subtraction.
|
|
Subtraction.
|
|
Subtraction.
|
|
Equal.
|
|
Not equal.
00436 { 00437 return !(a == b); 00438 } |