Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ad19250

Browse files
Merge pull request #348 from rust-ndarray/lax-trianglar
Merge `Triangular_` into `Lapack`
2 parents 120fb07 + 27c7fa1 commit ad19250

File tree

2 files changed

+40
-12
lines changed

2 files changed

+40
-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: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
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+
///
8+
/// LAPACK correspondance
9+
/// ----------------------
10+
///
11+
/// | f32 | f64 | c32 | c64 |
12+
/// |:-------|:-------|:-------|:-------|
13+
/// | strtrs | dtrtrs | ctrtrs | ztrtrs |
14+
///
15+
pub trait SolveTriangularImpl: Scalar {
816
fn solve_triangular(
917
al: MatrixLayout,
1018
bl: MatrixLayout,
@@ -16,8 +24,8 @@ pub trait Triangular_: Scalar {
1624
}
1725

1826
macro_rules! impl_triangular {
19-
($scalar:ty, $trtri:path, $trtrs:path) => {
20-
impl Triangular_ for $scalar {
27+
($scalar:ty, $trtrs:path) => {
28+
impl SolveTriangularImpl for $scalar {
2129
fn solve_triangular(
2230
a_layout: MatrixLayout,
2331
b_layout: MatrixLayout,
@@ -79,7 +87,7 @@ macro_rules! impl_triangular {
7987
};
8088
} // impl_triangular!
8189

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_);
90+
impl_triangular!(f64, lapack_sys::dtrtrs_);
91+
impl_triangular!(f32, lapack_sys::strtrs_);
92+
impl_triangular!(c64, lapack_sys::ztrtrs_);
93+
impl_triangular!(c32, lapack_sys::ctrtrs_);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /