Commit e6b36699 authored by Ludovic Courtès's avatar Ludovic Courtès

core: 'function' aggregates 'parameters' instead of inheriting from it.

parent 10664d7a
This diff is collapsed.
......@@ -39,9 +39,7 @@ class function
public: // methods
function()
: _in_param(params::UNKNOWN_INPUT), _out_param(params::UNKNOWN_OUTPUT),
_nX(0), _nY(0),
_min(vec::Zero(0)), _max(vec::Zero(0)) { };
: _min(vec::Zero(0)), _max(vec::Zero(0)) { };
/* NEEDED FUNCTIONS */
......@@ -108,28 +106,26 @@ class function
// Definition domain of the function.
// TODO: Move this to a 'parameterization' class.
virtual void setMin(const vec& min) { _min = min; }
virtual void setMax(const vec& max) { _max = max; }
int dimX() const { return _nX; }
int dimY() const { return _nX; }
virtual void setDimX(int x) { _nX = x; _min.resize(x); _max.resize(x); }
virtual void setDimY(int y) { _nY = y; }
void setParametrization(params::input p) { _in_param = p; }
void setParametrization(params::output p) { _out_param = p; }
params::input parametrization() const { return _in_param; }
params::input input_parametrization() const { return _in_param; }
params::output output_parametrization() const { return _out_param; }
virtual vec min() const { return _min; }
virtual vec max() const { return _max; }
const parameters& parametrization() const {
return _parameters;
}
void setParametrization(const parameters& p) {
_parameters = p;
}
// TODO: Deprecate, then remove these two methods.
virtual void setDimX(int x);
virtual void setDimY(int y);
protected:
// Input and output parametrization
// TODO: Move this to a 'parameterization' class.
params::input _in_param;
params::output _out_param;
int _nX, _nY;
parameters _parameters;
vec _min, _max;
};
......@@ -367,9 +363,6 @@ class product_function : public nonlinear_function
virtual void setMin(const vec& min);
virtual void setMax(const vec& max);
//! Provide the output parametrization of the object.
virtual params::output output_parametrization() const;
//! \brief Number of parameters to this non-linear function
virtual int nbParameters() const;
......@@ -403,8 +396,7 @@ class cosine_function : public nonlinear_function
// of transformations in a compound object.
cosine_function()
{
_in_param = params::CARTESIAN;
_nX = 6;
_parameters = alta::parameters(6, 0, params::CARTESIAN, params::UNKNOWN_OUTPUT);
}
// Overload the function operator
......@@ -414,8 +406,10 @@ class cosine_function : public nonlinear_function
}
virtual vec value(const vec& x) const
{
vec res(dimY());
for(int i=0; i<dimY(); ++i) { res[i] = ((x[2] > 0.0) ? x[2] : 0.0) * ((x[5] > 0.0) ? x[5] : 0.0); }
vec res(parametrization().dimY());
for(int i=0; i<parametrization().dimY(); ++i) {
res[i] = ((x[2] > 0.0) ? x[2] : 0.0) * ((x[5] > 0.0) ? x[5] : 0.0);
}
return res;
}
......
......@@ -190,7 +190,6 @@ function* plugins_manager::load_function(const std::string& filename)
file.precision(10);
// Parameters of the function object
int nX, nY;
params::input param_in = params::UNKNOWN_INPUT;
params::output param_out = params::UNKNOWN_OUTPUT;
arguments args;
......@@ -211,22 +210,21 @@ function* plugins_manager::load_function(const std::string& filename)
arguments header = arguments::parse_header(file);
std::pair<int, int> dim = header.get_pair<int>("DIM");
nX = dim.first;
nY = dim.second;
param_in = params::parse_input(header.get_string("PARAM_IN", "UNKNOWN_INPUT"));
param_out = params::parse_output(header.get_string("PARAM_OUT", "UNKNOWN_OUTPUT"));
args = arguments::create_arguments(header["CMD"]);
parameters params(dim.first, dim.second, param_in, param_out);
// Create the function from the command line
function* f = get_function(args);
f->setDimX(nX);
f->setDimY(nY);
if(f->input_parametrization() == params::UNKNOWN_INPUT)
{
f->setParametrization(param_in);
}
f->setParametrization(param_out);
f->setParametrization(params);
// FIXME: Since the above is not quite the same as calling 'setDimY' (which
// is virtual), also call it from here. TODO: Remove it ASAP.
f->setDimY(params.dimY());
f->setDimX(params.dimX());
// Load the function part from the file object
if( f->load(file) )
......@@ -495,7 +493,7 @@ void plugins_manager::check_compatibility( ptr<data>& d,
const arguments& args)
{
if(d->parametrization().input_parametrization() == params::UNKNOWN_INPUT &&
f->input_parametrization() == params::UNKNOWN_INPUT)
f->parametrization().input_parametrization() == params::UNKNOWN_INPUT)
{
std::cout << "<<WARNING>> both function and data objects have no parametrization" << std::endl;
}
......@@ -506,16 +504,20 @@ void plugins_manager::check_compatibility( ptr<data>& d,
std::cout << "<<WARNING>> unknown parametrization for data" << std::endl;
}
if(f->input_parametrization() == params::UNKNOWN_INPUT)
if(f->parametrization().input_parametrization() == params::UNKNOWN_INPUT)
{
std::cout << "<<DEBUG>> function will take the parametrization of the data" << std::endl;
f->setParametrization(d->parametrization().input_parametrization());
parameters params(f->parametrization().dimX(),
f->parametrization().dimY(),
d->parametrization().input_parametrization(),
f->parametrization().output_parametrization());
f->setParametrization(params);
}
else if(d->parametrization().input_parametrization() != f->input_parametrization() && args.is_defined("change-param"))
else if(d->parametrization().input_parametrization() != f->parametrization().input_parametrization() && args.is_defined("change-param"))
{
std::cout << "<<INFO>> has to change the parametrization of the input data " << params::get_name(d->parametrization().input_parametrization()) << std::endl;
std::cout << "<<INFO>> to " << params::get_name(f->input_parametrization()) << std::endl;
ptr<data_params> dd = ptr<data_params>(new data_params(d, f->input_parametrization()));
std::cout << "<<INFO>> to " << params::get_name(f->parametrization().input_parametrization()) << std::endl;
ptr<data_params> dd = ptr<data_params>(new data_params(d, f->parametrization().input_parametrization()));
d = dynamic_pointer_cast<data>(dd) ;
}
else
......@@ -524,7 +526,7 @@ void plugins_manager::check_compatibility( ptr<data>& d,
}
}
if(f->dimY() != d->parametrization().dimY())
if(f->parametrization().dimY() != d->parametrization().dimY())
{
f->setDimY(d->parametrization().dimY());
}
......
/* ALTA --- Analysis of Bidirectional Reflectance Distribution Functions
Copyright (C) 2013, 2014 Inria
Copyright (C) 2013, 2014, 2016 Inria
This file is part of ALTA.
......@@ -54,7 +54,7 @@ bool rational_function_1d::load(std::istream& in)
// TODO: Check if the indices match the current index?
for(int j=0; j<_np; ++j)
{
for(int k=0; k<_nX; ++k)
for(int k=0; k<_parameters.dimX(); ++k)
{
in >> token;
}
......@@ -65,7 +65,7 @@ bool rational_function_1d::load(std::istream& in)
// TODO: Check if the indices match the current index?
for(int j=0; j<_nq; ++j)
{
for(int k=0; k<_nX; ++k)
for(int k=0; k<_parameters.dimX(); ++k)
{
in >> token;
}
......@@ -96,7 +96,7 @@ void rational_function_1d::save_body(std::ostream& out, const arguments& args) c
out << "#NQ " << nq << std::endl;
for(unsigned int i=0; i<np; ++i)
{
for(int j=0; j<dimX(); ++j)
for(int j=0; j<_parameters.dimX(); ++j)
{
out << _p_coeffs[i].deg[j] << "\t" ;
}
......@@ -105,7 +105,7 @@ void rational_function_1d::save_body(std::ostream& out, const arguments& args) c
for(unsigned int i=0; i<nq; ++i)
{
for(int j=0; j<dimX(); ++j)
for(int j=0; j<_parameters.dimX(); ++j)
{
out << _q_coeffs[i].deg[j] << "\t" ;
}
......@@ -119,9 +119,9 @@ void rational_function_1d::save_body(std::ostream& out, const arguments& args) c
for(unsigned int i=0; i<np; ++i)
{
out << _p_coeffs[i].a;
for(int k=0; k<dimX(); ++k)
for(int k=0; k<_parameters.dimX(); ++k)
{
if(k != dimX()-1) { out << ".*"; }
if(k != _parameters.dimX()-1) { out << ".*"; }
out << "x(k).^" << _q_coeffs[i].deg[k];
}
if(i != np-1) { out << " + "; }
......@@ -131,9 +131,9 @@ void rational_function_1d::save_body(std::ostream& out, const arguments& args) c
for(unsigned int i=0; i<nq; ++i)
{
out << _p_coeffs[i].a << "x.^" << i;
for(int k=0; k<dimX(); ++k)
for(int k=0; k<_parameters.dimX(); ++k)
{
if(k != dimX()-1) { out << ".*"; }
if(k != _parameters.dimX()-1) { out << ".*"; }
out << "x(k).^" << _q_coeffs[i].deg[k];
}
if(i != nq-1) { out << " + "; }
......@@ -204,7 +204,7 @@ void rational_function_1d::resize(unsigned int np, unsigned int nq)
// It is not possible to resize the multi-dimensional vector
// if the input dimensions size is not defined. This can
// happen at the creation of the rational function object.
if(dimX() == 0) { return; }
if(_parameters.dimX() == 0) { return; }
// Resize the numerator
if(_p_coeffs.size() != np)
......@@ -331,13 +331,13 @@ void rational_function_1d::populate(std::vector<int>& vec, int N, int M, int j)
std::vector<int> rational_function_1d::index2degree(int i) const
{
std::vector<int> deg ; deg.assign(dimX(), 0) ;
std::vector<int> deg ; deg.assign(_parameters.dimX(), 0) ;
if(i == 0)
return deg ;
// The case of one dimensional signals is trivial
if(dimX() == 1)
if(_parameters.dimX() == 1)
{
deg[0] = i;
return deg;
......@@ -348,16 +348,16 @@ std::vector<int> rational_function_1d::index2degree(int i) const
if(_separable)
{
const int index = i-1;
const int base = index / dimX() + 1;
for(int k=0; k<dimX(); ++k)
const int base = index / _parameters.dimX() + 1;
for(int k=0; k<_parameters.dimX(); ++k)
{
deg[k] = (index % dimX() == k) ? base : 0;
deg[k] = (index % _parameters.dimX() == k) ? base : 0;
}
}
else
#endif
{
if(dimX() == 2)
if(_parameters.dimX() == 2)
{
int Nk = 1 ;
int k = 1 ;
......@@ -375,17 +375,17 @@ std::vector<int> rational_function_1d::index2degree(int i) const
{
int Nk = 1 ;
int k = 1 ;
int dk = estimate_dk(k, dimX()) ;
int dk = estimate_dk(k, _parameters.dimX()) ;
while(!(i >= Nk && i < Nk+dk))
{
Nk += dk ;
++k ;
dk = estimate_dk(k, dimX()) ;
dk = estimate_dk(k, _parameters.dimX()) ;
}
// Populate the vector from front to back
int j = i-Nk ;
populate(deg, dimX(), k, j) ;
populate(deg, _parameters.dimX(), k, j) ;
}
}
......@@ -403,7 +403,7 @@ std::vector<int> rational_function_1d::index2degree(int i) const
double rational_function_1d::p(const vec& x, int i) const
{
double res = 1.0;
for(int k=0; k<dimX(); ++k)
for(int k=0; k<_parameters.dimX(); ++k)
{
const double xp = 2.0*((x[k] - _min[k]) / (_max[k]-_min[k]) - 0.5);
res *= pow(xp, _p_coeffs[i].deg[k]) ;
......@@ -414,7 +414,7 @@ double rational_function_1d::p(const vec& x, int i) const
double rational_function_1d::q(const vec& x, int i) const
{
double res = 1.0;
for(int k=0; k<dimX(); ++k)
for(int k=0; k<_parameters.dimX(); ++k)
{
const double xp = 2.0*((x[k] - _min[k]) / (_max[k]-_min[k]) - 0.5);
res *= pow(xp, _q_coeffs[i].deg[k]) ;
......@@ -510,18 +510,18 @@ void rational_function::update(int i, rational_function_1d* r)
rational_function_1d* rational_function::get(int i)
{
// Check for consistency in the index of color channel
if(i < _nY)
if(i < _parameters.dimY())
{
if(rs[i] == NULL)
{
rs[i] = new rational_function_1d(dimX(), np, nq);
rs[i] = new rational_function_1d(_parameters.dimX(), np, nq);
// Test if the input domain is not empty. If one dimension of
// the input domain is a point, I manually inflate this dimension
// to avoid numerical issues.
vec _min = min();
vec _max = max();
for(int k=0; k<dimX(); ++k)
for(int k=0; k<_parameters.dimX(); ++k)
{
if(_min[k] == _max[k])
{
......@@ -545,7 +545,7 @@ rational_function_1d* rational_function::get(int i)
rational_function_1d* rational_function::get(int i) const
{
// Check for consistency in the index of color channel
if(i < _nY)
if(i < _parameters.dimY())
{
return rs[i];
}
......@@ -560,9 +560,9 @@ rational_function_1d* rational_function::get(int i) const
vec rational_function::value(const vec& x) const
{
vec res(_nY) ;
vec res(_parameters.dimY()) ;
for(int k=0; k<_nY; ++k)
for(int k=0; k<_parameters.dimY(); ++k)
{
res[k] = rs[k]->value(x)[0] ;
}
......@@ -602,14 +602,14 @@ bool rational_function::load(std::istream& in)
}
// Check for the MIN and MAX vector
vec min(dimX()), max(dimX());
vec min(_parameters.dimX()), max(_parameters.dimX());
in >> token;
if(token.compare("#MIN") != 0)
{
std::cerr << "<<ERROR>> the min value for the input space is not defined." << std::endl;
return false;
}
for(int k=0; k<dimX(); ++k) {in >> min[k];}
for(int k=0; k<_parameters.dimX(); ++k) {in >> min[k];}
setMin(min);
in >> token;
......@@ -618,10 +618,10 @@ bool rational_function::load(std::istream& in)
std::cerr << "<<ERROR>> the max value for the input space is not defined." << std::endl;
return false;
}
for(int k=0; k<dimX(); ++k) {in >> max[k]; }
for(int k=0; k<_parameters.dimX(); ++k) {in >> max[k]; }
setMax(max);
for(int i=0; i<_nY; ++i)
for(int i=0; i<_parameters.dimY(); ++i)
{
// Update the i_th color channel
if(!get(i)->load(in)) { return false; }
......@@ -636,10 +636,10 @@ void rational_function::save_call(std::ostream& out, const arguments& args) cons
out.precision(64);
out << std::scientific;
out << "#FUNC rational_function" << std::endl;
out << "#MIN "; for(int k=0; k<_nX; ++k) { out << _min[k] << " "; } out << std::endl;
out << "#MAX "; for(int k=0; k<_nX; ++k) { out << _max[k] << " "; } out << std::endl;
out << "#MIN "; for(int k=0; k<_parameters.dimX(); ++k) { out << _min[k] << " "; } out << std::endl;
out << "#MAX "; for(int k=0; k<_parameters.dimX(); ++k) { out << _max[k] << " "; } out << std::endl;
for(int k=0; k<_nY; ++k)
for(int k=0; k<_parameters.dimY(); ++k)
{
const rational_function_1d* rf = get(k);
rf->save_body(out, args);
......@@ -649,7 +649,7 @@ void rational_function::save_call(std::ostream& out, const arguments& args) cons
std::ostream& operator<< (std::ostream& out, const rational_function& r)
{
for(int i=0; i<r.dimY(); ++i)
for(int i=0; i < r.parametrization().dimY(); ++i)
{
rational_function_1d* rf = r.get(i);
out << "dimension " << i << ": ";
......
/* ALTA --- Analysis of Bidirectional Reflectance Distribution Functions
Copyright (C) 2013, 2014 Inria
Copyright (C) 2013, 2014, 2016 Inria
This file is part of ALTA.
......@@ -190,10 +190,10 @@ class rational_function : public function
// Update the function
virtual void update(const ptr<rational_function>& r)
{
assert(r->dimX() == dimX());
assert(r->dimY() == dimY());
assert(r->parametrization().dimX() == _parameters.dimX());
assert(r->parametrization().dimY() == _parameters.dimY());
for(int k=0; k<dimY(); ++k)
for(int k=0; k < _parameters.dimY(); ++k)
{
get(k)->update(r->get(k));
}
......@@ -207,10 +207,13 @@ class rational_function : public function
//! Set the dimension of the output space of the function. This function
//! will update the size of the rs vector size.
virtual void setDimY(int nY)
{
_nY = nY ;
rs.resize(nY);
virtual void setDimY(int nY)
{
parameters new_params(_parameters.dimX(), nY,
_parameters.input_parametrization(),
_parameters.output_parametrization());
_parameters = new_params;
rs.resize(nY);
}
//! \brief Set the size of the rational function. Any newly created 1D
......@@ -226,7 +229,7 @@ class rational_function : public function
virtual void clear()
{
rs.clear();
rs.resize(_nY);
rs.resize(_parameters.dimY());
}
virtual void setMin(const vec& min)
......
......@@ -34,7 +34,7 @@ class CeresFunctor : public ceres::CostFunction
public:
CeresFunctor(const ptr<nonlinear_function>& f, const vec& xi, const arguments& args) : _f(f), _xi(xi)
{
set_num_residuals(f->dimY());
set_num_residuals(f->parametrization().dimY());
mutable_parameter_block_sizes()->push_back(f->nbParameters());
_log_fit = args.is_defined("log-fit");
......@@ -59,15 +59,15 @@ class CeresFunctor : public ceres::CostFunction
for(int i=0; i<_f->nbParameters(); ++i) { _p[i] = x[0][i]; }
_f->setParameters(_p);
vec _di = vec(_f->dimY());
for(int i=0; i<_f->dimY(); ++i)
vec _di = vec(_f->parametrization().dimY());
for(int i=0; i<_f->parametrization().dimY(); ++i)
{
_di[i] = _xi[_f->dimX() + i];
_di[i] = _xi[_f->parametrization().dimX() + i];
}
const vec _yi = _f->value(_xi);
const vec _y = _di - _yi;
for(int i=0; i<_f->dimY(); ++i)
for(int i=0; i<_f->parametrization().dimY(); ++i)
{
y[i] = (_log_fit) ? log(1.0 + _di[i]) - log(1.0 + _yi[i]) : _y[i] ;
}
......@@ -90,7 +90,7 @@ class CeresFunctor : public ceres::CostFunction
// For each output channel, update the subpart of the
// vector row
for(int i=0; i<_f->dimY(); ++i)
for(int i=0; i<_f->parametrization().dimY(); ++i)
{
// Fill the columns of the matrix
for(int j=0; j<_f->nbParameters(); ++j)
......@@ -119,10 +119,8 @@ nonlinear_fitter_ceres::~nonlinear_fitter_ceres()
bool nonlinear_fitter_ceres::fit_data(const ptr<data>& d, ptr<function>& fit, const arguments &args)
{
// I need to set the dimension of the resulting function to be equal
// to the dimension of my fitting problem
fit->setDimX(d->parametrization().dimX()) ;
fit->setDimY(d->parametrization().dimY()) ;
// XXX: FIT and D may have different values of dimX() and dimY(), but
// this is fine: we convert values as needed in operator().
fit->setMin(d->min()) ;
fit->setMax(d->max()) ;
......@@ -157,14 +155,14 @@ bool nonlinear_fitter_ceres::fit_data(const ptr<data>& d, ptr<function>& fit, co
for(int i=0; i<d->size(); ++i)
{
vec xi = d->get(i);
vec xf(nf->dimX() + nf->dimY());
vec xf(nf->parametrization().dimX() + nf->parametrization().dimY());
// Convert the sample to be in the parametrizatio of the function
params::convert(&xi[0], d->parametrization().input_parametrization(),
nf->input_parametrization(), &xf[0]);
for(int k=0; k<nf->dimY(); ++k)
nf->parametrization().input_parametrization(), &xf[0]);
for(int k=0; k<nf->parametrization().dimY(); ++k)
{
xf[nf->dimX() + k] = xi[d->parametrization().dimX() + k];
xf[nf->parametrization().dimX() + k] = xi[d->parametrization().dimX() + k];
}
problem.AddResidualBlock(new CeresFunctor(nf, xf, args), NULL, &p[0]);
......
......@@ -65,8 +65,8 @@ struct EigenFunctor: Eigen::DenseFunctor<double>
for(int i=0; i<inputs(); ++i) { _p[i] = x(i); }
_f->setParameters(_p);
const int nx = _f->dimX();
const int ny = _f->dimY();
const int nx = _f->parametrization().dimX();
const int ny = _f->parametrization().dimY();
for(int s=0; s<_d->size(); ++s)
{
......@@ -76,7 +76,7 @@ struct EigenFunctor: Eigen::DenseFunctor<double>
vec x(nx);
params::convert(&_x[0],
_d->parametrization().input_parametrization(),
_f->input_parametrization(),
_f->parametrization().input_parametrization(),
&x[0]);
// Compute the cosine factor. Only update the constant if the flag
......@@ -122,10 +122,10 @@ struct EigenFunctor: Eigen::DenseFunctor<double>
vec xi = _d->get(s);
// Convert the sample point into the function space
vec x(_f->dimX());
vec x(_f->parametrization().dimX());
params::convert(&xi[0],
_d->parametrization().input_parametrization(),
_f->input_parametrization(),
_f->parametrization().input_parametrization(),
&x[0]);
// Compute the cosine factor. Only update the constant if the flag
......@@ -148,7 +148,7 @@ struct EigenFunctor: Eigen::DenseFunctor<double>
{
// For each output channel, update the subpart of the
// vector row
for(int i=0; i<_f->dimY(); ++i)
for(int i=0; i<_f->parametrization().dimY(); ++i)
{
fjac(i*_d->size() + s, j) = - cos * _jac[i*_f->nbParameters() + j];
}
......@@ -207,21 +207,21 @@ struct CompoundFunctor: Eigen::DenseFunctor<double>
cos = cart[5];
}
vec _di = vec(f->dimY());
for(int i=0; i<f->dimY(); ++i)
_di[i] = _x[f->dimX() + i];
vec _di = vec(f->parametrization().dimY());
for(int i=0; i<f->parametrization().dimY(); ++i)
_di[i] = _x[f->parametrization().dimX() + i];
// Compute the value of the preceding functions
vec _fy = vec::Zero(f->dimY());
vec _fy = vec::Zero(f->parametrization().dimY());
for(int i=0; i<_index+1; ++i)
{
const nonlinear_function* f = (*_f)[i];
if(f->input_parametrization() != _d->parametrization().input_parametrization())
if(f->parametrization().input_parametrization() != _d->parametrization().input_parametrization())
{
vec x(f->dimX());
vec x(f->parametrization().dimX());
params::convert(&_x[0],
_d->parametrization().input_parametrization(),
f->input_parametrization(),
f->parametrization().input_parametrization(),
&x[0]);
_fy += (*f)(x);
......@@ -234,7 +234,7 @@ struct CompoundFunctor: Eigen::DenseFunctor<double>
// Should add the resulting vector completely
vec _y = _di - cos*_fy;
for(int i=0; i<f->dimY(); ++i)
for(int i=0; i<f->parametrization().dimY(); ++i)
y(i*_d->size() + s) = _y[i];
}
......@@ -274,12 +274,12 @@ struct CompoundFunctor: Eigen::DenseFunctor<double>
// Get the associated jacobian
vec _jac;
if(f->input_parametrization() != _d->parametrization().input_parametrization())
if(f->parametrization().input_parametrization() != _d->parametrization().input_parametrization())
{
vec x(f->dimX());
vec x(f->parametrization().dimX());
params::convert(&xi[0],
_d->parametrization().input_parametrization(),
f->input_parametrization(),
f->parametrization().input_parametrization(),
&x[0]);
_jac = f->parametersJacobian(x);
......@@ -295,7 +295,7 @@ struct CompoundFunctor: Eigen::DenseFunctor<double>
{
// For each output channel, update the subpart of the
// vector row
for(int i=0; i<_f->dimY(); ++i)
for(int i=0; i<_f->parametrization().dimY(); ++i)
{
fjac(i*_d->size() + s, j) = - cos * _jac[i*f->nbParameters() + j];
}
......
......@@ -111,25 +111,25 @@ class altaNLP : public Ipopt::TNLP
// This plugin can for the moment only account for function and data
// of the same output size. TODO: Add conversion between spaces.
assert(_d->parametrization().dimY() == _f->dimY());
assert(_d->parametrization().dimY() == _f->parametrization().dimY());
const int dDimX = _d->parametrization().dimX();
// Extract the objective from the current vector
vec _di = vec(_f->dimY());
for(int i=0; i<_f->dimY(); ++i)
vec _di = vec(_f->parametrization().dimY());
for(int i=0; i<_f->parametrization().dimY(); ++i)
{
_di[i] = _x[dDimX + i];
}
// Convert the sample point into the function space
vec x(_f->dimX());
vec x(_f->parametrization().dimX());
params::convert(&_x[0], _d->parametrization().input_parametrization(),
_f->input_parametrization(), &x[0]);
_f->parametrization().input_parametrization(), &x[0]);
// Compute the difference vector and add its
// components to the obj_value
vec _y = _di - _f->value(x);
for(int i=0; i<_f->dimY(); ++i)
for(int i=0; i<_f->parametrization().dimY(); ++i)
{
obj_value += pow(_y[i], 2);
}
......@@ -157,16 +157,16 @@ class altaNLP : public Ipopt::TNLP
const int dDimX = _d->parametrization().dimX();
// Extract the objective from the current vector
vec _di = vec(_f->dimY());
for(int i=0; i<_f->dimY(); ++i)
vec _di = vec(_f->parametrization().dimY());
for(int i=0; i<_f->parametrization().dimY(); ++i)
{
_di[i] = _x[dDimX + i];
}
// Convert the sample point into the function space
vec x(_f->dimX());
vec x(_f->parametrization().dimX());
params::convert(&_x[0], _d->parametrization().input_parametrization(),
_f->input_parametrization(), &x[0]);