NonCenteredFiniteDifferenceGradient¶
- class NonCenteredFiniteDifferenceGradient(*args)¶
First order non-centered finite-difference scheme.
- Available constructors:
NonCenteredFiniteDifferenceGradient(epsilon, evalImpl)
NonCenteredFiniteDifferenceGradient(step, evalImpl)
- Parameters
- evalImpl
EvaluationImplementation
Implementation of the evaluation of a function.
- epsilonfloat, sequence of float
Finite difference steps for each dimension.
- step
FiniteDifferenceStep
Defines how finite difference steps values are computed.
- evalImpl
Notes
NonCenteredFiniteDifferenceGradient provides a first order non-centered finite-difference scheme:
Examples
>>> import openturns as ot >>> formulas = ['x1 * sin(x2)', 'cos(x1 + x2)', '(x2 + 1) * exp(x1 - 2 * x2)'] >>> myFunc = ot.SymbolicFunction(['x1', 'x2'], formulas) >>> epsilon = [0.01]*2 >>> myGradient = ot.NonCenteredFiniteDifferenceGradient(epsilon, myFunc.getEvaluation()) >>> inPoint = [1.0]*2 >>> print(myGradient.gradient(inPoint)) [[ 0.841471 -0.907202 0.73945 ] [ 0.536086 -0.907202 -1.09631 ]]
Methods
Accessor to the number of times the gradient has been called.
Accessor to the object's name.
Get the finite difference steps.
Get the implementation of the evaluation of the function.
Get the finite difference step.
getId
()Accessor to the object's id.
Get the input dimension.
getMarginal
(*args)Accessor to the gradient implementation of a specific output.
getName
()Accessor to the object's name.
Get the output dimension.
Accessor to the parameter values.
Accessor to the object's shadowed id.
Accessor to the object's visibility state.
gradient
(inP)Get the gradient at some point.
hasName
()Test if the object is named.
Test if the object has a distinguishable name.
Accessor to the validity flag.
setFiniteDifferenceStep
(finiteDifferenceStep)Set the finite difference step.
setName
(name)Accessor to the object's name.
setParameter
(parameter)Accessor to the parameter values.
setShadowedId
(id)Accessor to the object's shadowed id.
setVisibility
(visible)Accessor to the object's visibility state.
- __init__(*args)¶
- getCallsNumber()¶
Accessor to the number of times the gradient has been called.
- Returns
- calls_numberint
Integer that counts the number of times the gradient has been called since its creation.
- getClassName()¶
Accessor to the object’s name.
- Returns
- class_namestr
The object class name (object.__class__.__name__).
- getEpsilon()¶
Get the finite difference steps.
- Returns
- epsilon
Point
Finite difference steps for each dimension.
- epsilon
- getEvaluation()¶
Get the implementation of the evaluation of the function.
- Returns
- evalImpl
EvaluationImplementation
Implementation of the evaluation of a function.
- evalImpl
- getFiniteDifferenceStep()¶
Get the finite difference step.
- Returns
- step
FiniteDifferenceStep
Defines how finite difference steps values are computed.
- step
- getId()¶
Accessor to the object’s id.
- Returns
- idint
Internal unique identifier.
- getInputDimension()¶
Get the input dimension.
- Returns
- dimensionint
Input dimension.
- getMarginal(*args)¶
Accessor to the gradient implementation of a specific output.
- Parameters
- iinteger
Integer corresponding to the output (Care: it starts at 0).
- indicessequence of integer
The set of indices for which the outputs are extracted.
- Returns
- gradientImplementation
GradientImplementation
A gradient implementation restricted to its compenents functions which indices are i or indices.
- gradientImplementation
- getName()¶
Accessor to the object’s name.
- Returns
- namestr
The name of the object.
- getOutputDimension()¶
Get the output dimension.
- Returns
- dimensionint
Output dimension.
- getShadowedId()¶
Accessor to the object’s shadowed id.
- Returns
- idint
Internal unique identifier.
- getVisibility()¶
Accessor to the object’s visibility state.
- Returns
- visiblebool
Visibility flag.
- gradient(inP)¶
Get the gradient at some point.
- Parameters
- pointsequence of float
Point where the gradient is computed.
- Returns
- gradient
Matrix
Transposed Jacobian matrix evaluated at point.
- gradient
- hasName()¶
Test if the object is named.
- Returns
- hasNamebool
True if the name is not empty.
- hasVisibleName()¶
Test if the object has a distinguishable name.
- Returns
- hasVisibleNamebool
True if the name is not empty and not the default one.
- isActualImplementation()¶
Accessor to the validity flag.
- Returns
- is_implbool
Whether the implementation is valid.
- setFiniteDifferenceStep(finiteDifferenceStep)¶
Set the finite difference step.
- Parameters
- step
FiniteDifferenceStep
Defines how finite difference steps values are computed.
- step
- setName(name)¶
Accessor to the object’s name.
- Parameters
- namestr
The name of the object.
- setParameter(parameter)¶
Accessor to the parameter values.
- Parameters
- parametersequence of float
The parameter values.
- setShadowedId(id)¶
Accessor to the object’s shadowed id.
- Parameters
- idint
Internal unique identifier.
- setVisibility(visible)¶
Accessor to the object’s visibility state.
- Parameters
- visiblebool
Visibility flag.