462
462
//!
463
463
//! ## Tips for LU, Det, Inverse
464
464
//!
465
- //! * If you save `self.lu()` rather than the direct use of `self.det()` or `self.lu()` then you
466
- //! can get better performance (via memoization)
465
+ //! * If you save `self.lu()` rather than the direct use of `self.det()` or `self.lu()` then you can get better performance (via memoization)
467
466
//!
468
467
//! ```rust
469
468
//! use peroxide::fuga::*;
@@ -2754,12 +2753,10 @@ impl FPMatrix for Matrix {
2754
2753
/// ```rust
2755
2754
/// use peroxide::fuga::*;
2756
2755
///
2757
- /// fn main() {
2758
- /// let x = ml_matrix("1 2;3 4;5 6");
2759
- /// let y = x.col_map(|c| c.fmap(|t| t - c.mean()));
2756
+ /// let x = ml_matrix("1 2;3 4;5 6");
2757
+ /// let y = x.col_map(|c| c.fmap(|t| t - c.mean()));
2760
2758
///
2761
- /// assert_eq!(y, ml_matrix("-2 -2;0 0;2 2"));
2762
- /// }
2759
+ /// assert_eq!(y, ml_matrix("-2 -2;0 0;2 2"));
2763
2760
/// ```
2764
2761
fn col_map < F > ( & self , f : F ) -> Matrix
2765
2762
where
@@ -2780,12 +2777,10 @@ impl FPMatrix for Matrix {
2780
2777
/// ```rust
2781
2778
/// use peroxide::fuga::*;
2782
2779
///
2783
- /// fn main() {
2784
- /// let x = ml_matrix("1 2 3;4 5 6");
2785
- /// let y = x.row_map(|r| r.fmap(|t| t - r.mean()));
2780
+ /// let x = ml_matrix("1 2 3;4 5 6");
2781
+ /// let y = x.row_map(|r| r.fmap(|t| t - r.mean()));
2786
2782
///
2787
- /// assert_eq!(y, ml_matrix("-1 0 1;-1 0 1"));
2788
- /// }
2783
+ /// assert_eq!(y, ml_matrix("-1 0 1;-1 0 1"));
2789
2784
/// ```
2790
2785
fn row_map < F > ( & self , f : F ) -> Matrix
2791
2786
where
@@ -3035,23 +3030,21 @@ impl LinearAlgebra<Matrix> for Matrix {
3035
3030
///
3036
3031
/// # Caution
3037
3032
/// It returns `Option<PQLU>` - You should unwrap to obtain real value.
3038
- /// `PQLU` has four field - `p`, `q`, `l`, `u`.
3039
- /// `p`, `q` are permutations.
3040
- /// `l`, `u` are matrices.
3033
+ /// - `PQLU` has four field - `p`, `q`, `l`, `u`.
3034
+ /// - `p`, `q` are permutations.
3035
+ /// - `l`, `u` are matrices.
3041
3036
///
3042
3037
/// # Examples
3043
3038
/// ```
3044
3039
/// use peroxide::fuga::*;
3045
3040
///
3046
- /// fn main() {
3047
- /// let a = matrix(vec![1,2,3,4], 2, 2, Row);
3048
- /// let pqlu = a.lu();
3049
- /// let (p,q,l,u) = (pqlu.p, pqlu.q, pqlu.l, pqlu.u);
3050
- /// assert_eq!(p, vec![1]); // swap 0 & 1 (Row)
3051
- /// assert_eq!(q, vec![1]); // swap 0 & 1 (Col)
3052
- /// assert_eq!(l, matrix(vec![1.0,0.0,0.5,1.0],2,2,Row));
3053
- /// assert_eq!(u, matrix(vec![4.0,3.0,0.0,-0.5],2,2,Row));
3054
- /// }
3041
+ /// let a = matrix(vec![1,2,3,4], 2, 2, Row);
3042
+ /// let pqlu = a.lu();
3043
+ /// let (p,q,l,u) = (pqlu.p, pqlu.q, pqlu.l, pqlu.u);
3044
+ /// assert_eq!(p, vec![1]); // swap 0 & 1 (Row)
3045
+ /// assert_eq!(q, vec![1]); // swap 0 & 1 (Col)
3046
+ /// assert_eq!(l, matrix(vec![1.0,0.0,0.5,1.0],2,2,Row));
3047
+ /// assert_eq!(u, matrix(vec![4.0,3.0,0.0,-0.5],2,2,Row));
3055
3048
/// ```
3056
3049
fn lu ( & self ) -> PQLU < Matrix > {
3057
3050
assert_eq ! ( self . col, self . row) ;
@@ -3155,16 +3148,14 @@ impl LinearAlgebra<Matrix> for Matrix {
3155
3148
/// ```
3156
3149
/// use peroxide::fuga::*;
3157
3150
///
3158
- /// fn main() {
3159
- /// let a = ml_matrix("12 -51 4;6 167 -68; -4 24 -41");
3160
- /// let qr = a.qr();
3161
- /// let r = ml_matrix("-14 -21 14; 0 -175 70; 0 0 -35");
3162
- /// #[cfg(feature="O3")]
3163
- /// {
3164
- /// assert_eq!(r, qr.r);
3165
- /// }
3166
- /// qr.r.print();
3151
+ /// let a = ml_matrix("12 -51 4;6 167 -68; -4 24 -41");
3152
+ /// let qr = a.qr();
3153
+ /// let r = ml_matrix("-14 -21 14; 0 -175 70; 0 0 -35");
3154
+ /// #[cfg(feature="O3")]
3155
+ /// {
3156
+ /// assert_eq!(r, qr.r);
3167
3157
/// }
3158
+ /// qr.r.print();
3168
3159
/// ```
3169
3160
#[ allow( non_snake_case) ]
3170
3161
fn qr ( & self ) -> QR < Matrix > {
@@ -3211,15 +3202,13 @@ impl LinearAlgebra<Matrix> for Matrix {
3211
3202
/// ```
3212
3203
/// use peroxide::fuga::*;
3213
3204
///
3214
- /// fn main() {
3215
- /// let a = ml_matrix("3 2 2;2 3 -2");
3216
- /// #[cfg(feature="O3")]
3217
- /// {
3218
- /// let svd = a.svd();
3219
- /// assert!(eq_vec(&vec![5f64, 3f64], &svd.s, 1e-7));
3220
- /// }
3221
- /// a.print();
3205
+ /// let a = ml_matrix("3 2 2;2 3 -2");
3206
+ /// #[cfg(feature="O3")]
3207
+ /// {
3208
+ /// let svd = a.svd();
3209
+ /// assert!(eq_vec(&vec![5f64, 3f64], &svd.s, 1e-7));
3222
3210
/// }
3211
+ /// a.print();
3223
3212
/// ```
3224
3213
fn svd ( & self ) -> SVD < Matrix > {
3225
3214
match ( ) {
@@ -3250,21 +3239,18 @@ impl LinearAlgebra<Matrix> for Matrix {
3250
3239
///
3251
3240
/// # Examples
3252
3241
/// ```
3253
- /// extern crate peroxide;
3254
3242
/// use peroxide::fuga::*;
3255
3243
///
3256
- /// fn main() {
3257
- /// let a = ml_matrix("1 2;2 5");
3258
- /// #[cfg(feature = "O3")]
3259
- /// {
3260
- /// let u = a.cholesky(Upper);
3261
- /// let l = a.cholesky(Lower);
3244
+ /// let a = ml_matrix("1 2;2 5");
3245
+ /// #[cfg(feature = "O3")]
3246
+ /// {
3247
+ /// let u = a.cholesky(Upper);
3248
+ /// let l = a.cholesky(Lower);
3262
3249
///
3263
- /// assert_eq!(u, ml_matrix("1 2;0 1"));
3264
- /// assert_eq!(l, ml_matrix("1 0;2 1"));
3265
- /// }
3266
- /// a.print();
3250
+ /// assert_eq!(u, ml_matrix("1 2;0 1"));
3251
+ /// assert_eq!(l, ml_matrix("1 0;2 1"));
3267
3252
/// }
3253
+ /// a.print();
3268
3254
/// ```
3269
3255
#[ cfg( feature = "O3" ) ]
3270
3256
fn cholesky ( & self , uplo : UPLO ) -> Matrix {
0 commit comments