Olena-patches
Threads by month
- ----- 2025 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
March 2008
- 12 participants
- 83 discussions
19 Mar '08
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
Icp : n dim, refactored, uses p_array, vec -> rounded point proc.
* mln/core/point.hh: Fix convertion to vec.
* mln/algebra/quat.hh: Fix namespace.
* mln/algebra/vec.hh: add to_point procedure.
* sandbox/jardonnet/test/icp.cc,
* sandbox/jardonnet/registration/quat7.hh,
* sandbox/jardonnet/registration/cloud.hh,
* sandbox/jardonnet/registration/jacobi.hh,
* sandbox/jardonnet/registration/icp.hh,
* sandbox/jardonnet/registration/projection.hh,
* sandbox/jardonnet/registration/quat/all.hh,
* sandbox/jardonnet/registration/quat/rotation.hh: Update for p_array and n dim (not ready yet).
* sandbox/jardonnet/registration/quat/interpol.hh: Remove. Provided by qut.hh
mln/algebra/quat.hh | 24 ++++-----
mln/algebra/vec.hh | 12 ++++
sandbox/jardonnet/registration/cloud.hh | 37 ++++++++------
sandbox/jardonnet/registration/icp.hh | 35 ++++++++------
sandbox/jardonnet/registration/jacobi.hh | 10 ++--
sandbox/jardonnet/registration/projection.hh | 33 ++++++-------
sandbox/jardonnet/registration/quat/all.hh | 1
sandbox/jardonnet/registration/quat/rotation.hh | 21 +++++---
sandbox/jardonnet/registration/quat7.hh | 60 ++++++++++++++----------
sandbox/jardonnet/test/icp.cc | 4 -
10 files changed, 136 insertions(+), 101 deletions(-)
Index: mln/core/point.hh
Index: mln/algebra/quat.hh
--- mln/algebra/quat.hh (revision 1791)
+++ mln/algebra/quat.hh (working copy)
@@ -30,7 +30,7 @@
/*! \file mln/algebra/quat.hh
*
- * \brief Define a class for quaternion values.
+ * \brief Define a class for quaternion algebra values.
*/
# include <cmath>
@@ -44,12 +44,13 @@
# include <mln/algebra/vec.hh>
# include <mln/norm/l2.hh>
+//FIXME: pow, exp etc... are def here and in value::...
namespace mln
{
// Fwd decls.
- namespace value { class quat; }
+ namespace algebra { class quat; }
namespace literal { struct zero_t; struct one_t; }
@@ -114,16 +115,15 @@
- namespace value
+ namespace algebra
{
- // FIXME doesn't compile
-
+ // FIXME value::Vectorial ??? value ???
class quat
:
- public Vectorial< quat >
+ public value::Vectorial< quat >
,
- public internal::value_like_< algebra::vec<4, float>, // Equivalent.
+ public value::internal::value_like_< algebra::vec<4, float>, // Equivalent.
algebra::vec<4, float>, // Encoding.
algebra::vec<4, float>, // Interoperation.
quat > // Exact.
@@ -606,7 +606,7 @@
quat slerp_2(const quat& p, const quat& q, float h)
{
assert(interpol_ok(p, q, h));
- quat tmp = p * value::pow(p.conj() * q, h);
+ quat tmp = p * pow(p.conj() * q, h);
assert(about_equal(tmp, slerp(p, q, h)));
return tmp;
}
@@ -615,7 +615,7 @@
quat slerp_3(const quat& p, const quat& q, float h)
{
assert(interpol_ok(p, q, h));
- quat tmp = value::pow(p * q.conj(), 1 - h) * q;
+ quat tmp = pow(p * q.conj(), 1 - h) * q;
assert(about_equal(tmp, slerp(p, q, h)));
return tmp;
}
@@ -624,7 +624,7 @@
quat slerp_4(const quat& p, const quat& q, float h)
{
assert(interpol_ok(p, q, h));
- quat tmp = value::pow(q * p.conj(), h) * p;
+ quat tmp = pow(q * p.conj(), h) * p;
assert(about_equal(tmp, slerp(p, q, h)));
return tmp;
}
@@ -633,7 +633,7 @@
quat slerp_5(const quat& p, const quat& q, float h)
{
assert(interpol_ok(p, q, h));
- quat tmp = q * value::pow(q.conj() * p, 1 - h);
+ quat tmp = q * pow(q.conj() * p, 1 - h);
assert(about_equal(tmp, slerp(p, q, h)));
return tmp;
}
@@ -641,7 +641,7 @@
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace mln::value
+ } // end of namespace mln::algebra
} // end of namespace mln
Index: mln/algebra/vec.hh
--- mln/algebra/vec.hh (revision 1791)
+++ mln/algebra/vec.hh (working copy)
@@ -549,6 +549,18 @@
return tmp;
}
+
+ template <typename P, unsigned n>
+ inline
+ P
+ to_point(const vec<n,float>& v)
+ {
+ P tmp;
+ for (unsigned i = 0; i < P::dim; ++i)
+ tmp[i] = round(v[i]);
+ return tmp;
+ }
+
# endif // MLN_INCLUDE_ONLY
} // end of namespace mln::algebra
Index: sandbox/jardonnet/test/icp.cc
--- sandbox/jardonnet/test/icp.cc (revision 1791)
+++ sandbox/jardonnet/test/icp.cc (working copy)
@@ -1,4 +1,4 @@
-#include <mln/core/image2d.hh>
+#include <mln/core/image3d.hh>
#include <mln/io/ppm/load.hh>
#include <mln/io/ppm/save.hh>
@@ -9,7 +9,7 @@
{
using namespace mln;
- image2d< value::rgb8 > img;
+ image3d< value::rgb8 > img;
registration::icp(img,img);
}
Index: sandbox/jardonnet/registration/quat7.hh
--- sandbox/jardonnet/registration/quat7.hh (revision 1791)
+++ sandbox/jardonnet/registration/quat7.hh (working copy)
@@ -6,6 +6,7 @@
# include <algorithm>
# include <mln/algebra/mat.hh>
+# include <mln/core/p_array.hh>
# include "quat/all.hh"
# include "jacobi.hh"
@@ -49,16 +50,17 @@
namespace mln
{
+ template <unsigned n>
struct quat7
{
- value::quat _qR;
- vec3f _qT;
+ algebra::quat _qR;
+ algebra::vec<n,float> _qT;
quat7()
{
}
- quat7(const value::quat& qR, const vec3f& qT) :
+ quat7(const algebra::quat& qR, const algebra::vec<n,float>& qT) :
_qR(qR),
_qT(qT)
{
@@ -76,19 +78,21 @@
// quat7 is an object-function
- vec3f operator()(const vec3f& v) const
+ algebra::vec<n,float> operator()(const algebra::vec<n,float>& v) const
{
return rotate(_qR, v) + _qT;
}
- void apply_on(const std::vector< vec3f >& input, std::vector< vec3f >& output) const
+ template <typename P>
+ void apply_on(const p_array<P>& input, p_array<P>& output) const
{
- assert(input.size() == output.size());
+ assert(input.npoints() == output.npoints());
assert(_qR.is_unit());
- std::transform(input.begin(), input.end(),
- output.begin(),
- *this);
+ //FIXME utiliser equivalent pour p_array
+ //std::transform(input.begin(), input.end(),
+ // output.begin(),
+ // *this);
}
};
@@ -107,42 +111,48 @@
}
- quat7 match(const vecs_t& P,
- const vec3f& mu_P,
- const vecs_t& Xk,
- const vec3f& mu_Xk)
+ template <typename P>
+ quat7<P::dim> match(const p_array<P>& C,
+ const algebra::vec<P::dim,float>& mu_C,
+ const p_array<P>& Xk,
+ const algebra::vec<P::dim,float>& mu_Xk)
{
- assert(P.size() == Xk.size());
+ assert(C.npoints() == Xk.npoints());
// qR
- algebra::mat<3,3,float> Ck;
- for (unsigned i = 0; i < P.size(); ++i)
- Ck += make::mat(P[i] - mu_P) * trans(make::mat(Xk[i] - mu_Xk));
- Ck /= P.size();
+ //FIXME : use P::dim ?
+ algebra::mat<P::dim,P::dim,float> Mk;
+ for (unsigned i = 0; i < C.npoints(); ++i)
+ {
+ algebra::vec<P::dim,float> Ci = C[i];
+ algebra::vec<P::dim,float> Xki = Xki;
+ Mk += make::mat(Ci - mu_C) * trans(make::mat(Xki - mu_Xk));
+ }
+ Mk /= C.npoints();
- const algebra::mat<3,3,float> Ak = Ck - trans(Ck);
+ const algebra::mat<P::dim,P::dim,float> Ak = Mk - trans(Mk);
const float v[3] = {Ak(1,2), Ak(2,0), Ak(0,1)};
const algebra::mat<3,1,float> D = make::mat<3,1,3,float>(v); // FIXME why <...>
algebra::mat<4,4,float> Qk;
- Qk(0,0) = tr(Ck);
+ Qk(0,0) = tr(Mk);
put(trans(D), 0,1, Qk);
put(D, 1,0, Qk);
- put(Ck + trans(Ck) - algebra::mat<3,3,float>::identity() * tr(Ck), 1,1, Qk);
+ put(Mk + trans(Mk) - algebra::mat<P::dim,P::dim,float>::identity() * tr(Mk), 1,1, Qk);
- value::quat qR;
+ algebra::quat qR;
jacobi(Qk, qR);
// qT
- const vec3f qT = mu_Xk - rotate(qR, mu_P);
+ const algebra::vec<P::dim,float> qT = mu_Xk - rotate(qR, mu_C);
- return quat7(qR, qT);
+ return quat7<P::dim>(qR, qT);
}
-}
+} //end of namespace mln
#endif // ndef QUAT7_HH
Index: sandbox/jardonnet/registration/cloud.hh
--- sandbox/jardonnet/registration/cloud.hh (revision 1791)
+++ sandbox/jardonnet/registration/cloud.hh (working copy)
@@ -8,6 +8,7 @@
# include <sstream>
# include <mln/algebra/vec.hh>
+# include <mln/core/p_array.hh>
namespace mln
{
@@ -15,32 +16,36 @@
namespace registration
{
- typedef algebra::vec<3, float> vec3f;
-
-
- vec3f center(const std::vector< vec3f >& vecs)
+ template <typename P>
+ P center(const p_array<P>& a)
+ {
+ algebra::vec<P::dim,float> c;
+ for (size_t i = 0; i < a.npoints(); ++i)
{
- vec3f c;
- for (size_t i = 0; i < vecs.size(); ++i)
- c += vecs[i];
- return c / vecs.size();
+ algebra::vec<P::dim,float> ai = a[i];
+ c += ai;
+ }
+
+ return algebra::to_point<P>(c / a.npoints());
}
- // FIXME : move
- float sqr_norm(const vec3f& v)
+ // FIXME : move //exist for P?
+ template <typename P>
+ float sqr_norm(const P& v)
{
return v[1] * v[1] + v[2] * v[2] + v[3] * v[3];
}
- float rms(const std::vector< vec3f >& vecs1,
- const std::vector< vec3f >& vecs2)
+ template <typename P>
+ float rms(const p_array<P>& a1,
+ const p_array<P>& a2)
{
- assert(vecs1.size() == vecs2.size());
+ assert(a1.npoints() == a2.npoints());
float f = 0.f;
- for (size_t i = 0; i < vecs1.size(); ++i)
- f += sqr_norm(vecs1[i] - vecs2[i]);
- return f / vecs1.size();
+ for (size_t i = 0; i < a1.npoints(); ++i)
+ f += sqr_norm(a1[i] - a2[i]);
+ return f / a1.npoints();
}
}
Index: sandbox/jardonnet/registration/jacobi.hh
--- sandbox/jardonnet/registration/jacobi.hh (revision 1791)
+++ sandbox/jardonnet/registration/jacobi.hh (working copy)
@@ -7,14 +7,16 @@
// from num. rec. in C
+namespace mln
+{
#define rotateJacobi(a,i,j,k,l) g=a(i,j);h=a(k,l);a(i,j)=g-s*(h+g*tau); \
a(k,l)=h+s*(g-h*tau);
-void jacobi(mln::algebra::mat<4,4,float> a, mln::value::quat& q)
+ void jacobi(algebra::mat<4,4,float> a, algebra::quat& q)
{
float dd, d[4];
- mln::algebra::mat<4,4,float> v;
+ algebra::mat<4,4,float> v;
int j,iq,ip,i = 0;
float tresh,theta,tau,t,sm,s,h,g,c,b[4],z[4];
for (ip=0;ip<4;ip++) {
@@ -39,7 +41,7 @@
iq = ip;
dd = d[ip];
}
- q = mln::value::quat(v(0,iq),
+ q = algebra::quat(v(0,iq),
v(1,iq),
v(2,iq),
v(3,iq));
@@ -103,6 +105,6 @@
}
}
-
+}
#endif // ndef JACOBI_HH
Index: sandbox/jardonnet/registration/icp.hh
--- sandbox/jardonnet/registration/icp.hh (revision 1791)
+++ sandbox/jardonnet/registration/icp.hh (working copy)
@@ -33,12 +33,12 @@
* \brief image registration
*/
-# include <mln/value/quat.hh>
+# include <mln/algebra/quat.hh>
# include <mln/algebra/vec.hh>
-typedef mln::algebra::vec<3, float> vec3f;
-typedef std::vector< vec3f > vecs_t;
+//typedef mln::algebra::vec<3, float> vec3f;
+//typedef mln::p_array< vec3f > vecs_t;
#include "cloud.hh"
#include "quat7.hh"
@@ -65,39 +65,44 @@
namespace impl
{
+ template <typename P>
inline
void
- icp_(const vecs_t& P,
- const vecs_t& X)
+ icp_(const p_array<P>& C,
+ const p_array<P>& X)
{
trace::entering("registration::impl::icp_");
unsigned int k;
- quat7 old_qk, qk;
+ quat7<P::dim> old_qk, qk;
float err, err_bis;
- vecs_t Pk(P.size()), Xk(Pk.size());
- vec3f mu_P = center(P), mu_Xk;
+ p_array<P> Ck, Xk;
+ Ck.reserve(C.npoints());
+ Xk.reserve(Ck.npoints());
+ algebra::vec<P::dim,float> mu_C = center(C), mu_Xk;
const float epsilon = 1e-3;
//step 1
k = 0;
- Pk = P;
+ Ck = C;
do {
//step 2 FIXME : etienne
- projection::de_base(Pk, X, Xk, mu_Xk, err_bis);
+ projection::de_base(Ck, X, Xk, err_bis);
+
+ mu_Xk = center(Xk);
// step 3
old_qk = qk;
- qk = match(P, mu_P, Xk, mu_Xk);
+ qk = match(C, mu_C, Xk, mu_Xk);
// step 4
- qk.apply_on(P, Pk); // Pk+1 = qk(P)
+ qk.apply_on(C, Ck); // Ck+1 = qk(C)
- // err = d(Pk+1,Xk)
- err = rms(Pk, Xk);
+ // err = d(Ck+1,Xk)
+ err = rms(Ck, Xk);
++k;
} while (k < 3 || (qk - old_qk).sqr_norm() > epsilon);
@@ -119,7 +124,7 @@
mln_precondition(exact(cloud).has_data());
mln_precondition(exact(surface).has_data());
- vecs_t a,b; // FIXME : to built.
+ p_array<mln_point(I)> a,b; // FIXME : to built.
impl::icp_(a, b);
Index: sandbox/jardonnet/registration/projection.hh
--- sandbox/jardonnet/registration/projection.hh (revision 1791)
+++ sandbox/jardonnet/registration/projection.hh (working copy)
@@ -10,40 +10,37 @@
namespace projection
{
- template <class Pk_t, class X_t, class Xk_t>
+ template <typename P>
void de_base(// input
- const Pk_t& Pk,
- const X_t& X,
+ const p_array<P>& Ck,
+ const p_array<P>& X,
// inout
- Xk_t& Xk,
- // output
- algebra::vec<3, float>& mu_Xk,
+ p_array<P>& Xk,
float& err)
{
- assert(Pk.size() == Xk.size());
+ assert(Ck.npoints() == Xk.npoints());
err = 0.f;
- mu_Xk = make::vec(0,0,0);
- for (size_t i = 0; i < Pk.size(); ++i)
+ for (size_t i = 0; i < Ck.npoints(); ++i)
{
- algebra::vec<3,float> best_x = X[0];
- float best_d = norm::l2(Pk[i] - best_x);
- for (size_t j = 1; j < X.size(); ++j)
+ algebra::vec<P::dim,float> Cki = Ck[i];
+ algebra::vec<P::dim,float> best_x = X[0];
+ float best_d = norm::l2(Cki - best_x);
+ for (size_t j = 1; j < X.npoints(); ++j)
{
- float d = norm::l2(Pk[i] - X[j]);
+ algebra::vec<P::dim,float> Xj = X[j];
+ float d = norm::l2(Cki - Xj);
if (d < best_d)
{
best_d = d;
- best_x = X[j];
+ best_x = Xj;
}
}
- Xk[i] = best_x;
- mu_Xk += Xk[i];
+ Xk.hook_()[i] = algebra::to_point<P>(best_x);
err += best_d;
}
- mu_Xk /= Pk.size();
- err /= Pk.size();
+ err /= Ck.npoints();
}
}
Index: sandbox/jardonnet/registration/quat/all.hh
--- sandbox/jardonnet/registration/quat/all.hh (revision 1791)
+++ sandbox/jardonnet/registration/quat/all.hh (working copy)
@@ -2,7 +2,6 @@
# define QUAT_ALL_HH
-# include "interpol.hh"
# include "rotation.hh"
Index: sandbox/jardonnet/registration/quat/rotation.hh
--- sandbox/jardonnet/registration/quat/rotation.hh (revision 1791)
+++ sandbox/jardonnet/registration/quat/rotation.hh (working copy)
@@ -10,26 +10,30 @@
# include <mln/algebra/vec.hh>
# include <mln/make/vec.hh>
# include <mln/make/mat.hh>
-# include <mln/value/quat.hh>
+# include <mln/algebra/quat.hh>
+# include "misc.hh"
// FIXME: rotation should be an abstract class
// and derived classes encapsulate either a quaternion or a algebra::matrix
namespace mln
{
- vec3f rotate(const value::quat& q, const vec3f& p)
+ // FIXME : quat is not appriate here
+ template <unsigned n>
+ algebra::vec<n,float> rotate(const algebra::quat& q, const algebra::vec<n,float>& p)
{
- return (q * value::quat(0. ,p) * q.inv()).v();
+ return (q * algebra::quat(0. ,p) * q.inv()).v();
}
-
- bool check_rotation(const algebra::mat<3,3,float>& mat,
- const value::quat& q)
+ //FIXME : check if correct with n != 3
+ template <unsigned n>
+ bool check_rotation(const algebra::mat<n,n,float>& mat,
+ const algebra::quat& q)
{
assert(q.is_unit());
- vec3f
+ algebra::vec<n,float>
tmp = make::vec(rand(), rand(), rand()),
p = tmp / norm::l2(tmp),
p_rot_1 = rotate(q, p),
@@ -38,7 +42,8 @@
}
- algebra::mat<3,3,float> quat2mat(const value::quat& q)
+ //FIXME : switch to n dim.
+ algebra::mat<3,3,float> quat2mat(const algebra::quat& q)
{
assert(q.is_unit());
float
1
0
https://svn.lrde.epita.fr/svn/oln/trunk
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Update test on rgb/hsi conversion.
* milena/doc/tutorial/image_types.txt: Augment.
* milena/mln/value/rgb.hh (red_t, green_t, blue_t): New.
* milena/sandbox/vigouroux/moyenne.cc: Update.
doc/tutorial/image_types.txt | 80 ++++++++++++++++++++++++++++++++++++++++---
mln/value/rgb.hh | 4 ++
sandbox/vigouroux/moyenne.cc | 55 +++++++++++++----------------
3 files changed, 106 insertions(+), 33 deletions(-)
Index: milena/doc/tutorial/image_types.txt
--- milena/doc/tutorial/image_types.txt (revision 1790)
+++ milena/doc/tutorial/image_types.txt (working copy)
@@ -236,23 +236,95 @@
** methods
-*** values
+*** about the image variable
+**** has_data
+
+sig is:
bool has_data() const
-// FIXME: ? better name is is_allocated Nota bene: is_initialized means "has relevant data"!
+is "is_allocated" / "is_ready" a better name?
+
+Nota bene: "is_initialized" is consistent with the "initialize"
+routine; yet, it means "has relevant data", which is not really
+what it meant!
+
+**** name_it(string)
+
+Later...
+
+*** about definition domain
+
+**** domain
const pset& domain() const
+
+**** has & owns_
+
bool has(const psite& p) const
bool owns_(const psite& p) const
-const box_<point>& bbox() const
-std::size_t npoints() const
+Major question: is ima.has(p) equivalent to ima.domain().has(p)? or
+(if it is equivalent) do we feature a specific method has_extended()?
+
+Remember that in the case of a window, we want to write:
+
+for_all(p)
+ for_all(q)
+ if (ima.has(q))
+ ..
+
+so that there is a decoupling between a window and an image. More
+precisely a site q of a window centered at p can lay outside the
+definition domain, thus we need the "has" test. Such a decoupling is
+great since we can reuse some window or neighborhood definition over a
+domain which is compatible but restricted. This is also true for a
+graph on which some window (resp. neighborhood) is defined and can be
+applied over a sub-graph.
+
+The owns_ method is weird because it is only internal.
+
+**** suggestion
+
+"has(p)" means that there is a value for p. The set of sites p that
+verify "has(p) = true" is the "extended domain." Some image types
+features such an extension; some other do not.
+
+We always have:
+ ima.domain().has(p) => ima.has(p)
+
+If the image ima does not extend the definition domain, we have:
+ ima.domain().has(p) <=> ima.has(p)
+
+A site p is in the extended domain iff:
+ ima.has(p) and not ima.domain().has(p).
+
+*** about data access
rvalue operator()(const psite& p) const
lvalue operator()(const psite& p)
+*** about destination space
+
const vset& destination() const // was: values()
+*** obsolete methods
+
+**** bbox
+
+const box_<point>& bbox() const
+
+too ambiguous because we want a bounding box:
+- either precise or approximative (larger)
+- on a grid (if possible)
+- on the space (if sites are located)
+
+remember that some image have sites that are not localized (and then a
+bbox, if it exists, can only be a index range for instance)
+
+**** npoints
+
+std::size_t npoints() const
+is useless since the user can write ima.domain().nsites()
* properties
Index: milena/mln/value/rgb.hh
--- milena/mln/value/rgb.hh (revision 1790)
+++ milena/mln/value/rgb.hh (working copy)
@@ -162,6 +162,10 @@
{
public:
+ typedef int_u<n> red_t;
+ typedef int_u<n> green_t;
+ typedef int_u<n> blue_t;
+
/// \{ Acces to red/green/blue component.
int_u<n> red() const { return this->v_[0]; }
int_u<n>& red() { return this->v_[0]; }
Index: milena/sandbox/vigouroux/moyenne.cc
--- milena/sandbox/vigouroux/moyenne.cc (revision 1790)
+++ milena/sandbox/vigouroux/moyenne.cc (working copy)
@@ -1,7 +1,9 @@
#include "color/my_hsi.hh"
#include "color/rgb_to_hsi.hh"
-#include <mln/display/save_and_show.hh>
-#include <mln/value/rgb.hh>
+
+#include <cmath>
+
+#include <mln/core/image2d.hh>
#include <mln/value/rgb8.hh>
#include <mln/io/ppm/load.hh>
@@ -9,43 +11,43 @@
#include <mln/math/round.hh>
#include <mln/level/transform.hh>
-#include <mln/core/image2d.hh>
-#include <cmath>
-#include <iostream>
-template <typename I, typename O>
-float rms (const I& ima, O& out)
+template <typename I1, typename I2>
+float rms(const mln::Image<I1>& ima1_, const mln::Image<I2>& ima2_)
{
- mln::value::rgb8 c1;
- mln::value::rgb8 c2;
- float distred = 0;
- float distgreen = 0;
- float distblue = 0;
- float sum = 0;
- float nb = 0;
- float moy = 0;
+ const I1& ima1 = exact(ima1_);
+ const I2& ima2 = exact(ima2_);
+
+ mln_precondition(ima1.has_data() && ima2.has_data());
+
+ double sum = 0, nb = 0;
- mln_piter(I) p(out.domain());
+ mln_piter(I1) p(ima1.domain());
for_all(p)
{
- c1 = ima(p);
- c2 = out(p);
- distred = c2.red() - c1.red();
- distgreen = c2.green() - c1.green();
+ mln_value(I1) c1 = ima1(p);
+ mln_value(I2) c2 = ima2(p);
+ double
+ distred = c2.red() - c1.red(),
+ distgreen = c2.green() - c1.green(),
distblue = c2.blue() - c1.blue();
++nb;
sum += distred * distred + distblue * distblue + distgreen * distgreen;
}
- moy = std::sqrt(sum / nb);
- return (moy);
+
+ if (nb = 0)
+ return 0;
+
+ return std::sqrt(sum / nb);
}
+
int main()
{
using namespace mln;
- using value::int_u8;
+
image2d<value::rgb8> lena;
io::ppm::load(lena, "../../img/lena.ppm");
@@ -55,12 +57,7 @@
image2d<value::rgb8> lena_rgb = level::transform(lena_hsi,
fun::v2v::f_hsi_to_rgb_3x8);
-
- float err = rms(lena, lena_rgb);
-
+ double err = rms(lena, lena_rgb);
std::cout << "err: " << err << std::endl;
-
- display::save_and_show (lena_rgb, "display", 50);
- return (0);
}
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2008-03-19 Michel Pellegrin <pellegrin(a)lrde.epita.fr>
Fix some mistakes, Add.
* sandbox/pellegrin/set/core/line2d.hh,
* sandbox/pellegrin/set/core/p_array.hh,
* sandbox/pellegrin/set/core/p_bgraph.hh,
* sandbox/pellegrin/set/core/p_graph.hh,
* sandbox/pellegrin/set/core/p_line_graph.hh,
* sandbox/pellegrin/set/core/p_priority_queue.hh,
* sandbox/pellegrin/set/core/p_priority_queue_fast.hh,
* sandbox/pellegrin/set/core/p_priority_queue_fast_with_array.hh,
* sandbox/pellegrin/set/core/p_queue.hh,
* sandbox/pellegrin/set/core/p_queue_fast.hh,
* sandbox/pellegrin/set/core/p_set.hh,
* sandbox/pellegrin/set/core/pset_if.hh: traits are up-to-date
(or not, i have to check it with theo) and add the fwd decls.
* sandbox/pellegrin/set/core/p_run.hh: New.
* sandbox/pellegrin/set/core/p_runs.hh: New.
* sandbox/pellegrin/set/core/runs_psite.hh: Remove (not a point_set).
---
line2d.hh | 8
p_array.hh | 6
p_bgraph.hh | 18 -
p_graph.hh | 6
p_line_graph.hh | 15
p_priority_queue.hh | 8
p_priority_queue_fast.hh | 8
p_priority_queue_fast_with_array.hh | 10
p_queue.hh | 6
p_queue_fast.hh | 6
p_run.hh | 250 ++++++++++++++++
p_runs.hh | 541 ++++++++++++++++++++++++++++++++++++
p_set.hh | 6
pset_if.hh | 7
14 files changed, 860 insertions(+), 35 deletions(-)
Index: trunk/milena/sandbox/pellegrin/set/core/runs_psite.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/pellegrin/set/core/p_priority_queue_fast.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_priority_queue_fast.hh (revision 1789)
+++ trunk/milena/sandbox/pellegrin/set/core/p_priority_queue_fast.hh (revision 1790)
@@ -44,19 +44,23 @@
# include <mln/core/p_array_piter.hh>
# include <mln/accu/bbox.hh>
# include <mln/core/p_queue_fast.hh>
+# include <mln/trait/point_set.hh>
+
namespace mln
{
// Fwd decls.
+ template <typename P, typename T> struct p_priority_queue_fast;
template <typename P> struct p_array_fwd_piter_;
template <typename P> struct p_array_bkd_piter_;
namespace trait
{
- template <typename P>
- struct point_set_<line2d> : public default_point_set_<P>
+ template <typename P, typename T>
+ struct point_set_< p_priority_queue_fast<P, T> >
+ : public default_point_set_< p_priority_queue_fast<P, T> >
{
typedef trait::point_set::arity::unique arity;
typedef trait::point_set::has_speed::fast has_speed;
Index: trunk/milena/sandbox/pellegrin/set/core/p_bgraph.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_bgraph.hh (revision 1789)
+++ trunk/milena/sandbox/pellegrin/set/core/p_bgraph.hh (revision 1790)
@@ -25,8 +25,11 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_CORE_BGRAPH_P_HH
-# define MLN_CORE_BGRAPH_P_HH
+#ifndef MLN_CORE_P_BGRAPH_HH
+# define MLN_CORE_P_BGRAPH_HH
+
+/// \file mln/core/p_bgraph.hh
+/// \brief Definition of a point set based on a boost graph.
# include <utility>
@@ -36,22 +39,21 @@
# include <mln/util/internal/boost_graph.hh>
# include <mln/core/bgraph_psite.hh>
# include <mln/core/p_bgraph_piter.hh>
+# include <mln/trait/point_set.hh>
-
-/// \file mln/core/p_bgraph.hh
-/// \brief Definition of a point set based on a boost graph.
-
namespace mln
{
+ // Fwd decls.
+ template <typename P> struct p_bgraph;
template<typename P> class p_bgraph_piter_;
namespace trait
{
template <typename P>
- struct point_set_<line2d> : public default_point_set_<P>
+ struct point_set_< p_bgraph<P> > : public default_point_set_< p_bgraph<P> >
{
typedef trait::point_set::arity::unique arity;
typedef trait::point_set::has_speed::fast has_speed;
@@ -229,4 +231,4 @@
} // end of mln
-#endif // MLN_CORE_BGRAPH_P_HH
+#endif // MLN_CORE_P_BGRAPH_HH
Index: trunk/milena/sandbox/pellegrin/set/core/p_run.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_run.hh (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/core/p_run.hh (revision 1790)
@@ -0,0 +1,250 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_P_RUN_HH
+# define MLN_CORE_P_RUN_HH
+
+/*! \file mln/core/p_run.hh
+ *
+ * \brief Definition of a point set class based on std::set.
+ */
+
+# include <mln/core/internal/point_set_base.hh>
+# include <mln/core/internal/set_of.hh>
+# include <mln/accu/bbox.hh>
+# include <mln/trait/point_set.hh>
+
+
+namespace mln
+{
+
+ // Fwd decls.
+ template <typename P> struct p_run;
+ template <typename P> struct p_run_fwd_piter_;
+ template <typename P> struct p_run_bkd_piter_;
+
+ namespace trait
+ {
+
+ template <typename P>
+ struct point_set_< p_run<P> > : public default_point_set_< p_run<P> >
+ {
+ typedef trait::point_set::arity::unique arity;
+ typedef trait::point_set::has_speed::fast has_speed;
+ }
+
+ }
+
+ /*! \brief Point set class in run.
+ *
+ * This is a mathematical set of points (not a multi-set). The
+ * parameter \p P shall be a Point type.
+ *
+ * \todo Test if \p P being a Point_Site is ok.
+ */
+ template <typename P>
+ class p_run : public internal::point_set_base_< P, p_run<P> >
+ {
+ public:
+
+ /// Forward Point_Iterator associated type.
+ typedef p_run_fwd_piter_<P> fwd_piter;
+
+ /// Backward Point_Iterator associated type.
+ typedef p_run_bkd_piter_<P> bkd_piter;
+
+ /// Constructor without argument.
+ p_run();
+
+ /// Constructor.
+ p_run(const P& start, std::size_t len);
+
+ /// Set the starting point.
+ void set_run(const P& start, std::size_t len);
+
+ /// Test is \p p belongs to this point set.
+ bool has(const P& p) const;
+
+ /// Give the number of points.
+ std::size_t npoints() const;
+
+ /// Give the length of the run.
+ std::size_t length() const;
+
+ /// Return the \p i-th point.
+ P operator[](unsigned i) const;
+
+ /// Return the first point.
+ const P& first() const;
+
+ /// Give the exact bounding box.
+ const box_<mln_point(P)>& bbox() const;
+
+ /// Set a relation order to p_run.
+ bool operator<(const p_run<P>& rhs) const;
+
+ protected:
+
+ accu::bbox<P> bb_;
+ // FIXME: Add invariant bb_.is_valid() <=> npoints() != 0
+
+ /// The first point of the run.
+ P p_;
+
+ /// The length of the run.
+ std::size_t len_;
+
+ /// For internal use.
+ bool is_valid_;
+ };
+
+ template <typename P>
+ std::ostream& operator<<(std::ostream& out, const p_run<P>& pr)
+ {
+ out << "Run: (" << pr.first() << ", " << pr.length() << ")";
+ return out;
+ }
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P>
+ inline
+ p_run<P>::p_run()
+ {
+ is_valid_ = false;
+ }
+
+ template <typename P>
+ inline
+ p_run<P>::p_run(const P& start, std::size_t len)
+ : p_(start),
+ len_(len)
+ {
+ mln_precondition(len != 0);
+ P p = start;
+ bb_.init();
+ bb_.take(p);
+ p[P::dim - 1] += len - 1;
+ bb_.take(p);
+ is_valid_ = true;
+ }
+
+ template <typename P>
+ inline
+ void
+ p_run<P>::set_run(const P& start, std::size_t len)
+ {
+ mln_precondition(len != 0);
+ p_ = start;
+ len_ = len;
+ P p = start;
+ bb_.init();
+ bb_.take(p);
+ p[P::dim - 1] += len - 1;
+ bb_.take(p);
+ is_valid_ = true;
+ }
+
+ template <typename P>
+ inline
+ bool
+ p_run<P>::has(const P& p) const
+ {
+ mln_precondition(is_valid_);
+ bool res = true;
+ for (int i = P::dim - 2; i >= 0; --i)
+ if (!(res = (res && p[i] == p_[i])))
+ return false;
+ return (p[P::dim - 1] >= p_[P::dim - 1]
+ && p[P::dim - 1] < p_[P::dim - 1] + (signed)len_);
+ }
+
+ template <typename P>
+ inline
+ std::size_t
+ p_run<P>::npoints() const
+ {
+ mln_precondition(is_valid_);
+ return len_;
+ }
+
+ template <typename P>
+ inline
+ std::size_t
+ p_run<P>::length() const
+ {
+ mln_precondition(is_valid_);
+ return len_;
+ }
+
+ template <typename P>
+ inline
+ P
+ p_run<P>::operator[](unsigned i) const
+ {
+ mln_precondition(is_valid_);
+ mln_precondition(i < npoints());
+ P p = p_;
+ p[P::dim - 1] += i;
+ return p;
+ }
+
+ template <typename P>
+ inline
+ const P&
+ p_run<P>::first() const
+ {
+ return p_;
+ }
+
+ template <typename P>
+ inline
+ const box_<mln_point(P)>&
+ p_run<P>::bbox() const
+ {
+ mln_precondition(is_valid_);
+ mln_precondition(npoints() != 0);
+ return bb_.to_result();
+ }
+
+ template <typename P>
+ inline
+ bool
+ p_run<P>::operator<(const p_run<P>& rhs) const
+ {
+ return (this->p_ < rhs.p_)
+ || (this->p_ == rhs.p_ && this->len_ < rhs.len_);
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+# include <mln/core/p_run_piter.hh>
+
+#endif // ! MLN_CORE_P_RUN_HH
Index: trunk/milena/sandbox/pellegrin/set/core/p_line_graph.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_line_graph.hh (revision 1789)
+++ trunk/milena/sandbox/pellegrin/set/core/p_line_graph.hh (revision 1790)
@@ -25,8 +25,8 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_CORE_LINE_GRAPH_P_HH
-# define MLN_CORE_LINE_GRAPH_P_HH
+#ifndef MLN_CORE_P_LINE_GRAPH_HH
+# define MLN_CORE_P_LINE_GRAPH_HH
# include <mln/core/concept/point_site.hh>
# include <mln/core/internal/point_set_base.hh>
@@ -35,11 +35,12 @@
# include <mln/core/line_graph_psite.hh>
# include <mln/core/p_line_graph_piter.hh>
# include <mln/core/point_pair.hh>
+# include <mln/trait/point_set.hh>
+
/* FIXME: This class shares a lot with p_graph. Factor as much as
possible. */
-
/// \file mln/core/p_line_graph.hh
/// \brief Definition of a point set based on line graph.
@@ -54,14 +55,15 @@
// Nothing.
};
-
+ // Fwd decl.
+ template <typename P> struct p_line_graph;
template<typename P> class p_line_graph_piter_;
namespace trait
{
template <typename P>
- struct point_set_<line2d> : public default_point_set_<P>
+ struct point_set_< p_line_graph<P> > : public default_point_set_< p_line_graph<P> >
{
typedef trait::point_set::arity::unique arity;
typedef trait::point_set::has_speed::fast has_speed;
@@ -172,5 +174,4 @@
} // end of mln
-
-#endif // MLN_CORE_P_GRAPH_HH
+#endif // MLN_CORE_P_LINE_GRAPH_HH
Index: trunk/milena/sandbox/pellegrin/set/core/pset_if.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/pset_if.hh (revision 1789)
+++ trunk/milena/sandbox/pellegrin/set/core/pset_if.hh (revision 1790)
@@ -35,6 +35,7 @@
# include <mln/core/internal/point_set_base.hh>
# include <mln/core/concept/function.hh>
+# include <mln/trait/point_set.hh>
namespace mln
@@ -48,11 +49,11 @@
namespace trait
{
- template <typename P>
- struct point_set_< pset_if<> > : public default_point_set_<P>
+ template <typename S, typename F>
+ struct point_set_< pset_if<S, F> > : public default_point_set_< pset_if<S, F> >
{
typedef trait::point_set::arity::unique arity;
- typedef trait::point_set::has_speed::fast has_speed;
+ typedef trait::point_set::has_speed::slow has_speed;
}
}
Index: trunk/milena/sandbox/pellegrin/set/core/p_array.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_array.hh (revision 1789)
+++ trunk/milena/sandbox/pellegrin/set/core/p_array.hh (revision 1790)
@@ -37,12 +37,14 @@
# include <mln/core/internal/point_set_base.hh>
# include <mln/accu/bbox.hh>
+# include <mln/trait/point_set.hh>
namespace mln
{
// Fwd decls.
+ template <typename P> struct p_array;
template <typename P> struct p_array_fwd_piter_;
template <typename P> struct p_array_bkd_piter_;
@@ -50,9 +52,9 @@
{
template <typename P>
- struct point_set_< p_array<P> > : public default_point_set_<P>
+ struct point_set_< p_array<P> > : public default_point_set_< p_array<P> >
{
- typedef trait::point_set::arity::unique arity;
+ typedef trait::point_set::arity::multiple arity;
typedef trait::point_set::has_speed::fast has_speed;
}
Index: trunk/milena/sandbox/pellegrin/set/core/p_queue.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_queue.hh (revision 1789)
+++ trunk/milena/sandbox/pellegrin/set/core/p_queue.hh (revision 1790)
@@ -41,12 +41,14 @@
# include <mln/core/internal/point_set_base.hh>
# include <mln/core/p_array_piter.hh>
# include <mln/accu/bbox.hh>
+# include <mln/trait/point_set.hh>
namespace mln
{
// Fwd decls.
+ template <typename P> struct p_queue;
template <typename P> struct p_array_fwd_piter_;
template <typename P> struct p_array_bkd_piter_;
@@ -54,10 +56,10 @@
{
template <typename P>
- struct point_set_<line2d> : public default_point_set_<P>
+ struct point_set_< p_queue<P> > : public default_point_set_< p_queue<P> >
{
typedef trait::point_set::arity::unique arity;
- typedef trait::point_set::has_speed::fast has_speed;
+ typedef trait::point_set::has_speed::slow has_speed;
}
}
Index: trunk/milena/sandbox/pellegrin/set/core/p_priority_queue.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_priority_queue.hh (revision 1789)
+++ trunk/milena/sandbox/pellegrin/set/core/p_priority_queue.hh (revision 1790)
@@ -44,11 +44,14 @@
# include <mln/core/p_array_piter.hh>
# include <mln/accu/bbox.hh>
# include <mln/core/p_queue.hh>
+# include <mln/trait/point_set.hh>
+
namespace mln
{
// Fwd decls.
+ template <typename P, typename T> struct p_priority_queue;
template <typename P> struct p_array_fwd_piter_;
template <typename P> struct p_array_bkd_piter_;
@@ -56,10 +59,11 @@
{
template <typename P>
- struct point_set_<line2d> : public default_point_set_<P>
+ struct point_set_< p_priority_queue<P> >
+ : public default_point_set_< p_priority_queue<P> >
{
typedef trait::point_set::arity::unique arity;
- typedef trait::point_set::has_speed::fast has_speed;
+ typedef trait::point_set::has_speed::slow has_speed;
}
}
Index: trunk/milena/sandbox/pellegrin/set/core/p_runs.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_runs.hh (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/core/p_runs.hh (revision 1790)
@@ -0,0 +1,541 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_P_RUNS_HH
+# define MLN_CORE_P_RUNS_HH
+
+/*! \file mln/core/p_runs.hh
+ *
+ * \brief Definition of mln::internal::p_runs_ class and its iterators
+ * (for internal use only).
+ */
+
+# include <utility>
+
+# include <mln/core/internal/point_set_base.hh>
+# include <mln/core/internal/point_iterator_base.hh>
+# include <mln/core/runs_psite.hh>
+# include <mln/core/p_run.hh>
+# include <mln/accu/bbox.hh>
+# include <mln/util/lazy_set.hh>
+# include <mln/trait/point_set.hh>
+
+
+namespace mln
+{
+
+ // Forward declaration
+ template <typename P> struct p_runs;
+ template <typename P> struct p_runs_fwd_piter_;
+ template <typename P> struct p_runs_bkd_piter_;
+
+ namespace trait
+ {
+
+ template <typename P>
+ struct point_set_< p_runs<P> > : public default_point_set_< p_runs<P> >
+ {
+ typedef trait::point_set::arity::multiple arity;
+ typedef trait::point_set::has_speed::fast has_speed;
+ }
+
+ }
+
+ /*! \brief p_runs_ class represent a point set used in run_image_ class.
+ *
+ * Parameter \c P is the type of the image point.
+ */
+ template <typename P>
+ class p_runs_ : public internal::point_set_base_< runs_psite<P>, p_runs_<P> >
+ {
+ public:
+
+// typedef util::lazy_set_<p_run<P> > container;
+ typedef p_runs_fwd_piter_<P> fwd_piter;
+ typedef p_runs_bkd_piter_<P> bkd_piter;
+
+ /// Constructor without arguments.
+ p_runs_();
+
+ /// Test is \p p belongs to this point set.
+ bool has(const runs_psite<P>& ps) const;
+
+ /// Give the exact bounding box.
+ const box_<P>& bbox() const;
+
+ /// Give the number of points.
+ typename std::size_t npoints() const;
+
+ /// Insert a range, start at point \p p wit len \p len.
+ void insert(const p_run<P>& pr);
+
+ /// Return the number of runs.
+ unsigned nruns() const;
+
+ /// Return the len of the range starting at point \p p.
+ unsigned range_len_(const P& p) const;
+
+ /// Return the i-th run of the list of runs
+ const p_run<P>& operator[](unsigned i) const;
+
+ /// Return the size of the data in memory.
+ unsigned size_mem() const;
+
+ /// Finalize the lazy_set (internal use)
+ void finalize();
+
+// /// Return the container of the pset (internal use only).
+// const container& con() const;
+
+ protected:
+
+ /// Number of points.
+ typename std::size_t npoints_;
+
+ /// Points container
+ util::lazy_set_<p_run<P> > con_;
+
+ /// Exact bounding box.
+ accu::bbox<P> fb_;
+ };
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P>
+ inline
+ p_runs_<P>::p_runs_() :
+ npoints_(0)
+ {
+ }
+
+ template <typename P>
+ inline
+ bool
+ p_runs_<P>::has(const runs_psite<P>& ps) const
+ {
+ if (ps.p_of_run() < nruns()
+ && ps.p_in_run() < con_[ps.p_of_run()].length())
+ return (ps == con_[ps.p_of_run()][ps.p_in_run()]);
+ else
+ return false;
+ }
+
+ template <typename P>
+ inline
+ const box_<P>&
+ p_runs_<P>::bbox() const
+ {
+ return fb_.to_result();
+ }
+
+ template <typename P>
+ inline
+ typename std::size_t
+ p_runs_<P>::npoints() const
+ {
+ return npoints_;
+ }
+
+ template <typename P>
+ inline
+ void
+ p_runs_<P>::insert(const p_run<P>& pr)
+ {
+ typename std::vector<p_run<P> >::const_iterator iter = con_.vect().begin();
+ while (iter != con_.vect().end() && iter->first() < pr.first())
+ ++iter;
+
+ if (iter != con_.vect().begin())
+ {
+ typename std::vector<p_run<P> >::const_iterator prec = iter;
+ --prec;
+ bool equal = true;
+ for (int i = P::dim - 2; i >= 0; --i)
+ if (!(equal = equal && (prec->first()[i] == pr.first()[i])))
+ break;
+ if (equal)
+ mln_assertion(prec->first()[P::dim - 1] + (signed)prec->length()
+ <= pr.first()[P::dim - 1]);
+ }
+
+ if (iter != con_.vect().end())
+ {
+ bool equal = true;
+ for (int i = P::dim - 2; i >= 0; --i)
+ if (!(equal = equal && ((*iter).first()[i] == pr.first()[i])))
+ break;
+ if (equal)
+ mln_assertion(pr.first()[P::dim - 1] + (signed)pr.length()
+ <= iter->first()[P::dim - 1]);
+ }
+ con_.insert(pr);
+
+ // update box
+ fb_.take(pr.bbox().pmin());
+ fb_.take(pr.bbox().pmax());
+ // update size
+ npoints_ += pr.npoints();
+ }
+
+ template <typename P>
+ inline
+ unsigned
+ p_runs_<P>::nruns() const
+ {
+ return con_.nelements();
+ }
+
+ template <typename P>
+ inline
+ unsigned
+ p_runs_<P>::range_len_(const P& p) const
+ {
+ unsigned i;
+ for (i = 0; i < con_.size(); ++i)
+ {
+ if (con_[i].first == p)
+ return con_[i].second;
+ }
+ mln_assertion(i < con_.size());
+
+ //Hack
+ return (con_[i].second);
+ }
+
+ template <typename P>
+ inline
+ const p_run<P>&
+ p_runs_<P>::operator[](unsigned i) const
+ {
+ return con_[i];
+ }
+
+ template <typename P>
+ inline
+ unsigned
+ p_runs_<P>::size_mem() const
+ {
+ if (con_.get_mode())
+ return nruns() * (sizeof(P) + sizeof(unsigned));
+ else
+ return 2 * nruns() * (sizeof(P) + sizeof(unsigned));
+ }
+
+ template <typename P>
+ inline
+ void
+ p_runs_<P>::finalize()
+ {
+ con_.set_const_mode(true);
+ }
+
+
+// template <typename P>
+// const typename p_runs_<P>::container&
+// p_runs_<P>::con() const
+// {
+// return con_;
+// }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ /*! \brief Factorization class for p_runs_iterator_.
+ *
+ * Parameter \c P is the type of the point used in the point set.
+ * Parameter \c E is the exact type of the iterator
+ */
+ template <typename P, typename E>
+ class p_runs_piter_ : public internal::point_iterator_base_< runs_psite<P>, E >
+ {
+ public:
+
+ /// Convertion into a point.
+ operator P () const;
+
+ /// Reference to the corresponding point.
+ const P& to_point() const;
+
+ /// Access to the current point coordinates.
+ mln_coord(P) operator[](unsigned i) const;
+
+ protected:
+
+ /// Current point.
+ P p_;
+
+ /// Point set container.
+ const p_runs_<P>& con_;
+
+ p_runs_piter_(const p_runs_<P>& pset);
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P, typename E>
+ inline
+ p_runs_piter_<P, E>::p_runs_piter_(const p_runs_<P>& pset) :
+ con_(pset)
+ {
+ }
+
+ template <typename P, typename E>
+ inline
+ p_runs_piter_<P, E>::operator P () const
+ {
+ return this->to_point();
+ }
+
+ template <typename P, typename E>
+ inline
+ const P&
+ p_runs_piter_<P, E>::to_point() const
+ {
+ mln_precondition(exact(this)->is_valid());
+ return p_;
+ }
+
+ template <typename P, typename E>
+ inline
+ mln_coord(P)
+ p_runs_piter_<P, E>::operator[] (unsigned i) const
+ {
+ mln_precondition(exact(this)->is_valid());
+ return p_[i];
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+
+ /*! \brief Forward iterator on p_runs_ point set.
+ *
+ * Parameter \c P is the type of the point used in the point set.
+ */
+ template <typename P>
+ class p_runs_fwd_piter_ : public p_runs_piter_<P, p_runs_fwd_piter_<P> >
+ {
+ typedef p_runs_piter_<P, p_runs_fwd_piter_<P> > super;
+ public:
+
+ p_runs_fwd_piter_(const p_runs_<P>& pset);
+
+ /// Test the iterator validity.
+ bool is_valid() const;
+
+ /// Invalidate the iterator.
+ void invalidate();
+
+ /// Start an iteration.
+ void start();
+
+ /// Go to the next point.
+ void next_();
+
+ /// Convertion into a point-site.
+ operator runs_psite<P> () const;
+
+ protected:
+
+ unsigned i_;
+
+ p_run_fwd_piter_<P> it_;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P>
+ inline
+ p_runs_fwd_piter_<P>::p_runs_fwd_piter_(const p_runs_<P>& pset) :
+ super(pset)
+ {
+ invalidate();
+ }
+
+ template <typename P>
+ inline
+ bool
+ p_runs_fwd_piter_<P>::is_valid() const
+ {
+ return i_ < this->con_.nruns();
+ }
+
+ template <typename P>
+ inline
+ void
+ p_runs_fwd_piter_<P>::invalidate()
+ {
+ i_ = this->con_.nruns();
+ }
+
+ template <typename P>
+ inline
+ void
+ p_runs_fwd_piter_<P>::start()
+ {
+ i_ = 0;
+ it_.assign_run(this->con_[i_]);
+ it_.start();
+ this->p_ = it_;
+ }
+
+ template <typename P>
+ inline
+ void
+ p_runs_fwd_piter_<P>::next_()
+ {
+ mln_precondition(this->is_valid());
+ it_.next();
+ if (!it_.is_valid())
+ {
+ ++i_;
+ if (is_valid())
+ {
+ it_.assign_run(this->con_[i_]);
+ it_.start();
+ }
+ else
+ return;
+ }
+ this->p_ = it_;
+ }
+
+ template <typename P>
+ p_runs_fwd_piter_<P>::operator runs_psite<P> () const
+ {
+ return runs_psite<P>(this->con_, it_.ind(), i_);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+
+ /*! \brief Backward iterator on p_runs_ point set.
+ *
+ * Parameter \c P is the type of the point used in the point set.
+ */
+ template <typename P>
+ class p_runs_bkd_piter_ : public p_runs_piter_<P, p_runs_bkd_piter_<P> >
+ {
+ typedef p_runs_piter_<P, p_runs_bkd_piter_<P> > super;
+ public:
+
+ p_runs_bkd_piter_(const p_runs_<P>& pset);
+
+ /// Test the iterator validity.
+ bool is_valid() const;
+
+ /// Invalidate the iterator.
+ void invalidate();
+
+ /// Start an iteration.
+ void start();
+
+ /// Go to the next point.
+ void next_();
+
+ /// Convertion into a point-site.
+ operator runs_psite<P> () const;
+
+ protected:
+
+ unsigned i_;
+
+ p_run_bkd_piter_<P> it_;
+};
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P>
+ inline
+ p_runs_bkd_piter_<P>::p_runs_bkd_piter_(const p_runs_<P>& pset) :
+ super(pset)
+ {
+ invalidate();
+ }
+
+ template <typename P>
+ inline
+ bool
+ p_runs_bkd_piter_<P>::is_valid() const
+ {
+ return i_ < this->con_.nruns();
+ }
+
+ template <typename P>
+ inline
+ void
+ p_runs_bkd_piter_<P>::invalidate()
+ {
+ i_ = this->con_.nruns();
+ }
+
+ template <typename P>
+ inline
+ void
+ p_runs_bkd_piter_<P>::start()
+ {
+ i_ = this->con_.nruns() - 1;
+ it_.assign_run(this->con_[i_]);
+ it_.start();
+ this->p_ = it_;
+ }
+
+ template <typename P>
+ inline
+ void
+ p_runs_bkd_piter_<P>::next_()
+ {
+ mln_precondition(this->is_valid());
+ it_.next();
+ if (!it_.is_valid())
+ {
+ --i_;
+ if (is_valid())
+ {
+ it_.assign_run(this->con_[i_]);
+ it_.start();
+ }
+ else
+ return;
+ }
+ this->p_ = it_;
+ }
+
+ template <typename P>
+ p_runs_bkd_piter_<P>::operator runs_psite<P> () const
+ {
+ return runs_psite<P>(this->con_, it_.ind(), i_);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_P_RUNS_HH
Index: trunk/milena/sandbox/pellegrin/set/core/p_set.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_set.hh (revision 1789)
+++ trunk/milena/sandbox/pellegrin/set/core/p_set.hh (revision 1790)
@@ -37,16 +37,20 @@
# include <mln/core/internal/set_of.hh>
# include <mln/accu/bbox.hh>
# include <mln/core/p_array.hh>
+# include <mln/trait/point_set.hh>
namespace mln
{
+ // Fwd decls.
+ template <typename P> struct p_set;
+
namespace trait
{
template <typename P>
- struct point_set_<line2d> : public default_point_set_<P>
+ struct point_set_< p_set<P> > : public default_point_set_< p_set<P> >
{
typedef trait::point_set::arity::unique arity;
typedef trait::point_set::has_speed::fast has_speed;
Index: trunk/milena/sandbox/pellegrin/set/core/p_priority_queue_fast_with_array.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_priority_queue_fast_with_array.hh (revision 1789)
+++ trunk/milena/sandbox/pellegrin/set/core/p_priority_queue_fast_with_array.hh (revision 1790)
@@ -44,21 +44,25 @@
# include <mln/core/p_array_piter.hh>
# include <mln/accu/bbox.hh>
# include <mln/core/p_queue_fast.hh>
+# include <mln/trait/point_set.hh>
+
namespace mln
{
// Fwd decls.
+ template <typename P, typename T, typename S> struct p_priority_queue_fast_with_array;
template <typename P> struct p_array_fwd_piter_;
template <typename P> struct p_array_bkd_piter_;
namespace trait
{
- template <typename P>
- struct point_set_<line2d> : public default_point_set_<P>
+ template <typename P, typename T, typename S>
+ struct point_set_< p_priority_queue_fast_with_array<P, T, S> >
+ : public default_point_set_< p_priority_queue_fast_with_array<P, T, S> >
{
- typedef trait::point_set::arity::unique arity;
+ typedef trait::point_set::arity::multiple arity;
typedef trait::point_set::has_speed::fast has_speed;
}
Index: trunk/milena/sandbox/pellegrin/set/core/line2d.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/line2d.hh (revision 1789)
+++ trunk/milena/sandbox/pellegrin/set/core/line2d.hh (revision 1790)
@@ -39,16 +39,20 @@
# include <mln/core/p_array_piter.hh>
# include <mln/core/box2d.hh>
# include <mln/math/all.hh>
+# include <mln/trait/point_set.hh>
namespace mln
{
+ // Fwd decl.
+ template <typename P> struct line2d;
+
namespace trait
{
- template <typename P>
- struct point_set_<line2d> : public default_point_set_<P>
+ template <>
+ struct point_set_<line2d> : public default_point_set_<line2d>
{
typedef trait::point_set::arity::unique arity;
typedef trait::point_set::has_speed::fast has_speed;
Index: trunk/milena/sandbox/pellegrin/set/core/p_graph.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_graph.hh (revision 1789)
+++ trunk/milena/sandbox/pellegrin/set/core/p_graph.hh (revision 1790)
@@ -34,6 +34,8 @@
# include <mln/util/graph.hh>
# include <mln/core/graph_psite.hh>
# include <mln/core/p_graph_piter.hh>
+# include <mln/trait/point_set.hh>
+
/// \file mln/core/p_graph.hh
/// \brief Definition of a point set based on graph.
@@ -41,13 +43,15 @@
namespace mln
{
+ // Fwd decls.
+ template <typename P> struct p_graph;
template<typename P> class p_graph_piter_;
namespace trait
{
template <typename P>
- struct point_set_<line2d> : public default_point_set_<P>
+ struct point_set_< p_graph<P> > : public default_point_set_< p_graph<P> >
{
typedef trait::point_set::arity::unique arity;
typedef trait::point_set::has_speed::fast has_speed;
Index: trunk/milena/sandbox/pellegrin/set/core/p_queue_fast.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_queue_fast.hh (revision 1789)
+++ trunk/milena/sandbox/pellegrin/set/core/p_queue_fast.hh (revision 1790)
@@ -42,12 +42,14 @@
# include <mln/core/internal/point_set_base.hh>
# include <mln/core/p_array_piter.hh>
# include <mln/accu/bbox.hh>
+# include <mln/trait/point_set.hh>
namespace mln
{
// Fwd decls.
+ template <typename P> struct p_queue_fast;
template <typename P> struct p_array_fwd_piter_;
template <typename P> struct p_array_bkd_piter_;
@@ -55,9 +57,9 @@
{
template <typename P>
- struct point_set_<line2d> : public default_point_set_<P>
+ struct point_set_< p_queue_fast<P> > : public default_point_set_< p_queue_fast<P> >
{
- typedef trait::point_set::arity::unique arity;
+ typedef trait::point_set::arity::multiple arity;
typedef trait::point_set::has_speed::fast has_speed;
}
--
Michel PELLEGRIN
ÉPITA - CSI 2010
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2008-03-19 Caroline Vigouroux <vigour_c(a)epita.fr>
rms.
* moyenne.cc: rms.
---
moyenne.cc | 79 ++++++++++++++++++-------------------------------------------
1 file changed, 24 insertions(+), 55 deletions(-)
Index: trunk/milena/sandbox/vigouroux/moyenne.cc
===================================================================
--- trunk/milena/sandbox/vigouroux/moyenne.cc (revision 1788)
+++ trunk/milena/sandbox/vigouroux/moyenne.cc (revision 1789)
@@ -1,5 +1,3 @@
-#include <mln/core/image2d.hh>
-#include <mln/value/int_u8.hh>
#include "color/my_hsi.hh"
#include "color/rgb_to_hsi.hh"
#include <mln/display/save_and_show.hh>
@@ -11,68 +9,36 @@
#include <mln/math/round.hh>
#include <mln/level/transform.hh>
-#include <mln/core/w_window2d_float.hh>
-#include <mln/border/thickness.hh>
-#include <mln/linear/convolve.hh>
-
-# include <mln/display/save.hh>
-# include <mln/display/show.hh>
-
#include <mln/core/image2d.hh>
-#include <mln/win/rectangle2d.hh>
-#include <mln/make/pixel.hh>
#include <cmath>
#include <iostream>
-// template <typename I, typename O, typename W>
-// float moyenne (I& ima, O& out, W& win)
-// {
-// mln::value::rgb8 c2;
-// mln_piter(I) p(out.domain());
-// mln_qixter(I, W) q(ima, win, p);
-// for_all(p)
-// {
-// for_all(q)
-// {
-// q.val()
-// }
-// out(p) = c2;
-// }
-
-// return ();
-// }
-
-template <typename I, typename O, typename W>
-float moyenne (I& ima, O& out, W& win)
+template <typename I, typename O>
+float rms (const I& ima, O& out)
{
- mln::value::hsi_3x8 c_hsi;
+ mln::value::rgb8 c1;
mln::value::rgb8 c2;
float distred = 0;
float distgreen = 0;
float distblue = 0;
float sum = 0;
- float nb_ct = 0;
+ float nb = 0;
float moy = 0;
mln_piter(I) p(out.domain());
- mln_qixter(I, W) q(ima, win, p);
for_all(p)
{
- for_all(q)
- {
- c_hsi = mln::fun::v2v::f_rgb_to_hsi_3x8(q.val());
- c2 = mln::fun::v2v::f_hsi_to_rgb_3x8(c_hsi);
- distred = c2.red() - q.val().red();
- distgreen = c2.green() - q.val().green();
- distblue = c2.blue() - q.val().blue();
- }
- nb_ct += 3;
+ c1 = ima(p);
+ c2 = out(p);
+ distred = c2.red() - c1.red();
+ distgreen = c2.green() - c1.green();
+ distblue = c2.blue() - c1.blue();
+
+ ++nb;
sum += distred * distred + distblue * distblue + distgreen * distgreen;
- out(p) = c2;
}
- moy = sqrt(sum / nb_ct);
- std::cout << "nb_point: " << nb_ct / 3 << std::endl;
+ moy = std::sqrt(sum / nb);
return (moy);
}
@@ -80,18 +46,21 @@
{
using namespace mln;
using value::int_u8;
- image2d<mln::value::rgb8> lena;
+ image2d<value::rgb8> lena;
io::ppm::load(lena, "../../img/lena.ppm");
- image2d<mln::value::hsi_3x8> inter(lena.domain());
- image2d<mln::value::rgb8> out(lena.domain());
- const image2d<mln::value::rgb8> input = exact(lena);
- float lol;
- win::rectangle2d rect(3, 3);
- lol = moyenne(input, out, rect);
+ image2d<value::hsi_3x8> lena_hsi = level::transform(lena,
+ fun::v2v::f_rgb_to_hsi_3x8);
+
+ image2d<value::rgb8> lena_rgb = level::transform(lena_hsi,
+ fun::v2v::f_hsi_to_rgb_3x8);
+
+
+ float err = rms(lena, lena_rgb);
- std::cout << "moyenne: " << lol << std::endl;
+ std::cout << "err: " << err << std::endl;
- display::save_and_show (out, "display", 50);
+ display::save_and_show (lena_rgb, "display", 50);
+ return (0);
}
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2008-03-19 Michel Pellegrin <pellegrin(a)lrde.epita.fr>
Commit of Sandbox.
* mln/core/internal/point_set_base.hh: Header.
* mln/core/line2d.hh: No append in line2d.
* mln/core/p_graph.hh: Typos.
* mln/util/lazy_set.hh: Disambiguization.
* sandbox/pellegrin/cond_inheritance/Makefile: .
* sandbox/pellegrin/cond_inheritance/concept/point_set.hh: .
* sandbox/pellegrin/cond_inheritance/internal/multi_set.hh: .
* sandbox/pellegrin/cond_inheritance/internal/point_set_base.hh: .
* sandbox/pellegrin/cond_inheritance/internal/uni_set.hh: .
* sandbox/pellegrin/cond_inheritance/p_array.hh: .
* sandbox/pellegrin/cond_inheritance/p_set.hh: .
* sandbox/pellegrin/cond_inheritance/test_cond_inherit.cc: .
* sandbox/pellegrin/first_test.cc: .
* sandbox/pellegrin/set/Makefile: .
* sandbox/pellegrin/set/core/concept/point_set.hh: New.
* sandbox/pellegrin/set/core/concept: New.
* sandbox/pellegrin/set/core/internal: New.
* sandbox/pellegrin/set/core/line2d.hh: New.
* sandbox/pellegrin/set/core/p_array.hh: New.
* sandbox/pellegrin/set/core/p_bgraph.hh: New.
* sandbox/pellegrin/set/core/p_graph.hh: New.
* sandbox/pellegrin/set/core/p_line_graph.hh: New.
* sandbox/pellegrin/set/core/p_priority_queue.hh: New.
* sandbox/pellegrin/set/core/p_priority_queue_fast.hh: New.
* sandbox/pellegrin/set/core/p_priority_queue_fast_with_array.hh: New.
* sandbox/pellegrin/set/core/p_queue.hh: New.
* sandbox/pellegrin/set/core/p_queue_fast.hh: New.
* sandbox/pellegrin/set/core/p_set.hh: New.
* sandbox/pellegrin/set/core/pset_if.hh: New.
* sandbox/pellegrin/set/core/runs_psite.hh: New.
* sandbox/pellegrin/set/core: New.
* sandbox/pellegrin/set/multi_set.hh: .
* sandbox/pellegrin/set/test_set.cc: .
* sandbox/pellegrin/set/trait/point_set.hh: New.
* sandbox/pellegrin/set/trait: New.
* sandbox/pellegrin/set/types_de_points.txt: New.
* sandbox/pellegrin/set/uni_set.hh: .
---
mln/core/internal/point_set_base.hh | 1
mln/core/line2d.hh | 3
mln/core/p_graph.hh | 4
mln/util/lazy_set.hh | 4
sandbox/pellegrin/cond_inheritance/Makefile | 24
sandbox/pellegrin/cond_inheritance/concept/point_set.hh | 2
sandbox/pellegrin/cond_inheritance/internal/multi_set.hh | 2
sandbox/pellegrin/cond_inheritance/internal/point_set_base.hh | 2
sandbox/pellegrin/cond_inheritance/internal/uni_set.hh | 2
sandbox/pellegrin/cond_inheritance/p_array.hh | 5
sandbox/pellegrin/cond_inheritance/p_set.hh | 5
sandbox/pellegrin/cond_inheritance/test_cond_inherit.cc | 4
sandbox/pellegrin/first_test.cc | 2
sandbox/pellegrin/set/Makefile | 26
sandbox/pellegrin/set/core/concept/point_set.hh | 252 ++++++
sandbox/pellegrin/set/core/line2d.hh | 208 +++++
sandbox/pellegrin/set/core/p_array.hh | 245 ++++++
sandbox/pellegrin/set/core/p_bgraph.hh | 232 ++++++
sandbox/pellegrin/set/core/p_graph.hh | 258 +++++++
sandbox/pellegrin/set/core/p_line_graph.hh | 176 ++++
sandbox/pellegrin/set/core/p_priority_queue.hh | 361 ++++++++++
sandbox/pellegrin/set/core/p_priority_queue_fast.hh | 361 ++++++++++
sandbox/pellegrin/set/core/p_priority_queue_fast_with_array.hh | 347 +++++++++
sandbox/pellegrin/set/core/p_queue.hh | 309 ++++++++
sandbox/pellegrin/set/core/p_queue_fast.hh | 316 ++++++++
sandbox/pellegrin/set/core/p_set.hh | 191 +++++
sandbox/pellegrin/set/core/pset_if.hh | 226 ++++++
sandbox/pellegrin/set/core/runs_psite.hh | 192 +++++
sandbox/pellegrin/set/multi_set.hh | 8
sandbox/pellegrin/set/test_set.cc | 4
sandbox/pellegrin/set/trait/point_set.hh | 110 +++
sandbox/pellegrin/set/types_de_points.txt | 14
sandbox/pellegrin/set/uni_set.hh | 8
33 files changed, 3824 insertions(+), 80 deletions(-)
Index: trunk/milena/mln/core/internal/point_set_base.hh
===================================================================
--- trunk/milena/mln/core/internal/point_set_base.hh (revision 1787)
+++ trunk/milena/mln/core/internal/point_set_base.hh (revision 1788)
@@ -45,7 +45,6 @@
/*! \internal A base class for point set classes.
* \p P is a point site type.
- *
*/
template <typename P, typename E>
struct point_set_base_ : public Point_Set<E>
Index: trunk/milena/mln/core/p_graph.hh
===================================================================
--- trunk/milena/mln/core/p_graph.hh (revision 1787)
+++ trunk/milena/mln/core/p_graph.hh (revision 1788)
@@ -25,8 +25,8 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_CORE_GRAPH_P_HH
-# define MLN_CORE_GRAPH_P_HH
+#ifndef MLN_CORE_P_GRAPH_HH
+# define MLN_CORE_P_GRAPH_HH
# include <mln/core/concept/point_site.hh>
# include <mln/core/internal/point_set_base.hh>
Index: trunk/milena/mln/core/line2d.hh
===================================================================
--- trunk/milena/mln/core/line2d.hh (revision 1787)
+++ trunk/milena/mln/core/line2d.hh (revision 1788)
@@ -71,9 +71,6 @@
/// Give the exact bounding box.
const box_<point2d>& bbox() const;
- /// Append a point \p p.
- line2d& append(const point2d& p);
-
/// Return the corresponding std::vector of points.
const std::vector<point2d>& vect() const;
Index: trunk/milena/mln/util/lazy_set.hh
===================================================================
--- trunk/milena/mln/util/lazy_set.hh (revision 1787)
+++ trunk/milena/mln/util/lazy_set.hh (revision 1788)
@@ -220,7 +220,7 @@
s_.insert(elt);
if (needs_update_ == false)
needs_update_ = true;
- return internal::force_exact< lazy_set_<E> >(*this);
+ return mln::internal::force_exact< lazy_set_<E> >(*this);
}
template <typename E>
@@ -233,7 +233,7 @@
std::remove(s_.begin(), s_.end(), elt);
if (needs_update_ == false)
needs_update_ = true;
- return internal::force_exact< lazy_set_<E> >(*this);
+ return mln::internal::force_exact< lazy_set_<E> >(*this);
}
template <typename E>
Index: trunk/milena/sandbox/pellegrin/first_test.cc
===================================================================
--- trunk/milena/sandbox/pellegrin/first_test.cc (revision 1787)
+++ trunk/milena/sandbox/pellegrin/first_test.cc (revision 1788)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
Index: trunk/milena/sandbox/pellegrin/set/multi_set.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/multi_set.hh (revision 1787)
+++ trunk/milena/sandbox/pellegrin/set/multi_set.hh (revision 1788)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -26,8 +26,8 @@
// Public License.
-#ifndef __MULTI_SET_HH__
-# define __MULTI_SET_HH__
+#ifndef MULTI_SET_HH
+# define MULTI_SET_HH
/*! \file sandbox/pellegrin/set/multi_set.hh
*
@@ -173,4 +173,4 @@
} // end of namespace mln
-#endif // ! __MULTI_SET_HH__
+#endif // ! MULTI_SET_HH
Index: trunk/milena/sandbox/pellegrin/set/trait/point_set.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/trait/point_set.hh (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/trait/point_set.hh (revision 1788)
@@ -0,0 +1,110 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_TRAIT_POINT_SET_HH
+# define MLN_TRAIT_POINT_SET_HH
+
+/*! \file mln/trait/point_set.hh
+ *
+ * \brief Properties of point_set classes.
+ */
+
+# include <string>
+# include <mln/trait/undef.hh>
+
+# define mln_trait_point_set_arity(P) typename mln::trait::point_set< P >::arity
+# define mln_trait_point_set_has_speed(P) typename mln::trait::point_set< P >::has_speed
+
+namespace mln
+{
+
+ struct line2d;
+ template <typename P> struct p_array;
+ template <typename P> struct p_bgraph;
+ template <typename P> struct p_graph;
+ template <typename P> struct p_line_graph;
+ template <typename P, typename T> struct p_priority_queue;
+ template <typename P, typename T> struct p_priority_queue_fast;
+ template <typename P, typename T, typename S> struct p_priority_queue_fast_with_array;
+ template <typename P> struct p_queue;
+ template <typename P> struct p_queue_fast;
+ template <typename P> struct p_run;
+ template <typename P> struct p_runs_;
+ template <typename P> struct p_set;
+ template <typename S, typename F> struct pset_if;
+
+ namespace trait
+ {
+
+ namespace point_set
+ {
+
+ struct arity
+ {
+ struct any {};
+ struct unique : any
+ { std::string name() const { return "arity::unique"; } };
+ struct multiple : any
+ { std::string name() const { return "arity::multiple"; } };
+ };
+
+ struct has_speed
+ {
+ struct any {};
+ struct slow : any
+ { std::string name() const { return "has_speed::slow"; } };
+ struct fast : any
+ { std::string name() const { return "has_speed::fast"; } };
+ };
+
+ } // end of namespace mln::trait::point_set
+
+ template <typename P>
+ struct undefined_point_set_
+ {
+ typedef undef arity; // unique or multiple
+ typedef undef has_speed; // slow or fast
+ };
+
+ template <typename P>
+ struct point_set_ : public undefined_point_set_<P>
+ {
+ };
+
+ template <typename P>
+ struct default_point_set_ : public undefined_point_set_<P>
+ {
+ typedef trait::point_set::arity::unique arity;
+ typedef trait::point_set::has_speed::fast has_speed;
+ };
+
+ } // end of namespace mln::trait
+
+} // end of namespace mln
+
+
+#endif // ! MLN_TRAIT_POINT_SET_HH
Index: trunk/milena/sandbox/pellegrin/set/uni_set.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/uni_set.hh (revision 1787)
+++ trunk/milena/sandbox/pellegrin/set/uni_set.hh (revision 1788)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -26,8 +26,8 @@
// Public License.
-#ifndef __UNI_SET_HH__
-# define __UNI_SET_HH__
+#ifndef UNI_SET_HH
+# define UNI_SET_HH
/*! \file sandbox/pellegrin/set/uni_set.hh
*
@@ -173,4 +173,4 @@
} // end of namespace mln
-#endif // ! __UNI_SET_HH__
+#endif // ! UNI_SET_HH
Index: trunk/milena/sandbox/pellegrin/set/types_de_points.txt
===================================================================
--- trunk/milena/sandbox/pellegrin/set/types_de_points.txt (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/types_de_points.txt (revision 1788)
@@ -0,0 +1,14 @@
+mln::line2d: uni, fast
+mln::p_array< P >: multi, fast
+mln::p_bgraph< P >: uni, fast
+mln::p_graph< P >: uni, fast
+mln::p_line_graph< P >: uni, fast
+mln::p_priority_queue< P, T >: uni, slow
+mln::p_priority_queue_fast< P, T >: uni, fast
+mln::p_priority_queue_fast_with_array< P, T, S >: multi, fast
+mln::p_queue< P >: multi, slow
+mln::p_queue_fast< P >: multi, fast
+mln::p_run< P >: uni, fast
+mln::p_runs_< P >: multi, fast
+mln::p_set< P >: uni, fast
+mln::pset_if< S, F >: uni, slow
Index: trunk/milena/sandbox/pellegrin/set/core/p_priority_queue_fast.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_priority_queue_fast.hh (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/core/p_priority_queue_fast.hh (revision 1788)
@@ -0,0 +1,361 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_P_PRIORITY_QUEUE_FAST_HH
+# define MLN_CORE_P_PRIORITY_QUEUE_FAST_HH
+
+/*! \file mln/core/p_priority_queue_fast.hh
+ *
+ * \brief Definition of a point set class based on p_queue_fast with
+ * priority features.
+ */
+
+# include <vector>
+# include <deque>
+# include <map>
+# include <algorithm>
+# include <iterator>
+
+# include <mln/core/internal/point_set_base.hh>
+# include <mln/core/p_array_piter.hh>
+# include <mln/accu/bbox.hh>
+# include <mln/core/p_queue_fast.hh>
+
+namespace mln
+{
+
+ // Fwd decls.
+ template <typename P> struct p_array_fwd_piter_;
+ template <typename P> struct p_array_bkd_piter_;
+
+ namespace trait
+ {
+
+ template <typename P>
+ struct point_set_<line2d> : public default_point_set_<P>
+ {
+ typedef trait::point_set::arity::unique arity;
+ typedef trait::point_set::has_speed::fast has_speed;
+ }
+
+ }
+
+ /*! \brief Point fast queue class (based on std::map and p_queue_fast).
+ *
+ * This is a mathematical set of points (unique insertion).
+ *
+ * \todo Make it work with P being a Point_Site.
+ *
+ * \warning We have some troubles with point set comparison based on
+ * a call to npoints() when this container is multiple.
+ */
+ template <typename P, typename T>
+ class p_priority_queue_fast : public internal::point_set_base_< P, p_priority_queue_fast<P, T> >
+ {
+ public:
+
+ /// Forward Point_Iterator associated type.
+ typedef p_array_fwd_piter_<P> fwd_piter;
+
+ /// Backward Point_Iterator associated type.
+ typedef p_array_bkd_piter_<P> bkd_piter;
+
+ /// Constructor.
+ p_priority_queue_fast();
+
+ /// Test is \p p belongs to this point set.
+ bool has(const P& p) const;
+
+ /// Test if queue is empty or not.
+ bool is_empty() const;
+
+ /// Give the number of points.
+ size_t npoints() const;
+
+ /// Give the exact bounding box.
+ const box_<P>& bbox() const;
+
+ /// Push force a point \p p in the queue.
+ p_priority_queue_fast<P, T>& push_force(const P& p, T prio = 0);
+
+ /// Push a point \p p in the queue.
+ p_priority_queue_fast<P, T>& push(const P& p, T prio = 0);
+
+ /// Pop (remove) the front point \p p from the queue; \p p is the
+ /// least recently inserted point.
+ void pop();
+
+ /// Give the front point \p p of the queue; \p p is the least
+ /// recently inserted point.
+ const P& front() const;
+
+ /// Pop (remove) the front point \p p from the queue; \p p is the
+ /// least recently inserted point and give the front point \p p of
+ /// the queue; \p p is the least recently inserted point.
+ const P& pop_front();
+
+ /// Clear the queue.
+ void clear();
+
+ /// Return the corresponding std::vector of points.
+ const std::vector<P>& vect() const;
+
+ /// Return the \p i-th point.
+ const P& operator[](unsigned i) const;
+
+ protected:
+
+ std::map<const T, p_queue_fast<P> > q_;
+
+ mutable std::vector<P> vect_;
+ mutable bool vect_needs_update_;
+ void vect_update_() const;
+
+ mutable accu::bbox<P> bb_;
+ mutable bool bb_needs_update_;
+ void bb_update_() const;
+
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P, typename T>
+ inline
+ p_priority_queue_fast<P, T>::p_priority_queue_fast()
+ {
+ vect_needs_update_ = false;
+ bb_needs_update_ = false;
+ }
+
+ template <typename P, typename T>
+ inline
+ void
+ p_priority_queue_fast<P, T>::vect_update_() const
+ {
+ vect_.clear();
+ vect_.reserve(npoints());
+
+ typename std::map<T, p_queue_fast<P> >::const_iterator it = q_.begin ();
+
+ for (; it != q_.end (); ++it)
+ std::copy((*it).second.vect().begin(), (*it).second.vect().end(),
+ std::back_inserter(vect_));
+ vect_needs_update_ = false;
+ }
+
+ template <typename P, typename T>
+ inline
+ void
+ p_priority_queue_fast<P, T>::bb_update_() const
+ {
+ bb_.init();
+
+ typename std::map<T, p_queue_fast<P> >::const_iterator it = q_.begin ();
+
+ for (; it != q_.end (); ++it)
+ for (unsigned i = 0; i < (*it).second.npoints (); ++i)
+ bb_.take((*it).second[i]);
+ bb_needs_update_ = false;
+ }
+
+
+ template <typename P, typename T>
+ inline
+ bool
+ p_priority_queue_fast<P, T>::has(const P& p) const
+ {
+ typename std::map<T, p_queue_fast<P> >::const_iterator it = q_.begin ();
+
+ for (; it != q_.end (); ++it)
+ if ((*it).second.has (p))
+ return true;
+ return false;
+ }
+
+ template <typename P, typename T>
+ inline
+ bool
+ p_priority_queue_fast<P, T>::is_empty() const
+ {
+ typename std::map<T, p_queue_fast<P> >::const_iterator it = q_.begin ();
+
+ for (; it != q_.end (); ++it)
+ if (!(*it).second.is_empty ())
+ return false;
+ return true;
+ }
+
+ template <typename P, typename T>
+ inline
+ size_t
+ p_priority_queue_fast<P, T>::npoints() const
+ {
+ unsigned res = 0;
+
+ typename std::map<T, p_queue_fast<P> >::const_iterator it = q_.begin ();
+
+ for (; it != q_.end (); ++it)
+ if (!(*it).second.is_empty ())
+ res += (*it).second.npoints();
+ return res;
+ }
+
+ template <typename P, typename T>
+ inline
+ const box_<P>&
+ p_priority_queue_fast<P, T>::bbox() const
+ {
+ mln_precondition(npoints() != 0);
+ if (bb_needs_update_)
+ bb_update_();
+ return bb_.to_result();
+ }
+
+ template <typename P, typename T>
+ inline
+ p_priority_queue_fast<P, T>&
+ p_priority_queue_fast<P, T>::push_force(const P& p, T prio)
+ {
+ q_[prio].push_force (p);
+ if (! vect_needs_update_)
+ {
+ vect_needs_update_ = true;
+ bb_needs_update_ = true;
+ }
+ return *this;
+ }
+
+ template <typename P, typename T>
+ inline
+ p_priority_queue_fast<P, T>&
+ p_priority_queue_fast<P, T>::push(const P& p, T prio)
+ {
+ if (! has(p))
+ return this->push_force(p, prio);
+ else
+ return *this;
+ }
+
+ template <typename P, typename T>
+ inline
+ void
+ p_priority_queue_fast<P, T>::pop()
+ {
+ typename std::map<T, p_queue_fast<P> >::reverse_iterator it = q_.rbegin ();
+
+ for (; it != q_.rend (); ++it)
+ if (!(*it).second.is_empty ())
+ return (*it).second.pop ();
+
+ if (! vect_needs_update_)
+ {
+ vect_needs_update_ = true;
+ bb_needs_update_ = true;
+ }
+ }
+
+ template <typename P, typename T>
+ inline
+ const P&
+ p_priority_queue_fast<P, T>::front() const
+ {
+ mln_precondition(! q_.empty());
+
+ typename std::map<T, p_queue_fast<P> >::const_reverse_iterator it = q_.rbegin ();
+
+ for (; it != q_.rend (); ++it)
+ if (!(*it).second.is_empty ())
+ break;
+ return (*it).second.front ();
+ }
+
+ template <typename P, typename T>
+ inline
+ const P&
+ p_priority_queue_fast<P, T>::pop_front()
+ {
+ const P& res = this->front();
+
+ this->pop();
+ return res;
+ }
+
+ template <typename P, typename T>
+ inline
+ void
+ p_priority_queue_fast<P, T>::clear()
+ {
+ typename std::map<T, p_queue_fast<P> >::iterator it = q_.begin ();
+
+ for (; it != q_.end (); ++it)
+ (*it).second.clear ();
+ q_.clear();
+ vect_needs_update_ = false;
+ bb_needs_update_ = false;
+ }
+
+ template <typename P, typename T>
+ inline
+ const std::vector<P>&
+ p_priority_queue_fast<P, T>::vect() const
+ {
+ if (vect_needs_update_)
+ vect_update_();
+ return vect_;
+ }
+
+ template <typename P, typename T>
+ inline
+ const P&
+ p_priority_queue_fast<P, T>::operator[](unsigned i) const
+ {
+ mln_precondition(i < npoints());
+
+ typename std::map<T, p_queue_fast<P> >::const_reverse_iterator it = q_.rbegin ();
+ unsigned cpt = 0;
+
+ for (; it != q_.rend (); ++it)
+ {
+ if (!(*it).second.is_empty ())
+ for (cpt = 0; cpt < (*it).second.npoints (); ++cpt)
+ {
+ if (i == 0)
+ return (*it).second[cpt];
+ --i;
+ }
+ }
+ return (*it).second[cpt];
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_P_PRIORITY_QUEUE_FAST_HH
Index: trunk/milena/sandbox/pellegrin/set/core/p_bgraph.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_bgraph.hh (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/core/p_bgraph.hh (revision 1788)
@@ -0,0 +1,232 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_BGRAPH_P_HH
+# define MLN_CORE_BGRAPH_P_HH
+
+# include <utility>
+
+# include <mln/core/concept/point_site.hh>
+# include <mln/core/internal/point_set_base.hh>
+# include <mln/accu/bbox.hh>
+# include <mln/util/internal/boost_graph.hh>
+# include <mln/core/bgraph_psite.hh>
+# include <mln/core/p_bgraph_piter.hh>
+
+
+
+/// \file mln/core/p_bgraph.hh
+/// \brief Definition of a point set based on a boost graph.
+
+namespace mln
+{
+
+ template<typename P> class p_bgraph_piter_;
+
+ namespace trait
+ {
+
+ template <typename P>
+ struct point_set_<line2d> : public default_point_set_<P>
+ {
+ typedef trait::point_set::arity::unique arity;
+ typedef trait::point_set::has_speed::fast has_speed;
+ }
+
+ }
+
+ template<typename P>
+ struct p_bgraph
+ : public internal::point_set_base_< graph_psite<P>, p_bgraph<P> >
+ {
+ typedef util::internal::boost_graph<P, util::empty> graph;
+
+ /// Point_Site associated type.
+ typedef bgraph_psite<P> psite;
+
+ /// Forward Point_Iterator associated type.
+ typedef p_bgraph_piter_<P> fwd_piter;
+
+ /// Backward Point_Iterator associated type.
+ typedef p_bgraph_piter_<P> bkd_piter;
+
+ /// Graph vertex/edge identifier
+ typedef typename graph::vertex_descriptor node_id;
+ typedef typename graph::edge_descriptor edge_id;
+
+ /// Graph vertex/edge iterator
+ typedef typename graph::vertex_iterator node_iterator;
+ typedef typename graph::edge_iterator edge_iterator;
+ typedef std::pair<node_iterator, node_iterator> node_iterators;
+
+
+ /// Construct a graph psite set from a graph of points.
+ /// \p gr is a pointer on a boost graph.
+ /// This boost graph must have been allocated dynamically.
+ p_bgraph (graph* gr);
+
+ /// Return The number of points (i.e., nodes) in the graph.
+ std::size_t npoints() const;
+
+ /// Return The number of lines (i.e., edges) in the graph.
+ std::size_t nlines() const;
+
+ /// Give the exact bounding box.
+ const box_<P>& bbox() const;
+
+ bool has(const psite& p) const;
+
+ /// Return the graph point (FIXME site?) from an index
+ const P& point_from_id(const node_id& id) const;
+ P& point_from_id(const node_id& id);
+
+ /// Return the point contained in the first node adjacent
+ // to the edge id \a e.
+ const P& node1(const edge_id& e) const;
+ /// Return the point contained in the second node adjacent
+ /// to the edge id \a e.
+ const P& node2(const edge_id& e) const;
+
+ /// Return the graph associated to the p_bgraph domain:
+ const graph& to_graph() const;
+ graph& to_graph();
+
+
+ private:
+ graph* gr_;
+ box_<P> bb_;
+ };
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template<typename P>
+ inline
+ p_bgraph<P>::p_bgraph (typename p_bgraph<P>::graph* gr)
+ : gr_ (gr)
+ {
+ mln_precondition(gr != 0);
+ // FIXME: Warning: if the underlying graph is updated later, this
+ // won't be taken into account by this p_bgraph!
+ accu::bbox<P> a;
+
+ for (node_iterators iter = boost::vertices(*gr_);
+ iter.first != iter.second;
+ ++iter.first)
+ a.take((*gr_)[*iter.first]);
+ bb_ = a.to_result();
+ }
+
+ template<typename P>
+ inline
+ std::size_t
+ p_bgraph<P>::npoints() const
+ {
+ return boost::num_vertices(*gr_);
+ }
+
+ template<typename P>
+ inline
+ std::size_t
+ p_bgraph<P>::nlines() const
+ {
+ return boost::num_edges(gr_->nedges());
+ }
+
+ template<typename P>
+ inline
+ const box_<P>&
+ p_bgraph<P>::bbox() const
+ {
+ return bb_;
+ }
+
+ template<typename P>
+ inline
+ bool
+ p_bgraph<P>::has(const psite& p) const
+ {
+ return
+ // Check whether P is compatible with this psite set.
+ (&p.pg() == this) &&
+ // Check that the node id of P belongs to the range of valid node ids.
+ (p.id() < this->npoints());
+ }
+
+
+ template <typename P>
+ const P&
+ p_bgraph<P>::point_from_id(const typename p_bgraph<P>::node_id& id) const
+ {
+ return this->gr_->operator[](id);
+ }
+
+ template <typename P>
+ P&
+ p_bgraph<P>::point_from_id(const typename p_bgraph<P>::node_id& id)
+ {
+ return this->gr_->operator[](id);
+ }
+
+
+ /// FIXME: Compare to p_bgraph, here we are loosing the vertex ordering
+ /// information. Is it bad??
+ template <typename P>
+ const P&
+ p_bgraph<P>::node1(const typename p_bgraph<P>::edge_id& e) const
+ {
+ return this->point_from_id(source(e, *this->gr_));
+ }
+
+ /// FIXME: same as node1...
+ template <typename P>
+ const P&
+ p_bgraph<P>::node2(const typename p_bgraph<P>::edge_id& e) const
+ {
+ return this->point_from_id(target(e, *this->gr_));
+ }
+
+ template <typename P>
+ const typename p_bgraph<P>::graph&
+ p_bgraph<P>::to_graph() const
+ {
+ return *this->gr_;
+ }
+
+ template <typename P>
+ typename p_bgraph<P>::graph&
+ p_bgraph<P>::to_graph()
+ {
+ return *this->gr_;
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of mln
+
+
+#endif // MLN_CORE_BGRAPH_P_HH
Index: trunk/milena/sandbox/pellegrin/set/core/p_queue.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_queue.hh (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/core/p_queue.hh (revision 1788)
@@ -0,0 +1,309 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_P_QUEUE_HH
+# define MLN_CORE_P_QUEUE_HH
+
+/*! \file mln/core/p_queue.hh
+ *
+ * \brief Definition of a point set class based on std::deque.
+ */
+
+# include <vector>
+# include <deque>
+# include <algorithm>
+# include <iterator>
+
+# include <mln/core/internal/point_set_base.hh>
+# include <mln/core/p_array_piter.hh>
+# include <mln/accu/bbox.hh>
+
+
+namespace mln
+{
+
+ // Fwd decls.
+ template <typename P> struct p_array_fwd_piter_;
+ template <typename P> struct p_array_bkd_piter_;
+
+ namespace trait
+ {
+
+ template <typename P>
+ struct point_set_<line2d> : public default_point_set_<P>
+ {
+ typedef trait::point_set::arity::unique arity;
+ typedef trait::point_set::has_speed::fast has_speed;
+ }
+
+ }
+
+ /*! \brief Point queue class (based on std::deque).
+ *
+ * This is a mathematical set of points (unique insertion).
+ *
+ * \todo Make it work with P being a Point_Site.
+ * \todo Add a parameter flag to choose another policy for "push"
+ * (i.e., no-op if multiple or allow multiple insertions).
+ *
+ * \warning We have some troubles with point set comparison based on
+ * a call to npoints() when this container is multiple.
+ */
+ template <typename P>
+ class p_queue : public internal::point_set_base_< P, p_queue<P> >
+ {
+ public:
+
+ /// Forward Point_Iterator associated type.
+ typedef p_array_fwd_piter_<P> fwd_piter;
+
+ /// Backward Point_Iterator associated type.
+ typedef p_array_bkd_piter_<P> bkd_piter;
+
+ /// Constructor.
+ p_queue();
+
+ /// Test is \p p belongs to this point set.
+ bool has(const P& p) const;
+
+ /// Test if queue is empty or not.
+ bool is_empty() const;
+
+ /// Give the number of points.
+ std::size_t npoints() const;
+
+ /// Give the exact bounding box.
+ const box_<P>& bbox() const;
+
+ /// Push force a point \p p in the queue.
+ p_queue<P>& push_force(const P& p);
+
+ /// Push a point \p p in the queue.
+ p_queue<P>& push(const P& p);
+
+ /// Pop (remove) the front point \p p from the queue; \p p is the
+ /// least recently inserted point.
+ void pop();
+
+ /// Give the front point \p p of the queue; \p p is the least
+ /// recently inserted point.
+ const P& front() const;
+
+ /// Give the front point \p p of the queue; \p p is the least
+ /// recently inserted point and pop (remove) the front point \p p
+ /// from the queue; \p p is the least recently inserted point.
+ const P& pop_front();
+
+ /// Clear the queue.
+ void clear();
+
+ /// Return the corresponding std::vector of points.
+ const std::vector<P>& vect() const;
+
+ /// Return the \p i-th point.
+ const P& operator[](unsigned i) const;
+
+ protected:
+
+ std::deque<P> q_;
+
+ mutable std::vector<P> vect_;
+ mutable bool vect_needs_update_;
+ void vect_update_() const;
+
+ mutable accu::bbox<P> bb_;
+ mutable bool bb_needs_update_;
+ void bb_update_() const;
+
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P>
+ inline
+ p_queue<P>::p_queue()
+ {
+ vect_needs_update_ = false;
+ bb_needs_update_ = false;
+ }
+
+ template <typename P>
+ inline
+ void
+ p_queue<P>::vect_update_() const
+ {
+ vect_.clear();
+ vect_.reserve(q_.size());
+ std::copy(q_.begin(), q_.end(),
+ std::back_inserter(vect_));
+ vect_needs_update_ = false;
+ }
+
+ template <typename P>
+ inline
+ void
+ p_queue<P>::bb_update_() const
+ {
+ bb_.init();
+ for (unsigned i = 0; i < q_.size(); ++i)
+ bb_.take(q_[i]);
+ bb_needs_update_ = false;
+ }
+
+ template <typename P>
+ inline
+ bool
+ p_queue<P>::has(const P& p) const
+ {
+ for (unsigned i = 0; i < q_.size(); ++i)
+ if (q_[i] == p)
+ return true;
+ return false;
+ }
+
+ template <typename P>
+ inline
+ bool
+ p_queue<P>::is_empty() const
+ {
+ return (q_.empty());
+ }
+
+ template <typename P>
+ inline
+ std::size_t
+ p_queue<P>::npoints() const
+ {
+ return q_.size();
+ }
+
+ template <typename P>
+ inline
+ const box_<P>&
+ p_queue<P>::bbox() const
+ {
+ mln_precondition(npoints() != 0);
+ if (bb_needs_update_)
+ bb_update_();
+ return bb_.to_result();
+ }
+
+ template <typename P>
+ inline
+ p_queue<P>&
+ p_queue<P>::push_force(const P& p)
+ {
+ q_.push_back(p);
+ if (! vect_needs_update_)
+ {
+ vect_needs_update_ = true;
+ bb_needs_update_ = true;
+ }
+ return *this;
+ }
+
+ template <typename P>
+ inline
+ p_queue<P>&
+ p_queue<P>::push(const P& p)
+ {
+ mln_precondition(! has(p));
+ // FIXME: Our choice is "error if multiple insertions"
+ return this->push_force(p);
+ }
+
+ template <typename P>
+ inline
+ void
+ p_queue<P>::pop()
+ {
+ q_.pop_front();
+ if (! vect_needs_update_)
+ {
+ vect_needs_update_ = true;
+ bb_needs_update_ = true;
+ }
+ }
+
+ template <typename P>
+ inline
+ const P&
+ p_queue<P>::front() const
+ {
+ mln_precondition(! q_.empty());
+ return q_.front();
+ }
+
+ template <typename P>
+ inline
+ const P&
+ p_queue<P>::pop_front()
+ {
+ const P& res = this->front();
+
+ this->pop();
+ return res;
+ }
+
+ template <typename P>
+ inline
+ void
+ p_queue<P>::clear()
+ {
+ q_.clear();
+ vect_.clear();
+ vect_needs_update_ = false;
+ bb_needs_update_ = false;
+ }
+
+ template <typename P>
+ inline
+ const std::vector<P>&
+ p_queue<P>::vect() const
+ {
+ if (vect_needs_update_)
+ vect_update_();
+ return vect_;
+ }
+
+ template <typename P>
+ inline
+ const P&
+ p_queue<P>::operator[](unsigned i) const
+ {
+ mln_precondition(i < npoints());
+ return q_[i];
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_P_QUEUE_HH
Index: trunk/milena/sandbox/pellegrin/set/core/p_priority_queue.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_priority_queue.hh (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/core/p_priority_queue.hh (revision 1788)
@@ -0,0 +1,361 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_P_PRIORITY_QUEUE_HH
+# define MLN_CORE_P_PRIORITY_QUEUE_HH
+
+/*! \file mln/core/p_priority_queue.hh
+ *
+ * \brief Definition of a point set class based on p_queue with
+ * priority features.
+ */
+
+# include <vector>
+# include <deque>
+# include <map>
+# include <algorithm>
+# include <iterator>
+
+# include <mln/core/internal/point_set_base.hh>
+# include <mln/core/p_array_piter.hh>
+# include <mln/accu/bbox.hh>
+# include <mln/core/p_queue.hh>
+
+namespace mln
+{
+
+ // Fwd decls.
+ template <typename P> struct p_array_fwd_piter_;
+ template <typename P> struct p_array_bkd_piter_;
+
+ namespace trait
+ {
+
+ template <typename P>
+ struct point_set_<line2d> : public default_point_set_<P>
+ {
+ typedef trait::point_set::arity::unique arity;
+ typedef trait::point_set::has_speed::fast has_speed;
+ }
+
+ }
+
+ /*! \brief Point priority queue class (based on p_queue and std::map).
+ *
+ * This is a mathematical set of points (unique insertion).
+ *
+ * \todo Make it work with P being a Point_Site.
+ *
+ * \warning We have some troubles with point set comparison based on
+ * a call to npoints() when this container is multiple.
+ */
+ template <typename P, typename T>
+ class p_priority_queue : public internal::point_set_base_< P, p_priority_queue<P, T> >
+ {
+ public:
+
+ /// Forward Point_Iterator associated type.
+ typedef p_array_fwd_piter_<P> fwd_piter;
+
+ /// Backward Point_Iterator associated type.
+ typedef p_array_bkd_piter_<P> bkd_piter;
+
+ /// Constructor.
+ p_priority_queue();
+
+ /// Test is \p p belongs to this point set.
+ bool has(const P& p) const;
+
+ /// Test if queue is empty or not.
+ bool is_empty() const;
+
+ /// Give the number of points.
+ size_t npoints() const;
+
+ /// Give the exact bounding box.
+ const box_<P>& bbox() const;
+
+ /// Push force a point \p p in the queue.
+ p_priority_queue<P, T>& push_force(const P& p, T prio = 0);
+
+ /// Push a point \p p in the queue.
+ p_priority_queue<P, T>& push(const P& p, T prio = 0);
+
+ /// Pop (remove) the front point \p p from the queue; \p p is the
+ /// least recently inserted point.
+ void pop();
+
+ /// Give the front point \p p of the queue; \p p is the least
+ /// recently inserted point.
+ const P& front() const;
+
+ /// Pop (remove) the front point \p p from the queue; \p p is the
+ /// least recently inserted point and give the front point \p p of
+ /// the queue; \p p is the least recently inserted point.
+ const P& pop_front();
+
+ /// Clear the queue.
+ void clear();
+
+ /// Return the corresponding std::vector of points.
+ const std::vector<P>& vect() const;
+
+ /// Return the \p i-th point.
+ const P& operator[](unsigned i) const;
+
+ protected:
+
+ std::map<const T, p_queue<P> > q_;
+
+ mutable std::vector<P> vect_;
+ mutable bool vect_needs_update_;
+ void vect_update_() const;
+
+ mutable accu::bbox<P> bb_;
+ mutable bool bb_needs_update_;
+ void bb_update_() const;
+
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P, typename T>
+ inline
+ p_priority_queue<P, T>::p_priority_queue()
+ {
+ vect_needs_update_ = false;
+ bb_needs_update_ = false;
+ }
+
+ template <typename P, typename T>
+ inline
+ void
+ p_priority_queue<P, T>::vect_update_() const
+ {
+ vect_.clear();
+ vect_.reserve(npoints());
+
+ typename std::map<T, p_queue<P> >::const_iterator it = q_.begin ();
+
+ for (; it != q_.end (); ++it)
+ std::copy((*it).second.vect().begin(), (*it).second.vect().end(),
+ std::back_inserter(vect_));
+ vect_needs_update_ = false;
+ }
+
+ template <typename P, typename T>
+ inline
+ void
+ p_priority_queue<P, T>::bb_update_() const
+ {
+ bb_.init();
+
+ typename std::map<T, p_queue<P> >::const_iterator it = q_.begin ();
+
+ for (; it != q_.end (); ++it)
+ for (unsigned i = 0; i < (*it).second.npoints (); ++i)
+ bb_.take((*it).second[i]);
+ bb_needs_update_ = false;
+ }
+
+
+ template <typename P, typename T>
+ inline
+ bool
+ p_priority_queue<P, T>::has(const P& p) const
+ {
+ typename std::map<T, p_queue<P> >::const_iterator it = q_.begin ();
+
+ for (; it != q_.end (); ++it)
+ if ((*it).second.has (p))
+ return true;
+ return false;
+ }
+
+ template <typename P, typename T>
+ inline
+ bool
+ p_priority_queue<P, T>::is_empty() const
+ {
+ typename std::map<T, p_queue<P> >::const_iterator it = q_.begin ();
+
+ for (; it != q_.end (); ++it)
+ if (!(*it).second.is_empty ())
+ return false;
+ return true;
+ }
+
+ template <typename P, typename T>
+ inline
+ size_t
+ p_priority_queue<P, T>::npoints() const
+ {
+ unsigned res = 0;
+
+ typename std::map<T, p_queue<P> >::const_iterator it = q_.begin ();
+
+ for (; it != q_.end (); ++it)
+ if (!(*it).second.is_empty ())
+ res += (*it).second.npoints();
+ return res;
+ }
+
+ template <typename P, typename T>
+ inline
+ const box_<P>&
+ p_priority_queue<P, T>::bbox() const
+ {
+ mln_precondition(npoints() != 0);
+ if (bb_needs_update_)
+ bb_update_();
+ return bb_.to_result();
+ }
+
+ template <typename P, typename T>
+ inline
+ p_priority_queue<P, T>&
+ p_priority_queue<P, T>::push_force(const P& p, T prio)
+ {
+ q_[prio].push_force (p);
+ if (! vect_needs_update_)
+ {
+ vect_needs_update_ = true;
+ bb_needs_update_ = true;
+ }
+ return *this;
+ }
+
+ template <typename P, typename T>
+ inline
+ p_priority_queue<P, T>&
+ p_priority_queue<P, T>::push(const P& p, T prio)
+ {
+ if (! has(p))
+ return this->push_force(p, prio);
+ else
+ return *this;
+ }
+
+ template <typename P, typename T>
+ inline
+ void
+ p_priority_queue<P, T>::pop()
+ {
+ typename std::map<T, p_queue<P> >::reverse_iterator it = q_.rbegin ();
+
+ for (; it != q_.rend (); ++it)
+ if (!(*it).second.is_empty ())
+ return (*it).second.pop ();
+
+ if (! vect_needs_update_)
+ {
+ vect_needs_update_ = true;
+ bb_needs_update_ = true;
+ }
+ }
+
+ template <typename P, typename T>
+ inline
+ const P&
+ p_priority_queue<P, T>::front() const
+ {
+ mln_precondition(! q_.empty());
+
+ typename std::map<T, p_queue<P> >::const_reverse_iterator it = q_.rbegin ();
+
+ for (; it != q_.rend (); ++it)
+ if (!(*it).second.is_empty ())
+ break;
+ return (*it).second.front ();
+ }
+
+ template <typename P, typename T>
+ inline
+ const P&
+ p_priority_queue<P, T>::pop_front()
+ {
+ const P& res = this->front();
+
+ this->pop();
+ return res;
+ }
+
+ template <typename P, typename T>
+ inline
+ void
+ p_priority_queue<P, T>::clear()
+ {
+ typename std::map<T, p_queue<P> >::iterator it = q_.begin ();
+
+ for (; it != q_.end (); ++it)
+ (*it).second.clear ();
+ q_.clear();
+ vect_needs_update_ = false;
+ bb_needs_update_ = false;
+ }
+
+ template <typename P, typename T>
+ inline
+ const std::vector<P>&
+ p_priority_queue<P, T>::vect() const
+ {
+ if (vect_needs_update_)
+ vect_update_();
+ return vect_;
+ }
+
+ template <typename P, typename T>
+ inline
+ const P&
+ p_priority_queue<P, T>::operator[](unsigned i) const
+ {
+ mln_precondition(i < npoints());
+
+ typename std::map<T, p_queue<P> >::const_reverse_iterator it = q_.rbegin ();
+ unsigned cpt = 0;
+
+ for (; it != q_.rend (); ++it)
+ {
+ if (!(*it).second.is_empty ())
+ for (cpt = 0; cpt < (*it).second.npoints (); ++cpt)
+ {
+ if (i == 0)
+ return (*it).second[cpt];
+ --i;
+ }
+ }
+ return (*it).second[cpt];
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_P_PRIORITY_QUEUE_HH
Index: trunk/milena/sandbox/pellegrin/set/core/p_line_graph.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_line_graph.hh (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/core/p_line_graph.hh (revision 1788)
@@ -0,0 +1,176 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_LINE_GRAPH_P_HH
+# define MLN_CORE_LINE_GRAPH_P_HH
+
+# include <mln/core/concept/point_site.hh>
+# include <mln/core/internal/point_set_base.hh>
+# include <mln/accu/bbox.hh>
+# include <mln/util/graph.hh>
+# include <mln/core/line_graph_psite.hh>
+# include <mln/core/p_line_graph_piter.hh>
+# include <mln/core/point_pair.hh>
+
+/* FIXME: This class shares a lot with p_graph. Factor as much as
+ possible. */
+
+
+/// \file mln/core/p_line_graph.hh
+/// \brief Definition of a point set based on line graph.
+
+namespace mln
+{
+
+ // FIXME: Dummy specialization, only to have this first version of
+ // our code compile.
+ template <typename P>
+ struct box_< point_pair<P> > : public Box< box_<P> >
+ {
+ // Nothing.
+ };
+
+
+ template<typename P> class p_line_graph_piter_;
+
+ namespace trait
+ {
+
+ template <typename P>
+ struct point_set_<line2d> : public default_point_set_<P>
+ {
+ typedef trait::point_set::arity::unique arity;
+ typedef trait::point_set::has_speed::fast has_speed;
+ }
+
+ }
+
+ template<typename P>
+ struct p_line_graph
+ : public internal::point_set_base_< line_graph_psite<P>, p_line_graph<P> >
+ {
+ typedef util::graph<P> graph;
+
+ /// Construct a line graph psite set from a graph of points.
+ p_line_graph (graph& gr);
+
+ /// Point_Site associated type.
+ typedef line_graph_psite<P> psite;
+
+ /// Point associated type.
+ typedef point_pair<P> point;
+
+ /// Forward Point_Iterator associated type.
+ typedef p_line_graph_piter_<P> fwd_piter;
+
+ /// Backward Point_Iterator associated type.
+ typedef p_line_graph_piter_<P> bkd_piter;
+
+ /// Return The number of points (i.e., nodes) in the graph.
+ std::size_t npoints() const;
+
+ /// Return The number of lines (i.e., edges) in the graph.
+ std::size_t nlines() const;
+
+ /// Give the exact bounding box.
+ // FIXME: Dummy.
+ const box_<point>& bbox() const;
+
+ bool has(const psite& p) const;
+
+ // FIXME: Should be private.
+ graph gr_;
+ // FIXME: (Roland) Is it really useful/needed?
+ /* 2007-12-19: It seems so, since graph_image must implement a
+ method named bbox(). Now the question is: should each image
+ type have a bounding box? In particular, an image whose sites
+ are actually /pairs of points/! */
+ // FIXME: Dummy.
+ box_<point> bb_;
+ };
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template<typename P>
+ inline
+ p_line_graph<P>::p_line_graph (util::graph<P>& gr)
+ : gr_ (gr)
+ {
+ // FIXME: Dummy initialization of bb_.
+// // FIXME: Warning: if the underlying graph is updated later, this
+// // won't be taken into account by this p_line_graph!
+// accu::bbox<point> a;
+// for (util::edge_id e = 0; e < nlines(); ++e)
+// a.take(point(gr_.node_data(gr_.edge(e).n1()),
+// gr_.node_data(gr_.edge(e).n2())));
+// bb_ = a.to_result();
+ }
+
+ // FIXME: Rename to npsites? In fact, this depends on the
+ // interface expected from models of Point_Sets.
+ template<typename P>
+ inline
+ std::size_t
+ p_line_graph<P>::npoints() const
+ {
+ return this->gr_.nnodes();
+ }
+
+ template<typename P>
+ inline
+ std::size_t
+ p_line_graph<P>::nlines() const
+ {
+ return this->gr_.nedges();
+ }
+
+ template<typename P>
+ inline
+ const box_< point_pair<P> >&
+ p_line_graph<P>::bbox() const
+ {
+ return bb_;
+ }
+
+ template<typename P>
+ inline
+ bool
+ p_line_graph<P>::has(const psite& p) const
+ {
+ return
+ // Check whether P is compatible with this psite set.
+ (&p.plg() == this) &&
+ // Check that the edge id of P belongs to the range of valid edge ids.
+ (p.id() < gr_.nedges());
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of mln
+
+
+#endif // MLN_CORE_P_GRAPH_HH
Index: trunk/milena/sandbox/pellegrin/set/core/pset_if.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/pset_if.hh (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/core/pset_if.hh (revision 1788)
@@ -0,0 +1,226 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_PSET_IF_HH
+# define MLN_CORE_PSET_IF_HH
+
+/*! \file mln/core/pset_if.hh
+ *
+ * \brief Definition of the restriction of a point set w.r.t. a predicate.
+ */
+
+# include <mln/core/internal/point_set_base.hh>
+# include <mln/core/concept/function.hh>
+
+
+namespace mln
+{
+
+ // Fwd decls.
+ template <typename S, typename F> struct pset_if;
+ template <typename S, typename F> struct pset_if_fwd_piter_;
+ template <typename S, typename F> struct pset_if_bkd_piter_;
+
+ namespace trait
+ {
+
+ template <typename P>
+ struct point_set_< pset_if<> > : public default_point_set_<P>
+ {
+ typedef trait::point_set::arity::unique arity;
+ typedef trait::point_set::has_speed::fast has_speed;
+ }
+
+ }
+
+ /*! \brief Restrict a point set \p pset to points that verify \p f.
+ *
+ * \param[in] pset A point set.
+ * \param[in] f A function from point to Boolean.
+ * \return A subset of points.
+ */
+ template <typename S, typename F>
+ pset_if<S, F>
+ operator | (const Point_Set<S>& pset, const Function_p2b<F>& f);
+
+
+
+ /*! \brief Generic subset class.
+ *
+ * Parameter \c S is a point set type; parameter F is a function
+ * from point to Boolean.
+ */
+ template <typename S, typename F>
+ class pset_if : public internal::point_set_base_< mln_psite(S), pset_if<S,F> >
+ {
+ typedef pset_if<S,F> self_;
+ typedef internal::point_set_base_<mln_psite(S), self_> super_;
+ public:
+
+ typedef mln_psite(super_) psite;
+
+ /// Forward Point_Iterator associated type.
+ typedef pset_if_fwd_piter_<S,F> fwd_piter;
+
+ /// Backward Point_Iterator associated type.
+ typedef mln::internal::fixme bkd_piter;
+
+
+ /// Constructor with a point set \p pset and a predicate \p f.
+ pset_if(const S& pset, const F& f);
+
+ /// Constructor without argument.
+ pset_if();
+
+
+ /// Test if \p p belongs to the subset.
+ bool has(const psite& p) const;
+
+ /// Give a bounding box of the subset.
+ const box_<mln_point(S)>& bbox() const;
+
+ /// Give the number of points of the subset.
+ std::size_t npoints() const;
+
+ /// Give the primary overset.
+ const S& overset() const;
+
+ /// Test predicate on point site \p p.
+ bool pred(const psite& p) const;
+
+ /// Give the predicate function.
+ const F& predicate() const;
+
+ protected:
+
+ S pset_;
+ F f_;
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename S, typename F>
+ inline
+ pset_if<S, F>
+ operator | (const Point_Set<S>& pset, const Function_p2b<F>& f)
+ {
+ pset_if<S, F> tmp(exact(pset), exact(f));
+ return tmp;
+ }
+
+
+ // pset_if<S,F>
+
+ template <typename S, typename F>
+ inline
+ bool
+ pset_if<S,F>::has(const psite& p) const
+ {
+ return pset_.has(p) && f_(p);
+ }
+
+ template <typename S, typename F>
+ inline
+ const box_<mln_point(S)>&
+ pset_if<S,F>::bbox() const
+ {
+ return pset_.bbox();
+ }
+
+ template <typename S, typename F>
+ inline
+ const S&
+ pset_if<S,F>::overset() const
+ {
+ return pset_;
+ }
+
+ template <typename S, typename F>
+ inline
+ bool
+ pset_if<S,F>::pred(const psite& p) const
+ {
+ return f_(p);
+ }
+
+ template <typename S, typename F>
+ inline
+ pset_if<S,F>::pset_if(const S& pset, const F& f)
+ : pset_(pset),
+ f_(f)
+ {
+ }
+
+ template <typename S, typename F>
+ inline
+ pset_if<S,F>::pset_if()
+ {
+ }
+
+ template <typename S, typename F>
+ inline
+ const F&
+ pset_if<S,F>::predicate() const
+ {
+ return f_;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+
+# include <mln/core/pset_if_piter.hh>
+
+
+
+namespace mln
+{
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename S, typename F>
+ std::size_t
+ pset_if<S,F>::npoints() const
+ {
+ std::size_t n = 0;
+ fwd_piter p(*this);
+ for_all(p)
+ ++n;
+ return n;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_PSET_IF_HH
Index: trunk/milena/sandbox/pellegrin/set/core/p_set.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_set.hh (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/core/p_set.hh (revision 1788)
@@ -0,0 +1,191 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_P_SET_HH
+# define MLN_CORE_P_SET_HH
+
+/*! \file mln/core/p_set.hh
+ *
+ * \brief Definition of a point set class based on std::set.
+ */
+
+# include <mln/core/internal/point_set_base.hh>
+# include <mln/core/internal/set_of.hh>
+# include <mln/accu/bbox.hh>
+# include <mln/core/p_array.hh>
+
+
+namespace mln
+{
+
+ namespace trait
+ {
+
+ template <typename P>
+ struct point_set_<line2d> : public default_point_set_<P>
+ {
+ typedef trait::point_set::arity::unique arity;
+ typedef trait::point_set::has_speed::fast has_speed;
+ }
+
+ }
+
+ /*! \brief Point set class based on std::set.
+ *
+ * This is a mathematical set of points (not a multi-set). The
+ * parameter \p P shall be a Point type.
+ *
+ * \todo Test if \p P being a Point_Site is ok.
+ */
+ template <typename P>
+ class p_set : public internal::point_set_base_< P, p_set<P> >,
+ private internal::set_of_<P>
+ {
+ typedef internal::set_of_<P> super_;
+
+ public:
+
+ /// Forward Point_Iterator associated type.
+ typedef p_array_fwd_piter_<P> fwd_piter;
+
+ /// Backward Point_Iterator associated type.
+ typedef p_array_bkd_piter_<P> bkd_piter;
+
+ /// Constructor.
+ p_set();
+
+ /// Test is \p p belongs to this point set.
+ bool has(const P& p) const;
+
+ /// Return the corresponding std::vector of points.
+ using super_::vect;
+
+ /// Give the number of points.
+ std::size_t npoints() const;
+
+ /// Insert a point \p p.
+ p_set<P>& insert(const P& p);
+
+ // FIXME : doesn't compile
+ // /// Remove a point \p p.
+ // p_set<P>& remove(P& p);
+
+ /// Return the \p i-th point.
+ const P& operator[](unsigned i) const;
+
+ /// Clear this set.
+ void clear();
+
+ /// Give the exact bounding box.
+ const box_<mln_point(P)>& bbox() const;
+
+ protected:
+
+ accu::bbox<P> bb_;
+ // FIXME: Add invariant bb_.is_valid() <=> npoints() != 0
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P>
+ inline
+ p_set<P>::p_set()
+ {
+ }
+
+ template <typename P>
+ inline
+ bool
+ p_set<P>::has(const P& p) const
+ {
+ return this->super_::has(p);
+ }
+
+ template <typename P>
+ inline
+ std::size_t
+ p_set<P>::npoints() const
+ {
+ return this->super_::nelements();
+ }
+
+ template <typename P>
+ inline
+ p_set<P>&
+ p_set<P>::insert(const P& p)
+ {
+ this->super_::insert(p);
+ bb_.take(p);
+ return *this;
+ }
+
+
+ // FIXME : finish it.
+ // template <typename P>
+ // p_set<P>&
+ // p_set<P>::remove(P& p)
+ // {
+ // this->super_::remove(p);
+ // // FIXME: need to rebuild bb_ ?
+ // //bb_.untake(p);
+ // return *this;
+ // }
+
+ template <typename P>
+ inline
+ const P&
+ p_set<P>::operator[](unsigned i) const
+ {
+ mln_precondition(i < npoints());
+ return this->super_::element(i);
+ }
+
+ template <typename P>
+ inline
+ void
+ p_set<P>::clear()
+ {
+ this->super_::clear();
+ bb_.init();
+ }
+
+ template <typename P>
+ inline
+ const box_<mln_point(P)>&
+ p_set<P>::bbox() const
+ {
+ mln_precondition(npoints() != 0);
+ return bb_.to_result();
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_P_SET_HH
Index: trunk/milena/sandbox/pellegrin/set/core/p_priority_queue_fast_with_array.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_priority_queue_fast_with_array.hh (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/core/p_priority_queue_fast_with_array.hh (revision 1788)
@@ -0,0 +1,347 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_P_PRIORITY_QUEUE_FAST_WITH_ARRAY_HH
+# define MLN_CORE_P_PRIORITY_QUEUE_FAST_WITH_ARRAY_HH
+
+/*! \file mln/core/p_priority_queue_fast_with_array.hh
+ *
+ * \brief Definition of a point set class based on p_queue with
+ * priority features.
+ */
+
+# include <vector>
+# include <deque>
+# include <map>
+# include <algorithm>
+# include <iterator>
+
+# include <mln/core/internal/point_set_base.hh>
+# include <mln/core/p_array_piter.hh>
+# include <mln/accu/bbox.hh>
+# include <mln/core/p_queue_fast.hh>
+
+namespace mln
+{
+
+ // Fwd decls.
+ template <typename P> struct p_array_fwd_piter_;
+ template <typename P> struct p_array_bkd_piter_;
+
+ namespace trait
+ {
+
+ template <typename P>
+ struct point_set_<line2d> : public default_point_set_<P>
+ {
+ typedef trait::point_set::arity::unique arity;
+ typedef trait::point_set::has_speed::fast has_speed;
+ }
+
+ }
+
+ /*! \brief Point queue class (based on std::vector and p_queue_fast).
+ *
+ * This is a mathematical set of points (unique insertion).
+ *
+ * \todo Make it work with P being a Point_Site.
+ *
+ * \warning We have some troubles with point set comparison based on
+ * a call to npoints() when this container is multiple.
+ */
+ template <typename P, typename T, unsigned S>
+ class p_priority_queue_fast_with_array : public internal::point_set_base_< P, p_priority_queue_fast_with_array<P, T, S> >
+ {
+ public:
+
+ /// Forward Point_Iterator associated type.
+ typedef p_array_fwd_piter_<P> fwd_piter;
+
+ /// Backward Point_Iterator associated type.
+ typedef p_array_bkd_piter_<P> bkd_piter;
+
+ /// Constructor.
+ p_priority_queue_fast_with_array();
+
+ /// Test is \p p belongs to this point set.
+ bool has(const P& p) const;
+
+ /// Test if queue is empty or not.
+ bool is_empty() const;
+
+ /// Give the number of points.
+ unsigned npoints() const;
+
+ /// Give the exact bounding box.
+ const box_<P>& bbox() const;
+
+ /// Push force a point \p p in the queue.
+ p_priority_queue_fast_with_array<P, T, S>& push_force(const P& p, T prio = 0);
+
+ /// Push a point \p p in the queue.
+ p_priority_queue_fast_with_array<P, T, S>& push(const P& p, T prio = 0);
+
+ /// Pop (remove) the front point \p p from the queue; \p p is the
+ /// least recently inserted point.
+ void pop();
+
+ /// Give the front point \p p of the queue; \p p is the least
+ /// recently inserted point.
+ const P& front() const;
+
+ /// Pop (remove) the front point \p p from the queue; \p p is the
+ /// least recently inserted point and give the front point \p p of
+ /// the queue; \p p is the least recently inserted point.
+ const P& pop_front();
+
+ /// Clear the queue.
+ void clear();
+
+ /// Return the corresponding std::vector of points.
+ const std::vector<P>& vect() const;
+
+ /// Return the \p i-th point.
+ const P& operator[](unsigned i) const;
+
+ protected:
+
+ std::vector<p_queue_fast<P> > q_;
+
+ mutable std::vector<P> vect_;
+ mutable bool vect_needs_update_;
+ void vect_update_() const;
+
+ mutable accu::bbox<P> bb_;
+ mutable bool bb_needs_update_;
+ void bb_update_() const;
+
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P, typename T, unsigned S>
+ inline
+ p_priority_queue_fast_with_array<P, T, S>::p_priority_queue_fast_with_array()
+ {
+ vect_needs_update_ = false;
+ bb_needs_update_ = false;
+ q_.reserve(S);
+ std::copy(q_.begin(), q_.end(),
+ std::back_inserter(q_));
+ for (unsigned i = 0; i < S; ++i)
+ q_[i].clear ();
+ }
+
+ template <typename P, typename T, unsigned S>
+ inline
+ void
+ p_priority_queue_fast_with_array<P, T, S>::vect_update_() const
+ {
+ vect_.clear();
+ vect_.reserve(npoints());
+
+ for (unsigned i = 0; i < S; ++i)
+ std::copy(q_[i].vect().begin(), q_[i].vect().end(),
+ std::back_inserter(vect_));
+ vect_needs_update_ = false;
+ }
+
+ template <typename P, typename T, unsigned S>
+ inline
+ void
+ p_priority_queue_fast_with_array<P, T, S>::bb_update_() const
+ {
+ bb_.init();
+
+ for (unsigned i = 0; i < S; ++i)
+ for (unsigned j = 0; j < q_[i].npoints (); ++j)
+ bb_.take(q_[i][j]);
+ bb_needs_update_ = false;
+ }
+
+
+ template <typename P, typename T, unsigned S>
+ inline
+ bool
+ p_priority_queue_fast_with_array<P, T, S>::has(const P& p) const
+ {
+ for (unsigned i = 0; i < S; ++i)
+ if (q_[i].has (p))
+ return true;
+ return false;
+ }
+
+ template <typename P, typename T, unsigned S>
+ inline
+ bool
+ p_priority_queue_fast_with_array<P, T, S>::is_empty() const
+ {
+ for (unsigned i = 0; i < S; ++i)
+ if (!q_[i].is_empty ())
+ return false;
+ return true;
+ }
+
+ template <typename P, typename T, unsigned S>
+ inline
+ unsigned
+ p_priority_queue_fast_with_array<P, T, S>::npoints() const
+ {
+ unsigned res = 0;
+
+ for (unsigned i = 0; i < S; ++i)
+ if (!q_[i].is_empty ())
+ res += q_[i].npoints();
+
+ return res;
+ }
+
+ template <typename P, typename T, unsigned S>
+ inline
+ const box_<P>&
+ p_priority_queue_fast_with_array<P, T, S>::bbox() const
+ {
+ mln_precondition(npoints() != 0);
+ if (bb_needs_update_)
+ bb_update_();
+ return bb_.to_result();
+ }
+
+ template <typename P, typename T, unsigned S>
+ inline
+ p_priority_queue_fast_with_array<P, T, S>&
+ p_priority_queue_fast_with_array<P, T, S>::push_force(const P& p, T prio)
+ {
+ q_[prio].push_force (p);
+ if (! vect_needs_update_)
+ {
+ vect_needs_update_ = true;
+ bb_needs_update_ = true;
+ }
+ mln_assertion(!q_[prio].is_empty ());
+ return *this;
+ }
+
+ template <typename P, typename T, unsigned S>
+ inline
+ p_priority_queue_fast_with_array<P, T, S>&
+ p_priority_queue_fast_with_array<P, T, S>::push(const P& p, T prio)
+ {
+ if (! has(p))
+ return this->push_force(p, prio);
+ else
+ return *this;
+ }
+
+ template <typename P, typename T, unsigned S>
+ inline
+ void
+ p_priority_queue_fast_with_array<P, T, S>::pop()
+ {
+ for (unsigned i = S - 1; i != UINT_MAX; --i)
+ if (!q_[i].is_empty ())
+ return q_[i].pop ();
+
+ if (! vect_needs_update_)
+ {
+ vect_needs_update_ = true;
+ bb_needs_update_ = true;
+ }
+ }
+
+ template <typename P, typename T, unsigned S>
+ inline
+ const P&
+ p_priority_queue_fast_with_array<P, T, S>::front() const
+ {
+ mln_precondition(! is_empty());
+
+ for (unsigned i = S - 1; i != UINT_MAX; --i)
+ if (!q_[i].is_empty ())
+ return q_[i].front ();
+ return q_[0].front ();
+ }
+
+ template <typename P, typename T, unsigned S>
+ inline
+ const P&
+ p_priority_queue_fast_with_array<P, T, S>::pop_front()
+ {
+ const P& res = this->front();
+
+ this->pop();
+ return res;
+ }
+
+ template <typename P, typename T, unsigned S>
+ inline
+ void
+ p_priority_queue_fast_with_array<P, T, S>::clear()
+ {
+ for (unsigned i = 0; i < S; ++i)
+ q_[i].clear ();
+ q_.clear();
+ vect_needs_update_ = false;
+ bb_needs_update_ = false;
+ }
+
+ template <typename P, typename T, unsigned S>
+ inline
+ const std::vector<P>&
+ p_priority_queue_fast_with_array<P, T, S>::vect() const
+ {
+ if (vect_needs_update_)
+ vect_update_();
+ return vect_;
+ }
+
+ template <typename P, typename T, unsigned S>
+ inline
+ const P&
+ p_priority_queue_fast_with_array<P, T, S>::operator[](unsigned n) const
+ {
+ mln_precondition(n < npoints());
+ unsigned i = S - 1;
+ unsigned cpt = 0;
+
+ for (; i != UINT_MAX; --i)
+ if (!q_[i].is_empty ())
+ for (cpt = 0; cpt < q_[i].npoints (); ++cpt, --n)
+ if (n == 0)
+ return q_[i][cpt];
+ mln_assertion (false);
+ return q_[i][cpt];
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_P_PRIORITY_QUEUE_FAST_WITH_ARRAY_HH
Index: trunk/milena/sandbox/pellegrin/set/core/runs_psite.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/runs_psite.hh (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/core/runs_psite.hh (revision 1788)
@@ -0,0 +1,192 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_RUNS_PSITE_HH
+# define MLN_CORE_RUNS_PSITE_HH
+
+/*! \file mln/core/runs_psite.hh
+ *
+ * \brief Definition of class mln::runs_psite_ for internal use only
+ */
+
+# include <mln/core/concept/point_site.hh>
+
+
+namespace mln
+{
+ // Fwd decl.
+ template <typename P> class p_runs_;
+
+ /*! \brief Psite class used in run_image_.
+ *
+ * Parameter \c P is the type of the image point.
+ */
+ template <typename P>
+ class runs_psite : public Point_Site< runs_psite<P> >
+ {
+ public:
+
+ typedef mln_mesh(P) mesh;
+ enum { dim = P::dim };
+ typedef P point;
+ typedef mln_dpoint(P) dpoint;
+ typedef mln_coord(P) coord;
+
+ runs_psite(const p_runs_<P>& pr, unsigned in_run, unsigned of_run);
+
+ operator P () const;
+
+ /// Return the point at the start of the current run.
+ P& range_start_();
+
+ /// Return the point at the start of the current run.
+ const P& range_start_() const;
+
+ /// Return the position of this psite in the point set.
+ unsigned p_of_run() const;
+
+ /// Return the position of this psite in the point set.
+ unsigned& p_of_run();
+
+ /// Return the position of this psite in the current range.
+ unsigned p_in_run() const;
+
+ /// Return the position of this psite in the current range.
+ unsigned& p_in_run();
+
+ /// Reference to the corresponding point.
+ const P& to_point() const;
+
+ /// Give the i-th coordinate of the corresponding point.
+ mln_coord(P) operator[](unsigned i) const;
+
+ protected:
+
+ /// Start of the psite range.
+ const p_runs_<P>& pr_;
+
+ /// Position in the psite range.
+ unsigned p_in_run_;
+
+ /// Position of the psite in the point set.
+ unsigned p_of_run_;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P>
+ inline
+ runs_psite<P>::runs_psite(const p_runs_<P>& pr, unsigned in_run, unsigned of_run)
+ : pr_(pr),
+ p_in_run_(in_run),
+ p_of_run_(of_run)
+ {
+ mln_precondition(of_run < pr.nruns());
+ mln_precondition(in_run < pr[of_run].length());
+ }
+
+ template <typename P>
+ inline
+ runs_psite<P>::operator P() const
+ {
+ return pr_[p_of_run_][p_in_run_];
+ }
+
+ template <typename P>
+ inline
+ const P&
+ runs_psite<P>::range_start_() const
+ {
+ return pr_[p_of_run_].first();
+ }
+
+ template <typename P>
+ inline
+ P&
+ runs_psite<P>::range_start_()
+ {
+ return pr_[p_of_run_].first();
+ }
+
+ template <typename P>
+ inline
+ unsigned
+ runs_psite<P>::p_of_run() const
+ {
+ return p_of_run_;
+ }
+
+ template <typename P>
+ inline
+ unsigned&
+ runs_psite<P>::p_of_run()
+ {
+ return p_of_run_;
+ }
+
+ template <typename P>
+ inline
+ unsigned
+ runs_psite<P>::p_in_run() const
+ {
+ return p_in_run_;
+ }
+
+ template <typename P>
+ inline
+ unsigned&
+ runs_psite<P>::p_in_run()
+ {
+ return p_in_run_;
+ }
+
+ template <typename P>
+ inline
+ const P&
+ runs_psite<P>::to_point() const
+ {
+ static P p = pr_[p_of_run_][p_in_run_];
+ return p;
+ }
+
+ template <typename P>
+ inline
+ mln_coord(P)
+ runs_psite<P>::operator[](unsigned i) const
+ {
+ mln_precondition(i < dim);
+ return pr_[p_of_run_][p_in_run_][i];
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+# include <mln/core/p_runs.hh>
+
+#endif // ! MLN_CORE_INTERNAL_RUNS_PSITE_HH
Index: trunk/milena/sandbox/pellegrin/set/core/line2d.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/line2d.hh (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/core/line2d.hh (revision 1788)
@@ -0,0 +1,208 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_LINE2D_HH
+# define MLN_CORE_LINE2D_HH
+
+/*! \file mln/core/line2d.hh
+ *
+ * \brief Definition of a point set class based on std::vector.
+ */
+
+# include <vector>
+
+# include <mln/core/internal/point_set_base.hh>
+# include <mln/core/p_array_piter.hh>
+# include <mln/core/box2d.hh>
+# include <mln/math/all.hh>
+
+
+namespace mln
+{
+
+ namespace trait
+ {
+
+ template <typename P>
+ struct point_set_<line2d> : public default_point_set_<P>
+ {
+ typedef trait::point_set::arity::unique arity;
+ typedef trait::point_set::has_speed::fast has_speed;
+ }
+
+ }
+
+ /*! \brief 2D line point set class.
+ */
+ class line2d : public internal::point_set_base_< point2d, line2d >
+ {
+ public:
+
+ /// Forward Point_Iterator associated type.
+ typedef p_array_fwd_piter_<point2d> fwd_piter;
+
+ /// Backward Point_Iterator associated type.
+ typedef p_array_bkd_piter_<point2d> bkd_piter;
+
+
+ /// Constructor from point \p beg to point \p end.
+ line2d(const point2d& beg, const point2d& end);
+
+
+ /// Test is \p p belongs to this point set.
+ bool has(const point2d& p) const;
+
+ /// Give the number of points.
+ std::size_t npoints() const;
+
+ /// Give the exact bounding box.
+ const box_<point2d>& bbox() const;
+
+ /// Return the corresponding std::vector of points.
+ const std::vector<point2d>& vect() const;
+
+ /// Return the \p i-th point.
+ const point2d& operator[](unsigned i) const;
+
+ protected:
+
+ point2d beg_, end_;
+ std::vector<point2d> vect_;
+ box2d bb_;
+
+ void compute_();
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ inline
+ line2d::line2d(const point2d& beg, const point2d& end)
+ : beg_(beg),
+ end_(end)
+ {
+ compute_();
+ }
+
+ inline
+ void
+ line2d::compute_()
+ {
+ // vect_
+ dpoint2d dp = end_ - beg_;
+ int
+ srow = math::sign(dp.row()), drow = math::abs(dp.row()), ddrow = 2 * drow,
+ scol = math::sign(dp.col()), dcol = math::abs(dp.col()), ddcol = 2 * dcol,
+ row = beg_.row(),
+ col = beg_.col();
+ if ( dcol > drow )
+ {
+ int e = ddrow - dcol;
+ for (int i = 0; i < dcol; ++i)
+ {
+ vect_.push_back(make::point2d(row, col));
+ while (e >= 0)
+ {
+ row += srow;
+ e -= ddcol;
+ }
+ col += scol;
+ e += ddrow;
+ }
+ }
+ else
+ {
+ int e = ddcol - drow;
+ for (int i = 0; i < drow; ++i)
+ {
+ vect_.push_back(make::point2d(row, col));
+ while (e >= 0)
+ {
+ col += scol;
+ e -= ddrow;
+ }
+ row += srow;
+ e += ddcol;
+ }
+ }
+ vect_.push_back(make::point2d(row, col));
+ // bb_
+ bb_.pmin() = make::point2d(math::min(beg_.row(), end_.row()),
+ math::min(beg_.col(), end_.col()));
+ bb_.pmax() = make::point2d(math::max(beg_.row(), end_.row()),
+ math::max(beg_.col(), end_.col()));
+ }
+
+ inline
+ bool
+ line2d::has(const point2d& p) const
+ {
+ if (! bb_.has(p))
+ return false;
+ // FIXME: Optimize!
+ for (unsigned i = 0; i < vect_.size(); ++i)
+ if (vect_[i] == p)
+ return true;
+ return false;
+ }
+
+ inline
+ std::size_t
+ line2d::npoints() const
+ {
+ return vect_.size();
+ }
+
+ inline
+ const box2d&
+ line2d::bbox() const
+ {
+ return bb_;
+ }
+
+ inline
+ const std::vector<point2d>&
+ line2d::vect() const
+ {
+ return vect_;
+ }
+
+ inline
+ const point2d&
+ line2d::operator[](unsigned i) const
+ {
+ mln_precondition(i < npoints());
+ return vect_[i];
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_LINE2D_HH
Index: trunk/milena/sandbox/pellegrin/set/core/p_array.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_array.hh (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/core/p_array.hh (revision 1788)
@@ -0,0 +1,245 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_P_ARRAY_HH
+# define MLN_CORE_P_ARRAY_HH
+
+/*! \file mln/core/p_array.hh
+ *
+ * \brief Definition of a point set class based on std::vector.
+ */
+
+# include <vector>
+
+# include <mln/core/internal/point_set_base.hh>
+# include <mln/accu/bbox.hh>
+
+
+namespace mln
+{
+
+ // Fwd decls.
+ template <typename P> struct p_array_fwd_piter_;
+ template <typename P> struct p_array_bkd_piter_;
+
+ namespace trait
+ {
+
+ template <typename P>
+ struct point_set_< p_array<P> > : public default_point_set_<P>
+ {
+ typedef trait::point_set::arity::unique arity;
+ typedef trait::point_set::has_speed::fast has_speed;
+ }
+
+ }
+
+ /*! \brief Point set class based on std::vector.
+ *
+ * This is a multi-set of points.
+ *
+ * \warning We have some troubles with point set comparison based on
+ * a call to npoints(). FIXME: Explain!
+ *
+ * \todo Make it work with P being a Point_Site.
+ */
+ template <typename P>
+ class p_array : public internal::point_set_base_< P, p_array<P> >
+ {
+ public:
+
+ /// Forward Point_Iterator associated type.
+ typedef p_array_fwd_piter_<P> fwd_piter;
+
+ /// Backward Point_Iterator associated type.
+ typedef p_array_bkd_piter_<P> bkd_piter;
+
+ /// Constructor.
+ p_array();
+
+ /// Constructor from a vector \p vect.
+ p_array(const std::vector<P>& vect);
+
+ /// Reserve \p n cells.
+ void reserve(std::size_t n);
+
+ /// Test is \p p belongs to this point set.
+ bool has(const P& p) const;
+
+ /// Give the number of points.
+ std::size_t npoints() const;
+
+ /// Give the exact bounding box.
+ const box_<P>& bbox() const;
+
+ /// Append a point \p p.
+ p_array<P>& append(const P& p);
+
+ /// Clear this set.
+ void clear();
+
+ /// Return the corresponding std::vector of points.
+ const std::vector<P>& vect() const;
+
+ /// Return the \p i-th point.
+ const P& operator[](unsigned i) const;
+
+ /// Hook to data.
+ std::vector<P>& hook_();
+
+ protected:
+
+ std::vector<P> vect_;
+ mutable accu::bbox<P> bb_;
+ mutable bool bb_needs_update_;
+
+ void update_bb_() const;
+ // FIXME: Add invariant bb_.is_valid() <=> npoints() != 0
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P>
+ inline
+ p_array<P>::p_array()
+ {
+ bb_needs_update_ = false;
+ }
+
+ template <typename P>
+ inline
+ p_array<P>::p_array(const std::vector<P>& vect)
+ : vect_(vect)
+ {
+ bb_needs_update_ = true;
+ }
+
+ template <typename P>
+ inline
+ void
+ p_array<P>::reserve(std::size_t n)
+ {
+ vect_.reserve(n);
+ }
+
+ template <typename P>
+ inline
+ std::vector<P>&
+ p_array<P>::hook_()
+ {
+ return vect_;
+ }
+
+ template <typename P>
+ inline
+ void
+ p_array<P>::update_bb_() const
+ {
+ bb_.init();
+ for (unsigned i = 0; i < vect_.size(); ++i)
+ bb_.take(vect_[i]);
+ bb_needs_update_ = false;
+ }
+
+ template <typename P>
+ inline
+ bool
+ p_array<P>::has(const P& p) const
+ {
+ for (unsigned i = 0; i < vect_.size(); ++i)
+ if (vect_[i] == p)
+ return true;
+ return false;
+ }
+
+ template <typename P>
+ inline
+ std::size_t
+ p_array<P>::npoints() const
+ {
+ return vect_.size();
+ }
+
+ template <typename P>
+ inline
+ const box_<P>&
+ p_array<P>::bbox() const
+ {
+ mln_precondition(npoints() != 0);
+ if (bb_needs_update_)
+ update_bb_();
+ return bb_.to_result();
+ }
+
+ template <typename P>
+ inline
+ p_array<P>&
+ p_array<P>::append(const P& p)
+ {
+ vect_.push_back(p);
+ if (! bb_needs_update_)
+ bb_needs_update_ = true;
+ return *this;
+ }
+
+ template <typename P>
+ inline
+ void
+ p_array<P>::clear()
+ {
+ vect_.clear();
+ bb_needs_update_ = false;
+ }
+
+ template <typename P>
+ inline
+ const std::vector<P>&
+ p_array<P>::vect() const
+ {
+ return vect_;
+ }
+
+ template <typename P>
+ inline
+ const P&
+ p_array<P>::operator[](unsigned i) const
+ {
+ mln_precondition(i < npoints());
+ return vect_[i];
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+# include <mln/core/p_array_piter.hh>
+
+
+#endif // ! MLN_CORE_P_ARRAY_HH
Index: trunk/milena/sandbox/pellegrin/set/core/concept/point_set.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/concept/point_set.hh (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/core/concept/point_set.hh (revision 1788)
@@ -0,0 +1,252 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_CONCEPT_POINT_SET_HH
+# define MLN_CORE_CONCEPT_POINT_SET_HH
+
+/*! \file mln/core/concept/point_set.hh
+ *
+ * \brief Definition of the concept of mln::Point_Set.
+ *
+ * \todo Think about adding an 'insert' method (not so easy because of
+ * pset_if...)
+ */
+
+# include <mln/core/concept/point_site.hh>
+# include <mln/core/concept/point_iterator.hh>
+# include <mln/trait/point_set.hh>
+
+
+namespace mln
+{
+
+ // Fwd decl.
+ template <typename E> struct Point_Set;
+
+
+ /// Point_Set category flag type.
+ template <>
+ struct Point_Set<void>
+ {
+ typedef Object<void> super;
+ };
+
+
+ /*! \brief Base class for implementation classes of point sets.
+ *
+ * \see mln::doc::Point_Set for a complete documentation of this
+ * class contents.
+ */
+ template <typename E>
+ struct Point_Set : public Object<E>
+ {
+ typedef Point_Set<void> category;
+
+ /*
+ typedef mesh;
+
+ typedef point;
+ typedef psite;
+
+ typedef fwd_piter;
+ typedef bkd_piter;
+
+ bool has(const psite& p) const;
+ const box_<point>& bbox() const;
+ std::size_t npoints() const;
+ */
+
+ protected:
+ Point_Set();
+ };
+
+
+ /*! \brief Equality test between point sets \p lhs and \p rhs.
+ *
+ * \param[in] lhs A point set.
+ * \param[in] rhs Another point set.
+ *
+ * \relates mln::Point_Set
+ */
+ template <typename Sl, typename Sr>
+ bool operator==(const Point_Set<Sl>& lhs, const Point_Set<Sr>& rhs);
+
+
+
+ /*! \brief Inclusion test between point sets \p lhs and \p rhs.
+ *
+ * \param[in] lhs A point set (included?).
+ * \param[in] rhs Another point set (includer?).
+ *
+ * \relates mln::Point_Set
+ */
+ template <typename Sl, typename Sr>
+ bool operator<=(const Point_Set<Sl>& lhs, const Point_Set<Sr>& rhs);
+
+
+
+ /*! \brief Strict inclusion test between point sets \p lhs and \p
+ * rhs.
+ *
+ * \param[in] lhs A point set (strictly included?).
+ * \param[in] rhs Another point set (includer?).
+ *
+ * \relates mln::Point_Set
+ */
+ template <typename Sl, typename Sr>
+ bool operator<(const Point_Set<Sl>& lhs, const Point_Set<Sr>& rhs);
+
+
+
+ /*! \brief Print a point set \p pset into the output stream \p
+ * ostr.
+ *
+ * \param[in,out] ostr An output stream.
+ * \param[in] pset A point set.
+ *
+ * \return The modified output stream \p ostr.
+ *
+ * \relates mln::Point_Set
+ */
+ template <typename S>
+ std::ostream& operator<<(std::ostream& ostr, const Point_Set<S>& pset);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ // fwd decl
+ template <typename P> struct box_;
+
+ template <typename E>
+ inline
+ Point_Set<E>::Point_Set()
+ {
+ typedef mln_mesh(E) mesh;
+
+ typedef mln_point(E) point;
+ typedef mln_psite(E) psite;
+
+ typedef mln_fwd_piter(E) fwd_piter;
+ typedef mln_bkd_piter(E) bkd_piter;
+
+ typedef mln_trait_point_set_arity(P) arity;
+ typedef mln_trait_point_set_has_speed(P) has_speed;
+
+ bool (E::*m1)(const psite& p) const = & E::has;
+ m1 = 0;
+ const box_<point>& (E::*m2)() const = & E::bbox;
+ m2 = 0;
+ std::size_t (E::*m3)() const = & E::npoints;
+ m3 = 0;
+ }
+
+
+ // operators
+
+
+ template <typename Sl, typename Sr>
+ inline
+ bool operator==(const Point_Set<Sl>& lhs_, const Point_Set<Sr>& rhs_)
+ {
+ // FIXME: Same grid!
+ const Sl& lhs = exact(lhs_);
+ const Sr& rhs = exact(rhs_);
+
+ // easy test:
+ if (lhs.npoints() != rhs.npoints())
+ return false;
+
+ // exhaustive test:
+ mln_fwd_piter(Sl) pl(lhs);
+ mln_fwd_piter(Sr) pr(rhs);
+ for (pl.start(), pr.start();
+ pl.is_valid() && pr.is_valid();
+ pl.next(), pr.next())
+ if (pl != pr)
+ return false; // difference found
+
+ // both sets are equal only if both browsings are completed
+ // at the same time:
+ return ! pl.is_valid() && ! pr.is_valid();
+ }
+
+
+ template <typename Sl, typename Sr>
+ inline
+ bool operator<=(const Point_Set<Sl>& lhs_, const Point_Set<Sr>& rhs_)
+ {
+ // FIXME: Same grid!
+ const Sl& lhs = exact(lhs_);
+ const Sr& rhs = exact(rhs_);
+
+ // easy test:
+ if (lhs.npoints() > rhs.npoints())
+ return false;
+
+ // exhaustive test:
+ mln_piter(Sl) pl(lhs);
+ for_all(pl)
+ if (! rhs.has(pl))
+ return false;
+
+ return true;
+ }
+
+
+ template <typename Sl, typename Sr>
+ inline
+ bool operator<(const Point_Set<Sl>& lhs_, const Point_Set<Sr>& rhs_)
+ {
+ // FIXME: Same grid!
+ const Sl& lhs = exact(lhs_);
+ const Sr& rhs = exact(rhs_);
+ return lhs <= rhs && lhs.npoints() != rhs.npoints();
+ }
+
+
+ template <typename S>
+ inline
+ std::ostream& operator<<(std::ostream& ostr, const Point_Set<S>& pset_)
+ {
+ const S& pset = exact(pset_);
+ ostr << '{';
+ mln_piter(S) p(pset);
+ for_all(p)
+ ostr << p;
+ return ostr << '}';
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+# include <mln/core/ops.hh>
+
+
+#endif // ! MLN_CORE_CONCEPT_POINT_SET_HH
Index: trunk/milena/sandbox/pellegrin/set/core/p_graph.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_graph.hh (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/core/p_graph.hh (revision 1788)
@@ -0,0 +1,258 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_P_GRAPH_HH
+# define MLN_CORE_P_GRAPH_HH
+
+# include <mln/core/concept/point_site.hh>
+# include <mln/core/internal/point_set_base.hh>
+# include <mln/accu/bbox.hh>
+# include <mln/util/graph.hh>
+# include <mln/core/graph_psite.hh>
+# include <mln/core/p_graph_piter.hh>
+
+/// \file mln/core/p_graph.hh
+/// \brief Definition of a point set based on graph.
+
+namespace mln
+{
+
+ template<typename P> class p_graph_piter_;
+
+ namespace trait
+ {
+
+ template <typename P>
+ struct point_set_<line2d> : public default_point_set_<P>
+ {
+ typedef trait::point_set::arity::unique arity;
+ typedef trait::point_set::has_speed::fast has_speed;
+ }
+
+ }
+
+ template<typename P>
+ struct p_graph
+ : public internal::point_set_base_< graph_psite<P>, p_graph<P> >
+ {
+ typedef util::graph<P> graph;
+
+ /// Construct a graph psite set from a graph of points.
+ p_graph (graph& gr);
+
+ /// Point_Site associated type.
+ typedef graph_psite<P> psite;
+
+ /// Forward Point_Iterator associated type.
+ typedef p_graph_piter_<P> fwd_piter;
+
+ /// Backward Point_Iterator associated type.
+ typedef p_graph_piter_<P> bkd_piter;
+
+ /// Return The number of points (i.e., nodes) in the graph.
+ std::size_t npoints() const;
+
+ /// Return The number of lines (i.e., edges) in the graph.
+ std::size_t nlines() const;
+
+ /// Give the exact bounding box.
+ const box_<P>& bbox() const;
+
+ bool has(const psite& p) const;
+
+ /// Return the graph point (FIXME site?) from an index
+ const P& point_from_id(const util::node_id& id) const;
+ P& point_from_id(const util::node_id& id);
+
+
+ /// Return the point contained in the first node adjacent
+ // to the edge id \a e.
+ const P& node1(const util::edge_id& e) const;
+ /// Return the point contained in the second node adjacent
+ /// to the edge id \a e.
+ const P& node2(const util::edge_id& e) const;
+
+ /// Return true if the psites lhs and rhs are adjacent, or equal.
+ bool adjacent_or_equal(const psite& lhs, const psite& rhs) const;
+
+ /// Return true if the nodes lhs and rhs are adjacent, or equal
+ bool adjacent_or_equal(const util::node_id& lhs,
+ const util::node_id& rhs) const;
+
+ /// Return the graph associated to the p_graph domain:
+ const graph& to_graph() const;
+ graph& to_graph();
+
+
+ private:
+ graph gr_;
+ // FIXME: (Roland) Is it really useful/needed?
+ /* 2007-12-19: It seems so, since graph_image must implement a method
+ named bbox(). Now the question is: should each image type have a
+ bounding box? */
+ box_<P> bb_;
+ };
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template<typename P>
+ inline
+ p_graph<P>::p_graph (util::graph<P>& gr)
+ : gr_ (gr)
+ {
+ // FIXME: Warning: if the underlying graph is updated later, this
+ // won't be taken into account by this p_graph!
+ accu::bbox<P> a;
+ for (unsigned i = 0; i < npoints(); ++i)
+ a.take(gr_.node_data(i));
+ bb_ = a.to_result();
+ }
+
+ // FIXME: Rename to npsites? In fact, this depends on the
+ // interface expected from models of Point_Sets.
+ template<typename P>
+ inline
+ std::size_t
+ p_graph<P>::npoints() const
+ {
+ return this->gr_.nnodes();
+ }
+
+ template<typename P>
+ inline
+ std::size_t
+ p_graph<P>::nlines() const
+ {
+ return this->gr_.nedges();
+ }
+
+ template<typename P>
+ inline
+ const box_<P>&
+ p_graph<P>::bbox() const
+ {
+ return bb_;
+ }
+
+ template<typename P>
+ inline
+ bool
+ p_graph<P>::has(const psite& p) const
+ {
+ return
+ // Check whether P is compatible with this psite set.
+ (&p.pg() == this) &&
+ // Check that the node id of P belongs to the range of valid node ids.
+ (p.id() < gr_.nnodes());
+ }
+
+ template <typename P>
+ const P&
+ p_graph<P>::point_from_id(const util::node_id& id) const
+ {
+ return this->gr_.node_data(id);
+ }
+
+ template <typename P>
+ P&
+ p_graph<P>::point_from_id(const util::node_id& id)
+ {
+ return this->gr_.node_data(id);
+ }
+
+ template <typename P>
+ const P&
+ p_graph<P>::node1(const util::edge_id& e) const
+ {
+ util::node_id n1 = this->gr_.edge(e).n1();
+ return this->point_from_id(n1);
+ }
+
+ template <typename P>
+ const P&
+ p_graph<P>::node2(const util::edge_id& e) const
+ {
+ util::node_id n2 = this->gr_.edge(e).n2();
+ return this->point_from_id(n2);
+ }
+
+ template <typename P>
+ inline
+ bool
+ p_graph<P>::adjacent_or_equal(const psite& lhs, const psite& rhs) const
+ {
+ assert (&lhs.pg() == this && rhs.pg() == this);
+ return adjacent_or_equal(lhs.id(), rhs.id());
+ }
+
+ template <typename P>
+ inline
+ bool
+ p_graph<P>::adjacent_or_equal(const util::node_id& lhs,
+ const util::node_id& rhs) const
+ {
+ // FIXME: Likewise, this is inefficient.
+
+ assert (lhs < this->npoints());
+ assert (rhs < this->npoints());
+
+ if (rhs == lhs)
+ return true;
+
+ // Check whether the iterator is among the neighbors of P_REF_.
+ typedef std::vector<util::node_id> adjacency_type;
+ const adjacency_type& lhs_neighbs = gr_.nodes()[lhs]->edges;
+
+ adjacency_type::const_iterator j =
+ std::find (lhs_neighbs.begin(), lhs_neighbs.end(), rhs);
+ if (j != lhs_neighbs.end())
+ return true;
+
+ return false;
+ }
+
+ template <typename P>
+ const typename p_graph<P>::graph&
+ p_graph<P>::to_graph() const
+ {
+ return this->gr_;
+ }
+
+ template <typename P>
+ typename p_graph<P>::graph&
+ p_graph<P>::to_graph()
+ {
+ return this->gr_;
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of mln
+
+
+#endif // MLN_CORE_P_GRAPH_HH
Index: trunk/milena/sandbox/pellegrin/set/core/p_queue_fast.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_queue_fast.hh (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/core/p_queue_fast.hh (revision 1788)
@@ -0,0 +1,316 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_P_QUEUE_FAST_HH
+# define MLN_CORE_P_QUEUE_FAST_HH
+
+/*! \file mln/core/p_queue_fast.hh
+ *
+ * \brief Definition of a point set class faster but needs more memory
+ * space.
+ */
+
+# include <vector>
+# include <deque>
+# include <algorithm>
+# include <iterator>
+
+# include <mln/core/internal/point_set_base.hh>
+# include <mln/core/p_array_piter.hh>
+# include <mln/accu/bbox.hh>
+
+
+namespace mln
+{
+
+ // Fwd decls.
+ template <typename P> struct p_array_fwd_piter_;
+ template <typename P> struct p_array_bkd_piter_;
+
+ namespace trait
+ {
+
+ template <typename P>
+ struct point_set_<line2d> : public default_point_set_<P>
+ {
+ typedef trait::point_set::arity::unique arity;
+ typedef trait::point_set::has_speed::fast has_speed;
+ }
+
+ }
+
+ /*! \brief Point queue class (based on std::deque).
+ *
+ * This is a mathematical set of points (unique insertion).
+ *
+ * \todo Make it work with P being a Point_Site.
+ *
+ * \warning We have some troubles with point set comparison based on
+ * a call to npoints() when this container is multiple.
+ */
+ template <typename P>
+ class p_queue_fast : public internal::point_set_base_< P, p_queue_fast<P> >
+ {
+ public:
+
+ /// Forward Point_Iterator associated type.
+ typedef p_array_fwd_piter_<P> fwd_piter;
+
+ /// Backward Point_Iterator associated type.
+ typedef p_array_bkd_piter_<P> bkd_piter;
+
+ /// Constructor.
+ p_queue_fast();
+
+ /// Test is \p p belongs to this point set.
+ bool has(const P& p) const;
+
+ /// Test if queue is empty or not.
+ bool is_empty() const;
+
+ /// Give the number of points.
+ std::size_t npoints() const;
+
+ /// Give the exact bounding box.
+ const box_<P>& bbox() const;
+
+ /// Push force a point \p p in the queue.
+ p_queue_fast<P>& push_force(const P& p);
+
+ /// Push a point \p p in the queue.
+ p_queue_fast<P>& push(const P& p);
+
+ /// Pop (remove) the front point \p p from the queue; \p p is the
+ /// least recently inserted point.
+ void pop();
+
+ /// Give the front point \p p of the queue; \p p is the least
+ /// recently inserted point.
+ const P& front() const;
+
+ /// Pop (remove) the front point \p p from the queue; \p p is the
+ /// least recently inserted point and give the front point \p p of
+ /// the queue; \p p is the least recently inserted point.
+ const P& pop_front();
+
+ /// Clear the queue.
+ void clear();
+
+ /// Return the corresponding std::vector of points.
+ const std::vector<P>& vect() const;
+
+ /// Return the \p i-th point.
+ const P& operator[](unsigned i) const;
+
+ protected:
+
+ std::vector<P> q_;
+ std::size_t begin_;
+ std::size_t end_;
+
+ mutable std::vector<P> vect_;
+ mutable bool vect_needs_update_;
+ void vect_update_() const;
+
+ mutable accu::bbox<P> bb_;
+ mutable bool bb_needs_update_;
+ void bb_update_() const;
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P>
+ inline
+ p_queue_fast<P>::p_queue_fast()
+ {
+ // vect_needs_update_ = false;
+ bb_needs_update_ = false;
+ begin_ = 0;
+ end_ = 0;
+ }
+
+ template <typename P>
+ inline
+ void
+ p_queue_fast<P>::vect_update_() const
+ {
+ vect_.clear();
+ vect_.reserve(q_.size());
+ std::copy(q_.begin(), q_.end(),
+ std::back_inserter(vect_));
+ vect_needs_update_ = false;
+ }
+
+ template <typename P>
+ inline
+ void
+ p_queue_fast<P>::bb_update_() const
+ {
+ bb_.init();
+ for (std::size_t i = this->begin_; i < this->end_; ++i)
+ bb_.take(q_[i]);
+ bb_needs_update_ = false;
+ }
+
+ template <typename P>
+ inline
+ bool
+ p_queue_fast<P>::has(const P& p) const
+ {
+ for (unsigned i = this->begin_; i < this->end_; ++i)
+ if (q_[i] == p)
+ return true;
+ return false;
+ }
+
+ template <typename P>
+ inline
+ bool
+ p_queue_fast<P>::is_empty() const
+ {
+ return (this->begin_ == this->end_);
+ }
+
+ template <typename P>
+ inline
+ std::size_t
+ p_queue_fast<P>::npoints() const
+ {
+ mln_precondition(this->end_ >= this->begin_);
+ return (this->end_ - this->begin_);
+ }
+
+ template <typename P>
+ inline
+ const box_<P>&
+ p_queue_fast<P>::bbox() const
+ {
+ mln_precondition(npoints() != 0);
+ if (bb_needs_update_)
+ bb_update_();
+ return bb_.to_result();
+ }
+
+ template <typename P>
+ inline
+ p_queue_fast<P>&
+ p_queue_fast<P>::push_force(const P& p)
+ {
+ q_.push_back(p);
+ ++this->end_;
+ if (! vect_needs_update_)
+ {
+ // vect_needs_update_ = true;
+ bb_needs_update_ = true;
+ }
+ return *this;
+ }
+
+ template <typename P>
+ inline
+ p_queue_fast<P>&
+ p_queue_fast<P>::push(const P& p)
+ {
+ mln_precondition(! this->has(p));
+ // FIXME: Our choice is "error if multiple insertions"
+ return this->push_force(p);
+ }
+
+ template <typename P>
+ inline
+ void
+ p_queue_fast<P>::pop()
+ {
+ ++this->begin_;
+// q_.pop_front();
+// if (! vect_needs_update_)
+// {
+// vect_needs_update_ = true;
+// bb_needs_update_ = true;
+// }
+ }
+
+ template <typename P>
+ inline
+ const P&
+ p_queue_fast<P>::front() const
+ {
+ mln_precondition(! this->is_empty());
+ return q_[begin_];
+ }
+
+ template <typename P>
+ inline
+ const P&
+ p_queue_fast<P>::pop_front()
+ {
+ const P& res = this->front();
+
+ this->pop();
+ return res;
+ }
+
+
+ template <typename P>
+ inline
+ void
+ p_queue_fast<P>::clear()
+ {
+ this->end_ = begin_;
+// q_.clear();
+// vect_.clear();
+// vect_needs_update_ = false;
+ bb_needs_update_ = false;
+ }
+
+ template <typename P>
+ inline
+ const std::vector<P>&
+ p_queue_fast<P>::vect() const
+ {
+ if (vect_needs_update_)
+ vect_update_();
+ return vect_;
+ }
+
+ template <typename P>
+ inline
+ const P&
+ p_queue_fast<P>::operator[](unsigned i) const
+ {
+ mln_precondition(i < npoints());
+ return q_[begin_ + i];
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_P_QUEUE_FAST_HH
Index: trunk/milena/sandbox/pellegrin/set/Makefile
===================================================================
--- trunk/milena/sandbox/pellegrin/set/Makefile (revision 1787)
+++ trunk/milena/sandbox/pellegrin/set/Makefile (revision 1788)
@@ -1,26 +1,2 @@
-All_warnings = -ansi -pedantic -Wabi -Wctor-dtor-privacy -Wnon-virtual-dtor \
- -Wreorder -Weffc++ -Wno-deprecated -Wstrict-null-sentinel \
- -Wno-non-template-friend -Wold-style-cast -Woverloaded-virtual \
- -Wno-pmf-conversions -Wsign-promo -fsyntax-only-pedantic-errors \
- -w -Wextra -Wall -Waddress -Waggregate-return -Wno-attributes \
- -Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment -Wconversion \
- -Wno-deprecated-declarations -Wdisabled-optimization -Wno-div-by-zero \
- -Wno-endif-labels -Werror -Wfatal-errors -Wfloat-equal -Wformat \
- -Wformat=2 -Wno-format-extra-args -Wformat-nonliteral \
- -Wformat-security -Wformat-y2k -Wimplicit -Wimport -Wno-import \
- -Winit-self -Winline -Wno-invalid-offsetof -Winvalid-pch \
- -Wlarger-than-1 -Wunsafe-loop-optimizations -Wlong-long \
- -Wmissing-braces -Wmissing-field-initializers \
- -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn \
- -Wno-multichar -Wno-overflow -Woverlength-strings -Wpacked -Wpadded \
- -Wparentheses -Wpointer-arith -Wredundant-decls -Wreturn-type \
- -Wsequence-point -Wshadow -Wsign-compare -Wstack-protector \
- -Wstrict-aliasing -Wstrict-overflow -Wswitch -Wswitch-default \
- -Wswitch-enum -Wsystem-headers -Wtrigraphs -Wundef -Wuninitialized \
- -Wunknown-pragmas -Wno-pragmas -Wunreachable-code -Wunused \
- -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value \
- -Wunused-variable -Wvariadic-macros -Wvolatile-register-var \
- -Wwrite-strings \
-
all:
- g++-4.2 -ansi -pedantic -I../.. first_test.cc -o first_test
+ g++-4.2 -ansi -pedantic -I../../.. test_has.cc -o test_has
Index: trunk/milena/sandbox/pellegrin/set/test_set.cc
===================================================================
--- trunk/milena/sandbox/pellegrin/set/test_set.cc (revision 1787)
+++ trunk/milena/sandbox/pellegrin/set/test_set.cc (revision 1788)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -27,7 +27,7 @@
/*! \file sandbox/pellegrin/set/test_set.cc
*
- * \brief test my work on set.
+ * \brief Test my work on set.
*/
#include <mln/core/image2d.hh>
Index: trunk/milena/sandbox/pellegrin/cond_inheritance/test_cond_inherit.cc
===================================================================
--- trunk/milena/sandbox/pellegrin/cond_inheritance/test_cond_inherit.cc (revision 1787)
+++ trunk/milena/sandbox/pellegrin/cond_inheritance/test_cond_inherit.cc (revision 1788)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -27,7 +27,7 @@
/*! \file sandbox/pellegrin/cond_inheritance/test_cond_inherit.cc
*
- * \brief test my work on conditional inheritance.
+ * \brief Test my work on conditional inheritance.
*/
#include <iostream>
Index: trunk/milena/sandbox/pellegrin/cond_inheritance/p_set.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/cond_inheritance/p_set.hh (revision 1787)
+++ trunk/milena/sandbox/pellegrin/cond_inheritance/p_set.hh (revision 1788)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -43,9 +43,8 @@
/*! \brief Point set class.
*
* This is a mathematical uni-set of points. The
- * parameter \p P shall be a Point type.
+ * parameter \p E shall be a Point type.
*
- * \todo All.
*/
template <typename E>
class p_set: public internal::point_set_base<p_set<E>, E>
Index: trunk/milena/sandbox/pellegrin/cond_inheritance/concept/point_set.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/cond_inheritance/concept/point_set.hh (revision 1787)
+++ trunk/milena/sandbox/pellegrin/cond_inheritance/concept/point_set.hh (revision 1788)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
Index: trunk/milena/sandbox/pellegrin/cond_inheritance/p_array.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/cond_inheritance/p_array.hh (revision 1787)
+++ trunk/milena/sandbox/pellegrin/cond_inheritance/p_array.hh (revision 1788)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -43,9 +43,8 @@
/*! \brief Point set class.
*
* This is a mathematical multi-set of points. The
- * parameter \p P shall be a Point type.
+ * parameter \p E shall be a Point type.
*
- * \todo All.
*/
template <typename E>
class p_array : public internal::point_set_base<p_array<E>, E>
Index: trunk/milena/sandbox/pellegrin/cond_inheritance/internal/multi_set.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/cond_inheritance/internal/multi_set.hh (revision 1787)
+++ trunk/milena/sandbox/pellegrin/cond_inheritance/internal/multi_set.hh (revision 1788)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
Index: trunk/milena/sandbox/pellegrin/cond_inheritance/internal/uni_set.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/cond_inheritance/internal/uni_set.hh (revision 1787)
+++ trunk/milena/sandbox/pellegrin/cond_inheritance/internal/uni_set.hh (revision 1788)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
Index: trunk/milena/sandbox/pellegrin/cond_inheritance/internal/point_set_base.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/cond_inheritance/internal/point_set_base.hh (revision 1787)
+++ trunk/milena/sandbox/pellegrin/cond_inheritance/internal/point_set_base.hh (revision 1788)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
Index: trunk/milena/sandbox/pellegrin/cond_inheritance/Makefile
===================================================================
--- trunk/milena/sandbox/pellegrin/cond_inheritance/Makefile (revision 1787)
+++ trunk/milena/sandbox/pellegrin/cond_inheritance/Makefile (revision 1788)
@@ -1,26 +1,2 @@
-All_warnings = -ansi -pedantic -Wabi -Wctor-dtor-privacy -Wnon-virtual-dtor \
- -Wreorder -Weffc++ -Wno-deprecated -Wstrict-null-sentinel \
- -Wno-non-template-friend -Wold-style-cast -Woverloaded-virtual \
- -Wno-pmf-conversions -Wsign-promo -fsyntax-only-pedantic-errors \
- -w -Wextra -Wall -Waddress -Waggregate-return -Wno-attributes \
- -Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment -Wconversion \
- -Wno-deprecated-declarations -Wdisabled-optimization -Wno-div-by-zero \
- -Wno-endif-labels -Werror -Wfatal-errors -Wfloat-equal -Wformat \
- -Wformat=2 -Wno-format-extra-args -Wformat-nonliteral \
- -Wformat-security -Wformat-y2k -Wimplicit -Wimport -Wno-import \
- -Winit-self -Winline -Wno-invalid-offsetof -Winvalid-pch \
- -Wlarger-than-1 -Wunsafe-loop-optimizations -Wlong-long \
- -Wmissing-braces -Wmissing-field-initializers \
- -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn \
- -Wno-multichar -Wno-overflow -Woverlength-strings -Wpacked -Wpadded \
- -Wparentheses -Wpointer-arith -Wredundant-decls -Wreturn-type \
- -Wsequence-point -Wshadow -Wsign-compare -Wstack-protector \
- -Wstrict-aliasing -Wstrict-overflow -Wswitch -Wswitch-default \
- -Wswitch-enum -Wsystem-headers -Wtrigraphs -Wundef -Wuninitialized \
- -Wunknown-pragmas -Wno-pragmas -Wunreachable-code -Wunused \
- -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value \
- -Wunused-variable -Wvariadic-macros -Wvolatile-register-var \
- -Wwrite-strings \
-
all:
g++-4.2 -ansi -pedantic -I../../.. -I. test_cond_inherit.cc -o test
--
Michel PELLEGRIN
ÉPITA - CSI 2010
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
Fix auto name substitution for vec and metal::math.
* tests/metal_pow.cc,
* tests/all.cc,
* mln/trait/value_.hh,
* mln/metal/math/pow.hh,
* mln/metal/math/max.hh,
* mln/metal/math/all.hh,
* mln/metal/math/sqrt.hh,
* mln/metal/all.hh,
* mln/value/graylevel.hh,
* mln/value/graylevel_f.hh,
* mln/value/float01_.hh,
* mln/value/int_s.hh,
* mln/value/internal/gray_.hh,
* mln/value/internal/gray_f.hh,
* mln/value/int_u.hh,
* mln/value/int_u_sat.hh,
* mln/value/label.hh: metal/math had been wrongly substitute by algebra/math.
* mln/trait/ch_value.hh,
* mln/core/h_vec.hh: wrong namespace for vec.
mln/core/h_vec.hh | 4 ++--
mln/metal/all.hh | 2 +-
mln/metal/math/all.hh | 10 +++++-----
mln/metal/math/max.hh | 8 ++++----
mln/metal/math/pow.hh | 8 ++++----
mln/metal/math/sqrt.hh | 6 +++---
mln/trait/ch_value.hh | 2 +-
mln/trait/value_.hh | 4 ++--
mln/value/float01_.hh | 2 +-
mln/value/graylevel.hh | 10 +++++-----
mln/value/graylevel_f.hh | 2 +-
mln/value/int_s.hh | 6 +++---
mln/value/int_u.hh | 2 +-
mln/value/int_u_sat.hh | 4 ++--
mln/value/internal/gray_.hh | 6 +++---
mln/value/internal/gray_f.hh | 6 +++---
mln/value/label.hh | 2 +-
tests/all.cc | 2 +-
tests/metal_pow.cc | 8 ++++----
19 files changed, 47 insertions(+), 47 deletions(-)
Index: tests/metal_pow.cc
--- tests/metal_pow.cc (revision 1786)
+++ tests/metal_pow.cc (working copy)
@@ -27,12 +27,12 @@
/*! \file tests/metal_pow.cc
*
- * \brief Test on mln::algebra::math.
+ * \brief Test on mln::metal::math.
*/
#include <iostream>
#include <mln/core/contract.hh>
-#include <mln/algebra/math/pow.hh>
+#include <mln/metal/math/pow.hh>
int main()
@@ -40,8 +40,8 @@
using namespace mln;
using namespace mln::metal;
- int res = algebra::math::pow_int<2,3>::value;
+ int res = metal::math::pow_int<2,3>::value;
mln_assertion(res == 8);
- std::cout << algebra::math::pow< int_<2>, int_<3> >::ret().name() << std::endl;
+ std::cout << metal::math::pow< int_<2>, int_<3> >::ret().name() << std::endl;
}
Index: tests/all.cc
--- tests/all.cc (revision 1786)
+++ tests/all.cc (working copy)
@@ -48,7 +48,7 @@
#include <mln/math/all.hh>
//#include <mln/set/all.hh>
#include <mln/draw/all.hh>
-#include <mln/algebra/math/all.hh>
+#include <mln/metal/math/all.hh>
#include <mln/metal/all.hh>
#include <mln/morpho/all.hh>
#include <mln/io/pfm/all.hh>
Index: mln/trait/ch_value.hh
--- mln/trait/ch_value.hh (revision 1786)
+++ mln/trait/ch_value.hh (working copy)
@@ -45,7 +45,7 @@
{
// Fwd decl.
- namespace metal { template <unsigned n, typename T> class vec; }
+ namespace algebra { template <unsigned n, typename T> class vec; }
Index: mln/trait/value_.hh
--- mln/trait/value_.hh (revision 1786)
+++ mln/trait/value_.hh (working copy)
@@ -37,11 +37,11 @@
# include <string>
# include <mln/metal/int.hh>
-# include <mln/algebra/math/pow.hh>
+# include <mln/metal/math/pow.hh>
# include <mln/metal/if.hh>
# include <mln/trait/value/all.hh>
-# include <mln/algebra/math/pow.hh>
+# include <mln/metal/math/pow.hh>
# define mln_trait_value_nature(V) typename mln::trait::value_< V >::nature
Index: mln/core/h_vec.hh
--- mln/core/h_vec.hh (revision 1786)
+++ mln/core/h_vec.hh (working copy)
@@ -134,7 +134,7 @@
return *this;
}
- namespace metal
+ namespace algebra
{
// Immersion of a vector in its homogeneous space.
@@ -149,7 +149,7 @@
return tmp;
}
- } // end of namespace mln::metal
+ } // end of namespace mln::algebra
template <unsigned d, typename C>
Index: mln/metal/math/pow.hh
--- mln/metal/math/pow.hh (revision 1786)
+++ mln/metal/math/pow.hh (working copy)
@@ -28,7 +28,7 @@
#ifndef MLN_METAL_MATH_POW_HH
# define MLN_METAL_MATH_POW_HH
-/*! \file mln/algebra/math/pow.hh
+/*! \file mln/metal/math/pow.hh
*
* \brief Definition of the 'power' static function.
*/
@@ -37,8 +37,8 @@
# include <mln/metal/int.hh>
-# define mlc_pow(X, N) typename mln::algebra::math::pow< X, N >::ret
-# define mlc_pow_int(x, n) mln::algebra::math::pow_int< x, n >::value
+# define mlc_pow(X, N) typename mln::metal::math::pow< X, N >::ret
+# define mlc_pow_int(x, n) mln::metal::math::pow_int< x, n >::value
@@ -105,7 +105,7 @@
};
- } // end of namespace mln::algebra::math
+ } // end of namespace mln::metal::math
} // end of namespace mln::metal
Index: mln/metal/math/max.hh
--- mln/metal/math/max.hh (revision 1786)
+++ mln/metal/math/max.hh (working copy)
@@ -28,7 +28,7 @@
#ifndef MLN_METAL_MATH_MAX_HH
# define MLN_METAL_MATH_MAX_HH
-/*! \file mln/algebra/math/max.hh
+/*! \file mln/metal/math/max.hh
*
* \brief Definition of the 'max' static function.
*/
@@ -36,8 +36,8 @@
# include <mln/metal/bool.hh>
# include <mln/metal/int.hh>
-# define mlc_max(X, Y) typename mln::algebra::math::max< X, Y >::ret
-# define mlc_max_int(x, y) mln::algebra::math::max_int< x, y >::value
+# define mlc_max(X, Y) typename mln::metal::math::max< X, Y >::ret
+# define mlc_max_int(x, y) mln::metal::math::max_int< x, y >::value
namespace mln
{
@@ -69,7 +69,7 @@
};
- } // end of namespace mln::algebra::math
+ } // end of namespace mln::metal::math
} // end of namespace mln::metal
Index: mln/metal/math/all.hh
--- mln/metal/math/all.hh (revision 1786)
+++ mln/metal/math/all.hh (working copy)
@@ -28,7 +28,7 @@
#ifndef MLN_METAL_MATH_ALL_HH
# define MLN_METAL_MATH_ALL_HH
-/*! \file mln/algebra/math/all.hh
+/*! \file mln/metal/math/all.hh
*
* \brief Include all static mathematical functions.
*/
@@ -43,7 +43,7 @@
/// Namespace of static mathematical functions.
namespace math
{
- /// \internal Implementation namespace of algebra::math namespace.
+ /// \internal Implementation namespace of metal::math namespace.
namespace impl {}
}
@@ -53,9 +53,9 @@
-# include <mln/algebra/math/pow.hh>
-# include <mln/algebra/math/sqrt.hh>
-# include <mln/algebra/math/max.hh>
+# include <mln/metal/math/pow.hh>
+# include <mln/metal/math/sqrt.hh>
+# include <mln/metal/math/max.hh>
// ...
Index: mln/metal/math/sqrt.hh
--- mln/metal/math/sqrt.hh (revision 1786)
+++ mln/metal/math/sqrt.hh (working copy)
@@ -28,7 +28,7 @@
#ifndef MLN_METAL_MATH_SQRT_HH
# define MLN_METAL_MATH_SQRT_HH
-/*! \file mln/algebra/math/sqrt.hh
+/*! \file mln/metal/math/sqrt.hh
*
* \brief Definition of the 'sqrt' static function.
*/
@@ -82,7 +82,7 @@
{
};
- } // end of namespace mln::algebra::math::impl
+ } // end of namespace mln::metal::math::impl
template <int n>
struct sqrt_int : impl::sqrt_int_if_< n, (n >= 0) >
@@ -102,7 +102,7 @@
};
- } // end of namespace mln::algebra::math
+ } // end of namespace mln::metal::math
} // end of namespace mln::metal
Index: mln/metal/all.hh
--- mln/metal/all.hh (revision 1786)
+++ mln/metal/all.hh (working copy)
@@ -77,7 +77,7 @@
# include <mln/algebra/vec.hh>
# include <mln/algebra/mat.hh>
-# include <mln/algebra/math/all.hh>
+# include <mln/metal/math/all.hh>
// FIXME: Remove the following includes below!
# include <mln/metal/same_coord.hh>
Index: mln/value/graylevel.hh
--- mln/value/graylevel.hh (revision 1786)
+++ mln/value/graylevel.hh (working copy)
@@ -38,8 +38,8 @@
# include <mln/value/ops.hh>
# include <mln/core/contract.hh>
-# include <mln/algebra/math/pow.hh>
-# include <mln/algebra/math/max.hh>
+# include <mln/metal/math/pow.hh>
+# include <mln/metal/math/max.hh>
# include <mln/metal/bexpr.hh>
# include <mln/literal/ops.hh>
@@ -513,7 +513,7 @@
inline
graylevel<n>::graylevel(const literal::medium_gray_t&)
{
- this->v_ = algebra::math::pow_int<2, n - 1>::value;
+ this->v_ = metal::math::pow_int<2, n - 1>::value;
}
template <unsigned n>
@@ -521,7 +521,7 @@
graylevel<n>&
graylevel<n>::operator=(const literal::medium_gray_t&)
{
- this->v_ = algebra::math::pow_int<2, n - 1>::value;
+ this->v_ = metal::math::pow_int<2, n - 1>::value;
return *this;
}
@@ -555,7 +555,7 @@
float
graylevel<n>::to_float() const
{
- static const float denom = float(algebra::math::pow_int<2, n>::value) - 1.f;
+ static const float denom = float(metal::math::pow_int<2, n>::value) - 1.f;
return float(this->v_) / denom;
}
Index: mln/value/graylevel_f.hh
--- mln/value/graylevel_f.hh (revision 1786)
+++ mln/value/graylevel_f.hh (working copy)
@@ -38,7 +38,7 @@
# include <mln/value/ops.hh>
# include <mln/core/contract.hh>
-# include <mln/algebra/math/pow.hh>
+# include <mln/metal/math/pow.hh>
# include <mln/metal/bexpr.hh>
# include <mln/literal/ops.hh>
Index: mln/value/float01_.hh
--- mln/value/float01_.hh (revision 1786)
+++ mln/value/float01_.hh (working copy)
@@ -35,7 +35,7 @@
# include <iostream>
# include <mln/core/contract.hh>
-# include <mln/algebra/math/pow.hh>
+# include <mln/metal/math/pow.hh>
# include <mln/metal/bexpr.hh>
# include <mln/value/int_u.hh>
Index: mln/value/int_s.hh
--- mln/value/int_s.hh (revision 1786)
+++ mln/value/int_s.hh (working copy)
@@ -35,7 +35,7 @@
# include <mln/value/ops.hh>
-# include <mln/algebra/math/pow.hh>
+# include <mln/metal/math/pow.hh>
# include <mln/value/internal/value_like.hh>
# include <mln/value/concept/integer.hh>
# include <mln/value/internal/encoding.hh>
@@ -180,7 +180,7 @@
inline
int_s<n>::int_s(int i)
{
- static const int max = algebra::math::pow_int<2, n-1>::value - 1;
+ static const int max = metal::math::pow_int<2, n-1>::value - 1;
static const int min = - max;
mln_precondition(i >= min);
mln_precondition(i <= max);
@@ -192,7 +192,7 @@
int_s<n>&
int_s<n>::operator=(int i)
{
- static const int max = algebra::math::pow_int<2, n-1>::value - 1;
+ static const int max = metal::math::pow_int<2, n-1>::value - 1;
static const int min = - max;
mln_precondition(i >= min);
mln_precondition(i <= max);
Index: mln/value/internal/gray_.hh
--- mln/value/internal/gray_.hh (revision 1786)
+++ mln/value/internal/gray_.hh (working copy)
@@ -37,8 +37,8 @@
# include <iostream>
# include <cmath>
-# include <mln/algebra/math/max.hh>
-# include <mln/algebra/math/pow.hh>
+# include <mln/metal/math/max.hh>
+# include <mln/metal/math/pow.hh>
# include <mln/value/concept/integer.hh>
@@ -312,7 +312,7 @@
inline
gray_<n>::operator graylevel_f() const
{
- static const float denom = float(algebra::math::pow_int<2, n>::value) - 1.f;
+ static const float denom = float(metal::math::pow_int<2, n>::value) - 1.f;
return graylevel_f(float(this->v_) / denom);
}
Index: mln/value/internal/gray_f.hh
--- mln/value/internal/gray_f.hh (revision 1786)
+++ mln/value/internal/gray_f.hh (working copy)
@@ -38,7 +38,7 @@
# include <mln/value/ops.hh>
# include <mln/core/contract.hh>
-# include <mln/algebra/math/pow.hh>
+# include <mln/metal/math/pow.hh>
# include <mln/metal/bexpr.hh>
# include <mln/literal/ops.hh>
@@ -225,7 +225,7 @@
template <unsigned n>
gray_f::gray_f(const gray_<n>& rhs)
{
- static const float denom = float(algebra::math::pow_int<2, n>::value) - 1.f;
+ static const float denom = float(metal::math::pow_int<2, n>::value) - 1.f;
this->v_ = float(rhs.value()) / denom;
}
@@ -233,7 +233,7 @@
gray_f&
gray_f::operator=(const gray_<n>& rhs)
{
- static const float denom = float(algebra::math::pow_int<2, n>::value) - 1.f;
+ static const float denom = float(metal::math::pow_int<2, n>::value) - 1.f;
this->v_ = float(rhs.value()) / denom;
return *this;
}
Index: mln/value/int_u.hh
--- mln/value/int_u.hh (revision 1786)
+++ mln/value/int_u.hh (working copy)
@@ -35,7 +35,7 @@
# include <mln/value/ops.hh>
-# include <mln/algebra/math/pow.hh>
+# include <mln/metal/math/pow.hh>
# include <mln/value/internal/value_like.hh>
# include <mln/value/internal/encoding.hh>
# include <mln/value/concept/integer.hh>
Index: mln/value/int_u_sat.hh
--- mln/value/int_u_sat.hh (revision 1786)
+++ mln/value/int_u_sat.hh (working copy)
@@ -34,7 +34,7 @@
* behavior.
*/
-# include <mln/algebra/math/pow.hh>
+# include <mln/metal/math/pow.hh>
# include <mln/value/internal/value_like.hh>
# include <mln/value/concept/integer.hh>
# include <mln/value/internal/encoding.hh>
@@ -59,7 +59,7 @@
struct value_< mln::value::int_u_sat<n> >
{
// FIXME: Overhaul these traits (see other value traits).
- static const std::size_t card = algebra::math::pow_int<2, n>::value;
+ static const std::size_t card = metal::math::pow_int<2, n>::value;
static const mln::value::int_u_sat<n> min() { return 0; }
static const mln::value::int_u_sat<n> max() { return card - 1; }
static const unsigned nbits = n;
Index: mln/value/label.hh
--- mln/value/label.hh (revision 1786)
+++ mln/value/label.hh (working copy)
@@ -33,7 +33,7 @@
* \brief Define a generic class for labels.
*/
-# include <mln/algebra/math/pow.hh>
+# include <mln/metal/math/pow.hh>
# include <mln/value/concept/symbolic.hh>
# include <mln/value/internal/value_like.hh>
# include <mln/value/internal/convert.hh>
1
0
Caroline Vigouroux wrote:
> URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
>
> ChangeLog:
> 2008-03-19 Caroline Vigouroux <vigour_c(a)epita.fr>
>
> correct structures.
> * my_cmy.hh: correction.
> * my_hsi.hh: correction.
> * my_hsl.hh: correction.
> * my_hsv.hh: correction.
> * my_xyz.hh: correction.
> * my_yiq.hh: correction.
> * my_yuv.hh: correction.
> * rgb_to_hsi.hh: correction.
IMHO 'correction' is a bit too vague. Don't hesitate to be more precise.
The idea is that by reading your Changelog we can easily know what
you've done.
By the way, repeating N-times the same message is useless, you can use
this formant :
* file1,
* file2,
* file3: Common changelog message.
--
\__/ \__/
(00) Maxime `yabo` van Noppen (00)
___) \ Epita 2009 / (___
(_____/ Président de Prologin \_____)
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2008-03-19 Caroline Vigouroux <vigour_c(a)epita.fr>
correct structures.
* my_cmy.hh: correction.
* my_hsi.hh: correction.
* my_hsl.hh: correction.
* my_hsv.hh: correction.
* my_xyz.hh: correction.
* my_yiq.hh: correction.
* my_yuv.hh: correction.
* rgb_to_hsi.hh: correction.
---
my_cmy.hh | 137 +++++++++++++++++++++++++++++++++++++----------------
my_hsi.hh | 106 ++++++++++++++++++++---------------------
my_hsl.hh | 134 +++++++++++++++++++++++++++++++++++++---------------
my_hsv.hh | 146 ++++++++++++++++++++++++++++++++++++++++++---------------
my_xyz.hh | 148 +++++++++++++++++++++++++++++++++++++++++-----------------
my_yiq.hh | 148 +++++++++++++++++++++++++++++++++++++++++-----------------
my_yuv.hh | 148 +++++++++++++++++++++++++++++++++++++++++-----------------
rgb_to_hsi.hh | 130 +++++++++++++++++++++++++++-----------------------
8 files changed, 739 insertions(+), 358 deletions(-)
Index: trunk/milena/sandbox/vigouroux/color/my_hsi.hh
===================================================================
--- trunk/milena/sandbox/vigouroux/color/my_hsi.hh (revision 1785)
+++ trunk/milena/sandbox/vigouroux/color/my_hsi.hh (revision 1786)
@@ -83,63 +83,63 @@
- template <unsigned n>
- struct hsi
- {
- public:
- /// Constructor without argument.
- hsi<n>();
-
- /// Constructor from component values.
- hsi<n>(double hue, double sat, double i);
-
- /// Access to component values.
- double hue() const { return this->hue_; }
- double sat() const { return this->sat_; }
- double i() const { return this->int_; }
-
- /// Set component values.
- void hue(double hue)
- {
- this->hue_ = hue;
- }
- void sat(double sat)
- {
- this->sat_ = sat;
- }
- void i(double i)
- {
- mln_precondition(i >= 0);
- this->int_ = i;
- }
-
- private:
- double hue_;
- double sat_;
- double int_;
- };
+// template <unsigned n>
+// struct hsi
+// {
+// public:
+// /// Constructor without argument.
+// hsi<n>();
+
+// /// Constructor from component values.
+// hsi<n>(double hue, double sat, double i);
+
+// /// Access to component values.
+// double hue() const { return this->hue_; }
+// double sat() const { return this->sat_; }
+// double i() const { return this->int_; }
+
+// /// Set component values.
+// void hue(double hue)
+// {
+// this->hue_ = hue;
+// }
+// void sat(double sat)
+// {
+// this->sat_ = sat;
+// }
+// void i(double i)
+// {
+// mln_precondition(i >= 0);
+// this->int_ = i;
+// }
+
+// private:
+// double hue_;
+// double sat_;
+// double int_;
+// };
# ifndef MLN_INCLUDE_ONLY
- template <unsigned n>
- inline
- hsi<n>::hsi()
- :hue_(0), sat_(0), int_(0)
- {
- }
-
- template <unsigned n>
- inline
- hsi<n>::hsi(double h, double sat, double i)
- {
- mln_invariant(h >= 0);
- mln_invariant(sat >= 0);
- mln_invariant(i >= 0);
- this->hue_ = h;
- this->sat_ = sat;
- this->i_ = i;
- }
+// template <unsigned n>
+// inline
+// hsi<n>::hsi()
+// :hue_(0), sat_(0), int_(0)
+// {
+// }
+
+// template <unsigned n>
+// inline
+// hsi<n>::hsi(double h, double sat, double i)
+// {
+// mln_invariant(h >= 0);
+// mln_invariant(sat >= 0);
+// mln_invariant(i >= 0);
+// this->hue_ = h;
+// this->sat_ = sat;
+// this->i_ = i;
+// }
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/sandbox/vigouroux/color/my_yuv.hh
===================================================================
--- trunk/milena/sandbox/vigouroux/color/my_yuv.hh (revision 1785)
+++ trunk/milena/sandbox/vigouroux/color/my_yuv.hh (revision 1786)
@@ -1,9 +1,3 @@
-// #include <mln/value/ops.hh>
-
-// #include <mln/value/concept/vectorial.hh>
-// #include <mln/value/int_u.hh>
-// #include <mln/algebra/vec.hh>
-
#ifndef MLN_VALUE_YUV_HH
# define MLN_VALUE_YUV_HH
@@ -11,59 +5,129 @@
{
namespace value
{
- template <unsigned n>
- struct yuv
+
+ template <typename E>
+ struct YUV
+ {
+ };
+
+ template <typename Y, typename U, typename V>
+ class yuv_ : public YUV< yuv_<Y,U,V> >
{
public:
- /// Constructor without argument.
- yuv<n>();
- /// Constructor from component values.
- yuv<n>(double y, double u, double v);
+ typedef Y y_type;
+ typedef U u_type;
+ typedef V v_type;
- /// Access to component values.
- double y() const { return this->y_; }
- double u() const { return this->u_; }
- double v() const { return this->v_; }
+ /// Constructor without argument.
+ yuv_()
+ {
+ }
- /// Set component values.
- void y(double y)
+ /// Constructor from component values.
+ yuv_(const Y& y, const U& u, const V& v)
+ : y_(y),
+ u_(u),
+ v_(v)
{
- this->y_ = y;
}
- void u(double u)
+
+ /// Read-only access to the y component.
+ const Y& y() const
{
- this->u_ = u;
+ return this->y_;
}
- void v(double v)
+ const U& u() const
{
- mln_precondition(v >= 0);
- this->v_ = v;
+ return this->u_;
}
-
- private:
- double y_;
- double u_;
- double v_;
- };
-
- template <unsigned n>
- inline
- yuv<n>::yuv()
- :y_(0), u_(0), v_(0)
+ const V& v() const
{
+ return this->v_;
}
- template <unsigned n>
- inline
- yuv<n>::yuv(double y, double u, double v)
+ /// Read-write access to the y component.
+ Y& y()
{
- mln_precondition(v >= 0);
- this->y_ = y;
- this->u_ = u;
- this->v_ = v;
+ return this->y_;
}
+ U& u()
+ {
+ return this->u_;
}
+ V& v()
+ {
+ return this->v_;
}
+ private:
+ Y y_;
+ U u_;
+ V v_;
+ };
+
+ typedef yuv_<float, float, float> yuv_3x8;
+
+ typedef yuv_<double, double, double> yuv_d;
+
+ } // end of namespace mln::value
+
+} // end of namespace mln
+
+// template <unsigned n>
+// struct yuv
+// {
+// public:
+// /// Constructor without argument.
+// yuv<n>();
+
+// /// Constructor from component values.
+// yuv<n>(double y, double u, double v);
+
+// /// Access to component values.
+// double y() const { return this->y_; }
+// double u() const { return this->u_; }
+// double v() const { return this->v_; }
+
+// /// Set component values.
+// void y(double y)
+// {
+// this->y_ = y;
+// }
+// void u(double u)
+// {
+// this->u_ = u;
+// }
+// void v(double v)
+// {
+// mln_precondition(v >= 0);
+// this->v_ = v;
+// }
+
+// private:
+// double y_;
+// double u_;
+// double v_;
+// };
+
+// template <unsigned n>
+// inline
+// yuv<n>::yuv()
+// :y_(0), u_(0), v_(0)
+// {
+// }
+
+// template <unsigned n>
+// inline
+// yuv<n>::yuv(double y, double u, double v)
+// {
+// mln_precondition(v >= 0);
+// this->y_ = y;
+// this->u_ = u;
+// this->v_ = v;
+// }
+// }
+// }
+
#endif // ! MLN_VALUE_YUV_HH
Index: trunk/milena/sandbox/vigouroux/color/my_hsl.hh
===================================================================
--- trunk/milena/sandbox/vigouroux/color/my_hsl.hh (revision 1785)
+++ trunk/milena/sandbox/vigouroux/color/my_hsl.hh (revision 1786)
@@ -11,61 +11,117 @@
{
namespace value
{
- template <unsigned n>
- struct hsl
+
+ template <typename E>
+ struct HSL
+ {
+ };
+
+ template <typename H, typename S, typename L>
+ class hsl_ : public HSL< hsl_<H,S,L> >
{
public:
+
+ typedef H h_type;
+ typedef S s_type;
+ typedef L l_type;
+
/// Constructor without argument.
- hsl<n>();
+ hsl_()
+ {
+ }
/// Constructor from component values.
- hsl<n>(int h, int s, int l);
-
- /// Access to component values.
- double h() const { return this->h_; }
- double s() const { return this->s_; }
- double l() const { return this->l_; }
+ hsl_(const H& hue, const S& sat, const L& light)
+ : hue_(hue),
+ sat_(sat),
+ light_(light)
+ {
+ }
- /// Set component values.
- void h(double h)
+ /// Read-only access to the hue component.
+ const H& hue() const
{
- this->h_ = h;
+ return this->hue_;
}
- void s(double s)
+ const S& sat() const
{
- this->s_ = s;
+ return this->sat_;
}
- void l(double l)
+ const L& light() const
{
- mln_precondition(l >= 0);
- this->l_ = l;
+ return this->light_;
}
private:
- double h_;
- double s_;
- double l_;
+ H hue_;
+ S sat_;
+ L light_;
};
- template <unsigned n>
- inline
- hsl<n>::hsl()
- :h_(0), s_(0), l_(0)
- {
- }
+ typedef hsl_<float, float, float> hsl_3x8;
- template <unsigned n>
- inline
- hsl<n>::hsl(int h, int s, int l)
- {
- mln_precondition(h >= 0);
- mln_precondition(s >= 0);
- mln_precondition(l >= 0);
- this->h_ = h;
- this->s_ = s;
- this->l_ = l;
- }
- }
-}
+ typedef hsl_<double, double, double> hsl_d;
+
+ } // end of namespace mln::value
+
+} // end of namespace mln
+
+// template <unsigned n>
+// struct hsl
+// {
+// public:
+// /// Constructor without argument.
+// hsl<n>();
+
+// /// Constructor from component values.
+// hsl<n>(int h, int s, int l);
+
+// /// Access to component values.
+// double h() const { return this->h_; }
+// double s() const { return this->s_; }
+// double l() const { return this->l_; }
+
+// /// Set component values.
+// void h(double h)
+// {
+// this->h_ = h;
+// }
+// void s(double s)
+// {
+// this->s_ = s;
+// }
+// void l(double l)
+// {
+// mln_precondition(l >= 0);
+// this->l_ = l;
+// }
+
+// private:
+// double h_;
+// double s_;
+// double l_;
+// };
+
+// template <unsigned n>
+// inline
+// hsl<n>::hsl()
+// :h_(0), s_(0), l_(0)
+// {
+// }
+
+// template <unsigned n>
+// inline
+// hsl<n>::hsl(int h, int s, int l)
+// {
+// mln_precondition(h >= 0);
+// mln_precondition(s >= 0);
+// mln_precondition(l >= 0);
+// this->h_ = h;
+// this->s_ = s;
+// this->l_ = l;
+// }
+// }
+// }
#endif // ! MLN_VALUE_HSL_HH
Index: trunk/milena/sandbox/vigouroux/color/my_cmy.hh
===================================================================
--- trunk/milena/sandbox/vigouroux/color/my_cmy.hh (revision 1785)
+++ trunk/milena/sandbox/vigouroux/color/my_cmy.hh (revision 1786)
@@ -1,3 +1,5 @@
+#include <mln/value/float01_8.hh>
+
#ifndef MLN_VALUE_CMY_HH
# define MLN_VALUE_CMY_HH
@@ -5,63 +7,116 @@
{
namespace value
{
- template <unsigned n>
- struct cmy
+
+ template <typename E>
+ struct CMY
+ {
+ };
+
+ template <typename C, typename M, typename Y>
+ class cmy_ : public CMY< cmy_<C,M,Y> >
{
public:
+
+ typedef C c_type;
+ typedef M m_type;
+ typedef Y y_type;
+
/// Constructor without argument.
- cmy();
+ cmy_()
+ {
+ }
/// Constructor from component values.
- cmy(double c, double m, double y);
-
- /// Access to component values.
- double c() const { return this->c_; }
- double m() const { return this->m_; }
- double y() const { return this->y_; }
+ cmy_(const C& cyan, const M& magenta, const Y& yellow)
+ : cyan_(cyan),
+ magenta_(magenta),
+ yellow_(yellow)
+ {
+ }
- /// Set component values.
- void c(double c)
+ /// Read-only access to the cyan component.
+ const C& cyan() const
{
- mln_precondition(c >= 0);
- this->c_ = c;
+ return this->cyan_;
}
- void m(double m)
+ const M& magenta() const
{
- mln_precondition(m >= 0);
- this->m_ = m;
+ return this->magenta_;
}
- void y(double y)
+ const Y& yellow() const
{
- mln_precondition(y >= 0);
- this->y_ = y;
+ return this->yellow_;
}
private:
- double c_;
- double m_;
- double y_;
+ C cyan_;
+ M magenta_;
+ Y yellow_;
};
- template <unsigned n>
- inline
- cmy<n>::cmy()
- :c_(0), m_(0), y_(0)
- {
- }
+ typedef cmy_<float, float, float> cmy_3x8;
- template <unsigned n>
- inline
- cmy<n>::cmy(double c, double m, double y)
- {
- mln_precondition(c >= 0);
- mln_precondition(m >= 0);
- mln_precondition(y >= 0);
- this->c_ = c;
- this->m_ = m;
- this->y_ = y;
- }
- }
-}
+ typedef cmy_<double, double, double> cmy_d;
+ } // end of namespace mln::value
+
+} // end of namespace mln
+
+// template <unsigned n>
+// struct cmy
+// {
+// public:
+// /// Constructor without argument.
+// cmy();
+
+// /// Constructor from component values.
+// cmy(double c, double m, double y);
+
+// /// Access to component values.
+// double c() const { return this->c_; }
+// double m() const { return this->m_; }
+// double y() const { return this->y_; }
+
+// /// Set component values.
+// void c(double c)
+// {
+// mln_precondition(c >= 0);
+// this->c_ = c;
+// }
+// void m(double m)
+// {
+// mln_precondition(m >= 0);
+// this->m_ = m;
+// }
+// void y(double y)
+// {
+// mln_precondition(y >= 0);
+// this->y_ = y;
+// }
+
+// private:
+// double c_;
+// double m_;
+// double y_;
+// };
+
+// template <unsigned n>
+// inline
+// cmy<n>::cmy()
+// :c_(0), m_(0), y_(0)
+// {
+// }
+
+// template <unsigned n>
+// inline
+// cmy<n>::cmy(double c, double m, double y)
+// {
+// mln_precondition(c >= 0);
+// mln_precondition(m >= 0);
+// mln_precondition(y >= 0);
+// this->c_ = c;
+// this->m_ = m;
+// this->y_ = y;
+// }
#endif // ! MLN_VALUE_CMY_HH
Index: trunk/milena/sandbox/vigouroux/color/my_xyz.hh
===================================================================
--- trunk/milena/sandbox/vigouroux/color/my_xyz.hh (revision 1785)
+++ trunk/milena/sandbox/vigouroux/color/my_xyz.hh (revision 1786)
@@ -1,9 +1,3 @@
-// #include <mln/value/ops.hh>
-
-// #include <mln/value/concept/vectorial.hh>
-// #include <mln/value/int_u.hh>
-// #include <mln/algebra/vec.hh>
-
#ifndef MLN_VALUE_XYZ_HH
# define MLN_VALUE_XYZ_HH
@@ -11,59 +5,129 @@
{
namespace value
{
- template <unsigned n>
- struct xyz
+
+ template <typename E>
+ struct XYZ
+ {
+ };
+
+ template <typename X, typename Y, typename Z>
+ class xyz_ : public XYZ< xyz_<X,Y,Z> >
{
public:
- /// Constructor without argument.
- xyz<n>();
- /// Constructor from component values.
- xyz<n>(double x, double y, double z);
+ typedef X x_type;
+ typedef Y y_type;
+ typedef Z z_type;
- /// Access to component values.
- double x() const { return this->x_; }
- double y() const { return this->y_; }
- double z() const { return this->z_; }
+ /// Constructor without argument.
+ xyz_()
+ {
+ }
- /// Set component values.
- void x(double x)
+ /// Constructor from component values.
+ xyz_(const X& x, const Y& y, const Z& z)
+ : x_(x),
+ y_(y),
+ z_(z)
{
- this->x_ = x;
}
- void y(double y)
+
+ /// Read-only access to the x component.
+ const X& x() const
{
- this->y_ = y;
+ return this->x_;
}
- void z(double z)
+ const Y& y() const
{
- mln_precondition(z >= 0);
- this->z_ = z;
+ return this->y_;
}
-
- private:
- double x_;
- double y_;
- double z_;
- };
-
- template <unsigned n>
- inline
- xyz<n>::xyz()
- :x_(0), y_(0), z_(0)
+ const Z& z() const
{
+ return this->z_;
}
- template <unsigned n>
- inline
- xyz<n>::xyz(double x, double y, double z)
+ /// Read-write access to the x component.
+ X& x()
{
- mln_precondition(z >= 0);
- this->x_ = x;
- this->y_ = y;
- this->z_ = z;
+ return this->x_;
}
+ Y& y()
+ {
+ return this->y_;
}
+ Z& z()
+ {
+ return this->z_;
}
+ private:
+ X x_;
+ Y y_;
+ Z z_;
+ };
+
+ typedef xyz_<float, float, float> xyz_3x8;
+
+ typedef xyz_<double, double, double> xyz_d;
+
+ } // end of namespace mln::value
+
+} // end of namespace mln
+
+// template <unsigned n>
+// struct xyz
+// {
+// public:
+// /// Constructor without argument.
+// xyz<n>();
+
+// /// Constructor from component values.
+// xyz<n>(double x, double y, double z);
+
+// /// Access to component values.
+// double x() const { return this->x_; }
+// double y() const { return this->y_; }
+// double z() const { return this->z_; }
+
+// /// Set component values.
+// void x(double x)
+// {
+// this->x_ = x;
+// }
+// void y(double y)
+// {
+// this->y_ = y;
+// }
+// void z(double z)
+// {
+// mln_precondition(z >= 0);
+// this->z_ = z;
+// }
+
+// private:
+// double x_;
+// double y_;
+// double z_;
+// };
+
+// template <unsigned n>
+// inline
+// xyz<n>::xyz()
+// :x_(0), y_(0), z_(0)
+// {
+// }
+
+// template <unsigned n>
+// inline
+// xyz<n>::xyz(double x, double y, double z)
+// {
+// mln_precondition(z >= 0);
+// this->x_ = x;
+// this->y_ = y;
+// this->z_ = z;
+// }
+// }
+// }
+
#endif // ! MLN_VALUE_XYZ_HH
Index: trunk/milena/sandbox/vigouroux/color/my_hsv.hh
===================================================================
--- trunk/milena/sandbox/vigouroux/color/my_hsv.hh (revision 1785)
+++ trunk/milena/sandbox/vigouroux/color/my_hsv.hh (revision 1786)
@@ -11,61 +11,131 @@
{
namespace value
{
- template <unsigned n>
- struct hsv
+
+ template <typename E>
+ struct HSV
+ {
+ };
+
+ template <typename H, typename S, typename V>
+ class hsv_ : public HSV< hsv_<H,S,V> >
{
public:
+
+ typedef H h_type;
+ typedef S s_type;
+ typedef V v_type;
+
/// Constructor without argument.
- hsv<n>();
+ hsv_()
+ {
+ }
/// Constructor from component values.
- hsv<n>(int h, int s, int v);
+ hsv_(const H& hue, const S& sat, const V& value)
+ : hue_(hue),
+ sat_(sat),
+ value_(value)
+ {
+ }
- /// Access to component values.
- double h() const { return this->h_; }
- double s() const { return this->s_; }
- double v() const { return this->v_; }
+ /// Read-only access to the hue component.
+ const H& hue() const
+ {
+ return this->hue_;
+ }
+ const S& sat() const
+ {
+ return this->sat_;
+ }
+ const V& value() const
+ {
+ return this->value_;
+ }
- /// Set component values.
- void h(double h)
+ /// Read-write access to the hue component.
+ H& hue()
{
- this->h_ = h;
+ return this->hue_;
}
- void s(double s)
+ S& sat()
{
- this->s_ = s;
+ return this->sat_;
}
- void v(double v)
+ V& value()
{
- mln_precondition(v >= 0);
- this->v_ = v;
+ return this->value_;
}
private:
- double h_;
- double s_;
- double v_;
+ H hue_;
+ S sat_;
+ V value_;
};
- template <unsigned n>
- inline
- hsi<n>::hsv()
- :h_(0), s_(0), v_(0)
- {
- }
+ typedef hsv_<float, float, float> hsv_3x8;
- template <unsigned n>
- inline
- hsv<n>::hsv(int h, int s, int v)
- {
- mln_precondition(h >= 0);
- mln_precondition(s >= 0);
- mln_precondition(v >= 0);
- this->h_ = h;
- this->s_ = s;
- this->v_ = v;
- }
- }
-}
+ typedef hsv_<double, double, double> hsv_d;
+
+ } // end of namespace mln::value
+
+} // end of namespace mln
+
+// template <unsigned n>
+// struct hsv
+// {
+// public:
+// /// Constructor without argument.
+// hsv<n>();
+
+// /// Constructor from component values.
+// hsv<n>(int h, int s, int v);
+
+// /// Access to component values.
+// double h() const { return this->h_; }
+// double s() const { return this->s_; }
+// double v() const { return this->v_; }
+
+// /// Set component values.
+// void h(double h)
+// {
+// this->h_ = h;
+// }
+// void s(double s)
+// {
+// this->s_ = s;
+// }
+// void v(double v)
+// {
+// mln_precondition(v >= 0);
+// this->v_ = v;
+// }
+
+// private:
+// double h_;
+// double s_;
+// double v_;
+// };
+
+// template <unsigned n>
+// inline
+// hsi<n>::hsv()
+// :h_(0), s_(0), v_(0)
+// {
+// }
+
+// template <unsigned n>
+// inline
+// hsv<n>::hsv(int h, int s, int v)
+// {
+// mln_precondition(h >= 0);
+// mln_precondition(s >= 0);
+// mln_precondition(v >= 0);
+// this->h_ = h;
+// this->s_ = s;
+// this->v_ = v;
+// }
+// }
+// }
#endif // ! MLN_VALUE_HSV_HH
Index: trunk/milena/sandbox/vigouroux/color/my_yiq.hh
===================================================================
--- trunk/milena/sandbox/vigouroux/color/my_yiq.hh (revision 1785)
+++ trunk/milena/sandbox/vigouroux/color/my_yiq.hh (revision 1786)
@@ -1,9 +1,3 @@
-// #include <mln/value/ops.hh>
-
-// #include <mln/value/concept/vectorial.hh>
-// #include <mln/value/int_u.hh>
-// #include <mln/algebra/vec.hh>
-
#ifndef MLN_VALUE_YIQ_HH
# define MLN_VALUE_YIQ_HH
@@ -11,59 +5,129 @@
{
namespace value
{
- template <unsigned n>
- struct yiq
+
+ template <typename E>
+ struct YIQ
+ {
+ };
+
+ template <typename Y, typename I, typename Q>
+ class yiq_ : public YIQ< yiq_<Y,I,Q> >
{
public:
- /// Constructor without argument.
- yiq<n>();
- /// Constructor from component values.
- yiq<n>(double y, double i, double q);
+ typedef Y y_type;
+ typedef I i_type;
+ typedef Q q_type;
- /// Access to component values.
- double y() const { return this->y_; }
- double i() const { return this->i_; }
- double q() const { return this->q_; }
+ /// Constructor without argument.
+ yiq_()
+ {
+ }
- /// Set component values.
- void y(double y)
+ /// Constructor from component values.
+ yiq_(const Y& y, const I& i, const Q& q)
+ : y_(y),
+ i_(i),
+ q_(q)
{
- this->y_ = y;
}
- void i(double i)
+
+ /// Read-only access to the y component.
+ const Y& y() const
{
- this->i_ = i;
+ return this->y_;
}
- void q(double q)
+ const I& i() const
{
- mln_precondition(q >= 0);
- this->q_ = q;
+ return this->i_;
}
-
- private:
- double y_;
- double i_;
- double q_;
- };
-
- template <unsigned n>
- inline
- yiq<n>::yiq()
- :y_(0), i_(0), q_(0)
+ const Q& q() const
{
+ return this->q_;
}
- template <unsigned n>
- inline
- yiq<n>::yiq(double y, double i, double q)
+ /// Read-write access to the y component.
+ Y& y()
{
- mln_precondition(q >= 0);
- this->y_ = y;
- this->i_ = i;
- this->q_ = q;
+ return this->y_;
}
+ I& i()
+ {
+ return this->i_;
}
+ Q& q()
+ {
+ return this->q_;
}
+ private:
+ Y y_;
+ I i_;
+ Q q_;
+ };
+
+ typedef yiq_<float, float, float> yiq_3x8;
+
+ typedef yiq_<double, double, double> yiq_d;
+
+ } // end of namespace mln::value
+
+} // end of namespace mln
+
+// template <unsigned n>
+// struct yiq
+// {
+// public:
+// /// Constructor without argument.
+// yiq<n>();
+
+// /// Constructor from component values.
+// yiq<n>(double y, double i, double q);
+
+// /// Access to component values.
+// double y() const { return this->y_; }
+// double i() const { return this->i_; }
+// double q() const { return this->q_; }
+
+// /// Set component values.
+// void y(double y)
+// {
+// this->y_ = y;
+// }
+// void i(double i)
+// {
+// this->i_ = i;
+// }
+// void q(double q)
+// {
+// mln_precondition(q >= 0);
+// this->q_ = q;
+// }
+
+// private:
+// double y_;
+// double i_;
+// double q_;
+// };
+
+// template <unsigned n>
+// inline
+// yiq<n>::yiq()
+// :y_(0), i_(0), q_(0)
+// {
+// }
+
+// template <unsigned n>
+// inline
+// yiq<n>::yiq(double y, double i, double q)
+// {
+// mln_precondition(q >= 0);
+// this->y_ = y;
+// this->i_ = i;
+// this->q_ = q;
+// }
+// }
+// }
+
#endif // ! MLN_VALUE_YIQ_HH
Index: trunk/milena/sandbox/vigouroux/color/rgb_to_hsi.hh
===================================================================
--- trunk/milena/sandbox/vigouroux/color/rgb_to_hsi.hh (revision 1785)
+++ trunk/milena/sandbox/vigouroux/color/rgb_to_hsi.hh (revision 1786)
@@ -8,6 +8,7 @@
#include <mln/io/ppm/save.hh>
#include <mln/display/save_and_show.hh>
#include <mln/level/fill.hh>
+#include <mln/math/round.hh>
#include "my_hsi.hh"
@@ -77,21 +78,28 @@
template <typename T_hsi>
T_rgb operator()(const T_hsi& hsi) const
{
- int r;
- int g;
- int b;
-
- static const double sqrt3_3 = sqrt(3) / 3;
- static const double inv_sqrt6 = 1 / sqrt(6);
- static const double inv_sqrt2 = 1 / sqrt(2);
-
- double h = hsi.hue() / 180.0 * 3.1415;
- double alpha = hsi.sat() * cos(h);
- double beta = hsi.sat() * sin(h);
-
- r = int(sqrt3_3 * hsi.i() + 2 * inv_sqrt6 * beta);
- g = int(sqrt3_3 * hsi.i() + inv_sqrt2 * alpha - inv_sqrt6 * beta);
- b = int(sqrt3_3 * hsi.i() - inv_sqrt2 * alpha - inv_sqrt6 * beta);
+ typedef typename T_rgb::red_t red_t;
+ typedef typename T_rgb::green_t green_t;
+ typedef typename T_rgb::blue_t blue_t;
+
+ static math::round<red_t> to_r;
+ static math::round<green_t> to_g;
+ static math::round<blue_t> to_b;
+
+ static const float
+ sqrt3_3 = std::sqrt(3) / 3,
+ inv_sqrt6 = 1 / std::sqrt(6),
+ inv_sqrt2 = 1 / std::sqrt(2);
+
+ float
+ h = hsi.hue() / 180.0 * 3.1415,
+ alpha = hsi.sat() * std::cos(h),
+ beta = hsi.sat() * std::sin(h);
+
+
+ red_t r = to_r(sqrt3_3 * hsi.i() + 2 * inv_sqrt6 * beta);
+ green_t g = to_g(sqrt3_3 * hsi.i() + inv_sqrt2 * alpha - inv_sqrt6 * beta);
+ blue_t b = to_b(sqrt3_3 * hsi.i() - inv_sqrt2 * alpha - inv_sqrt6 * beta);
T_rgb rgb(r, g, b);
@@ -110,63 +118,63 @@
} // end of namespace fun
+}
+ // namespace convert
+// {
- namespace convert
- {
-
- struct f_rgb_to_hsi
- {
- value::hsi<8> operator()(const value::rgb<8>& rgb) const
- {
- struct value::hsi<8> hsi;
- double sqrt3_3 = sqrt(3) / 3;
- double inv_sqrt6 = 1 / sqrt(6);
- double inv_sqrt2 = 1 / sqrt(2);
-
- double alpha = inv_sqrt2 * rgb.green() - inv_sqrt2 * rgb.blue();
- double beta = 2 * inv_sqrt6 * rgb.red() - inv_sqrt6 * rgb.green() - inv_sqrt6 * rgb.blue();
-
- hsi.hue(atan2(beta, alpha) / 3.1415 * 180.0);
- if (hsi.hue() < 0)
- hsi.hue(hsi.hue() + 360.0);
- mln_precondition(hsi.hue() >= 0);
- hsi.sat(sqrt(alpha * alpha + beta * beta));
- hsi.i(sqrt3_3 * rgb.red() + sqrt3_3 * rgb.green() + sqrt3_3 * rgb.blue());
+// struct f_rgb_to_hsi
+// {
+// value::hsi<8> operator()(const value::rgb<8>& rgb) const
+// {
+// struct value::hsi<8> hsi;
+// double sqrt3_3 = sqrt(3) / 3;
+// double inv_sqrt6 = 1 / sqrt(6);
+// double inv_sqrt2 = 1 / sqrt(2);
+
+// double alpha = inv_sqrt2 * rgb.green() - inv_sqrt2 * rgb.blue();
+// double beta = 2 * inv_sqrt6 * rgb.red() - inv_sqrt6 * rgb.green() - inv_sqrt6 * rgb.blue();
+
+// hsi.hue(atan2(beta, alpha) / 3.1415 * 180.0);
+// if (hsi.hue() < 0)
+// hsi.hue(hsi.hue() + 360.0);
+// mln_precondition(hsi.hue() >= 0);
+// hsi.sat(sqrt(alpha * alpha + beta * beta));
+// hsi.i(sqrt3_3 * rgb.red() + sqrt3_3 * rgb.green() + sqrt3_3 * rgb.blue());
- return hsi;
- }
- };
+// return hsi;
+// }
+// };
- struct f_hsi_to_rgb
- {
+// struct f_hsi_to_rgb
+// {
- value::rgb<8> doit(const value::hsi<8>& hsi) const
- {
- int r;
- int g;
- int b;
+// value::rgb<8> doit(const value::hsi<8>& hsi) const
+// {
+// int r;
+// int g;
+// int b;
- double sqrt3_3 = sqrt(3) / 3;
- double inv_sqrt6 = 1 / sqrt(6);
- double inv_sqrt2 = 1 / sqrt(2);
+// double sqrt3_3 = sqrt(3) / 3;
+// double inv_sqrt6 = 1 / sqrt(6);
+// double inv_sqrt2 = 1 / sqrt(2);
- double h = hsi.hue() / 180.0 * 3.1415;
- double alpha = hsi.sat() * cos(h);
- double beta = hsi.sat() * sin(h);
+// double h = hsi.hue() / 180.0 * 3.1415;
+// double alpha = hsi.sat() * cos(h);
+// double beta = hsi.sat() * sin(h);
- r = int(sqrt3_3 * hsi.i() + 2 * inv_sqrt6 * beta);
- g = int(sqrt3_3 * hsi.i() + inv_sqrt2 * alpha - inv_sqrt6 * beta);
- b = int(sqrt3_3 * hsi.i() - inv_sqrt2 * alpha - inv_sqrt6 * beta);
+// r = int(sqrt3_3 * hsi.i() + 2 * inv_sqrt6 * beta);
+// g = int(sqrt3_3 * hsi.i() + inv_sqrt2 * alpha - inv_sqrt6 * beta);
+// b = int(sqrt3_3 * hsi.i() - inv_sqrt2 * alpha - inv_sqrt6 * beta);
- value::rgb<8> rgb(r, g, b);
+// value::rgb<8> rgb(r, g, b);
- return rgb;
- }
- };
+// return rgb;
+// }
+// };
- } // end of FIXME
+// } // end of FIXME
-} // end of FIXME
+// } // end of FIXME
1
0
Re: [Olena-patches] 1784: Icp legacy. algebra:: now contains types vec, mat and quat.
by Ugo Jardonnet 18 Mar '08
by Ugo Jardonnet 18 Mar '08
18 Mar '08
Roland Levillain wrote:
> Le 17 mars 08 à 19:39, Ugo Jardonnet a écrit :
>
>> https://svn.lrde.epita.fr/svn/oln/trunk/milena
>>
>>
>> Index: ChangeLog
>> from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
>>
>> Icp legacy. algebra:: now contains types vec, mat and quat.
>>
>> * tests/metal_mat.cc: .
>> * tests/metal_pow.cc: .
>> * tests/all.cc: .
>> * tests/mat.cc: .
>> * tests/metal_vec.cc: .
>> * tests/core/h_vec.cc: .
>> * tests/core/tr_image.cc: .
>> * tests/stack.cc: .
>> * tests/dpoint1d.cc: .
>> * tests/dpoint2d.cc: .
>> * tests/dpoint3d.cc: .
>
> [...]
>
> First of all, please pay attention when filling ChangeLogs: all these
> entries deserve a proper comment!
>
> Then, I don't see why everything from metal:: has to go to algebra::, in
> particular metal::pow<>, which actually is a metaprogramming facility!
>
> Last, if you move something to algebra::, then the path of the file
> should reflect this change too, as well as the header guards.
>
>
> I don't have time to discuss this much tonight, but we must definitely
> fix this! (You broke some tests I was working on!).
>
>
I'm bitterly sorry,
:S
The script I used.
---- script.sh : (dans milena)
#!/bin/sh
rm -f tmpffff
for i in `find . -name '*.hh'`
do
sed -f sed.cmds < $i > tmpffff
cat tmpffff > $i
rm tmpffff
done
----
---- sed.cmds :
s/metal::vec/algebra::vec/g
s/metal\/vec/algebra\/vec/g
s/metal::mat/algebra::mat/g
s/metal\/mat/algebra\/mat/g
----
I may revert the patch tomorrow...
For the Changelog I don't understand no more.
sorry again.
1
0
18 Mar '08
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
Icp legacy. algebra:: now contains types vec, mat and quat.
* tests/metal_mat.cc: .
* tests/metal_pow.cc: .
* tests/all.cc: .
* tests/mat.cc: .
* tests/metal_vec.cc: .
* tests/core/h_vec.cc: .
* tests/core/tr_image.cc: .
* tests/stack.cc: .
* tests/dpoint1d.cc: .
* tests/dpoint2d.cc: .
* tests/dpoint3d.cc: .
* tests/fun/x2x/translation.cc: .
* tests/fun/x2x/rotation.cc: .
* tests/fun/x2x/composed.cc: .
* tests/fun/vv2v/min.cc: .
* tests/fun/vv2v/max.cc: .
* tests/fun/v2v/norm.cc: .
* tests/vec.cc: .
* tests/point1d.cc: .
* tests/point2d.cc: .
* tests/norm/l1.cc: .
* tests/norm/l2.cc: .
* tests/norm/linfty.cc: .
* tests/interpolated.cc: .
* mln/trait/ch_value.hh: .
* mln/trait/value_.hh: .
* mln/core/point.hh: .
* mln/core/line_graph_image.hh: .
* mln/core/h_vec.hh: .
* mln/core/tr_image.hh: .
* mln/core/interpolated.hh: .
* mln/core/bgraph_image.hh: .
* mln/core/trait/op_mult.hh: .
* mln/core/graph_image.hh: .
* mln/core/h_mat.hh: .
* mln/core/dpoint.hh: .
* mln/core/plain.hh: .
* mln/metal/mat.hh: .
* mln/metal/math/pow.hh: .
* mln/metal/math/max.hh: .
* mln/metal/math/all.hh: .
* mln/metal/math/sqrt.hh: .
* mln/metal/all.hh: .
* mln/metal/vec.hh: .
* mln/linear/sobel.hh: .
* mln/linear/gaussian.hh: .
* mln/value/graylevel.hh: .
* mln/value/graylevel_f.hh: .
* mln/value/float01_.hh: .
* mln/value/quat.hh: Remove.
* mln/value/int_s.hh: .
* mln/value/int_u.hh: .
* mln/value/internal/gray_.hh: .
* mln/value/internal/gray_f.hh: .
* mln/value/int_u_sat.hh: .
* mln/value/stack.hh: .
* mln/value/rgb.hh: .
* mln/value/label.hh: .
* mln/make/vec.hh: .
* mln/make/mat.hh: .
* mln/make/voronoi.hh: .
* mln/geom/seeds2tiling_roundness.hh: .
* mln/geom/seeds2tiling.hh: .
* mln/fun/x2x/composed.hh: .
* mln/fun/x2x/translation.hh: .
* mln/fun/x2x/rotation.hh: .
* mln/fun/internal/selector.hh: .
* mln/algebra/mat.hh: New.
* mln/algebra/quat.hh: New.
* mln/norm/linfty.hh: .
* mln/norm/l1.hh: .
* mln/norm/l2.hh: .
* sandbox/duhamel/slow_seed2tiling.cc: .
* sandbox/duhamel/labeling_algo.hh: .
* sandbox/duhamel/mesh_image.hh: .
* sandbox/jardonnet/test/icp.cc: New.
* sandbox/jardonnet/test/gaussian_subsampling.cc: .
* sandbox/jardonnet/test/Makefile: .
* sandbox/jardonnet/subsampling/gaussian_subsampling.hh: .
* sandbox/jardonnet/subsampling/sub_sampled_image.hh: .
* sandbox/jardonnet/TODO: .
* sandbox/jardonnet/registration/quat7.hh: New.
* sandbox/jardonnet/registration/cloud.hh: New.
* sandbox/jardonnet/registration/jacobi.hh: New.
* sandbox/jardonnet/registration/icp.hh: .
* sandbox/jardonnet/registration/projection.hh: New.
* sandbox/jardonnet/registration/quat: New.
* sandbox/jardonnet/registration/quat/all.hh: New.
* sandbox/jardonnet/registration/quat/misc.hh: New.
* sandbox/jardonnet/registration/quat/interpol.hh: New.
* sandbox/jardonnet/registration/quat/rotation.hh: New.
* sandbox/vigouroux/color/my_yuv.hh: .
* sandbox/vigouroux/color/my_hsi.hh: .
* sandbox/vigouroux/color/my_hsl.hh: .
* sandbox/vigouroux/color/my_xyz.hh: .
* sandbox/vigouroux/color/my_hsv.hh: .
* sandbox/vigouroux/color/my_yiq.hh: .
* sandbox/folio/dmap.cc: .
* sandbox/garrigues/image_identity/interpolated.hh: .
* sandbox/garrigues/image_identity/interpolated.cc: .
mln/algebra/mat.hh | 487 +++++++++++++
mln/algebra/quat.hh | 648 ++++++++++++++++++
mln/core/bgraph_image.hh | 2
mln/core/dpoint.hh | 14
mln/core/graph_image.hh | 2
mln/core/h_mat.hh | 12
mln/core/h_vec.hh | 22
mln/core/interpolated.hh | 10
mln/core/line_graph_image.hh | 2
mln/core/plain.hh | 2
mln/core/point.hh | 14
mln/core/tr_image.hh | 20
mln/core/trait/op_mult.hh | 28
mln/fun/internal/selector.hh | 4
mln/fun/x2x/composed.hh | 2
mln/fun/x2x/rotation.hh | 22
mln/fun/x2x/translation.hh | 22
mln/geom/seeds2tiling.hh | 2
mln/geom/seeds2tiling_roundness.hh | 2
mln/linear/gaussian.hh | 4
mln/linear/sobel.hh | 2
mln/make/mat.hh | 23
mln/make/vec.hh | 36 -
mln/make/voronoi.hh | 2
mln/metal/all.hh | 6
mln/metal/math/all.hh | 10
mln/metal/math/max.hh | 8
mln/metal/math/pow.hh | 8
mln/metal/math/sqrt.hh | 6
mln/norm/l1.hh | 12
mln/norm/l2.hh | 12
mln/norm/linfty.hh | 14
mln/trait/ch_value.hh | 2
mln/trait/value_.hh | 4
mln/value/float01_.hh | 2
mln/value/graylevel.hh | 10
mln/value/graylevel_f.hh | 2
mln/value/int_s.hh | 6
mln/value/int_u.hh | 2
mln/value/int_u_sat.hh | 4
mln/value/internal/gray_.hh | 6
mln/value/internal/gray_f.hh | 6
mln/value/label.hh | 2
mln/value/rgb.hh | 28
mln/value/stack.hh | 30
sandbox/duhamel/labeling_algo.hh | 6
sandbox/duhamel/mesh_image.hh | 2
sandbox/duhamel/slow_seed2tiling.cc | 2
sandbox/folio/dmap.cc | 2
sandbox/garrigues/image_identity/interpolated.cc | 6
sandbox/garrigues/image_identity/interpolated.hh | 10
sandbox/jardonnet/TODO | 6
sandbox/jardonnet/registration/cloud.hh | 49 +
sandbox/jardonnet/registration/icp.hh | 53 -
sandbox/jardonnet/registration/jacobi.hh | 108 +++
sandbox/jardonnet/registration/projection.hh | 52 +
sandbox/jardonnet/registration/quat/all.hh | 9
sandbox/jardonnet/registration/quat/interpol.hh | 100 ++
sandbox/jardonnet/registration/quat/misc.hh | 19
sandbox/jardonnet/registration/quat/rotation.hh | 60 +
sandbox/jardonnet/registration/quat7.hh | 148 ++++
sandbox/jardonnet/subsampling/gaussian_subsampling.hh | 4
sandbox/jardonnet/subsampling/sub_sampled_image.hh | 4
sandbox/jardonnet/test/Makefile | 7
sandbox/jardonnet/test/gaussian_subsampling.cc | 2
sandbox/jardonnet/test/icp.cc | 16
sandbox/vigouroux/color/my_hsi.hh | 2
sandbox/vigouroux/color/my_hsl.hh | 2
sandbox/vigouroux/color/my_hsv.hh | 2
sandbox/vigouroux/color/my_xyz.hh | 2
sandbox/vigouroux/color/my_yiq.hh | 2
sandbox/vigouroux/color/my_yuv.hh | 2
tests/all.cc | 2
tests/core/h_vec.cc | 6
tests/core/tr_image.cc | 2
tests/dpoint1d.cc | 2
tests/dpoint2d.cc | 2
tests/dpoint3d.cc | 2
tests/fun/v2v/norm.cc | 4
tests/fun/vv2v/max.cc | 4
tests/fun/vv2v/min.cc | 4
tests/fun/x2x/composed.cc | 2
tests/fun/x2x/rotation.cc | 2
tests/fun/x2x/translation.cc | 2
tests/interpolated.cc | 6
tests/mat.cc | 10
tests/metal_mat.cc | 16
tests/metal_pow.cc | 8
tests/metal_vec.cc | 8
tests/norm/l1.cc | 6
tests/norm/l2.cc | 6
tests/norm/linfty.cc | 4
tests/point1d.cc | 2
tests/point2d.cc | 2
tests/stack.cc | 2
tests/vec.cc | 12
96 files changed, 2041 insertions(+), 316 deletions(-)
Index: tests/metal_mat.cc
--- tests/metal_mat.cc (revision 1783)
+++ tests/metal_mat.cc (working copy)
@@ -27,10 +27,10 @@
/*! \file tests/metal_mat.cc
*
- * \brief Test on mln::metal::mat.
+ * \brief Test on mln::algebra::mat.
*/
-#include <mln/metal/mat.hh>
+#include <mln/algebra/mat.hh>
#include <mln/value/int_u8.hh>
@@ -47,18 +47,18 @@
// tab2[6] = {2, 5, 1, 0, 7, 2},
// tab3[6] = {3, 1, 6, 2, 1, 0};
- // metal::mat<3,6,int> mat36 = make::mat<3,6,18>(tab1);
- // metal::mat<2,3,int> mat23_1 = make::mat<2,3,6>(tab2);
- // metal::mat<2,3,int> mat23_2 = make::mat<2,3,6>(tab3);
+ // algebra::mat<3,6,int> mat36 = make::mat<3,6,18>(tab1);
+ // algebra::mat<2,3,int> mat23_1 = make::mat<2,3,6>(tab2);
+ // algebra::mat<2,3,int> mat23_2 = make::mat<2,3,6>(tab3);
- // metal::mat<2,3,float> mat23_3 = mat23_1 - mat23_2;
+ // algebra::mat<2,3,float> mat23_3 = mat23_1 - mat23_2;
// std::cout << mat23_3 << std::endl << mat23_3 * mat36 << std::endl;
- using metal::vec;
+ using algebra::vec;
vec<2,int> v = make::vec(5,1);
- using metal::mat;
+ using algebra::mat;
mat<2,2, vec<2,int> > mv;
mv.set_all(v);
// std::cout << mv << std::endl;
Index: tests/metal_pow.cc
--- tests/metal_pow.cc (revision 1783)
+++ tests/metal_pow.cc (working copy)
@@ -27,12 +27,12 @@
/*! \file tests/metal_pow.cc
*
- * \brief Test on mln::metal::math.
+ * \brief Test on mln::algebra::math.
*/
#include <iostream>
#include <mln/core/contract.hh>
-#include <mln/metal/math/pow.hh>
+#include <mln/algebra/math/pow.hh>
int main()
@@ -40,8 +40,8 @@
using namespace mln;
using namespace mln::metal;
- int res = metal::math::pow_int<2,3>::value;
+ int res = algebra::math::pow_int<2,3>::value;
mln_assertion(res == 8);
- std::cout << metal::math::pow< int_<2>, int_<3> >::ret().name() << std::endl;
+ std::cout << algebra::math::pow< int_<2>, int_<3> >::ret().name() << std::endl;
}
Index: tests/all.cc
--- tests/all.cc (revision 1783)
+++ tests/all.cc (working copy)
@@ -48,7 +48,7 @@
#include <mln/math/all.hh>
//#include <mln/set/all.hh>
#include <mln/draw/all.hh>
-#include <mln/metal/math/all.hh>
+#include <mln/algebra/math/all.hh>
#include <mln/metal/all.hh>
#include <mln/morpho/all.hh>
#include <mln/io/pfm/all.hh>
Index: tests/mat.cc
--- tests/mat.cc (revision 1783)
+++ tests/mat.cc (working copy)
@@ -27,13 +27,13 @@
/*! \file tests/mat.cc
*
- * \brief Tests on mln::metal::mat.
+ * \brief Tests on mln::algebra::mat.
*/
#include <iostream>
#include <mln/fun/i2v/all_to.hh>
-#include <mln/metal/mat.hh>
+#include <mln/algebra/mat.hh>
#include <mln/core/h_mat.hh>
@@ -42,14 +42,14 @@
{
using namespace mln;
- metal::mat<1,3,float> m1(all_to(4.));
- metal::mat<2,2,float> m2 = metal::mat<2,2,float>::Id;
+ algebra::mat<1,3,float> m1(all_to(4.));
+ algebra::mat<2,2,float> m2 = metal::mat<2,2,float>::Id;
h_mat<1,float> hm1(m2);
h_mat<2,float> hm2;
h_mat<3,float> hm3(all_to(1.5));
- metal::mat<4,4,float> m4 = hm3;
+ algebra::mat<4,4,float> m4 = hm3;
std::cout << "m1 = " << m1 << ";" << std::endl;
std::cout << "m2 = " << m2 << ";" << std::endl;
Index: tests/metal_vec.cc
--- tests/metal_vec.cc (revision 1783)
+++ tests/metal_vec.cc (working copy)
@@ -27,10 +27,10 @@
/*! \file tests/metal_vec.cc
*
- * \brief Test on mln::metal::vec.
+ * \brief Test on mln::algebra::vec.
*/
-#include <mln/metal/vec.hh>
+#include <mln/algebra/vec.hh>
#include <mln/value/int_u8.hh>
@@ -40,8 +40,8 @@
{
using namespace mln;
- metal::vec<3,int> v_int = make::vec(3, 6, 7);
- metal::vec<3,float> v_f = make::vec(2.6, 1.9, 5.2);
+ algebra::vec<3,int> v_int = make::vec(3, 6, 7);
+ algebra::vec<3,float> v_f = make::vec(2.6, 1.9, 5.2);
mln_assertion((v_int + v_f) == ((v_f + v_int)));
mln_assertion((v_f / 3) == ((3 * v_f) / 9));
Index: tests/core/h_vec.cc
--- tests/core/h_vec.cc (revision 1783)
+++ tests/core/h_vec.cc (working copy)
@@ -36,7 +36,7 @@
using namespace mln;
-void run_in_3d(const metal::vec<3, int>&)
+void run_in_3d(const algebra::vec<3, int>&)
{
}
@@ -53,7 +53,7 @@
int main()
{
- metal::vec<3, int> x;
+ algebra::vec<3, int> x;
h_vec<3, int> w = x.to_h_vec();
typedef h_vec<3, int> p3d;
@@ -65,7 +65,7 @@
run_in_3d_h(k.to_h_vec());
{
- metal::vec<3,float> v;
+ algebra::vec<3,float> v;
h_vec<3,float> w(v.to_h_vec());
w = v.to_h_vec();
foo(v.to_h_vec());
Index: tests/core/tr_image.cc
--- tests/core/tr_image.cc (revision 1783)
+++ tests/core/tr_image.cc (working copy)
@@ -58,7 +58,7 @@
for_all(p)
{
- metal::vec<3,int> vec = (image3d<int_u8>::point)p;
+ algebra::vec<3,int> vec = (image3d<int_u8>::point)p;
if (inter.has(vec))
out(p) = inter(vec);
else
Index: tests/stack.cc
--- tests/stack.cc (revision 1783)
+++ tests/stack.cc (working copy)
@@ -44,7 +44,7 @@
image2d<int> ima5(b), ima1(b);
point2d p = make::point2d(0, 0);
- metal::vec<2, int> v = make::vec(5, 1);
+ algebra::vec<2, int> v = make::vec(5, 1);
value::stack(ima5, ima1)(p) = v;
mln_assertion(value::stack(ima5, ima1)(p) == v);
Index: tests/dpoint1d.cc
--- tests/dpoint1d.cc (revision 1783)
+++ tests/dpoint1d.cc (working copy)
@@ -48,6 +48,6 @@
mln_assertion(dp == q - p);
mln_assertion(q == p + dp);
- metal::vec<1, float> v = dp;
+ algebra::vec<1, float> v = dp;
mln_assertion(v[0] == 3);
}
Index: tests/dpoint2d.cc
--- tests/dpoint2d.cc (revision 1783)
+++ tests/dpoint2d.cc (working copy)
@@ -48,7 +48,7 @@
mln_assertion(dp == q - p);
mln_assertion(q == p + dp);
- metal::vec<2, float> v = dp;
+ algebra::vec<2, float> v = dp;
mln_assertion(v[0] / 2 == 1.5);
p += dp;
Index: tests/dpoint3d.cc
--- tests/dpoint3d.cc (revision 1783)
+++ tests/dpoint3d.cc (working copy)
@@ -48,6 +48,6 @@
mln_assertion(dp == q - p);
mln_assertion(q == p + dp);
- metal::vec<3, float> v = dp;
+ algebra::vec<3, float> v = dp;
mln_assertion(v[1] == 6);
}
Index: tests/fun/x2x/translation.cc
--- tests/fun/x2x/translation.cc (revision 1783)
+++ tests/fun/x2x/translation.cc (working copy)
@@ -46,7 +46,7 @@
b = 0,
c = 2.9;
- metal::vec<3,float> vec1 = make::vec(a, b, c);
+ algebra::vec<3,float> vec1 = make::vec(a, b, c);
fun::x2x::translation<3,float> tr1(all_to(1.6));
std::cout << vec1 << std::endl;
Index: tests/fun/x2x/rotation.cc
--- tests/fun/x2x/rotation.cc (revision 1783)
+++ tests/fun/x2x/rotation.cc (working copy)
@@ -59,7 +59,7 @@
for_all(p)
{
- metal::vec<2,float> v = rot1.inv()((point2d::vec_t)(point2d)p);
+ algebra::vec<2,float> v = rot1.inv()((point2d::vec_t)(point2d)p);
if (inter.owns_(v))
out(p) = inter(v);
else
Index: tests/fun/x2x/composed.cc
--- tests/fun/x2x/composed.cc (revision 1783)
+++ tests/fun/x2x/composed.cc (working copy)
@@ -48,7 +48,7 @@
b = 0,
c = 2.9;
- metal::vec<3,float> vec1 = make::vec(a, b, c);
+ algebra::vec<3,float> vec1 = make::vec(a, b, c);
fun::x2x::translation<3,float> tr(all_to(1.6));
fun::x2x::rotation<3,float> rot(0.3, 1);
Index: tests/fun/vv2v/min.cc
--- tests/fun/vv2v/min.cc (revision 1783)
+++ tests/fun/vv2v/min.cc (working copy)
@@ -30,7 +30,7 @@
#include <cassert>
-#include <mln/metal/vec.hh>
+#include <mln/algebra/vec.hh>
#include <mln/fun/vv2v/min.hh>
int main()
@@ -43,7 +43,7 @@
// work.
#if 0
// Vectors.
- typedef mln::metal::vec<3, int> vec_t;
+ typedef mln::algebra::vec<3, int> vec_t;
mln::fun::vv2v::min<vec_t> min_vec_t;
vec_t t, u;
t.set (1, -2, 3);
Index: tests/fun/vv2v/max.cc
--- tests/fun/vv2v/max.cc (revision 1783)
+++ tests/fun/vv2v/max.cc (working copy)
@@ -30,7 +30,7 @@
#include <cassert>
-#include <mln/metal/vec.hh>
+#include <mln/algebra/vec.hh>
#include <mln/fun/vv2v/max.hh>
int main()
@@ -43,7 +43,7 @@
// work.
#if 0
// Vectors.
- typedef mln::metal::vec<3, int> vec_t;
+ typedef mln::algebra::vec<3, int> vec_t;
mln::fun::vv2v::max<vec_t> max_vec_t;
vec_t t, u;
t.set (1, -2, 3);
Index: tests/fun/v2v/norm.cc
--- tests/fun/v2v/norm.cc (revision 1783)
+++ tests/fun/v2v/norm.cc (working copy)
@@ -30,7 +30,7 @@
* \brief Test the norm functors.
*/
-#include <mln/metal/vec.hh>
+#include <mln/algebra/vec.hh>
#include <mln/fun/v2v/norm.hh>
#include <tests/norm/common.hh>
@@ -38,7 +38,7 @@
int main()
{
- typedef mln::metal::vec<3, int> vec_t;
+ typedef mln::algebra::vec<3, int> vec_t;
// L1-norm.
{
Index: tests/vec.cc
--- tests/vec.cc (revision 1783)
+++ tests/vec.cc (working copy)
@@ -27,13 +27,13 @@
/*! \file tests/vec.cc
*
- * \brief Tests on mln::metal::vec.
+ * \brief Tests on mln::algebra::vec.
*/
#include <iostream>
#include <mln/fun/i2v/all_to.hh>
-#include <mln/metal/vec.hh>
+#include <mln/algebra/vec.hh>
#include <mln/core/h_vec.hh>
@@ -42,8 +42,8 @@
{
using namespace mln;
- metal::vec<1,float> v1(all_to(4.));
- metal::vec<2,float> v2 = make::vec(6., 2.8);
+ algebra::vec<1,float> v1(all_to(4.));
+ algebra::vec<2,float> v2 = make::vec(6., 2.8);
h_vec<1,float> hv1;
h_vec<2,float> hv2 = v2.to_h_vec(); // Immersion into homogeneous.
@@ -52,8 +52,8 @@
hv3 += make::vec(0., 0., 0., 0.5);
- metal::vec<3,float> v3 = hv3.to_vec(); // Back from homogeneous.
- metal::vec<4,float> v4 = hv3;
+ algebra::vec<3,float> v3 = hv3.to_vec(); // Back from homogeneous.
+ algebra::vec<4,float> v4 = hv3;
std::cout << "v1 = " << v1 << ";" << std::endl;
std::cout << "v2 = " << v2 << ";" << std::endl;
Index: tests/point1d.cc
--- tests/point1d.cc (revision 1783)
+++ tests/point1d.cc (working copy)
@@ -43,7 +43,7 @@
// assignment
p[0] = 4;
- metal::vec<1,int> v = p;
+ algebra::vec<1,int> v = p;
std::cout << v << std::endl;
p.ind() += 1;
Index: tests/point2d.cc
--- tests/point2d.cc (revision 1783)
+++ tests/point2d.cc (working copy)
@@ -74,5 +74,5 @@
for (unsigned i = 0; i < p.dim; ++i)
mln_assertion(q[i] == 0);
- std::cout << 3.4 * metal::vec<2, int>(p) << std::endl;
+ std::cout << 3.4 * algebra::vec<2, int>(p) << std::endl;
}
Index: tests/norm/l1.cc
--- tests/norm/l1.cc (revision 1783)
+++ tests/norm/l1.cc (working copy)
@@ -32,7 +32,7 @@
#include <tests/norm/common.hh>
-#include <mln/metal/vec.hh>
+#include <mln/algebra/vec.hh>
#include <mln/norm/l1.hh>
@@ -58,12 +58,12 @@
int main()
{
- typedef mln::metal::vec<3, int> vec_t;
+ typedef mln::algebra::vec<3, int> vec_t;
// Reference value.
int d = (5 - 1) + (1 + 2) + 3;
- // Tests using mln::metal::vec.
+ // Tests using mln::algebra::vec.
vec_t t, u;
t.set(1, -2, 3);
u.set(5, 1, 0);
Index: tests/norm/l2.cc
--- tests/norm/l2.cc (revision 1783)
+++ tests/norm/l2.cc (working copy)
@@ -35,7 +35,7 @@
#include <tests/norm/common.hh>
-#include <mln/metal/vec.hh>
+#include <mln/algebra/vec.hh>
#include <mln/norm/l2.hh>
@@ -61,14 +61,14 @@
int main()
{
- typedef mln::metal::vec<3, int> vec_t;
+ typedef mln::algebra::vec<3, int> vec_t;
// Reference value.
float d = std::sqrt((4 - 2) * (4 - 2) +
(1 + 2) * (1 + 2) +
(0 - 3) * (0 - 3));
- // Tests using mln::metal::vec.
+ // Tests using mln::algebra::vec.
vec_t t, u;
t.set(2, -2, 3);
u.set(4, 1, 0);
Index: tests/norm/linfty.cc
--- tests/norm/linfty.cc (revision 1783)
+++ tests/norm/linfty.cc (working copy)
@@ -32,7 +32,7 @@
#include <tests/norm/common.hh>
-#include <mln/metal/vec.hh>
+#include <mln/algebra/vec.hh>
#include <mln/math/abs.hh>
#include <mln/norm/linfty.hh>
@@ -59,7 +59,7 @@
int main()
{
- typedef mln::metal::vec<3, int> vec_t;
+ typedef mln::algebra::vec<3, int> vec_t;
// Reference value.
float d = std::max(std::abs(4 - 2),
Index: tests/interpolated.cc
--- tests/interpolated.cc (revision 1783)
+++ tests/interpolated.cc (working copy)
@@ -35,7 +35,7 @@
#include <mln/core/image2d.hh>
#include <mln/core/interpolated.hh>
-#include <mln/metal/vec.hh>
+#include <mln/algebra/vec.hh>
#include <mln/level/fill.hh>
@@ -60,8 +60,8 @@
interpolated< image2d<float> > inter(f);
- metal::vec<2, float> v1 = make::vec(2.3, 0.6);
- metal::vec<2, float> v2 = make::vec(3.2, 1.8);
+ algebra::vec<2, float> v1 = make::vec(2.3, 0.6);
+ algebra::vec<2, float> v2 = make::vec(3.2, 1.8);
debug::println(f);
Index: mln/trait/ch_value.hh
--- mln/trait/ch_value.hh (revision 1783)
+++ mln/trait/ch_value.hh (working copy)
@@ -98,7 +98,7 @@
{
/* FIXME: The code used to read
- typedef metal::vec<n, V> value;
+ typedef algebra::vec<n, V> value;
typedef mln_ch_value(I, value) ret;
here. But this is wrong IMHO (Roland). Changing the value
Index: mln/trait/value_.hh
--- mln/trait/value_.hh (revision 1783)
+++ mln/trait/value_.hh (working copy)
@@ -37,11 +37,11 @@
# include <string>
# include <mln/metal/int.hh>
-# include <mln/metal/math/pow.hh>
+# include <mln/algebra/math/pow.hh>
# include <mln/metal/if.hh>
# include <mln/trait/value/all.hh>
-# include <mln/metal/math/pow.hh>
+# include <mln/algebra/math/pow.hh>
# define mln_trait_value_nature(V) typename mln::trait::value_< V >::nature
Index: mln/core/point.hh
--- mln/core/point.hh (revision 1783)
+++ mln/core/point.hh (working copy)
@@ -38,7 +38,7 @@
# include <mln/fun/i2v/all_to.hh>
# include <mln/metal/bool.hh>
-# include <mln/metal/vec.hh>
+# include <mln/algebra/vec.hh>
# include <mln/metal/converts_to.hh>
# include <mln/core/h_vec.hh>
@@ -62,7 +62,7 @@
template <typename M, typename C>
struct point_to_
{
- typedef metal::vec<M::dim, C> metal_vec;
+ typedef algebra::vec<M::dim, C> metal_vec;
typedef h_vec<M::dim, C> h_vec;
};
@@ -143,17 +143,17 @@
point_<M,C>& operator-=(const dpoint& dp);
/// Type of the array of coordinates.
- typedef metal::vec<M::dim, C> vec_t;
+ typedef algebra::vec<M::dim, C> vec_t;
/// Hook to coordinates.
operator typename internal::point_to_<M, C>::metal_vec () const;
- operator metal::vec<M::dim, float> () const;
+ operator algebra::vec<M::dim, float> () const;
/// Transform to point in homogene coordinate system.
h_vec<M::dim, C> to_h_vec() const;
protected:
- metal::vec<M::dim, C> coord_;
+ algebra::vec<M::dim, C> coord_;
};
@@ -312,9 +312,9 @@
template <typename M, typename C>
inline
- point_<M,C>::operator metal::vec<M::dim, float> () const
+ point_<M,C>::operator algebra::vec<M::dim, float> () const
{
- metal::vec<dim, float> tmp;
+ algebra::vec<dim, float> tmp;
for (unsigned i = 0; i < dim; ++i)
tmp[i] = coord_[i];
return tmp;
Index: mln/core/line_graph_image.hh
--- mln/core/line_graph_image.hh (revision 1783)
+++ mln/core/line_graph_image.hh (working copy)
@@ -34,7 +34,7 @@
# include <mln/trait/images.hh>
# include <mln/core/internal/image_primary.hh>
-# include <mln/metal/vec.hh>
+# include <mln/algebra/vec.hh>
# include <mln/core/p_line_graph.hh>
# include <mln/core/line_graph_psite.hh>
# include <mln/value/set.hh>
Index: mln/core/h_vec.hh
--- mln/core/h_vec.hh (revision 1783)
+++ mln/core/h_vec.hh (working copy)
@@ -33,7 +33,7 @@
* \brief Definition of a vector with homogeneous coordinates.
*/
-# include <mln/metal/vec.hh>
+# include <mln/algebra/vec.hh>
# include <mln/literal/one.hh>
namespace mln
@@ -86,7 +86,7 @@
*
*/
template <unsigned d, typename C>
- struct h_vec : public metal::vec<d + 1, C>
+ struct h_vec : public algebra::vec<d + 1, C>
{
/// Dimension is the 'natural' one (3 for 3D), not the one of the vector (dim + 1).
enum { dim = d };
@@ -94,12 +94,12 @@
/// Constructor without argument.
h_vec();
/// Constructor with the underlying vector.
- h_vec(const metal::vec<d+1, C>& other);
+ h_vec(const algebra::vec<d+1, C>& other);
- h_vec& operator=(const metal::vec<d+1, C>& rhs);
+ h_vec& operator=(const algebra::vec<d+1, C>& rhs);
/// Back to the natural (non-homogeneous) space.
- metal::vec<d,C> to_vec() const;
+ algebra::vec<d,C> to_vec() const;
};
@@ -119,18 +119,18 @@
template <unsigned d, typename C>
inline
- h_vec<d,C>::h_vec(const metal::vec<d+1, C>& other)
- : metal::vec<d+1, C>(other)
+ h_vec<d,C>::h_vec(const algebra::vec<d+1, C>& other)
+ : algebra::vec<d+1, C>(other)
{
}
template <unsigned d, typename C>
inline
- h_vec<d,C>& h_vec<d,C>::operator=(const metal::vec<d+1, C>& rhs)
+ h_vec<d,C>& h_vec<d,C>::operator=(const algebra::vec<d+1, C>& rhs)
{
if (& rhs == this)
return *this;
- this->metal::vec<d+1, C>::operator=(rhs);
+ this->algebra::vec<d+1, C>::operator=(rhs);
return *this;
}
@@ -154,12 +154,12 @@
template <unsigned d, typename C>
inline
- metal::vec<d,C> h_vec<d,C>::to_vec() const
+ algebra::vec<d,C> h_vec<d,C>::to_vec() const
{
const C w = this->data_[d];
mln_assertion(w != 0);
- metal::vec<d,C> tmp;
+ algebra::vec<d,C> tmp;
for (unsigned i = 0; i < d; ++i)
tmp[i] = this->data_[i] / w;
return tmp;
Index: mln/core/tr_image.hh
--- mln/core/tr_image.hh (revision 1783)
+++ mln/core/tr_image.hh (working copy)
@@ -38,7 +38,7 @@
# include <cmath>
# include <mln/core/internal/image_identity.hh>
-# include <mln/metal/vec.hh>
+# include <mln/algebra/vec.hh>
# include <mln/value/set.hh>
@@ -114,18 +114,18 @@
using super_::owns_;
/// Test if a pixel value is accessible at \p v.
- bool owns_(const mln::metal::vec<I::point::dim, float>& v) const;
+ bool owns_(const mln::algebra::vec<I::point::dim, float>& v) const;
using super_::has;
/// Test if a pixel value is belonging to image at \p v.
- bool has(const mln::metal::vec<I::point::dim, float>& v) const;
+ bool has(const mln::algebra::vec<I::point::dim, float>& v) const;
/// Read-only access of pixel value at point site \p p.
/// Mutable access is only OK for reading (not writing).
using super_::operator();
- mln_value(I) operator()(const mln::metal::vec<I::point::dim, float>& v) const;
+ mln_value(I) operator()(const mln::algebra::vec<I::point::dim, float>& v) const;
void set_tr(T& tr);
};
@@ -173,10 +173,10 @@
template <typename T, typename I>
inline
- bool tr_image<T,I>::owns_(const metal::vec<I::point::dim, float>& v) const
+ bool tr_image<T,I>::owns_(const algebra::vec<I::point::dim, float>& v) const
{
mln_point(I) p;
- metal::vec<I::point::dim, float> v2 = this->data_->tr_.inv()(v);
+ algebra::vec<I::point::dim, float> v2 = this->data_->tr_.inv()(v);
for (unsigned i = 0; i < I::point::dim; ++i)
p[i] = static_cast<int>(round(v2[i]));
return this->delegatee_().owns_(p);
@@ -184,10 +184,10 @@
template <typename T, typename I>
inline
- bool tr_image<T,I>::has(const metal::vec<I::point::dim, float>& v) const
+ bool tr_image<T,I>::has(const algebra::vec<I::point::dim, float>& v) const
{
mln_point(I) p;
- metal::vec<I::point::dim, float> v2 = this->data_->tr_.inv()(v);
+ algebra::vec<I::point::dim, float> v2 = this->data_->tr_.inv()(v);
for (unsigned i = 0; i < I::point::dim; ++i)
p[i] = static_cast<int>(round(v2[i]));
return this->delegatee_()->domain().has(p);
@@ -196,10 +196,10 @@
template <typename T, typename I>
inline
mln_value(I)
- tr_image<T,I>::operator()(const metal::vec<I::point::dim, float>& v) const
+ tr_image<T,I>::operator()(const algebra::vec<I::point::dim, float>& v) const
{
mln_point(I) p;
- metal::vec<I::point::dim, float> v2 = this->data_->tr_.inv()(v);
+ algebra::vec<I::point::dim, float> v2 = this->data_->tr_.inv()(v);
for (unsigned i = 0; i < I::point::dim; ++i)
p[i] = static_cast<int>(round(v2[i]));
mln_assertion(this->delegatee_()->owns_(p));
Index: mln/core/interpolated.hh
--- mln/core/interpolated.hh (revision 1783)
+++ mln/core/interpolated.hh (working copy)
@@ -37,7 +37,7 @@
# include <cmath>
# include <mln/core/internal/image_identity.hh>
-# include <mln/metal/vec.hh>
+# include <mln/algebra/vec.hh>
# include <mln/value/set.hh>
namespace mln
@@ -101,13 +101,13 @@
using super_::owns_;
/// Test if a pixel value is accessible at \p v.
- bool owns_(const mln::metal::vec<I::point::dim, float>& v) const;
+ bool owns_(const mln::algebra::vec<I::point::dim, float>& v) const;
/// Read-only access of pixel value at point site \p p.
/// Mutable access is only OK for reading (not writing).
using super_::operator();
- mln_value(I) operator()(const mln::metal::vec<I::point::dim, float>& v) const;
+ mln_value(I) operator()(const mln::algebra::vec<I::point::dim, float>& v) const;
/// Give the set of values of the image.
@@ -156,7 +156,7 @@
template <typename I>
inline
- bool interpolated<I>::owns_(const mln::metal::vec<I::point::dim, float>& v) const
+ bool interpolated<I>::owns_(const mln::algebra::vec<I::point::dim, float>& v) const
{
mln_point(I) p;
for (unsigned i = 0; i < I::point::dim; ++i)
@@ -167,7 +167,7 @@
template <typename I>
inline
mln_value(I)
- interpolated<I>::operator()(const mln::metal::vec<I::point::dim, float>& v) const
+ interpolated<I>::operator()(const mln::algebra::vec<I::point::dim, float>& v) const
{
mln_point(I) p;
for (unsigned i = 0; i < I::point::dim; ++i)
Index: mln/core/bgraph_image.hh
--- mln/core/bgraph_image.hh (revision 1783)
+++ mln/core/bgraph_image.hh (working copy)
@@ -33,7 +33,7 @@
# include <mln/trait/images.hh>
# include <mln/core/internal/image_primary.hh>
-# include <mln/metal/vec.hh>
+# include <mln/algebra/vec.hh>
# include <mln/core/p_bgraph.hh>
# include <mln/core/bgraph_psite.hh>
Index: mln/core/trait/op_mult.hh
--- mln/core/trait/op_mult.hh (revision 1783)
+++ mln/core/trait/op_mult.hh (working copy)
@@ -101,43 +101,43 @@
};
template <unsigned n, typename T, typename U>
- struct op_mult<metal::vec<n, T>, U>
+ struct op_mult<algebra::vec<n, T>, U>
{
- typedef metal::vec<n, mln_op_mult(T, U)> ret;
+ typedef algebra::vec<n, mln_op_mult(T, U)> ret;
};
template <typename U, unsigned n, typename T>
- struct op_mult<U, metal::vec<n, T> >
+ struct op_mult<U, algebra::vec<n, T> >
{
- typedef metal::vec<n, mln_op_mult(T, U)> ret;
+ typedef algebra::vec<n, mln_op_mult(T, U)> ret;
};
template <unsigned n, unsigned m, typename T, typename U>
- struct op_mult<metal::mat<n, m, T>, U>
+ struct op_mult<algebra::mat<n, m, T>, U>
{
- typedef metal::mat<n, m, mln_op_mult(T, U)> ret;
+ typedef algebra::mat<n, m, mln_op_mult(T, U)> ret;
};
template <typename U, unsigned n, unsigned m, typename T>
- struct op_mult<U, metal::mat<n, m, T> >
+ struct op_mult<U, algebra::mat<n, m, T> >
{
- typedef metal::mat<n, m, mln_op_mult(T, U)> ret;
+ typedef algebra::mat<n, m, mln_op_mult(T, U)> ret;
};
template <unsigned n, unsigned o, typename T, unsigned m, typename U>
- struct op_mult<metal::mat<n, o, T>, metal::mat<o, m, U> >
+ struct op_mult<algebra::mat<n, o, T>, algebra::mat<o, m, U> >
{
- typedef metal::mat<n, m, mln_op_mult(T, U)> ret;
+ typedef algebra::mat<n, m, mln_op_mult(T, U)> ret;
};
template <unsigned m, unsigned n, typename T, typename U>
- struct op_mult<metal::mat<m, n, T>, metal::vec<n, U> >
+ struct op_mult<algebra::mat<m, n, T>, algebra::vec<n, U> >
{
- typedef metal::mat<m, 1, mln_op_mult(T, U)> ret;
+ typedef algebra::mat<m, 1, mln_op_mult(T, U)> ret;
};
template <unsigned n, typename U, unsigned m, typename T>
- struct op_mult< metal::vec<n, U>, metal::mat<n, m, T> >
+ struct op_mult< algebra::vec<n, U>, algebra::mat<n, m, T> >
{
- typedef metal::mat<1, m, mln_op_mult(T, U)> ret;
+ typedef algebra::mat<1, m, mln_op_mult(T, U)> ret;
};
Index: mln/core/graph_image.hh
--- mln/core/graph_image.hh (revision 1783)
+++ mln/core/graph_image.hh (working copy)
@@ -34,7 +34,7 @@
# include <mln/trait/images.hh>
# include <mln/core/internal/image_primary.hh>
-# include <mln/metal/vec.hh>
+# include <mln/algebra/vec.hh>
# include <mln/core/p_graph.hh>
# include <mln/core/graph_psite.hh>
# include <mln/value/set.hh>
Index: mln/core/h_mat.hh
--- mln/core/h_mat.hh (revision 1783)
+++ mln/core/h_mat.hh (working copy)
@@ -33,7 +33,7 @@
* \brief Definition of a matrix with homogeneous coordinates.
*/
-# include <mln/metal/mat.hh>
+# include <mln/algebra/mat.hh>
namespace mln
@@ -43,7 +43,7 @@
*
*/
template <unsigned d, typename T>
- struct h_mat : public metal::mat<d+1, d+1, T>
+ struct h_mat : public algebra::mat<d+1, d+1, T>
{
/// Dimension is the 'natural' one (3 for 3D), not the one of the vector (dim + 1)
enum { N = d,
@@ -53,7 +53,7 @@
/// Constructor without argument.
h_mat();
/// Constructor with the underlying matrix.
- h_mat(const metal::mat<d+1, d+1, T>& x);
+ h_mat(const algebra::mat<d+1, d+1, T>& x);
};
@@ -62,14 +62,14 @@
template <unsigned d, typename T>
inline
h_mat<d,T>::h_mat()
- : metal::mat<d+1, d+1, T>(metal::mat<d+1, d+1, T>::Id)
+ : algebra::mat<d+1, d+1, T>(algebra::mat<d+1, d+1, T>::Id)
{
}
template <unsigned d, typename T>
inline
- h_mat<d,T>::h_mat(const metal::mat<d+1, d+1, T>& x)
- : metal::mat<d+1, d+1, T>(x)
+ h_mat<d,T>::h_mat(const algebra::mat<d+1, d+1, T>& x)
+ : algebra::mat<d+1, d+1, T>(x)
{
}
Index: mln/core/dpoint.hh
--- mln/core/dpoint.hh (revision 1783)
+++ mln/core/dpoint.hh (working copy)
@@ -36,7 +36,7 @@
# include <mln/core/concept/dpoint.hh>
# include <mln/core/internal/coord_impl.hh>
# include <mln/fun/i2v/all.hh>
-# include <mln/metal/vec.hh>
+# include <mln/algebra/vec.hh>
# include <mln/metal/converts_to.hh>
@@ -113,15 +113,15 @@
/// Set all coordinates to the value \p c.
void set_all(C c);
- /// Conversion towards a metal::vec.
+ /// Conversion towards a algebra::vec.
template <typename Q>
- operator metal::vec<M::dim, Q>() const;
+ operator algebra::vec<M::dim, Q>() const;
/// Explicit conversion.
- metal::vec<M::dim, C> to_vec() const;
+ algebra::vec<M::dim, C> to_vec() const;
protected:
- metal::vec<M::dim, C> coord_;
+ algebra::vec<M::dim, C> coord_;
};
@@ -232,14 +232,14 @@
template <typename M, typename C>
template <typename Q>
inline
- dpoint_<M,C>::operator metal::vec<M::dim, Q> () const
+ dpoint_<M,C>::operator algebra::vec<M::dim, Q> () const
{
return coord_;
}
template <typename M, typename C>
inline
- metal::vec<M::dim, C>
+ algebra::vec<M::dim, C>
dpoint_<M,C>::to_vec() const
{
return coord_;
Index: mln/core/plain.hh
--- mln/core/plain.hh (revision 1783)
+++ mln/core/plain.hh (working copy)
@@ -39,7 +39,7 @@
# include <mln/core/internal/image_identity.hh>
# include <mln/core/clone.hh>
-# include <mln/metal/vec.hh>
+# include <mln/algebra/vec.hh>
namespace mln
Index: mln/metal/math/pow.hh
--- mln/metal/math/pow.hh (revision 1783)
+++ mln/metal/math/pow.hh (working copy)
@@ -28,7 +28,7 @@
#ifndef MLN_METAL_MATH_POW_HH
# define MLN_METAL_MATH_POW_HH
-/*! \file mln/metal/math/pow.hh
+/*! \file mln/algebra/math/pow.hh
*
* \brief Definition of the 'power' static function.
*/
@@ -37,8 +37,8 @@
# include <mln/metal/int.hh>
-# define mlc_pow(X, N) typename mln::metal::math::pow< X, N >::ret
-# define mlc_pow_int(x, n) mln::metal::math::pow_int< x, n >::value
+# define mlc_pow(X, N) typename mln::algebra::math::pow< X, N >::ret
+# define mlc_pow_int(x, n) mln::algebra::math::pow_int< x, n >::value
@@ -105,7 +105,7 @@
};
- } // end of namespace mln::metal::math
+ } // end of namespace mln::algebra::math
} // end of namespace mln::metal
Index: mln/metal/math/max.hh
--- mln/metal/math/max.hh (revision 1783)
+++ mln/metal/math/max.hh (working copy)
@@ -28,7 +28,7 @@
#ifndef MLN_METAL_MATH_MAX_HH
# define MLN_METAL_MATH_MAX_HH
-/*! \file mln/metal/math/max.hh
+/*! \file mln/algebra/math/max.hh
*
* \brief Definition of the 'max' static function.
*/
@@ -36,8 +36,8 @@
# include <mln/metal/bool.hh>
# include <mln/metal/int.hh>
-# define mlc_max(X, Y) typename mln::metal::math::max< X, Y >::ret
-# define mlc_max_int(x, y) mln::metal::math::max_int< x, y >::value
+# define mlc_max(X, Y) typename mln::algebra::math::max< X, Y >::ret
+# define mlc_max_int(x, y) mln::algebra::math::max_int< x, y >::value
namespace mln
{
@@ -69,7 +69,7 @@
};
- } // end of namespace mln::metal::math
+ } // end of namespace mln::algebra::math
} // end of namespace mln::metal
Index: mln/metal/math/all.hh
--- mln/metal/math/all.hh (revision 1783)
+++ mln/metal/math/all.hh (working copy)
@@ -28,7 +28,7 @@
#ifndef MLN_METAL_MATH_ALL_HH
# define MLN_METAL_MATH_ALL_HH
-/*! \file mln/metal/math/all.hh
+/*! \file mln/algebra/math/all.hh
*
* \brief Include all static mathematical functions.
*/
@@ -43,7 +43,7 @@
/// Namespace of static mathematical functions.
namespace math
{
- /// \internal Implementation namespace of metal::math namespace.
+ /// \internal Implementation namespace of algebra::math namespace.
namespace impl {}
}
@@ -53,9 +53,9 @@
-# include <mln/metal/math/pow.hh>
-# include <mln/metal/math/sqrt.hh>
-# include <mln/metal/math/max.hh>
+# include <mln/algebra/math/pow.hh>
+# include <mln/algebra/math/sqrt.hh>
+# include <mln/algebra/math/max.hh>
// ...
Index: mln/metal/math/sqrt.hh
--- mln/metal/math/sqrt.hh (revision 1783)
+++ mln/metal/math/sqrt.hh (working copy)
@@ -28,7 +28,7 @@
#ifndef MLN_METAL_MATH_SQRT_HH
# define MLN_METAL_MATH_SQRT_HH
-/*! \file mln/metal/math/sqrt.hh
+/*! \file mln/algebra/math/sqrt.hh
*
* \brief Definition of the 'sqrt' static function.
*/
@@ -82,7 +82,7 @@
{
};
- } // end of namespace mln::metal::math::impl
+ } // end of namespace mln::algebra::math::impl
template <int n>
struct sqrt_int : impl::sqrt_int_if_< n, (n >= 0) >
@@ -102,7 +102,7 @@
};
- } // end of namespace mln::metal::math
+ } // end of namespace mln::algebra::math
} // end of namespace mln::metal
Index: mln/metal/all.hh
--- mln/metal/all.hh (revision 1783)
+++ mln/metal/all.hh (working copy)
@@ -74,10 +74,10 @@
# include <mln/metal/unqualif.hh>
# include <mln/metal/is_unqualif.hh>
-# include <mln/metal/vec.hh>
-# include <mln/metal/mat.hh>
+# include <mln/algebra/vec.hh>
+# include <mln/algebra/mat.hh>
-# include <mln/metal/math/all.hh>
+# include <mln/algebra/math/all.hh>
// FIXME: Remove the following includes below!
# include <mln/metal/same_coord.hh>
Index: mln/linear/sobel.hh
--- mln/linear/sobel.hh (revision 1783)
+++ mln/linear/sobel.hh (working copy)
@@ -243,7 +243,7 @@
// The type of a component of a vector from the gradient.
typedef mln_sum(mln_value(I)) gradient_val_t;
// The type of a vector from the gradient.
- typedef mln::metal::vec<I::point::dim, gradient_val_t> gradient_vec_t;
+ typedef mln::algebra::vec<I::point::dim, gradient_val_t> gradient_vec_t;
return sobel_norm(input,
fun::v2v::l1_norm<gradient_vec_t, gradient_val_t>());
}
Index: mln/linear/gaussian.hh
--- mln/linear/gaussian.hh (revision 1783)
+++ mln/linear/gaussian.hh (working copy)
@@ -327,7 +327,7 @@
inline
void
gaussian(const Image<I>& input, float sigma,
- Image<O>& out)
+ Image<O>& output)
{
mln_precondition(exact(input).has_data());
mln_precondition(exact(output).has_data());
@@ -339,7 +339,7 @@
0.6318f, 1.997f,
sigma);
impl::gaussian_common_(mln_trait_value_nature(mln_value(I))(),
- input, coef, sigma, out);
+ input, coef, sigma, output);
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/value/graylevel.hh
--- mln/value/graylevel.hh (revision 1783)
+++ mln/value/graylevel.hh (working copy)
@@ -38,8 +38,8 @@
# include <mln/value/ops.hh>
# include <mln/core/contract.hh>
-# include <mln/metal/math/pow.hh>
-# include <mln/metal/math/max.hh>
+# include <mln/algebra/math/pow.hh>
+# include <mln/algebra/math/max.hh>
# include <mln/metal/bexpr.hh>
# include <mln/literal/ops.hh>
@@ -513,7 +513,7 @@
inline
graylevel<n>::graylevel(const literal::medium_gray_t&)
{
- this->v_ = metal::math::pow_int<2, n - 1>::value;
+ this->v_ = algebra::math::pow_int<2, n - 1>::value;
}
template <unsigned n>
@@ -521,7 +521,7 @@
graylevel<n>&
graylevel<n>::operator=(const literal::medium_gray_t&)
{
- this->v_ = metal::math::pow_int<2, n - 1>::value;
+ this->v_ = algebra::math::pow_int<2, n - 1>::value;
return *this;
}
@@ -555,7 +555,7 @@
float
graylevel<n>::to_float() const
{
- static const float denom = float(metal::math::pow_int<2, n>::value) - 1.f;
+ static const float denom = float(algebra::math::pow_int<2, n>::value) - 1.f;
return float(this->v_) / denom;
}
Index: mln/value/graylevel_f.hh
--- mln/value/graylevel_f.hh (revision 1783)
+++ mln/value/graylevel_f.hh (working copy)
@@ -38,7 +38,7 @@
# include <mln/value/ops.hh>
# include <mln/core/contract.hh>
-# include <mln/metal/math/pow.hh>
+# include <mln/algebra/math/pow.hh>
# include <mln/metal/bexpr.hh>
# include <mln/literal/ops.hh>
Index: mln/value/float01_.hh
--- mln/value/float01_.hh (revision 1783)
+++ mln/value/float01_.hh (working copy)
@@ -35,7 +35,7 @@
# include <iostream>
# include <mln/core/contract.hh>
-# include <mln/metal/math/pow.hh>
+# include <mln/algebra/math/pow.hh>
# include <mln/metal/bexpr.hh>
# include <mln/value/int_u.hh>
Index: mln/value/int_s.hh
--- mln/value/int_s.hh (revision 1783)
+++ mln/value/int_s.hh (working copy)
@@ -35,7 +35,7 @@
# include <mln/value/ops.hh>
-# include <mln/metal/math/pow.hh>
+# include <mln/algebra/math/pow.hh>
# include <mln/value/internal/value_like.hh>
# include <mln/value/concept/integer.hh>
# include <mln/value/internal/encoding.hh>
@@ -180,7 +180,7 @@
inline
int_s<n>::int_s(int i)
{
- static const int max = metal::math::pow_int<2, n-1>::value - 1;
+ static const int max = algebra::math::pow_int<2, n-1>::value - 1;
static const int min = - max;
mln_precondition(i >= min);
mln_precondition(i <= max);
@@ -192,7 +192,7 @@
int_s<n>&
int_s<n>::operator=(int i)
{
- static const int max = metal::math::pow_int<2, n-1>::value - 1;
+ static const int max = algebra::math::pow_int<2, n-1>::value - 1;
static const int min = - max;
mln_precondition(i >= min);
mln_precondition(i <= max);
Index: mln/value/int_u.hh
--- mln/value/int_u.hh (revision 1783)
+++ mln/value/int_u.hh (working copy)
@@ -35,7 +35,7 @@
# include <mln/value/ops.hh>
-# include <mln/metal/math/pow.hh>
+# include <mln/algebra/math/pow.hh>
# include <mln/value/internal/value_like.hh>
# include <mln/value/internal/encoding.hh>
# include <mln/value/concept/integer.hh>
Index: mln/value/internal/gray_.hh
--- mln/value/internal/gray_.hh (revision 1783)
+++ mln/value/internal/gray_.hh (working copy)
@@ -37,8 +37,8 @@
# include <iostream>
# include <cmath>
-# include <mln/metal/math/max.hh>
-# include <mln/metal/math/pow.hh>
+# include <mln/algebra/math/max.hh>
+# include <mln/algebra/math/pow.hh>
# include <mln/value/concept/integer.hh>
@@ -312,7 +312,7 @@
inline
gray_<n>::operator graylevel_f() const
{
- static const float denom = float(metal::math::pow_int<2, n>::value) - 1.f;
+ static const float denom = float(algebra::math::pow_int<2, n>::value) - 1.f;
return graylevel_f(float(this->v_) / denom);
}
Index: mln/value/internal/gray_f.hh
--- mln/value/internal/gray_f.hh (revision 1783)
+++ mln/value/internal/gray_f.hh (working copy)
@@ -38,7 +38,7 @@
# include <mln/value/ops.hh>
# include <mln/core/contract.hh>
-# include <mln/metal/math/pow.hh>
+# include <mln/algebra/math/pow.hh>
# include <mln/metal/bexpr.hh>
# include <mln/literal/ops.hh>
@@ -225,7 +225,7 @@
template <unsigned n>
gray_f::gray_f(const gray_<n>& rhs)
{
- static const float denom = float(metal::math::pow_int<2, n>::value) - 1.f;
+ static const float denom = float(algebra::math::pow_int<2, n>::value) - 1.f;
this->v_ = float(rhs.value()) / denom;
}
@@ -233,7 +233,7 @@
gray_f&
gray_f::operator=(const gray_<n>& rhs)
{
- static const float denom = float(metal::math::pow_int<2, n>::value) - 1.f;
+ static const float denom = float(algebra::math::pow_int<2, n>::value) - 1.f;
this->v_ = float(rhs.value()) / denom;
return *this;
}
Index: mln/value/int_u_sat.hh
--- mln/value/int_u_sat.hh (revision 1783)
+++ mln/value/int_u_sat.hh (working copy)
@@ -34,7 +34,7 @@
* behavior.
*/
-# include <mln/metal/math/pow.hh>
+# include <mln/algebra/math/pow.hh>
# include <mln/value/internal/value_like.hh>
# include <mln/value/concept/integer.hh>
# include <mln/value/internal/encoding.hh>
@@ -59,7 +59,7 @@
struct value_< mln::value::int_u_sat<n> >
{
// FIXME: Overhaul these traits (see other value traits).
- static const std::size_t card = metal::math::pow_int<2, n>::value;
+ static const std::size_t card = algebra::math::pow_int<2, n>::value;
static const mln::value::int_u_sat<n> min() { return 0; }
static const mln::value::int_u_sat<n> max() { return card - 1; }
static const unsigned nbits = n;
Index: mln/value/stack.hh
--- mln/value/stack.hh (revision 1783)
+++ mln/value/stack.hh (working copy)
@@ -35,7 +35,7 @@
# include <mln/core/internal/image_value_morpher.hh>
-# include <mln/metal/vec.hh>
+# include <mln/algebra/vec.hh>
# include <mln/value/set.hh>
# include <mln/value/proxy.hh>
@@ -57,8 +57,8 @@
struct data_< value::stack_image<n, I> >
{
public:
- data_(const metal::vec<n,I>& imas);
- metal::vec<n,I> imas_;
+ data_(const algebra::vec<n,I>& imas);
+ algebra::vec<n,I> imas_;
I& ima_;
};
@@ -83,7 +83,7 @@
template <unsigned n, typename I>
struct helper_stack_image_lvalue_< n, const I >
{
- typedef metal::vec<n, mln_value(I)> ret;
+ typedef algebra::vec<n, mln_value(I)> ret;
static ret make(stack_image<n, const I>& ima, const mln_psite(I)& p)
{
return ima.read_(p);
@@ -102,7 +102,7 @@
template <unsigned n, typename I>
struct image_< mln::value::stack_image<n, I> >
: default_image_morpher_< I,
- metal::vec<n, mln_value(I)>,
+ algebra::vec<n, mln_value(I)>,
mln::value::stack_image<n, I> >
{
// FIXME: We shall carefully define the missing required traits
@@ -155,7 +155,7 @@
typedef mln_pset(I) pset;
/// Value associated type.
- typedef metal::vec<n, mln_value(I)> value;
+ typedef algebra::vec<n, mln_value(I)> value;
/// Return type of read-only access.
typedef value rvalue;
@@ -173,7 +173,7 @@
/// Constructors.
/// \{
- stack_image(const metal::vec<n,I>& imas);
+ stack_image(const algebra::vec<n,I>& imas);
stack_image();
/// \}
@@ -215,7 +215,7 @@
template <unsigned n, typename I>
inline
- data_< value::stack_image<n,I> >::data_(const metal::vec<n,I>& imas)
+ data_< value::stack_image<n,I> >::data_(const algebra::vec<n,I>& imas)
: imas_(imas),
ima_(imas_[0])
{
@@ -236,7 +236,7 @@
template <unsigned n, typename I>
inline
- stack_image<n,I>::stack_image(const metal::vec<n,I>& imas)
+ stack_image<n,I>::stack_image(const algebra::vec<n,I>& imas)
{
this->data_ = new mln::internal::data_< stack_image<n, I> >(imas);
for (unsigned i = 0; i < n; ++i)
@@ -256,11 +256,11 @@
template <unsigned n, typename I>
inline
- metal::vec<n, mln_value(I)>
+ algebra::vec<n, mln_value(I)>
stack_image<n,I>::read_(const psite& p) const
{
mln_precondition(this->owns_(p));
- metal::vec<n, mln_value(I)> tmp;
+ algebra::vec<n, mln_value(I)> tmp;
for (unsigned i = 0; i < n; ++i)
tmp[i] = this->data_->imas_[i].operator()(p);
return tmp;
@@ -268,7 +268,7 @@
template <unsigned n, typename I>
inline
- metal::vec<n, mln_value(I)>
+ algebra::vec<n, mln_value(I)>
stack_image<n,I>::operator()(const psite& p) const
{
return read_(p);
@@ -295,7 +295,7 @@
template <unsigned n, typename I>
inline
- const mln::value::set< metal::vec<n, mln_value(I)> >&
+ const mln::value::set< algebra::vec<n, mln_value(I)> >&
stack_image<n,I>::values() const
{
return vset::the();
@@ -309,7 +309,7 @@
stack(const Image<I>& ima1, const Image<I>& ima2)
{
mln_precondition(exact(ima1).domain() == exact(ima2).domain());
- metal::vec<2, const I> imas;
+ algebra::vec<2, const I> imas;
imas[0] = exact(ima1);
imas[1] = exact(ima2);
return imas;
@@ -321,7 +321,7 @@
stack(Image<I>& ima1, Image<I>& ima2)
{
mln_precondition(exact(ima1).domain() == exact(ima2).domain());
- metal::vec<2, I> imas;
+ algebra::vec<2, I> imas;
imas[0] = exact(ima1);
imas[1] = exact(ima2);
return imas;
Index: mln/value/rgb.hh
--- mln/value/rgb.hh (revision 1783)
+++ mln/value/rgb.hh (working copy)
@@ -38,7 +38,7 @@
# include <mln/value/concept/vectorial.hh>
# include <mln/value/int_u.hh>
-# include <mln/metal/vec.hh>
+# include <mln/algebra/vec.hh>
namespace mln
@@ -137,7 +137,7 @@
typedef trait::value::kind::color kind;
typedef mln_value_quant_from_(card) quant;
- typedef metal::vec<3, float> sum;
+ typedef algebra::vec<3, float> sum;
};
} // end of namespace trait
@@ -155,9 +155,9 @@
:
public Vectorial< rgb<n> >
,
- public internal::value_like_< metal::vec< 3, int_u<n> >, // Equivalent.
- metal::vec< 3, int_u<n> >, // Encoding.
- metal::vec< 3, int >, // Interoperation.
+ public internal::value_like_< algebra::vec< 3, int_u<n> >, // Equivalent.
+ algebra::vec< 3, int_u<n> >, // Encoding.
+ algebra::vec< 3, int >, // Interoperation.
rgb<n> > // Exact.
{
public:
@@ -179,15 +179,15 @@
/// Constructor from component values.
rgb<n>(int r, int g, int b);
- /// Constructor from a metal::vec.
- rgb<n>(const metal::vec<3, int>& rhs);
- rgb<n>(const metal::vec<3, unsigned>& rhs);
- rgb<n>(const metal::vec<3, int_u<n> >& rhs);
+ /// Constructor from a algebra::vec.
+ rgb<n>(const algebra::vec<3, int>& rhs);
+ rgb<n>(const algebra::vec<3, unsigned>& rhs);
+ rgb<n>(const algebra::vec<3, int_u<n> >& rhs);
// Conversion to the interoperation type.
- operator metal::vec<3, int>() const { return this->v_; }
+ operator algebra::vec<3, int>() const { return this->v_; }
// Conversion to the sum type.
- operator metal::vec<3, float>() const { return this->v_; }
+ operator algebra::vec<3, float>() const { return this->v_; }
/// \{ Constructors with literals.
rgb<n>(const literal::white_t&);
@@ -293,21 +293,21 @@
template <unsigned n>
inline
- rgb<n>::rgb(const metal::vec<3, int>& v)
+ rgb<n>::rgb(const algebra::vec<3, int>& v)
{
this->v_ = v;
}
template <unsigned n>
inline
- rgb<n>::rgb(const metal::vec<3, unsigned>& v)
+ rgb<n>::rgb(const algebra::vec<3, unsigned>& v)
{
this->v_ = v;
}
template <unsigned n>
inline
- rgb<n>::rgb(const metal::vec<3, int_u<n> >& v)
+ rgb<n>::rgb(const algebra::vec<3, int_u<n> >& v)
{
this->v_ = v;
}
Index: mln/value/label.hh
--- mln/value/label.hh (revision 1783)
+++ mln/value/label.hh (working copy)
@@ -33,7 +33,7 @@
* \brief Define a generic class for labels.
*/
-# include <mln/metal/math/pow.hh>
+# include <mln/algebra/math/pow.hh>
# include <mln/value/concept/symbolic.hh>
# include <mln/value/internal/value_like.hh>
# include <mln/value/internal/convert.hh>
Index: mln/make/vec.hh
--- mln/make/vec.hh (revision 1783)
+++ mln/make/vec.hh (working copy)
@@ -30,10 +30,10 @@
/*! \file mln/make/vec.hh
*
- * \brief Routine to construct an mln::metal::vec.
+ * \brief Routine to construct an mln::algebra::vec.
*/
-# include <mln/metal/vec.hh>
+# include <mln/algebra/vec.hh>
# include <mln/core/concept/function.hh>
namespace mln
@@ -43,16 +43,16 @@
{
- /*! \brief Create an mln::metal::vec<n,T>.
+ /*! \brief Create an mln::algebra::vec<n,T>.
*
* \param[in] v_0 First coordinate.
*
* \return A 1D vector.
*/
template <typename T>
- metal::vec<1, T> vec(const T& v_0);
+ algebra::vec<1, T> vec(const T& v_0);
- /*! \brief Create an mln::metal::vec<2,T>.
+ /*! \brief Create an mln::algebra::vec<2,T>.
*
* \param[in] v_0 First coordinate.
* \param[in] v_1 Second coordinate.
@@ -60,9 +60,9 @@
* \return A 2D vector.
*/
template <typename T>
- metal::vec<2, T> vec(const T& v_0, const T& v_1);
+ algebra::vec<2, T> vec(const T& v_0, const T& v_1);
- /*! \brief Create an mln::metal::vec<3,T>.
+ /*! \brief Create an mln::algebra::vec<3,T>.
*
* \param[in] v_0 First coordinate.
* \param[in] v_1 Second coordinate.
@@ -71,9 +71,9 @@
* \return A 3D vector.
*/
template <typename T>
- metal::vec<3, T> vec(const T& v_0, const T& v_1, const T& v_2);
+ algebra::vec<3, T> vec(const T& v_0, const T& v_1, const T& v_2);
- /*! \brief Create an mln::metal::vec<4,T>.
+ /*! \brief Create an mln::algebra::vec<4,T>.
*
* \param[in] v_0 First coordinate.
* \param[in] v_1 Second coordinate.
@@ -83,25 +83,25 @@
* \return A 4D vector.
*/
template <typename T>
- metal::vec<4, T> vec(const T& v_0, const T& v_1, const T& v_2, const T& v_3);
+ algebra::vec<4, T> vec(const T& v_0, const T& v_1, const T& v_2, const T& v_3);
# ifndef MLN_INCLUDE_ONLY
template <typename T>
inline
- metal::vec<1, T> vec(const T& v_0)
+ algebra::vec<1, T> vec(const T& v_0)
{
- metal::vec<1, T> tmp;
+ algebra::vec<1, T> tmp;
tmp[0] = v_0;
return tmp;
}
template <typename T>
inline
- metal::vec<2, T> vec(const T& v_0, const T& v_1)
+ algebra::vec<2, T> vec(const T& v_0, const T& v_1)
{
- metal::vec<2, T> tmp;
+ algebra::vec<2, T> tmp;
tmp[0] = v_0;
tmp[1] = v_1;
return tmp;
@@ -109,9 +109,9 @@
template <typename T>
inline
- metal::vec<3, T> vec(const T& v_0, const T& v_1, const T& v_2)
+ algebra::vec<3, T> vec(const T& v_0, const T& v_1, const T& v_2)
{
- metal::vec<3, T> tmp;
+ algebra::vec<3, T> tmp;
tmp[0] = v_0;
tmp[1] = v_1;
tmp[2] = v_2;
@@ -120,9 +120,9 @@
template <typename T>
inline
- metal::vec<4, T> vec(const T& v_0, const T& v_1, const T& v_2, const T& v_3)
+ algebra::vec<4, T> vec(const T& v_0, const T& v_1, const T& v_2, const T& v_3)
{
- metal::vec<4, T> tmp;
+ algebra::vec<4, T> tmp;
tmp[0] = v_0;
tmp[1] = v_1;
tmp[2] = v_2;
Index: mln/make/mat.hh
--- mln/make/mat.hh (revision 1783)
+++ mln/make/mat.hh (working copy)
@@ -30,17 +30,17 @@
/*! \file mln/make/mat.hh
*
- * \brief Routine to construct an mln::metal::mat.
+ * \brief Routine to construct an mln::algebra::mat.
*/
-# include <mln/metal/mat.hh>
+# include <mln/algebra/mat.hh>
namespace mln
{
namespace make
{
- /*! \brief Create an mln::metal::mat<n,m,T>.
+ /*! \brief Create an mln::algebra::mat<n,m,T>.
*
* \param[in] tab Tab of value.
*
@@ -48,21 +48,32 @@
* with n and m, the dimensions oh the matrix.
*/
template <unsigned n, unsigned m, unsigned N, typename T>
- metal::mat<n,m,T> mat(const T tab[N]);
+ algebra::mat<n,m,T> mat(const T tab[N]);
+
+ template <unsigned n, unsigned m, typename T>
+ algebra::mat<n,m,T> mat(algebra::vec<n,T> v);
# ifndef MLN_INCLUDE_ONLY
template <unsigned n, unsigned m, unsigned N, typename T>
inline
- metal::mat<n,m,T> mat(const T tab[N])
+ algebra::mat<n,m,T> mat(const T tab[N])
{
mln_precondition(n * m == N);
- metal::mat<n,m,T> tmp;
+ algebra::mat<n,m,T> tmp;
for (unsigned i = 0; i < N; ++i)
tmp(i / m, i % m) = tab[i];
return tmp;
}
+ template <unsigned n, typename T>
+ algebra::mat<n,1,T> mat(algebra::vec<n,T> v)
+ {
+ algebra::mat<n,1,T> tmp;
+ for (unsigned i = 0; i < n; i++)
+ tmp(i,1) = v[i];
+ return tmp;
+ }
# endif // ! MLN_INCLUDE_ONLY
Index: mln/make/voronoi.hh
--- mln/make/voronoi.hh (revision 1783)
+++ mln/make/voronoi.hh (working copy)
@@ -77,7 +77,7 @@
Image<I>& orig_,
const Neighborhood<N>& nbh)
{
- typedef metal::vec<2,float> X;
+ typedef algebra::vec<2,float> X;
typedef mln_value(I) V;
typedef mln_psite(I) P;
Index: mln/geom/seeds2tiling_roundness.hh
--- mln/geom/seeds2tiling_roundness.hh (revision 1783)
+++ mln/geom/seeds2tiling_roundness.hh (working copy)
@@ -41,7 +41,7 @@
# include <mln/core/clone.hh>
# include <mln/accu/mean.hh>
# include <mln/estim/min_max.hh>
-# include <mln/metal/vec.hh>
+# include <mln/algebra/vec.hh>
# include <mln/geom/chamfer.hh>
Index: mln/geom/seeds2tiling.hh
--- mln/geom/seeds2tiling.hh (revision 1783)
+++ mln/geom/seeds2tiling.hh (working copy)
@@ -40,7 +40,7 @@
# include <mln/core/clone.hh>
# include <mln/accu/mean.hh>
# include <mln/estim/min_max.hh>
-# include <mln/metal/vec.hh>
+# include <mln/algebra/vec.hh>
namespace mln
Index: mln/fun/x2x/composed.hh
--- mln/fun/x2x/composed.hh (revision 1783)
+++ mln/fun/x2x/composed.hh (working copy)
@@ -35,7 +35,7 @@
# include <mln/core/concept/function.hh>
# include <mln/fun/internal/x2x_linear_impl.hh>
-# include <mln/metal/vec.hh>
+# include <mln/algebra/vec.hh>
# include <mln/metal/is.hh>
# include <mln/metal/bexpr.hh>
# include <mln/core/h_mat.hh>
Index: mln/fun/x2x/translation.hh
--- mln/fun/x2x/translation.hh (revision 1783)
+++ mln/fun/x2x/translation.hh (working copy)
@@ -35,7 +35,7 @@
# include <mln/core/concept/function.hh>
# include <mln/fun/internal/x2x_linear_impl.hh>
-# include <mln/metal/vec.hh>
+# include <mln/algebra/vec.hh>
# include <mln/core/h_mat.hh>
# include <mln/fun/i2v/all.hh>
@@ -54,11 +54,11 @@
template <unsigned n, typename C>
struct translation
- : internal::x2x_linear_impl_< metal::vec<n,C>, translation<n,C> >
+ : internal::x2x_linear_impl_< algebra::vec<n,C>, translation<n,C> >
,
public Bijection_x2x< translation<n,C> >
{
- typedef fun::internal::x2x_linear_impl_< metal::vec<n,C>, translation<n,C> > super_;
+ typedef fun::internal::x2x_linear_impl_< algebra::vec<n,C>, translation<n,C> > super_;
/// Type of the inverse function.
typedef translation<n,C> invert;
@@ -68,19 +68,19 @@
/// Constructor without argument.
translation();
/// Constructor with the translation vector.
- translation(const metal::vec<n,C>& t);
+ translation(const algebra::vec<n,C>& t);
using super_::operator();
/// Perform the translation of the given vector
- metal::vec<n,C> operator()(const metal::vec<n,C>& v) const;
+ algebra::vec<n,C> operator()(const algebra::vec<n,C>& v) const;
/// Set a net translation vector.
- void set_t(const metal::vec<n,C>& t);
+ void set_t(const algebra::vec<n,C>& t);
protected:
void update();
- metal::vec<n,C> t_;
+ algebra::vec<n,C> t_;
};
@@ -94,7 +94,7 @@
template <unsigned n, typename C>
inline
- translation<n,C>::translation(const metal::vec<n,C>& t)
+ translation<n,C>::translation(const algebra::vec<n,C>& t)
:t_(t)
{
this->m_ = h_mat<n,C>::Id;
@@ -103,8 +103,8 @@
template <unsigned n, typename C>
inline
- metal::vec<n,C>
- translation<n,C>::operator()(const metal::vec<n,C>& v) const
+ algebra::vec<n,C>
+ translation<n,C>::operator()(const algebra::vec<n,C>& v) const
{
return v + t_;
}
@@ -122,7 +122,7 @@
template <unsigned n, typename C>
inline
void
- translation<n,C>::set_t(const metal::vec<n,C>& t)
+ translation<n,C>::set_t(const algebra::vec<n,C>& t)
{
this->t_ = t;
this->update();
Index: mln/fun/x2x/rotation.hh
--- mln/fun/x2x/rotation.hh (revision 1783)
+++ mln/fun/x2x/rotation.hh (working copy)
@@ -35,8 +35,8 @@
# include <mln/core/concept/function.hh>
# include <mln/fun/internal/x2x_linear_impl.hh>
-# include <mln/metal/vec.hh>
-# include <mln/metal/mat.hh>
+# include <mln/algebra/vec.hh>
+# include <mln/algebra/mat.hh>
# include <cmath>
namespace mln
@@ -53,10 +53,10 @@
*/
template <unsigned n, typename C>
struct rotation
- : internal::x2x_linear_impl_< metal::vec<n,C>, rotation<n,C> >
+ : internal::x2x_linear_impl_< algebra::vec<n,C>, rotation<n,C> >
, public Bijection_x2x< rotation<n,C> >
{
- typedef fun::internal::x2x_linear_impl_< metal::vec<n,C>, rotation<n,C> > super_;
+ typedef fun::internal::x2x_linear_impl_< algebra::vec<n,C>, rotation<n,C> > super_;
/// Type of the inverse function.
typedef rotation<n,C> invert;
@@ -70,7 +70,7 @@
using super_::operator();
/// Perform the rotation of the given vector.
- metal::vec<n,C> operator()(const metal::vec<n,C>& v) const;
+ algebra::vec<n,C> operator()(const algebra::vec<n,C>& v) const;
/// Set a new grade alpha.
void set_alpha(float alpha);
@@ -106,12 +106,12 @@
template <unsigned n, typename C>
inline
- metal::vec<n,C>
- rotation<n,C>::operator()(const metal::vec<n,C>& v) const
+ algebra::vec<n,C>
+ rotation<n,C>::operator()(const algebra::vec<n,C>& v) const
{
- metal::mat<n+1,1,C> hmg;
- metal::mat<n+1,1,C> tmp;
- metal::vec<n,C> res;
+ algebra::mat<n+1,1,C> hmg;
+ algebra::mat<n+1,1,C> tmp;
+ algebra::vec<n,C> res;
for (unsigned i = 0; i < n; ++i)
hmg(i,0) = v[i];
@@ -158,7 +158,7 @@
{
const float cos_a = cos(alpha_);
const float sin_a = sin(alpha_);
- const metal::vec<4,float> vec = make::vec(cos_a, -sin_a, sin_a, cos_a);
+ const algebra::vec<4,float> vec = make::vec(cos_a, -sin_a, sin_a, cos_a);
unsigned k = 0;
for (unsigned i = 0; i < n; ++i)
Index: mln/fun/internal/selector.hh
--- mln/fun/internal/selector.hh (revision 1783)
+++ mln/fun/internal/selector.hh (working copy)
@@ -38,7 +38,7 @@
# include <mln/metal/unqualif.hh>
# include <mln/metal/if.hh>
# include <mln/metal/is_a.hh>
-# include <mln/metal/vec.hh>
+# include <mln/algebra/vec.hh>
namespace mln
@@ -152,7 +152,7 @@
};
template <unsigned n, typename T>
- struct tag_< metal::vec<n,T> >
+ struct tag_< algebra::vec<n,T> >
{
enum { value = x_ };
};
Index: mln/algebra/mat.hh
--- mln/algebra/mat.hh (revision 0)
+++ mln/algebra/mat.hh (revision 0)
@@ -0,0 +1,487 @@
+// Copyright (C) 2006 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_ALGEBRA_MAT_HH
+# define MLN_ALGEBRA_MAT_HH
+
+/*!
+ * \file mln/algebra/mat.hh
+ *
+ * \brief Definition of a generic matrix class.
+ */
+
+# include <iostream>
+
+# include <mln/core/concept/object.hh>
+# include <mln/core/concept/function.hh>
+# include <mln/core/contract.hh>
+# include <mln/trait/all.hh>
+# include <mln/trait/value_.hh>
+# include <mln/algebra/vec.hh>
+
+
+// FIXME: Document.
+
+
+
+namespace mln
+{
+
+
+ // Fwd decl.
+ namespace algebra {
+ template <unsigned n, unsigned m, typename T> class mat;
+ }
+
+
+ namespace trait
+ {
+
+ template <unsigned n, unsigned m, typename T>
+ struct value_< algebra::mat<n,m,T> >
+ {
+ typedef trait::value::nature::matrix nature;
+ typedef trait::value::kind::data kind;
+
+ enum {
+ nbits = n * m * mln_nbits(T),
+ card = n * m * mln_card(T)
+ };
+ typedef mln_value_quant_from_(card) quant;
+
+ typedef algebra::mat<n, m, mln_sum(T)> sum;
+ };
+
+ } // end of namespace mln::trait
+
+
+
+ namespace algebra
+ {
+
+ template <unsigned n, unsigned m, typename T>
+ class mat : public Object< mat<n,m,T> >
+ {
+ public:
+
+ typedef T coord;
+ enum { N = n,
+ M = m,
+ dim = n * m };
+
+ static const mat<n,m,T> Id;
+
+ mat()
+ {
+ }
+
+ template <typename U>
+ mat(const mat<n,m,U>& rhs);
+
+ /// Constructor; coordinates are set by function \p f.
+ template <typename F>
+ mat(const Function_i2v<F>& f);
+
+ template <typename U>
+ mat& operator=(const mat<n,m,U>& rhs);
+
+ const T& operator()(unsigned i, unsigned j) const;
+
+ T& operator()(unsigned i, unsigned j);
+
+ void set_all(const T& val);
+
+ unsigned size() const;
+
+ static mat identity();
+
+ private:
+ T data_[n][m];
+ };
+
+ }
+
+
+ namespace trait
+ {
+
+ // Unarys.
+
+ template < template<class> class Name,
+ unsigned n, unsigned m, typename T >
+ struct set_precise_unary_< Name, algebra::mat<n,m,T> >
+ {
+ typedef algebra::mat<n, m, mln_trait_unary(Name, T)> ret;
+ };
+
+ // Default for binarys; works for (+), (-), comparisons, and promote.
+
+ template < template<class, class> class Name,
+ unsigned n, unsigned m, typename T, typename U>
+ struct set_precise_binary_< Name, algebra::mat<n,m,T>, algebra::mat<n,m,U> >
+ {
+ typedef algebra::mat<n, m, mln_trait_binary(Name, T, U)> ret;
+ };
+
+ // mat * mat
+
+ template < unsigned n, unsigned o, typename T,
+ unsigned m, typename U >
+ struct set_precise_binary_< op::times, algebra::mat<n,o,T>, algebra::mat<o,m,U> >
+ {
+ typedef algebra::mat<n, m, mln_sum_x(T, U)> ret;
+ };
+
+ template < unsigned n, typename T, typename U >
+ struct set_precise_binary_< op::times, algebra::mat<n,n,T>, algebra::mat<n,n,U> >
+ { // Disambiguate between both previous defs.
+ typedef algebra::mat<n, n, mln_sum_x(T, U)> ret;
+ };
+
+ // mat * vec
+
+ template < unsigned n, unsigned m, typename T,
+ typename U >
+ struct set_precise_binary_< op::times, algebra::mat<n,m,T>, algebra::vec<m,U> >
+ {
+ typedef algebra::vec<n, mln_sum_x(T, U)> ret;
+ };
+
+ // mat * s
+
+ template < template<class, class> class Name,
+ unsigned n, unsigned m, typename T,
+ typename S >
+ struct set_precise_binary_< Name, algebra::mat<n,m,T>, mln::value::scalar_<S> >
+ {
+ typedef algebra::mat<n, m, mln_trait_binary(Name, T, S)> ret;
+ };
+
+ template < template<class, class> class Name,
+ unsigned n, unsigned m, typename T,
+ typename S >
+ struct set_binary_< Name,
+ mln::Object, algebra::mat<n,m,T>,
+ mln::value::Scalar, S >
+ {
+ typedef algebra::mat<n, m, mln_trait_binary(Name, T, S)> ret;
+ };
+
+ } // end of namespace mln::trait
+
+
+
+ namespace algebra
+ {
+
+ // ==
+
+ template <unsigned n, unsigned m, typename T, typename U>
+ bool
+ operator==(mat<n,m,T>& lhs, const mat<n,m,U>& rhs);
+
+ // +
+
+ template <unsigned n, unsigned m, typename T, typename U>
+ inline
+ mat<n, m, mln_trait_op_plus(T,U)>
+ operator+(const mat<n,m,T>& lhs, const mat<n,m,U>& rhs);
+
+ // -
+
+ template <unsigned n, unsigned m, typename T, typename U>
+ mat<n, m, mln_trait_op_minus(T,U)>
+ operator-(const mat<n,m,T>& lhs, const mat<n,m,U>& rhs);
+
+ // - (unary)
+
+ template <unsigned n, unsigned m, typename T>
+ mat<n, m, mln_trait_op_uminus(T)>
+ operator-(const mat<n,m,T>& lhs);
+
+ // mat * mat
+
+ template <unsigned n, unsigned o, typename T,
+ unsigned m, typename U>
+ mat<n, m, mln_sum_x(T,U)>
+ operator*(const mat<n,o,T>& lhs, const mat<o,m,U>& rhs);
+
+ // mat * vec
+
+ template <unsigned n, unsigned m, typename T,
+ typename U>
+ vec<n, mln_sum_x(T,U)>
+ operator*(const mat<n,m,T>& lhs, const vec<m,U>& rhs);
+
+ // mat * s
+
+ template <unsigned n, unsigned m, typename T,
+ typename S>
+ mat<n, m, mln_trait_op_times(T,S)>
+ operator*(const mat<n,m,T>& lhs, const value::scalar_<S>& s);
+
+ // mat / s
+
+ template <unsigned n, unsigned m, typename T, typename S>
+ mat<n, m, mln_trait_op_div(T,S)>
+ operator/(const mat<n,m,T>& lhs, const value::scalar_<S>& s);
+
+ // <<
+
+ template <unsigned n, unsigned m, typename T>
+ std::ostream&
+ operator<<(std::ostream& ostr, const mat<n,m,T>& v);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <unsigned n, unsigned m, typename T>
+ const mat<n,m,T> mat<n,m,T>::Id = mat<n,m,T>::identity();
+
+ template <unsigned n, unsigned m, typename T>
+ inline
+ mat<n,m,T> mat<n,m,T>::identity()
+ {
+ static mat<n,m,T> id_;
+ static bool flower = true;
+ if (flower)
+ {
+ for (unsigned i = 0; i < n; ++i)
+ for (unsigned j = 0; j < m; ++j)
+ id_(i, j) = (i == j);
+ flower = false;
+ }
+ return id_;
+ }
+
+ template <unsigned n, unsigned m, typename T>
+ template <typename U>
+ inline
+ mat<n,m,T>::mat(const mat<n,m,U>& rhs)
+ {
+ for (unsigned i = 0; i < n; ++i)
+ for (unsigned j = 0; j < m; ++j)
+ data_[i][j] = rhs(i, j);
+ }
+
+ template <unsigned n, unsigned m, typename T>
+ template <typename F>
+ inline
+ mat<n,m,T>::mat(const Function_i2v<F>& f_)
+ {
+ mlc_converts_to(mln_result(F), T)::check();
+ const F& f = exact(f_);
+ for (unsigned i = 0; i < n; ++i)
+ for (unsigned j = 0; j < m; ++j)
+ data_[i][j] = f(i * n + j);
+ }
+
+ template <unsigned n, unsigned m, typename T>
+ template <typename U>
+ inline
+ mat<n,m,T>&
+ mat<n,m,T>::operator=(const mat<n,m,U>& rhs)
+ {
+ for (unsigned i = 0; i < n; ++i)
+ for (unsigned j = 0; j < m; ++j)
+ data_[i][j] = rhs(i, j);
+ return *this;
+ }
+
+ template <unsigned n, unsigned m, typename T>
+ inline
+ const T&
+ mat<n,m,T>::operator()(unsigned i, unsigned j) const
+ {
+ mln_precondition(i < n && j < m);
+ return data_[i][j];
+ }
+
+ template <unsigned n, unsigned m, typename T>
+ inline
+ T&
+ mat<n,m,T>::operator()(unsigned i, unsigned j)
+ {
+ mln_precondition(i < n && j < m);
+ return data_[i][j];
+ }
+
+ template <unsigned n, unsigned m, typename T>
+ inline
+ void mat<n,m,T>::set_all(const T& val)
+ {
+ for (unsigned i = 0; i < n; ++i)
+ for (unsigned j = 0; j < m; ++j)
+ data_[i][j] = val;
+ }
+
+ template <unsigned n, unsigned m, typename T>
+ inline
+ unsigned mat<n,m,T>::size() const
+ {
+ return n * m;
+ }
+
+
+ // Operators.
+
+
+ template <unsigned n, unsigned m, typename T, typename U>
+ inline
+ bool
+ operator==(const mat<n,m,T>& lhs, const mat<n,m,U>& rhs)
+ {
+ for (unsigned i = 0; i < n; ++i)
+ for (unsigned j = 0; j < m; ++j)
+ if (lhs(i, j) != rhs(i, j))
+ return false;
+ return true;
+ }
+
+ template <unsigned n, unsigned m, typename T, typename U>
+ inline
+ mat<n, m, mln_trait_op_plus(T,U)>
+ operator+(const mat<n,m,T>& lhs, const mat<n,m,U>& rhs)
+ {
+ mat<n, m, mln_trait_op_plus(T,U)> tmp;
+ for (unsigned i = 0; i < n; ++i)
+ for (unsigned j = 0; j < m; ++j)
+ tmp(i, j) = lhs(i, j) + rhs(i, j);
+ return tmp;
+ }
+
+ template <unsigned n, unsigned m, typename T, typename U>
+ inline
+ mat<n,m, mln_trait_op_minus(T,U)>
+ operator-(const mat<n,m,T>& lhs, const mat<n,m,U>& rhs)
+ {
+ mat<n,m, mln_trait_op_minus(T,U)> tmp;
+ for (unsigned i = 0; i < n; ++i)
+ for (unsigned j = 0; j < m; ++j)
+ tmp(i, j) = lhs(i, j) - rhs(i, j);
+ return tmp;
+ }
+
+ template <unsigned n, unsigned m, typename T>
+ inline
+ mat<n,m, mln_trait_op_uminus(T)>
+ operator-(const mat<n,m,T>& rhs)
+ {
+ mat<n,m, mln_trait_op_uminus(T)> tmp;
+ for (unsigned i = 0; i < n; ++i)
+ for (unsigned j = 0; i < m; ++i)
+ tmp(i, j) = - rhs(i, j);
+ return tmp;
+ }
+
+ template <unsigned n, unsigned o, typename T,
+ unsigned m, typename U>
+ inline
+ mat<n, m, mln_sum_x(T,U)>
+ operator*(const mat<n,o,T>& lhs, const mat<o,m,U>& rhs)
+ {
+ mat<n,m, mln_sum_x(T,U)> tmp;
+ for (unsigned i = 0; i < n; ++i)
+ for (unsigned j = 0; j < m; ++j)
+ {
+ tmp(i, j) = literal::zero;
+ for (unsigned k = 0; k < o; ++k)
+ tmp(i, j) += lhs(i, k) * rhs(k, j);
+ }
+ return tmp;
+ }
+
+ template <unsigned n, unsigned m, typename T,
+ typename U>
+ inline
+ vec<n, mln_sum_x(T,U)>
+ operator*(const mat<n,m,T>& lhs, const vec<m,U>& rhs)
+ {
+ vec<n, mln_sum_x(T,U)> tmp;
+ for (unsigned i = 0; i < n; ++i)
+ {
+ mln_sum_x(T,U) sum(literal::zero);
+ for (unsigned j = 0; j < m; ++j)
+ sum += lhs(i, j) * rhs[j];
+ tmp[i] = sum;
+ }
+ return tmp;
+ }
+
+ template <unsigned n, unsigned m, typename T, typename S>
+ inline
+ mat<n, m, mln_trait_op_times(T,S)>
+ operator*(const mat<n,m,T>& lhs, const value::scalar_<S>& s_)
+ {
+ S s = s_.to_equiv();
+ mat<n, m, mln_trait_op_times(T,S)> tmp;
+ for (unsigned i = 0; i < n; ++i)
+ for (unsigned j = 0; j < m; ++j)
+ tmp(i, j) = lhs(i, j) * s;
+ return tmp;
+ }
+
+ template <unsigned n, unsigned m, typename T, typename S>
+ inline
+ mat<n,m, mln_trait_op_div(T,S)>
+ operator/(const mat<n,m,T>& lhs, const value::scalar_<S>& s_)
+ {
+ S s = s_.to_equiv();
+ mat<n,m, mln_trait_op_times(T,S)> tmp;
+ for (unsigned i = 0; i < n; ++i)
+ for (unsigned j = 0; j < m; ++j)
+ tmp(i,j) = lhs(i, j) / s;
+ return tmp;
+ }
+
+ // <<
+
+ template <unsigned n, unsigned m, typename T>
+ inline
+ std::ostream&
+ operator<<(std::ostream& ostr, const mat<n,m,T>& v)
+ {
+ for (unsigned i = 0; i < n; ++i)
+ {
+ ostr << '[';
+ for (unsigned j = 0; j < m; ++j)
+ ostr << debug::format(v(i, j)) << (j == m - 1 ? "]" : ", ");
+ ostr << std::endl;
+ }
+ return ostr;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::algebra
+
+} // end of namespace mln
+
+# include <mln/make/mat.hh>
+
+#endif // ! MLN_ALGEBRA_MAT_HH
Index: mln/algebra/quat.hh
--- mln/algebra/quat.hh (revision 0)
+++ mln/algebra/quat.hh (revision 0)
@@ -0,0 +1,648 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_ALGEBRA_QUAT_HH
+# define MLN_ALGEBRA_QUAT_HH
+
+/*! \file mln/algebra/quat.hh
+ *
+ * \brief Define a class for quaternion values.
+ */
+
+# include <cmath>
+
+# include <mln/value/ops.hh>
+
+# include <mln/value/concept/vectorial.hh>
+# include <mln/value/internal/value_like.hh>
+# include <mln/trait/value_.hh>
+
+# include <mln/algebra/vec.hh>
+# include <mln/norm/l2.hh>
+
+
+namespace mln
+{
+
+ // Fwd decls.
+ namespace value { class quat; }
+ namespace literal { struct zero_t; struct one_t; }
+
+
+ namespace trait
+ {
+
+ // quat OP quat
+
+ template <>
+ struct set_precise_binary_< op::plus, mln::algebra::quat, mln::algebra::quat >
+ {
+ typedef mln::algebra::quat ret;
+ };
+
+ template <>
+ struct set_precise_binary_< op::minus, mln::algebra::quat, mln::algebra::quat >
+ {
+ typedef mln::algebra::quat ret;
+ };
+
+ template <>
+ struct set_precise_binary_< op::times, mln::algebra::quat, mln::algebra::quat >
+ {
+ typedef mln::algebra::quat ret;
+ };
+
+ // quat OP scalar
+
+ template < typename S >
+ struct set_precise_binary_< op::times, mln::algebra::quat, mln::value::scalar_<S> >
+ {
+ typedef mln::algebra::quat ret;
+ };
+
+ template < typename S >
+ struct set_precise_binary_< op::div, mln::algebra::quat, mln::value::scalar_<S> >
+ {
+ typedef mln::algebra::quat ret;
+ };
+
+
+ // 'quat' as a value.
+
+
+ template <>
+ struct value_< mln::algebra::quat >
+ {
+ typedef trait::value::nature::vectorial nature;
+ typedef trait::value::kind::data kind;
+ typedef trait::value::quant::high quant;
+
+ enum {
+ nbits = 4 * sizeof(float),
+ card = 0
+ };
+
+ typedef mln::algebra::quat sum;
+ };
+
+
+ } // end of namespace mln::trait
+
+
+
+ namespace value
+ {
+
+ // FIXME doesn't compile
+
+ class quat
+ :
+ public Vectorial< quat >
+ ,
+ public internal::value_like_< algebra::vec<4, float>, // Equivalent.
+ algebra::vec<4, float>, // Encoding.
+ algebra::vec<4, float>, // Interoperation.
+ quat > // Exact.
+ {
+ public:
+
+ /// Constructor without argument.
+ quat();
+
+ /// Constructor with components.
+ quat(float s, float x, float y, float z);
+
+ /// Constructor from a scalar and a 3D vector.
+ quat(float s, const algebra::vec<3,float>& v);
+
+
+ /// Constructor from a 4D vector.
+ quat(const algebra::vec<4,float>& v);
+
+ /// Assignment from a 4D vector.
+ quat& operator=(const algebra::vec<4,float>& v);
+
+
+ /// \{ Constructors/assignments with literals zero and one.
+ quat(const literal::zero_t&);
+ quat& operator=(const literal::zero_t&);
+ quat(const literal::one_t&);
+ quat& operator=(const literal::one_t&);
+ /// \}
+
+
+ /// Explicit conversion to a 4D algebra::vec.
+ const algebra::vec<4,float>& to_vec() const;
+
+
+ /// Give the scalar part.
+ float s() const;
+
+ /// Access to the scalar part.
+ float& s();
+
+ const algebra::vec<3,float>& v() const;
+ algebra::vec<3,float>& v();
+
+ void set_v(float x, float y, float z);
+
+ /// Scalar product.
+ float sprod(const quat& rhs) const;
+
+ /// Test if it is a unit quaternion.
+ bool is_unit() const;
+
+ /// Test if the quaternion is null.
+ bool is_null() const;
+
+ /// Test if it is a pure quaternion.
+ bool is_pure() const;
+
+ /// Give the conjugate.
+ quat conj() const;
+
+ /// Give the invert.
+ quat inv() const; // FIXME: Rename inv as invert.
+
+ /// Transform into unit quaternion.
+ quat& set_unit();
+
+ /// Transform into unit quaternion.
+ template <typename T>
+ void set_unit(float theta, const algebra::vec<3,T>& uv);
+
+ // only for unit quaternions described by theta and uv such as:
+ // q = ( cos(theta), sin(theta) * uv )
+
+ quat(unsigned one, float theta, const algebra::vec<3,float>& uv);
+
+ float theta() const;
+ void set_theta(float theta);
+
+ algebra::vec<3,float> uv() const;
+ void set_uv(const algebra::vec<3,float>& uv);
+ };
+
+
+ // Operators.
+
+ std::ostream& operator<<(std::ostream& ostr, const quat& q);
+
+ quat operator+(const quat& lhs, const quat& rhs);
+ quat operator-(const quat& lhs, const quat& rhs);
+ quat operator*(const quat& lhs, const quat& rhs);
+ template <typename S> quat operator*(const quat& lhs, const value::scalar_<S>& rhs);
+ template <typename S> quat operator/(const quat& lhs, const value::scalar_<S>& rhs);
+
+ // overloaded math procs
+
+ quat log(const quat& q);
+ quat exp(const quat& q);
+ quat pow(const quat& q, double t);
+ template <typename T>
+ bool about_equal(const T& f, const T& q);
+ bool about_equal(const quat& p, const quat& q);
+
+
+ // Misc.
+
+ bool interpol_ok(const quat& p, const quat& q, float h);
+
+
+ // Linear Quaternion Interpolation.
+
+ quat lerp(const quat& p, const quat& q, float h);
+
+
+ // Spherical Linear Quaternion Interpolation.
+
+ quat slerp(const quat& p, const quat& q, float h);
+
+ quat slerp_2(const quat& p, const quat& q, float h);
+
+ quat slerp_3(const quat& p, const quat& q, float h);
+
+ quat slerp_4(const quat& p, const quat& q, float h);
+
+ quat slerp_5(const quat& p, const quat& q, float h);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ // Constructors.
+
+ inline
+ quat::quat()
+ {
+ }
+
+ inline
+ quat::quat(float s, float x, float y, float z)
+ {
+ v_[0] = s;
+ set_v(x, y, z);
+ }
+
+ inline
+ quat::quat(float s, const algebra::vec<3,float>& v)
+ {
+ v_[0] = s;
+ this->v() = v;
+ }
+
+ inline
+ quat::quat(const algebra::vec<4,float>& v)
+ {
+ this->v_ = v;
+ }
+
+ inline
+ quat&
+ quat::operator=(const algebra::vec<4,float>& v)
+ {
+ this->v_ = v;
+ return *this;
+ }
+
+
+ // With literals.
+
+ inline
+ quat::quat(const literal::zero_t&)
+ {
+ v_.set_all(0);
+ }
+
+ inline
+ quat&
+ quat::operator=(const literal::zero_t&)
+ {
+ v_.set_all(0);
+ return *this;
+ }
+
+ inline
+ quat::quat(const literal::one_t&)
+ {
+ s() = 1;
+ v().set_all(0);
+ }
+
+ inline
+ quat&
+ quat::operator=(const literal::one_t&)
+ {
+ s() = 1;
+ v().set_all(0);
+ return *this;
+ }
+
+
+ inline
+ const algebra::vec<4,float>&
+ quat::to_vec() const
+ {
+ return this->v_;
+ }
+
+ inline
+ float
+ quat::s() const
+ {
+ return this->v_[0];
+ }
+
+ inline
+ float&
+ quat::s()
+ {
+ return this->v_[0];
+ }
+
+ inline
+ const algebra::vec<3, float>&
+ quat::v() const
+ {
+ return *(const algebra::vec<3, float>*)(const void*)(& this->v_[1]);
+ // return make::vec(this->v_[1], this->v_[2], this->v_[3]);
+ }
+
+ inline
+ algebra::vec<3, float>&
+ quat::v()
+ {
+ return *(algebra::vec<3, float>*)(void*)(& this->v_[1]);
+ }
+
+ inline
+ void quat::set_v(float x, float y, float z)
+ {
+ this->v_[1] = x;
+ this->v_[2] = y;
+ this->v_[3] = z;
+ }
+
+ inline
+ float
+ quat::sprod(const quat& rhs) const
+ {
+ return v_ * rhs.to_vec();
+ }
+
+ inline
+ bool quat::is_unit() const
+ {
+ return about_equal(norm::l2(v_), 1.f);
+ }
+
+ inline
+ bool quat::is_null() const
+ {
+ return about_equal(norm::l2(v_), 0.f);
+ }
+
+ inline
+ bool quat::is_pure() const
+ {
+ return about_equal(v_[0], 0.f);
+ }
+
+ inline
+ quat quat::conj() const
+ {
+ return quat(s(), - v());
+ }
+
+ inline
+ quat quat::inv() const
+ {
+ assert(! is_null());
+ float f = norm::l2(v_);
+ return conj().to_vec() / (f * f);
+ }
+
+ inline
+ quat& quat::set_unit()
+ {
+ v_.normalize();
+ return *this;
+ }
+
+ template <typename T>
+ inline
+ void quat::set_unit(float theta, const algebra::vec<3,T>& uv)
+ {
+ static const float pi = 3.14159265358979323846;
+
+ mln_precondition(theta > - pi - mln_epsilon(float)
+ && theta < pi + mln_epsilon(float));
+ mln_precondition(about_equal(norm::l2(uv), 1.f));
+
+ this->v_[0] = cos(theta);
+ float sint = sin(theta);
+ this->v_[1] = uv[0] * sint;
+ this->v_[2] = uv[1] * sint;
+ this->v_[3] = uv[2] * sint;
+ }
+
+ // only for unit quaternions described by theta and uv such as:
+ // q = ( cos(theta), sin(theta) * uv )
+
+ inline
+ quat::quat(unsigned one, float theta, const algebra::vec<3,float>& uv)
+ {
+ mln_precondition(one == 1);
+ set_unit(theta, uv);
+ }
+
+ inline
+ float quat::theta() const
+ {
+ mln_precondition(is_unit());
+ return acos(s());
+ }
+
+ inline
+ void quat::set_theta(float theta)
+ {
+ mln_precondition(is_unit());
+ set_unit(theta, uv());
+ }
+
+ inline
+ algebra::vec<3, float> quat::uv() const
+ {
+ mln_precondition(is_unit());
+ algebra::vec<3, float> w = v();
+ return w.normalize();
+ }
+
+ inline
+ void quat::set_uv(const algebra::vec<3,float>& uv)
+ {
+ mln_precondition(is_unit());
+ set_unit(theta(), uv);
+ }
+
+
+ // Operators.
+
+ inline
+ std::ostream& operator<<(std::ostream& ostr, const quat& q)
+ {
+ return ostr << q.to_vec();
+ }
+
+ inline
+ quat operator+(const quat& lhs, const quat& rhs)
+ {
+ quat tmp(lhs.to_vec() + rhs.to_vec());
+ return tmp;
+ }
+
+ inline
+ quat operator-(const quat& lhs, const quat& rhs)
+ {
+ quat tmp(lhs.to_vec() - rhs.to_vec());
+ return tmp;
+ }
+
+ inline
+ quat operator*(const quat& lhs, const quat& rhs)
+ {
+ quat tmp(lhs.s() * rhs.s() - lhs.v() * rhs.v(),
+ algebra::vprod(lhs.v(), rhs.v()) + lhs.s() * rhs.v() + rhs.s() * lhs.v());
+ return tmp;
+ }
+
+ template <typename S>
+ inline
+ quat operator*(const quat& lhs, const value::scalar_<S>& rhs)
+ {
+ mlc_converts_to(S, float)::check();
+ quat tmp(lhs.to_vec() * rhs.to_equiv());
+ return tmp;
+ }
+
+ template <typename S>
+ inline
+ quat operator/(const quat& lhs, const value::scalar_<S>& rhs_)
+ {
+ mlc_converts_to(S, float)::check();
+ float rhs = rhs_.to_equiv();
+ mln_precondition(rhs != 0.f);
+ quat tmp(lhs.to_vec() / rhs);
+ return tmp;
+ }
+
+
+ // overloaded math procs
+
+ inline
+ quat log(const quat& q)
+ {
+ mln_precondition(q.is_unit());
+ return quat(0.f, q.theta() * q.uv());
+ }
+
+
+ inline
+ quat exp(const quat& q)
+ {
+ mln_precondition(about_equal(q.s(), 0.f));
+ algebra::vec<3, float> v = q.v();
+ float theta = norm::l2(v);
+ mln_precondition(!about_equal(theta, 0.f));
+ algebra::vec<3, float> uv = v / theta;
+ return quat(cos(theta), sin(theta) * uv);
+ }
+
+
+ inline
+ quat pow(const quat& q, double t)
+ {
+ mln_precondition(q.is_unit());
+ return exp(t * log(q));
+ }
+
+ template <typename T>
+ inline
+ bool about_equal(const T& f, const T& q)
+ {
+ // FIXME: Use abs!
+ if (f > q)
+ return (f - q ) < mln_epsilon(T);
+ return (q - f) < mln_epsilon(T);
+ }
+
+ inline
+ bool about_equal(const quat& p, const quat& q)
+ {
+ return about_equal<float>(norm::l2(p.to_vec() - q.to_vec()), 0);
+ }
+
+ // Misc.
+
+ inline
+ bool interpol_ok(const quat& p, const quat& q, float h)
+ {
+ return
+ p.is_unit() &&
+ q.is_unit() &&
+ h >= 0 &&
+ h <= 1;
+ }
+
+
+ // Linear Quaternion Interpolation.
+
+ inline
+ quat lerp(const quat& p, const quat& q, float h)
+ {
+ assert(interpol_ok(p, q, h));
+ return (1 - h) * p + h * q;
+ }
+
+
+ // Spherical Linear Quaternion Interpolation.
+
+ inline
+ quat slerp(const quat& p, const quat& q, float h)
+ {
+ assert(interpol_ok(p, q, h));
+ float omega = acos(p.sprod(q));
+ return
+ about_equal(omega, 0.f) ?
+ lerp(p, q, h) :
+ quat((sin((1-h)*omega) * p + sin(h*omega) * q) / sin(omega));
+ }
+
+ inline
+ quat slerp_2(const quat& p, const quat& q, float h)
+ {
+ assert(interpol_ok(p, q, h));
+ quat tmp = p * value::pow(p.conj() * q, h);
+ assert(about_equal(tmp, slerp(p, q, h)));
+ return tmp;
+ }
+
+ inline
+ quat slerp_3(const quat& p, const quat& q, float h)
+ {
+ assert(interpol_ok(p, q, h));
+ quat tmp = value::pow(p * q.conj(), 1 - h) * q;
+ assert(about_equal(tmp, slerp(p, q, h)));
+ return tmp;
+ }
+
+ inline
+ quat slerp_4(const quat& p, const quat& q, float h)
+ {
+ assert(interpol_ok(p, q, h));
+ quat tmp = value::pow(q * p.conj(), h) * p;
+ assert(about_equal(tmp, slerp(p, q, h)));
+ return tmp;
+ }
+
+ inline
+ quat slerp_5(const quat& p, const quat& q, float h)
+ {
+ assert(interpol_ok(p, q, h));
+ quat tmp = q * value::pow(q.conj() * p, 1 - h);
+ assert(about_equal(tmp, slerp(p, q, h)));
+ return tmp;
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::value
+
+} // end of namespace mln
+
+#endif // ! MLN_ALGEBRA_QUAT_HH
Index: mln/norm/linfty.hh
--- mln/norm/linfty.hh (revision 1783)
+++ mln/norm/linfty.hh (working copy)
@@ -36,7 +36,7 @@
*/
# include <mln/math/abs.hh>
-# include <mln/metal/vec.hh>
+# include <mln/algebra/vec.hh>
namespace mln
@@ -51,7 +51,7 @@
C linfty(const C (&vec)[n]);
template <unsigned n, typename C>
- C linfty(const metal::vec<n,C>& vec);
+ C linfty(const algebra::vec<n,C>& vec);
/// \}
@@ -61,8 +61,8 @@
C linfty_distance(const C (&vec1)[n], const C (&vec2)[n]);
template <unsigned n, typename C>
- C linfty_distance(const metal::vec<n,C>& vec1,
- const metal::vec<n,C>& vec2);
+ C linfty_distance(const algebra::vec<n,C>& vec1,
+ const algebra::vec<n,C>& vec2);
/// \}
@@ -119,7 +119,7 @@
template <unsigned n, typename C>
inline
- C linfty(const metal::vec<n,C>& vec)
+ C linfty(const algebra::vec<n,C>& vec)
{
return impl::linfty_<n, C>(vec);
}
@@ -133,8 +133,8 @@
template <unsigned n, typename C>
inline
- C linfty_distance(const metal::vec<n,C>& vec1,
- const metal::vec<n,C>& vec2)
+ C linfty_distance(const algebra::vec<n,C>& vec1,
+ const algebra::vec<n,C>& vec2)
{
return impl::linfty_distance_<n, C>(vec1, vec2);
}
Index: mln/norm/l1.hh
--- mln/norm/l1.hh (revision 1783)
+++ mln/norm/l1.hh (working copy)
@@ -35,7 +35,7 @@
*/
# include <mln/math/abs.hh>
-# include <mln/metal/vec.hh>
+# include <mln/algebra/vec.hh>
// FIXME: Use mln_sum_x (to be renamed as mln_sum_product) instead of
// mln_sum.
@@ -52,7 +52,7 @@
mln_sum(C) l1(const C (&vec)[n]);
template <unsigned n, typename C>
- mln_sum(C) l1(const metal::vec<n,C>& vec);
+ mln_sum(C) l1(const algebra::vec<n,C>& vec);
/// \}
/// L1-norm distance between vectors \a vec1 and \a vec2.
@@ -61,8 +61,8 @@
mln_sum(C) l1_distance(const C (&vec1)[n], const C (&vec2)[n]);
template <unsigned n, typename C>
- mln_sum(C) l1_distance(const metal::vec<n,C>& vec1,
- const metal::vec<n,C>& vec2);
+ mln_sum(C) l1_distance(const algebra::vec<n,C>& vec1,
+ const algebra::vec<n,C>& vec2);
/// \}
@@ -110,7 +110,7 @@
template <unsigned n, typename C>
inline
mln_sum(C)
- l1(const metal::vec<n,C>& vec)
+ l1(const algebra::vec<n,C>& vec)
{
return impl::l1_<n, C>(vec);
}
@@ -126,7 +126,7 @@
template <unsigned n, typename C>
inline
mln_sum(C)
- l1_distance(const metal::vec<n,C>& vec1, const metal::vec<n,C>& vec2)
+ l1_distance(const algebra::vec<n,C>& vec1, const algebra::vec<n,C>& vec2)
{
return impl::l1_distance_<n, C>(vec1, vec2);
}
Index: mln/norm/l2.hh
--- mln/norm/l2.hh (revision 1783)
+++ mln/norm/l2.hh (working copy)
@@ -36,7 +36,7 @@
# include <mln/math/sqr.hh>
# include <mln/math/sqrt.hh>
-# include <mln/metal/vec.hh>
+# include <mln/algebra/vec.hh>
// FIXME: Use mln_sum_x (to be renamed as mln_sum_product) instead of
@@ -54,7 +54,7 @@
mln_sum(C) l2(const C (&vec)[n]);
template <unsigned n, typename C>
- mln_sum(C) l2(const metal::vec<n,C>& vec);
+ mln_sum(C) l2(const algebra::vec<n,C>& vec);
/// \}
/// L2-norm distance between vectors \a vec1 and \p vec2.
@@ -63,8 +63,8 @@
mln_sum(C) l2_distance(const C (&vec1)[n], const C (&vec2)[n]);
template <unsigned n, typename C>
- mln_sum(C) l2_distance(const metal::vec<n,C>& vec1,
- const metal::vec<n,C>& vec2);
+ mln_sum(C) l2_distance(const algebra::vec<n,C>& vec1,
+ const algebra::vec<n,C>& vec2);
/// \}
@@ -113,7 +113,7 @@
template <unsigned n, typename C>
inline
mln_sum(C)
- l2(const metal::vec<n,C>& vec)
+ l2(const algebra::vec<n,C>& vec)
{
return impl::l2_<n, C>(vec);
}
@@ -129,7 +129,7 @@
template <unsigned n, typename C>
inline
mln_sum(C)
- l2_distance(const metal::vec<n,C>& vec1, const metal::vec<n,C>& vec2)
+ l2_distance(const algebra::vec<n,C>& vec1, const algebra::vec<n,C>& vec2)
{
return impl::l2_distance_<n, C>(vec1, vec2);
}
Index: sandbox/duhamel/slow_seed2tiling.cc
--- sandbox/duhamel/slow_seed2tiling.cc (revision 1783)
+++ sandbox/duhamel/slow_seed2tiling.cc (working copy)
@@ -60,7 +60,7 @@
# include <mln/core/clone.hh>
# include <mln/accu/mean.hh>
# include <mln/estim/min_max.hh>
-# include <mln/metal/vec.hh>
+# include <mln/algebra/vec.hh>
# include <mln/norm/l2.hh>
# include <mln/norm/l1.hh>
Index: sandbox/duhamel/labeling_algo.hh
--- sandbox/duhamel/labeling_algo.hh (revision 1783)
+++ sandbox/duhamel/labeling_algo.hh (working copy)
@@ -17,7 +17,7 @@
#include <algorithm>
#include <utility>
#include <map>
-#include <mln/metal/vec.hh>
+#include <mln/algebra/vec.hh>
namespace mln
{
@@ -64,7 +64,7 @@
graph_with_no_border (Image<I>& ima_,
const Neighborhood<N>& nbh)
{
- typedef metal::vec<2,float> X;
+ typedef algebra::vec<2,float> X;
typedef mln_value(I) V;
typedef mln_psite(I) P;
@@ -111,7 +111,7 @@
Image<I>& orig_,
const Neighborhood<N>& nbh)
{
- typedef metal::vec<2,float> X;
+ typedef algebra::vec<2,float> X;
typedef mln_value(I) V;
typedef mln_psite(I) P;
Index: sandbox/duhamel/mesh_image.hh
--- sandbox/duhamel/mesh_image.hh (revision 1783)
+++ sandbox/duhamel/mesh_image.hh (working copy)
@@ -36,7 +36,7 @@
# include <cmath>
# include <mln/core/internal/image_identity.hh>
-# include <mln/metal/vec.hh>
+# include <mln/algebra/vec.hh>
# include "mesh_p.hh"
# include "mesh_psite.hh"
# include <vector>
Index: sandbox/jardonnet/test/icp.cc
--- sandbox/jardonnet/test/icp.cc (revision 0)
+++ sandbox/jardonnet/test/icp.cc (revision 0)
@@ -0,0 +1,16 @@
+#include <mln/core/image2d.hh>
+
+#include <mln/io/ppm/load.hh>
+#include <mln/io/ppm/save.hh>
+
+#include <sandbox/jardonnet/registration/icp.hh>
+
+int main(int, char*)
+{
+ using namespace mln;
+
+ image2d< value::rgb8 > img;
+
+ registration::icp(img,img);
+}
+
Index: sandbox/jardonnet/test/gaussian_subsampling.cc
--- sandbox/jardonnet/test/gaussian_subsampling.cc (revision 1783)
+++ sandbox/jardonnet/test/gaussian_subsampling.cc (working copy)
@@ -15,7 +15,7 @@
io::pgm::load(img, "../../../img/lena.pgm");
- image2d<int_u8> output = subsampling::gaussian_subsampling(img, make::dpoint2d(1,1), argc);
+ image2d<int_u8> output = subsampling::gaussian_subsampling(img, 0.1, make::dpoint2d(1,1), argc);
io::pgm::save(output, "gsub.pgm");
}
Index: sandbox/jardonnet/test/Makefile
--- sandbox/jardonnet/test/Makefile (revision 1783)
+++ sandbox/jardonnet/test/Makefile (working copy)
@@ -1,7 +1,7 @@
SOURCE=test.cc subsampling.cc
-FLAG=-Wall -W -I../../.. -g
+FLAG=-Wall -W -pedantic -I../../.. -g
-all: sub gsub
+all: sub gsub gau icp
sub:
@@ -13,5 +13,9 @@
gau:
g++ gaussian.cc $(FLAG) -o '+gau.exe'
+icp:
+ g++ icp.cc $(FLAG) -o '+icp.exe'
+
run:
time ./+sub.exe . . ; time ./+gsub.exe . .
\ No newline at end of file
+
Index: sandbox/jardonnet/subsampling/gaussian_subsampling.hh
--- sandbox/jardonnet/subsampling/gaussian_subsampling.hh (revision 1783)
+++ sandbox/jardonnet/subsampling/gaussian_subsampling.hh (working copy)
@@ -55,7 +55,7 @@
template <typename I>
inline
mln_concrete(I)
- gaussian_subsampling(const Image<I>& input, float sigma
+ gaussian_subsampling(const Image<I>& input, float sigma,
const mln_dpoint(I)& first_p,
const mln_coord(I)& gap);
@@ -76,7 +76,7 @@
mln_concrete(I) output(geom::nrows(input) / gap,
geom::ncols(input) / gap); //FIXME : only for image2d.
- linear::gaussian(input, 0.1, temp);
+ linear::gaussian(input, sigma, temp);
output = impl::subsampling_(exact(temp), first_p, gap);
trace::exiting("subsampling::gaussian_subsampling");
Index: sandbox/jardonnet/subsampling/sub_sampled_image.hh
--- sandbox/jardonnet/subsampling/sub_sampled_image.hh (revision 1783)
+++ sandbox/jardonnet/subsampling/sub_sampled_image.hh (working copy)
@@ -34,7 +34,7 @@
# include <mln/core/internal/image_morpher.hh>
# include <mln/convert/to_dpoint.hh>
-# include <mln/metal/vec.hh>
+# include <mln/algebra/vec.hh>
# include <mln/value/set.hh>
@@ -214,7 +214,7 @@
sub_sampled_image<I>::translate_coords_(const mln_point(I)& p) const
{
- return mln_point(I)(metal::vec<2, int>(p) * gap + metal::vec<2, int>(first_p));
+ return mln_point(I)(algebra::vec<2, int>(p) * gap + algebra::vec<2, int>(first_p));
}
Index: sandbox/jardonnet/TODO
--- sandbox/jardonnet/TODO (revision 1783)
+++ sandbox/jardonnet/TODO (working copy)
@@ -1,10 +1,8 @@
image2d< value::rgb8 >
img == out
-
-- - - - - - - - - -
+-
gaussian.cc: In function 'int main(int, char*)':
gaussian.cc:22: error: no match for 'operator==' in 'img == out'
+- -
-
-*/*/*/*/*/*/*/*
\ No newline at end of file
Index: sandbox/jardonnet/registration/quat7.hh
--- sandbox/jardonnet/registration/quat7.hh (revision 0)
+++ sandbox/jardonnet/registration/quat7.hh (revision 0)
@@ -0,0 +1,148 @@
+
+#ifndef QUAT7_HH
+# define QUAT7_HH
+
+# include <assert.h>
+# include <algorithm>
+
+# include <mln/algebra/mat.hh>
+
+# include "quat/all.hh"
+# include "jacobi.hh"
+
+# include <mln/norm/l2.hh>
+
+# include <mln/trait/all.hh>
+
+
+// FIXME : move elsewhere
+namespace mln
+{
+ namespace algebra
+ {
+
+ template<unsigned n, unsigned m, typename T>
+ mat<m,n,T>
+ trans(const mat<n,m,T>& matrice)
+ {
+ mat<m,n,T> tmp;
+ for (unsigned i = 0; i < n; ++i)
+ for (unsigned j = 0; j < m; ++j)
+ tmp(j,i) = matrice(i,j);
+ return tmp;
+ }
+
+ // trace
+
+ template<unsigned n, typename T> inline
+ float tr(const mat<n,n,T>& m)
+ {
+ float f = 0.f;
+ for (unsigned i = 0; i < n; ++i)
+ f += m(i,i);
+ return f;
+ }
+
+ }
+}
+
+namespace mln
+{
+
+ struct quat7
+ {
+ value::quat _qR;
+ vec3f _qT;
+
+ quat7()
+ {
+ }
+
+ quat7(const value::quat& qR, const vec3f& qT) :
+ _qR(qR),
+ _qT(qT)
+ {
+ }
+
+ float sqr_norm() const
+ {
+ return norm::l2(_qR.to_vec()) + norm::l2(_qT);
+ }
+
+ quat7 operator-(const quat7& rhs) const
+ {
+ return quat7(_qR - rhs._qR, _qT - rhs._qT);
+ }
+
+ // quat7 is an object-function
+
+ vec3f operator()(const vec3f& v) const
+ {
+ return rotate(_qR, v) + _qT;
+ }
+
+ void apply_on(const std::vector< vec3f >& input, std::vector< vec3f >& output) const
+ {
+ assert(input.size() == output.size());
+ assert(_qR.is_unit());
+
+ std::transform(input.begin(), input.end(),
+ output.begin(),
+ *this);
+ }
+ };
+
+
+ // very usefull routine
+
+ template <unsigned p, unsigned q, unsigned n, unsigned m>
+ void put(const algebra::mat<p,q,float>& in, // a matrix to put into...
+ unsigned row, unsigned col, // top-left location
+ algebra::mat<n,m,float>& inout) // ...a matrix to modify
+ {
+ assert(row + p <= n && col + q <= m);
+ for (unsigned i = 0; i < p; ++i)
+ for (unsigned j = 0; j < q; ++j)
+ inout(row + i, col + j) = in(i,j);
+ }
+
+
+ quat7 match(const vecs_t& P,
+ const vec3f& mu_P,
+ const vecs_t& Xk,
+ const vec3f& mu_Xk)
+ {
+ assert(P.size() == Xk.size());
+
+ // qR
+
+ algebra::mat<3,3,float> Ck;
+ for (unsigned i = 0; i < P.size(); ++i)
+ Ck += make::mat(P[i] - mu_P) * trans(make::mat(Xk[i] - mu_Xk));
+ Ck /= P.size();
+
+ const algebra::mat<3,3,float> Ak = Ck - trans(Ck);
+
+ const float v[3] = {Ak(1,2), Ak(2,0), Ak(0,1)};
+ const algebra::mat<3,1,float> D = make::mat<3,1,3,float>(v); // FIXME why <...>
+
+ algebra::mat<4,4,float> Qk;
+ Qk(0,0) = tr(Ck);
+ put(trans(D), 0,1, Qk);
+ put(D, 1,0, Qk);
+
+ put(Ck + trans(Ck) - algebra::mat<3,3,float>::identity() * tr(Ck), 1,1, Qk);
+
+ value::quat qR;
+ jacobi(Qk, qR);
+
+ // qT
+
+ const vec3f qT = mu_Xk - rotate(qR, mu_P);
+
+ return quat7(qR, qT);
+ }
+
+}
+
+#endif // ndef QUAT7_HH
Index: sandbox/jardonnet/registration/cloud.hh
--- sandbox/jardonnet/registration/cloud.hh (revision 0)
+++ sandbox/jardonnet/registration/cloud.hh (revision 0)
@@ -0,0 +1,49 @@
+#ifndef CLOUD_HH
+# define CLOUD_HH
+
+# include <assert.h>
+# include <string>
+# include <vector>
+# include <fstream>
+# include <sstream>
+
+# include <mln/algebra/vec.hh>
+
+namespace mln
+{
+
+ namespace registration
+ {
+
+ typedef algebra::vec<3, float> vec3f;
+
+
+ vec3f center(const std::vector< vec3f >& vecs)
+ {
+ vec3f c;
+ for (size_t i = 0; i < vecs.size(); ++i)
+ c += vecs[i];
+ return c / vecs.size();
+ }
+
+
+ // FIXME : move
+ float sqr_norm(const vec3f& v)
+ {
+ return v[1] * v[1] + v[2] * v[2] + v[3] * v[3];
+ }
+
+ float rms(const std::vector< vec3f >& vecs1,
+ const std::vector< vec3f >& vecs2)
+ {
+ assert(vecs1.size() == vecs2.size());
+ float f = 0.f;
+ for (size_t i = 0; i < vecs1.size(); ++i)
+ f += sqr_norm(vecs1[i] - vecs2[i]);
+ return f / vecs1.size();
+ }
+
+ }
+}
+
+#endif // ndef CLOUD_HH
Index: sandbox/jardonnet/registration/jacobi.hh
--- sandbox/jardonnet/registration/jacobi.hh (revision 0)
+++ sandbox/jardonnet/registration/jacobi.hh (revision 0)
@@ -0,0 +1,108 @@
+
+#ifndef JACOBI_HH
+# define JACOBI_HH
+
+
+#include <mln/algebra/mat.hh>
+
+// from num. rec. in C
+
+
+#define rotateJacobi(a,i,j,k,l) g=a(i,j);h=a(k,l);a(i,j)=g-s*(h+g*tau); \
+ a(k,l)=h+s*(g-h*tau);
+
+void jacobi(mln::algebra::mat<4,4,float> a, mln::value::quat& q)
+{
+ float dd, d[4];
+ mln::algebra::mat<4,4,float> v;
+ int j,iq,ip,i = 0;
+ float tresh,theta,tau,t,sm,s,h,g,c,b[4],z[4];
+ for (ip=0;ip<4;ip++) {
+ for (iq=0;iq<4;iq++) v(ip,iq)=0.0;
+ v(ip,ip)=1.0;
+ }
+ for (ip=0;ip<4;ip++) {
+ b[ip]=d[ip]=a(ip,ip);
+ z[ip]=0.0;
+ }
+ while (1) {
+ sm=0.0;
+ for (ip=0;ip<3;ip++) {
+ for (iq=ip+1;iq<4;iq++)
+ sm += fabs(a(ip,iq));
+ }
+ if (sm < 1e-12) {
+ dd = d[0];
+ iq = 0;
+ for (ip=1;ip<4;ip++)
+ if (d[ip]>dd) {
+ iq = ip;
+ dd = d[ip];
+ }
+ q = mln::value::quat(v(0,iq),
+ v(1,iq),
+ v(2,iq),
+ v(3,iq));
+ q.set_unit();
+ return;
+ }
+ if (i < 4) {
+ i++;
+ tresh=0.0125*sm;
+ }
+ else
+ tresh=0.0;
+ for (ip=0;ip<3;ip++) {
+ for (iq=ip+1;iq<4;iq++) {
+
+ /* unusefull */
+ g=100.0*fabs(a(ip,iq));
+ if (i > 4 && (float)(fabs(d[ip])+g) == (float)fabs(d[ip])
+ && (float)(fabs(d[iq])+g) == (float)fabs(d[iq]))
+ a(ip,iq)=0.0;
+ /* unusefull */
+
+ else if (fabs(a(ip,iq)) > tresh) {
+ h=d[iq]-d[ip];
+ if ((float)(fabs(h)+g) == (float)fabs(h))
+ t=(a(ip,iq))/h;
+ else {
+ theta=0.5*h/(a(ip,iq));
+ t=1.0/(fabs(theta)+sqrt(1.0+theta*theta));
+ if (theta < 0.0) t = -t;
+ }
+ c=1.0/sqrt(1+t*t);
+ s=t*c;
+ tau=s/(1.0+c);
+ h=t*a(ip,iq);
+ z[ip] -= h;
+ z[iq] += h;
+ d[ip] -= h;
+ d[iq] += h;
+ a(ip,iq)=0.0;
+ for (j=0;j<=ip-1;j++) {
+ rotateJacobi(a,j,ip,j,iq)
+ }
+ for (j=ip+1;j<=iq-1;j++) {
+ rotateJacobi(a,ip,j,j,iq)
+ }
+ for (j=iq+1;j<4;j++) {
+ rotateJacobi(a,ip,j,iq,j)
+ }
+ for (j=0;j<4;j++) {
+ rotateJacobi(v,j,ip,j,iq)
+ }
+ }
+ }
+ }
+ for (ip=0;ip<4;ip++) {
+ b[ip] += z[ip];
+ d[ip]=b[ip];
+ z[ip]=0.0;
+ }
+ }
+}
+
+
+
+#endif // ndef JACOBI_HH
Index: sandbox/jardonnet/registration/icp.hh
--- sandbox/jardonnet/registration/icp.hh (revision 1783)
+++ sandbox/jardonnet/registration/icp.hh (working copy)
@@ -25,17 +25,25 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_REGISTRATION_REGISTRATION_HH
-# define MLN_REGISTRATION_REGISTRATION_HH
+#ifndef MLN_REGISTRATION_ICP_HH
+# define MLN_REGISTRATION_ICP_HH
-/*! \file mln/binarization/threshold.hh
+/*! \file mln/registration/icp.hh
*
- * \brief Produce a subsampled image
+ * \brief image registration
*/
# include <mln/value/quat.hh>
# include <mln/algebra/vec.hh>
+
+typedef mln::algebra::vec<3, float> vec3f;
+typedef std::vector< vec3f > vecs_t;
+
+#include "cloud.hh"
+#include "quat7.hh"
+#include "projection.hh"
+
namespace mln
{
@@ -46,7 +54,7 @@
*
*
*/
- template <typename I, template J>
+ template <typename I, typename J>
inline
void
icp(const Image<I>& cloud,
@@ -57,34 +65,43 @@
namespace impl
{
- template <typename I, typename J>
inline
void
- icp_(const I& P,
- const J& X)
+ icp_(const vecs_t& P,
+ const vecs_t& X)
{
trace::entering("registration::impl::icp_");
- mln_concrete(I) Pk(cloud.domain());
+ unsigned int k;
+ quat7 old_qk, qk;
+ float err, err_bis;
+
+ vecs_t Pk(P.size()), Xk(Pk.size());
+ vec3f mu_P = center(P), mu_Xk;
const float epsilon = 1e-3;
- float err, err_bis;
- quat old_qk, qk;
- unsigned int k;
+ //step 1
k = 0;
Pk = P;
+
do {
- //projection
+ //step 2 FIXME : etienne
+ projection::de_base(Pk, X, Xk, mu_Xk, err_bis);
+ // step 3
old_qk = qk;
- //qk = match(P, mu_P, Xk, mu_Xk);
+ qk = match(P, mu_P, Xk, mu_Xk);
+
+ // step 4
+ qk.apply_on(P, Pk); // Pk+1 = qk(P)
+
+ // err = d(Pk+1,Xk)
+ err = rms(Pk, Xk);
- // error =
++k;
} while (k < 3 || (qk - old_qk).sqr_norm() > epsilon);
-
trace::exiting("registration::impl::icp_");
}
@@ -102,9 +119,9 @@
mln_precondition(exact(cloud).has_data());
mln_precondition(exact(surface).has_data());
+ vecs_t a,b; // FIXME : to built.
-
- output = impl::icp_(exact(cloud), exact(surface));
+ impl::icp_(a, b);
trace::exiting("registration::icp");
}
Index: sandbox/jardonnet/registration/projection.hh
--- sandbox/jardonnet/registration/projection.hh (revision 0)
+++ sandbox/jardonnet/registration/projection.hh (revision 0)
@@ -0,0 +1,52 @@
+
+#ifndef PROJECTION_HH
+# define PROJECTION_HH
+
+# include <assert.h>
+
+namespace mln
+{
+
+ namespace projection
+ {
+
+ template <class Pk_t, class X_t, class Xk_t>
+ void de_base(// input
+ const Pk_t& Pk,
+ const X_t& X,
+ // inout
+ Xk_t& Xk,
+ // output
+ algebra::vec<3, float>& mu_Xk,
+ float& err)
+ {
+ assert(Pk.size() == Xk.size());
+
+ err = 0.f;
+ mu_Xk = make::vec(0,0,0);
+
+ for (size_t i = 0; i < Pk.size(); ++i)
+ {
+ algebra::vec<3,float> best_x = X[0];
+ float best_d = norm::l2(Pk[i] - best_x);
+ for (size_t j = 1; j < X.size(); ++j)
+ {
+ float d = norm::l2(Pk[i] - X[j]);
+ if (d < best_d)
+ {
+ best_d = d;
+ best_x = X[j];
+ }
+ }
+ Xk[i] = best_x;
+ mu_Xk += Xk[i];
+ err += best_d;
+ }
+ mu_Xk /= Pk.size();
+ err /= Pk.size();
+ }
+
+ }
+}
+
+#endif // ndef PROJECTION_HH
Index: sandbox/jardonnet/registration/quat/all.hh
--- sandbox/jardonnet/registration/quat/all.hh (revision 0)
+++ sandbox/jardonnet/registration/quat/all.hh (revision 0)
@@ -0,0 +1,9 @@
+#ifndef QUAT_ALL_HH
+# define QUAT_ALL_HH
+
+
+# include "interpol.hh"
+# include "rotation.hh"
+
+
+#endif // ndef QUAT_ALL_HH
Index: sandbox/jardonnet/registration/quat/misc.hh
--- sandbox/jardonnet/registration/quat/misc.hh (revision 0)
+++ sandbox/jardonnet/registration/quat/misc.hh (revision 0)
@@ -0,0 +1,19 @@
+#ifndef MISC_HH
+# define MISC_HH
+
+
+inline
+float epsilon()
+{
+ static const float e = 1e-5;
+ return e;
+}
+
+inline
+bool about_equal(float val1, float val2)
+{
+ return fabs(val1 - val2) < epsilon();
+}
+
+
+#endif // ndef MISC_HH
Index: sandbox/jardonnet/registration/quat/interpol.hh
--- sandbox/jardonnet/registration/quat/interpol.hh (revision 0)
+++ sandbox/jardonnet/registration/quat/interpol.hh (revision 0)
@@ -0,0 +1,100 @@
+#ifndef INTERPOL_HH
+# define INTERPOL_HH
+
+# include <vector>
+# include "misc.hh"
+
+# include <mln/value/quat.hh>
+
+// misc
+
+namespace mln
+{
+
+ inline
+ value::quat slerp_2(const value::quat& p, const value::quat& q, float h)
+ {
+ assert(interpol_ok(p, q, h));
+ value::quat tmp = p * pow(p.conj() * q, h);
+ assert(about_equal(tmp, slerp(p, q, h)));
+ return tmp;
+ }
+
+ inline
+ value::quat slerp_3(const value::quat& p, const value::quat& q, float h)
+ {
+ assert(interpol_ok(p, q, h));
+ value::quat tmp = pow(p * q.conj(), 1 - h) * q;
+ assert(about_equal(tmp, slerp(p, q, h)));
+ return tmp;
+ }
+
+ inline
+ value::quat slerp_4(const value::quat& p, const value::quat& q, float h)
+ {
+ assert(interpol_ok(p, q, h));
+ value::quat tmp = pow(q * p.conj(), h) * p;
+ assert(about_equal(tmp, slerp(p, q, h)));
+ return tmp;
+ }
+
+ inline
+ value::quat slerp_5(const value::quat& p, const value::quat& q, float h)
+ {
+ assert(interpol_ok(p, q, h));
+ value::quat tmp = q * pow(q.conj() * p, 1 - h);
+ assert(about_equal(tmp, slerp(p, q, h)));
+ return tmp;
+ }
+
+
+ // Spherical Spline Value::Quaternion Interpolation
+
+ inline
+ value::quat squad(const std::vector<value::quat>& q,
+ const std::vector<value::quat>& s,
+ unsigned i,
+ float h)
+ {
+ assert(i < q.size() && s.size() == q.size());
+ return slerp(slerp(q[i], q[i+1], h),
+ slerp(s[i], s[i+1], h),
+ 2 * h * (1 - h));
+ }
+
+
+ inline
+ value::quat s_from_q(const std::vector<value::quat>& q, unsigned i)
+ {
+ assert(i < q.size());
+ assert(q[i].is_unit());
+ if (i == 0 || i == q.size() - 1)
+ return q[i];
+ assert(q[i-1].is_unit() && q[i+1].is_unit());
+ return q[i] * exp(-(log(q[i].inv() * q[i+1]) + log(q[i].inv() * q[i-1]))
+ / 4);
+ }
+
+
+ inline
+ std::vector<value::quat> do_squad(const std::vector<value::quat>& q,
+ unsigned n)
+ {
+ assert(n > 1);
+ std::vector<value::quat> s(q.size()), res;
+
+ for (unsigned i = 0; i < q.size(); ++i)
+ s[i] = s_from_q(q, i);
+
+ res.push_back(q[0]);
+ for (unsigned i = 0; i < q.size() - 1; ++i)
+ {
+ for (unsigned j = 1; j < n; ++j)
+ res.push_back(squad(q, s, i, float(j) / n));
+ res.push_back(q[i + 1]);
+ }
+ return res;
+ }
+}
+
+#endif // ndef INTERPOL_HH
Index: sandbox/jardonnet/registration/quat/rotation.hh
--- sandbox/jardonnet/registration/quat/rotation.hh (revision 0)
+++ sandbox/jardonnet/registration/quat/rotation.hh (revision 0)
@@ -0,0 +1,60 @@
+#ifndef ROTATION_HH
+# define ROTATION_HH
+
+# include <stdlib.h>
+//# include "quat.hh"
+
+//# include "mat.hh"
+
+# include <mln/algebra/mat.hh>
+# include <mln/algebra/vec.hh>
+# include <mln/make/vec.hh>
+# include <mln/make/mat.hh>
+# include <mln/value/quat.hh>
+
+
+// FIXME: rotation should be an abstract class
+// and derived classes encapsulate either a quaternion or a algebra::matrix
+namespace mln
+{
+
+ vec3f rotate(const value::quat& q, const vec3f& p)
+ {
+
+ return (q * value::quat(0. ,p) * q.inv()).v();
+ }
+
+
+ bool check_rotation(const algebra::mat<3,3,float>& mat,
+ const value::quat& q)
+ {
+ assert(q.is_unit());
+ vec3f
+ tmp = make::vec(rand(), rand(), rand()),
+ p = tmp / norm::l2(tmp),
+ p_rot_1 = rotate(q, p),
+ p_rot_2 = mat * p;
+ return about_equal(norm::l2(p_rot_1 - p_rot_2), 0.f);
+ }
+
+
+ algebra::mat<3,3,float> quat2mat(const value::quat& q)
+ {
+ assert(q.is_unit());
+ float
+ w = q.to_vec()[0],
+ x = q.to_vec()[1], x2 = 2*x*x, xw = 2*x*w,
+ y = q.to_vec()[2], y2 = 2*y*y, xy = 2*x*y, yw = 2*y*w,
+ z = q.to_vec()[3], z2 = 2*z*z, xz = 2*x*z, yz = 2*y*z, zw = 2*z*w;
+ float t[9] = {1.f - y2 - z2, xy - zw, xz + yw,
+ xy + zw, 1.f - x2 - z2, yz - xw,
+ xz - yw, yz + xw, 1.f - x2 - y2};
+ algebra::mat<3,3,float> tmp = make::mat<3,3,9,float>(t);
+ // postcondition
+ assert(check_rotation(tmp, q));
+ return tmp;
+ }
+}
+
+
+#endif // ndef ROTATION_HH
Index: sandbox/vigouroux/color/my_yuv.hh
--- sandbox/vigouroux/color/my_yuv.hh (revision 1783)
+++ sandbox/vigouroux/color/my_yuv.hh (working copy)
@@ -2,7 +2,7 @@
// #include <mln/value/concept/vectorial.hh>
// #include <mln/value/int_u.hh>
-// #include <mln/metal/vec.hh>
+// #include <mln/algebra/vec.hh>
#ifndef MLN_VALUE_YUV_HH
# define MLN_VALUE_YUV_HH
Index: sandbox/vigouroux/color/my_hsi.hh
--- sandbox/vigouroux/color/my_hsi.hh (revision 1783)
+++ sandbox/vigouroux/color/my_hsi.hh (working copy)
@@ -2,7 +2,7 @@
#include <mln/value/concept/vectorial.hh>
#include <mln/value/int_u.hh>
-#include <mln/metal/vec.hh>
+#include <mln/algebra/vec.hh>
#include <mln/value/float01_8.hh>
Index: sandbox/vigouroux/color/my_hsl.hh
--- sandbox/vigouroux/color/my_hsl.hh (revision 1783)
+++ sandbox/vigouroux/color/my_hsl.hh (working copy)
@@ -2,7 +2,7 @@
#include <mln/value/concept/vectorial.hh>
#include <mln/value/int_u.hh>
-#include <mln/metal/vec.hh>
+#include <mln/algebra/vec.hh>
#ifndef MLN_VALUE_HSL_HH
# define MLN_VALUE_HSL_HH
Index: sandbox/vigouroux/color/my_xyz.hh
--- sandbox/vigouroux/color/my_xyz.hh (revision 1783)
+++ sandbox/vigouroux/color/my_xyz.hh (working copy)
@@ -2,7 +2,7 @@
// #include <mln/value/concept/vectorial.hh>
// #include <mln/value/int_u.hh>
-// #include <mln/metal/vec.hh>
+// #include <mln/algebra/vec.hh>
#ifndef MLN_VALUE_XYZ_HH
# define MLN_VALUE_XYZ_HH
Index: sandbox/vigouroux/color/my_hsv.hh
--- sandbox/vigouroux/color/my_hsv.hh (revision 1783)
+++ sandbox/vigouroux/color/my_hsv.hh (working copy)
@@ -2,7 +2,7 @@
#include <mln/value/concept/vectorial.hh>
#include <mln/value/int_u.hh>
-#include <mln/metal/vec.hh>
+#include <mln/algebra/vec.hh>
#ifndef MLN_VALUE_HSV_HH
# define MLN_VALUE_HSV_HH
Index: sandbox/vigouroux/color/my_yiq.hh
--- sandbox/vigouroux/color/my_yiq.hh (revision 1783)
+++ sandbox/vigouroux/color/my_yiq.hh (working copy)
@@ -2,7 +2,7 @@
// #include <mln/value/concept/vectorial.hh>
// #include <mln/value/int_u.hh>
-// #include <mln/metal/vec.hh>
+// #include <mln/algebra/vec.hh>
#ifndef MLN_VALUE_YIQ_HH
# define MLN_VALUE_YIQ_HH
Index: sandbox/folio/dmap.cc
--- sandbox/folio/dmap.cc (revision 1783)
+++ sandbox/folio/dmap.cc (working copy)
@@ -34,7 +34,7 @@
for_all(q)
if (input(q) == true) // q is in the object.
{
- metal::vec<2,int> vp = p.to_point(), vq = q.to_point();
+ algebra::vec<2,int> vp = p.to_point(), vq = q.to_point();
min.take(norm::l2_distance(vp, vq));
}
output(p) = min;
Index: sandbox/garrigues/image_identity/interpolated.hh
--- sandbox/garrigues/image_identity/interpolated.hh (revision 1783)
+++ sandbox/garrigues/image_identity/interpolated.hh (working copy)
@@ -36,7 +36,7 @@
# include <cmath>
# include "image_identity.hh"
-# include <mln/metal/vec.hh>
+# include <mln/algebra/vec.hh>
namespace mln
@@ -99,13 +99,13 @@
using super_::owns_;
/// Test if a pixel value is accessible at \p v.
- bool owns_(const mln::metal::vec<I::point::dim, float>& v) const;
+ bool owns_(const mln::algebra::vec<I::point::dim, float>& v) const;
/// Read-only access of pixel value at point site \p p.
/// Mutable access is only OK for reading (not writing).
using super_::operator();
- mln_value(I) operator()(const mln::metal::vec<I::point::dim, float>& v) const;
+ mln_value(I) operator()(const mln::algebra::vec<I::point::dim, float>& v) const;
/// Give the set of values of the image.
@@ -149,7 +149,7 @@
}
template <typename I>
- bool interpolated<I>::owns_(const mln::metal::vec<I::point::dim, float>& v) const
+ bool interpolated<I>::owns_(const mln::algebra::vec<I::point::dim, float>& v) const
{
mln_point(I) p;
for (unsigned i = 0; i < I::point::dim; ++i)
@@ -159,7 +159,7 @@
template <typename I>
mln_value(I)
- interpolated<I>::operator()(const mln::metal::vec<I::point::dim, float>& v) const
+ interpolated<I>::operator()(const mln::algebra::vec<I::point::dim, float>& v) const
{
mln_point(I) p;
for (unsigned i = 0; i < I::point::dim; ++i)
Index: sandbox/garrigues/image_identity/interpolated.cc
--- sandbox/garrigues/image_identity/interpolated.cc (revision 1783)
+++ sandbox/garrigues/image_identity/interpolated.cc (working copy)
@@ -35,7 +35,7 @@
#include <mln/core/image2d_b.hh>
#include "interpolated.hh"
-#include <mln/metal/vec.hh>
+#include <mln/algebra/vec.hh>
#include <mln/level/fill.hh>
@@ -60,8 +60,8 @@
interpolated< image2d_b<float> > inter(f);
- metal::vec<2, float> v1 = make::vec(2.3, 0.6);
- metal::vec<2, float> v2 = make::vec(3.2, 1.8);
+ algebra::vec<2, float> v1 = make::vec(2.3, 0.6);
+ algebra::vec<2, float> v2 = make::vec(3.2, 1.8);
debug::println(f);
2
1