ellalgo/linear_algebra.hpp file

Basic linear algebra utilities for vectors and matrices.

This header provides simple vector and matrix classes for basic linear algebra operations. These are lightweight implementations designed specifically for the ellalgo library.

Classes

template<typename T>
class Vector2
A simple 2D vector class for linear algebra operations.
template<typename T>
class Matrix2
A simple 2D matrix class for linear algebra operations.

Functions

template<typename T>
auto operator+(Vector2<T> lhs, const Vector2<T>& rhs) -> Vector2<T>
template<typename T>
auto operator-(Vector2<T> lhs, const Vector2<T>& rhs) -> Vector2<T>
template<typename T>
auto operator*(Vector2<T> v, T scalar) -> Vector2<T>
template<typename T>
auto operator*(T scalar, Vector2<T> v) -> Vector2<T>

Function documentation

template<typename T>
Vector2<T> operator+(Vector2<T> lhs, const Vector2<T>& rhs)

Parameters
lhs The Vector2 to add the elements of the given Vector2 to.
rhs The Vector2 to add to the elements of the given Vector2.
Returns The resulting Vector2 after the addition.

Adds the elements of the given Vector2 to the corresponding elements of this Vector2.

template<typename T>
Vector2<T> operator-(Vector2<T> lhs, const Vector2<T>& rhs)

Parameters
lhs The Vector2 to subtract the elements of the given Vector2 from.
rhs The Vector2 to subtract from the elements of the given Vector2.
Returns The resulting Vector2 after the subtraction.

Subtracts the elements of the given Vector2 from the corresponding elements of this Vector2.

template<typename T>
Vector2<T> operator*(Vector2<T> v, T scalar)

Parameters
v The Vector2 to multiply by the scalar.
scalar The scalar value to multiply the Vector2 by.
Returns The resulting Vector2 after the multiplication.

Multiplies the elements of the given Vector2 by the given scalar value.

template<typename T>
Vector2<T> operator*(T scalar, Vector2<T> v)

Parameters
scalar The scalar value to multiply the Vector2 by.
v The Vector2 to multiply by the scalar.
Returns The resulting Vector2 after the multiplication.

Multiplies the given scalar value by the elements of the given Vector2.