wuzp
Wrong Unit? Zero Points! Compile-time checks for units, coordinate systems and points vs. vectors.
Loading...
Searching...
No Matches
wuzp::Tensor< IndicesT_, QuantitiesT_, CoordinateSystemT_, AbsoluteT_ > Class Template Reference

A tensor of rank 0, 1 or 2, whose components are quantities, expressed in a coordinate system, e.g. a vector, a covector, a linear map or a mass matrix. More...

#include <wuzp/core/Tensor.hpp>

Public Types

using IndicesT = IndicesT_
using QuantitiesT = QuantitiesT_
using CoordinateSystemT = CoordinateSystemT_
using UnitsT = typename QuantitiesT::UnitsT
using ValuesT = typename QuantitiesT::ValuesT
using ValueT = typename QuantitiesT::ValueT
using AbsoluteT = AbsoluteT_
using ThisT = Tensor<IndicesT, QuantitiesT, CoordinateSystemT, AbsoluteT>

Public Member Functions

 Tensor ()=default
template<typename T0, typename... Ts>
requires (!IsSpecialization<T0, Tag>::value && !CopiesOrMoves<Tensor, T0, Ts...>)
 explicit (!IsValidConversion< ThisT, std::remove_cvref_t< T0 >, std::remove_cvref_t< Ts >... >::value) Tensor(T0 &&t0
Ts Ts std::forward (t0)
Ts Ts std::forward (ts)...)
template<typename ValuesOtherT_, typename UnitsOtherT_>
void setQuantities (const Quantities< ValuesOtherT_, UnitsOtherT_ > &component)
const QuantitiesT & getQuantities () const &
QuantitiesT getQuantities () &&
 The quantities of a temporary are moved out of it, which avoids a copy and does not refer to the destroyed temporary.
template<typename ValuesOtherT_>
void setValues (const ValuesOtherT_ &values)
const ValuesT & getValues () const &
ValuesT getValues () &&
template<typename IndicesOtherT_, typename QuantitiesOtherT_, typename CoordinateSystemOtherT_, typename AbsoluteOtherT_>
bool isApprox (const Tensor< IndicesOtherT_, QuantitiesOtherT_, CoordinateSystemOtherT_, AbsoluteOtherT_ > &other, const ValueT precision=Precision< ValueT >::value()) const
 Whether the components of both tensors, which must have the same indices, coordinate system and absoluteness, are approximately equal, relatively, like Eigen's isApprox (https://eigen.tuxfamily.org/dox/classEigen_1_1DenseBase.html#ae8443357b808cd393be1b51974213f9c): ||a - b|| <= precision * min(||a||, ||b||), in the Frobenius norm of the values, with every value matrix backend.
auto getQuantity () const
template<int RowIdV_, int ColIdV_>
auto getQuantity () const
template<int IdV_>
requires (Dimension<ThisT>::value <= 1 || internal::isBatch<IndicesT, QuantitiesT>)
auto getQuantity () const
 The component with the single index IdV_ of a vector, a point or a covector, e.g. velocity.getQuantity<1>() for v^1 of a vector or a point, or w_1 of a covector: the row of a vector, a column, and the column of a covector, a row.
auto getQuantity (const int rowId, const int colId) const
auto getQuantity (const int id) const
 The component with the single index id of a vector, a point or a covector, like getQuantity<IdV_>(), but with an index known at run time, which, like getQuantity(rowId, colId), requires all components to have the same unit.
template<typename QuantityT_>
requires (Dimension<ThisT>::value == 0)
void setQuantity (const QuantityT_ &quantity)
template<int RowIdV_, int ColIdV_, typename QuantityT_>
void setQuantity (const QuantityT_ &quantity)
template<int IdV_, typename QuantityT_>
requires (Dimension<ThisT>::value <= 1 || internal::isBatch<IndicesT, QuantitiesT>)
void setQuantity (const QuantityT_ &quantity)
 Sets the component with the single index IdV_ of a vector, a point or a covector, e.g. velocity.setQuantity<1>(speed) (see getQuantity<IdV_>()), like setQuantity<RowIdV_, ColIdV_>(), which checks the index and the unit at compile time.
template<typename QuantityT_>
void setQuantity (const int rowId, const int colId, const QuantityT_ &quantity)
template<typename QuantityT_>
requires (Dimension<ThisT>::value <= 1 || internal::isBatch<IndicesT, QuantitiesT>)
void setQuantity (const int id, const QuantityT_ &quantity)
 Sets the component with the single index id of a vector, a point or a covector, like setQuantity<IdV_>(), but with an index known at run time, which, like setQuantity(rowId, colId, quantity), requires all components to have the same unit.
template<int BlockRowIdV_, int BlockColIdV_, int BlockRowsV_, int BlockColsV_>
auto block () const
auto transpose () const
 The transpose of the matrix of the components: a vector becomes a covector and vice versa, and the indices of a tensor of rank 2 are swapped, e.g. a linear map T^i_j becomes (T^T)_j^i (see Transpose<Indices<...>>).
template<typename IndicesOtherT_, typename QuantitiesOtherT_, typename CoordinateSystemOtherT_, typename AbsoluteOtherT_>
auto innerProduct (const Tensor< IndicesOtherT_, QuantitiesOtherT_, CoordinateSystemOtherT_, AbsoluteOtherT_ > &other) const
 The inner product, see innerProduct().
template<typename IndicesOtherT_, typename QuantitiesOtherT_, typename CoordinateSystemOtherT_, typename AbsoluteOtherT_>
auto dotProduct (const Tensor< IndicesOtherT_, QuantitiesOtherT_, CoordinateSystemOtherT_, AbsoluteOtherT_ > &other) const
 The dot product sum_i v_i w_i of two vectors in the same coordinate system, which must be Euclidean: it is the product with the Euclidean metric delta_ij in an orthonormal basis (see Metric).
template<typename IndicesOtherT_, typename QuantitiesOtherT_, typename CoordinateSystemOtherT_, typename AbsoluteOtherT_>
auto crossProduct (const Tensor< IndicesOtherT_, QuantitiesOtherT_, CoordinateSystemOtherT_, AbsoluteOtherT_ > &other) const
 The cross product a x b of two three-dimensional vectors in the same Euclidean coordinate system (see Metric), e.g. the torque r x F or the velocity w x r of a point of a rotating body.
auto inverse () const
 The matrix inverse of a tensor of rank 0 or 2, like Eigen's MatrixBase::inverse(): e.g. the inverse of a linear map T^i_j is a linear map, and the inverse of a metric g_ij, or of a mass matrix M_ij, has two upper indices, g^ij (see Inverse<Indices<...>>).
auto cwiseInverse () const
 The elementwise reciprocal of the components, like Eigen's ArrayBase::inverse().
auto norm () const
auto squaredNorm () const
auto determinant () const
 The determinant of a tensor of rank 0 or of a mixed tensor of rank 2, e.g. a linear map T^i_j, which is invariant.
auto hyperdeterminant () const
 Not implemented. The return type is deduced, so that the message is the first error (see FailOnInstantiation).
auto evaluate () const &
auto evaluate () &&

Static Public Member Functions

static ThisT zero ()
static ThisT random ()

Public Attributes

Ts && ts: Tensor(typename GetTag<ThisT
Ts T0

Detailed Description

template<AnyIndices IndicesT_, AnyQuantities QuantitiesT_, AnyCoordinateSystem CoordinateSystemT_, AbsoluteOrRelative AbsoluteT_>
class wuzp::Tensor< IndicesT_, QuantitiesT_, CoordinateSystemT_, AbsoluteT_ >

A tensor of rank 0, 1 or 2, whose components are quantities, expressed in a coordinate system, e.g. a vector, a covector, a linear map or a mass matrix.

Template Parameters
IndicesT_The indices, e.g. Indices<Up> for a vector or Indices<Down, Down> for a mass matrix (see Indices).
QuantitiesT_The components, a matrix with the first index as the row: a 1x1 matrix for rank 0, a column for a vector, a row for a covector, a square matrix for rank 2. A tensor with an upper index may also store a batch of vectors or points, one per column, e.g. a point cloud.
CoordinateSystemT_The coordinate system that the components are expressed in. Its metric, Euclidean by default, decides whether dotProduct, norm, squaredNorm, crossProduct and the transpose of a vector or a covector are defined (see Metric).
AbsoluteT_Absolute for points, Relative for vectors and all other tensors (see Absolute.hpp). Only a tensor with one upper index, a vector or a batch of vectors, can be absolute: the components of a point are those of the vector from the origin of the coordinate system to it. An absolute scalar, e.g. a time point or a temperature on the Celsius scale, is a point in a one-dimensional coordinate system whose origin is its zero, e.g. an epoch or the ice point, like the Celsius temperature t = T - T0 of the SI Brochure, section 2.3.1 (https://www.bipm.org/en/publications/si-brochure) (see TimePoint).

Definition at line 99 of file Tensor.hpp.

Member Typedef Documentation

◆ AbsoluteT

template<AnyIndices IndicesT_, AnyQuantities QuantitiesT_, AnyCoordinateSystem CoordinateSystemT_, AbsoluteOrRelative AbsoluteT_>
using wuzp::Tensor< IndicesT_, QuantitiesT_, CoordinateSystemT_, AbsoluteT_ >::AbsoluteT = AbsoluteT_

Definition at line 107 of file Tensor.hpp.

◆ CoordinateSystemT

template<AnyIndices IndicesT_, AnyQuantities QuantitiesT_, AnyCoordinateSystem CoordinateSystemT_, AbsoluteOrRelative AbsoluteT_>
using wuzp::Tensor< IndicesT_, QuantitiesT_, CoordinateSystemT_, AbsoluteT_ >::CoordinateSystemT = CoordinateSystemT_

Definition at line 103 of file Tensor.hpp.

◆ IndicesT

template<AnyIndices IndicesT_, AnyQuantities QuantitiesT_, AnyCoordinateSystem CoordinateSystemT_, AbsoluteOrRelative AbsoluteT_>
using wuzp::Tensor< IndicesT_, QuantitiesT_, CoordinateSystemT_, AbsoluteT_ >::IndicesT = IndicesT_

Definition at line 101 of file Tensor.hpp.

◆ QuantitiesT

template<AnyIndices IndicesT_, AnyQuantities QuantitiesT_, AnyCoordinateSystem CoordinateSystemT_, AbsoluteOrRelative AbsoluteT_>
using wuzp::Tensor< IndicesT_, QuantitiesT_, CoordinateSystemT_, AbsoluteT_ >::QuantitiesT = QuantitiesT_

Definition at line 102 of file Tensor.hpp.

◆ ThisT

template<AnyIndices IndicesT_, AnyQuantities QuantitiesT_, AnyCoordinateSystem CoordinateSystemT_, AbsoluteOrRelative AbsoluteT_>
using wuzp::Tensor< IndicesT_, QuantitiesT_, CoordinateSystemT_, AbsoluteT_ >::ThisT = Tensor<IndicesT, QuantitiesT, CoordinateSystemT, AbsoluteT>

Definition at line 108 of file Tensor.hpp.

◆ UnitsT

template<AnyIndices IndicesT_, AnyQuantities QuantitiesT_, AnyCoordinateSystem CoordinateSystemT_, AbsoluteOrRelative AbsoluteT_>
using wuzp::Tensor< IndicesT_, QuantitiesT_, CoordinateSystemT_, AbsoluteT_ >::UnitsT = typename QuantitiesT::UnitsT

Definition at line 104 of file Tensor.hpp.

◆ ValuesT

template<AnyIndices IndicesT_, AnyQuantities QuantitiesT_, AnyCoordinateSystem CoordinateSystemT_, AbsoluteOrRelative AbsoluteT_>
using wuzp::Tensor< IndicesT_, QuantitiesT_, CoordinateSystemT_, AbsoluteT_ >::ValuesT = typename QuantitiesT::ValuesT

Definition at line 105 of file Tensor.hpp.

◆ ValueT

template<AnyIndices IndicesT_, AnyQuantities QuantitiesT_, AnyCoordinateSystem CoordinateSystemT_, AbsoluteOrRelative AbsoluteT_>
using wuzp::Tensor< IndicesT_, QuantitiesT_, CoordinateSystemT_, AbsoluteT_ >::ValueT = typename QuantitiesT::ValueT

Definition at line 106 of file Tensor.hpp.

Constructor & Destructor Documentation

◆ Tensor()

template<AnyIndices IndicesT_, AnyQuantities QuantitiesT_, AnyCoordinateSystem CoordinateSystemT_, AbsoluteOrRelative AbsoluteT_>
wuzp::Tensor< IndicesT_, QuantitiesT_, CoordinateSystemT_, AbsoluteT_ >::Tensor ( )
default

Member Function Documentation

◆ block()

template<AnyIndices IndicesT_, AnyQuantities QuantitiesT_, AnyCoordinateSystem CoordinateSystemT_, AbsoluteOrRelative AbsoluteT_>
template<int BlockRowIdV_, int BlockColIdV_, int BlockRowsV_, int BlockColsV_>
auto wuzp::Tensor< IndicesT_, QuantitiesT_, CoordinateSystemT_, AbsoluteT_ >::block ( ) const
inline

Definition at line 255 of file Tensor.hpp.

◆ crossProduct()

template<AnyIndices IndicesT_, AnyQuantities QuantitiesT_, AnyCoordinateSystem CoordinateSystemT_, AbsoluteOrRelative AbsoluteT_>
template<typename IndicesOtherT_, typename QuantitiesOtherT_, typename CoordinateSystemOtherT_, typename AbsoluteOtherT_>
auto wuzp::Tensor< IndicesT_, QuantitiesT_, CoordinateSystemT_, AbsoluteT_ >::crossProduct ( const Tensor< IndicesOtherT_, QuantitiesOtherT_, CoordinateSystemOtherT_, AbsoluteOtherT_ > & other) const
inline

The cross product a x b of two three-dimensional vectors in the same Euclidean coordinate system (see Metric), e.g. the torque r x F or the velocity w x r of a point of a rotating body.

It is a pseudovector, a covector density, which changes its sign under parity (Carroll, Lecture Notes on General Relativity, https://arxiv.org/abs/gr-qc/9712019, eq. 1.90): a linear transformation M maps it to (M a) x (M b) = det(M) M^-T (a x b) (https://en.wikipedia.org/wiki/Cross_product#Algebraic_properties), which is M (a x b) only for proper rotations, det(M) = 1 and M^-T = M, which the rotations guarantee (see ActiveSpatialRotation). A reflection flips its sign, and a linear transformation that is not a rotation, e.g. a scaling or a shear, does not transform it like a vector: compute the cross product of the transformed vectors instead of transforming the cross product. The result is typed as a vector, which is only right in right-handed orthonormal bases under proper rotations (see "Cross product" in DESIGN.md).

Definition at line 297 of file Tensor.hpp.

◆ cwiseInverse()

template<AnyIndices IndicesT_, AnyQuantities QuantitiesT_, AnyCoordinateSystem CoordinateSystemT_, AbsoluteOrRelative AbsoluteT_>
auto wuzp::Tensor< IndicesT_, QuantitiesT_, CoordinateSystemT_, AbsoluteT_ >::cwiseInverse ( ) const
inline

The elementwise reciprocal of the components, like Eigen's ArrayBase::inverse().

It depends on the basis, so it is not a tensor: it returns quantities, without indices or a coordinate system, like cwiseProduct(). Points are rejected, since their components depend on the origin.

Definition at line 314 of file Tensor.hpp.

◆ determinant()

template<AnyIndices IndicesT_, AnyQuantities QuantitiesT_, AnyCoordinateSystem CoordinateSystemT_, AbsoluteOrRelative AbsoluteT_>
auto wuzp::Tensor< IndicesT_, QuantitiesT_, CoordinateSystemT_, AbsoluteT_ >::determinant ( ) const
inline

The determinant of a tensor of rank 0 or of a mixed tensor of rank 2, e.g. a linear map T^i_j, which is invariant.

The determinant of a tensor with two upper or two lower indices depends on the basis, so it is rejected (see Determinant<Indices<...>>); getQuantities().determinant() computes the determinant of its components. Like inverse(), it exists for every tensor, so that vectors, covectors and batches are rejected with a clear message.

Definition at line 346 of file Tensor.hpp.

◆ dotProduct()

template<AnyIndices IndicesT_, AnyQuantities QuantitiesT_, AnyCoordinateSystem CoordinateSystemT_, AbsoluteOrRelative AbsoluteT_>
template<typename IndicesOtherT_, typename QuantitiesOtherT_, typename CoordinateSystemOtherT_, typename AbsoluteOtherT_>
auto wuzp::Tensor< IndicesT_, QuantitiesT_, CoordinateSystemT_, AbsoluteT_ >::dotProduct ( const Tensor< IndicesOtherT_, QuantitiesOtherT_, CoordinateSystemOtherT_, AbsoluteOtherT_ > & other) const
inline

The dot product sum_i v_i w_i of two vectors in the same coordinate system, which must be Euclidean: it is the product with the Euclidean metric delta_ij in an orthonormal basis (see Metric).

In other coordinate systems, e.g. Minkowski, pair a covector and a vector with innerProduct, which needs no metric.

Definition at line 279 of file Tensor.hpp.

◆ evaluate() [1/2]

template<AnyIndices IndicesT_, AnyQuantities QuantitiesT_, AnyCoordinateSystem CoordinateSystemT_, AbsoluteOrRelative AbsoluteT_>
auto wuzp::Tensor< IndicesT_, QuantitiesT_, CoordinateSystemT_, AbsoluteT_ >::evaluate ( ) &&
inline

Definition at line 352 of file Tensor.hpp.

◆ evaluate() [2/2]

template<AnyIndices IndicesT_, AnyQuantities QuantitiesT_, AnyCoordinateSystem CoordinateSystemT_, AbsoluteOrRelative AbsoluteT_>
auto wuzp::Tensor< IndicesT_, QuantitiesT_, CoordinateSystemT_, AbsoluteT_ >::evaluate ( ) const &
inline

Definition at line 351 of file Tensor.hpp.

◆ explicit()

template<AnyIndices IndicesT_, AnyQuantities QuantitiesT_, AnyCoordinateSystem CoordinateSystemT_, AbsoluteOrRelative AbsoluteT_>
template<typename T0, typename... Ts>
requires (!IsSpecialization<T0, Tag>::value && !CopiesOrMoves<Tensor, T0, Ts...>)
wuzp::Tensor< IndicesT_, QuantitiesT_, CoordinateSystemT_, AbsoluteT_ >::explicit ( !IsValidConversion< ThisT, std::remove_cvref_t< T0 >, std::remove_cvref_t< Ts >... >::value ) &&

◆ getQuantities() [1/2]

template<AnyIndices IndicesT_, AnyQuantities QuantitiesT_, AnyCoordinateSystem CoordinateSystemT_, AbsoluteOrRelative AbsoluteT_>
QuantitiesT wuzp::Tensor< IndicesT_, QuantitiesT_, CoordinateSystemT_, AbsoluteT_ >::getQuantities ( ) &&
inline

The quantities of a temporary are moved out of it, which avoids a copy and does not refer to the destroyed temporary.

Definition at line 142 of file Tensor.hpp.

◆ getQuantities() [2/2]

template<AnyIndices IndicesT_, AnyQuantities QuantitiesT_, AnyCoordinateSystem CoordinateSystemT_, AbsoluteOrRelative AbsoluteT_>
const QuantitiesT & wuzp::Tensor< IndicesT_, QuantitiesT_, CoordinateSystemT_, AbsoluteT_ >::getQuantities ( ) const &
inline

Definition at line 140 of file Tensor.hpp.

◆ getQuantity() [1/5]

template<AnyIndices IndicesT_, AnyQuantities QuantitiesT_, AnyCoordinateSystem CoordinateSystemT_, AbsoluteOrRelative AbsoluteT_>
template<int IdV_>
requires (Dimension<ThisT>::value <= 1 || internal::isBatch<IndicesT, QuantitiesT>)
auto wuzp::Tensor< IndicesT_, QuantitiesT_, CoordinateSystemT_, AbsoluteT_ >::getQuantity ( ) const
inline

The component with the single index IdV_ of a vector, a point or a covector, e.g. velocity.getQuantity<1>() for v^1 of a vector or a point, or w_1 of a covector: the row of a vector, a column, and the column of a covector, a row.

The only component of a scalar or of a one-dimensional vector or point, e.g. a TimePoint, both stored as a 1x1 matrix, has the index 0, so that code that is generic over the dimension also works in one dimension (see internal::vectorElementRowId()). Like getQuantity<RowIdV_, ColIdV_>(), it checks the index at compile time and has the unit of the component.

Definition at line 197 of file Tensor.hpp.

◆ getQuantity() [2/5]

template<AnyIndices IndicesT_, AnyQuantities QuantitiesT_, AnyCoordinateSystem CoordinateSystemT_, AbsoluteOrRelative AbsoluteT_>
template<int RowIdV_, int ColIdV_>
auto wuzp::Tensor< IndicesT_, QuantitiesT_, CoordinateSystemT_, AbsoluteT_ >::getQuantity ( ) const
inline

Definition at line 182 of file Tensor.hpp.

◆ getQuantity() [3/5]

template<AnyIndices IndicesT_, AnyQuantities QuantitiesT_, AnyCoordinateSystem CoordinateSystemT_, AbsoluteOrRelative AbsoluteT_>
auto wuzp::Tensor< IndicesT_, QuantitiesT_, CoordinateSystemT_, AbsoluteT_ >::getQuantity ( ) const
inline

Definition at line 175 of file Tensor.hpp.

◆ getQuantity() [4/5]

template<AnyIndices IndicesT_, AnyQuantities QuantitiesT_, AnyCoordinateSystem CoordinateSystemT_, AbsoluteOrRelative AbsoluteT_>
auto wuzp::Tensor< IndicesT_, QuantitiesT_, CoordinateSystemT_, AbsoluteT_ >::getQuantity ( const int id) const
inline

The component with the single index id of a vector, a point or a covector, like getQuantity<IdV_>(), but with an index known at run time, which, like getQuantity(rowId, colId), requires all components to have the same unit.

Definition at line 208 of file Tensor.hpp.

◆ getQuantity() [5/5]

template<AnyIndices IndicesT_, AnyQuantities QuantitiesT_, AnyCoordinateSystem CoordinateSystemT_, AbsoluteOrRelative AbsoluteT_>
auto wuzp::Tensor< IndicesT_, QuantitiesT_, CoordinateSystemT_, AbsoluteT_ >::getQuantity ( const int rowId,
const int colId ) const
inline

Definition at line 204 of file Tensor.hpp.

◆ getValues() [1/2]

template<AnyIndices IndicesT_, AnyQuantities QuantitiesT_, AnyCoordinateSystem CoordinateSystemT_, AbsoluteOrRelative AbsoluteT_>
ValuesT wuzp::Tensor< IndicesT_, QuantitiesT_, CoordinateSystemT_, AbsoluteT_ >::getValues ( ) &&
inline

Definition at line 149 of file Tensor.hpp.

◆ getValues() [2/2]

template<AnyIndices IndicesT_, AnyQuantities QuantitiesT_, AnyCoordinateSystem CoordinateSystemT_, AbsoluteOrRelative AbsoluteT_>
const ValuesT & wuzp::Tensor< IndicesT_, QuantitiesT_, CoordinateSystemT_, AbsoluteT_ >::getValues ( ) const &
inline

Definition at line 148 of file Tensor.hpp.

◆ hyperdeterminant()

template<AnyIndices IndicesT_, AnyQuantities QuantitiesT_, AnyCoordinateSystem CoordinateSystemT_, AbsoluteOrRelative AbsoluteT_>
auto wuzp::Tensor< IndicesT_, QuantitiesT_, CoordinateSystemT_, AbsoluteT_ >::hyperdeterminant ( ) const
inline

Not implemented. The return type is deduced, so that the message is the first error (see FailOnInstantiation).

Definition at line 349 of file Tensor.hpp.

◆ innerProduct()

template<AnyIndices IndicesT_, AnyQuantities QuantitiesT_, AnyCoordinateSystem CoordinateSystemT_, AbsoluteOrRelative AbsoluteT_>
template<typename IndicesOtherT_, typename QuantitiesOtherT_, typename CoordinateSystemOtherT_, typename AbsoluteOtherT_>
auto wuzp::Tensor< IndicesT_, QuantitiesT_, CoordinateSystemT_, AbsoluteT_ >::innerProduct ( const Tensor< IndicesOtherT_, QuantitiesOtherT_, CoordinateSystemOtherT_, AbsoluteOtherT_ > & other) const
inline

The inner product, see innerProduct().

Definition at line 268 of file Tensor.hpp.

◆ inverse()

template<AnyIndices IndicesT_, AnyQuantities QuantitiesT_, AnyCoordinateSystem CoordinateSystemT_, AbsoluteOrRelative AbsoluteT_>
auto wuzp::Tensor< IndicesT_, QuantitiesT_, CoordinateSystemT_, AbsoluteT_ >::inverse ( ) const
inline

The matrix inverse of a tensor of rank 0 or 2, like Eigen's MatrixBase::inverse(): e.g. the inverse of a linear map T^i_j is a linear map, and the inverse of a metric g_ij, or of a mass matrix M_ij, has two upper indices, g^ij (see Inverse<Indices<...>>).

The units of the components must describe a linear map, M_ij = a_i / b_j, and those of the inverse are (M^-1)_ij = b_i / a_j (see Inverse<TypeMatrixImpl<...>> in Units.hpp). Vectors, covectors and points have no inverse.

Definition at line 309 of file Tensor.hpp.

◆ isApprox()

template<AnyIndices IndicesT_, AnyQuantities QuantitiesT_, AnyCoordinateSystem CoordinateSystemT_, AbsoluteOrRelative AbsoluteT_>
template<typename IndicesOtherT_, typename QuantitiesOtherT_, typename CoordinateSystemOtherT_, typename AbsoluteOtherT_>
bool wuzp::Tensor< IndicesT_, QuantitiesT_, CoordinateSystemT_, AbsoluteT_ >::isApprox ( const Tensor< IndicesOtherT_, QuantitiesOtherT_, CoordinateSystemOtherT_, AbsoluteOtherT_ > & other,
const ValueT precision = Precision<ValueT>::value() ) const
inline

Whether the components of both tensors, which must have the same indices, coordinate system and absoluteness, are approximately equal, relatively, like Eigen's isApprox (https://eigen.tuxfamily.org/dox/classEigen_1_1DenseBase.html#ae8443357b808cd393be1b51974213f9c): ||a - b|| <= precision * min(||a||, ||b||), in the Frobenius norm of the values, with every value matrix backend.

Integer values compare exactly, whatever the precision (see ValuesWrapper::isApprox()). Two consequences of the relative comparison:

  • It cannot compare with zero: only zero is approximately equal to zero. Compare the norm of a small vector with an absolute tolerance instead, e.g. v.norm().getValue() <= 1e-9.
  • For points, the components depend on the origin, and so does the comparison: the same two points are approximately equal far from the origin, but not close to it. Compare the distance of points with an absolute tolerance instead, e.g. (p - q).norm().getValue() <= 1e-9 for a tolerance in the unit of the components. The norm sums the squares of all values, also of components with different units, e.g. m and rad, so the comparison of such tensors depends on the units.

Definition at line 166 of file Tensor.hpp.

◆ norm()

template<AnyIndices IndicesT_, AnyQuantities QuantitiesT_, AnyCoordinateSystem CoordinateSystemT_, AbsoluteOrRelative AbsoluteT_>
auto wuzp::Tensor< IndicesT_, QuantitiesT_, CoordinateSystemT_, AbsoluteT_ >::norm ( ) const
inline

Definition at line 324 of file Tensor.hpp.

◆ random()

template<AnyIndices IndicesT_, AnyQuantities QuantitiesT_, AnyCoordinateSystem CoordinateSystemT_, AbsoluteOrRelative AbsoluteT_>
ThisT wuzp::Tensor< IndicesT_, QuantitiesT_, CoordinateSystemT_, AbsoluteT_ >::random ( )
inlinestatic

Definition at line 133 of file Tensor.hpp.

◆ setQuantities()

template<AnyIndices IndicesT_, AnyQuantities QuantitiesT_, AnyCoordinateSystem CoordinateSystemT_, AbsoluteOrRelative AbsoluteT_>
template<typename ValuesOtherT_, typename UnitsOtherT_>
void wuzp::Tensor< IndicesT_, QuantitiesT_, CoordinateSystemT_, AbsoluteT_ >::setQuantities ( const Quantities< ValuesOtherT_, UnitsOtherT_ > & component)
inline

Definition at line 136 of file Tensor.hpp.

◆ setQuantity() [1/5]

template<AnyIndices IndicesT_, AnyQuantities QuantitiesT_, AnyCoordinateSystem CoordinateSystemT_, AbsoluteOrRelative AbsoluteT_>
template<typename QuantityT_>
requires (Dimension<ThisT>::value <= 1 || internal::isBatch<IndicesT, QuantitiesT>)
void wuzp::Tensor< IndicesT_, QuantitiesT_, CoordinateSystemT_, AbsoluteT_ >::setQuantity ( const int id,
const QuantityT_ & quantity )
inline

Sets the component with the single index id of a vector, a point or a covector, like setQuantity<IdV_>(), but with an index known at run time, which, like setQuantity(rowId, colId, quantity), requires all components to have the same unit.

Definition at line 245 of file Tensor.hpp.

◆ setQuantity() [2/5]

template<AnyIndices IndicesT_, AnyQuantities QuantitiesT_, AnyCoordinateSystem CoordinateSystemT_, AbsoluteOrRelative AbsoluteT_>
template<typename QuantityT_>
void wuzp::Tensor< IndicesT_, QuantitiesT_, CoordinateSystemT_, AbsoluteT_ >::setQuantity ( const int rowId,
const int colId,
const QuantityT_ & quantity )
inline

Definition at line 238 of file Tensor.hpp.

◆ setQuantity() [3/5]

template<AnyIndices IndicesT_, AnyQuantities QuantitiesT_, AnyCoordinateSystem CoordinateSystemT_, AbsoluteOrRelative AbsoluteT_>
template<int IdV_, typename QuantityT_>
requires (Dimension<ThisT>::value <= 1 || internal::isBatch<IndicesT, QuantitiesT>)
void wuzp::Tensor< IndicesT_, QuantitiesT_, CoordinateSystemT_, AbsoluteT_ >::setQuantity ( const QuantityT_ & quantity)
inline

Sets the component with the single index IdV_ of a vector, a point or a covector, e.g. velocity.setQuantity<1>(speed) (see getQuantity<IdV_>()), like setQuantity<RowIdV_, ColIdV_>(), which checks the index and the unit at compile time.

Definition at line 230 of file Tensor.hpp.

◆ setQuantity() [4/5]

template<AnyIndices IndicesT_, AnyQuantities QuantitiesT_, AnyCoordinateSystem CoordinateSystemT_, AbsoluteOrRelative AbsoluteT_>
template<int RowIdV_, int ColIdV_, typename QuantityT_>
void wuzp::Tensor< IndicesT_, QuantitiesT_, CoordinateSystemT_, AbsoluteT_ >::setQuantity ( const QuantityT_ & quantity)
inline

Definition at line 223 of file Tensor.hpp.

◆ setQuantity() [5/5]

template<AnyIndices IndicesT_, AnyQuantities QuantitiesT_, AnyCoordinateSystem CoordinateSystemT_, AbsoluteOrRelative AbsoluteT_>
template<typename QuantityT_>
requires (Dimension<ThisT>::value == 0)
void wuzp::Tensor< IndicesT_, QuantitiesT_, CoordinateSystemT_, AbsoluteT_ >::setQuantity ( const QuantityT_ & quantity)
inline

Definition at line 216 of file Tensor.hpp.

◆ setValues()

template<AnyIndices IndicesT_, AnyQuantities QuantitiesT_, AnyCoordinateSystem CoordinateSystemT_, AbsoluteOrRelative AbsoluteT_>
template<typename ValuesOtherT_>
void wuzp::Tensor< IndicesT_, QuantitiesT_, CoordinateSystemT_, AbsoluteT_ >::setValues ( const ValuesOtherT_ & values)
inline

Definition at line 145 of file Tensor.hpp.

◆ squaredNorm()

template<AnyIndices IndicesT_, AnyQuantities QuantitiesT_, AnyCoordinateSystem CoordinateSystemT_, AbsoluteOrRelative AbsoluteT_>
auto wuzp::Tensor< IndicesT_, QuantitiesT_, CoordinateSystemT_, AbsoluteT_ >::squaredNorm ( ) const
inline

Definition at line 333 of file Tensor.hpp.

◆ std::forward() [1/2]

template<AnyIndices IndicesT_, AnyQuantities QuantitiesT_, AnyCoordinateSystem CoordinateSystemT_, AbsoluteOrRelative AbsoluteT_>
Ts Ts wuzp::Tensor< IndicesT_, QuantitiesT_, CoordinateSystemT_, AbsoluteT_ >::std::forward ( t0 )

◆ std::forward() [2/2]

template<AnyIndices IndicesT_, AnyQuantities QuantitiesT_, AnyCoordinateSystem CoordinateSystemT_, AbsoluteOrRelative AbsoluteT_>
Ts Ts wuzp::Tensor< IndicesT_, QuantitiesT_, CoordinateSystemT_, AbsoluteT_ >::std::forward ( ts )
inline

Definition at line 130 of file Tensor.hpp.

◆ transpose()

template<AnyIndices IndicesT_, AnyQuantities QuantitiesT_, AnyCoordinateSystem CoordinateSystemT_, AbsoluteOrRelative AbsoluteT_>
auto wuzp::Tensor< IndicesT_, QuantitiesT_, CoordinateSystemT_, AbsoluteT_ >::transpose ( ) const
inline

The transpose of the matrix of the components: a vector becomes a covector and vice versa, and the indices of a tensor of rank 2 are swapped, e.g. a linear map T^i_j becomes (T^T)_j^i (see Transpose<Indices<...>>).

The transpose of a vector or a covector lowers or raises its index with the Euclidean metric, which keeps the components, so it requires a Euclidean coordinate system (see Metric): e.g. a force, a vector, becomes the covector that a Jacobian pulls back.

Definition at line 264 of file Tensor.hpp.

◆ zero()

template<AnyIndices IndicesT_, AnyQuantities QuantitiesT_, AnyCoordinateSystem CoordinateSystemT_, AbsoluteOrRelative AbsoluteT_>
ThisT wuzp::Tensor< IndicesT_, QuantitiesT_, CoordinateSystemT_, AbsoluteT_ >::zero ( )
inlinestatic

Definition at line 132 of file Tensor.hpp.

Member Data Documentation

◆ T0

template<AnyIndices IndicesT_, AnyQuantities QuantitiesT_, AnyCoordinateSystem CoordinateSystemT_, AbsoluteOrRelative AbsoluteT_>
Ts wuzp::Tensor< IndicesT_, QuantitiesT_, CoordinateSystemT_, AbsoluteT_ >::T0

Definition at line 130 of file Tensor.hpp.

◆ ts

template<AnyIndices IndicesT_, AnyQuantities QuantitiesT_, AnyCoordinateSystem CoordinateSystemT_, AbsoluteOrRelative AbsoluteT_>
Ts&& wuzp::Tensor< IndicesT_, QuantitiesT_, CoordinateSystemT_, AbsoluteT_ >::ts

Definition at line 129 of file Tensor.hpp.


The documentation for this class was generated from the following files: