Expand description
Conversion utilities between ndarray and OxiBLAS types.
This module provides two distinct kinds of conversions between
ndarray’s Array2/ArrayView2/ArrayViewMut2 and OxiBLAS’s
Mat/MatRef/MatMut types, and it is important not to confuse them:
- Genuinely zero-copy views:
array_view_to_mat_ref,array_view_to_mat_ref_or_transposed,array_view_mut_to_mat_mut,array_viewd_to_mat_ref,array_viewd_to_mat_ref_or_transposed, andarray_view_mutd_to_mat_mutwrap the source array’s existing buffer in a borrowingMatRef/MatMut- no allocation, no element copy - whenever the array is contiguous along one axis with a non-negative stride. They returnNonefor layouts that cannot be represented this way (non-contiguous, or a reversed/negative-stride axis, whichMatRef/MatMutdo not support). - Copying conversions:
array2_to_mat,array2_into_mat,arrayd_to_mat,arrayd_into_mat,mat_to_array2,mat_to_array2_c,mat_ref_to_array2,mat_to_arrayd, andmat_ref_to_arraydalways allocate a brand-new buffer and copy every element.Mat’s storage (AlignedVec) is always a distinct, cache-line-aligned allocation with a possibly-padded column stride (seeoxiblas_matrix::Mat’s memory layout docs), so it can never adopt/reuse anndarray::Array2’sVec-backed buffer - regardless of whether the source array happens to already be column-major. If you need a real zero-copy path, work withMatRef/MatMutvia the view conversions above instead ofMat.
Functions§
- array1_
to_ vec - Converts an ndarray Array1 to a Vec.
- array2_
into_ mat - Converts an ndarray Array2 to an OxiBLAS Mat, consuming the array.
- array2_
to_ arrayd - Converts an Array2 to an ArrayD.
- array2_
to_ mat - Converts an ndarray Array2 to an OxiBLAS Mat by copying every element.
- array_
view1_ as_ slice - Gets a slice from an ArrayView1 if contiguous.
- array_
view1_ as_ slice_ mut - Gets a mutable slice from an ArrayViewMut1 if contiguous.
- array_
view_ mut_ to_ mat_ mut - Creates a MatMut view from an ndarray ArrayViewMut2.
- array_
view_ mutd_ to_ mat_ mut - Creates a MatMut view from an ndarray ArrayViewMutD.
- array_
view_ to_ mat_ ref - Creates a MatRef view from an ndarray ArrayView2.
- array_
view_ to_ mat_ ref_ or_ transposed - Creates a MatRef view from an ndarray ArrayView2, handling row-major layout by returning a transposed view if needed.
- array_
viewd_ to_ mat_ ref - Creates a MatRef view from an ndarray ArrayViewD.
- array_
viewd_ to_ mat_ ref_ or_ transposed - Creates a MatRef view from an ndarray ArrayViewD, handling row-major layout.
- arrayd_
into_ mat - Converts an ndarray ArrayD to an OxiBLAS Mat, consuming the array.
- arrayd_
to_ array2 - Converts an ArrayD to an Array2.
- arrayd_
to_ mat - Converts an ndarray ArrayD (dynamic dimension) to an OxiBLAS Mat.
- filled_
f - Creates a column-major Array2 filled with a value.
- is_
column_ major - Checks if an Array2 is in column-major (Fortran) order.
- is_
row_ major - Checks if an Array2 is in row-major (C) order.
- mat_
ref_ to_ array2 - Converts an OxiBLAS MatRef to an ndarray Array2.
- mat_
ref_ to_ arrayd - Converts an OxiBLAS MatRef to an ndarray ArrayD.
- mat_
to_ array2 - Converts an OxiBLAS Mat to an ndarray Array2.
- mat_
to_ array2_ c - Converts an OxiBLAS Mat to a row-major ndarray Array2.
- mat_
to_ arrayd - Converts an OxiBLAS Mat to an ndarray ArrayD.
- slice_
to_ array1 - Converts a slice to an ndarray Array1.
- to_
column_ major - Converts a row-major Array2 to column-major.
- zeros_f
- Creates a column-major Array2 (Fortran order).