Note: this is documentation for an old release. View the latest documentation at docs.fenicsproject.org/basix/v0.9.0/cpp/namespacebasix_1_1math.html

Basix 0.7.0

Home     Installation     Demos     C++ docs     Python docs

Functions
basix::math Namespace Reference

Functions

template<typename U , typename V >
std::pair< std::vector< typename U::value_type >, std::array< std::size_t, 2 > > outer (const U &u, const V &v)
 Compute the outer product of vectors u and v. More...
 
template<typename U , typename V >
std::array< typename U::value_type, 3 > cross (const U &u, const V &v)
 
template<std::floating_point T>
std::pair< std::vector< T >, std::vector< T > > eigh (std::span< const T > A, std::size_t n)
 
template<std::floating_point T>
std::vector< T > solve (MDSPAN_IMPL_STANDARD_NAMESPACE::mdspan< const T, MDSPAN_IMPL_STANDARD_NAMESPACE::dextents< std::size_t, 2 >> A, MDSPAN_IMPL_STANDARD_NAMESPACE::mdspan< const T, MDSPAN_IMPL_STANDARD_NAMESPACE::dextents< std::size_t, 2 >> B)
 
template<std::floating_point T>
bool is_singular (MDSPAN_IMPL_STANDARD_NAMESPACE::mdspan< const T, MDSPAN_IMPL_STANDARD_NAMESPACE::dextents< std::size_t, 2 >> A)
 
template<std::floating_point T>
std::vector< std::size_t > transpose_lu (std::pair< std::vector< T >, std::array< std::size_t, 2 >> &A)
 
template<typename U , typename V , typename W >
void dot (const U &A, const V &B, W &&C)
 
template<std::floating_point T>
std::vector< T > eye (std::size_t n)
 
template<std::floating_point T>
void orthogonalise (MDSPAN_IMPL_STANDARD_NAMESPACE::mdspan< T, MDSPAN_IMPL_STANDARD_NAMESPACE::dextents< std::size_t, 2 >> wcoeffs, std::size_t start=0)
 

Detailed Description

Mathematical functions

Note
The functions in this namespace are designed to be called multiple times at runtime, so their performance is critical.

Function Documentation

◆ cross()

template<typename U , typename V >
std::array<typename U::value_type, 3> basix::math::cross ( const U &  u,
const V &  v 
)

Compute the cross product u x v

Parameters
uThe first vector. It must has size 3.
vThe second vector. It must has size 3.
Returns
The cross product u x v. The type will be the same as u.

◆ dot()

template<typename U , typename V , typename W >
void basix::math::dot ( const U &  A,
const V &  B,
W &&  C 
)

Compute C = A * B

Parameters
[in]AInput matrix
[in]BInput matrix
[out]COutput matrix. Must be sized correctly before calling this function.

◆ eigh()

template<std::floating_point T>
std::pair<std::vector<T>, std::vector<T> > basix::math::eigh ( std::span< const T >  A,
std::size_t  n 
)

Compute the eigenvalues and eigenvectors of a square Hermitian matrix A

Parameters
[in]AInput matrix, row-major storage
[in]nNumber of rows
Returns
Eigenvalues (0) and eigenvectors (1). The eigenvector array uses column-major storage, which each column being an eigenvector.
Precondition
The matrix A must be symmetric

◆ eye()

template<std::floating_point T>
std::vector<T> basix::math::eye ( std::size_t  n)

Build an identity matrix

Parameters
[in]nThe number of rows/columns
Returns
Identity matrix using row-major storage

◆ is_singular()

template<std::floating_point T>
bool basix::math::is_singular ( MDSPAN_IMPL_STANDARD_NAMESPACE::mdspan< const T, MDSPAN_IMPL_STANDARD_NAMESPACE::dextents< std::size_t, 2 >>  A)

Check if A is a singular matrix

Parameters
[in]AThe matrix
Returns
A bool indicating if the matrix is singular

◆ orthogonalise()

template<std::floating_point T>
void basix::math::orthogonalise ( MDSPAN_IMPL_STANDARD_NAMESPACE::mdspan< T, MDSPAN_IMPL_STANDARD_NAMESPACE::dextents< std::size_t, 2 >>  wcoeffs,
std::size_t  start = 0 
)

Orthogonalise the rows of a matrix (in place)

Parameters
[in]wcoeffsThe matrix
[in]startThe row to start from. The rows before this should already be orthogonal

◆ outer()

template<typename U , typename V >
std::pair<std::vector<typename U::value_type>, std::array<std::size_t, 2> > basix::math::outer ( const U &  u,
const V &  v 
)

Compute the outer product of vectors u and v.

Parameters
uThe first vector
vThe second vector
Returns
The outer product. The type will be the same as u.

◆ solve()

template<std::floating_point T>
std::vector<T> basix::math::solve ( MDSPAN_IMPL_STANDARD_NAMESPACE::mdspan< const T, MDSPAN_IMPL_STANDARD_NAMESPACE::dextents< std::size_t, 2 >>  A,
MDSPAN_IMPL_STANDARD_NAMESPACE::mdspan< const T, MDSPAN_IMPL_STANDARD_NAMESPACE::dextents< std::size_t, 2 >>  B 
)

Solve A X = B

Parameters
[in]AThe matrix
[in]BRight-hand side matrix/vector
Returns
A^{-1} B

◆ transpose_lu()

template<std::floating_point T>
std::vector<std::size_t> basix::math::transpose_lu ( std::pair< std::vector< T >, std::array< std::size_t, 2 >> &  A)

Compute the LU decomposition of the transpose of a square matrix A

Parameters
[in,out]AThe matrix
Returns
The LU permutation, in prepared format (see basix::precompute::prepare_permutation)