rstsr/lib.rs
1#![doc = include_str!("../notes_to_api_doc.md")]
2#![doc = include_str!("../readme.md")]
3pub mod prelude;
4
5#[allow(unused_imports)]
6use crate as rstsr;
7
8pub mod api_specification {
9 #![doc = include_str!("docs/api_specification.md")]
10 #![allow(unused_imports)]
11
12 use crate::prelude::*;
13 use rt::*;
14 extern crate alloc;
15}
16
17#[test]
18fn test() {
19 use crate::prelude::*;
20
21 // 3x2 matrix with c-contiguous memory layout
22 let a = rt::asarray((vec![6., 2., 7., 4., 8., 5.], [3, 2].c()));
23
24 // 2x4x3 matrix by arange and reshaping
25 let b = rt::arange(24.);
26 let b = b.reshape((-1, 4, 3));
27 // in one line, you can also
28 // let b = rt::arange(24.).into_shape((-1, 4, 3));
29
30 // broadcasted matrix multiplication
31 let c = b % a;
32
33 // print layout of the result
34 println!("{:?}", c.layout());
35 // output:
36 // 3-Dim (dyn), contiguous: Cc
37 // shape: [2, 4, 2], stride: [8, 2, 1], offset: 0
38
39 // print the result
40 println!("{c:6.1}");
41 // output:
42 // [[[ 23.0 14.0]
43 // [ 86.0 47.0]
44 // [ 149.0 80.0]
45 // [ 212.0 113.0]]
46 //
47 // [[ 275.0 146.0]
48 // [ 338.0 179.0]
49 // [ 401.0 212.0]
50 // [ 464.0 245.0]]]
51}