Commit f99dcfa9 authored by Laurent Belcour's avatar Laurent Belcour

Changing param information

parent 41312683
......@@ -86,6 +86,17 @@ class params
*/
}
static std::string get_name(const params::input param)
{
std::map<params::input, const params::param_info>::const_iterator it = input_map.find(param);
if(it != input_map.end())
{
return it->second.name;
}
return std::string();
}
//! \brief parse a string to provide a parametrization type.
static params::output parse_output(const std::string& txt)
{
......@@ -172,6 +183,9 @@ class params
case params::RUSIN_TH_PH_TD:
half_to_cartesian(invec[0], invec[1], invec[2], 0.0, outvec);
break;
case params::RUSIN_TH_TD_PD:
half_to_cartesian(invec[0], 0.0, invec[1], invec[2], outvec);
break;
// 4D Parametrization
case params::RUSIN_TH_PH_TD_PD:
......@@ -229,6 +243,10 @@ class params
outvec[0] = half[2];
outvec[1] = half[0]*outvec[0] + half[1]*outvec[1] + half[2]*outvec[2];
break;
case params::RUSIN_TH_TD:
outvec[0] = acos(half[2]);
outvec[2] = acos(half[0]*outvec[0] + half[1]*outvec[1] + half[2]*outvec[2]);
break;
// 3D Parametrization
case params::RUSIN_TH_PH_TD:
......@@ -410,6 +428,7 @@ class params
}
}
protected:
struct param_info
......
......@@ -156,7 +156,17 @@ function* plugins_manager::get_function(const std::string& n)
}
#ifdef USING_STATIC
QString path = QDir::currentPath() + QString(n.c_str()) ;
std::string file;
if(n[0] == '.')
{
file = n.substr(1, n.size()-1);
}
else
{
file = n;
}
QString path = QDir::currentPath() + QString(file.c_str()) ;
QLibrary function_lib(path);
if(!function_lib.isLoaded())
{
......@@ -201,7 +211,17 @@ data* plugins_manager::get_data(const std::string& n)
}
#ifdef USING_STATIC
QString path = QDir::currentPath() + QString(n.c_str()) ;
std::string file;
if(n[0] == '.')
{
file = n.substr(1, n.size()-1);
}
else
{
file = n;
}
QString path = QDir::currentPath() + QString(file.c_str()) ;
QLibrary data_lib(path);
if(!data_lib.isLoaded())
{
......@@ -246,7 +266,17 @@ fitter* plugins_manager::get_fitter(const std::string& n)
}
#ifdef USING_STATIC
QString path = QDir::currentPath() + QString(n.c_str()) ;
std::string file;
if(n[0] == '.')
{
file = n.substr(1, n.size()-1);
}
else
{
file = n;
}
QString path = QDir::currentPath() + QString(file.c_str()) ;
QLibrary fitting_lib(path);
if(!fitting_lib.isLoaded())
{
......
......@@ -78,12 +78,12 @@ class plugins_manager
{
std::cout << "<<DEBUG>> no change was made to the parametrization" << std::endl;
}
/*
if(f->dimY() != d->dimY())
{
std::cout << "<<ERROR>> the data and the function have different Y dimensions" << std::endl;
}
*/
/*
// Check is the data has to be clusterized
if(args.is_defined("cluster-dim"))
......
......@@ -304,6 +304,12 @@ void rational_function::load(const std::string& filename)
linestream >> nq ;
b.resize(nq*nY);
}
else if(comment == std::string("INPUT_PARAM"))
{
std::string param;
linestream >> param ;
setParametrization(params::parse_input(param));
}
continue ;
}
else if(line.empty())
......@@ -570,7 +576,8 @@ void rational_function::save(const std::string& filename) const
file << "#DIM " << _nX << " " << _nY << std::endl ;
file << "#NP " << a.size() / _nY << std::endl ;
file << "#NQ " << b.size() / _nY << std::endl ;
file << "#BASIS LEGENDRE" << std::endl ;
file << "#BASIS LEGENDRE" << std::endl ;
file << "#INPUT_PARAM " << params::get_name(this->parametrization()) << std::endl;
unsigned int np = a.size() / _nY ;
unsigned int nq = b.size() / _nY ;
......
......@@ -34,7 +34,7 @@ class data_merl : public QObject, public data
virtual params::input parametrization() const
{
return params::RUSIN_TH_TD;
return params::RUSIN_TH_TD_PD;
}
// Get min and max input space values
......
......@@ -40,11 +40,12 @@ int main(int argc, char** argv)
std::cerr << "<<ERROR>> the data exporter is not defined" << std::endl ;
return 1 ;
}
/*
if(! args.is_defined("func")) {
std::cerr << "<<ERROR>> the function importer is not defined" << std::endl ;
return 1 ;
}
*/
// Import data
data* d = NULL ;
d = manager.get_data(args["data"]) ;
......@@ -55,15 +56,18 @@ int main(int argc, char** argv)
// Modify function or data to provide coherent
// interfaces
plugins_manager::check_compatibility(d, f, args);
// plugins_manager::check_compatibility(d, f, args);
if(d != NULL && f != NULL)
{
vec temp(f->dimX());
for(int i=0; i<d->size(); ++i)
{
// Copy the input vector
vec x = d->get(i);
vec y = f->value(x);
params::convert(&x[0], d->parametrization(), f->parametrization(), &temp[0]);
vec y = f->value(temp);
for(int j=0; j<d->dimY(); ++j)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment