pub struct VectorI32View<'a> { /* private fields */ }
Implementations
sourceimpl<'a> VectorI32View<'a>
impl<'a> VectorI32View<'a>
sourcepub fn from_vector(v: &'a mut VectorI32, offset: usize, n: usize) -> Self
pub fn from_vector(v: &'a mut VectorI32, offset: usize, n: usize) -> Self
These functions return a vector view of a subvector of another vector v. The start of the new vector is offset by offset elements from the start of the original vector. The new vector has n elements. Mathematically, the i-th element of the new vector v’ is given by,
v’(i) = v->data[(offset + i)*v->stride]
where the index i runs from 0 to n-1.
The data pointer of the returned vector struct is set to null if the combined parameters (offset,n) overrun the end of the original vector.
The new vector is only a view of the block underlying the original vector, v. The block containing the elements of v is not owned by the new vector. When the view goes out of scope the original vector v and its block will continue to exist. The original memory can only be deallocated by freeing the original vector. Of course, the original vector should not be deallocated while the view is still in use.
The function gsl_vector_const_subvector is equivalent to gsl_vector_subvector but can be used for vectors which are declared const.
sourcepub fn from_vector_with_stride(
v: &'a mut VectorI32,
offset: usize,
stride: usize,
n: usize
) -> Self
pub fn from_vector_with_stride(
v: &'a mut VectorI32,
offset: usize,
stride: usize,
n: usize
) -> Self
These functions return a vector view of a subvector of another vector v with an additional stride argument. The subvector is formed in the same way as for gsl_vector_subvector but the new vector has n elements with a step-size of stride from one element to the next in the original vector. Mathematically, the i-th element of the new vector v’ is given by,
v’(i) = v->data[(offset + i*stride)*v->stride] where the index i runs from 0 to n-1.
Note that subvector views give direct access to the underlying elements of the original vector. For example, the following code will zero the even elements of the vector v of length n, while leaving the odd elements untouched,
gsl_vector_view v_even
= gsl_vector_subvector_with_stride (v, 0, 2, n/2);
gsl_vector_set_zero (&v_even.vector);
A vector view can be passed to any subroutine which takes a vector argument just as a directly allocated vector would be, using &view.vector. For example, the following code computes the norm of the odd elements of v using the BLAS routine DNRM2,
gsl_vector_view v_odd
= gsl_vector_subvector_with_stride (v, 1, 2, n/2);
double r = gsl_blas_dnrm2 (&v_odd.vector);
The function gsl_vector_const_subvector_with_stride is equivalent to gsl_vector_subvector_with_stride but can be used for vectors which are declared const.
sourcepub fn from_array(base: &'a mut [f64]) -> Self
pub fn from_array(base: &'a mut [f64]) -> Self
These functions return a vector view of an array. The start of the new vector is given by base and has n elements. Mathematically, the i-th element of the new vector v’ is given by,
v'(i) = base[i]
where the index i runs from 0 to n-1.
The array containing the elements of v is not owned by the new vector view. When the view goes out of scope the original array will continue to exist. The original memory can only be deallocated by freeing the original pointer base. Of course, the original array should not be deallocated while the view is still in use.
The function gsl_vector_const_view_array is equivalent to gsl_vector_view_array but can be used for arrays which are declared const.
sourcepub fn from_array_with_stride(base: &'a mut [i32], stride: usize) -> Self
pub fn from_array_with_stride(base: &'a mut [i32], stride: usize) -> Self
These functions return a vector view of an array base with an additional stride argument. The subvector is formed in the same way as for gsl_vector_view_array but the new vector has n elements with a step-size of stride from one element to the next in the original array. Mathematically, the i-th element of the new vector v’ is given by,
v’(i) = base[i*stride]
where the index i runs from 0 to n-1.
Note that the view gives direct access to the underlying elements of the original array. A vector view can be passed to any subroutine which takes a vector argument just as a directly allocated vector would be, using &view.vector.
The function gsl_vector_const_view_array_with_stride is equivalent to gsl_vector_view_array_with_stride but can be used for arrays which are declared const.
pub fn vector<F: FnOnce(Option<&VectorI32>)>(&self, f: F)
pub fn vector_mut<F: FnOnce(Option<&mut VectorI32>)>(&mut self, f: F)
Auto Trait Implementations
impl<'a> RefUnwindSafe for VectorI32View<'a>
impl<'a> !Send for VectorI32View<'a>
impl<'a> !Sync for VectorI32View<'a>
impl<'a> Unpin for VectorI32View<'a>
impl<'a> UnwindSafe for VectorI32View<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more