Vector
-
template<class T>
class zhetapi::Vector : public zhetapi::Matrix<T> Represents a vector whose components are of type T.
- tparam T
the type of each component.
Public Functions
-
Vector()
Default vector constructor.
-
Vector(const Vector&)
Copy constructor.
- Parameters
other – the reference vector (to be copied from).
-
Vector(size_t)
Size constructor. Components are initialized to 0 or the default value of T.
- Parameters
len – size of the vector.
-
Vector(size_t, T)
Size constructor. Each component is initialized to def.
- Parameters
rs – the number of rows (size) of the vector.
def – the value each component is initialized to.
-
template<class A>
explicit Vector(const Vector<A>&) Heterogenous copy constructor.
- Parameters
other – the reference vector (to be copied from).
-
inline size_t get_cols() const
Safety getter function.
TODO: eliminate this somehow
- inline __cuda_dual__ T & get (size_t)
Indexing function.
- Parameters
i – the specified index.
- Returns
the \(i\)th component of the vector.
- inline __cuda_dual__ const T & get (size_t) const
Indexing function.
- Parameters
i – the specified index.
- Returns
the \(i\)th component of the vector.
- inline __cuda_dual__ T & operator[] (size_t)
Indexing operator.
- Parameters
i – the specified index.
- Returns
the \(i\)th component of the vector.
- inline __cuda_dual__ const T & operator[] (size_t) const
Indexing operator.
- Parameters
i – the specified index.
- Returns
the \(i\)th component of the vector.
-
T arg() const
Returns the argument of the vector. Assumes that the vector has at least two components.
- Returns
the argument of the vector in radians (the angle at which the vector is pointing to).
-
size_t imin() const
The index of the smallest component: essentially argmin.
- Returns
the index of the smallest component.
-
size_t imax() const
The index of the largest component: essentially argmax.
- Returns
the index of the largest component.
-
void normalize()
Normalizes the components of the vector (the modified vector will have unit length).
-
Vector normalized() const
Returns a vector with normalized components (length of 1). The direction is preserved, as with normalization.
- Returns
The normalized vector.
-
void operator+=(const Vector&)
Add and assignment operator.
TODO: Needs to return itself
- Parameters
the – vector that will be added to this.
-
void operator-=(const Vector&)
Subtract and assignment operator.
TODO: Needs to return itself
- Parameters
the – vector that will be subtracted from this.
-
template<class T>
Vector(const std::vector<T> &ref) Constructs a vector out of a list of components.
- Parameters
ref – the list of components.
-
template<class T>
Vector(const std::initializer_list<T> &ref) Constructs a vector out of a list of components.
- Parameters
ref – the list of components.
-
class index_out_of_bounds