luclaurent/gradFD: gradFD: a MATLAB/OCTAVE's class for computing gradients and hessians of a function using finite differences
Creators
Description
gradFD is a MATLAB/OCTAVE's class which can be used for computing the derivatives and hessians of a function using finite differences. Many schemes have been implemented.
Notice that the hessian computation remains incomplete and needs to be improved.
Features
gradFD is able to
- Compute derivatives with the following schemes
- forward and backward finite differences of order 1 to 5 (BDx and FDx with x={1,...,5})
- central finite differences of order 2 to 8 (CDx with x={2,4,6,8})
- Minimize the number of computations (especially the responses at the central points is done only one time)
- Use a specific stepsize in every direction
- Generate the set of sample points which can be used externally for computing responses. These responses can be loaded by the class in order to compute the gradients.
First start
Many example script have been proposed
Example_basic_gradFD.m
: basic example of a classical use of the classExample_external_gradFD.m
: example of use of the external featureExample_plot1D_gradFD.m
: plot derivatives compute on 1D function with the classExample_plot2D_gradFD.m
: plot derivatives compute on 2D function with the classExample_error_gradFD.m
: study of the error on derivatives vs the stepsize
The following picture is the result of the execution of the Example_plot2D_gradFD.m
script:
The following picture is the result of the execution of the Example_error_gradFD.m
script:
Use of the class
The class could be called using the following syntax gradFD(typeIn,XrefIn,stepsIn,funIn)
where
typeIn
is the chosen schemes (the full list of finite difference schemes is available via the execution ofgradFD
with no option or via the methoddisplaySchemes
).XrefIn
is the array of points on which the gradient must be calculated.stepsIn
is the list of stepsizes used in every direction and/or every point.funIn
is the handle function (defined using @()) [optional]
If all these arguments are given to the class the gradients are calculated directly and stored in the property GZeval
.
In the case of an external computation of the responses, the sample points can be exported usind the property XevalG
and the responses computed externally can be loaded using the method loadZextG
(see for instance the example Example_external_gradFD.m
)
Full Changelog: https://github.com/luclaurent/gradFD/compare/v2.2.1...v2.2.2
Files
luclaurent/gradFD-2.2.1.zip
Files
(3.0 MB)
Name | Size | Download all |
---|---|---|
md5:f47aaaeefcc2c8993944c0b789fdaea6
|
1.5 MB | Preview Download |
md5:1b6203d022c15c65b8599b9ae5d5ef4e
|
1.5 MB | Preview Download |
Additional details
Related works
- Is supplement to
- Software: https://github.com/luclaurent/gradFD/tree/v2.2.2 (URL)