Skip to content

Commit 04ddbdb

Browse files
committed
Implement TriangularMatrix for RcArray
1 parent ea7cead commit 04ddbdb

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/triangular.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
use ndarray::{Ix2, Array, NdFloat, ArrayBase, DataMut};
2+
use ndarray::{Ix2, Array, RcArray, NdFloat, ArrayBase, DataMut};
33

44
use matrix::{Matrix, MFloat};
55
use square::SquareMatrix;
@@ -32,6 +32,17 @@ impl<A: MFloat> TriangularMatrix for Array<A, Ix2> {
3232
}
3333
}
3434

35+
impl<A: MFloat> TriangularMatrix for RcArray<A, Ix2> {
36+
fn solve_upper(&self, b: Self::Vector) -> Result<Self::Vector, LinalgError> {
37+
let x = self.to_owned().solve_upper(b.to_owned())?;
38+
Ok(x.into_shared())
39+
}
40+
fn solve_lower(&self, b: Self::Vector) -> Result<Self::Vector, LinalgError> {
41+
let x = self.to_owned().solve_lower(b.to_owned())?;
42+
Ok(x.into_shared())
43+
}
44+
}
45+
3546
pub fn drop_upper<A: NdFloat, S>(mut a: ArrayBase<S, Ix2>) -> ArrayBase<S, Ix2>
3647
where S: DataMut<Elem = A>
3748
{

0 commit comments

Comments
 (0)