Changeset 890 for trunk/src/SDFitter.cc
- Timestamp:
- 03/08/06 13:32:27 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/SDFitter.cc
r612 r890 1 1 //#--------------------------------------------------------------------------- 2 //# SDFitter.cc: A Fitter class for spectra2 //# Fitter.cc: A Fitter class for spectra 3 3 //#-------------------------------------------------------------------------- 4 4 //# Copyright (C) 2004 … … 27 27 //# AUSTRALIA 28 28 //# 29 //# $Id: 29 //# $Id:$ 30 30 //#--------------------------------------------------------------------------- 31 31 #include <casa/aips.h> … … 47 47 using namespace casa; 48 48 49 SDFitter::SDFitter()50 { 51 } 52 53 SDFitter::~SDFitter()49 Fitter::Fitter() 50 { 51 } 52 53 Fitter::~Fitter() 54 54 { 55 55 reset(); 56 56 } 57 57 58 void SDFitter::clear()58 void Fitter::clear() 59 59 { 60 60 for (uInt i=0;i< funcs_.nelements();++i) { … … 69 69 } 70 70 71 void SDFitter::reset()71 void Fitter::reset() 72 72 { 73 73 clear(); … … 78 78 79 79 80 bool SDFitter::computeEstimate() {80 bool Fitter::computeEstimate() { 81 81 if (x_.nelements() == 0 || y_.nelements() == 0) 82 82 throw (AipsError("No x/y data specified.")); … … 122 122 } 123 123 124 std::vector<float> SDFitter::getEstimate() const124 std::vector<float> Fitter::getEstimate() const 125 125 { 126 126 if (estimate_.nelements() == 0) … … 132 132 133 133 134 bool SDFitter::setExpression(const std::string& expr, int ncomp)134 bool Fitter::setExpression(const std::string& expr, int ncomp) 135 135 { 136 136 clear(); … … 154 154 } 155 155 156 bool SDFitter::setData(std::vector<float> absc, std::vector<float> spec,156 bool Fitter::setData(std::vector<float> absc, std::vector<float> spec, 157 157 std::vector<bool> mask) 158 158 { … … 171 171 } 172 172 173 std::vector<float> SDFitter::getResidual() const173 std::vector<float> Fitter::getResidual() const 174 174 { 175 175 if (residual_.nelements() == 0) … … 180 180 } 181 181 182 std::vector<float> SDFitter::getFit() const182 std::vector<float> Fitter::getFit() const 183 183 { 184 184 Vector<Float> out = thefit_; … … 189 189 } 190 190 191 std::vector<float> SDFitter::getErrors() const191 std::vector<float> Fitter::getErrors() const 192 192 { 193 193 Vector<Float> out = error_; … … 197 197 } 198 198 199 bool SDFitter::setParameters(std::vector<float> params)199 bool Fitter::setParameters(std::vector<float> params) 200 200 { 201 201 Vector<Float> tmppar(params); … … 226 226 } 227 227 228 bool SDFitter::setFixedParameters(std::vector<bool> fixed)228 bool Fitter::setFixedParameters(std::vector<bool> fixed) 229 229 { 230 230 Vector<Bool> tmp(fixed); … … 252 252 } 253 253 254 std::vector<float> SDFitter::getParameters() const {254 std::vector<float> Fitter::getParameters() const { 255 255 Vector<Float> out = parameters_; 256 256 std::vector<float> stlout; … … 259 259 } 260 260 261 std::vector<bool> SDFitter::getFixedParameters() const {261 std::vector<bool> Fitter::getFixedParameters() const { 262 262 Vector<Bool> out(parameters_.nelements()); 263 263 if (fixedpar_.nelements() == 0) { … … 272 272 } 273 273 274 float SDFitter::getChisquared() const {274 float Fitter::getChisquared() const { 275 275 return chisquared_; 276 276 } 277 277 278 bool SDFitter::fit() {278 bool Fitter::fit() { 279 279 NonLinearFitLM<Float> fitter; 280 280 CompoundFunction<Float> func; … … 293 293 Vector<Float> sigma(x_.nelements()); 294 294 sigma = 1.0; 295 295 296 296 parameters_.resize(); 297 297 parameters_ = fitter.fit(x_, y_, sigma, &m_); … … 304 304 305 305 chisquared_ = fitter.getChi2(); 306 306 307 307 residual_.resize(); 308 308 residual_ = y_; … … 316 316 317 317 318 std::vector<float> SDFitter::evaluate(int whichComp) const319 { 318 std::vector<float> Fitter::evaluate(int whichComp) const 319 { 320 320 std::vector<float> stlout; 321 uInt idx = uInt(whichComp); 321 uInt idx = uInt(whichComp); 322 322 Float y; 323 323 if ( idx < funcs_.nelements() ) {
Note: See TracChangeset
for help on using the changeset viewer.