vsip_mview_f* vsip_mtransview_f(const vsip_mview_f* matrix); vsip_cmview_f* vsip_cmtransview_f(const vsip_cmview_f* matrix);
This function creates a new matrix view that represents the transpose of the input matrix. The transposed view shares the same underlying data block as the original matrix but presents it with rows and columns swapped. This operation is efficient as it doesn’t copy any data, but rather creates a new view with transposed dimensions and strides.
For an
input matrix, the transposed view will be an
matrix where the element at position
in the transposed
view corresponds to the element at position
in the original matrix.
const vsip_dmview_p* matrix: Pointer to the source matrix view to be transposed.
On success, returns a pointer to the newly created transposed matrix view.
On error, returns NULL.
vsip_mview_f *original_matrix; vsip_mview_f *transposed_matrix; vsip_length i, j; // Create a 4x3 matrix original_matrix = vsip_mcreate_f(4, 3, VSIP_ROW, VSIP_MEM_NONE); // Fill the matrix with some values for (i = 0; i < 4; i++) { for (j = 0; j < 3; j++) { vsip_mput_f(original_matrix, i, j, i * 3 + j + 1); } } // Create a transposed view (3x4) transposed_matrix = vsip_mtransview_f(original_matrix); if (transposed_matrix == NULL) { // Handle error } // Now transposed_matrix is a 3x4 view of the original 4x3 matrix data // Accessing transposed_matrix[0][1] is equivalent to original_matrix[1][0]
The transposed view shares the same underlying data block as the original matrix.
Modifications to the transposed view will affect the original matrix and vice versa.
The transposed view has swapped dimensions compared to the original matrix.
The strides of the transposed view are adjusted to provide the transposed access pattern.
This operation is efficient as it doesn’t copy any data, only creates a new view.