Skip to content

Commit e13ca64

Browse files
committed
Introduce Field, RealField
1 parent 16904ae commit e13ca64

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

src/impl2/triangular.rs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
use lapack::c;
44

55
use error::*;
6+
use types::*;
67
use layout::Layout;
78
use super::{UPLO, Transpose, into_result};
89

@@ -18,11 +19,14 @@ pub trait Triangular_: Sized {
1819
fn solve_triangular(al: Layout, bl: Layout, UPLO, Diag, a: &[Self], b: &mut [Self]) -> Result<()>;
1920
}
2021

21-
impl Triangular_ for f64 {
22+
macro_rules! impl_triangular {
23+
($scalar:ty, $trtri:path, $trtrs:path) => {
24+
25+
impl Triangular_ for $scalar {
2226
fn inv_triangular(l: Layout, uplo: UPLO, diag: Diag, a: &mut [Self]) -> Result<()> {
2327
let (n, _) = l.size();
2428
let lda = l.lda();
25-
let info = c::dtrtri(l.lapacke_layout(), uplo as u8, diag as u8, n, a, lda);
29+
let info = $trtri(l.lapacke_layout(), uplo as u8, diag as u8, n, a, lda);
2630
into_result(info, ())
2731
}
2832

@@ -31,16 +35,14 @@ impl Triangular_ for f64 {
3135
let lda = al.lda();
3236
let nrhs = bl.len();
3337
let ldb = bl.lda();
34-
let info = c::dtrtrs(al.lapacke_layout(),
35-
uplo as u8,
36-
Transpose::No as u8,
37-
diag as u8,
38-
n,
39-
nrhs,
40-
a,
41-
lda,
42-
&mut b,
43-
ldb);
38+
let info = $trtrs(al.lapacke_layout(), uplo as u8, Transpose::No as u8, diag as u8, n, nrhs, a, lda, &mut b, ldb);
4439
into_result(info, ())
4540
}
4641
}
42+
43+
}} // impl_triangular!
44+
45+
impl_triangular!(f64, c::dtrtri, c::dtrtrs);
46+
impl_triangular!(f32, c::strtri, c::strtrs);
47+
impl_triangular!(c64, c::ztrtri, c::ztrtrs);
48+
impl_triangular!(c32, c::ctrtri, c::ctrtrs);

src/prelude.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ pub use opnorm::*;
1212
pub use solve::*;
1313
pub use eigh::*;
1414
pub use cholesky::*;
15+
pub use impl2::LapackScalar;

src/triangular.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ use super::layout::*;
77
use super::error::*;
88
use super::impl2::*;
99

10+
pub use super::impl2::Diag;
11+
1012
/// solve a triangular system with upper triangular matrix
1113
pub trait SolveTriangular<Rhs> {
1214
type Output;

0 commit comments

Comments
 (0)