Commit 9b9c16e3 authored by Laurent Belcour's avatar Laurent Belcour
Browse files

Multidimensional fitting should be tested on bigger data

parent 24dab179
......@@ -21,8 +21,8 @@ class function //: public std::function<double(double)>
virtual int dimX() const { return _nX ; } ;
virtual int dimY() const { return _nY ; } ;
virtual int setDimX(int nX) { _nX = nX ; } ;
virtual int setDimY(int nY) { _nY = nY ; } ;
virtual void setDimX(int nX) { _nX = nX ; } ;
virtual void setDimY(int nY) { _nY = nY ; } ;
protected:
// Dimension of the function
......
......@@ -26,7 +26,7 @@ void rational_data::load(const std::string& filename, double min, double max)
// boost::regex e ("^([0-9]*\.?[0-9]+[\\t ]?)");
_nX = 0 ; _nY = 0 ;
std::vector<int> vs ;
std::vector<int> vs ; int current_vs = 0 ;
double x, y, dy ;
while(file.good())
......@@ -42,13 +42,12 @@ void rational_data::load(const std::string& filename, double min, double max)
std::string comment ;
linestream >> comment ;
std::cout << comment << std::endl ;
if(comment == std::string("DIM"))
{
linestream >> _nX >> _nY ;
vs.resize(dimY()) ;
vs.assign(dimY(), 0) ;
for(int k=0; k<dimY(); ++k)
{
vs[k] = 0 ;
......@@ -62,6 +61,12 @@ void rational_data::load(const std::string& filename, double min, double max)
_max[k] = -std::numeric_limits<double>::max() ;
}
}
else if(comment == std::string("VS"))
{
int t ;
linestream >> t ;
vs[current_vs] = t ; ++current_vs ;
}
continue ;
}
else if(line.empty()/*!boost::regex_match(line,e)*/)
......@@ -81,25 +86,36 @@ 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(vs[i] == 2)
{
linestream >> v[dimX() + dimY()+i] ;
linestream >> v[dimX() + 2*dimY()+i] ;
}
else if(vs[i] == 1)
{
double dt ;
linestream >> dt ;
v[dimX() + dimY()+i] = v[dimX() + i] - dt ;
v[dimX() + 2*dimY()+i] = v[dimX() + i] + dt ;
}
else
*/ {
{
// TODO Specify the delta in case
// Handle multiple dim
v[dimX() + dimY()+i] = v[dimX() + i] - 0.01f ;
v[dimX() + 2*dimY()+i] = v[dimX() + i] + 0.01f ;
v[dimX() + dimY()+i] = v[dimX() + i] - 0.01 ;
v[dimX() + 2*dimY()+i] = v[dimX() + i] + 0.01 ;
}
}
// 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)
for(int i=0; i<dimX(); ++i)
{
is_in = false ;
if(v[i] < min || v[i] > max)
{
is_in = false ;
}
}
if(!is_in)
{
......
......@@ -8,6 +8,4 @@ INCLUDEPATH += ../..
HEADERS = rational_data.h
SOURCES = rational_data.cpp
#LIBS += -lboost_regex
QMAKE_CXXFLAGS += -frounding-math -fPIC -g
QMAKE_CXXFLAGS += -frounding-math -fPIC
#include "rational_1d_fitter_cgal.h"
#include "rational_fitter_cgal.h"
#include <CGAL/basic.h>
#include <CGAL/QP_models.h>
......@@ -41,12 +41,13 @@ bool rational_fitter_cgal::fit_data(const data* d, function*& fit)
}
std::cout << "<<INFO>> fitt using np = " << temp_np << " & nq = " << temp_nq << " failed\r" ;
std::cout.flush() ;
if(temp_np <= _max_np)
if(temp_np < _max_np)
{
++temp_np ;
}
if(temp_nq <= _max_nq)
if(temp_nq < _max_nq)
{
++temp_nq ;
}
......
TEMPLATE = lib
CONFIG *= qt \
plugin \
debug
eigen \
cgal \
# debug
DESTDIR = ../../build
INCLUDEPATH += ../rational_function ../rational_data ../.. \
# /home/belcour/Sources/Eigen/include/eigen3
HEADERS = rational_1d_fitter_cgal.h
SOURCES = rational_1d_fitter_cgal.cpp
INCLUDEPATH += ../rational_function \
../rational_data \
../..
LIBS += -lCGAL \
-L../build \
-lrational_function -lrational_data
HEADERS = rational_fitter_cgal.h
SOURCES = rational_fitter_cgal.cpp
QMAKE_CXXFLAGS += -frounding-math -fPIC -g
LIBS += -lCGAL \
-L../build \
-lrational_function \
-lrational_data
QMAKE_CXXFLAGS += -frounding-math -fPIC
......@@ -8,7 +8,5 @@ INCLUDEPATH += ../..
HEADERS = rational_function.h
SOURCES = rational_function.cpp
#LIBS += -lboost_regex
QMAKE_CXXFLAGS += -frounding-math -fPIC -rdynamic -g
QMAKE_CXXFLAGS += -frounding-math -fPIC
DESTDIR = ../../build
CONFIG += debug plugin
#CONFIG += debug
QT +=
INCLUDEPATH += ../../ ../../libs/rational_1d \
# /home/belcour/Sources/Eigen/include/eigen3
SOURCES += main.cpp
......
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