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_FUN_V2W_W2V_NORM_HH
00027 # define MLN_FUN_V2W_W2V_NORM_HH
00028 
00034 
00035 # include <mln/core/concept/function.hh>
00036 # include <mln/trait/value_.hh>
00037 
00038 # include <mln/norm/all.hh>
00039 
00040 
00041 namespace mln
00042 {
00043 
00044   namespace fun
00045   {
00046 
00047     namespace v2w_w2v
00048     {
00049 
00055       template <typename V, typename R>
00056       struct l1_norm : public Function_v2v< l1_norm<V, R> >
00057       {
00058         typedef R result;
00059         R operator()(const V& v) const;
00060         V f_1(const V& v, const R& r) const;
00061       };
00062 
00068       template <typename V, typename R>
00069       struct l2_norm : public Function_v2v< l2_norm<V, R> >
00070       {
00071         typedef R result;
00072         R operator()(const V& v) const;
00073         V f_1(const V& v, const R& r) const;
00074       };
00075 
00081       template <typename V, typename R>
00082       struct linfty_norm : public Function_v2v< linfty_norm<V, R> >
00083       {
00084         typedef R result;
00085         R operator()(const V& v) const;
00086         V f_1(const V& v, const R& r) const;
00087       };
00088 
00089 
00090 # ifndef MLN_INCLUDE_ONLY
00091 
00092       template <typename V, typename R>
00093       inline
00094       R
00095       l1_norm<V, R>::operator()(const V& v) const
00096       {
00097         return mln::norm::l1 (v);
00098       }
00099 
00100       template <typename V, typename R>
00101       inline
00102       V
00103       l1_norm<V, R>::f_1(const V& v, const R& r) const
00104       {
00105         return v / mln::norm::l1 (v) * r;
00106       }
00107 
00108       template <typename V, typename R>
00109       inline
00110       R
00111       l2_norm<V, R>::operator()(const V& v) const
00112       {
00113         return mln::norm::l2 (v);
00114       }
00115 
00116       template <typename V, typename R>
00117       inline
00118       V
00119       l2_norm<V, R>::f_1(const V& v, const R& r) const
00120       {
00121         return v / mln::norm::l2 (v) * r;
00122       }
00123 
00124       template <typename V, typename R>
00125       inline
00126       R
00127       linfty_norm<V, R>::operator()(const V& v) const
00128       {
00129         return mln::norm::linfty (v);
00130       }
00131 
00132       template <typename V, typename R>
00133       inline
00134       V
00135       linfty_norm<V, R>::f_1(const V& v, const R& r) const
00136       {
00137         return v / mln::norm::linfty (v) * r;
00138       }
00139 
00140 # endif // ! MLN_INCLUDE_ONLY
00141 
00142     } 
00143 
00144   } 
00145 
00146 } 
00147 
00148 
00149 #endif // ! MLN_FUN_V2W_W2V_NORM_HH