IGLib
1.7.2
The IGLib base library for development of numerical, technical and business applications.
|
Dynamically generates IRealFunction classes from user definitions. User can define in string form how function, its derivative, second derivative, integral, or inverse function is calculated. Then this class can be used to compile these definitions in the wrapping script, which is then used to create the corresponding function objects. More...
Public Member Functions | |
RealFunctionLoader () | |
Constructor. More... | |
void | InvalidateDefinitions () |
Clears strings that define the function (i.e. strings that define expressions for function value, derivative, integral, inverse, etc.). More... | |
void | SetNames (string returnedValueName, string functionArgumentName, string independentVariableName) |
Sets names used in generated script code. More... | |
void | SaveCode (string filePath) |
Saves the generated script code to the specified file. File is overwritten if it already exists. More... | |
string | Compile () |
Compiles the code that contains dynamically loadable definition of a real function of one variable. More... | |
LoadableRealFunctionBase | CreateRealFunction () |
Creates and returns an instance of dynamically compiled real function object. More... | |
LoadableRealFunctionBase | CreateRealFunction (double Kx, double Sx) |
Creates and returns an instance of dynamically compiled real function object. More... | |
LoadableRealFunctionBase | CreateRealFunction (double Kx, double Sx, double Ky, double Sy) |
Creates and returns an instance of dynamically compiled real function object. More... | |
Static Public Member Functions | |
static void | Example () |
Example of use of the RealFunctionLoader class. Creates a function loader and uses it for dynamic definition of functions. More... | |
static void | Example (string scriptPath) |
Example of use of the RealFunctionLoader class. Creates a function loader and uses it for dynamic definition of functions. More... | |
Public Attributes | |
const string | DefaultScriptClassName = "RealFunctionScript" |
Default name of the class used in loadable scripts containing user definitions of real function class. More... | |
const string | FuncNameInitDynamic = "InitDynamic" |
Name of the function that initializes variables realated to dynamically loaded real function class. More... | |
const string | VarNameReturnedValueName = "_returnedValueName" |
Name of variable (internal in class defined in loadable script) that holds the name of local variable (defined within functions in the dynamically loaded script) where returned value is stored. More... | |
const string | DefaultReturnedValueName = "ret" |
Default name of the variable that holds returned value in script functions. More... | |
const string | VarNameFunctionArgumentName = "_functionArgumentName" |
Name of variable (internal in class defined in loadable script) that holds the name of function argument (defined within functions in the dynamically loaded script) through which independent variable is passed. More... | |
const string | DefaultFunctionArgumentName = "arg" |
Default name of the function argument in script functions. More... | |
const string | VarNameIndependentVariableName = "_independentVariableName" |
Name of variable (internal in class defined in loadable script) that holds the name of local variable (defined within functions in the dynamically loaded script) that holds the independent variable in dunction definitions. More... | |
const string | DefaultIndependentVariableName = "x" |
Default name of the independent variable in expression definitions used in scripts to define calculation of function values, derivatives, etc. More... | |
const string | VarNameValueDefinitionString = "_valueDefinitionString" |
Name of the variable (internal in class defined in loadable script) that holds user definition (as string) of function value. More... | |
const string | VarNameDerivativeDefinitionString = "_derivativeDefinitionString" |
Name of the variable (internal in class defined in loadable script) that holds user definition (as string) of function derivative. More... | |
const string | VarNameSecondDerivativeDefinitionString = "_secondDerivativeDefinitionString" |
Name of the variable (internal in class defined in loadable script) that holds user definition (as string) of function second derivative. More... | |
const string | VarNameIntegralDefinitionString = "_integralDefinitionString" |
Name of the variable (internal in class defined in loadable script) that holds user definition (as string) of function integral. More... | |
const string | VarNameInverseDefinitionString = "_inverseDefinitionString" |
Name of the variable (internal in class defined in loadable script) that holds user definition (as string) of function inverse. More... | |
const string | FuncNameValueDefinition = "RefValue" |
Name of the function (internal in class defined in loadable script) that defines calculation of function value. More... | |
const string | FuncNameDerivativeDefinition = "RefDerivative" |
Name of the function (internal in class defined in loadable script) that defines calculation of function derivative. More... | |
const string | FuncNameSecondDerivativeDefinition = "RefSecondDerivative" |
Name of the function (internal in class defined in loadable script) that defines calculation of function second derivative. More... | |
const string | FuncNameIntegralDefinition = "RefIntegral" |
Name of the function (internal in class defined in loadable script) that defines calculation of function integral. More... | |
const string | FuncNameInverseDefinition = "RefInverse" |
Name of the function (internal in class defined in loadable script) that defines calculation of function inverse. More... | |
const string | VarNameValueDefined = "_valueDefined" |
Name of the variable (internal in class defined in loadable script) that holds a flag telling whether calculation of function value is implemented. More... | |
const string | VarNameDerivativeDefined = "_derivativeDefined" |
Name of the variable (internal in class defined in loadable script) that holds a flag telling whether calculation of function derivative is implemented. More... | |
const string | VarNameSecondDerivativeDefined = "_secondDerivativeDefined" |
Name of the variable (internal in class defined in loadable script) that holds a flag telling whether calculation of function second derivative is implemented. More... | |
const string | VarNameIntegralDefined = "_integralDefined" |
Name of the variable (internal in class defined in loadable script) that holds a flag telling whether calculation of function integral is implemented. More... | |
const string | VarNameInverseDefined = "_inverseDefined" |
Name of the variable (internal in class defined in loadable script) that holds a flag telling whether calculation of function inverse is implemented. More... | |
Protected Member Functions | |
virtual string | GetCode () |
Generates and returns script code for dynamically loadable function definition. More... | |
Properties | |
object | Lock [get] |
This object's central lock object to be used by other object. Do not use this object for locking in class' methods, for this you should use InternalLock. More... | |
bool | ValueDefined [get] |
Whether calculation of function value is implemented. More... | |
bool | DerivativeDefined [get] |
Whether calculation of function derivative is implemented. More... | |
bool | SecondDerivativeDefined [get] |
Whether calculation of function second derivative is implemented. More... | |
bool | IntegralDefined [get] |
Whether calculation of function indefinite integral is implemented. More... | |
bool | InverseDefined [get] |
Whether calculation of inverse function is implemented. More... | |
string | ReturnedValueName [get, set] |
Name of variable (within functions in the loadable scripts) that holds the returned value. Set to constant DefaultReturnedValueName by default. More... | |
string | FunctionArgumentName [get, set] |
Name of function arguments (in functions in the loadable scripts) that holds the independent variable. Set to constant DefaultFunctionArgumentName by default. More... | |
string | IndependentVariableName [get, set] |
Name of variable (within functions in the loadable scripts) that holds the independent variable. Set to constant DefaultIndependentVariableName by default. More... | |
string | ValueDefinitionString [get, set] |
Expression that defines function value. More... | |
string | DerivativeDefinitionString [get, set] |
Expression that defines function derivative. More... | |
string | SecondDerivativeDefinitionString [get, set] |
Expression that defines function second derivative. More... | |
string | IntegralDefinitionString [get, set] |
Expression that defines function indefinite integral derivative. More... | |
string | InverseDefinitionString [get, set] |
Expression that defines function inverse. More... | |
string | Code [get, protected set] |
Generated script code. More... | |
ScriptLoaderBase | Loader [get, protected set] |
Script loader used to load and instantiate real function class generated from script. More... | |
bool | IsCompiled [get, protected set] |
Whether the current function definition has been compiled or not. More... | |
string | ScriptClassName [get, protected set] |
Name of the script class that containe definition of the compiled real function class. More... | |
LoadableScriptRealFunctionBase | Creator [get] |
Returns an object of the dynamically compiled class that can create function objects. More... | |
Properties inherited from IG.Lib.ILockable | |
object | Lock [get] |
Private Member Functions | |
void | AppendIndents (StringBuilder sb, int numIndent) |
Appends to the apecified string builder the specified level of indentation. More... | |
void | AppendSetVariable (StringBuilder sb, string varName, object value, int numIndents) |
Appends to the apecified string builder the C# statements that sets the specified variable to the specified value. More... | |
void | AppendFunctonDefinition (StringBuilder sb, string functionName, string definitionString, int numIndents) |
Appends to the apecified string builder the C# definition of a double function returning double. Function is of form 'protected override double (double arg)'. More... | |
Private Attributes | |
object | _mainLock = new object() |
string | _returnedValueName = DefaultReturnedValueName |
string | _functionArgumentName = DefaultFunctionArgumentName |
string | _independentVariableName = DefaultIndependentVariableName |
string | _valueDefinitionString |
string | _derivativeDefinitionString |
string | _secondDerivativeDefinitionString |
string | _integralDefinitionString |
string | _inverseDefinitionString |
string | _code |
ScriptLoaderBase | _loader |
bool | _iscompiled = false |
string | _scriptClassName |
Dynamically generates IRealFunction classes from user definitions. User can define in string form how function, its derivative, second derivative, integral, or inverse function is calculated. Then this class can be used to compile these definitions in the wrapping script, which is then used to create the corresponding function objects.
$A Igor Jun10;
|
inline |
Constructor.
|
inline |
Clears strings that define the function (i.e. strings that define expressions for function value, derivative, integral, inverse, etc.).
Referenced by IG.Lib.RealFunctionLoader.Example().
|
inline |
Sets names used in generated script code.
returnedValueName | Name of the variabble that holds returned value in functions in generated script code. |
functionArgumentName | Name of function argument in generated script code. |
independentVariableName | Name of independent variable in generated script code. |
|
inline |
Saves the generated script code to the specified file. File is overwritten if it already exists.
filePath | Path to the file where script code is saved. |
|
inlineprivate |
Appends to the apecified string builder the specified level of indentation.
sb | String builder to which indents are appended. |
numIndent | Number of indents that are appended. |
|
inlineprivate |
Appends to the apecified string builder the C# statements that sets the specified variable to the specified value.
sb | String builder to which the statement is appended. |
varName | Name of the variable that is set. |
value | Value that is assigned to the variable. |
numIndents | Number of indents that are written before code lines. |
|
inlineprivate |
Appends to the apecified string builder the C# definition of a double function returning double. Function is of form 'protected override double (double arg)'.
sb | String builder to which the code (function definition) is appended. |
functionName | Name of the function. |
definitionString | Expression that specifies how the returned value is calculated. |
numIndents | Number of indents that are prepended before code lines. |
|
inlineprotectedvirtual |
Generates and returns script code for dynamically loadable function definition.
|
inline |
Compiles the code that contains dynamically loadable definition of a real function of one variable.
|
inline |
Creates and returns an instance of dynamically compiled real function object.
Referenced by IG.Lib.RealFunctionLoader.Example().
|
inline |
Creates and returns an instance of dynamically compiled real function object.
$A Igor Sep11;
|
inline |
Creates and returns an instance of dynamically compiled real function object.
$A Igor Sep11;
|
inlinestatic |
Example of use of the RealFunctionLoader class. Creates a function loader and uses it for dynamic definition of functions.
$A Igor Jun10;
|
inlinestatic |
Example of use of the RealFunctionLoader class. Creates a function loader and uses it for dynamic definition of functions.
scriptPath | Path where script that defines the function is saved. If null or empty string then script is not saved to a file. |
$A Igor Jun10;
References IG.Lib.RealFunctionLoader.Code, IG.Lib.RealFunctionLoader.CreateRealFunction(), IG.Num.IRealFunction.Derivative(), IG.Num.IRealFunction.DerivativeDefined, IG.Lib.RealFunctionLoader.DerivativeDefinitionString, IG.Lib.RealFunctionLoader.IndependentVariableName, IG.Lib.RealFunctionLoader.InvalidateDefinitions(), IG.Lib.UtilConsole.Read(), IG.Lib.StopWatch1.Start(), IG.Lib.StopWatch1.Stop(), IG.Lib.StopWatch1.Time, IG.Num.IRealFunction.Value(), IG.Num.IRealFunction.ValueDefined, and IG.Lib.RealFunctionLoader.ValueDefinitionString.
|
private |
const string IG.Lib.RealFunctionLoader.DefaultScriptClassName = "RealFunctionScript" |
Default name of the class used in loadable scripts containing user definitions of real function class.
const string IG.Lib.RealFunctionLoader.FuncNameInitDynamic = "InitDynamic" |
Name of the function that initializes variables realated to dynamically loaded real function class.
const string IG.Lib.RealFunctionLoader.VarNameReturnedValueName = "_returnedValueName" |
Name of variable (internal in class defined in loadable script) that holds the name of local variable (defined within functions in the dynamically loaded script) where returned value is stored.
const string IG.Lib.RealFunctionLoader.DefaultReturnedValueName = "ret" |
Default name of the variable that holds returned value in script functions.
const string IG.Lib.RealFunctionLoader.VarNameFunctionArgumentName = "_functionArgumentName" |
Name of variable (internal in class defined in loadable script) that holds the name of function argument (defined within functions in the dynamically loaded script) through which independent variable is passed.
const string IG.Lib.RealFunctionLoader.DefaultFunctionArgumentName = "arg" |
Default name of the function argument in script functions.
const string IG.Lib.RealFunctionLoader.VarNameIndependentVariableName = "_independentVariableName" |
Name of variable (internal in class defined in loadable script) that holds the name of local variable (defined within functions in the dynamically loaded script) that holds the independent variable in dunction definitions.
const string IG.Lib.RealFunctionLoader.DefaultIndependentVariableName = "x" |
Default name of the independent variable in expression definitions used in scripts to define calculation of function values, derivatives, etc.
const string IG.Lib.RealFunctionLoader.VarNameValueDefinitionString = "_valueDefinitionString" |
Name of the variable (internal in class defined in loadable script) that holds user definition (as string) of function value.
const string IG.Lib.RealFunctionLoader.VarNameDerivativeDefinitionString = "_derivativeDefinitionString" |
Name of the variable (internal in class defined in loadable script) that holds user definition (as string) of function derivative.
const string IG.Lib.RealFunctionLoader.VarNameSecondDerivativeDefinitionString = "_secondDerivativeDefinitionString" |
Name of the variable (internal in class defined in loadable script) that holds user definition (as string) of function second derivative.
const string IG.Lib.RealFunctionLoader.VarNameIntegralDefinitionString = "_integralDefinitionString" |
Name of the variable (internal in class defined in loadable script) that holds user definition (as string) of function integral.
const string IG.Lib.RealFunctionLoader.VarNameInverseDefinitionString = "_inverseDefinitionString" |
Name of the variable (internal in class defined in loadable script) that holds user definition (as string) of function inverse.
const string IG.Lib.RealFunctionLoader.FuncNameValueDefinition = "RefValue" |
Name of the function (internal in class defined in loadable script) that defines calculation of function value.
const string IG.Lib.RealFunctionLoader.FuncNameDerivativeDefinition = "RefDerivative" |
Name of the function (internal in class defined in loadable script) that defines calculation of function derivative.
const string IG.Lib.RealFunctionLoader.FuncNameSecondDerivativeDefinition = "RefSecondDerivative" |
Name of the function (internal in class defined in loadable script) that defines calculation of function second derivative.
const string IG.Lib.RealFunctionLoader.FuncNameIntegralDefinition = "RefIntegral" |
Name of the function (internal in class defined in loadable script) that defines calculation of function integral.
const string IG.Lib.RealFunctionLoader.FuncNameInverseDefinition = "RefInverse" |
Name of the function (internal in class defined in loadable script) that defines calculation of function inverse.
const string IG.Lib.RealFunctionLoader.VarNameValueDefined = "_valueDefined" |
Name of the variable (internal in class defined in loadable script) that holds a flag telling whether calculation of function value is implemented.
const string IG.Lib.RealFunctionLoader.VarNameDerivativeDefined = "_derivativeDefined" |
Name of the variable (internal in class defined in loadable script) that holds a flag telling whether calculation of function derivative is implemented.
const string IG.Lib.RealFunctionLoader.VarNameSecondDerivativeDefined = "_secondDerivativeDefined" |
Name of the variable (internal in class defined in loadable script) that holds a flag telling whether calculation of function second derivative is implemented.
const string IG.Lib.RealFunctionLoader.VarNameIntegralDefined = "_integralDefined" |
Name of the variable (internal in class defined in loadable script) that holds a flag telling whether calculation of function integral is implemented.
const string IG.Lib.RealFunctionLoader.VarNameInverseDefined = "_inverseDefined" |
Name of the variable (internal in class defined in loadable script) that holds a flag telling whether calculation of function inverse is implemented.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
get |
This object's central lock object to be used by other object. Do not use this object for locking in class' methods, for this you should use InternalLock.
|
get |
Whether calculation of function value is implemented.
|
get |
Whether calculation of function derivative is implemented.
|
get |
Whether calculation of function second derivative is implemented.
|
get |
Whether calculation of function indefinite integral is implemented.
|
get |
Whether calculation of inverse function is implemented.
|
getset |
Name of variable (within functions in the loadable scripts) that holds the returned value. Set to constant DefaultReturnedValueName by default.
|
getset |
Name of function arguments (in functions in the loadable scripts) that holds the independent variable. Set to constant DefaultFunctionArgumentName by default.
|
getset |
Name of variable (within functions in the loadable scripts) that holds the independent variable. Set to constant DefaultIndependentVariableName by default.
Referenced by IG.Lib.RealFunctionLoader.Example().
|
getset |
Expression that defines function value.
Referenced by IG.Lib.RealFunctionLoader.Example().
|
getset |
Expression that defines function derivative.
Referenced by IG.Lib.RealFunctionLoader.Example().
|
getset |
Expression that defines function second derivative.
|
getset |
Expression that defines function indefinite integral derivative.
|
getset |
Expression that defines function inverse.
|
getprotected set |
Generated script code.
Referenced by IG.Lib.RealFunctionLoader.Example().
|
getprotected set |
Script loader used to load and instantiate real function class generated from script.
$A Igor Jun10 Aug10;
|
getprotected set |
Whether the current function definition has been compiled or not.
|
getprotected set |
Name of the script class that containe definition of the compiled real function class.
|
get |
Returns an object of the dynamically compiled class that can create function objects.