#ifndef COMPONENT_MODEL_H_ #define COMPONENT_MODEL_H_ #define OPT_HEADER #include #include #include #include #include /* *Represents a distribution composed of more than one components */ namespace opt_utilities { template class component :public model,optvec,optvec,std::string> { private: std::vector,optvec,optvec,std::string>*> components; std::vector weight_num; private: component* do_clone()const { return new component(*this); } const char* do_get_type_name()const { return "Multi-distribution"; } public: component() { //this->push_param_info(param_info >("x0",0)); //this->push_param_info(param_info >("sigma",1)); } component(const component& rhs) { for(int i=0;idestroy(); } components.clear(); for(int i=0;idestroy(); } } public: void add_component(const model,optvec,optvec,std::string>& m,const T& w=0) { int morder=components.size(); components.push_back(m.clone()); std::ostringstream oss; oss<1) { param_info,std::string> p1(std::string("_w")+smorder,w); this->push_param_info(p1); //std::cout<get_num_params()<get_num_params()-1); } int np=m.get_num_params(); for(int i=0;i,std::string> p(m.get_param_info(i)); param_info,std::string> p1(p.get_name()+smorder,p.get_value()); this->push_param_info(p1); if(this->get_num_params()==1) { std::cout<<"origin:"<get_param_info(0).get_value()<get_num_params()< convert_unit_sph(const optvec& p) { int ndim=p.size()+1; optvec result(ndim); result[0]=1; for(int i=0;i do_eval(const optvec& x,const optvec& param) { T result(0); optvec weight_angle; for(int i=0;i weight(convert_unit_sph(weight_angle)); int pnum=0; //std::cout< p(components[i]->get_num_params()); for(int j=0;jeval(x,p)[0]*weight[i]); ++pnum; } optvec result1(1); result1[0]=result;; return result1; } private: std::string do_get_information()const { return ""; } }; } #endif //EOF