Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
dunecore
dunecore
DuneInterface
Utility
ParFormula.h
Go to the documentation of this file.
1
// ParFormula.h
2
//
3
// David Adams
4
// July 2021
5
//
6
// Interface for a formula with N variables and M named parameters.
7
// Methods are provided to set the parameters and evaluate
8
// given variables using those settings.
9
10
#ifndef ParFormula_H
11
#define ParFormula_H
12
13
#include <string>
14
#include <vector>
15
16
class
ParFormula
{
17
18
public
:
19
20
using
Value
= double;
// Type for variables, parameters and evaluation
21
using
Values
= std::vector<Value>;
22
using
Index
=
unsigned
int
;
23
using
Name
=
std::string
;
24
using
Names
= std::vector<Name>;
25
26
public
:
// const methods
27
28
// Dtor;
29
virtual
~ParFormula
() { }
30
31
// Formula name.
32
virtual
Name
name
()
const
{
return
""
; }
33
34
// String representation of the formula.
35
// Expected but not required that prameters are in square brackets
36
// and variables x, y, z or x[0], x[1], ....
37
// E.g. for parameters Par1 and Par2: [Par1]*sin(x + [Par2])
38
virtual
Name
formulaString
()
const
=0;
39
40
// Number of variables.
41
virtual
Index
nvar
()
const
=0;
42
43
// Parameter count and names.
44
virtual
Index
npar
()
const
{
return
pars
().size(); }
45
virtual
Names
pars
()
const
=0;
46
47
// Return the set, unset and reset parameter names.
48
virtual
Names
setPars
()
const
=0;
49
virtual
Names
unsetPars
()
const
=0;
50
virtual
Names
resetPars
()
const
=0;
51
52
// Return if a parameter appears in the equation.
53
virtual
bool
isPar
(
Name
parnam)
const
=0;
54
55
// Return if all parameters are set.
56
virtual
bool
ready
()
const
{
return
setPars
().size() ==
npar
(); }
57
58
// Default evaluation value.
59
virtual
Value
defaultEval
()
const
{
return
0.0; }
60
61
// Evaluate the formula for N, 1 and 0 variables.
62
virtual
double
eval
(
const
Values
& vars)
const
=0;
63
virtual
double
eval
(
Value
var
)
const
=0;
64
virtual
double
eval
()
const
=0;
65
66
public
:
// non-const methods
67
68
// Set a parameter value.
69
// Return 0 for success.
70
virtual
int
setParValue
(
Name
parnam,
Value
parval) =0;
71
72
// Set the default evaluation value.
73
// Return 0 for success.
74
virtual
int
setDefaultEval
(
Value
val
) {
return
1; }
75
76
// Unset the parameters.
77
virtual
int
unsetParValues
() =0;
78
79
};
80
81
#endif
ParFormula::Name
std::string Name
Definition:
ParFormula.h:23
val
Definition:
registry_via_id_test_2.cc:15
ParFormula::setDefaultEval
virtual int setDefaultEval(Value val)
Definition:
ParFormula.h:74
ParFormula::pars
virtual Names pars() const =0
string
std::string string
Definition:
nybbler.cc:12
ParFormula::Index
unsigned int Index
Definition:
ParFormula.h:22
ParFormula::eval
virtual double eval() const =0
ParFormula::formulaString
virtual Name formulaString() const =0
ParFormula::ready
virtual bool ready() const
Definition:
ParFormula.h:56
ParFormula::unsetPars
virtual Names unsetPars() const =0
ParFormula::Value
double Value
Definition:
ParFormula.h:20
ParFormula::npar
virtual Index npar() const
Definition:
ParFormula.h:44
ParFormula::nvar
virtual Index nvar() const =0
ParFormula::setPars
virtual Names setPars() const =0
ParFormula::setParValue
virtual int setParValue(Name parnam, Value parval)=0
ParFormula
Definition:
ParFormula.h:16
ParFormula::Names
std::vector< Name > Names
Definition:
ParFormula.h:24
keras_to_tensorflow.int
int
Definition:
keras_to_tensorflow.py:69
var
int var
Definition:
018_def.c:9
ParFormula::Values
std::vector< Value > Values
Definition:
ParFormula.h:21
ParFormula::defaultEval
virtual Value defaultEval() const
Definition:
ParFormula.h:59
ParFormula::resetPars
virtual Names resetPars() const =0
ParFormula::unsetParValues
virtual int unsetParValues()=0
ParFormula::isPar
virtual bool isPar(Name parnam) const =0
ParFormula::name
virtual Name name() const
Definition:
ParFormula.h:32
ParFormula::~ParFormula
virtual ~ParFormula()
Definition:
ParFormula.h:29
Generated by
1.8.11