Chemical Data Processing Library C++ API - Version 1.2.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 
42  template <template <typename T1, typename T2> class F, typename Q, typename E>
44  {
45  typedef F<typename Q::Reference, typename E::ValueType> FunctorType;
46 
47  FunctorType::apply(q.getC1(), e().getC1());
48  FunctorType::apply(q.getC2(), e().getC2());
49  FunctorType::apply(q.getC3(), e().getC3());
50  FunctorType::apply(q.getC4(), e().getC4());
51  }
52 
53  template <template <typename T1, typename T2> class F, typename Q, typename T>
54  void quaternionAssignScalar(Q& q, const T& t)
55  {
56  typedef F<typename Q::Reference, T> FunctorType;
57 
58  FunctorType::apply(q.getC1(), t);
59  FunctorType::apply(q.getC2(), t);
60  FunctorType::apply(q.getC3(), t);
61  FunctorType::apply(q.getC4(), t);
62  }
63 
64  template <typename Q, typename E>
66  {
67  std::swap(q.getC1(), e().getC1());
68  std::swap(q.getC2(), e().getC2());
69  std::swap(q.getC3(), e().getC3());
70  std::swap(q.getC4(), e().getC4());
71  }
72  } // namespace Math
73 } // namespace CDPL
74 
75 #endif // CDPL_MATH_QUATERNIONASSIGNMENT_HPP
Definition: Expression.hpp:98
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
A 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)
Definition: QuaternionAssignment.hpp:54
void quaternionSwap(Q &q, QuaternionExpression< E > &e)
Definition: QuaternionAssignment.hpp:65
void quaternionAssignQuaternion(Q &q, const QuaternionExpression< E > &e)
Definition: QuaternionAssignment.hpp:43
The namespace of the Chemical Data Processing Library.