Commit 965a5e29 authored by Laurent Belcour's avatar Laurent Belcour

Adding another NIST data file (Gauss3)

Removing an error introducted in a previous commit
parent 56792be4
......@@ -168,43 +168,63 @@ double function::Linf_distance(const data* d) const
vec mean = vec::Zero(dimY());
vec var = vec::Zero(dimY());
std::cout << "<<DEBUG>> input param here = " << params::get_name(input_parametrization()) << std::endl;
double linf_dist = 0.0;
for(int i=0; i<d->size(); ++i)
{
vec dat = d->get(i);
vec x(dimX()), y(dimY());
if(input_parametrization() == params::UNKNOWN_INPUT)
{
memcpy(&x[0], &dat[0], dimX()*sizeof(double));
}
else
// Convert the position of the data sample to the parametrization
// of the function.
if(input_parametrization() == params::UNKNOWN_INPUT)
{
memcpy(&x[0], &dat[0], dimX()*sizeof(double));
}
else
{
params::convert(&dat[0], d->input_parametrization(), input_parametrization(), &x[0]);
}
// Copy the value part of the data vector in a vector to perform vector
// operations on it (used in the computation of the mean).
memcpy(&y[0], &dat[d->dimX()], d->dimY()*sizeof(double));
// Take the componentwise-max of the two vectors.
const vec v = value(x);
for(int j=0; j<d->dimY(); ++j)
{
params::convert(&dat[0], d->input_parametrization(), input_parametrization(), &x[0]);
linf_dist = std::max<double>(linf_dist, std::abs(y[j]-v[j]));
}
memcpy(&y[0], &dat[d->dimX()], dimY()*sizeof(double));
linf_dist = std::max<double>(linf_dist, std::abs(norm(y-value(x))));
mean += (y-value(x)) / double(d->size());
// Compute the mean
mean += (y-v) / double(d->size());
}
// Compute the standard deviation with respect to the mean error
for(int i=0; i<d->size(); ++i)
{
vec dat = d->get(i);
vec x(dimX()), y(d->dimY()), val(dimY());
// Convert the position of the data sample to the parametrization
// of the function.
if(input_parametrization() == params::UNKNOWN_INPUT)
{
memcpy(&x[0], &dat[0], dimX()*sizeof(double));
}
else
{
params::convert(&dat[0], d->input_parametrization(), input_parametrization(), &x[0]);
}
if(input_parametrization() == params::UNKNOWN_INPUT)
{
memcpy(&x[0], &dat[0], dimX()*sizeof(double));
}
else
{
params::convert(&dat[0], d->input_parametrization(), input_parametrization(), &x[0]);
}
// Copy the value part of the data vector in a vector to perform vector
// operations on it (used in the computation of the mean).
memcpy(&y[0], &dat[d->dimX()], dimY()*sizeof(double));
val = value(x);
val = value(x);
for(int j=0; j<d->dimY(); ++j)
{
y[j] = dat[d->dimX()+j];
......
......@@ -213,6 +213,7 @@ function* plugins_manager::get_function(const std::string& filename)
// Parameters of the function object
int nX, nY;
params::input param_in; params::output param_out;
arguments args;
// Test for the first line of the file. Should be a ALTA FUNC HEADER
......@@ -228,7 +229,6 @@ function* plugins_manager::get_function(const std::string& filename)
while(line != "#ALTA HEADER END")
{
std::getline(file, line) ;
std::cout << line << std::endl;
std::stringstream linestream(line) ;
linestream.ignore(1) ;
......@@ -239,7 +239,19 @@ function* plugins_manager::get_function(const std::string& filename)
if(comment == std::string("DIM"))
{
linestream >> nX >> nY ;
std::cout << "<<DEBUG>> " << nX << " x " << nY << std::endl;
}
else if(comment == std::string("PARAM_IN"))
{
std::string name;
linestream >> name;
std::cout << "<<DEBUG>> parsed input parametrization: " << name << std::endl;
param_in = params::parse_input(name);
}
else if(comment == std::string("PARAM_OUT"))
{
std::string name;
linestream >> name;
param_out = params::parse_output(name);
}
else if(comment == std::string("CMD"))
{
......@@ -251,6 +263,8 @@ function* plugins_manager::get_function(const std::string& filename)
function* f = get_function(args);
f->setDimX(nX);
f->setDimY(nY);
f->setParametrization(param_in);
f->setParametrization(param_out);
// Load the function part from the file object
f->load(file);
......
......@@ -19,10 +19,10 @@ rational_function_1d::rational_function_1d(int np, int nq, bool separable)
}
rational_function_1d::rational_function_1d(const vec& a,
const vec& b)
const vec& b) : a(a), b(b)
{
_separable = false;
update(a, b);
//update(a, b);
_separable = false;
}
bool rational_function_1d::load(std::istream&)
......@@ -39,7 +39,7 @@ void rational_function_1d::update(const vec& in_a,
//#define NORMALIZE
#ifdef NORMALIZE
const double b0 = (std::abs(in_b[0]) > 1.0E-10) ? in_b[0] : 1.0;
const double b0 = (std::abs(in_b[0]) > 1.0E-16) ? in_b[0] : 1.0;
#else
const double b0 = 1.0;
#endif
......
......@@ -49,7 +49,7 @@ void vertical_segment::load(const std::string& filename, const arguments& args)
{
linestream >> _nX >> _nY ;
vs.assign(dimY(), 0) ;
vs.reserve(dimY()) ;
for(int k=0; k<dimY(); ++k)
{
vs[k] = 0 ;
......@@ -60,11 +60,15 @@ void vertical_segment::load(const std::string& filename, const arguments& args)
min = args.get_vec("min", _nX, -std::numeric_limits<float>::max()) ;
max = args.get_vec("max", _nX, std::numeric_limits<float>::max()) ;
#ifdef DEBUG
std::cout << "<<DEBUG>> data will remove outside of " << min << " -> " << max << " x-interval" << std::endl;
#endif
ymin = args.get_vec("ymin", _nY, -std::numeric_limits<float>::max()) ;
ymax = args.get_vec("ymax", _nY, std::numeric_limits<float>::max()) ;
#ifdef DEBUG
std::cout << "<<DEBUG>> data will remove outside of " << ymin << " -> " << ymax << " y-interval" << std::endl;
#endif
for(int k=0; k<dimX(); ++k)
{
......@@ -160,7 +164,7 @@ void vertical_segment::load(const std::string& filename, const arguments& args)
if(args.is_defined("dt-relative"))
{
v[dimX() + dimY()+i] = v[dimX() + i] * (1.0 + min_dt) ;
v[dimX() + dimY()+i] = v[dimX() + i] * (1.0 + min_dt) ;
v[dimX() + 2*dimY()+i] = v[dimX() + i] * (1.0 + max_dt) ;
}
else
......@@ -168,6 +172,9 @@ void vertical_segment::load(const std::string& filename, const arguments& args)
v[dimX() + dimY()+i] = v[dimX() + i] + min_dt ;
v[dimX() + 2*dimY()+i] = v[dimX() + i] + max_dt ;
}
#ifdef DEBUG
std::cout << "<<DEBUG>> vs = [" << v[dimX() + dimY()+i] << ", " << v[dimX() + 2*dimY()+i] << "]" << std::endl;
#endif
}
// If data is not in the interval of fit
......
......@@ -100,14 +100,14 @@ int main(int argc, char** argv)
vec x(f->dimX());
// Convert the data to the function's input space.
if(f->input_parametrization() == params::UNKNOWN_INPUT)
{
memcpy(&x[0], &v[0], f->dimX()*sizeof(double));
}
else
{
params::convert(&v[0], d->input_parametrization(), f->input_parametrization(), &x[0]);
}
if(f->input_parametrization() == params::UNKNOWN_INPUT)
{
memcpy(&x[0], &v[0], f->dimX()*sizeof(double));
}
else
{
params::convert(&v[0], d->input_parametrization(), f->input_parametrization(), &x[0]);
}
// Evaluate the function. I can add the cosine term to the BRDF
// value.
......
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