NeuroLab
|
Class for mathematical functions. More...
Public Member Functions | |
Function (const Function &) | |
Copy. | |
Function (double d) | |
Double to Function. More... | |
virtual | ~Function () |
Destructor. | |
virtual string | getName () const |
Returns the name. More... | |
Function & | setVerbose (bool verbose=true, ostream *log=&cout) |
Set function to be verbose. More... | |
virtual double | getValue () const |
Returns the value. More... | |
double | operator() (double x) |
Returns the value at a point. More... | |
double | operator() (double x, double y) |
Returns the value at a point. More... | |
void | setXInput (double) |
Set x input. More... | |
void | setYInput (double) |
Set y input. More... | |
double | getXInput () |
Get x input. More... | |
double | getYInput () |
Get y input. More... | |
virtual double | getLastValue () const |
Returns the value. More... | |
Function & | setPhysical (string s, Unit u) |
Returns the function graph. More... | |
virtual Function & | setXRange (double min, double max, double stepsize) |
Set the x range. More... | |
virtual Function & | setYRange (double min, double max, double stepsize) |
Set the y range. More... | |
string | getXInputName () |
Get input name. More... | |
string | getYInputName () |
Get input name. More... | |
Function & | setName (string s) |
Sets the name. More... | |
void | operator+= (Function &function) |
Add. More... | |
void | operator-= (Function &function) |
Subtract. More... | |
void | operator*= (Function &function) |
Multiply. More... | |
void | operator/= (Function &function) |
Divide. More... | |
Public Member Functions inherited from Physical | |
Physical () | |
Construct. | |
Physical (const Physical &) | |
Copy. | |
Physical (string name) | |
Construct. | |
Physical (string name, string unitPrefix, string unitSymbol) | |
Construct. | |
Physical (string name, Unit unit) | |
Construct. | |
virtual string | getDescription () |
Retrive the physical name. More... | |
virtual string | getPhysicalDescription () |
Returns the physical description. More... | |
virtual string | getUnitName () |
Returns the unit name. | |
virtual string | getUnitSymbol () |
Returns the unit name. | |
virtual void | setDescription (string name) |
Set the name. More... | |
virtual void | setPhysicalDescription (string name) |
Set the name. Same as setDescription(). More... | |
virtual void | setUnit (Unit u) |
Set the unit. | |
virtual void | setUnitPrefix (int n) |
Set unit prefix. More... | |
virtual Unit | getUnit () const |
Retrieve the unit. | |
Protected Member Functions | |
Function () | |
Default Constructor. More... | |
void | unvalidate () |
Set unvalid. More... | |
Protected Attributes | |
int | nRefs |
we do reference counting | |
vector< Function * > | vParents |
parents, for ref counting | |
Friends | |
Function & | operator/ (Function &left, Function &right) |
Divide. More... | |
Function & | exp (Function &right) |
Exponential. More... | |
Function & | ln (Function &right) |
Logarithm. More... | |
Function & | sin (Function &right) |
Sine. More... | |
Function & | cos (Function &right) |
Cosine. More... | |
Function & | sqrt (Function &right) |
Square root. More... | |
Function & | square (Function &right) |
Square. More... | |
Function & | root (Function &left, Function &n) |
Root. More... | |
Function & | power (Function &left, Function &n) |
Power. More... | |
Function & | integral (Function &integrand, Function &integrator) |
Integral.. More... | |
Function & | increments (Function &right) |
Increments. More... | |
Function & | greater (Function &left, Function &right) |
Comparison. More... | |
Function & | smaller (Function &left, Function &right) |
Comparison. More... | |
Function & | operator> (Function &left, Function &right) |
Comparison. More... | |
Function & | operator< (Function &left, Function &right) |
Comparison. More... | |
Function & | operator<= (Function &left, Function &right) |
Comparison. More... | |
Function & | operator>= (Function &left, Function &right) |
Comparison. More... | |
Function & | sign (Function &right) |
Sign of a number. | |
ostream & | operator<< (ostream &os, Function &f) |
Appends the function specification string to a stream. More... | |
Function & | input (string) |
Create input. More... | |
Function & | cnst (double) |
Create a function from a constant. | |
Function & | cnst (double, string) |
Create a function from a constant and a name. | |
Function & | xtable (Matrix &, Function &right) |
Create a function from a matrix. | |
Function & | empty () |
An empty function. | |
Class for mathematical functions.
This class implements mathematical functions for use with the Display class (which supports only gnuplot output at the moment. Functions are created from Variables using +, -, *, /, exp, ln, sqrt, square, sqrt, power, or root. Note the special variables X and Y. Functions use referencing, and form an execution tree. When any variable in the function changes, the function output changes. Appending a function to a Display (using <<) will append the output with the current variable setting. That way you can append the same function to the same display, with different values of its variables, and the result will be different curves on top of each other. The function can be appended to any string using the << operator.
|
inlineprotected |
Default Constructor.
Constructs an empty function. This is mainly for use in the derived classes X and Y.
Function::Function | ( | double | d | ) |
Double to Function.
Constructs a constant from a double. Same as cnst(double).
|
virtual |
Returns the value.
Returns the last value of the function. This is the value which was produced by the last getValue() call. No recomputation is executed.
|
virtual |
|
virtual |
Returns the value.
Computes the current value of the function. This is dependent on variables and input.
double Function::getXInput | ( | ) |
Get x input.
This gets the x input of the whole tree. If input values are different at different branches, the first which is encountered will be returned.
string Function::getXInputName | ( | ) |
Get input name.
Returns the name of the first input, for instance 't' or 'x'.
double Function::getYInput | ( | ) |
Get y input.
This gets the y input of the whole tree. If input values are different at different branches, the first which is encountered will be returned.
string Function::getYInputName | ( | ) |
Get input name.
Returns the name of the second input, for instance 't' or 'x'.
|
inline |
Returns the value at a point.
Computes the current value of the function. This is dependent on variables and input.
|
inline |
Returns the value at a point.
Computes the current value of the function. This is dependent on variables and input.
void Function::operator*= | ( | Function & | function | ) |
Multiply.
Multiplies the given function to this function object.
void Function::operator+= | ( | Function & | function | ) |
Add.
Adds the given function to this function object.
void Function::operator-= | ( | Function & | function | ) |
Subtract.
Subtracts the given function from the object..
void Function::operator/= | ( | Function & | function | ) |
Divide.
Divides the given function to this function object.
Function& Function::setName | ( | string | s | ) |
Sets the name.
This function returns a reference to its object for convenience.
Returns the function graph.
Returns the function graph. This is dependent on variables and input range. Sets the physical type. This sets a physical name (like 'voltage'), and a unit (like mV).
Function& Function::setVerbose | ( | bool | verbose = true , |
ostream * | log = &cout |
||
) |
Set function to be verbose.
If this is set, the function will append its current value and its name to a stream, each time getValue() is called. setVerbose() will set all subfunctions to be verbose as well. This way a log of the whole calculation will be appended to a stream.
verbose | whether the function is verbose (sends state log-messages to a stream) |
log | the stream receiving the log messages |
void Function::setXInput | ( | double | ) |
Set x input.
This sets the x input of the whole tree to the given value.
|
virtual |
Set the x range.
Sets the x range of the function, i.e. the function will be plotted in a range from minimum to maximum, with the given step size.
min | minimum |
max | maximum |
stepsize | step size |
void Function::setYInput | ( | double | ) |
Set y input.
This sets the y input of the whole tree to the given value.
|
virtual |
Set the y range.
Sets the y range of the function, i.e. the function will be plotted in a range from minimum to maximum, with the given step size.
min | minimum |
max | maximum |
stepsize | step size |
|
protected |
Set unvalid.
After this, the function will perform a full computation, if getValue() is called. Otherwise just the last value is return. This function needs to be called if some input has changed lower down in the execution tree.
Cosine.
Creates a Function which is the logarithm of the input function.
Exponential.
Creates a Function which is the exponential of the input function.
Comparison.
Returns 1.0 at places where the comparison is true, and 0.0 at places where the comparison is false.
Increments.
Creates the differential df(x) of a given integrand f(x). If plotted, you will see the function
.
|
friend |
Create input.
Creates a function which serves as input for other functions.
Integral..
Creates the undefinite integral of the given integrand. If plotted, you will see the function
.
Logarithm.
Creates a Function which is the logarithm of the input function.
Divide.
Creates a Function which is the quotient of the two input functions.
Comparison.
Returns 1.0 at places where the comparison is true, and 0.0 at places where the comparison is false.
|
friend |
Appends the function specification string to a stream.
The appended string is gnuplot readable, and may contain lots of parentheses, depending on the complexity of the function.
Comparison.
Returns 1.0 at places where the comparison is true, and 0.0 at places where the comparison is false.
Comparison.
Returns 1.0 at places where the comparison is true, and 0.0 at places where the comparison is false.
Comparison.
Returns 1.0 at places where the comparison is true, and 0.0 at places where the comparison is false.
Power.
Root.
Sine.
Creates a Function which is the logarithm of the input function.
Comparison.
Returns 1.0 at places where the comparison is true, and 0.0 at places where the comparison is false.