From 94d884346cbca4baed01f5800adbd61d43b33581 Mon Sep 17 00:00:00 2001 From: Toshiki Teramura Date: Thu, 8 Sep 2022 15:58:11 +0900 Subject: [PATCH] Update document about SVD --- lax/src/least_squares.rs | 6 +++++- lax/src/lib.rs | 15 +++++++-------- lax/src/svd.rs | 13 +++++++++++-- lax/src/svddc.rs | 11 +++++++++++ 4 files changed, 34 insertions(+), 11 deletions(-) diff --git a/lax/src/least_squares.rs b/lax/src/least_squares.rs index 6be44f33..5699257d 100644 --- a/lax/src/least_squares.rs +++ b/lax/src/least_squares.rs @@ -12,14 +12,18 @@ pub struct LeastSquaresOutput { pub rank: i32, } -/// Wraps `*gelsd` +#[cfg_attr(doc, katexit::katexit)] +/// Solve least square problem pub trait LeastSquaresSvdDivideConquer_: Scalar { + /// Compute a vector $x$ which minimizes Euclidian norm $\| Ax - b\|$ + /// for a given matrix $A$ and a vector $b$. fn least_squares( a_layout: MatrixLayout, a: &mut [Self], b: &mut [Self], ) -> Result>; + /// Solve least square problems $\argmin_X \| AX - B\|$ fn least_squares_nrhs( a_layout: MatrixLayout, a: &mut [Self], diff --git a/lax/src/lib.rs b/lax/src/lib.rs index 9a8bf1cf..47f3eedc 100644 --- a/lax/src/lib.rs +++ b/lax/src/lib.rs @@ -61,16 +61,15 @@ //! - [Eig_] trait provides methods for eigenvalue problem for general matrix. //! - [Eigh_] trait provides methods for eigenvalue problem for symmetric/hermite matrix. //! -//! Singular Value Decomposition (SVD), Least square problem -//! ---------------------------------------------------------- +//! Singular Value Decomposition +//! ----------------------------- //! -//! | matrix type | Singular Value Decomposition (SVD) | SVD with divided-and-conquer (SDD) | Least square problem (LSD) | -//! |:-------------|:-----------------------------------|:-----------------------------------|:---------------------------| -//! | General (GE) | [svd] | [svddc] | [least_squares] | +//! - [SVD_] trait provides methods for singular value decomposition for general matrix +//! - [SVDDC_] trait provides methods for singular value decomposition for general matrix +//! with divided-and-conquer algorithm +//! - [LeastSquaresSvdDivideConquer_] trait provides methods +//! for solving least square problem by SVD //! -//! [svd]: svd/trait.SVD_.html#tymethod.svd -//! [svddc]: svddck/trait.SVDDC_.html#tymethod.svddc -//! [least_squares]: least_squares/trait.LeastSquaresSvdDivideConquer_.html#tymethod.least_squares #[cfg(any(feature = "intel-mkl-system", feature = "intel-mkl-static"))] extern crate intel_mkl_src as _src; diff --git a/lax/src/svd.rs b/lax/src/svd.rs index 0a509a0e..0f0f81ab 100644 --- a/lax/src/svd.rs +++ b/lax/src/svd.rs @@ -14,9 +14,18 @@ pub struct SVDOutput { pub vt: Option>, } -/// Wraps `*gesvd` +#[cfg_attr(doc, katexit::katexit)] +/// Singular value decomposition pub trait SVD_: Scalar { - /// Calculate singular value decomposition $ A = U \Sigma V^T $ + /// Compute singular value decomposition $A = U \Sigma V^T$ + /// + /// LAPACK correspondance + /// ---------------------- + /// + /// | f32 | f64 | c32 | c64 | + /// |:-------|:-------|:-------|:-------| + /// | sgesvd | dgesvd | cgesvd | zgesvd | + /// fn svd(l: MatrixLayout, calc_u: bool, calc_vt: bool, a: &mut [Self]) -> Result>; } diff --git a/lax/src/svddc.rs b/lax/src/svddc.rs index bb59348f..55ddfd46 100644 --- a/lax/src/svddc.rs +++ b/lax/src/svddc.rs @@ -2,7 +2,18 @@ use crate::{error::*, layout::MatrixLayout, *}; use cauchy::*; use num_traits::{ToPrimitive, Zero}; +#[cfg_attr(doc, katexit::katexit)] +/// Singular value decomposition with divide-and-conquer method pub trait SVDDC_: Scalar { + /// Compute singular value decomposition $A = U \Sigma V^T$ + /// + /// LAPACK correspondance + /// ---------------------- + /// + /// | f32 | f64 | c32 | c64 | + /// |:-------|:-------|:-------|:-------| + /// | sgesdd | dgesdd | cgesdd | zgesdd | + /// fn svddc(l: MatrixLayout, jobz: JobSvd, a: &mut [Self]) -> Result>; }