Struct vectrix::Row [−][src]
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()
.
pub fn get<I>(
&self,
index: I
) -> Option<&<I as StrideIndex<Stride<T, S>>>::Output> where
I: StrideIndex<Stride<T, S>>,
pub fn get<I>(
&self,
index: I
) -> Option<&<I as StrideIndex<Stride<T, S>>>::Output> where
I: StrideIndex<Stride<T, S>>,
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);
pub fn get_mut<I>(
&mut self,
index: I
) -> Option<&mut <I as StrideIndex<Stride<T, S>>>::Output> where
I: StrideIndex<Stride<T, S>>,
pub fn get_mut<I>(
&mut self,
index: I
) -> Option<&mut <I as StrideIndex<Stride<T, S>>>::Output> where
I: StrideIndex<Stride<T, S>>,
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]));
pub unsafe fn get_unchecked<I>(
&self,
index: I
) -> &<I as StrideIndex<Stride<T, S>>>::Output where
I: StrideIndex<Stride<T, S>>,
pub unsafe fn get_unchecked<I>(
&self,
index: I
) -> &<I as StrideIndex<Stride<T, S>>>::Output where
I: StrideIndex<Stride<T, S>>,
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.
pub unsafe fn get_unchecked_mut<I>(
&mut self,
index: I
) -> &mut <I as StrideIndex<Stride<T, S>>>::Output where
I: StrideIndex<Stride<T, S>>,
pub unsafe fn get_unchecked_mut<I>(
&mut self,
index: I
) -> &mut <I as StrideIndex<Stride<T, S>>>::Output where
I: StrideIndex<Stride<T, S>>,
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.
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 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
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