logo
#[repr(C)]
pub struct X2<Scalar: ScalarInterface>(pub Scalar, pub Scalar);
Expand description

Vector X2

Tuple Fields

0: Scalar1: Scalar

Methods from Deref<Target = Vector2<Scalar>>

The dot product between two vectors or matrices (seen as vectors).

This is equal to self.transpose() * rhs. For the sesquilinear complex dot product, use self.dotc(rhs).

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.

Example
let vec1 = Vector3::new(1.0, 2.0, 3.0);
let vec2 = Vector3::new(0.1, 0.2, 0.3);
assert_eq!(vec1.dot(&vec2), 1.4);

let mat1 = Matrix2x3::new(1.0, 2.0, 3.0,
                          4.0, 5.0, 6.0);
let mat2 = Matrix2x3::new(0.1, 0.2, 0.3,
                          0.4, 0.5, 0.6);
assert_eq!(mat1.dot(&mat2), 9.1);

The conjugate-linear dot product between two vectors or matrices (seen as vectors).

This is equal to self.adjoint() * rhs. For real vectors, this is identical to self.dot(&rhs). 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.

Example
let vec1 = Vector2::new(Complex::new(1.0, 2.0), Complex::new(3.0, 4.0));
let vec2 = Vector2::new(Complex::new(0.4, 0.3), Complex::new(0.2, 0.1));
assert_eq!(vec1.dotc(&vec2), Complex::new(2.0, -1.0));

// Note that for complex vectors, we generally have:
// vec1.dotc(&vec2) != vec2.dot(&vec2)
assert_ne!(vec1.dotc(&vec2), vec1.dot(&vec2));

The dot product between the transpose of self and rhs.

Example
let vec1 = Vector3::new(1.0, 2.0, 3.0);
let vec2 = RowVector3::new(0.1, 0.2, 0.3);
assert_eq!(vec1.tr_dot(&vec2), 1.4);

let mat1 = Matrix2x3::new(1.0, 2.0, 3.0,
                          4.0, 5.0, 6.0);
let mat2 = Matrix3x2::new(0.1, 0.4,
                          0.2, 0.5,
                          0.3, 0.6);
assert_eq!(mat1.tr_dot(&mat2), 9.1);

Computes self = a * x * c + b * self.

If b is zero, self is never read from.

Example
let mut vec1 = Vector3::new(1.0, 2.0, 3.0);
let vec2 = Vector3::new(0.1, 0.2, 0.3);
vec1.axcpy(5.0, &vec2, 2.0, 5.0);
assert_eq!(vec1, Vector3::new(6.0, 12.0, 18.0));

Computes self = a * x + b * self.

If b is zero, self is never read from.

Example
let mut vec1 = Vector3::new(1.0, 2.0, 3.0);
let vec2 = Vector3::new(0.1, 0.2, 0.3);
vec1.axpy(10.0, &vec2, 5.0);
assert_eq!(vec1, Vector3::new(6.0, 12.0, 18.0));

Computes self = alpha * a * x + beta * self, where a is a matrix, x a vector, and alpha, beta two scalars.

If beta is zero, self is never read.

Example
let mut vec1 = Vector2::new(1.0, 2.0);
let vec2 = Vector2::new(0.1, 0.2);
let mat = Matrix2::new(1.0, 2.0,
                       3.0, 4.0);
vec1.gemv(10.0, &mat, &vec2, 5.0);
assert_eq!(vec1, Vector2::new(10.0, 21.0));

Computes self = alpha * a * x + beta * self, where a is a symmetric matrix, x a vector, and alpha, beta two scalars.

For hermitian matrices, use .hegemv instead. If beta is zero, self is never read. If self is read, only its lower-triangular part (including the diagonal) is actually read.

Examples
let mat = Matrix2::new(1.0, 2.0,
                       2.0, 4.0);
let mut vec1 = Vector2::new(1.0, 2.0);
let vec2 = Vector2::new(0.1, 0.2);
vec1.sygemv(10.0, &mat, &vec2, 5.0);
assert_eq!(vec1, Vector2::new(10.0, 20.0));


// The matrix upper-triangular elements can be garbage because it is never
// read by this method. Therefore, it is not necessary for the caller to
// fill the matrix struct upper-triangle.
let mat = Matrix2::new(1.0, 9999999.9999999,
                       2.0, 4.0);
let mut vec1 = Vector2::new(1.0, 2.0);
vec1.sygemv(10.0, &mat, &vec2, 5.0);
assert_eq!(vec1, Vector2::new(10.0, 20.0));

Computes self = alpha * a * x + beta * self, where a is an hermitian matrix, x a vector, and alpha, beta two scalars.

If beta is zero, self is never read. If self is read, only its lower-triangular part (including the diagonal) is actually read.

Examples
let mat = Matrix2::new(Complex::new(1.0, 0.0), Complex::new(2.0, -0.1),
                       Complex::new(2.0, 1.0), Complex::new(4.0, 0.0));
let mut vec1 = Vector2::new(Complex::new(1.0, 2.0), Complex::new(3.0, 4.0));
let vec2 = Vector2::new(Complex::new(0.1, 0.2), Complex::new(0.3, 0.4));
vec1.sygemv(Complex::new(10.0, 20.0), &mat, &vec2, Complex::new(5.0, 15.0));
assert_eq!(vec1, Vector2::new(Complex::new(-48.0, 44.0), Complex::new(-75.0, 110.0)));


// The matrix upper-triangular elements can be garbage because it is never
// read by this method. Therefore, it is not necessary for the caller to
// fill the matrix struct upper-triangle.

let mat = Matrix2::new(Complex::new(1.0, 0.0), Complex::new(99999999.9, 999999999.9),
                       Complex::new(2.0, 1.0), Complex::new(4.0, 0.0));
let mut vec1 = Vector2::new(Complex::new(1.0, 2.0), Complex::new(3.0, 4.0));
let vec2 = Vector2::new(Complex::new(0.1, 0.2), Complex::new(0.3, 0.4));
vec1.sygemv(Complex::new(10.0, 20.0), &mat, &vec2, Complex::new(5.0, 15.0));
assert_eq!(vec1, Vector2::new(Complex::new(-48.0, 44.0), Complex::new(-75.0, 110.0)));

Computes self = alpha * a.transpose() * x + beta * self, where a is a matrix, x a vector, and alpha, beta two scalars.

If beta is zero, self is never read.

Example
let mat = Matrix2::new(1.0, 3.0,
                       2.0, 4.0);
let mut vec1 = Vector2::new(1.0, 2.0);
let vec2 = Vector2::new(0.1, 0.2);
let expected = mat.transpose() * vec2 * 10.0 + vec1 * 5.0;

vec1.gemv_tr(10.0, &mat, &vec2, 5.0);
assert_eq!(vec1, expected);

Computes self = alpha * a.adjoint() * x + beta * self, where a is a matrix, x a vector, and alpha, beta two scalars.

For real matrices, this is the same as .gemv_tr. If beta is zero, self is never read.

Example
let mat = Matrix2::new(Complex::new(1.0, 2.0), Complex::new(3.0, 4.0),
                       Complex::new(5.0, 6.0), Complex::new(7.0, 8.0));
let mut vec1 = Vector2::new(Complex::new(1.0, 2.0), Complex::new(3.0, 4.0));
let vec2 = Vector2::new(Complex::new(0.1, 0.2), Complex::new(0.3, 0.4));
let expected = mat.adjoint() * vec2 * Complex::new(10.0, 20.0) + vec1 * Complex::new(5.0, 15.0);

vec1.gemv_ad(Complex::new(10.0, 20.0), &mat, &vec2, Complex::new(5.0, 15.0));
assert_eq!(vec1, expected);

Computes self = alpha * x * y.transpose() + beta * self.

If beta is zero, self is never read.

Example
let mut mat = Matrix2x3::repeat(4.0);
let vec1 = Vector2::new(1.0, 2.0);
let vec2 = Vector3::new(0.1, 0.2, 0.3);
let expected = vec1 * vec2.transpose() * 10.0 + mat * 5.0;

mat.ger(10.0, &vec1, &vec2, 5.0);
assert_eq!(mat, expected);

Computes self = alpha * x * y.adjoint() + beta * self.

If beta is zero, self is never read.

Example
let mut mat = Matrix2x3::repeat(Complex::new(4.0, 5.0));
let vec1 = Vector2::new(Complex::new(1.0, 2.0), Complex::new(3.0, 4.0));
let vec2 = Vector3::new(Complex::new(0.6, 0.5), Complex::new(0.4, 0.5), Complex::new(0.2, 0.1));
let expected = vec1 * vec2.adjoint() * Complex::new(10.0, 20.0) + mat * Complex::new(5.0, 15.0);

mat.gerc(Complex::new(10.0, 20.0), &vec1, &vec2, Complex::new(5.0, 15.0));
assert_eq!(mat, expected);

Computes self = alpha * a * b + beta * self, where a, b, self are matrices. alpha and beta are scalar.

If beta is zero, self is never read.

Example
let mut mat1 = Matrix2x4::identity();
let mat2 = Matrix2x3::new(1.0, 2.0, 3.0,
                          4.0, 5.0, 6.0);
let mat3 = Matrix3x4::new(0.1, 0.2, 0.3, 0.4,
                          0.5, 0.6, 0.7, 0.8,
                          0.9, 1.0, 1.1, 1.2);
let expected = mat2 * mat3 * 10.0 + mat1 * 5.0;

mat1.gemm(10.0, &mat2, &mat3, 5.0);
assert_relative_eq!(mat1, expected);

Computes self = alpha * a.transpose() * b + beta * self, where a, b, self are matrices. alpha and beta are scalar.

If beta is zero, self is never read.

Example
let mut mat1 = Matrix2x4::identity();
let mat2 = Matrix3x2::new(1.0, 4.0,
                          2.0, 5.0,
                          3.0, 6.0);
let mat3 = Matrix3x4::new(0.1, 0.2, 0.3, 0.4,
                          0.5, 0.6, 0.7, 0.8,
                          0.9, 1.0, 1.1, 1.2);
let expected = mat2.transpose() * mat3 * 10.0 + mat1 * 5.0;

mat1.gemm_tr(10.0, &mat2, &mat3, 5.0);
assert_eq!(mat1, expected);

Computes self = alpha * a.adjoint() * b + beta * self, where a, b, self are matrices. alpha and beta are scalar.

If beta is zero, self is never read.

Example
let mut mat1 = Matrix2x4::identity();
let mat2 = Matrix3x2::new(Complex::new(1.0, 4.0), Complex::new(7.0, 8.0),
                          Complex::new(2.0, 5.0), Complex::new(9.0, 10.0),
                          Complex::new(3.0, 6.0), Complex::new(11.0, 12.0));
let mat3 = Matrix3x4::new(Complex::new(0.1, 1.3), Complex::new(0.2, 1.4), Complex::new(0.3, 1.5), Complex::new(0.4, 1.6),
                          Complex::new(0.5, 1.7), Complex::new(0.6, 1.8), Complex::new(0.7, 1.9), Complex::new(0.8, 2.0),
                          Complex::new(0.9, 2.1), Complex::new(1.0, 2.2), Complex::new(1.1, 2.3), Complex::new(1.2, 2.4));
let expected = mat2.adjoint() * mat3 * Complex::new(10.0, 20.0) + mat1 * Complex::new(5.0, 15.0);

mat1.gemm_ad(Complex::new(10.0, 20.0), &mat2, &mat3, Complex::new(5.0, 15.0));
assert_eq!(mat1, expected);
👎 Deprecated:

This is renamed syger to match the original BLAS terminology.

Computes self = alpha * x * y.transpose() + beta * self, where self is a symmetric matrix.

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.

Example
let mut mat = Matrix2::identity();
let vec1 = Vector2::new(1.0, 2.0);
let vec2 = Vector2::new(0.1, 0.2);
let expected = vec1 * vec2.transpose() * 10.0 + mat * 5.0;
mat.m12 = 99999.99999; // This component is on the upper-triangular part and will not be read/written.

mat.ger_symm(10.0, &vec1, &vec2, 5.0);
assert_eq!(mat.lower_triangle(), expected.lower_triangle());
assert_eq!(mat.m12, 99999.99999); // This was untouched.

Computes self = alpha * x * y.transpose() + beta * self, where self is a symmetric matrix.

For hermitian complex matrices, use .hegerc instead. 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.

Example
let mut mat = Matrix2::identity();
let vec1 = Vector2::new(1.0, 2.0);
let vec2 = Vector2::new(0.1, 0.2);
let expected = vec1 * vec2.transpose() * 10.0 + mat * 5.0;
mat.m12 = 99999.99999; // This component is on the upper-triangular part and will not be read/written.

mat.syger(10.0, &vec1, &vec2, 5.0);
assert_eq!(mat.lower_triangle(), expected.lower_triangle());
assert_eq!(mat.m12, 99999.99999); // This was untouched.

Computes self = alpha * x * y.adjoint() + beta * self, where self is an hermitian matrix.

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.

Example
let mut mat = Matrix2::identity();
let vec1 = Vector2::new(Complex::new(1.0, 3.0), Complex::new(2.0, 4.0));
let vec2 = Vector2::new(Complex::new(0.2, 0.4), Complex::new(0.1, 0.3));
let expected = vec1 * vec2.adjoint() * Complex::new(10.0, 20.0) + mat * Complex::new(5.0, 15.0);
mat.m12 = Complex::new(99999.99999, 88888.88888); // This component is on the upper-triangular part and will not be read/written.

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.m12, Complex::new(99999.99999, 88888.88888)); // This was untouched.

Computes the quadratic form self = alpha * lhs * mid * lhs.transpose() + beta * self.

This uses the provided workspace work to avoid allocations for intermediate results.

Example
// Note that all those would also work with statically-sized matrices.
// We use DMatrix/DVector since that's the only case where pre-allocating the
// workspace is actually useful (assuming the same workspace is re-used for
// several computations) because it avoids repeated dynamic allocations.
let mut mat = DMatrix::identity(2, 2);
let lhs = DMatrix::from_row_slice(2, 3, &[1.0, 2.0, 3.0,
                                          4.0, 5.0, 6.0]);
let mid = DMatrix::from_row_slice(3, 3, &[0.1, 0.2, 0.3,
                                          0.5, 0.6, 0.7,
                                          0.9, 1.0, 1.1]);
// The random shows that values on the workspace do not
// matter as they will be overwritten.
let mut workspace = DVector::new_random(2);
let expected = &lhs * &mid * lhs.transpose() * 10.0 + &mat * 5.0;

mat.quadform_tr_with_workspace(&mut workspace, 10.0, &lhs, &mid, 5.0);
assert_relative_eq!(mat, expected);

Computes the quadratic form self = alpha * lhs * mid * lhs.transpose() + beta * self.

This allocates a workspace vector of dimension D1 for intermediate results. If D1 is a type-level integer, then the allocation is performed on the stack. Use .quadform_tr_with_workspace(...) instead to avoid allocations.

Example
let mut mat = Matrix2::identity();
let lhs = Matrix2x3::new(1.0, 2.0, 3.0,
                         4.0, 5.0, 6.0);
let mid = Matrix3::new(0.1, 0.2, 0.3,
                       0.5, 0.6, 0.7,
                       0.9, 1.0, 1.1);
let expected = lhs * mid * lhs.transpose() * 10.0 + mat * 5.0;

mat.quadform_tr(10.0, &lhs, &mid, 5.0);
assert_relative_eq!(mat, expected);

Computes the quadratic form self = alpha * rhs.transpose() * mid * rhs + beta * self.

This uses the provided workspace work to avoid allocations for intermediate results.

Example
// Note that all those would also work with statically-sized matrices.
// We use DMatrix/DVector since that's the only case where pre-allocating the
// workspace is actually useful (assuming the same workspace is re-used for
// several computations) because it avoids repeated dynamic allocations.
let mut mat = DMatrix::identity(2, 2);
let rhs = DMatrix::from_row_slice(3, 2, &[1.0, 2.0,
                                          3.0, 4.0,
                                          5.0, 6.0]);
let mid = DMatrix::from_row_slice(3, 3, &[0.1, 0.2, 0.3,
                                          0.5, 0.6, 0.7,
                                          0.9, 1.0, 1.1]);
// The random shows that values on the workspace do not
// matter as they will be overwritten.
let mut workspace = DVector::new_random(3);
let expected = rhs.transpose() * &mid * &rhs * 10.0 + &mat * 5.0;

mat.quadform_with_workspace(&mut workspace, 10.0, &mid, &rhs, 5.0);
assert_relative_eq!(mat, expected);

Computes the quadratic form self = alpha * rhs.transpose() * mid * rhs + beta * self.

This allocates a workspace vector of dimension D2 for intermediate results. If D2 is a type-level integer, then the allocation is performed on the stack. Use .quadform_with_workspace(...) instead to avoid allocations.

Example
let mut mat = Matrix2::identity();
let rhs = Matrix3x2::new(1.0, 2.0,
                         3.0, 4.0,
                         5.0, 6.0);
let mid = Matrix3::new(0.1, 0.2, 0.3,
                       0.5, 0.6, 0.7,
                       0.9, 1.0, 1.1);
let expected = rhs.transpose() * mid * rhs * 10.0 + mat * 5.0;

mat.quadform(10.0, &mid, &rhs, 5.0);
assert_relative_eq!(mat, expected);

Negates self in-place.

Equivalent to self + rhs but stores the result into out to avoid allocations.

Equivalent to self + rhs but stores the result into out to avoid allocations.

Equivalent to self.transpose() * rhs.

Equivalent to self.adjoint() * rhs.

Equivalent to self.transpose() * rhs but stores the result into out to avoid allocations.

Equivalent to self.adjoint() * rhs but stores the result into out to avoid allocations.

Equivalent to self * rhs but stores the result into out to avoid allocations.

The kronecker product of two matrices (aka. tensor product of the corresponding linear maps).

Computes the transformation equal to self followed by an uniform scaling factor.

Computes the transformation equal to an uniform scaling factor followed by self.

Computes the transformation equal to self followed by a non-uniform scaling factor.

Computes the transformation equal to a non-uniform scaling factor followed by self.

Computes the transformation equal to self followed by a translation.

Computes the transformation equal to a translation followed by self.

Computes in-place the transformation equal to self followed by an uniform scaling factor.

Computes in-place the transformation equal to an uniform scaling factor followed by self.

Computes in-place the transformation equal to self followed by a non-uniform scaling factor.

Computes in-place the transformation equal to a non-uniform scaling factor followed by self.

Computes the transformation equal to self followed by a translation.

Computes the transformation equal to a translation followed by self.

Transforms the given vector, assuming the matrix self uses homogeneous coordinates.

Transforms the given point, assuming the matrix self uses homogeneous coordinates.

Transforms the given point, assuming the matrix self uses homogeneous coordinates.

Computes the component-wise absolute value.

Example
let a = Matrix2::new(0.0, 1.0,
                     -2.0, -3.0);
assert_eq!(a.abs(), Matrix2::new(0.0, 1.0, 2.0, 3.0))

Componentwise matrix or vector multiplication.

Example
let a = Matrix2::new(0.0, 1.0, 2.0, 3.0);
let b = Matrix2::new(4.0, 5.0, 6.0, 7.0);
let expected = Matrix2::new(0.0, 5.0, 12.0, 21.0);

assert_eq!(a.component_mul(&b), expected);

Computes componentwise self[i] = alpha * a[i] * b[i] + beta * self[i].

Example
let mut m = Matrix2::new(0.0, 1.0, 2.0, 3.0);
let a = Matrix2::new(0.0, 1.0, 2.0, 3.0);
let b = Matrix2::new(4.0, 5.0, 6.0, 7.0);
let expected = (a.component_mul(&b) * 5.0) + m * 10.0;

m.cmpy(5.0, &a, &b, 10.0);
assert_eq!(m, expected);

Inplace componentwise matrix or vector multiplication.

Example
let mut a = Matrix2::new(0.0, 1.0, 2.0, 3.0);
let b = Matrix2::new(4.0, 5.0, 6.0, 7.0);
let expected = Matrix2::new(0.0, 5.0, 12.0, 21.0);

a.component_mul_assign(&b);

assert_eq!(a, expected);
👎 Deprecated:

This is renamed using the _assign suffix instead of the _mut suffix.

Inplace componentwise matrix or vector multiplication.

Example
let mut a = Matrix2::new(0.0, 1.0, 2.0, 3.0);
let b = Matrix2::new(4.0, 5.0, 6.0, 7.0);
let expected = Matrix2::new(0.0, 5.0, 12.0, 21.0);

a.component_mul_assign(&b);

assert_eq!(a, expected);

Componentwise matrix or vector division.

Example
let a = Matrix2::new(0.0, 1.0, 2.0, 3.0);
let b = Matrix2::new(4.0, 5.0, 6.0, 7.0);
let expected = Matrix2::new(0.0, 1.0 / 5.0, 2.0 / 6.0, 3.0 / 7.0);

assert_eq!(a.component_div(&b), expected);

Computes componentwise self[i] = alpha * a[i] / b[i] + beta * self[i].

Example
let mut m = Matrix2::new(0.0, 1.0, 2.0, 3.0);
let a = Matrix2::new(4.0, 5.0, 6.0, 7.0);
let b = Matrix2::new(4.0, 5.0, 6.0, 7.0);
let expected = (a.component_div(&b) * 5.0) + m * 10.0;

m.cdpy(5.0, &a, &b, 10.0);
assert_eq!(m, expected);

Inplace componentwise matrix or vector division.

Example
let mut a = Matrix2::new(0.0, 1.0, 2.0, 3.0);
let b = Matrix2::new(4.0, 5.0, 6.0, 7.0);
let expected = Matrix2::new(0.0, 1.0 / 5.0, 2.0 / 6.0, 3.0 / 7.0);

a.component_div_assign(&b);

assert_eq!(a, expected);
👎 Deprecated:

This is renamed using the _assign suffix instead of the _mut suffix.

Inplace componentwise matrix or vector division.

Example
let mut a = Matrix2::new(0.0, 1.0, 2.0, 3.0);
let b = Matrix2::new(4.0, 5.0, 6.0, 7.0);
let expected = Matrix2::new(0.0, 1.0 / 5.0, 2.0 / 6.0, 3.0 / 7.0);

a.component_div_assign(&b);

assert_eq!(a, expected);

Computes the infimum (aka. componentwise min) of two matrices/vectors.

Example
let u = Matrix2::new(4.0, 2.0, 1.0, -2.0);
let v = Matrix2::new(2.0, 4.0, -2.0, 1.0);
let expected = Matrix2::new(2.0, 2.0, -2.0, -2.0);
assert_eq!(u.inf(&v), expected)

Computes the supremum (aka. componentwise max) of two matrices/vectors.

Example
let u = Matrix2::new(4.0, 2.0, 1.0, -2.0);
let v = Matrix2::new(2.0, 4.0, -2.0, 1.0);
let expected = Matrix2::new(4.0, 4.0, 1.0, 1.0);
assert_eq!(u.sup(&v), expected)

Computes the (infimum, supremum) of two matrices/vectors.

Example
let u = Matrix2::new(4.0, 2.0, 1.0, -2.0);
let v = Matrix2::new(2.0, 4.0, -2.0, 1.0);
let expected = (Matrix2::new(2.0, 2.0, -2.0, -2.0), Matrix2::new(4.0, 4.0, 1.0, 1.0));
assert_eq!(u.inf_sup(&v), expected)

Adds a scalar to self.

Example
let u = Matrix2::new(1.0, 2.0, 3.0, 4.0);
let s = 10.0;
let expected = Matrix2::new(11.0, 12.0, 13.0, 14.0);
assert_eq!(u.add_scalar(s), expected)

Adds a scalar to self in-place.

Example
let mut u = Matrix2::new(1.0, 2.0, 3.0, 4.0);
let s = 10.0;
u.add_scalar_mut(s);
let expected = Matrix2::new(11.0, 12.0, 13.0, 14.0);
assert_eq!(u, expected)

Extracts the upper triangular part of this matrix (including the diagonal).

Extracts the lower triangular part of this matrix (including the diagonal).

Creates a new matrix by extracting the given set of rows from self.

Creates a new matrix by extracting the given set of columns from self.

Fills the diagonal of this matrix with the content of the given vector.

Fills the diagonal of this matrix with the content of the given iterator.

This will fill as many diagonal elements as the iterator yields, up to the minimum of the number of rows and columns of self, and starting with the diagonal element at index (0, 0).

Fills the selected row of this matrix with the content of the given vector.

Fills the selected column of this matrix with the content of the given vector.

Sets all the elements of this matrix to the value returned by the closure.

Sets all the elements of this matrix to val.

Fills self with the identity matrix.

Sets all the diagonal elements of this matrix to val.

Sets all the elements of the selected row to val.

Sets all the elements of the selected column to val.

Sets all the elements of the lower-triangular part of this matrix to val.

The parameter shift allows some subdiagonals to be left untouched:

  • If shift = 0 then the diagonal is overwritten as well.
  • If shift = 1 then the diagonal is left untouched.
  • If shift > 1, then the diagonal and the first shift - 1 subdiagonals are left untouched.

Sets all the elements of the lower-triangular part of this matrix to val.

The parameter shift allows some superdiagonals to be left untouched:

  • If shift = 0 then the diagonal is overwritten as well.
  • If shift = 1 then the diagonal is left untouched.
  • If shift > 1, then the diagonal and the first shift - 1 superdiagonals are left untouched.

Copies the upper-triangle of this matrix to its lower-triangular part.

This makes the matrix symmetric. Panics if the matrix is not square.

Copies the upper-triangle of this matrix to its upper-triangular part.

This makes the matrix symmetric. Panics if the matrix is not square.

Swaps two rows in-place.

Swaps two columns in-place.

Resizes this matrix in-place.

The values are copied such that self[(i, j)] == result[(i, j)]. If the result has more rows and/or columns than self, then the extra rows or columns are filled with val.

Defined only for owned fully-dynamic matrices, i.e., DMatrix.

Changes the number of rows of this matrix in-place.

The values are copied such that self[(i, j)] == result[(i, j)]. If the result has more rows than self, then the extra rows are filled with val.

Defined only for owned matrices with a dynamic number of rows (for example, DVector).

Changes the number of column of this matrix in-place.

The values are copied such that self[(i, j)] == result[(i, j)]. If the result has more columns than self, then the extra columns are filled with val.

Defined only for owned matrices with a dynamic number of columns (for example, DVector).

Produces a view of the data at the given index, or None if the index is out of bounds.

Produces a mutable view of the data at the given index, or None if the index is out of bounds.

Produces a view of the data at the given index, or panics if the index is out of bounds.

Produces a mutable view of the data at the given index, or panics if the index is out of bounds.

Produces a view of the data at the given index, without doing any bounds checking.

Returns a mutable view of the data at the given index, without doing any bounds checking.

The shape of this matrix returned as the tuple (number of rows, number of columns).

Example
let mat = Matrix3x4::<f32>::zeros();
assert_eq!(mat.shape(), (3, 4));

The shape of this matrix wrapped into their representative types (Const or Dynamic).

The number of rows of this matrix.

Example
let mat = Matrix3x4::<f32>::zeros();
assert_eq!(mat.nrows(), 3);

The number of columns of this matrix.

Example
let mat = Matrix3x4::<f32>::zeros();
assert_eq!(mat.ncols(), 4);

The strides (row stride, column stride) of this matrix.

Example
let mat = DMatrix::<f32>::zeros(10, 10);
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.
assert_eq!(mat.strides(), (1, 10));

Computes the row and column coordinates of the i-th element of this matrix seen as a vector.

Example
let m = Matrix2::new(1, 2,
                     3, 4);
let i = m.vector_to_matrix_index(3);
assert_eq!(i, (1, 1));
assert_eq!(m[i], m[3]);

Returns a pointer to the start of the matrix.

If the matrix is not empty, this pointer is guaranteed to be aligned and non-null.

Example
let m = Matrix2::new(1, 2,
                     3, 4);
let ptr = m.as_ptr();
assert_eq!(unsafe { *ptr }, m[0]);

Tests whether self and rhs are equal up to a given epsilon.

See relative_eq from the RelativeEq trait for more details.

Tests whether self and rhs are exactly equal.

Clones this matrix to one that owns its data.

Clones this matrix into one that owns its data. The actual type of the result depends on matrix storage combination rules for addition.

Transposes self and store the result into out.

Transposes self.

Returns a matrix containing the result of f applied to each of its entries.

Similar to self.iter().fold(init, f) except that init is replaced by a closure.

The initialization closure is given the first component of this matrix:

  • If the matrix has no component (0 rows or 0 columns) then init_f is called with None and its return value is the value returned by this method.
  • If the matrix has has least one component, then init_f is called with the first component to compute the initial value. Folding then continues on all the remaining components of the matrix.

Returns a matrix containing the result of f applied to each of its entries. Unlike map, f also gets passed the row and column index, i.e. f(row, col, value).

Returns a matrix containing the result of f applied to each entries of self and rhs.

Returns a matrix containing the result of f applied to each entries of self and b, and c.

Folds a function f on each entry of self.

Folds a function f on each pairs of entries from self and rhs.

Applies a closure f to modify each component of self.

Replaces each component of self by the result of a closure f applied on its components joined with the components from rhs.

Replaces each component of self by the result of a closure f applied on its components joined with the components from b and c.

Iterates through this matrix coordinates in column-major order.

Example
let mat = Matrix2x3::new(11, 12, 13,
                         21, 22, 23);
let mut it = mat.iter();
assert_eq!(*it.next().unwrap(), 11);
assert_eq!(*it.next().unwrap(), 21);
assert_eq!(*it.next().unwrap(), 12);
assert_eq!(*it.next().unwrap(), 22);
assert_eq!(*it.next().unwrap(), 13);
assert_eq!(*it.next().unwrap(), 23);
assert!(it.next().is_none());

Iterate through the rows of this matrix.

Example
let mut a = Matrix2x3::new(1, 2, 3,
                           4, 5, 6);
for (i, row) in a.row_iter().enumerate() {
    assert_eq!(row, a.row(i))
}

Iterate through the columns of this matrix.

Example
let mut a = Matrix2x3::new(1, 2, 3,
                           4, 5, 6);
for (i, column) in a.column_iter().enumerate() {
    assert_eq!(column, a.column(i))
}

Mutably iterates through this matrix coordinates.

Mutably iterates through this matrix rows.

Example
let mut a = Matrix2x3::new(1, 2, 3,
                           4, 5, 6);
for (i, mut row) in a.row_iter_mut().enumerate() {
    row *= (i + 1) * 10;
}

let expected = Matrix2x3::new(10, 20, 30,
                              80, 100, 120);
assert_eq!(a, expected);

Mutably iterates through this matrix columns.

Example
let mut a = Matrix2x3::new(1, 2, 3,
                           4, 5, 6);
for (i, mut col) in a.column_iter_mut().enumerate() {
    col *= (i + 1) * 10;
}

let expected = Matrix2x3::new(10, 40, 90,
                              40, 100, 180);
assert_eq!(a, expected);

Returns a mutable pointer to the start of the matrix.

If the matrix is not empty, this pointer is guaranteed to be aligned and non-null.

Swaps two entries without bound-checking.

Swaps two entries.

Fills this matrix with the content of a slice. Both must hold the same number of elements.

The components of the slice are assumed to be ordered in column-major order.

Fills this matrix with the content of another one. Both must have the same shape.

Fills this matrix with the content of the transpose another one.

Gets a reference to the i-th element of this column vector without bound checking.

Gets a mutable reference to the i-th element of this column vector without bound checking.

Extracts a slice containing the entire matrix entries ordered column-by-columns.

Extracts a mutable slice containing the entire matrix entries ordered column-by-columns.

Transposes the square matrix self in-place.

Takes the adjoint (aka. conjugate-transpose) of self and store the result into out.

The adjoint (aka. conjugate-transpose) of self.

👎 Deprecated:

Renamed self.adjoint_to(out).

Takes the conjugate and transposes self and store the result into out.

👎 Deprecated:

Renamed self.adjoint().

The conjugate transposition of self.

The conjugate of self.

Divides each component of the complex matrix self by the given real.

Multiplies each component of the complex matrix self by the given real.

The conjugate of the complex matrix self computed in-place.

Divides each component of the complex matrix self by the given real.

Multiplies each component of the complex matrix self by the given real.

👎 Deprecated:

Renamed to self.adjoint_mut().

Sets self to its adjoint.

Sets self to its adjoint (aka. conjugate-transpose).

The diagonal of this matrix.

Apply the given function to this matrix’s diagonal and returns it.

This is a more efficient version of self.diagonal().map(f) since this allocates only once.

Computes a trace of a square matrix, i.e., the sum of its diagonal elements.

The symmetric part of self, i.e., 0.5 * (self + self.transpose()).

The hermitian part of self, i.e., 0.5 * (self + self.adjoint()).

Yields the homogeneous matrix for this matrix, i.e., appending an additional dimension and and setting the diagonal element to 1.

Computes the coordinates in projective space of this vector, i.e., appends a 0 to its coordinates.

Constructs a new vector of higher dimension by appending element to the end of self.

The perpendicular product between two 2D column vectors, i.e. a.x * b.y - a.y * b.x.

The 3D cross product between two vectors.

Panics if the shape is not 3D vector. In the future, this will be implemented only for dynamically-sized matrices and statically-sized 3D matrices.

Computes the matrix M such that for all vector v we have M * v == self.cross(&v).

The smallest angle between two vectors.

Returns a slice containing the i-th row of this matrix.

Returns a slice containing the n first elements of the i-th row of this matrix.

Extracts from this matrix a set of consecutive rows.

Extracts from this matrix a set of consecutive rows regularly skipping step rows.

Extracts a compile-time number of consecutive rows from this matrix.

Extracts from this matrix a compile-time number of rows regularly skipping step rows.

Extracts from this matrix nrows rows regularly skipping step rows. Both argument may or may not be values known at compile-time.

Extracts from this matrix nrows rows regularly skipping step rows. Both argument may or may not be values known at compile-time.

Returns a slice containing the i-th column of this matrix.

Returns a slice containing the n first elements of the i-th column of this matrix.

Extracts from this matrix a set of consecutive columns.

Extracts from this matrix a set of consecutive columns regularly skipping step columns.

Extracts a compile-time number of consecutive columns from this matrix.

Extracts from this matrix a compile-time number of columns regularly skipping step columns.

Extracts from this matrix ncols columns. The number of columns may or may not be known at compile-time.

Extracts from this matrix ncols columns skipping step columns. Both argument may or may not be values known at compile-time.

Slices this matrix starting at its component (irow, icol) and with (nrows, ncols) consecutive elements.

Slices this matrix starting at its component (start.0, start.1) and with (shape.0, shape.1) components. Each row (resp. column) of the sliced matrix is separated by steps.0 (resp. steps.1) ignored rows (resp. columns) of the original matrix.

Slices this matrix starting at its component (irow, icol) and with (R::dim(), CSlice::dim()) consecutive components.

Slices this matrix starting at its component (start.0, start.1) and with (RSLICE, CSLICE) components. Each row (resp. column) of the sliced matrix is separated by steps.0 (resp. steps.1) ignored rows (resp. columns) of the original matrix.

Creates a slice that may or may not have a fixed size and stride.

Creates a slice that may or may not have a fixed size and stride.

Splits this NxM matrix into two parts delimited by two ranges.

Panics if the ranges overlap or if the first range is empty.

Splits this NxM matrix into two parts delimited by two ranges.

Panics if the ranges overlap or if the first range is empty.

Returns a slice containing the i-th row of this matrix.

Returns a slice containing the n first elements of the i-th row of this matrix.

Extracts from this matrix a set of consecutive rows.

Extracts from this matrix a set of consecutive rows regularly skipping step rows.

Extracts a compile-time number of consecutive rows from this matrix.

Extracts from this matrix a compile-time number of rows regularly skipping step rows.

Extracts from this matrix nrows rows regularly skipping step rows. Both argument may or may not be values known at compile-time.

Extracts from this matrix nrows rows regularly skipping step rows. Both argument may or may not be values known at compile-time.

Returns a slice containing the i-th column of this matrix.

Returns a slice containing the n first elements of the i-th column of this matrix.

Extracts from this matrix a set of consecutive columns.

Extracts from this matrix a set of consecutive columns regularly skipping step columns.

Extracts a compile-time number of consecutive columns from this matrix.

Extracts from this matrix a compile-time number of columns regularly skipping step columns.

Extracts from this matrix ncols columns. The number of columns may or may not be known at compile-time.

Extracts from this matrix ncols columns skipping step columns. Both argument may or may not be values known at compile-time.

Slices this matrix starting at its component (irow, icol) and with (nrows, ncols) consecutive elements.

Slices this matrix starting at its component (start.0, start.1) and with (shape.0, shape.1) components. Each row (resp. column) of the sliced matrix is separated by steps.0 (resp. steps.1) ignored rows (resp. columns) of the original matrix.

Slices this matrix starting at its component (irow, icol) and with (R::dim(), CSlice::dim()) consecutive components.

Slices this matrix starting at its component (start.0, start.1) and with (RSLICE, CSLICE) components. Each row (resp. column) of the sliced matrix is separated by steps.0 (resp. steps.1) ignored rows (resp. columns) of the original matrix.

Creates a slice that may or may not have a fixed size and stride.

Creates a slice that may or may not have a fixed size and stride.

Splits this NxM matrix into two parts delimited by two ranges.

Panics if the ranges overlap or if the first range is empty.

Splits this NxM matrix into two parts delimited by two ranges.

Panics if the ranges overlap or if the first range is empty.

Slices a sub-matrix containing the rows indexed by the range rows and the columns indexed by the range cols.

Slice containing all the rows indexed by the range rows.

Slice containing all the columns indexed by the range rows.

Slices a mutable sub-matrix containing the rows indexed by the range rows and the columns indexed by the range cols.

Slice containing all the rows indexed by the range rows.

Slice containing all the columns indexed by the range cols.

The squared L2 norm of this vector.

The L2 norm of this matrix.

Use .apply_norm to apply a custom norm.

Compute the distance between self and rhs using the metric induced by the euclidean norm.

Use .apply_metric_distance to apply a custom norm.

Uses the given norm to compute the norm of self.

Example

let v = Vector3::new(1.0, 2.0, 3.0);
assert_eq!(v.apply_norm(&UniformNorm), 3.0);
assert_eq!(v.apply_norm(&LpNorm(1)), 6.0);
assert_eq!(v.apply_norm(&EuclideanNorm), v.norm());

Uses the metric induced by the given norm to compute the metric distance between self and rhs.

Example

let v1 = Vector3::new(1.0, 2.0, 3.0);
let v2 = Vector3::new(10.0, 20.0, 30.0);

assert_eq!(v1.apply_metric_distance(&v2, &UniformNorm), 27.0);
assert_eq!(v1.apply_metric_distance(&v2, &LpNorm(1)), 27.0 + 18.0 + 9.0);
assert_eq!(v1.apply_metric_distance(&v2, &EuclideanNorm), (v1 - v2).norm());

A synonym for the norm of this matrix.

Aka the length.

This function is simply implemented as a call to norm()

A synonym for the squared norm of this matrix.

Aka the squared length.

This function is simply implemented as a call to norm_squared()

Sets the magnitude of this vector.

Returns a normalized version of this matrix.

The Lp norm of this matrix.

Attempts to normalize self.

The components of this matrix can be SIMD types.

Sets the magnitude of this vector unless it is smaller than min_magnitude.

If self.magnitude() is smaller than min_magnitude, it will be left unchanged. Otherwise this is equivalent to: `*self = self.normalize() * magnitude.

Returns a new vector with the same magnitude as self clamped between 0.0 and max.

Returns a new vector with the same magnitude as self clamped between 0.0 and max.

Returns a normalized version of this matrix unless its norm as smaller or equal to eps.

The components of this matrix cannot be SIMD types (see simd_try_normalize) instead.

Normalizes this matrix in-place and returns its norm.

The components of the matrix cannot be SIMD types (see simd_try_normalize_mut instead).

Normalizes this matrix in-place and return its norm.

The components of the matrix can be SIMD types.

Normalizes this matrix in-place or does nothing if its norm is smaller or equal to eps.

If the normalization succeeded, returns the old norm of this matrix.

The total number of elements of this matrix.

Examples:
let mat = Matrix3x4::<f32>::zeros();
assert_eq!(mat.len(), 12);

Returns true if the matrix contains no elements.

Examples:
let mat = Matrix3x4::<f32>::zeros();
assert!(!mat.is_empty());

Indicates if this is a square matrix.

Indicated if this is the identity matrix within a relative error of eps.

If the matrix is diagonal, this checks that diagonal elements (i.e. at coordinates (i, i) for i from 0 to min(R, C)) are equal one; and that all other elements are zero.

Checks that Mᵀ × M = Id.

In this definition Id is approximately equal to the identity matrix with a relative error equal to eps.

Checks that this matrix is orthogonal and has a determinant equal to 1.

Returns true if this matrix is invertible.

Returns a row vector where each element is the result of the application of f on the corresponding column of the original matrix.

Returns a column vector where each element is the result of the application of f on the corresponding column of the original matrix.

This is the same as self.compress_rows(f).transpose().

Returns a column vector resulting from the folding of f on each column of this matrix.

The sum of all the elements of this matrix.

Example

let m = Matrix2x3::new(1.0, 2.0, 3.0,
                       4.0, 5.0, 6.0);
assert_eq!(m.sum(), 21.0);

The sum of all the rows of this matrix.

Use .row_sum_tr if you need the result in a column vector instead.

Example

let m = Matrix2x3::new(1.0, 2.0, 3.0,
                       4.0, 5.0, 6.0);
assert_eq!(m.row_sum(), RowVector3::new(5.0, 7.0, 9.0));

let mint = Matrix3x2::new(1, 2,
                          3, 4,
                          5, 6);
assert_eq!(mint.row_sum(), RowVector2::new(9,12));

The sum of all the rows of this matrix. The result is transposed and returned as a column vector.

Example

let m = Matrix2x3::new(1.0, 2.0, 3.0,
                       4.0, 5.0, 6.0);
assert_eq!(m.row_sum_tr(), Vector3::new(5.0, 7.0, 9.0));

let mint = Matrix3x2::new(1, 2,
                          3, 4,
                          5, 6);
assert_eq!(mint.row_sum_tr(), Vector2::new(9, 12));

The sum of all the columns of this matrix.

Example

let m = Matrix2x3::new(1.0, 2.0, 3.0,
                       4.0, 5.0, 6.0);
assert_eq!(m.column_sum(), Vector2::new(6.0, 15.0));

let mint = Matrix3x2::new(1, 2,
                          3, 4,
                          5, 6);
assert_eq!(mint.column_sum(), Vector3::new(3, 7, 11));

The product of all the elements of this matrix.

Example

let m = Matrix2x3::new(1.0, 2.0, 3.0,
                       4.0, 5.0, 6.0);
assert_eq!(m.product(), 720.0);

The product of all the rows of this matrix.

Use .row_sum_tr if you need the result in a column vector instead.

Example

let m = Matrix2x3::new(1.0, 2.0, 3.0,
                       4.0, 5.0, 6.0);
assert_eq!(m.row_product(), RowVector3::new(4.0, 10.0, 18.0));

let mint = Matrix3x2::new(1, 2,
                          3, 4,
                          5, 6);
assert_eq!(mint.row_product(), RowVector2::new(15, 48));

The product of all the rows of this matrix. The result is transposed and returned as a column vector.

Example

let m = Matrix2x3::new(1.0, 2.0, 3.0,
                       4.0, 5.0, 6.0);
assert_eq!(m.row_product_tr(), Vector3::new(4.0, 10.0, 18.0));

let mint = Matrix3x2::new(1, 2,
                          3, 4,
                          5, 6);
assert_eq!(mint.row_product_tr(), Vector2::new(15, 48));

The product of all the columns of this matrix.

Example

let m = Matrix2x3::new(1.0, 2.0, 3.0,
                       4.0, 5.0, 6.0);
assert_eq!(m.column_product(), Vector2::new(6.0, 120.0));

let mint = Matrix3x2::new(1, 2,
                          3, 4,
                          5, 6);
assert_eq!(mint.column_product(), Vector3::new(2, 12, 30));

The variance of all the elements of this matrix.

Example

let m = Matrix2x3::new(1.0, 2.0, 3.0,
                       4.0, 5.0, 6.0);
assert_relative_eq!(m.variance(), 35.0 / 12.0, epsilon = 1.0e-8);

The variance of all the rows of this matrix.

Use .row_variance_tr if you need the result in a column vector instead.

Example

let m = Matrix2x3::new(1.0, 2.0, 3.0,
                       4.0, 5.0, 6.0);
assert_eq!(m.row_variance(), RowVector3::new(2.25, 2.25, 2.25));

The variance of all the rows of this matrix. The result is transposed and returned as a column vector.

Example

let m = Matrix2x3::new(1.0, 2.0, 3.0,
                       4.0, 5.0, 6.0);
assert_eq!(m.row_variance_tr(), Vector3::new(2.25, 2.25, 2.25));

The variance of all the columns of this matrix.

Example

let m = Matrix2x3::new(1.0, 2.0, 3.0,
                       4.0, 5.0, 6.0);
assert_relative_eq!(m.column_variance(), Vector2::new(2.0 / 3.0, 2.0 / 3.0), epsilon = 1.0e-8);

The mean of all the elements of this matrix.

Example

let m = Matrix2x3::new(1.0, 2.0, 3.0,
                       4.0, 5.0, 6.0);
assert_eq!(m.mean(), 3.5);

The mean of all the rows of this matrix.

Use .row_mean_tr if you need the result in a column vector instead.

Example

let m = Matrix2x3::new(1.0, 2.0, 3.0,
                       4.0, 5.0, 6.0);
assert_eq!(m.row_mean(), RowVector3::new(2.5, 3.5, 4.5));

The mean of all the rows of this matrix. The result is transposed and returned as a column vector.

Example

let m = Matrix2x3::new(1.0, 2.0, 3.0,
                       4.0, 5.0, 6.0);
assert_eq!(m.row_mean_tr(), Vector3::new(2.5, 3.5, 4.5));

The mean of all the columns of this matrix.

Example

let m = Matrix2x3::new(1.0, 2.0, 3.0,
                       4.0, 5.0, 6.0);
assert_eq!(m.column_mean(), Vector2::new(2.0, 5.0));

Builds a new vector from components of self.

Builds a new vector from components of self.

Builds a new vector from components of self.

Builds a new vector from components of self.

Builds a new vector from components of self.

Builds a new vector from components of self.

Builds a new vector from components of self.

Builds a new vector from components of self.

Builds a new vector from components of self.

Builds a new vector from components of self.

Builds a new vector from components of self.

Builds a new vector from components of self.

Builds a new vector from components of self.

Builds a new vector from components of self.

Builds a new vector from components of self.

Builds a new vector from components of self.

Builds a new vector from components of self.

Builds a new vector from components of self.

Builds a new vector from components of self.

Builds a new vector from components of self.

Builds a new vector from components of self.

Builds a new vector from components of self.

Builds a new vector from components of self.

Builds a new vector from components of self.

Builds a new vector from components of self.

Builds a new vector from components of self.

Builds a new vector from components of self.

Builds a new vector from components of self.

Builds a new vector from components of self.

Builds a new vector from components of self.

Builds a new vector from components of self.

Builds a new vector from components of self.

Builds a new vector from components of self.

Builds a new vector from components of self.

Builds a new vector from components of self.

Builds a new vector from components of self.

Returns self * (1.0 - t) + rhs * t, i.e., the linear blend of the vectors x and y using the scalar value a.

The value for a is not restricted to the range [0, 1].

Examples:
let x = Vector3::new(1.0, 2.0, 3.0);
let y = Vector3::new(10.0, 20.0, 30.0);
assert_eq!(x.lerp(&y, 0.1), Vector3::new(1.9, 3.8, 5.7));

Computes the spherical linear interpolation between two non-zero vectors.

The result is a unit vector.

Examples:

let v1 =Vector2::new(1.0, 2.0);
let v2 = Vector2::new(2.0, -3.0);

let v = v1.slerp(&v2, 1.0);

assert_eq!(v, v2.normalize());

Returns the absolute value of the component with the largest absolute value.

Example
assert_eq!(Vector3::new(-1.0, 2.0, 3.0).amax(), 3.0);
assert_eq!(Vector3::new(-1.0, -2.0, -3.0).amax(), 3.0);

Returns the the 1-norm of the complex component with the largest 1-norm.

Example
assert_eq!(Vector3::new(
    Complex::new(-3.0, -2.0),
    Complex::new(1.0, 2.0),
    Complex::new(1.0, 3.0)).camax(), 5.0);

Returns the component with the largest value.

Example
assert_eq!(Vector3::new(-1.0, 2.0, 3.0).max(), 3.0);
assert_eq!(Vector3::new(-1.0, -2.0, -3.0).max(), -1.0);
assert_eq!(Vector3::new(5u32, 2, 3).max(), 5);

Returns the absolute value of the component with the smallest absolute value.

Example
assert_eq!(Vector3::new(-1.0, 2.0, -3.0).amin(), 1.0);
assert_eq!(Vector3::new(10.0, 2.0, 30.0).amin(), 2.0);

Returns the the 1-norm of the complex component with the smallest 1-norm.

Example
assert_eq!(Vector3::new(
    Complex::new(-3.0, -2.0),
    Complex::new(1.0, 2.0),
    Complex::new(1.0, 3.0)).camin(), 3.0);

Returns the component with the smallest value.

Example
assert_eq!(Vector3::new(-1.0, 2.0, 3.0).min(), -1.0);
assert_eq!(Vector3::new(1.0, 2.0, 3.0).min(), 1.0);
assert_eq!(Vector3::new(5u32, 2, 3).min(), 2);

Computes the index of the matrix component with the largest absolute value.

Examples:
let mat = Matrix2x3::new(Complex::new(11.0, 1.0), Complex::new(-12.0, 2.0), Complex::new(13.0, 3.0),
                         Complex::new(21.0, 43.0), Complex::new(22.0, 5.0), Complex::new(-23.0, 0.0));
assert_eq!(mat.icamax_full(), (1, 0));

Computes the index of the matrix component with the largest absolute value.

Examples:
let mat = Matrix2x3::new(11, -12, 13,
                         21, 22, -23);
assert_eq!(mat.iamax_full(), (1, 2));

Computes the index of the vector component with the largest complex or real absolute value.

Examples:
let vec = Vector3::new(Complex::new(11.0, 3.0), Complex::new(-15.0, 0.0), Complex::new(13.0, 5.0));
assert_eq!(vec.icamax(), 2);

Computes the index and value of the vector component with the largest value.

Examples:
let vec = Vector3::new(11, -15, 13);
assert_eq!(vec.argmax(), (2, 13));

Computes the index of the vector component with the largest value.

Examples:
let vec = Vector3::new(11, -15, 13);
assert_eq!(vec.imax(), 2);

Computes the index of the vector component with the largest absolute value.

Examples:
let vec = Vector3::new(11, -15, 13);
assert_eq!(vec.iamax(), 1);

Computes the index and value of the vector component with the smallest value.

Examples:
let vec = Vector3::new(11, -15, 13);
assert_eq!(vec.argmin(), (1, -15));

Computes the index of the vector component with the smallest value.

Examples:
let vec = Vector3::new(11, -15, 13);
assert_eq!(vec.imin(), 1);

Computes the index of the vector component with the smallest absolute value.

Examples:
let vec = Vector3::new(11, -15, 13);
assert_eq!(vec.iamin(), 0);

Returns the convolution of the target vector and a kernel.

Arguments
  • kernel - A Vector with size > 0
Errors

Inputs must satisfy vector.len() >= kernel.len() > 0.

Returns the convolution of the target vector and a kernel.

The output convolution consists only of those elements that do not rely on the zero-padding.

Arguments
  • kernel - A Vector with size > 0
Errors

Inputs must satisfy self.len() >= kernel.len() > 0.

Returns the convolution of the target vector and a kernel.

The output convolution is the same size as vector, centered with respect to the ‘full’ output.

Arguments
  • kernel - A Vector with size > 0
Errors

Inputs must satisfy self.len() >= kernel.len() > 0.

Computes the matrix determinant.

If the matrix has a dimension larger than 3, an LU decomposition is used.

Computes exponential of this matrix

Attempts to invert this matrix in-place. Returns false and leaves self untouched if inversion fails.

Raises this matrix to an integral power exp in-place.

Raise this matrix to an integral power exp.

Computes the eigenvalues of this matrix.

Computes the eigenvalues of this matrix.

Computes the solution of the linear system self . x = b where x is the unknown and only the lower-triangular part of self (including the diagonal) is considered not-zero.

Computes the solution of the linear system self . x = b where x is the unknown and only the upper-triangular part of self (including the diagonal) is considered not-zero.

Solves the linear system self . x = b where x is the unknown and only the lower-triangular part of self (including the diagonal) is considered not-zero.

Solves the linear system self . x = b where x is the unknown and only the lower-triangular part of self is considered not-zero. The diagonal is never read as it is assumed to be equal to diag. Returns false and does not modify its inputs if diag is zero.

Solves the linear system self . x = b where x is the unknown and only the upper-triangular part of self (including the diagonal) is considered not-zero.

Computes the solution of the linear system self.transpose() . x = b where x is the unknown and only the lower-triangular part of self (including the diagonal) is considered not-zero.

Computes the solution of the linear system self.transpose() . x = b where x is the unknown and only the upper-triangular part of self (including the diagonal) is considered not-zero.

Solves the linear system self.transpose() . x = b where x is the unknown and only the lower-triangular part of self (including the diagonal) is considered not-zero.

Solves the linear system self.transpose() . x = b where x is the unknown and only the upper-triangular part of self (including the diagonal) is considered not-zero.

Computes the solution of the linear system self.adjoint() . x = b where x is the unknown and only the lower-triangular part of self (including the diagonal) is considered not-zero.

Computes the solution of the linear system self.adjoint() . x = b where x is the unknown and only the upper-triangular part of self (including the diagonal) is considered not-zero.

Solves the linear system self.adjoint() . x = b where x is the unknown and only the lower-triangular part of self (including the diagonal) is considered not-zero.

Solves the linear system self.adjoint() . x = b where x is the unknown and only the upper-triangular part of self (including the diagonal) is considered not-zero.

Computes the solution of the linear system self . x = b where x is the unknown and only the lower-triangular part of self (including the diagonal) is considered not-zero.

Computes the solution of the linear system self . x = b where x is the unknown and only the upper-triangular part of self (including the diagonal) is considered not-zero.

Solves the linear system self . x = b where x is the unknown and only the lower-triangular part of self (including the diagonal) is considered not-zero.

Solves the linear system self . x = b where x is the unknown and only the lower-triangular part of self is considered not-zero. The diagonal is never read as it is assumed to be equal to diag. Returns false and does not modify its inputs if diag is zero.

Solves the linear system self . x = b where x is the unknown and only the upper-triangular part of self (including the diagonal) is considered not-zero.

Computes the solution of the linear system self.transpose() . x = b where x is the unknown and only the lower-triangular part of self (including the diagonal) is considered not-zero.

Computes the solution of the linear system self.transpose() . x = b where x is the unknown and only the upper-triangular part of self (including the diagonal) is considered not-zero.

Solves the linear system self.transpose() . x = b where x is the unknown and only the lower-triangular part of self (including the diagonal) is considered not-zero.

Solves the linear system self.transpose() . x = b where x is the unknown and only the upper-triangular part of self (including the diagonal) is considered not-zero.

Computes the solution of the linear system self.adjoint() . x = b where x is the unknown and only the lower-triangular part of self (including the diagonal) is considered not-zero.

Computes the solution of the linear system self.adjoint() . x = b where x is the unknown and only the upper-triangular part of self (including the diagonal) is considered not-zero.

Solves the linear system self.adjoint() . x = b where x is the unknown and only the lower-triangular part of self (including the diagonal) is considered not-zero.

Solves the linear system self.adjoint() . x = b where x is the unknown and only the upper-triangular part of self (including the diagonal) is considered not-zero.

Computes the singular values of this matrix. The singular values are not guaranteed to be sorted in any particular order. If a descending order is required, consider using singular_values instead.

Computes the rank of this matrix.

All singular values below eps are considered equal to 0.

Computes the singular values of this matrix. The singular values are guaranteed to be sorted in descending order. If this order is not required consider using singular_values_unordered.

Computes the eigenvalues of this symmetric matrix.

Only the lower-triangular part of the matrix is read.

Trait Implementations

The resulting type after applying the + operator.

Performs the + operation. Read more

The resulting type after applying the + operator.

Performs the + operation. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

The resulting type after dereferencing.

Dereferences the value.

Mutably dereferences the value.

Formats the value using the given formatter. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

The resulting type after applying the - operator.

Performs the unary - operation. Read more

The resulting type after applying the - operator.

Performs the unary - operation. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

The resulting type after applying the - operator.

Performs the - operation. Read more

The resulting type after applying the - operator.

Performs the - operation. Read more

Constructor.

Make an instance filling fields with NaN.

Make an instance filling fields with default values.

First element.

Second element.

First element.

Second element.

Canonical representation of the vector.

Mutable canonical representation of the vector.

Assign value.

First element.

Second element.

First element.

Second element.

Interpret as tuple.

Interpret as array.

Interpret as slice.

Interpret as mutable tuple.

Interpret as mutable array.

Interpret as mutable slice.

Type of element.

First element.

Second element.

First element.

Second element.

Clone as tuple.

Clone as array.

Clone as canonical.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more

Checks if self is actually part of its subset T (and can be converted to it).

Use with care! Same as self.to_subset but without any property checks. Always succeeds.

The inclusion map: converts self to the equivalent element of its superset.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.