TRIQS/nda 1.3.0
Multi-dimensional array library for C++
Loading...
Searching...
No Matches
BLAS interface

Detailed Description

Interface to parts of the BLAS library.

Functions

template<MemoryVector X, MemoryVector Y>
requires (have_same_value_type_v<X, Y> and mem::have_compatible_addr_space<X, Y> and is_blas_lapack_v<get_value_t<X>>)
auto nda::blas::dot (X const &x, Y const &y)
 Interface to the BLAS dot and dotu routine.
template<MemoryVector X, MemoryVector Y>
requires (have_same_value_type_v<X, Y> and mem::have_compatible_addr_space<X, Y> and is_blas_lapack_v<get_value_t<X>>)
auto nda::blas::dotc (X const &x, Y const &y)
 Interface to the BLAS dotc routine.
template<Matrix A, Matrix B, MemoryMatrix C>
requires ((MemoryMatrix<A> or is_conj_array_expr<A>) and (MemoryMatrix<B> or is_conj_array_expr<B>) and have_same_value_type_v<A, B, C> and mem::have_compatible_addr_space<A, B, C> and is_blas_lapack_v<get_value_t<A>>)
void nda::blas::gemm (get_value_t< A > alpha, A const &a, B const &b, get_value_t< A > beta, C &&c)
 Interface to the BLAS gemm routine.
template<bool is_vbatch = false, Matrix A, Matrix B, MemoryMatrix C>
requires ((MemoryMatrix<A> or is_conj_array_expr<A>) and (MemoryMatrix<B> or is_conj_array_expr<B>) and have_same_value_type_v<A, B, C> and mem::have_compatible_addr_space<A, B, C> and is_blas_lapack_v<get_value_t<A>>)
void nda::blas::gemm_batch (get_value_t< A > alpha, std::vector< A > const &va, std::vector< B > const &vb, get_value_t< A > beta, std::vector< C > &vc)
 Interface to MKL's/CUDA's gemm_batch and gemm_vbatch routines.
template<ArrayOfRank< 3 > A, ArrayOfRank< 3 > B, MemoryArrayOfRank< 3 > C>
requires ((MemoryArrayOfRank<A, 3> or is_conj_array_expr<A>) and (MemoryArrayOfRank<B, 3> or is_conj_array_expr<B>) and have_same_value_type_v<A, B, C> and mem::have_compatible_addr_space<A, B, C> and is_blas_lapack_v<get_value_t<A>>)
void nda::blas::gemm_batch_strided (get_value_t< A > alpha, A const &a, B const &b, get_value_t< A > beta, C &&c)
 Interface to MKL's/CUDA's gemm_batch_strided routine.
template<Matrix A, Matrix B, MemoryMatrix C>
void nda::blas::gemm_vbatch (get_value_t< A > alpha, std::vector< A > const &va, std::vector< B > const &vb, get_value_t< A > beta, std::vector< C > &vc)
 Interface to MKL's/Magma's gemm_vbatch routine.
template<Matrix A, MemoryVector X, MemoryVector Y>
requires ((MemoryMatrix<A> or is_conj_array_expr<A>) and have_same_value_type_v<A, X, Y> and mem::have_compatible_addr_space<A, X, Y> and is_blas_lapack_v<get_value_t<A>>)
void nda::blas::gemv (get_value_t< A > alpha, A const &a, X const &x, get_value_t< A > beta, Y &&y)
 Interface to the BLAS gemv routine.
template<MemoryVector X, MemoryVector Y, MemoryMatrix M>
requires (have_same_value_type_v<X, Y, M> and mem::have_compatible_addr_space<X, Y, M> and is_blas_lapack_v<get_value_t<X>>)
void nda::blas::ger (get_value_t< X > alpha, X const &x, Y const &y, M &&m)
 Interface to the BLAS ger and geru routine.
template<MemoryVector X, MemoryVector Y, MemoryMatrix M>
requires (have_same_value_type_v<X, Y, M> and mem::have_compatible_addr_space<X, Y, M> and is_blas_lapack_v<get_value_t<X>>)
void nda::blas::gerc (get_value_t< X > alpha, X const &x, Y const &y, M &&m)
 Interface to the BLAS gerc routine.
template<MemoryVector X>
requires (is_blas_lapack_v<get_value_t<X>>)
void nda::blas::scal (get_value_t< X > alpha, X &&x)
 Interface to the BLAS scal routine.

Function Documentation

◆ dot()

template<MemoryVector X, MemoryVector Y>
requires (have_same_value_type_v<X, Y> and mem::have_compatible_addr_space<X, Y> and is_blas_lapack_v<get_value_t<X>>)
auto nda::blas::dot ( X const & x,
Y const & y )

#include <nda/blas/dot.hpp>

Interface to the BLAS dot and dotu routine.

This function forms the dot product of two vectors. It calculates

\[ \mathbf{x}^T \mathbf{y} \; . \]

Note
The first argument is never conjugated. Even for complex types. Use nda::blas::dotc for that.
Template Parameters
Xnda::MemoryVector type.
Ynda::MemoryVector type.
Parameters
xInput vector \( \mathbf{x} \).
yInput vector \( \mathbf{y} \).
Returns
Result of \( \mathbf{x}^T \mathbf{y} \).

Definition at line 48 of file dot.hpp.

◆ dotc()

template<MemoryVector X, MemoryVector Y>
requires (have_same_value_type_v<X, Y> and mem::have_compatible_addr_space<X, Y> and is_blas_lapack_v<get_value_t<X>>)
auto nda::blas::dotc ( X const & x,
Y const & y )

#include <nda/blas/dot.hpp>

Interface to the BLAS dotc routine.

This function forms the dot product of two vectors. It calculates

\[ \mathbf{x}^H \mathbf{y} \; . \]

If the value type of the input vectors is real, it calls nda::blas::dot and returns a real result.

Template Parameters
Xnda::MemoryVector type.
Ynda::MemoryVector type.
Parameters
xInput vector \( \mathbf{x} \).
yInput vector \( \mathbf{y} \).
Returns
Result of \( \mathbf{x}^H \mathbf{y} \).

Definition at line 83 of file dot.hpp.

◆ gemm()

template<Matrix A, Matrix B, MemoryMatrix C>
requires ((MemoryMatrix<A> or is_conj_array_expr<A>) and (MemoryMatrix<B> or is_conj_array_expr<B>) and have_same_value_type_v<A, B, C> and mem::have_compatible_addr_space<A, B, C> and is_blas_lapack_v<get_value_t<A>>)
void nda::blas::gemm ( get_value_t< A > alpha,
A const & a,
B const & b,
get_value_t< A > beta,
C && c )

#include <nda/blas/gemm.hpp>

Interface to the BLAS gemm routine.

This function performs one of the matrix-matrix operations

\[ \mathbf{C} \leftarrow \alpha \mathrm{op}_A(\mathbf{A}) \mathrm{op}_B(\mathbf{B}) + \beta \mathbf{C} \;, \]

where \( \mathrm{op}(\mathbf{X}) \) is one of

  • \( \mathrm{op}(\mathbf{X}) = \mathbf{X} \) or,
  • \( \mathrm{op}(\mathbf{X}) = \mathbf{X}^* \) (only if \( \mathbf{X} \) is in nda::C_layout).

Here, \( \alpha \) and \( \beta \) are scalars, and \( \mathbf{A} \), \( \mathbf{B} \) and \( \mathbf{C} \) are matrices of size \( m \times k \), \( k \times n \) and \( m \times n \), respectively.

Note
If matrix \( \mathbf{C} \) is in nda::C_layout, we transpose both \( \mathbf{A} \) and \( \mathbf{B} \) and swap their order.
Template Parameters
Anda::Matrix type.
Bnda::Matrix type.
Cnda::MemoryMatrix type.
Parameters
alphaInput scalar \( \alpha \).
aInput matrix \( \mathrm{op}_A(\mathbf{A}) \) of size \( m \times k \).
bInput matrix \( \mathrm{op}_B(\mathbf{B}) \) of size \( k \times n \).
betaInput scalar \( \beta \).
cInput/Output matrix \( \mathbf{C} \) of size \( m \times n \).

Definition at line 63 of file gemm.hpp.

◆ gemm_batch()

template<bool is_vbatch = false, Matrix A, Matrix B, MemoryMatrix C>
requires ((MemoryMatrix<A> or is_conj_array_expr<A>) and (MemoryMatrix<B> or is_conj_array_expr<B>) and have_same_value_type_v<A, B, C> and mem::have_compatible_addr_space<A, B, C> and is_blas_lapack_v<get_value_t<A>>)
void nda::blas::gemm_batch ( get_value_t< A > alpha,
std::vector< A > const & va,
std::vector< B > const & vb,
get_value_t< A > beta,
std::vector< C > & vc )

#include <nda/blas/gemm_batch.hpp>

Interface to MKL's/CUDA's gemm_batch and gemm_vbatch routines.

This routine is a batched version of nda::blas::gemm, performing multiple gemm operations in a single call. Each gemm operation performs a matrix-matrix product.

If is_vbatch is true, the matrices are allowed to have different sizes. Otherwise, they are required to have the same size.

See also nda::blas::gemm for more details.

Template Parameters
is_vbatchAllow variable sized matrices.
Anda::Matrix type.
Bnda::Matrix type.
Cnda::MemoryMatrix type.
Parameters
alphaInput scalar \( \alpha \).
vastd::vector of input matrices.
vbstd::vector of input matrices.
betaInput scalar \( \beta \).
vcstd::vector of input/output matrices.

Definition at line 86 of file gemm_batch.hpp.

◆ gemm_batch_strided()

template<ArrayOfRank< 3 > A, ArrayOfRank< 3 > B, MemoryArrayOfRank< 3 > C>
requires ((MemoryArrayOfRank<A, 3> or is_conj_array_expr<A>) and (MemoryArrayOfRank<B, 3> or is_conj_array_expr<B>) and have_same_value_type_v<A, B, C> and mem::have_compatible_addr_space<A, B, C> and is_blas_lapack_v<get_value_t<A>>)
void nda::blas::gemm_batch_strided ( get_value_t< A > alpha,
A const & a,
B const & b,
get_value_t< A > beta,
C && c )

#include <nda/blas/gemm_batch.hpp>

Interface to MKL's/CUDA's gemm_batch_strided routine.

This function is similar to nda::blas::gemm_batch except that it takes 3-dimensional arrays as arguments instead of vectors of matrices. The first dimension of the arrays indexes the matrices to be multiplied.

Template Parameters
Anda::ArrayOfRank<3> type.
Bnda::ArrayOfRank<3> type.
Cnda::ArrayOfRank<3> type.
Parameters
alphaInput scalar \( \alpha \).
a3-dimensional input array.
b3-dimensional input array.
betaInput scalar \( \beta \).
c3-dimensional input/output array.

Definition at line 209 of file gemm_batch.hpp.

◆ gemm_vbatch()

template<Matrix A, Matrix B, MemoryMatrix C>
void nda::blas::gemm_vbatch ( get_value_t< A > alpha,
std::vector< A > const & va,
std::vector< B > const & vb,
get_value_t< A > beta,
std::vector< C > & vc )

#include <nda/blas/gemm_batch.hpp>

Interface to MKL's/Magma's gemm_vbatch routine.

It simply calls nda::blas::gemm_batch with is_vbatch set to true.

Template Parameters
Anda::Matrix type.
Bnda::Matrix type.
Cnda::MemoryMatrix type.
Parameters
alphaInput scalar \( \alpha \).
vastd::vector of input matrices.
vbstd::vector of input matrices.
betaInput scalar \( \beta \).
vcstd::vector of input/output matrices.

Definition at line 187 of file gemm_batch.hpp.

◆ gemv()

template<Matrix A, MemoryVector X, MemoryVector Y>
requires ((MemoryMatrix<A> or is_conj_array_expr<A>) and have_same_value_type_v<A, X, Y> and mem::have_compatible_addr_space<A, X, Y> and is_blas_lapack_v<get_value_t<A>>)
void nda::blas::gemv ( get_value_t< A > alpha,
A const & a,
X const & x,
get_value_t< A > beta,
Y && y )

#include <nda/blas/gemv.hpp>

Interface to the BLAS gemv routine.

This function performs one of the matrix-vector operations

  • \( \mathbf{y} \leftarrow \alpha \mathbf{A} \mathbf{x} + \beta \mathbf{y} \),
  • \( \mathbf{y} \leftarrow \alpha \mathbf{A}^* \mathbf{x} + \beta \mathbf{y} \) (only if \( \mathbf{A} \) is in nda::C_layout),

where \( \alpha \) and \( \beta \) are scalars, \( \mathbf{A} \) is an \( m \times n \) matrix and \(\mathbf{x} \) and \( \mathbf{y} \) are vectors of sizes \( n \) and \( m \), respectively.

Template Parameters
Anda::Matrix type.
Xnda::MemoryVector type.
Ynda::MemoryVector type.
Parameters
alphaInput scalar \( \alpha \).
aInput matrix \( \mathbf{A} \) of size \( m \times n \).
xInput vector \( \mathbf{x} \) of size \( n \).
betaInput scalar \( \beta \).
yInput/Output vector \( \mathbf{y} \) of size \( m \).

Definition at line 57 of file gemv.hpp.

◆ ger()

template<MemoryVector X, MemoryVector Y, MemoryMatrix M>
requires (have_same_value_type_v<X, Y, M> and mem::have_compatible_addr_space<X, Y, M> and is_blas_lapack_v<get_value_t<X>>)
void nda::blas::ger ( get_value_t< X > alpha,
X const & x,
Y const & y,
M && m )

#include <nda/blas/ger.hpp>

Interface to the BLAS ger and geru routine.

This function performs the rank 1 operation

\[ \mathbf{M} \leftarrow \alpha \mathbf{x} \mathbf{y}^T + \mathbf{M} \; , \]

where \( \alpha \) is a scalar, \( \mathbf{x} \) is an \( m \) element vector, \( \mathbf{y} \) is an \( n \) element vector and \( \mathbf{M} \) is an \( m \times n \) matrix.

Note
The vector \( \mathbf{y} \) is never conjugated. Even for complex types. Use nda::blas::gerc for that.
Template Parameters
Xnda::MemoryVector type.
Ynda::MemoryVector type.
Mnda::MemoryMatrix type.
Parameters
alphaInput scalar \( \alpha \).
xInput vector \( \mathbf{x} \) of size \( m \).
yInput vector \( \mathbf{y} \) of size \( n \).
mInput/Output matrix \( \mathbf{M} \) of size \( m \times n \) to which the outer product is added.

Definition at line 55 of file ger.hpp.

◆ gerc()

template<MemoryVector X, MemoryVector Y, MemoryMatrix M>
requires (have_same_value_type_v<X, Y, M> and mem::have_compatible_addr_space<X, Y, M> and is_blas_lapack_v<get_value_t<X>>)
void nda::blas::gerc ( get_value_t< X > alpha,
X const & x,
Y const & y,
M && m )

#include <nda/blas/ger.hpp>

Interface to the BLAS gerc routine.

This function performs the rank 1 operation

\[ \mathbf{M} \leftarrow \alpha \mathbf{x} \mathbf{y}^H + \mathbf{M} \; , \]

where \( \alpha \) is a scalar, \( \mathbf{x} \) is an \( m \) element vector, \( \mathbf{y} \) is an \( n \) element vector and \( \mathbf{M} \) is an \( m \times n \) matrix.

If the value type of the input vectors/matrix is real, it calls nda::blas::ger.

Note
\( \mathbf{M} \) has to be in nda::F_layout.
Template Parameters
Xnda::MemoryVector type.
Ynda::MemoryVector type.
Mnda::MemoryMatrix type.
Parameters
alphaInput scalar \( \alpha \).
xInput vector \( \mathbf{x} \) of size \( m \).
yInput vector \( \mathbf{y} \) of size \( n \).
mInput/Output matrix \( \mathbf{M} \) of size \( m \times n \) to which the outer product is added.

Definition at line 105 of file ger.hpp.

◆ scal()

template<MemoryVector X>
requires (is_blas_lapack_v<get_value_t<X>>)
void nda::blas::scal ( get_value_t< X > alpha,
X && x )

#include <nda/blas/scal.hpp>

Interface to the BLAS scal routine.

Scales a vector by a constant. This function calculates \( \mathbf{x} \leftarrow \alpha \mathbf{x} \), where \( \alpha \) is a scalar constant and \( \mathbf{x} \) is a vector.

Template Parameters
Xnda::MemoryVector type.
Parameters
alphaInput scalar \( \alpha \).
xInput/Output vector \( \mathbf{x} \) to be scaled.

Definition at line 38 of file scal.hpp.