#ifndef LEAST_SQ_HPP #define LeAST_SQ_HPP #include #include #include #include using std::cerr;using std::endl; namespace opt_utilities { template class leastsq :public statistic { private: bool verb; int n; statistic* do_clone()const { // return const_cast*>(this); return new leastsq(*this); } public: void verbose(bool v) { verb=v; } public: leastsq() :verb(false) {} Ts do_eval(const Tp& p) { Ts result(0); for(int i=(this->get_data_set()).size()-1;i>=0;--i) { Ty chi=(this->get_data_set().get_data(i).get_y()-eval_model(this->get_data_set().get_data(i).get_x(),p)); result+=chi*chi; } if(verb) { n++; if(n%10==0) { cerr<