Files Classes Functions Hierarchy
#include <vec.h>
Public Member Functions | |
| vec (A ai_, uintc N_) | |
| Pass in the vector and it number of dimensions. | |
| void | operator= (T const x) |
| Scalar assigned to each component. | |
| template<typename Z > | |
| void | operator= (Z const &zi) |
| Copy vector to ai. | |
| void | operator= (vec< A, T > const &vb) |
| Copy vector to ai. | |
| template<typename Z > | |
| void | operator*= (Z const &zi) |
| Matching component multiplication. | |
| template<typename Z > | |
| void | operator+= (Z const &zi) |
| Matching component addition. | |
| template<typename Z > | |
| void | operator-= (Z const &zi) |
| Matching component subraction. | |
| void | operator+= (T const x) |
| Scalar addition. | |
| void | operator*= (T const x) |
| Scalar multiplication. | |
| T const | operator[] (uintc i) const |
| Element access. | |
| T & | operator[] (uintc i) |
| Element access. | |
| void | identity (uintc k, T const x=1) |
| Set the value in the ith component, all others zero. | |
| void | difference () |
| Difference X=X-rightshift(X). | |
| void | sum () |
| X=X+rightshif(X). | |
| void | binomial (uintc N) |
| Generate the binomial coefficients for N degree polynomial. | |
| operator string () const | |
| Write the vector out as a string separated with spaces. | |
Public Attributes | |
| A | ai |
| The vector. | |
| uintc | N |
| The number of dimensions. | |
Support arithmetic operations on a data type with the [] operator.
This class does not explicity manage memory. No array bounds error checking or anything, nothing to interfere with the cache. Let the emphasis be on the client data structures to provide such functionality if they choose to.
unsigned int const n=3;
double a1[n] = { 2.0, 7.0, 0.0 };
double a2[n] = { 1.0, -3.0, 2.0 };
double a3[n] = { 0.0, 0.0, 0.0 };
vec<double*,double> v1(&a1[0],n);
vec<double*,double> v2(&a2[0],n);
vec<double*,double> v3(&a3[0],n);
// Calculate equation
// a3 = 2(a1-a2)
v3 = a1;
v3 -= a2;
v3 *= 2.0;
Definition at line 42 of file vec.h.
Generate the binomial coefficients for N degree polynomial.
Definition at line 133 of file vec.h.
References vec< A, T >::identity(), and vec< A, T >::sum().
Referenced by vectest::test02().
Difference X=X-rightshift(X).
Definition at line 149 of file vec.h.
References vec< A, T >::ai, and vec< A, T >::N.
Referenced by patternsearchD2< EXP >::patternsearchD2(), and vectest::test02().
Set the value in the ith component, all others zero.
Definition at line 141 of file vec.h.
References vec< A, T >::ai, and vec< A, T >::N.
Referenced by vec< A, T >::binomial(), and patternsearchD2< EXP >::patternsearchD2().
Write the vector out as a string separated with spaces.
Definition at line 115 of file vec.h.
References vec< A, T >::ai, and vec< A, T >::N.
00116 { 00117 if (N==0) 00118 return ""; 00119 00120 string s; 00121 { stringstream ss; ss << ai[0]; s+=ss.str(); } 00122 00123 for (uint i=1; i<N; ++i) 00124 { 00125 s += " "; 00126 { stringstream ss; ss << ai[i]; s+=ss.str(); } 00127 } 00128 00129 return s; 00130 }
Scalar multiplication.
Definition at line 202 of file vec.h.
References vec< A, T >::ai, and vec< A, T >::N.
| void vec< A, T >::operator*= | ( | Z const & | zi | ) | [inline] |
Matching component multiplication.
Definition at line 172 of file vec.h.
References vec< A, T >::ai, and vec< A, T >::N.
Scalar addition.
Definition at line 209 of file vec.h.
References vec< A, T >::ai, and vec< A, T >::N.
| void vec< A, T >::operator+= | ( | Z const & | zi | ) | [inline] |
Matching component addition.
Definition at line 180 of file vec.h.
References vec< A, T >::ai, and vec< A, T >::N.
| void vec< A, T >::operator-= | ( | Z const & | zi | ) | [inline] |
Matching component subraction.
Definition at line 188 of file vec.h.
References vec< A, T >::ai, and vec< A, T >::N.
Copy vector to ai.
Definition at line 216 of file vec.h.
References vec< A, T >::ai, and vec< A, T >::N.
| void vec< A, T >::operator= | ( | Z const & | zi | ) | [inline] |
Copy vector to ai.
Definition at line 164 of file vec.h.
References vec< A, T >::ai, and vec< A, T >::N.
Scalar assigned to each component.
Definition at line 195 of file vec.h.
References vec< A, T >::ai, and vec< A, T >::N.
X=X+rightshif(X).
Definition at line 156 of file vec.h.
References vec< A, T >::ai, and vec< A, T >::N.
Referenced by vec< A, T >::binomial().
The vector.
Definition at line 47 of file vec.h.
Referenced by vec< A, T >::difference(), vec< A, T >::identity(), vec< A, T >::operator string(), vec< A, T >::operator*=(), vec< A, T >::operator+=(), vec< A, T >::operator-=(), vec< A, T >::operator=(), vec< XI, T >::operator[](), and vec< A, T >::sum().
The number of dimensions.
Definition at line 50 of file vec.h.
Referenced by vec< A, T >::difference(), vec< A, T >::identity(), vec< A, T >::operator string(), vec< A, T >::operator*=(), vec< A, T >::operator+=(), vec< A, T >::operator-=(), vec< A, T >::operator=(), and vec< A, T >::sum().
1.5.8