Extract rows/columns from ** matrices in C/C++ -


i have square matrix double **a

i know how iterate through matrix:

for (int = 0; < matrix_size; i++) {  (int j = 0; j < matrix_size; j ++) {    int val = a[i][j];    printf("val: %d\n", val);  } } 

however, i'm wondering how can assign entire row or column variable given have ** matrix (the ** pointer pointer nonsense still little confusing. believe saying list of list of doubles).

to add little more background, i'm trying extract rows , columns can perform cuda matrix multiplication. see lot of documentation online uses one-dimensional vectors represent matrices (i.e. double* a) however, getting confused **

a two-dimensional array of doubles (double **) can looked @ one-dimensional array of one-dimensional arrays of doubles.

double **arr; // initialized for(int rownumber = 0; rownumber < matrix_size; ++rownumber) {     double *row = arr[rownumber];     // row     for(int colnumber = 0; colnumber < matrix_size; ++colnumber)     {         double value = row[colnumber];         // value     } } 

in above example, row pointer contiguous row of values initial array. works because 2 dimensional array allocated this:

double **arr = new double*[row_count]; for(int rownumber = 0; rownumber < row_count; ++rownumber) {     arr[rownumber] = new double[col_count]; } 

getting pointer column in matrix (like did row above) not possible because values in column not contiguous, values in each row contiguous.


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -