At Thu, 11 Dec 2008 10:36:40 +0100,
George Kalema wrote:
> 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.
> 
> How do I use gsl_matrix to do this?

You need some code like this in the inner loop:

{
  gsl_matrix_view Xi = gsl_matrix_submatrix (X, begin, 0, ni, P)
  gsl_matrix * work = gsl_matrix_alloc(ni, p);
  gsl_matrix_memcpy (work, &(Xi.matrix));
  /* do calculation on working copy */
  ....
  /* copy work back into X, if needed */
  gsl_matrix_memcpy (&(Xi.matrix), work);
  gsl_matrix_free (work)
}

You'll find many examples of this type of code in the linalg directory
of the GSL source.

-- 
Brian Gough

Support freedom by joining the FSF!
http://www.fsf.org/news/fall-2008-fundraiser


_______________________________________________
Help-gsl mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-gsl

Reply via email to