mgcpp
A C++ Math Library Based on CUDA
Enumerations | Functions
mgcpp::strict Namespace Reference

Enumerations

enum  trans_mode { trans_mode::same = CUBLAS_OP_N, trans_mode::transposed = CUBLAS_OP_T, trans_mode::conj_trans = CUBLAS_OP_C }
 

Functions

template<typename LhsDenseMat , typename RhsDenseMat , typename Type >
decltype(auto) add (dense_matrix< LhsDenseMat, Type > const &lhs, dense_matrix< RhsDenseMat, Type > const &rhs)
 
template<typename LhsDenseVec , typename RhsDenseVec , typename Type >
decltype(auto) add (dense_vector< LhsDenseVec, Type > const &first, dense_vector< RhsDenseVec, Type > const &second)
 
template<typename DeviceVec , typename Type >
decltype(auto) rfft (dense_vector< DeviceVec, Type > const &vec)
 
template<typename DeviceVec , typename Type >
decltype(auto) irfft (dense_vector< DeviceVec, complex< Type >> const &vec, int n=-1)
 
template<typename DeviceVec , typename Type >
decltype(auto) cfft (dense_vector< DeviceVec, complex< Type >> const &vec, fft_direction direction)
 
template<typename DeviceMat , typename Type >
decltype(auto) rfft (dense_matrix< DeviceMat, Type > const &mat)
 
template<typename DeviceMat , typename Type >
decltype(auto) irfft (dense_matrix< DeviceMat, complex< Type >> const &mat, int n=-1)
 
template<typename DeviceMat , typename Type >
decltype(auto) cfft (dense_matrix< DeviceMat, complex< Type >> const &mat, fft_direction direction)
 
template<typename ADense , typename BDense , typename CDense , typename Type >
decltype(auto) gemm (dense_matrix< ADense, Type > const &A, dense_matrix< BDense, Type > const &B, dense_matrix< CDense, Type > const &C)
 
template<typename ADense , typename BDense , typename CDense , typename Type , typename ScalarAlpha , typename ScalarBeta , typename = typename std::enable_if<is_scalar<ScalarAlpha>::value && is_scalar<ScalarBeta>::value>::type>
decltype(auto) gemm (ScalarAlpha alpha, dense_matrix< ADense, Type > const &A, dense_matrix< BDense, Type > const &B, ScalarBeta beta, dense_matrix< CDense, Type > const &C)
 
template<typename ADense , typename BDense , typename CDense , typename Type , typename ScalarAlpha , typename ScalarBeta , typename = typename std::enable_if<is_scalar<ScalarAlpha>::value && is_scalar<ScalarBeta>::value>::type>
decltype(auto) gemm (ScalarAlpha alpha, dense_matrix< ADense, Type > const &A, dense_matrix< BDense, Type > const &B, ScalarBeta beta, dense_matrix< CDense, Type > &&C)
 
template<typename ADense , typename BDense , typename CDense , typename Type , typename ScalarAlpha , typename ScalarBeta , typename = typename std::enable_if<is_scalar<ScalarAlpha>::value && is_scalar<ScalarBeta>::value>::type>
decltype(auto) gemm (ScalarAlpha alpha, trans_mode mode_A, trans_mode mode_B, dense_matrix< ADense, Type > const &A, dense_matrix< BDense, Type > const &B, ScalarBeta beta, dense_matrix< CDense, Type > const &C)
 
template<typename ADense , typename BDense , typename CDense , typename Type , typename ScalarAlpha , typename ScalarBeta , typename = typename std::enable_if<is_scalar<ScalarAlpha>::value && is_scalar<ScalarBeta>::value>::type>
decltype(auto) gemm (ScalarAlpha alpha, trans_mode mode_A, trans_mode mode_B, dense_matrix< ADense, Type > const &A, dense_matrix< BDense, Type > const &B, ScalarBeta beta, dense_matrix< CDense, Type > &&C)
 
template<typename LhsDenseVec , typename RhsDenseVec , typename Type >
decltype(auto) hdmd (dense_vector< LhsDenseVec, Type > const &lhs, dense_vector< RhsDenseVec, Type > const &rhs)
 
template<typename Type , outcome::result< void >(*)(Type *, size_t) Function, typename DenseVec >
device_vector< Type, typename DenseVec::allocator_type > map (dense_vector< DenseVec, Type > const &vec)
 
template<typename Type , outcome::result< void >(*)(Type *, size_t) Function, typename DenseMat >
device_matrix< Type, typename DenseMat::allocator_type > map (dense_matrix< DenseMat, Type > const &mat)
 
template<typename DenseVec , typename Type >
decltype(auto) abs (dense_vector< DenseVec, Type > const &vec)
 
template<typename DenseMat , typename Type >
decltype(auto) abs (dense_matrix< DenseMat, Type > const &mat)
 
template<typename DenseVec , typename Type >
decltype(auto) sin (dense_vector< DenseVec, Type > const &vec)
 
template<typename DenseMat , typename Type >
decltype(auto) sin (dense_matrix< DenseMat, Type > const &mat)
 
template<typename DenseVec , typename Type >
decltype(auto) cos (dense_vector< DenseVec, Type > const &vec)
 
template<typename DenseMat , typename Type >
decltype(auto) cos (dense_matrix< DenseMat, Type > const &mat)
 
template<typename DenseVec , typename Type >
decltype(auto) tan (dense_vector< DenseVec, Type > const &vec)
 
template<typename DenseMat , typename Type >
decltype(auto) tan (dense_matrix< DenseMat, Type > const &mat)
 
template<typename DenseVec , typename Type >
decltype(auto) sinh (dense_vector< DenseVec, Type > const &vec)
 
template<typename DenseMat , typename Type >
decltype(auto) sinh (dense_matrix< DenseMat, Type > const &mat)
 
template<typename DenseVec , typename Type >
decltype(auto) cosh (dense_vector< DenseVec, Type > const &vec)
 
template<typename DenseMat , typename Type >
decltype(auto) cosh (dense_matrix< DenseMat, Type > const &mat)
 
template<typename DenseVec , typename Type >
decltype(auto) tanh (dense_vector< DenseVec, Type > const &vec)
 
template<typename DenseMat , typename Type >
decltype(auto) tanh (dense_matrix< DenseMat, Type > const &mat)
 
template<typename DenseVec , typename Type >
decltype(auto) relu (dense_vector< DenseVec, Type > const &vec)
 
template<typename DenseMat , typename Type >
decltype(auto) relu (dense_matrix< DenseMat, Type > const &mat)
 
template<typename DenseVec , typename Type >
decltype(auto) mean (dense_vector< DenseVec, Type > const &vec)
 
template<typename DenseMat , typename Type >
decltype(auto) mean (dense_matrix< DenseMat, Type > const &mat)
 
template<typename LhsDenseMat , typename RhsDenseMat , typename Type >
decltype(auto) mult (dense_matrix< LhsDenseMat, Type > const &lhs, dense_matrix< RhsDenseMat, Type > const &rhs)
 
template<typename DenseMat , typename DenseVec , typename Type >
decltype(auto) mult (dense_matrix< DenseMat, Type > const &mat, dense_vector< DenseVec, Type > const &vec)
 
template<typename DenseVec , typename ScalarType , typename VectorType , typename = typename std::enable_if<is_scalar<ScalarType>::value>::type>
decltype(auto) mult (ScalarType scalar, dense_vector< DenseVec, VectorType > const &vec)
 
template<typename DenseMat , typename MatrixType , typename ScalarType , typename = typename std::enable_if<is_scalar<ScalarType>::value>::type>
decltype(auto) mult (ScalarType scalar, dense_matrix< DenseMat, MatrixType > const &mat)
 
template<typename LhsDenseVec , typename RhsDenseVec , typename Type >
decltype(auto) outer (dense_vector< LhsDenseVec, Type > const &lhs, dense_vector< RhsDenseVec, Type > const &rhs)
 
template<typename DenseVec , typename Type >
decltype(auto) pad (dense_vector< DenseVec, Type > const &vec, pad_size_t pad, typename value_type< Type >::type pad_constant=typename value_type< Type >::type{})
 
template<typename LhsDenseVec , typename RhsDenseVec , typename Type >
decltype(auto) sub (dense_vector< LhsDenseVec, Type > const &lhs, dense_vector< RhsDenseVec, Type > const &rhs)
 
template<typename LhsDenseMat , typename RhsDenseMat , typename Type >
decltype(auto) sub (dense_matrix< LhsDenseMat, Type > const &lhs, dense_matrix< RhsDenseMat, Type > const &rhs)
 
template<typename DeviceVec , typename Type >
decltype(auto) sum (dense_vector< DeviceVec, Type > const &vec)
 
template<typename DenseMat , typename Type >
decltype(auto) sum (dense_matrix< DenseMat, Type > const &mat)
 
template<typename DenseMat , typename Type >
decltype(auto) trans (dense_matrix< DenseMat, Type > const &mat)
 

Enumeration Type Documentation

◆ trans_mode

Enumerator
same 
transposed 
conj_trans 

Function Documentation

◆ abs() [1/2]

template<typename DenseVec , typename Type >
decltype(auto) mgcpp::strict::abs ( dense_vector< DenseVec, Type > const &  vec)
inline

Computes the absolute value of each element.

Parameters
vecvector to calculate the absolute value of.

◆ abs() [2/2]

template<typename DenseMat , typename Type >
decltype(auto) mgcpp::strict::abs ( dense_matrix< DenseMat, Type > const &  mat)
inline

Computes the absolute value of each element.

Parameters
matmatrix to calculate the absolute value of.

◆ add() [1/2]

template<typename LhsDenseMat , typename RhsDenseMat , typename Type >
decltype(auto) mgcpp::strict::add ( dense_matrix< LhsDenseMat, Type > const &  lhs,
dense_matrix< RhsDenseMat, Type > const &  rhs 
)
inline

Adds two same-sized matrices together.

Parameters
lhsthe left-hand side
rhsthe right-hand side

◆ add() [2/2]

template<typename LhsDenseVec , typename RhsDenseVec , typename Type >
decltype(auto) mgcpp::strict::add ( dense_vector< LhsDenseVec, Type > const &  first,
dense_vector< RhsDenseVec, Type > const &  second 
)
inline

Adds two same-sized vectors together.

Parameters
firstthe left-hand side
secondthe right-hand side

◆ cfft() [1/2]

template<typename DeviceVec , typename Type >
decltype(auto) mgcpp::strict::cfft ( dense_vector< DeviceVec, complex< Type >> const &  vec,
fft_direction  direction 
)
inline

Performs complex-to-complex FFT.

Parameters
vecthe vector to perform the fft on.
directionfft_direction::forward for forward fft, fft_direction::inverse for inverse normalized fft.
Returns
the FFT result.

◆ cfft() [2/2]

template<typename DeviceMat , typename Type >
decltype(auto) mgcpp::strict::cfft ( dense_matrix< DeviceMat, complex< Type >> const &  mat,
fft_direction  direction 
)
inline

Performs 2D complex-to-complex FFT.

Parameters
matthe matrix to perform the fft on.
directionfft_direction::forward for forward fft, fft_direction::inverse for inverse normalized fft.
Returns
the FFT result.

◆ cos() [1/2]

template<typename DenseVec , typename Type >
decltype(auto) mgcpp::strict::cos ( dense_vector< DenseVec, Type > const &  vec)
inline

◆ cos() [2/2]

template<typename DenseMat , typename Type >
decltype(auto) mgcpp::strict::cos ( dense_matrix< DenseMat, Type > const &  mat)
inline

◆ cosh() [1/2]

template<typename DenseVec , typename Type >
decltype(auto) mgcpp::strict::cosh ( dense_vector< DenseVec, Type > const &  vec)
inline

◆ cosh() [2/2]

template<typename DenseMat , typename Type >
decltype(auto) mgcpp::strict::cosh ( dense_matrix< DenseMat, Type > const &  mat)
inline

◆ gemm() [1/5]

template<typename ADense , typename BDense , typename CDense , typename Type >
decltype(auto) mgcpp::strict::gemm ( dense_matrix< ADense, Type > const &  A,
dense_matrix< BDense, Type > const &  B,
dense_matrix< CDense, Type > const &  C 
)
inline

General Matrix-matrix Multiplication.

Parameters
Aleft-hand side matrix operand
Bright-hand side matrix operand
Cmatrix to add after the multiplication
Returns
A * B + C

◆ gemm() [2/5]

template<typename ADense , typename BDense , typename CDense , typename Type , typename ScalarAlpha , typename ScalarBeta , typename = typename std::enable_if<is_scalar<ScalarAlpha>::value && is_scalar<ScalarBeta>::value>::type>
decltype(auto) mgcpp::strict::gemm ( ScalarAlpha  alpha,
dense_matrix< ADense, Type > const &  A,
dense_matrix< BDense, Type > const &  B,
ScalarBeta  beta,
dense_matrix< CDense, Type > const &  C 
)
inline

General Matrix-matrix Multiplication.

Parameters
alphascalar constant to multiply to A
Aleft-hand side matrix operand
Bright-hand side matrix operand
betascalar constant to multiply to C
Cmatrix to add after the multiplication
Returns
alpha * A * B + beta * C

◆ gemm() [3/5]

template<typename ADense , typename BDense , typename CDense , typename Type , typename ScalarAlpha , typename ScalarBeta , typename = typename std::enable_if<is_scalar<ScalarAlpha>::value && is_scalar<ScalarBeta>::value>::type>
decltype(auto) mgcpp::strict::gemm ( ScalarAlpha  alpha,
dense_matrix< ADense, Type > const &  A,
dense_matrix< BDense, Type > const &  B,
ScalarBeta  beta,
dense_matrix< CDense, Type > &&  C 
)
inline

General Matrix-matrix Multiplication.

Parameters
alphascalar constant to multiply to A
Aleft-hand side matrix operand
Bright-hand side matrix operand
betascalar constant to multiply to C
Cmatrix to add after the multiplication. It is moved instead of copied.
Returns
alpha * A * B + beta * C

◆ gemm() [4/5]

template<typename ADense , typename BDense , typename CDense , typename Type , typename ScalarAlpha , typename ScalarBeta , typename = typename std::enable_if<is_scalar<ScalarAlpha>::value && is_scalar<ScalarBeta>::value>::type>
decltype(auto) mgcpp::strict::gemm ( ScalarAlpha  alpha,
trans_mode  mode_A,
trans_mode  mode_B,
dense_matrix< ADense, Type > const &  A,
dense_matrix< BDense, Type > const &  B,
ScalarBeta  beta,
dense_matrix< CDense, Type > const &  C 
)
inline

General Matrix-matrix Multiplication.

Parameters
alphascalar constant to multiply to A
mode_Atransposition mode to apply to A before the operation. Can be strict::trans_mode::same, strict::trans_mode::transposed, or strict::trans_mode::conj_trans.
Aleft-hand side matrix operand
Bright-hand side matrix operand
betascalar constant to multiply to C
mode_Btransposition mode to apply to B before the operation. The accepted values are the same as mode_A.
Cmatrix to add after the multiplication.
Returns
alpha * mode_A(A) * mode_B(B) + beta * C

◆ gemm() [5/5]

template<typename ADense , typename BDense , typename CDense , typename Type , typename ScalarAlpha , typename ScalarBeta , typename = typename std::enable_if<is_scalar<ScalarAlpha>::value && is_scalar<ScalarBeta>::value>::type>
decltype(auto) mgcpp::strict::gemm ( ScalarAlpha  alpha,
trans_mode  mode_A,
trans_mode  mode_B,
dense_matrix< ADense, Type > const &  A,
dense_matrix< BDense, Type > const &  B,
ScalarBeta  beta,
dense_matrix< CDense, Type > &&  C 
)
inline

General Matrix-matrix Multiplication.

Parameters
alphascalar constant to multiply to A
mode_Atransposition mode to apply to A before the operation. Can be strict::trans_mode::same, strict::trans_mode::transposed, or strict::trans_mode::conj_trans.
Aleft-hand side matrix operand
Bright-hand side matrix operand
betascalar constant to multiply to C
mode_Btransposition mode to apply to B before the operation. The accepted values are the same as mode_A.
Cmatrix to add after the multiplication. It is moved instead of copied.
Returns
alpha * mode_A(A) * mode_B(B) + beta * C

◆ hdmd()

template<typename LhsDenseVec , typename RhsDenseVec , typename Type >
decltype(auto) mgcpp::strict::hdmd ( dense_vector< LhsDenseVec, Type > const &  lhs,
dense_vector< RhsDenseVec, Type > const &  rhs 
)
inline

Element-wise multiplication of two equal-sized vectors. (Hadamard Product)

Parameters
lhsleft-hand side
rhsright-hand side
Returns
the element-wise multiplication of lhs and rhs

◆ irfft() [1/2]

template<typename DeviceVec , typename Type >
decltype(auto) mgcpp::strict::irfft ( dense_vector< DeviceVec, complex< Type >> const &  vec,
int  n = -1 
)
inline

Performs complex-to-real inverse normalized FFT.

Parameters
vecthe vector to perform the fft on.
nperforms ((vec.size() - 1) * 2) point inverse FFT if n equals -1, otherwise performs an n-point inverse FFT.
Returns
the FFT result.

◆ irfft() [2/2]

template<typename DeviceMat , typename Type >
decltype(auto) mgcpp::strict::irfft ( dense_matrix< DeviceMat, complex< Type >> const &  mat,
int  n = -1 
)
inline

Performs 2D complex-to-real inverse normalized FFT.

Parameters
matthe matrix to perform the fft on.
nthe number of rows. if n == -1, the number is deduced from the size of mat.
Returns
the FFT result.

◆ map() [1/2]

template<typename Type , outcome::result< void >(*)(Type *, size_t) Function, typename DenseVec >
device_vector<Type, typename DenseVec::allocator_type> mgcpp::strict::map ( dense_vector< DenseVec, Type > const &  vec)
inline

◆ map() [2/2]

template<typename Type , outcome::result< void >(*)(Type *, size_t) Function, typename DenseMat >
device_matrix<Type, typename DenseMat::allocator_type> mgcpp::strict::map ( dense_matrix< DenseMat, Type > const &  mat)
inline

◆ mean() [1/2]

template<typename DenseVec , typename Type >
decltype(auto) mgcpp::strict::mean ( dense_vector< DenseVec, Type > const &  vec)
inline

◆ mean() [2/2]

template<typename DenseMat , typename Type >
decltype(auto) mgcpp::strict::mean ( dense_matrix< DenseMat, Type > const &  mat)
inline

◆ mult() [1/4]

template<typename LhsDenseMat , typename RhsDenseMat , typename Type >
decltype(auto) mgcpp::strict::mult ( dense_matrix< LhsDenseMat, Type > const &  lhs,
dense_matrix< RhsDenseMat, Type > const &  rhs 
)
inline

Matrix-matrix multiplication.

Parameters
lhsleft-hand side matrix
rhsright-hand side matrix
Returns
lhs * rhs

◆ mult() [2/4]

template<typename DenseMat , typename DenseVec , typename Type >
decltype(auto) mgcpp::strict::mult ( dense_matrix< DenseMat, Type > const &  mat,
dense_vector< DenseVec, Type > const &  vec 
)
inline

Matrix-vector multiplication. If matrix is size (n x m), then vector's size must be m. The resulting vector is of size n.

Parameters
matleft-hand side matrix
vecright-hand side vector
Returns
mat * vec

◆ mult() [3/4]

template<typename DenseVec , typename ScalarType , typename VectorType , typename = typename std::enable_if<is_scalar<ScalarType>::value>::type>
decltype(auto) mgcpp::strict::mult ( ScalarType  scalar,
dense_vector< DenseVec, VectorType > const &  vec 
)
inline

Scalar-vector multiplication.

Parameters
scalarthe scalar multiplier
vecvector to be multiplied by the scalar
Returns
scalar * vec

◆ mult() [4/4]

template<typename DenseMat , typename MatrixType , typename ScalarType , typename = typename std::enable_if<is_scalar<ScalarType>::value>::type>
decltype(auto) mgcpp::strict::mult ( ScalarType  scalar,
dense_matrix< DenseMat, MatrixType > const &  mat 
)
inline

Scalar-matrix multiplication.

Parameters
scalarthe scalar multiplier
matmatrix to be multiplied by the scalar
Returns
scalar * mat

◆ outer()

template<typename LhsDenseVec , typename RhsDenseVec , typename Type >
decltype(auto) mgcpp::strict::outer ( dense_vector< LhsDenseVec, Type > const &  lhs,
dense_vector< RhsDenseVec, Type > const &  rhs 
)
inline

◆ pad()

template<typename DenseVec , typename Type >
decltype(auto) mgcpp::strict::pad ( dense_vector< DenseVec, Type > const &  vec,
pad_size_t  pad,
typename value_type< Type >::type  pad_constant = typename value_type< Type >::type{} 
)
inline

Applies padding to a vector.

Parameters
vecthe vector to be padded.
padthe padding size.
pad_constantthe value of the padding cells. If not specified, the default padding is zero.
Returns
the padded result

◆ relu() [1/2]

template<typename DenseVec , typename Type >
decltype(auto) mgcpp::strict::relu ( dense_vector< DenseVec, Type > const &  vec)
inline

◆ relu() [2/2]

template<typename DenseMat , typename Type >
decltype(auto) mgcpp::strict::relu ( dense_matrix< DenseMat, Type > const &  mat)
inline

◆ rfft() [1/2]

template<typename DeviceVec , typename Type >
decltype(auto) mgcpp::strict::rfft ( dense_vector< DeviceVec, Type > const &  vec)
inline

Performs real-to-complex forward FFT.

Parameters
vecthe vector to perform the fft on.
Returns
the FFT result.

◆ rfft() [2/2]

template<typename DeviceMat , typename Type >
decltype(auto) mgcpp::strict::rfft ( dense_matrix< DeviceMat, Type > const &  mat)
inline

Performs 2D real-to-complex forward FFT.

Parameters
matthe matrix to perform the fft on.
Returns
the FFT result.

◆ sin() [1/2]

template<typename DenseVec , typename Type >
decltype(auto) mgcpp::strict::sin ( dense_vector< DenseVec, Type > const &  vec)
inline

◆ sin() [2/2]

template<typename DenseMat , typename Type >
decltype(auto) mgcpp::strict::sin ( dense_matrix< DenseMat, Type > const &  mat)
inline

◆ sinh() [1/2]

template<typename DenseVec , typename Type >
decltype(auto) mgcpp::strict::sinh ( dense_vector< DenseVec, Type > const &  vec)
inline

◆ sinh() [2/2]

template<typename DenseMat , typename Type >
decltype(auto) mgcpp::strict::sinh ( dense_matrix< DenseMat, Type > const &  mat)
inline

◆ sub() [1/2]

template<typename LhsDenseVec , typename RhsDenseVec , typename Type >
decltype(auto) mgcpp::strict::sub ( dense_vector< LhsDenseVec, Type > const &  lhs,
dense_vector< RhsDenseVec, Type > const &  rhs 
)
inline

Vector Subtraction.

Parameters
lhsthe left-hand side
rhsthe right-hand side
Returns
lhs - rhs

◆ sub() [2/2]

template<typename LhsDenseMat , typename RhsDenseMat , typename Type >
decltype(auto) mgcpp::strict::sub ( dense_matrix< LhsDenseMat, Type > const &  lhs,
dense_matrix< RhsDenseMat, Type > const &  rhs 
)
inline

Matrix Subtraction.

Parameters
lhsthe left-hand side
rhsthe right-hand side
Returns
lhs - rhs

◆ sum() [1/2]

template<typename DeviceVec , typename Type >
decltype(auto) mgcpp::strict::sum ( dense_vector< DeviceVec, Type > const &  vec)
inline

◆ sum() [2/2]

template<typename DenseMat , typename Type >
decltype(auto) mgcpp::strict::sum ( dense_matrix< DenseMat, Type > const &  mat)
inline

◆ tan() [1/2]

template<typename DenseVec , typename Type >
decltype(auto) mgcpp::strict::tan ( dense_vector< DenseVec, Type > const &  vec)
inline

◆ tan() [2/2]

template<typename DenseMat , typename Type >
decltype(auto) mgcpp::strict::tan ( dense_matrix< DenseMat, Type > const &  mat)
inline

◆ tanh() [1/2]

template<typename DenseVec , typename Type >
decltype(auto) mgcpp::strict::tanh ( dense_vector< DenseVec, Type > const &  vec)
inline

◆ tanh() [2/2]

template<typename DenseMat , typename Type >
decltype(auto) mgcpp::strict::tanh ( dense_matrix< DenseMat, Type > const &  mat)
inline

◆ trans()

template<typename DenseMat , typename Type >
decltype(auto) mgcpp::strict::trans ( dense_matrix< DenseMat, Type > const &  mat)