#include <gmatrix.h>
Collaboration diagram for gmatrix::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) |
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 61 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 78 of file gmatrix.h.
00078 { } |
|
Copy constructor. Copies the data from a vector to the newly created vector.
Definition at line 85 of file gmatrix.h.
00086 { 00087 for (int i=0; i<S; i++) { 00088 _v[i] = v._v[i]; 00089 } 00090 } |
|
vector maximum. Return the highest value in the vector.
Definition at line 270 of file gmatrix.h.
00271 { 00272 TYPE r = _v[0]; 00273 00274 for (int i=1; i<S; i++) { 00275 if (_v[i] > r) r = _v[i]; 00276 } 00277 return r; 00278 } |
|
vector minimum. Return the lowest value in the vector.
Definition at line 285 of file gmatrix.h.
00286 { 00287 TYPE r = _v[0]; 00288 00289 for (int i=1; i<S; i++) { 00290 if (_v[i] < r) r = _v[i]; 00291 } 00292 return r; 00293 } |
|
operator* (dot product). Dot product of two vectors of the same size and type.
Definition at line 255 of file gmatrix.h.
00256 { 00257 TYPE r = 0; 00258 00259 for (int i=0; i<S; i++) { 00260 r = _v[i] * v._v[i]; 00261 } 00262 return r; 00263 } |
|
operator*. Multiply a vector by a scalar (same underlying type).
Definition at line 172 of file gmatrix.h.
00173 { 00174 GVector<S,TYPE> r; 00175 00176 for (int i=0; i<S; i++) { 00177 r._v[i] = _v[i] * k; 00178 } 00179 00180 return r; 00181 } |
|
operator*=. Self multiplication of this vector with a scalar (same underlying type).
Definition at line 229 of file gmatrix.h.
00230 { 00231 for (int i=0; i<S; i++) { 00232 _v[i] *= k; 00233 } 00234 } |
|
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 99 of file gmatrix.h.
00099 { return &_v[0]; }
|
|
operator+. Addition of two vectors. The current vector is not modified.
Definition at line 138 of file gmatrix.h.
00139 { 00140 GVector<S,TYPE> r; 00141 00142 for (int i=0; i<S; i++) { 00143 r._v[i] = _v[i] + v._v[i]; 00144 } 00145 00146 return r; 00147 } |
|
operator+=. Self addition of two vectors.
Definition at line 205 of file gmatrix.h.
00206 { 00207 for (int i=0; i<S; i++) { 00208 _v[i] += v._v[i]; 00209 } 00210 } |
|
operator-. Substraction of two vectors. The current vector is not modified.
Definition at line 155 of file gmatrix.h.
00156 { 00157 GVector<S,TYPE> r; 00158 00159 for (int i=0; i<S; i++) { 00160 r._v[i] = _v[i] - v._v[i]; 00161 } 00162 00163 return r; 00164 } |
|
operator-=. Self substratcion of two vectors.
Definition at line 217 of file gmatrix.h.
00218 { 00219 for (int i=0; i<S; i++) { 00220 _v[i] -= v._v[i]; 00221 } 00222 } |
|
operator*. Divide a vector by a scalar (same underlying type).
Definition at line 189 of file gmatrix.h.
00190 { 00191 GVector<S,TYPE> r; 00192 00193 for (int i=0; i<S; i++) { 00194 r._v[i] = _v[i] / k; 00195 } 00196 00197 return r; 00198 } |
|
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 242 of file gmatrix.h.
00243 { 00244 for (int i=0; i<S; i++) { 00245 _v[i] /= k; 00246 } 00247 } |
|
operator=. Copie the content of an existing vector to this one.
Definition at line 124 of file gmatrix.h.
00125 { 00126 for (int i=0; i<S; i++) { 00127 _v[i] = v._v[i]; 00128 } 00129 return *this; 00130 } |
|
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 116 of file gmatrix.h.
00116 { 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 107 of file gmatrix.h.
00107 { return _v[s]; }
|