Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
alta
alta
Commits
9622bd98
Commit
9622bd98
authored
Aug 28, 2013
by
Laurent Belcour
Browse files
Towards changing the vector class for ALTA
parent
8abedfd7
Changes
29
Hide whitespace changes
Inline
Side-by-side
sources/core/common.h
View file @
9622bd98
...
...
@@ -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.
...
...
sources/core/core.pro
View file @
9622bd98
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
\
...
...
sources/core/function.h
View file @
9622bd98
...
...
@@ -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
;
...
...
sources/core/rational_function.cpp
View file @
9622bd98
...
...
@@ -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
.
res
erv
e
(
in_a
.
size
())
;
b
.
res
erv
e
(
in_b
.
size
())
;
a
.
res
iz
e
(
in_a
.
size
())
;
b
.
res
iz
e
(
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
<<
"
\t
p("
<<
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
<<
"
\t
p = "
;
...
...
@@ -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
)
{
...
...
sources/core/rational_function.h
View file @
9622bd98
...
...
@@ -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
...
...
sources/plugins/data_merl/data_merl.pro
View file @
9622bd98
TEMPLATE
=
lib
CONFIG
*=
qt
\
plugin
plugin
\
eigen
DESTDIR
=
..
/../
build
...
...
sources/plugins/nonlinear_fresnel_schlick/nonlinear_fresnel_schlick.pro
View file @
9622bd98
TEMPLATE
=
lib
CONFIG
*=
plugin
CONFIG
*=
plugin
\
eigen
DESTDIR
=
..
/../
build
...
...
sources/plugins/nonlinear_function_diffuse/function.cpp
View file @
9622bd98
...
...
@@ -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
;
...
...
sources/plugins/nonlinear_function_diffuse/nonlinear_function_diffuse.pro
View file @
9622bd98
TEMPLATE
=
lib
CONFIG
*=
qt
\
plugin
plugin
\
eigen
DESTDIR
=
..
/../
build
...
...
sources/plugins/nonlinear_function_isotropic_lafortune/nonlinear_function_isotropic_lafortune.pro
View file @
9622bd98
TEMPLATE
=
lib
CONFIG
*=
plugin
CONFIG
*=
plugin
\
eigen
DESTDIR
=
..
/../
build
...
...
sources/plugins/nonlinear_function_lafortune/nonlinear_function_lafortune.pro
View file @
9622bd98
TEMPLATE
=
lib
CONFIG
*=
qt
\
plugin
plugin
\
eigen
DESTDIR
=
..
/../
build
...
...
sources/plugins/nonlinear_function_phong/nonlinear_function_phong.pro
View file @
9622bd98
TEMPLATE
=
lib
CONFIG
*=
qt
\
plugin
plugin
\
eigen
DESTDIR
=
..
/../
build
...
...
sources/plugins/nonlinear_levenberg_eigen/fitter.cpp
View file @
9622bd98
...
...
@@ -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
);
...
...
sources/plugins/rational_fitter_cgal/rational_fitter_cgal.cpp
View file @
9622bd98
...
...
@@ -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
))
;
...
...
sources/plugins/rational_fitter_leastsquare/rational_fitter.cpp
View file @
9622bd98
...
...
@@ -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
);
...
...
sources/plugins/rational_fitter_matlab/rational_fitter.cpp
View file @
9622bd98
...
...
@@ -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
)
;
...
...
sources/plugins/rational_fitter_quadprog/rational_fitter.cpp
View file @
9622bd98
...
...
@@ -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
;
}
}
...
...
sources/plugins/rational_function_chebychev/rational_function.cpp
View file @
9622bd98
...
...
@@ -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
();
...
...
sources/plugins/rational_function_chebychev/rational_function.h
View file @
9622bd98
...
...
@@ -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
...
...
sources/plugins/rational_function_chebychev/rational_function_chebychev.pro
View file @
9622bd98
TEMPLATE
=
lib
CONFIG
*=
qt
\
plugin
plugin
\
eigen
DESTDIR
=
..
/../
build
...
...
Prev
1
2
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment