[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## [Help-gsl] creating a submatrix from a matrix in a loop

**From**: |
George Kalema |

**Subject**: |
[Help-gsl] creating a submatrix from a matrix in a loop |

**Date**: |
Thu, 11 Dec 2008 10:36:40 +0100 |

Hi!
I am very new to GSL but I would like to do the following.
I have a matrix X of dimension [N by P]. This matrix contains data for
K subjects
meaning that there are K submatrices of dimension [ni by P] in matrix X. I
would like to take each of these submatrices Xi from X and use it for
computation in a loop.
int begin = 1;
for (i =0; i < K; i++) // loop for each subject
{
ni = freq[ i ]; // freq is a vector containing the number of rows of each
submatrix for subject i
endi = begin + ( ni - 1 ); //counter for taking me
to the end of the submatrix for subject i.
gsl_matrix * Xi = gsl_matrix_alloc(ni, p);
for (k = begin; k <= endi; k++)
{
for ( j = 0; j < p; j++)
gsl_matrix_view Xi = gsl_matrix_submatrix
(gsl_matrix * X, N, P, ni, P); ????????
}
begin = endi + 1; /* go to next subject's sub matrix */
}
How do I use gsl_matrix to do this?
Thank you for helping
Will

**[Help-gsl] creating a submatrix from a matrix in a loop**,
*George Kalema* **<=**