#include <Vector.hpp>
Public Member Functions | |
Vector () | |
default constructor | |
Vector (const size_t &size) | |
constructor with a specific size and template type | |
Vector (const Vector< T > &v) | |
Copy Constructor. | |
Vector (Vector< T > *v) | |
Copy Constructor. | |
Vector (const size_t &dataSize, const T *a) | |
Constructor from a data array. | |
Vector (const size_t &dataSize, const T &d) | |
Constructor from a constant : duplicate this constant on all the vector entries. | |
virtual | ~Vector (void) |
Destructor. | |
T & | at (const unsigned int &i) |
Access to an element of the Vector. | |
const T & | at (const unsigned int &i) const |
Access to an element of the Vector. | |
void | resize (const int &size) |
Resize and reset this vector. | |
void | resizeAndCopy (const Vector< T > &v) |
Resize this vector and copy the v into it Copy v data int this vector. | |
bool | operator== (const Vector< T > &v) const |
test if the vector is equal to another one | |
bool | operator!= (const Vector< T > &v) const |
test if the vector differs from another one | |
Vector< T > & | operator= (const Vector< T > &v) |
copy the value of the argument vector to this vector | |
Vector< T > & | operator= (const T &value) |
Fill the vector with a value. | |
Vector< T > | operator+ (const Vector< T > &v) const |
adds two vectors | |
Vector< T > | operator- (const Vector< T > &v) const |
subtracts two vectors | |
Vector< T > | operator/ (const T &d) const |
Divides the Vector by a value. | |
T | operator* (const Vector< T > &v) const |
dot product | |
T | dot (const Vector< T > &v) const |
dot product | |
Vector< T > | operator* (const T &d) const |
Multiplies the Vector with a value. | |
Vector< T > | operator- (void) const |
Compute opposite of the Vector. | |
Vector< T > & | operator+= (const Vector< T > &v) |
Adds the Vector with a Vector. | |
Vector< T > & | operator-= (const Vector< T > &v) |
Subtracts the Vector with a Vector. | |
Vector< T > & | operator/= (const T &d) |
Divides the Vector with a value All values of the Vector are divided by d. | |
Vector< T > & | operator*= (const T &d) |
Multiplies the Vector with a value. | |
T & | operator[] (const unsigned int &i) |
Access to an element of the Vector. | |
const T & | operator[] (const unsigned int &i) const |
Access to an element of the Vector. | |
T & | operator() (const unsigned int &i) |
Access to an element of the Vector. | |
const T & | operator() (const unsigned int &i) const |
Access to an element of the Vector. | |
Vector< T > | operator^ (const Vector< T > &v) const |
cross product between 2 vectors of size 3 | |
Vector< T > | cross (const Vector< T > &v) const |
cross product between 2 vectors of size 3 | |
size_t | size (void) const |
Returns the size of the vector (number of elements). | |
void | fill (const T &d) |
Sets the value d on every entry of the vector. | |
void | setZero (void) |
Reset the vector entries to zero. | |
void | roundZero (const double &d=1.0e-14) |
Sets the small values ( |x| < d) to 0. | |
void | setSubVector (const unsigned int &index, const Vector< T > &v) |
Copies the content of a vector v inside this vector The data from the vector v is duplicated inside this vector from the position "index". | |
void | setSubVector (const unsigned int &index1, const unsigned int &index2, const unsigned int &size, const Vector< T > &v) |
Copies the content of a vector v inside this vector The data from the vector v is duplicated inside this vector from the position "index". | |
Vector< T > | getSubVector (const unsigned int &index, const int &size) const |
Returns a sub Vector of the vector. | |
virtual T * | begin (void) const |
Returns the beginning of the vector data. | |
virtual T * | end (void) const |
Returns the end of the vector data. | |
double | getNorm (void) const |
Returns the norm of the vector. | |
Vector< T > & | normalize (void) |
Normalize the vector Divide each elements of this vector its norm. | |
Vector< T > | getNormalized (void) const |
Normalize a copy of the vector. | |
void | swap (const unsigned int &index1, const unsigned int &index2) |
Swaps two elements of this vector. | |
Vector< T > | getHomogeneous (const T &d=T(1.0)) const |
Returns the homogeneous form of the vector by adding a component. | |
Vector< T > | getUnhomogeneous (const T &zeroValue=T(1.0e-13)) const |
Returns the unhomogeneous form of the vector by removing a component. | |
void | setHomogeneousNormalForm (const T &zeroValue=T(1.0e-13)) const |
set the last vector component to 1 (if non-zero). | |
Protected Member Functions | |
void | allocate (const size_t &d) |
Check and allocate the memory to build the vector of size d. | |
void | desallocate (void) |
Check and allocate the memory to build the vector of size d. | |
Protected Attributes | |
size_t | sizeVector |
Vector size. | |
T * | begin_ |
Pointer on the beginning of the data. | |
T * | end_ |
Pointer on the end of the data. | |
T * | data |
Array containing the vector data. |
Definition at line 62 of file Vector.hpp.
kn::Vector< T >::Vector | ( | ) | [inline] |
kn::Vector< T >::Vector | ( | const size_t & | size | ) | [inline, explicit] |
constructor with a specific size and template type
size | of the vector |
Definition at line 505 of file Vector.hpp.
kn::Vector< T >::Vector | ( | const Vector< T > & | v | ) | [inline] |
kn::Vector< T >::Vector | ( | Vector< T > * | v | ) | [inline] |
kn::Vector< T >::Vector | ( | const size_t & | dataSize, | |
const T * | a | |||
) | [inline] |
Constructor from a data array.
dataSize | of the vector | |
a | Source data array |
MathException | dataArray is null |
Definition at line 528 of file Vector.hpp.
kn::Vector< T >::Vector | ( | const size_t & | dataSize, | |
const T & | d | |||
) | [inline] |
Constructor from a constant : duplicate this constant on all the vector entries.
dataSize | of the vector | |
d | Element to duplicate |
Definition at line 539 of file Vector.hpp.
virtual kn::Vector< T >::~Vector | ( | void | ) | [inline, virtual] |
void kn::Vector< T >::allocate | ( | const size_t & | d | ) | [inline, protected] |
Check and allocate the memory to build the vector of size d.
Definition at line 561 of file Vector.hpp.
const T & kn::Vector< T >::at | ( | const unsigned int & | i | ) | const [inline] |
Access to an element of the Vector.
i | the number of the element |
MathException | i is out of bounds |
Definition at line 577 of file Vector.hpp.
T & kn::Vector< T >::at | ( | const unsigned int & | i | ) | [inline] |
Access to an element of the Vector.
i | the number of the element |
MathException | i is out of bounds |
Definition at line 571 of file Vector.hpp.
virtual T* kn::Vector< T >::begin | ( | void | ) | const [inline, virtual] |
Returns the beginning of the vector data.
Definition at line 435 of file Vector.hpp.
Vector<T> kn::Vector< T >::cross | ( | const Vector< T > & | v | ) | const [inline] |
cross product between 2 vectors of size 3
v | vector of size 3 |
MathException | cross product only with vectors of size 3 |
Definition at line 361 of file Vector.hpp.
void kn::Vector< T >::desallocate | ( | void | ) | [inline, protected] |
Check and allocate the memory to build the vector of size d.
Definition at line 146 of file Vector.hpp.
T kn::Vector< T >::dot | ( | const Vector< T > & | v | ) | const [inline] |
dot product
v | the Vector used for the dot product |
MathException | incompatible vector size |
Definition at line 266 of file Vector.hpp.
virtual T* kn::Vector< T >::end | ( | void | ) | const [inline, virtual] |
Returns the end of the vector data.
Definition at line 444 of file Vector.hpp.
void kn::Vector< T >::fill | ( | const T & | d | ) | [inline] |
Sets the value d on every entry of the vector.
Reimplemented in kn::Vector2< T >, kn::Vector3< T >, and kn::Vector4< T >.
Definition at line 382 of file Vector.hpp.
Vector< T > kn::Vector< T >::getHomogeneous | ( | const T & | d = T(1.0) |
) | const [inline] |
Returns the homogeneous form of the vector by adding a component.
The default value is 1.0 (a finite vector) but could be set as '0' (ideal point) or something else.
d | : value to set on the additional component |
Definition at line 771 of file Vector.hpp.
double kn::Vector< T >::getNorm | ( | void | ) | const [inline] |
Vector< T > kn::Vector< T >::getNormalized | ( | void | ) | const [inline] |
Normalize a copy of the vector.
Reimplemented in kn::Vector2< T >, kn::Vector3< T >, and kn::Vector4< T >.
Definition at line 763 of file Vector.hpp.
Vector< T > kn::Vector< T >::getSubVector | ( | const unsigned int & | index, | |
const int & | size | |||
) | const [inline] |
Returns a sub Vector of the vector.
MathException | size too big | |
MathException | index out of bounds |
Definition at line 735 of file Vector.hpp.
Vector< T > kn::Vector< T >::getUnhomogeneous | ( | const T & | zeroValue = T(1.0e-13) |
) | const [inline] |
Returns the unhomogeneous form of the vector by removing a component.
All the component of the vector are devided by the last component, exept if this component is zero.
zeroValue | : limit to consider a number equal to zero |
Definition at line 782 of file Vector.hpp.
Vector< T > & kn::Vector< T >::normalize | ( | void | ) | [inline] |
Normalize the vector Divide each elements of this vector its norm.
Reimplemented in kn::Vector2< T >, kn::Vector3< T >, and kn::Vector4< T >.
Definition at line 754 of file Vector.hpp.
bool kn::Vector< T >::operator!= | ( | const Vector< T > & | v | ) | const [inline] |
test if the vector differs from another one
v | the vector to test |
Definition at line 207 of file Vector.hpp.
const T & kn::Vector< T >::operator() | ( | const unsigned int & | i | ) | const [inline] |
Access to an element of the Vector.
i | the number of the element |
Definition at line 688 of file Vector.hpp.
T & kn::Vector< T >::operator() | ( | const unsigned int & | i | ) | [inline] |
Access to an element of the Vector.
i | the number of the element |
Definition at line 683 of file Vector.hpp.
Vector<T> kn::Vector< T >::operator* | ( | const T & | d | ) | const [inline] |
Multiplies the Vector with a value.
d | the value multiplied with this Vector |
Reimplemented in kn::Vector2< T >, kn::Vector3< T >, and kn::Vector4< T >.
Definition at line 275 of file Vector.hpp.
T kn::Vector< T >::operator* | ( | const Vector< T > & | v | ) | const [inline] |
dot product
v | the Vector used for the dot product |
MathException | incompatible vector size |
Definition at line 634 of file Vector.hpp.
Vector< T > & kn::Vector< T >::operator*= | ( | const T & | d | ) | [inline] |
Multiplies the Vector with a value.
d | the value multiplied with this Vector |
Reimplemented in kn::Vector2< T >, kn::Vector3< T >, and kn::Vector4< T >.
Definition at line 667 of file Vector.hpp.
Vector< T > kn::Vector< T >::operator+ | ( | const Vector< T > & | v | ) | const [inline] |
adds two vectors
v | the vector to be added |
MathException | incompatible vector size |
Definition at line 611 of file Vector.hpp.
Vector< T > & kn::Vector< T >::operator+= | ( | const Vector< T > & | v | ) | [inline] |
Adds the Vector with a Vector.
v | the Vector to be added |
MathException | incompatible vector size |
Definition at line 641 of file Vector.hpp.
Vector<T> kn::Vector< T >::operator- | ( | void | ) | const [inline] |
Compute opposite of the Vector.
Reimplemented in kn::Vector2< T >, kn::Vector3< T >, and kn::Vector4< T >.
Definition at line 283 of file Vector.hpp.
Vector< T > kn::Vector< T >::operator- | ( | const Vector< T > & | v | ) | const [inline] |
subtracts two vectors
v | the vector to be substracted |
Definition at line 623 of file Vector.hpp.
Vector< T > & kn::Vector< T >::operator-= | ( | const Vector< T > & | v | ) | [inline] |
Subtracts the Vector with a Vector.
v | the Vector to be subtracted |
MathException | incompatible vector size |
Definition at line 651 of file Vector.hpp.
Vector<T> kn::Vector< T >::operator/ | ( | const T & | d | ) | const [inline] |
Divides the Vector by a value.
d | the value dividing this Vector |
MathException | d is null |
Reimplemented in kn::Vector2< T >, kn::Vector3< T >, and kn::Vector4< T >.
Definition at line 248 of file Vector.hpp.
Vector< T > & kn::Vector< T >::operator/= | ( | const T & | d | ) | [inline] |
Divides the Vector with a value All values of the Vector are divided by d.
d | the value divided with this Vector |
MathException | d is null |
Reimplemented in kn::Vector2< T >, kn::Vector3< T >, and kn::Vector4< T >.
Definition at line 660 of file Vector.hpp.
Vector< T > & kn::Vector< T >::operator= | ( | const T & | value | ) | [inline] |
Fill the vector with a value.
value | Value to set the vector with |
Definition at line 604 of file Vector.hpp.
Vector< T > & kn::Vector< T >::operator= | ( | const Vector< T > & | v | ) | [inline] |
copy the value of the argument vector to this vector
v | the source vector |
MathException | the incompatible vector size |
Definition at line 591 of file Vector.hpp.
bool kn::Vector< T >::operator== | ( | const Vector< T > & | v | ) | const [inline] |
test if the vector is equal to another one
v | the vector to test |
Definition at line 583 of file Vector.hpp.
const T & kn::Vector< T >::operator[] | ( | const unsigned int & | i | ) | const [inline] |
Access to an element of the Vector.
i | the number of the element |
Definition at line 678 of file Vector.hpp.
T & kn::Vector< T >::operator[] | ( | const unsigned int & | i | ) | [inline] |
Access to an element of the Vector.
i | the number of the element |
Definition at line 673 of file Vector.hpp.
Vector< T > kn::Vector< T >::operator^ | ( | const Vector< T > & | v | ) | const [inline] |
cross product between 2 vectors of size 3
v | vector of size 3 |
MathException | cross product only with vectors of size 3 |
Definition at line 693 of file Vector.hpp.
void kn::Vector< T >::resize | ( | const int & | size | ) | [inline] |
Resize and reset this vector.
size | new size for the vector |
Definition at line 546 of file Vector.hpp.
void kn::Vector< T >::resizeAndCopy | ( | const Vector< T > & | v | ) | [inline] |
Resize this vector and copy the v into it Copy v data int this vector.
v | vector to be copied |
Definition at line 553 of file Vector.hpp.
void kn::Vector< T >::roundZero | ( | const double & | d = 1.0e-14 |
) | [inline] |
Sets the small values ( |x| < d) to 0.
d | the limit around which values are set to 0 |
Definition at line 708 of file Vector.hpp.
void kn::Vector< T >::setHomogeneousNormalForm | ( | const T & | zeroValue = T(1.0e-13) |
) | const [inline] |
set the last vector component to 1 (if non-zero).
Divide all the components of the vector by the last component if non-zero.
zeroValue | : limit to consider a number equal to zero |
Definition at line 799 of file Vector.hpp.
void kn::Vector< T >::setSubVector | ( | const unsigned int & | index1, | |
const unsigned int & | index2, | |||
const unsigned int & | size, | |||
const Vector< T > & | v | |||
) | [inline] |
Copies the content of a vector v inside this vector The data from the vector v is duplicated inside this vector from the position "index".
index1 | : position where the copy starts | |
index2 | : position where we start to copy in v | |
size | : number of element to copy | |
v | : the vector to be (partially) duplicated |
MathException | size too big | |
MathException | index1 out of bounds | |
MathException | index2 out of bounds |
Definition at line 726 of file Vector.hpp.
void kn::Vector< T >::setSubVector | ( | const unsigned int & | index, | |
const Vector< T > & | v | |||
) | [inline] |
Copies the content of a vector v inside this vector The data from the vector v is duplicated inside this vector from the position "index".
index | : position where the copy starts | |
v | : the vector to be duplicated |
MathException | v size too big | |
MathException | index out of bounds |
Definition at line 719 of file Vector.hpp.
void kn::Vector< T >::setZero | ( | void | ) | [inline] |
Reset the vector entries to zero.
Reimplemented in kn::Vector2< T >, kn::Vector3< T >, and kn::Vector4< T >.
Definition at line 389 of file Vector.hpp.
size_t kn::Vector< T >::size | ( | void | ) | const [inline] |
Returns the size of the vector (number of elements).
Reimplemented in kn::Vector2< T >, kn::Vector3< T >, and kn::Vector4< T >.
Definition at line 375 of file Vector.hpp.
void kn::Vector< T >::swap | ( | const unsigned int & | index1, | |
const unsigned int & | index2 | |||
) | [inline] |
Swaps two elements of this vector.
index1 | 1st element | |
index2 | 2nd element |
MathException | index1 or index2 are out of bounds |
Definition at line 809 of file Vector.hpp.
T* kn::Vector< T >::begin_ [protected] |
T* kn::Vector< T >::data [protected] |
T* kn::Vector< T >::end_ [protected] |
size_t kn::Vector< T >::sizeVector [protected] |