rust_numpy/lib.rs
1#![allow(unused_macros)]
2
3pub use vector::Vector;
4pub use matrix::Matrix;
5
6
7mod vector;
8mod matrix;
9mod vectors;
10mod macroses;
11
12#[cfg(test)]
13mod tests;
14
15pub trait Init {
16
17 type Output;
18 type Size;
19
20 fn init(value: f64, size: Self::Size) -> Self::Output;
21
22 fn init_func<F>(func: F, size: Self::Size) -> Self::Output
23 where F: std::ops::Fn(Self::Size) -> f64;
24
25 fn zeros(size: Self::Size) -> Self::Output {
26 Self::init(0.0, size)
27 }
28
29 fn ones(size: Self::Size) ->Self::Output {
30 Self::init(1.0, size)
31 }
32}
33
34
35pub trait Dot<Rhs = Self> {
36 type Output;
37
38 fn dot(&self, rhs: &Rhs) -> Self::Output;
39}
40
41
42// #[macro_export]
43// macro_rules! impl_math {
44// ( $( $func:ident ),* ) => {
45// trait Math {
46// type Output;
47// $(
48// fn $func(&self) -> Self::Output {
49// self.apply(f64::$func)
50// }
51// )*
52//
53// #[inline]
54// fn apply(&self, func: fn(f64) -> f64) -> Self::Output;
55// }
56// };
57// }
58
59
60
61
62// impl_math![
63// sin, cos, tan,
64// // (asin), (acos), (atan),
65// // (sinh), (cosh), (tanh),
66// // (asinh), (acosh), (atanh),
67// // (ln), (log10), (log2)
68// (powf, power : f64)
69// ];
70
71