@@ -15,49 +15,74 @@ pub trait SolveTriangular<Rhs> {
15
15
fn solve_triangular ( & self , UPLO , Diag , Rhs ) -> Result < Self :: Output > ;
16
16
}
17
17
18
- impl < A , Si , So , D > SolveTriangular < ArrayBase < So , D > > for ArrayBase < Si , Ix2 >
19
- where A : LapackScalar ,
18
+ impl < A , Si , So > SolveTriangular < ArrayBase < So , Ix2 > > for ArrayBase < Si , Ix2 >
19
+ where A : LapackScalar + Copy ,
20
20
Si : Data < Elem = A > ,
21
- So : DataMut < Elem = A > ,
22
- D : Dimension ,
23
- ArrayBase < So , D > : AllocatedArrayMut < Elem = A >
21
+ So : DataMut < Elem = A > + DataOwned
24
22
{
25
- type Output = ArrayBase < So , D > ;
23
+ type Output = ArrayBase < So , Ix2 > ;
26
24
27
- fn solve_triangular ( & self , uplo : UPLO , diag : Diag , mut b : ArrayBase < So , D > ) -> Result < Self :: Output > {
25
+ fn solve_triangular ( & self , uplo : UPLO , diag : Diag , mut b : ArrayBase < So , Ix2 > ) -> Result < Self :: Output > {
28
26
self . solve_triangular ( uplo, diag, & mut b) ?;
29
27
Ok ( b)
30
28
}
31
29
}
32
30
33
- impl < ' a , A , Si , So , D > SolveTriangular < & ' a mut ArrayBase < So , D > > for ArrayBase < Si , Ix2 >
34
- where A : LapackScalar ,
31
+ impl < ' a , A , Si , So > SolveTriangular < & ' a mut ArrayBase < So , Ix2 > > for ArrayBase < Si , Ix2 >
32
+ where A : LapackScalar + Copy ,
35
33
Si : Data < Elem = A > ,
36
- So : DataMut < Elem = A > ,
37
- D : Dimension ,
38
- ArrayBase < So , D > : AllocatedArrayMut < Elem = A >
34
+ So : DataMut < Elem = A > + DataOwned
39
35
{
40
- type Output = & ' a mut ArrayBase < So , D > ;
36
+ type Output = & ' a mut ArrayBase < So , Ix2 > ;
41
37
42
- fn solve_triangular ( & self , uplo : UPLO , diag : Diag , mut b : & ' a mut ArrayBase < So , D > ) -> Result < Self :: Output > {
38
+ fn solve_triangular ( & self , uplo : UPLO , diag : Diag , mut b : & ' a mut ArrayBase < So , Ix2 > ) -> Result < Self :: Output > {
43
39
let la = self . layout ( ) ?;
44
- let lb = b. layout ( ) ?;
45
40
let a_ = self . as_allocated ( ) ?;
41
+ let lb = b. layout ( ) ?;
42
+ if !la. same_order ( & lb) {
43
+ data_transpose ( b) ?;
44
+ }
45
+ let lb = b. layout ( ) ?;
46
46
A :: solve_triangular ( la, lb, uplo, diag, a_, b. as_allocated_mut ( ) ?) ?;
47
47
Ok ( b)
48
48
}
49
49
}
50
50
51
- impl < ' a , A , Si , So , D > SolveTriangular < & ' a ArrayBase < So , D > > for ArrayBase < Si , Ix2 >
51
+ impl < ' a , A , Si , So > SolveTriangular < & ' a ArrayBase < So , Ix2 > > for ArrayBase < Si , Ix2 >
52
+ where A : LapackScalar + Copy ,
53
+ Si : Data < Elem = A > ,
54
+ So : DataMut < Elem = A > + DataOwned
55
+ {
56
+ type Output = ArrayBase < So , Ix2 > ;
57
+
58
+ fn solve_triangular ( & self , uplo : UPLO , diag : Diag , b : & ' a ArrayBase < So , Ix2 > ) -> Result < Self :: Output > {
59
+ let b = replicate ( b) ;
60
+ self . solve_triangular ( uplo, diag, b)
61
+ }
62
+ }
63
+
64
+ impl < A , Si , So > SolveTriangular < ArrayBase < So , Ix1 > > for ArrayBase < Si , Ix2 >
65
+ where A : LapackScalar + Copy ,
66
+ Si : Data < Elem = A > ,
67
+ So : DataMut < Elem = A > + DataOwned
68
+ {
69
+ type Output = ArrayBase < So , Ix1 > ;
70
+
71
+ fn solve_triangular ( & self , uplo : UPLO , diag : Diag , b : ArrayBase < So , Ix1 > ) -> Result < Self :: Output > {
72
+ let b = into_col_vec ( b) ;
73
+ let b = self . solve_triangular ( uplo, diag, b) ?;
74
+ Ok ( into_vec ( b) )
75
+ }
76
+ }
77
+
78
+ impl < ' a , A , Si , So > SolveTriangular < & ' a ArrayBase < So , Ix1 > > for ArrayBase < Si , Ix2 >
52
79
where A : LapackScalar + Copy ,
53
80
Si : Data < Elem = A > ,
54
- So : DataMut < Elem = A > + DataOwned ,
55
- D : Dimension ,
56
- ArrayBase < So , D > : AllocatedArrayMut < Elem = A >
81
+ So : DataMut < Elem = A > + DataOwned
57
82
{
58
- type Output = ArrayBase < So , D > ;
83
+ type Output = ArrayBase < So , Ix1 > ;
59
84
60
- fn solve_triangular ( & self , uplo : UPLO , diag : Diag , b : & ' a ArrayBase < So , D > ) -> Result < Self :: Output > {
85
+ fn solve_triangular ( & self , uplo : UPLO , diag : Diag , b : & ' a ArrayBase < So , Ix1 > ) -> Result < Self :: Output > {
61
86
let b = replicate ( b) ;
62
87
self . solve_triangular ( uplo, diag, b)
63
88
}
0 commit comments