Commit 72d606cc authored by Laurent Belcour's avatar Laurent Belcour
Browse files

Small update, the dt parameter is a relative error value

parent abbc0209
......@@ -96,15 +96,16 @@ void rational_data::load(const std::string& filename, const arguments& args)
{
double dt ;
linestream >> dt ;
v[dimX() + dimY()+i] = v[dimX() + i] - dt ;
v[dimX() + 2*dimY()+i] = v[dimX() + i] + dt ;
v[dimX() + dimY()+i] = v[dimX() + i] * (1.0f - dt) ;
v[dimX() + 2*dimY()+i] = v[dimX() + i] * (1.0f + dt) ;
}
else
{
// TODO Specify the delta in case
// Handle multiple dim
v[dimX() + dimY()+i] = v[dimX() + i] - args.get_float("dt", 0.1) ;
v[dimX() + 2*dimY()+i] = v[dimX() + i] + args.get_float("dt", 0.1) ;
float dt = args.get_float("dt", 0.1);
v[dimX() + dimY()+i] = v[dimX() + i] * (1.0f - dt) ;
v[dimX() + 2*dimY()+i] = v[dimX() + i] * (1.0f + dt) ;
}
}
......
......@@ -214,7 +214,12 @@ bool rational_fitter_matlab::fit_data(const rational_data* d, int np, int nq, in
const double sigma_m = svd.singularValues()(std::min(2*M, N)-1) ;
const double sigma_M = svd.singularValues()(0) ;
double delta = sigma_m / sigma_M ;
#ifdef NOT_WORKING
static double cond_number = std::numeric_limits<double>::max() ;
cond_number = std::min(delta, cond_number) ;
#endif
if(std::isnan(delta) || (std::abs(delta) == std::numeric_limits<double>::infinity()))
{
#ifdef DEBUG
......@@ -227,13 +232,15 @@ bool rational_fitter_matlab::fit_data(const rational_data* d, int np, int nq, in
delta = 1.0 ;
}
#ifdef DEBUG
#ifndef DEBUG
std::cout << "<<DEBUG>> delta factor: " << sigma_m << " / " << sigma_M << " = " << delta << std::endl ;
#endif
for(int i=0; i<2*M; ++i)
{
ci(i) = ci(i) * delta ;
}
#ifdef DEBUG
std::cout << "CI = " << CI << std::endl << std::endl ;
#endif
......@@ -274,9 +281,15 @@ bool rational_fitter_matlab::fit_data(const rational_data* d, int np, int nq, in
#ifdef USE_MATLAB
engEvalString(ep, "[x, fval, flag] = quadprog(H,f,A,b);");
#ifdef DEBUG
std::cout << output << std::endl ;
#endif
#else
engEvalString(ep, "cd matlab;");
engEvalString(ep, "[x, err] = qpas(H,f,A,b);");
#ifdef DEBUG
std::cout << output << std::endl ;
#endif
engEvalString(ep, "flag = err == 0.0;");
engEvalString(ep, "cd ..;");
#endif
......
......@@ -257,7 +257,7 @@ bool rational_fitter_quadprog::fit_data(const rational_data* dat, int np, int nq
}
#ifdef DEBUG
#ifndef DEBUG
std::cout << "<<DEBUG>> delta factor: " << sigma_m << " / " << sigma_M << " = " << delta << std::endl ;
#endif
for(int i=0; i<2*d->size(); ++i)
......
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