This is the mail archive of the
gsl-discuss@sources.redhat.com
mailing list for the GSL project.
help with gsl_matrix_complex_row
- From: Mario Pernici <Mario dot Pernici at mi dot infn dot it>
- To: gsl-discuss at sources dot redhat dot com
- Date: Thu, 15 May 2003 23:31:27 +0200 (CEST)
- Subject: help with gsl_matrix_complex_row
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