Changeset 483 for trunk/src/SDFitter.cc


Ignore:
Timestamp:
02/21/05 08:21:00 (19 years ago)
Author:
mar637
Message:
  • Added history support.
  • Added version keyword to SDMemTable.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/SDFitter.cc

    r125 r483  
    6060    for (uInt i=0;i< funcs_.nelements();++i) {
    6161        delete funcs_[i]; funcs_[i] = 0;
    62     };
     62    }
    6363    funcs_.resize(0, True);
    6464    parameters_.resize();
     
    146146        funcs_[0] = new Polynomial<Float>(ncomp);
    147147    } else {
    148         cerr << " compiled functions not yet implemented" << endl;
     148        //cerr << " compiled functions not yet implemented" << endl;
    149149        //funcs_.resize(1);
    150150        //funcs_[0] = new CompiledFunction<Float>();
     
    285285        //computeEstimates();
    286286        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);
    291293            }
     294           
    292295            func.addFunction(gauss);
    293296        }
    294297    } 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);
    301305    } 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++) {
    305309//             comp[j] = AutoDiff<Float>(0, comp.nparameters(), j);
    306310//             comp.mask(j) = funcs_[0]->mask(j);
    307311//         }
    308312//         func.addFunction(comp);
    309 
     313       
    310314        cout << "NYI." << endl;
    311315    } else {
    312         throw (AipsError("Fitter not set up correctly."));
     316        throw(AipsError("Fitter not set up correctly."));
    313317    }
    314318    fitter.setFunction(func);
     
    316320    // Convergence criterium
    317321    fitter.setCriteria(0.001);
     322
    318323    // Fit
    319324    Vector<Float> sigma(x_.nelements());
    320325    sigma = 1.0;
    321     //Vector<Float> sol;
     326
    322327    parameters_.resize();
    323     //Vector<Float> err;
     328    parameters_ = fitter.fit(x_, y_, sigma, &m_);
     329
    324330    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     */
    333331    error_ = fitter.errors();
     332
    334333    chisquared_ = fitter.getChi2();
     334
    335335    residual_.resize();
    336336    residual_ =  y_;
    337337    fitter.residual(residual_,x_);
     338
    338339    // use fitter.residual(model=True) to get the model
    339340    thefit_.resize(x_.nelements());
Note: See TracChangeset for help on using the changeset viewer.