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 */ vsip_mview_f* vsip_mputattrib_f(vsip_mview_f* v, const vsip_mattr_f* attr); vsip_cmview_f* vsip_cmputattrib_f(vsip_cmview_f* v, const vsip_cmattr_f* attr);
This function modifies the attributes of an existing matrix view according to the parameters specified in a vsip_dmattr_p structure. It allows you to change the view’s dimensions, memory layout, and binding to its data block in a single operation.
vsip_dmview_p* v: Pointer to the matrix view to be modified.
const vsip_dmattr_p* attr: Pointer to the attribute structure containing the new attributes.
On success, returns a pointer to the modified matrix view.
On error, returns NULL.
vsip_mview_f *matrix; vsip_mattr_f attr; vsip_block_f *new_block; // Create a matrix matrix = vsip_mcreate_f(100, 100, VSIP_ROW, VSIP_MEM_NONE); // Get current attributes vsip_mgetattrib_f(matrix, &attr); printf("Original dimensions: %lu x %lu\n", attr.row_length, attr.col_length); // Modify the view to show only a submatrix attr.row_length = 50; // Show only first 50 rows attr.col_length = 50; // Show only first 50 columns attr.offset = 0; // Start from beginning of block // Keep the same strides and block if (vsip_mputattrib_f(matrix, &attr) == NULL) { // Handle error }
This function completely reconfigures the matrix view according to the provided attributes.
The new configuration must be valid (e.g., the block must be large enough to contain the view with the specified offset and strides).
The view’s dimensions can be changed, but must be compatible with the block size and strides.
The offset must be valid for the specified block.
Strides must be positive and compatible with the block size and view dimensions.