|
1 |
| -//! Linear Algebra eXtension (LAX) |
2 |
| -//! =============================== |
3 |
| -//! |
4 | 1 | //! ndarray-free safe Rust wrapper for LAPACK FFI
|
5 | 2 | //!
|
6 |
| -//! Linear equation, Inverse matrix, Condition number |
7 |
| -//! -------------------------------------------------- |
| 3 | +//! `Lapack` trait and sub-traits |
| 4 | +//! ------------------------------- |
8 | 5 | //!
|
9 |
| -//! As the property of $A$, several types of triangular factorization are used: |
| 6 | +//! This crates provides LAPACK wrapper as `impl` of traits to base scalar types. |
| 7 | +//! For example, LU decomposition to double-precision matrix is provided like: |
10 | 8 | //!
|
11 |
| -//! - LU-decomposition for general matrix |
12 |
| -//! - $PA = LU$, where $L$ is lower matrix, $U$ is upper matrix, and $P$ is permutation matrix |
13 |
| -//! - Bunch-Kaufman diagonal pivoting method for nonpositive-definite Hermitian matrix |
14 |
| -//! - $A = U D U^\dagger$, where $U$ is upper matrix, |
15 |
| -//! $D$ is Hermitian and block diagonal with 1-by-1 and 2-by-2 diagonal blocks. |
| 9 | +//! ```ignore |
| 10 | +//! impl Solve_ for f64 { |
| 11 | +//! fn lu(l: MatrixLayout, a: &mut [Self]) -> Result<Pivot> { ... } |
| 12 | +//! } |
| 13 | +//! ``` |
16 | 14 | //!
|
17 |
| -//! | matrix type | Triangler factorization (TRF) | Solve (TRS) | Inverse matrix (TRI) | Reciprocal condition number (CON) | |
18 |
| -//! |:--------------------------------|:------------------------------|:------------|:---------------------|:----------------------------------| |
19 |
| -//! | General (GE) | [lu] | [solve] | [inv] | [rcond] | |
20 |
| -//! | Symmetric (SY) / Hermitian (HE) | [bk] | [solveh] | [invh] | - | |
| 15 | +//! see [Solve_] for detail. You can use it like `f64::lu`: |
21 | 16 | //!
|
22 |
| -//! [lu]: solve/trait.Solve_.html#tymethod.lu |
23 |
| -//! [solve]: solve/trait.Solve_.html#tymethod.solve |
24 |
| -//! [inv]: solve/trait.Solve_.html#tymethod.inv |
25 |
| -//! [rcond]: solve/trait.Solve_.html#tymethod.rcond |
| 17 | +//! ``` |
| 18 | +//! use lax::{Solve_, layout::MatrixLayout, Transpose}; |
26 | 19 | //!
|
27 |
| -//! [bk]: solveh/trait.Solveh_.html#tymethod.bk |
28 |
| -//! [solveh]: solveh/trait.Solveh_.html#tymethod.solveh |
29 |
| -//! [invh]: solveh/trait.Solveh_.html#tymethod.invh |
| 20 | +//! let mut a = vec![ |
| 21 | +//! 1.0, 2.0, |
| 22 | +//! 3.0, 4.0 |
| 23 | +//! ]; |
| 24 | +//! let mut b = vec![1.0, 2.0]; |
| 25 | +//! let layout = MatrixLayout::C { row: 2, lda: 2 }; |
| 26 | +//! let pivot = f64::lu(layout, &mut a).unwrap(); |
| 27 | +//! f64::solve(layout, Transpose::No, &a, &pivot, &mut b).unwrap(); |
| 28 | +//! ``` |
30 | 29 | //!
|
31 |
| -//! Eigenvalue Problem |
32 |
| -//! ------------------- |
| 30 | +//! When you want to write generic algorithm for real and complex matrices, |
| 31 | +//! this trait can be used as a trait bound: |
| 32 | +//! |
| 33 | +//! ``` |
| 34 | +//! use lax::{Solve_, layout::MatrixLayout, Transpose}; |
33 | 35 | //!
|
34 |
| -//! Solve eigenvalue problem for a matrix $A$ |
| 36 | +//! fn solve_at_once<T: Solve_>(layout: MatrixLayout, a: &mut [T], b: &mut [T]) -> Result<(), lax::error::Error> { |
| 37 | +//! let pivot = T::lu(layout, a)?; |
| 38 | +//! T::solve(layout, Transpose::No, a, &pivot, b)?; |
| 39 | +//! Ok(()) |
| 40 | +//! } |
| 41 | +//! ``` |
35 | 42 | //!
|
36 |
| -//! $$ Av_i = \lambda_i v_i $$ |
| 43 | +//! There are several similar traits as described below to keep development easy. |
| 44 | +//! They are merged into a single trait, [Lapack]. |
37 | 45 | //!
|
38 |
| -//! or generalized eigenvalue problem |
| 46 | +//! Linear equation, Inverse matrix, Condition number |
| 47 | +//! -------------------------------------------------- |
| 48 | +//! |
| 49 | +//! According to the property input metrix, several types of triangular decomposition are used: |
39 | 50 | //!
|
40 |
| -//! $$ Av_i = \lambda_i B v_i $$ |
| 51 | +//! - [Solve_] trait provides methods for LU-decomposition for general matrix. |
| 52 | +//! - [Solveh_] triat provides methods for Bunch-Kaufman diagonal pivoting method for symmetric/hermite indefinite matrix. |
| 53 | +//! - [Cholesky_] triat provides methods for Cholesky decomposition for symmetric/hermite positive dinite matrix. |
| 54 | +//! |
| 55 | +//! Eigenvalue Problem |
| 56 | +//! ------------------- |
41 | 57 | //!
|
42 |
| -//! | matrix type | Eigenvalue (EV) | Generalized Eigenvalue Problem (EG) | |
43 |
| -//! |:--------------------------------|:----------------|:------------------------------------| |
44 |
| -//! | General (GE) |[eig] | - | |
45 |
| -//! | Symmetric (SY) / Hermitian (HE) |[eigh] |[eigh_generalized] | |
| 58 | +//! According to the property input metrix, |
| 59 | +//! there are several types of eigenvalue problem API |
46 | 60 | //!
|
47 |
| -//! [eig]: eig/trait.Eig_.html#tymethod.eig |
48 |
| -//! [eigh]: eigh/trait.Eigh_.html#tymethod.eigh |
49 |
| -//! [eigh_generalized]: eigh/trait.Eigh_.html#tymethod.eigh_generalized |
| 61 | +//! - [Eig_] trait provides methods for eigenvalue problem for general matrix. |
| 62 | +//! - [Eigh_] trait provides methods for eigenvalue problem for symmetric/hermite matrix. |
50 | 63 | //!
|
51 |
| -//! Singular Value Decomposition (SVD), Least square problem |
52 |
| -//! ---------------------------------------------------------- |
| 64 | +//! Singular Value Decomposition |
| 65 | +//! ----------------------------- |
53 | 66 | //!
|
54 |
| -//! | matrix type | Singular Value Decomposition (SVD) | SVD with divided-and-conquer (SDD) | Least square problem (LSD) | |
55 |
| -//! |:-------------|:-----------------------------------|:-----------------------------------|:---------------------------| |
56 |
| -//! | General (GE) | [svd] | [svddc] | [least_squares] | |
| 67 | +//! - [SVD_] trait provides methods for singular value decomposition for general matrix |
| 68 | +//! - [SVDDC_] trait provides methods for singular value decomposition for general matrix |
| 69 | +//! with divided-and-conquer algorithm |
| 70 | +//! - [LeastSquaresSvdDivideConquer_] trait provides methods |
| 71 | +//! for solving least square problem by SVD |
57 | 72 | //!
|
58 |
| -//! [svd]: svd/trait.SVD_.html#tymethod.svd |
59 |
| -//! [svddc]: svddck/trait.SVDDC_.html#tymethod.svddc |
60 |
| -//! [least_squares]: least_squares/trait.LeastSquaresSvdDivideConquer_.html#tymethod.least_squares |
61 | 73 |
|
62 | 74 | #[cfg(any(feature = "intel-mkl-system", feature = "intel-mkl-static"))]
|
63 | 75 | extern crate intel_mkl_src as _src;
|
|
0 commit comments