MVE - Multi-View Environment mve-devel
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Attributes | Protected Attributes | List of all members
math::Vector< T, N > Class Template Reference

Vector class for arbitrary dimensions and types. More...

#include <vector.h>

Public Types

typedef T ValueType
 

Public Member Functions

template<typename O >
 Vector (O const *values)
 Ctor taking a pointer from different type to initialize values.
 
 Vector (T const &v1, T const &v2)
 Ctor that initializes the first two elements.
 
 Vector (T const &v1, T const &v2, T const &v3)
 Ctor that initializes the first three elements.
 
 Vector (T const &v1, T const &v2, T const &v3, T const &v4)
 Ctor that initializes the first four elements.
 
 Vector (T const &value)
 Ctor that initializes ALL elements.
 
 Vector (T const *values)
 Ctor taking a pointer to initialize values.
 
template<typename O >
 Vector (Vector< O, N > const &other)
 Copy ctor from vector of different type.
 
 Vector (Vector< T, N > const &other)
 Copy ctor from vector of same type.
 
 Vector (Vector< T, N-1 > const &other, T const &v1)
 Ctor that takes a smaller vector and one element.
 
 Vector (void)
 Default ctor.
 
abs_sum (void) const
 Returns the sum of the absolute values of all elements.
 
Vector< T, N > & abs_value (void)
 Component-wise absolute-value on self, returns self.
 
Vector< T, N > abs_valued (void) const
 Returns a component-wise absolute-value copy of self.
 
template<typename F >
Vector< T, N > applied_for_each (F functor) const
 Applies a for-each functor to a copy of the vector.
 
template<typename F >
Vector< T, N > & apply_for_each (F functor)
 Applies a for-each functor to all values.
 
T * begin (void)
 
T const * begin (void) const
 
Vector< T, N > & copy (T const *values, int num=N)
 Copies values from the given pointer.
 
Vector< T, N > cross (Vector< T, N > const &other) const
 Cross product between this and another vector.
 
Vector< T, N > cw_div (Vector< T, N > const &other) const
 Component-wise division with another vector.
 
Vector< T, N > cw_mult (Vector< T, N > const &other) const
 Component-wise multiplication with another vector.
 
dot (Vector< T, N > const &other) const
 Dot (or scalar) product between self and another vector.
 
T * end (void)
 
T const * end (void) const
 
Vector< T, N > & fill (T const &value)
 Fills all vector elements with the given value.
 
bool is_similar (Vector< T, N > const &other, T const &epsilon) const
 Component-wise similarity using epsilon checks.
 
maximum (void) const
 Returns the largest element in the vector.
 
minimum (void) const
 Returns the smallest element in the vector.
 
Vector< T, N > & negate (void)
 Component-wise negation on self, returns self.
 
Vector< T, N > negated (void) const
 Returns a component-wise negation on copy of self.
 
norm (void) const
 Computes the norm (length) of the vector.
 
Vector< T, N > & normalize (void)
 Normalizes self and returns reference to self.
 
Vector< T, N > normalized (void) const
 Returns a normalized copy of self.
 
bool operator!= (Vector< T, N > const &rhs) const
 Comparison operator.
 
T & operator() (int index)
 Element access operator.
 
T const & operator() (int index) const
 Const element access operator.
 
Vector< T, N > operator* (T const &rhs) const
 Component-wise multiplication with scalar.
 
T * operator* (void)
 Dereference operator to value array.
 
T const * operator* (void) const
 Const dereference operator to value array.
 
Vector< T, N > & operator*= (T const &rhs)
 Component-wise self-multiplication with scalar.
 
Vector< T, N > operator+ (T const &rhs) const
 Component-wise addition with scalar.
 
Vector< T, N > operator+ (Vector< T, N > const &rhs) const
 Addition with other vector.
 
Vector< T, N > & operator+= (T const &rhs)
 Component-wise self-addition with scalar.
 
Vector< T, N > & operator+= (Vector< T, N > const &rhs)
 Self-addition with other vector.
 
Vector< T, N > operator- (T const &rhs) const
 Component-wise substraction with scalar.
 
Vector< T, N > operator- (Vector< T, N > const &rhs) const
 Substraction with other vector.
 
Vector< T, N > operator- (void) const
 Component-wise negation.
 
Vector< T, N > & operator-= (T const &rhs)
 Component-wise self-substraction with scalar.
 
Vector< T, N > & operator-= (Vector< T, N > const &rhs)
 Self-substraction with other vector.
 
Vector< T, N > operator/ (T const &rhs) const
 Component-wise division by scalar.
 
Vector< T, N > & operator/= (T const &rhs)
 Component-wise self-division by scalar.
 
template<typename O >
Vector< T, N > & operator= (Vector< O, N > const &rhs)
 Assignment operator from different type.
 
Vector< T, N > & operator= (Vector< T, N > const &rhs)
 Assignment operator.
 
bool operator== (Vector< T, N > const &rhs) const
 Comparison operator.
 
T & operator[] (int index)
 Element access operator.
 
T const & operator[] (int index) const
 Const element access operator.
 
product (void) const
 Returns the product of all elements.
 
Vector< T, N > & sort_asc (void)
 Sorts the elements of the vector into ascending order.
 
Vector< T, N > & sort_desc (void)
 Sorts the elements of the vector into descending order.
 
Vector< T, N > sorted_asc (void) const
 Returns a sorted vector into ascending order.
 
Vector< T, N > sorted_desc (void) const
 Returns a sorted vector into descending order.
 
square_norm (void) const
 Computes the squared norm of the vector (much cheaper).
 
sum (void) const
 Returns the sum of all elements.
 

Static Public Attributes

static int constexpr dim = N
 

Protected Attributes

v [N]
 

Detailed Description

template<typename T, int N>
class math::Vector< T, N >

Vector class for arbitrary dimensions and types.

Definition at line 86 of file vector.h.

Member Typedef Documentation

◆ ValueType

template<typename T , int N>
typedef T math::Vector< T, N >::ValueType

Definition at line 89 of file vector.h.

Constructor & Destructor Documentation

◆ Vector() [1/10]

template<typename T , int N>
math::Vector< T, N >::Vector ( void  )
inline

Default ctor.

Definition at line 287 of file vector.h.

◆ Vector() [2/10]

template<typename T , int N>
math::Vector< T, N >::Vector ( T const *  values)
inlineexplicit

Ctor taking a pointer to initialize values.

Definition at line 293 of file vector.h.

◆ Vector() [3/10]

template<typename T , int N>
math::Vector< T, N >::Vector ( T const &  value)
inlineexplicit

Ctor that initializes ALL elements.

Definition at line 300 of file vector.h.

◆ Vector() [4/10]

template<typename T , int N>
math::Vector< T, N >::Vector ( T const &  v1,
T const &  v2 
)
inline

Ctor that initializes the first two elements.

Definition at line 307 of file vector.h.

◆ Vector() [5/10]

template<typename T , int N>
math::Vector< T, N >::Vector ( T const &  v1,
T const &  v2,
T const &  v3 
)
inline

Ctor that initializes the first three elements.

Definition at line 314 of file vector.h.

◆ Vector() [6/10]

template<typename T , int N>
math::Vector< T, N >::Vector ( T const &  v1,
T const &  v2,
T const &  v3,
T const &  v4 
)
inline

Ctor that initializes the first four elements.

Definition at line 321 of file vector.h.

◆ Vector() [7/10]

template<typename T , int N>
math::Vector< T, N >::Vector ( Vector< T, N-1 > const &  other,
T const &  v1 
)
inline

Ctor that takes a smaller vector and one element.

Definition at line 328 of file vector.h.

◆ Vector() [8/10]

template<typename T , int N>
math::Vector< T, N >::Vector ( Vector< T, N > const &  other)
inline

Copy ctor from vector of same type.

Definition at line 336 of file vector.h.

◆ Vector() [9/10]

template<typename T , int N>
template<typename O >
math::Vector< T, N >::Vector ( Vector< O, N > const &  other)
inline

Copy ctor from vector of different type.

Definition at line 344 of file vector.h.

◆ Vector() [10/10]

template<typename T , int N>
template<typename O >
math::Vector< T, N >::Vector ( O const *  values)
inlineexplicit

Ctor taking a pointer from different type to initialize values.

Definition at line 352 of file vector.h.

Member Function Documentation

◆ abs_sum()

template<typename T , int N>
T math::Vector< T, N >::abs_sum ( void  ) const
inline

Returns the sum of the absolute values of all elements.

Definition at line 418 of file vector.h.

◆ abs_value()

template<typename T , int N>
Vector< T, N > & math::Vector< T, N >::abs_value ( void  )
inline

Component-wise absolute-value on self, returns self.

Definition at line 463 of file vector.h.

◆ abs_valued()

template<typename T , int N>
Vector< T, N > math::Vector< T, N >::abs_valued ( void  ) const
inline

Returns a component-wise absolute-value copy of self.

Definition at line 471 of file vector.h.

◆ applied_for_each()

template<typename T , int N>
template<typename F >
Vector< T, N > math::Vector< T, N >::applied_for_each ( functor) const
inline

Applies a for-each functor to a copy of the vector.

Definition at line 533 of file vector.h.

◆ apply_for_each()

template<typename T , int N>
template<typename F >
Vector< T, N > & math::Vector< T, N >::apply_for_each ( functor)
inline

Applies a for-each functor to all values.

Definition at line 524 of file vector.h.

◆ begin() [1/2]

template<typename T , int N>
T * math::Vector< T, N >::begin ( void  )
inline

Definition at line 583 of file vector.h.

◆ begin() [2/2]

template<typename T , int N>
T const * math::Vector< T, N >::begin ( void  ) const
inline

Definition at line 590 of file vector.h.

◆ copy()

template<typename T , int N>
Vector< T, N > & math::Vector< T, N >::copy ( T const *  values,
int  num = N 
)
inline

Copies values from the given pointer.

Definition at line 389 of file vector.h.

◆ cross()

template<typename T , int N>
Vector< T, N > math::Vector< T, N >::cross ( Vector< T, N > const &  other) const
inline

Cross product between this and another vector.

Definition at line 549 of file vector.h.

◆ cw_div()

template<typename T , int N>
Vector< T, N > math::Vector< T, N >::cw_div ( Vector< T, N > const &  other) const
inline

Component-wise division with another vector.

Definition at line 565 of file vector.h.

◆ cw_mult()

template<typename T , int N>
Vector< T, N > math::Vector< T, N >::cw_mult ( Vector< T, N > const &  other) const
inline

Component-wise multiplication with another vector.

Definition at line 556 of file vector.h.

◆ dot()

template<typename T , int N>
T math::Vector< T, N >::dot ( Vector< T, N > const &  other) const
inline

Dot (or scalar) product between self and another vector.

Definition at line 542 of file vector.h.

◆ end() [1/2]

template<typename T , int N>
T * math::Vector< T, N >::end ( void  )
inline

Definition at line 597 of file vector.h.

◆ end() [2/2]

template<typename T , int N>
T const * math::Vector< T, N >::end ( void  ) const
inline

Definition at line 604 of file vector.h.

◆ fill()

template<typename T , int N>
Vector< T, N > & math::Vector< T, N >::fill ( T const &  value)
inline

Fills all vector elements with the given value.

Definition at line 381 of file vector.h.

◆ is_similar()

template<typename T , int N>
bool math::Vector< T, N >::is_similar ( Vector< T, N > const &  other,
T const &  epsilon 
) const
inline

Component-wise similarity using epsilon checks.

Definition at line 574 of file vector.h.

◆ maximum()

template<typename T , int N>
T math::Vector< T, N >::maximum ( void  ) const
inline

Returns the largest element in the vector.

Definition at line 404 of file vector.h.

◆ minimum()

template<typename T , int N>
T math::Vector< T, N >::minimum ( void  ) const
inline

Returns the smallest element in the vector.

Definition at line 397 of file vector.h.

◆ negate()

template<typename T , int N>
Vector< T, N > & math::Vector< T, N >::negate ( void  )
inline

Component-wise negation on self, returns self.

Definition at line 478 of file vector.h.

◆ negated()

template<typename T , int N>
Vector< T, N > math::Vector< T, N >::negated ( void  ) const
inline

Returns a component-wise negation on copy of self.

Definition at line 486 of file vector.h.

◆ norm()

template<typename T , int N>
T math::Vector< T, N >::norm ( void  ) const
inline

Computes the norm (length) of the vector.

Definition at line 434 of file vector.h.

◆ normalize()

template<typename T , int N>
Vector< T, N > & math::Vector< T, N >::normalize ( void  )
inline

Normalizes self and returns reference to self.

Definition at line 448 of file vector.h.

◆ normalized()

template<typename T , int N>
Vector< T, N > math::Vector< T, N >::normalized ( void  ) const
inline

Returns a normalized copy of self.

Definition at line 456 of file vector.h.

◆ operator!=()

template<typename T , int N>
bool math::Vector< T, N >::operator!= ( Vector< T, N > const &  rhs) const
inline

Comparison operator.

Definition at line 662 of file vector.h.

◆ operator()() [1/2]

template<typename T , int N>
T & math::Vector< T, N >::operator() ( int  index)
inline

Element access operator.

Definition at line 641 of file vector.h.

◆ operator()() [2/2]

template<typename T , int N>
T const & math::Vector< T, N >::operator() ( int  index) const
inline

Const element access operator.

Definition at line 648 of file vector.h.

◆ operator*() [1/3]

template<typename T , int N>
Vector< T, N > math::Vector< T, N >::operator* ( T const &  rhs) const
inline

Component-wise multiplication with scalar.

Definition at line 761 of file vector.h.

◆ operator*() [2/3]

template<typename T , int N>
T * math::Vector< T, N >::operator* ( void  )
inline

Dereference operator to value array.

Definition at line 613 of file vector.h.

◆ operator*() [3/3]

template<typename T , int N>
T const * math::Vector< T, N >::operator* ( void  ) const
inline

Const dereference operator to value array.

Definition at line 620 of file vector.h.

◆ operator*=()

template<typename T , int N>
Vector< T, N > & math::Vector< T, N >::operator*= ( T const &  rhs)
inline

Component-wise self-multiplication with scalar.

Definition at line 753 of file vector.h.

◆ operator+() [1/2]

template<typename T , int N>
Vector< T, N > math::Vector< T, N >::operator+ ( T const &  rhs) const
inline

Component-wise addition with scalar.

Definition at line 746 of file vector.h.

◆ operator+() [2/2]

template<typename T , int N>
Vector< T, N > math::Vector< T, N >::operator+ ( Vector< T, N > const &  rhs) const
inline

Addition with other vector.

Definition at line 716 of file vector.h.

◆ operator+=() [1/2]

template<typename T , int N>
Vector< T, N > & math::Vector< T, N >::operator+= ( T const &  rhs)
inline

Component-wise self-addition with scalar.

Definition at line 738 of file vector.h.

◆ operator+=() [2/2]

template<typename T , int N>
Vector< T, N > & math::Vector< T, N >::operator+= ( Vector< T, N > const &  rhs)
inline

Self-addition with other vector.

Definition at line 708 of file vector.h.

◆ operator-() [1/3]

template<typename T , int N>
Vector< T, N > math::Vector< T, N >::operator- ( T const &  rhs) const
inline

Component-wise substraction with scalar.

Definition at line 731 of file vector.h.

◆ operator-() [2/3]

template<typename T , int N>
Vector< T, N > math::Vector< T, N >::operator- ( Vector< T, N > const &  rhs) const
inline

Substraction with other vector.

Definition at line 701 of file vector.h.

◆ operator-() [3/3]

template<typename T , int N>
Vector< T, N > math::Vector< T, N >::operator- ( void  ) const
inline

Component-wise negation.

Definition at line 686 of file vector.h.

◆ operator-=() [1/2]

template<typename T , int N>
Vector< T, N > & math::Vector< T, N >::operator-= ( T const &  rhs)
inline

Component-wise self-substraction with scalar.

Definition at line 723 of file vector.h.

◆ operator-=() [2/2]

template<typename T , int N>
Vector< T, N > & math::Vector< T, N >::operator-= ( Vector< T, N > const &  rhs)
inline

Self-substraction with other vector.

Definition at line 693 of file vector.h.

◆ operator/()

template<typename T , int N>
Vector< T, N > math::Vector< T, N >::operator/ ( T const &  rhs) const
inline

Component-wise division by scalar.

Definition at line 776 of file vector.h.

◆ operator/=()

template<typename T , int N>
Vector< T, N > & math::Vector< T, N >::operator/= ( T const &  rhs)
inline

Component-wise self-division by scalar.

Definition at line 768 of file vector.h.

◆ operator=() [1/2]

template<typename T , int N>
template<typename O >
Vector< T, N > & math::Vector< T, N >::operator= ( Vector< O, N > const &  rhs)
inline

Assignment operator from different type.

Definition at line 678 of file vector.h.

◆ operator=() [2/2]

template<typename T , int N>
Vector< T, N > & math::Vector< T, N >::operator= ( Vector< T, N > const &  rhs)
inline

Assignment operator.

Definition at line 669 of file vector.h.

◆ operator==()

template<typename T , int N>
bool math::Vector< T, N >::operator== ( Vector< T, N > const &  rhs) const
inline

Comparison operator.

Definition at line 655 of file vector.h.

◆ operator[]() [1/2]

template<typename T , int N>
T & math::Vector< T, N >::operator[] ( int  index)
inline

Element access operator.

Definition at line 627 of file vector.h.

◆ operator[]() [2/2]

template<typename T , int N>
T const & math::Vector< T, N >::operator[] ( int  index) const
inline

Const element access operator.

Definition at line 634 of file vector.h.

◆ product()

template<typename T , int N>
T math::Vector< T, N >::product ( void  ) const
inline

Returns the product of all elements.

Definition at line 425 of file vector.h.

◆ sort_asc()

template<typename T , int N>
Vector< T, N > & math::Vector< T, N >::sort_asc ( void  )
inline

Sorts the elements of the vector into ascending order.

Definition at line 493 of file vector.h.

◆ sort_desc()

template<typename T , int N>
Vector< T, N > & math::Vector< T, N >::sort_desc ( void  )
inline

Sorts the elements of the vector into descending order.

Definition at line 501 of file vector.h.

◆ sorted_asc()

template<typename T , int N>
Vector< T, N > math::Vector< T, N >::sorted_asc ( void  ) const
inline

Returns a sorted vector into ascending order.

Definition at line 509 of file vector.h.

◆ sorted_desc()

template<typename T , int N>
Vector< T, N > math::Vector< T, N >::sorted_desc ( void  ) const
inline

Returns a sorted vector into descending order.

Definition at line 516 of file vector.h.

◆ square_norm()

template<typename T , int N>
T math::Vector< T, N >::square_norm ( void  ) const
inline

Computes the squared norm of the vector (much cheaper).

Definition at line 441 of file vector.h.

◆ sum()

template<typename T , int N>
T math::Vector< T, N >::sum ( void  ) const
inline

Returns the sum of all elements.

Definition at line 411 of file vector.h.

Member Data Documentation

◆ dim

template<typename T , int N>
int constexpr math::Vector< T, N >::dim = N
staticconstexpr

Definition at line 91 of file vector.h.

◆ v

template<typename T , int N>
T math::Vector< T, N >::v[N]
protected

Definition at line 268 of file vector.h.


The documentation for this class was generated from the following file: