This is the mail archive of the gsl-discuss@sources.redhat.com mailing list for the GSL project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

gsl_matrix_fread fails


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

Attachment: msg00209/pgp00000.pgp
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]