MCPcopy Index your code
hub / github.com/arrayfire/arrayfire-rust / non_macro_seq_array_assign

Function non_macro_seq_array_assign

src/core/index.rs:770–799  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

768
769 #[test]
770 fn non_macro_seq_array_assign() {
771 set_device(0);
772 // ANCHOR: non_macro_seq_array_assign
773 let values: [f32; 3] = [1.0, 2.0, 3.0];
774 let indices = Array::new(&values, dim4!(3, 1, 1, 1));
775 let seq4gen = seq!(0:2:1);
776 let mut a = randu::<f32>(dim4!(5, 3, 1, 1));
777 // [5 3 1 1]
778 // 0.0000 0.2190 0.3835
779 // 0.1315 0.0470 0.5194
780 // 0.7556 0.6789 0.8310
781 // 0.4587 0.6793 0.0346
782 // 0.5328 0.9347 0.0535
783
784 let b = constant(2.0 as f32, dim4!(3, 3, 1, 1));
785
786 let mut idxrs = Indexer::default();
787 idxrs.set_index(&indices, 0, None); // 2nd arg is indexing dimension
788 idxrs.set_index(&seq4gen, 1, Some(false)); // 3rd arg indicates batch operation
789
790 let _sub2 = assign_gen(&mut a, &idxrs, &b);
791 //println!("a(indices, seq(0, 2, 1))"); print(&sub2);
792 // [5 3 1 1]
793 // 0.0000 0.2190 0.3835
794 // 2.0000 2.0000 2.0000
795 // 2.0000 2.0000 2.0000
796 // 2.0000 2.0000 2.0000
797 // 0.5328 0.9347 0.0535
798 // ANCHOR_END: non_macro_seq_array_assign
799 }
800
801 #[test]
802 fn setrow() {

Callers

nothing calls this directly

Calls 4

set_deviceFunction · 0.85
constantFunction · 0.85
assign_genFunction · 0.85
set_indexMethod · 0.80

Tested by

no test coverage detected