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
pylene
Commits
125d1978
Commit
125d1978
authored
Feb 05, 2019
by
Edwin Carlinet
Browse files
Fix rows(...) to take only non-temporaries and fix algoithms.
parent
74c8b8cd
Changes
10
Hide whitespace changes
Inline
Side-by-side
pylene/include/mln/core/algorithm/accumulate.hpp
View file @
125d1978
...
@@ -66,7 +66,8 @@ namespace mln
...
@@ -66,7 +66,8 @@ namespace mln
static_assert
(
mln
::
is_a
<
InputImage
,
Image
>
());
static_assert
(
mln
::
is_a
<
InputImage
,
Image
>
());
auto
a
=
accu
::
make_accumulator
(
exact
(
accu
),
image_value_t
<
InputImage
>
());
auto
a
=
accu
::
make_accumulator
(
exact
(
accu
),
image_value_t
<
InputImage
>
());
for
(
auto
row
:
mln
::
ranges
::
rows
(
input
.
new_values
()))
auto
&&
vals
=
input
.
new_values
();
for
(
auto
row
:
mln
::
ranges
::
rows
(
vals
))
for
(
auto
&&
v
:
row
)
for
(
auto
&&
v
:
row
)
a
.
take
(
v
);
a
.
take
(
v
);
return
ex
(
a
);
return
ex
(
a
);
...
@@ -78,7 +79,8 @@ namespace mln
...
@@ -78,7 +79,8 @@ namespace mln
{
{
static_assert
(
mln
::
is_a
<
InputImage
,
Image
>
());
static_assert
(
mln
::
is_a
<
InputImage
,
Image
>
());
for
(
auto
row
:
mln
::
ranges
::
rows
(
input
.
new_values
()))
auto
&&
vals
=
input
.
new_values
();
for
(
auto
row
:
mln
::
ranges
::
rows
(
vals
))
for
(
auto
&&
v
:
row
)
for
(
auto
&&
v
:
row
)
init
=
op
(
init
,
v
);
init
=
op
(
init
,
v
);
...
...
pylene/include/mln/core/algorithm/any_of.hpp
View file @
125d1978
...
@@ -29,7 +29,8 @@ namespace mln
...
@@ -29,7 +29,8 @@ namespace mln
static_assert
(
mln
::
is_a
<
InputImage
,
Image
>
());
static_assert
(
mln
::
is_a
<
InputImage
,
Image
>
());
static_assert
(
::
ranges
::
Predicate
<
UnaryPredicate
,
image_reference_t
<
InputImage
>>
());
static_assert
(
::
ranges
::
Predicate
<
UnaryPredicate
,
image_reference_t
<
InputImage
>>
());
for
(
auto
r
:
ranges
::
rows
(
input
.
new_values
()))
auto
&&
vals
=
input
.
new_values
();
for
(
auto
r
:
ranges
::
rows
(
vals
))
if
(
::
ranges
::
any_of
(
r
,
p
))
if
(
::
ranges
::
any_of
(
r
,
p
))
return
true
;
return
true
;
return
false
;
return
false
;
...
@@ -41,7 +42,8 @@ namespace mln
...
@@ -41,7 +42,8 @@ namespace mln
static_assert
(
mln
::
is_a
<
InputImage
,
Image
>
());
static_assert
(
mln
::
is_a
<
InputImage
,
Image
>
());
static_assert
(
std
::
is_convertible_v
<
image_reference_t
<
InputImage
>
,
bool
>
);
static_assert
(
std
::
is_convertible_v
<
image_reference_t
<
InputImage
>
,
bool
>
);
for
(
auto
r
:
ranges
::
rows
(
input
.
new_values
()))
auto
&&
vals
=
input
.
new_values
();
for
(
auto
r
:
ranges
::
rows
(
vals
))
for
(
auto
&&
v
:
r
)
for
(
auto
&&
v
:
r
)
if
(
v
)
if
(
v
)
return
true
;
return
true
;
...
...
pylene/include/mln/core/algorithm/copy.hpp
View file @
125d1978
...
@@ -113,10 +113,10 @@ namespace mln
...
@@ -113,10 +113,10 @@ namespace mln
static_assert
(
mln
::
is_a
<
OutputImage
,
Image
>
());
static_assert
(
mln
::
is_a
<
OutputImage
,
Image
>
());
static_assert
(
std
::
is_convertible_v
<
image_value_t
<
InputImage
>
,
image_value_t
<
OutputImage
>>
);
static_assert
(
std
::
is_convertible_v
<
image_value_t
<
InputImage
>
,
image_value_t
<
OutputImage
>>
);
auto
input_rows
=
ranges
::
rows
(
input
.
new_values
()
)
;
auto
&&
ivals
=
input
.
new_values
();
auto
output_rows
=
ranges
::
rows
(
output
.
new_values
()
)
;
auto
&&
ovals
=
output
.
new_values
();
for
(
auto
[
r1
,
r2
]
:
ranges
::
view
::
zip
(
input_rows
,
output_rows
))
for
(
auto
[
r1
,
r2
]
:
ranges
::
view
::
zip
(
ranges
::
rows
(
ivals
),
ranges
::
rows
(
ovals
)
))
::
ranges
::
copy
(
r1
,
::
ranges
::
begin
(
r2
));
::
ranges
::
copy
(
r1
,
::
ranges
::
begin
(
r2
));
}
}
}
// namespace experimental
}
// namespace experimental
...
...
pylene/include/mln/core/algorithm/for_each.hpp
View file @
125d1978
...
@@ -29,7 +29,8 @@ namespace mln
...
@@ -29,7 +29,8 @@ namespace mln
static_assert
(
mln
::
is_a
<
InputImage
,
Image
>
());
static_assert
(
mln
::
is_a
<
InputImage
,
Image
>
());
static_assert
(
::
ranges
::
Invocable
<
UnaryFunction
,
image_reference_t
<
InputImage
>>
());
static_assert
(
::
ranges
::
Invocable
<
UnaryFunction
,
image_reference_t
<
InputImage
>>
());
for
(
auto
r
:
ranges
::
rows
(
input
.
new_values
()))
auto
&&
vals
=
input
.
new_values
();
for
(
auto
r
:
ranges
::
rows
(
vals
))
::
ranges
::
for_each
(
r
,
f
);
::
ranges
::
for_each
(
r
,
f
);
}
}
}
// namespace experimental
}
// namespace experimental
...
...
pylene/include/mln/core/algorithm/generate.hpp
View file @
125d1978
...
@@ -23,7 +23,8 @@ namespace mln
...
@@ -23,7 +23,8 @@ namespace mln
static_assert
(
mln
::
is_a
<
OutputImage
,
Image
>
());
static_assert
(
mln
::
is_a
<
OutputImage
,
Image
>
());
static_assert
(
std
::
is_convertible_v
<
std
::
invoke_result_t
<
Generator
>
,
image_value_t
<
OutputImage
>>
);
static_assert
(
std
::
is_convertible_v
<
std
::
invoke_result_t
<
Generator
>
,
image_value_t
<
OutputImage
>>
);
for
(
auto
row
:
mln
::
ranges
::
rows
(
output
.
new_values
()))
auto
&&
vals
=
output
.
new_values
();
for
(
auto
row
:
mln
::
ranges
::
rows
(
vals
))
for
(
auto
&
v
:
row
)
for
(
auto
&
v
:
row
)
v
=
g
();
v
=
g
();
}
}
...
...
pylene/include/mln/core/algorithm/iota.hpp
View file @
125d1978
...
@@ -73,7 +73,8 @@ namespace mln
...
@@ -73,7 +73,8 @@ namespace mln
static_assert
(
mln
::
is_a
<
OutputImage
,
Image
>
());
static_assert
(
mln
::
is_a
<
OutputImage
,
Image
>
());
static_assert
(
std
::
is_convertible_v
<
Value
,
image_value_t
<
OutputImage
>>
);
static_assert
(
std
::
is_convertible_v
<
Value
,
image_value_t
<
OutputImage
>>
);
for
(
auto
row
:
mln
::
ranges
::
rows
(
output
.
new_values
()))
auto
&&
vals
=
output
.
new_values
();
for
(
auto
row
:
mln
::
ranges
::
rows
(
vals
))
for
(
auto
&
v
:
row
)
for
(
auto
&
v
:
row
)
v
=
val
++
;
v
=
val
++
;
}
}
...
...
pylene/include/mln/core/algorithm/none_of.hpp
View file @
125d1978
...
@@ -29,7 +29,8 @@ namespace mln
...
@@ -29,7 +29,8 @@ namespace mln
static_assert
(
mln
::
is_a
<
InputImage
,
Image
>
());
static_assert
(
mln
::
is_a
<
InputImage
,
Image
>
());
static_assert
(
::
ranges
::
Predicate
<
UnaryPredicate
,
image_reference_t
<
InputImage
>>
());
static_assert
(
::
ranges
::
Predicate
<
UnaryPredicate
,
image_reference_t
<
InputImage
>>
());
for
(
auto
r
:
ranges
::
rows
(
input
.
new_values
()))
auto
&&
vals
=
input
.
new_values
();
for
(
auto
r
:
ranges
::
rows
(
vals
))
if
(
!::
ranges
::
none_of
(
r
,
p
))
if
(
!::
ranges
::
none_of
(
r
,
p
))
return
false
;
return
false
;
return
true
;
return
true
;
...
@@ -41,7 +42,8 @@ namespace mln
...
@@ -41,7 +42,8 @@ namespace mln
static_assert
(
mln
::
is_a
<
InputImage
,
Image
>
());
static_assert
(
mln
::
is_a
<
InputImage
,
Image
>
());
static_assert
(
std
::
is_convertible_v
<
image_reference_t
<
InputImage
>
,
bool
>
);
static_assert
(
std
::
is_convertible_v
<
image_reference_t
<
InputImage
>
,
bool
>
);
for
(
auto
r
:
ranges
::
rows
(
input
.
new_values
()))
auto
&&
vals
=
input
.
new_values
();
for
(
auto
r
:
ranges
::
rows
(
vals
))
for
(
auto
&&
v
:
r
)
for
(
auto
&&
v
:
r
)
if
(
v
)
if
(
v
)
return
false
;
return
false
;
...
...
pylene/include/mln/core/algorithm/paste.hpp
View file @
125d1978
...
@@ -82,10 +82,9 @@ namespace mln
...
@@ -82,10 +82,9 @@ namespace mln
static_assert
(
mln
::
is_a
<
OutputImage
,
Image
>
());
static_assert
(
mln
::
is_a
<
OutputImage
,
Image
>
());
static_assert
(
std
::
is_convertible_v
<
image_value_t
<
InputImage
>
,
image_value_t
<
OutputImage
>>
);
static_assert
(
std
::
is_convertible_v
<
image_value_t
<
InputImage
>
,
image_value_t
<
OutputImage
>>
);
auto
input_rows
=
ranges
::
rows
(
src
.
new_pixels
());
auto
&&
pixels
=
src
.
new_pixels
();
for
(
auto
row
:
ranges
::
rows
(
pixels
))
for
(
auto
r
:
input_rows
)
for
(
auto
px
:
row
)
for
(
auto
px
:
r
)
dest
(
px
.
point
())
=
px
.
val
();
dest
(
px
.
point
())
=
px
.
val
();
}
}
...
...
pylene/include/mln/core/algorithm/transform.hpp
View file @
125d1978
...
@@ -122,9 +122,9 @@ namespace mln
...
@@ -122,9 +122,9 @@ namespace mln
mln_entering
(
"mln::experimental::transform"
);
mln_entering
(
"mln::experimental::transform"
);
mln_precondition
(
in
.
domain
()
==
out
.
domain
());
mln_precondition
(
in
.
domain
()
==
out
.
domain
());
auto
input_rows
=
ranges
::
rows
(
in
.
new_values
()
)
;
auto
&&
ivals
=
in
.
new_values
();
auto
output_rows
=
ranges
::
rows
(
out
.
new_values
()
)
;
auto
&&
ovals
=
out
.
new_values
();
for
(
auto
[
r1
,
r2
]
:
ranges
::
view
::
zip
(
input_rows
,
output_rows
))
for
(
auto
[
r1
,
r2
]
:
ranges
::
view
::
zip
(
ranges
::
rows
(
ivals
),
ranges
::
rows
(
ovals
)
))
::
ranges
::
transform
(
r1
,
::
ranges
::
begin
(
r2
),
f
);
::
ranges
::
transform
(
r1
,
::
ranges
::
begin
(
r2
),
f
);
}
}
...
...
pylene/include/mln/core/rangev3/rows.hpp
View file @
125d1978
...
@@ -15,6 +15,7 @@ namespace mln::ranges
...
@@ -15,6 +15,7 @@ namespace mln::ranges
template
<
class
R
,
typename
=
std
::
enable_if_t
<
is_segmented_range_v
<
std
::
remove_reference_t
<
R
>
>>>
template
<
class
R
,
typename
=
std
::
enable_if_t
<
is_segmented_range_v
<
std
::
remove_reference_t
<
R
>
>>>
decltype
(
auto
)
rows
(
R
&&
rng
)
// decltype for perfect forwarding
decltype
(
auto
)
rows
(
R
&&
rng
)
// decltype for perfect forwarding
{
{
static_assert
(
std
::
is_lvalue_reference
<
R
>
(),
"Cannot apply on a temporary range."
);
return
rng
.
rows
();
return
rng
.
rows
();
}
}
...
...
Write
Preview
Markdown
is supported
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