Indirect indexing

Issue #388 resolved
Paul Jurczak created an issue

As far as I can tell, indirect indexing like in this Eigen v3.3.90 code snippet:

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

  cout << v << endl << v(i) << endl;

which produces:

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

is not available in Blaze. Is that accurate?

Comments (4)

  1. Klaus Iglberger

    Hi Paul!

    Blaze approaches the problem 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. Log in to comment