/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/*             ********   ***                                 SparseLib++    */
/*          *******  **  ***       ***      ***               v. 1.5c        */
/*           *****      ***     ******** ********                            */
/*            *****    ***     ******** ********              R. Pozo        */
/*       **  *******  ***   **   ***      ***                 K. Remington   */
/*        ********   ********                                 A. Lumsdaine   */
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/*                                                                           */
/*                                                                           */
/*                     SparseLib++ : Sparse Matrix Library                   */
/*                                                                           */
/*               National Institute of Standards and Technology              */
/*                        University of Notre Dame                           */
/*              Authors: R. Pozo, K. Remington, A. Lumsdaine                 */
/*                                                                           */
/*                                 NOTICE                                    */
/*                                                                           */
/* Permission to use, copy, modify, and distribute this software and         */
/* its documentation for any purpose and without fee is hereby granted       */
/* provided that the above notice appear in all copies and supporting        */
/* documentation.                                                            */
/*                                                                           */
/* Neither the Institutions (National Institute of Standards and Technology, */
/* University of Notre Dame) nor the Authors make any representations about  */
/* the suitability of this software for any purpose.  This software is       */
/* provided ``as is'' without expressed or implied warranty.                 */
/*                                                                           */
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/


#ifndef _IOHB_H_
#define _IOHB_H_

#include<stdio.h>  // ajout GR
#include<stdlib.h> // ajout GR
#include<string.h> // ajout GR

#ifdef __ProtoGlarp__
#undef __ProtoGlarp__
#endif
#if defined(__STDC__) || defined(__cplusplus)
#define __ProtoGlarp__(x) x
#else
#define __ProtoGlarp__(x) ()
#endif
 
//#ifdef __cplusplus
//extern "C" {
//#endif

void  readHB_info       __ProtoGlarp__(( const char*, int*, int*, int*, int* ));
//void readHB_mat_double  __ProtoGlarp__(( const char*, int*, int*, double*));
//void readHB_mat_float   __ProtoGlarp__(( const char*, int*, int*, float*));

//void readHB_rhs_double __ProtoGlarp__(( const char*, double*, int));
//void readHB_rhs_float  __ProtoGlarp__(( const char*, float*, int));

//void writeHB_mat_double 
//    __ProtoGlarp__(( const char*, int, int, int, const int*, const int*, 
//            const double*, int, const double*, const char*, const char*));
//void writeHB_mat_float  
 //   __ProtoGlarp__(( const char*, int, int, int, const int*, const int*, 
//            const float*, int, const double*, const char*, const char*));

//#ifdef __cplusplus
//}
//#endif

void  readHB_header
(FILE *in_file, char *Title, char *Key, char *Type, 
int *Nrow, int *Ncol, int *Nnzero, int *Nrhs,
char *Ptrfmt, char *Indfmt, char *Valfmt, char *Rhsfmt,
int *Ptrcrd, int *Indcrd, int *Valcrd, int *Rhscrd,
char *Rhstype);

void nullchk(char *line_ptr);

void readHB_mat_double(const char *filename, int colptr[], int rowind[], double val[]);

void ParseIfmt(char *fmt, int *perline, int *width);

void ParseRfmt(char *fmt, int *perline, int *width, int *flag);

char* substr(char *S,int pos,int len);

char* substr_after(char *S, char M);

char* substr_before(char *S, char M);

char* substr_through(char *S, char M);

void upcase(char *S);

int my_index(char *S, char M);

void readHB_newmat_double(char *filename, int *M, int *N, int *nonzeros,
              int **colptr,int **rowind, double **val);
              
void readHB_newmat_float(char *filename, int *M, int *N, int *nonzeros,
                      int **colptr, int **rowind, float **val);
                      
void convertDtoE(char *line);

void readHB_mat_float(char *filename, int *colptr, int *rowind, float *val);

void readHB_rhs_double(const char *filename, double b[], int j);

void readHB_rhs_float(char *filename, float b[], int j);

void writeHB_mat_double(const char *filename, int M,int N,int nz,const int colptr[]
,const  int rowind[],const  double val[], int nrhs,const double rhs[], const char *Title,const  char *Key);

void writeHB_mat_float(char *filename, int M,int N,int nz,int colptr[]
       , int rowind[], float val[], int nrhs,float rhs[]
       , char *Title, char *Key);







#endif
