-
Couldn't load subscription status.
- Fork 58
-
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);
}
Beta Was this translation helpful? Give feedback.
All reactions
should use "approx1"
Replies: 1 comment
-
should use "approx1"
Beta Was this translation helpful? Give feedback.