Chemical Data Processing Library C++ API - Version 1.4.0
Expression.hpp
Go to the documentation of this file.
1 /*
2  * Expression.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_EXPRESSION_HPP
28 #define CDPL_MATH_EXPRESSION_HPP
29 
30 
31 namespace CDPL
32 {
33 
34  namespace Math
35  {
36 
41  template <typename E>
42  class Expression
43  {
44 
45  public:
49  typedef E ExpressionType;
50 
51  protected:
54 
55  private:
56  const Expression& operator=(const Expression&);
57  };
58 
66  template <typename E>
67  class VectorExpression : public Expression<E>
68  {
69 
70  public:
74  typedef E ExpressionType;
75 
80  const ExpressionType& operator()() const
81  {
82  return *static_cast<const ExpressionType*>(this);
83  }
84 
90  {
91  return *static_cast<ExpressionType*>(this);
92  }
93 
94  protected:
97  };
98 
106  template <typename E>
107  class MatrixExpression : public Expression<E>
108  {
109 
110  public:
114  typedef E ExpressionType;
115 
120  const ExpressionType& operator()() const
121  {
122  return *static_cast<const ExpressionType*>(this);
123  }
124 
130  {
131  return *static_cast<ExpressionType*>(this);
132  }
133 
134  protected:
137  };
138 
146  template <typename E>
148  {
149 
150  public:
154  typedef E ExpressionType;
155 
160  const ExpressionType& operator()() const
161  {
162  return *static_cast<const ExpressionType*>(this);
163  }
164 
170  {
171  return *static_cast<ExpressionType*>(this);
172  }
173 
174  protected:
177  };
178 
186  template <typename E>
187  class GridExpression : public Expression<E>
188  {
189 
190  public:
194  typedef E ExpressionType;
195 
200  const ExpressionType& operator()() const
201  {
202  return *static_cast<const ExpressionType*>(this);
203  }
204 
210  {
211  return *static_cast<ExpressionType*>(this);
212  }
213 
214  protected:
217  };
218 
223  template <typename C>
225  {
226 
227  public:
231  typedef C ContainerType;
232 
237  const ContainerType& operator()() const
238  {
239  return *static_cast<const ContainerType*>(this);
240  }
241 
247  {
248  return *static_cast<ContainerType*>(this);
249  }
250 
251  protected:
254  };
255 
260  template <typename C>
262  {
263 
264  public:
268  typedef C ContainerType;
269 
274  const ContainerType& operator()() const
275  {
276  return *static_cast<const ContainerType*>(this);
277  }
278 
284  {
285  return *static_cast<ContainerType*>(this);
286  }
287 
288  protected:
291  };
292 
297  template <typename C>
299  {
300 
301  public:
305  typedef C ContainerType;
306 
311  const ContainerType& operator()() const
312  {
313  return *static_cast<const ContainerType*>(this);
314  }
315 
321  {
322  return *static_cast<ContainerType*>(this);
323  }
324 
325  protected:
328  };
329 
334  template <typename C>
335  class GridContainer : public GridExpression<C>
336  {
337 
338  public:
342  typedef C ContainerType;
343 
348  const ContainerType& operator()() const
349  {
350  return *static_cast<const ContainerType*>(this);
351  }
352 
358  {
359  return *static_cast<ContainerType*>(this);
360  }
361 
362  protected:
365  };
366  } // namespace Math
367 } // namespace CDPL
368 
369 #endif // CDPL_MATH_EXPRESSION_HPP
CRTP base class of all numeric expression types in the Math namespace.
Definition: Expression.hpp:43
E ExpressionType
The derived expression type.
Definition: Expression.hpp:49
~Expression()
Definition: Expression.hpp:53
Expression()
Definition: Expression.hpp:52
Refinement of Math::GridExpression marking the derived type as a concrete (writable) grid container.
Definition: Expression.hpp:336
ContainerType & operator()()
Returns a reference to the derived grid container class instance.
Definition: Expression.hpp:357
~GridContainer()
Definition: Expression.hpp:364
const ContainerType & operator()() const
Returns a const reference to the derived grid container class instance.
Definition: Expression.hpp:348
C ContainerType
The derived grid container type.
Definition: Expression.hpp:342
GridContainer()
Definition: Expression.hpp:363
CRTP base class of all grid expression types.
Definition: Expression.hpp:188
E ExpressionType
The derived grid expression type.
Definition: Expression.hpp:194
ExpressionType & operator()()
Returns a reference to the derived grid expression class instance.
Definition: Expression.hpp:209
GridExpression()
Definition: Expression.hpp:215
~GridExpression()
Definition: Expression.hpp:216
const ExpressionType & operator()() const
Returns a const reference to the derived grid expression class instance.
Definition: Expression.hpp:200
Refinement of Math::MatrixExpression marking the derived type as a concrete (writable) matrix contain...
Definition: Expression.hpp:262
const ContainerType & operator()() const
Returns a const reference to the derived matrix container class instance.
Definition: Expression.hpp:274
MatrixContainer()
Definition: Expression.hpp:289
C ContainerType
The derived matrix container type.
Definition: Expression.hpp:268
~MatrixContainer()
Definition: Expression.hpp:290
ContainerType & operator()()
Returns a reference to the derived matrix container class instance.
Definition: Expression.hpp:283
CRTP base class of all matrix expression types.
Definition: Expression.hpp:108
E ExpressionType
The derived matrix expression type.
Definition: Expression.hpp:114
const ExpressionType & operator()() const
Returns a const reference to the derived matrix expression class instance.
Definition: Expression.hpp:120
MatrixExpression()
Definition: Expression.hpp:135
ExpressionType & operator()()
Returns a reference to the derived matrix expression class instance.
Definition: Expression.hpp:129
~MatrixExpression()
Definition: Expression.hpp:136
Refinement of Math::QuaternionExpression marking the derived type as a concrete (writable) quaternion...
Definition: Expression.hpp:299
ContainerType & operator()()
Returns a reference to the derived quaternion container class instance.
Definition: Expression.hpp:320
const ContainerType & operator()() const
Returns a const reference to the derived quaternion container class instance.
Definition: Expression.hpp:311
QuaternionContainer()
Definition: Expression.hpp:326
C ContainerType
The derived quaternion container type.
Definition: Expression.hpp:305
~QuaternionContainer()
Definition: Expression.hpp:327
CRTP base class of all quaternion expression types.
Definition: Expression.hpp:148
QuaternionExpression()
Definition: Expression.hpp:175
ExpressionType & operator()()
Returns a reference to the derived quaternion expression class instance.
Definition: Expression.hpp:169
~QuaternionExpression()
Definition: Expression.hpp:176
const ExpressionType & operator()() const
Returns a const reference to the derived quaternion expression class instance.
Definition: Expression.hpp:160
E ExpressionType
The derived quaternion expression type.
Definition: Expression.hpp:154
Refinement of Math::VectorExpression marking the derived type as a concrete (writable) vector contain...
Definition: Expression.hpp:225
~VectorContainer()
Definition: Expression.hpp:253
C ContainerType
The derived vector container type.
Definition: Expression.hpp:231
ContainerType & operator()()
Returns a reference to the derived vector container class instance.
Definition: Expression.hpp:246
const ContainerType & operator()() const
Returns a const reference to the derived vector container class instance.
Definition: Expression.hpp:237
VectorContainer()
Definition: Expression.hpp:252
CRTP base class of all vector expression types.
Definition: Expression.hpp:68
const ExpressionType & operator()() const
Returns a const reference to the derived vector expression class instance.
Definition: Expression.hpp:80
~VectorExpression()
Definition: Expression.hpp:96
ExpressionType & operator()()
Returns a reference to the derived vector expression class instance.
Definition: Expression.hpp:89
E ExpressionType
The derived vector expression type.
Definition: Expression.hpp:74
VectorExpression()
Definition: Expression.hpp:95
constexpr unsigned int C
Specifies Carbon.
Definition: AtomType.hpp:92
constexpr unsigned int E
Specifies that the stereocenter has E configuration.
Definition: CIPDescriptor.hpp:96
The namespace of the Chemical Data Processing Library.