13 #include "msdevstudio/MSconfig.h"
27 #ifdef ITERATOR_MEMBER_DEFECT
36 using namespace hippodraw::Numeric;
38 using namespace hippodraw;
41 LMFitter (
const char * name )
43 m_chi_cutoff ( 0.000001 ),
44 m_start_lambda ( 0.001 ),
45 m_lambda_shrink_factor( 9.8 ),
46 m_lambda_expand_factor( 10.2 )
54 m_chi_cutoff ( fitter.m_chi_cutoff ),
55 m_start_lambda ( fitter.m_start_lambda ),
56 m_lambda_shrink_factor ( fitter.m_lambda_shrink_factor ),
57 m_lambda_expand_factor ( fitter.m_lambda_expand_factor )
74 unsigned int num_parms =
m_beta.size();
77 for ( ; j < num_parms; j++ ) {
78 for (
unsigned int k = 0; k < j; k++ ) {
84 for ( ; j < num_parms; j++ ) {
108 unsigned int num_parms =
m_beta.size ();
110 vector< int > ipiv ( num_parms, 0 );
112 vector< int > indxr ( num_parms, -1 );
113 vector< int > indxc ( num_parms, -1 );
115 unsigned int irow = UINT_MAX;
116 unsigned int icol = UINT_MAX;
118 for (
unsigned int i = 0; i < num_parms; i++ ) {
121 for (
unsigned int j = 0; j < num_parms; j++ ) {
122 if ( ipiv[j] != 1 ) {
124 for (
unsigned int k = 0; k < num_parms; k++ ) {
125 if ( ipiv[k] == 0 ) {
126 if ( abs (
m_alpha[j][k] ) >= big ) {
132 else if ( ipiv[k] > 1 ) {
139 if ( irow == UINT_MAX ) {
144 if ( irow != icol ) {
145 for (
unsigned int l = 0; l < num_parms; l++ ) {
152 if (
m_alpha[icol][icol] == 0.0 ) {
155 double pivinv = 1.0 /
m_alpha[icol][icol];
158 for (
unsigned int l = 0; l < num_parms; l++ ) {
163 for (
unsigned int ll = 0; ll < num_parms; ll++ ) {
165 double dum =
m_alpha[ll][icol];
168 for (
unsigned int l = 0; l < num_parms; l++ ) {
176 for (
int l = num_parms - 1; l >= 0; l-- ) {
177 if ( indxr[l] != indxc[l] ) {
179 for (
unsigned int k = 0; k < num_parms; k++ ) {
204 vector< double > old_parms;
208 assert ( old_parms.size() ==
m_beta.size() );
210 vector< double > new_parms ( old_parms );
211 vector< double >::iterator pit = new_parms.begin ( );
212 vector< double >::iterator dit =
m_beta.begin ( );
214 while ( pit != new_parms.end () ) {
217 m_fcn -> setFreeParameters ( new_parms );
221 if ( abs ( old_chisq - new_chisq ) <
m_chi_cutoff )
break;
223 if ( new_chisq < old_chisq ) {
228 m_fcn -> setFreeParameters ( old_parms );
231 if ( ! ok )
return ok;
243 fcn -> setNeedsDerivatives (
true );