39 static constexpr int RankV =
static_cast<int>(
sizeof...(VariancesT_));
45template <
typename VarianceT_>
57template <
typename IndicesT_>
61template <
typename Variance0T_,
typename... VariancesT_>
62struct FirstIndex<Indices<Variance0T_, VariancesT_...>> {
63 using type = Variance0T_;
67template <
typename IndicesT_>
71template <
typename Variance0T_,
typename... VariancesT_>
72struct LastIndex<Indices<Variance0T_, VariancesT_...>> {
73 using type = std::tuple_element_t<
sizeof...(VariancesT_), std::tuple<Variance0T_, VariancesT_...>>;
77template <
typename IndicesT_>
78struct DropFirstIndex {
79 using type = Indices<>;
81template <
typename Variance0T_,
typename... VariancesT_>
82struct DropFirstIndex<Indices<Variance0T_, VariancesT_...>> {
83 using type = Indices<VariancesT_...>;
87template <
typename IndicesT_>
89 using type = Indices<>;
91template <
typename Variance0T_,
typename Variance1T_>
92struct DropLastIndex<Indices<Variance0T_, Variance1T_>> {
93 using type = Indices<Variance0T_>;
97template <
typename IndicesLhsT_,
typename IndicesRhsT_>
98struct ConcatenateIndices;
99template <
typename... VariancesLhsT_,
typename... VariancesRhsT_>
100struct ConcatenateIndices<Indices<VariancesLhsT_...>, Indices<VariancesRhsT_...>> {
101 using type = Indices<VariancesLhsT_..., VariancesRhsT_...>;
106template <
typename... VariancesLhsT_,
typename... VariancesRhsT_>
108 static_assert(std::is_same_v<
Indices<VariancesLhsT_...>,
Indices<VariancesRhsT_...>>,
"Indices do not match.");
112template <
typename... VariancesLhsT_,
typename... VariancesRhsT_>
114 static_assert(std::is_same_v<
Indices<VariancesLhsT_...>,
Indices<VariancesRhsT_...>>,
"Indices do not match.");
126template <
typename... VariancesLhsT_,
typename... VariancesRhsT_>
128 static_assert(
sizeof...(VariancesLhsT_) == 0 ||
sizeof...(VariancesRhsT_) == 0,
129 "A tensor can only be multiplied by a scalar, a quantity or a tensor of rank 0. Use innerProduct, outerProduct or "
130 "cwiseProduct for other products.");
135template <
typename... VariancesLhsT_,
typename... VariancesRhsT_>
137 static_assert(
sizeof...(VariancesRhsT_) == 0,
138 "A tensor can only be divided by a scalar, a quantity or a tensor of rank 0. Use cwiseQuotient for elementwise "
149template <
typename... VariancesLhsT_,
typename... VariancesRhsT_>
152 using LhsT =
Indices<VariancesLhsT_...>;
153 using RhsT =
Indices<VariancesRhsT_...>;
154 static constexpr bool HasIndicesV =
sizeof...(VariancesLhsT_) > 0 &&
sizeof...(VariancesRhsT_) > 0;
155 static constexpr bool OppositeV = !std::is_same_v<typename internal::LastIndex<LhsT>::type,
typename internal::FirstIndex<RhsT>::type>;
159 static_assert(HasIndicesV,
160 "An inner product contracts an index of each tensor, but a tensor of rank 0 has none. Multiply by it instead.");
161 static_assert(!HasIndicesV || OppositeV,
162 "An inner product contracts an upper with a lower index, but the last index of the left-hand side and the first index "
163 "of the right-hand side are both upper or both lower.");
164 using type =
typename internal::ConcatenateIndices<typename internal::DropLastIndex<LhsT>::type,
165 typename internal::DropFirstIndex<RhsT>::type>
::type;
170template <
typename... VariancesLhsT_,
typename... VariancesRhsT_>
173 static constexpr bool HasIndicesV =
sizeof...(VariancesLhsT_) > 0 &&
sizeof...(VariancesRhsT_) > 0;
176 static_assert(HasIndicesV,
"An outer product with a tensor of rank 0 is a product. Multiply by it instead.");
177 static_assert(!HasIndicesV ||
sizeof...(VariancesLhsT_) +
sizeof...(VariancesRhsT_) <= 2,
178 "The outer product would have rank 3 or more, which is not supported.");
184template <
typename... VariancesLhsT_,
typename... VariancesRhsT_>
187 "Cross product is only defined for vectors.");
200template <
typename VarianceT_>
204template <
typename Variance0T_,
typename Variance1T_>
219template <
typename VarianceT_>
222 "A vector or a covector has no inverse. Use cwiseInverse() for the reciprocals of its components.");
225template <
typename Variance0T_,
typename Variance1T_>
242template <
typename VarianceT_>
247template <
typename Variance0T_,
typename Variance1T_>
249 static_assert(!std::is_same_v<Variance0T_, Variance1T_>,
250 "The determinant of a tensor with two upper or two lower indices depends on the basis. Use getQuantities().determinant() "
251 "for the determinant of its components.");
Up or Down: whether an index of a tensor is upper (contravariant) or lower (covariant).
Indices< VariancesLhsT_... > type
Indices< VariancesLhsT_... > type
A lower, or covariant, index, e.g. of a covector w_i, whose components transform with the inverse of ...
False for every type, so that a static_assert on it fails only when the template that names it is ins...
The indices of a tensor, in their order, e.g. Indices<Up, Down> for a linear map T^i_j,...
static constexpr int RankV
typename internal::ConcatenateIndices< typename internal::DropLastIndex< LhsT >::type, typename internal::DropFirstIndex< RhsT >::type >::type type
Indices< typename internal::Flip< Variance1T_ >::type, typename internal::Flip< Variance0T_ >::type > type
Indices< VarianceT_ > type
The inverse: the matrix inverse of a matrix, like Eigen's MatrixBase::inverse(), and the reciprocal o...
Indices< VariancesLhsT_..., VariancesRhsT_... > type
std::conditional_t< sizeof...(VariancesLhsT_)==0, Indices< VariancesRhsT_... >, Indices< VariancesLhsT_... > > type
Indices< VariancesLhsT_... > type
Indices< Variance1T_, Variance0T_ > type
Indices< typename internal::Flip< VarianceT_ >::type > type
An upper, or contravariant, index, e.g. of a vector v^i, whose components transform like the coordina...