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

Quadprog parallel runs on non OpenMP friendly systems. Warning, it is slow.

parent 11c1f144
......@@ -56,7 +56,8 @@ NLOPT_DIR = ['#external/build/lib']
NLOPT_LIBS = ['nlopt']
NLOPT_OPT_LIBS = []
# MATLAB library and Engine
## MATLAB library and Engine
##
MATLAB_INC = ['/home/pac/MATLAB/R2013b/extern/include/']
MATLAB_DIR = ['/home/pac/MATLAB/R2013b/bin/glnxa64/']
MATLAB_LIBS = ['']
MATLAB_LIBS = ['engine']
import os
Import('env')
env = env.Clone()
if env.GetOption('clean'):
print "Nothing to do in external"
......
Import('env')
env = env.Clone()
env.AppendUnique(CPPPATH = env['MATLAB_INC'])
env.AppendUnique(LIBPATH = env['MATLAB_DIR'])
env.AppendUnique(LIBS = env['MATLAB_LIBS'])
env.AppendUnique(LIBS = ['core'])
conf = Configure(env)
sources = ['rational_fitter.cpp']
if conf.CheckLib(env['MATLAB_LIBS']):
env.SharedLibrary('../../build/rational_fitter_matlab', sources)
#end
conf.Finish()
......@@ -4,15 +4,19 @@ env = env.Clone()
env.AppendUnique(CPPPATH = env['QUADPROG_INC'])
env.AppendUnique(LIBPATH = env['QUADPROG_DIR'])
env.AppendUnique(LIBS = env['QUADPROG_LIBS'])
env.AppendUnique(CCFLAGS = env['OPENMP_FLAGS'])
env.AppendUnique(LIBS = env['OPENMP_LIBS'])
env.AppendUnique(LIBS = ['core'])
conf = Configure(env)
sources = ['rational_fitter.cpp']
if conf.CheckLib(env['QUADPROG_LIBS']) and conf.CheckLib(env['OPENMP_LIBS']):
if conf.CheckLib(env['QUADPROG_LIBS']):
env.AppendUnique(CCFLAGS = env['OPENMP_FLAGS'])
if conf.CheckLib(env['OPENMP_LIBS']):
env.AppendUnique(LIBS = env['OPENMP_LIBS'])
#end
env.SharedLibrary('../../build/rational_fitter_parallel', sources)
#end
conf.Finish()
......@@ -218,9 +218,10 @@ bool rational_fitter_quadprog::fit_data(const vertical_segment* d, int np, int n
}
#endif
/*
// Update the ci column with the delta parameter
// (See Celis et al. 2007 p.12)
Eigen::JacobiSVD<Eigen::MatrixXd, Eigen::HouseholderQRPreconditioner> svd(eCI, Eigen::ComputeThinU | Eigen::ComputeThinV);
Eigen::JacobiSVD<Eigen::MatrixXd, Eigen::HouseholderQRPreconditioner> svd(eCI);
const double sigma_m = svd.singularValues()(std::min(2*M, N)-1) ;
const double sigma_M = svd.singularValues()(0) ;
......@@ -235,6 +236,10 @@ bool rational_fitter_quadprog::fit_data(const vertical_segment* d, int np, int n
double delta = sigma_m / sigma_M ;
#ifndef DEBUG
std::cout << "<<DEBUG>> delta factor: " << sigma_m << " / " << sigma_M << " = " << delta << std::endl ;
#endif
if(isnan(delta) || (std::abs(delta) == std::numeric_limits<double>::infinity()))
{
std::cerr << "<<ERROR>> delta factor is NaN of Inf" << std::endl ;
......@@ -244,10 +249,9 @@ bool rational_fitter_quadprog::fit_data(const vertical_segment* d, int np, int n
{
delta = 1.0 ;
}
#ifndef DEBUG
std::cout << "<<DEBUG>> delta factor: " << sigma_m << " / " << sigma_M << " = " << delta << std::endl ;
#endif
/*/
const double delta = 1.0;
//*/
for(int i=0; i<2*M; ++i)
{
ci[i] = ci[i] * delta ;
......
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