I am trying to modify a value in an existing Arrayfire Matrix with a custom value. Below is an example of changing several rows and columns to a specified value (1.0) However I am struggling no doing two things:
- Change the dimensions of the area to be changed (3x3) -> (2x2) instead.
- Move the area to be changed Horizontally or vertically. Any change I make seems to give an invalid index error.
use arrayfire::{constant, Dim4, Seq, assign_seq, print};
let a = constant(2.0 as f32, Dim4::new(&[5, 3, 1, 1]));
let b = constant(1.0 as f32, Dim4::new(&[3, 3, 1, 1]));
let seqs = &[Seq::new(1.0, 3.0, 1.0), Seq::default()];
print(&a);
// 2.0 2.0 2.0
// 2.0 2.0 2.0
// 2.0 2.0 2.0
// 2.0 2.0 2.0
// 2.0 2.0 2.0
let sub = assign_seq(&a, seqs, &b);
print(&sub);
// 2.0 2.0 2.0
// 1.0 1.0 1.0
// 1.0 1.0 1.0
// 1.0 1.0 1.0
// 2.0 2.0 2.0
After days of research I found an answer after reaching out to the author of the library:
Arrayfire 3.7.1 also introduces a new elegant syntax: