Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Olena
olena
Commits
9aa2edee
Commit
9aa2edee
authored
Nov 16, 2010
by
Guillaume Lazzara
Browse files
Improve dispatch in arith::revert routine.
* mln/arith/revert.hh, * mln/arith/revert.spe.hh: Add a standard dispatch.
parent
0ad1284d
Changes
3
Hide whitespace changes
Inline
Side-by-side
milena/ChangeLog
View file @
9aa2edee
2010-11-15 Guillaume Lazzara <z@lrde.epita.fr>
Improve dispatch in arith::revert routine.
* mln/arith/revert.hh,
* mln/arith/revert.spe.hh: Add a standard dispatch.
2010-11-15 Guillaume Lazzara <z@lrde.epita.fr>
* mln/data/paste_without_localization.hh: Remove duplicate
milena/mln/arith/revert.hh
View file @
9aa2edee
// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
// Copyright (C) 2007, 2008, 2009, 2010 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
//
...
...
@@ -40,7 +41,8 @@
// FIXME: Rely instead on mln/fun/v2v/revert.hh.
// FIXME: Revert on int value 0 does not give 0 (since min != - max; idem for float etc.)
// FIXME: Revert on int value 0 does not give 0 (since min != - max;
// idem for float etc.)
namespace
mln
...
...
@@ -88,10 +90,17 @@ namespace mln
template
<
typename
I
,
typename
O
>
inline
void
revert
_
(
const
I
&
input
,
O
&
output
)
void
revert
(
const
I
mage
<
I
>
&
input
_
,
Image
<
O
>
&
output
_
)
{
trace
::
entering
(
"arith::impl::generic::revert_"
);
const
I
&
input
=
exact
(
input_
);
O
&
output
=
exact
(
output_
);
mln_precondition
(
input
.
is_valid
());
mln_precondition
(
output
.
is_valid
());
mln_precondition
(
input
.
domain
()
==
output
.
domain
());
typedef
mln_value
(
I
)
V
;
mln_piter
(
I
)
p
(
input
.
domain
());
for_all
(
p
)
...
...
@@ -105,6 +114,43 @@ namespace mln
}
// end of namespace mln::arith::impl
// Dispatch.
namespace
internal
{
template
<
typename
I
,
typename
O
>
inline
void
revert_dispatch
(
trait
::
image
::
speed
::
any
,
const
I
&
input
,
O
&
output
)
{
impl
::
generic
::
revert
(
input
,
output
);
}
template
<
typename
I
,
typename
O
>
inline
void
revert_dispatch
(
trait
::
image
::
speed
::
fastest
,
const
I
&
input
,
O
&
output
)
{
impl
::
revert_fastest
(
input
,
output
);
}
template
<
typename
I
,
typename
O
>
inline
void
revert_dispatch
(
const
Image
<
I
>&
input
,
Image
<
O
>&
output
)
{
revert_dispatch
(
mln_trait_image_speed
(
I
)(),
exact
(
input
),
exact
(
output
));
}
}
// end of namespace mln::arith::internal
// Facades.
template
<
typename
I
>
...
...
@@ -117,7 +163,7 @@ namespace mln
mln_concrete
(
I
)
output
;
initialize
(
output
,
input
);
i
mp
l
::
revert_
(
mln_trait_image_speed
(
I
)(),
exact
(
input
),
output
);
i
nterna
l
::
revert_
dispatch
(
exact
(
input
),
exact
(
output
)
)
;
trace
::
exiting
(
"arith::revert"
);
return
output
;
...
...
@@ -131,7 +177,7 @@ namespace mln
mln_precondition
(
exact
(
input
).
is_valid
());
i
mp
l
::
revert_
(
mln_trait_image_speed
(
I
)(),
exact
(
input
),
exact
(
input
));
i
nterna
l
::
revert_
dispatch
(
exact
(
input
),
exact
(
input
));
trace
::
exiting
(
"arith::revert_inplace"
);
}
...
...
milena/mln/arith/revert.spe.hh
View file @
9aa2edee
// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
// Copyright (C) 2007, 2008, 2009, 2010 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
//
...
...
@@ -49,24 +50,19 @@ namespace mln
namespace
impl
{
namespace
generic
{
template
<
typename
I
,
typename
O
>
void
revert_
(
const
I
&
input
,
O
&
output
);
}
// FIXME: This is a fast implementation not a fastest one!
template
<
typename
I
,
typename
O
>
inline
void
revert_
(
trait
::
image
::
speed
::
any
,
const
I
&
input
,
O
&
output
)
void
revert_
fastest
(
const
Image
<
I
>
&
input
_
,
Image
<
O
>
&
output
_
)
{
generic
::
revert_
(
input
,
output
);
}
trace
::
entering
(
"arith::impl::revert_fastest"
);
template
<
typename
I
,
typename
O
>
inline
void
revert_
(
trait
::
image
::
speed
::
fastest
,
const
I
&
input
,
O
&
output
)
{
trace
::
entering
(
"arith::impl::revert_"
);
const
I
&
input
=
exact
(
input_
);
O
&
output
=
exact
(
output_
);
mln_precondition
(
input
.
is_valid
());
mln_precondition
(
output
.
is_valid
());
mln_precondition
(
input
.
domain
()
==
output
.
domain
());
typedef
mln_value
(
I
)
V
;
mln_pixter
(
const
I
)
ip
(
input
);
...
...
@@ -74,7 +70,7 @@ namespace mln
for_all_2
(
ip
,
op
)
op
.
val
()
=
mln_min
(
V
)
+
(
mln_max
(
V
)
-
ip
.
val
());
trace
::
entering
(
"arith::impl::revert_"
);
trace
::
entering
(
"arith::impl::revert_
fastest
"
);
}
}
// end of namespace mln::arith::impl
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment