7#ifndef GMATTENSOR_CARTESIAN3D_H
8#define GMATTENSOR_CARTESIAN3D_H
10#include <xtensor/xadapt.hpp>
11#include <xtensor/xnoalias.hpp>
12#include <xtensor/xrandom.hpp>
13#include <xtensor/xtensor.hpp>
14#include <xtensor/xview.hpp>
26namespace Cartesian3d {
183inline auto Trace(
const T& A);
191template <
class T,
class R>
192inline void trace(
const T& A, R& ret);
214template <
class T,
class R>
225inline auto Det(
const T& A);
233template <
class T,
class R>
234inline void det(
const T& A, R& ret);
252inline auto A2_ddot_B2(
const T& A,
const T& B);
261template <
class T,
class R>
262inline void A2_ddot_B2(
const T& A,
const T& B, R& ret);
284template <
class T,
class R>
285inline void A2s_ddot_B2s(
const T& A,
const T& B, R& ret);
306template <
class T,
class R>
329template <
class T,
class R>
347inline auto Sym(
const T& A);
355template <
class T,
class R>
356inline void sym(
const T& A, R& ret);
366inline auto Inv(
const T& A);
374template <
class T,
class R>
375inline void inv(
const T& A, R& ret);
386inline auto Logs(
const T& A);
394template <
class T,
class R>
395inline void logs(
const T& A, R& ret);
420template <
class T,
class R>
439inline auto A2_dot_B2(
const T& A,
const T& B);
448template <
class T,
class R>
449inline void A2_dot_B2(
const T& A,
const T& B, R& ret);
476template <
class T,
class R>
477inline void A2_dyadic_B2(
const T& A,
const T& B, R& ret);
494template <
class T,
class U>
495inline auto A4_ddot_B2(
const T& A,
const U& B);
504template <
class T,
class U,
class R>
505inline void A4_ddot_B2(
const T& A,
const U& B, R& ret);
522template <
class T,
class U>
523inline auto A4_dot_B2(
const T& A,
const U& B);
532template <
class T,
class U,
class R>
533inline void A4_dot_B2(
const T& A,
const U& B, R& ret);
544 return detail::impl_A2<T, 3>::toSizeT0(A.shape());
556 return detail::impl_A4<T, 3>::toSizeT0(A.shape());
568 return detail::impl_A2<T, 3>::toShapeT0(A.shape());
580 return detail::impl_A4<T, 3>::toShapeT0(A.shape());
597 constexpr static std::size_t
rank = N;
613 const std::array<size_t, N>&
shape()
const;
691 void init(
const std::array<size_t, N>&
shape);
732inline void O2(T* ret);
740inline void O4(T* ret);
748inline void I2(T* ret);
756inline void II(T* ret);
764inline void I4(T* ret);
772inline void I4rt(T* ret);
780inline void I4s(T* ret);
788inline void I4d(T* ret);
797inline T
Trace(
const T* A);
815inline T
Det(
const T* A);
824inline void sym(
const T* A, T* ret);
834inline T
Inv(
const T* A, T* ret);
894inline void A2_dyadic_B2(
const T* A,
const T* B, T* ret);
904inline void A4_dot_B2(
const T* A,
const T* B, T* ret);
914inline void A2_dot_B2(
const T* A,
const T* B, T* ret);
933inline void A4_ddot_B2(
const T* A,
const T* B, T* ret);
982void eigs(
const T* A, T* vec, T* val);
993void from_eigs(
const T* vec,
const T* val, T* ret);
1002void logs(
const T* A, T* ret);
Implementation of GMatTensor/Cartesian3d.h.
Implementation of GMatTensor/Cartesian3d.h.
array_type::tensor< double, N+4 > I4d() const
Array of Cartesian3d::I4d()
const std::array< size_t, N+2 > & shape_tensor2() const
Shape of the array of second-order tensors.
std::array< size_t, N+4 > m_shape_tensor4
Shape of an array of 4th-order tensors == [m_shape, 3, 3, 3, 3].
array_type::tensor< double, N+4 > I4s() const
Array of Cartesian3d::I4s()
array_type::tensor< double, N+4 > I4() const
Array of Cartesian3d::I4()
static constexpr size_t m_stride_tensor4
Storage stride for 4th-order tensors ( ).
static constexpr size_t m_ndim
Number of dimensions of tensors.
std::array< size_t, N > m_shape
Shape of the array (of scalars).
const std::array< size_t, N > & shape() const
Shape of the array (of scalars).
array_type::tensor< double, N+4 > II() const
Array of Cartesian3d::II()
void init(const std::array< size_t, N > &shape)
Constructor 'alias'.
array_type::tensor< double, N+4 > O4() const
Array of Cartesian3d::O4()
std::array< size_t, N+2 > m_shape_tensor2
Shape of an array of 2nd-order tensors == [m_shape, 3, 3].
static constexpr std::size_t rank
Rank of the array (the actual rank is increased with the tensor-rank).
size_t m_size
Size of the array (of scalars) == prod(m_shape).
array_type::tensor< double, N+2 > O2() const
Array of Cartesian3d::O2()
const std::array< size_t, N+4 > & shape_tensor4() const
Shape of the array of fourth-order tensors.
array_type::tensor< double, N+2 > I2() const
Array of Cartesian3d::I2()
array_type::tensor< double, N+4 > I4rt() const
Array of Cartesian3d::I4rt()
static constexpr size_t m_stride_tensor2
Storage stride for 2nd-order tensors ( ).
void logs(const T *A, T *ret)
See Cartesian3d::Logs()
void A2_dyadic_B2(const T *A, const T *B, T *ret)
See Cartesian3d::A2_dyadic_B2()
void from_eigs(const T *vec, const T *val, T *ret)
Reconstruct tensor from eigenvalues/-vectors (reverse operation of eigs()) Symmetric tensors only,...
void A2_dot_B2_dot_C2T(const T *A, const T *B, const T *C, T *ret)
Product.
T Inv(const T *A, T *ret)
See Cartesian3d::Inv(), returns Cartesian3d::Det()
void eigs(const T *A, T *vec, T *val)
Get eigenvalues/-vectors such that.
T A2s_ddot_B2s(const T *A, const T *B)
See Cartesian3d::A2s_ddot_B2s()
void A4_dot_B2(const T *A, const T *B, T *ret)
See Cartesian3d::A4_dot_B2()
T Det(const T *A)
See Cartesian3d::Det()
T Trace(const T *A)
See Cartesian3d::Trace()
T Hydrostatic(const T *A)
See Cartesian3d::Hydrostatic()
T Deviatoric_ddot_deviatoric(const T *A)
Double tensor contraction of the tensor's deviator.
void A2_dot_A2T(const T *A, T *ret)
See Cartesian3d::A2_dot_A2T()
T Norm_deviatoric(const T *A)
See Cartesian3d::Norm_deviatoric()
void A2_dot_B2(const T *A, const T *B, T *ret)
See Cartesian3d::A2_dot_B2()
T A2_ddot_B2(const T *A, const T *B)
See Cartesian3d::A2_ddot_B2()
void A4_ddot_B2(const T *A, const T *B, T *ret)
See Cartesian3d::A4_ddot_B2()
void sym(const T *A, T *ret)
See Cartesian3d::Sym()
T Hydrostatic_deviatoric(const T *A, T *ret)
Returns Cartesian3d::Hydrostatic() and computes Cartesian3d::Deviatoric()
void A4_ddot_B4_ddot_C4(const T *A, const T *B, const T *C, T *ret)
Product.
void hydrostatic(const T &A, R &ret)
Same as Hydrostatic() but writes to externally allocated output.
auto Deviatoric(const T &A)
Deviatoric part of a tensor:
auto A2_dyadic_B2(const T &A, const T &B)
Dyadic product.
size_t underlying_size_A2(const T &A)
Size of the underlying array.
auto Sym(const T &A)
Symmetric part of a tensor:
auto underlying_shape_A2(const T &A) -> std::array< size_t, detail::impl_A2< T, 3 >::rank >
Shape of the underlying array.
auto A2s_ddot_B2s(const T &A, const T &B)
Same as A2_ddot_B2(const T& A, const T& B, R& ret) but for symmetric tensors.
void trace(const T &A, R &ret)
Same as Trace() but writes to externally allocated output.
auto Logs(const T &A)
Logarithm.
array_type::tensor< double, 2 > I2()
2nd-order identity tensor.
array_type::tensor< double, 2 > O2()
2nd-order null tensor (all components equal to zero).
auto A2_dot_B2(const T &A, const T &B)
Dot-product (single tensor contraction)
void deviatoric(const T &A, R &ret)
Same as Deviatoric() but writes to externally allocated output.
array_type::tensor< double, 4 > I4()
Fourth order unit tensor.
array_type::tensor< double, 4 > II()
Result of the dyadic product of two 2nd-order identity tensors (see I2()).
auto A2_ddot_B2(const T &A, const T &B)
Double tensor contraction.
array_type::tensor< double, 4 > I4rt()
Right-transposed fourth order unit tensor.
array_type::tensor< double, 4 > I4d()
Fourth order deviatoric projection.
void det(const T &A, R &ret)
Same as Det() but writes to externally allocated output.
void logs(const T &A, R &ret)
Same as Logs() but writes to externally allocated output.
array_type::tensor< double, 4 > Random4()
Random 4th-order tensor (for example for use in testing).
void sym(const T &A, R &ret)
Same as Sym() but writes to externally allocated output.
array_type::tensor< double, 4 > I4s()
Fourth order symmetric projection.
auto Det(const T &A)
Determinant.
auto underlying_shape_A4(const T &A) -> std::array< size_t, detail::impl_A4< T, 3 >::rank >
Shape of the underlying array.
array_type::tensor< double, 4 > O4()
4th-order null tensor (all components equal to zero).
auto Inv(const T &A)
Inverse.
void inv(const T &A, R &ret)
Same as Inv() but writes to externally allocated output.
auto Norm_deviatoric(const T &A)
Norm of the tensor's deviator:
size_t underlying_size_A4(const T &A)
Size of the underlying array.
auto Trace(const T &A)
Trace or 2nd-order tensor.
auto A4_dot_B2(const T &A, const U &B)
Tensor contraction.
void norm_deviatoric(const T &A, R &ret)
Same as Norm_deviatoric() but writes to externally allocated output.
auto A4_ddot_B2(const T &A, const U &B)
Double tensor contraction.
auto Hydrostatic(const T &A)
Hydrostatic part of a tensor.
array_type::tensor< double, 2 > Random2()
Random 2nd-order tensor (for example for use in testing).
auto A2_dot_A2T(const T &A)
Dot-product (single tensor contraction)
xt::xtensor< T, N > tensor
Fixed (static) rank array.
Tensor products / operations.