Indirect indexing (scatter/gather)

Issue #400 duplicate
Paul Jurczak created an issue

Both Eigen and Fastor libraries provide indirect indexing (scatter/gather) notation, e.g. in Eigen:

Array<int, 1, 9> v{0, 1, 2, 3, 4, 5, 6, 7, 8};
v({6, 3, 0}) = v({0, 4, 8});

I couldn’t find a similar feature in Blaze. It is useful for concise notation of stencils and convolutions among others. Additionally, there are efficient AVX scatter/gather instructions and this is a high level way to invoke them.

Comments (3)

  1. Klaus Iglberger

    Hi Paul!

    If I’m not mistaken you have asked the same question in issue #388. As also explained there, Blaze approaches this problem more generally by means of views, and in particular element selections:

    blaze::DynamicVector<int> a{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
    
    auto e = elements<6,3,0>( a );  // Select the elements 6, 3, and 0
    
    std::cout << a << '\n' << e << '\n';
    
    elements<1,2,3>( a ) = e;  // Assign to the elements 1, 2, and 3
    
    std::cout << a << '\n';
    

    Output:

    ( 0 1 2 3 4 5 6 7 8 )
    ( 6 3 0 )
    ( 0 6 3 0 4 5 6 7 8 )
    

    I hope this answers your question.

    Best regards,

    Klaus!

  2. Paul Jurczak reporter

    Hi Klaus,

    I’m sorry for asking the same question twice. I had a faint memory of asking a question before, but when I searched for “My issues” on this page, it returned no matches. I’ve been evaluating too many software libraries in recent months…

    Thank you,

    Paul

  3. Log in to comment