gmsh-TingyuanDoc  0.1
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
mathEvaluator.h
Go to the documentation of this file.
1 // Gmsh - Copyright (C) 1997-2022 C. Geuzaine, J.-F. Remacle
2 //
3 // See the LICENSE.txt file in the Gmsh root directory for license information.
4 // Please report all issues on https://gitlab.onelab.info/gmsh/gmsh/issues.
5 
6 #ifndef MATH_EVALUATOR_H
7 #define MATH_EVALUATOR_H
8 
9 #include <vector>
10 #include <string>
11 #include "GmshConfig.h"
12 #include "GmshMessage.h"
13 
14 #if defined(HAVE_MATHEX)
15 
16 #include "mathex.h"
17 
18 class mathEvaluator {
19 private:
20  std::vector<smlib::mathex *> _expressions;
21  std::vector<double> _variables;
22 
23 public:
24  // initialize one or more expressions depending on zero or more
25  // variables. If an error occurs the vector of expressions is
26  // cleared.
27  mathEvaluator(std::vector<std::string> &expressions,
28  const std::vector<std::string> &variables);
30  // evaluate the expression(s) using the given values and fill the
31  // result vector. Returns true if the evaluation succeeded.
32  bool eval(const std::vector<double> &values, std::vector<double> &res);
33 };
34 
35 #else
36 
38 public:
39  mathEvaluator(std::vector<std::string> &expressions,
40  const std::vector<std::string> &variables)
41  {
42  Msg::Error("Gmsh must be compiled with MathEx support to evaluate math "
43  "expressions");
44  expressions.clear();
45  }
47  bool eval(const std::vector<double> &values, std::vector<double> &res)
48  {
49  return false;
50  }
51 };
52 
53 #endif
54 
55 #endif
mathEvaluator
Definition: mathEvaluator.h:37
mathEvaluator::mathEvaluator
mathEvaluator(std::vector< std::string > &expressions, const std::vector< std::string > &variables)
Definition: mathEvaluator.h:39
Msg::Error
static void Error(const char *fmt,...)
Definition: GmshMessage.cpp:482
mathEvaluator::eval
bool eval(const std::vector< double > &values, std::vector< double > &res)
Definition: mathEvaluator.h:47
GmshMessage.h
mathEvaluator::~mathEvaluator
~mathEvaluator()
Definition: mathEvaluator.h:46