Skip to content

Commit 9f4788b

Browse files
committed
Merge Triangular_ into Lapack
1 parent 120fb07 commit 9f4788b

File tree

2 files changed

+33
-12
lines changed

2 files changed

+33
-12
lines changed

lax/src/lib.rs

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,17 +100,16 @@ pub mod solve;
100100
pub mod solveh;
101101
pub mod svd;
102102
pub mod svddc;
103+
pub mod triangular;
103104

104105
mod alloc;
105-
mod triangular;
106106
mod tridiagonal;
107107

108108
pub use self::cholesky::*;
109109
pub use self::flags::*;
110110
pub use self::least_squares::LeastSquaresOwned;
111111
pub use self::opnorm::*;
112112
pub use self::svd::{SvdOwned, SvdRef};
113-
pub use self::triangular::*;
114113
pub use self::tridiagonal::*;
115114

116115
use self::{alloc::*, error::*, layout::*};
@@ -121,7 +120,7 @@ pub type Pivot = Vec<i32>;
121120

122121
#[cfg_attr(doc, katexit::katexit)]
123122
/// Trait for primitive types which implements LAPACK subroutines
124-
pub trait Lapack: Triangular_ + Tridiagonal_ {
123+
pub trait Lapack: Tridiagonal_ {
125124
/// Compute right eigenvalue and eigenvectors for a general matrix
126125
fn eig(
127126
calc_v: bool,
@@ -298,6 +297,15 @@ pub trait Lapack: Triangular_ + Tridiagonal_ {
298297
/// $$
299298
///
300299
fn opnorm(t: NormType, l: MatrixLayout, a: &[Self]) -> Self::Real;
300+
301+
fn solve_triangular(
302+
al: MatrixLayout,
303+
bl: MatrixLayout,
304+
uplo: UPLO,
305+
d: Diag,
306+
a: &[Self],
307+
b: &mut [Self],
308+
) -> Result<()>;
301309
}
302310

303311
macro_rules! impl_lapack {
@@ -471,6 +479,18 @@ macro_rules! impl_lapack {
471479
let mut work = OperatorNormWork::<$s>::new(t, l);
472480
work.calc(a)
473481
}
482+
483+
fn solve_triangular(
484+
al: MatrixLayout,
485+
bl: MatrixLayout,
486+
uplo: UPLO,
487+
d: Diag,
488+
a: &[Self],
489+
b: &mut [Self],
490+
) -> Result<()> {
491+
use triangular::*;
492+
SolveTriangularImpl::solve_triangular(al, bl, uplo, d, a, b)
493+
}
474494
}
475495
};
476496
}

lax/src/triangular.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
//! Implement linear solver and inverse matrix
1+
//! Linear problem for triangular matrices
22
33
use crate::{error::*, layout::*, *};
44
use cauchy::*;
55

6-
/// Wraps `*trtri` and `*trtrs`
7-
pub trait Triangular_: Scalar {
6+
/// Solve linear problem for triangular matrices
7+
///`*trtrs`
8+
pub trait SolveTriangularImpl: Scalar {
89
fn solve_triangular(
910
al: MatrixLayout,
1011
bl: MatrixLayout,
@@ -16,8 +17,8 @@ pub trait Triangular_: Scalar {
1617
}
1718

1819
macro_rules! impl_triangular {
19-
($scalar:ty, $trtri:path, $trtrs:path) => {
20-
impl Triangular_ for $scalar {
20+
($scalar:ty, $trtrs:path) => {
21+
impl SolveTriangularImpl for $scalar {
2122
fn solve_triangular(
2223
a_layout: MatrixLayout,
2324
b_layout: MatrixLayout,
@@ -79,7 +80,7 @@ macro_rules! impl_triangular {
7980
};
8081
} // impl_triangular!
8182

82-
impl_triangular!(f64, lapack_sys::dtrtri_, lapack_sys::dtrtrs_);
83-
impl_triangular!(f32, lapack_sys::strtri_, lapack_sys::strtrs_);
84-
impl_triangular!(c64, lapack_sys::ztrtri_, lapack_sys::ztrtrs_);
85-
impl_triangular!(c32, lapack_sys::ctrtri_, lapack_sys::ctrtrs_);
83+
impl_triangular!(f64, lapack_sys::dtrtrs_);
84+
impl_triangular!(f32, lapack_sys::strtrs_);
85+
impl_triangular!(c64, lapack_sys::ztrtrs_);
86+
impl_triangular!(c32, lapack_sys::ctrtrs_);

0 commit comments

Comments
 (0)