cisst-saw
Toggle main menu visibility
Loading...
Searching...
No Matches
tmp
cisst-saw
cisst
cisstNumerical
nmrFnSolver.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 _nmrFnSolver_h
29
#define _nmrFnSolver_h
30
31
#include <
cisstVector/vctDynamicMatrix.h
>
32
33
#include <cnetlib.h>
34
96
class
nmrFnSolver
{
97
// we have this class so that we reserve memory only one
98
// would help if svd of a same size matrix (or a matrix)
99
// that doesnt change much is desired.
100
101
protected
:
102
CISSTNETLIB_INTEGER
N
;
103
CISSTNETLIB_DOUBLE
Tolerance
;
104
CISSTNETLIB_INTEGER
Info
;
105
CISSTNETLIB_INTEGER
Lwork
;
106
vctDynamicVector<CISSTNETLIB_DOUBLE>
Work
;
107
108
public
:
113
nmrFnSolver
(
void
)
114
{
115
Allocate
(0);
116
}
117
118
127
nmrFnSolver
(CISSTNETLIB_INTEGER n)
128
{
129
Allocate
(n);
130
}
131
132
139
nmrFnSolver
(
vctDynamicVector<CISSTNETLIB_DOUBLE>
&
X
) {
140
Allocate
(
X
);
141
}
142
143
144
151
inline
void
Allocate
(CISSTNETLIB_INTEGER n) {
152
N
= n;
153
Lwork
=
N
*(3*3*3*
N
+13)/2;
154
Tolerance
= 1e-6;
155
Work
.SetSize(
Lwork
);
156
}
157
158
164
inline
void
Allocate
(
vctDynamicVector<CISSTNETLIB_DOUBLE>
&
X
) {
165
Allocate
(
X
.size());
166
}
167
168
169
176
178
template
<
int
__instanceLine,
class
__elementType>
179
inline
void
Solve
(
nmrCallBackFunctionF<__instanceLine, __elementType>
&callBack,
vctDynamicVector<CISSTNETLIB_DOUBLE>
&
X
,
180
vctDynamicVector<CISSTNETLIB_DOUBLE>
&F, CISSTNETLIB_DOUBLE tolerance)
throw
(std::runtime_error) {
181
if
((
N
!=
static_cast<
CISSTNETLIB_INTEGER
>
(
X
.size())) || (
N
!=
static_cast<
CISSTNETLIB_INTEGER
>
(F.size()))) {
182
cmnThrow
(std::runtime_error(
"nmrFnSolver Solve: Size used for Allocate was different"
));
183
}
184
Tolerance
= tolerance;
185
/* call the MINPACK C function */
186
hybrd1_((U_fp)callBack.FunctionFhybrd, &
N
,
187
X
.Pointer(), F.Pointer(),
188
&
Tolerance
, &
Info
,
189
Work
.Pointer(), &
Lwork
);
190
}
191
192
193
};
194
195
#endif
// _nmrFnSolver_h
196
nmrCallBackFunctionF
Definition
nmrCallBack.h:45
nmrFnSolver::N
CISSTNETLIB_INTEGER N
Definition
nmrFnSolver.h:102
nmrFnSolver::Info
CISSTNETLIB_INTEGER Info
Definition
nmrFnSolver.h:104
nmrFnSolver::nmrFnSolver
nmrFnSolver(vctDynamicVector< CISSTNETLIB_DOUBLE > &X)
Definition
nmrFnSolver.h:139
nmrFnSolver::Lwork
CISSTNETLIB_INTEGER Lwork
Definition
nmrFnSolver.h:105
nmrFnSolver::Allocate
void Allocate(CISSTNETLIB_INTEGER n)
Definition
nmrFnSolver.h:151
nmrFnSolver::Solve
void Solve(nmrCallBackFunctionF< __instanceLine, __elementType > &callBack, vctDynamicVector< CISSTNETLIB_DOUBLE > &X, vctDynamicVector< CISSTNETLIB_DOUBLE > &F, CISSTNETLIB_DOUBLE tolerance)
Definition
nmrFnSolver.h:179
nmrFnSolver::Work
vctDynamicVector< CISSTNETLIB_DOUBLE > Work
Definition
nmrFnSolver.h:106
nmrFnSolver::nmrFnSolver
nmrFnSolver(void)
Definition
nmrFnSolver.h:113
nmrFnSolver::Tolerance
CISSTNETLIB_DOUBLE Tolerance
Definition
nmrFnSolver.h:103
nmrFnSolver::nmrFnSolver
nmrFnSolver(CISSTNETLIB_INTEGER n)
Definition
nmrFnSolver.h:127
nmrFnSolver::Allocate
void Allocate(vctDynamicVector< CISSTNETLIB_DOUBLE > &X)
Definition
nmrFnSolver.h:164
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