[][src]Function arrayfire::assign_gen

pub fn assign_gen<T>(lhs: &mut Array<T>, indices: &Indexer<'_>, rhs: &Array<T>) where
    T: HasAfEnum

Assign an Array to another after indexing it using any combination of Array's and Sequence's

Examples

use arrayfire::{Array, Dim4, Seq, print, randu, constant, Indexer, assign_gen};
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 mut 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 b    = constant(2.0 as f32, Dim4::new(&[3, 3, 1, 1]));

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

assign_gen(&mut a, &idxrs, &b);
println!("a(indices, seq(0, 2, 1))"); print(&a);
// [5 3 1 1]
//     0.0000     0.2190     0.3835
//     2.0000     2.0000     2.0000
//     2.0000     2.0000     2.0000
//     2.0000     2.0000     2.0000
//     0.5328     0.9347     0.0535