Better coding-style in the doc-tests.

This commit is contained in:
Sébastien Crozet 2023-01-14 15:48:42 +01:00
parent d54c56fd43
commit 82b4960740
1 changed files with 16 additions and 18 deletions

View File

@ -169,20 +169,19 @@ where
/// Using parallel column iterators to calculate the sum of the maximum /// Using parallel column iterators to calculate the sum of the maximum
/// elements in each column: /// elements in each column:
/// ``` /// ```
/// use nalgebra::{dmatrix,DMatrix}; /// use nalgebra::{dmatrix, DMatrix};
/// use rayon::prelude::*; /// use rayon::prelude::*;
/// ///
/// let matrix : DMatrix<f64> = /// let matrix : DMatrix<f64> = dmatrix![1.0, 0.0, 5.0;
/// nalgebra::dmatrix![1.,0.,5.; /// 2.0, 4.0, 1.0;
/// 2.,4.,1.; /// 3.0, 2.0, 2.0;
/// 3.,2.,2.;]; /// ];
/// let sum_of_max :f64 = /// let sum_of_max :f64 = matrix
/// matrix /// .par_column_iter()
/// .par_column_iter() /// .map(|col| col.max())
/// .map(|col|col.max()) /// .sum();
/// .sum();
/// ///
/// assert_eq!(sum_of_max,3.+4.+5.); /// assert_eq!(sum_of_max,3.0 + 4.0 + 5.0);
/// ///
/// ``` /// ```
/// ///
@ -200,17 +199,16 @@ where
/// Normalize each column of a matrix with respect to its own maximum value. /// Normalize each column of a matrix with respect to its own maximum value.
/// ///
/// ``` /// ```
/// use nalgebra::{dmatrix,DMatrix}; /// use nalgebra::{dmatrix, DMatrix};
/// use rayon::prelude::*; /// use rayon::prelude::*;
/// ///
/// let mut matrix : DMatrix<f64> = /// let mut matrix : DMatrix<f64> = dmatrix![
/// dmatrix![2.,4.,6.; /// 2.0, 4.0, 6.0;
/// 1.,2.,3.]; /// 1.0, 2.0, 3.0;
/// ];
/// matrix.par_column_iter_mut().for_each(|mut col| col /= col.max()); /// matrix.par_column_iter_mut().for_each(|mut col| col /= col.max());
/// ///
/// assert_eq!(matrix, /// assert_eq!(matrix, dmatrix![1.0, 1.0, 1.0; 0.5, 0.5, 0.5]);
/// dmatrix![1. ,1. , 1.;
/// 0.5,0.5,0.5]);
/// ``` /// ```
/// ///
/// [`par_column_iter`]: crate::Matrix::par_column_iter /// [`par_column_iter`]: crate::Matrix::par_column_iter