27 #ifndef CDPL_MATH_VECTOREXPRESSION_HPP
28 #define CDPL_MATH_VECTOREXPRESSION_HPP
30 #include <type_traits>
46 template <
typename E,
typename F>
51 typedef F FunctorType;
53 typedef typename E::ConstClosureType ExpressionClosureType;
69 return expr.getSize();
74 return FunctorType::apply(expr(i));
79 return FunctorType::apply(expr[i]);
83 ExpressionClosureType expr;
86 template <
typename E,
typename F>
94 template <
typename E1,
typename E2,
typename F>
99 typedef F FunctorType;
100 typedef E1 Expression1Type;
101 typedef E2 Expression2Type;
102 typedef typename E1::ConstClosureType Expression1ClosureType;
103 typedef typename E2::ConstClosureType Expression2ClosureType;
115 expr1(e1), expr2(e2) {}
124 return FunctorType::apply(expr1(i), expr2(i));
129 return FunctorType::apply(expr1[i], expr2[i]);
133 Expression1ClosureType expr1;
134 Expression2ClosureType expr2;
137 template <
typename E1,
typename E2,
typename F>
145 template <
typename E1,
typename E2,
typename F>
150 typedef F FunctorType;
151 typedef E1 Expression1Type;
152 typedef E2 Expression2Type;
153 typedef typename E1::ConstClosureType Expression1ClosureType;
154 typedef typename E2::ConstClosureType Expression2ClosureType;
166 expr1(e1), expr2(e2) {}
175 return FunctorType::apply(expr1, expr2, i);
180 return FunctorType::apply(expr1, expr2, i);
184 Expression1ClosureType expr1;
185 Expression2ClosureType expr2;
188 template <
typename E1,
typename E2,
typename F>
196 template <
typename E1,
typename E2,
typename F>
201 typedef F FunctorType;
202 typedef E1 Expression1Type;
203 typedef E2 Expression2Type;
204 typedef const E1 Expression1ClosureType;
205 typedef typename E2::ConstClosureType Expression2ClosureType;
217 expr1(e1), expr2(e2) {}
221 return expr2.getSize();
226 return FunctorType::apply(expr1, expr2(i));
231 return FunctorType::apply(expr1, expr2[i]);
235 Expression1ClosureType expr1;
236 Expression2ClosureType expr2;
239 template <
typename E1,
typename E2,
typename F>
247 template <
typename E1,
typename E2,
typename F>
252 typedef F FunctorType;
253 typedef E1 Expression1Type;
254 typedef E2 Expression2Type;
255 typedef typename E1::ConstClosureType Expression1ClosureType;
256 typedef const E2 Expression2ClosureType;
268 expr1(e1), expr2(e2) {}
272 return expr1.getSize();
277 return FunctorType::apply(expr1(i), expr2);
282 return FunctorType::apply(expr1[i], expr2);
286 Expression1ClosureType expr1;
287 Expression2ClosureType expr2;
290 template <
typename E1,
typename E2,
typename F>
298 template <
typename E1,
typename E2,
typename F>
303 typedef F FunctorType;
304 typedef E1 Expression1Type;
305 typedef E2 Expression2Type;
306 typedef typename E1::ConstClosureType Expression1ClosureType;
307 typedef typename E2::ConstClosureType Expression2ClosureType;
319 expr1(e1), expr2(e2) {}
323 return expr2.getSize();
328 return FunctorType::apply(expr1, expr2, i);
333 return FunctorType::apply(expr1, expr2, i);
337 Expression1ClosureType expr1;
338 Expression2ClosureType expr2;
341 template <
typename E1,
typename E2,
typename F>
349 template <
typename E>
355 return ExpressionType(e());
358 template <
typename E>
365 template <
typename E1,
typename E2>
366 typename VectorBinary1Traits<E1, E2, ScalarAddition<typename E1::ValueType, typename E2::ValueType> >::ResultType
372 return ExpressionType(e1(), e2());
375 template <
typename E1,
typename E2>
376 typename VectorBinary1Traits<E1, E2, ScalarSubtraction<typename E1::ValueType, typename E2::ValueType> >::ResultType
382 return ExpressionType(e1(), e2());
385 template <
typename E,
typename T>
386 typename std::enable_if<IsScalar<T>::value,
typename Scalar2VectorBinaryTraits<E, T, ScalarMultiplication<typename E::ValueType, T> >::ResultType>::type
392 return ExpressionType(e(), t);
395 template <
typename T,
typename E>
396 typename std::enable_if<IsScalar<T>::value,
typename Scalar1VectorBinaryTraits<T, E, ScalarMultiplication<T, typename E::ValueType> >::ResultType>::type
402 return ExpressionType(t, e());
405 template <
typename E,
typename T>
406 typename std::enable_if<IsScalar<T>::value,
typename Scalar2VectorBinaryTraits<E, T, ScalarDivision<typename E::ValueType, T> >::ResultType>::type
412 return ExpressionType(e(), t);
415 template <
typename E1,
typename E2>
422 template <
typename E1,
typename E2>
429 template <
typename E1,
typename E2,
typename T>
436 template <
typename E>
437 typename VectorUnaryTraits<E, ScalarConjugation<typename E::ValueType> >::ResultType
442 return ExpressionType(e());
445 template <
typename E>
446 typename VectorUnaryTraits<E, ScalarConjugation<typename E::ValueType> >::ResultType
451 return ExpressionType(e());
454 template <
typename E>
455 typename VectorUnaryTraits<E, ScalarReal<typename E::ValueType> >::ResultType
460 return ExpressionType(e());
463 template <
typename E>
464 typename VectorUnaryTraits<E, ScalarImaginary<typename E::ValueType> >::ResultType
469 return ExpressionType(e());
472 template <
typename E1,
typename E2>
473 typename VectorBinary1Traits<E1, E2, ScalarDivision<typename E1::ValueType, typename E2::ValueType> >::ResultType
479 return ExpressionType(e1(), e2());
482 template <
typename E1,
typename E2>
483 typename VectorBinary1Traits<E1, E2, ScalarMultiplication<typename E1::ValueType, typename E2::ValueType> >::ResultType
489 return ExpressionType(e1(), e2());
492 template <
typename E1,
typename E2>
493 typename VectorBinary2Traits<E1, E2, VectorCrossProduct<E1, E2> >::ResultType
499 return ExpressionType(e1(), e2());
502 template <
typename E1,
typename E2>
509 template <
typename E1,
typename E2,
typename T>
516 template <
typename E>
523 template <
typename E>
530 template <
typename E>
537 template <
typename E>
544 template <
typename E>
551 template <
typename E>
558 template <
typename E>
565 template <
typename E>
572 template <
typename E1,
typename E2>
573 typename QuaternionVectorBinaryTraits<E1, E2, QuaternionVectorRotation<E1, E2> >::ResultType
578 return ExpressionType(e1(), e2());
Definition of exception classes.
Definition of various preprocessor macros for error checking.
#define CDPL_MATH_CHECK_SIZE_EQUALITY(size1, size2, e)
Definition: Check.hpp:62
Definition of basic expression types.
Definition of various functors.
Definition of type traits.
Thrown to indicate that the size of a (multidimensional) array is not correct.
Definition: Base/Exceptions.hpp:133
E ExpressionType
Definition: Expression.hpp:42
Definition: Expression.hpp:98
Definition: VectorExpression.hpp:300
SelfType ClosureType
Definition: VectorExpression.hpp:314
SizeType getSize() const
Definition: VectorExpression.hpp:321
ConstReference operator()(SizeType i) const
Definition: VectorExpression.hpp:326
E2::SizeType SizeType
Definition: VectorExpression.hpp:315
E2::DifferenceType DifferenceType
Definition: VectorExpression.hpp:316
QuaternionVectorBinary(const Expression1Type &e1, const Expression2Type &e2)
Definition: VectorExpression.hpp:318
const ValueType Reference
Definition: VectorExpression.hpp:312
const ValueType ConstReference
Definition: VectorExpression.hpp:311
const SelfType ConstClosureType
Definition: VectorExpression.hpp:313
F::ResultType ValueType
Definition: VectorExpression.hpp:310
ConstReference operator[](SizeType i) const
Definition: VectorExpression.hpp:331
Definition: VectorExpression.hpp:198
Scalar1VectorBinary(const Expression1Type &e1, const Expression2Type &e2)
Definition: VectorExpression.hpp:216
const ValueType ConstReference
Definition: VectorExpression.hpp:209
ConstReference operator[](SizeType i) const
Definition: VectorExpression.hpp:229
E2::DifferenceType DifferenceType
Definition: VectorExpression.hpp:214
const ValueType Reference
Definition: VectorExpression.hpp:210
SelfType ClosureType
Definition: VectorExpression.hpp:212
const SelfType ConstClosureType
Definition: VectorExpression.hpp:211
E2::SizeType SizeType
Definition: VectorExpression.hpp:213
ConstReference operator()(SizeType i) const
Definition: VectorExpression.hpp:224
SizeType getSize() const
Definition: VectorExpression.hpp:219
F::ResultType ValueType
Definition: VectorExpression.hpp:208
Definition: VectorExpression.hpp:249
const SelfType ConstClosureType
Definition: VectorExpression.hpp:262
E1::DifferenceType DifferenceType
Definition: VectorExpression.hpp:265
F::ResultType ValueType
Definition: VectorExpression.hpp:259
const ValueType ConstReference
Definition: VectorExpression.hpp:260
Scalar2VectorBinary(const Expression1Type &e1, const Expression2Type &e2)
Definition: VectorExpression.hpp:267
SelfType ClosureType
Definition: VectorExpression.hpp:263
SizeType getSize() const
Definition: VectorExpression.hpp:270
ConstReference operator[](SizeType i) const
Definition: VectorExpression.hpp:280
E1::SizeType SizeType
Definition: VectorExpression.hpp:264
ConstReference operator()(SizeType i) const
Definition: VectorExpression.hpp:275
const ValueType Reference
Definition: VectorExpression.hpp:261
Definition: VectorExpression.hpp:96
ConstReference operator()(SizeType i) const
Definition: VectorExpression.hpp:122
ConstReference operator[](SizeType i) const
Definition: VectorExpression.hpp:127
const ValueType Reference
Definition: VectorExpression.hpp:108
CommonType< typename E1::DifferenceType, typename E2::DifferenceType >::Type DifferenceType
Definition: VectorExpression.hpp:112
VectorBinary1(const Expression1Type &e1, const Expression2Type &e2)
Definition: VectorExpression.hpp:114
F::ResultType ValueType
Definition: VectorExpression.hpp:106
const SelfType ConstClosureType
Definition: VectorExpression.hpp:109
SizeType getSize() const
Definition: VectorExpression.hpp:117
SelfType ClosureType
Definition: VectorExpression.hpp:110
const ValueType ConstReference
Definition: VectorExpression.hpp:107
CommonType< typename E1::SizeType, typename E2::SizeType >::Type SizeType
Definition: VectorExpression.hpp:111
Definition: VectorExpression.hpp:147
SizeType getSize() const
Definition: VectorExpression.hpp:168
ConstReference operator()(SizeType i) const
Definition: VectorExpression.hpp:173
CommonType< typename E1::SizeType, typename E2::SizeType >::Type SizeType
Definition: VectorExpression.hpp:162
F::ResultType ValueType
Definition: VectorExpression.hpp:157
const SelfType ConstClosureType
Definition: VectorExpression.hpp:160
const ValueType Reference
Definition: VectorExpression.hpp:159
VectorBinary2(const Expression1Type &e1, const Expression2Type &e2)
Definition: VectorExpression.hpp:165
ConstReference operator[](SizeType i) const
Definition: VectorExpression.hpp:178
SelfType ClosureType
Definition: VectorExpression.hpp:161
const ValueType ConstReference
Definition: VectorExpression.hpp:158
CommonType< typename E1::DifferenceType, typename E2::DifferenceType >::Type DifferenceType
Definition: VectorExpression.hpp:163
Definition: Expression.hpp:54
Definition: VectorExpression.hpp:48
E::SizeType SizeType
Definition: VectorExpression.hpp:61
SelfType ClosureType
Definition: VectorExpression.hpp:60
const SelfType ConstClosureType
Definition: VectorExpression.hpp:59
E::DifferenceType DifferenceType
Definition: VectorExpression.hpp:62
VectorUnary(const ExpressionType &e)
Definition: VectorExpression.hpp:64
F::ResultType ValueType
Definition: VectorExpression.hpp:56
const ValueType Reference
Definition: VectorExpression.hpp:58
ConstReference operator[](SizeType i) const
Definition: VectorExpression.hpp:77
const ValueType ConstReference
Definition: VectorExpression.hpp:57
ConstReference operator()(SizeType i) const
Definition: VectorExpression.hpp:72
SizeType getSize() const
Definition: VectorExpression.hpp:67
constexpr unsigned int T
Specifies Hydrogen (Tritium).
Definition: AtomType.hpp:67
constexpr unsigned int F
Specifies Fluorine.
Definition: AtomType.hpp:107
constexpr unsigned int E
Specifies that the stereocenter has E configuration.
Definition: CIPDescriptor.hpp:96
VectorBinary2Traits< E1, E2, VectorCrossProduct< E1, E2 > >::ResultType crossProd(const VectorExpression< E1 > &e1, const VectorExpression< E2 > &e2)
Definition: VectorExpression.hpp:494
GridBinary1Traits< E1, E2, ScalarMultiplication< typename E1::ValueType, typename E2::ValueType > >::ResultType elemProd(const GridExpression< E1 > &e1, const GridExpression< E2 > &e2)
Definition: GridExpression.hpp:406
MatrixTranspose< E > trans(MatrixExpression< E > &e)
Definition: MatrixExpression.hpp:941
GridUnaryTraits< E, ScalarConjugation< typename E::ValueType > >::ResultType herm(const GridExpression< E > &e)
Definition: GridExpression.hpp:369
GridUnaryTraits< E, ScalarConjugation< typename E::ValueType > >::ResultType conj(const GridExpression< E > &e)
Definition: GridExpression.hpp:360
VectorNormInfinityIndex< E >::ResultType normInfIndex(const VectorExpression< E > &e)
Definition: VectorExpression.hpp:546
std::enable_if< std::is_arithmetic< T >::value, typename GridToleranceEquality< E1, E2, T >::ResultType >::type equals(const GridExpression< E1 > &e1, const GridExpression< E2 > &e2, const T &eps)
Definition: GridExpression.hpp:353
VectorInnerProduct< E1, E2 >::ResultType innerProd(const VectorExpression< E1 > &e1, const VectorExpression< E2 > &e2)
Definition: VectorExpression.hpp:504
std::enable_if< IsScalar< T >::value, typename Scalar2GridBinaryTraits< E, T, ScalarDivision< typename E::ValueType, T > >::ResultType >::type operator/(const GridExpression< E > &e, const T &t)
Definition: GridExpression.hpp:329
GridUnaryTraits< E, ScalarReal< typename E::ValueType > >::ResultType real(const GridExpression< E > &e)
Definition: GridExpression.hpp:378
QuaternionNorm2< E >::ResultType norm2(const QuaternionExpression< E > &e)
Definition: QuaternionExpression.hpp:804
GridEquality< E1, E2 >::ResultType operator!=(const GridExpression< E1 > &e1, const GridExpression< E2 > &e2)
Definition: GridExpression.hpp:346
VectorAngleCosine< E1, E2, T >::ResultType angleCos(const VectorExpression< E1 > &e1, const VectorExpression< E2 > &e2, const T &sd, bool clamp=true)
Definition: VectorExpression.hpp:511
VectorNorm2< E >::ResultType length(const VectorExpression< E > &e)
Definition: VectorExpression.hpp:553
GridEquality< E1, E2 >::ResultType operator==(const GridExpression< E1 > &e1, const GridExpression< E2 > &e2)
Definition: GridExpression.hpp:339
std::enable_if< IsScalar< T >::value, typename Scalar2GridBinaryTraits< E, T, ScalarMultiplication< typename E::ValueType, T > >::ResultType >::type operator*(const GridExpression< E > &e, const T &t)
Definition: GridExpression.hpp:309
GridBinary1Traits< E1, E2, ScalarDivision< typename E1::ValueType, typename E2::ValueType > >::ResultType elemDiv(const GridExpression< E1 > &e1, const GridExpression< E2 > &e2)
Definition: GridExpression.hpp:396
GridUnaryTraits< E, ScalarImaginary< typename E::ValueType > >::ResultType imag(const GridExpression< E > &e)
Definition: GridExpression.hpp:387
MatrixNormInfinity< E >::ResultType normInf(const MatrixExpression< E > &e)
Definition: MatrixExpression.hpp:917
QuaternionVectorBinaryTraits< E1, E2, QuaternionVectorRotation< E1, E2 > >::ResultType rotate(const QuaternionExpression< E1 > &e1, const VectorExpression< E2 > &e2)
Definition: VectorExpression.hpp:574
GridUnaryTraits< E, ScalarNegation< typename E::ValueType > >::ResultType operator-(const GridExpression< E > &e)
Definition: GridExpression.hpp:272
GridElementSum< E >::ResultType sum(const GridExpression< E > &e)
Definition: GridExpression.hpp:416
MatrixNorm1< E >::ResultType norm1(const MatrixExpression< E > &e)
Definition: MatrixExpression.hpp:903
const E & operator+(const GridExpression< E > &e)
Definition: GridExpression.hpp:282
The namespace of the Chemical Data Processing Library.
std::common_type< T1, T2 >::type Type
Definition: CommonType.hpp:43
Definition: VectorExpression.hpp:343
QuaternionVectorBinary< E1, E2, F > ExpressionType
Definition: VectorExpression.hpp:345
ExpressionType ResultType
Definition: VectorExpression.hpp:346
Definition: VectorExpression.hpp:241
ExpressionType ResultType
Definition: VectorExpression.hpp:244
Scalar1VectorBinary< E1, E2, F > ExpressionType
Definition: VectorExpression.hpp:243
Definition: VectorExpression.hpp:292
ExpressionType ResultType
Definition: VectorExpression.hpp:295
Scalar2VectorBinary< E1, E2, F > ExpressionType
Definition: VectorExpression.hpp:294
Definition: Functional.hpp:211
Definition: Functional.hpp:253
Definition: Functional.hpp:239
Definition: Functional.hpp:225
static ResultType apply(const VectorExpression< V1 > &e1, const VectorExpression< V2 > &e2, const T &sd, bool clamp)
Definition: Functional.hpp:298
CommonType< typename VectorInnerProduct< V1, V2 >::ResultType, T >::Type ResultType
Definition: Functional.hpp:296
Definition: VectorExpression.hpp:139
ExpressionType ResultType
Definition: VectorExpression.hpp:142
VectorBinary1< E1, E2, F > ExpressionType
Definition: VectorExpression.hpp:141
Definition: VectorExpression.hpp:190
VectorBinary2< E1, E2, F > ExpressionType
Definition: VectorExpression.hpp:192
ExpressionType ResultType
Definition: VectorExpression.hpp:193
Definition: Functional.hpp:384
VectorScalarUnaryFunctor< V >::ResultType ResultType
Definition: Functional.hpp:423
static ResultType apply(const VectorExpression< V > &e)
Definition: Functional.hpp:425
VectorBooleanBinaryFunctor< V1, V2 >::ResultType ResultType
Definition: Functional.hpp:324
static ResultType apply(const VectorExpression< V1 > &e1, const VectorExpression< V2 > &e2)
Definition: Functional.hpp:326
VectorScalarBinaryFunctor< V1, V2 >::ResultType ResultType
Definition: Functional.hpp:276
static ResultType apply(const VectorExpression< V1 > &e1, const VectorExpression< V2 > &e2)
Definition: Functional.hpp:278
static ResultType apply(const VectorExpression< V > &e)
Definition: Functional.hpp:455
VectorScalarRealUnaryFunctor< V >::ResultType ResultType
Definition: Functional.hpp:453
VectorScalarRealUnaryFunctor< V >::ResultType ResultType
Definition: Functional.hpp:474
static ResultType apply(const VectorExpression< V > &e)
Definition: Functional.hpp:476
VectorScalarIndexUnaryFunctor< V >::ResultType ResultType
Definition: Functional.hpp:532
static ResultType apply(const VectorExpression< V > &e)
Definition: Functional.hpp:534
static ResultType apply(const VectorExpression< V > &e)
Definition: Functional.hpp:500
VectorScalarRealUnaryFunctor< V >::ResultType ResultType
Definition: Functional.hpp:498
Scalar3VectorBooleanTernaryFunctor< V1, V2, T >::ResultType ResultType
Definition: Functional.hpp:355
static ResultType apply(const VectorExpression< V1 > &e1, const VectorExpression< V2 > &e2, Argument3Type epsilon)
Definition: Functional.hpp:358
Definition: VectorExpression.hpp:88
ExpressionType ResultType
Definition: VectorExpression.hpp:91
VectorUnary< E, F > ExpressionType
Definition: VectorExpression.hpp:90