Struct vectrix::Row

source ·
#[repr(transparent)]
pub struct Row<T, const M: usize, const N: usize> { /* private fields */ }
Expand description

A row in a Matrix.

Implementations

Returns the dot product between a row and column.

Examples
let row_vector = row_vector![1, 2, 3];
let row = row_vector.row(0);

let column_vector = vector![4, 5, 6];
let column = column_vector.column(0);

assert_eq!(row.dot(column), 32);

Methods from Deref<Target = Stride<T, M>>

Returns the number of elements in the strided slice.

This is equivalent to the ceiling division of the underlying slice length by S.

Examples
let data = &[1, 2, 3, 4, 5, 6];
assert_eq!(Stride::<_, 1>::new(data).len(), 6);
assert_eq!(Stride::<_, 2>::new(data).len(), 3);
assert_eq!(Stride::<_, 3>::new(data).len(), 2);

Returns true if the strided slice has a length of 0.

Examples
let stride = Stride::<_, 3>::new(&[1, 2, 3, 4, 5, 6]);
assert!(!stride.is_empty());

Returns a raw pointer to the underlying slice’s buffer.

See slice::as_ptr().

Returns an unsafe mutable pointer to the underlying slice’s buffer.

See slice::as_mut_ptr().

Returns a reference to an element or substride depending on the type of index.

  • If given a position, returns a reference to the element at that position or None if out of bounds.
  • If given a range, returns the substride corresponding to that range, or None if out of bounds.
Examples
let stride = Stride::<_, 2>::new(&[1, 2, 3, 4, 5, 6]);
assert_eq!(stride.get(1), Some(&3));
assert_eq!(stride.get(0..2), Some(Stride::<_, 2>::new(&[1, 2, 3, 4])));
assert_eq!(stride.get(3), None);
assert_eq!(stride.get(0..4), None);

Returns a mutable reference to an element or substride depending on the type of index (see get) or None if the index is out of bounds.

Examples
let data = &mut [0, 1, 2, 3];
let stride = Stride::<_, 2>::new_mut(data);

if let Some(elem) = stride.get_mut(1) {
    *elem = 42;
}
assert_eq!(stride, Stride::<_, 2>::new(&[0, 1, 42, 3]));

Returns a reference to an element or substride, without doing bounds checking.

For a safe alternative see get.

Safety

Calling this method with an out-of-bounds index is undefined behavior even if the resulting reference is not used.

Returns a mutable reference to an element or substride, without doing bounds checking.

For a safe alternative see get_mut.

Safety

Calling this method with an out-of-bounds index is undefined behavior even if the resulting reference is not used.

Returns a reference to the first element of the strided slice, or None if it is empty.

Returns a mutable reference to the first element of the strided slice, or None if it is empty.

Returns a reference to the last element of the strided slice, or None if it is empty.

Returns a mutable reference to the last element of the strided slice, or None if it is empty.

Swaps two elements in the strided slice.

Arguments
  • a - The index of the first element
  • b - The index of the second element
Panics

If a or b are out of bounds.

Returns an iterator over the stride.

Examples
let stride = Stride::<_, 2>::new(&[1, 2, 3, 4, 5, 6]);
let mut iterator = stride.iter();
assert_eq!(iterator.next(), Some(&1));
assert_eq!(iterator.next(), Some(&3));
assert_eq!(iterator.next(), Some(&5));
assert_eq!(iterator.next(), None);

Returns an iterator over the stride that allows modifying each value.

Examples
let slice = &mut [1, 1, 2, 2, 3, 3];
let stride = Stride::<_, 2>::new_mut(slice);
for elem in stride.iter_mut() {
    *elem *= 2;
}
assert_eq!(slice, &[2, 1, 4, 2, 6, 3]);

Returns a slice containing the entire strided slice.

Only available on strided slices with a stride of 1.

Examples
let slice = &[1, 2, 3];
let stride = Stride::<_, 1>::new(slice);
assert_eq!(stride.as_slice(), slice);

Returns a mutable slice containing the entire strided slice.

Only available on strided slices with a stride of 1.

Examples
let slice = &mut [1, 2, 7];
let stride = Stride::<_, 1>::new_mut(slice);
stride.as_mut_slice()[2] = 3;
assert_eq!(slice, &[1, 2, 3])

Trait Implementations

Formats the value using the given formatter. Read more
The resulting type after dereferencing.
Dereferences the value.
Mutably dereferences the value.
Feeds this value into the given Hasher. Read more
This method returns an Ordering between self and other. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

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