Created
March 12, 2014 08:24
-
-
Save sebsjoberg/9502907 to your computer and use it in GitHub Desktop.
Negative stride on slice produces wrong result
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <vexcl/vexcl.hpp> | |
#include <vector> | |
#include <algorithm> | |
int main() { | |
vex::Context ctx(vex::Filter::Env && vex::Filter::Count(1)); | |
std::cout << ctx << std::endl; | |
std::vector<float> v = { | |
0, 5, | |
1, 4, | |
2, 3, | |
3, 2, | |
4, 1, | |
5, 0, | |
}; | |
const std::size_t rows = 6; | |
const std::size_t cols = 2; | |
vex::vector<float> x(ctx, rows * cols); | |
vex::copy(v, x); | |
vex::vector<float> z(ctx, rows / 2 * cols); | |
vex::slicer<2> slice(vex::extents[rows][cols]); | |
std::copy(x.begin(), x.end(), std::ostream_iterator<float>(std::cout, " ")); | |
std::cout << std::endl; | |
z = slice[vex::range(5, -2, 0)][vex::range()](x); | |
std::copy(z.begin(), z.end(), std::ostream_iterator<float>(std::cout, " ")); | |
std::cout << std::endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment