#include <gmatrix.h>
Collaboration diagram for GVector< S, TYPE >:
Public Member Functions | |
GVector () | |
Default constructor. | |
GVector (const GVector< S, TYPE > &v) | |
Copy constructor. | |
operator TYPE * () const | |
Cast operator. | |
TYPE & | operator[] (int s) |
Data access operator. Provided to give an R/W access to the vector data. No check is performed on the s value (if it is aout of bound important runtime errors may arise). | |
TYPE | operator[] (int s) const |
Data access operator (const). | |
GVector< S, TYPE > & | operator= (const GVector< S, TYPE > &v) const |
operator=. | |
GVector< S, TYPE > | operator+ (const GVector< S, TYPE > &v) const |
operator+. | |
GVector< S, TYPE > | operator- (const GVector< S, TYPE > &v) const |
operator-. | |
GVector< S, TYPE > | operator * (TYPE k) const |
operator*. | |
GVector< S, TYPE > | operator/ (TYPE k) const |
operator*. | |
void | operator+= (const GVector< S, TYPE > &v) |
operator+=. | |
void | operator-= (const GVector< S, TYPE > &v) |
operator-=. | |
void | operator *= (TYPE k) |
operator*=. | |
void | operator/= (TYPE k) |
operator/=. | |
TYPE | operator * (const GVector< S, TYPE > &v) const |
operator* (dot product). | |
TYPE | max () const |
vector maximum. | |
TYPE | min () const |
vector minimum. |
The GVector class implements a N-vector object. It is mainly used for mathematics purpose (and therefore, it is not a good idea to make a GVector of std::string objects :) All the classical operators are defined : arithmetics (+, -, *, /), dot product (via the * operator) and data access (via the [] operator).
S | the size of the vector |
TYPE | the underlying data type (default is float) |
Definition at line 53 of file gmatrix.h.
|
Default constructor. Does nothing. The vector datas are still uninitialized after the construction of the vector. This is mainly done to avoid the multiple initialization of the vetcor datas. Definition at line 70 of file gmatrix.h.
00070 { } |
|
Copy constructor. Copies the data from a vector to the newly created vector.
Definition at line 77 of file gmatrix.h.
00078 { 00079 for (int i=0; i<S; i++) { 00080 _v[i] = v._v[i]; 00081 } 00082 } |
|
vector maximum. Return the highest value in the vector.
Definition at line 262 of file gmatrix.h.
00263 { 00264 TYPE r = _v[0]; 00265 00266 for (int i=1; i<S; i++) { 00267 if (_v[i] > r) r = _v[i]; 00268 } 00269 return r; 00270 } |
|
vector minimum. Return the lowest value in the vector.
Definition at line 277 of file gmatrix.h.
00278 { 00279 TYPE r = _v[0]; 00280 00281 for (int i=1; i<S; i++) { 00282 if (_v[i] < r) r = _v[i]; 00283 } 00284 return r; 00285 } |
|
operator* (dot product). Dot product of two vectors of the same size and type.
Definition at line 247 of file gmatrix.h.
00248 { 00249 TYPE r = 0; 00250 00251 for (int i=0; i<S; i++) { 00252 r = _v[i] * v._v[i]; 00253 } 00254 return r; 00255 } |
|
operator*. Multiply a vector by a scalar (same underlying type).
Definition at line 164 of file gmatrix.h.
00165 { 00166 GVector<S,TYPE> r; 00167 00168 for (int i=0; i<S; i++) { 00169 r._v[i] = _v[i] * k; 00170 } 00171 00172 return r; 00173 } |
|
operator*=. Self multiplication of this vector with a scalar (same underlying type).
Definition at line 221 of file gmatrix.h.
00222 { 00223 for (int i=0; i<S; i++) { 00224 _v[i] *= k; 00225 } 00226 } |
|
Cast operator. Casts the GVector<> object to const TYPE*. The purpose of this function is to mimic the behavior of a classical C array when it is passed as a function parameter.
Definition at line 91 of file gmatrix.h.
00091 { return &_v[0]; }
|
|
operator+. Addition of two vectors. The current vector is not modified.
Definition at line 130 of file gmatrix.h.
00131 { 00132 GVector<S,TYPE> r; 00133 00134 for (int i=0; i<S; i++) { 00135 r._v[i] = _v[i] + v._v[i]; 00136 } 00137 00138 return r; 00139 } |
|
operator+=. Self addition of two vectors.
Definition at line 197 of file gmatrix.h.
00198 { 00199 for (int i=0; i<S; i++) { 00200 _v[i] += v._v[i]; 00201 } 00202 } |
|
operator-. Substraction of two vectors. The current vector is not modified.
Definition at line 147 of file gmatrix.h.
00148 { 00149 GVector<S,TYPE> r; 00150 00151 for (int i=0; i<S; i++) { 00152 r._v[i] = _v[i] - v._v[i]; 00153 } 00154 00155 return r; 00156 } |
|
operator-=. Self substratcion of two vectors.
Definition at line 209 of file gmatrix.h.
00210 { 00211 for (int i=0; i<S; i++) { 00212 _v[i] -= v._v[i]; 00213 } 00214 } |
|
operator*. Divide a vector by a scalar (same underlying type).
Definition at line 181 of file gmatrix.h.
00182 { 00183 GVector<S,TYPE> r; 00184 00185 for (int i=0; i<S; i++) { 00186 r._v[i] = _v[i] / k; 00187 } 00188 00189 return r; 00190 } |
|
operator/=. Self divide of this vector with a scalar (same underlying type). If k is 0 then the result of the divide operation is undefined.
Definition at line 234 of file gmatrix.h.
00235 { 00236 for (int i=0; i<S; i++) { 00237 _v[i] /= k; 00238 } 00239 } |
|
operator=. Copie the content of an existing vector to this one.
Definition at line 116 of file gmatrix.h.
00117 { 00118 for (int i=0; i<S; i++) { 00119 _v[i] = v._v[i]; 00120 } 00121 return *this; 00122 } |
|
Data access operator (const). Provided to give an RO access to the vector data. No check is performed on the s value (if it is aout of bound important runtime errors may arise)
Definition at line 108 of file gmatrix.h.
00108 { return _v[s]; }
|
|
Data access operator. Provided to give an R/W access to the vector data. No check is performed on the s value (if it is aout of bound important runtime errors may arise).
Definition at line 99 of file gmatrix.h.
00099 { return _v[s]; }
|