org.bytedeco.javacpp

• All Implemented Interfaces:
AutoCloseable
Enclosing class:
opencv_core

```@Namespace(value="cv")
extends opencv_core.MinProblemSolver```
\brief This class is used to perform the non-linear non-constrained minimization of a function with known gradient,

defined on an *n*-dimensional Euclidean space, using the **Nonlinear Conjugate Gradient method**. The implementation was done based on the beautifully clear explanatory article [An Introduction to the Conjugate Gradient Method Without the Agonizing Pain](http://www.cs.cmu.edu/~quake-papers/painless-conjugate-gradient.pdf) by Jonathan Richard Shewchuk. The method can be seen as an adaptation of a standard Conjugate Gradient method (see, for example ) for numerically solving the systems of linear equations.

It should be noted, that this method, although deterministic, is rather a heuristic method and therefore may converge to a local minima, not necessary a global one. What is even more disastrous, most of its behaviour is ruled by gradient, therefore it essentially cannot distinguish between local minima and maxima. Therefore, if it starts sufficiently near to the local maximum, it may converge to it. Another obvious restriction is that it should be possible to compute the gradient of a function at any point, thus it is preferable to have analytic expression for gradient and computational burden should be born by the user.

The latter responsibility is accompilished via the getGradient method of a MinProblemSolver::Function interface (which represents function being optimized). This method takes point a point in *n*-dimensional space (first argument represents the array of coordinates of that point) and comput its gradient (it should be stored in the second argument as an array).

\note class ConjGradSolver thus does not add any new methods to the basic MinProblemSolver interface.

\note term criteria should meet following condition:

``````
termcrit.type == (TermCriteria::MAX_ITER + TermCriteria::EPS) && termcrit.epsilon > 0 && termcrit.maxCount > 0
// or
termcrit.type == TermCriteria::MAX_ITER) && termcrit.maxCount > 0
``````

• ### Nested classes/interfaces inherited from class org.bytedeco.javacpp.opencv_core.MinProblemSolver

`opencv_core.MinProblemSolver.Function`
• ### Nested classes/interfaces inherited from class org.bytedeco.javacpp.Pointer

`Pointer.CustomDeallocator, Pointer.Deallocator, Pointer.NativeDeallocator`

• ### Fields inherited from class org.bytedeco.javacpp.Pointer

`address, capacity, limit, position`
• ### Constructor Summary

Constructors
Constructor and Description
`ConjGradSolver(Pointer p)`
Pointer cast constructor.
• ### Method Summary

All Methods
Modifier and Type Method and Description
`static opencv_core.ConjGradSolver` `create()`
`static opencv_core.ConjGradSolver` ```create(opencv_core.MinProblemSolver.Function f, opencv_core.TermCriteria termcrit)```
• ### Methods inherited from class org.bytedeco.javacpp.opencv_core.MinProblemSolver

`getFunction, getTermCriteria, minimize, minimize, minimize, setFunction, setTermCriteria`
• ### Methods inherited from class org.bytedeco.javacpp.opencv_core.Algorithm

`clear, empty, getDefaultName, position, read, save, save, write, write, write`
• ### Methods inherited from class org.bytedeco.javacpp.Pointer

`address, asBuffer, asByteBuffer, availablePhysicalBytes, calloc, capacity, capacity, close, deallocate, deallocate, deallocateReferences, deallocator, deallocator, equals, fill, formatBytes, free, hashCode, isNull, limit, limit, malloc, maxBytes, maxPhysicalBytes, memchr, memcmp, memcpy, memmove, memset, offsetof, parseBytes, physicalBytes, position, put, realloc, setNull, sizeof, toString, totalBytes, totalPhysicalBytes, withDeallocator, zero`
• ### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

• ### Method Detail

• #### create

```@opencv_core.Ptr
opencv_core.MinProblemSolver.Function f,
@ByVal(nullValue="cv::TermCriteria(cv::TermCriteria::MAX_ITER+cv::TermCriteria::EPS,5000,0.000001)")
opencv_core.TermCriteria termcrit)```
`f` - Pointer to the function that will be minimized, similarly to the one you submit via MinProblemSolver::setFunction.
`termcrit` - Terminal criteria to the algorithm, similarly to the one you submit via MinProblemSolver::setTermCriteria.
```@opencv_core.Ptr