Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
xerus
xerus
Commits
60e6d230
Commit
60e6d230
authored
Jun 26, 2020
by
Philipp Trunschke
Browse files
replace std::inclusive_scan
parent
c66c205b
Pipeline
#2113
failed with stages
in 3 minutes and 59 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/xerus/applications/uqSALSA.cpp
View file @
60e6d230
...
...
@@ -31,6 +31,9 @@
#include
<numeric>
#define REVERSE_ACCESS(vector, index) vector[vector.size()-1-(index)]
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsuggest-override"
#pragma GCC diagnostic ignored "-Wold-style-cast"
...
...
@@ -82,13 +85,22 @@ namespace xerus { namespace uq {
std
::
vector
<
size_t
>
compute_max_theoretic_ranks
(
const
std
::
vector
<
size_t
>&
_dimensions
)
{
// np.minimum(np.cumprod(d[:-1]), np.cumprod(d[:0:-1])[::-1])
std
::
vector
<
size_t
>
cumprod_left
(
_dimensions
.
size
()
-
1
);
std
::
inclusive_scan
(
_dimensions
.
begin
(),
_dimensions
.
end
()
-
1
,
cumprod_left
.
begin
(),
std
::
multiplies
<>
{});
const
size_t
M
=
_dimensions
.
size
();
std
::
vector
<
size_t
>
cumprod_left
(
M
-
1
);
/* std::inclusive_scan(_dimensions.begin(), _dimensions.end()-1, */
/* cumprod_left.begin(), std::multiplies<>{}); */
cumprod_left
[
0
]
=
_dimensions
[
0
];
for
(
size_t
i
=
1
;
i
<
M
-
1
;
++
i
)
{
cumprod_left
[
i
]
=
cumprod_left
[
i
-
1
]
*
_dimensions
[
i
];
}
std
::
vector
<
size_t
>
cumprod_right
(
_dimensions
.
size
()
-
1
);
std
::
inclusive_scan
(
_dimensions
.
rbegin
(),
_dimensions
.
rend
()
-
1
,
cumprod_right
.
rbegin
(),
std
::
multiplies
<>
{});
std
::
vector
<
size_t
>
cumprod_right
(
M
-
1
);
/* std::inclusive_scan(_dimensions.rbegin(), _dimensions.rend()-1, */
/* cumprod_right.rbegin(), std::multiplies<>{}); */
REVERSE_ACCESS
(
cumprod_right
,
0
)
=
REVERSE_ACCESS
(
_dimensions
,
0
);
for
(
size_t
i
=
1
;
i
<
_dimensions
.
size
()
-
1
;
++
i
)
{
REVERSE_ACCESS
(
cumprod_right
,
i
)
=
REVERSE_ACCESS
(
cumprod_right
,
i
-
1
)
*
REVERSE_ACCESS
(
_dimensions
,
i
);
}
std
::
vector
<
size_t
>
ranks
;
std
::
transform
(
cumprod_left
.
begin
(),
cumprod_left
.
end
(),
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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