One-dimensional array of doubles with element-wise arithmetic.
More...
#include <matrix.hpp>
|
|
| Vector ()=default |
| | Default-constructs an empty vector.
|
| |
| | Vector (std::size_t size, double fill=0.0) |
| | Constructs a vector of the given length.
|
| |
|
| Vector (const Vector &)=default |
| | Copy constructor (deep-copies element storage).
|
| |
|
| Vector (Vector &&) noexcept=default |
| | Move constructor.
|
| |
|
Vector & | operator= (const Vector &)=default |
| | Copy assignment.
|
| |
|
Vector & | operator= (Vector &&) noexcept=default |
| | Move assignment.
|
| |
| std::size_t | size () const noexcept |
| |
| bool | empty () const noexcept |
| |
| double & | operator[] (std::size_t i) |
| | Mutable element access.
|
| |
| const double & | operator[] (std::size_t i) const |
| | Const element access.
|
| |
| double * | data () noexcept |
| |
| const double * | data () const noexcept |
| |
| Vector | operator+ (const Vector &other) const |
| | Element-wise addition.
|
| |
| Vector | operator- (const Vector &other) const |
| | Element-wise subtraction.
|
| |
|
Vector | operator* (double scalar) const |
| | Scalar multiplication (each element times scalar).
|
| |
| Vector & | operator+= (const Vector &other) |
| | In-place element-wise addition.
|
| |
| Vector & | operator-= (const Vector &other) |
| | In-place element-wise subtraction.
|
| |
|
Vector & | operator*= (double scalar) |
| | In-place scalar multiplication.
|
| |
| double | sum () const |
| |
|
void | normalize () |
| | Divides each element by sum(); no-op if sum is zero.
|
| |
| Vector | normalized () const |
| |
| bool | is_equal (const Vector &other, double abs_tol=1e-12) const |
| | Exact equality within absolute tolerance.
|
| |
| bool | is_near (const Vector &other, double abs_tol=1e-9, double rel_tol=1e-9) const |
| | Approximate equality (absolute and relative tolerances).
|
| |
|
|
Vector | operator* (double scalar, const Vector &v) |
| | Scalar multiplication from the left (scalar * v).
|
| |
One-dimensional array of doubles with element-wise arithmetic.
◆ Vector()
| anpcpp::Vector::Vector |
( |
std::size_t |
size, |
|
|
double |
fill = 0.0 |
|
) |
| |
|
explicit |
Constructs a vector of the given length.
- Parameters
-
| size | Number of elements. |
| fill | Initial value for every element (default 0). |
◆ data() [1/2]
| const double * anpcpp::Vector::data |
( |
| ) |
const |
|
inlinenoexcept |
- Returns
- Pointer to contiguous element storage (const).
◆ data() [2/2]
| double * anpcpp::Vector::data |
( |
| ) |
|
|
inlinenoexcept |
- Returns
- Pointer to contiguous element storage (mutable).
◆ empty()
| bool anpcpp::Vector::empty |
( |
| ) |
const |
|
inlinenoexcept |
- Returns
- True if size() is zero.
◆ is_equal()
| bool anpcpp::Vector::is_equal |
( |
const Vector & |
other, |
|
|
double |
abs_tol = 1e-12 |
|
) |
| const |
Exact equality within absolute tolerance.
- Parameters
-
| other | Vector to compare. |
| abs_tol | Maximum absolute difference per element. |
◆ is_near()
| bool anpcpp::Vector::is_near |
( |
const Vector & |
other, |
|
|
double |
abs_tol = 1e-9, |
|
|
double |
rel_tol = 1e-9 |
|
) |
| const |
Approximate equality (absolute and relative tolerances).
- Parameters
-
| other | Vector to compare. |
| abs_tol | Absolute tolerance per element. |
| rel_tol | Relative tolerance scaled by element magnitudes. |
◆ normalized()
| Vector anpcpp::Vector::normalized |
( |
| ) |
const |
- Returns
- A copy of this vector with elements L1-normalized.
◆ operator+()
| Vector anpcpp::Vector::operator+ |
( |
const Vector & |
other | ) |
const |
Element-wise addition.
- Exceptions
-
◆ operator+=()
In-place element-wise addition.
- Exceptions
-
◆ operator-()
| Vector anpcpp::Vector::operator- |
( |
const Vector & |
other | ) |
const |
Element-wise subtraction.
- Exceptions
-
◆ operator-=()
In-place element-wise subtraction.
- Exceptions
-
◆ operator[]() [1/2]
| double & anpcpp::Vector::operator[] |
( |
std::size_t |
i | ) |
|
Mutable element access.
- Parameters
-
- Returns
- Reference to element
i.
- Exceptions
-
◆ operator[]() [2/2]
| const double & anpcpp::Vector::operator[] |
( |
std::size_t |
i | ) |
const |
Const element access.
- Parameters
-
- Returns
- Const reference to element
i.
- Exceptions
-
◆ size()
| std::size_t anpcpp::Vector::size |
( |
| ) |
const |
|
inlinenoexcept |
- Returns
- Number of elements.
◆ sum()
| double anpcpp::Vector::sum |
( |
| ) |
const |
- Returns
- Sum of all elements.
The documentation for this class was generated from the following file: