Changeset 483 for trunk/src/SDFitter.cc
- Timestamp:
- 02/21/05 08:21:00 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/SDFitter.cc
r125 r483 60 60 for (uInt i=0;i< funcs_.nelements();++i) { 61 61 delete funcs_[i]; funcs_[i] = 0; 62 } ;62 } 63 63 funcs_.resize(0, True); 64 64 parameters_.resize(); … … 146 146 funcs_[0] = new Polynomial<Float>(ncomp); 147 147 } else { 148 cerr << " compiled functions not yet implemented" << endl;148 //cerr << " compiled functions not yet implemented" << endl; 149 149 //funcs_.resize(1); 150 150 //funcs_[0] = new CompiledFunction<Float>(); … … 285 285 //computeEstimates(); 286 286 for (uInt i=0; i<funcs_.nelements(); i++) { 287 Gaussian1D<AutoDiff<Float> > gauss; 288 for (uInt j=0; j<funcs_[i]->nparameters(); j++) { 289 gauss[j] = AutoDiff<Float>((*funcs_[i])[j], gauss.nparameters(), j); 290 gauss.mask(j) = funcs_[i]->mask(j); 287 Gaussian1D<AutoDiff<Float> > gauss;//(*funcs_[i]); 288 289 for (uInt j=0; j<funcs_[i]->nparameters(); j++) { 290 gauss[j] = AutoDiff<Float>((*funcs_[i])[j], 291 gauss.nparameters(), j); 292 gauss.mask(j) = funcs_[i]->mask(j); 291 293 } 294 292 295 func.addFunction(gauss); 293 296 } 294 297 } else if (dynamic_cast<Polynomial<Float>* >(funcs_[0]) != 0) { 295 Polynomial<AutoDiff<Float> > poly(funcs_[0]->nparameters()-1); 296 for (uInt j=0; j<funcs_[0]->nparameters(); j++) { 297 poly[j] = AutoDiff<Float>(0, poly.nparameters(), j); 298 poly.mask(j) = funcs_[0]->mask(j); 299 } 300 func.addFunction(poly); 298 Polynomial<AutoDiff<Float> > poly(funcs_[0]->nparameters()-1); 299 //Polynomial<AutoDiff<Float> > poly(*funcs_[0]); 300 for (uInt j=0; j<funcs_[0]->nparameters(); j++) { 301 poly[j] = AutoDiff<Float>(0, poly.nparameters(), j); 302 poly.mask(j) = funcs_[0]->mask(j); 303 } 304 func.addFunction(poly); 301 305 } else if (dynamic_cast<CompiledFunction<Float>* >(funcs_[0]) != 0) { 302 303 // CompiledFunction<AutoDiff<Float> > comp;304 // for (uInt j=0; j<funcs_[0]->nparameters(); j++) {306 307 // CompiledFunction<AutoDiff<Float> > comp; 308 // for (uInt j=0; j<funcs_[0]->nparameters(); j++) { 305 309 // comp[j] = AutoDiff<Float>(0, comp.nparameters(), j); 306 310 // comp.mask(j) = funcs_[0]->mask(j); 307 311 // } 308 312 // func.addFunction(comp); 309 313 310 314 cout << "NYI." << endl; 311 315 } else { 312 throw 316 throw(AipsError("Fitter not set up correctly.")); 313 317 } 314 318 fitter.setFunction(func); … … 316 320 // Convergence criterium 317 321 fitter.setCriteria(0.001); 322 318 323 // Fit 319 324 Vector<Float> sigma(x_.nelements()); 320 325 sigma = 1.0; 321 //Vector<Float> sol; 326 322 327 parameters_.resize(); 323 //Vector<Float> err; 328 parameters_ = fitter.fit(x_, y_, sigma, &m_); 329 324 330 error_.resize(); 325 parameters_ = fitter.fit(x_, y_, sigma, &m_);326 /*327 CompoundFunction<Float> f;328 for (uInt i=0; i<funcs_.nelements(); i++) {329 f.addFunction(*funcs_[i]);330 }331 f.parameters().setParameters(parameters_);332 */333 331 error_ = fitter.errors(); 332 334 333 chisquared_ = fitter.getChi2(); 334 335 335 residual_.resize(); 336 336 residual_ = y_; 337 337 fitter.residual(residual_,x_); 338 338 339 // use fitter.residual(model=True) to get the model 339 340 thefit_.resize(x_.nelements());
Note: See TracChangeset
for help on using the changeset viewer.