File tree Expand file tree Collapse file tree 4 files changed +16
-37
lines changed Expand file tree Collapse file tree 4 files changed +16
-37
lines changed Original file line number Diff line number Diff line change 1
1
//! Define trait for Hermite matrices
2
2
3
- use ndarray:: { Ix2 , Array , LinalgScalar } ;
4
- use std:: fmt:: Debug ;
5
- use num_traits:: float:: Float ;
6
- use num_traits:: One ;
3
+ use ndarray:: { Ix2 , Array } ;
7
4
use lapack:: c:: Layout ;
8
5
9
- use matrix:: Matrix ;
6
+ use matrix:: { Matrix , MFloat } ;
10
7
use square:: SquareMatrix ;
11
8
use error:: LinalgError ;
12
9
use eigh:: ImplEigh ;
13
- use qr:: ImplQR ;
14
- use svd:: ImplSVD ;
15
- use norm:: ImplNorm ;
16
- use solve:: ImplSolve ;
17
10
use cholesky:: ImplCholesky ;
18
11
12
+ pub trait HMFloat : ImplEigh + ImplCholesky + MFloat { }
13
+ impl < A : ImplEigh + ImplCholesky + MFloat > HMFloat for A { }
14
+
19
15
/// Methods for Hermite matrix
20
16
pub trait HermiteMatrix : SquareMatrix + Matrix {
21
17
/// eigenvalue decomposition
@@ -28,9 +24,7 @@ pub trait HermiteMatrix: SquareMatrix + Matrix {
28
24
fn deth ( self ) -> Result < Self :: Scalar , LinalgError > ;
29
25
}
30
26
31
- impl < A > HermiteMatrix for Array < A , Ix2 >
32
- where A : ImplQR + ImplSVD + ImplNorm + ImplSolve + ImplEigh + ImplCholesky + LinalgScalar + Float + Debug + One
33
- {
27
+ impl < A : HMFloat > HermiteMatrix for Array < A , Ix2 > {
34
28
fn eigh ( self ) -> Result < ( Self :: Vector , Self ) , LinalgError > {
35
29
self . check_square ( ) ?;
36
30
let layout = self . layout ( ) ?;
Original file line number Diff line number Diff line change 1
1
//! Define trait for general matrix
2
2
3
3
use std:: cmp:: min;
4
- use std:: fmt:: Debug ;
5
4
use ndarray:: prelude:: * ;
6
- use ndarray:: LinalgScalar ;
7
5
use lapack:: c:: Layout ;
8
6
9
7
use error:: { LinalgError , StrideError } ;
@@ -12,6 +10,9 @@ use svd::ImplSVD;
12
10
use norm:: ImplNorm ;
13
11
use solve:: ImplSolve ;
14
12
13
+ pub trait MFloat : ImplQR + ImplSVD + ImplNorm + ImplSolve + NdFloat { }
14
+ impl < A : ImplQR + ImplSVD + ImplNorm + ImplSolve + NdFloat > MFloat for A { }
15
+
15
16
/// Methods for general matrices
16
17
pub trait Matrix : Sized {
17
18
type Scalar ;
@@ -42,9 +43,7 @@ pub trait Matrix: Sized {
42
43
}
43
44
}
44
45
45
- impl < A > Matrix for Array < A , Ix2 >
46
- where A : ImplQR + ImplSVD + ImplNorm + ImplSolve + LinalgScalar + Debug
47
- {
46
+ impl < A : MFloat > Matrix for Array < A , Ix2 > {
48
47
type Scalar = A ;
49
48
type Vector = Array < A , Ix1 > ;
50
49
type Permutator = Vec < i32 > ;
Original file line number Diff line number Diff line change 1
1
//! Define trait for Hermite matrices
2
2
3
- use ndarray:: { Ix2 , Array , LinalgScalar } ;
4
- use std:: fmt:: Debug ;
5
- use num_traits:: float:: Float ;
3
+ use ndarray:: { Ix2 , Array } ;
6
4
use lapack:: c:: Layout ;
7
5
8
- use matrix:: Matrix ;
6
+ use matrix:: { Matrix , MFloat } ;
9
7
use error:: { LinalgError , NotSquareError } ;
10
- use qr:: ImplQR ;
11
- use svd:: ImplSVD ;
12
- use norm:: ImplNorm ;
13
8
use solve:: ImplSolve ;
14
9
15
10
/// Methods for square matrices
@@ -37,9 +32,7 @@ pub trait SquareMatrix: Matrix {
37
32
}
38
33
}
39
34
40
- impl < A > SquareMatrix for Array < A , Ix2 >
41
- where A : ImplQR + ImplNorm + ImplSVD + ImplSolve + LinalgScalar + Float + Debug
42
- {
35
+ impl < A : MFloat > SquareMatrix for Array < A , Ix2 > {
43
36
fn inv ( self ) -> Result < Self , LinalgError > {
44
37
self . check_square ( ) ?;
45
38
let ( n, _) = self . size ( ) ;
Original file line number Diff line number Diff line change 1
1
2
- use ndarray:: { Ix2 , Array , LinalgScalar } ;
3
- use std:: fmt:: Debug ;
4
- use num_traits:: float:: Float ;
2
+ use ndarray:: { Ix2 , Array } ;
5
3
6
- use matrix:: Matrix ;
4
+ use matrix:: { Matrix , MFloat } ;
7
5
use square:: SquareMatrix ;
8
6
use error:: LinalgError ;
9
- use qr:: ImplQR ;
10
- use svd:: ImplSVD ;
11
- use norm:: ImplNorm ;
12
7
use solve:: ImplSolve ;
13
8
14
9
pub trait TriangularMatrix : Matrix + SquareMatrix {
@@ -18,9 +13,7 @@ pub trait TriangularMatrix: Matrix + SquareMatrix {
18
13
fn solve_lower ( & self , Self :: Vector ) -> Result < Self :: Vector , LinalgError > ;
19
14
}
20
15
21
- impl < A > TriangularMatrix for Array < A , Ix2 >
22
- where A : ImplQR + ImplNorm + ImplSVD + ImplSolve + LinalgScalar + Float + Debug
23
- {
16
+ impl < A : MFloat > TriangularMatrix for Array < A , Ix2 > {
24
17
fn solve_upper ( & self , b : Self :: Vector ) -> Result < Self :: Vector , LinalgError > {
25
18
self . check_square ( ) ?;
26
19
let ( n, _) = self . size ( ) ;
You can’t perform that action at this time.
0 commit comments