Skip to content

Commit 263fbfd

Browse files
authored
Merge pull request #52 from termoshtt/docs
Update document
2 parents f002e8e + 3e47c0d commit 263fbfd

26 files changed

+106
-86
lines changed

README.md

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,16 @@ Linear algebra package for [rust-ndarray](https://github.com/bluss/rust-ndarray)
88

99
Examples
1010
---------
11+
See [examples](https://github.com/termoshtt/ndarray-linalg/tree/master/examples) directory.
1112

12-
```rust
13-
extern crate ndarray;
14-
extern crate ndarray_linalg;
15-
16-
use ndarray::prelude::*;
17-
use ndarray_linalg::prelude::*;
18-
19-
fn main() {
20-
let a = arr2(&[[3.0, 1.0, 1.0], [1.0, 3.0, 1.0], [1.0, 1.0, 3.0]]);
21-
let (e, vecs) = a.clone().eigh().unwrap();
22-
println!("eigenvalues = \n{:?}", e);
23-
println!("V = \n{:?}", vecs);
24-
let av = a.dot(&vecs);
25-
println!("AV = \n{:?}", av);
26-
}
27-
```
13+
Versions
14+
---------
2815

29-
See complete example at [src/bin/main.rs](src/bin/main.rs).
16+
- v0.5.0 (not released)
17+
- **Breaking Change** Rewrite all algorithms to support complex numbers and general `ArrayBase`
3018

31-
Progress
32-
---------
33-
Some algorithms have not been implemented yet. See [#6](https://github.com/termoshtt/ndarray-linalg/issues/6).
19+
- v0.4.1
20+
- ADD: assertion [#31](https://github.com/termoshtt/ndarray-linalg/pull/31)
3421

35-
Similar Projects
36-
-----------------
37-
- [linxal](https://github.com/masonium/linxal)
22+
- v0.4.0
23+
- MOD: use ndarray v0.9

src/assert.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use ndarray::*;
55
use super::types::*;
66
use super::norm::*;
77

8+
/// check two values are close in terms of the relative torrence
89
pub fn rclose<A, Tol>(test: A, truth: A, rtol: Tol) -> Result<Tol, Tol>
910
where A: Field + Absolute<Output = Tol>,
1011
Tol: RealField
@@ -13,6 +14,7 @@ pub fn rclose<A, Tol>(test: A, truth: A, rtol: Tol) -> Result<Tol, Tol>
1314
if dev < rtol { Ok(dev) } else { Err(dev) }
1415
}
1516

17+
/// check two values are close in terms of the absolute torrence
1618
pub fn aclose<A, Tol>(test: A, truth: A, atol: Tol) -> Result<Tol, Tol>
1719
where A: Field + Absolute<Output = Tol>,
1820
Tol: RealField

src/cholesky.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//! Cholesky decomposition
12
23
use ndarray::*;
34
use num_traits::Zero;
@@ -6,8 +7,8 @@ use super::error::*;
67
use super::layout::*;
78
use super::triangular::IntoTriangular;
89

9-
use impl2::LapackScalar;
10-
pub use impl2::UPLO;
10+
use lapack_traits::LapackScalar;
11+
pub use lapack_traits::UPLO;
1112

1213
pub trait Cholesky<K> {
1314
fn cholesky(self, UPLO) -> Result<K>;

src/eigh.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
//! Eigenvalue decomposition for Hermite matrices
12
23
use ndarray::*;
34

45
use super::error::*;
56
use super::layout::*;
67

7-
use impl2::LapackScalar;
8-
pub use impl2::UPLO;
8+
use lapack_traits::LapackScalar;
9+
pub use lapack_traits::UPLO;
910

1011
pub trait Eigh<EigVal, EigVec> {
1112
fn eigh(self, UPLO) -> Result<(EigVal, EigVec)>;

src/error.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use ndarray::{Ixs, ShapeError};
66

77
pub type Result<T> = ::std::result::Result<T, LinalgError>;
88

9+
/// Master Error type of this crate
910
#[derive(Debug, EnumError)]
1011
pub enum LinalgError {
1112
NotSquare(NotSquareError),
@@ -15,6 +16,7 @@ pub enum LinalgError {
1516
Shape(ShapeError),
1617
}
1718

19+
/// Error from LAPACK
1820
#[derive(Debug, new)]
1921
pub struct LapackError {
2022
pub return_code: i32,
@@ -38,6 +40,7 @@ impl From<i32> for LapackError {
3840
}
3941
}
4042

43+
/// Error that matrix is not square
4144
#[derive(Debug, new)]
4245
pub struct NotSquareError {
4346
pub rows: i32,
@@ -56,6 +59,7 @@ impl error::Error for NotSquareError {
5659
}
5760
}
5861

62+
/// Error that strides of the array is not supported
5963
#[derive(Debug, new)]
6064
pub struct StrideError {
6165
pub s0: Ixs,
@@ -74,6 +78,7 @@ impl error::Error for StrideError {
7478
}
7579
}
7680

81+
/// Error that the memory is not aligned continously
7782
#[derive(Debug, new)]
7883
pub struct MemoryContError {}
7984

src/generate.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//! Generator functions for matrices
12
23
use ndarray::*;
34
use std::ops::*;
@@ -7,6 +8,7 @@ use super::layout::*;
78
use super::types::*;
89
use super::error::*;
910

11+
/// Hermite conjugate matrix
1012
pub fn conjugate<A, Si, So>(a: &ArrayBase<Si, Ix2>) -> ArrayBase<So, Ix2>
1113
where A: Conjugate,
1214
Si: Data<Elem = A>,
@@ -19,6 +21,7 @@ pub fn conjugate<A, Si, So>(a: &ArrayBase<Si, Ix2>) -> ArrayBase<So, Ix2>
1921
a
2022
}
2123

24+
/// Generate random array
2225
pub fn random<A, S, Sh, D>(sh: Sh) -> ArrayBase<S, D>
2326
where A: RandNormal,
2427
S: DataOwned<Elem = A>,

src/impl2/cholesky.rs renamed to src/lapack_traits/cholesky.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! implement Cholesky decomposition
1+
//! Cholesky decomposition
22
33
use lapack::c;
44

src/impl2/eigh.rs renamed to src/lapack_traits/eigh.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//! Eigenvalue decomposition for Hermite matrices
12
23
use lapack::c;
34
use num_traits::Zero;
@@ -8,6 +9,7 @@ use layout::Layout;
89

910
use super::{into_result, UPLO};
1011

12+
/// Wraps `*syev` for real and `*heev` for complex
1113
pub trait Eigh_: AssociatedReal {
1214
fn eigh(calc_eigenvec: bool, Layout, UPLO, a: &mut [Self]) -> Result<Vec<Self::Real>>;
1315
}

src/impl2/mod.rs renamed to src/lapack_traits/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//! Define traits wrapping LAPACK routines
12
23
pub mod opnorm;
34
pub mod qr;
@@ -33,6 +34,7 @@ pub fn into_result<T>(info: i32, val: T) -> Result<T> {
3334
}
3435
}
3536

37+
/// Upper/Lower specification for seveal usages
3638
#[derive(Debug, Clone, Copy)]
3739
#[repr(u8)]
3840
pub enum UPLO {

src/impl2/opnorm.rs renamed to src/lapack_traits/opnorm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Implement Operator norms for matrices
1+
//! Operator norms of matrices
22
33
use lapack::c;
44
use lapack::c::Layout::ColumnMajor as cm;

0 commit comments

Comments
 (0)