cisst-saw
Toggle main menu visibility
Loading...
Searching...
No Matches
tmp
cisst-saw
cisst
cisstNumerical
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
14
This software is provided "as is" under an open source license, with
15
no warranty. The complete license can be found in license.txt and
16
http://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
32
#include <
cisstVector/vctDynamicMatrix.h
>
33
34
#include <cnetlib.h>
35
102
class
nmrFnJacobianSolver
{
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
107
protected
:
108
CISSTNETLIB_INTEGER
N
;
109
CISSTNETLIB_INTEGER
Ldfjac
;
110
CISSTNETLIB_DOUBLE
Tolerance
;
111
CISSTNETLIB_INTEGER
Info
;
112
CISSTNETLIB_INTEGER
Lwork
;
113
vctDynamicVector<CISSTNETLIB_DOUBLE>
Work
;
114
115
public
:
120
nmrFnJacobianSolver
(
void
)
121
{
122
Allocate
(0);
123
}
124
125
134
nmrFnJacobianSolver
(CISSTNETLIB_INTEGER n)
135
{
136
Allocate
(n);
137
}
138
139
146
nmrFnJacobianSolver
(
vctDynamicVector<CISSTNETLIB_DOUBLE>
&
X
) {
147
Allocate
(
X
);
148
}
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
172
inline
void
Allocate
(
vctDynamicVector<CISSTNETLIB_DOUBLE>
&
X
) {
173
Allocate
(
X
.size());
174
}
175
176
177
184
186
template
<
int
__instanceLineF,
class
__elementTypeF,
int
__instanceLineJ,
class
__elementTypeJ>
187
inline
void
Solve
(
nmrCallBackFunctionF<__instanceLineF, __elementTypeF>
&callBackF,
188
nmrCallBackFunctionJ<__instanceLineJ, __elementTypeJ>
&callBackJ,
189
vctDynamicVector<CISSTNETLIB_DOUBLE>
&
X
,
vctDynamicVector<CISSTNETLIB_DOUBLE>
&F,
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
nmrCallBackFunctionF
Definition
nmrCallBack.h:45
nmrCallBackFunctionJ
Definition
nmrCallBack.h:106
nmrFnJacobianSolver::Ldfjac
CISSTNETLIB_INTEGER Ldfjac
Definition
nmrFnJacobianSolver.h:109
nmrFnJacobianSolver::Solve
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::nmrFnJacobianSolver
nmrFnJacobianSolver(CISSTNETLIB_INTEGER n)
Definition
nmrFnJacobianSolver.h:134
nmrFnJacobianSolver::Allocate
void Allocate(CISSTNETLIB_INTEGER n)
Definition
nmrFnJacobianSolver.h:158
nmrFnJacobianSolver::Lwork
CISSTNETLIB_INTEGER Lwork
Definition
nmrFnJacobianSolver.h:112
nmrFnJacobianSolver::nmrFnJacobianSolver
nmrFnJacobianSolver(void)
Definition
nmrFnJacobianSolver.h:120
nmrFnJacobianSolver::nmrFnJacobianSolver
nmrFnJacobianSolver(vctDynamicVector< CISSTNETLIB_DOUBLE > &X)
Definition
nmrFnJacobianSolver.h:146
nmrFnJacobianSolver::N
CISSTNETLIB_INTEGER N
Definition
nmrFnJacobianSolver.h:108
nmrFnJacobianSolver::Tolerance
CISSTNETLIB_DOUBLE Tolerance
Definition
nmrFnJacobianSolver.h:110
nmrFnJacobianSolver::Allocate
void Allocate(vctDynamicVector< CISSTNETLIB_DOUBLE > &X)
Definition
nmrFnJacobianSolver.h:172
nmrFnJacobianSolver::Work
vctDynamicVector< CISSTNETLIB_DOUBLE > Work
Definition
nmrFnJacobianSolver.h:113
nmrFnJacobianSolver::Info
CISSTNETLIB_INTEGER Info
Definition
nmrFnJacobianSolver.h:111
vctDynamicVector
Definition
vctForwardDeclarations.h:131
cmnThrow
void cmnThrow(const _exceptionType &except, cmnLogLevel lod=CMN_LOG_LEVEL_INIT_ERROR)
Definition
cmnThrow.h:76
X
const value_type & X(void) const
Definition
vctDynamicConstVectorBase.h:263
vctDynamicMatrix.h
Declaration of vctDynamicMatrix.
Generated by
1.18.0