@@ -15,14 +15,31 @@ pub trait SolveTriangular<Rhs> {
15
15
fn solve_triangular ( & self , UPLO , Diag , Rhs ) -> Result < Self :: Output > ;
16
16
}
17
17
18
- impl < A , S , V > SolveTriangular < V > for ArrayBase < S , Ix2 >
18
+ impl < A , Si , So , D > SolveTriangular < ArrayBase < So , D > > for ArrayBase < Si , Ix2 >
19
19
where A : LapackScalar ,
20
- S : Data < Elem = A > ,
21
- V : AllocatedArrayMut < Elem = A >
20
+ Si : Data < Elem = A > ,
21
+ So : DataMut < Elem = A > ,
22
+ D : Dimension ,
23
+ ArrayBase < So , D > : AllocatedArrayMut < Elem = A >
22
24
{
23
- type Output = V ;
25
+ type Output = ArrayBase < So , D > ;
24
26
25
- fn solve_triangular ( & self , uplo : UPLO , diag : Diag , mut b : V ) -> Result < Self :: Output > {
27
+ fn solve_triangular ( & self , uplo : UPLO , diag : Diag , mut b : ArrayBase < So , D > ) -> Result < Self :: Output > {
28
+ self . solve_triangular ( uplo, diag, & mut b) ?;
29
+ Ok ( b)
30
+ }
31
+ }
32
+
33
+ impl < ' a , A , Si , So , D > SolveTriangular < & ' a mut ArrayBase < So , D > > for ArrayBase < Si , Ix2 >
34
+ where A : LapackScalar ,
35
+ Si : Data < Elem = A > ,
36
+ So : DataMut < Elem = A > ,
37
+ D : Dimension ,
38
+ ArrayBase < So , D > : AllocatedArrayMut < Elem = A >
39
+ {
40
+ type Output = & ' a mut ArrayBase < So , D > ;
41
+
42
+ fn solve_triangular ( & self , uplo : UPLO , diag : Diag , mut b : & ' a mut ArrayBase < So , D > ) -> Result < Self :: Output > {
26
43
let la = self . layout ( ) ?;
27
44
let lb = b. layout ( ) ?;
28
45
let a_ = self . as_allocated ( ) ?;
@@ -31,16 +48,19 @@ impl<A, S, V> SolveTriangular<V> for ArrayBase<S, Ix2>
31
48
}
32
49
}
33
50
34
- pub fn drop_upper < A : Zero , S > ( a : ArrayBase < S , Ix2 > ) -> ArrayBase < S , Ix2 >
35
- where S : DataMut < Elem = A >
51
+ impl < ' a , A , Si , So , D > SolveTriangular < & ' a ArrayBase < So , D > > for ArrayBase < Si , Ix2 >
52
+ where A : LapackScalar + Copy ,
53
+ Si : Data < Elem = A > ,
54
+ So : DataMut < Elem = A > + DataOwned ,
55
+ D : Dimension ,
56
+ ArrayBase < So , D > : AllocatedArrayMut < Elem = A >
36
57
{
37
- a. into_triangular ( UPLO :: Lower )
38
- }
58
+ type Output = ArrayBase < So , D > ;
39
59
40
- pub fn drop_lower < A : Zero , S > ( a : ArrayBase < S , Ix2 > ) -> ArrayBase < S , Ix2 >
41
- where S : DataMut < Elem = A >
42
- {
43
- a . into_triangular ( UPLO :: Upper )
60
+ fn solve_triangular ( & self , uplo : UPLO , diag : Diag , b : & ' a ArrayBase < So , D > ) -> Result < Self :: Output > {
61
+ let b = replicate ( b ) ;
62
+ self . solve_triangular ( uplo , diag , b )
63
+ }
44
64
}
45
65
46
66
pub trait IntoTriangular < T > {
@@ -81,3 +101,15 @@ impl<A, S> IntoTriangular<ArrayBase<S, Ix2>> for ArrayBase<S, Ix2>
81
101
self
82
102
}
83
103
}
104
+
105
+ pub fn drop_upper < A : Zero , S > ( a : ArrayBase < S , Ix2 > ) -> ArrayBase < S , Ix2 >
106
+ where S : DataMut < Elem = A >
107
+ {
108
+ a. into_triangular ( UPLO :: Lower )
109
+ }
110
+
111
+ pub fn drop_lower < A : Zero , S > ( a : ArrayBase < S , Ix2 > ) -> ArrayBase < S , Ix2 >
112
+ where S : DataMut < Elem = A >
113
+ {
114
+ a. into_triangular ( UPLO :: Upper )
115
+ }
0 commit comments