|
202 | 202 | //! `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) |
203 | 203 | //! `np.full((3, 4), 7.)` | [`Array::from_elem((3, 4), 7.)`][::from_elem()] | create a 3×4 array filled with the value `7.` |
204 | 204 | //! `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) |
205 | 206 | //! `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` |
206 | 207 | //! `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 |
207 | 208 | //! `np.random` | See the [`ndarray-rand`](https://crates.io/crates/ndarray-rand) crate. | create arrays of random numbers |
|
458 | 459 | //! |
459 | 460 | //! </td><td> |
460 | 461 | //! |
461 | | -//! `a.sum() / a.len() as f64` |
462 | | -//! |
| 462 | +//! [`a.mean().unwrap()`][.mean()] |
463 | 463 | //! </td><td> |
464 | 464 | //! |
465 | 465 | //! calculate the mean of the elements in `f64` array `a` |
|
490 | 490 | //! |
491 | 491 | //! </td><td> |
492 | 492 | //! |
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) |
494 | 494 | //! |
495 | 495 | //! </td></tr> |
496 | 496 | //! |
|
514 | 514 | //! |
515 | 515 | //! </td><td> |
516 | 516 | //! |
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) |
520 | 518 | //! |
521 | 519 | //! </td><td> |
522 | 520 | //! |
|
595 | 593 | //! [.fold_axis()]: ../../struct.ArrayBase.html#method.fold_axis |
596 | 594 | //! [::from_elem()]: ../../struct.ArrayBase.html#method.from_elem |
597 | 595 | //! [::from_iter()]: ../../struct.ArrayBase.html#method.from_iter |
| 596 | +//! [::from_diag()]: ../../struct.ArrayBase.html#method.from_diag |
598 | 597 | //! [::from_shape_fn()]: ../../struct.ArrayBase.html#method.from_shape_fn |
599 | 598 | //! [::from_shape_vec()]: ../../struct.ArrayBase.html#method.from_shape_vec |
600 | 599 | //! [::from_shape_vec_unchecked()]: ../../struct.ArrayBase.html#method.from_shape_vec_unchecked |
|
618 | 617 | //! [.mapv_inplace()]: ../../struct.ArrayBase.html#method.mapv_inplace |
619 | 618 | //! [.mapv_into()]: ../../struct.ArrayBase.html#method.mapv_into |
620 | 619 | //! [matrix-* dot]: ../../struct.ArrayBase.html#method.dot-1 |
| 620 | +//! [.mean()]: ../../struct.ArrayBase.html#method.mean |
621 | 621 | //! [.mean_axis()]: ../../struct.ArrayBase.html#method.mean_axis |
622 | 622 | //! [.ndim()]: ../../struct.ArrayBase.html#method.ndim |
623 | 623 | //! [NdProducer]: ../../trait.NdProducer.html |
|
0 commit comments