Chemical Data Processing Library C++ API - Version 1.4.0
QuaternionAssignment.hpp
Go to the documentation of this file.
1 /*
2  * QuaternionAssignment.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_QUATERNIONASSIGNMENT_HPP
28 #define CDPL_MATH_QUATERNIONASSIGNMENT_HPP
29 
30 #include <utility>
31 
32 
33 namespace CDPL
34 {
35 
36  namespace Math
37  {
38 
39  template <typename E>
40  class QuaternionExpression;
41 
55  template <template <typename T1, typename T2> class F, typename Q, typename E>
57  {
58  typedef F<typename Q::Reference, typename E::ValueType> FunctorType;
59 
60  FunctorType::apply(q.getC1(), e().getC1());
61  FunctorType::apply(q.getC2(), e().getC2());
62  FunctorType::apply(q.getC3(), e().getC3());
63  FunctorType::apply(q.getC4(), e().getC4());
64  }
65 
74  template <template <typename T1, typename T2> class F, typename Q, typename T>
75  void quaternionAssignScalar(Q& q, const T& t)
76  {
77  typedef F<typename Q::Reference, T> FunctorType;
78 
79  FunctorType::apply(q.getC1(), t);
80  FunctorType::apply(q.getC2(), t);
81  FunctorType::apply(q.getC3(), t);
82  FunctorType::apply(q.getC4(), t);
83  }
84 
92  template <typename Q, typename E>
94  {
95  std::swap(q.getC1(), e().getC1());
96  std::swap(q.getC2(), e().getC2());
97  std::swap(q.getC3(), e().getC3());
98  std::swap(q.getC4(), e().getC4());
99  }
100  } // namespace Math
101 } // namespace CDPL
102 
103 #endif // CDPL_MATH_QUATERNIONASSIGNMENT_HPP
CRTP base class for all quaternion expression types.
Definition: Expression.hpp:142
constexpr unsigned int T
Specifies Hydrogen (Tritium).
Definition: AtomType.hpp:67
constexpr unsigned int F
Specifies Fluorine.
Definition: AtomType.hpp:107
constexpr unsigned int Q
Generic type that covers any element except hydrogen and carbon.
Definition: AtomType.hpp:647
constexpr unsigned int E
Specifies that the stereocenter has E configuration.
Definition: CIPDescriptor.hpp:96
void quaternionAssignScalar(Q &q, const T &t)
Applies the element-wise functor F to every (quaternion component, scalar) pair.
Definition: QuaternionAssignment.hpp:75
void quaternionSwap(Q &q, QuaternionExpression< E > &e)
Swaps the components of two quaternion expressions component by component.
Definition: QuaternionAssignment.hpp:93
void quaternionAssignQuaternion(Q &q, const QuaternionExpression< E > &e)
Applies the binary functor F componentwise between the destination quaternion q and the source quater...
Definition: QuaternionAssignment.hpp:56
The namespace of the Chemical Data Processing Library.