trase
trase::Vector< T, N > Class Template Reference

An N-dimensional vector class. More...

#include <Vector.hpp>

Public Types

using value_type = T
 
using iter = typename std::array< T, N >::iterator
 
using const_iter = typename std::array< T, N >::const_iterator
 
using reverse_iter = typename std::array< T, N >::reverse_iterator
 
using const_reverse_iter = typename std::array< T, N >::const_reverse_iterator
 

Public Member Functions

 Vector ()=default
 Constructs an vector and allocates memory.
 
 Vector (T arg1)
 Constructs an vector with initial values. More...
 
 Vector (T arg1, T arg2)
 Constructs a vector with initial values. More...
 
 Vector (T arg1, T arg2, T arg3)
 Constructs an vector with initial values. More...
 
 Vector (T arg1, T arg2, T arg3, T arg4)
 Constructs an vector with initial values. More...
 
 Vector (T arg1, T arg2, T arg3, T arg4, T arg5)
 Constructs an vector with initial values. More...
 
template<typename T2 >
 Vector (const Vector< T2, N > &arg)
 Constructs a vector with another vector of different type. More...
 
iter begin () noexcept
 
const_iter begin () const noexcept
 
iter end () noexcept
 
const_iter end () const noexcept
 
reverse_iter rbegin () noexcept
 
const_reverse_iter rbegin () const noexcept
 
reverse_iter rend () noexcept
 
const_reverse_iter rend () const noexcept
 
const_iter cbegin () const noexcept
 
const_iter cend () const noexcept
 
const_reverse_iter crbegin () const noexcept
 
const_reverse_iter crend () const noexcept
 
const T & operator[] (const int n) const noexcept
 const Index operator More...
 
T & operator[] (const int n) noexcept
 Index operator. More...
 
inner_product (const Vector< T, N > &arg) const noexcept
 inner product More...
 
dot (const Vector< T, N > &arg) const noexcept
 dot product More...
 
template<typename T2 >
Vector< T2, N > cast () const noexcept
 change vector type More...
 
squaredNorm () const noexcept
 squared norm More...
 
double norm () const noexcept
 2-norm More...
 
inf_norm () const noexcept
 inf-norm More...
 
template<typename EXP_T >
Vector< T, N > pow (const EXP_T exponent) const noexcept
 element-wise pow function More...
 
void normalize () noexcept
 normalise vector so that its length (2-norm) equals one. More...
 
bool all () const noexcept
 collapse vector to bool using std::all_of More...
 
bool any () const noexcept
 collapse vector to bool using std::any_of More...
 
bool none () const noexcept
 collapse vector to bool using std::none_of More...
 
minCoeff () const noexcept
 find the minimum element of the vector More...
 
maxCoeff () const noexcept
 find the maximum element of the vector More...
 
prod () const noexcept
 returns the product of every element in the vector
 
sum () const noexcept
 returns the sum of every element in the vector
 
T * data () noexcept
 returns the raw memory array containing the data for the vector
 
const T * data () const noexcept
 
Vector< T, N > & operator+= (const Vector< T, N > &a)
 this-Vector compound plus operator
 
Vector< T, N > & operator-= (const Vector< T, N > &a)
 this-Vector compound minus operator
 
Vector< T, N > & operator*= (const Vector< T, N > &a)
 this-Vector compound multiples operator
 
Vector< T, N > & operator/= (const Vector< T, N > &a)
 this-Vector compound divides operator
 
Vector< T, N > & operator+= (const T &k)
 this-scalar compound plus operator
 
Vector< T, N > & operator-= (const T &k)
 this-scalar compound minus operator
 
Vector< T, N > & operator*= (const T &k)
 this-scalar compound multiples operator
 
Vector< T, N > & operator/= (const T &k)
 this-scalar compound divides operator
 

Static Public Member Functions

static Vector Zero ()
 Zero Vector. More...
 
static Vector Constant (const T &c)
 Constant Vector. More...
 

Static Public Attributes

static const int size = N
 

Detailed Description

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

An N-dimensional vector class.

Normal C++ operators ('*','/','<' etc.) operate on this vector class in an element-wise fashion.

Parameters
Tthe base type of each element of the vector
Nthe dimension of the vector (i.e. how many elements)

Constructor & Destructor Documentation

◆ Vector() [1/6]

template<typename T, int N>
trase::Vector< T, N >::Vector ( arg1)
inlineexplicit

Constructs an vector with initial values.

Parameters
arg1All the elements of the vector are set to this value

◆ Vector() [2/6]

template<typename T, int N>
trase::Vector< T, N >::Vector ( arg1,
arg2 
)
inline

Constructs a vector with initial values.

Parameters
arg1The first element is set to this value
arg2The second element is set to this value

◆ Vector() [3/6]

template<typename T, int N>
trase::Vector< T, N >::Vector ( arg1,
arg2,
arg3 
)
inline

Constructs an vector with initial values.

Parameters
arg1The first element is set to this value
arg2The second element is set to this value
arg3The third element is set to this value

◆ Vector() [4/6]

template<typename T, int N>
trase::Vector< T, N >::Vector ( arg1,
arg2,
arg3,
arg4 
)
inline

Constructs an vector with initial values.

Parameters
arg1The first element is set to this value
arg2The second element is set to this value
arg3The third element is set to this value
arg4The fourth element is set to this value

◆ Vector() [5/6]

template<typename T, int N>
trase::Vector< T, N >::Vector ( arg1,
arg2,
arg3,
arg4,
arg5 
)
inline

Constructs an vector with initial values.

Parameters
arg1The first element is set to this value
arg2The second element is set to this value
arg3The third element is set to this value
arg4The fourth element is set to this value
arg5The fourth element is set to this value

◆ Vector() [6/6]

template<typename T, int N>
template<typename T2 >
trase::Vector< T, N >::Vector ( const Vector< T2, N > &  arg)
inlineexplicit

Constructs a vector with another vector of different type.

The input vector must have same length as this one

Parameters
argThe vector to be copied

Member Function Documentation

◆ all()

template<typename T, int N>
bool trase::Vector< T, N >::all ( ) const
inlinenoexcept

collapse vector to bool using std::all_of

Returns
true if all elements cast to true

◆ any()

template<typename T, int N>
bool trase::Vector< T, N >::any ( ) const
inlinenoexcept

collapse vector to bool using std::any_of

Returns
true if any element casts to true

◆ cast()

template<typename T, int N>
template<typename T2 >
Vector<T2, N> trase::Vector< T, N >::cast ( ) const
inlinenoexcept

change vector type

Returns
A new vector with each element static_cast to T2

◆ Constant()

template<typename T, int N>
static Vector trase::Vector< T, N >::Constant ( const T &  c)
inlinestatic

Constant Vector.

Returns a constant vector

◆ dot()

template<typename T, int N>
T trase::Vector< T, N >::dot ( const Vector< T, N > &  arg) const
inlinenoexcept

dot product

Returns
The inner product (dot product) of this vector with arg
See also
inner_product

◆ inf_norm()

template<typename T, int N>
T trase::Vector< T, N >::inf_norm ( ) const
inlinenoexcept

inf-norm

Returns
the infinity norm of the vector $ |v_i|$

◆ inner_product()

template<typename T, int N>
T trase::Vector< T, N >::inner_product ( const Vector< T, N > &  arg) const
inlinenoexcept

inner product

Returns
the inner product (dot product) of this vector with arg

◆ maxCoeff()

template<typename T, int N>
T trase::Vector< T, N >::maxCoeff ( ) const
inlinenoexcept

find the maximum element of the vector

Returns
the maximum element of the vector

◆ minCoeff()

template<typename T, int N>
T trase::Vector< T, N >::minCoeff ( ) const
inlinenoexcept

find the minimum element of the vector

Returns
the value of the minimum element of the vector

◆ none()

template<typename T, int N>
bool trase::Vector< T, N >::none ( ) const
inlinenoexcept

collapse vector to bool using std::none_of

Returns
true if no element casts to true

◆ norm()

template<typename T, int N>
double trase::Vector< T, N >::norm ( ) const
inlinenoexcept

2-norm

Returns
the 2-norm of the vector ${ v_i^2}$

◆ normalize()

template<typename T, int N>
void trase::Vector< T, N >::normalize ( )
inlinenoexcept

normalise vector so that its length (2-norm) equals one.

See also
norm

◆ operator[]() [1/2]

template<typename T, int N>
const T& trase::Vector< T, N >::operator[] ( const int  n) const
inlinenoexcept

const Index operator

Returns a const reference to the n-th element of the vector

Parameters
nthe element number to index

◆ operator[]() [2/2]

template<typename T, int N>
T& trase::Vector< T, N >::operator[] ( const int  n)
inlinenoexcept

Index operator.

Returns a reference to the n-th element of the vector

Parameters
nthe element number to index

◆ pow()

template<typename T, int N>
template<typename EXP_T >
Vector<T, N> trase::Vector< T, N >::pow ( const EXP_T  exponent) const
inlinenoexcept

element-wise pow function

Returns
a new vector with each element taken to the power of exponent
Parameters
exponentthe exponent

◆ squaredNorm()

template<typename T, int N>
T trase::Vector< T, N >::squaredNorm ( ) const
inlinenoexcept

squared norm

Returns
the squared 2-norm of the vector $ v_i^2$

◆ Zero()

template<typename T, int N>
static Vector trase::Vector< T, N >::Zero ( )
inlinestatic

Zero Vector.

Returns a zero vector


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