Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How to do point point look up in arrayfire's array? #342

Answered by 3togo
3togo asked this question in Q&A
Discussion options

Let say, I have a 3d array called f
mat = f(x,y,z)
I want to look up from a list of points (x0,y0,z0).....(xn,yn,zn);
by spliting it up into
arr_x = x0, x1, ....xn;
arr_y = y0, y1,....yn;
arr_z = z0, z1.... zn;

I want to get the output like
output = f(arr_x, arr_y, arr_z)

Since arr_x, arr_y, arr_z are random points, I have difficult to use "lookup", "locate", "view!", "index_gen", "assign_seq" to generate the "output" without converting the array "f" to a 1d array.

The following code will not work as of my expectation because view! will do a permutation mapping of xs and ys. It will expand the dimension of output instead of doing point to point lookup.

Thank in advance for your help.

Eli


use arrayfire::*;
fn main() {
 let (h, w, ch) = (4, 2, 3);
 let x = range::<i32>(dim4!(1, w), 1);
 let y = range::<i32>(dim4!(h), 0);
 let z = range::<i32>(dim4!(1, 1, ch), 2);
 let xs = tile(&x, dim4!(h));
 let ys = tile(&y, dim4!(1, w));
 let zs = tile(&z, dim4!(h, w, 1));
 af_print!("xs=", &xs);
 af_print!("ys=", &ys);
 af_print!("zs=", &zs);
 let out = view!(zs[xs, ys]);
 af_print!("out=", &out);
}
You must be logged in to vote

should use "approx1"

Replies: 1 comment

Comment options

should use "approx1"

You must be logged in to vote
0 replies
Answer selected by 3togo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /