cisst-saw
Loading...
Searching...
No Matches
nmrFnJacobianSolver.h
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */
3
4/*
5
6 Author(s): Ankur Kapoor
7 Created on: 2004-10-26
8
9 (C) Copyright 2004-2007 Johns Hopkins University (JHU), All Rights
10 Reserved.
11
12--- begin cisst license - do not edit ---
13
14This software is provided "as is" under an open source license, with
15no warranty. The complete license can be found in license.txt and
16http://www.cisst.org/cisst/license.txt.
17
18--- end cisst license ---
19*/
20
21
26
27
28#ifndef _nmrFnJacobianSolver_h
29#define _nmrFnJacobianSolver_h
30
31
33
34#include <cnetlib.h>
35
103 // we have this class so that we reserve memory only one
104 // would help if svd of a same size matrix (or a matrix)
105 // that doesnt change much is desired.
106
107protected:
108 CISSTNETLIB_INTEGER N;
109 CISSTNETLIB_INTEGER Ldfjac;
110 CISSTNETLIB_DOUBLE Tolerance;
111 CISSTNETLIB_INTEGER Info;
112 CISSTNETLIB_INTEGER Lwork;
114
115public:
121 {
122 Allocate(0);
123 }
124
125
134 nmrFnJacobianSolver(CISSTNETLIB_INTEGER n)
135 {
136 Allocate(n);
137 }
138
139
149
150
151
158 inline void Allocate(CISSTNETLIB_INTEGER n) {
159 N = n;
160 Lwork = N*(N+13)/2;
161 Ldfjac = N;
162 Tolerance = 1e-6;
163 Work.SetSize(Lwork);
164 }
165
166
173 Allocate(X.size());
174 }
175
176
177
184
186 template <int __instanceLineF, class __elementTypeF, int __instanceLineJ, class __elementTypeJ>
190 vctDynamicVector<CISSTNETLIB_DOUBLE> &J, CISSTNETLIB_DOUBLE tolerance) throw (std::runtime_error) {
191 if ((N != static_cast<CISSTNETLIB_INTEGER>(X.size())) || (N != static_cast<CISSTNETLIB_INTEGER>(F.size())) || (Ldfjac*N != static_cast<CISSTNETLIB_INTEGER>(J.size()))) {
192 cmnThrow(std::runtime_error("nmrFnJacobianSolver Solve: Size used for Allocate was different"));
193 }
194 Tolerance = tolerance;
195 /* call the MINPACK C function */
196 hybrj2_(callBackF.FunctionFhybrd, callBackJ.FunctionFhybrj2, &N,
197 X.Pointer(), F.Pointer(), J.Pointer(),
198 &Ldfjac, &Tolerance, &Info,
199 Work.Pointer(), &Lwork);
200 }
201
202
203};
204
205#endif // _nmrFnJacobianSolver_h
206
Definition nmrCallBack.h:45
Definition nmrCallBack.h:106
CISSTNETLIB_INTEGER Ldfjac
Definition nmrFnJacobianSolver.h:109
void Solve(nmrCallBackFunctionF< __instanceLineF, __elementTypeF > &callBackF, nmrCallBackFunctionJ< __instanceLineJ, __elementTypeJ > &callBackJ, vctDynamicVector< CISSTNETLIB_DOUBLE > &X, vctDynamicVector< CISSTNETLIB_DOUBLE > &F, vctDynamicVector< CISSTNETLIB_DOUBLE > &J, CISSTNETLIB_DOUBLE tolerance)
Definition nmrFnJacobianSolver.h:187
nmrFnJacobianSolver(CISSTNETLIB_INTEGER n)
Definition nmrFnJacobianSolver.h:134
void Allocate(CISSTNETLIB_INTEGER n)
Definition nmrFnJacobianSolver.h:158
CISSTNETLIB_INTEGER Lwork
Definition nmrFnJacobianSolver.h:112
nmrFnJacobianSolver(void)
Definition nmrFnJacobianSolver.h:120
nmrFnJacobianSolver(vctDynamicVector< CISSTNETLIB_DOUBLE > &X)
Definition nmrFnJacobianSolver.h:146
CISSTNETLIB_INTEGER N
Definition nmrFnJacobianSolver.h:108
CISSTNETLIB_DOUBLE Tolerance
Definition nmrFnJacobianSolver.h:110
void Allocate(vctDynamicVector< CISSTNETLIB_DOUBLE > &X)
Definition nmrFnJacobianSolver.h:172
vctDynamicVector< CISSTNETLIB_DOUBLE > Work
Definition nmrFnJacobianSolver.h:113
CISSTNETLIB_INTEGER Info
Definition nmrFnJacobianSolver.h:111
Definition vctForwardDeclarations.h:131
void cmnThrow(const _exceptionType &except, cmnLogLevel lod=CMN_LOG_LEVEL_INIT_ERROR)
Definition cmnThrow.h:76
const value_type & X(void) const
Definition vctDynamicConstVectorBase.h:263
Declaration of vctDynamicMatrix.