8 |
|
#ifndef _RAD_CMATRIX_H_ |
9 |
|
#define _RAD_CMATRIX_H_ |
10 |
|
|
11 |
+ |
#include <sys/types.h> |
12 |
|
#include "color.h" |
13 |
|
|
14 |
|
#ifdef __cplusplus |
29 |
|
|
30 |
|
#define COLSPEC (sizeof(COLORV)==sizeof(float) ? "%f %f %f" : "%lf %lf %lf") |
31 |
|
|
32 |
< |
#define cm_lval(cm,r,c) ((cm)->cmem + 3*((r)*(cm)->ncols + (c))) |
32 |
> |
#define cm_lval(cm,r,c) ((cm)->cmem + 3*((size_t)(r)*(cm)->ncols + (c))) |
33 |
|
|
34 |
|
#define cv_lval(cm,i) ((cm)->cmem + 3*(i)) |
35 |
|
|
42 |
|
#define cm_free(cm) free(cm) |
43 |
|
|
44 |
|
/* Load header to obtain/check data type and matrix dimensions */ |
45 |
< |
extern char *cm_getheader(int *dt, int *nr, int *nc, FILE *fp); |
45 |
> |
extern char *cm_getheader(int *dt, int *nr, int *nc, int *swp, FILE *fp); |
46 |
|
|
47 |
|
/* Allocate and load a matrix from the given input (or stdin if NULL) */ |
48 |
|
extern CMATRIX *cm_load(const char *inspec, int nrows, int ncols, int dtype); |
49 |
|
|
50 |
|
/* Extract a column vector from a matrix */ |
51 |
|
extern CMATRIX *cm_column(const CMATRIX *cm, int c); |
51 |
– |
|
52 |
– |
/* Scale a matrix by a single value */ |
53 |
– |
extern CMATRIX *cm_scale(const CMATRIX *cm1, const COLOR sca); |
52 |
|
|
53 |
|
/* Multiply two matrices (or a matrix and a vector) and allocate the result */ |
54 |
|
extern CMATRIX *cm_multiply(const CMATRIX *cm1, const CMATRIX *cm2); |