16#include "wuzp/trafo/internal/apply_units.hpp"
17#include "wuzp/trafo/internal/pull_back.hpp"
18#include "wuzp/trafo/internal/push_forward.hpp"
19#include "wuzp/trafo/internal/with_quantities.hpp"
24template <
template <
typename,
int,
int>
typename ValuesT_,
typename ValueT_,
AnyCoordinateSystem CoordinateSystemT_,
int DimensionFromV_,
25 int DimensionToV_,
typename... UnitsT_>
34template <
template <
typename,
int,
int>
typename ValuesT_,
typename CoordinateSystemT_,
typename QuantitiesT_>
35struct ActiveLinearTransformationOf {
36 template <
typename... UnitsT_>
37 using WithUnits = ActiveLinearTransformation<ValuesT_, typename QuantitiesT_::ValueT, CoordinateSystemT_, Cols<QuantitiesT_>::value,
38 Rows<QuantitiesT_>::value, UnitsT_...>;
39 using type =
typename ApplyUnits<typename QuantitiesT_::UnitsT, WithUnits>::type;
42template <
template <
typename,
int,
int>
typename ValuesT_,
typename CoordinateSystemT_,
typename QuantitiesT_>
43auto makeActiveLinearTransformation(QuantitiesT_ quantities) {
44 return typename ActiveLinearTransformationOf<ValuesT_, CoordinateSystemT_, QuantitiesT_>::type{std::move(quantities)};
49template <
template <
typename,
int,
int>
typename ValuesT_,
typename ValueT_,
AnyCoordinateSystem CoordinateSystemT_,
int DimensionFromV_,
50 int DimensionToV_,
typename... UnitsT_>
54 ActiveLinearTransformation<ValuesT_, ValueT_, CoordinateSystemT_, DimensionFromV_, DimensionToV_, UnitsT_...>> {
57 using ValuesT = ValuesT_<ValueT_, DimensionToV_, DimensionFromV_>;
64 template <
typename... Args>
72 requires(DimensionFromV_ == DimensionToV_)
82 auto inverse()
const {
return internal::makeActiveLinearTransformation<ValuesT_, CoordinateSystemT_>(quantities_.inverse()); }
86 template <
template <
typename,
int,
int>
typename ValuesOtherT_,
typename ValueOtherT_,
typename CoordinateSystemOtherT_,
87 int DimensionFromOtherV_,
int DimensionToOtherV_,
typename... UnitsOtherT_>
89 DimensionToOtherV_, UnitsOtherT_...>& other,
91 static_assert(std::is_same_v<CoordinateSystemT_, CoordinateSystemOtherT_>,
"Coordinate systems do not match.");
92 return quantities_.isApprox(other.getQuantities(), precision);
101template <
template <
typename,
int,
int>
typename ValuesT_,
typename ValueT_,
typename CoordinateSystemT_,
int DimensionFromV_,
102 int DimensionToV_,
typename... UnitsT_>
104 using type = CoordinateSystemT_;
116template <
template <
typename,
int,
int>
typename ValuesT_,
typename ValueT_,
typename CoordinateSystemT_,
int DimensionFromV_,
117 int DimensionToV_,
typename... UnitsT_,
typename QuantitiesOtherT_,
typename CoordinateSystemOtherT_>
120 template <
typename TransformationT_>
121 static auto transform(
const TransformationT_& transformation,
124 return internal::pullBack<CoordinateSystemT_, CoordinateSystemT_>(transformation.inverse().getQuantities(),
object);
128template <
template <
typename,
int,
int>
typename ValuesT_,
typename ValueT_,
typename CoordinateSystemT_,
int DimensionFromV_,
129 int DimensionToV_,
typename... UnitsT_,
typename QuantitiesOtherT_,
typename CoordinateSystemOtherT_>
132 template <
typename TransformationT_>
133 static auto transform(
const TransformationT_& transformation,
136 return internal::pullBack<CoordinateSystemT_, CoordinateSystemT_>(transformation.inverse().getQuantities(),
object);
140template <
template <
typename,
int,
int>
typename ValuesT_,
typename ValueT_,
typename CoordinateSystemT_,
int DimensionFromV_,
141 int DimensionToV_,
typename... UnitsT_,
typename QuantitiesOtherT_,
typename CoordinateSystemOtherT_,
typename AbsoluteOtherT_>
143 Tensor<
Indices<
Up>, QuantitiesOtherT_, CoordinateSystemOtherT_, AbsoluteOtherT_>> {
144 template <
typename TransformationT_>
145 static auto transform(
const TransformationT_& transformation,
146 const Tensor<
Indices<Up>, QuantitiesOtherT_, CoordinateSystemOtherT_, AbsoluteOtherT_>&
object) {
148 return internal::pushForward<CoordinateSystemT_, CoordinateSystemT_>(transformation.getQuantities(),
object);
152template <
template <
typename,
int,
int>
typename ValuesT_,
typename ValueT_,
typename CoordinateSystemT_,
int DimensionFromV_,
153 int DimensionToV_,
typename... UnitsT_,
typename QuantitiesOtherT_,
typename CoordinateSystemOtherT_>
156 template <
typename TransformationT_>
157 static auto transform(
const TransformationT_& transformation,
160 return internal::withQuantities<CoordinateSystemT_>(
162 innerProduct(transformation.getQuantities(),
innerProduct(
object.getQuantities(), transformation.inverse().getQuantities())));
166template <
template <
typename,
int,
int>
typename ValuesT_,
typename ValueT_,
typename CoordinateSystemT_,
int DimensionFromV_,
167 int DimensionToV_,
typename... UnitsT_,
typename QuantitiesOtherT_,
typename CoordinateSystemOtherT_>
170 template <
typename TransformationT_>
171 static auto transform(
const TransformationT_& transformation,
174 return internal::pushForward<CoordinateSystemT_, CoordinateSystemT_>(transformation.getQuantities(),
object);
179template <
template <
typename,
int,
int>
typename ValuesT_,
typename ValueT_,
typename CoordinateSystemT_,
int DimensionFromV_,
180 int DimensionToV_,
typename... UnitsT_,
template <
typename,
int,
int>
typename ValuesOtherT_,
int DimensionOtherV_,
181 typename ValueOtherT_,
typename CoordinateSystemOtherT_,
typename... UnitsOtherT_>
183 ActiveTranslation<ValuesOtherT_, DimensionOtherV_, ValueOtherT_, CoordinateSystemOtherT_, UnitsOtherT_...>> {
184 template <
typename TransformationT_>
186 const TransformationT_& transformation,
188 return ActiveTranslation<ValuesOtherT_, DimensionOtherV_, ValueOtherT_, CoordinateSystemOtherT_, UnitsOtherT_...>(
189 transformation.transform(
object.getTensor()));
194template <
template <
typename,
int,
int>
typename ValuesT_,
typename ValueT_,
typename CoordinateSystemT_,
int DimensionFromV_,
195 int DimensionToV_,
typename... UnitsT_,
template <
typename,
int,
int>
typename ValuesOtherT_,
typename ValueOtherT_,
196 typename CoordinateSystemOtherT_,
int DimensionFromOtherV_,
int DimensionToOtherV_,
typename... UnitsOtherT_>
199 DimensionToOtherV_, UnitsOtherT_...>> {
200 template <
typename TransformationT_>
201 static auto transform(
const TransformationT_& transformation,
203 DimensionToOtherV_, UnitsOtherT_...>&
object) {
204 return ActiveLinearTransformation<ValuesOtherT_, ValueOtherT_, CoordinateSystemOtherT_, DimensionFromOtherV_, DimensionToOtherV_,
205 UnitsOtherT_...>(transformation.transform(
object.getTensor()).getQuantities());
210template <
template <
typename,
int,
int>
typename ValuesLhsT_,
typename ValueLhsT_,
typename CoordinateSystemLhsT_,
int DimensionFromLhsV_,
211 int DimensionToLhsV_,
typename... UnitsLhsT_,
template <
typename,
int,
int>
typename ValuesRhsT_,
typename ValueRhsT_,
212 typename CoordinateSystemRhsT_,
int DimensionFromRhsV_,
int DimensionToRhsV_,
typename... UnitsRhsT_>
214 ActiveLinearTransformation<ValuesLhsT_, ValueLhsT_, CoordinateSystemLhsT_, DimensionFromLhsV_, DimensionToLhsV_, UnitsLhsT_...>,
215 ActiveLinearTransformation<ValuesRhsT_, ValueRhsT_, CoordinateSystemRhsT_, DimensionFromRhsV_, DimensionToRhsV_, UnitsRhsT_...>> {
216 template <
typename LhsT_,
typename RhsT_>
217 static auto compose(
const LhsT_& lhs,
const RhsT_& rhs) {
218 return internal::makeActiveLinearTransformation<ValuesLhsT_, CoordinateSystemLhsT_>(
219 innerProduct(lhs.getQuantities(), rhs.getQuantities()));
223template <
template <
typename,
int,
int>
typename ValuesLhsT_,
typename ValueLhsT_,
typename CoordinateSystemLhsT_,
int DimensionFromLhsV_,
224 int DimensionToLhsV_,
typename... UnitsLhsT_,
template <
typename,
int,
int>
typename ValuesRhsT_,
typename ValueRhsT_,
225 typename CoordinateSystemRhsT_,
int DimensionFromRhsV_,
int DimensionToRhsV_,
typename... UnitsRhsT_>
229 UnitsRhsT_...>& rhs) {
230 static_assert(std::is_same_v<CoordinateSystemLhsT_, CoordinateSystemRhsT_>,
"Coordinate systems do not match.");
231 return lhs.getQuantities() == rhs.getQuantities();
234template <
template <
typename,
int,
int>
typename ValuesLhsT_,
typename ValueLhsT_,
typename CoordinateSystemLhsT_,
int DimensionFromLhsV_,
235 int DimensionToLhsV_,
typename... UnitsLhsT_,
template <
typename,
int,
int>
typename ValuesRhsT_,
typename ValueRhsT_,
236 typename CoordinateSystemRhsT_,
int DimensionFromRhsV_,
int DimensionToRhsV_,
typename... UnitsRhsT_>
240 UnitsRhsT_...>& rhs) {
241 return !(lhs == rhs);
244template <
template <
typename,
int,
int>
typename ValuesT_,
typename ValueT_,
typename CoordinateSystemT_,
int DimensionFromV_,
245 int DimensionToV_,
typename... UnitsT_>
An active translation, which moves points by a vector t, p' = p + t, and leaves vectors,...
Container to store quantities.
A tensor of rank 0, 1 or 2, whose components are quantities, expressed in a coordinate system,...
Any coordinate system: a specialization of CoordinateSystem, including the intermediate ones of trans...
The alias template ValueMatrix<ValueT_, RowsV_, ColsV_> of any value matrix backend,...
Whether constructing a Class from the arguments copies or moves it, i.e. whether they are a single Cl...
bool operator!=(const Quantities< ValuesLhsT_, UnitsLhsT_ > &lhs, const Quantities< ValuesRhsT_, UnitsRhsT_ > &rhs)
std::ostream & operator<<(std::ostream &lhs, const Quantities< ValuesT_, UnitsT_ > &rhs)
auto innerProduct(const Quantities< ValuesLhsT_, UnitsLhsT_ > &lhs, const Quantities< ValuesRhsT_, UnitsRhsT_ > &rhs)
internal::AbsoluteImpl< false > Relative
bool operator==(const Quantities< ValuesLhsT_, UnitsLhsT_ > &lhs, const Quantities< ValuesRhsT_, UnitsRhsT_ > &rhs)
typename CreateTypeMatrix< RowsV_, ColsV_, Types... >::type TypeMatrix
A matrix storing types at compile-time.
The composition lhs * rhs of two transformations, which applies rhs first, then lhs: (lhs * rhs)....
A lower, or covariant, index, e.g. of a covector w_i, whose components transform with the inverse of ...
The indices of a tensor, in their order, e.g. Indices<Up, Down> for a linear map T^i_j,...
static constexpr ValueT_ value()
An upper, or contravariant, index, e.g. of a vector v^i, whose components transform like the coordina...