00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef MLN_ACCU_MATH_INF_HH
00027 # define MLN_ACCU_MATH_INF_HH
00028
00032
00033 # include <mln/accu/internal/base.hh>
00034 # include <mln/core/concept/meta_accumulator.hh>
00035 # include <mln/trait/value_.hh>
00036 # include <mln/util/pix.hh>
00037 # include <mln/fun/math/inf.hh>
00038
00039 namespace mln
00040 {
00041
00042 namespace accu
00043 {
00044
00045 namespace math
00046 {
00047
00048
00054
00055 template <typename T>
00056 struct inf : public mln::accu::internal::base< const T&, inf<T> >
00057 {
00058 typedef T argument;
00059
00060 inf();
00061
00064 void init();
00065 void take_as_init_(const argument& t);
00066 void take(const argument& t);
00067 void take(const inf<T>& other);
00069
00071 const T& to_result() const;
00072
00075 bool is_valid() const;
00076
00077 protected:
00078
00079 T t_;
00080 typename mln::fun::inf::with<T, T>::ret fun_;
00081 };
00082
00083
00084 template <typename I> struct inf< util::pix<I> >;
00085
00086 }
00087
00088
00089 namespace meta
00090 {
00091
00092 namespace math
00093 {
00094
00096
00097 struct inf : public Meta_Accumulator< inf >
00098 {
00099 template <typename T>
00100 struct with
00101 {
00102 typedef accu::math::inf<T> ret;
00103 };
00104 };
00105
00106 }
00107
00108 }
00109
00110
00111 # ifndef MLN_INCLUDE_ONLY
00112
00113 namespace math
00114 {
00115
00116 template <typename T>
00117 inline
00118 inf<T>::inf()
00119 {
00120 init();
00121 }
00122
00123 template <typename T>
00124 inline
00125 void
00126 inf<T>::init()
00127 {
00128 t_ = mln_max(T);
00129 }
00130
00131 template <typename T>
00132 inline
00133 void inf<T>::take_as_init_(const argument& t)
00134 {
00135 t_ = t;
00136 }
00137
00138 template <typename T>
00139 inline
00140 void inf<T>::take(const argument& t)
00141 {
00142 this->t_ = this->fun_(t_, t);
00143 }
00144
00145 template <typename T>
00146 inline
00147 void
00148 inf<T>::take(const inf<T>& other)
00149 {
00150 this->t_ = this->fun_(t_, other.t_);
00151 }
00152
00153 template <typename T>
00154 inline
00155 const T&
00156 inf<T>::to_result() const
00157 {
00158 return t_;
00159 }
00160
00161 template <typename T>
00162 inline
00163 bool
00164 inf<T>::is_valid() const
00165 {
00166 return true;
00167 }
00168
00169 }
00170
00171 # endif // ! MLN_INCLUDE_ONLY
00172
00173 }
00174
00175 }
00176
00177
00178 #endif // ! MLN_ACCU_MATH_INF_HH