ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/cmatrix.h
Revision: 2.15
Committed: Fri Apr 4 18:06:48 2025 UTC (3 weeks, 6 days ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 2.14: +10 -3 lines
Log Message:
perf(rmtxop,rcomb): Switched default internal data type from double to float

File Contents

# User Rev Content
1 greg 2.15 /* RCSid $Id: cmatrix.h,v 2.14 2023/11/21 01:30:20 greg Exp $ */
2 greg 2.1 /*
3     * Color matrix routine declarations.
4     *
5     * G. Ward
6     */
7    
8     #ifndef _RAD_CMATRIX_H_
9     #define _RAD_CMATRIX_H_
10    
11 greg 2.8 #include <sys/types.h>
12 greg 2.1 #include "color.h"
13    
14     #ifdef __cplusplus
15     extern "C" {
16     #endif
17    
18 greg 2.15 /* Data types for file loading (used to be an enum) */
19     #define DTfromHeader 0
20     #define DTrgbe 1
21     #define DTxyze 2
22     #define DTspec 3
23     #define DTfloat 4
24     #define DTascii 5
25     #define DTdouble 6
26     #define DTend 7
27 greg 2.4
28 greg 2.13 extern const char stdin_name[];
29 greg 2.4 extern const char *cm_fmt_id[];
30     extern const int cm_elem_size[];
31 greg 2.1
32     /* A color coefficient matrix -- vectors have ncols==1 */
33     typedef struct {
34     int nrows, ncols;
35     COLORV cmem[3]; /* extends struct */
36     } CMATRIX;
37    
38     #define COLSPEC (sizeof(COLORV)==sizeof(float) ? "%f %f %f" : "%lf %lf %lf")
39    
40 greg 2.8 #define cm_lval(cm,r,c) ((cm)->cmem + 3*((size_t)(r)*(cm)->ncols + (c)))
41 greg 2.1
42     #define cv_lval(cm,i) ((cm)->cmem + 3*(i))
43    
44     /* Allocate a color coefficient matrix */
45 greg 2.5 extern CMATRIX *cm_alloc(int nrows, int ncols);
46 greg 2.1
47     /* Resize color coefficient matrix */
48 greg 2.5 extern CMATRIX *cm_resize(CMATRIX *cm, int nrows);
49 greg 2.1
50     #define cm_free(cm) free(cm)
51    
52 greg 2.5 /* Load header to obtain/check data type and matrix dimensions */
53 greg 2.12 extern char *cm_getheader(int *dt, int *nr, int *nc,
54     int *swp, COLOR scale, FILE *fp);
55 greg 2.1
56 greg 2.7 /* Allocate and load a matrix from the given input (or stdin if NULL) */
57     extern CMATRIX *cm_load(const char *inspec, int nrows, int ncols, int dtype);
58 greg 2.1
59     /* Extract a column vector from a matrix */
60 greg 2.5 extern CMATRIX *cm_column(const CMATRIX *cm, int c);
61 greg 2.1
62     /* Multiply two matrices (or a matrix and a vector) and allocate the result */
63 greg 2.5 extern CMATRIX *cm_multiply(const CMATRIX *cm1, const CMATRIX *cm2);
64 greg 2.1
65 greg 2.4 /* write out matrix to file (precede by resolution string if picture) */
66 greg 2.5 extern int cm_write(const CMATRIX *cm, int dtype, FILE *fp);
67 greg 2.1
68 greg 2.3 /* Load and convert a matrix BTDF from the given XML file */
69 greg 2.13 extern CMATRIX *cm_loadBTDF(const char *fname);
70    
71     /* Load and convert a matrix BRDF from the given XML file */
72     extern CMATRIX *cm_loadBRDF(const char *fname, int backside);
73 greg 2.1
74     #ifdef __cplusplus
75     }
76     #endif
77     #endif /* _RAD_CMATRIX_H_ */