$extrastylesheet
Olena
User documentation 2.1
An Image Processing Platform
Milena
Getting started
API Reference Manual
All Classes
Examples
Demos
Publications
All
Classes
Namespaces
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
v2w_w2v/norm.hh
1
// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
2
//
3
// This file is part of Olena.
4
//
5
// Olena is free software: you can redistribute it and/or modify it under
6
// the terms of the GNU General Public License as published by the Free
7
// Software Foundation, version 2 of the License.
8
//
9
// Olena is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
// General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with Olena. If not, see <http://www.gnu.org/licenses/>.
16
//
17
// As a special exception, you may use this file as part of a free
18
// software project without restriction. Specifically, if other files
19
// instantiate templates or use macros or inline functions from this
20
// file, or you compile this file and link it with other files to produce
21
// an executable, this file does not by itself cause the resulting
22
// executable to be covered by the GNU General Public License. This
23
// exception does not however invalidate any other reasons why the
24
// executable file might be covered by the GNU General Public License.
25
26
#ifndef MLN_FUN_V2W_W2V_NORM_HH
27
# define MLN_FUN_V2W_W2V_NORM_HH
28
34
35
# include <mln/core/concept/function.hh>
36
# include <mln/trait/value_.hh>
37
38
# include <mln/norm/all.hh>
39
40
41
namespace
mln
42
{
43
44
namespace
fun
45
{
46
47
namespace
v2w_w2v
48
{
49
55
template
<
typename
V,
typename
R>
56
struct
l1_norm
:
public
Function_v2v
< l1_norm<V, R> >
57
{
58
typedef
R
result
;
59
R
operator()
(
const
V& v)
const
;
60
V
f_1
(
const
V& v,
const
R& r)
const
;
61
};
62
68
template
<
typename
V,
typename
R>
69
struct
l2_norm
:
public
Function_v2v
< l2_norm<V, R> >
70
{
71
typedef
R
result
;
72
R
operator()
(
const
V& v)
const
;
73
V
f_1
(
const
V& v,
const
R& r)
const
;
74
};
75
81
template
<
typename
V,
typename
R>
82
struct
linfty_norm
:
public
Function_v2v
< linfty_norm<V, R> >
83
{
84
typedef
R
result
;
85
R
operator()
(
const
V& v)
const
;
86
V
f_1
(
const
V& v,
const
R& r)
const
;
87
};
88
89
90
# ifndef MLN_INCLUDE_ONLY
91
92
template
<
typename
V,
typename
R>
93
inline
94
R
95
l1_norm<V, R>::operator()
(
const
V& v)
const
96
{
97
return
mln::norm::l1
(v);
98
}
99
100
template
<
typename
V,
typename
R>
101
inline
102
V
103
l1_norm<V, R>::f_1
(
const
V& v,
const
R& r)
const
104
{
105
return
v /
mln::norm::l1
(v) * r;
106
}
107
108
template
<
typename
V,
typename
R>
109
inline
110
R
111
l2_norm<V, R>::operator()
(
const
V& v)
const
112
{
113
return
mln::norm::l2
(v);
114
}
115
116
template
<
typename
V,
typename
R>
117
inline
118
V
119
l2_norm<V, R>::f_1
(
const
V& v,
const
R& r)
const
120
{
121
return
v /
mln::norm::l2
(v) * r;
122
}
123
124
template
<
typename
V,
typename
R>
125
inline
126
R
127
linfty_norm<V, R>::operator()
(
const
V& v)
const
128
{
129
return
mln::norm::linfty
(v);
130
}
131
132
template
<
typename
V,
typename
R>
133
inline
134
V
135
linfty_norm<V, R>::f_1
(
const
V& v,
const
R& r)
const
136
{
137
return
v /
mln::norm::linfty
(v) * r;
138
}
139
140
# endif // ! MLN_INCLUDE_ONLY
141
142
}
// end of namespace mln::fun::v2w_w2v
143
144
}
// end of namespace mln::fun
145
146
}
// end of namespace mln
147
148
149
#endif // ! MLN_FUN_V2W_W2V_NORM_HH
mln
fun
v2w_w2v
norm.hh
Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)