blitzdg
an open-source project aiming to implement parallel discontinuous Galerkin (dg) solvers for common partial differential equations systems using blitz++ for array and tensor manipulations and MPI for distributed parallelism.
notoperator.h
1 
2 // Copyright Joakim Karlsson & Kim Gräsman 2010-2013.
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
6 
7 #ifndef IGLOO_NOTOPERATOR_H
8 #define IGLOO_NOTOPERATOR_H
9 
10 namespace snowhouse {
11 
13  {
14  template <typename ConstraintListType, typename ActualType>
15  void Evaluate(ConstraintListType& list, ResultStack& result, OperatorStack& operators, const ActualType& actual)
16  {
17  EvaluateOperatorsWithLessOrEqualPrecedence(*this, operators, result);
18 
19  operators.push(this);
20 
21  EvaluateConstraintList(list.m_tail, result, operators, actual);
22  }
23 
24  void PerformOperation(ResultStack& result)
25  {
26  if(result.size() < 1)
27  {
28  throw InvalidExpressionException("The expression contains a not operator without any operand");
29  }
30 
31  bool right = result.top();
32  result.pop();
33 
34  result.push(!right);
35  }
36 
37  int Precedence() const
38  {
39  return 2;
40  }
41  };
42 
43  template<>
45  {
46  static std::string ToString(const NotOperator&)
47  {
48  return "not";
49  }
50  };
51 }
52 
53 #endif
Definition: notoperator.h:12
Definition: assert.h:13
Definition: constraintoperator.h:26
Definition: constraintoperator.h:12
Definition: stringize.h:71