27 #ifndef CDPL_MATH_GRIDEXPRESSION_HPP
28 #define CDPL_MATH_GRIDEXPRESSION_HPP
30 #include <type_traits>
49 template <
typename E,
typename F>
54 typedef F FunctorType;
56 typedef typename E::ConstClosureType ExpressionClosureType;
72 return expr.getSize1();
77 return expr.getSize2();
82 return expr.getSize3();
87 return FunctorType::apply(expr(i, j, k));
91 ExpressionClosureType expr;
94 template <
typename E,
typename F>
102 template <
typename E1,
typename E2,
typename F>
107 typedef F FunctorType;
108 typedef E1 Expression1Type;
109 typedef E2 Expression2Type;
110 typedef typename E1::ConstClosureType Expression1ClosureType;
111 typedef typename E2::ConstClosureType Expression2ClosureType;
122 GridBinary1(
const Expression1Type& e1,
const Expression2Type& e2):
123 expr1(e1), expr2(e2) {}
142 return FunctorType::apply(expr1(i, j, k), expr2(i, j, k));
146 Expression1ClosureType expr1;
147 Expression2ClosureType expr2;
150 template <
typename E1,
typename E2,
typename F>
158 template <
typename E1,
typename E2,
typename F>
163 typedef F FunctorType;
164 typedef E1 Expression1Type;
165 typedef E2 Expression2Type;
166 typedef const E1 Expression1ClosureType;
167 typedef typename E2::ConstClosureType Expression2ClosureType;
179 expr1(e1), expr2(e2) {}
183 return expr2.getSize1();
188 return expr2.getSize2();
193 return expr2.getSize3();
198 return FunctorType::apply(expr1, expr2(i, j, k));
202 Expression1ClosureType expr1;
203 Expression2ClosureType expr2;
206 template <
typename E1,
typename E2,
typename F>
214 template <
typename E1,
typename E2,
typename F>
219 typedef F FunctorType;
220 typedef E1 Expression1Type;
221 typedef E2 Expression2Type;
222 typedef typename E1::ConstClosureType Expression1ClosureType;
223 typedef const E2 Expression2ClosureType;
235 expr1(e1), expr2(e2) {}
239 return expr1.getSize1();
244 return expr1.getSize2();
249 return expr1.getSize3();
254 return FunctorType::apply(expr1(i, j, k), expr2);
258 Expression1ClosureType expr1;
259 Expression2ClosureType expr2;
262 template <
typename E1,
typename E2,
typename F>
270 template <
typename E>
276 return ExpressionType(e());
279 template <
typename E>
287 template <
typename E1,
typename E2>
288 typename GridBinary1Traits<E1, E2, ScalarAddition<typename E1::ValueType, typename E2::ValueType> >::ResultType
294 return ExpressionType(e1(), e2());
297 template <
typename E1,
typename E2>
298 typename GridBinary1Traits<E1, E2, ScalarSubtraction<typename E1::ValueType, typename E2::ValueType> >::ResultType
304 return ExpressionType(e1(), e2());
307 template <
typename E,
typename T>
308 typename std::enable_if<IsScalar<T>::value,
typename Scalar2GridBinaryTraits<E, T, ScalarMultiplication<typename E::ValueType, T> >::ResultType>::type
314 return ExpressionType(e(), t);
317 template <
typename T,
typename E>
318 typename std::enable_if<IsScalar<T>::value,
typename Scalar1GridBinaryTraits<T, E, ScalarMultiplication<T, typename E::ValueType> >::ResultType>::type
324 return ExpressionType(t, e());
327 template <
typename E,
typename T>
328 typename std::enable_if<IsScalar<T>::value,
typename Scalar2GridBinaryTraits<E, T, ScalarDivision<typename E::ValueType, T> >::ResultType>::type
334 return ExpressionType(e(), t);
337 template <
typename E1,
typename E2>
344 template <
typename E1,
typename E2>
351 template <
typename E1,
typename E2,
typename T>
358 template <
typename E>
359 typename GridUnaryTraits<E, ScalarConjugation<typename E::ValueType> >::ResultType
364 return ExpressionType(e());
367 template <
typename E>
368 typename GridUnaryTraits<E, ScalarConjugation<typename E::ValueType> >::ResultType
373 return ExpressionType(e());
376 template <
typename E>
377 typename GridUnaryTraits<E, ScalarReal<typename E::ValueType> >::ResultType
382 return ExpressionType(e());
385 template <
typename E>
386 typename GridUnaryTraits<E, ScalarImaginary<typename E::ValueType> >::ResultType
391 return ExpressionType(e());
394 template <
typename E1,
typename E2>
395 typename GridBinary1Traits<E1, E2, ScalarDivision<typename E1::ValueType, typename E2::ValueType> >::ResultType
401 return ExpressionType(e1(), e2());
404 template <
typename E1,
typename E2>
405 typename GridBinary1Traits<E1, E2, ScalarMultiplication<typename E1::ValueType, typename E2::ValueType> >::ResultType
411 return ExpressionType(e1(), e2());
414 template <
typename E>
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: GridExpression.hpp:104
F::ResultType ValueType
Definition: GridExpression.hpp:114
CommonType< typename E1::SizeType, typename E2::SizeType >::Type SizeType
Definition: GridExpression.hpp:119
ConstReference operator()(SizeType i, SizeType j, SizeType k) const
Definition: GridExpression.hpp:140
GridBinary1(const Expression1Type &e1, const Expression2Type &e2)
Definition: GridExpression.hpp:122
SizeType getSize1() const
Definition: GridExpression.hpp:125
const ValueType ConstReference
Definition: GridExpression.hpp:115
SelfType ClosureType
Definition: GridExpression.hpp:118
CommonType< typename E1::DifferenceType, typename E2::DifferenceType >::Type DifferenceType
Definition: GridExpression.hpp:120
const SelfType ConstClosureType
Definition: GridExpression.hpp:117
SizeType getSize3() const
Definition: GridExpression.hpp:135
const ValueType Reference
Definition: GridExpression.hpp:116
SizeType getSize2() const
Definition: GridExpression.hpp:130
Definition: Expression.hpp:120
Definition: GridExpression.hpp:51
E::SizeType SizeType
Definition: GridExpression.hpp:64
SizeType getSize2() const
Definition: GridExpression.hpp:75
const SelfType ConstClosureType
Definition: GridExpression.hpp:62
SizeType getSize1() const
Definition: GridExpression.hpp:70
SizeType getSize3() const
Definition: GridExpression.hpp:80
SelfType ClosureType
Definition: GridExpression.hpp:63
E::DifferenceType DifferenceType
Definition: GridExpression.hpp:65
GridUnary(const ExpressionType &e)
Definition: GridExpression.hpp:67
ConstReference operator()(SizeType i, SizeType j, SizeType k) const
Definition: GridExpression.hpp:85
const ValueType ConstReference
Definition: GridExpression.hpp:60
const ValueType Reference
Definition: GridExpression.hpp:61
F::ResultType ValueType
Definition: GridExpression.hpp:59
Definition: GridExpression.hpp:160
SizeType getSize2() const
Definition: GridExpression.hpp:186
const SelfType ConstClosureType
Definition: GridExpression.hpp:173
F::ResultType ValueType
Definition: GridExpression.hpp:170
SizeType getSize3() const
Definition: GridExpression.hpp:191
Scalar1GridBinary(const Expression1Type &e1, const Expression2Type &e2)
Definition: GridExpression.hpp:178
E2::DifferenceType DifferenceType
Definition: GridExpression.hpp:176
const ValueType ConstReference
Definition: GridExpression.hpp:171
ConstReference operator()(SizeType i, SizeType j, SizeType k) const
Definition: GridExpression.hpp:196
E2::SizeType SizeType
Definition: GridExpression.hpp:175
SizeType getSize1() const
Definition: GridExpression.hpp:181
SelfType ClosureType
Definition: GridExpression.hpp:174
const ValueType Reference
Definition: GridExpression.hpp:172
Definition: GridExpression.hpp:216
E1::SizeType SizeType
Definition: GridExpression.hpp:231
const ValueType Reference
Definition: GridExpression.hpp:228
ConstReference operator()(SizeType i, SizeType j, SizeType k) const
Definition: GridExpression.hpp:252
SizeType getSize2() const
Definition: GridExpression.hpp:242
const SelfType ConstClosureType
Definition: GridExpression.hpp:229
SizeType getSize3() const
Definition: GridExpression.hpp:247
SizeType getSize1() const
Definition: GridExpression.hpp:237
Scalar2GridBinary(const Expression1Type &e1, const Expression2Type &e2)
Definition: GridExpression.hpp:234
SelfType ClosureType
Definition: GridExpression.hpp:230
F::ResultType ValueType
Definition: GridExpression.hpp:226
const ValueType ConstReference
Definition: GridExpression.hpp:227
E1::DifferenceType DifferenceType
Definition: GridExpression.hpp:232
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
GridBinary1Traits< E1, E2, ScalarMultiplication< typename E1::ValueType, typename E2::ValueType > >::ResultType elemProd(const GridExpression< E1 > &e1, const GridExpression< E2 > &e2)
Definition: GridExpression.hpp:406
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
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
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
GridEquality< E1, E2 >::ResultType operator!=(const GridExpression< E1 > &e1, const GridExpression< E2 > &e2)
Definition: GridExpression.hpp:346
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
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
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: GridExpression.hpp:152
GridBinary1< E1, E2, F > ExpressionType
Definition: GridExpression.hpp:154
ExpressionType ResultType
Definition: GridExpression.hpp:155
GridScalarUnaryFunctor< G >::ResultType ResultType
Definition: Functional.hpp:1579
static ResultType apply(const GridExpression< G > &e)
Definition: Functional.hpp:1581
static ResultType apply(const GridExpression< G1 > &e1, const GridExpression< G2 > &e2)
Definition: Functional.hpp:1503
GridBooleanBinaryFunctor< G1, G2 >::ResultType ResultType
Definition: Functional.hpp:1501
Scalar3GridBooleanTernaryFunctor< G1, G2, T >::ResultType ResultType
Definition: Functional.hpp:1540
static ResultType apply(const GridExpression< G1 > &e1, const GridExpression< G2 > &e2, Argument3Type epsilon)
Definition: Functional.hpp:1543
Definition: GridExpression.hpp:96
ExpressionType ResultType
Definition: GridExpression.hpp:99
GridUnary< E, F > ExpressionType
Definition: GridExpression.hpp:98
Definition: GridExpression.hpp:208
ExpressionType ResultType
Definition: GridExpression.hpp:211
Scalar1GridBinary< E1, E2, F > ExpressionType
Definition: GridExpression.hpp:210
Definition: GridExpression.hpp:264
ExpressionType ResultType
Definition: GridExpression.hpp:267
Scalar2GridBinary< E1, E2, F > ExpressionType
Definition: GridExpression.hpp:266
Definition: Functional.hpp:211
Definition: Functional.hpp:253
Definition: Functional.hpp:239
Definition: Functional.hpp:225