Commit 7b00ec33 authored by Laurent Belcour's avatar Laurent Belcour

Correction of bugs

 * data2gnuplot: I removed the plugin manager call to have the same
   parametrizations for data and function.
 * function_blinn: correction of an issue in the parsing
parent 5c9e9a5b
......@@ -118,12 +118,12 @@ double function::L2_distance(const data* d) const
for(int i=0; i<d->size(); ++i)
{
vec dat = d->get(i);
vec y(d->dimY());
for(int j=0; j<d->dimY(); ++j)
y[j] = dat[d->dimX()+j];
vec x(d->dimX()), y(d->dimY());
for(int j=0; j<d->dimX(); ++j) { x[j] = dat[j]; }
for(int j=0; j<d->dimY(); ++j) { y[j] = dat[d->dimX()+j]; }
//linf_dist = std::max<double>(linf_dist, std::abs<double>(norm(y-rj->value(dat))));
l2_dist += std::pow(norm(y-value(dat)), 2);
l2_dist += std::pow(norm(y-value(x)), 2);
}
l2_dist = std::sqrt(l2_dist / d->size());
return l2_dist;
......@@ -137,9 +137,9 @@ double function::Linf_distance(const data* d) const
for(int i=0; i<d->size(); ++i)
{
vec dat = d->get(i);
vec y(d->dimY());
for(int j=0; j<d->dimY(); ++j)
y[j] = dat[d->dimX()+j];
vec x(d->dimX()), y(d->dimY());
for(int j=0; j<d->dimX(); ++j) { x[j] = dat[j]; }
for(int j=0; j<d->dimY(); ++j) { y[j] = dat[d->dimX()+j]; }
linf_dist = std::max<double>(linf_dist, std::abs(norm(y-value(dat))));
}
......
......@@ -447,7 +447,7 @@ void plugins_manager::check_compatibility(data*& d, function*& f,
if(f->dimY() != d->dimY())
{
std::cout << "<<WARNING>> the data and the function have different Y dimensions" << std::endl;
f->setDimY(d->dimY());
}
/*
......
......@@ -43,7 +43,7 @@ void blinn_function::load(std::istream& in)
// Checking for the comment line #FUNC nonlinear_function_blinn
std::string token;
in >> token;
if(token != "FUNC") { std::cerr << "<<ERROR>> parsing the stream. The #FUNC is not the next line defined." << std::endl; }
if(token != "#FUNC") { std::cerr << "<<ERROR>> parsing the stream. The #FUNC is not the next line defined." << std::endl; }
in >> token;
if(token != "nonlinear_function_blinn") { std::cerr << "<<ERROR>> parsing the stream. function name is not the next token." << std::endl; }
......@@ -55,6 +55,8 @@ void blinn_function::load(std::istream& in)
in >> token >> _ks[i];
in >> token >> _N[i];
}
std::cout << "<<DEBUG>> load parameters " << parameters() << std::endl;
}
//! Number of parameters to this non-linear function
......
......@@ -62,7 +62,7 @@ def parseAction(xmlNode):
outputNode = xmlNode.find('output');
if not(outputNode is None):
cmd += ' --output ' + inputNode.attrib['name'];
cmd += ' --output ' + outputNode.attrib['name'];
#end
for plugin in xmlNode.findall('plugin'):
......@@ -99,6 +99,7 @@ for child in root.findall('action'):
# Parse the action
cmd += parseAction(child);
#print cmd;
ret = os.system(cmd);
if(ret != 0):
print '<<PYTHON>> the action was not performed';
......
......@@ -49,13 +49,16 @@ int main(int argc, char** argv)
d->load(args["data"]) ;
}
// If the function loaded has no parametrization (for example a diffuse
// function), the function will take the parametrization of the data
if(f->input_parametrization() == params::UNKNOWN_INPUT)
{
manager.check_compatibility(d, f, args);
}
/*
// Print the distance to the data to check if it correspond to the value
// computed prior.
double L2 = f->L2_distance(d);
double Linf = f->Linf_distance(d);
std::cout << "<<INFO>> L2 distance to data = " << L2 << std::endl;
std::cout << "<<INFO>> Linf distance to data = " << Linf << std::endl;
*/
// Check the kind of plot to do
bool plot_error = false ;
bool linear_plot = false;
if(args.is_defined("error"))
......@@ -78,7 +81,10 @@ int main(int argc, char** argv)
{
vec v = d->get(i) ;
vec y2 = f->value(v) ;
vec x(f->dimX());
params::convert(&v[0], d->input_parametrization(), f->input_parametrization(), &x[0]);
vec y2 = f->value(x) ;
if(!linear_plot)
{
for(int u=0; u<d->dimX(); ++u)
......
......@@ -87,6 +87,7 @@ int main(int argc, char** argv)
std::cout << "<<INFO>> L2 distance to data = " << L2 << std::endl;
std::cout << "<<INFO>> Linf distance to data = " << Linf << std::endl;
/*
std::stringstream append; // Append informations to the export
if(args.is_defined("export-append")) {
append << args["export-append"];
......@@ -94,6 +95,7 @@ int main(int argc, char** argv)
append << "#L2 " << L2 << std::endl;
append << "#LINF " << Linf ;
args.update("export-append", append.str());
*/
f->save(args["output"], args) ;
return 0;
......
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