Adelsbach/VSIPL
Core Programming Reference Guide
DD-00016-015
Core

1.4.4 vsip_dmget_p - Get Matrix Element

vsip_scalar_f vsip_mget_f(const vsip_mview_f *v, vsip_index i, vsip_index j); 
vsip_cscalar_f vsip_cmget_f(const vsip_cmview_f *v, vsip_index i, vsip_index j);
Description

This function retrieves the value of a specific element from a matrix view. The element is identified by its row and column indices (0-based).

Parameters
Return Value
Example

vsip_mview_f *matrix; 
vsip_scalar_f value; 
vsip_index i, j; 
 
// Create and initialize a matrix 
matrix = vsip_mcreate_f(5, 5, VSIP_ROW, VSIP_MEM_NONE); 
 
// Fill the matrix with some values 
for (i = 0; i < 5; i++) { 
    for (j = 0; j < 5; j++) { 
        vsip_mput_f(matrix, i, j, i * 5 + j + 1); 
    } 
} 
 
// Retrieve specific elements 
value = vsip_mget_f(matrix, 0, 0);  // Top-left corner 
printf("Element at (0,0): %f\n", value); 
 
value = vsip_mget_f(matrix, 2, 3);  // Middle element 
printf("Element at (2,3): %f\n", value); 
 
value = vsip_mget_f(matrix, 4, 4);  // Bottom-right corner 
printf("Element at (4,4): %f\n", value);
Notes