()
| 2 | |
| 3 | #[allow(unused_must_use)] |
| 4 | fn main() { |
| 5 | set_device(0); |
| 6 | info(); |
| 7 | print!("Info String:\n{}", info_string(true)); |
| 8 | println!("Arrayfire version: {:?}", get_version()); |
| 9 | let (name, platform, toolkit, compute) = device_info(); |
| 10 | print!( |
| 11 | "Name: {}\nPlatform: {}\nToolkit: {}\nCompute: {}\n", |
| 12 | name, platform, toolkit, compute |
| 13 | ); |
| 14 | println!("Revision: {}", get_revision()); |
| 15 | |
| 16 | let num_rows: i64 = 5; |
| 17 | let num_cols: i64 = 3; |
| 18 | let values: [f32; 3] = [1.0, 2.0, 3.0]; |
| 19 | let indices = Array::new(&values, Dim4::new(&[3, 1, 1, 1])); |
| 20 | |
| 21 | af_print!("Indices ", indices); |
| 22 | |
| 23 | let dims = Dim4::new(&[num_rows as u64, num_cols as u64, 1, 1]); |
| 24 | |
| 25 | let mut a = randu::<f32>(dims); |
| 26 | af_print!("Create a 5-by-3 float matrix on the GPU", a); |
| 27 | |
| 28 | println!("Element-wise arithmetic"); |
| 29 | let b = add(&sin(&a), &1.5f32, false); |
| 30 | |
| 31 | let b2 = add(&sin(&a), &cos(&a), false); |
| 32 | |
| 33 | let b3 = !&a; |
| 34 | af_print!("sin(a) + 1.5 a.k.a b => ", b); |
| 35 | af_print!("sin(a) + cos(a) => ", b2); |
| 36 | af_print!("!a => ", b3); |
| 37 | |
| 38 | let test = a.clone() + b.clone(); |
| 39 | af_print!("a + b", test); |
| 40 | |
| 41 | let negation = -(a.clone()); |
| 42 | af_print!("-a ", negation); |
| 43 | |
| 44 | // Index array using sequences |
| 45 | let seqs = &[Seq::new(1u32, 3, 1), Seq::default()]; |
| 46 | let sub = index(&a, seqs); |
| 47 | af_print!("a(seq(1,3,1), span)", sub); |
| 48 | |
| 49 | //Index array using array and sequence |
| 50 | let seq4gen = Seq::new(0u32, 2, 1); |
| 51 | |
| 52 | let mut idxrs = Indexer::default(); |
| 53 | idxrs.set_index(&indices, 0, None); |
| 54 | idxrs.set_index(&seq4gen, 1, Some(false)); |
| 55 | |
| 56 | let sub2 = index_gen(&a, idxrs); |
| 57 | af_print!("a(indices, seq(0, 2, 1))", sub2); |
| 58 | |
| 59 | println!("Fourier transform the result"); |
| 60 | print(&fft(&b, 1.0, 0)); |
| 61 |
nothing calls this directly
no test coverage detected