pub trait Reallocator<T: Scalar, RFrom: Dim, CFrom: Dim, RTo: Dim, CTo: Dim>: Allocator<T, RFrom, CFrom> + Allocator<T, RTo, CTo> {
unsafe fn reallocate_copy(
nrows: RTo,
ncols: CTo,
buf: <Self as Allocator<T, RFrom, CFrom>>::Buffer
) -> <Self as Allocator<T, RTo, CTo>>::Buffer;
}
Expand description
A matrix reallocator. Changes the size of the memory buffer that initially contains (RFrom × CFrom) elements to a smaller or larger size (RTo, CTo).
Required methods
Reallocates a buffer of shape (RTo, CTo)
, possibly reusing a previously allocated buffer
buf
. Data stored by buf
are linearly copied to the output:
- The copy is performed as if both were just arrays (without a matrix structure).
- If
buf
is larger than the output size, then extra elements ofbuf
are truncated. - If
buf
is smaller than the output size, then extra elements of the output are left uninitialized.