public inbox for gsl-discuss@sourceware.org
 help / color / mirror / Atom feed
* help with gsl_matrix_complex_row
@ 2003-05-15 21:31 Mario Pernici
  2003-05-19  9:42 ` Brian Gough
       [not found] ` <200305191158.43653.ivo.alxneit@psi.ch>
  0 siblings, 2 replies; 6+ messages in thread
From: Mario Pernici @ 2003-05-15 21:31 UTC (permalink / raw)
  To: gsl-discuss


Hello.
I cannot find what I do wrong using gsl_matrix_complex_row.
The following example gives garbage in the second row.
The corresponding example with gsl_matrix_row and doubles works correctly.
Help would be appreciated.
Bye
 Mario

Here is the example:
#include <stdio.h>
#include <gsl/gsl_matrix_complex_double.h>

int main()
{
  gsl_complex z00, z01, z10, z11;
  gsl_matrix_complex * m;
  gsl_vector_complex_view vv0, vv1;
  int i;

  GSL_SET_COMPLEX(&z00, 1.0, 1.1); GSL_SET_COMPLEX(&z01, 1.2, 1.3);
  GSL_SET_COMPLEX(&z10, 1.4, 1.5); GSL_SET_COMPLEX(&z11, 1.6, 1.7);

  m = gsl_matrix_complex_alloc(2,2);
  gsl_matrix_complex_set(m,0,0,z00); gsl_matrix_complex_set(m,0,1,z01);
  gsl_matrix_complex_set(m,1,0,z10); gsl_matrix_complex_set(m,1,1,z11);

  vv0 = gsl_matrix_complex_row(m,0); vv1 = gsl_matrix_complex_row(m,1);

  for(i=0; i < 2; i++) {
  gsl_complex z0;
  z0 = gsl_vector_complex_get(&vv0.vector, i);
  printf("row0(%d) = %g, %g\n", i, GSL_REAL(z0), GSL_IMAG(z0));

  z0 = gsl_vector_complex_get(&vv1.vector, i);
  printf("row1(%d) = %g, %g\n", i, GSL_REAL(z0), GSL_IMAG(z0));
  }

  gsl_matrix_complex_free (m);
}

===========
Output:
row0(0) = 1, 1.1
row1(0) = -3.00652e-182, 7.7651e-62
row0(1) = 1.2, 1.3
row1(1) = -1.31435e+64, 3.39464e+184



^ permalink raw reply	[flat|nested] 6+ messages in thread
* help with gsl_matrix_complex_row
@ 2003-05-20 13:01 Mario Pernici
  2003-05-20 13:30 ` Dirk Eddelbuettel
  0 siblings, 1 reply; 6+ messages in thread
From: Mario Pernici @ 2003-05-20 13:01 UTC (permalink / raw)
  To: gsl-discuss

Dear Brian,
 > I cannot find what I do wrong using gsl_matrix_complex_row.
 > The following example gives garbage in the second row.
 > The corresponding example with gsl_matrix_row and doubles works 
correctly.
 > Help would be appreciated.
 >

< What platform and compiler?
< It works for me (gcc 2.95.4 on x86, Debian 3.0).

 I have Red Hat Linux 7.2 and
 gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-98)

 Bye
  Mario




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

end of thread, other threads:[~2003-05-20 22:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-15 21:31 help with gsl_matrix_complex_row Mario Pernici
2003-05-19  9:42 ` Brian Gough
     [not found] ` <200305191158.43653.ivo.alxneit@psi.ch>
     [not found]   ` <16073.2415.364552.763652@debian.local>
2003-05-20  9:17     ` Ivo Alxneit
2003-05-20 13:01 Mario Pernici
2003-05-20 13:30 ` Dirk Eddelbuettel
2003-05-20 22:15   ` Mario Pernici

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).