Generic statically-sized N-D vector class. More...
#include <Core/Vector/Vector.h>
Public Types | |
using | ContainerType = std::array< T, N > |
Public Member Functions | |
Vector () | |
Constructs a vector with zeros. More... | |
template<typename... Params> | |
Vector (Params... params) | |
Constructs vector instance with parameters. More... | |
template<typename U > | |
Vector (const std::initializer_list< U > &list) | |
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... | |
void | Set (const T &s) |
Sets all elements to s . More... | |
template<typename U > | |
void | Set (const std::initializer_list< U > &list) |
Set vector instance with initializer list. More... | |
template<typename E > | |
void | Set (const VectorExpression< T, E > &other) |
Sets vector with expression template. More... | |
void | Set (const Vector &other) |
Set vector instance with other vector. 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 * | 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 | SubdominantAxis () const |
Returns the index of the subdominant 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 > &list) |
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... | |
template<typename E > | |
VectorAdd< T, Vector< T, N >, E > | Add (const E &v) const |
template<typename E > | |
VectorSub< T, Vector< T, N >, E > | Sub (const E &v) const |
template<typename E > | |
VectorMul< T, Vector< T, N >, E > | Mul (const E &v) const |
template<typename E > | |
VectorDiv< T, Vector< T, N >, E > | Div (const E &v) const |
template<typename E > | |
VectorSub< T, Vector< T, N >, E > | RSub (const E &v) const |
template<typename E > | |
VectorDiv< T, Vector< T, N >, E > | RDiv (const E &v) const |
template<typename U > | |
Vector< T, N > & | operator= (const std::initializer_list< U > &list) |
template<typename E > | |
Vector< T, N > & | operator= (const VectorExpression< T, E > &other) |
template<typename E > | |
Vector< T, N > & | operator+= (const E &v) |
template<typename E > | |
Vector< T, N > & | operator-= (const E &v) |
template<typename E > | |
Vector< T, N > & | operator*= (const E &v) |
template<typename E > | |
Vector< T, N > & | operator/= (const E &v) |
Public Member Functions inherited from CubbyFlow::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... | |
Detailed Description
template<typename T, size_t N>
class CubbyFlow::Vector< T, N >
Generic statically-sized N-D vector class.
This class defines N-D vector data where its size is determined statically at compile time.
- Template Parameters
-
T - Number type. N - Dimension.
Member Typedef Documentation
◆ ContainerType
using CubbyFlow::Vector< T, N >::ContainerType = std::array<T, N> |
Constructor & Destructor Documentation
◆ Vector() [1/5]
CubbyFlow::Vector< T, N >::Vector | ( | ) |
Constructs a vector with zeros.
◆ Vector() [2/5]
|
explicit |
Constructs vector instance with parameters.
◆ Vector() [3/5]
CubbyFlow::Vector< T, N >::Vector | ( | const std::initializer_list< U > & | list | ) |
Constructs vector instance with initializer list.
◆ Vector() [4/5]
CubbyFlow::Vector< T, N >::Vector | ( | const VectorExpression< T, E > & | other | ) |
Constructs vector with expression template.
◆ Vector() [5/5]
CubbyFlow::Vector< T, N >::Vector | ( | const Vector< T, N > & | other | ) |
Copy constructor.
Member Function Documentation
◆ AbsMax()
T CubbyFlow::Vector< T, N >::AbsMax | ( | ) | const |
Returns the absolute maximum element.
◆ AbsMin()
T CubbyFlow::Vector< T, N >::AbsMin | ( | ) | const |
Returns the absolute minimum element.
◆ Accessor()
ArrayAccessor1< T > CubbyFlow::Vector< T, N >::Accessor | ( | ) |
Returns the array accessor.
◆ Add() [1/3]
VectorAdd<T, Vector, E> CubbyFlow::Vector< T, N >::Add | ( | const E & | v | ) | const |
Computes this + v.
◆ Add() [2/3]
VectorScalarAdd< T, Vector< T, N > > CubbyFlow::Vector< T, N >::Add | ( | const T & | s | ) | const |
Computes this + (s, s, ... , s).
◆ Add() [3/3]
VectorAdd<T, Vector<T, N>, E> CubbyFlow::Vector< T, N >::Add | ( | const E & | v | ) | const |
◆ At() [1/2]
T CubbyFlow::Vector< T, N >::At | ( | size_t | i | ) | const |
Returns const reference to the i
-th element of the vector.
◆ At() [2/2]
T & CubbyFlow::Vector< T, N >::At | ( | size_t | i | ) |
Returns reference to the i
-th element of the vector.
◆ Avg()
T CubbyFlow::Vector< T, N >::Avg | ( | ) | const |
Returns the average of all the elements.
◆ begin() [1/2]
Vector< T, N >::ContainerType::iterator CubbyFlow::Vector< T, N >::begin | ( | ) |
Returns the begin iterator of the vector.
◆ begin() [2/2]
Vector< T, N >::ContainerType::const_iterator CubbyFlow::Vector< T, N >::begin | ( | ) | const |
Returns the begin const iterator of the vector.
◆ CastTo()
VectorTypeCast< U, Vector< T, N >, T > CubbyFlow::Vector< T, N >::CastTo | ( | ) | const |
Returns a vector with different value type.
◆ ConstAccessor()
ConstArrayAccessor1< T > CubbyFlow::Vector< T, N >::ConstAccessor | ( | ) | const |
Returns the const array accessor.
◆ data() [1/2]
T * CubbyFlow::Vector< T, N >::data | ( | ) |
Returns the raw pointer to the vector data.
◆ data() [2/2]
const T * CubbyFlow::Vector< T, N >::data | ( | ) | const |
Returns the const raw pointer to the vector data.
◆ DistanceSquaredTo()
T CubbyFlow::Vector< T, N >::DistanceSquaredTo | ( | const E & | other | ) | const |
Returns the squared distance to the other vector.
◆ DistanceTo()
T CubbyFlow::Vector< T, N >::DistanceTo | ( | const E & | other | ) | const |
Returns the distance to the other vector.
◆ Div() [1/3]
VectorDiv<T, Vector, E> CubbyFlow::Vector< T, N >::Div | ( | const E & | v | ) | const |
Computes this / v.
◆ Div() [2/3]
VectorScalarDiv< T, Vector< T, N > > CubbyFlow::Vector< T, N >::Div | ( | const T & | s | ) | const |
Computes this / (s, s, ... , s).
◆ Div() [3/3]
VectorDiv<T, Vector<T, N>, E> CubbyFlow::Vector< T, N >::Div | ( | const E & | v | ) | const |
◆ DominantAxis()
size_t CubbyFlow::Vector< T, N >::DominantAxis | ( | ) | const |
Returns the index of the dominant axis.
◆ Dot()
T CubbyFlow::Vector< T, N >::Dot | ( | const E & | v | ) | const |
Computes dot product.
◆ end() [1/2]
Vector< T, N >::ContainerType::iterator CubbyFlow::Vector< T, N >::end | ( | ) |
Returns the end iterator of the vector.
◆ end() [2/2]
Vector< T, N >::ContainerType::const_iterator CubbyFlow::Vector< T, N >::end | ( | ) | const |
Returns the end const iterator of the vector.
◆ ForEach()
void CubbyFlow::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:
◆ ForEachIndex()
void CubbyFlow::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:
◆ IAdd() [1/2]
void CubbyFlow::Vector< T, N >::IAdd | ( | const T & | s | ) |
Computes this += (s, s, ... , s).
◆ IAdd() [2/2]
void CubbyFlow::Vector< T, N >::IAdd | ( | const E & | v | ) |
Computes this += v.
◆ IDiv() [1/2]
void CubbyFlow::Vector< T, N >::IDiv | ( | const T & | s | ) |
Computes this /= (s, s, ... , s).
◆ IDiv() [2/2]
void CubbyFlow::Vector< T, N >::IDiv | ( | const E & | v | ) |
Computes this /= v.
◆ IMul() [1/2]
void CubbyFlow::Vector< T, N >::IMul | ( | const T & | s | ) |
Computes this *= (s, s, ... , s).
◆ IMul() [2/2]
void CubbyFlow::Vector< T, N >::IMul | ( | const E & | v | ) |
Computes this *= v.
◆ IsEqual()
bool CubbyFlow::Vector< T, N >::IsEqual | ( | const E & | other | ) | const |
Returns true if other
is the same as this vector.
◆ IsSimilar()
bool CubbyFlow::Vector< T, N >::IsSimilar | ( | const E & | other, |
T | epsilon = std::numeric_limits<T>::epsilon() |
||
) | const |
Returns true if other
is similar to this vector.
◆ ISub() [1/2]
void CubbyFlow::Vector< T, N >::ISub | ( | const T & | s | ) |
Computes this -= (s, s, ... , s).
◆ ISub() [2/2]
void CubbyFlow::Vector< T, N >::ISub | ( | const E & | v | ) |
Computes this -= v.
◆ Length()
T CubbyFlow::Vector< T, N >::Length | ( | ) | const |
Returns the length of the vector.
◆ LengthSquared()
T CubbyFlow::Vector< T, N >::LengthSquared | ( | ) | const |
Returns the squared length of the vector.
◆ Max()
T CubbyFlow::Vector< T, N >::Max | ( | ) | const |
Returns the maximum element.
◆ Min()
T CubbyFlow::Vector< T, N >::Min | ( | ) | const |
Returns the minimum element.
◆ Mul() [1/3]
VectorMul<T, Vector, E> CubbyFlow::Vector< T, N >::Mul | ( | const E & | v | ) | const |
Computes this * v.
◆ Mul() [2/3]
VectorScalarMul< T, Vector< T, N > > CubbyFlow::Vector< T, N >::Mul | ( | const T & | s | ) | const |
Computes this * (s, s, ... , s).
◆ Mul() [3/3]
VectorMul<T, Vector<T, N>, E> CubbyFlow::Vector< T, N >::Mul | ( | const E & | v | ) | const |
◆ Normalize()
void CubbyFlow::Vector< T, N >::Normalize | ( | ) |
Normalizes this vector.
◆ Normalized()
VectorScalarDiv< T, Vector< T, N > > CubbyFlow::Vector< T, N >::Normalized | ( | ) | const |
Returns normalized vector.
◆ operator!=()
bool CubbyFlow::Vector< T, N >::operator!= | ( | const E & | v | ) | const |
Returns true if other
is the not same as this vector.
◆ operator*=() [1/3]
Vector< T, N > & CubbyFlow::Vector< T, N >::operator*= | ( | const T & | s | ) |
Computes this *= (s, s, ... , s)
◆ operator*=() [2/3]
Vector& CubbyFlow::Vector< T, N >::operator*= | ( | const E & | v | ) |
Computes this *= v.
◆ operator*=() [3/3]
Vector<T, N>& CubbyFlow::Vector< T, N >::operator*= | ( | const E & | v | ) |
◆ operator+=() [1/3]
Vector< T, N > & CubbyFlow::Vector< T, N >::operator+= | ( | const T & | s | ) |
Computes this += (s, s, ... , s)
◆ operator+=() [2/3]
Vector& CubbyFlow::Vector< T, N >::operator+= | ( | const E & | v | ) |
Computes this += v.
◆ operator+=() [3/3]
Vector<T, N>& CubbyFlow::Vector< T, N >::operator+= | ( | const E & | v | ) |
◆ operator-=() [1/3]
Vector< T, N > & CubbyFlow::Vector< T, N >::operator-= | ( | const T & | s | ) |
Computes this -= (s, s, ... , s)
◆ operator-=() [2/3]
Vector& CubbyFlow::Vector< T, N >::operator-= | ( | const E & | v | ) |
Computes this -= v.
◆ operator-=() [3/3]
Vector<T, N>& CubbyFlow::Vector< T, N >::operator-= | ( | const E & | v | ) |
◆ operator/=() [1/3]
Vector< T, N > & CubbyFlow::Vector< T, N >::operator/= | ( | const T & | s | ) |
Computes this /= (s, s, ... , s)
◆ operator/=() [2/3]
Vector& CubbyFlow::Vector< T, N >::operator/= | ( | const E & | v | ) |
Computes this /= v.
◆ operator/=() [3/3]
Vector<T, N>& CubbyFlow::Vector< T, N >::operator/= | ( | const E & | v | ) |
◆ operator=() [1/4]
Vector& CubbyFlow::Vector< T, N >::operator= | ( | const std::initializer_list< U > & | list | ) |
Set vector instance with initializer list.
◆ operator=() [2/4]
Vector& CubbyFlow::Vector< T, N >::operator= | ( | const VectorExpression< T, E > & | other | ) |
Sets vector with expression template.
◆ operator=() [3/4]
Vector<T, N>& CubbyFlow::Vector< T, N >::operator= | ( | const std::initializer_list< U > & | list | ) |
◆ operator=() [4/4]
Vector<T, N>& CubbyFlow::Vector< T, N >::operator= | ( | const VectorExpression< T, E > & | other | ) |
◆ operator==()
bool CubbyFlow::Vector< T, N >::operator== | ( | const E & | v | ) | const |
Returns true if other
is the same as this vector.
◆ operator[]() [1/2]
const T & CubbyFlow::Vector< T, N >::operator[] | ( | size_t | i | ) | const |
Returns the const reference to the i
-th element.
◆ operator[]() [2/2]
T & CubbyFlow::Vector< T, N >::operator[] | ( | size_t | i | ) |
Returns the reference to the i
-th element.
◆ RDiv() [1/3]
VectorScalarRDiv< T, Vector< T, N > > CubbyFlow::Vector< T, N >::RDiv | ( | const T & | s | ) | const |
Computes (s, s, ... , s) / this.
◆ RDiv() [2/3]
VectorDiv<T, Vector, E> CubbyFlow::Vector< T, N >::RDiv | ( | const E & | v | ) | const |
Computes v / this.
◆ RDiv() [3/3]
VectorDiv<T, Vector<T, N>, E> CubbyFlow::Vector< T, N >::RDiv | ( | const E & | v | ) | const |
◆ RSub() [1/3]
VectorScalarRSub< T, Vector< T, N > > CubbyFlow::Vector< T, N >::RSub | ( | const T & | s | ) | const |
Computes (s, s, ... , s) - this.
◆ RSub() [2/3]
VectorSub<T, Vector, E> CubbyFlow::Vector< T, N >::RSub | ( | const E & | v | ) | const |
Computes v - this.
◆ RSub() [3/3]
VectorSub<T, Vector<T, N>, E> CubbyFlow::Vector< T, N >::RSub | ( | const E & | v | ) | const |
◆ Set() [1/4]
void CubbyFlow::Vector< T, N >::Set | ( | const T & | s | ) |
Sets all elements to s
.
◆ Set() [2/4]
void CubbyFlow::Vector< T, N >::Set | ( | const std::initializer_list< U > & | list | ) |
Set vector instance with initializer list.
◆ Set() [3/4]
void CubbyFlow::Vector< T, N >::Set | ( | const VectorExpression< T, E > & | other | ) |
Sets vector with expression template.
◆ Set() [4/4]
void CubbyFlow::Vector< T, N >::Set | ( | const Vector< T, N > & | other | ) |
Set vector instance with other vector.
◆ SetZero()
void CubbyFlow::Vector< T, N >::SetZero | ( | ) |
Sets all elements to zero.
◆ size()
constexpr size_t CubbyFlow::Vector< T, N >::size | ( | ) | const |
Returns the size of the vector.
◆ Sub() [1/3]
VectorSub<T, Vector, E> CubbyFlow::Vector< T, N >::Sub | ( | const E & | v | ) | const |
Computes this - v.
◆ Sub() [2/3]
VectorScalarSub< T, Vector< T, N > > CubbyFlow::Vector< T, N >::Sub | ( | const T & | s | ) | const |
Computes this - (s, s, ... , s).
◆ Sub() [3/3]
VectorSub<T, Vector<T, N>, E> CubbyFlow::Vector< T, N >::Sub | ( | const E & | v | ) | const |
◆ SubdominantAxis()
size_t CubbyFlow::Vector< T, N >::SubdominantAxis | ( | ) | const |
Returns the index of the subdominant axis.
◆ Sum()
T CubbyFlow::Vector< T, N >::Sum | ( | ) | const |
Returns the sum of all the elements.
◆ Swap()
void CubbyFlow::Vector< T, N >::Swap | ( | Vector< T, N > & | other | ) |
Swaps the content of the vector with other
vector.
The documentation for this class was generated from the following files:
- Core/Vector/Vector.h
- Core/Vector/Vector-Impl.h