Ignore:
Timestamp:
09/01/06 13:14:11 (18 years ago)
Author:
mar637
Message:

Merge from Release2.1.0b tag

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/STFitter.cpp

    r1067 r1232  
    6464  funcs_.resize(0,True);
    6565  parameters_.resize();
     66  fixedpar_.resize();
    6667  error_.resize();
    6768  thefit_.resize();
     
    205206    if (parameters_.nelements() > 0 && tmppar.nelements() != parameters_.nelements())
    206207        throw (AipsError("Number of parameters inconsistent with function."));
    207     if (parameters_.nelements() == 0)
     208    if (parameters_.nelements() == 0) {
    208209        parameters_.resize(tmppar.nelements());
    209         fixedpar_.resize(tmppar.nelements());
    210         fixedpar_ = False;
     210        if (tmppar.nelements() != fixedpar_.nelements()) {
     211            fixedpar_.resize(tmppar.nelements());
     212            fixedpar_ = False;
     213        }
     214    }
    211215    if (dynamic_cast<Gaussian1D<Float>* >(funcs_[0]) != 0) {
    212216        uInt count = 0;
     
    224228        }
    225229    }
     230    // reset
     231    if (params.size() == 0) {
     232        parameters_.resize();
     233        fixedpar_.resize();
     234    }
    226235    return true;
    227236}
     
    229238bool Fitter::setFixedParameters(std::vector<bool> fixed)
    230239{
    231     Vector<Bool> tmp(fixed);
    232240    if (funcs_.nelements() == 0)
    233241        throw (AipsError("Function not yet set."));
    234     if (fixedpar_.nelements() > 0 && tmp.nelements() != fixedpar_.nelements())
     242    if (fixedpar_.nelements() > 0 && fixed.size() != fixedpar_.nelements())
    235243        throw (AipsError("Number of mask elements inconsistent with function."));
     244    if (fixedpar_.nelements() == 0) {
     245        fixedpar_.resize(parameters_.nelements());
     246        fixedpar_ = False;
     247    }
    236248    if (dynamic_cast<Gaussian1D<Float>* >(funcs_[0]) != 0) {
    237249        uInt count = 0;
    238250        for (uInt j=0; j < funcs_.nelements(); ++j) {
    239251            for (uInt i=0; i < funcs_[j]->nparameters(); ++i) {
    240                 funcs_[j]->mask(i) = !tmp[count];
    241                 fixedpar_[count] = !tmp[count];
     252                funcs_[j]->mask(i) = !fixed[count];
     253                fixedpar_[count] = fixed[count];
    242254                ++count;
    243255            }
     
    245257    } else if (dynamic_cast<Polynomial<Float>* >(funcs_[0]) != 0) {
    246258        for (uInt i=0; i < funcs_[0]->nparameters(); ++i) {
    247             fixedpar_[i] = tmp[i];
    248             funcs_[0]->mask(i) =  tmp[i];
    249         }
    250     }
    251     //fixedpar_ = !tmpmsk;
     259            fixedpar_[i] = fixed[i];
     260            funcs_[0]->mask(i) =  !fixed[i];
     261        }
     262    }
    252263    return true;
    253264}
     
    263274  Vector<Bool> out(parameters_.nelements());
    264275  if (fixedpar_.nelements() == 0) {
    265     out = False;
     276    return std::vector<bool>();
    266277    //throw (AipsError("No parameter mask set."));
    267278  } else {
     
    312323  residual_ =  y_;
    313324  fitter.residual(residual_,x_);
    314 
    315325  // use fitter.residual(model=True) to get the model
    316326  thefit_.resize(x_.nelements());
Note: See TracChangeset for help on using the changeset viewer.