Une nouvelle version du portail de gestion des comptes externes sera mise en production lundi 09 août. Elle permettra d'allonger la validité d'un compte externe jusqu'à 3 ans. Pour plus de détails sur cette version consulter : https://doc-si.inria.fr/x/FCeS

Commit 9622bd98 authored by Laurent Belcour's avatar Laurent Belcour
Browse files

Towards changing the vector class for ALTA

parent 8abedfd7
......@@ -7,6 +7,7 @@
#include <cstring>
#include <algorithm>
#ifdef OLD
/*! \brief A core implementation of a vector of double.
* \ingroup core
* \internal
......@@ -221,6 +222,16 @@ class vec : public std::vector<double>
} ;
#endif
#include <Eigen/Core>
typedef Eigen::VectorXd vec;
double norm(const vec& a);
vec normalize(const vec& a);
double dot(const vec& a, const vec& b);
//! \brief locate the first index of value v in vector vec. Complexity in
//! O(n) is the worst case.
......
TEMPLATE = lib
CONFIG *= static \
console
console \
eigen
DESTDIR = ../build
......@@ -19,7 +20,8 @@ HEADERS = args.h \
params.h \
clustering.h
SOURCES = plugins_manager.cpp \
SOURCES = common.cpp \
plugins_manager.cpp \
vertical_segment.cpp \
rational_function.cpp \
params.cpp \
......
......@@ -344,8 +344,7 @@ class compound_function: public nonlinear_function, public std::vector<nonlinear
{
int nb_params = this->nbParameters();
vec jac(nb_params*_nY);
jac.assign(nb_params*_nY, 0.0);
jac = vec::Zero(nb_params*_nY);
int start_i = 0;
......
......@@ -18,8 +18,8 @@ rational_function_1d::rational_function_1d(int np, int nq)
b.resize(nq);
}
rational_function_1d::rational_function_1d(const std::vector<double>& a,
const std::vector<double>& b) :
rational_function_1d::rational_function_1d(const vec& a,
const vec& b) :
a(a), b(b)
{
}
......@@ -28,11 +28,11 @@ void rational_function_1d::load(std::istream& in)
{
}
void rational_function_1d::update(const std::vector<double>& in_a,
const std::vector<double>& in_b)
void rational_function_1d::update(const vec& in_a,
const vec& in_b)
{
a.reserve(in_a.size()) ;
b.reserve(in_b.size()) ;
a.resize(in_a.size()) ;
b.resize(in_b.size()) ;
a = in_a ;
b = in_b ;
}
......@@ -501,8 +501,8 @@ void rational_function::save_matlab(const std::string& filename, const arguments
for(int j=0; j<dimY(); ++j)
{
rational_function_1d* rf = get(j);
std::vector<double> a = rf->getP();
std::vector<double> b = rf->getQ();
vec a = rf->getP();
vec b = rf->getQ();
// Export the numerator of the jth color channel
file << "\tp(" << j+1 << ",:) = ";
......@@ -616,8 +616,8 @@ void rational_function::save_cpp(const std::string& filename, const arguments& a
for(int j=0; j<dimY(); ++j)
{
rational_function_1d* rf = get(j);
std::vector<double> a = rf->getP();
std::vector<double> b = rf->getQ();
vec a = rf->getP();
vec b = rf->getQ();
// Export the numerator of the jth color channel
file << "\tp = ";
......@@ -711,8 +711,8 @@ void rational_function::save(const std::string& filename) const
for(int k=0; k<_nY; ++k)
{
rational_function_1d* rf = get(k);
std::vector<double> a = rf->getP();
std::vector<double> b = rf->getQ();
vec a = rf->getP();
vec b = rf->getQ();
for(unsigned int i=0; i<np; ++i)
{
......
......@@ -19,8 +19,8 @@ class rational_function_1d : public function
rational_function_1d() ;
rational_function_1d(int np, int nq) ;
rational_function_1d(const std::vector<double>& a,
const std::vector<double>& b) ;
rational_function_1d(const vec& a,
const vec& b) ;
virtual ~rational_function_1d() {}
// Overload the function operator
......@@ -39,8 +39,8 @@ class rational_function_1d : public function
virtual void load(std::istream& in);
// Update the function
virtual void update(const std::vector<double>& in_a,
const std::vector<double>& in_b) ;
virtual void update(const vec& in_a,
const vec& in_b) ;
// Resize the polynomial
virtual void resize(int np, int nq);
......@@ -49,8 +49,8 @@ class rational_function_1d : public function
virtual double getP(int i) const { return a[i]; }
virtual double getQ(int i) const { return b[i]; }
virtual std::vector<double> getP() const { return a; }
virtual std::vector<double> getQ() const { return b; }
virtual vec getP() const { return a; }
virtual vec getQ() const { return b; }
// STL stream ouput
friend std::ostream& operator<< (std::ostream& out,
......@@ -72,8 +72,7 @@ class rational_function_1d : public function
// Store the coefficients for the moment, I assume
// the functions to be polynomials.
std::vector<double> a ;
std::vector<double> b ;
vec a, b ;
} ;
class rational_function : public function
......
TEMPLATE = lib
CONFIG *= qt \
plugin
plugin \
eigen
DESTDIR = ../../build
......
TEMPLATE = lib
CONFIG *= plugin
CONFIG *= plugin \
eigen
DESTDIR = ../../build
......
......@@ -81,9 +81,8 @@ vec diffuse_function::parameters() const
res[i*3 + 0] = _kd[i];
}
#else
vec res(0);
vec res(1);
#endif
return res;
}
......@@ -119,7 +118,7 @@ vec diffuse_function::parametersJacobian(const vec& x) const
}
}
#else
vec jac(0);
vec jac(1);
#endif
return jac;
......
TEMPLATE = lib
CONFIG *= qt \
plugin
plugin \
eigen
DESTDIR = ../../build
......
TEMPLATE = lib
CONFIG *= plugin
CONFIG *= plugin \
eigen
DESTDIR = ../../build
......
TEMPLATE = lib
CONFIG *= qt \
plugin
plugin \
eigen
DESTDIR = ../../build
......
TEMPLATE = lib
CONFIG *= qt \
plugin
plugin \
eigen
DESTDIR = ../../build
......
......@@ -153,7 +153,6 @@ bool nonlinear_fitter_eigen::fit_data(const data* d, function* fit, const argume
x[i] = nf_x[i];
}
EigenFunctor functor(nf, d);
Eigen::LevenbergMarquardt<EigenFunctor> lm(functor);
......
......@@ -296,8 +296,8 @@ bool rational_fitter_cgal::fit_data(const vertical_segment* d, int np, int nq, i
if(solves_qp)
{
// Recopy the vector d
std::vector<double> p, q;
p.assign(np, 0.0) ; q.assign(nq, 0.0) ;
vec p, q;
p = vec::Zero(np) ; q = vec::Zero(nq) ;
for(int i=0; i<np+nq; ++i)
{
const double v = CGAL::to_double(*(s.variable_numerators_begin()+i)) ;
......
......@@ -200,7 +200,7 @@ bool rational_fitter_leastsquare::fit_data(const vertical_segment* d, int np, in
}
} // iterations
std::vector<double> p(np), q(nq);
vec p(np), q(nq);
Eigen::VectorXd::Map(&p[0], np) = pq.head(np);
Eigen::VectorXd::Map(&q[0], nq) = pq.tail(nq);
......
......@@ -312,17 +312,17 @@ bool rational_fitter_matlab::fit_data(const vertical_segment* d, int np, int nq,
double total = 0.0;
double* val = (double*)mxGetData(x) ;
std::vector<double> a, b;
vec a(np), b(nq);
for(int i=0; i<N; ++i)
{
total += val[i]*val[i] ;
if(i < np)
{
a.push_back(val[i]) ;
a[i] =val[i] ;
}
else
{
b.push_back(val[i]) ;
b[i] = val[i] ;
}
}
r->update(a, b) ;
......
......@@ -299,7 +299,7 @@ bool rational_fitter_quadprog::fit_data(const vertical_segment* dat, int np, int
if(solves_qp)
{
// Recopy the vector d
std::vector<double> p, q;
vec p(np), q(nq);
double norm = 0.0 ;
for(int i=0; i<np+nq; ++i)
{
......@@ -307,11 +307,11 @@ bool rational_fitter_quadprog::fit_data(const vertical_segment* dat, int np, int
norm += v*v ;
if(i < np)
{
p.push_back(v) ;
p[i] = v ;
}
else
{
q.push_back(v) ;
q[i - np] = v ;
}
}
......
......@@ -32,8 +32,8 @@ rational_function_chebychev_1d::rational_function_chebychev_1d(int np, int nq) :
{
}
rational_function_chebychev_1d::rational_function_chebychev_1d(const std::vector<double>& a,
const std::vector<double>& b) :
rational_function_chebychev_1d::rational_function_chebychev_1d(const vec& a,
const vec& b) :
rational_function_1d(a, b)
{
}
......@@ -119,8 +119,8 @@ void rational_function_chebychev::save_matlab(const std::string& filename, const
for(int j=0; j<dimY(); ++j)
{
rational_function_1d* rf = get(j);
std::vector<double> a = rf->getP();
std::vector<double> b = rf->getQ();
vec a = rf->getP();
vec b = rf->getQ();
const unsigned int np = a.size();
const unsigned int nq = b.size();
......@@ -226,8 +226,8 @@ void rational_function_chebychev::save_cpp(const std::string& filename, const ar
for(int j=0; j<dimY(); ++j)
{
rational_function_1d* rf = get(j);
std::vector<double> a = rf->getP();
std::vector<double> b = rf->getQ();
vec a = rf->getP();
vec b = rf->getQ();
const unsigned int np = a.size();
const unsigned int nq = b.size();
......@@ -300,8 +300,8 @@ void rational_function_chebychev::save(const std::string& filename) const
for(int k=0; k<_nY; ++k)
{
rational_function_1d* rf = get(k);
std::vector<double> a = rf->getP();
std::vector<double> b = rf->getQ();
vec a = rf->getP();
vec b = rf->getQ();
const unsigned int np = a.size();
const unsigned int nq = b.size();
......
......@@ -18,7 +18,7 @@ public: // methods
rational_function_chebychev_1d() ;
rational_function_chebychev_1d(int np, int nq) ;
rational_function_chebychev_1d(const std::vector<double>& a, const std::vector<double>& b) ;
rational_function_chebychev_1d(const vec& a, const vec& b) ;
virtual ~rational_function_chebychev_1d() {}
// Get the p_i and q_j function
......
TEMPLATE = lib
CONFIG *= qt \
plugin
plugin \
eigen
DESTDIR = ../../build
......
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