| 16 |
|
none, transmission, reflection front (normal side), reflection back */ |
| 17 |
|
typedef enum {RMPnone=-1, RMPtrans=0, RMPreflF, RMPreflB} RMPref; |
| 18 |
|
|
| 19 |
+ |
/* RMATRIX flags (usually private): |
| 20 |
+ |
need to swap input, we should free memory */ |
| 21 |
+ |
#define RMF_SWAPIN 1 |
| 22 |
+ |
#define RMF_FREEMEM 2 |
| 23 |
+ |
|
| 24 |
+ |
#define DTrmx_native DTdouble /* in-core data type */ |
| 25 |
+ |
#define rmx_dtype double |
| 26 |
+ |
|
| 27 |
|
/* General [row][col][cmp] component matrix */ |
| 28 |
|
typedef struct { |
| 29 |
< |
char *info; |
| 30 |
< |
void *mapped; |
| 31 |
< |
double *mtx; |
| 32 |
< |
COLOR cexp; |
| 33 |
< |
float wlpart[4]; |
| 34 |
< |
int nrows, ncols; |
| 35 |
< |
short ncomp; |
| 36 |
< |
uby8 dtype; |
| 37 |
< |
uby8 swapin; |
| 29 |
> |
char *info; |
| 30 |
> |
void *mapped; |
| 31 |
> |
rmx_dtype *mtx; |
| 32 |
> |
COLOR cexp; |
| 33 |
> |
float wlpart[4]; |
| 34 |
> |
int nrows, ncols; |
| 35 |
> |
short ncomp; |
| 36 |
> |
uby8 dtype; |
| 37 |
> |
uby8 pflags; |
| 38 |
|
} RMATRIX; |
| 39 |
|
|
| 40 |
|
#define rmx_lval(rm,r,c) ((rm)->mtx + (rm)->ncomp*((c)+(size_t)(rm)->ncols*(r))) |
| 41 |
|
#define rmx_val rmx_lval |
| 42 |
|
|
| 43 |
+ |
#define rmx_array_size(rm) (sizeof(rmx_dtype)*(rm)->nrows*(rm)->ncols*(rm)->ncomp) |
| 44 |
+ |
#define rmx_mapped_size(rm) ((char *)(rm)->mtx + rmx_array_size(rm) - (char *)(rm)->mapped) |
| 45 |
+ |
|
| 46 |
|
/* Initialize a RMATRIX struct but don't allocate array space */ |
| 47 |
|
extern RMATRIX *rmx_new(int nr, int nc, int n); |
| 48 |
|
|
| 64 |
|
/* Read matrix header from input stream (cannot be XML) */ |
| 65 |
|
extern int rmx_load_header(RMATRIX *rm, FILE *fp); |
| 66 |
|
|
| 67 |
< |
/* Load next row as double (cannot be XML) */ |
| 68 |
< |
extern int rmx_load_row(double *drp, const RMATRIX *rm, FILE *fp); |
| 67 |
> |
/* Load next row as rmx_dtype (cannot be XML) */ |
| 68 |
> |
extern int rmx_load_row(rmx_dtype *drp, const RMATRIX *rm, FILE *fp); |
| 69 |
|
|
| 70 |
|
/* Allocate & load post-header data from stream given type set in rm->dtype */ |
| 71 |
|
extern int rmx_load_data(RMATRIX *rm, FILE *fp); |
| 80 |
|
extern int rmx_write_header(const RMATRIX *rm, int dtype, FILE *fp); |
| 81 |
|
|
| 82 |
|
/* Write out matrix data (usually by row) */ |
| 83 |
< |
extern int rmx_write_data(const double *dp, int nc, int len, |
| 83 |
> |
extern int rmx_write_data(const rmx_dtype *dp, int nc, int len, |
| 84 |
|
int dtype, FILE *fp); |
| 85 |
|
|
| 86 |
|
/* Write matrix using file format indicated by dtype */ |
| 92 |
|
/* Duplicate the given matrix */ |
| 93 |
|
extern RMATRIX *rmx_copy(const RMATRIX *rm); |
| 94 |
|
|
| 95 |
< |
/* Allocate and assign transposed matrix */ |
| 96 |
< |
extern RMATRIX *rmx_transpose(const RMATRIX *rm); |
| 95 |
> |
/* Replace data in first matrix with data from second */ |
| 96 |
> |
extern int rmx_transfer_data(RMATRIX *rdst, RMATRIX *rsrc, int dometa); |
| 97 |
> |
|
| 98 |
> |
/* Transpose the given matrix */ |
| 99 |
> |
extern int rmx_transpose(RMATRIX *rm); |
| 100 |
|
|
| 101 |
|
/* Multiply (concatenate) two matrices and allocate the result */ |
| 102 |
|
extern RMATRIX *rmx_multiply(const RMATRIX *m1, const RMATRIX *m2); |