1

I have a for-loop to do indexing:

for (int i=0; i<N; i++){
    a[i] = b[c[i]]
}

c are the indices of interest and are int *, while b and a are float * and the manipulated values.

But, this takes a long time (and it can't take that long). I'd like to have some vectorizing version, most likely found in BLAS/LAPLACK/etc.

I'm looking for nested_indexing(float * output_vector, float * input_vector, int * input_indices).

I've tried looking through the docs, but have not found anything.

2
  • What you need is a gather instruction - stackoverflow.com/questions/16193434/… . Not sure if there are supporting libs Commented Nov 5, 2013 at 23:02
  • Have you looked at ?lapmt and ?laswp from LAPACK? They do something similar (if you don't mind the fact that the matrix is permuted in-place, not copied.) Commented Nov 5, 2013 at 23:30

1 Answer 1

1

vDSP_vgathr does exactly this. It takes in two float *'s and one int *. It does the equivalent of for (i=0; i<N; i++) a[i] = b[c[i]].

The wording they used was

Uses elements of vector B as indices to copy selected elements of vector A to sequential locations in vector C

It could be sequential indexing too, perhaps. I've noticed that the hardest part about finding these obscure functions is finding the right words to use in your searches.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.