Skip to content

Commit ed99462

Browse files
Add another constructor
1 parent 016c190 commit ed99462

File tree

1 file changed

+6
-6
lines changed
  • src/doc/ndarray_for_numpy_users

1 file changed

+6
-6
lines changed

src/doc/ndarray_for_numpy_users/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@
202202
//! `np.zeros_like(a, order='C')` | [`Array::zeros(a.raw_dim())`][::zeros()] | create an array of zeros of the shape shape as `a`, with row-major memory layout (unlike NumPy, this infers the element type from context instead of duplicating `a`'s element type)
203203
//! `np.full((3, 4), 7.)` | [`Array::from_elem((3, 4), 7.)`][::from_elem()] | create a 3×4 array filled with the value `7.`
204204
//! `np.eye(3)` | [`Array::eye(3)`][::eye()] | create a 3×3 identity matrix (inferring the element type)
205+
//! `np.diag(np.array([1, 2, 3]))` | [`Array2::from_diag(&arr1(&[1, 2, 3]))`][::from_diag()] | create a 3×3 matrix with `[1, 2, 3]` as diagonal and zeros elsewhere (inferring the element type)
205206
//! `np.array([1, 2, 3, 4]).reshape((2, 2))` | [`Array::from_shape_vec((2, 2), vec![1, 2, 3, 4])?`][::from_shape_vec()] | create a 2×2 array from the elements in the list/`Vec`
206207
//! `np.array([1, 2, 3, 4]).reshape((2, 2), order='F')` | [`Array::from_shape_vec((2, 2).f(), vec![1, 2, 3, 4])?`][::from_shape_vec()] | create a 2×2 array from the elements in the list/`Vec` using Fortran (column-major) order
207208
//! `np.random` | See the [`ndarray-rand`](https://crates.io/crates/ndarray-rand) crate. | create arrays of random numbers
@@ -458,8 +459,7 @@
458459
//!
459460
//! </td><td>
460461
//!
461-
//! `a.sum() / a.len() as f64`
462-
//!
462+
//! [`a.mean().unwrap()`][.mean()]
463463
//! </td><td>
464464
//!
465465
//! calculate the mean of the elements in `f64` array `a`
@@ -490,7 +490,7 @@
490490
//!
491491
//! </td><td>
492492
//!
493-
//! check if the arrays' elementwise differences are within an absolute tolerance
493+
//! check if the arrays' elementwise differences are within an absolute tolerance (it requires the `approx` feature-flag)
494494
//!
495495
//! </td></tr>
496496
//!
@@ -514,9 +514,7 @@
514514
//!
515515
//! </td><td>
516516
//!
517-
//! See other crates, e.g.
518-
//! [`ndarray-linalg`](https://crates.io/crates/ndarray-linalg) and
519-
//! [`linxal`](https://crates.io/crates/linxal).
517+
//! See [`ndarray-linalg`](https://crates.io/crates/ndarray-linalg)
520518
//!
521519
//! </td><td>
522520
//!
@@ -595,6 +593,7 @@
595593
//! [.fold_axis()]: ../../struct.ArrayBase.html#method.fold_axis
596594
//! [::from_elem()]: ../../struct.ArrayBase.html#method.from_elem
597595
//! [::from_iter()]: ../../struct.ArrayBase.html#method.from_iter
596+
//! [::from_diag()]: ../../struct.ArrayBase.html#method.from_diag
598597
//! [::from_shape_fn()]: ../../struct.ArrayBase.html#method.from_shape_fn
599598
//! [::from_shape_vec()]: ../../struct.ArrayBase.html#method.from_shape_vec
600599
//! [::from_shape_vec_unchecked()]: ../../struct.ArrayBase.html#method.from_shape_vec_unchecked
@@ -618,6 +617,7 @@
618617
//! [.mapv_inplace()]: ../../struct.ArrayBase.html#method.mapv_inplace
619618
//! [.mapv_into()]: ../../struct.ArrayBase.html#method.mapv_into
620619
//! [matrix-* dot]: ../../struct.ArrayBase.html#method.dot-1
620+
//! [.mean()]: ../../struct.ArrayBase.html#method.mean
621621
//! [.mean_axis()]: ../../struct.ArrayBase.html#method.mean_axis
622622
//! [.ndim()]: ../../struct.ArrayBase.html#method.ndim
623623
//! [NdProducer]: ../../trait.NdProducer.html

0 commit comments

Comments
 (0)