ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/rmatrix.h
Revision: 2.2
Committed: Sat May 31 19:21:21 2014 UTC (9 years, 10 months ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad4R2
Changes since 2.1: +4 -6 lines
Log Message:
Bug fixes

File Contents

# User Rev Content
1 greg 2.2 /* RCSid $Id: rmatrix.h,v 2.1 2014/05/31 05:02:37 greg Exp $ */
2 greg 2.1 /*
3     * Header file for general matrix routines.
4     */
5    
6     #ifndef _RAD_RMATRIX_H_
7     #define _RAD_RMATRIX_H_
8    
9     #include "cmatrix.h"
10    
11     #ifdef __cplusplus
12     extern "C" {
13     #endif
14    
15     /* General plane-ordered component matrix */
16     typedef struct {
17     int nrows, ncols, ncomp;
18     double mtx[1]; /* extends struct */
19     } RMATRIX;
20    
21 greg 2.2 #define rmx_lval(rm,r,c,i) (rm)->mtx[((i)*(rm)->nrows+(r))*(rm)->ncols+(c)]
22 greg 2.1
23     #define rmx_free(rm) free(rm)
24    
25     /* Allocate a nr x nc matrix with n components */
26     extern RMATRIX *rmx_alloc(int nr, int nc, int n);
27    
28     /* Load matrix from supported file type */
29     extern RMATRIX *rmx_load(const char *fname);
30    
31     /* Write matrix to file type indicated by dt */
32     extern long rmx_write(const RMATRIX *rm, int dtype, FILE *fp);
33    
34     /* Allocate and assign square identity matrix with n components */
35     extern RMATRIX *rmx_identity(int dim, int n);
36    
37     /* Duplicate the given matrix */
38     extern RMATRIX *rmx_copy(const RMATRIX *rm);
39    
40 greg 2.2 /* Allocate and assign transposed matrix */
41     extern RMATRIX *rmx_transpose(const RMATRIX *rm);
42 greg 2.1
43     /* Multiply (concatenate) two matrices and allocate the result */
44     extern RMATRIX *rmx_multiply(const RMATRIX *m1, const RMATRIX *m2);
45    
46     /* Sum second matrix into first, applying scale factor beforehand */
47     extern int rmx_sum(RMATRIX *msum, const RMATRIX *madd, const double sf[]);
48    
49     /* Scale the given matrix by the indicated scalar component vector */
50     extern int rmx_scale(RMATRIX *rm, const double sf[]);
51    
52     /* Allocate new matrix and apply component transformation */
53     extern RMATRIX *rmx_transform(const RMATRIX *msrc, int n, const double cmat[]);
54    
55     /* Convert a color matrix to newly allocated RMATRIX buffer */
56     extern RMATRIX *rmx_from_cmatrix(const CMATRIX *cm);
57    
58     /* Convert general matrix to newly allocated CMATRIX buffer */
59     extern CMATRIX *cm_from_rmatrix(const RMATRIX *rm);
60    
61     #ifdef __cplusplus
62     }
63     #endif
64     #endif /* _RAD_RMATRIX_H_ */