#ifndef matfile_included #define matfile_included #ifndef dbext_included #include "dbext.h" /* HOST_ENVIRONMENT and LONG*/ #endif #define PC 0000 #define M68000 1000 #define VAX_D 2000 /* #define VAX_G 3000 -- not currently supported in CODAS3 */ /*----------------------------------------------------------------------- EDIT FOLLOWING LINE(S) TO DEFINE HOST ENVIRONMENT OTHER THAN LISTED -----------------------------------------------------------------------*/ #if HOST_ENVIRONMENT == PC_COMPATIBLE_HOST #define MACHINE_TYPE PC #define NaN_d_0 0 #define NaN_d_1 -524288 /* 0xFFFF80000 */ #else #if HOST_ENVIRONMENT == SUN3_COMPATIBLE_HOST #define MACHINE_TYPE M68000 #define NaN_d_0 0x7FFFFFFF #define NaN_d_1 0xFFFFFFFF #endif #endif /* We need to find out what these should be for the other machines. */ #define REAL_ROWS 0 #define IMAG_ROWS 1 #define REAL_COLS 10 #define IMAG_COLS 11 #define COLUMN_WISE 0 #define ROW_WISE 100 #define type_M(x) ( (x).type / 1000 * 1000 ) /* Machine type */ #define type_O(x) ( (x).type % 1000 / 100 * 100 ) /* Orientation */ #define type_P(x) ( (x).type % 100 / 10 * 10 ) /* Precision */ #define type_T(x) ( (x).type % 10 ) /* Text */ /* These functions for working with matfiles are in MATFIL_S.LIB */ typedef struct { LONG type; /* type */ LONG mrows; /* row dimension */ LONG ncols; /* column dimension */ LONG imagf; /* flag indicating imag part */ LONG namlen; /* name length (including NULL) */ } Fmatrix; typedef struct { FILE *fp; int Fmatrix_origin; /* offset into file */ int count_offset; /* offset of count from Fmatrix_origin */ int count; /* number of rows or columns written */ int nbytes; /* bytes per data item */ int n_rc; /* number of rows or columns */ } MAT_ARRAY_FP_TYPE; /* SAVEMATX.C */ double *matstring(char *s, int *n); char *transpose(char pdata[], int Crows, int Ccols, int nbytes); void savemat( FILE *fp, /* File pointer */ char type, char *pname, /* pointer to matrix name */ int mrows, /* row dimension */ int ncols, /* column dimension */ int imagf, /* imaginary flag */ char *preal, /* pointer to real data */ char *pimag); /* pointer to imag data */ /* SAVEMATC.C */ void tonan_f(double *dest, float *source, int n); void tonan_d(double *dest, double *source, int n); void tonan_mask_d(double *dest, double *source, int *mask, int minmask, int n); MAT_ARRAY_FP_TYPE *start_mat_array( FILE *fp, /* File pointer */ char type, /* d, f, l, i, u, t: double, float, long, short, ushort, text */ char *pname, /* pointer to matrix name */ char rc_flag, /* r if rows will be added, c otherwise */ int n_rc); /* number of columns if rows will be added, or the converse */ void add_to_mat_array( MAT_ARRAY_FP_TYPE *mat_ptr, char *data_ptr); void end_mat_array( MAT_ARRAY_FP_TYPE *mat_ptr); /* LOADMATX.C */ int loadmat( FILE *fp, /* File pointer */ char *type, /* Type flag: d, f, l, i, u, t */ char *pname, /* pointer to matrix name */ int *mrows, /* row dimension */ int *ncols, /* column dimension */ int *imagf, /* imaginary flag */ char **preal, /* pointer to real data */ char **pimag); /* pointer to imag data */ char *convert_mat_string(double *s, int n); /* MATSCAN.C */ void matscan(FILE *fp); #endif /* ifndef matfile_included */