typedef struct { vsip_length row_length; /* Number of rows */ vsip_length col_length; /* Number of columns */ vsip_offset offset; /* Offset into the block */ vsip_stride row_stride; /* Stride between rows */ vsip_stride col_stride; /* Stride between columns */ vsip_block_f* block; /* Pointer to the data block */ } vsip_mattr_f; /* same for the other dataypes with the respective vsip_dblock_p */ void vsip_mgetattrib_f(const vsip_mview_f* v, vsip_mattr_f* attr); void vsip_cmgetattrib_f(const vsip_cmview_f* v, vsip_cmattr_f* attr);
This function retrieves all attributes of a matrix view and stores them in a vsip_dmattr_p structure. The attribute structure contains complete information about the matrix view’s dimensions, memory layout, and binding to its data block.
const vsip_dmview_p* v: Pointer to the matrix view.
vsip_dmattr_p* attr: Pointer to the attribute structure where the matrix attributes will be stored.
vsip_mview_f *matrix; vsip_mattr_f attr; // Create a matrix matrix = vsip_mcreate_f(100, 100, VSIP_ROW, VSIP_MEM_NONE); // Get all matrix attributes vsip_mgetattrib_f(matrix, &attr); printf("Matrix attributes:\n"); printf(" Dimensions: %lu x %lu\n", attr.row_length, attr.col_length); printf(" Memory offset: %ld\n", attr.offset); printf(" Row stride: %ld\n", attr.row_stride); printf(" Column stride: %ld\n", attr.col_stride); printf(" Block pointer: %p\n", (void*)attr.block); // Create a submatrix view and examine its attributes vsip_mview_f *submatrix = vsip_msubview_f(matrix, 10, 10, 50, 50); vsip_mgetattrib_f(submatrix, &attr); printf("\nSubmatrix attributes:\n"); printf(" Dimensions: %lu x %lu\n", attr.row_length, attr.col_length); printf(" Memory offset: %ld\n", attr.offset); // Create a transposed view and examine its attributes vsip_mview_f *transposed = vsip_mtransview_f(matrix); vsip_mgetattrib_f(transposed, &attr); printf("\nTransposed matrix attributes:\n"); printf(" Dimensions: %lu x %lu\n", attr.row_length, attr.col_length); printf(" Row stride: %ld\n", attr.row_stride); printf(" Column stride: %ld\n", attr.col_stride);
The vsip_mattr_f structure contains all information needed to completely describe a matrix view.
The block field points to the underlying data block that stores the matrix elements.
For row-major matrices, col_stride is typically 1 and row_stride equals the number of columns.
For column-major matrices, row_stride is typically 1 and col_stride equals the number of rows.
For transposed views, the row and column strides are swapped compared to the original matrix.
The offset indicates how many elements from the start of the block the matrix begins at.