Commit c6ea14e4 authored by Laurent Belcour's avatar Laurent Belcour
Browse files

Fixing a bug in the parallel plugin

parent acf44c92
...@@ -109,7 +109,6 @@ bool rational_fitter_parallel::fit_data(const data* dat, function* fit, const ar ...@@ -109,7 +109,6 @@ bool rational_fitter_parallel::fit_data(const data* dat, function* fit, const ar
double mean_delta = 0.0; double mean_delta = 0.0;
int nb_sol_found = 0; int nb_sol_found = 0;
int nb_sol_tested = 0; int nb_sol_tested = 0;
int np, nq ;
#pragma omp parallel for #pragma omp parallel for
for(int j=1; j<i; ++j) for(int j=1; j<i; ++j)
...@@ -118,6 +117,7 @@ bool rational_fitter_parallel::fit_data(const data* dat, function* fit, const ar ...@@ -118,6 +117,7 @@ bool rational_fitter_parallel::fit_data(const data* dat, function* fit, const ar
int temp_nq = j; int temp_nq = j;
vec p(temp_np*r->dimY()), q(temp_nq*r->dimY()); vec p(temp_np*r->dimY()), q(temp_nq*r->dimY());
rs[omp_get_thread_num()]->setSize(temp_np, temp_nq);
double delta, linf_dist, l2_dist; double delta, linf_dist, l2_dist;
bool is_fitted = fit_data(d, temp_np, temp_nq, rs[omp_get_thread_num()], args, p, q, delta, linf_dist, l2_dist); bool is_fitted = fit_data(d, temp_np, temp_nq, rs[omp_get_thread_num()], args, p, q, delta, linf_dist, l2_dist);
...@@ -138,7 +138,11 @@ bool rational_fitter_parallel::fit_data(const data* dat, function* fit, const ar ...@@ -138,7 +138,11 @@ bool rational_fitter_parallel::fit_data(const data* dat, function* fit, const ar
if(delta < min_delta) if(delta < min_delta)
{ {
min_delta = delta ; min_delta = delta ;
r = rs[omp_get_thread_num()]; r->setSize(temp_np, temp_nq);
for(int y=0; y<r->dimY(); ++y)
{
r->update(y, rs[omp_get_thread_num()]->get(y));
}
} }
// Get the solution with the minumum L2 norm // Get the solution with the minumum L2 norm
...@@ -198,7 +202,6 @@ bool rational_fitter_parallel::fit_data(const data* dat, function* fit, const ar ...@@ -198,7 +202,6 @@ bool rational_fitter_parallel::fit_data(const data* dat, function* fit, const ar
time.stop(); time.stop();
std::cout << "<<INFO>> got a fit using N = " << i << std::endl ; std::cout << "<<INFO>> got a fit using N = " << i << std::endl ;
std::cout << "<<INFO>> got a fit using {np, nq} = " << np << ", " << nq << std::endl ;
std::cout << "<<INFO>> it took " << time << std::endl ; std::cout << "<<INFO>> it took " << time << std::endl ;
std::cout << "<<INFO>> I got " << nb_sol_found << " solutions to the QP" << std::endl ; std::cout << "<<INFO>> I got " << nb_sol_found << " solutions to the QP" << std::endl ;
return true ; return true ;
...@@ -222,6 +225,7 @@ bool rational_fitter_parallel::fit_data(const vertical_segment* d, int np, int n ...@@ -222,6 +225,7 @@ bool rational_fitter_parallel::fit_data(const vertical_segment* d, int np, int n
{ {
vec p(np), q(nq); vec p(np), q(nq);
rational_function_1d* rf = r->get(j); rational_function_1d* rf = r->get(j);
rf->resize(np, nq);
if(!fit_data(d, np, nq, j, rf, p, q, delta)) if(!fit_data(d, np, nq, j, rf, p, q, delta))
{ {
return false ; return false ;
......
Supports Markdown
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