Skip to content

Commit fe5deea

Browse files
committed
Update document in solve.rs
Drop module-level doc in solve.rs
1 parent 014b5ee commit fe5deea

File tree

1 file changed

+27
-8
lines changed

1 file changed

+27
-8
lines changed

lax/src/solve.rs

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,43 @@
1-
//! Solve linear problem using LU decomposition
2-
31
use crate::{error::*, layout::MatrixLayout, *};
42
use cauchy::*;
53
use num_traits::{ToPrimitive, Zero};
64

5+
#[cfg_attr(doc, katexit::katexit)]
6+
/// Solve linear equations using LU-decomposition
7+
///
8+
/// For a given matrix $A$, LU decomposition is described as $PA = LU$ where
9+
///
10+
/// - $L$ is lower matrix
11+
/// - $U$ is upper matrix
12+
/// - $P$ is permutation matrix represented by [Pivot]
13+
///
14+
/// This is designed as two step computation according to LAPACK API:
15+
///
16+
/// 1. Factorize input matrix $A$ into $L$, $U$, and $P$.
17+
/// 2. Solve linear equation $Ax = b$ or compute inverse matrix $A^{-1}$
18+
/// using the output of LU factorization.
19+
///
720
pub trait Solve_: Scalar + Sized {
8-
/// Computes the LU factorization of a general `m x n` matrix `a` using
9-
/// partial pivoting with row interchanges.
21+
/// Computes the LU factorization of a general $m \times n$ matrix
22+
/// with partial pivoting with row interchanges.
1023
///
11-
/// $ PA = LU $
24+
/// Output
25+
/// -------
26+
/// - $U$ and $L$ are stored in `a` after LU factorization has succeeded.
27+
/// - $P$ is returned as [Pivot]
1228
///
1329
/// Error
1430
/// ------
15-
/// - `LapackComputationalFailure { return_code }` when the matrix is singular
16-
/// - Division by zero will occur if it is used to solve a system of equations
17-
/// because `U[(return_code-1, return_code-1)]` is exactly zero.
31+
/// - if the matrix is singular
32+
/// - On this case, `return_code` in [Error::LapackComputationalFailure] means
33+
/// `return_code`-th diagonal element of $U$ becomes zero.
34+
///
1835
fn lu(l: MatrixLayout, a: &mut [Self]) -> Result<Pivot>;
1936

37+
/// Compute inverse matrix $A^{-1}$ from the output of LU-factorization
2038
fn inv(l: MatrixLayout, a: &mut [Self], p: &Pivot) -> Result<()>;
2139

40+
/// Solve linear equations $Ax = b$ using the output of LU-factorization
2241
fn solve(l: MatrixLayout, t: Transpose, a: &[Self], p: &Pivot, b: &mut [Self]) -> Result<()>;
2342
}
2443

0 commit comments

Comments
 (0)