Search code examples
c++arrayfire

Best Way to order ArrayFire Array with Index-Array


What's the fastest way to order an Arrayfire array with an Index-Array? This is what i mean with normal arrays:

    std::array<int,3> A = {3,2,1};
    std::array<int,3> indices = {2,1,3};

    std::array<int,3> tempA = A;
    for (int i = 0; i < 3; i++)
    {
        A[i] = tempA[Indices[i]];
    }

Do I have to use gfor?


Solution

  • Much easier than I thought:

        af::array c = B(inds);
    

    from http://arrayfire.org/docs/indexing.htm