Skip to main content

to_row_major

Function to_row_major 

Source
pub fn to_row_major<'a, S: Data<Elem = f64>>(
    a: &'a ArrayBase<S, Ix2>,
) -> Cow<'a, [f64]>
Expand description

Borrow (or pack) a 2D array’s buffer in ROW-major (C) order.

The col-major dual of to_col_major: when the input is already C-contiguous its raw buffer IS the row-major flat layout, so this borrows it with no allocation or copy. Non-contiguous / F-order inputs are packed row by row.

This is the host-transpose-free upload path. A row-major (r × c) buffer, reinterpreted as a column-major buffer, is exactly the transpose (c × r) of the logical matrix — which is what the swapped-operand cuBLAS GEMM (Cᵀ = Bᵀ·Aᵀ) consumes, letting both the design upload and the result download skip the O(r·c) scalar permutation that dominated tall-skinny GEMMs on the host.