Changeset 2666 for trunk/src/STFitter.cpp
- Timestamp:
- 10/15/12 15:52:38 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/STFitter.cpp
r2580 r2666 80 80 y_.resize(); 81 81 m_.resize(); 82 constraints_.clear(); 82 83 } 83 84 … … 294 295 } 295 296 297 void Fitter::addConstraint(const std::vector<float>& constraint) 298 { 299 if (funcs_.nelements() == 0) 300 throw (AipsError("Function not yet set.")); 301 constraints_.push_back(constraint); 302 303 } 304 305 void Fitter::applyConstraints(GenericL2Fit<Float>& fitter) 306 { 307 std::vector<std::vector<float> >::const_iterator it; 308 for (it = constraints_.begin(); it != constraints_.end(); ++it) { 309 Vector<Float> tmp(*it); 310 fitter.addConstraint(tmp(Slice(0,tmp.nelements()-1)), 311 tmp(tmp.nelements()-1)); 312 } 313 } 314 296 315 bool Fitter::setFixedParameters(std::vector<bool> fixed) 297 316 { … … 377 396 // Convergence criterium 378 397 fitter.setCriteria(0.001); 398 applyConstraints(fitter); 379 399 380 400 // Fit … … 397 417 chisquared_ = fitter.getChi2(); 398 418 399 // residual_.resize();400 // residual_ = y_;401 // fitter.residual(residual_,x_);402 419 // use fitter.residual(model=True) to get the model 403 420 thefit_.resize(x_.nelements()); 404 421 fitter.residual(thefit_,x_,True); 405 // residual = data - model406 422 residual_.resize(x_.nelements()); 407 423 residual_ = y_ - thefit_ ; … … 419 435 420 436 fitter.setFunction(func); 421 //fitter.setMaxIter(50+n*10); 422 // Convergence criterium 423 //fitter.setCriteria(0.001); 424 425 // Fit 426 // Vector<Float> sigma(x_.nelements()); 427 // sigma = 1.0; 437 applyConstraints(fitter); 428 438 429 439 parameters_.resize(); 430 // parameters_ = fitter.fit(x_, y_, sigma, &m_);431 440 parameters_ = fitter.fit(x_, y_, &m_); 432 441 std::vector<float> ps; … … 439 448 chisquared_ = fitter.getChi2(); 440 449 441 // residual_.resize();442 // residual_ = y_;443 // fitter.residual(residual_,x_);444 // use fitter.residual(model=True) to get the model445 450 thefit_.resize(x_.nelements()); 446 451 fitter.residual(thefit_,x_,True); 447 // residual = data - model448 452 residual_.resize(x_.nelements()); 449 453 residual_ = y_ - thefit_ ;
Note: See TracChangeset
for help on using the changeset viewer.