vsip_mview_f* vsip_msubview_f(const vsip_mview_f* matrix, vsip_index row_offset, vsip_index col_offset, vsip_length row_length, vsip_length col_length); vsip_cmview_f* vsip_cmsubview_f(const vsip_cmview_f* matrix, vsip_index row_offset, vsip_index col_offset, vsip_length row_length, vsip_length col_length);
This function creates a new matrix view that represents a submatrix of an existing matrix view. The submatrix is defined by its offset from the parent matrix and its dimensions. The new view shares the same underlying data block as the parent matrix but provides access to only the specified subregion.
This operation is efficient as it doesn’t copy any data, but rather creates a new view that references a portion of the original matrix’s data.
const vsip_mview_f* matrix: Pointer to the source matrix view.
vsip_index row_offset: The row offset of the submatrix from the parent matrix (0-based).
vsip_index col_offset: The column offset of the submatrix from the parent matrix (0-based).
vsip_length row_length: The number of rows in the submatrix.
vsip_length col_length: The number of columns in the submatrix.
On success, returns a pointer to the newly created submatrix view.
On error (e.g., if the submatrix would extend beyond the parent matrix boundaries), returns NULL.
vsip_mview_f *parent_matrix; vsip_mview_f *submatrix; // Create a parent matrix parent_matrix = vsip_mcreate_f(100, 100, VSIP_ROW, VSIP_MEM_NONE); // Create a 50x50 submatrix starting at row 25, column 25 submatrix = vsip_msubview_f(parent_matrix, 25, 25, 50, 50); if (submatrix == NULL) { // Handle error (e.g., invalid submatrix dimensions) }
The submatrix view shares the same underlying data block as the parent matrix.
Modifications to the submatrix will affect the parent matrix and vice versa.
The submatrix must be entirely contained within the parent matrix.
The strides of the submatrix are inherited from the parent matrix.
This function is useful for working with portions of a matrix without copying data.
For non-contiguous submatrices or more complex views, consider using vsip_dmbind_p directly.