27#include "neml2/tensors/PrimitiveTensor.h"
28#include "neml2/tensors/Scalar.h"
29#include "neml2/tensors/R2.h"
41template <
class Derived>
63 template <
class Derived2>
67 template <
class Derived2>
71 template <
class Derived2>
93template <
class Derived>
94template <
class Derived2>
99 auto res = torch::linalg_vecdot(*
this,
v);
103template <
class Derived>
104template <
class Derived2>
111 auto pair = torch::broadcast_tensors({*
this,
v});
113 return Derived(torch::linalg_cross(
pair[0],
pair[1]), batch_dim);
116template <
class Derived>
117template <
class Derived2>
121 return torch::matmul(this->
unsqueeze(-1), v.unsqueeze(-2));
The wrapper (decorator) for cross-referencing unresolved values at parse time.
Definition CrossRef.h:54
PrimitiveTensor inherits from TensorBase and additionally templates on the base shape.
Definition PrimitiveTensor.h:38
PrimitiveTensor()=default
Default constructor.
Second order tensor without symmetry.
Definition R2.h:42
Third order tensor without symmetry.
Definition R3.h:41
Rotation stored as modified Rodrigues parameters.
Definition Rot.h:49
Scalar.
Definition Scalar.h:38
Base class 3-vector.
Definition VecBase.h:43
Derived rotate(const Rot &r) const
Rotate using a Rodrigues vector.
Definition VecBase.cxx:78
R2 outer(const VecBase< Derived2 > &v) const
outer product
Definition VecBase.h:119
Derived cross(const VecBase< Derived2 > &v) const
cross product
Definition VecBase.h:106
Scalar operator()(Size i) const
Accessor.
Definition VecBase.cxx:57
static R2 identity_map(const torch::TensorOptions &options=default_tensor_options())
The derivative of a vector with respect to itself.
Definition VecBase.cxx:50
Scalar norm_sq() const
Norm squared.
Definition VecBase.cxx:64
Scalar dot(const VecBase< Derived2 > &v) const
dot product
Definition VecBase.h:96
static Derived fill(const Real &v1, const Real &v2, const Real &v3, const torch::TensorOptions &options=default_tensor_options())
Definition VecBase.cxx:33
Scalar norm() const
Norm.
Definition VecBase.cxx:71
R2 drotate(const Rot &r) const
Derivative of the rotated vector w.r.t. the Rodrigues vector.
Definition VecBase.cxx:92
Definition CrossRef.cxx:31
Size broadcast_batch_dim(const T &...)
The batch dimension after broadcasting.
torch::TensorOptions & default_tensor_options()
Definition types.cxx:157
double Real
Definition types.h:31
int64_t Size
Definition types.h:33
void neml_assert_broadcastable_dbg(const T &...)
A helper function to assert (in Debug mode) that all tensors are broadcastable.