Loading...
Searching...
No Matches
vector.hpp File Reference

Go to the source code of this file.

Classes

class  terra::linalg::detail::DummyVector< ScalarT >
 Dummy vector class for concept checks and testing. Implements required vector operations as no-ops. More...
 
class  terra::linalg::detail::DummyBlock2Vector< ScalarT >
 Dummy block 2-vector class for concept checks and testing. Contains two DummyVector blocks. More...
 

Namespaces

namespace  terra
 
namespace  terra::linalg
 Contains linear algebra utilities and functions for the Terra project.
 
namespace  terra::linalg::detail
 

Concepts

concept  terra::linalg::VectorLike
 Concept for types that behave like vectors. Requires exposing ScalarType and implementations for linear algebra operations.
 
concept  terra::linalg::Block2VectorLike
 Concept for types that behave like block 2-vectors. Extends VectorLike and requires block types and accessors.
 

Typedefs

template<VectorLike Vector>
using terra::linalg::ScalarOf = typename Vector::ScalarType
 Alias for the scalar type of a vector.
 

Functions

template<VectorLike Vector>
void terra::linalg::lincomb (Vector &y, const std::vector< ScalarOf< Vector > > &c, const std::vector< Vector > &x, const ScalarOf< Vector > &c0)
 Compute a linear combination of vectors. Implements: \( y = \sum_{i} c_i x_i + c_0 \).
 
template<VectorLike Vector>
void terra::linalg::lincomb (Vector &y, const std::vector< ScalarOf< Vector > > &c, const std::vector< Vector > &x)
 Compute a linear combination of vectors with zero scalar. Implements: \( y = \sum_{i} c_i x_i \).
 
template<VectorLike Vector>
void terra::linalg::assign (Vector &y, const ScalarOf< Vector > &c0)
 Assign a scalar value to a vector. Implements: \( y \gets c_0 \).
 
template<VectorLike Vector>
void terra::linalg::assign (Vector &y, const Vector &x)
 Assign one vector to another. Implements: \( y \gets x \).
 
template<VectorLike Vector>
ScalarOf< Vector > terra::linalg::dot (const Vector &y, const Vector &x)
 Compute the dot product of two vectors. Implements: \( y \cdot x = \sum_{i} y_i x_i \).
 
template<VectorLike Vector>
void terra::linalg::invert_entries (Vector &y)
 Invert the entries of a vector. For each entry \( y_i \), computes \( y_i = 1 / y_i \).
 
template<VectorLike Vector>
void terra::linalg::scale_in_place (Vector &y, const Vector &x)
 Scale a vector in place with another vector. For each entry \( y_i \), computes \( y_i = y_i \cdot x_i \).
 
template<VectorLike Vector>
void terra::linalg::randomize (Vector &y)
 Randomize the entries of a vector. Sets each entry of \( y \) to a random value.
 
template<VectorLike Vector>
ScalarOf< Vector > terra::linalg::norm_inf (const Vector &y)
 Compute the infinity norm (max absolute entry) of a vector. Implements: \( \|y\|_\infty = \max_i |y_i| \).
 
template<VectorLike Vector>
ScalarOf< Vector > terra::linalg::norm_2 (const Vector &y)
 Compute the 2-norm (Euclidean norm) of a vector. Implements: \( \|y\|_2 = \sqrt{ \sum_i y_i^2 } \).
 
template<VectorLike Vector>
ScalarOf< Vector > terra::linalg::norm_2_scaled (const Vector &y, const ScalarOf< Vector > &scaling_factor_under_the_root)
 Compute the scaled 2-norm of a vector. Implements: \( \|y\|_2^{\text{scaled}} = \sqrt{ (\sum_i y_i^2) \cdot s } \).
 
template<VectorLike Vector>
bool terra::linalg::has_nan_or_inf (const Vector &y)
 Check if a vector contains NaN or inf entries. Returns true if any entry of \( y \) is NaN or inf.
 
template<VectorLike Vector>
void terra::linalg::swap (Vector &x, Vector &y)
 Swap the contents of two vectors. Exchanges the entries of \( x \) and \( y \).