vsip_vview_f* vsip_mcolview_f(const vsip_mview_f* matrix, vsip_index col_index); vsip_cvview_f* vsip_cmcolview_f(const vsip_cmview_f* matrix, vsip_index col_index);
This function creates a vector view that represents a single column of a matrix. The resulting vector view shares the same underlying data block as the matrix but provides access to only the specified column. 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 rows 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 col_index: The index of the column to extract (0-based).
On success, returns a pointer to the newly created vector view representing the specified column.
On error (e.g., if the column index is out of bounds), returns NULL.
vsip_mview_f *matrix; vsip_vview_f *col_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) col_vector = vsip_mcolview_f(matrix, 2); if (col_vector == NULL) { // Handle error } // Now col_vector represents the 3rd row of the matrix // and has length equal to the number of rows (5)
The column vector view shares the same underlying data block as the source matrix.
Modifications to the column vector will affect the source matrix and vice versa.
The column index must be within the valid range of the matrix (0
col_index
number of columns).
The created vector view has a length equal to the number of rows in the source matrix.
The vector view maintains the same stride as the column stride of the source matrix.
This operation is efficient as it doesn’t copy any data, only creates a new view.