LRE
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
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
List overview
Download
Olena-patches
----- 2025 -----
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
olena-patches@lrde.epita.fr
9625 discussions
Start a n
N
ew thread
milena r1786: correct structures
by Caroline Vigouroux
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
16Â years, 10Â months
1
0
0
0
Re: [Olena-patches] 1784: Icp legacy. algebra:: now contains types vec, mat and quat.
by Ugo Jardonnet
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.
16Â years, 10Â months
1
0
0
0
1784: Icp legacy. algebra:: now contains types vec, mat and quat.
by Ugo Jardonnet
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);
16Â years, 10Â months
2
1
0
0
1785: Sandbox: Site/Psite refactorization: finalize the example.
by Nicolas Ballas
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog from Nicolas Ballas <ballas(a)lrde.epita.fr> Sandbox: Site/Psite refactorization: finalize the example. * sandbox/ballas/refactorization/test/test.cc: Remove this tes. * sandbox/ballas/refactorization/test/rle.cc, * sandbox/ballas/refactorization/test/image2d.cc: update tests. * sandbox/ballas/refactorization/image2d.hh: update values_. * sandbox/ballas/refactorization/concept.hh: u. * sandbox/ballas/refactorization/internal/impl.hh, * sandbox/ballas/refactorization/internal/force_exact.hh, * sandbox/ballas/refactorization/internal/piter_base.hh, * sandbox/ballas/refactorization/internal/psite_base.hh, * sandbox/ballas/refactorization/point2d_impl.hh: Impl recovering. concept.hh | 2 - image2d.hh | 23 ++++++++++---- internal/force_exact.hh | 77 ++++++++++++++++++++++++++++++++++++++++++++++++ internal/impl.hh | 2 - internal/piter_base.hh | 2 - internal/psite_base.hh | 2 - point2d_impl.hh | 11 +++--- test/image2d.cc | 11 ++++++ test/rle.cc | 43 +++++++++++++++++++------- 9 files changed, 146 insertions(+), 27 deletions(-) Index: sandbox/ballas/refactorization/test/rle.cc --- sandbox/ballas/refactorization/test/rle.cc (revision 1784) +++ sandbox/ballas/refactorization/test/rle.cc (working copy) @@ -5,6 +5,7 @@ //# include <p_run.hh> //# include <rle_psite.hh> # include <rle_image.hh> +# include <image2d.hh> int main() @@ -13,20 +14,15 @@ typedef point2d<int> point; - point p1(5, 5), p2(12, 2), p3(7, 6); + point p1(5, 5), p3(12, 6), p2(7, 6); + std::cout << "p1: " << p1 << std::endl; + std::cout << "p2: " << p2 << std::endl; + std::cout << "p3: " << p3 << std::endl; + p_run<point> prun1(p1, 5); p_run<point> prun2(p2, 12); p_run<point> prun3(p3, 4); - rle_pset<point> pset; -// pset.insert(prun1); -// pset.insert(prun2); -// pset.insert(prun3); - -// rle_pset<point>::piter p(pset); -// for (p.start(); p.is_valid(); p.next()) -// std::cout << (point) p << std::endl; - rle_image<point, int> ima; ima.insert(prun1, 1); @@ -35,7 +31,32 @@ rle_image<point, int>::piter p(ima.domain()); for (p.start(); p.is_valid(); p.next()) - std::cout << ima(p) << std::endl; + { + std::cout << "coord: " << p[0] << "," + << p[1] << std::endl; + std::cout << "ima: "<< ima(p) << std::endl; + } + + + /// Interoperability + std::cout << "------------------------------------------------" << std::endl; + int i = 0; + point2d<int> p4(12, 17); + box2d<int> bb(p1, p4); + image2d<int> ima2d(bb); + image2d<int>::fwd_piter piter2(ima2d.domain()); + for (piter2.start(); piter2.is_valid(); piter2.next()) + { + ++i; + ima2d(piter2) = i; + } + for (p.start(); p.is_valid(); p.next()) + { + std::cout << "coord: " << p[0] << "," + << p[1] << std::endl; + std::cout << "ima: "<< ima(p) << std::endl; + std::cout << "ima2d: "<< ima2d(p) << std::endl; + } } Index: sandbox/ballas/refactorization/test/image2d.cc --- sandbox/ballas/refactorization/test/image2d.cc (revision 1784) +++ sandbox/ballas/refactorization/test/image2d.cc (working copy) @@ -5,13 +5,22 @@ { using namespace mln; - point2d<int> pmin(0, 0), pmax(5, 5); + point2d<int> pmin(0, 0), pmax(0, 5); box2d<int> b(pmin, pmax); image2d<int> ima(b); ima(pmin) = 5; + int i = 0; image2d<int>::fwd_piter p(ima.domain()); for (p.start(); p.is_valid(); p.next()) + { + ++i; + ima(p) = i; + } + + + + for (p.start(); p.is_valid(); p.next()) std::cout << ima(p) << std::endl; } Index: sandbox/ballas/refactorization/image2d.hh --- sandbox/ballas/refactorization/image2d.hh (revision 1784) +++ sandbox/ballas/refactorization/image2d.hh (working copy) @@ -26,6 +26,7 @@ image2d(int nrows, int ncols); image2d(const box2d<int>& b); + ~image2d(); ///typedef mln::value::set<T> vset; // const vset& values() const; @@ -39,7 +40,7 @@ private: - T value_; + T* values_; box2d<int> b_; bool is_ready_; }; @@ -51,6 +52,8 @@ b_(nrows, ncols), is_ready_(false) { + values_ = new T[nrows * ncols]; + is_ready_ = true; } template <typename T> @@ -58,6 +61,15 @@ b_(b), is_ready_(false) { + values_ = new T[(b.pmax()[0] - b.pmin()[0] + 1) * + (b.pmax()[1] - b.pmin()[1] + 1)]; + is_ready_ = true; + } + + template <typename T> + image2d<T>::~image2d() + { + delete[] values_; } template <typename T> @@ -69,17 +81,16 @@ template <typename T> const T& - image2d<T>::operator()(const point2d<int>&) const + image2d<T>::operator()(const point2d<int>& p) const { - return value_; + return values_[p[0] * b_.pmax()[1] + p[1]]; } template <typename T> T& - image2d<T>::operator()(const point2d<int>&) + image2d<T>::operator()(const point2d<int>& p) { - is_ready_ = true; - return value_; + return values_[p[0] * b_.pmax()[1] + p[1]]; } template <typename T> Index: sandbox/ballas/refactorization/concept.hh --- sandbox/ballas/refactorization/concept.hh (revision 1784) +++ sandbox/ballas/refactorization/concept.hh (working copy) @@ -67,7 +67,7 @@ }; template <typename E> - struct Dpsite : public Object<E> + struct Dpsite : public Dsite<E> { /* typedef dpsite; Index: sandbox/ballas/refactorization/internal/impl.hh --- sandbox/ballas/refactorization/internal/impl.hh (revision 1784) +++ sandbox/ballas/refactorization/internal/impl.hh (working copy) @@ -4,7 +4,7 @@ namespace mln { - template <typename S> + template <typename E, typename S> struct impl { /// empty implementation Index: sandbox/ballas/refactorization/internal/force_exact.hh --- sandbox/ballas/refactorization/internal/force_exact.hh (revision 0) +++ sandbox/ballas/refactorization/internal/force_exact.hh (revision 0) @@ -0,0 +1,77 @@ +// 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_INTERNAL_FORCE_EXACT_HH +# define MLN_CORE_INTERNAL_FORCE_EXACT_HH + +/*! \file mln/core/internal/force_exact.hh + * + * \brief Definition of a violent cast for internal use only. + * + */ + + + +namespace mln +{ + + namespace internal + { + + /*! \internal Violent cast. + * This cast is an alternative to the mln::exact cast. + * It is used for objects that do not derive from + * mln::Object. + * Warning Do not to use this cast! + * see mln::exact + */ + template <typename E, typename T> + E& force_exact(const T& ref) + { + /* + static const E exact_obj; + static const Type& exact_obj_ref = exact_obj; + static const int exact_offset = + (const char*)(void*)(&exact_obj_ref) + - (const char*)(void*)(&exact_obj); + return *(E*)((char*)(this_) - exact_offset); + */ + static const E* exact_obj; + static const T& exact_obj_ref = *exact_obj; + static const int exact_offset = + (const char*)(void*)(&exact_obj_ref) + - (const char*)(void*)( exact_obj); + + return *(E*)((char*)(&ref) - exact_offset); + } + + } // end of namespace mln::internal + +} // end of namespace mln + + +#endif // ! MLN_CORE_INTERNAL_FORCE_EXACT_HH Index: sandbox/ballas/refactorization/internal/piter_base.hh --- sandbox/ballas/refactorization/internal/piter_base.hh (revision 1784) +++ sandbox/ballas/refactorization/internal/piter_base.hh (working copy) @@ -34,7 +34,7 @@ /// Piter base template <typename E, typename Site, typename Psite> struct piter_base_ : - public impl<Site>, + public impl<E, Site>, public piter_base_site_cast<E, Site, typename mlc_equal(Site, Psite)::eval> { Index: sandbox/ballas/refactorization/internal/psite_base.hh --- sandbox/ballas/refactorization/internal/psite_base.hh (revision 1784) +++ sandbox/ballas/refactorization/internal/psite_base.hh (working copy) @@ -11,7 +11,7 @@ template <typename E, typename P> struct psite_base_ : public Psite<E>, - public impl<P> + public impl<E, P> { operator E() const; Index: sandbox/ballas/refactorization/point2d_impl.hh --- sandbox/ballas/refactorization/point2d_impl.hh (revision 1784) +++ sandbox/ballas/refactorization/point2d_impl.hh (working copy) @@ -2,6 +2,7 @@ # define POINT2D_IMPL_HH_ # include <internal/impl.hh> +# include <internal/force_exact.hh> namespace mln @@ -11,8 +12,8 @@ template <typename C> struct point2d; - template <typename C> - struct impl< point2d<C> > + template <typename E, typename C> + struct impl< E, point2d<C> > { C operator[](unsigned i) const; @@ -26,11 +27,11 @@ # ifndef MLN_INCLUDE_ONLY - template <typename C> + template <typename E, typename C> C - impl< point2d<C> >::operator[] (unsigned i) const + impl< E, point2d<C> >::operator[] (unsigned i) const { - return this->to_site()[i]; + return internal::force_exact<E>(*this).to_site()[i]; } # endif // ! MLN_INCLUDE_ONLY
16Â years, 10Â months
1
0
0
0
Re: [Olena-patches] 1784: Icp legacy. algebra:: now contains types vec, mat and quat.
by Ugo Jardonnet
Ugo Jardonnet wrote: >
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. > > * sandbox/jardonnet/test/icp.cc: New test. > * sandbox/jardonnet/TODO: Up my TODO. > * sandbox/jardonnet/registration/quat7.hh: New quat rot + tr. > * sandbox/jardonnet/registration/cloud.hh: New tools. > * sandbox/jardonnet/registration/jacobi.hh: New jacobu < nr. > * sandbox/jardonnet/registration/icp.hh: Up icp. > * sandbox/jardonnet/registration/projection.hh: New projection. > * sandbox/jardonnet/registration/quat/misc.hh: New misc. > * sandbox/jardonnet/registration/quat/interpol.hh: New quat tool. > * sandbox/jardonnet/registration/quat/rotation.hh: New quat tool.
16Â years, 10Â months
1
0
0
0
1783: sandbox: psite/site refactorization: add the rle image type.
by Nicolas Ballas
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog from Nicolas Ballas <ballas(a)lrde.epita.fr> sandbox: psite/site refactorization: add the rle image type. * sandbox/ballas/refactorization/test/rle.cc: New tests. * sandbox/ballas/refactorization/p_run.hh, * sandbox/ballas/refactorization/rle_pset.hh, * sandbox/ballas/refactorization/rle_psite.hh, * sandbox/ballas/refactorization/rle_image.hh: New, rle image type. * sandbox/ballas/refactorization/internal/pset_base.hh, * sandbox/ballas/refactorization/internal/image_base.hh, * sandbox/ballas/refactorization/internal/piter_base.hh, * sandbox/ballas/refactorization/internal/psite_base.hh, * sandbox/ballas/refactorization/box2d.hh, * sandbox/ballas/refactorization/point2d.hh: update box2d.hh | 4 internal/image_base.hh | 9 + internal/piter_base.hh | 27 ++-- internal/pset_base.hh | 25 +++ internal/psite_base.hh | 20 +-- p_run.hh | 286 +++++++++++++++++++++++++++++++++++++++++++++ point2d.hh | 13 ++ rle_image.hh | 118 ++++++++++++++++++ rle_pset.hh | 308 +++++++++++++++++++++++++++++++++++++++++++++++++ rle_psite.hh | 137 +++++++++++++++++++++ test/rle.cc | 41 ++++++ 11 files changed, 962 insertions(+), 26 deletions(-) Index: sandbox/ballas/refactorization/test/rle.cc --- sandbox/ballas/refactorization/test/rle.cc (revision 0) +++ sandbox/ballas/refactorization/test/rle.cc (revision 0) @@ -0,0 +1,41 @@ +// # include <rle_pset.hh> +# include <iostream> + +# include <point2d.hh> +//# include <p_run.hh> +//# include <rle_psite.hh> +# include <rle_image.hh> + + +int main() +{ + using namespace mln; + + typedef point2d<int> point; + + point p1(5, 5), p2(12, 2), p3(7, 6); + p_run<point> prun1(p1, 5); + p_run<point> prun2(p2, 12); + p_run<point> prun3(p3, 4); + + rle_pset<point> pset; +// pset.insert(prun1); +// pset.insert(prun2); +// pset.insert(prun3); + +// rle_pset<point>::piter p(pset); +// for (p.start(); p.is_valid(); p.next()) +// std::cout << (point) p << std::endl; + + rle_image<point, int> ima; + + ima.insert(prun1, 1); + ima.insert(prun2, 2); + ima.insert(prun3, 3); + + rle_image<point, int>::piter p(ima.domain()); + for (p.start(); p.is_valid(); p.next()) + std::cout << ima(p) << std::endl; + +} + Index: sandbox/ballas/refactorization/p_run.hh --- sandbox/ballas/refactorization/p_run.hh (revision 0) +++ sandbox/ballas/refactorization/p_run.hh (revision 0) @@ -0,0 +1,286 @@ +#ifndef P_RUN_HH_ +# define P_RUN_HH_ + +# include <cstddef> +# include <iostream> +# include <internal/pset_base.hh> +# include <internal/piter_base.hh> + +namespace mln +{ + // Fwd decls. + template <typename P> struct p_run_fwd_piter_; + + template <typename P> + class p_run : + public internal::pset_base_< P, p_run<P> > + { + public: + typedef P site; + typedef P psite; + + typedef p_run_fwd_piter_<P> fwd_piter; + typedef p_run_fwd_piter_<P> bkd_piter; + typedef fwd_piter piter; + + p_run(); + p_run(const P& start, std::size_t len); + void set_run(const P& start, std::size_t len); + + bool owns_(const P& p) const; + std::size_t nsites() const; + std::size_t length() const; + + P operator[](unsigned i) const; + + const P& first() const; + + protected: + P p_; + std::size_t len_; + bool is_valid_; + }; + + template <typename P> + std::ostream& operator<<(std::ostream& out, const p_run<P>& pr); + +# 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) + { + assert(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) + { + assert(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>::owns_(const P& p) const + { + assert(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>::nsites() const + { + assert(is_valid_); + return len_; + } + + template <typename P> + inline + std::size_t + p_run<P>::length() const + { + assert(is_valid_); + return len_; + } + + template <typename P> + inline + P + p_run<P>::operator[](unsigned i) const + { + assert(is_valid_); + assert(i < nsites()); + 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> + std::ostream& + operator<<(std::ostream& out, const p_run<P>& pr) + { + out << "Run: (" << pr.first() << ", " << pr.length() << ")"; + return out; + } + +# endif // ! MLN_INCLUDE_ONLY + + + /// Iterators + + template <typename P> + struct p_run_fwd_piter_ : + public internal::piter_base_< p_run_fwd_piter_<P>, P, p_run<P> > + { + typedef p_run_fwd_piter_<P> self_; + typedef internal::piter_base_< p_run_fwd_piter_<P>, P, p_run<P> > super_; + public: + + typedef P site; + typedef p_run<P> psite; + + enum { dim = P::dim }; + + p_run_fwd_piter_(); + p_run_fwd_piter_(const p_run<P>& pr); + void assign_run(const p_run<P>& pr); + + const site& to_site() const; + const psite& to_psite() const; + + /// operator[] ? + + bool is_valid() const; + void invalidate(); + void start(); + void next_(); + + /// Get the index of the point in the run. + unsigned ind() const; + + + protected: + const p_run<P>* run_; + bool is_valid_; + unsigned i_; + P p_; + }; + + +# ifndef MLN_INCLUDE_ONLY + + template <typename P> + inline + p_run_fwd_piter_<P>::p_run_fwd_piter_() + : run_ (0), + is_valid_(false) + { + } + + template <typename P> + inline + p_run_fwd_piter_<P>::p_run_fwd_piter_(const p_run<P>& pr) + : run_(&pr), + is_valid_(false) + { + } + + template <typename P> + inline + void + p_run_fwd_piter_<P>::assign_run(const p_run<P>& pr) + { + run_ = ≺ + is_valid_ = false; + } + + template <typename P> + inline + const typename p_run_fwd_piter_<P>::site& + p_run_fwd_piter_<P>::to_site() const + { + assert(is_valid()); + return p_; + } + + template <typename P> + inline + const typename p_run_fwd_piter_<P>::psite& + p_run_fwd_piter_<P>::to_psite() const + { + assert(is_valid()); + return *run_; + } + + template <typename P> + inline + bool + p_run_fwd_piter_<P>::is_valid() const + { + return is_valid_; + } + + template <typename P> + inline + void + p_run_fwd_piter_<P>::invalidate() + { + is_valid_ = false; + } + + template <typename P> + inline + void + p_run_fwd_piter_<P>::start() + { + p_ = run_->first(); + i_ = 0; + is_valid_ = true; + } + + template <typename P> + inline + void + p_run_fwd_piter_<P>::next_() + { + p_[dim - 1]++; + ++i_; + is_valid_ = p_[dim - 1] - run_->first()[dim - 1] < (signed)run_->length(); + } + + template <typename P> + inline + unsigned + p_run_fwd_piter_<P>::ind() const + { + return i_; + } + +# endif // ! MLN_INCLUDE_ONLY + +} // end of namespace mln + + +#endif // !P_RUN_HH_ Index: sandbox/ballas/refactorization/rle_image.hh --- sandbox/ballas/refactorization/rle_image.hh (revision 0) +++ sandbox/ballas/refactorization/rle_image.hh (revision 0) @@ -0,0 +1,118 @@ +#ifndef RLE_IMAGE_CC_ +# define RLE_IMAGE_CC_ + + +# include <rle_pset.hh> +# include <internal/image_base.hh> + +namespace mln +{ + + // note P must be a point + template <typename P, typename T> + class rle_image : + public internal::image_base_<rle_pset<P>, rle_image<P, T> > + { + public: + + typedef T value; + typedef T& lvalue; + typedef const T rvalue; + + typedef P site; + typedef rle_psite<P> psite; + + typedef rle_pset<P> pset; + typedef typename pset::fwd_piter fwd_piter; + typedef typename pset::bkd_piter bkd_piter; + typedef typename pset::fwd_piter piter; + + + rle_image(); + + void insert(const p_run<P>& pr, T value); + rvalue operator() (const rle_psite<P>& psite) const; + lvalue operator() (const rle_psite<P>& psite); + bool has_data() const; + + bool owns_(const rle_psite<P>& ps) const; + const pset& domain() const; + + protected: + std::vector<T> values_; + rle_pset<P> domain_; + }; + + +# ifndef MLN_INCLUDE_ONLY + + template <typename P, typename T> + inline + rle_image<P, T>::rle_image() + { + } + + template <typename P, typename T> + inline + bool + rle_image<P, T>::has_data() const + { + return this->values_.size() != 0; + } + + template <typename P, typename T> + inline + void + rle_image<P, T>::insert(const p_run<P>& pr, T value) + { + this->domain_.insert(pr); + this->values_.push_back(value); + } + + template <typename P, typename T> + inline + typename rle_image<P, T>::rvalue + rle_image<P, T>::operator() (const rle_psite<P>& psite) + const + { + assert(this->owns_(psite)); + return this->values_[psite.p_of_run()]; + } + + template <typename P, typename T> + inline + typename rle_image<P, T>::lvalue + rle_image<P, T>::operator() (const rle_psite<P>& psite) + { + assert(this->owns_(psite)); + return this->values_[psite.p_of_run()]; + } + + template <typename P, typename T> + inline + const typename rle_image<P, T>::pset& + rle_image<P, T>::domain() const + { + return this->domain_; + } + + template <typename P, typename T> + inline + bool + rle_image<P, T>::owns_(const rle_psite<P>& ps) const + { + if (!this->has_data()) + return false; + else + return (ps.p_of_run() < this->domain_.nruns() && + ps.p_in_run() < this->domain_[ps.p_of_run()].length() && + this->domain_[ps.p_of_run()][ps.p_in_run()] == ps.to_site()); + /// FIXME -> to_site.... + } + +# endif // ! MLN_INCLUDE_ONLY + +} // end of namespace mln + + +#endif // !RLE_IMAGE_CC_ Index: sandbox/ballas/refactorization/rle_psite.hh --- sandbox/ballas/refactorization/rle_psite.hh (revision 0) +++ sandbox/ballas/refactorization/rle_psite.hh (revision 0) @@ -0,0 +1,137 @@ +#ifndef RLE_PSITE_HH_ +# define RLE_PSITE_HH_ + + +# include <internal/psite_base.hh> + +namespace mln +{ + + template <typename P> class rle_pset; + + template <typename P> + class rle_psite : public internal::psite_base_< rle_psite<P>, P> + { + public: + + enum { dim = 2 }; + + typedef P site; + typedef rle_psite<P> psite; + // FIXME dpsite?? + + rle_psite(const rle_pset<P>& pr, unsigned in_run, unsigned of_run); + + P& range_start_(); + const P& range_start_() const; + unsigned p_of_run() const; + unsigned& p_of_run(); + unsigned p_in_run() const; + unsigned& p_in_run(); + const P& to_site() const; + void update_(); + + protected: + const rle_pset<P>& pr_; + + unsigned p_in_run_; + unsigned p_of_run_; + + P p_; + }; + + template <typename P> + inline + bool operator==(const rle_psite<P>& lhs_, const rle_psite<P>& rhs_); + +# ifndef MLN_INCLUDE_ONLY + + template <typename P> + void + rle_psite<P>::update_() + { + this->p_.operator= (pr_[p_of_run_][p_in_run_]); + } + + template <typename P> + inline + rle_psite<P>::rle_psite(const rle_pset<P>& pr, + unsigned in_run, + unsigned of_run) + : pr_(pr), + p_in_run_(in_run), + p_of_run_(of_run), + p_(pr[p_of_run_][p_in_run_]) + { + } + + template <typename P> + inline + const P& + rle_psite<P>::range_start_() const + { + return pr_[p_of_run_].first(); + } + + template <typename P> + inline + P& + rle_psite<P>::range_start_() + { + return pr_[p_of_run_].first(); + } + + template <typename P> + inline + unsigned + rle_psite<P>::p_of_run() const + { + return p_of_run_; + } + + template <typename P> + inline + unsigned& + rle_psite<P>::p_of_run() + { + return p_of_run_; + } + + template <typename P> + inline + unsigned + rle_psite<P>::p_in_run() const + { + return p_in_run_; + } + + template <typename P> + inline + unsigned& + rle_psite<P>::p_in_run() + { + return p_in_run_; + } + + template <typename P> + inline + const P& + rle_psite<P>::to_site() const + { + return p_; + } + + template <typename P> + inline + bool operator==(const rle_psite<P>& lhs_, const rle_psite<P>& rhs_) + { + return lhs_.p_of_run_ == lhs_.p_of_run && lhs_.p_in_run_ == rhs_.p_in_run_; + } + +# endif // ! MLN_INCLUDE_ONLY + +} // end of namespace mln + +# include <rle_psite.hh> + +#endif // !RLE_PSITE_HH_ Index: sandbox/ballas/refactorization/rle_pset.hh --- sandbox/ballas/refactorization/rle_pset.hh (revision 0) +++ sandbox/ballas/refactorization/rle_pset.hh (revision 0) @@ -0,0 +1,308 @@ +// 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 RLE_PSET_HH_ +# define RLE_PSET_HH_ + + + +# include <internal/pset_base.hh> +# include <internal/psite_base.hh> + +# include <rle_psite.hh> +# include <p_run.hh> + +# include <vector> +# include <utility> + + + +namespace mln +{ + + // Forward declaration + template <typename P> struct rle_pset_fwd_piter_; + + template <typename P> + class rle_pset : + public internal::pset_base_< rle_psite<P>, rle_pset<P> > + { + typedef std::vector< p_run<P> >container; + public: + typedef rle_pset_fwd_piter_<P> fwd_piter; + typedef fwd_piter bkd_piter; + typedef fwd_piter piter; + + rle_pset(); + + /// Test is \p p belongs to this point set. + bool owns_(const rle_psite<P>& ps) const; + + typename std::size_t nsites() const; + void insert(const p_run<P>& pr); + + + unsigned nruns() const; + unsigned range_len_(const P& p) const; + + const p_run<P>& operator[](unsigned i) const; + + const container& con() const; + + protected: + + typename std::size_t nsites_; + container con_; + + }; + +# ifndef MLN_INCLUDE_ONLY + + template <typename P> + inline + rle_pset<P>::rle_pset() : + nsites_(0) + { + } + + template <typename P> + inline + bool + rle_pset<P>::owns_(const rle_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 + typename std::size_t + rle_pset<P>::nsites() const + { + return nsites_; + } + + template <typename P> + inline + void + rle_pset<P>::insert(const p_run<P>& pr) + { + /// This doesn't deal with recovering pset. + con_.push_back(pr); + nsites_ += pr.nsites(); + } + + template <typename P> + inline + unsigned + rle_pset<P>::nruns() const + { + return con_.size(); + } + + template <typename P> + inline + unsigned + rle_pset<P>::range_len_(const P& p) const + { + unsigned i; + for (i = 0; i < con_.size(); ++i) + { + if (con_[i].first == p) + return con_[i].nsites(); + } + + assert(i < con_.size()); + return (con_.size()); + } + + template <typename P> + inline + const p_run<P>& + rle_pset<P>::operator[](unsigned i) const + { + return con_[i]; + } + + template <typename P> + const typename rle_pset<P>::container& + rle_pset<P>::con() const + { + return con_; + } + +# endif // ! MLN_INCLUDE_ONLY + + template <typename P, typename E> + class rle_pset_piter_ : public internal::piter_base_<E, P, rle_psite<P> > + { + public: + typedef P site; + typedef rle_psite<P> psite; + + const P& to_site() const; + + protected: + P p_; + const rle_pset<P>& con_; + rle_pset_piter_(const rle_pset<P>& pset); + }; + + +# ifndef MLN_INCLUDE_ONLY + + template <typename P, typename E> + inline + rle_pset_piter_<P, E>::rle_pset_piter_(const rle_pset<P>& pset) : + con_(pset) + { + } + + template <typename P, typename E> + inline + const P& + rle_pset_piter_<P, E>::to_site() const + { + assert(exact(this)->is_valid()); + return p_; + } + +# endif // ! MLN_INCLUDE_ONLY + + + template <typename P> + class rle_pset_fwd_piter_ : + public rle_pset_piter_<P, rle_pset_fwd_piter_<P> > + { + typedef rle_pset_piter_<P, rle_pset_fwd_piter_<P> > super; + public: + + rle_pset_fwd_piter_(const rle_pset<P>& pset); + + bool is_valid() const; + void invalidate(); + void start(); + void next_(); + + const rle_psite<P>& to_psite() const; + + protected: + void update_(); + + unsigned i_; + p_run_fwd_piter_<P> it_; + rle_psite<P> ps_; + }; + + +# ifndef MLN_INCLUDE_ONLY + + template <typename P> + inline + rle_pset_fwd_piter_<P>::rle_pset_fwd_piter_(const rle_pset<P>& pset) : + super(pset), + ps_(pset, 0, 0) + { + invalidate(); + } + + template <typename P> + inline + bool + rle_pset_fwd_piter_<P>::is_valid() const + { + return i_ < this->con_.nruns(); + } + + template <typename P> + inline + void + rle_pset_fwd_piter_<P>::invalidate() + { + i_ = this->con_.nruns(); + } + + template <typename P> + inline + void + rle_pset_fwd_piter_<P>::start() + { + i_ = 0; + it_.assign_run(this->con_[i_]); + it_.start(); + this->p_ = it_; + this->update_(); + } + + template <typename P> + inline + void + rle_pset_fwd_piter_<P>::next_() + { + assert(this->is_valid()); + it_.next(); + if (!it_.is_valid()) + { + ++i_; + if (is_valid()) + { + it_.assign_run(this->con_[i_]); + it_.start(); + } + else + return; + } + this->update_(); + } + + template <typename P> + void + rle_pset_fwd_piter_<P>::update_() + { + this->p_ = it_; + ps_.p_in_run() = it_.ind(); + ps_.p_of_run() = i_; + this->ps_.update_(); + } + + template <typename P> + const rle_psite<P>& + rle_pset_fwd_piter_<P>::to_psite() const + { + return ps_; + } + +# endif // ! MLN_INCLUDE_ONLY + + +} // end of namespace mln + + +#endif // !RLE_PSET_HH_ Index: sandbox/ballas/refactorization/internal/pset_base.hh --- sandbox/ballas/refactorization/internal/pset_base.hh (revision 1782) +++ sandbox/ballas/refactorization/internal/pset_base.hh (working copy) @@ -3,6 +3,7 @@ # include <concept.hh> +# include <exact.hh> namespace mln { @@ -15,9 +16,33 @@ template <typename P, typename E> struct pset_base_ : public Pset<E> { + /// !!! typedef typename P::site site; typedef P psite; + + + bool has(const P& ps) const; + protected: + pset_base_(); }; + + +# ifndef MLN_INCLUDE_ONLY + + template <typename P, typename E> + pset_base_<P, E>::pset_base_() + { + } + + template <typename P, typename E> + bool + pset_base_<P, E>::has(const P& ps) const + { + return exact(this)->owns_(ps); + } + +# endif // ! MLN_INCLUDE_ONLY + } } Index: sandbox/ballas/refactorization/internal/image_base.hh --- sandbox/ballas/refactorization/internal/image_base.hh (revision 1782) +++ sandbox/ballas/refactorization/internal/image_base.hh (working copy) @@ -19,7 +19,7 @@ typedef typename S::fwd_piter fwd_piter; typedef typename S::bkd_piter bkd_piter; - bool has(const psite&) const; + bool has(const psite& ps) const; protected: image_base_(); @@ -34,6 +34,13 @@ { } + template <typename S, typename E> + bool + image_base_<S, E>::has(const psite& ps) const + { + return exact(this)->owns_(ps); + } + # endif // ! MLN_INCLUDE_ONLY } Index: sandbox/ballas/refactorization/internal/piter_base.hh --- sandbox/ballas/refactorization/internal/piter_base.hh (revision 1782) +++ sandbox/ballas/refactorization/internal/piter_base.hh (working copy) @@ -2,6 +2,8 @@ # define INTERNAL_PITER_BASE_HH_ # include <concept.hh> +# include <point2d_impl.hh> + # include <exact.hh> # include <metal/bool.hh> # include <metal/equal.hh> @@ -13,40 +15,39 @@ { /// fwd declaration - template <typename E, typename B> + template <typename E, typename Site, typename B> struct piter_base_site_cast; /// Psite = Site - template <typename E> - struct piter_base_site_cast<E, metal::true_> : public Piter<E> + template <typename E, typename Site> + struct piter_base_site_cast<E, Site, metal::true_> : public Piter<E> { }; /// Psite != site - template <typename E> - struct piter_base_site_cast<E, metal::false_> : public Piter<E> + template <typename E, typename Site> + struct piter_base_site_cast<E, Site, metal::false_> : public Piter<E> { - operator typename E::site() const; + operator Site() const; }; /// Piter base template <typename E, typename Site, typename Psite> struct piter_base_ : - public piter_base_site_cast<E, - typename mlc_equal(Site, - Psite)::eval> + public impl<Site>, + public piter_base_site_cast<E, Site, + typename mlc_equal(Site, Psite)::eval> { operator Psite () const; protected: piter_base_(); - }; # ifndef MLN_INCLUDE_ONLY - template <typename E> - piter_base_site_cast<E, metal::false_>::operator typename E::site () const + template <typename E, typename Site> + piter_base_site_cast<E, Site, metal::false_>::operator Site () const { return exact(this)->to_site(); } @@ -55,7 +56,7 @@ template <typename E, typename Site, typename Psite> piter_base_<E, Site, Psite>::operator Psite () const { - return exact(this)->to_site(); + return exact(this)->to_psite(); } Index: sandbox/ballas/refactorization/internal/psite_base.hh --- sandbox/ballas/refactorization/internal/psite_base.hh (revision 1782) +++ sandbox/ballas/refactorization/internal/psite_base.hh (working copy) @@ -9,26 +9,26 @@ namespace internal { - template <typename E> - struct psite_base : public Psite<E>, - public impl<typename E::site> + template <typename E, typename P> + struct psite_base_ : public Psite<E>, + public impl<P> { - operator typename E::psite () const; + operator E() const; protected: - psite_base(); + psite_base_(); }; # ifndef MLN_INCLUDE_ONLY - template <typename E> - psite_base<E>::operator typename E::psite () const + template <typename E, typename P> + psite_base_<E, P>::operator E() const { - return exact(this)->to_site(); + return exact(this)->to_psite(); } - template <typename E> - psite_base<E>::psite_base() + template <typename E, typename P> + psite_base_<E, P>::psite_base_() { } Index: sandbox/ballas/refactorization/box2d.hh --- sandbox/ballas/refactorization/box2d.hh (revision 1782) +++ sandbox/ballas/refactorization/box2d.hh (working copy) @@ -36,7 +36,7 @@ box2d(); box2d(const site& pmin, const site& pmax); - bool has(const site& p) const; + bool owns_(const site& p) const; protected: point2d<C> pmin_, pmax_; @@ -98,7 +98,7 @@ template <typename C> inline bool - box2d<C>::has(const site& p) const + box2d<C>::owns_(const site& p) const { for (unsigned i = 0; i < C::dim; ++i) if (p[i] < pmin_[i] || p[i] > pmax_[i]) Index: sandbox/ballas/refactorization/point2d.hh --- sandbox/ballas/refactorization/point2d.hh (revision 1782) +++ sandbox/ballas/refactorization/point2d.hh (working copy) @@ -38,6 +38,7 @@ enum { dim = 2 }; typedef dpoint2d<C> dpoint; + typedef point2d<C> site; typedef C coord; @@ -51,6 +52,7 @@ point2d<C>& operator+=(const dpoint& dp); point2d<C>& operator-=(const dpoint& dp); + point2d<C>& operator=(const point2d<C>& p); protected: std::vector<C> coord_; @@ -189,6 +191,17 @@ } template <typename C> + inline + point2d<C>& + point2d<C>::operator=(const point2d<C>& p) + { + if (&p != this) + for (unsigned i = 0; i < dim; ++i) + this->coord_[i] = p.coord_[i]; + return *this; + } + + template <typename C> std::ostream& operator<<(std::ostream& ostr, const point2d<C>& p) { return ostr << "(" << p[0] << "," << p[1] << ")";
16Â years, 10Â months
1
0
0
0
scool r53: Add tests and refs
by Maxime van Noppen
URL:
https://svn.lrde.epita.fr/svn/scool/trunk
ChangeLog: 2008-03-13 Maxime van Noppen <yabo(a)lrde.epita.fr> Add tests and refs * input/concept_1.scl: New. * input/sample_5.scl: New. * parser/sample_5.ref: New. * parser/sample_container.ref: New. * parser/var_decl_7.ref: New. * transformer/class_dec.ref: New. * transformer/consinit.ref: New. * transformer/funcall.ref: New. * transformer/funcall_no-args.ref: New. * transformer/function.ref: New. * transformer/function_call_1.ref: New. * transformer/function_call_2.ref: New. * transformer/function_decl_2.ref: New. * transformer/fundec.ref: New. * transformer/guard.ref: New. * transformer/manydec.ref: New. * transformer/sample_5.ref: New. * transformer/sample_container.ref: New. * transformer/vardec.ref: New. * transformer/varinit.ref: New. * transformer/wiki1.ref: New. * transformer/wiki3.ref: New. input/concept_1.scl | 6 ++++++ input/sample_5.scl | 4 ++++ parser/sample_5.ref | 1 + parser/sample_container.ref | 1 + parser/var_decl_7.ref | 1 + transformer/class_dec.ref | 15 +++++++++++++++ transformer/consinit.ref | 1 + transformer/funcall.ref | 4 ++++ transformer/funcall_no-args.ref | 4 ++++ transformer/function.ref | 4 ++++ transformer/function_call_1.ref | 4 ++++ transformer/function_call_2.ref | 4 ++++ transformer/function_decl_2.ref | 4 ++++ transformer/fundec.ref | 3 +++ transformer/guard.ref | 4 ++++ transformer/manydec.ref | 3 +++ transformer/sample_5.ref | 4 ++++ transformer/sample_container.ref | 19 +++++++++++++++++++ transformer/vardec.ref | 1 + transformer/varinit.ref | 1 + transformer/wiki1.ref | 7 +++++++ transformer/wiki3.ref | 8 ++++++++ 22 files changed, 103 insertions(+) Index: trunk/tests/input/sample_5.scl =================================================================== --- trunk/tests/input/sample_5.scl (revision 0) +++ trunk/tests/input/sample_5.scl (revision 53) @@ -0,0 +1,4 @@ +sqrt : (arg : float) -> float = +{ + -> |[ std::sqrt(arg); ]|; +} Index: trunk/tests/input/concept_1.scl =================================================================== --- trunk/tests/input/concept_1.scl (revision 0) +++ trunk/tests/input/concept_1.scl (revision 53) @@ -0,0 +1,6 @@ +box : concept = +{ + value : type; + + decl get_value : () -> value; +} Index: trunk/tests/transformer/sample_5.ref =================================================================== --- trunk/tests/transformer/sample_5.ref (revision 0) +++ trunk/tests/transformer/sample_5.ref (revision 53) @@ -0,0 +1,4 @@ +float sqrt(float arg) +{ + return std::sqrt(arg); +} Index: trunk/tests/transformer/funcall_no-args.ref =================================================================== --- trunk/tests/transformer/funcall_no-args.ref (revision 0) +++ trunk/tests/transformer/funcall_no-args.ref (revision 53) @@ -0,0 +1,4 @@ +int doit() +{ + return foo(); +} Index: trunk/tests/transformer/class_dec.ref =================================================================== --- trunk/tests/transformer/class_dec.ref (revision 0) +++ trunk/tests/transformer/class_dec.ref (revision 53) @@ -0,0 +1,15 @@ +// Class point + +template < typename E > +class point +{ + public: + int x() + { + return x; + } + + private: + int x; + int y; +}; Index: trunk/tests/transformer/manydec.ref =================================================================== --- trunk/tests/transformer/manydec.ref (revision 0) +++ trunk/tests/transformer/manydec.ref (revision 53) @@ -0,0 +1,3 @@ +const int answer = 42; +int i; +int j = i; Index: trunk/tests/transformer/function.ref =================================================================== --- trunk/tests/transformer/function.ref (revision 0) +++ trunk/tests/transformer/function.ref (revision 53) @@ -0,0 +1,4 @@ +int answer() +{ + return 42; +} Index: trunk/tests/transformer/consinit.ref =================================================================== --- trunk/tests/transformer/consinit.ref (revision 0) +++ trunk/tests/transformer/consinit.ref (revision 53) @@ -0,0 +1 @@ +const int i = 3; Index: trunk/tests/transformer/function_decl_2.ref =================================================================== --- trunk/tests/transformer/function_decl_2.ref (revision 0) +++ trunk/tests/transformer/function_decl_2.ref (revision 53) @@ -0,0 +1,4 @@ +template < int i > +int f() +{ +} Index: trunk/tests/transformer/function_call_1.ref =================================================================== --- trunk/tests/transformer/function_call_1.ref (revision 0) +++ trunk/tests/transformer/function_call_1.ref (revision 53) @@ -0,0 +1,4 @@ +int doit() +{ + return foo(); +} Index: trunk/tests/transformer/function_call_2.ref =================================================================== --- trunk/tests/transformer/function_call_2.ref (revision 0) +++ trunk/tests/transformer/function_call_2.ref (revision 53) @@ -0,0 +1,4 @@ +int doit() +{ + return foo(bar, baz); +} Index: trunk/tests/transformer/fundec.ref =================================================================== --- trunk/tests/transformer/fundec.ref (revision 0) +++ trunk/tests/transformer/fundec.ref (revision 53) @@ -0,0 +1,3 @@ +bool f(int a, int b) +{ +} Index: trunk/tests/transformer/vardec.ref =================================================================== --- trunk/tests/transformer/vardec.ref (revision 0) +++ trunk/tests/transformer/vardec.ref (revision 53) @@ -0,0 +1 @@ +int i; Index: trunk/tests/transformer/varinit.ref =================================================================== --- trunk/tests/transformer/varinit.ref (revision 0) +++ trunk/tests/transformer/varinit.ref (revision 53) @@ -0,0 +1 @@ +int i = 42; Index: trunk/tests/transformer/sample_container.ref =================================================================== --- trunk/tests/transformer/sample_container.ref (revision 0) +++ trunk/tests/transformer/sample_container.ref (revision 53) @@ -0,0 +1,19 @@ +// Class Container + +template < typename E > +class Container +{ + public: + type value_type; + type iterator; + type const_iterator; + type reference; + type const_reference; + type size_type; + iterator begin(); + const_iterator begin(); + iterator end(); + const_iterator end(); + size_type size(); + bool empty(); +}; Index: trunk/tests/transformer/funcall.ref =================================================================== --- trunk/tests/transformer/funcall.ref (revision 0) +++ trunk/tests/transformer/funcall.ref (revision 53) @@ -0,0 +1,4 @@ +int doit() +{ + return foo(bar, baz); +} Index: trunk/tests/transformer/wiki1.ref =================================================================== --- trunk/tests/transformer/wiki1.ref (revision 0) +++ trunk/tests/transformer/wiki1.ref (revision 53) @@ -0,0 +1,7 @@ +void f() +{ + const int16 i = 3; + i = 4; + int16 j = 3; + j = 4; +} Index: trunk/tests/transformer/wiki3.ref =================================================================== --- trunk/tests/transformer/wiki3.ref (revision 0) +++ trunk/tests/transformer/wiki3.ref (revision 53) @@ -0,0 +1,8 @@ +void f() +{ + int i; + int j; + i = 0; + j = i; + i = j + i; +} Index: trunk/tests/transformer/guard.ref =================================================================== --- trunk/tests/transformer/guard.ref (revision 0) +++ trunk/tests/transformer/guard.ref (revision 53) @@ -0,0 +1,4 @@ +template < int i > +int f() +{ +} Index: trunk/tests/parser/sample_5.ref =================================================================== --- trunk/tests/parser/sample_5.ref (revision 0) +++ trunk/tests/parser/sample_5.ref (revision 53) @@ -0,0 +1 @@ +Program([FunDec([],"sqrt",[("arg",Var("float"))],Var("float"),[Return(Cxx("std::sqrt(arg);"))])]) Index: trunk/tests/parser/var_decl_7.ref =================================================================== --- trunk/tests/parser/var_decl_7.ref (revision 0) +++ trunk/tests/parser/var_decl_7.ref (revision 53) @@ -0,0 +1 @@ +Program([VarDec([],"a",StaticFunCall("test",[Var("int")]))]) Index: trunk/tests/parser/sample_container.ref =================================================================== --- trunk/tests/parser/sample_container.ref (revision 0) +++ trunk/tests/parser/sample_container.ref (revision 53) @@ -0,0 +1 @@ +Program([ConstDec([],"Container",Class,ClassVal([Accessblock(Public,[ConstDec([],"value_type",None,Var("type")),ConstDec([],"iterator",None,Var("type")),ConstDec([],"const_iterator",None,Var("type")),ConstDec([],"reference",None,Var("type")),ConstDec([],"const_reference",None,Var("type")),ConstDec([],"size_type",None,Var("type")),ConstDec(["decl"],"begin",None,FunType([],Var("iterator"))),ConstDec(["decl"],"begin",Some("const"),FunType([],Var("const_iterator"))),ConstDec(["decl"],"end",None,FunType([],Var("iterator"))),ConstDec(["decl"],"end",Some("const"),FunType([],Var("const_iterator"))),ConstDec(["decl"],"size",Some("const"),FunType([],Var("size_type"))),ConstDec(["decl"],"empty",Some("const"),FunType([],Var("bool")))])]))]) -- \__/ \__/ (00) Maxime `yabo` van Noppen (00) ___) \ Epita 2009 / (___ (_____/ Président de Prologin \_____)
16Â years, 10Â months
2
1
0
0
scool r54: Start work on concepts
by Maxime van Noppen
URL:
https://svn.lrde.epita.fr/svn/scool/trunk
ChangeLog: 2008-03-13 Maxime van Noppen <yabo(a)lrde.epita.fr> Start work on concepts * scl-syn/Concept.sdf: New. * scl-syn/Decl.sdf, * scl-syn/Lexical.sdf, * scl-syn/Makefile.am: Modify grammar to parse concepts. Concept.sdf | 9 +++++++++ Decl.sdf | 3 ++- Lexical.sdf | 1 + Makefile.am | 2 +- 4 files changed, 13 insertions(+), 2 deletions(-) Index: trunk/src/scl-syn/Decl.sdf =================================================================== --- trunk/src/scl-syn/Decl.sdf (revision 53) +++ trunk/src/scl-syn/Decl.sdf (revision 54) @@ -1,7 +1,7 @@ module Decl imports - Lexical Type Stm + Lexical Type Stm Concept exports sorts Decl @@ -9,6 +9,7 @@ Cxx -> Decl + Concept -> Decl Qualifier* "var" Id ":" Type ";" -> Decl {cons("VarDec")} Index: trunk/src/scl-syn/Concept.sdf =================================================================== --- trunk/src/scl-syn/Concept.sdf (revision 0) +++ trunk/src/scl-syn/Concept.sdf (revision 54) @@ -0,0 +1,9 @@ +module Concept + +imports + Lexical Decl + +exports + sorts Concept + context-free syntax + Id ":" "concept" "=" "{" Decl* "}" -> Concept {cons("Concept")} Index: trunk/src/scl-syn/Makefile.am =================================================================== --- trunk/src/scl-syn/Makefile.am (revision 53) +++ trunk/src/scl-syn/Makefile.am (revision 54) @@ -1,7 +1,7 @@ # Makefile.am -*-Makefile-*- MODULES = Scool -SDFS = Class Decl Exp ExpOrType Lexical Scool Stm Type +SDFS = Class Concept Decl Exp ExpOrType Lexical Scool Stm Type include $(top_srcdir)/config/Makefile.xt -include $(MODULES:=.dep) Index: trunk/src/scl-syn/Lexical.sdf =================================================================== --- trunk/src/scl-syn/Lexical.sdf (revision 53) +++ trunk/src/scl-syn/Lexical.sdf (revision 54) @@ -16,6 +16,7 @@ [\ \t\n] -> LAYOUT ~[\ ]~[\]\|]*~[\ ] -> RawCxx "class" -> Id {reject} + "concept" -> Id {reject} BlockComment -> LAYOUT -- \__/ \__/ (00) Maxime `yabo` van Noppen (00) ___) \ Epita 2009 / (___ (_____/ Président de Prologin \_____)
16Â years, 10Â months
1
0
0
0
scool r52: Improve verbatim C++ handling
by Maxime van Noppen
URL:
https://svn.lrde.epita.fr/svn/scool/trunk
ChangeLog: 2008-03-12 Maxime van Noppen <yabo(a)lrde.epita.fr> Improve verbatim C++ handling * pp-cxx/CxxExp.str: Handle more Cxx constructors. * pp-cxx/CxxStm.str: Fix the double semicolon problem when inserting verbatim C++. * pp-cxx/CxxDecl.str: Remove a FIXME comment. * scoolt/Exp.str: Improve verbatim C++ handling. pp-cxx/CxxDecl.str | 2 -- pp-cxx/CxxExp.str | 33 +++++++++++++++++++++------------ pp-cxx/CxxStm.str | 12 +++++++++++- scoolt/Decl.str | 1 + scoolt/Exp.str | 10 +++++++++- 5 files changed, 42 insertions(+), 16 deletions(-) Index: trunk/src/pp-cxx/CxxFun.str =================================================================== Index: trunk/src/pp-cxx/CxxExp.str =================================================================== --- trunk/src/pp-cxx/CxxExp.str (revision 51) +++ trunk/src/pp-cxx/CxxExp.str (revision 52) @@ -4,8 +4,14 @@ rules - CxxExpToAbox: - CxxInt(i) -> S(i) + CxxArgListToStr: + [ e | [h|tail] ] -> <concat-strings> [ e, ", ", <CxxArgListToStr> [h|tail] ] + + CxxArgListToStr: + [e | []] -> e + + CxxArgListToStr: + [] -> "" CxxExpToStr: CxxInt(i) -> i @@ -14,18 +20,21 @@ CxxSum(e1, e2) -> <concat-strings> [<CxxExpToStr> e1, " + ", <CxxExpToStr> e2] CxxExpToStr: + CxxKeyword(idf, exp) -> <concat-strings> [idf, " ", <CxxExpToStr> exp] + + CxxExpToStr: + CxxAffect(idf, exp) -> <concat-strings> [idf, " = ", <CxxExpToStr> exp] + + CxxExpToStr: + CxxFunCall(idf, args) -> <concat-strings> [ idf, "(", <CxxArgListToStr> args, ")" ] + + CxxExpToStr: + CxxProgram(exp) -> exp + + CxxExpToStr: x -> x where <is-string> x - /* - * Handle the CxxKeyword ctor. - * TODO: Generalize the type of exp. - */ CxxExpToAbox: - CxxKeyword(idf, exp) -> S(<concat-strings> [idf, " ", <CxxExpToStr> exp, ";"]) + x -> S(<CxxExpToStr> x) - CxxExpToAbox: - CxxAffect(idf, exp) -> S(<concat-strings> [idf, " = ", <CxxExpToStr> exp, ";"]) - - CxxExpToAbox: - x -> S(x) Index: trunk/src/pp-cxx/CxxStm.str =================================================================== --- trunk/src/pp-cxx/CxxStm.str (revision 51) +++ trunk/src/pp-cxx/CxxStm.str (revision 52) @@ -5,4 +5,14 @@ rules CxxStmToAbox: - CxxExpStm(e) -> <CxxExpToAbox> e + CxxExpStm(e) -> H hs=0 [ ~<CxxExpToAbox> e ~<Semicolon> e] + + // Don't add an extra ';' to verbatim C++ that we insert. + // As said on
https://trac.lrde.org/scool/wiki/SCOOL/Specs/Misc
the C++ inserted + // must be valid and so contain an ending ';' + Semicolon: + _#([_, CxxProgram(exp)]) -> S("") + + Semicolon: + _#([_, _]) -> S(";") + Index: trunk/src/pp-cxx/CxxDecl.str =================================================================== --- trunk/src/pp-cxx/CxxDecl.str (revision 51) +++ trunk/src/pp-cxx/CxxDecl.str (revision 52) @@ -45,8 +45,6 @@ CxxComment(txt) -> H hs=1 [ "//" ~S(txt) ] -// FIXME: MERGE!!! - CxxBodyToAbox: CxxPublic(b) -> V is=2 [ "public:" V [ ~*<map(CxxTopLevelToAbox)> b ] ] Index: trunk/src/scoolt/Exp.str =================================================================== --- trunk/src/scoolt/Exp.str (revision 51) +++ trunk/src/scoolt/Exp.str (revision 52) @@ -8,6 +8,9 @@ Int(i) -> CxxInt(i) ExpToCxx: + String(s) -> <un-double-quote> s + + ExpToCxx: Var(v) -> v ExpToCxx: @@ -18,4 +21,9 @@ where <debug> e ExpToCxx: - Cxx(s) -> s + Cxx(s) -> CxxProgram(s) + + ExpToCxx: + FunCall(name, args) -> CxxFunCall(name, <map (ExpToCxx)> args) + + Index: trunk/src/scoolt/Decl.str =================================================================== --- trunk/src/scoolt/Decl.str (revision 51) +++ trunk/src/scoolt/Decl.str (revision 52) @@ -197,6 +197,7 @@ ! (CxxType(t), idf) end> + ArgDefToCxx: (idf, t) -> (<TypeToConstRefCxx <+ TypeToCxx> t, idf) //(idf, t) -> (<TypeToCxx; try(CxxTypeToStc(|CxxType(p-idf)))> t, idf) -- \__/ \__/ (00) Maxime `yabo` van Noppen (00) ___) \ Epita 2009 / (___ (_____/ Président de Prologin \_____)
16Â years, 10Â months
1
0
0
0
scool r51: Update tests regarding to the Olena to Milena switch
by Maxime van Noppen
URL:
https://svn.lrde.epita.fr/svn/scool/trunk
ChangeLog: 2008-03-12 Maxime van Noppen <yabo(a)lrde.epita.fr> Update tests regarding to the Olena to Milena switch * mouline.sh: Add summary feature. * transformer/command: Exit with the good exit value. * transformer/class_decl_1.ref, * transformer/class_decl_2.ref, * transformer/class_decl_3.ref, * transformer/class_decl_inh.ref, * transformer/class_decl_inh_abst.ref, * transformer/class_decl_inh_fin.ref, * transformer/class_members_1.ref, * transformer/class_predecl.ref, * transformer/class_predecl_inh.ref, * transformer/class_template_1.ref, * transformer/class_template_2.ref, * transformer/cons_decl_1.ref, * transformer/cons_decl_2.ref, * transformer/empty.ref, * transformer/function_decl_1.ref, * transformer/function_decl_10.ref, * transformer/function_decl_3.ref, * transformer/function_decl_4.ref, * transformer/function_decl_5.ref, * transformer/function_decl_6.ref, * transformer/function_decl_7.ref, * transformer/function_decl_8.ref, * transformer/function_decl_9.ref, * transformer/function_return_1.ref, * transformer/function_return_2.ref, * transformer/function_return_3.ref, * transformer/sample_1.ref, * transformer/sample_3.ref, * transformer/sample_4.ref, * transformer/var_decl_1.ref, * transformer/var_decl_2.ref, * transformer/var_decl_3.ref, * transformer/var_decl_5.ref, * transformer/var_decl_6.ref: Update ref. mouline.sh | 28 +++++++++++++++++++++++++++- transformer/class_decl_1.ref | 9 ++------- transformer/class_decl_2.ref | 9 ++------- transformer/class_decl_3.ref | 9 ++------- transformer/class_decl_inh.ref | 15 ++++----------- transformer/class_decl_inh_abst.ref | 13 ++++--------- transformer/class_decl_inh_fin.ref | 19 +++++-------------- transformer/class_members_1.ref | 9 ++------- transformer/class_predecl.ref | 5 +---- transformer/class_predecl_inh.ref | 3 --- transformer/class_template_1.ref | 3 --- transformer/class_template_2.ref | 3 --- transformer/command | 25 +++++++++++++++++++------ transformer/cons_decl_1.ref | 3 --- transformer/cons_decl_2.ref | 3 --- transformer/empty.ref | 3 +-- transformer/function_decl_1.ref | 3 --- transformer/function_decl_10.ref | 3 --- transformer/function_decl_3.ref | 3 --- transformer/function_decl_4.ref | 3 --- transformer/function_decl_5.ref | 3 --- transformer/function_decl_6.ref | 3 --- transformer/function_decl_7.ref | 3 --- transformer/function_decl_8.ref | 3 --- transformer/function_decl_9.ref | 3 --- transformer/function_return_1.ref | 3 --- transformer/function_return_2.ref | 3 --- transformer/function_return_3.ref | 3 --- transformer/sample_1.ref | 3 --- transformer/sample_3.ref | 3 --- transformer/sample_4.ref | 5 +---- transformer/var_decl_1.ref | 3 --- transformer/var_decl_2.ref | 3 --- transformer/var_decl_3.ref | 3 --- transformer/var_decl_5.ref | 3 --- transformer/var_decl_6.ref | 3 --- 36 files changed, 70 insertions(+), 151 deletions(-) Index: trunk/tests/mouline.sh =================================================================== --- trunk/tests/mouline.sh (revision 50) +++ trunk/tests/mouline.sh (revision 51) @@ -12,6 +12,10 @@ print_diff=0 gen_ref=0 +nb_pass=0 +nb_skip=0 +nb_fail=0 + align () { echo -e -n "\033[$1G" @@ -36,14 +40,25 @@ if [ $gen_ref -eq 1 ]; then $cmd $input > $ref + exit_val=$? + if [ $exit_val -ne 0 ]; then + echo -e "$bblue[$byell sk $bblue]" + nb_skip=$(($nb_skip + 1)) + rm $ref + else + echo -e "$bblue[$bgreen ok $bblue]" + nb_pass=$(($nb_pass + 1)) + fi else if [ -r $ref ]; then cmd_log=`$cmd $input 2> /dev/null` - diff_log=`printf "%s\n" "$cmd_log" | diff -u $ref -` + diff_log=`printf "%s\n" "$cmd_log" | diff -EwB -u $ref -` if [ "$diff_log" = "" ]; then echo -e "$bblue[$bgreen ok $bblue]" + nb_pass=$(($nb_pass + 1)) else echo -e "$bblue[$bred ko $bblue]" + nb_fail=$(($nb_fail + 1)) if [ $print_diff -eq 1 ]; then echo -e -n $red echo "$diff_log" @@ -53,6 +68,7 @@ else echo -e "$bblue[$byell sk $bblue]" echo -e -n $red + nb_skip=$(($nb_skip + 1)) fi fi } @@ -112,3 +128,13 @@ done fi done + +echo +echo -e $bblue "Summary :" +echo -e $bgreen " - Passed : " $nb_pass +echo -e $byell " - Skiped : " $nb_skip +if [ $gen_ref -ne 1 ]; then + echo -e $bred " - Failed : " $nb_fail +fi +echo -e $bblue " ---------------" +echo -e $bblue " Total : " $(($nb_pass + $nb_skip + $nb_fail)) Index: trunk/tests/transformer/sample_4.ref =================================================================== --- trunk/tests/transformer/sample_4.ref (revision 50) +++ trunk/tests/transformer/sample_4.ref (revision 51) @@ -1,7 +1,4 @@ -#include <stc/any.hh> -#include <stc/find_exact.hh> - float sqrt(float arg) { - return std::sqrt(arg); + return std::sqrt(arg) } Index: trunk/tests/transformer/function_return_1.ref =================================================================== --- trunk/tests/transformer/function_return_1.ref (revision 50) +++ trunk/tests/transformer/function_return_1.ref (revision 51) @@ -1,6 +1,3 @@ -#include <stc/any.hh> -#include <stc/find_exact.hh> - int answer() { return 42; Index: trunk/tests/transformer/function_return_2.ref =================================================================== --- trunk/tests/transformer/function_return_2.ref (revision 50) +++ trunk/tests/transformer/function_return_2.ref (revision 51) @@ -1,6 +1,3 @@ -#include <stc/any.hh> -#include <stc/find_exact.hh> - int answer(int a, bool b) { return 42; Index: trunk/tests/transformer/function_return_3.ref =================================================================== --- trunk/tests/transformer/function_return_3.ref (revision 50) +++ trunk/tests/transformer/function_return_3.ref (revision 51) @@ -1,6 +1,3 @@ -#include <stc/any.hh> -#include <stc/find_exact.hh> - int answer() { return 42; Index: trunk/tests/transformer/cons_decl_1.ref =================================================================== --- trunk/tests/transformer/cons_decl_1.ref (revision 50) +++ trunk/tests/transformer/cons_decl_1.ref (revision 51) @@ -1,4 +1 @@ -#include <stc/any.hh> -#include <stc/find_exact.hh> - const int i; Index: trunk/tests/transformer/cons_decl_2.ref =================================================================== --- trunk/tests/transformer/cons_decl_2.ref (revision 50) +++ trunk/tests/transformer/cons_decl_2.ref (revision 51) @@ -1,4 +1 @@ -#include <stc/any.hh> -#include <stc/find_exact.hh> - const int i = 3; Index: trunk/tests/transformer/class_decl_1.ref =================================================================== --- trunk/tests/transformer/class_decl_1.ref (revision 50) +++ trunk/tests/transformer/class_decl_1.ref (revision 51) @@ -1,11 +1,6 @@ -#include <stc/any.hh> -#include <stc/find_exact.hh> - // Class Foo -template < typename T > -class Foo_: public stc::any<stc_find_exact(Foo_, T)> +template < typename E > +class Foo { }; - -typedef Foo_<stc::itself> Foo; Index: trunk/tests/transformer/class_decl_2.ref =================================================================== --- trunk/tests/transformer/class_decl_2.ref (revision 50) +++ trunk/tests/transformer/class_decl_2.ref (revision 51) @@ -1,10 +1,7 @@ -#include <stc/any.hh> -#include <stc/find_exact.hh> - // Class point -template < typename T > -class point_: public stc::any<stc_find_exact(point_, T)> +template < typename E > +class point { public: int x() @@ -16,5 +13,3 @@ int x; int y; }; - -typedef point_<stc::itself> point; Index: trunk/tests/transformer/class_decl_3.ref =================================================================== --- trunk/tests/transformer/class_decl_3.ref (revision 50) +++ trunk/tests/transformer/class_decl_3.ref (revision 51) @@ -1,10 +1,7 @@ -#include <stc/any.hh> -#include <stc/find_exact.hh> - // Class point -template < typename T > -class point_: public stc::any<stc_find_exact(point_, T)> +template < typename E > +class point { public: int x() @@ -16,5 +13,3 @@ int x; int y; }; - -typedef point_<stc::itself> point; Index: trunk/tests/transformer/class_template_1.ref =================================================================== --- trunk/tests/transformer/class_template_1.ref (revision 50) +++ trunk/tests/transformer/class_template_1.ref (revision 51) @@ -1,6 +1,3 @@ -#include <stc/any.hh> -#include <stc/find_exact.hh> - template < class T > class A { Index: trunk/tests/transformer/class_template_2.ref =================================================================== --- trunk/tests/transformer/class_template_2.ref (revision 50) +++ trunk/tests/transformer/class_template_2.ref (revision 51) @@ -1,6 +1,3 @@ -#include <stc/any.hh> -#include <stc/find_exact.hh> - template < class T, bool B > class A { Index: trunk/tests/transformer/class_decl_inh.ref =================================================================== --- trunk/tests/transformer/class_decl_inh.ref (revision 50) +++ trunk/tests/transformer/class_decl_inh.ref (revision 51) @@ -1,19 +1,12 @@ -#include <stc/any.hh> -#include <stc/find_exact.hh> - // Class Bar -template < typename T > -class Bar_: public stc::any<stc_find_exact(Bar_, T)> +template < typename E > +class Bar { }; - -typedef Bar_<stc::itself> Bar; // Class Foo -template < typename T > -class Foo_: public Bar_<stc_find_exact(Foo_, T)> +template < typename E > +class Foo: public Bar<E> { }; - -typedef Foo_<stc::itself> Foo; Index: trunk/tests/transformer/function_decl_1.ref =================================================================== --- trunk/tests/transformer/function_decl_1.ref (revision 50) +++ trunk/tests/transformer/function_decl_1.ref (revision 51) @@ -1,6 +1,3 @@ -#include <stc/any.hh> -#include <stc/find_exact.hh> - bool f(int a, int b) { } Index: trunk/tests/transformer/function_decl_3.ref =================================================================== --- trunk/tests/transformer/function_decl_3.ref (revision 50) +++ trunk/tests/transformer/function_decl_3.ref (revision 51) @@ -1,4 +1 @@ -#include <stc/any.hh> -#include <stc/find_exact.hh> - void foo(); Index: trunk/tests/transformer/empty.ref =================================================================== --- trunk/tests/transformer/empty.ref (revision 50) +++ trunk/tests/transformer/empty.ref (revision 51) @@ -1,2 +1 @@ -#include <stc/any.hh> -#include <stc/find_exact.hh> + Index: trunk/tests/transformer/var_decl_1.ref =================================================================== --- trunk/tests/transformer/var_decl_1.ref (revision 50) +++ trunk/tests/transformer/var_decl_1.ref (revision 51) @@ -1,4 +1 @@ -#include <stc/any.hh> -#include <stc/find_exact.hh> - int i; Index: trunk/tests/transformer/function_decl_4.ref =================================================================== --- trunk/tests/transformer/function_decl_4.ref (revision 50) +++ trunk/tests/transformer/function_decl_4.ref (revision 51) @@ -1,6 +1,3 @@ -#include <stc/any.hh> -#include <stc/find_exact.hh> - void foo(); float foo(int arg1); char foo(const toto& arg1, double& arg2); Index: trunk/tests/transformer/function_decl_5.ref =================================================================== --- trunk/tests/transformer/function_decl_5.ref (revision 50) +++ trunk/tests/transformer/function_decl_5.ref (revision 51) @@ -1,6 +1,3 @@ -#include <stc/any.hh> -#include <stc/find_exact.hh> - bool f(int a, int& b) { } Index: trunk/tests/transformer/var_decl_2.ref =================================================================== --- trunk/tests/transformer/var_decl_2.ref (revision 50) +++ trunk/tests/transformer/var_decl_2.ref (revision 51) @@ -1,4 +1 @@ -#include <stc/any.hh> -#include <stc/find_exact.hh> - int i = 42; Index: trunk/tests/transformer/function_decl_6.ref =================================================================== --- trunk/tests/transformer/function_decl_6.ref (revision 50) +++ trunk/tests/transformer/function_decl_6.ref (revision 51) @@ -1,6 +1,3 @@ -#include <stc/any.hh> -#include <stc/find_exact.hh> - template < class T > void f() { Index: trunk/tests/transformer/var_decl_3.ref =================================================================== --- trunk/tests/transformer/var_decl_3.ref (revision 50) +++ trunk/tests/transformer/var_decl_3.ref (revision 51) @@ -1,6 +1,3 @@ -#include <stc/any.hh> -#include <stc/find_exact.hh> - const int answer = 42; int i; int j = i; Index: trunk/tests/transformer/function_decl_7.ref =================================================================== --- trunk/tests/transformer/function_decl_7.ref (revision 50) +++ trunk/tests/transformer/function_decl_7.ref (revision 51) @@ -1,6 +1,3 @@ -#include <stc/any.hh> -#include <stc/find_exact.hh> - template < class T > void f(int a) { Index: trunk/tests/transformer/function_decl_8.ref =================================================================== --- trunk/tests/transformer/function_decl_8.ref (revision 50) +++ trunk/tests/transformer/function_decl_8.ref (revision 51) @@ -1,6 +1,3 @@ -#include <stc/any.hh> -#include <stc/find_exact.hh> - template < class T > void f(int a) { Index: trunk/tests/transformer/command =================================================================== --- trunk/tests/transformer/command (revision 50) +++ trunk/tests/transformer/command (revision 51) @@ -44,6 +44,7 @@ transformer="$base/scoolt/scoolt" printer="$base/pp-cxx/pp-cxx" cxxprinter="abox2text" +exitval=0 if [ $printsrc -eq 1 ]; then echo "----[ cat $1 ]----" @@ -55,31 +56,43 @@ then echo '----[' $parser ']----' tmp=`$parser` - if [ $? -ne 0 ]; then exit $?; fi + exit_val=$? + if [ $exit_val -ne 0 ]; then exit $exit_val; fi printf "%s\n" "$tmp" | pp-aterm echo echo '----[' $transformer ']----' tmp=`printf "%s\n" "$tmp" | $transformer` - if [ $? -ne 0 ]; then exit $?; fi + exit_val=$? + if [ $exit_val -ne 0 ]; then exit $exit_val; fi printf "%s\n" "$tmp" | pp-aterm echo echo '----[' $printer ']----' tmp=`printf "%s\n" "$tmp" | $printer` - if [ $? -ne 0 ]; then exit $?; fi + exit_val=$? + if [ $exit_val -ne 0 ]; then exit $exit_val; fi printf "%s\n" "$tmp" echo echo '---[' $cxxprinter ']----' tmp=`printf "%s\n" "$tmp" | $cxxprinter` - if [ $? -ne 0 ]; then exit $?; fi + exit_val=$? + if [ $exit_val -ne 0 ]; then exit $exit_val; fi printf "%s\n" "$tmp" echo else if [ $verb -eq 1 ]; then - printf "%s\n" "`$parser | $transformer | $printer | $cxxprinter`" + tmp=`$parser | $transformer | $printer | $cxxprinter` + exit_val=$? + if [ $exit_val -ne 0 ]; then exit $exit_val; fi + printf "%s\n" "$tmp" else - printf "%s\n" "`$parser 2> err-log | $transformer 2>> err-log | $printer 2>> err-log | $cxxprinter 2>> err-log`" + tmp=`$parser 2> err-log | $transformer 2>> err-log | $printer 2>> err-log | $cxxprinter 2>> err-log` + exit_val=$? + if [ $exit_val -ne 0 ]; then exit $exit_val; fi + printf "%s\n" "$tmp" fi fi + +exit $exitval Index: trunk/tests/transformer/var_decl_5.ref =================================================================== --- trunk/tests/transformer/var_decl_5.ref (revision 50) +++ trunk/tests/transformer/var_decl_5.ref (revision 51) @@ -1,4 +1 @@ -#include <stc/any.hh> -#include <stc/find_exact.hh> - int a[42]; Index: trunk/tests/transformer/function_decl_9.ref =================================================================== --- trunk/tests/transformer/function_decl_9.ref (revision 50) +++ trunk/tests/transformer/function_decl_9.ref (revision 51) @@ -1,6 +1,3 @@ -#include <stc/any.hh> -#include <stc/find_exact.hh> - template < class T > T f(const T& a) { Index: trunk/tests/transformer/var_decl_6.ref =================================================================== --- trunk/tests/transformer/var_decl_6.ref (revision 50) +++ trunk/tests/transformer/var_decl_6.ref (revision 51) @@ -1,4 +1 @@ -#include <stc/any.hh> -#include <stc/find_exact.hh> - std::vector<int> a; Index: trunk/tests/transformer/function_decl_10.ref =================================================================== --- trunk/tests/transformer/function_decl_10.ref (revision 50) +++ trunk/tests/transformer/function_decl_10.ref (revision 51) @@ -1,6 +1,3 @@ -#include <stc/any.hh> -#include <stc/find_exact.hh> - double f(int a, double b) { return a + b; Index: trunk/tests/transformer/class_decl_inh_fin.ref =================================================================== --- trunk/tests/transformer/class_decl_inh_fin.ref (revision 50) +++ trunk/tests/transformer/class_decl_inh_fin.ref (revision 51) @@ -1,26 +1,17 @@ -#include <stc/any.hh> -#include <stc/find_exact.hh> - // Class Animal -template < typename T > -class Animal_: public stc::any<stc_find_exact(Animal_, T)> +template < typename E > +class Animal { }; - -typedef Animal_<stc::itself> Animal; // Class Mammal -template < typename T > -class Mammal_: public Animal_<stc_find_exact(Mammal_, T)> +template < typename E > +class Mammal: public Animal<E> { }; - -typedef Mammal_<stc::itself> Mammal; // Class Monkey -class Monkey: public Mammal_<Monkey> +class Monkey: public Mammal<Monkey> { }; - -typedef Monkey_<stc::itself> Monkey; Index: trunk/tests/transformer/class_members_1.ref =================================================================== --- trunk/tests/transformer/class_members_1.ref (revision 50) +++ trunk/tests/transformer/class_members_1.ref (revision 51) @@ -1,13 +1,8 @@ -#include <stc/any.hh> -#include <stc/find_exact.hh> - // Class Student -template < typename T > -class Student_: public stc::any<stc_find_exact(Student_, T)> +template < typename E > +class Student { public: int money; }; - -typedef Student_<stc::itself> Student; Index: trunk/tests/transformer/sample_1.ref =================================================================== --- trunk/tests/transformer/sample_1.ref (revision 50) +++ trunk/tests/transformer/sample_1.ref (revision 51) @@ -1,6 +1,3 @@ -#include <stc/any.hh> -#include <stc/find_exact.hh> - void f() { const int16 i = 3; Index: trunk/tests/transformer/class_predecl_inh.ref =================================================================== --- trunk/tests/transformer/class_predecl_inh.ref (revision 50) +++ trunk/tests/transformer/class_predecl_inh.ref (revision 51) @@ -1,4 +1 @@ -#include <stc/any.hh> -#include <stc/find_exact.hh> - class Foo: public Bar; Index: trunk/tests/transformer/sample_3.ref =================================================================== --- trunk/tests/transformer/sample_3.ref (revision 50) +++ trunk/tests/transformer/sample_3.ref (revision 51) @@ -1,6 +1,3 @@ -#include <stc/any.hh> -#include <stc/find_exact.hh> - void f() { int i; Index: trunk/tests/transformer/class_decl_inh_abst.ref =================================================================== --- trunk/tests/transformer/class_decl_inh_abst.ref (revision 50) +++ trunk/tests/transformer/class_decl_inh_abst.ref (revision 51) @@ -1,17 +1,12 @@ -#include <stc/any.hh> -#include <stc/find_exact.hh> - // Class Animal -template < typename T > -class Animal_: public stc::any<stc_find_exact(Animal_, T)> +template < typename E > +class Animal { }; // Class Mammal -template < typename T > -class Mammal_: public Animal_<stc_find_exact(Mammal_, T)> +template < typename E > +class Mammal: public Animal<E> { }; - -typedef Mammal_<stc::itself> Mammal; Index: trunk/tests/transformer/class_predecl.ref =================================================================== --- trunk/tests/transformer/class_predecl.ref (revision 50) +++ trunk/tests/transformer/class_predecl.ref (revision 51) @@ -1,5 +1,2 @@ -#include <stc/any.hh> -#include <stc/find_exact.hh> - template < typename T > -class Foo_; +class Foo; -- \__/ \__/ (00) Maxime `yabo` van Noppen (00) ___) \ Epita 2009 / (___ (_____/ Président de Prologin \_____)
16Â years, 10Â months
1
0
0
0
← Newer
1
...
779
780
781
782
783
784
785
...
963
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
Results per page:
10
25
50
100
200