27#include "neml2/tensors/BatchTensor.h"
38constexpr Real eps = std::numeric_limits<at::scalar_value_type<Real>::type>::epsilon();
44constexpr TorchSize mandel_index[6][2] = {{0, 0}, {1, 1}, {2, 2}, {1, 2}, {0, 2}, {0, 1}};
47constexpr Real skew_factor[3][3] = {{0.0, -1.0, 1.0}, {1.0, 0.0, -1.0}, {-1.0, 1.0, 0.0}};
52 return i < 3 ? 1.0 :
sqrt2;
80 torch::Tensor _full_to_mandel_map;
81 torch::Tensor _mandel_to_full_map;
82 torch::Tensor _full_to_mandel_factor;
83 torch::Tensor _mandel_to_full_factor;
84 torch::Tensor _full_to_skew_map;
85 torch::Tensor _skew_to_full_map;
86 torch::Tensor _full_to_skew_factor;
87 torch::Tensor _skew_to_full_factor;
112 const torch::Tensor &
rmap,
128 const torch::Tensor &
rmap,
Definition BatchTensor.h:32
The wrapper (decorator) for cross-referencing unresolved values at parse time.
Definition CrossRef.h:52
The (logical) symmetric second order tensor.
Definition SR2.h:46
The (logical) symmetric fourth order tensor, with symmetry in the first two dimensionss as well as in...
Definition SSR4.h:44
The (logical) symmetric fourth order tensor, with symmetry in the first two dimensionss and skew-symm...
Definition SWR4.h:40
A skew rank 2, represented as an axial vector.
Definition WR2.h:43
The (logical) symmetric fourth order tensor, with skew symmetry in the first two dimensionss and symm...
Definition WSR4.h:40
BatchTensor solve(const BatchTensor &A, const BatchTensor &B)
Solve the linear system A X = B.
Definition math.cxx:340
BatchTensor inv(const BatchTensor &m)
Inverse of a square matrix.
Definition math.cxx:334
std::tuple< BatchTensor, BatchTensor > lu_factor(const BatchTensor &A, bool pivot)
Definition math.cxx:346
BatchTensor vector_norm(const BatchTensor &v)
Vector norm of a vector. Falls back to math::abs is v is a Scalar.
Definition math.cxx:317
BatchTensor lu_solve(const BatchTensor &LU, const BatchTensor &pivots, const BatchTensor &B, bool left, bool adjoint)
Definition math.cxx:353
constexpr Real skew_factor[3][3]
Definition math.h:47
constexpr Real eps
Definition math.h:38
SWR4 d_skew_and_sym_to_sym_d_skew(const SR2 &e)
Derivative of w_ik e_kj - e_ik w_kj wrt. w.
Definition math.cxx:279
SSR4 d_skew_and_sym_to_sym_d_sym(const WR2 &w)
Derivative of w_ik e_kj - e_ik w_kj wrt. e.
Definition math.cxx:270
BatchTensor mandel_to_full(const BatchTensor &mandel, TorchSize dim)
Convert a BatchTensor from Mandel notation to full notation.
Definition math.cxx:179
constexpr Real invsqrt2
Definition math.h:41
BatchTensor skew_to_full(const BatchTensor &skew, TorchSize dim)
Convert a BatchTensor from skew vector notation to full notation.
Definition math.cxx:199
BatchTensor base_diag_embed(const BatchTensor &a, TorchSize offset, TorchSize d1, TorchSize d2)
Definition math.cxx:251
BatchTensor reduced_to_full(const BatchTensor &reduced, const torch::Tensor &rmap, const torch::Tensor &rfactors, TorchSize dim)
Convert a BatchTensor from reduced notation to full notation.
Definition math.cxx:144
constexpr TorchSize mandel_index[6][2]
Definition math.h:44
WSR4 d_multiply_and_make_skew_d_first(const SR2 &b)
Derivative of a_ik b_kj - b_ik a_kj wrt a.
Definition math.cxx:297
SR2 skew_and_sym_to_sym(const SR2 &e, const WR2 &w)
Product w_ik e_kj - e_ik w_kj with e SR2 and w WR2.
Definition math.cxx:260
WR2 multiply_and_make_skew(const SR2 &a, const SR2 &b)
Shortcut product a_ik b_kj - b_ik a_kj with both SR2.
Definition math.cxx:288
BatchTensor full_to_reduced(const BatchTensor &full, const torch::Tensor &rmap, const torch::Tensor &rfactors, TorchSize dim)
Generic function to reduce two axes to one with some map.
Definition math.cxx:116
constexpr Real mandel_factor(TorchSize i)
Definition math.h:50
constexpr TorchSize skew_reverse_index[3][3]
Definition math.h:46
constexpr TorchSize mandel_reverse_index[3][3]
Definition math.h:43
WSR4 d_multiply_and_make_skew_d_second(const SR2 &a)
Derivative of a_ik b_kj - b_ik a_kj wrt b.
Definition math.cxx:306
BatchTensor full_to_mandel(const BatchTensor &full, TorchSize dim)
Convert a BatchTensor from full notation to Mandel notation.
Definition math.cxx:169
BatchTensor jacrev(const BatchTensor &y, const BatchTensor &p)
Use automatic differentiation (AD) to calculate the derivatives w.r.t. to the parameter.
Definition math.cxx:209
constexpr Real sqrt2
Definition math.h:40
BatchTensor full_to_skew(const BatchTensor &full, TorchSize dim)
Convert a BatchTensor from full notation to skew vector notation.
Definition math.cxx:189
Definition CrossRef.cxx:32
int64_t TorchSize
Definition types.h:35
double Real
Definition types.h:33
A helper class to hold static data of type torch::Tensor.
Definition math.h:64
static const torch::Tensor & skew_to_full_map()
Definition math.cxx:98
static const torch::Tensor & full_to_mandel_factor()
Definition math.cxx:80
static const torch::Tensor & full_to_skew_factor()
Definition math.cxx:104
static const torch::Tensor & full_to_skew_map()
Definition math.cxx:92
ConstantTensors()
Definition math.cxx:36
static ConstantTensors & get()
Definition math.cxx:61
static const torch::Tensor & mandel_to_full_factor()
Definition math.cxx:86
static const torch::Tensor & mandel_to_full_map()
Definition math.cxx:74
static const torch::Tensor & full_to_mandel_map()
Definition math.cxx:68
static const torch::Tensor & skew_to_full_factor()
Definition math.cxx:110