ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/rmatrix.h
(Generate patch)

Comparing ray/src/util/rmatrix.h (file contents):
Revision 2.9 by greg, Wed Oct 31 22:19:57 2018 UTC vs.
Revision 2.23 by greg, Thu Jun 6 16:46:31 2024 UTC

# Line 12 | Line 12
12   extern "C" {
13   #endif
14  
15 < /* General plane-ordered component matrix */
15 > /* Preferred BSDF component:
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 >
26 > /* General [row][col][cmp] component matrix */
27   typedef struct {
17        int     nrows, ncols, ncomp;
18        int     dtype;
28          char    *info;
29 <        double  mtx[1];                 /* extends struct */
29 >        void    *mapped;
30 >        double  *mtx;
31 >        COLOR   cexp;
32 >        float   wlpart[4];
33 >        int     nrows, ncols;
34 >        short   ncomp;
35 >        uby8    dtype;
36 >        uby8    pflags;
37   } RMATRIX;
38  
39 < #define rmx_lval(rm,r,c,i)      (rm)->mtx[(i)+(rm)->ncomp*((c)+(size_t)(rm)->ncols*(r))]
39 > #define rmx_lval(rm,r,c)        ((rm)->mtx + (rm)->ncomp*((c)+(size_t)(rm)->ncols*(r)))
40 > #define rmx_val                 rmx_lval
41  
42 < /* Allocate a nr x nc matrix with n components */
42 > #define rmx_array_size(rm)      (sizeof(double)*(rm)->nrows*(rm)->ncols*(rm)->ncomp)
43 > #define rmx_mapped_size(rm)     ((char *)(rm)->mtx + rmx_array_size(rm) - (char *)(rm)->mapped)
44 >
45 > /* Initialize a RMATRIX struct but don't allocate array space */
46 > extern RMATRIX  *rmx_new(int nr, int nc, int n);
47 >
48 > /* Prepare a RMATRIX for writing (allocate array if needed) */
49 > extern int      rmx_prepare(RMATRIX *rm);
50 >
51 > /* Call rmx_new() and rmx_prepare() */
52   extern RMATRIX  *rmx_alloc(int nr, int nc, int n);
53  
54 < /* Free a RMATRIX array */
54 > /* Clear state by freeing info and matrix data */
55 > extern void     rmx_reset(RMATRIX *rm);
56 >
57 > /* Free an RMATRIX struct and data */
58   extern void     rmx_free(RMATRIX *rm);
59  
60   /* Resolve data type based on two input types (returns 0 for mismatch) */
61   extern int      rmx_newtype(int dtyp1, int dtyp2);
62  
63 + /* Read matrix header from input stream (cannot be XML) */
64 + extern int      rmx_load_header(RMATRIX *rm, FILE *fp);
65 +
66 + /* Load next row as double (cannot be XML) */
67 + extern int      rmx_load_row(double *drp, const RMATRIX *rm, FILE *fp);
68 +
69 + /* Allocate & load post-header data from stream given type set in rm->dtype */
70 + extern int      rmx_load_data(RMATRIX *rm, FILE *fp);
71 +
72   /* Load matrix from supported file type (NULL for stdin, '!' with command) */
73 < extern RMATRIX  *rmx_load(const char *inspec);
73 > extern RMATRIX  *rmx_load(const char *inspec, RMPref rmp);
74  
75   /* Append header information associated with matrix data */
76   extern int      rmx_addinfo(RMATRIX *rm, const char *info);
77  
78 < /* Write matrix to file type indicated by dtype */
78 > /* Finish writing header data with resolution and format, returning type used */
79 > extern int      rmx_write_header(const RMATRIX *rm, int dtype, FILE *fp);
80 >
81 > /* Write out matrix data (usually by row) */
82 > extern int      rmx_write_data(const double *dp, int nc, int len,
83 >                                int dtype, FILE *fp);
84 >
85 > /* Write matrix using file format indicated by dtype */
86   extern int      rmx_write(const RMATRIX *rm, int dtype, FILE *fp);
87  
88   /* Allocate and assign square identity matrix with n components */
# Line 45 | Line 90 | extern RMATRIX *rmx_identity(int dim, int n);
90  
91   /* Duplicate the given matrix */
92   extern RMATRIX  *rmx_copy(const RMATRIX *rm);
93 +
94 + /* Replace data in first matrix with data from second */
95 + extern int      rmx_transfer_data(RMATRIX *rdst, RMATRIX *rsrc, int dometa);
96  
97   /* Allocate and assign transposed matrix */
98   extern RMATRIX  *rmx_transpose(const RMATRIX *rm);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines