Skip to content

Commit bdb4ac3

Browse files
committed
Add document for self-consuming trait
1 parent b88d65c commit bdb4ac3

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

src/lib.rs

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,39 @@
77
//! - [solve linear problem](solve/index.html)
88
//! - [solve linear problem for triangular matrix](triangular/trait.SolveTriangular.html)
99
//! - [inverse matrix](solve/trait.Inverse.html)
10-
//! - [eigenvalue decomposition for Hermite matrix](eigh/trait.Eigh.html)
10+
//! - [eigenvalue decomposition for Hermite matrix][eigh]
1111
//!
12-
//! Utilites
12+
//! [eigh]:eigh/trait.Eigh.html
13+
//!
14+
//! Utilities
1315
//! -----------
1416
//! - [assertions for array](index.html#macros)
1517
//! - [generator functions](generate/index.html)
1618
//! - [Scalar trait](types/trait.Field.html)
19+
//!
20+
//! Usage
21+
//! ------
22+
//! Most functions in this crate is defined as [self-consuming trait technique][sct] like [serde]
23+
//! does.
24+
//!
25+
//! For example, we can execute [eigh][eigh] using three types of interfaces:
26+
//!
27+
//! ```rust
28+
//! let a = random((3, 3));
29+
//! let (eval, evec) = a.eigh(UPLO::Upper)?;
30+
//! let (eval, evec) = (&a).eigh(UPLO::Upper)?;
31+
//! let (eval, evec) = (&mut a).eigh(UPLO::Upper)?;
32+
//! ```
33+
//!
34+
//! The first type `a.eigh()` consumes `a`, and the memory of `a` is used for `evec`.
35+
//! The second type `(&a).eigh()` consumes the reference (not `a` itself),
36+
//! and the memory for `evec` is newly allocated.
37+
//! The last one `(&mut a).eigh()` is similar to the first one;
38+
//! It borrows `a` mutably, and rewrite it to contains `evec`.
39+
//! In all cases, the array `eval` is newly allocated.
40+
//!
41+
//! [sct]:https://github.com/serde-rs/serde/releases/tag/v0.9.0
42+
//! [serde]:https://github.com/serde-rs/serde
1743
1844
extern crate blas;
1945
extern crate lapack;

0 commit comments

Comments
 (0)