gsl_matrix_fread fails

Ivo Alxneit ivo.alxneit@psi.ch
Fri May 31 07:52:00 GMT 2002


hi
i am trying to read a matrix with the following code

#include <stdio.h>
#include <stdlib.h>
#include <gsl/gsl_matrix.h>
#include "lavision.h"

int main(void)
{
	image_header header;
	gsl_matrix *m;

	fread(&header, sizeof(image_header), 1, stdin);
	
	m = gsl_matrix_alloc(header.rows, header.columns);
	gsl_matrix_fread(stdin, m);
	
	gsl_matrix_free(m);
	return 0;
}

running it as ./a.out < test.imx
fails with
gsl: fwrite_source.c:64: ERROR: fread failed

Program received signal SIGABRT, Aborted.
0x401f2d21 in __kill () from /lib/libc.so.6

when i traced it in ddd i found that it fails in

int
FUNCTION (gsl_matrix, fread) (FILE * stream, TYPE (gsl_matrix) * m)
{
  int status = 0;
    
  const size_t size1 = m->size1; 
  const size_t size2 = m->size2;
    
  const size_t tda = m->tda;
    
  if (tda == size2) /* the rows are contiguous */
    {
      status = FUNCTION (gsl_block, raw_fread) (stream,    <<<<<< error!
                                                m->data, 
                                                size1 * size2, 1);
            
however fwrite_source.c line 64 is

int
FUNCTION (gsl_matrix, fwrite) (FILE * stream, const TYPE (gsl_matrix) * m)
{
  int status = 0;

  const size_t size1 = m->size1; 
  const size_t size2 = m->size2;

  const size_t tda = m->tda;

  if (tda == size2) /* the rows are contiguous */
    {							<<<<<line 64!
      status = FUNCTION (gsl_block, raw_fwrite) (stream, 
                                                 m->data, 
                                                 size1 * size2, 1);

so while supposed to read gsl fails in a low level write routine?? i am
completely confused. and yes i compiled gsl myself so sources should
match libraries used.
-- 
Dr. Ivo Alxneit
Laboratory for Solar Technology   phone: +41 56 310 4092
CH-5232 Villigen                    fax: +41 56 310 2624
Paul Scherrer Institute
Switzerland

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gsl-discuss/attachments/20020531/96e10a33/attachment.sig>


More information about the Gsl-discuss mailing list