Linear algebra
- group Linear algebra
-
Functions
-
__host__ __device__ inline constexpr void load(const T *inVector)
Load values from a C-array into this vector.
- Parameters:
inVector – [in] Input C-array vector to load values from.
-
__host__ __device__ inline constexpr void load(std::initializer_list<T> l)
Load values from a C++ initiliazer list into this vector.
- Parameters:
l – [in] Input C++ initializer list to load values from.
-
__host__ __device__ inline constexpr void store(T *outVector) const
Store values to a C-array from this vector.
- Parameters:
outVector – [out] Output C-array vector to store values to.
-
__host__ __device__ inline constexpr int size() const
Get size (number of elements) of this vector.
- Returns:
Vector size.
-
__host__ __device__ inline constexpr const T &operator[](int i) const
Subscript operator for read-only access.
- Parameters:
i – [in] Position to access.
- Returns:
Value (constant reference) at given position.
-
__host__ __device__ inline constexpr T &operator[](int i)
Subscript operator for read-and-write access.
- Parameters:
i – [in] Position to access.
- Returns:
Value (reference) at given position.
-
__host__ __device__ inline explicit constexpr operator const T*() const
Pointer-access operator (constant).
- Returns:
Pointer to the first element of this vector.
-
__host__ __device__ inline explicit constexpr operator T*()
Pointer-access operator.
- Returns:
Pointer to the first element of this vector.
-
__host__ __device__ inline constexpr const T *cbegin() const
Begin (constant) pointer access.
- Returns:
Pointer to the first element of this vector.
-
__host__ __device__ inline constexpr T *begin()
Begin pointer access.
- Returns:
Pointer to the first element of this vector.
-
__host__ __device__ inline constexpr const T *cend() const
End (constant) pointer access.
- Returns:
Pointer to the one-past-last element of this vector.
-
__host__ __device__ inline constexpr T *end()
End pointer access.
- Returns:
Pointer to the one-past-last element of this vector.
-
inline std::vector<T> to_vector() const
Convert a vector of this class to an stl vector.
- Returns:
STL std::vector.
-
template<int R>
__host__ __device__ inline constexpr Vector<T, R> subv(int beg) const Get a sub-vector of this vector.
- Parameters:
beg – [in] Position to start getting values from this vector.
- Template Parameters:
R – Size of the sub-vector to be returned.
- Returns:
Vector of value from given index to the end.
-
__host__ __device__ inline constexpr void load(const T *inFlattenMatrix)
Load values from a flatten array into this matrix.
- Parameters:
inFlattenMatrix – [in] Input flatten matrix to load values from.
-
__host__ __device__ inline constexpr void load(std::initializer_list<T> l)
Load values from a C++ initiliazer list into this matrix.
- Parameters:
l – [in] Input C++ initializer list to load values from.
-
__host__ __device__ inline constexpr void store(T *outFlattenMatrix) const
Store values to a flatten array from this matrix.
- Parameters:
outFlattenMatrix – [out] Output flatten matrix to store values to.
-
__host__ __device__ inline constexpr int rows() const
Get number of rows of this matrix.
- Returns:
Number of rows.
-
__host__ __device__ inline constexpr int cols() const
Get number of columns of this matrix.
- Returns:
Number of columns.
-
__host__ __device__ inline constexpr const Vector<T, N> &operator[](int i) const
Subscript operator for read-only access.
- Parameters:
i – [in] Row of the matrix to access.
- Returns:
Vector (constant reference) of the corresponding row.
-
__host__ __device__ inline constexpr Vector<T, N> &operator[](int i)
Subscript operator for read-and-write access.
- Parameters:
i – [in] Row of the matrix to access.
- Returns:
Vector (reference) of the corresponding row.
-
__host__ __device__ inline constexpr const T &operator[](int2 c) const
Subscript operator for read-only access of matrix elements.
- Parameters:
c – [in] Coordinates (y row and x column) of the matrix element to access.
- Returns:
Element (constant reference) of the corresponding row and column.
-
__host__ __device__ inline constexpr T &operator[](int2 c)
Subscript operator for read-and-write access of matrix elements.
- Parameters:
c – [in] Coordinates (y row and x column) of the matrix element to access.
- Returns:
Element (reference) of the corresponding row and column.
-
__host__ __device__ inline constexpr Vector<T, M> col(int j) const
Get column j of this matrix.
- Parameters:
j – [in] Index of column to get.
- Returns:
Column j (copied) as a vector.
-
__host__ __device__ inline constexpr void set_col(int j, T v)
Set column j of this matrix.
- Parameters:
j – [in] Index of column to set.
v – [in] Value to place in matrix column.
-
__host__ __device__ inline constexpr void set_col(int j, const Vector<T, M> &c)
Set column j of this matrix.
- Parameters:
j – [in] Index of column to set.
c – [in] Vector to place in matrix column.
-
__host__ __device__ inline constexpr void set_col(int j, const T *c)
-
__host__ __device__ inline constexpr Matrix<T, M - 1, N - 1> subm(int skip_i, int skip_j) const
Get a sub-matrix of this matrix.
- Parameters:
skip_i – [in] Row to skip when getting values from this matrix.
skip_j – [in] Column to skip when getting values from this matrix.
- Returns:
Matrix with one less row and one less column.
-
template<class T, int N>
__host__ __device__ constexpr Vector<T, N> &operator+=(Vector<T, N> &lhs, const Vector<T, N> &rhs)
-
template<class T, int N>
__host__ __device__ constexpr Vector<T, N> operator+(const Vector<T, N> &a, const Vector<T, N> &b)
-
template<class T, int N>
__host__ __device__ constexpr Vector<T, N> &operator+=(Vector<T, N> &lhs, T rhs)
-
template<class T, int N>
__host__ __device__ constexpr Vector<T, N> operator+(const Vector<T, N> &a, T b)
-
template<class T, int N>
__host__ __device__ constexpr Vector<T, N> operator+(T a, const Vector<T, N> &b)
-
template<class T, int N>
__host__ __device__ constexpr Vector<T, N> &operator-=(Vector<T, N> &lhs, const Vector<T, N> &rhs)
-
template<class T, int N>
__host__ __device__ constexpr Vector<T, N> operator-(const Vector<T, N> &a, const Vector<T, N> &b)
-
template<class T, int N>
__host__ __device__ constexpr Vector<T, N> &operator-=(Vector<T, N> &lhs, T rhs)
-
template<class T, int N>
__host__ __device__ constexpr Vector<T, N> operator-(const Vector<T, N> &a, T b)
-
template<class T, int N>
__host__ __device__ constexpr Vector<T, N> operator-(T a, const Vector<T, N> &b)
-
template<class T, int N>
__host__ __device__ constexpr Vector<T, N> &operator*=(Vector<T, N> &lhs, const T &rhs)
-
template<class T, int N>
__host__ __device__ constexpr Vector<T, N> operator*(const Vector<T, N> &a, const T &b)
-
template<class T, int N>
__host__ __device__ constexpr Vector<T, N> operator*(const T &a, const Vector<T, N> &b)
-
template<class T, int N>
__host__ __device__ constexpr Vector<T, N> &operator*=(Vector<T, N> &lhs, const Vector<T, N> &rhs)
-
template<class T, int N>
__host__ __device__ constexpr Vector<T, N> operator*(const Vector<T, N> &a, const Vector<T, N> &b)
-
template<class T, int N>
__host__ __device__ constexpr Vector<T, N> &operator/=(Vector<T, N> &lhs, const T &rhs)
-
template<class T, int N>
__host__ __device__ constexpr Vector<T, N> operator/(const Vector<T, N> &a, const T &b)
-
template<class T, int N>
__host__ __device__ constexpr Vector<T, N> operator/(T a, const Vector<T, N> &b)
-
template<class T, int N>
__host__ __device__ constexpr Vector<T, N> &operator/=(Vector<T, N> &lhs, const Vector<T, N> &rhs)
-
template<class T, int N>
__host__ __device__ constexpr Vector<T, N> operator/(const Vector<T, N> &a, const Vector<T, N> &b)
-
template<class T, int N>
__host__ __device__ constexpr Vector<T, N> operator-(const Vector<T, N> &v)
-
template<class T, int N>
__host__ __device__ constexpr bool operator==(const Vector<T, N> &a, const Vector<T, N> &b)
-
template<class T, int N>
__host__ __device__ constexpr bool operator==(const T &a, const Vector<T, N> &b)
-
template<class T, int N>
__host__ __device__ constexpr bool operator==(const Vector<T, N> &a, const T &b)
-
template<class T, int N>
__host__ __device__ constexpr bool operator<(const Vector<T, N> &a, const Vector<T, N> &b)
-
template<class T, int M, int N>
__host__ __device__ constexpr Matrix<T, M, N> operator*(const Matrix<T, M, N> &m, T val)
-
template<class T, int M, int N>
std::ostream &operator<<(std::ostream &out, const Matrix<T, M, N> &m)
-
template<class T, int M, int N, int P>
__host__ __device__ constexpr Matrix<T, M, P> operator*(const Matrix<T, M, N> &a, const Matrix<T, N, P> &b)
-
template<class T, int M, int N>
__host__ __device__ constexpr Matrix<T, M, N> &operator*=(Matrix<T, M, N> &lhs, T rhs)
-
template<class T, int M, int N>
__host__ __device__ constexpr Matrix<T, M, N> operator*(T val, const Matrix<T, M, N> &m)
-
template<class T, int M, int N>
__host__ __device__ constexpr Matrix<T, M, N> &operator+=(Matrix<T, M, N> &lhs, const Matrix<T, M, N> &rhs)
-
template<class T, int M, int N>
__host__ __device__ constexpr Matrix<T, M, N> operator+(const Matrix<T, M, N> &lhs, const Matrix<T, M, N> &rhs)
-
template<class T, int M, int N>
__host__ __device__ constexpr Matrix<T, M, N> &operator-=(Matrix<T, M, N> &lhs, const Matrix<T, M, N> &rhs)
-
template<class T, int M, int N>
__host__ __device__ constexpr Matrix<T, M, N> operator-(const Matrix<T, M, N> &a, const Matrix<T, M, N> &b)
-
template<class T, int M, int N>
__host__ __device__ constexpr Vector<T, N> operator*(const Vector<T, M> &v, const Matrix<T, M, N> &m)
-
template<class T, int M, int N>
__host__ __device__ constexpr Vector<T, M> operator*(const Matrix<T, M, N> &m, const Vector<T, N> &v)
- template<class T, int M, int N, class = cuda::Require<(M == N && N > 1> constexpr __host__ __device__ Matrix< T, M, N > operator* (const Matrix< T, M, 1 > &m, const Vector< T, N > &v)
-
template<class T, int M, int N>
__host__ __device__ constexpr Vector<T, N> &operator*=(Vector<T, M> &v, const Matrix<T, M, M> &m)
-
template<class T, int M, int N>
__host__ __device__ constexpr Matrix<T, M, N> &operator*=(Matrix<T, M, N> &lhs, const Matrix<T, N, N> &rhs)
-
template<class T, int M, int N>
__host__ __device__ constexpr Matrix<T, M, N> operator-(const Matrix<T, M, N> &m)
-
template<class T, int M, int N>
__host__ __device__ constexpr bool operator==(const Matrix<T, M, N> &a, const Matrix<T, M, N> &b)
-
template<class T, int M, int N>
__host__ __device__ constexpr bool operator==(const T &a, const Matrix<T, M, N> &b)
-
template<class T, int M, int N>
__host__ __device__ constexpr bool operator==(const Matrix<T, M, N> &a, const T &b)
-
template<class T, int M, int N>
__host__ __device__ constexpr bool operator<(const Matrix<T, M, N> &a, const Matrix<T, M, N> &b)
-
template<class T, int M>
__host__ __device__ constexpr Matrix<T, M, M> vander(const Vector<T, M> &v)
-
template<class T, int R>
__host__ __device__ constexpr Matrix<T, R, R> compan(const Vector<T, R> &a)
-
template<class T, int N>
__host__ __device__ constexpr T dot(const Vector<T, N> &a, const Vector<T, N> &b)
-
template<class T, int M>
__host__ __device__ constexpr Matrix<T, M, M> &transp_inplace(Matrix<T, M, M> &m)
-
template<class T, int M, int N>
__host__ __device__ constexpr Matrix<T, N, M> transp(const Matrix<T, M, N> &m)
-
template<class T, int N>
__host__ __device__ constexpr Matrix<T, N, 1> transp(const Vector<T, N> &v)
-
template<class T, int M, int N>
__host__ __device__ constexpr Matrix<T, M, N> flip_rows(const Matrix<T, M, N> &m)
-
template<class T, int N>
class Vector - #include <LinAlg.hpp>
Vector class to represent small vectors.
- Template Parameters:
T – Vector value type.
N – Number of elements.
-
template<class T, int M, int N = M>
class Matrix - #include <LinAlg.hpp>
Matrix class to represent small matrices.
It uses the Vector class to stores each row, storing elements in row-major order, i.e. it has M row vectors where each vector has N elements.
- Template Parameters:
T – Matrix value type.
M – Number of rows.
N – Number of columns. Default is M (a square matrix).
-
namespace detail
-
__host__ __device__ inline constexpr void load(const T *inVector)