• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List

norm.hh

00001 // Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
00002 //
00003 // This file is part of Olena.
00004 //
00005 // Olena is free software: you can redistribute it and/or modify it under
00006 // the terms of the GNU General Public License as published by the Free
00007 // Software Foundation, version 2 of the License.
00008 //
00009 // Olena is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 // General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with Olena.  If not, see <http://www.gnu.org/licenses/>.
00016 //
00017 // As a special exception, you may use this file as part of a free
00018 // software project without restriction.  Specifically, if other files
00019 // instantiate templates or use macros or inline functions from this
00020 // file, or you compile this file and link it with other files to produce
00021 // an executable, this file does not by itself cause the resulting
00022 // executable to be covered by the GNU General Public License.  This
00023 // exception does not however invalidate any other reasons why the
00024 // executable file might be covered by the GNU General Public License.
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     } // end of namespace mln::fun::v2w_w2v
00143 
00144   } // end of namespace mln::fun
00145 
00146 } // end of namespace mln
00147 
00148 
00149 #endif // ! MLN_FUN_V2W_W2V_NORM_HH

Generated on Tue Oct 4 2011 15:24:07 for Milena (Olena) by  doxygen 1.7.1