Skip to content

mod_pure_linalg

Lines: 135 | Visibility: private

Pure linear algebra functions including easy-to-use interfaces to BLAS and LAPACK.

WARNING: may be unstable! The routines in this module should only be used when it is absolutely crucial for performance or code structure that the calling routine is declared as pure. In general, LAPACK routines have side effects and are therefore not declared pure. Use the routines in mod_linalg instead.

author: Alexander Knoll

Dependencies

Uses

module~~mod_pure_linalg~~UsesGraph module~mod_pure_linalg mod_pure_linalg module~mod_precision mod_precision module~mod_pure_linalg->module~mod_precision iso_c_binding iso_c_binding module~mod_precision->iso_c_binding iso_fortran_env iso_fortran_env module~mod_precision->iso_fortran_env

Used By

module~~mod_pure_linalg~~UsedByGraph module~mod_pure_linalg mod_pure_linalg module~mod_sparse_matrices mod_sparse_matrices module~mod_sparse_matrices->module~mod_pure_linalg module~smod_eigenval_and_vectors smod_eigenval_and_vectors module~smod_eigenval_and_vectors->module~mod_pure_linalg module~smod_first_derivative smod_first_derivative module~smod_first_derivative->module~mod_pure_linalg module~smod_first_derivative->module~mod_sparse_matrices

Procedures Summary

Name Type Description
dot Function Compute the dot product of two vectors.
cp_upper_triangle Subroutine
cp_lower_triangle Subroutine
eigenvectors_symmetric_matrix Subroutine diagonalize a symmetric matrix A, only its upper triangle needs to be defined. Here we compute...
eigenvalues_symmetric_matrix Subroutine diagonalize a symmetric matrix A, only its upper triangle needs to be defined. Here we only...
matrix_plus_matrix_times_matrix Subroutine Compute the matrix-matrix product \(C = alpha * A * B + beta * C\) using BLAS where A has...
matrix_transpose_times_matrix_plus_matrix Subroutine Compute the matrix-matrix product \(C = alpha * A * B + beta * C\) using BLAS where A has...
symmetric_matrix_times_matrix_plus_matrix_upper_triangle Subroutine Compute a matrix matrix product for a symmetry matrix A \(C = \alpha * A * B + \beta *C\) using...

Interface Details

interface ddot


interface dlacpy


interface dsyev


interface dgemm


interface dsymm


Procedure Details

function dot

function dot( &
    d, &
    x, &
    y &
)

Compute the dot product of two vectors.

Arguments

  • d : integer [in]– Dimension of `x` and `y`.
  • x : real(DP) (dim: (d)) [in]– Vectors to be multiplied.
  • y : real(DP) (dim: (d)) [in]– Vectors to be multiplied.

Called By

proc~~dot~2~~CalledByGraph proc~dot~2 mod_pure_linalg::dot proc~derived_matrix_and_eigenvectors_to_derived_eigenval mod_sparse_matrices::derived_matrix_and_eigenvectors_to_derived_eigenval proc~derived_matrix_and_eigenvectors_to_derived_eigenval->proc~dot~2 proc~derivative_eval_one_neighbor smod_first_derivative::derivative_eval_one_neighbor proc~derivative_eval_one_neighbor->proc~derived_matrix_and_eigenvectors_to_derived_eigenval proc~derivative_eval_self smod_first_derivative::derivative_eval_self proc~derivative_eval_self->proc~derived_matrix_and_eigenvectors_to_derived_eigenval

subroutine cp_upper_triangle

subroutine cp_upper_triangle( &
    d, &
    mat, &
    copy &
)

Arguments

  • d : integer [in]
  • mat : real(DP) (dim: (d,d)) [in]
  • copy : real(DP) (dim: (d,d)) [out]

Called By

proc~~cp_upper_triangle~2~~CalledByGraph proc~cp_upper_triangle~2 mod_pure_linalg::cp_upper_triangle proc~om_and_eigenvectors smod_eigenval_and_vectors::om_and_eigenvectors proc~om_and_eigenvectors->proc~cp_upper_triangle~2

subroutine cp_lower_triangle

subroutine cp_lower_triangle( &
    d, &
    mat, &
    copy &
)

Arguments

  • d : integer [in]
  • mat : real(DP) (dim: (d,d)) [in]
  • copy : real(DP) (dim: (d,d)) [out]

subroutine eigenvectors_symmetric_matrix

subroutine eigenvectors_symmetric_matrix( &
    d, &
    mat, &
    eval &
)

diagonalize a symmetric matrix A, only its upper triangle needs to be defined. Here we compute eigenvalues and their corresponding eigen- vectors, but only return the eigenvectors.

Arguments

  • d : integer [in]– Dimension of matrix `mat`.
  • mat : real(DP) (dim: (d,d)) [inout]– Matrix to be diagonalized
  • eval : real(DP) (dim: (d)) [out]– Vector of eigenvalues

Called By

proc~~eigenvectors_symmetric_matrix~2~~CalledByGraph proc~eigenvectors_symmetric_matrix~2 mod_pure_linalg::eigenvectors_symmetric_matrix proc~om_and_eigenvectors smod_eigenval_and_vectors::om_and_eigenvectors proc~om_and_eigenvectors->proc~eigenvectors_symmetric_matrix~2

subroutine eigenvalues_symmetric_matrix

subroutine eigenvalues_symmetric_matrix( &
    d, &
    mat, &
    eval &
)

diagonalize a symmetric matrix A, only its upper triangle needs to be defined. Here we only compute eigenvalues, not the eigenvectors, which should be significantly faster.

Arguments

  • d : integer [in]– Dimension of matrix `mat`.
  • mat : real(DP) (dim: (d,d)) [inout]– Matrix to be diagonalized
  • eval : real(DP) (dim: (d)) [out]– Vector of eigenvalues

Called By

proc~~eigenvalues_symmetric_matrix~2~~CalledByGraph proc~eigenvalues_symmetric_matrix~2 mod_pure_linalg::eigenvalues_symmetric_matrix proc~value~2 smod_eigenval_and_vectors::value proc~value~2->proc~eigenvalues_symmetric_matrix~2

subroutine matrix_plus_matrix_times_matrix

subroutine matrix_plus_matrix_times_matrix( &
    m, &
    n, &
    k, &
    alpha, &
    beta, &
    mat_a, &
    mat_b, &
    mat_c &
)

Compute the matrix-matrix product \(C = alpha * A * B + beta * C\) using BLAS where A has dimensions (m, k), B has dimensions (k, n) and C has dimensions (m, n).

Arguments

  • m : integer [in]– Matrix dimensions.
  • n : integer [in]– Matrix dimensions.
  • k : integer [in]– Matrix dimensions.
  • alpha : real(DP) [in]– Scalar factors.
  • beta : real(DP) [in]– Scalar factors.
  • mat_a : real(DP) (dim: (m,k)) [in]– The first matrix to be multiplied.
  • mat_b : real(DP) (dim: (k,n)) [in]– The second matrix to be multiplied.
  • mat_c : real(DP) (dim: (m,n)) [inout]– The result matrix to be added.

Called By

proc~~matrix_plus_matrix_times_matrix~~CalledByGraph proc~matrix_plus_matrix_times_matrix mod_pure_linalg::matrix_plus_matrix_times_matrix proc~derived_matrix_and_eigenvectors_to_derived_eigenval mod_sparse_matrices::derived_matrix_and_eigenvectors_to_derived_eigenval proc~derived_matrix_and_eigenvectors_to_derived_eigenval->proc~matrix_plus_matrix_times_matrix proc~derivative_eval_one_neighbor smod_first_derivative::derivative_eval_one_neighbor proc~derivative_eval_one_neighbor->proc~derived_matrix_and_eigenvectors_to_derived_eigenval proc~derivative_eval_self smod_first_derivative::derivative_eval_self proc~derivative_eval_self->proc~derived_matrix_and_eigenvectors_to_derived_eigenval

subroutine matrix_transpose_times_matrix_plus_matrix

subroutine matrix_transpose_times_matrix_plus_matrix( &
    m, &
    n, &
    k, &
    alpha, &
    beta, &
    mat_a, &
    mat_b, &
    mat_c &
)

Compute the matrix-matrix product \(C = alpha * A * B + beta * C\) using BLAS where A has dimensions (m, k), B has dimensions (k, n) and C has dimensions (m, n). A has the dimensions (k, m) on entry and is transposed during the routine.

Arguments

  • m : integer [in]– Matrix dimensions.
  • n : integer [in]– Matrix dimensions.
  • k : integer [in]– Matrix dimensions.
  • alpha : real(DP) [in]– Scalar factors.
  • beta : real(DP) [in]– Scalar factors.
  • mat_a : real(DP) (dim: (k,m)) [in]– The first matrix to be multiplied.
  • mat_b : real(DP) (dim: (k,n)) [in]– The second matrix to be multiplied.
  • mat_c : real(DP) (dim: (m,n)) [inout]– The result matrix to be added.

Called By

proc~~matrix_transpose_times_matrix_plus_matrix~~CalledByGraph proc~matrix_transpose_times_matrix_plus_matrix mod_pure_linalg::matrix_transpose_times_matrix_plus_matrix proc~derived_matrix_and_eigenvectors_to_derived_eigenval mod_sparse_matrices::derived_matrix_and_eigenvectors_to_derived_eigenval proc~derived_matrix_and_eigenvectors_to_derived_eigenval->proc~matrix_transpose_times_matrix_plus_matrix proc~derivative_eval_one_neighbor smod_first_derivative::derivative_eval_one_neighbor proc~derivative_eval_one_neighbor->proc~derived_matrix_and_eigenvectors_to_derived_eigenval proc~derivative_eval_self smod_first_derivative::derivative_eval_self proc~derivative_eval_self->proc~derived_matrix_and_eigenvectors_to_derived_eigenval

subroutine symmetric_matrix_times_matrix_plus_matrix_upper_triangle

subroutine symmetric_matrix_times_matrix_plus_matrix_upper_triangle( &
    m, &
    n, &
    mat_a, &
    mat_b, &
    mat_c, &
    alpha, &
    beta &
)

Compute a matrix matrix product for a symmetry matrix A \(C = \alpha * A * B + \beta *C\) using BLAS. ATTENTION: Since A is symmetric, only the upper part is filled.

Arguments

  • m : integer [in]– Matrix dimensions.
  • n : integer [in]– Matrix dimensions.
  • mat_a : real(DP) (dim: (m,m)) [in]
  • mat_b : real(DP) (dim: (m,n)) [in]
  • mat_c : real(DP) (dim: (m,n)) [inout]
  • alpha : real(DP) [in]
  • beta : real(DP) [in]

Called By

proc~~symmetric_matrix_times_matrix_plus_matrix_upper_triangle~2~~CalledByGraph proc~symmetric_matrix_times_matrix_plus_matrix_upper_triangle~2 mod_pure_linalg::symmetric_matrix_times_matrix_plus_matrix_upper_triangle proc~derivative_eval_self smod_first_derivative::derivative_eval_self proc~derivative_eval_self->proc~symmetric_matrix_times_matrix_plus_matrix_upper_triangle~2