ML Reference
|
Template class for vector arithmetic with floating point data types. More...
#include <mlFloatingPointVector.h>
Public Types | |
enum | { Size = size } |
This enum grants access to the size during compile time, e.g. More... | |
typedef T | ComponentType |
A typedef to "export" the type of components. | |
Public Member Functions | |
Constructors and assignment operators. | |
FloatingPointVector (T value=T(0)) | |
Default and value constructor. | |
FloatingPointVector< T, size, DataContainer > & | operator= (T value) |
Assignment of scalar value to all components. | |
Comparison. | |
bool | operator== (const FloatingPointVector< T, size, DataContainer > &buffer) const |
Returns whether *this and buffer are component wise equal. | |
bool | operator!= (const FloatingPointVector< T, size, DataContainer > &buffer) const |
Returns whether any components of *this and buffer are not equal. | |
bool | operator< (const FloatingPointVector< T, size, DataContainer > &buffer) const |
Defines an artificial order for use in sort algorithms (lexicographical order). | |
Value access and indexing operators. | |
const T & | operator[] (const size_t i) const |
Constant indexing operators. | |
T & | operator[] (const size_t i) |
Indexing operators. | |
Other operations. | |
size_t | getSize () const |
Returns the number of elements of value buffer. | |
T | norm2 () const |
Returns the Euclidean norm (the vector length), i.e., square root of sum of squares of all components. | |
T | norm2 (const FloatingPointVector< T, size, DataContainer > &weight) const |
Returns the weighted Euclidean norm, i.e., square root of sum of squares of all components multiplied with corresponding squared component of weight. | |
T | dot (const FloatingPointVector< T, size, DataContainer > &buffer) const |
Returns the dot product, i.e., sum of all components multiplied with corresponding components of buffer. | |
T | normalize () |
Normalizes the buffer and returns the Euclidean length of vector before normalization, i.e., norm2. | |
T | length () const |
Returns the length of the vector, i.e. norm2(). | |
T | distance (const FloatingPointVector< T, size, DataContainer > &buffer) const |
Returns the distance of this vector to a given one. | |
T | distanceSquared (const FloatingPointVector< T, size, DataContainer > &buffer) const |
Returns the squared distance of this vector to a given one. | |
T | lengthSquared () const |
Returns the squared length of the vector. | |
T | compSum () const |
Returns the sum of all components. | |
T | compMul () const |
Returns the product of all vector components. | |
T | compMaxAbs () const |
Returns the maximum of absolute component values. | |
void | compMin (FloatingPointVector< T, size, DataContainer > buffer) |
Sets the component wise minimum of *this and buffer in *this. | |
void | compMax (FloatingPointVector< T, size, DataContainer > buffer) |
Sets the component wise maximum of *this and buffer in *this. | |
void | compAbs () |
Kills negative signs from all components. | |
void | compDiv (const FloatingPointVector< T, size, DataContainer > &d) |
Divides each vector component by the corresponding one of d. | |
void | compSqr () |
Calculates and sets the square of all components. | |
void | compSqrt () |
Calculates and sets square root of all components. | |
void | clampMin (const FloatingPointVector< T, size, DataContainer > &lower) |
Calculates and sets all components clamped to lower, i.e., if any component is smaller than the corresponding one in lower then it is set to the one from lower. | |
void | clampMax (const FloatingPointVector< T, size, DataContainer > &upper) |
Calculates and sets all components clamped to upper, i.e., if any component is greater than the corresponding one in upper then it is set to the one from upper. | |
void | clamp (const FloatingPointVector< T, size, DataContainer > &lower, const FloatingPointVector< T, size, DataContainer > &upper) |
Calculates and sets all components of *this so that they are between minimum min and maximum max. | |
void | compRound () |
Rounds all components of this vector using floor(component + 0.5). | |
void | compFloor () |
Rounds all components of this vector using floor(component). | |
void | compCeil () |
Rounds all components of this vector to integer using ceil(component). | |
FloatingPointVector< T, 3, DataContainer > | cross (const FloatingPointVector< T, 3, DataContainer > &b) const |
Returns the cross product for elements, i.e., return vector vertical to *this and b. | |
void | apply (ML_LA_FROM_DOUBLE_TO_DOUBLE f) |
Applies the function f to each component starting from index 0 to index size-1. | |
std::ostream & | writeOut (std::ostream &os) const |
Writes all components to ostream os starting from index 0 to size-1. | |
std::istream & | readIn (std::istream &is) |
Reads all components from istream is starting starting from index 0 to size-1. | |
Related Symbols | |
(Note that these are not member symbols.) | |
Standalone functions for FloatingPointVector. | |
template<class T , size_t size, class DataContainer > | |
FloatingPointVector< T, size, DataContainer > & | operator+= (FloatingPointVector< T, size, DataContainer > &op1, const FloatingPointVector< T, size, DataContainer > &buffer) |
Arithmetic assignment: Component wise addition. | |
template<class T , size_t size, class DataContainer > | |
FloatingPointVector< T, size, DataContainer > & | operator-= (FloatingPointVector< T, size, DataContainer > &op1, const FloatingPointVector< T, size, DataContainer > &buffer) |
Arithmetic assignment: Component wise subtraction of buffer from *this. | |
template<class T , size_t size, class DataContainer > | |
FloatingPointVector< T, size, DataContainer > & | operator*= (FloatingPointVector< T, size, DataContainer > &op1, MLdouble value) |
Arithmetic assignment: Component wise multiplication *this with specialized MLdouble scalar value. | |
template<class T , size_t size, class DataContainer > | |
FloatingPointVector< T, size, DataContainer > & | operator*= (FloatingPointVector< T, size, DataContainer > &op1, const FloatingPointVector< T, size, DataContainer > &op2) |
Arithmetic assignment: Component wise multiplication *this with a vector of the same size. | |
template<class T , size_t size, class DataContainer > | |
FloatingPointVector< T, size, DataContainer > & | operator/= (FloatingPointVector< T, size, DataContainer > &op1, MLdouble value) |
Arithmetic assignment: Component wise division of *this by scalar value. | |
template<class T , size_t size, class DataContainer > | |
FloatingPointVector< T, size, DataContainer > & | operator/= (FloatingPointVector< T, size, DataContainer > &op1, const FloatingPointVector< T, size, DataContainer > &op2) |
Arithmetic assignment: Component wise division of *this by the values of a vector of the same size. | |
template<class T , size_t size, class DataContainer > | |
bool | operator! (const FloatingPointVector< T, size, DataContainer > &a) |
Returns whether all components are 0. | |
template<class T , size_t size, class DataContainer > | |
FloatingPointVector< T, size, DataContainer > | operator+ (FloatingPointVector< T, size, DataContainer > lhs, const FloatingPointVector< T, size, DataContainer > &rhs) |
Return value is the component wise addition of lhs and rhs. | |
template<class T , size_t size, class DataContainer > | |
FloatingPointVector< T, size, DataContainer > | operator- (FloatingPointVector< T, size, DataContainer > lhs, const FloatingPointVector< T, size, DataContainer > &rhs) |
Return value is the component wise subtraction of rhs from lhs. | |
template<class T , size_t size, class DataContainer > | |
FloatingPointVector< T, size, DataContainer > | operator+ (const FloatingPointVector< T, size, DataContainer > &buffer) |
Unary plus, for completeness and for those who really want to use that... | |
template<class T , size_t size, class DataContainer > | |
FloatingPointVector< T, size, DataContainer > | operator- (const FloatingPointVector< T, size, DataContainer > &buffer) |
Unary minus, all components of the vector are multiplied with -1. | |
template<class T , size_t size, class DataContainer > | |
T | operator* (const FloatingPointVector< T, size, DataContainer > &a, const FloatingPointVector< T, size, DataContainer > &b) |
Dot product, returns a.dot(b). | |
template<class T , size_t size, class DataContainer > | |
FloatingPointVector< T, size, DataContainer > | operator* (FloatingPointVector< T, size, DataContainer > lhs, MLdouble rhs) |
Component wise multiplication of lhs with rhs. | |
template<class T , size_t size, class DataContainer > | |
FloatingPointVector< T, size, DataContainer > | operator* (MLdouble lhs, FloatingPointVector< T, size, DataContainer > rhs) |
Component wise multiplication of rhs with lhs. | |
template<class T , size_t size, class DataContainer > | |
FloatingPointVector< T, size, DataContainer > | operator/ (FloatingPointVector< T, size, DataContainer > lhs, MLdouble rhs) |
Component wise division of lhs by specialized rhs of type MLdouble. | |
template<class T , size_t size, class DataContainer > | |
FloatingPointVector< T, size, DataContainer > | compMin (FloatingPointVector< T, size, DataContainer > buffer1, const FloatingPointVector< T, size, DataContainer > &buffer2) |
Component wise minimum of buffer1 and buffer2. | |
template<class T , size_t size, class DataContainer > | |
FloatingPointVector< T, size, DataContainer > | compMax (FloatingPointVector< T, size, DataContainer > buffer1, const FloatingPointVector< T, size, DataContainer > &buffer2) |
Component wise maximum of buffer1 and buffer2. | |
template<class T , size_t size, class DataContainer > | |
FloatingPointVector< T, size, DataContainer > | compAbs (FloatingPointVector< T, size, DataContainer > vec) |
Returns a vector with all components from vec without negative sign. | |
template<class T , size_t size, class DataContainer > | |
FloatingPointVector< T, size, DataContainer > | compSqr (FloatingPointVector< T, size, DataContainer > vec) |
Returns a vector with all components from vec squared. | |
template<class T , size_t size, class DataContainer > | |
FloatingPointVector< T, size, DataContainer > | compSqrt (FloatingPointVector< T, size, DataContainer > vec) |
Returns a vector with all components from vec square-rooted. | |
template<class T , size_t size, class DataContainer > | |
FloatingPointVector< T, size, DataContainer > | compDiv (FloatingPointVector< T, size, DataContainer > vec, const FloatingPointVector< T, size, DataContainer > &d) |
Component wise division of vec / d. | |
template<class T , size_t size, class DataContainer > | |
FloatingPointVector< T, size, DataContainer > | clampMin (FloatingPointVector< T, size, DataContainer > vec, const FloatingPointVector< T, size, DataContainer > &m) |
Returns a new vector with all components from vec clamped to minimum m. | |
template<class T , size_t size, class DataContainer > | |
FloatingPointVector< T, size, DataContainer > | clampMax (FloatingPointVector< T, size, DataContainer > vec, const FloatingPointVector< T, size, DataContainer > &m) |
Returns a new vector with all components from vec clamped to maximum m. | |
template<class T , size_t size, class DataContainer > | |
FloatingPointVector< T, size, DataContainer > | clamp (FloatingPointVector< T, size, DataContainer > vec, const FloatingPointVector< T, size, DataContainer > &lower, const FloatingPointVector< T, size, DataContainer > &upper) |
Returns a new vector with all components from vec clamped to range [lower, upper]. | |
template<class T , size_t size, class DataContainer > | |
T | compMul (const FloatingPointVector< T, size, DataContainer > &vec) |
Returns the product of all components. | |
Additional Inherited Members | |
Protected Attributes inherited from ml::FloatingPointVectorDataContainerBase< DT, size > | |
DT | _buffer [size] |
Template class for vector arithmetic with floating point data types.
Notes:
Definition at line 62 of file mlFloatingPointVector.h.
typedef T ml::FloatingPointVector< T, size, DataContainer >::ComponentType |
A typedef to "export" the type of components.
Definition at line 68 of file mlFloatingPointVector.h.
anonymous enum |
This enum grants access to the size during compile time, e.g.
it can be used as a template argument.
Enumerator | |
---|---|
Size |
Definition at line 72 of file mlFloatingPointVector.h.
|
inlineexplicit |
Default and value constructor.
Default is the initialization of all components with value whose default is 0.
Definition at line 586 of file mlFloatingPointVector.h.
|
inline |
Applies the function f to each component starting from index 0 to index size-1.
Definition at line 953 of file mlFloatingPointVector.h.
|
inline |
Calculates and sets all components of *this so that they are between minimum min and maximum max.
This is done by applying clampMin(lower) first and then clampMax(upper). Note that components can become smaller than lower if a component in upper is smaller than their corresponding one in in lower.
Definition at line 912 of file mlFloatingPointVector.h.
References ml::FloatingPointVector< T, size, DataContainer >::clampMax(), and ml::FloatingPointVector< T, size, DataContainer >::clampMin().
|
inline |
Calculates and sets all components clamped to upper, i.e., if any component is greater than the corresponding one in upper then it is set to the one from upper.
Definition at line 899 of file mlFloatingPointVector.h.
References ml::compMin().
Referenced by ml::FloatingPointVector< T, size, DataContainer >::clamp(), ml::FloatingPointVector< T, size, DataContainer >::clamp(), and ml::FloatingPointVector< T, size, DataContainer >::clampMax().
|
inline |
Calculates and sets all components clamped to lower, i.e., if any component is smaller than the corresponding one in lower then it is set to the one from lower.
Definition at line 889 of file mlFloatingPointVector.h.
References ml::compMax().
Referenced by ml::FloatingPointVector< T, size, DataContainer >::clamp(), ml::FloatingPointVector< T, size, DataContainer >::clamp(), and ml::FloatingPointVector< T, size, DataContainer >::clampMin().
|
inline |
Kills negative signs from all components.
Definition at line 844 of file mlFloatingPointVector.h.
References MLAbs().
Referenced by ml::FloatingPointVector< T, size, DataContainer >::compAbs().
|
inline |
Rounds all components of this vector to integer using ceil(component).
Definition at line 944 of file mlFloatingPointVector.h.
|
inline |
Divides each vector component by the corresponding one of d.
Divisions by zero are not handled; the caller must avoid them.
Definition at line 854 of file mlFloatingPointVector.h.
References ml::FloatingPointVectorDataContainerBase< DT, size >::_buffer.
Referenced by ml::FloatingPointVector< T, size, DataContainer >::compDiv().
|
inline |
Rounds all components of this vector using floor(component).
Definition at line 935 of file mlFloatingPointVector.h.
|
inline |
Sets the component wise maximum of *this and buffer in *this.
Definition at line 833 of file mlFloatingPointVector.h.
References ml::FloatingPointVectorDataContainerBase< DT, size >::_buffer.
Referenced by ml::FloatingPointVector< T, size, DataContainer >::compMax().
|
inline |
Returns the maximum of absolute component values.
Definition at line 809 of file mlFloatingPointVector.h.
References MLAbs().
|
inline |
Sets the component wise minimum of *this and buffer in *this.
Definition at line 822 of file mlFloatingPointVector.h.
References ml::FloatingPointVectorDataContainerBase< DT, size >::_buffer.
Referenced by ml::FloatingPointVector< T, size, DataContainer >::compMin().
|
inline |
Returns the product of all vector components.
Definition at line 798 of file mlFloatingPointVector.h.
Referenced by ml::FloatingPointVector< T, size, DataContainer >::compMul().
|
inline |
Rounds all components of this vector using floor(component + 0.5).
Definition at line 926 of file mlFloatingPointVector.h.
|
inline |
Calculates and sets the square of all components.
Definition at line 863 of file mlFloatingPointVector.h.
Referenced by ml::FloatingPointVector< T, size, DataContainer >::compSqr().
|
inline |
Calculates and sets square root of all components.
Negative values have to be avoided by caller.
Definition at line 873 of file mlFloatingPointVector.h.
Referenced by ml::FloatingPointVector< T, size, DataContainer >::compSqrt().
|
inline |
Returns the sum of all components.
Definition at line 787 of file mlFloatingPointVector.h.
|
inline |
Returns the cross product for elements, i.e., return vector vertical to *this and b.
Definition at line 220 of file mlFloatingPointVector.h.
References ml::FloatingPointVectorDataContainerBase< DT, size >::_buffer.
Referenced by ml::TQuaternion< DT >::mult().
|
inline |
Returns the distance of this vector to a given one.
Definition at line 151 of file mlFloatingPointVector.h.
|
inline |
Returns the squared distance of this vector to a given one.
Definition at line 157 of file mlFloatingPointVector.h.
|
inline |
Returns the dot product, i.e., sum of all components multiplied with corresponding components of buffer.
Definition at line 741 of file mlFloatingPointVector.h.
References ml::FloatingPointVectorDataContainerBase< DT, size >::_buffer.
Referenced by ml::TQuaternion< DT >::mult(), and ml::FloatingPointVector< T, size, DataContainer >::operator*().
|
inline |
Returns the number of elements of value buffer.
Definition at line 696 of file mlFloatingPointVector.h.
|
inline |
Returns the length of the vector, i.e. norm2().
Definition at line 769 of file mlFloatingPointVector.h.
Referenced by ml::TQuaternion< DT >::cos(), ml::TQuaternion< DT >::cosh(), ml::TQuaternion< DT >::sin(), and ml::TQuaternion< DT >::sinh().
|
inline |
Returns the squared length of the vector.
Definition at line 778 of file mlFloatingPointVector.h.
|
inline |
Returns the Euclidean norm (the vector length), i.e., square root of sum of squares of all components.
Definition at line 706 of file mlFloatingPointVector.h.
|
inline |
Returns the weighted Euclidean norm, i.e., square root of sum of squares of all components multiplied with corresponding squared component of weight.
Definition at line 722 of file mlFloatingPointVector.h.
References ml::FloatingPointVectorDataContainerBase< DT, size >::_buffer.
|
inline |
Normalizes the buffer and returns the Euclidean length of vector before normalization, i.e., norm2.
On zero vector length the vector is left unchanged.
Definition at line 753 of file mlFloatingPointVector.h.
References MLValueIs0WOM().
Referenced by ml::Tmat4< DT >::getRotationMatrix(), and ml::rotation3D().
|
inline |
Returns whether any components of *this and buffer are not equal.
Definition at line 624 of file mlFloatingPointVector.h.
References ml::FloatingPointVectorDataContainerBase< DT, size >::_buffer, and MLValuesDifferWOM().
|
inline |
Defines an artificial order for use in sort algorithms (lexicographical order).
Starting from the first component(i.e. index 0) all components from *this are compared with the corresponding one in buffer: If the components of *this is smaller than the corresponding one in buffer then true is returned, if the comparison is bigger then false is returned and on equality the components for the next index are compared. If all components are equal then false is returned.
Definition at line 645 of file mlFloatingPointVector.h.
References ml::FloatingPointVectorDataContainerBase< DT, size >::_buffer, and MLValuesDifferWOM().
|
inline |
Assignment of scalar value to all components.
Definition at line 595 of file mlFloatingPointVector.h.
|
inline |
Returns whether *this and buffer are component wise equal.
Definition at line 609 of file mlFloatingPointVector.h.
References ml::FloatingPointVectorDataContainerBase< DT, size >::_buffer, and MLValuesDifferWOM().
|
inline |
Indexing operators.
The caller must guarantee that is in [0, size-1]. It is legal to consider all elements as a subsequent array in memory for pointer addressing of all elements.
Definition at line 677 of file mlFloatingPointVector.h.
|
inline |
Constant indexing operators.
The caller must guarantee that is in [0, size-1]. It is legal to consider all elements as a subsequent array in memory for pointer addressing of all elements.
Definition at line 666 of file mlFloatingPointVector.h.
|
inline |
Reads all components from istream is starting starting from index 0 to size-1.
Definition at line 973 of file mlFloatingPointVector.h.
References ml::is().
|
inline |
Writes all components to ostream os starting from index 0 to size-1.
Each buffer elements is followed separated by a space symbols " ".
Definition at line 963 of file mlFloatingPointVector.h.
|
related |
Returns a new vector with all components from vec clamped to range [lower, upper].
Not that this does not hold if components in lower are greater than their corresponding ones in upper. See FloatingPointVector<T, size, DataContainer>::clamp().
Definition at line 523 of file mlFloatingPointVector.h.
References ml::FloatingPointVector< T, size, DataContainer >::clampMax(), and ml::FloatingPointVector< T, size, DataContainer >::clampMin().
|
related |
Returns a new vector with all components from vec clamped to maximum m.
See FloatingPointVector<T, size, DataContainer>::clampMax().
Definition at line 508 of file mlFloatingPointVector.h.
References ml::FloatingPointVector< T, size, DataContainer >::clampMax().
|
related |
Returns a new vector with all components from vec clamped to minimum m.
See FloatingPointVector<T, size, DataContainer>::clampMin().
Definition at line 495 of file mlFloatingPointVector.h.
References ml::FloatingPointVector< T, size, DataContainer >::clampMin().
|
related |
Returns a vector with all components from vec without negative sign.
Definition at line 447 of file mlFloatingPointVector.h.
References ml::FloatingPointVector< T, size, DataContainer >::compAbs().
|
related |
Component wise division of vec / d.
Division by zeros are not handled and must be avoided by caller.
Definition at line 482 of file mlFloatingPointVector.h.
References ml::FloatingPointVector< T, size, DataContainer >::compDiv().
|
related |
Component wise maximum of buffer1 and buffer2.
Definition at line 435 of file mlFloatingPointVector.h.
References ml::FloatingPointVector< T, size, DataContainer >::compMax().
|
related |
Component wise minimum of buffer1 and buffer2.
Definition at line 423 of file mlFloatingPointVector.h.
References ml::FloatingPointVector< T, size, DataContainer >::compMin().
|
related |
Returns the product of all components.
Definition at line 537 of file mlFloatingPointVector.h.
References ml::FloatingPointVector< T, size, DataContainer >::compMul().
|
related |
Returns a vector with all components from vec squared.
Definition at line 458 of file mlFloatingPointVector.h.
References ml::FloatingPointVector< T, size, DataContainer >::compSqr().
|
related |
Returns a vector with all components from vec square-rooted.
Definition at line 470 of file mlFloatingPointVector.h.
References ml::FloatingPointVector< T, size, DataContainer >::compSqrt().
|
related |
Returns whether all components are 0.
Definition at line 326 of file mlFloatingPointVector.h.
|
related |
Dot product, returns a.dot(b).
Definition at line 383 of file mlFloatingPointVector.h.
References ml::FloatingPointVector< T, size, DataContainer >::dot().
|
related |
Component wise multiplication of lhs with rhs.
Definition at line 393 of file mlFloatingPointVector.h.
|
related |
Component wise multiplication of rhs with lhs.
Definition at line 403 of file mlFloatingPointVector.h.
|
related |
Arithmetic assignment: Component wise multiplication *this with a vector of the same size.
Definition at line 285 of file mlFloatingPointVector.h.
|
related |
Arithmetic assignment: Component wise multiplication *this with specialized MLdouble scalar value.
Definition at line 274 of file mlFloatingPointVector.h.
|
related |
Unary plus, for completeness and for those who really want to use that...
Definition at line 360 of file mlFloatingPointVector.h.
|
related |
Return value is the component wise addition of lhs and rhs.
Definition at line 338 of file mlFloatingPointVector.h.
|
related |
Arithmetic assignment: Component wise addition.
Definition at line 252 of file mlFloatingPointVector.h.
|
related |
Unary minus, all components of the vector are multiplied with -1.
Definition at line 371 of file mlFloatingPointVector.h.
|
related |
Return value is the component wise subtraction of rhs from lhs.
Definition at line 349 of file mlFloatingPointVector.h.
|
related |
Arithmetic assignment: Component wise subtraction of buffer from *this.
Definition at line 263 of file mlFloatingPointVector.h.
|
related |
Component wise division of lhs by specialized rhs of type MLdouble.
Definition at line 413 of file mlFloatingPointVector.h.
|
related |
Arithmetic assignment: Component wise division of *this by the values of a vector of the same size.
Division by zero is not handled and must be avoided by user.
Definition at line 312 of file mlFloatingPointVector.h.
|
related |
Arithmetic assignment: Component wise division of *this by scalar value.
Division by zero is not handled and must be avoided by user.
Definition at line 297 of file mlFloatingPointVector.h.