Created
December 18, 2013 06:20
-
-
Save ddemidov/8018055 to your computer and use it in GitHub Desktop.
Two alternatives to vex::multivector
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
#define VEXCL_SHOW_KERNELS | |
#define USE_PERMUTATION | |
#include <vexcl/vexcl.hpp> | |
int main() { | |
vex::Context ctx(vex::Filter::Count(1)); | |
const size_t n = 5; | |
vex::vector<double> x(ctx, 3 * n); | |
auto X = vex::tag<0>(x); | |
#ifdef USE_PERMUTATION | |
auto idx = vex::tag<1>( vex::element_index(0, n) ); | |
auto N = vex::tag<2>( n ); | |
VEX_CONSTANT(two, 2); | |
auto x0 = vex::permutation(idx )(X); | |
auto x1 = vex::permutation(idx + N )(X); | |
auto x2 = vex::permutation(idx + N * two())(X); | |
#else | |
vex::slicer<2> slice( vex::extents[3][n] ); | |
auto x0 = slice[0](X); | |
auto x1 = slice[1](X); | |
auto x2 = slice[2](X); | |
#endif | |
// write individual components: | |
x0 = 1; | |
x1 = 2; | |
x2 = 3; | |
// Do the fused call: | |
vex::tie(x0, x1, x2) = std::tie(sin(x0), cos(x1), x1 - x0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment