Skip to content

Namespace ae108::tensor

Namespace List > ae108 > tensor

Multi dimensional arrays based on std::array. More...

Classes

Type Name
struct NDArray <class T, D>
Eigen based N-dimensional array class.

Public Types

Type Name
typedef typename detail::TensorImpl< T, Sizes... >::type Tensor
An alias for an array of arrays. For instance, in the case of a matrix, the first size parameter is the number of rows and the second size parameter is the number of columns.

Public Functions

Type Name
Eigen::Map< Eigen::Matrix< ValueType_, Rows_, Cols_,(Rows_==1 &&Cols_ > 1) ? Eigen::RowMajor :Eigen::ColMajor > > as_matrix_of_columns (std::array< std::array< ValueType_, Rows_ >, Cols_ > & data)
Interprets the input as a an array of colums and returns an Eigen matrix.
Eigen::Map< const Eigen::Matrix< ValueType_, Rows_, Cols_,(Rows_==1 &&Cols_ > 1) ? Eigen::RowMajor :Eigen::ColMajor > > as_matrix_of_columns (const std::array< std::array< ValueType_, Rows_ >, Cols_ > & data)
Interprets the input as a an array of colums and returns a constant Eigen matrix.
Eigen::Map< Eigen::Matrix< ValueType_, Rows_, Cols_,(Cols_==1 &&Rows_ !=1) ? Eigen::ColMajor :Eigen::RowMajor > > as_matrix_of_rows (std::array< std::array< ValueType_, Cols_ >, Rows_ > & data) noexcept
Interprets the input as a an array of colums and returns an Eigen matrix.
Eigen::Map< const Eigen::Matrix< ValueType_, Rows_, Cols_,(Cols_==1 &&Rows_ !=1) ? Eigen::ColMajor :Eigen::RowMajor > > as_matrix_of_rows (const std::array< std::array< ValueType_, Cols_ >, Rows_ > & data) noexcept
Interprets the input as a an array of colums and returns a constant Eigen matrix.
Eigen::Map< Eigen::Matrix< ValueType_, A_ *B_, C_ *D_,(C_ *D_==1 &&A_ *B_ !=1) ? Eigen::ColMajor :Eigen::RowMajor > > as_two_tensor (std::array< std::array< std::array< std::array< ValueType_, D_ >, C_ >, B_ >, A_ > & data)
Interprets the input 4-tensor as a row-major 2-tensor matrix.
Eigen::Map< const Eigen::Matrix< ValueType_, A_ *B_, C_ *D_,(C_ *D_==1 &&A_ *B_ !=1) ? Eigen::ColMajor :Eigen::RowMajor > > as_two_tensor (const std::array< std::array< std::array< std::array< ValueType_, D_ >, C_ >, B_ >, A_ > & data)
Interprets the input 4-tensor as a row-major 2-tensor matrix.
Eigen::Map< Eigen::Matrix< ValueType_, Rows_, 1 > > as_vector (std::array< ValueType_, Rows_ > & data)
Interprets the input as a vector and returns an Eigen vector.
Eigen::Map< const Eigen::Matrix< ValueType_, Rows_, 1 > > as_vector (const std::array< ValueType_, Rows_ > & data)
Interprets the input as a vector and returns a constant Eigen vector.
Eigen::Map< Eigen::Matrix< ValueType_, Rows_ *Cols_, 1 > > as_vector (std::array< std::array< ValueType_, Cols_ >, Rows_ > & data)
Interprets the input as a vector of columns stacked on top of each other and returns an Eigen vector.
Eigen::Map< const Eigen::Matrix< ValueType_, Rows_ *Cols_, 1 > > as_vector (const std::array< std::array< ValueType_, Cols_ >, Rows_ > & data)
Interprets the input as a vector of columns stacked on top of each other and returns a constant Eigen vector.
Eigen::Matrix< typename EigenVector::Scalar, D2, D3 > contract (const EigenVector & v, const tensor::NDArray< typename EigenVector::Scalar, EigenVector::SizeAtCompileTime, D2, D3 > & tensor)
Multiply a 3-tensor with a vector from the left ( v_k t_kij in Einstein summation notation).
tensor::NDArray< T, D1, D2, D4 > contract (const tensor::NDArray< T, D1, D2, D3 > & tensor, const Eigen::Matrix< T, D3, D4 > & m)
Multiply a 3-tensor with a matrix from the right ( t_ijl m_lk in Einstein summation notation).
tensor::NDArray< T, D1, D3, D4 > contract (const Eigen::Matrix< T, D1, D2 > & m, const tensor::NDArray< T, D2, D3, D4 > & tensor)
Multiply a 3-tensor with a matrix from the left ( m_il t_ljk in Einstein summation notation).
tensor::NDArray< typename EigenVector::Scalar, 3, N, M > cross (const EigenVector & v, const NDArray< typename EigenVector::Scalar, 3, N, M > & tensor)
Cross product of a vector to the first index of a tensor ( eps_ilm v_l t_mjk in Einstein summation notation).
std::decay_t< T > differentiate (F && f, T && t)
Calls a Boost library function to perform finite difference differentiation. Only supports differentiation of real-valued functions of one real-valued parameter.
Eigen::Matrix< typename VectorType::Scalar, decltype(std::declval< F >()(std::declval< VectorType >()))::SizeAtCompileTime, VectorType::SizeAtCompileTime > jacobian (const F f, const VectorType & x0)
Compute the jacobian of a vector valued function f atx0 .
K jacobian (const F f, const std::array< T, K > & x0)
NDArray< typenamedetail::VectorTrait< VectorType >::ScalarType, decltype(std::declval< F >()(std::declval< VectorType >()))::RowsAtCompileTime, decltype(std::declval< F >()(std::declval< VectorType >()))::ColsAtCompileTime, detail::VectorTrait< VectorType >::SIZE matrix_derivative (const F f, const VectorType & x0)
Compute the jacobian of a vector valued function f atx0 .
double midpoint_formula (const Tensor< double, 2 > & x, const Tensor< double, 2 > & delta, const double L)
Mid-point formula to achieve a better numerical conditioning for |x+delta| - |x| = <2x + delta, delta> / (|x+delta| + |x|) .
double midpoint_formula (const Tensor< double, 3 > & x, const Tensor< double, 3 > & delta, const double L)
NDArray< T, D... > operator* (const T x, const NDArray< T, D... > & t)
template NDArray< double, 3, 3, 3 > operator* (const double x, const NDArray< double, 3, 3, 3 > & t)
NDArray< T, D... > operator+ (const NDArray< T, D... > & t, const NDArray< T, D... > & u)
template NDArray< double, 3, 3, 3 > operator+ (const NDArray< double, 3, 3, 3 > & t, const NDArray< double, 3, 3, 3 > & u)
NDArray< T, D... > operator- (const NDArray< T, D... > & t, const NDArray< T, D... > & u)
template NDArray< double, 3, 3, 3 > operator- (const NDArray< double, 3, 3, 3 > & t, const NDArray< double, 3, 3, 3 > & u)
NDArray< T, D... > operator- (const NDArray< T, D... > & t)
template NDArray< double, 3, 3, 3 > operator- (const NDArray< double, 3, 3, 3 > & t)
tensor::NDArray< typename EigenVector::Scalar, EigenMatrix::RowsAtCompileTime, EigenMatrix::ColsAtCompileTime, EigenVector::RowsAtCompileTime > outer (const EigenMatrix & m, const EigenVector & v)
Outer product of a matrix and a vector ( m_ij v_k ).
tensor::NDArray< typename EigenVector::Scalar, EigenVector::RowsAtCompileTime, EigenMatrix::RowsAtCompileTime, EigenMatrix::ColsAtCompileTime > outer (const EigenVector & v, const EigenMatrix & m)
Outer product of a vector and a matrix ( v_i m_jk ).
tensor::NDArray< typename EigenVector::Scalar, EigenMatrix::RowsAtCompileTime, EigenVector::RowsAtCompileTime, EigenMatrix::ColsAtCompileTime > outer_middle (const EigenMatrix & m, const EigenVector & v)
Outer product of a matrix and a vector ( m_ik v_j ).
tensor::NDArray< T, D1, D2, D1 > symmetrize_ik (const tensor::NDArray< T, D1, D2, D1 > & tensor)
Return a 3-tensor t with entriest_ijk = tensor_ijk + tensor_kji .
template tensor::NDArray< double, 3, 3, 3 > symmetrize_ik (const tensor::NDArray< double, 3, 3, 3 > & tensor)
tensor::NDArray< T, D1, D2, D2 > symmetrize_jk (const tensor::NDArray< T, D1, D2, D2 > & tensor)
Return a 3-tensor t with entriest_ijk = tensor_ijk + tensor_ikj .
template tensor::NDArray< double, 3, 3, 3 > symmetrize_jk (const tensor::NDArray< double, 3, 3, 3 > & tensor)
std::array< typename EigenType_::Scalar, EigenType_::ColsAtCompileTime *EigenType_::RowsAtCompileTime > to_array (const EigenType_ & vec)
Converts an Eigen column or row vector to a std::array.

Detailed Description

Library about multi dimensional arrays ae108::tensor::Tensor which Eigen can operate on via ae108::tensor::as_vector / ae108::tensor::as_matrix_of_columns / ae108::tensor::as_matrix_of_rows views.

Public Types Documentation

typedef Tensor

An alias for an array of arrays. For instance, in the case of a matrix, the first size parameter is the number of rows and the second size parameter is the number of columns.

using ae108::tensor::Tensor = typedef typename detail::TensorImpl<T, Sizes...>::type;

Template parameters:

  • T The value type.

Remark:

The values are stored in row-major format. For instance, a matrix is stored as an array of rows.


Public Functions Documentation

function as_matrix_of_columns

Interprets the input as a an array of colums and returns an Eigen matrix.

template<class ValueType_, std::size_t Rows_, std::size_t Cols_>
Eigen::Map< Eigen::Matrix< ValueType_, Rows_, Cols_,(Rows_==1 &&Cols_ > 1) ? Eigen::RowMajor :Eigen::ColMajor > > ae108::tensor::as_matrix_of_columns (
    std::array< std::array< ValueType_, Rows_ >, Cols_ > & data
) 


function as_matrix_of_columns

Interprets the input as a an array of colums and returns a constant Eigen matrix.

template<class ValueType_, std::size_t Rows_, std::size_t Cols_>
Eigen::Map< const Eigen::Matrix< ValueType_, Rows_, Cols_,(Rows_==1 &&Cols_ > 1) ? Eigen::RowMajor :Eigen::ColMajor > > ae108::tensor::as_matrix_of_columns (
    const std::array< std::array< ValueType_, Rows_ >, Cols_ > & data
) 


function as_matrix_of_rows

Interprets the input as a an array of colums and returns an Eigen matrix.

template<class ValueType_, std::size_t Rows_, std::size_t Cols_>
Eigen::Map< Eigen::Matrix< ValueType_, Rows_, Cols_,(Cols_==1 &&Rows_ !=1) ? Eigen::ColMajor :Eigen::RowMajor > > ae108::tensor::as_matrix_of_rows (
    std::array< std::array< ValueType_, Cols_ >, Rows_ > & data
) noexcept


function as_matrix_of_rows

Interprets the input as a an array of colums and returns a constant Eigen matrix.

template<class ValueType_, std::size_t Rows_, std::size_t Cols_>
Eigen::Map< const Eigen::Matrix< ValueType_, Rows_, Cols_,(Cols_==1 &&Rows_ !=1) ? Eigen::ColMajor :Eigen::RowMajor > > ae108::tensor::as_matrix_of_rows (
    const std::array< std::array< ValueType_, Cols_ >, Rows_ > & data
) noexcept


function as_two_tensor

Interprets the input 4-tensor as a row-major 2-tensor matrix.

template<class ValueType_, std::size_t A_, std::size_t B_, std::size_t C_, std::size_t D_>
Eigen::Map< Eigen::Matrix< ValueType_, A_ *B_, C_ *D_,(C_ *D_==1 &&A_ *B_ !=1) ? Eigen::ColMajor :Eigen::RowMajor > > ae108::tensor::as_two_tensor (
    std::array< std::array< std::array< std::array< ValueType_, D_ >, C_ >, B_ >, A_ > & data
) 


function as_two_tensor

Interprets the input 4-tensor as a row-major 2-tensor matrix.

template<class ValueType_, std::size_t A_, std::size_t B_, std::size_t C_, std::size_t D_>
Eigen::Map< const Eigen::Matrix< ValueType_, A_ *B_, C_ *D_,(C_ *D_==1 &&A_ *B_ !=1) ? Eigen::ColMajor :Eigen::RowMajor > > ae108::tensor::as_two_tensor (
    const std::array< std::array< std::array< std::array< ValueType_, D_ >, C_ >, B_ >, A_ > & data
) 


function as_vector

Interprets the input as a vector and returns an Eigen vector.

template<class ValueType_, std::size_t Rows_>
Eigen::Map< Eigen::Matrix< ValueType_, Rows_, 1 > > ae108::tensor::as_vector (
    std::array< ValueType_, Rows_ > & data
) 


function as_vector

Interprets the input as a vector and returns a constant Eigen vector.

template<class ValueType_, std::size_t Rows_>
Eigen::Map< const Eigen::Matrix< ValueType_, Rows_, 1 > > ae108::tensor::as_vector (
    const std::array< ValueType_, Rows_ > & data
) 


function as_vector

Interprets the input as a vector of columns stacked on top of each other and returns an Eigen vector.

template<class ValueType_, std::size_t Rows_, std::size_t Cols_>
Eigen::Map< Eigen::Matrix< ValueType_, Rows_ *Cols_, 1 > > ae108::tensor::as_vector (
    std::array< std::array< ValueType_, Cols_ >, Rows_ > & data
) 


function as_vector

Interprets the input as a vector of columns stacked on top of each other and returns a constant Eigen vector.

template<class ValueType_, std::size_t Rows_, std::size_t Cols_>
Eigen::Map< const Eigen::Matrix< ValueType_, Rows_ *Cols_, 1 > > ae108::tensor::as_vector (
    const std::array< std::array< ValueType_, Cols_ >, Rows_ > & data
) 


function contract

Multiply a 3-tensor with a vector from the left ( v_k t_kij in Einstein summation notation).

template<class EigenVector, std::size_t D2, std::size_t D3>
Eigen::Matrix< typename EigenVector::Scalar, D2, D3 > ae108::tensor::contract (
    const EigenVector & v,
    const tensor::NDArray < typename EigenVector::Scalar, EigenVector::SizeAtCompileTime, D2, D3 > & tensor
) 


function contract

Multiply a 3-tensor with a matrix from the right ( t_ijl m_lk in Einstein summation notation).

template<class T, std::size_t D1, std::size_t D2, std::size_t D3, std::size_t D4>
tensor::NDArray < T, D1, D2, D4 > ae108::tensor::contract (
    const tensor::NDArray < T, D1, D2, D3 > & tensor,
    const Eigen::Matrix< T, D3, D4 > & m
) 


function contract

Multiply a 3-tensor with a matrix from the left ( m_il t_ljk in Einstein summation notation).

template<class T, std::size_t D1, std::size_t D2, std::size_t D3, std::size_t D4>
tensor::NDArray < T, D1, D3, D4 > ae108::tensor::contract (
    const Eigen::Matrix< T, D1, D2 > & m,
    const tensor::NDArray < T, D2, D3, D4 > & tensor
) 


function cross

Cross product of a vector to the first index of a tensor ( eps_ilm v_l t_mjk in Einstein summation notation).

template<class EigenVector, std::size_t N, std::size_t M>
tensor::NDArray < typename EigenVector::Scalar, 3, N, M > ae108::tensor::cross (
    const EigenVector & v,
    const NDArray < typename EigenVector::Scalar, 3, N, M > & tensor
) 


function differentiate

Calls a Boost library function to perform finite difference differentiation. Only supports differentiation of real-valued functions of one real-valued parameter.

template<class T, class F>
std::decay_t< T > ae108::tensor::differentiate (
    F && f,
    T && t
) 


function jacobian

Compute the jacobian of a vector valued function f atx0 .

template<class F, class VectorType>
Eigen::Matrix< typename VectorType::Scalar, decltype(std::declval< F >()(std::declval< VectorType >()))::SizeAtCompileTime, VectorType::SizeAtCompileTime > ae108::tensor::jacobian (
    const F f,
    const VectorType & x0
) 


function jacobian

K ae108::tensor::jacobian (
    const F f,
    const std::array< T, K > & x0
) 

function matrix_derivative

Compute the jacobian of a vector valued function f atx0 .

template<class F, class VectorType>
NDArray < typenamedetail::VectorTrait< VectorType >::ScalarType, decltype(std::declval< F >()(std::declval< VectorType >()))::RowsAtCompileTime, decltype(std::declval< F >()(std::declval< VectorType >()))::ColsAtCompileTime, detail::VectorTrait< VectorType >::SIZE ae108::tensor::matrix_derivative (
    const F f,
    const VectorType & x0
) 


function midpoint_formula

Mid-point formula to achieve a better numerical conditioning for |x+delta| - |x| = <2x + delta, delta> / (|x+delta| + |x|) .

double ae108::tensor::midpoint_formula (
    const Tensor < double, 2 > & x,
    const Tensor < double, 2 > & delta,
    const double L
) 

Parameters:

  • L L = |x| (assumed to be precomputed).

function midpoint_formula

double ae108::tensor::midpoint_formula (
    const Tensor < double, 3 > & x,
    const Tensor < double, 3 > & delta,
    const double L
) 

function operator*

template<class T, std::size_t... D>
NDArray < T, D... > ae108::tensor::operator* (
    const T x,
    const NDArray < T, D... > & t
) 

function operator*

template NDArray < double, 3, 3, 3 > ae108::tensor::operator* (
    const double x,
    const NDArray < double, 3, 3, 3 > & t
) 

function operator+

template<class T, std::size_t... D>
NDArray < T, D... > ae108::tensor::operator+ (
    const NDArray < T, D... > & t,
    const NDArray < T, D... > & u
) 

function operator+

template NDArray < double, 3, 3, 3 > ae108::tensor::operator+ (
    const NDArray < double, 3, 3, 3 > & t,
    const NDArray < double, 3, 3, 3 > & u
) 

function operator-

template<class T, std::size_t... D>
NDArray < T, D... > ae108::tensor::operator- (
    const NDArray < T, D... > & t,
    const NDArray < T, D... > & u
) 

function operator-

template NDArray < double, 3, 3, 3 > ae108::tensor::operator- (
    const NDArray < double, 3, 3, 3 > & t,
    const NDArray < double, 3, 3, 3 > & u
) 

function operator-

template<class T, std::size_t... D>
NDArray < T, D... > ae108::tensor::operator- (
    const NDArray < T, D... > & t
) 

function operator-

template NDArray < double, 3, 3, 3 > ae108::tensor::operator- (
    const NDArray < double, 3, 3, 3 > & t
) 

function outer

Outer product of a matrix and a vector ( m_ij v_k ).

template<class EigenVector, class EigenMatrix>
tensor::NDArray < typename EigenVector::Scalar, EigenMatrix::RowsAtCompileTime, EigenMatrix::ColsAtCompileTime, EigenVector::RowsAtCompileTime > ae108::tensor::outer (
    const EigenMatrix & m,
    const EigenVector & v
) 


function outer

Outer product of a vector and a matrix ( v_i m_jk ).

template<class EigenVector, class EigenMatrix>
tensor::NDArray < typename EigenVector::Scalar, EigenVector::RowsAtCompileTime, EigenMatrix::RowsAtCompileTime, EigenMatrix::ColsAtCompileTime > ae108::tensor::outer (
    const EigenVector & v,
    const EigenMatrix & m
) 


function outer_middle

Outer product of a matrix and a vector ( m_ik v_j ).

template<class EigenVector, class EigenMatrix>
tensor::NDArray < typename EigenVector::Scalar, EigenMatrix::RowsAtCompileTime, EigenVector::RowsAtCompileTime, EigenMatrix::ColsAtCompileTime > ae108::tensor::outer_middle (
    const EigenMatrix & m,
    const EigenVector & v
) 


function symmetrize_ik

Return a 3-tensor t with entriest_ijk = tensor_ijk + tensor_kji .

template<class T, std::size_t D1, std::size_t D2>
tensor::NDArray < T, D1, D2, D1 > ae108::tensor::symmetrize_ik (
    const tensor::NDArray < T, D1, D2, D1 > & tensor
) 


function symmetrize_ik

template tensor::NDArray < double, 3, 3, 3 > ae108::tensor::symmetrize_ik (
    const tensor::NDArray < double, 3, 3, 3 > & tensor
) 

function symmetrize_jk

Return a 3-tensor t with entriest_ijk = tensor_ijk + tensor_ikj .

template<class T, std::size_t D1, std::size_t D2>
tensor::NDArray < T, D1, D2, D2 > ae108::tensor::symmetrize_jk (
    const tensor::NDArray < T, D1, D2, D2 > & tensor
) 


function symmetrize_jk

template tensor::NDArray < double, 3, 3, 3 > ae108::tensor::symmetrize_jk (
    const tensor::NDArray < double, 3, 3, 3 > & tensor
) 

function to_array

Converts an Eigen column or row vector to a std::array.

template<class EigenType_>
std::array< typename EigenType_::Scalar, EigenType_::ColsAtCompileTime *EigenType_::RowsAtCompileTime > ae108::tensor::to_array (
    const EigenType_ & vec
) 



The documentation for this class was generated from the following file tensor/src/include/ae108/tensor/as_matrix_of_columns.h