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

Detailed Description

Various other linear algebra related operations.

Functions

template<Scalar T, typename LP = F_layout>
auto nda::linalg::get_permutation_matrix (Vector auto const &ipiv, int m)
 Get the permutation matrix \( \mathbf{P} \) from the pivot indices returned by nda::lapack::getrf or other LAPACK routines.
template<Scalar T, typename LP = F_layout>
auto nda::linalg::get_permutation_matrix (Vector auto const &sigma, bool column_permutations=false)
 Get the permutation matrix \( \mathbf{P} \) from a permutation vector \( \mathbf{\sigma} \).
auto nda::linalg::get_permutation_vector (Vector auto const &ipiv, int m)
 Get the permutation vector \( \mathbf{\sigma} \) from the pivot indices returned by nda::lapack::getrf or other LAPACK routines.

Function Documentation

◆ get_permutation_matrix() [1/2]

template<Scalar T, typename LP = F_layout>
auto nda::linalg::get_permutation_matrix ( Vector auto const & ipiv,
int m )

#include <nda/linalg/utils.hpp>

Get the permutation matrix \( \mathbf{P} \) from the pivot indices returned by nda::lapack::getrf or other LAPACK routines.

It simply calls nda::linalg::get_permutation_vector to get the permutation vector from the pivot indices, and then calls nda::linalg::get_permutation_matrix to get the permutation matrix.

Note
The input vector is required to satisfy nda::mem::have_host_compatible_addr_space.
Template Parameters
Tnda::Scalar value type of the permutation matrix.
LPPolicy determining the memory layout of the permutation matrix.
Parameters
ipivnda::Vector containing the pivot indices returned by nda::lapack::getrf.
mNumber of rows/columns of the square permutation matrix \( \mathbf{P} \).
Returns
Permutation matrix \( \mathbf{P} \) as an nda::matrix with value type T and layout LP.

Definition at line 98 of file utils.hpp.

◆ get_permutation_matrix() [2/2]

template<Scalar T, typename LP = F_layout>
auto nda::linalg::get_permutation_matrix ( Vector auto const & sigma,
bool column_permutations = false )

#include <nda/linalg/utils.hpp>

Get the permutation matrix \( \mathbf{P} \) from a permutation vector \( \mathbf{\sigma} \).

The function constructs the permutation matrix \( \mathbf{P} \) of size \( m \times m \) from the permutation vector \( \sigma \) of size \( m \).

The permutation matrix only has the following non-zero elements (for all \( i = 0, 1, \ldots, m - 1 \)):

  • \( \mathbf{P}_{i, \sigma_i} = 1 \) for row permutations,
  • \( \mathbf{P}_{\sigma_i, i} = 1 \) for column permutations.
Note
The input vector is required to satisfy nda::mem::have_host_compatible_addr_space.
Template Parameters
Tnda::Scalar value type of the permutation matrix.
LPPolicy determining the memory layout of the permutation matrix.
Parameters
sigmanda::Vector containing the permutation vector with values \( \in \{0, 1, \ldots, m - 1 \} \).
column_permutationsIf true, constructs the permutation matrix for column permutations.
Returns
Permutation matrix \( \mathbf{P} \) as an nda::matrix with value type T and layout LP.

Definition at line 74 of file utils.hpp.

◆ get_permutation_vector()

auto nda::linalg::get_permutation_vector ( Vector auto const & ipiv,
int m )

#include <nda/linalg/utils.hpp>

Get the permutation vector \( \mathbf{\sigma} \) from the pivot indices returned by nda::lapack::getrf or other LAPACK routines.

The function constructs the permutation vector \( \mathbf{\sigma} \) of size \( m \) from the pivot index vector ipiv of size \( l \). Starting from an identity permutation, i.e. \( \mathbf{\sigma} = (0, 1, \ldots, m - 1) \), it interchanges \( \sigma_i \) with \( \sigma_{\mathrm{ipiv}_i - 1} \) for all \( i = 0, 1, \dots, l - 1 \).

Note
The input vector is required to satisfy nda::mem::have_host_compatible_addr_space.
Parameters
ipivnda::Vector containing the pivot indices returned by nda::lapack::getrf.
mNumber of elements of the permutation vector \( \mathbf{\sigma} \).
Returns
Permutation vector \( \mathbf{\sigma} \) as an nda::vector.

Definition at line 47 of file utils.hpp.