Commit 5c944269 authored by Laurent Belcour's avatar Laurent Belcour

Adding correct parsing of the input param

parent ca5ea84a
......@@ -14,7 +14,7 @@
*/
class data
{
public: // methods
public: // methods
// Load data from a file
virtual void load(const std::string& filename) = 0 ;
......@@ -35,18 +35,36 @@ class data
virtual vec min() const = 0 ;
virtual vec max() const = 0 ;
virtual int dimX() const { return _nX ; }
virtual int dimY() const { return _nY ; }
virtual int dimX() const { return _nX ; }
virtual int dimY() const { return _nY ; }
virtual params::input parametrization() const
{
return params::UNKNOWN_INPUT;
}
protected: // data
//! \brief provide the parametrization of the function.
//! \note some function type can modify the parametrization to adapt
//! to the data.
virtual params::input parametrization() const
{
return _in_param;
}
//! \brief can set the input parametrization of a non-parametrized
//! function. Throw an exception if it tries to erase a previously
//! defined one.
virtual void setParametrization(params::input new_param)
{
if(_in_param != params::UNKNOWN_INPUT)
throw("A parametrization is already defined");
_in_param = new_param;
}
protected: // data
// Dimensions of the data
// Dimensions of the data
int _nX, _nY ;
// Input and output parametrization
params::input _in_param ;
params::output _out_param ;
} ;
Q_DECLARE_INTERFACE(data, "Fitter.Data")
......@@ -60,87 +78,87 @@ Q_DECLARE_INTERFACE(data, "Fitter.Data")
*/
class data_params : public data
{
public: // structures
//! \brief when changing from a parametrization to another, you might
//! lose some dimensions. This list enumerate the different operators
//! that can be applied on the raw data to be clusterized.
//! \note by default we use <em>none</em>, but if the input space
//! dimension is reduced, the program will halt.
enum clustrering
{
MEAN,
MEDIAN,
NONE
};
public: // methods
//! \brief contructor requires the definition of a base class that
//! has a parametrization, and a new parametrization.
data_params(const data* d, params::input param,
data_params::clustrering method = data_params::NONE) :
_d(d), _param_in(param), _clustering_method(method)
{
_nX = params::dimension(param);
_nY = d->dimY();
if(_nX < _d->dimX() && method == data_params::NONE)
{
throw("No cluster method provided");
}
}
// Load data from a file
virtual void load(const std::string& filename)
{
std::cerr << "<<ERROR>> this data type cannot load data" << std::endl;
throw;
}
virtual void load(const std::string& filename, const arguments& args)
{
std::cerr << "<<ERROR>> this data type cannot load data" << std::endl;
throw;
}
// Acces to data
virtual vec get(int i) const
{
vec res(_nX + _nY);
vec in = _d->get(i);
params::convert(&in[0], _d->parametrization(), _param_in, &res[0]);
memcpy(&res[_nX], &in[_d->dimX()], _nY*sizeof(double));
return res;
}
virtual vec operator[](int i) const
{
return this->get(i);
}
// Get data size, e.g. the number of samples to fit
virtual int size() const
{
return _d->size();
}
// Get min and max input space values
virtual vec min() const
{
return _d->min();
}
virtual vec max() const
{
return _d->max();
}
protected: // data
const data* _d;
params::input _param_in;
data_params::clustrering _clustering_method;
//! \todo Add a cluster object that will duplicate data or store indices.
public: // structures
//! \brief when changing from a parametrization to another, you might
//! lose some dimensions. This list enumerate the different operators
//! that can be applied on the raw data to be clusterized.
//! \note by default we use <em>none</em>, but if the input space
//! dimension is reduced, the program will halt.
enum clustrering
{
MEAN,
MEDIAN,
NONE
};
public: // methods
//! \brief contructor requires the definition of a base class that
//! has a parametrization, and a new parametrization.
data_params(const data* d, params::input param,
data_params::clustrering method = data_params::NONE) :
_d(d), _param_in(param), _clustering_method(method)
{
_nX = params::dimension(param);
_nY = d->dimY();
if(_nX < _d->dimX() && method == data_params::NONE)
{
throw("No cluster method provided");
}
}
// Load data from a file
virtual void load(const std::string& filename)
{
std::cerr << "<<ERROR>> this data type cannot load data" << std::endl;
throw;
}
virtual void load(const std::string& filename, const arguments& args)
{
std::cerr << "<<ERROR>> this data type cannot load data" << std::endl;
throw;
}
// Acces to data
virtual vec get(int i) const
{
vec res(_nX + _nY);
vec in = _d->get(i);
params::convert(&in[0], _d->parametrization(), _param_in, &res[0]);
memcpy(&res[_nX], &in[_d->dimX()], _nY*sizeof(double));
return res;
}
virtual vec operator[](int i) const
{
return this->get(i);
}
// Get data size, e.g. the number of samples to fit
virtual int size() const
{
return _d->size();
}
// Get min and max input space values
virtual vec min() const
{
return _d->min();
}
virtual vec max() const
{
return _d->max();
}
protected: // data
const data* _d;
params::input _param_in;
data_params::clustrering _clustering_method;
//! \todo Add a cluster object that will duplicate data or store indices.
};
......@@ -72,12 +72,18 @@ void vertical_segment::load(const std::string& filename, const arguments& args)
linestream >> t ;
vs[current_vs] = t ; ++current_vs ;
}
else if(comment == std::string("PARAM_IN"))
{
}
else if(comment == std::string("PARAM_OUT"))
{
}
else if(comment == std::string("PARAM_IN"))
{
std::string param;
linestream >> param;
_in_param = params::parse_input(param);
}
else if(comment == std::string("PARAM_OUT"))
{
std::string param;
linestream >> param;
_out_param = params::parse_output(param);
}
continue ;
}
else if(line.empty())
......
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