Low-Level Linear Algebra (BLAS, LAPACK, etc.)#

The low-level linear algebra functions are a collection of functions that provide a direct interface to the underlying linear algebra libraries (e.g., BLAS, LAPACK, etc.). These functions are intended to be used by developers who need to access the low-level linear algebra routines directly. The functions in this module are not intended to be used by end-users, as they do not provide a high-level interface to the linear algebra routines.

Before using the low-level linear algebra functions, you should be familiar with the underlying linear algebra libraries.

The low-level linear algebra functions are organized into the following categories:

  • BLAS Level 1 Functions

  • BLAS Level 2 Functions

  • BLAS Level 3 Functions

  • LAPACK Functions

Before using any of the functions listed in this module, the Einsums BLAS subsystem needs to be initialized. This is done with the following function:

void einsums::blas::initialize()#

Initializes the underlying BLAS and LAPACK library.

Handles any initialization that the underlying BLAS implementation requires. For example, a GPU implementation would likely need to obtain a device handle to run. That would be handled by this function.

You typically will not need to call this function manually. einsums::initialize() will handle calling this function for you.

The BLAS subsystem should be finalized when you are done using the low-level linear algebra functions.

void einsums::blas::finalize()#

Handles any shutdown procedure needed by the BLAS implementation.

BLAS Level 1 Functions#

BLAS Level 2 Functions#

BLAS Level 3 Functions#

BLAS Level 3 routines perform matrix-matrix operations, such as matrix-matrix multiplication, rank-k update, and solutions of triangular systems.

The following BLAS Level 3 functions are available:

template<typename T>
void einsums::blas::gemm(char transa, char transb, blas_int m, blas_int n, blas_int k, T alpha, const T *a, blas_int lda, const T *b, blas_int ldb, T beta, T *c, blas_int ldc)#

Perform a General Matrix Multiply (GEMM) operation.

This function computes the product of two matrices,

\[ C = alpha * A * B + beta * C, \]
where A, B, and C are matrices, and alpha and beta are scalar values.

Note

The function performs one of the following matrix operations:

  • If transA is ‘N’ or ‘n’ and transB is ‘N’ or ‘n’: \(C = alpha * A * B + beta * C\)

  • If transA is ‘N’ or ‘n’ and transB is ‘T’ or ‘t’: \(C = alpha * A * B^T + beta * C\)

  • If transA is ‘T’ or ‘t’ and transB is ‘N’ or ‘n’: \(C = alpha * A^T * B + beta * C\)

  • If transA is ‘T’ or ‘t’ and transB is ‘T’ or ‘t’: \(C = alpha * A^T * B^T + beta * C\)

  • If transA is ‘C’ or ‘c’ and transB is ‘N’ or ‘n’: \(C = alpha * A^H * B + beta * C\)

  • If transA is ‘C’ or ‘c’ and transB is ‘T’ or ‘t’: \(C = alpha * A^H * B^T + beta * C\)

Template Parameters:

T – The datatype of the GEMM.

Parameters:
  • transa – Whether to transpose matrix a :

    • ’N’ or ‘n’ for no transpose,

    • ’T’ or ‘t’ for transpose,

    • ’C’ or ‘c’ for conjugate transpose.

  • transb – Whether to transpose matrix b .

  • m – The number of rows in matrix A and C.

  • n – The number of columns in matrix B and C.

  • k – The number of columns in matrix A and rows in matrix B.

  • alpha – The scalar alpha.

  • a – A pointer to the matrix A with dimensions (lda, k) when transa is ‘N’ or ‘n’, and (lda, m) otherwise.

  • lda – Leading dimension of A, specifying the distance between two consecutive columns.

  • b – A pointer to the matrix B with dimensions (ldb, n) when transB is ‘N’ or ‘n’, and (ldb, k) otherwise.

  • ldb – Leading dimension of B, specifying the distance between two consecutive columns.

  • beta – The scalar beta.

  • c – A pointer to the matrix C with dimensions (ldc, n).

  • ldc – Leading dimension of C, specifying the distance between two consecutive columns.

Returns:

None.

LAPACK Functions#

To Be Classified#