TRIQS/nda 2.0.0
Multi-dimensional array library for C++
Loading...
Searching...
No Matches
BLAS/LAPACK utilities

Detailed Description

Utilities for the BLAS/LAPACK (and cuBLAS/cuSOLVER) interface.

Concepts

concept  nda::blas_lapack::BlasArray
 BLAS/LAPACK compatible array type.
concept  nda::blas_lapack::BlasArrayCplx
 BLAS/LAPACK compatible array type with complex value type.
concept  nda::blas_lapack::BlasArrayFor
 BLAS/LAPACK compatible array type that has the same value type as the reference array type and a compatible address space.
concept  nda::blas_lapack::BlasArrayOrConj
 BLAS/LAPACK compatible array or conjugate lazy expression type.
concept  nda::blas_lapack::BlasArrayOrConjFor
 BLAS/LAPACK compatible array or conjugate lazy expression type that has the same value type as the reference array type and a compatible address space.
concept  nda::blas_lapack::BlasArrayReal
 BLAS/LAPACK compatible array type with real value type.
concept  nda::blas_lapack::BlasArrayRealFor
 BLAS/LAPACK compatible array type that has a compatible floating-point value type and address space with the reference array type.
concept  nda::blas_lapack::PivotArrayFor
 BLAS/LAPACK compatible pivot array type that has a compatible address space with the reference array type.

Typedefs

using nda::dcomplex = std::complex<double>
 Alias for std::complex<double> type.
template<MemoryArray A>
using nda::blas_lapack::vector_fp_t = vector<get_fp_t<A>, heap<mem::get_addr_space<A>>>
 Alias for an nda::vector with the same address space as the given type and its value type determined by nda::get_fp_t<A>.
template<MemoryArray A>
using nda::blas_lapack::vector_value_t = vector<get_value_t<A>, heap<mem::get_addr_space<A>>>
 Alias for an nda::vector with the same value type and address space as the given type.

Functions

template<Array A>
requires (MemoryArrayOfRank<A, 3> or MemoryArrayOfRank<A, 2>)
auto nda::blas_lapack::batch_ptrs (A &&a)
 Given a 2- or 3-dimensional array get an array of pointers to each of the submatrices/subvectors indexed by the slowest varying dimension.
template<Array A>
requires (MemoryArray<A> or is_conj_array_expr<A>)
MemoryArray decltype(auto) nda::blas_lapack::get_array (A &&a)
 Get the underlying array of a conjugate lazy expression or return the array itself in case it is an nda::MemoryArray.
template<MemoryArray A>
requires (get_rank<A> == 1 or get_rank<A> == 2)
int nda::blas_lapack::get_ld (A const &a)
 Get the leading dimension of an nda::MemoryArray with rank 1 or 2 for BLAS/LAPACK calls.
template<MemoryArray A>
requires (get_rank<A> == 1 or get_rank<A> == 2)
int nda::blas_lapack::get_ncols (A const &a)
 Get the number of columns of an nda::MemoryArray with rank 1 or 2 for BLAS/LAPACK calls.
template<typename A>
requires (is_regular_or_view_v<A> and get_rank<A> == 1)
void nda::blas_lapack::resize_or_check_work_buffer (A &a, long min_size)
 Resize or check the size of a 1D array/view.

Variables

template<Array A>
static constexpr char nda::blas_lapack::get_op
 Variable template that determines the BLAS matrix operation tag ('N','T','C') based on the given boolean flags for conjugation and transposition.
template<Array... As>
static constexpr bool nda::blas_lapack::has_C_layout
 Constexpr variable that is true if all given nda::Array types have nda::C_layout.
template<Array... As>
static constexpr bool nda::blas_lapack::has_F_layout
 Constexpr variable that is true if all given nda::Array types have nda::F_layout.
template<typename A>
static constexpr bool nda::blas_lapack::is_conj_array_expr = false
 Constexpr variable that is true if the given type is a conjugate lazy expression.
template<MemoryArray A>
static constexpr bool nda::blas_lapack::is_conj_array_expr< expr_call< detail::conj_f, A > > = true
 Specialization of nda::blas_lapack::is_conj_array_expr for the conjugate lazy expressions.

Typedef Documentation

◆ vector_fp_t

template<MemoryArray A>
using nda::blas_lapack::vector_fp_t = vector<get_fp_t<A>, heap<mem::get_addr_space<A>>>

#include <nda/blas/tools.hpp>

Alias for an nda::vector with the same address space as the given type and its value type determined by nda::get_fp_t<A>.

Template Parameters
Anda::MemoryArray type.

Definition at line 170 of file tools.hpp.

◆ vector_value_t

#include <nda/blas/tools.hpp>

Alias for an nda::vector with the same value type and address space as the given type.

Template Parameters
Anda::MemoryArray type.

Definition at line 161 of file tools.hpp.

Function Documentation

◆ batch_ptrs()

template<Array A>
requires (MemoryArrayOfRank<A, 3> or MemoryArrayOfRank<A, 2>)
auto nda::blas_lapack::batch_ptrs ( A && a)

#include <nda/blas/tools.hpp>

Given a 2- or 3-dimensional array get an array of pointers to each of the submatrices/subvectors indexed by the slowest varying dimension.

Template Parameters
Anda::MemoryArray of rank 2 or 3.
Parameters
aInput array.
Returns
nda::vector of pointers to each submatrix/subvector.

Definition at line 182 of file tools.hpp.

◆ get_array()

template<Array A>
requires (MemoryArray<A> or is_conj_array_expr<A>)
MemoryArray decltype(auto) nda::blas_lapack::get_array ( A && a)

#include <nda/blas/tools.hpp>

Get the underlying array of a conjugate lazy expression or return the array itself in case it is an nda::MemoryArray.

Template Parameters
Anda::Array type.
Parameters
aConjugate expression or array/view.
Returns
nda::MemoryArray object.

Definition at line 68 of file tools.hpp.

◆ get_ld()

template<MemoryArray A>
requires (get_rank<A> == 1 or get_rank<A> == 2)
int nda::blas_lapack::get_ld ( A const & a)

#include <nda/blas/tools.hpp>

Get the leading dimension of an nda::MemoryArray with rank 1 or 2 for BLAS/LAPACK calls.

The leading dimension is the stride between two consecutive columns (rows) of a matrix in Fortran (C) layout. For 1-dimensional arrays, we simply return the size of the array.

Template Parameters
Anda::MemoryArray type.
Parameters
anda::MemoryArray object.
Returns
Leading dimension for BLAS/LAPACK calls.

Definition at line 128 of file tools.hpp.

◆ get_ncols()

template<MemoryArray A>
requires (get_rank<A> == 1 or get_rank<A> == 2)
int nda::blas_lapack::get_ncols ( A const & a)

#include <nda/blas/tools.hpp>

Get the number of columns of an nda::MemoryArray with rank 1 or 2 for BLAS/LAPACK calls.

The number of columns corresponds to the extent of the second (first) dimension of a matrix in Fortran (C) layout. For 1-dimensional arrays, we return 1.

Template Parameters
Anda::MemoryArray type.
Parameters
anda::MemoryArray object.
Returns
Number of columns for BLAS/LAPACK calls.

Definition at line 148 of file tools.hpp.

◆ resize_or_check_work_buffer()

template<typename A>
requires (is_regular_or_view_v<A> and get_rank<A> == 1)
void nda::blas_lapack::resize_or_check_work_buffer ( A & a,
long min_size )

#include <nda/blas/tools.hpp>

Resize or check the size of a 1D array/view.

This function is similar to nda::resize_or_check_if_view except that

  • it only works for 1D arrays/views,
  • it does not resize or throw an error if the size is too big and
  • it expects that the memory is contiguous.
Template Parameters
AType of the object.
Parameters
aObject to resize or check.
min_sizeMinimum size.

Definition at line 207 of file tools.hpp.

Variable Documentation

◆ get_op

template<Array A>
char nda::blas_lapack::get_op
staticconstexpr

#include <nda/blas/tools.hpp>

Initial value:
= []() {
auto constexpr conj = is_conj_array_expr<A>;
auto constexpr transpose = has_C_layout<A>;
static_assert(!(conj and not transpose), "Error in nda::blas_lapack::get_op: Cannot use conjugate operation alone in BLAS operations");
if constexpr (conj and transpose)
return 'C';
else if constexpr (transpose)
return 'T';
else
return 'N';
}()
auto transpose(A &&a)
Transpose the memory layout of an nda::MemoryArray or an nda::expr_call.
decltype(auto) conj(A &&a)
Function conj for nda::ArrayOrScalar types (lazy and coefficient-wise for nda::Array types with a com...
static constexpr bool is_conj_array_expr
Constexpr variable that is true if the given type is a conjugate lazy expression.
Definition tools.hpp:47
static constexpr bool has_C_layout
Constexpr variable that is true if all given nda::Array types have nda::C_layout.
Definition tools.hpp:89

Variable template that determines the BLAS matrix operation tag ('N','T','C') based on the given boolean flags for conjugation and transposition.

Template Parameters
conjBoolean flag for conjugation.
transposeBoolean flag for transposition.

Definition at line 104 of file tools.hpp.