![]() |
OpendTect
7.0
|
Math formula: (expression, inputs, units, calculation, storage). More...
Classes | |
class | InpDef |
Public Member Functions | |
Formula (bool inputsareseries, const SpecVarSet &, const char *txt=nullptr) | |
Formula (bool inputsareseries=true, const char *txt=nullptr) | |
Formula (const Formula &) | |
~Formula () | |
void | clearAllDefs () |
void | clearInputDefs () |
Formula & | copyFrom (const Math::Formula &) |
*< Does not use the description and values More... | |
const char * | description () const |
const char * | errMsg () const |
const Expression * | expression () const |
void | fillPar (IOPar &) const |
double | getConstVal (int) const |
if isConst returns toDouble(inputDef(i)), else Udf More... | |
void | getInputMnemonics (MnemonicSelection &) const |
const TypeSet< int > & | getShifts (int iinp) const |
double | getValue (const double *) const |
double | getValue (const double *vals, bool internuns) const |
float | getValue (const float *vals, bool internuns=true) const |
bool | hasFixedUnits () const |
const char * | inputDef (int iinp) const |
const char * | inputDescription (int iinp) const |
const UnitOfMeasure * | inputFormUnit (int iinp) const |
const Mnemonic * | inputMnemonic (int iinp) const |
bool | inputsAreSeries () const |
const char * | inputVar (int iinp) const |
bool | isBad () const |
bool | isCompatibleWith (const Formula &) const |
bool | isCompatibleWith (const Mnemonic &, const MnemonicSelection *inps=nullptr) const |
bool | isConst (int iinp) const |
bool | isOK () const |
bool | isRecursive () const |
bool | isSpec (int iinp) const |
int | maxRecShift () const |
int | nrConsts () const |
int | nrExternalInputs () const |
int | nrInputs () const |
int | nrSpecs () const |
int | nrValues2Provide () const |
bool | operator!= (const Formula &) const |
*< Does not use the description More... | |
Formula & | operator= (const Formula &) |
*< Does not use the description More... | |
bool | operator== (const Formula &) const |
const UnitOfMeasure * | outputFormUnit () const |
const Mnemonic * | outputMnemonic () const |
TypeSet< double > & | recStartVals () |
void | setDescription (const char *descstr) |
*< Does not copy input definitions and descriptions More... | |
void | setInputDef (int, const char *) |
void | setInputDescription (int, const char *) |
Optional description of an input. More... | |
void | setInputFormUnit (int, const UnitOfMeasure *) |
The input unit within the expression. More... | |
void | setInputMnemonic (int, const Mnemonic *) |
void | setInputValUnit (int, const UnitOfMeasure *) |
The input unit of incoming values. More... | |
void | setOutputFormUnit (const UnitOfMeasure *uom) |
The output unit of the math expression. More... | |
void | setOutputMnemonic (const Mnemonic *mn) |
void | setOutputValUnit (const UnitOfMeasure *uom) |
The unit of the returned value (getValue) More... | |
virtual void | setText (const char *) |
Interval< int > | shiftRange (int iinp) const |
int | specIdx (int) const |
const SpecVarSet & | specVars () const |
void | startNewSeries () const |
const char * | text () const |
void | usePar (const IOPar &) |
const char * | userDispText () const |
const char * | variableName (int iinp) const |
![]() | |
NamedObject (const char *nm=nullptr) | |
NamedObject (const NamedObject &oth) | |
virtual | ~NamedObject () |
virtual BufferString | getName () const |
bool | getNameFromPar (const IOPar &) |
const name_type & | name () const override |
NamedObject & | operator= (const NamedObject &) |
bool | operator== (const NamedObject &oth) const |
virtual void | setName (const char *nm) |
![]() | |
virtual | ~ObjectWithName () |
bool | hasName (const char *nm) const |
bool | hasName (const name_type &nm) const |
void | putNameInPar (IOPar &) const |
Static Public Member Functions | |
static const char * | sKeyExpression () |
static const char * | sKeyFileType () |
static const char * | sKeyRecStartVals () |
Protected Member Functions | |
void | addShift (int, int, int &, TypeSet< TypeSet< int > > &) |
int | varNameIdx (const char *varnm) const |
Protected Attributes | |
BufferString | desc_ |
BufferString | errmsg_ |
Expression * | expr_ = nullptr |
Threads::Lock | formlock_ |
TypeSet< int > | inpidxs_ |
ObjectSet< InpDef > | inps_ |
const bool | inputsareseries_ |
const Mnemonic * | outputformmn_ = nullptr |
const UnitOfMeasure * | outputformunit_ = nullptr |
const UnitOfMeasure * | outputvalunit_ = nullptr |
TypeSet< double > | prevvals_ |
TypeSet< int > | recshifts_ |
TypeSet< double > | recstartvals_ |
const SpecVarSet * | specvars_ |
BufferString | text_ |
TypeSet< int > | validxs_ |
![]() | |
BufferString | name_ |
Additional Inherited Members | |
![]() | |
typedef OD::String | name_type |
Math formula: (expression, inputs, units, calculation, storage).
Before construction gather your 'special variables'. Users can insert them and they are not 'regular input'. See SpecVars and SpecVarSet.
At construction or when calling setText(), the input text is parsed. Then, the variable definitions are known. You can use setInputFormUnit(idx) before calculation, this unit is the unit that the user wants the variable value to be used into the mathexpression. setOutputFormUnit(idx) will specify the unit of the variable return by the mathexpression.
When you know what is required, you can provide numbers for the different inputs and get a result using getValue(). The input values you provide must match the form input units, otherwise setInputValUnit must be called. The output values will match the form output unit, unless setOutputValUnit was called.
If your formula is to work on a series of input vectors, then two things become possible: 1) Recursive values. This is when the user uses out[i] ot this[i]. 2) Input shifts. For example: ampl[-1] or den[3]. For (1), you can specify start values. The maximum shift is the size of the TypeSet. These recursive variables will not show up in the inputs. For (2), you need to have extra values in the input value array (i.e. you need to loop over the getShifts(iinp).
Before using getValue(), you want to use setInputDef(idx) and maybe set the input unit conversions. This makes it possible to store/retrieve in IOPar, but this is aso required if there are constants in the expression.
The setOutputUnit() can be used to keep track of what the result means, or to get the result in that unit from getValue().
Lastly, the SpecVarSet you provide usually lives forever, but should at least stay alive during the lifetime of the formula (it is not copied).
<>
Math::Formula::Formula | ( | bool | inputsareseries = true , |
const char * | txt = nullptr |
||
) |
Math::Formula::Formula | ( | bool | inputsareseries, |
const SpecVarSet & | , | ||
const char * | txt = nullptr |
||
) |
Math::Formula::Formula | ( | const Formula & | ) |
Math::Formula::~Formula | ( | ) |
void Math::Formula::clearAllDefs | ( | ) |
void Math::Formula::clearInputDefs | ( | ) |
Formula& Math::Formula::copyFrom | ( | const Math::Formula & | ) |
*< Does not use the description and values
|
inline |
|
inline |
|
inline |
void Math::Formula::fillPar | ( | IOPar & | ) | const |
double Math::Formula::getConstVal | ( | int | ) | const |
if isConst returns toDouble(inputDef(i)), else Udf
void Math::Formula::getInputMnemonics | ( | MnemonicSelection & | ) | const |
|
inline |
double Math::Formula::getValue | ( | const double * | ) | const |
You may annotate the units of incoming values, and require the conversion of the output value
double Math::Formula::getValue | ( | const double * | vals, |
bool | internuns | ||
) | const |
float Math::Formula::getValue | ( | const float * | vals, |
bool | internuns = true |
||
) | const |
bool Math::Formula::hasFixedUnits | ( | ) | const |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
bool Math::Formula::isCompatibleWith | ( | const Formula & | ) | const |
bool Math::Formula::isCompatibleWith | ( | const Mnemonic & | , |
const MnemonicSelection * | inps = nullptr |
||
) | const |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
int Math::Formula::nrConsts | ( | ) | const |
int Math::Formula::nrExternalInputs | ( | ) | const |
|
inline |
int Math::Formula::nrSpecs | ( | ) | const |
int Math::Formula::nrValues2Provide | ( | ) | const |
bool Math::Formula::operator!= | ( | const Formula & | ) | const |
*< Does not use the description
bool Math::Formula::operator== | ( | const Formula & | ) | const |
|
inline |
|
inline |
|
inline |
|
inline |
*< Does not copy input definitions and descriptions
Optional description of the formula output
void Math::Formula::setInputDef | ( | int | , |
const char * | |||
) |
The variable name (replacing c*), or a string carrying a constant/special value
void Math::Formula::setInputDescription | ( | int | , |
const char * | |||
) |
Optional description of an input.
void Math::Formula::setInputFormUnit | ( | int | , |
const UnitOfMeasure * | |||
) |
The input unit within the expression.
void Math::Formula::setInputMnemonic | ( | int | , |
const Mnemonic * | |||
) |
void Math::Formula::setInputValUnit | ( | int | , |
const UnitOfMeasure * | |||
) |
The input unit of incoming values.
|
inline |
The output unit of the math expression.
|
inline |
|
inline |
The unit of the returned value (getValue)
|
virtual |
Reimplemented in RockPhysics::Formula.
|
inline |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
int Math::Formula::specIdx | ( | int | ) | const |
|
inline |
void Math::Formula::startNewSeries | ( | ) | const |
|
inline |
void Math::Formula::usePar | ( | const IOPar & | ) |
const char* Math::Formula::userDispText | ( | ) | const |
|
inline |
|
protected |
|
protected |
|
mutableprotected |
|
protected |
|
mutableprotected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
mutableprotected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
Generated at 02/08/2024 10:20:20 for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B.V. 1995-2024