Merge pull request #1096 from sterlingjensen/cleanupdoc

Cleanup examples and doc links
This commit is contained in:
Sébastien Crozet 2022-03-24 10:00:24 +01:00 committed by GitHub
commit 77cf2c935f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 82 additions and 78 deletions

View File

@ -125,7 +125,6 @@ impl Parse for Matrix {
/// (`;`) designates that a new row begins. /// (`;`) designates that a new row begins.
/// ///
/// # Examples /// # Examples
///
/// ``` /// ```
/// use nalgebra::matrix; /// use nalgebra::matrix;
/// ///
@ -170,6 +169,7 @@ pub fn matrix(stream: TokenStream) -> TokenStream {
/// `SMatrix`, it produces instances of `DMatrix`. At the moment it is not usable /// `SMatrix`, it produces instances of `DMatrix`. At the moment it is not usable
/// in `const fn` contexts. /// in `const fn` contexts.
/// ///
/// # Example
/// ``` /// ```
/// use nalgebra::dmatrix; /// use nalgebra::dmatrix;
/// ///
@ -243,8 +243,7 @@ impl Parse for Vector {
/// `vector!` is intended to be the most readable and performant way of constructing small, /// `vector!` is intended to be the most readable and performant way of constructing small,
/// fixed-size vectors, and it is usable in `const fn` contexts. /// fixed-size vectors, and it is usable in `const fn` contexts.
/// ///
/// ## Examples /// # Example
///
/// ``` /// ```
/// use nalgebra::vector; /// use nalgebra::vector;
/// ///
@ -271,6 +270,7 @@ pub fn vector(stream: TokenStream) -> TokenStream {
/// `SVector`, it produces instances of `DVector`. At the moment it is not usable /// `SVector`, it produces instances of `DVector`. At the moment it is not usable
/// in `const fn` contexts. /// in `const fn` contexts.
/// ///
/// # Example
/// ``` /// ```
/// use nalgebra::dvector; /// use nalgebra::dvector;
/// ///
@ -301,8 +301,7 @@ pub fn dvector(stream: TokenStream) -> TokenStream {
/// `point!` is intended to be the most readable and performant way of constructing small, /// `point!` is intended to be the most readable and performant way of constructing small,
/// points, and it is usable in `const fn` contexts. /// points, and it is usable in `const fn` contexts.
/// ///
/// ## Examples /// # Example
///
/// ``` /// ```
/// use nalgebra::point; /// use nalgebra::point;
/// ///

View File

@ -175,8 +175,7 @@ where
/// Note that this is **not** the matrix multiplication as in, e.g., numpy. For matrix /// Note that this is **not** the matrix multiplication as in, e.g., numpy. For matrix
/// multiplication, use one of: `.gemm`, `.mul_to`, `.mul`, the `*` operator. /// multiplication, use one of: `.gemm`, `.mul_to`, `.mul`, the `*` operator.
/// ///
/// # Examples: /// # Example
///
/// ``` /// ```
/// # use nalgebra::{Vector3, Matrix2x3}; /// # use nalgebra::{Vector3, Matrix2x3};
/// let vec1 = Vector3::new(1.0, 2.0, 3.0); /// let vec1 = Vector3::new(1.0, 2.0, 3.0);
@ -207,8 +206,7 @@ where
/// Note that this is **not** the matrix multiplication as in, e.g., numpy. For matrix /// Note that this is **not** the matrix multiplication as in, e.g., numpy. For matrix
/// multiplication, use one of: `.gemm`, `.mul_to`, `.mul`, the `*` operator. /// multiplication, use one of: `.gemm`, `.mul_to`, `.mul`, the `*` operator.
/// ///
/// # Examples: /// # Example
///
/// ``` /// ```
/// # use nalgebra::{Vector2, Complex}; /// # use nalgebra::{Vector2, Complex};
/// let vec1 = Vector2::new(Complex::new(1.0, 2.0), Complex::new(3.0, 4.0)); /// let vec1 = Vector2::new(Complex::new(1.0, 2.0), Complex::new(3.0, 4.0));
@ -232,8 +230,7 @@ where
/// The dot product between the transpose of `self` and `rhs`. /// The dot product between the transpose of `self` and `rhs`.
/// ///
/// # Examples: /// # Example
///
/// ``` /// ```
/// # use nalgebra::{Vector3, RowVector3, Matrix2x3, Matrix3x2}; /// # use nalgebra::{Vector3, RowVector3, Matrix2x3, Matrix3x2};
/// let vec1 = Vector3::new(1.0, 2.0, 3.0); /// let vec1 = Vector3::new(1.0, 2.0, 3.0);
@ -285,8 +282,7 @@ where
/// ///
/// If `b` is zero, `self` is never read from. /// If `b` is zero, `self` is never read from.
/// ///
/// # Examples: /// # Example
///
/// ``` /// ```
/// # use nalgebra::Vector3; /// # use nalgebra::Vector3;
/// let mut vec1 = Vector3::new(1.0, 2.0, 3.0); /// let mut vec1 = Vector3::new(1.0, 2.0, 3.0);
@ -308,8 +304,7 @@ where
/// ///
/// If `b` is zero, `self` is never read from. /// If `b` is zero, `self` is never read from.
/// ///
/// # Examples: /// # Example
///
/// ``` /// ```
/// # use nalgebra::Vector3; /// # use nalgebra::Vector3;
/// let mut vec1 = Vector3::new(1.0, 2.0, 3.0); /// let mut vec1 = Vector3::new(1.0, 2.0, 3.0);
@ -333,8 +328,7 @@ where
/// ///
/// If `beta` is zero, `self` is never read. /// If `beta` is zero, `self` is never read.
/// ///
/// # Examples: /// # Example
///
/// ``` /// ```
/// # use nalgebra::{Matrix2, Vector2}; /// # use nalgebra::{Matrix2, Vector2};
/// let mut vec1 = Vector2::new(1.0, 2.0); /// let mut vec1 = Vector2::new(1.0, 2.0);
@ -425,8 +419,7 @@ where
/// If `beta` is zero, `self` is never read. If `self` is read, only its lower-triangular part /// If `beta` is zero, `self` is never read. If `self` is read, only its lower-triangular part
/// (including the diagonal) is actually read. /// (including the diagonal) is actually read.
/// ///
/// # Examples: /// # Examples
///
/// ``` /// ```
/// # use nalgebra::{Matrix2, Vector2}; /// # use nalgebra::{Matrix2, Vector2};
/// let mat = Matrix2::new(1.0, 2.0, /// let mat = Matrix2::new(1.0, 2.0,
@ -468,8 +461,7 @@ where
/// If `beta` is zero, `self` is never read. If `self` is read, only its lower-triangular part /// If `beta` is zero, `self` is never read. If `self` is read, only its lower-triangular part
/// (including the diagonal) is actually read. /// (including the diagonal) is actually read.
/// ///
/// # Examples: /// # Examples
///
/// ``` /// ```
/// # use nalgebra::{Matrix2, Vector2, Complex}; /// # use nalgebra::{Matrix2, Vector2, Complex};
/// let mat = Matrix2::new(Complex::new(1.0, 0.0), Complex::new(2.0, -0.1), /// let mat = Matrix2::new(Complex::new(1.0, 0.0), Complex::new(2.0, -0.1),
@ -552,8 +544,7 @@ where
/// ///
/// If `beta` is zero, `self` is never read. /// If `beta` is zero, `self` is never read.
/// ///
/// # Examples: /// # Example
///
/// ``` /// ```
/// # use nalgebra::{Matrix2, Vector2}; /// # use nalgebra::{Matrix2, Vector2};
/// let mat = Matrix2::new(1.0, 3.0, /// let mat = Matrix2::new(1.0, 3.0,
@ -587,8 +578,7 @@ where
/// For real matrices, this is the same as `.gemv_tr`. /// For real matrices, this is the same as `.gemv_tr`.
/// If `beta` is zero, `self` is never read. /// If `beta` is zero, `self` is never read.
/// ///
/// # Examples: /// # Example
///
/// ``` /// ```
/// # use nalgebra::{Matrix2, Vector2, Complex}; /// # use nalgebra::{Matrix2, Vector2, Complex};
/// let mat = Matrix2::new(Complex::new(1.0, 2.0), Complex::new(3.0, 4.0), /// let mat = Matrix2::new(Complex::new(1.0, 2.0), Complex::new(3.0, 4.0),
@ -656,8 +646,7 @@ where
/// ///
/// If `beta` is zero, `self` is never read. /// If `beta` is zero, `self` is never read.
/// ///
/// # Examples: /// # Example
///
/// ``` /// ```
/// # use nalgebra::{Matrix2x3, Vector2, Vector3}; /// # use nalgebra::{Matrix2x3, Vector2, Vector3};
/// let mut mat = Matrix2x3::repeat(4.0); /// let mut mat = Matrix2x3::repeat(4.0);
@ -688,8 +677,7 @@ where
/// ///
/// If `beta` is zero, `self` is never read. /// If `beta` is zero, `self` is never read.
/// ///
/// # Examples: /// # Example
///
/// ``` /// ```
/// # #[macro_use] extern crate approx; /// # #[macro_use] extern crate approx;
/// # use nalgebra::{Matrix2x3, Vector2, Vector3, Complex}; /// # use nalgebra::{Matrix2x3, Vector2, Vector3, Complex};
@ -722,8 +710,7 @@ where
/// ///
/// If `beta` is zero, `self` is never read. /// If `beta` is zero, `self` is never read.
/// ///
/// # Examples: /// # Example
///
/// ``` /// ```
/// # #[macro_use] extern crate approx; /// # #[macro_use] extern crate approx;
/// # use nalgebra::{Matrix2x3, Matrix3x4, Matrix2x4}; /// # use nalgebra::{Matrix2x3, Matrix3x4, Matrix2x4};
@ -763,8 +750,7 @@ where
/// ///
/// If `beta` is zero, `self` is never read. /// If `beta` is zero, `self` is never read.
/// ///
/// # Examples: /// # Example
///
/// ``` /// ```
/// # #[macro_use] extern crate approx; /// # #[macro_use] extern crate approx;
/// # use nalgebra::{Matrix3x2, Matrix3x4, Matrix2x4}; /// # use nalgebra::{Matrix3x2, Matrix3x4, Matrix2x4};
@ -821,8 +807,7 @@ where
/// ///
/// If `beta` is zero, `self` is never read. /// If `beta` is zero, `self` is never read.
/// ///
/// # Examples: /// # Example
///
/// ``` /// ```
/// # #[macro_use] extern crate approx; /// # #[macro_use] extern crate approx;
/// # use nalgebra::{Matrix3x2, Matrix3x4, Matrix2x4, Complex}; /// # use nalgebra::{Matrix3x2, Matrix3x4, Matrix2x4, Complex};
@ -921,8 +906,7 @@ where
/// If `beta` is zero, `self` is never read. The result is symmetric. Only the lower-triangular /// If `beta` is zero, `self` is never read. The result is symmetric. Only the lower-triangular
/// (including the diagonal) part of `self` is read/written. /// (including the diagonal) part of `self` is read/written.
/// ///
/// # Examples: /// # Example
///
/// ``` /// ```
/// # use nalgebra::{Matrix2, Vector2}; /// # use nalgebra::{Matrix2, Vector2};
/// let mut mat = Matrix2::identity(); /// let mut mat = Matrix2::identity();
@ -934,6 +918,7 @@ where
/// mat.ger_symm(10.0, &vec1, &vec2, 5.0); /// mat.ger_symm(10.0, &vec1, &vec2, 5.0);
/// assert_eq!(mat.lower_triangle(), expected.lower_triangle()); /// assert_eq!(mat.lower_triangle(), expected.lower_triangle());
/// assert_eq!(mat.m12, 99999.99999); // This was untouched. /// assert_eq!(mat.m12, 99999.99999); // This was untouched.
/// ```
#[inline] #[inline]
#[deprecated(note = "This is renamed `syger` to match the original BLAS terminology.")] #[deprecated(note = "This is renamed `syger` to match the original BLAS terminology.")]
pub fn ger_symm<D2: Dim, D3: Dim, SB, SC>( pub fn ger_symm<D2: Dim, D3: Dim, SB, SC>(
@ -958,8 +943,7 @@ where
/// If `beta` is zero, `self` is never read. The result is symmetric. Only the lower-triangular /// If `beta` is zero, `self` is never read. The result is symmetric. Only the lower-triangular
/// (including the diagonal) part of `self` is read/written. /// (including the diagonal) part of `self` is read/written.
/// ///
/// # Examples: /// # Example
///
/// ``` /// ```
/// # use nalgebra::{Matrix2, Vector2}; /// # use nalgebra::{Matrix2, Vector2};
/// let mut mat = Matrix2::identity(); /// let mut mat = Matrix2::identity();
@ -971,6 +955,7 @@ where
/// mat.syger(10.0, &vec1, &vec2, 5.0); /// mat.syger(10.0, &vec1, &vec2, 5.0);
/// assert_eq!(mat.lower_triangle(), expected.lower_triangle()); /// assert_eq!(mat.lower_triangle(), expected.lower_triangle());
/// assert_eq!(mat.m12, 99999.99999); // This was untouched. /// assert_eq!(mat.m12, 99999.99999); // This was untouched.
/// ```
#[inline] #[inline]
pub fn syger<D2: Dim, D3: Dim, SB, SC>( pub fn syger<D2: Dim, D3: Dim, SB, SC>(
&mut self, &mut self,
@ -993,8 +978,7 @@ where
/// If `beta` is zero, `self` is never read. The result is symmetric. Only the lower-triangular /// If `beta` is zero, `self` is never read. The result is symmetric. Only the lower-triangular
/// (including the diagonal) part of `self` is read/written. /// (including the diagonal) part of `self` is read/written.
/// ///
/// # Examples: /// # Example
///
/// ``` /// ```
/// # use nalgebra::{Matrix2, Vector2, Complex}; /// # use nalgebra::{Matrix2, Vector2, Complex};
/// let mut mat = Matrix2::identity(); /// let mut mat = Matrix2::identity();
@ -1006,6 +990,7 @@ where
/// mat.hegerc(Complex::new(10.0, 20.0), &vec1, &vec2, Complex::new(5.0, 15.0)); /// mat.hegerc(Complex::new(10.0, 20.0), &vec1, &vec2, Complex::new(5.0, 15.0));
/// assert_eq!(mat.lower_triangle(), expected.lower_triangle()); /// assert_eq!(mat.lower_triangle(), expected.lower_triangle());
/// assert_eq!(mat.m12, Complex::new(99999.99999, 88888.88888)); // This was untouched. /// assert_eq!(mat.m12, Complex::new(99999.99999, 88888.88888)); // This was untouched.
/// ```
#[inline] #[inline]
pub fn hegerc<D2: Dim, D3: Dim, SB, SC>( pub fn hegerc<D2: Dim, D3: Dim, SB, SC>(
&mut self, &mut self,
@ -1031,8 +1016,7 @@ where
/// ///
/// This uses the provided workspace `work` to avoid allocations for intermediate results. /// This uses the provided workspace `work` to avoid allocations for intermediate results.
/// ///
/// # Examples: /// # Example
///
/// ``` /// ```
/// # #[macro_use] extern crate approx; /// # #[macro_use] extern crate approx;
/// # use nalgebra::{DMatrix, DVector}; /// # use nalgebra::{DMatrix, DVector};
@ -1053,6 +1037,7 @@ where
/// ///
/// mat.quadform_tr_with_workspace(&mut workspace, 10.0, &lhs, &mid, 5.0); /// mat.quadform_tr_with_workspace(&mut workspace, 10.0, &lhs, &mid, 5.0);
/// assert_relative_eq!(mat, expected); /// assert_relative_eq!(mat, expected);
/// ```
pub fn quadform_tr_with_workspace<D2, S2, R3, C3, S3, D4, S4>( pub fn quadform_tr_with_workspace<D2, S2, R3, C3, S3, D4, S4>(
&mut self, &mut self,
work: &mut Vector<T, D2, S2>, work: &mut Vector<T, D2, S2>,
@ -1085,8 +1070,7 @@ where
/// If `D1` is a type-level integer, then the allocation is performed on the stack. /// If `D1` is a type-level integer, then the allocation is performed on the stack.
/// Use `.quadform_tr_with_workspace(...)` instead to avoid allocations. /// Use `.quadform_tr_with_workspace(...)` instead to avoid allocations.
/// ///
/// # Examples: /// # Example
///
/// ``` /// ```
/// # #[macro_use] extern crate approx; /// # #[macro_use] extern crate approx;
/// # use nalgebra::{Matrix2, Matrix3, Matrix2x3, Vector2}; /// # use nalgebra::{Matrix2, Matrix3, Matrix2x3, Vector2};
@ -1100,6 +1084,7 @@ where
/// ///
/// mat.quadform_tr(10.0, &lhs, &mid, 5.0); /// mat.quadform_tr(10.0, &lhs, &mid, 5.0);
/// assert_relative_eq!(mat, expected); /// assert_relative_eq!(mat, expected);
/// ```
pub fn quadform_tr<R3, C3, S3, D4, S4>( pub fn quadform_tr<R3, C3, S3, D4, S4>(
&mut self, &mut self,
alpha: T, alpha: T,
@ -1124,6 +1109,7 @@ where
/// ///
/// This uses the provided workspace `work` to avoid allocations for intermediate results. /// This uses the provided workspace `work` to avoid allocations for intermediate results.
/// ///
/// # Example
/// ``` /// ```
/// # #[macro_use] extern crate approx; /// # #[macro_use] extern crate approx;
/// # use nalgebra::{DMatrix, DVector}; /// # use nalgebra::{DMatrix, DVector};
@ -1145,6 +1131,7 @@ where
/// ///
/// mat.quadform_with_workspace(&mut workspace, 10.0, &mid, &rhs, 5.0); /// mat.quadform_with_workspace(&mut workspace, 10.0, &mid, &rhs, 5.0);
/// assert_relative_eq!(mat, expected); /// assert_relative_eq!(mat, expected);
/// ```
pub fn quadform_with_workspace<D2, S2, D3, S3, R4, C4, S4>( pub fn quadform_with_workspace<D2, S2, D3, S3, R4, C4, S4>(
&mut self, &mut self,
work: &mut Vector<T, D2, S2>, work: &mut Vector<T, D2, S2>,
@ -1180,6 +1167,7 @@ where
/// If `D2` is a type-level integer, then the allocation is performed on the stack. /// If `D2` is a type-level integer, then the allocation is performed on the stack.
/// Use `.quadform_with_workspace(...)` instead to avoid allocations. /// Use `.quadform_with_workspace(...)` instead to avoid allocations.
/// ///
/// # Example
/// ``` /// ```
/// # #[macro_use] extern crate approx; /// # #[macro_use] extern crate approx;
/// # use nalgebra::{Matrix2, Matrix3x2, Matrix3}; /// # use nalgebra::{Matrix2, Matrix3x2, Matrix3};
@ -1194,6 +1182,7 @@ where
/// ///
/// mat.quadform(10.0, &mid, &rhs, 5.0); /// mat.quadform(10.0, &mid, &rhs, 5.0);
/// assert_relative_eq!(mat, expected); /// assert_relative_eq!(mat, expected);
/// ```
pub fn quadform<D2, S2, R3, C3, S3>( pub fn quadform<D2, S2, R3, C3, S3>(
&mut self, &mut self,
alpha: T, alpha: T,

View File

@ -411,8 +411,6 @@ where
{ {
/// Assumes a matrix's entries to be initialized. This operation should be near zero-cost. /// Assumes a matrix's entries to be initialized. This operation should be near zero-cost.
/// ///
/// For the similar method that operates on matrix slices, see [`slice_assume_init`].
///
/// # Safety /// # Safety
/// The user must make sure that every single entry of the buffer has been initialized, /// The user must make sure that every single entry of the buffer has been initialized,
/// or Undefined Behavior will immediately occur. /// or Undefined Behavior will immediately occur.
@ -433,12 +431,12 @@ impl<T, R: Dim, C: Dim, S: RawStorage<T, R, C>> Matrix<T, R, C, S> {
/// The shape of this matrix returned as the tuple (number of rows, number of columns). /// The shape of this matrix returned as the tuple (number of rows, number of columns).
/// ///
/// # Examples: /// # Example
///
/// ``` /// ```
/// # use nalgebra::Matrix3x4; /// # use nalgebra::Matrix3x4;
/// let mat = Matrix3x4::<f32>::zeros(); /// let mat = Matrix3x4::<f32>::zeros();
/// assert_eq!(mat.shape(), (3, 4)); /// assert_eq!(mat.shape(), (3, 4));
/// ```
#[inline] #[inline]
#[must_use] #[must_use]
pub fn shape(&self) -> (usize, usize) { pub fn shape(&self) -> (usize, usize) {
@ -455,12 +453,12 @@ impl<T, R: Dim, C: Dim, S: RawStorage<T, R, C>> Matrix<T, R, C, S> {
/// The number of rows of this matrix. /// The number of rows of this matrix.
/// ///
/// # Examples: /// # Example
///
/// ``` /// ```
/// # use nalgebra::Matrix3x4; /// # use nalgebra::Matrix3x4;
/// let mat = Matrix3x4::<f32>::zeros(); /// let mat = Matrix3x4::<f32>::zeros();
/// assert_eq!(mat.nrows(), 3); /// assert_eq!(mat.nrows(), 3);
/// ```
#[inline] #[inline]
#[must_use] #[must_use]
pub fn nrows(&self) -> usize { pub fn nrows(&self) -> usize {
@ -469,12 +467,12 @@ impl<T, R: Dim, C: Dim, S: RawStorage<T, R, C>> Matrix<T, R, C, S> {
/// The number of columns of this matrix. /// The number of columns of this matrix.
/// ///
/// # Examples: /// # Example
///
/// ``` /// ```
/// # use nalgebra::Matrix3x4; /// # use nalgebra::Matrix3x4;
/// let mat = Matrix3x4::<f32>::zeros(); /// let mat = Matrix3x4::<f32>::zeros();
/// assert_eq!(mat.ncols(), 4); /// assert_eq!(mat.ncols(), 4);
/// ```
#[inline] #[inline]
#[must_use] #[must_use]
pub fn ncols(&self) -> usize { pub fn ncols(&self) -> usize {
@ -483,14 +481,14 @@ impl<T, R: Dim, C: Dim, S: RawStorage<T, R, C>> Matrix<T, R, C, S> {
/// The strides (row stride, column stride) of this matrix. /// The strides (row stride, column stride) of this matrix.
/// ///
/// # Examples: /// # Example
///
/// ``` /// ```
/// # use nalgebra::DMatrix; /// # use nalgebra::DMatrix;
/// let mat = DMatrix::<f32>::zeros(10, 10); /// let mat = DMatrix::<f32>::zeros(10, 10);
/// let slice = mat.slice_with_steps((0, 0), (5, 3), (1, 2)); /// let slice = mat.slice_with_steps((0, 0), (5, 3), (1, 2));
/// // The column strides is the number of steps (here 2) multiplied by the corresponding dimension. /// // The column strides is the number of steps (here 2) multiplied by the corresponding dimension.
/// assert_eq!(mat.strides(), (1, 10)); /// assert_eq!(mat.strides(), (1, 10));
/// ```
#[inline] #[inline]
#[must_use] #[must_use]
pub fn strides(&self) -> (usize, usize) { pub fn strides(&self) -> (usize, usize) {
@ -1085,8 +1083,7 @@ impl<T, R: Dim, C: Dim, S: RawStorage<T, R, C>> Matrix<T, R, C, S> {
impl<T, R: Dim, C: Dim, S: RawStorage<T, R, C>> Matrix<T, R, C, S> { impl<T, R: Dim, C: Dim, S: RawStorage<T, R, C>> Matrix<T, R, C, S> {
/// Iterates through this matrix coordinates in column-major order. /// Iterates through this matrix coordinates in column-major order.
/// ///
/// # Examples: /// # Example
///
/// ``` /// ```
/// # use nalgebra::Matrix2x3; /// # use nalgebra::Matrix2x3;
/// let mat = Matrix2x3::new(11, 12, 13, /// let mat = Matrix2x3::new(11, 12, 13,
@ -1099,6 +1096,7 @@ impl<T, R: Dim, C: Dim, S: RawStorage<T, R, C>> Matrix<T, R, C, S> {
/// assert_eq!(*it.next().unwrap(), 13); /// assert_eq!(*it.next().unwrap(), 13);
/// assert_eq!(*it.next().unwrap(), 23); /// assert_eq!(*it.next().unwrap(), 23);
/// assert!(it.next().is_none()); /// assert!(it.next().is_none());
/// ```
#[inline] #[inline]
pub fn iter(&self) -> MatrixIter<'_, T, R, C, S> { pub fn iter(&self) -> MatrixIter<'_, T, R, C, S> {
MatrixIter::new(&self.data) MatrixIter::new(&self.data)
@ -1121,6 +1119,7 @@ impl<T, R: Dim, C: Dim, S: RawStorage<T, R, C>> Matrix<T, R, C, S> {
} }
/// Iterate through the columns of this matrix. /// Iterate through the columns of this matrix.
///
/// # Example /// # Example
/// ``` /// ```
/// # use nalgebra::Matrix2x3; /// # use nalgebra::Matrix2x3;

View File

@ -19,6 +19,7 @@ use simba::scalar::{ClosedNeg, RealField};
/// `DualQuaternions` are stored as \[..real, ..dual\]. /// `DualQuaternions` are stored as \[..real, ..dual\].
/// Both of the quaternion components are laid out in `i, j, k, w` order. /// Both of the quaternion components are laid out in `i, j, k, w` order.
/// ///
/// # Example
/// ``` /// ```
/// # use nalgebra::{DualQuaternion, Quaternion}; /// # use nalgebra::{DualQuaternion, Quaternion};
/// ///
@ -620,6 +621,7 @@ where
/// dq.rotation().euler_angles().0, std::f32::consts::FRAC_PI_2, epsilon = 1.0e-6 /// dq.rotation().euler_angles().0, std::f32::consts::FRAC_PI_2, epsilon = 1.0e-6
/// ); /// );
/// assert_relative_eq!(dq.translation().vector.y, 3.0, epsilon = 1.0e-6); /// assert_relative_eq!(dq.translation().vector.y, 3.0, epsilon = 1.0e-6);
/// ```
#[inline] #[inline]
#[must_use] #[must_use]
pub fn sclerp(&self, other: &Self, t: T) -> Self pub fn sclerp(&self, other: &Self, t: T) -> Self
@ -710,6 +712,7 @@ where
/// Return the rotation part of this unit dual quaternion. /// Return the rotation part of this unit dual quaternion.
/// ///
/// # Example
/// ``` /// ```
/// # #[macro_use] extern crate approx; /// # #[macro_use] extern crate approx;
/// # use nalgebra::{UnitDualQuaternion, UnitQuaternion, Vector3}; /// # use nalgebra::{UnitDualQuaternion, UnitQuaternion, Vector3};
@ -730,6 +733,7 @@ where
/// Return the translation part of this unit dual quaternion. /// Return the translation part of this unit dual quaternion.
/// ///
/// # Example
/// ``` /// ```
/// # #[macro_use] extern crate approx; /// # #[macro_use] extern crate approx;
/// # use nalgebra::{UnitDualQuaternion, UnitQuaternion, Vector3}; /// # use nalgebra::{UnitDualQuaternion, UnitQuaternion, Vector3};
@ -755,6 +759,7 @@ where
/// Builds an isometry from this unit dual quaternion. /// Builds an isometry from this unit dual quaternion.
/// ///
/// # Example
/// ``` /// ```
/// # #[macro_use] extern crate approx; /// # #[macro_use] extern crate approx;
/// # use nalgebra::{UnitDualQuaternion, UnitQuaternion, Vector3}; /// # use nalgebra::{UnitDualQuaternion, UnitQuaternion, Vector3};
@ -780,6 +785,7 @@ where
/// ///
/// This is the same as the multiplication `self * pt`. /// This is the same as the multiplication `self * pt`.
/// ///
/// # Example
/// ``` /// ```
/// # #[macro_use] extern crate approx; /// # #[macro_use] extern crate approx;
/// # use nalgebra::{UnitDualQuaternion, UnitQuaternion, Vector3, Point3}; /// # use nalgebra::{UnitDualQuaternion, UnitQuaternion, Vector3, Point3};
@ -804,6 +810,7 @@ where
/// ///
/// This is the same as the multiplication `self * v`. /// This is the same as the multiplication `self * v`.
/// ///
/// # Example
/// ``` /// ```
/// # #[macro_use] extern crate approx; /// # #[macro_use] extern crate approx;
/// # use nalgebra::{UnitDualQuaternion, UnitQuaternion, Vector3}; /// # use nalgebra::{UnitDualQuaternion, UnitQuaternion, Vector3};
@ -828,6 +835,7 @@ where
/// This may be cheaper than inverting the unit dual quaternion and /// This may be cheaper than inverting the unit dual quaternion and
/// transforming the point. /// transforming the point.
/// ///
/// # Example
/// ``` /// ```
/// # #[macro_use] extern crate approx; /// # #[macro_use] extern crate approx;
/// # use nalgebra::{UnitDualQuaternion, UnitQuaternion, Vector3, Point3}; /// # use nalgebra::{UnitDualQuaternion, UnitQuaternion, Vector3, Point3};
@ -853,6 +861,7 @@ where
/// This may be cheaper than inverting the unit dual quaternion and /// This may be cheaper than inverting the unit dual quaternion and
/// transforming the vector. /// transforming the vector.
/// ///
/// # Example
/// ``` /// ```
/// # #[macro_use] extern crate approx; /// # #[macro_use] extern crate approx;
/// # use nalgebra::{UnitDualQuaternion, UnitQuaternion, Vector3}; /// # use nalgebra::{UnitDualQuaternion, UnitQuaternion, Vector3};
@ -877,6 +886,7 @@ where
/// cheaper than inverting the unit dual quaternion and transforming the /// cheaper than inverting the unit dual quaternion and transforming the
/// vector. /// vector.
/// ///
/// # Example
/// ``` /// ```
/// # #[macro_use] extern crate approx; /// # #[macro_use] extern crate approx;
/// # use nalgebra::{UnitDualQuaternion, UnitQuaternion, Unit, Vector3}; /// # use nalgebra::{UnitDualQuaternion, UnitQuaternion, Unit, Vector3};
@ -906,6 +916,7 @@ where
/// Converts this unit dual quaternion interpreted as an isometry /// Converts this unit dual quaternion interpreted as an isometry
/// into its equivalent homogeneous transformation matrix. /// into its equivalent homogeneous transformation matrix.
/// ///
/// # Example
/// ``` /// ```
/// # #[macro_use] extern crate approx; /// # #[macro_use] extern crate approx;
/// # use nalgebra::{Matrix4, UnitDualQuaternion, UnitQuaternion, Vector3}; /// # use nalgebra::{Matrix4, UnitDualQuaternion, UnitQuaternion, Vector3};

View File

@ -27,7 +27,6 @@ impl<T: Scalar> DualQuaternion<T> {
/// The dual quaternion multiplicative identity. /// The dual quaternion multiplicative identity.
/// ///
/// # Example /// # Example
///
/// ``` /// ```
/// # use nalgebra::{DualQuaternion, Quaternion}; /// # use nalgebra::{DualQuaternion, Quaternion};
/// ///
@ -134,6 +133,7 @@ impl<T: SimdRealField> UnitDualQuaternion<T> {
/// The unit dual quaternion multiplicative identity, which also represents /// The unit dual quaternion multiplicative identity, which also represents
/// the identity transformation as an isometry. /// the identity transformation as an isometry.
/// ///
/// # Example
/// ``` /// ```
/// # use nalgebra::{UnitDualQuaternion, UnitQuaternion, Vector3, Point3}; /// # use nalgebra::{UnitDualQuaternion, UnitQuaternion, Vector3, Point3};
/// let ident = UnitDualQuaternion::identity(); /// let ident = UnitDualQuaternion::identity();
@ -171,6 +171,7 @@ where
/// Return a dual quaternion representing the translation and orientation /// Return a dual quaternion representing the translation and orientation
/// given by the provided rotation quaternion and translation vector. /// given by the provided rotation quaternion and translation vector.
/// ///
/// # Example
/// ``` /// ```
/// # #[macro_use] extern crate approx; /// # #[macro_use] extern crate approx;
/// # use nalgebra::{UnitDualQuaternion, UnitQuaternion, Vector3, Point3}; /// # use nalgebra::{UnitDualQuaternion, UnitQuaternion, Vector3, Point3};
@ -196,6 +197,7 @@ where
/// Return a unit dual quaternion representing the translation and orientation /// Return a unit dual quaternion representing the translation and orientation
/// given by the provided isometry. /// given by the provided isometry.
/// ///
/// # Example
/// ``` /// ```
/// # #[macro_use] extern crate approx; /// # #[macro_use] extern crate approx;
/// # use nalgebra::{Isometry3, UnitDualQuaternion, UnitQuaternion, Vector3, Point3}; /// # use nalgebra::{Isometry3, UnitDualQuaternion, UnitQuaternion, Vector3, Point3};

View File

@ -316,6 +316,7 @@ impl<T: RealField> Orthographic3<T> {
/// The left offset of the view cuboid. /// The left offset of the view cuboid.
/// ///
/// # Example
/// ``` /// ```
/// # #[macro_use] extern crate approx; /// # #[macro_use] extern crate approx;
/// # use nalgebra::Orthographic3; /// # use nalgebra::Orthographic3;
@ -333,6 +334,7 @@ impl<T: RealField> Orthographic3<T> {
/// The right offset of the view cuboid. /// The right offset of the view cuboid.
/// ///
/// # Example
/// ``` /// ```
/// # #[macro_use] extern crate approx; /// # #[macro_use] extern crate approx;
/// # use nalgebra::Orthographic3; /// # use nalgebra::Orthographic3;
@ -350,6 +352,7 @@ impl<T: RealField> Orthographic3<T> {
/// The bottom offset of the view cuboid. /// The bottom offset of the view cuboid.
/// ///
/// # Example
/// ``` /// ```
/// # #[macro_use] extern crate approx; /// # #[macro_use] extern crate approx;
/// # use nalgebra::Orthographic3; /// # use nalgebra::Orthographic3;
@ -367,6 +370,7 @@ impl<T: RealField> Orthographic3<T> {
/// The top offset of the view cuboid. /// The top offset of the view cuboid.
/// ///
/// # Example
/// ``` /// ```
/// # #[macro_use] extern crate approx; /// # #[macro_use] extern crate approx;
/// # use nalgebra::Orthographic3; /// # use nalgebra::Orthographic3;
@ -384,6 +388,7 @@ impl<T: RealField> Orthographic3<T> {
/// The near plane offset of the view cuboid. /// The near plane offset of the view cuboid.
/// ///
/// # Example
/// ``` /// ```
/// # #[macro_use] extern crate approx; /// # #[macro_use] extern crate approx;
/// # use nalgebra::Orthographic3; /// # use nalgebra::Orthographic3;
@ -401,6 +406,7 @@ impl<T: RealField> Orthographic3<T> {
/// The far plane offset of the view cuboid. /// The far plane offset of the view cuboid.
/// ///
/// # Example
/// ``` /// ```
/// # #[macro_use] extern crate approx; /// # #[macro_use] extern crate approx;
/// # use nalgebra::Orthographic3; /// # use nalgebra::Orthographic3;
@ -523,6 +529,7 @@ impl<T: RealField> Orthographic3<T> {
/// Sets the left offset of the view cuboid. /// Sets the left offset of the view cuboid.
/// ///
/// # Example
/// ``` /// ```
/// # #[macro_use] extern crate approx; /// # #[macro_use] extern crate approx;
/// # use nalgebra::Orthographic3; /// # use nalgebra::Orthographic3;
@ -542,6 +549,7 @@ impl<T: RealField> Orthographic3<T> {
/// Sets the right offset of the view cuboid. /// Sets the right offset of the view cuboid.
/// ///
/// # Example
/// ``` /// ```
/// # #[macro_use] extern crate approx; /// # #[macro_use] extern crate approx;
/// # use nalgebra::Orthographic3; /// # use nalgebra::Orthographic3;
@ -561,6 +569,7 @@ impl<T: RealField> Orthographic3<T> {
/// Sets the bottom offset of the view cuboid. /// Sets the bottom offset of the view cuboid.
/// ///
/// # Example
/// ``` /// ```
/// # #[macro_use] extern crate approx; /// # #[macro_use] extern crate approx;
/// # use nalgebra::Orthographic3; /// # use nalgebra::Orthographic3;
@ -580,6 +589,7 @@ impl<T: RealField> Orthographic3<T> {
/// Sets the top offset of the view cuboid. /// Sets the top offset of the view cuboid.
/// ///
/// # Example
/// ``` /// ```
/// # #[macro_use] extern crate approx; /// # #[macro_use] extern crate approx;
/// # use nalgebra::Orthographic3; /// # use nalgebra::Orthographic3;
@ -599,6 +609,7 @@ impl<T: RealField> Orthographic3<T> {
/// Sets the near plane offset of the view cuboid. /// Sets the near plane offset of the view cuboid.
/// ///
/// # Example
/// ``` /// ```
/// # #[macro_use] extern crate approx; /// # #[macro_use] extern crate approx;
/// # use nalgebra::Orthographic3; /// # use nalgebra::Orthographic3;
@ -618,6 +629,7 @@ impl<T: RealField> Orthographic3<T> {
/// Sets the far plane offset of the view cuboid. /// Sets the far plane offset of the view cuboid.
/// ///
/// # Example
/// ``` /// ```
/// # #[macro_use] extern crate approx; /// # #[macro_use] extern crate approx;
/// # use nalgebra::Orthographic3; /// # use nalgebra::Orthographic3;
@ -637,6 +649,7 @@ impl<T: RealField> Orthographic3<T> {
/// Sets the view cuboid offsets along the `x` axis. /// Sets the view cuboid offsets along the `x` axis.
/// ///
/// # Example
/// ``` /// ```
/// # #[macro_use] extern crate approx; /// # #[macro_use] extern crate approx;
/// # use nalgebra::Orthographic3; /// # use nalgebra::Orthographic3;
@ -662,6 +675,7 @@ impl<T: RealField> Orthographic3<T> {
/// Sets the view cuboid offsets along the `y` axis. /// Sets the view cuboid offsets along the `y` axis.
/// ///
/// # Example
/// ``` /// ```
/// # #[macro_use] extern crate approx; /// # #[macro_use] extern crate approx;
/// # use nalgebra::Orthographic3; /// # use nalgebra::Orthographic3;
@ -687,6 +701,7 @@ impl<T: RealField> Orthographic3<T> {
/// Sets the near and far plane offsets of the view cuboid. /// Sets the near and far plane offsets of the view cuboid.
/// ///
/// # Example
/// ``` /// ```
/// # #[macro_use] extern crate approx; /// # #[macro_use] extern crate approx;
/// # use nalgebra::Orthographic3; /// # use nalgebra::Orthographic3;

View File

@ -266,6 +266,7 @@ where
/// assert_eq!(it.next(), Some(2.0)); /// assert_eq!(it.next(), Some(2.0));
/// assert_eq!(it.next(), Some(3.0)); /// assert_eq!(it.next(), Some(3.0));
/// assert_eq!(it.next(), None); /// assert_eq!(it.next(), None);
/// ```
#[inline] #[inline]
pub fn iter( pub fn iter(
&self, &self,
@ -292,6 +293,7 @@ where
/// } /// }
/// ///
/// assert_eq!(p, Point3::new(10.0, 20.0, 30.0)); /// assert_eq!(p, Point3::new(10.0, 20.0, 30.0));
/// ```
#[inline] #[inline]
pub fn iter_mut( pub fn iter_mut(
&mut self, &mut self,

View File

@ -402,6 +402,7 @@ where
/// let expected = Quaternion::new(-20.0, 0.0, 0.0, 0.0); /// let expected = Quaternion::new(-20.0, 0.0, 0.0, 0.0);
/// let result = a.inner(&b); /// let result = a.inner(&b);
/// assert_relative_eq!(expected, result, epsilon = 1.0e-5); /// assert_relative_eq!(expected, result, epsilon = 1.0e-5);
/// ```
#[inline] #[inline]
#[must_use] #[must_use]
pub fn inner(&self, other: &Self) -> Self { pub fn inner(&self, other: &Self) -> Self {
@ -1227,8 +1228,7 @@ where
/// Panics if the angle between both quaternion is 180 degrees (in which case the interpolation /// Panics if the angle between both quaternion is 180 degrees (in which case the interpolation
/// is not well-defined). Use `.try_slerp` instead to avoid the panic. /// is not well-defined). Use `.try_slerp` instead to avoid the panic.
/// ///
/// # Examples: /// # Example
///
/// ``` /// ```
/// # use nalgebra::geometry::UnitQuaternion; /// # use nalgebra::geometry::UnitQuaternion;
/// ///
@ -1450,7 +1450,6 @@ where
/// Builds a rotation matrix from this unit quaternion. /// Builds a rotation matrix from this unit quaternion.
/// ///
/// # Example /// # Example
///
/// ``` /// ```
/// # #[macro_use] extern crate approx; /// # #[macro_use] extern crate approx;
/// # use std::f32; /// # use std::f32;
@ -1533,7 +1532,6 @@ where
/// Converts this unit quaternion into its equivalent homogeneous transformation matrix. /// Converts this unit quaternion into its equivalent homogeneous transformation matrix.
/// ///
/// # Example /// # Example
///
/// ``` /// ```
/// # #[macro_use] extern crate approx; /// # #[macro_use] extern crate approx;
/// # use std::f32; /// # use std::f32;
@ -1557,7 +1555,6 @@ where
/// This is the same as the multiplication `self * pt`. /// This is the same as the multiplication `self * pt`.
/// ///
/// # Example /// # Example
///
/// ``` /// ```
/// # #[macro_use] extern crate approx; /// # #[macro_use] extern crate approx;
/// # use std::f32; /// # use std::f32;
@ -1578,7 +1575,6 @@ where
/// This is the same as the multiplication `self * v`. /// This is the same as the multiplication `self * v`.
/// ///
/// # Example /// # Example
///
/// ``` /// ```
/// # #[macro_use] extern crate approx; /// # #[macro_use] extern crate approx;
/// # use std::f32; /// # use std::f32;
@ -1599,7 +1595,6 @@ where
/// point. /// point.
/// ///
/// # Example /// # Example
///
/// ``` /// ```
/// # #[macro_use] extern crate approx; /// # #[macro_use] extern crate approx;
/// # use std::f32; /// # use std::f32;
@ -1622,7 +1617,6 @@ where
/// vector. /// vector.
/// ///
/// # Example /// # Example
///
/// ``` /// ```
/// # #[macro_use] extern crate approx; /// # #[macro_use] extern crate approx;
/// # use std::f32; /// # use std::f32;
@ -1643,7 +1637,6 @@ where
/// vector. /// vector.
/// ///
/// # Example /// # Example
///
/// ``` /// ```
/// # #[macro_use] extern crate approx; /// # #[macro_use] extern crate approx;
/// # use std::f32; /// # use std::f32;

View File

@ -38,7 +38,6 @@ where
/// Creates a new identity similarity. /// Creates a new identity similarity.
/// ///
/// # Example /// # Example
///
/// ``` /// ```
/// # use nalgebra::{Similarity2, Point2, Similarity3, Point3}; /// # use nalgebra::{Similarity2, Point2, Similarity3, Point3};
/// ///
@ -95,7 +94,6 @@ where
/// its axis passing through the point `p`. /// its axis passing through the point `p`.
/// ///
/// # Example /// # Example
///
/// ``` /// ```
/// # #[macro_use] extern crate approx; /// # #[macro_use] extern crate approx;
/// # use std::f32; /// # use std::f32;
@ -146,7 +144,6 @@ where
/// Creates a new similarity from a translation, a rotation, and an uniform scaling factor. /// Creates a new similarity from a translation, a rotation, and an uniform scaling factor.
/// ///
/// # Example /// # Example
///
/// ``` /// ```
/// # #[macro_use] extern crate approx; /// # #[macro_use] extern crate approx;
/// # use std::f32; /// # use std::f32;
@ -188,7 +185,6 @@ where
/// Creates a new similarity from a translation and a rotation angle. /// Creates a new similarity from a translation and a rotation angle.
/// ///
/// # Example /// # Example
///
/// ``` /// ```
/// # #[macro_use] extern crate approx; /// # #[macro_use] extern crate approx;
/// # use std::f32; /// # use std::f32;
@ -232,7 +228,6 @@ macro_rules! similarity_construction_impl(
/// factor. /// factor.
/// ///
/// # Example /// # Example
///
/// ``` /// ```
/// # #[macro_use] extern crate approx; /// # #[macro_use] extern crate approx;
/// # use std::f32; /// # use std::f32;
@ -288,7 +283,6 @@ macro_rules! similarity_construction_impl(
/// to `eye - at`. Non-collinearity is not checked. /// to `eye - at`. Non-collinearity is not checked.
/// ///
/// # Example /// # Example
///
/// ``` /// ```
/// # #[macro_use] extern crate approx; /// # #[macro_use] extern crate approx;
/// # use std::f32; /// # use std::f32;
@ -316,7 +310,7 @@ macro_rules! similarity_construction_impl(
Self::from_isometry(Isometry::<_, $Rot<T>, 3>::face_towards(eye, target, up), scaling) Self::from_isometry(Isometry::<_, $Rot<T>, 3>::face_towards(eye, target, up), scaling)
} }
/// Deprecated: Use [`SimilarityMatrix3::face_towards`] instead. /// Deprecated: Use [`SimilarityMatrix3::face_towards`](Self::face_towards) instead.
#[deprecated(note="renamed to `face_towards`")] #[deprecated(note="renamed to `face_towards`")]
pub fn new_observer_frames(eye: &Point3<T>, pub fn new_observer_frames(eye: &Point3<T>,
target: &Point3<T>, target: &Point3<T>,
@ -338,7 +332,6 @@ macro_rules! similarity_construction_impl(
/// requirement of this parameter is to not be collinear to `target - eye`. /// requirement of this parameter is to not be collinear to `target - eye`.
/// ///
/// # Example /// # Example
///
/// ``` /// ```
/// # #[macro_use] extern crate approx; /// # #[macro_use] extern crate approx;
/// # use std::f32; /// # use std::f32;
@ -376,7 +369,6 @@ macro_rules! similarity_construction_impl(
/// requirement of this parameter is to not be collinear to `target - eye`. /// requirement of this parameter is to not be collinear to `target - eye`.
/// ///
/// # Example /// # Example
///
/// ``` /// ```
/// # #[macro_use] extern crate approx; /// # #[macro_use] extern crate approx;
/// # use std::f32; /// # use std::f32;

View File

@ -228,6 +228,7 @@ impl<T: Scalar + ClosedAdd, const D: usize> Translation<T, D> {
/// let t = Translation3::new(1.0, 2.0, 3.0); /// let t = Translation3::new(1.0, 2.0, 3.0);
/// let transformed_point = t.transform_point(&Point3::new(4.0, 5.0, 6.0)); /// let transformed_point = t.transform_point(&Point3::new(4.0, 5.0, 6.0));
/// assert_eq!(transformed_point, Point3::new(5.0, 7.0, 9.0)); /// assert_eq!(transformed_point, Point3::new(5.0, 7.0, 9.0));
/// ```
#[inline] #[inline]
#[must_use] #[must_use]
pub fn transform_point(&self, pt: &Point<T, D>) -> Point<T, D> { pub fn transform_point(&self, pt: &Point<T, D>) -> Point<T, D> {
@ -244,6 +245,7 @@ impl<T: Scalar + ClosedSub, const D: usize> Translation<T, D> {
/// let t = Translation3::new(1.0, 2.0, 3.0); /// let t = Translation3::new(1.0, 2.0, 3.0);
/// let transformed_point = t.inverse_transform_point(&Point3::new(4.0, 5.0, 6.0)); /// let transformed_point = t.inverse_transform_point(&Point3::new(4.0, 5.0, 6.0));
/// assert_eq!(transformed_point, Point3::new(3.0, 3.0, 3.0)); /// assert_eq!(transformed_point, Point3::new(3.0, 3.0, 3.0));
/// ```
#[inline] #[inline]
#[must_use] #[must_use]
pub fn inverse_transform_point(&self, pt: &Point<T, D>) -> Point<T, D> { pub fn inverse_transform_point(&self, pt: &Point<T, D>) -> Point<T, D> {

View File

@ -246,8 +246,8 @@ pub fn min<T: Ord>(a: T, b: T) -> T {
/// The absolute value of `a`. /// The absolute value of `a`.
/// ///
/// Deprecated: Use [`Matrix::abs`] or [`RealField::abs`] instead. /// Deprecated: Use [`Matrix::abs`] or [`ComplexField::abs`] instead.
#[deprecated(note = "use the inherent method `Matrix::abs` or `RealField::abs` instead")] #[deprecated(note = "use the inherent method `Matrix::abs` or `ComplexField::abs` instead")]
#[inline] #[inline]
pub fn abs<T: Signed>(a: &T) -> T { pub fn abs<T: Signed>(a: &T) -> T {
a.abs() a.abs()