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:
62  typedef typename F::ResultType ValueType;
64  typedef const ValueType ConstReference;
66  typedef const ValueType Reference;
68  typedef const SelfType ConstClosureType;
72  typedef typename E::SizeType SizeType;
74  typedef typename E::DifferenceType DifferenceType;
75 
81  expr(e) {}
82 
87  SizeType getSize() const
88  {
89  return expr.getSize();
90  }
91 
98  {
99  return FunctorType::apply(expr(i));
100  }
101 
108  {
109  return FunctorType::apply(expr[i]);
110  }
111 
112  private:
113  ExpressionClosureType expr;
114  };
115 
121  template <typename E, typename F>
123  {
124 
129  };
130 
137  template <typename E1, typename E2, typename F>
138  class VectorBinary1 : public VectorExpression<VectorBinary1<E1, E2, F> >
139  {
140 
142  typedef F FunctorType;
143  typedef E1 Expression1Type;
144  typedef E2 Expression2Type;
145  typedef typename E1::ConstClosureType Expression1ClosureType;
146  typedef typename E2::ConstClosureType Expression2ClosureType;
147 
148  public:
150  typedef typename F::ResultType ValueType;
152  typedef const ValueType ConstReference;
154  typedef const ValueType Reference;
156  typedef const SelfType ConstClosureType;
163 
169  VectorBinary1(const Expression1Type& e1, const Expression2Type& e2):
170  expr1(e1), expr2(e2) {}
171 
178  {
179  return CDPL_MATH_CHECK_SIZE_EQUALITY(SizeType(expr1.getSize()), SizeType(expr2.getSize()), Base::SizeError);
180  }
181 
188  {
189  return FunctorType::apply(expr1(i), expr2(i));
190  }
191 
198  {
199  return FunctorType::apply(expr1[i], expr2[i]);
200  }
201 
202  private:
203  Expression1ClosureType expr1;
204  Expression2ClosureType expr2;
205  };
206 
213  template <typename E1, typename E2, typename F>
215  {
216 
221  };
222 
234  template <typename E1, typename E2, typename F>
235  class VectorBinary2 : public VectorExpression<VectorBinary2<E1, E2, F> >
236  {
237 
239  typedef F FunctorType;
240  typedef E1 Expression1Type;
241  typedef E2 Expression2Type;
242  typedef typename E1::ConstClosureType Expression1ClosureType;
243  typedef typename E2::ConstClosureType Expression2ClosureType;
244 
245  public:
247  typedef typename F::ResultType ValueType;
249  typedef const ValueType ConstReference;
251  typedef const ValueType Reference;
253  typedef const SelfType ConstClosureType;
260 
266  VectorBinary2(const Expression1Type& e1, const Expression2Type& e2):
267  expr1(e1), expr2(e2) {}
268 
275  {
276  return CDPL_MATH_CHECK_SIZE_EQUALITY(SizeType(expr1.getSize()), SizeType(expr2.getSize()), Base::SizeError);
277  }
278 
285  {
286  return FunctorType::apply(expr1, expr2, i);
287  }
288 
295  {
296  return FunctorType::apply(expr1, expr2, i);
297  }
298 
299  private:
300  Expression1ClosureType expr1;
301  Expression2ClosureType expr2;
302  };
303 
310  template <typename E1, typename E2, typename F>
312  {
313 
318  };
319 
326  template <typename E1, typename E2, typename F>
327  class Scalar1VectorBinary : public VectorExpression<Scalar1VectorBinary<E1, E2, F> >
328  {
329 
331  typedef F FunctorType;
332  typedef E1 Expression1Type;
333  typedef E2 Expression2Type;
334  typedef const E1 Expression1ClosureType;
335  typedef typename E2::ConstClosureType Expression2ClosureType;
336 
337  public:
339  typedef typename F::ResultType ValueType;
341  typedef const ValueType ConstReference;
343  typedef const ValueType Reference;
345  typedef const SelfType ConstClosureType;
349  typedef typename E2::SizeType SizeType;
351  typedef typename E2::DifferenceType DifferenceType;
352 
358  Scalar1VectorBinary(const Expression1Type& e1, const Expression2Type& e2):
359  expr1(e1), expr2(e2) {}
360 
366  {
367  return expr2.getSize();
368  }
369 
376  {
377  return FunctorType::apply(expr1, expr2(i));
378  }
379 
386  {
387  return FunctorType::apply(expr1, expr2[i]);
388  }
389 
390  private:
391  Expression1ClosureType expr1;
392  Expression2ClosureType expr2;
393  };
394 
401  template <typename E1, typename E2, typename F>
403  {
404 
409  };
410 
417  template <typename E1, typename E2, typename F>
418  class Scalar2VectorBinary : public VectorExpression<Scalar2VectorBinary<E1, E2, F> >
419  {
420 
422  typedef F FunctorType;
423  typedef E1 Expression1Type;
424  typedef E2 Expression2Type;
425  typedef typename E1::ConstClosureType Expression1ClosureType;
426  typedef const E2 Expression2ClosureType;
427 
428  public:
430  typedef typename F::ResultType ValueType;
432  typedef const ValueType ConstReference;
434  typedef const ValueType Reference;
436  typedef const SelfType ConstClosureType;
440  typedef typename E1::SizeType SizeType;
442  typedef typename E1::DifferenceType DifferenceType;
443 
449  Scalar2VectorBinary(const Expression1Type& e1, const Expression2Type& e2):
450  expr1(e1), expr2(e2) {}
451 
457  {
458  return expr1.getSize();
459  }
460 
467  {
468  return FunctorType::apply(expr1(i), expr2);
469  }
470 
477  {
478  return FunctorType::apply(expr1[i], expr2);
479  }
480 
481  private:
482  Expression1ClosureType expr1;
483  Expression2ClosureType expr2;
484  };
485 
492  template <typename E1, typename E2, typename F>
494  {
495 
500  };
501 
509  template <typename E1, typename E2, typename F>
510  class QuaternionVectorBinary : public VectorExpression<QuaternionVectorBinary<E1, E2, F> >
511  {
512 
514  typedef F FunctorType;
515  typedef E1 Expression1Type;
516  typedef E2 Expression2Type;
517  typedef typename E1::ConstClosureType Expression1ClosureType;
518  typedef typename E2::ConstClosureType Expression2ClosureType;
519 
520  public:
522  typedef typename F::ResultType ValueType;
524  typedef const ValueType ConstReference;
526  typedef const ValueType Reference;
528  typedef const SelfType ConstClosureType;
532  typedef typename E2::SizeType SizeType;
534  typedef typename E2::DifferenceType DifferenceType;
535 
541  QuaternionVectorBinary(const Expression1Type& e1, const Expression2Type& e2):
542  expr1(e1), expr2(e2) {}
543 
549  {
550  return expr2.getSize();
551  }
552 
559  {
560  return FunctorType::apply(expr1, expr2, i);
561  }
562 
569  {
570  return FunctorType::apply(expr1, expr2, i);
571  }
572 
573  private:
574  Expression1ClosureType expr1;
575  Expression2ClosureType expr2;
576  };
577 
584  template <typename E1, typename E2, typename F>
586  {
587 
592  };
593 
600  template <typename E>
603  {
604  typedef typename VectorUnaryTraits<E, ScalarNegation<typename E::ValueType> >::ExpressionType ExpressionType;
605 
606  return ExpressionType(e());
607  }
608 
615  template <typename E>
616  const E&
618  {
619  return e();
620  }
621 
630  template <typename E1, typename E2>
631  typename VectorBinary1Traits<E1, E2, ScalarAddition<typename E1::ValueType, typename E2::ValueType> >::ResultType
633  {
634  typedef typename VectorBinary1Traits<E1, E2,
636 
637  return ExpressionType(e1(), e2());
638  }
639 
648  template <typename E1, typename E2>
649  typename VectorBinary1Traits<E1, E2, ScalarSubtraction<typename E1::ValueType, typename E2::ValueType> >::ResultType
651  {
652  typedef typename VectorBinary1Traits<E1, E2,
654 
655  return ExpressionType(e1(), e2());
656  }
657 
666  template <typename E, typename T>
667  typename std::enable_if<IsScalar<T>::value, typename Scalar2VectorBinaryTraits<E, T, ScalarMultiplication<typename E::ValueType, T> >::ResultType>::type
668  operator*(const VectorExpression<E>& e, const T& t)
669  {
670  typedef typename Scalar2VectorBinaryTraits<E, T,
671  ScalarMultiplication<typename E::ValueType, T> >::ExpressionType ExpressionType;
672 
673  return ExpressionType(e(), t);
674  }
675 
684  template <typename T, typename E>
685  typename std::enable_if<IsScalar<T>::value, typename Scalar1VectorBinaryTraits<T, E, ScalarMultiplication<T, typename E::ValueType> >::ResultType>::type
686  operator*(const T& t, const VectorExpression<E>& e)
687  {
688  typedef typename Scalar1VectorBinaryTraits<T, E,
689  ScalarMultiplication<T, typename E::ValueType> >::ExpressionType ExpressionType;
690 
691  return ExpressionType(t, e());
692  }
693 
702  template <typename E, typename T>
703  typename std::enable_if<IsScalar<T>::value, typename Scalar2VectorBinaryTraits<E, T, ScalarDivision<typename E::ValueType, T> >::ResultType>::type
704  operator/(const VectorExpression<E>& e, const T& t)
705  {
706  typedef typename Scalar2VectorBinaryTraits<E, T,
707  ScalarDivision<typename E::ValueType, T> >::ExpressionType ExpressionType;
708 
709  return ExpressionType(e(), t);
710  }
711 
720  template <typename E1, typename E2>
723  {
724  return VectorEquality<E1, E2>::apply(e1, e2);
725  }
726 
735  template <typename E1, typename E2>
738  {
739  return !VectorEquality<E1, E2>::apply(e1, e2);
740  }
741 
752  template <typename E1, typename E2, typename T>
753  typename std::enable_if<std::is_arithmetic<T>::value, typename VectorToleranceEquality<E1, E2, T>::ResultType>::type
754  equals(const VectorExpression<E1>& e1, const VectorExpression<E2>& e2, const T& eps)
755  {
756  return VectorToleranceEquality<E1, E2, T>::apply(e1, e2, eps);
757  }
758 
765  template <typename E>
766  typename VectorUnaryTraits<E, ScalarConjugation<typename E::ValueType> >::ResultType
768  {
769  typedef typename VectorUnaryTraits<E, ScalarConjugation<typename E::ValueType> >::ExpressionType ExpressionType;
770 
771  return ExpressionType(e());
772  }
773 
780  template <typename E>
781  typename VectorUnaryTraits<E, ScalarConjugation<typename E::ValueType> >::ResultType
783  {
784  typedef typename VectorUnaryTraits<E, ScalarConjugation<typename E::ValueType> >::ExpressionType ExpressionType;
785 
786  return ExpressionType(e());
787  }
788 
795  template <typename E>
796  typename VectorUnaryTraits<E, ScalarReal<typename E::ValueType> >::ResultType
798  {
799  typedef typename VectorUnaryTraits<E, ScalarReal<typename E::ValueType> >::ExpressionType ExpressionType;
800 
801  return ExpressionType(e());
802  }
803 
810  template <typename E>
811  typename VectorUnaryTraits<E, ScalarImaginary<typename E::ValueType> >::ResultType
813  {
814  typedef typename VectorUnaryTraits<E, ScalarImaginary<typename E::ValueType> >::ExpressionType ExpressionType;
815 
816  return ExpressionType(e());
817  }
818 
827  template <typename E1, typename E2>
828  typename VectorBinary1Traits<E1, E2, ScalarDivision<typename E1::ValueType, typename E2::ValueType> >::ResultType
830  {
831  typedef typename VectorBinary1Traits<E1, E2,
833 
834  return ExpressionType(e1(), e2());
835  }
836 
845  template <typename E1, typename E2>
846  typename VectorBinary1Traits<E1, E2, ScalarMultiplication<typename E1::ValueType, typename E2::ValueType> >::ResultType
848  {
849  typedef typename VectorBinary1Traits<E1, E2,
851 
852  return ExpressionType(e1(), e2());
853  }
854 
863  template <typename E1, typename E2>
864  typename VectorBinary2Traits<E1, E2, VectorCrossProduct<E1, E2> >::ResultType
866  {
867  typedef typename VectorBinary2Traits<E1, E2,
868  VectorCrossProduct<E1, E2> >::ExpressionType ExpressionType;
869 
870  return ExpressionType(e1(), e2());
871  }
872 
881  template <typename E1, typename E2>
884  {
885  return VectorInnerProduct<E1, E2>::apply(e1, e2);
886  }
887 
899  template <typename E1, typename E2, typename T>
901  angleCos(const VectorExpression<E1>& e1, const VectorExpression<E2>& e2, const T& sd, bool clamp = true)
902  {
903  return VectorAngleCosine<E1, E2, T>::apply(e1, e2, sd, clamp);
904  }
905 
912  template <typename E>
915  {
916  return VectorElementSum<E>::apply(e);
917  }
918 
925  template <typename E>
928  {
929  return VectorNorm1<E>::apply(e);
930  }
931 
938  template <typename E>
941  {
942  return VectorNorm2<E>::apply(e);
943  }
944 
951  template <typename E>
954  {
956  }
957 
964  template <typename E>
967  {
969  }
970 
977  template <typename E>
980  {
981  return norm2(e);
982  }
983 
990  template <typename E>
991  const E&
993  {
994  return e();
995  }
996 
1003  template <typename E>
1004  E&
1006  {
1007  return e();
1008  }
1009 
1018  template <typename E1, typename E2>
1019  typename QuaternionVectorBinaryTraits<E1, E2, QuaternionVectorRotation<E1, E2> >::ResultType
1021  {
1022  typedef typename QuaternionVectorBinaryTraits<E1, E2, QuaternionVectorRotation<E1, E2> >::ExpressionType ExpressionType;
1023 
1024  return ExpressionType(e1(), e2());
1025  }
1026  } // namespace Math
1027 } // namespace CDPL
1028 
1029 #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 (made available to expression-template machinery).
Definition: Expression.hpp:47
CRTP base class for all quaternion expression types.
Definition: Expression.hpp:142
Expression-template node combining a quaternion expression E1 and a vector expression E2 into a vecto...
Definition: VectorExpression.hpp:511
SelfType ClosureType
Closure type used when this expression appears inside another expression.
Definition: VectorExpression.hpp:530
SizeType getSize() const
Returns the wrapped vector expression's size.
Definition: VectorExpression.hpp:548
ConstReference operator()(SizeType i) const
Invokes the functor with the quaternion expression, the vector expression, and the index i.
Definition: VectorExpression.hpp:558
E2::SizeType SizeType
The size type inherited from the wrapped vector expression.
Definition: VectorExpression.hpp:532
E2::DifferenceType DifferenceType
The signed difference type inherited from the wrapped vector expression.
Definition: VectorExpression.hpp:534
QuaternionVectorBinary(const Expression1Type &e1, const Expression2Type &e2)
Constructs the expression-template node combining the quaternion expression e1 and the vector express...
Definition: VectorExpression.hpp:541
const ValueType Reference
Mutable reference type (degrades to const for expression-template results).
Definition: VectorExpression.hpp:526
const ValueType ConstReference
Constant reference type to an element value.
Definition: VectorExpression.hpp:524
const SelfType ConstClosureType
Constant closure type used when this expression appears inside another expression.
Definition: VectorExpression.hpp:528
F::ResultType ValueType
The element value type of the expression (the functor's result type).
Definition: VectorExpression.hpp:522
ConstReference operator[](SizeType i) const
Alias for operator() — invokes the functor with both wrapped expressions and the index i.
Definition: VectorExpression.hpp:568
Expression-template node combining a scalar E1 (lhs) and a vector expression E2 (rhs) element-wise vi...
Definition: VectorExpression.hpp:328
Scalar1VectorBinary(const Expression1Type &e1, const Expression2Type &e2)
Constructs the expression-template node combining the scalar e1 and the vector expression e2.
Definition: VectorExpression.hpp:358
const ValueType ConstReference
Constant reference type to an element value.
Definition: VectorExpression.hpp:341
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:385
E2::DifferenceType DifferenceType
The signed difference type inherited from the wrapped vector expression.
Definition: VectorExpression.hpp:351
const ValueType Reference
Mutable reference type (degrades to const for expression-template results).
Definition: VectorExpression.hpp:343
SelfType ClosureType
Closure type used when this expression appears inside another expression.
Definition: VectorExpression.hpp:347
const SelfType ConstClosureType
Constant closure type used when this expression appears inside another expression.
Definition: VectorExpression.hpp:345
E2::SizeType SizeType
The size type inherited from the wrapped vector expression.
Definition: VectorExpression.hpp:349
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:375
SizeType getSize() const
Returns the wrapped vector expression's size.
Definition: VectorExpression.hpp:365
F::ResultType ValueType
The element value type of the expression (the functor's result type).
Definition: VectorExpression.hpp:339
Expression-template node combining a vector expression E1 (lhs) and a scalar E2 (rhs) element-wise vi...
Definition: VectorExpression.hpp:419
const SelfType ConstClosureType
Constant closure type used when this expression appears inside another expression.
Definition: VectorExpression.hpp:436
E1::DifferenceType DifferenceType
The signed difference type inherited from the wrapped vector expression.
Definition: VectorExpression.hpp:442
F::ResultType ValueType
The element value type of the expression (the functor's result type).
Definition: VectorExpression.hpp:430
const ValueType ConstReference
Constant reference type to an element value.
Definition: VectorExpression.hpp:432
Scalar2VectorBinary(const Expression1Type &e1, const Expression2Type &e2)
Constructs the expression-template node combining the vector expression e1 and the scalar e2.
Definition: VectorExpression.hpp:449
SelfType ClosureType
Closure type used when this expression appears inside another expression.
Definition: VectorExpression.hpp:438
SizeType getSize() const
Returns the wrapped vector expression's size.
Definition: VectorExpression.hpp:456
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:476
E1::SizeType SizeType
The size type inherited from the wrapped vector expression.
Definition: VectorExpression.hpp:440
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:466
const ValueType Reference
Mutable reference type (degrades to const for expression-template results).
Definition: VectorExpression.hpp:434
Expression-template node combining two vector expressions E1 and E2 element-wise via the binary funct...
Definition: VectorExpression.hpp:139
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:187
ConstReference operator[](SizeType i) const
Alias for operator() — applies the binary functor element-wise at index i.
Definition: VectorExpression.hpp:197
const ValueType Reference
Mutable reference type (degrades to const for expression-template results).
Definition: VectorExpression.hpp:154
CommonType< typename E1::DifferenceType, typename E2::DifferenceType >::Type DifferenceType
The common signed difference type of the two wrapped expressions.
Definition: VectorExpression.hpp:162
VectorBinary1(const Expression1Type &e1, const Expression2Type &e2)
Constructs the expression-template node wrapping e1 and e2.
Definition: VectorExpression.hpp:169
F::ResultType ValueType
The element value type of the expression (the functor's result type).
Definition: VectorExpression.hpp:150
const SelfType ConstClosureType
Constant closure type used when this expression appears inside another expression.
Definition: VectorExpression.hpp:156
SizeType getSize() const
Returns the element count after verifying that both wrapped expressions agree on it.
Definition: VectorExpression.hpp:177
SelfType ClosureType
Closure type used when this expression appears inside another expression.
Definition: VectorExpression.hpp:158
const ValueType ConstReference
Constant reference type to an element value.
Definition: VectorExpression.hpp:152
CommonType< typename E1::SizeType, typename E2::SizeType >::Type SizeType
The common size type of the two wrapped expressions.
Definition: VectorExpression.hpp:160
Expression-template node combining two vector expressions E1 and E2 via a binary functor F invoked wi...
Definition: VectorExpression.hpp:236
SizeType getSize() const
Returns the element count after verifying that both wrapped expressions agree on it.
Definition: VectorExpression.hpp:274
ConstReference operator()(SizeType i) const
Invokes the functor with both wrapped expressions and the index i and returns the result.
Definition: VectorExpression.hpp:284
CommonType< typename E1::SizeType, typename E2::SizeType >::Type SizeType
The common size type of the two wrapped expressions.
Definition: VectorExpression.hpp:257
F::ResultType ValueType
The element value type of the expression (the functor's result type).
Definition: VectorExpression.hpp:247
const SelfType ConstClosureType
Constant closure type used when this expression appears inside another expression.
Definition: VectorExpression.hpp:253
const ValueType Reference
Mutable reference type (degrades to const for expression-template results).
Definition: VectorExpression.hpp:251
VectorBinary2(const Expression1Type &e1, const Expression2Type &e2)
Constructs the expression-template node wrapping e1 and e2.
Definition: VectorExpression.hpp:266
ConstReference operator[](SizeType i) const
Alias for operator() — invokes the functor with both wrapped expressions and the index i.
Definition: VectorExpression.hpp:294
SelfType ClosureType
Closure type used when this expression appears inside another expression.
Definition: VectorExpression.hpp:255
const ValueType ConstReference
Constant reference type to an element value.
Definition: VectorExpression.hpp:249
CommonType< typename E1::DifferenceType, typename E2::DifferenceType >::Type DifferenceType
The common signed difference type of the two wrapped expressions.
Definition: VectorExpression.hpp:259
CRTP base class for all vector expression types.
Definition: Expression.hpp:66
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:72
SelfType ClosureType
Closure type used when this expression appears inside another expression.
Definition: VectorExpression.hpp:70
const SelfType ConstClosureType
Constant closure type used when this expression appears inside another expression.
Definition: VectorExpression.hpp:68
E::DifferenceType DifferenceType
The signed difference type inherited from the wrapped expression.
Definition: VectorExpression.hpp:74
VectorUnary(const ExpressionType &e)
Constructs the expression-template node wrapping e.
Definition: VectorExpression.hpp:80
F::ResultType ValueType
The element value type of the expression (the functor's result type).
Definition: VectorExpression.hpp:62
const ValueType Reference
Mutable reference type (degrades to const for expression-template results).
Definition: VectorExpression.hpp:66
ConstReference operator[](SizeType i) const
Alias for operator() — applies the unary functor to element i of the wrapped expression.
Definition: VectorExpression.hpp:107
const ValueType ConstReference
Constant reference type to an element value.
Definition: VectorExpression.hpp:64
ConstReference operator()(SizeType i) const
Applies the unary functor to element i of the wrapped expression and returns the result.
Definition: VectorExpression.hpp:97
SizeType getSize() const
Returns the wrapped expression's size.
Definition: VectorExpression.hpp:87
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 3-vector cross product as an expression-template node.
Definition: VectorExpression.hpp:865
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:704
MatrixTranspose< E > trans(MatrixExpression< E > &e)
Returns a mutable Math::MatrixTranspose view of the matrix expression e.
Definition: MatrixExpression.hpp:1692
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:639
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:624
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:966
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:611
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:883
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:561
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:654
QuaternionNorm2< E >::ResultType norm2(const QuaternionExpression< E > &e)
Returns the squared norm of the quaternion expression e.
Definition: QuaternionExpression.hpp:1397
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:594
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:901
VectorNorm2< E >::ResultType length(const VectorExpression< E > &e)
Returns the length (L2 norm) of the vector expression e (alias of norm2()).
Definition: VectorExpression.hpp:979
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:579
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:525
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:686
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:669
MatrixNormInfinity< E >::ResultType normInf(const MatrixExpression< E > &e)
Returns the L∞ (maximum absolute row sum) norm of the matrix expression e.
Definition: MatrixExpression.hpp:1650
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:1020
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:458
GridElementSum< E >::ResultType sum(const GridExpression< E > &e)
Returns the sum of all elements of the grid expression e.
Definition: GridExpression.hpp:720
MatrixNorm1< E >::ResultType norm1(const MatrixExpression< E > &e)
Returns the L1 (maximum absolute column sum) norm of the matrix expression e.
Definition: MatrixExpression.hpp:1624
const E & operator+(const GridExpression< E > &e)
Returns the grid expression e unchanged (unary +).
Definition: GridExpression.hpp:474
The namespace of the Chemical Data Processing Library.
std::common_type< T1, T2 >::type Type
The common type.
Definition: CommonType.hpp:49
Traits selecting the expression-template node and its result type for the Math::QuaternionVectorBinar...
Definition: VectorExpression.hpp:586
QuaternionVectorBinary< E1, E2, F > ExpressionType
The expression-template node type.
Definition: VectorExpression.hpp:589
ExpressionType ResultType
The expression-template result type returned by free-function operators.
Definition: VectorExpression.hpp:591
Traits selecting the expression-template node and its result type for the Math::Scalar1VectorBinary i...
Definition: VectorExpression.hpp:403
ExpressionType ResultType
The expression-template result type returned by free-function operators.
Definition: VectorExpression.hpp:408
Scalar1VectorBinary< E1, E2, F > ExpressionType
The expression-template node type.
Definition: VectorExpression.hpp:406
Traits selecting the expression-template node and its result type for the Math::Scalar2VectorBinary i...
Definition: VectorExpression.hpp:494
ExpressionType ResultType
The expression-template result type returned by free-function operators.
Definition: VectorExpression.hpp:499
Scalar2VectorBinary< E1, E2, F > ExpressionType
The expression-template node type.
Definition: VectorExpression.hpp:497
Scalar binary addition functor: apply(t1, t2) returns t1 + t2.
Definition: Functional.hpp:344
Scalar binary division functor: apply(t1, t2) returns t1 / t2.
Definition: Functional.hpp:419
Scalar binary multiplication functor: apply(t1, t2) returns t1 * t2.
Definition: Functional.hpp:394
Scalar binary subtraction functor: apply(t1, t2) returns t1 - t2.
Definition: Functional.hpp:369
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:502
CommonType< typename VectorInnerProduct< V1, V2 >::ResultType, T >::Type ResultType
Definition: Functional.hpp:492
Traits selecting the expression-template node and its result type for the Math::VectorBinary1 instant...
Definition: VectorExpression.hpp:215
ExpressionType ResultType
The expression-template result type returned by free-function operators.
Definition: VectorExpression.hpp:220
VectorBinary1< E1, E2, F > ExpressionType
The expression-template node type.
Definition: VectorExpression.hpp:218
Traits selecting the expression-template node and its result type for the Math::VectorBinary2 instant...
Definition: VectorExpression.hpp:312
VectorBinary2< E1, E2, F > ExpressionType
The expression-template node type.
Definition: VectorExpression.hpp:315
ExpressionType ResultType
The expression-template result type returned by free-function operators.
Definition: VectorExpression.hpp:317
Vector cross-product functor: apply(e1, e2, i) returns the i-th component of the 3-vector cross produ...
Definition: Functional.hpp:641
VectorScalarUnaryFunctor< V >::ResultType ResultType
Definition: Functional.hpp:701
static ResultType apply(const VectorExpression< V > &e)
Returns the sum of all elements of e.
Definition: Functional.hpp:708
VectorBooleanBinaryFunctor< V1, V2 >::ResultType ResultType
Definition: Functional.hpp:541
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:549
VectorScalarBinaryFunctor< V1, V2 >::ResultType ResultType
Definition: Functional.hpp:459
static ResultType apply(const VectorExpression< V1 > &e1, const VectorExpression< V2 > &e2)
Returns the inner product of e1 and e2.
Definition: Functional.hpp:468
static ResultType apply(const VectorExpression< V > &e)
Returns the L1 norm of e.
Definition: Functional.hpp:754
VectorScalarRealUnaryFunctor< V >::ResultType ResultType
Definition: Functional.hpp:747
VectorScalarRealUnaryFunctor< V >::ResultType ResultType
Definition: Functional.hpp:777
static ResultType apply(const VectorExpression< V > &e)
Returns the L2 norm of e.
Definition: Functional.hpp:784
VectorScalarIndexUnaryFunctor< V >::ResultType ResultType
Definition: Functional.hpp:860
static ResultType apply(const VectorExpression< V > &e)
Returns the index of the element of e with the largest L∞ norm.
Definition: Functional.hpp:867
static ResultType apply(const VectorExpression< V > &e)
Returns the L∞ norm of e.
Definition: Functional.hpp:817
VectorScalarRealUnaryFunctor< V >::ResultType ResultType
Definition: Functional.hpp:810
Scalar3VectorBooleanTernaryFunctor< V1, V2, T >::ResultType ResultType
Definition: Functional.hpp:594
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:604
Traits selecting the expression-template node and its result type for the Math::VectorUnary instantia...
Definition: VectorExpression.hpp:123
ExpressionType ResultType
The expression-template result type returned by free-function operators.
Definition: VectorExpression.hpp:128
VectorUnary< E, F > ExpressionType
The expression-template node type.
Definition: VectorExpression.hpp:126