public inbox for gsl-discuss@sourceware.org
 help / color / mirror / Atom feed
* Arrays in higher dimensions
@ 2002-07-16  2:27 Przemyslaw Sliwa
  2002-07-16  6:25 ` John Ketchum
  0 siblings, 1 reply; 2+ messages in thread
From: Przemyslaw Sliwa @ 2002-07-16  2:27 UTC (permalink / raw)
  To: gsl-discuss

Hi,
my problem is - is it possible to create an ayray of gsl_matrices and 
gsl_vectors within the gsl library?
I would like to create 3 and 4 dimansional arrays - that means I need 
one and two dimensional array of
gsl_matrices and gsl_vectors.

If it is possible - how can I access the elements of such an array.
Thanks to everyone.


Przemyslaw Sliwa


Witout stupid mementos.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Arrays in higher dimensions
  2002-07-16  2:27 Arrays in higher dimensions Przemyslaw Sliwa
@ 2002-07-16  6:25 ` John Ketchum
  0 siblings, 0 replies; 2+ messages in thread
From: John Ketchum @ 2002-07-16  6:25 UTC (permalink / raw)
  To: sliwa, gsl-discuss

For 4-d array, with dimensions n1, n2, n3, and n4, something like the 
following:

gsl_matrix ***m4;
m4 = (gsl_matrix***)malloc(n4*sizeof(gsl_matrix**));
for (i=0; i<n4; i++) {
         m4[i] = (gsl_matrix**)malloc(n3*sizeof(gsl_matrix*));
         for (j=0; j<n3; j++) m4[i][j]=gsl_matrix_alloc(n1,n2);
}


This gives you a matrix of pointers to gsl matrices,  which is a 4-d construct.

Make sure you free all of the memory when you are done:

for (i=0; i<n4; i++) {
         for (j=0; j<n3; j++) gsl_matrix_free(m4[i][j]);
         free(m4[i]);
}
free(m4);



At 11:26 AM 7/16/2002 +0200, Przemyslaw Sliwa wrote:
>Hi,
>my problem is - is it possible to create an ayray of gsl_matrices and 
>gsl_vectors within the gsl library?
>I would like to create 3 and 4 dimansional arrays - that means I need one 
>and two dimensional array of
>gsl_matrices and gsl_vectors.
>
>If it is possible - how can I access the elements of such an array.
>Thanks to everyone.
>
>
>Przemyslaw Sliwa
>
>
>Witout stupid mementos.
>

John Ketchum
Qualcomm Inc.
9 Damonmill Square Suite 2A
Concord, MA 01742
Office: 60915
Direct: 781-276-0915
Fax: 781-276-0901
Mobile: 617-312-7023

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-07-16 13:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-16  2:27 Arrays in higher dimensions Przemyslaw Sliwa
2002-07-16  6:25 ` John Ketchum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).