cisst-saw
Loading...
Searching...
No Matches
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
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 _nmrFnSolver_h
29#define _nmrFnSolver_h
30
32
33#include <cnetlib.h>
34
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
101protected:
102 CISSTNETLIB_INTEGER N;
103 CISSTNETLIB_DOUBLE Tolerance;
104 CISSTNETLIB_INTEGER Info;
105 CISSTNETLIB_INTEGER Lwork;
107
108public:
114 {
115 Allocate(0);
116 }
117
118
127 nmrFnSolver(CISSTNETLIB_INTEGER n)
128 {
129 Allocate(n);
130 }
131
132
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
165 Allocate(X.size());
166 }
167
168
169
176
178 template <int __instanceLine, class __elementType>
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
Definition nmrCallBack.h:45
CISSTNETLIB_INTEGER N
Definition nmrFnSolver.h:102
CISSTNETLIB_INTEGER Info
Definition nmrFnSolver.h:104
nmrFnSolver(vctDynamicVector< CISSTNETLIB_DOUBLE > &X)
Definition nmrFnSolver.h:139
CISSTNETLIB_INTEGER Lwork
Definition nmrFnSolver.h:105
void Allocate(CISSTNETLIB_INTEGER n)
Definition nmrFnSolver.h:151
void Solve(nmrCallBackFunctionF< __instanceLine, __elementType > &callBack, vctDynamicVector< CISSTNETLIB_DOUBLE > &X, vctDynamicVector< CISSTNETLIB_DOUBLE > &F, CISSTNETLIB_DOUBLE tolerance)
Definition nmrFnSolver.h:179
vctDynamicVector< CISSTNETLIB_DOUBLE > Work
Definition nmrFnSolver.h:106
nmrFnSolver(void)
Definition nmrFnSolver.h:113
CISSTNETLIB_DOUBLE Tolerance
Definition nmrFnSolver.h:103
nmrFnSolver(CISSTNETLIB_INTEGER n)
Definition nmrFnSolver.h:127
void Allocate(vctDynamicVector< CISSTNETLIB_DOUBLE > &X)
Definition nmrFnSolver.h:164
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.