Chemical Data Processing Library C++ API - Version 1.4.0
VectorExpression.hpp
Go to the documentation of this file.
1 /*
2  * VectorExpression.hpp
3  *
4  * Copyright (C) 2003 Thomas Seidel <thomas.seidel@univie.ac.at>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this library; see the file COPYING. If not, write to
18  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21 
27 #ifndef CDPL_MATH_VECTOREXPRESSION_HPP
28 #define CDPL_MATH_VECTOREXPRESSION_HPP
29 
30 #include <type_traits>
31 
32 #include "CDPL/Math/Check.hpp"
33 #include "CDPL/Math/Expression.hpp"
34 #include "CDPL/Math/CommonType.hpp"
35 #include "CDPL/Math/Functional.hpp"
36 #include "CDPL/Math/TypeTraits.hpp"
37 #include "CDPL/Base/Exceptions.hpp"
38 
39 
40 namespace CDPL
41 {
42 
43  namespace Math
44  {
45 
51  template <typename E, typename F>
52  class VectorUnary : public VectorExpression<VectorUnary<E, F> >
53  {
54 
56  typedef F FunctorType;
57  typedef E ExpressionType;
58  typedef typename E::ConstClosureType ExpressionClosureType;
59 
60  public:
64  typedef typename F::ResultType ValueType;
65 
69  typedef const ValueType ConstReference;
70 
74  typedef const ValueType Reference;
75 
79  typedef const SelfType ConstClosureType;
80 
85 
89  typedef typename E::SizeType SizeType;
90 
94  typedef typename E::DifferenceType DifferenceType;
95 
101  expr(e) {}
102 
108  {
109  return expr.getSize();
110  }
111 
118  {
119  return FunctorType::apply(expr(i));
120  }
121 
128  {
129  return FunctorType::apply(expr[i]);
130  }
131 
132  private:
133  ExpressionClosureType expr;
134  };
135 
141  template <typename E, typename F>
143  {
144 
149 
154  };
155 
162  template <typename E1, typename E2, typename F>
163  class VectorBinary1 : public VectorExpression<VectorBinary1<E1, E2, F> >
164  {
165 
167  typedef F FunctorType;
168  typedef E1 Expression1Type;
169  typedef E2 Expression2Type;
170  typedef typename E1::ConstClosureType Expression1ClosureType;
171  typedef typename E2::ConstClosureType Expression2ClosureType;
172 
173  public:
177  typedef typename F::ResultType ValueType;
178 
182  typedef const ValueType ConstReference;
183 
187  typedef const ValueType Reference;
188 
192  typedef const SelfType ConstClosureType;
193 
198 
203 
208 
214  VectorBinary1(const Expression1Type& e1, const Expression2Type& e2):
215  expr1(e1), expr2(e2) {}
216 
223  {
224  return CDPL_MATH_CHECK_SIZE_EQUALITY(SizeType(expr1.getSize()), SizeType(expr2.getSize()), Base::SizeError);
225  }
226 
233  {
234  return FunctorType::apply(expr1(i), expr2(i));
235  }
236 
243  {
244  return FunctorType::apply(expr1[i], expr2[i]);
245  }
246 
247  private:
248  Expression1ClosureType expr1;
249  Expression2ClosureType expr2;
250  };
251 
258  template <typename E1, typename E2, typename F>
260  {
261 
266 
271  };
272 
284  template <typename E1, typename E2, typename F>
285  class VectorBinary2 : public VectorExpression<VectorBinary2<E1, E2, F> >
286  {
287 
289  typedef F FunctorType;
290  typedef E1 Expression1Type;
291  typedef E2 Expression2Type;
292  typedef typename E1::ConstClosureType Expression1ClosureType;
293  typedef typename E2::ConstClosureType Expression2ClosureType;
294 
295  public:
299  typedef typename F::ResultType ValueType;
300 
304  typedef const ValueType ConstReference;
305 
309  typedef const ValueType Reference;
310 
314  typedef const SelfType ConstClosureType;
315 
320 
325 
330 
336  VectorBinary2(const Expression1Type& e1, const Expression2Type& e2):
337  expr1(e1), expr2(e2) {}
338 
345  {
346  return CDPL_MATH_CHECK_SIZE_EQUALITY(SizeType(expr1.getSize()), SizeType(expr2.getSize()), Base::SizeError);
347  }
348 
355  {
356  return FunctorType::apply(expr1, expr2, i);
357  }
358 
365  {
366  return FunctorType::apply(expr1, expr2, i);
367  }
368 
369  private:
370  Expression1ClosureType expr1;
371  Expression2ClosureType expr2;
372  };
373 
380  template <typename E1, typename E2, typename F>
382  {
383 
388 
393  };
394 
401  template <typename E1, typename E2, typename F>
402  class Scalar1VectorBinary : public VectorExpression<Scalar1VectorBinary<E1, E2, F> >
403  {
404 
406  typedef F FunctorType;
407  typedef E1 Expression1Type;
408  typedef E2 Expression2Type;
409  typedef const E1 Expression1ClosureType;
410  typedef typename E2::ConstClosureType Expression2ClosureType;
411 
412  public:
416  typedef typename F::ResultType ValueType;
417 
421  typedef const ValueType ConstReference;
422 
426  typedef const ValueType Reference;
427 
431  typedef const SelfType ConstClosureType;
432 
437 
441  typedef typename E2::SizeType SizeType;
442 
446  typedef typename E2::DifferenceType DifferenceType;
447 
453  Scalar1VectorBinary(const Expression1Type& e1, const Expression2Type& e2):
454  expr1(e1), expr2(e2) {}
455 
461  {
462  return expr2.getSize();
463  }
464 
471  {
472  return FunctorType::apply(expr1, expr2(i));
473  }
474 
481  {
482  return FunctorType::apply(expr1, expr2[i]);
483  }
484 
485  private:
486  Expression1ClosureType expr1;
487  Expression2ClosureType expr2;
488  };
489 
496  template <typename E1, typename E2, typename F>
498  {
499 
504 
509  };
510 
517  template <typename E1, typename E2, typename F>
518  class Scalar2VectorBinary : public VectorExpression<Scalar2VectorBinary<E1, E2, F> >
519  {
520 
522  typedef F FunctorType;
523  typedef E1 Expression1Type;
524  typedef E2 Expression2Type;
525  typedef typename E1::ConstClosureType Expression1ClosureType;
526  typedef const E2 Expression2ClosureType;
527 
528  public:
532  typedef typename F::ResultType ValueType;
533 
537  typedef const ValueType ConstReference;
538 
542  typedef const ValueType Reference;
543 
547  typedef const SelfType ConstClosureType;
548 
553 
557  typedef typename E1::SizeType SizeType;
558 
562  typedef typename E1::DifferenceType DifferenceType;
563 
569  Scalar2VectorBinary(const Expression1Type& e1, const Expression2Type& e2):
570  expr1(e1), expr2(e2) {}
571 
577  {
578  return expr1.getSize();
579  }
580 
587  {
588  return FunctorType::apply(expr1(i), expr2);
589  }
590 
597  {
598  return FunctorType::apply(expr1[i], expr2);
599  }
600 
601  private:
602  Expression1ClosureType expr1;
603  Expression2ClosureType expr2;
604  };
605 
612  template <typename E1, typename E2, typename F>
614  {
615 
620 
625  };
626 
634  template <typename E1, typename E2, typename F>
635  class QuaternionVectorBinary : public VectorExpression<QuaternionVectorBinary<E1, E2, F> >
636  {
637 
639  typedef F FunctorType;
640  typedef E1 Expression1Type;
641  typedef E2 Expression2Type;
642  typedef typename E1::ConstClosureType Expression1ClosureType;
643  typedef typename E2::ConstClosureType Expression2ClosureType;
644 
645  public:
649  typedef typename F::ResultType ValueType;
650 
654  typedef const ValueType ConstReference;
655 
659  typedef const ValueType Reference;
660 
664  typedef const SelfType ConstClosureType;
665 
670 
674  typedef typename E2::SizeType SizeType;
675 
679  typedef typename E2::DifferenceType DifferenceType;
680 
686  QuaternionVectorBinary(const Expression1Type& e1, const Expression2Type& e2):
687  expr1(e1), expr2(e2) {}
688 
694  {
695  return expr2.getSize();
696  }
697 
704  {
705  return FunctorType::apply(expr1, expr2, i);
706  }
707 
714  {
715  return FunctorType::apply(expr1, expr2, i);
716  }
717 
718  private:
719  Expression1ClosureType expr1;
720  Expression2ClosureType expr2;
721  };
722 
729  template <typename E1, typename E2, typename F>
731  {
732 
737 
742  };
743 
750  template <typename E>
753  {
754  typedef typename VectorUnaryTraits<E, ScalarNegation<typename E::ValueType> >::ExpressionType ExpressionType;
755 
756  return ExpressionType(e());
757  }
758 
765  template <typename E>
766  const E&
768  {
769  return e();
770  }
771 
780  template <typename E1, typename E2>
781  typename VectorBinary1Traits<E1, E2, ScalarAddition<typename E1::ValueType, typename E2::ValueType> >::ResultType
783  {
784  typedef typename VectorBinary1Traits<E1, E2,
786 
787  return ExpressionType(e1(), e2());
788  }
789 
798  template <typename E1, typename E2>
799  typename VectorBinary1Traits<E1, E2, ScalarSubtraction<typename E1::ValueType, typename E2::ValueType> >::ResultType
801  {
802  typedef typename VectorBinary1Traits<E1, E2,
804 
805  return ExpressionType(e1(), e2());
806  }
807 
816  template <typename E, typename T>
817  typename std::enable_if<IsScalar<T>::value, typename Scalar2VectorBinaryTraits<E, T, ScalarMultiplication<typename E::ValueType, T> >::ResultType>::type
818  operator*(const VectorExpression<E>& e, const T& t)
819  {
820  typedef typename Scalar2VectorBinaryTraits<E, T,
821  ScalarMultiplication<typename E::ValueType, T> >::ExpressionType ExpressionType;
822 
823  return ExpressionType(e(), t);
824  }
825 
834  template <typename T, typename E>
835  typename std::enable_if<IsScalar<T>::value, typename Scalar1VectorBinaryTraits<T, E, ScalarMultiplication<T, typename E::ValueType> >::ResultType>::type
836  operator*(const T& t, const VectorExpression<E>& e)
837  {
838  typedef typename Scalar1VectorBinaryTraits<T, E,
839  ScalarMultiplication<T, typename E::ValueType> >::ExpressionType ExpressionType;
840 
841  return ExpressionType(t, e());
842  }
843 
852  template <typename E, typename T>
853  typename std::enable_if<IsScalar<T>::value, typename Scalar2VectorBinaryTraits<E, T, ScalarDivision<typename E::ValueType, T> >::ResultType>::type
854  operator/(const VectorExpression<E>& e, const T& t)
855  {
856  typedef typename Scalar2VectorBinaryTraits<E, T,
857  ScalarDivision<typename E::ValueType, T> >::ExpressionType ExpressionType;
858 
859  return ExpressionType(e(), t);
860  }
861 
870  template <typename E1, typename E2>
873  {
874  return VectorEquality<E1, E2>::apply(e1, e2);
875  }
876 
885  template <typename E1, typename E2>
888  {
889  return !VectorEquality<E1, E2>::apply(e1, e2);
890  }
891 
902  template <typename E1, typename E2, typename T>
903  typename std::enable_if<std::is_arithmetic<T>::value, typename VectorToleranceEquality<E1, E2, T>::ResultType>::type
904  equals(const VectorExpression<E1>& e1, const VectorExpression<E2>& e2, const T& eps)
905  {
906  return VectorToleranceEquality<E1, E2, T>::apply(e1, e2, eps);
907  }
908 
915  template <typename E>
916  typename VectorUnaryTraits<E, ScalarConjugation<typename E::ValueType> >::ResultType
918  {
919  typedef typename VectorUnaryTraits<E, ScalarConjugation<typename E::ValueType> >::ExpressionType ExpressionType;
920 
921  return ExpressionType(e());
922  }
923 
930  template <typename E>
931  typename VectorUnaryTraits<E, ScalarConjugation<typename E::ValueType> >::ResultType
933  {
934  typedef typename VectorUnaryTraits<E, ScalarConjugation<typename E::ValueType> >::ExpressionType ExpressionType;
935 
936  return ExpressionType(e());
937  }
938 
945  template <typename E>
946  typename VectorUnaryTraits<E, ScalarReal<typename E::ValueType> >::ResultType
948  {
949  typedef typename VectorUnaryTraits<E, ScalarReal<typename E::ValueType> >::ExpressionType ExpressionType;
950 
951  return ExpressionType(e());
952  }
953 
960  template <typename E>
961  typename VectorUnaryTraits<E, ScalarImaginary<typename E::ValueType> >::ResultType
963  {
964  typedef typename VectorUnaryTraits<E, ScalarImaginary<typename E::ValueType> >::ExpressionType ExpressionType;
965 
966  return ExpressionType(e());
967  }
968 
977  template <typename E1, typename E2>
978  typename VectorBinary1Traits<E1, E2, ScalarDivision<typename E1::ValueType, typename E2::ValueType> >::ResultType
980  {
981  typedef typename VectorBinary1Traits<E1, E2,
983 
984  return ExpressionType(e1(), e2());
985  }
986 
995  template <typename E1, typename E2>
996  typename VectorBinary1Traits<E1, E2, ScalarMultiplication<typename E1::ValueType, typename E2::ValueType> >::ResultType
998  {
999  typedef typename VectorBinary1Traits<E1, E2,
1001 
1002  return ExpressionType(e1(), e2());
1003  }
1004 
1013  template <typename E1, typename E2>
1014  typename VectorBinary2Traits<E1, E2, VectorCrossProduct<E1, E2> >::ResultType
1016  {
1017  typedef typename VectorBinary2Traits<E1, E2,
1018  VectorCrossProduct<E1, E2> >::ExpressionType ExpressionType;
1019 
1020  return ExpressionType(e1(), e2());
1021  }
1022 
1031  template <typename E1, typename E2>
1034  {
1035  return VectorInnerProduct<E1, E2>::apply(e1, e2);
1036  }
1037 
1049  template <typename E1, typename E2, typename T>
1051  angleCos(const VectorExpression<E1>& e1, const VectorExpression<E2>& e2, const T& sd, bool clamp = true)
1052  {
1053  return VectorAngleCosine<E1, E2, T>::apply(e1, e2, sd, clamp);
1054  }
1055 
1062  template <typename E>
1065  {
1066  return VectorElementSum<E>::apply(e);
1067  }
1068 
1075  template <typename E>
1078  {
1079  return VectorNorm1<E>::apply(e);
1080  }
1081 
1088  template <typename E>
1091  {
1092  return VectorNorm2<E>::apply(e);
1093  }
1094 
1101  template <typename E>
1104  {
1105  return VectorNormInfinity<E>::apply(e);
1106  }
1107 
1114  template <typename E>
1117  {
1119  }
1120 
1127  template <typename E>
1130  {
1131  return norm2(e);
1132  }
1133 
1140  template <typename E>
1141  const E&
1143  {
1144  return e();
1145  }
1146 
1153  template <typename E>
1154  E&
1156  {
1157  return e();
1158  }
1159 
1168  template <typename E1, typename E2>
1169  typename QuaternionVectorBinaryTraits<E1, E2, QuaternionVectorRotation<E1, E2> >::ResultType
1171  {
1172  typedef typename QuaternionVectorBinaryTraits<E1, E2, QuaternionVectorRotation<E1, E2> >::ExpressionType ExpressionType;
1173 
1174  return ExpressionType(e1(), e2());
1175  }
1176  } // namespace Math
1177 } // namespace CDPL
1178 
1179 #endif // CDPL_MATH_VECTOREXPRESSION_HPP
Definition of exception classes.
Definition of various preprocessor macros for error checking.
#define CDPL_MATH_CHECK_SIZE_EQUALITY(size1, size2, e)
Throws the exception e if size1 differs from size2, otherwise returns std::min(size1,...
Definition: Check.hpp:84
Common type deduction.
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
The derived expression type.
Definition: Expression.hpp:49
CRTP base class of all quaternion expression types.
Definition: Expression.hpp:148
Expression template node combining a quaternion expression E1 and a vector expression E2 into a vecto...
Definition: VectorExpression.hpp:636
SelfType ClosureType
Closure type used when this expression appears inside another expression.
Definition: VectorExpression.hpp:669
SizeType getSize() const
Returns the wrapped vector expression's size.
Definition: VectorExpression.hpp:693
ConstReference operator()(SizeType i) const
Invokes the functor with the quaternion expression, the vector expression, and the index i.
Definition: VectorExpression.hpp:703
E2::SizeType SizeType
The size type inherited from the wrapped vector expression.
Definition: VectorExpression.hpp:674
E2::DifferenceType DifferenceType
The signed difference type inherited from the wrapped vector expression.
Definition: VectorExpression.hpp:679
QuaternionVectorBinary(const Expression1Type &e1, const Expression2Type &e2)
Constructs the expression template node combining the quaternion expression e1 and the vector express...
Definition: VectorExpression.hpp:686
const ValueType Reference
Mutable element reference type (degrades to const for expression template results).
Definition: VectorExpression.hpp:659
const ValueType ConstReference
Constant element reference type.
Definition: VectorExpression.hpp:654
const SelfType ConstClosureType
Constant closure type used when this expression appears inside another expression.
Definition: VectorExpression.hpp:664
F::ResultType ValueType
The element value type of the expression (the functor's result type).
Definition: VectorExpression.hpp:649
ConstReference operator[](SizeType i) const
Alias for operator() — invokes the functor with both wrapped expressions and the index i.
Definition: VectorExpression.hpp:713
Expression template node combining a scalar E1 (lhs) and a vector expression E2 (rhs) element-wise vi...
Definition: VectorExpression.hpp:403
Scalar1VectorBinary(const Expression1Type &e1, const Expression2Type &e2)
Constructs the expression template node combining the scalar e1 and the vector expression e2.
Definition: VectorExpression.hpp:453
const ValueType ConstReference
Constant element reference type.
Definition: VectorExpression.hpp:421
ConstReference operator[](SizeType i) const
Alias for operator() — applies the binary functor to the scalar and element i of the wrapped expressi...
Definition: VectorExpression.hpp:480
E2::DifferenceType DifferenceType
The signed difference type inherited from the wrapped vector expression.
Definition: VectorExpression.hpp:446
const ValueType Reference
Mutable element reference type (degrades to const for expression template results).
Definition: VectorExpression.hpp:426
SelfType ClosureType
Closure type used when this expression appears inside another expression.
Definition: VectorExpression.hpp:436
const SelfType ConstClosureType
Constant closure type used when this expression appears inside another expression.
Definition: VectorExpression.hpp:431
E2::SizeType SizeType
The size type inherited from the wrapped vector expression.
Definition: VectorExpression.hpp:441
ConstReference operator()(SizeType i) const
Applies the binary functor to the scalar and element i of the wrapped vector expression and returns t...
Definition: VectorExpression.hpp:470
SizeType getSize() const
Returns the wrapped vector expression's size.
Definition: VectorExpression.hpp:460
F::ResultType ValueType
The element value type of the expression (the functor's result type).
Definition: VectorExpression.hpp:416
Expression template node combining a vector expression E1 (lhs) and a scalar E2 (rhs) element-wise vi...
Definition: VectorExpression.hpp:519
const SelfType ConstClosureType
Constant closure type used when this expression appears inside another expression.
Definition: VectorExpression.hpp:547
E1::DifferenceType DifferenceType
The signed difference type inherited from the wrapped vector expression.
Definition: VectorExpression.hpp:562
F::ResultType ValueType
The element value type of the expression (the functor's result type).
Definition: VectorExpression.hpp:532
const ValueType ConstReference
Constant element reference type.
Definition: VectorExpression.hpp:537
Scalar2VectorBinary(const Expression1Type &e1, const Expression2Type &e2)
Constructs the expression template node combining the vector expression e1 and the scalar e2.
Definition: VectorExpression.hpp:569
SelfType ClosureType
Closure type used when this expression appears inside another expression.
Definition: VectorExpression.hpp:552
SizeType getSize() const
Returns the wrapped vector expression's size.
Definition: VectorExpression.hpp:576
ConstReference operator[](SizeType i) const
Alias for operator() — applies the binary functor to element i of the wrapped expression and the scal...
Definition: VectorExpression.hpp:596
E1::SizeType SizeType
The size type inherited from the wrapped vector expression.
Definition: VectorExpression.hpp:557
ConstReference operator()(SizeType i) const
Applies the binary functor to element i of the wrapped vector expression and the scalar and returns t...
Definition: VectorExpression.hpp:586
const ValueType Reference
Mutable element reference type (degrades to const for expression template results).
Definition: VectorExpression.hpp:542
Expression template node combining two vector expressions E1 and E2 element-wise via the binary funct...
Definition: VectorExpression.hpp:164
ConstReference operator()(SizeType i) const
Applies the binary functor element-wise at index i of the two wrapped expressions and returns the res...
Definition: VectorExpression.hpp:232
ConstReference operator[](SizeType i) const
Alias for operator() — applies the binary functor element-wise at index i.
Definition: VectorExpression.hpp:242
const ValueType Reference
Mutable element reference type (degrades to const for expression template results).
Definition: VectorExpression.hpp:187
CommonType< typename E1::DifferenceType, typename E2::DifferenceType >::Type DifferenceType
The common signed difference type of the two wrapped expressions.
Definition: VectorExpression.hpp:207
VectorBinary1(const Expression1Type &e1, const Expression2Type &e2)
Constructs the expression template node wrapping e1 and e2.
Definition: VectorExpression.hpp:214
F::ResultType ValueType
The element value type of the expression (the functor's result type).
Definition: VectorExpression.hpp:177
const SelfType ConstClosureType
Constant closure type used when this expression appears inside another expression.
Definition: VectorExpression.hpp:192
SizeType getSize() const
Returns the element count after verifying that both wrapped expressions agree on it.
Definition: VectorExpression.hpp:222
SelfType ClosureType
Closure type used when this expression appears inside another expression.
Definition: VectorExpression.hpp:197
const ValueType ConstReference
Constant element reference type.
Definition: VectorExpression.hpp:182
CommonType< typename E1::SizeType, typename E2::SizeType >::Type SizeType
The common size type of the two wrapped expressions.
Definition: VectorExpression.hpp:202
Expression template node combining two vector expressions E1 and E2 via a binary functor F invoked wi...
Definition: VectorExpression.hpp:286
SizeType getSize() const
Returns the element count after verifying that both wrapped expressions agree on it.
Definition: VectorExpression.hpp:344
ConstReference operator()(SizeType i) const
Invokes the functor with both wrapped expressions and the index i and returns the result.
Definition: VectorExpression.hpp:354
CommonType< typename E1::SizeType, typename E2::SizeType >::Type SizeType
The common size type of the two wrapped expressions.
Definition: VectorExpression.hpp:324
F::ResultType ValueType
The element value type of the expression (the functor's result type).
Definition: VectorExpression.hpp:299
const SelfType ConstClosureType
Constant closure type used when this expression appears inside another expression.
Definition: VectorExpression.hpp:314
const ValueType Reference
Mutable element reference type (degrades to const for expression template results).
Definition: VectorExpression.hpp:309
VectorBinary2(const Expression1Type &e1, const Expression2Type &e2)
Constructs the expression template node wrapping e1 and e2.
Definition: VectorExpression.hpp:336
ConstReference operator[](SizeType i) const
Alias for operator() — invokes the functor with both wrapped expressions and the index i.
Definition: VectorExpression.hpp:364
SelfType ClosureType
Closure type used when this expression appears inside another expression.
Definition: VectorExpression.hpp:319
const ValueType ConstReference
Constant element reference type.
Definition: VectorExpression.hpp:304
CommonType< typename E1::DifferenceType, typename E2::DifferenceType >::Type DifferenceType
The common signed difference type of the two wrapped expressions.
Definition: VectorExpression.hpp:329
CRTP base class of all vector expression types.
Definition: Expression.hpp:68
Expression template node applying a unary functor F element-wise to a vector expression E.
Definition: VectorExpression.hpp:53
E::SizeType SizeType
The size type inherited from the wrapped expression.
Definition: VectorExpression.hpp:89
SelfType ClosureType
Closure type used when this expression appears inside another expression.
Definition: VectorExpression.hpp:84
const SelfType ConstClosureType
Constant closure type used when this expression appears inside another expression.
Definition: VectorExpression.hpp:79
E::DifferenceType DifferenceType
The signed difference type inherited from the wrapped expression.
Definition: VectorExpression.hpp:94
VectorUnary(const ExpressionType &e)
Constructs the expression template node wrapping e.
Definition: VectorExpression.hpp:100
F::ResultType ValueType
The element value type of the expression (the functor's result type).
Definition: VectorExpression.hpp:64
const ValueType Reference
Mutable element reference type (degrades to const for expression template results).
Definition: VectorExpression.hpp:74
ConstReference operator[](SizeType i) const
Alias for operator() — applies the unary functor to element i of the wrapped expression.
Definition: VectorExpression.hpp:127
const ValueType ConstReference
Constant element reference type.
Definition: VectorExpression.hpp:69
ConstReference operator()(SizeType i) const
Applies the unary functor to element i of the wrapped expression and returns the result.
Definition: VectorExpression.hpp:117
SizeType getSize() const
Returns the wrapped expression's size.
Definition: VectorExpression.hpp:107
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)
Returns the 3D vector cross product as an expression template node.
Definition: VectorExpression.hpp:1015
GridBinary1Traits< E1, E2, ScalarMultiplication< typename E1::ValueType, typename E2::ValueType > >::ResultType elemProd(const GridExpression< E1 > &e1, const GridExpression< E2 > &e2)
Returns the element-wise product of the grid expressions e1 and e2 (Hadamard product).
Definition: GridExpression.hpp:802
MatrixTranspose< E > trans(MatrixExpression< E > &e)
Returns a mutable Math::MatrixTranspose view of the matrix expression e.
Definition: MatrixExpression.hpp:1943
GridUnaryTraits< E, ScalarConjugation< typename E::ValueType > >::ResultType herm(const GridExpression< E > &e)
Returns the Hermitian conjugate of the grid expression e (alias of conj() for grids).
Definition: GridExpression.hpp:737
GridUnaryTraits< E, ScalarConjugation< typename E::ValueType > >::ResultType conj(const GridExpression< E > &e)
Returns the element-wise complex conjugate of the grid expression e (identity for real-valued grids).
Definition: GridExpression.hpp:722
VectorNormInfinityIndex< E >::ResultType normInfIndex(const VectorExpression< E > &e)
Returns the (first) index at which the vector expression e attains its L∞ norm.
Definition: VectorExpression.hpp:1116
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)
Tells whether the grid expressions e1 and e2 agree element-wise within the absolute tolerance eps.
Definition: GridExpression.hpp:709
VectorInnerProduct< E1, E2 >::ResultType innerProd(const VectorExpression< E1 > &e1, const VectorExpression< E2 > &e2)
Returns the inner (dot) product of the vector expressions e1 and e2.
Definition: VectorExpression.hpp:1033
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)
Returns the element-wise quotient of the grid expression e by the scalar t.
Definition: GridExpression.hpp:659
GridUnaryTraits< E, ScalarReal< typename E::ValueType > >::ResultType real(const GridExpression< E > &e)
Returns the element-wise real part of the grid expression e.
Definition: GridExpression.hpp:752
QuaternionNorm2< E >::ResultType norm2(const QuaternionExpression< E > &e)
Returns the squared norm of the quaternion expression e.
Definition: QuaternionExpression.hpp:1587
GridEquality< E1, E2 >::ResultType operator!=(const GridExpression< E1 > &e1, const GridExpression< E2 > &e2)
Tells whether the grid expressions e1 and e2 differ in at least one element.
Definition: GridExpression.hpp:692
VectorAngleCosine< E1, E2, T >::ResultType angleCos(const VectorExpression< E1 > &e1, const VectorExpression< E2 > &e2, const T &sd, bool clamp=true)
Returns the cosine of the angle between the vector expressions e1 and e2 (optionally clamped to [-1,...
Definition: VectorExpression.hpp:1051
VectorNorm2< E >::ResultType length(const VectorExpression< E > &e)
Returns the length (L2 norm) of the vector expression e (alias of norm2()).
Definition: VectorExpression.hpp:1129
GridEquality< E1, E2 >::ResultType operator==(const GridExpression< E1 > &e1, const GridExpression< E2 > &e2)
Tells whether the grid expressions e1 and e2 are element-wise equal.
Definition: GridExpression.hpp:677
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)
Returns the element-wise product of the grid expression e and the scalar t.
Definition: GridExpression.hpp:623
GridBinary1Traits< E1, E2, ScalarDivision< typename E1::ValueType, typename E2::ValueType > >::ResultType elemDiv(const GridExpression< E1 > &e1, const GridExpression< E2 > &e2)
Returns the element-wise quotient of the grid expressions e1 and e2.
Definition: GridExpression.hpp:784
GridUnaryTraits< E, ScalarImaginary< typename E::ValueType > >::ResultType imag(const GridExpression< E > &e)
Returns the element-wise imaginary part of the grid expression e.
Definition: GridExpression.hpp:767
MatrixNormInfinity< E >::ResultType normInf(const MatrixExpression< E > &e)
Returns the L∞ (maximum absolute row sum) norm of the matrix expression e.
Definition: MatrixExpression.hpp:1901
QuaternionVectorBinaryTraits< E1, E2, QuaternionVectorRotation< E1, E2 > >::ResultType rotate(const QuaternionExpression< E1 > &e1, const VectorExpression< E2 > &e2)
Rotates the vector expression e2 by the quaternion expression e1.
Definition: VectorExpression.hpp:1170
GridUnaryTraits< E, ScalarNegation< typename E::ValueType > >::ResultType operator-(const GridExpression< E > &e)
Returns the element-wise negation of the grid expression e.
Definition: GridExpression.hpp:557
GridElementSum< E >::ResultType sum(const GridExpression< E > &e)
Returns the sum of all elements of the grid expression e.
Definition: GridExpression.hpp:818
MatrixNorm1< E >::ResultType norm1(const MatrixExpression< E > &e)
Returns the L1 (maximum absolute column sum) norm of the matrix expression e.
Definition: MatrixExpression.hpp:1875
const E & operator+(const GridExpression< E > &e)
Returns the grid expression e unchanged (unary +).
Definition: GridExpression.hpp:572
The namespace of the Chemical Data Processing Library.
std::common_type< T1, T2 >::type Type
The common type.
Definition: CommonType.hpp:51
Traits selecting the expression template node and its result type for the Math::QuaternionVectorBinar...
Definition: VectorExpression.hpp:731
QuaternionVectorBinary< E1, E2, F > ExpressionType
The expression template node type.
Definition: VectorExpression.hpp:736
ExpressionType ResultType
The expression template result type returned by free-function operators.
Definition: VectorExpression.hpp:741
Traits selecting the expression template node and its result type for the Math::Scalar1VectorBinary i...
Definition: VectorExpression.hpp:498
ExpressionType ResultType
The expression template result type returned by free-function operators.
Definition: VectorExpression.hpp:508
Scalar1VectorBinary< E1, E2, F > ExpressionType
The expression template node type.
Definition: VectorExpression.hpp:503
Traits selecting the expression template node and its result type for the Math::Scalar2VectorBinary i...
Definition: VectorExpression.hpp:614
ExpressionType ResultType
The expression template result type returned by free-function operators.
Definition: VectorExpression.hpp:624
Scalar2VectorBinary< E1, E2, F > ExpressionType
The expression template node type.
Definition: VectorExpression.hpp:619
Scalar binary addition functor: apply(t1, t2) returns t1 + t2.
Definition: Functional.hpp:373
Scalar binary division functor: apply(t1, t2) returns t1 / t2.
Definition: Functional.hpp:448
Scalar binary multiplication functor: apply(t1, t2) returns t1 * t2.
Definition: Functional.hpp:423
Scalar binary subtraction functor: apply(t1, t2) returns t1 - t2.
Definition: Functional.hpp:398
static ResultType apply(const VectorExpression< V1 > &e1, const VectorExpression< V2 > &e2, const T &sd, bool clamp)
Returns the cosine of the angle between e1 and e2.
Definition: Functional.hpp:533
CommonType< typename VectorInnerProduct< V1, V2 >::ResultType, T >::Type ResultType
Definition: Functional.hpp:523
Traits selecting the expression template node and its result type for the Math::VectorBinary1 instant...
Definition: VectorExpression.hpp:260
ExpressionType ResultType
The expression template result type returned by free-function operators.
Definition: VectorExpression.hpp:270
VectorBinary1< E1, E2, F > ExpressionType
The expression template node type.
Definition: VectorExpression.hpp:265
Traits selecting the expression template node and its result type for the Math::VectorBinary2 instant...
Definition: VectorExpression.hpp:382
VectorBinary2< E1, E2, F > ExpressionType
The expression template node type.
Definition: VectorExpression.hpp:387
ExpressionType ResultType
The expression template result type returned by free-function operators.
Definition: VectorExpression.hpp:392
Vector cross-product functor: apply(e1, e2, i) returns the i-th component of the 3D vector cross prod...
Definition: Functional.hpp:693
VectorScalarUnaryFunctor< V >::ResultType ResultType
Definition: Functional.hpp:758
static ResultType apply(const VectorExpression< V > &e)
Returns the sum of all elements of e.
Definition: Functional.hpp:765
VectorBooleanBinaryFunctor< V1, V2 >::ResultType ResultType
Definition: Functional.hpp:580
static ResultType apply(const VectorExpression< V1 > &e1, const VectorExpression< V2 > &e2)
Tells whether the vector expressions e1 and e2 are element-wise equal.
Definition: Functional.hpp:588
VectorScalarBinaryFunctor< V1, V2 >::ResultType ResultType
Definition: Functional.hpp:490
static ResultType apply(const VectorExpression< V1 > &e1, const VectorExpression< V2 > &e2)
Returns the inner product of e1 and e2.
Definition: Functional.hpp:499
static ResultType apply(const VectorExpression< V > &e)
Returns the L1 norm of e.
Definition: Functional.hpp:819
VectorScalarRealUnaryFunctor< V >::ResultType ResultType
Definition: Functional.hpp:812
VectorScalarRealUnaryFunctor< V >::ResultType ResultType
Definition: Functional.hpp:842
static ResultType apply(const VectorExpression< V > &e)
Returns the L2 norm of e.
Definition: Functional.hpp:849
VectorScalarIndexUnaryFunctor< V >::ResultType ResultType
Definition: Functional.hpp:933
static ResultType apply(const VectorExpression< V > &e)
Returns the index of the element of e with the largest L∞ norm.
Definition: Functional.hpp:940
static ResultType apply(const VectorExpression< V > &e)
Returns the L∞ norm of e.
Definition: Functional.hpp:882
VectorScalarRealUnaryFunctor< V >::ResultType ResultType
Definition: Functional.hpp:875
Scalar3VectorBooleanTernaryFunctor< V1, V2, T >::ResultType ResultType
Definition: Functional.hpp:644
static ResultType apply(const VectorExpression< V1 > &e1, const VectorExpression< V2 > &e2, Argument3Type epsilon)
Tells whether the vector expressions e1 and e2 are element-wise equal within an absolute tolerance ep...
Definition: Functional.hpp:654
Traits selecting the expression template node and its result type for the Math::VectorUnary instantia...
Definition: VectorExpression.hpp:143
ExpressionType ResultType
The expression template result type returned by free-function operators.
Definition: VectorExpression.hpp:153
VectorUnary< E, F > ExpressionType
The expression template node type.
Definition: VectorExpression.hpp:148