Vector0 class
#include <ellalgo/conjugate_gradient.hpp>
A simple vector class for conjugate gradient calculations.
This class provides basic vector operations needed for the conjugate gradient method, including addition, subtraction, scalar multiplication, dot product, and norm calculation.
Constructors, destructors, conversion operators
Public functions
-
auto operator[](size_
t i) -> double& - Access element at index i.
-
auto operator[](size_
t i) const -> const double& - Access element at index i (const version)
-
auto size() const -> size_
t - Get the size of the vector.
- auto operator+=(const Vector0& rhs) -> Vector0&
- Add another vector to this vector.
- auto operator-=(const Vector0& rhs) -> Vector0&
- Subtract another vector from this vector.
- auto operator*=(double scalar) -> Vector0&
- Multiply this vector by a scalar.
- auto dot(const Vector0& other) const -> double
- Compute the dot product with another vector.
- auto norm() const -> double
- Compute the L2 norm of the vector.
Function documentation
double& Vector0:: operator[](size_ t i)
Access element at index i.
| Parameters | |
|---|---|
| i in | Index of the element |
| Returns | Reference to the element |
const double& Vector0:: operator[](size_ t i) const
Access element at index i (const version)
| Parameters | |
|---|---|
| i in | Index of the element |
| Returns | Const reference to the element |
Vector0& Vector0:: operator+=(const Vector0& rhs)
Add another vector to this vector.
| Parameters | |
|---|---|
| rhs in | The vector to add |
| Returns | Reference to this vector after addition |
Vector0& Vector0:: operator-=(const Vector0& rhs)
Subtract another vector from this vector.
| Parameters | |
|---|---|
| rhs in | The vector to subtract |
| Returns | Reference to this vector after subtraction |
Vector0& Vector0:: operator*=(double scalar)
Multiply this vector by a scalar.
| Parameters | |
|---|---|
| scalar in | The scalar value to multiply |
| Returns | Reference to this vector after multiplication |