Type Definition nalgebra::base::Vector

source · []
pub type Vector<T, D, S> = Matrix<T, D, U1, S>;
Expand description

A matrix with one column and D rows.

Implementations

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

If b is zero, self is never read from.

Examples:
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.

Examples:
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.

Examples:
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));
👎 Deprecated:

This is renamed sygemv to match the original BLAS terminology.

Computes self = alpha * a * x + beta * self, where a is a symmetric matrix, x a vector, and alpha, beta two scalars. DEPRECATED: use sygemv instead.

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.

Examples:
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.

Examples:
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);

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.

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

Constructs a vector from coordinates in projective space, i.e., removes a 0 at the end of self. Returns None if this last component is not zero.

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

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

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());

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.