1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
pub(crate) mod blas;
pub mod decomposition;
pub mod equation;
pub(crate) mod lapack;
pub mod matrix;
pub use cauchy::Scalar;
pub trait Real: num_traits::Float {
fn copysign(self, sign: Self) -> Self;
fn recip(self) -> Self;
fn eps() -> Self;
fn sfmin() -> Self;
}
impl Real for f64 {
#[inline]
fn copysign(self, sign: Self) -> Self {
self.copysign(sign)
}
#[inline]
fn recip(self) -> Self {
self.recip()
}
#[inline]
fn eps() -> Self {
5.960_464_477_539_063e-8
}
#[inline]
fn sfmin() -> Self {
2.225_073_858_507_201_4e-_308
}
}
impl Real for f32 {
#[inline]
fn copysign(self, sign: Self) -> Self {
self.copysign(sign)
}
#[inline]
fn recip(self) -> Self {
self.recip()
}
#[inline]
fn eps() -> Self {
1.110_223e-16
}
#[inline]
fn sfmin() -> Self {
1.175_494_4e-38
}
}
#[derive(Debug, thiserror::Error)]
pub enum InvalidInput {
#[error("shape error: {0}")]
Shape(String),
#[error("value error: {0}")]
Value(String),
}