Commit 34643ef9 authored by Laurent Belcour's avatar Laurent Belcour
Browse files

Updating to remove C++11 depedancies

parent b83c9185
#include "rational_data.h"
#include <boost/regex.hpp>
#include <string>
#include <sstream>
#include <iostream>
#include <fstream>
#include <limits>
......@@ -16,7 +16,7 @@ void rational_data::load(const std::string& filename)
void rational_data::load(const std::string& filename, double min, double max)
{
std::ifstream file(filename) ;
std::ifstream file(filename.c_str()) ;
if(!file.is_open())
{
std::cerr << "<<ERROR>> unable to open file \"" << filename << "\"" << std::endl ;
......@@ -81,12 +81,12 @@ void rational_data::load(const std::string& filename, double min, double max)
{
// TODO, the firts case does not account for the
// dimension of the ouput vector
if(linestream.good())
/* if(linestream.good())
{
linestream >> v[dimX() + dimY()+i] ;
}
else
{
*/ {
// TODO Specify the delta in case
// Handle multiple dim
v[dimX() + dimY()+i] = v[dimX() + i] - 0.01f ;
......@@ -96,7 +96,12 @@ void rational_data::load(const std::string& filename, double min, double max)
// If data is not in the interval of fit
// TODO: Update to more dims
bool is_in = true ;
if(v[0] < min || v[0] > max)
{
is_in = false ;
}
if(!is_in)
{
continue ;
}
......
#pragma once
// Include STL
#include <functional>
#include <vector>
#include <string>
#include <tuple>
// Interface
#include <QObject>
......
......@@ -2,12 +2,12 @@ TEMPLATE = lib
CONFIG *= qt \
plugin
DESTDIR = ../build
DESTDIR = ../../build
INCLUDEPATH += ../..
HEADERS = rational_data.h
SOURCES = rational_data.cpp
LIBS += -lboost_regex
#LIBS += -lboost_regex
QMAKE_CXXFLAGS += -std=c++11 -frounding-math -fPIC -g
QMAKE_CXXFLAGS += -frounding-math -fPIC -g
......@@ -71,7 +71,7 @@ bool rational_fitter_cgal::fit_data(const data* dat, int np, int nq, function*&
rational_function* r = dynamic_cast<rational_function*>(rf) ;
const rational_data* d = dynamic_cast<const rational_data*>(dat) ;
if(r == nullptr || d == nullptr)
if(r == NULL || d == NULL)
{
std::cerr << "<<ERROR>> not passing the correct class to the fitter" << std::endl ;
return false ;
......@@ -140,7 +140,15 @@ bool rational_fitter_cgal::fit_data(const data* dat, int np, int nq, function*&
ci(i) = sqrt(a0_norm) ;
ci(i+d->size()) = sqrt(a1_norm) ;
}
#ifdef DEBUG
for(int j=0; j<d->size()*2; ++j)
{
for(int i=0; i<np+nq; ++i)
std::cout << CI(i,j) << "\t";
std::cout << std::endl;
}
std::cout << std::endl ;
#endif
// Update the ci column with the delta parameter
// (See Celis et al. 2007 p.12)
Eigen::JacobiSVD<Eigen::MatrixXd> svd(CI);
......@@ -262,7 +270,7 @@ bool rational_fitter_cgal::fit_data(const data* dat, int np, int nq, function*&
}
}
if(r != nullptr)
if(r != NULL)
{
delete r ;
}
......
#pragma once
// Include STL
#include <functional>
#include <vector>
#include <string>
#include <tuple>
// Interface
#include <QObject>
......
......@@ -3,15 +3,16 @@ CONFIG *= qt \
plugin \
debug
DESTDIR = ../build
DESTDIR = ../../build
INCLUDEPATH += ../rational_function ../rational_data ../.. /home/belcour/Sources/Eigen/include/eigen3
INCLUDEPATH += ../rational_function ../rational_data ../.. \
# /home/belcour/Sources/Eigen/include/eigen3
HEADERS = rational_1d_fitter_cgal.h
SOURCES = rational_1d_fitter_cgal.cpp
LIBS += -lCGAL -lboost_regex \
LIBS += -lCGAL \
-L../build \
-lrational_function -lrational_data
QMAKE_CXXFLAGS += -std=c++11 -frounding-math -fPIC -g
QMAKE_CXXFLAGS += -frounding-math -fPIC -g
......@@ -54,7 +54,12 @@ vec rational_function::operator()(const vec& x) const
// Get the p_i and q_j function
double rational_function::p(const vec& x, int i) const
{
std::vector<int> deg ; deg.assign(dimY(), 0) ;
if(dimX() == 1)
{
return pow(x[0], i) ;
}
std::vector<int> deg ; deg.assign(dimX(), 0) ;
double res = 1.0 ;
......@@ -63,13 +68,14 @@ double rational_function::p(const vec& x, int i) const
int temp_i = i ;
int temp_c ;
while(temp_i != 0)
while(temp_i > 1)
{
temp_c = (temp_i-1) % dimX() ;
temp_c = temp_i % dimX() ;
temp_i = (temp_i - temp_c) / dimX() ;
deg[temp_c] += 1 ;
}
deg[0] += temp_i ;
for(int k=0; k<dimX(); ++k)
{
......@@ -80,7 +86,12 @@ double rational_function::p(const vec& x, int i) const
}
double rational_function::q(const vec& x, int i) const
{
std::vector<int> deg ; deg.assign(dimY(), 0) ;
if(dimX() == 1)
{
return pow(x[0], i) ;
}
std::vector<int> deg ; deg.assign(dimX(), 0) ;
double res = 1.0 ;
......@@ -89,13 +100,14 @@ double rational_function::q(const vec& x, int i) const
int temp_i = i ;
int temp_c ;
while(temp_i != 0)
while(temp_i > 1)
{
temp_c = (temp_i-1) % dimX() ;
temp_c = temp_i % dimX() ;
temp_i = (temp_i - temp_c) / dimX() ;
deg[temp_c] += 1 ;
}
deg[0] += temp_i ;
for(int k=0; k<dimX(); ++k)
{
......
#pragma once
// Include STL
#include <functional>
#include <vector>
#include <string>
#include <tuple>
// Interface
#include <QObject>
......
......@@ -2,13 +2,13 @@ TEMPLATE = lib
CONFIG *= qt \
plugin
DESTDIR = ../build
DESTDIR = ../../build
INCLUDEPATH += ../..
HEADERS = rational_function.h
SOURCES = rational_function.cpp
LIBS += -lboost_regex
#LIBS += -lboost_regex
QMAKE_CXXFLAGS += -std=c++11 -frounding-math -fPIC -rdynamic -g
QMAKE_CXXFLAGS += -frounding-math -fPIC -rdynamic -g
......@@ -39,12 +39,12 @@ int main(int argc, char** argv)
QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
QObject *plugin = loader.instance();
if (plugin != nullptr)
if (plugin != NULL)
{
#ifdef DEBUG
std::cout << "<<DEBUG>> loading plugin " << fileName.toStdString() << std::endl ;
#endif
if(dynamic_cast<function*>(plugin) != nullptr)
if(dynamic_cast<function*>(plugin) != NULL)
{
#ifdef DEBUG
std::cout << "<<DEBUG>> -> it is a function" << std::endl ;
......@@ -52,7 +52,7 @@ int main(int argc, char** argv)
functions.push_back(dynamic_cast<function*>(plugin)) ;
}
if(dynamic_cast<data*>(plugin) != nullptr)
if(dynamic_cast<data*>(plugin) != NULL)
{
#ifdef DEBUG
std::cout << "<<DEBUG>> -> it is a data loader" << std::endl ;
......@@ -60,7 +60,7 @@ int main(int argc, char** argv)
datas.push_back(dynamic_cast<data*>(plugin)) ;
}
if(dynamic_cast<fitter*>(plugin) != nullptr)
if(dynamic_cast<fitter*>(plugin) != NULL)
{
#ifdef DEBUG
std::cout << "<<DEBUG>> -> it is a fitter" << std::endl ;
......@@ -108,7 +108,7 @@ int main(int argc, char** argv)
// Display the result
if(is_fitted)
{
std::ofstream file(args["output"], std::ios_base::trunc);
std::ofstream file(args["output"].c_str(), std::ios_base::trunc);
const double dt = (d->max()[0] - d->min()[0]) / 100.0f ;
for(double x=d->min()[0]; x<=d->max()[0]; x+=dt)
{
......
DEST_DIR = ../bin
DESTDIR = ../../build
CONFIG += debug plugin
QT +=
INCLUDEPATH += ../../ ../../libs/rational_1d /home/belcour/Sources/Eigen/include/eigen3
INCLUDEPATH += ../../ ../../libs/rational_1d \
# /home/belcour/Sources/Eigen/include/eigen3
SOURCES += main.cpp
QMAKE_CXXFLAGS += -std=c++11 -frounding-math -fPIC
QMAKE_LFLAGS += -Wl,-rpath="/home/belcour/Projects/alta/sources/plugins/build"
QMAKE_CXXFLAGS += -frounding-math -fPIC
QMAKE_LFLAGS += -Wl,-rpath='\$\$ORIGIN:.:./build:./plugins'
LIBS += -lCGAL -lboost_regex
LIBS += -lCGAL
DEST_DIR = ../bin
CONFIG += debug plugin
CONFIG += plugin \
# debug
QT +=
INCLUDEPATH += ../../ ../../plugins/rational_1d /home/belcour/Sources/Eigen/include/eigen3
......
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