[][src]Function arrayfire::index_gen

pub fn index_gen<T>(input: &Array<T>, indices: Indexer) -> Array<T> where
    T: HasAfEnum

Index an Array using any combination of Array's and Sequence's

Examples

use arrayfire::{Array, Dim4, Seq, print, randu, index_gen, Indexer};
let values: [f32; 3] = [1.0, 2.0, 3.0];
let indices = Array::new(&values, Dim4::new(&[3, 1, 1, 1]));
let seq4gen = Seq::new(0.0, 2.0, 1.0);
let a = randu::<f32>(Dim4::new(&[5, 3, 1, 1]));
// [5 3 1 1]
//     0.0000     0.2190     0.3835
//     0.1315     0.0470     0.5194
//     0.7556     0.6789     0.8310
//     0.4587     0.6793     0.0346
//     0.5328     0.9347     0.0535


let mut idxrs = Indexer::default();
idxrs.set_index(&indices, 0, None); // 2nd parameter is indexing dimension
idxrs.set_index(&seq4gen, 1, Some(false)); // 3rd parameter indicates batch operation

let sub2 = index_gen(&a, idxrs);
println!("a(indices, seq(0, 2, 1))"); print(&sub2);
// [3 3 1 1]
//     0.1315     0.0470     0.5194
//     0.7556     0.6789     0.8310
//     0.4587     0.6793     0.0346