vsip_vview_f* vsip_mrowview_f(const vsip_mview_f* matrix, vsip_index row_index); vsip_cvview_f* vsip_cmrowview_f(const vsip_cmview_f* matrix, vsip_index row_index);
This function creates a vector view that represents a single row of a matrix. The resulting vector view shares the same underlying data block as the matrix but provides access to only the specified row. This operation is efficient as it doesn’t copy any data, but rather creates a new view that references the row data.
The created vector view has a length equal to the number of columns in the source matrix. The vector view maintains the same data type as the matrix elements.
const vsip_dmview_p* matrix: Pointer to the source matrix view.
vsip_index row_index: The index of the row to extract (0-based).
On success, returns a pointer to the newly created vector view representing the specified row.
On error (e.g., if the row index is out of bounds), returns NULL.
vsip_mview_f *matrix; vsip_vview_f *row_vector; vsip_length i, j; // Create a 5x10 matrix matrix = vsip_mcreate_f(5, 10, VSIP_ROW, VSIP_MEM_NONE); // Fill the matrix with some values for (i = 0; i < 5; i++) { for (j = 0; j < 10; j++) { vsip_mput_f(matrix, i, j, i * 10 + j + 1); } } // Get a vector view of the 3rd row (index 2) row_vector = vsip_mrowview_f(matrix, 2); if (row_vector == NULL) { // Handle error } // Now row_vector represents the 3rd row of the matrix // and has length equal to the number of columns (10)
The row vector view shares the same underlying data block as the source matrix.
Modifications to the row vector will affect the source matrix and vice versa.
The row index must be within the valid range of the matrix (0
row_index
number of rows).
The created vector view has a length equal to the number of columns in the source matrix.
The vector view maintains the same stride as the row stride of the source matrix.
This operation is efficient as it doesn’t copy any data, only creates a new view.