|
| Vector () |
| No-argument constructor. More...
|
|
| Vector (const std::initializer_list< T > args) |
| Initializes a vector given initializer list. More...
|
|
| Vector (const Vector< D, T > &other) |
| Copy constructor. More...
|
|
| Vector (Vector< D, T > &&) noexcept=default |
| Move constructor. More...
|
|
Vector< D, T > & | operator= (const Vector< D, T > &other) |
| Assignment operator. More...
|
|
Vector< D, T > & | operator= (Vector< D, T > &&) noexcept=default |
| Move assignment operator. More...
|
|
virtual | ~Vector ()=default |
| Destructor. More...
|
|
virtual std::string | toString () const |
| Returns string form of vector. More...
|
|
Vector< D, T > | operator- () const |
| Negative of a vector. More...
|
|
Vector< D, T > | operator+ () const |
| Positive of a vector. More...
|
|
Vector< D, T > & | operator+= (const Vector< D, T > &other) |
| In-place addition. More...
|
|
Vector< D, T > & | operator-= (const Vector< D, T > &other) |
| In-place subtraction. More...
|
|
Vector< D, T > & | operator*= (const T other) |
| In-place scalar multiplication. More...
|
|
Vector< D, T > & | operator/= (const T other) |
| In-place scalar division. More...
|
|
T | dot (const Vector< D, T > &other) const |
| Dot product. More...
|
|
T | magn () const |
| Magnitude. More...
|
|
Vector< D, T > | normalize () const |
| Normalizes a vector. More...
|
|
constexpr std::size_t | numDimensions () const |
| Gets the number of dimensions. More...
|
|
bool | isZero () const |
| Determines whether the current vector is a zero vector. More...
|
|
const T & | operator[] (const std::size_t index) const |
| Value of a certain component of a vector. More...
|
|
T & | operator[] (const std::size_t index) |
| Sets value of a certain component. More...
|
|
const T & | at (const std::size_t index) const |
| Value of a certain component of a vector. More...
|
|
T & | at (const std::size_t index) |
| Sets value of a certain component. More...
|
|
iterator | begin () noexcept |
| Iterator of first element. More...
|
|
const_iterator | begin () const noexcept |
| Const interator of first element. More...
|
|
iterator | end () noexcept |
| Interator of last element + 1. More...
|
|
const_iterator | end () const noexcept |
| Const interator of last element + 1. More...
|
|
reverse_iterator | rbegin () noexcept |
| Reverse iterator to last element. More...
|
|
const_reverse_iterator | rbegin () const noexcept |
| Const reverse iterator to last element. More...
|
|
reverse_iterator | rend () noexcept |
| Reverse iterator to first element - 1. More...
|
|
const_reverse_iterator | rend () const noexcept |
| Const reverse iterator to first element - 1. More...
|
|
template<std::size_t D, typename T = double>
class svector::Vector< D, T >
A base vector representation.
- Note
- The binary +, -, *, /, ==, and != operators are by default implemented in functions.hpp. To use the class implementation rather than the one in functions.hpp, define the variable SVECTOR_USE_CLASS_OPERATORS.
template<std::size_t D, typename T = double>
Initializes a vector given initializer list.
The initializer list should represent the components of the vector in each dimension. If the size of the initializer list is greater than the number of dimensions given, then the vector only initializes with the first D elements in the list, where D is the number of dimensions. If the size of the initializer list is less than the number of dimensions given, then the vector fills the rest of the dimensions with the value 0.
- Parameters
-
args | the initializer list. |
template<std::size_t D, typename T = double>
Sets value of a certain component.
Sets a certain component of the vector given the dimension number.
Throws an out_of_range exception if the given number is out of bounds.
- Parameters
-
index | The dimension number. |
template<std::size_t D, typename T = double>
Value of a certain component of a vector.
Gets a reference to a specific component of the vector given the dimension number.
Throws an out_of_range exception if the given number is out of bounds.
- Parameters
-
index | The dimension number. |
- Returns
- A constant reference to that dimension's component of the vector.
template<std::size_t D, typename T = double>
Const interator of last element + 1.
Returns a constant iterator to the element following the last dimension of the vector.
This iterator is a placeholder and attempting to access it will result in undefined behavior.
- Returns
- A constant iterator to the element following the last dimension.
template<std::size_t D, typename T = double>
Interator of last element + 1.
Returns an iterator to the element following the last dimension of the vector.
This iterator is a placeholder and attempting to access it will result in undefined behavior.
This can be used for looping through the dimensions of a vector.
- Returns
- An iterator to the element following the last dimension.
template<std::size_t D, typename T = double>
Reverse iterator to last element.
Returns a reverse iterator to the first dimension of the reversed vector. It corresponds to the last dimension of the original vector. The iterator will be equal to rend() for a zero-dimension vector.
This can be used for looping through the dimensions of a vector.
- Returns
- A reverse iterator to the first dimension.
template<std::size_t D, typename T = double>
Const reverse iterator to first element - 1.
Returns a constant reverse iterator to the element following the last dimension of the reversed vector. It corresponds to the element preceding the first dimension of the original vector.
This iterator is a placeholder and attempting to access it will result in undefined behavior.
- Returns
- A constant reverse iterator to the element following the last dimension.
template<std::size_t D, typename T = double>
Reverse iterator to first element - 1.
Returns a reverse iterator to the element following the last dimension of the reversed vector. It corresponds to the element preceding the first dimension of the original vector.
This iterator is a placeholder and attempting to access it will result in undefined behavior.
This can be used for looping through the dimensions of a vector.
- Returns
- A reverse iterator to the element following the last dimension.