Linear algebra

group NVCV_CPP_CUDATOOLS_LINALG

Typedefs

using Type = T
using Type = T

Functions

inline constexpr __host__ __device__ 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.

inline constexpr __host__ __device__ 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.

inline constexpr __host__ __device__ 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.

inline constexpr __host__ __device__ int size () const

Get size (number of elements) of this vector.

Returns:

Vector size.

inline constexpr const __host__ __device__ T & operator[] (int i) const

Subscript operator for read-only access.

Parameters:

i[in] Position to access.

Returns:

Value (constant reference) at given position.

inline constexpr __host__ __device__ T & operator[] (int i)

Subscript operator for read-and-write access.

Parameters:

i[in] Position to access.

Returns:

Value (reference) at given position.

inline constexpr __host__ __device__ operator const T * () const

Pointer-access operator (constant).

Returns:

Pointer to the first element of this vector.

inline constexpr __host__ __device__ operator T* ()

Pointer-access operator.

Returns:

Pointer to the first element of this vector.

inline constexpr const __host__ __device__ T * cbegin () const

Begin (constant) pointer access.

Returns:

Pointer to the first element of this vector.

inline constexpr __host__ __device__ T * begin ()

Begin pointer access.

Returns:

Pointer to the first element of this vector.

inline constexpr const __host__ __device__ T * cend () const

End (constant) pointer access.

Returns:

Pointer to the one-past-last element of this vector.

inline constexpr __host__ __device__ 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> inline constexpr __host__ __device__ 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.

inline constexpr __host__ __device__ void load (const T *inFlattenMatrix)

Load values from a flatten array into this matrix.

Parameters:

inFlattenMatrix[in] Input flatten matrix to load values from.

inline constexpr __host__ __device__ 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.

inline constexpr __host__ __device__ void store (T *outFlattenMatrix) const

Store values to a flatten array from this matrix.

Parameters:

outFlattenMatrix[out] Output flatten matrix to store values to.

inline constexpr __host__ __device__ int rows () const

Get number of rows of this matrix.

Returns:

Number of rows.

inline constexpr __host__ __device__ int cols () const

Get number of columns of this matrix.

Returns:

Number of columns.

inline constexpr const __host__ __device__ 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.

inline constexpr __host__ __device__ 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.

inline constexpr const __host__ __device__ 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.

inline constexpr __host__ __device__ 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.

inline constexpr __host__ __device__ 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.

inline constexpr __host__ __device__ 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.

inline constexpr __host__ __device__ 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.

inline constexpr __host__ __device__ void set_col (int j, const T *c)
inline constexpr __host__ __device__ 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> constexpr __host__ __device__ void swap (T &a, T &b)
template<class T, int N> constexpr __host__ __device__ Vector< T, N > & operator+= (Vector< T, N > &lhs, const Vector< T, N > &rhs)
template<class T, int N> constexpr __host__ __device__ Vector< T, N > operator+ (const Vector< T, N > &a, const Vector< T, N > &b)
template<class T, int N> constexpr __host__ __device__ Vector< T, N > & operator+= (Vector< T, N > &lhs, T rhs)
template<class T, int N> constexpr __host__ __device__ Vector< T, N > operator+ (const Vector< T, N > &a, T b)
template<class T, int N> constexpr __host__ __device__ Vector< T, N > operator+ (T a, const Vector< T, N > &b)
template<class T, int N> constexpr __host__ __device__ Vector< T, N > & operator-= (Vector< T, N > &lhs, const Vector< T, N > &rhs)
template<class T, int N> constexpr __host__ __device__ Vector< T, N > operator- (const Vector< T, N > &a, const Vector< T, N > &b)
template<class T, int N> constexpr __host__ __device__ Vector< T, N > & operator-= (Vector< T, N > &lhs, T rhs)
template<class T, int N> constexpr __host__ __device__ Vector< T, N > operator- (const Vector< T, N > &a, T b)
template<class T, int N> constexpr __host__ __device__ Vector< T, N > operator- (T a, const Vector< T, N > &b)
template<class T, int N> constexpr __host__ __device__ Vector< T, N > & operator*= (Vector< T, N > &lhs, const T &rhs)
template<class T, int N> constexpr __host__ __device__ Vector< T, N > operator* (const Vector< T, N > &a, const T &b)
template<class T, int N> constexpr __host__ __device__ Vector< T, N > operator* (const T &a, const Vector< T, N > &b)
template<class T, int N> constexpr __host__ __device__ Vector< T, N > & operator*= (Vector< T, N > &lhs, const Vector< T, N > &rhs)
template<class T, int N> constexpr __host__ __device__ Vector< T, N > operator* (const Vector< T, N > &a, const Vector< T, N > &b)
template<class T, int N> constexpr __host__ __device__ Vector< T, N > & operator/= (Vector< T, N > &lhs, const T &rhs)
template<class T, int N> constexpr __host__ __device__ Vector< T, N > operator/ (const Vector< T, N > &a, const T &b)
template<class T, int N> constexpr __host__ __device__ Vector< T, N > operator/ (T a, const Vector< T, N > &b)
template<class T, int N> constexpr __host__ __device__ Vector< T, N > & operator/= (Vector< T, N > &lhs, const Vector< T, N > &rhs)
template<class T, int N> constexpr __host__ __device__ Vector< T, N > operator/ (const Vector< T, N > &a, const Vector< T, N > &b)
template<class T, int N>
std::ostream &operator<<(std::ostream &out, const Vector<T, N> &v)
template<class T, int N> constexpr __host__ __device__ Vector< T, N > operator- (const Vector< T, N > &v)
template<class T, int N> constexpr __host__ __device__ bool operator== (const Vector< T, N > &a, const Vector< T, N > &b)
template<class T, int N> constexpr __host__ __device__ bool operator== (const T &a, const Vector< T, N > &b)
template<class T, int N> constexpr __host__ __device__ bool operator== (const Vector< T, N > &a, const T &b)
template<class T, int N> constexpr __host__ __device__ bool operator< (const Vector< T, N > &a, const Vector< T, N > &b)
template<class T, int M, int N> constexpr __host__ __device__ 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> constexpr __host__ __device__ Matrix< T, M, P > operator* (const Matrix< T, M, N > &a, const Matrix< T, N, P > &b)
template<class T, int M, int N> constexpr __host__ __device__ Matrix< T, M, N > & operator*= (Matrix< T, M, N > &lhs, T rhs)
template<class T, int M, int N> constexpr __host__ __device__ Matrix< T, M, N > operator* (T val, const Matrix< T, M, N > &m)
template<class T, int M, int N> constexpr __host__ __device__ Matrix< T, M, N > & operator+= (Matrix< T, M, N > &lhs, const Matrix< T, M, N > &rhs)
template<class T, int M, int N> constexpr __host__ __device__ Matrix< T, M, N > operator+ (const Matrix< T, M, N > &lhs, const Matrix< T, M, N > &rhs)
template<class T, int M, int N> constexpr __host__ __device__ Matrix< T, M, N > & operator-= (Matrix< T, M, N > &lhs, const Matrix< T, M, N > &rhs)
template<class T, int M, int N> constexpr __host__ __device__ Matrix< T, M, N > operator- (const Matrix< T, M, N > &a, const Matrix< T, M, N > &b)
template<class T, int M, int N> constexpr __host__ __device__ Vector< T, N > operator* (const Vector< T, M > &v, const Matrix< T, M, N > &m)
template<class T, int M, int N> constexpr __host__ __device__ 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> constexpr __host__ __device__ Vector< T, N > & operator*= (Vector< T, M > &v, const Matrix< T, M, M > &m)
template<class T, int M, int N> constexpr __host__ __device__ Matrix< T, M, N > & operator*= (Matrix< T, M, N > &lhs, const Matrix< T, N, N > &rhs)
template<class T, int M, int N> constexpr __host__ __device__ Matrix< T, M, N > operator- (const Matrix< T, M, N > &m)
template<class T, int M, int N> constexpr __host__ __device__ bool operator== (const Matrix< T, M, N > &a, const Matrix< T, M, N > &b)
template<class T, int M, int N> constexpr __host__ __device__ bool operator== (const T &a, const Matrix< T, M, N > &b)
template<class T, int M, int N> constexpr __host__ __device__ bool operator== (const Matrix< T, M, N > &a, const T &b)
template<class T, int M, int N> constexpr __host__ __device__ bool operator< (const Matrix< T, M, N > &a, const Matrix< T, M, N > &b)
template<typename T, int N, int M>
constexpr Matrix<T, N, M> as_matrix(const T (&values)[N][M])
template<class T, int N> constexpr __host__ __device__ Vector< T, N > zeros ()
template<class T, int M, int N> constexpr __host__ __device__ Matrix< T, M, N > zeros ()
template<class T, int N> constexpr __host__ __device__ Vector< T, N > ones ()
template<class T, int M, int N> constexpr __host__ __device__ Matrix< T, M, N > ones ()
template<class T, int M, int N> constexpr __host__ __device__ Matrix< T, M, N > identity ()
template<class T, int M> constexpr __host__ __device__ Matrix< T, M, M > vander (const Vector< T, M > &v)
template<class T, int R> constexpr __host__ __device__ Matrix< T, R, R > compan (const Vector< T, R > &a)
template<class T, int M> constexpr __host__ __device__ Matrix< T, M, M > diag (const Vector< T, M > &v)
template<class T, int N> constexpr __host__ __device__ T dot (const Vector< T, N > &a, const Vector< T, N > &b)
template<class T, int N> constexpr __host__ __device__ Vector< T, N > reverse (const Vector< T, N > &a)
template<class T, int M> constexpr __host__ __device__ Matrix< T, M, M > & transp_inplace (Matrix< T, M, M > &m)
template<class T, int M, int N> constexpr __host__ __device__ Matrix< T, N, M > transp (const Matrix< T, M, N > &m)
template<class T, int N> constexpr __host__ __device__ Matrix< T, N, 1 > transp (const Vector< T, N > &v)
template<class T, int M, int N> constexpr __host__ __device__ Matrix< T, M, N > flip_rows (const Matrix< T, M, N > &m)
template<class T, int M, int N> constexpr __host__ __device__ Matrix< T, M, N > flip_cols (const Matrix< T, M, N > &m)
template<class T, int M, int N> constexpr __host__ __device__ Matrix< T, M, N > flip (const Matrix< T, M, N > &m)

Variables

T m_data[N] = {}
Vector<T, N> m_data[M]
template<class T, int N>
class Vector
#include <LinAlg.hpp>

Vector class to represent small vectors.

Template Parameters:
  • TVector 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:
  • TMatrix value type.

  • M – Number of rows.

  • N – Number of columns. Default is M (a square matrix).