|
Jet
v1.3.3
|
Generic statically-sized N-D vector class. More...
#include <jet/vector.h>
Public Types | |
| typedef std::array< T, N > | ContainerType |
Public Member Functions | |
| Vector () | |
| Constructs a vector with zeros. More... | |
| template<typename... Params> | |
| Vector (Params... params) | |
| Constructs vector instance with parameters. More... | |
| void | set (const T &s) |
Sets all elements to s. More... | |
| template<typename U > | |
| Vector (const std::initializer_list< U > &lst) | |
| Constructs vector instance with initializer list. More... | |
| template<typename E > | |
| Vector (const VectorExpression< T, E > &other) | |
| Constructs vector with expression template. More... | |
| Vector (const Vector &other) | |
| Copy constructor. More... | |
| template<typename U > | |
| void | set (const std::initializer_list< U > &lst) |
| Set vector instance with initializer list. More... | |
| template<typename E > | |
| void | set (const VectorExpression< T, E > &other) |
| Sets vector with expression template. More... | |
| void | swap (Vector &other) |
Swaps the content of the vector with other vector. More... | |
| void | setZero () |
| Sets all elements to zero. More... | |
| void | normalize () |
| Normalizes this vector. More... | |
| constexpr size_t | size () const |
| Returns the size of the vector. More... | |
| T * | data () |
| Returns the raw pointer to the vector data. More... | |
| const T *const | data () const |
| Returns the const raw pointer to the vector data. More... | |
| ContainerType::iterator | begin () |
| Returns the begin iterator of the vector. More... | |
| ContainerType::const_iterator | begin () const |
| Returns the begin const iterator of the vector. More... | |
| ContainerType::iterator | end () |
| Returns the end iterator of the vector. More... | |
| ContainerType::const_iterator | end () const |
| Returns the end const iterator of the vector. More... | |
| ArrayAccessor1< T > | accessor () |
| Returns the array accessor. More... | |
| ConstArrayAccessor1< T > | constAccessor () const |
| Returns the const array accessor. More... | |
| T | at (size_t i) const |
Returns const reference to the i -th element of the vector. More... | |
| T & | at (size_t i) |
Returns reference to the i -th element of the vector. More... | |
| T | sum () const |
| Returns the sum of all the elements. More... | |
| T | avg () const |
| Returns the average of all the elements. More... | |
| T | min () const |
| Returns the minimum element. More... | |
| T | max () const |
| Returns the maximum element. More... | |
| T | absmin () const |
| Returns the absolute minimum element. More... | |
| T | absmax () const |
| Returns the absolute maximum element. More... | |
| size_t | dominantAxis () const |
| Returns the index of the dominant axis. More... | |
| size_t | subminantAxis () const |
| Returns the index of the subminant axis. More... | |
| VectorScalarDiv< T, Vector > | normalized () const |
| Returns normalized vector. More... | |
| T | length () const |
| Returns the length of the vector. More... | |
| T | lengthSquared () const |
| Returns the squared length of the vector. More... | |
| template<typename E > | |
| T | distanceTo (const E &other) const |
| Returns the distance to the other vector. More... | |
| template<typename E > | |
| T | distanceSquaredTo (const E &other) const |
| Returns the squared distance to the other vector. More... | |
| template<typename U > | |
| VectorTypeCast< U, Vector< T, N >, T > | castTo () const |
| Returns a vector with different value type. More... | |
| template<typename E > | |
| bool | isEqual (const E &other) const |
Returns true if other is the same as this vector. More... | |
| template<typename E > | |
| bool | isSimilar (const E &other, T epsilon=std::numeric_limits< T >::epsilon()) const |
Returns true if other is similar to this vector. More... | |
| template<typename E > | |
| VectorAdd< T, Vector, E > | add (const E &v) const |
| Computes this + v. More... | |
| VectorScalarAdd< T, Vector > | add (const T &s) const |
| Computes this + (s, s, ... , s). More... | |
| template<typename E > | |
| VectorSub< T, Vector, E > | sub (const E &v) const |
| Computes this - v. More... | |
| VectorScalarSub< T, Vector > | sub (const T &s) const |
| Computes this - (s, s, ... , s). More... | |
| template<typename E > | |
| VectorMul< T, Vector, E > | mul (const E &v) const |
| Computes this * v. More... | |
| VectorScalarMul< T, Vector > | mul (const T &s) const |
| Computes this * (s, s, ... , s). More... | |
| template<typename E > | |
| VectorDiv< T, Vector, E > | div (const E &v) const |
| Computes this / v. More... | |
| VectorScalarDiv< T, Vector > | div (const T &s) const |
| Computes this / (s, s, ... , s). More... | |
| template<typename E > | |
| T | dot (const E &v) const |
| Computes dot product. More... | |
| VectorScalarRSub< T, Vector > | rsub (const T &s) const |
| Computes (s, s, ... , s) - this. More... | |
| template<typename E > | |
| VectorSub< T, Vector, E > | rsub (const E &v) const |
| Computes v - this. More... | |
| VectorScalarRDiv< T, Vector > | rdiv (const T &s) const |
| Computes (s, s, ... , s) / this. More... | |
| template<typename E > | |
| VectorDiv< T, Vector, E > | rdiv (const E &v) const |
| Computes v / this. More... | |
| void | iadd (const T &s) |
| Computes this += (s, s, ... , s). More... | |
| template<typename E > | |
| void | iadd (const E &v) |
| Computes this += v. More... | |
| void | isub (const T &s) |
| Computes this -= (s, s, ... , s). More... | |
| template<typename E > | |
| void | isub (const E &v) |
| Computes this -= v. More... | |
| void | imul (const T &s) |
| Computes this *= (s, s, ... , s). More... | |
| template<typename E > | |
| void | imul (const E &v) |
| Computes this *= v. More... | |
| void | idiv (const T &s) |
| Computes this /= (s, s, ... , s). More... | |
| template<typename E > | |
| void | idiv (const E &v) |
| Computes this /= v. More... | |
| template<typename Callback > | |
| void | forEach (Callback func) const |
Iterates the vector and invoke given func for each element. More... | |
| template<typename Callback > | |
| void | forEachIndex (Callback func) const |
Iterates the vector and invoke given func for each index. More... | |
| const T & | operator[] (size_t i) const |
Returns the const reference to the i -th element. More... | |
| T & | operator[] (size_t) |
Returns the reference to the i -th element. More... | |
| template<typename U > | |
| Vector & | operator= (const std::initializer_list< U > &lst) |
| Set vector instance with initializer list. More... | |
| template<typename E > | |
| Vector & | operator= (const VectorExpression< T, E > &other) |
| Sets vector with expression template. More... | |
| Vector & | operator+= (const T &s) |
| Computes this += (s, s, ... , s) More... | |
| template<typename E > | |
| Vector & | operator+= (const E &v) |
| Computes this += v. More... | |
| Vector & | operator-= (const T &s) |
| Computes this -= (s, s, ... , s) More... | |
| template<typename E > | |
| Vector & | operator-= (const E &v) |
| Computes this -= v. More... | |
| Vector & | operator*= (const T &s) |
| Computes this *= (s, s, ... , s) More... | |
| template<typename E > | |
| Vector & | operator*= (const E &v) |
| Computes this *= v. More... | |
| Vector & | operator/= (const T &s) |
| Computes this /= (s, s, ... , s) More... | |
| template<typename E > | |
| Vector & | operator/= (const E &v) |
| Computes this /= v. More... | |
| template<typename E > | |
| bool | operator== (const E &v) const |
Returns true if other is the same as this vector. More... | |
| template<typename E > | |
| bool | operator!= (const E &v) const |
Returns true if other is the not same as this vector. More... | |
Public Member Functions inherited from jet::VectorExpression< T, Vector< T, N > > | |
| size_t | size () const |
| Size of the vector. More... | |
| const Vector< T, N > & | operator() () const |
| Returns actual implementation (the subclass). More... | |
Generic statically-sized N-D vector class.
This class defines N-D vector data where its size is determined statically at compile time.
| T | - Number type. |
| N | - Dimension. |
| typedef std::array<T, N> jet::Vector< T, N >::ContainerType |
| jet::Vector< T, N >::Vector | ( | ) |
Constructs a vector with zeros.
|
explicit |
Constructs vector instance with parameters.
| jet::Vector< T, N >::Vector | ( | const std::initializer_list< U > & | lst | ) |
Constructs vector instance with initializer list.
| jet::Vector< T, N >::Vector | ( | const VectorExpression< T, E > & | other | ) |
Constructs vector with expression template.
| jet::Vector< T, N >::Vector | ( | const Vector< T, N > & | other | ) |
Copy constructor.
| T jet::Vector< T, N >::absmax | ( | ) | const |
Returns the absolute maximum element.
| T jet::Vector< T, N >::absmin | ( | ) | const |
Returns the absolute minimum element.
| ArrayAccessor1<T> jet::Vector< T, N >::accessor | ( | ) |
Returns the array accessor.
| VectorAdd<T, Vector, E> jet::Vector< T, N >::add | ( | const E & | v | ) | const |
Computes this + v.
| VectorScalarAdd<T, Vector> jet::Vector< T, N >::add | ( | const T & | s | ) | const |
Computes this + (s, s, ... , s).
| T& jet::Vector< T, N >::at | ( | size_t | i | ) |
Returns reference to the i -th element of the vector.
| T jet::Vector< T, N >::at | ( | size_t | i | ) | const |
Returns const reference to the i -th element of the vector.
| T jet::Vector< T, N >::avg | ( | ) | const |
Returns the average of all the elements.
| ContainerType::iterator jet::Vector< T, N >::begin | ( | ) |
Returns the begin iterator of the vector.
| ContainerType::const_iterator jet::Vector< T, N >::begin | ( | ) | const |
Returns the begin const iterator of the vector.
| VectorTypeCast<U, Vector<T, N>, T> jet::Vector< T, N >::castTo | ( | ) | const |
Returns a vector with different value type.
| ConstArrayAccessor1<T> jet::Vector< T, N >::constAccessor | ( | ) | const |
Returns the const array accessor.
| T* jet::Vector< T, N >::data | ( | ) |
Returns the raw pointer to the vector data.
| const T* const jet::Vector< T, N >::data | ( | ) | const |
Returns the const raw pointer to the vector data.
| T jet::Vector< T, N >::distanceSquaredTo | ( | const E & | other | ) | const |
Returns the squared distance to the other vector.
| T jet::Vector< T, N >::distanceTo | ( | const E & | other | ) | const |
Returns the distance to the other vector.
| VectorDiv<T, Vector, E> jet::Vector< T, N >::div | ( | const E & | v | ) | const |
Computes this / v.
| VectorScalarDiv<T, Vector> jet::Vector< T, N >::div | ( | const T & | s | ) | const |
Computes this / (s, s, ... , s).
| size_t jet::Vector< T, N >::dominantAxis | ( | ) | const |
Returns the index of the dominant axis.
| T jet::Vector< T, N >::dot | ( | const E & | v | ) | const |
Computes dot product.
| ContainerType::iterator jet::Vector< T, N >::end | ( | ) |
Returns the end iterator of the vector.
| ContainerType::const_iterator jet::Vector< T, N >::end | ( | ) | const |
Returns the end const iterator of the vector.
| void jet::Vector< T, N >::forEach | ( | Callback | func | ) | const |
Iterates the vector and invoke given func for each element.
This function iterates the vector elements and invoke the callback function func. The callback function takes array's element as its input. The order of execution will be 0 to N-1 where N is the size of the vector. Below is the sample usage:
| void jet::Vector< T, N >::forEachIndex | ( | Callback | func | ) | const |
Iterates the vector and invoke given func for each index.
This function iterates the vector elements and invoke the callback function func. The callback function takes one parameter which is the index of the vector. The order of execution will be 0 to N-1 where N is the size of the array. Below is the sample usage:
Computes this += v.
| void jet::Vector< T, N >::iadd | ( | const T & | s | ) |
Computes this += (s, s, ... , s).
Computes this /= v.
| void jet::Vector< T, N >::idiv | ( | const T & | s | ) |
Computes this /= (s, s, ... , s).
Computes this *= v.
| void jet::Vector< T, N >::imul | ( | const T & | s | ) |
Computes this *= (s, s, ... , s).
| bool jet::Vector< T, N >::isEqual | ( | const E & | other | ) | const |
Returns true if other is the same as this vector.
| bool jet::Vector< T, N >::isSimilar | ( | const E & | other, |
| T | epsilon = std::numeric_limits< T >::epsilon() |
||
| ) | const |
Returns true if other is similar to this vector.
Computes this -= v.
| void jet::Vector< T, N >::isub | ( | const T & | s | ) |
Computes this -= (s, s, ... , s).
| T jet::Vector< T, N >::length | ( | ) | const |
Returns the length of the vector.
| T jet::Vector< T, N >::lengthSquared | ( | ) | const |
Returns the squared length of the vector.
| T jet::Vector< T, N >::max | ( | ) | const |
Returns the maximum element.
| T jet::Vector< T, N >::min | ( | ) | const |
Returns the minimum element.
| VectorMul<T, Vector, E> jet::Vector< T, N >::mul | ( | const E & | v | ) | const |
Computes this * v.
| VectorScalarMul<T, Vector> jet::Vector< T, N >::mul | ( | const T & | s | ) | const |
Computes this * (s, s, ... , s).
| void jet::Vector< T, N >::normalize | ( | ) |
Normalizes this vector.
| VectorScalarDiv<T, Vector> jet::Vector< T, N >::normalized | ( | ) | const |
Returns normalized vector.
| bool jet::Vector< T, N >::operator!= | ( | const E & | v | ) | const |
Returns true if other is the not same as this vector.
| Vector& jet::Vector< T, N >::operator*= | ( | const E & | v | ) |
Computes this *= v.
| Vector& jet::Vector< T, N >::operator*= | ( | const T & | s | ) |
Computes this *= (s, s, ... , s)
| Vector& jet::Vector< T, N >::operator+= | ( | const E & | v | ) |
Computes this += v.
| Vector& jet::Vector< T, N >::operator+= | ( | const T & | s | ) |
Computes this += (s, s, ... , s)
| Vector& jet::Vector< T, N >::operator-= | ( | const E & | v | ) |
Computes this -= v.
| Vector& jet::Vector< T, N >::operator-= | ( | const T & | s | ) |
Computes this -= (s, s, ... , s)
| Vector& jet::Vector< T, N >::operator/= | ( | const E & | v | ) |
Computes this /= v.
| Vector& jet::Vector< T, N >::operator/= | ( | const T & | s | ) |
Computes this /= (s, s, ... , s)
| Vector& jet::Vector< T, N >::operator= | ( | const std::initializer_list< U > & | lst | ) |
Set vector instance with initializer list.
| Vector& jet::Vector< T, N >::operator= | ( | const VectorExpression< T, E > & | other | ) |
Sets vector with expression template.
| bool jet::Vector< T, N >::operator== | ( | const E & | v | ) | const |
Returns true if other is the same as this vector.
| const T& jet::Vector< T, N >::operator[] | ( | size_t | i | ) | const |
Returns the const reference to the i -th element.
| T& jet::Vector< T, N >::operator[] | ( | size_t | ) |
Returns the reference to the i -th element.
| VectorDiv<T, Vector, E> jet::Vector< T, N >::rdiv | ( | const E & | v | ) | const |
Computes v / this.
| VectorScalarRDiv<T, Vector> jet::Vector< T, N >::rdiv | ( | const T & | s | ) | const |
Computes (s, s, ... , s) / this.
| VectorSub<T, Vector, E> jet::Vector< T, N >::rsub | ( | const E & | v | ) | const |
Computes v - this.
| VectorScalarRSub<T, Vector> jet::Vector< T, N >::rsub | ( | const T & | s | ) | const |
Computes (s, s, ... , s) - this.
| void jet::Vector< T, N >::set | ( | const std::initializer_list< U > & | lst | ) |
Set vector instance with initializer list.
| void jet::Vector< T, N >::set | ( | const T & | s | ) |
Sets all elements to s.
| void jet::Vector< T, N >::set | ( | const VectorExpression< T, E > & | other | ) |
Sets vector with expression template.
| void jet::Vector< T, N >::setZero | ( | ) |
Sets all elements to zero.
|
constexpr |
Returns the size of the vector.
| VectorSub<T, Vector, E> jet::Vector< T, N >::sub | ( | const E & | v | ) | const |
Computes this - v.
| VectorScalarSub<T, Vector> jet::Vector< T, N >::sub | ( | const T & | s | ) | const |
Computes this - (s, s, ... , s).
| size_t jet::Vector< T, N >::subminantAxis | ( | ) | const |
Returns the index of the subminant axis.
| T jet::Vector< T, N >::sum | ( | ) | const |
Returns the sum of all the elements.
| void jet::Vector< T, N >::swap | ( | Vector< T, N > & | other | ) |
Swaps the content of the vector with other vector.
1.8.18