#include <vectorbase.h>
Public Types | |
typedef T | ScalType |
Public Member Functions | |
T * | array () |
const T * | array () const |
void | cross (const Derived &other, Derived *res) const |
Derived | cross (const Derived &other) const |
T | dot (const Derived &other) const |
bool | hasDynamicSize () const |
bool | isApprox (const Derived &other, const T &precision=Util::epsilon< T >()) const |
bool | isNegligible (const Derived &other, const T &precision=Util::epsilon< T >()) const |
bool | isNegligible (const T &other, const T &precision=Util::epsilon< T >()) const |
bool | isZero (const T &precision=Util::epsilon< T >()) const |
Derived & | loadOrtho (const Derived &other) |
Derived & | loadRandom () |
Derived & | loadRandomUnit () |
Derived & | loadZero () |
Derived & | makeOrthoVector (Derived *res) const |
T | norm () const |
T | norm2 () const |
Derived & | normalize () |
Derived | normalized () |
bool | operator!= (const Derived &other) const |
T & | operator() (int i) |
const T & | operator() (int i) const |
Derived | operator* (const T &factor) const |
Derived & | operator*= (const T &factor) |
Derived | operator+ (const Derived &other) const |
Derived & | operator+= (const Derived &other) |
Derived | operator- () const |
Derived | operator- (const Derived &other) const |
Derived & | operator-= (const Derived &other) |
Derived | operator/ (const T &factor) const |
Derived & | operator/= (const T &factor) |
Derived & | operator= (const Derived &other) |
bool | operator== (const Derived &other) const |
T & | operator[] (int i) |
const T & | operator[] (int i) const |
Derived | ortho () const |
void | readArray (const T *src) |
void | replaceWithOpposite () |
void | resize (int newsize) |
int | size () const |
const T & | w () const |
T & | w () |
const T & | x () const |
T & | x () |
const T & | y () const |
T & | y () |
const T & | z () const |
T & | z () |
This class template is only internally used in Eigen. It provides the base that the Vector and VectorX class templates inherit.
Note that one template parameter is Derived: this is a C++ trick knows as Curiously Recursive Template Pattern. Here, it allows us to implement in VectorBase the code of both Vector and VectorX, which are very different (Vector stores the size of the vector as template argument, while VectorX stores it as member data, thus storing the array itself on the heap).
typedef T ScalType |
T* array | ( | ) | [inline] |
const T* array | ( | ) | const [inline] |
Returns the array of the vector, as constant.
void cross | ( | const Derived & | other, | |
Derived * | res | |||
) | const [inline] |
Sets *res to be the cross product of *this by other. *this and other must have size exactly 3.
In fixed-size, *res must also have size 3. In dynamic-size, *res gets resized to size 3 if necessary.
Derived cross | ( | const Derived & | other | ) | const [inline] |
Returns the cross product of *this by other. *this and other must have size exactly 3.
This method returns an object by value, which is inefficient. For better performance, use cross(const Derived &, Derived *) const
T dot | ( | const Derived & | other | ) | const [inline] |
Returns the dot product of *this by other.
*this and other must have the same size (the compiler will check that for fixed-size vectors, but not for dynamic-size vectors).
If T is std::complex, the dot product is hermitian, i.e. the coords of *this get complex-conjugated in the formula.
bool hasDynamicSize | ( | ) | const [inline] |
bool isApprox | ( | const Derived & | other, | |
const T & | precision = Util::epsilon<T>() | |||
) | const [inline] |
Returns true if *this and other are approximately equal.
The optional parameter precision allows to control the number of significant digits of precision. For instance, setting precision to 1e-5 results in a precision of 5 decimal digits.
This test is for nonzero vectors. If either of the two vectors being compared is zero, then it returns true if, and only if the other one is also zero -- which is not what one typically wants.
To compare a vector with the zero vector, i.e. to check whether a vector is approximately zero, use isZero() instead.
bool isNegligible | ( | const Derived & | other, | |
const T & | precision = Util::epsilon<T>() | |||
) | const [inline] |
Checks whether the vector *this is much smaller than other.
Equivalent to isNegligible( other.norm(), precision ).
bool isNegligible | ( | const T & | other, | |
const T & | precision = Util::epsilon<T>() | |||
) | const [inline] |
Returns true if all coeffs of *this are smaller (in absolute value) than other*precision. In other words, returns true if all coeffs are much smaller than other. For the meaning of precision, see isApprox().
bool isZero | ( | const T & | precision = Util::epsilon<T>() |
) | const [inline] |
Tests whether *this is approximately equal to the zero matrix.
Equivalent to isNegligible(1). In other words, returns true if all entries of *this are approximately zero, in the sense that they have absolute value smaller than epsilon.
Derived & loadOrtho | ( | const Derived & | other | ) | [inline] |
Loads into *this a unit vector that is orthogonal to other.
The size of other must be at least 2. *this gets resized to have the same size, if it has dynamic size.
If the size is exactly 2, then other points toward the left, other.x() = -y() and other.y() = x(). For dimensions at least 3, it is of course impossible to speak of "pointing toward the left".
Derived & loadRandom | ( | ) | [inline] |
Sets all coords to random values between -1.0 and 1.0. For complex numbers, both the real and imaginary parts can range from -1.0 to 1.0. The resulting vector can be zero (though that's not going to happen often!)
Derived& loadRandomUnit | ( | ) | [inline] |
Derived & loadZero | ( | ) | [inline] |
Derived& makeOrthoVector | ( | Derived * | res | ) | const [inline] |
Constructs a unit vector that is orthogonal to *this, and stores it into *res.
*res and *this must have the same size, and that size must be at least 2.
T norm | ( | ) | const [inline] |
Returns the norm of *this, obtained as the square root of norm2().
T norm2 | ( | ) | const [inline] |
Derived& normalize | ( | ) | [inline] |
Derived normalized | ( | ) | [inline] |
Returns a normalized copy of *this. In other words, returns (*this) / norm().
This method returns an object by value, which is inefficient.
bool operator!= | ( | const Derived & | other | ) | const [inline] |
Equivalent to !isApprox() with the default precision.
T& operator() | ( | int | i | ) | [inline] |
const T& operator() | ( | int | i | ) | const [inline] |
Derived operator* | ( | const T & | factor | ) | const [inline] |
Returns *this * factor (multiplication of each coord).
This method returns an object by value, which is inefficient.
Derived& operator*= | ( | const T & | factor | ) | [inline] |
Stores *this * factor into *this (multiplication of each coord).
Reimplemented in Vector< T, Size >, VectorX< T >, Vector< int, Size >, and VectorX< int >.
Derived operator+ | ( | const Derived & | other | ) | const [inline] |
Returns *this + other (coordinate-wise addition). The vectors *this and other must have the same size.
This method returns an object by value, which is inefficient.
Derived& operator+= | ( | const Derived & | other | ) | [inline] |
Stores *this + other into *this (coordinate-wise addition).
*this and other must have the same size.
Derived operator- | ( | void | ) | const [inline] |
Returns (-(*this)).
This method returns an object by value, which is inefficient.
Derived operator- | ( | const Derived & | other | ) | const [inline] |
Returns *this - other (coordinate-wise substraction). The vectors *this and other must have the same size.
This method returns an object by value, which is inefficient.
Derived& operator-= | ( | const Derived & | other | ) | [inline] |
Stores *this - other into *this (coordinate-wise substraction).
*this and other must have the same size.
Derived operator/ | ( | const T & | factor | ) | const [inline] |
Returns *this / factor (division of each coord).
This method returns an object by value, which is inefficient.
Derived& operator/= | ( | const T & | factor | ) | [inline] |
Stores *this / factor into *this (division of each coord).
Reimplemented in Vector< T, Size >, VectorX< T >, Vector< int, Size >, and VectorX< int >.
Derived& operator= | ( | const Derived & | other | ) | [inline] |
Copies other into *this.
*this gets resized if it didn't already have the same size as other.
bool operator== | ( | const Derived & | other | ) | const [inline] |
Equivalent to isApprox() with the default precision.
T& operator[] | ( | int | i | ) | [inline] |
const T& operator[] | ( | int | i | ) | const [inline] |
Derived ortho | ( | ) | const [inline] |
Returns a unit vector that is orthogonal to *this.
This method returns an object by value, which is inefficient. For better performance, use loadOrtho() instead.
void readArray | ( | const T * | src | ) | [inline] |
Reads the coords of *this from an array. The number of entries read from the array is equal to size().
void replaceWithOpposite | ( | ) | [inline] |
Replaces *this with (-(*this)).
void resize | ( | int | newsize | ) | [inline] |
Tries to resize the vector. That is only possible if the vector has dynamic size, i.e. is an object of class VectorX. Otherwise, nothing is done.
The vector coords are not kept, they are left with undefined values after resizing.
int size | ( | ) | const [inline] |
const T& w | ( | ) | const [inline] |
Returns a constant reference to the fourth coord of *this.
The size of *this must be at least 4.
T& w | ( | ) | [inline] |
Returns a reference to the fourth coord of *this.
The size of *this must be at least 4.
const T& x | ( | ) | const [inline] |
T& x | ( | ) | [inline] |
const T& y | ( | ) | const [inline] |
Returns a constant reference to the second coord of *this.
The size of *this must be at least 2.
T& y | ( | ) | [inline] |
Returns a reference to the second coord of *this.
The size of *this must be at least 2.
const T& z | ( | ) | const [inline] |
Returns a constant reference to the third coord of *this.
The size of *this must be at least 3.
T& z | ( | ) | [inline] |
Returns a reference to the third coord of *this.
The size of *this must be at least 3.