Skip to content

Commit 23e2cc2

Browse files
committed
Add doc for traits and errors
1 parent 6eb4b9b commit 23e2cc2

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

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/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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use super::layout::*;
88
use super::types::*;
99
use super::error::*;
1010

11+
/// Hermite conjugate matrix
1112
pub fn conjugate<A, Si, So>(a: &ArrayBase<Si, Ix2>) -> ArrayBase<So, Ix2>
1213
where A: Conjugate,
1314
Si: Data<Elem = A>,
@@ -20,6 +21,7 @@ pub fn conjugate<A, Si, So>(a: &ArrayBase<Si, Ix2>) -> ArrayBase<So, Ix2>
2021
a
2122
}
2223

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

src/types.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,17 @@ trait_alias!(Field: LapackScalar,
3636

3737
trait_alias!(RealField: Field, Float);
3838

39+
/// Define associating real float type
3940
pub trait AssociatedReal: Sized {
4041
type Real: Float + Mul<Self, Output = Self>;
4142
}
43+
44+
/// Define associating complex type
4245
pub trait AssociatedComplex: Sized {
4346
type Complex;
4447
}
4548

46-
/// Field with norm
49+
/// Define `abs()` more generally
4750
pub trait Absolute {
4851
type Output: RealField;
4952
fn squared(&self) -> Self::Output;
@@ -52,14 +55,17 @@ pub trait Absolute {
5255
}
5356
}
5457

58+
/// Define `sqrt()` more generally
5559
pub trait SquareRoot {
5660
fn sqrt(&self) -> Self;
5761
}
5862

63+
/// Complex conjugate value
5964
pub trait Conjugate: Copy {
6065
fn conj(self) -> Self;
6166
}
6267

68+
/// Scalars which can be initialized from Gaussian random number
6369
pub trait RandNormal {
6470
fn randn<R: Rng>(&mut R) -> Self;
6571
}

0 commit comments

Comments
 (0)