/[gsl]/gsl/rng/file.c
ViewVC logotype

Diff of /gsl/rng/file.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1.2.1 by bjg, Fri May 30 15:49:49 2003 UTC revision 1.1.2.2 by bjg, Wed Jul 23 15:06:33 2003 UTC
# Line 1  Line 1 
1  /* rng/file.c  /* rng/file.c
2   *   *
3   * Copyright (C) 1996, 1997, 1998, 1999, 2000 Brian Gough   * Copyright (C) 2003 Olaf Lenz
4   *   *
5   * This program is free software; you can redistribute it and/or modify   * This program is free software; you can redistribute it and/or modify
6   * it under the terms of the GNU General Public License as published by   * it under the terms of the GNU General Public License as published by
# Line 55  gsl_rng_fwrite (FILE * stream, const gsl Line 55  gsl_rng_fwrite (FILE * stream, const gsl
55    
56    return GSL_SUCCESS;    return GSL_SUCCESS;
57  }  }
   
 int  
 gsl_rng_fprintf (FILE * stream, const gsl_rng * r, const char * sep)  
 {  
   size_t n = r->type->size ;  
   
   unsigned char * state = r->state;  
   
   size_t i;  
   
   for (i = 0; i < n; i++)  
     {  
       int status = fprintf (stream, "%x%s", state[i], sep);  
   
       if (status < 0)  
         {  
           GSL_ERROR ("fprintf failed", GSL_EFAILED);  
         }  
     }  
   
   return GSL_SUCCESS;  
 }  
   
 int  
 gsl_rng_fscanf (FILE * stream, gsl_rng * r)  
 {  
   size_t n = r->type->size ;  
   
   unsigned char * state = r->state;  
   
   size_t i;  
   
   for (i = 0; i < n; i++)  
     {  
       unsigned int j ;    
   
       int status = fscanf (stream, "%x", &j);    
   
       j &= 0xff;  
   
       if (status != 1)  
         {  
           GSL_ERROR ("fscanf failed", GSL_EFAILED);  
         }  
   
       state[i] = j;  
     }  
   
   return GSL_SUCCESS;  
 }  
   

Legend:
Removed from v.1.1.2.1  
changed lines
  Added in v.1.1.2.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26