1 
2 /*
3  * International Color Consortium color transform expanded support
4  *
5  * Author:  Graeme W. Gill
6  * Date:    21/6/01
7  * Version: 1.00
8  *
9  * Copyright 2000 - 2006 Graeme W. Gill
10  * All rights reserved.
11  *
12  * This material is licenced under the GNU GENERAL PUBLIC LICENSE Version 2 or later :-
13  * see the License2.txt file for licencing details.
14  *
15  * Based on the old iccXfm class.
16  */
17 
18 /*
19  * This module supports converting spectral samples
20  * into CIE XYZ (1.0) or D50 Lab tristimulous values.
21  */
22 
23 /*
24  * TTBD:
25  *
26  * Should add some more modern standard CMFs - see <http://www.cvrl.org/>
27  *
28  * [Does this make any sense though ? That is what's happening
29  *  for a standard A illuminant instrument emitting D50 XYZ values,
30  *  but doesn't represent actually viewing under a (say) M2 illuminant.
31  *  But is M0 actual A illuminant, or notional D50 measured by an A illuminant ?]
32  */
33 
34 #include <stdlib.h>
35 #include <sys/types.h>
36 #include <time.h>
37 #include <string.h>
38 #include <math.h>
39 #ifndef SALONEINSTLIB
40 # include "numlib.h"
41 # include "cgats.h"
42 # include "plot.h"			/* For debugging */
43 #else
44 # include "numsup.h"
45 # include "sa_conv.h"
46 #endif
47 #include "conv.h"
48 #include "xspect.h"
49 
50 #define CLAMP_XYZ			/* [def] Clamp XYZ to be >= 0.0 */
51 
52 #ifndef SALONEINSTLIB
53 
54 #undef STOCKFWA				/* [und] Use table shape else compute from flat line estimate*/
55 
56 #undef DEBUG				/* [und] Extra printouts + debugging messages (need to uncomment) */
57 #undef DOPLOT				/* [und] Plot FWA setup */
58 #undef DOPLOT_ALL_FWA		/* [und] Plot all FWA corrected conversions */
59 #undef WRITE_FWA1_STIM		/* [und] Write file "fwa1_stip.sp" when FWA is setup */
60 
61 #endif /* !SALONEINSTLIB */
62 
63 #ifndef CLAMP_XYZ
64 # pragma message("###### CLAMP_XYZ is not defined ######")
65 #endif
66 
67 #if defined(DEBUG) || defined(DOPLOT) || defined(DOPLOT_ALL_FWA) || defined(WRITE_FWA1_STIM)
68 # pragma message("###### xspect debugging is on ######")
69 #endif
70 
71 #ifdef DEBUG
72 # define DBG(xx)	a1logd(g_log, 0, xx )
73 # define DBGA g_log, 0 		/* First argument to DBGF() */
74 # define DBGF(xx)	a1logd xx
75 #else
76 # define DBG(xx)
77 # define DBGF(xx)
78 #endif
79 
80 /* ======================================================== */
81 #if defined(__APPLE__) && defined(__POWERPC__)
82 
83 /* Workaround for a PPC gcc 3.3 optimiser bug... */
84 /* It seems to cause a segmentation fault instead of */
85 /* converting an integer loop index into a float, */
86 /* when there are sufficient variables in play. */
gcc_bug_fix(int i)87 static int gcc_bug_fix(int i) {
88 	static int nn;
89 	nn += i;
90 	return nn;
91 }
92 #endif	/* APPLE */
93 
94 /* ======================================================== */
95 /* Define various standard spectra */
96 
97 /* ------------------ */
98 /* Illuminant spectra */
99 
100 /* Dummy "no illuminant" illuminant spectra used to signal an emmission */
101 /* or equal energy 'E' illuminant */
102 static xspect il_none = {
103 	531, 300.0, 830.0,	/* 531 bands from 300 to 830 in 1nm steps */
104 	1.0,				/* Scale factor */
105 	{
106 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
107 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
108 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
109 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
110 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
111 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
112 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
113 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
114 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
115 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
116 
117 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
118 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
119 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
120 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
121 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
122 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
123 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
124 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
125 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
126 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
127 
128 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
129 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
130 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
131 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
132 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
133 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
134 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
135 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
136 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
137 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
138 
139 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
140 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
141 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
142 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
143 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
144 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
145 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
146 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
147 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
148 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
149 
150 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
151 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
152 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
153 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
154 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
155 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
156 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
157 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
158 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
159 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
160 
161 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
162 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
163 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
164 		1.0
165 	}
166 };
167 
168 #ifdef NEVER
169 static xspect il_none = {
170 	54, 300.0, 830.0,	/* 54 bands from 300 to 830 in 10nm steps */
171 	1.0,				/* Scale factor */
172 	{
173 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
174 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
175 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
176 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
177 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
178 		1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0
179 	}
180 };
181 #endif /* NEVER */
182 
183 
184 /* CIE 15.2-1986 Table 1.1 */
185 /* Part 1: CIE Standard Illuminant A relative spectral power distribution */
186 /* This is a 2848K tungsten filament lamp (Acording to the old temperature scale) */
187 /* and 2856 according to the newer temerature scale. */
188 static xspect il_A = {
189 	107, 300.0, 830.0,	/* 107 bands from 300 to 830 nm in 5nm steps */
190 	100.0,				/* Arbitrary scale factor */
191 	{
192 		0.930483, 1.128210, 1.357690, 1.622190, 1.925080,
193 		2.269800, 2.659810, 3.098610, 3.589680, 4.136480,
194 		4.742380, 5.410700, 6.144620, 6.947200, 7.821350,
195 		8.769800, 9.795100, 10.899600, 12.085300, 13.354300,
196 		14.708000, 16.148000, 17.675300, 19.290700, 20.995000,
197 		22.788300, 24.670900, 26.642500, 28.702700, 30.850800,
198 		33.085900, 35.406800, 37.812100, 40.300200, 42.869300,
199 		45.517400, 48.242300, 51.041800, 53.913200, 56.853900,
200 		59.861100, 62.932000, 66.063500, 69.252500, 72.495900,
201 		75.790300, 79.132600, 82.519300, 85.947000, 89.412400,
202 		92.912000, 96.442300, 100.000000, 103.582000, 107.184000,
203 		110.803000, 114.436000, 118.080000, 121.731000, 125.386000,
204 		129.043000, 132.697000, 136.346000, 139.988000, 143.618000,
205 		147.235000, 150.836000, 154.418000, 157.979000, 161.516000,
206 		165.028000, 168.510000, 171.963000, 175.383000, 178.769000,
207 		182.118000, 185.429000, 188.701000, 191.931000, 195.118000,
208 		198.261000, 201.359000, 204.409000, 207.411000, 210.365000,
209 		213.268000, 216.120000, 218.920000, 221.667000, 224.361000,
210 		227.000000, 229.585000, 232.115000, 234.589000, 237.008000,
211 		239.370000, 241.675000, 243.924000, 246.116000, 248.251000,
212 		250.329000, 252.350000, 254.314000, 256.221000, 258.071000,
213 		259.865000, 261.602000
214 	}
215 };
216 
217 /* CIE 15.2-1986 Table 1.1 */
218 /* Part 1: CIE Standard Illuminant C relative spectral power distribution */
219 /* This is a CIE Illuminant A combined with a filter to simulate daylight. */
220 static xspect il_C = {
221 	93, 320.0, 780.0,	/* 107 bands from 300 to 830 nm in 5nm steps */
222 	100.0,				/* Arbitrary factor */
223 	{
224 		0.01,   0.20,   0.40,   1.55,   2.70,   4.85,   7.00,   9.95,   12.90,  17.20,
225 		21.40,  27.50,  33.00,  39.92,  47.40,  55.17,  63.30,  71.81,  80.60,  89.53,
226 		98.10,  105.80, 112.40, 117.75, 121.50, 123.45, 124.00, 123.60, 123.10, 123.30,
227 		123.80, 124.09, 123.90, 122.92, 120.70, 116.90, 112.10, 106.98, 102.30, 98.81,
228 		96.90,  96.78,  98.00,  99.94,  102.10, 103.95, 105.20, 105.67, 105.30, 104.11,
229 		102.30, 100.15, 97.80,  95.43,  93.20,  91.22,  89.70,  88.83,  88.40,  88.19,
230 		88.10,  88.06,  88.00,  87.86,  87.80,  87.99,  88.20,  88.20,  87.90,  87.22,
231 		86.30,  85.30,  84.00,  82.21,  80.20,  78.24,  76.30,  74.36,  72.40,  70.40,
232 		68.30,  66.30,  64.40,  62.80,  61.50,  60.20,  59.20,  58.50,  58.10,  58.00,
233 		58.20,  58.50,  59.10
234 	}
235 };
236 
237 /* D50 illuminant spectra */
238 static xspect il_D50 = {
239 	107, 300.0, 830.0,	/* 107 bands from 300 to 830 nm in 5nm steps */
240 	100.0,				/* Arbitrary factor */
241 	{
242 		0.02, 1.03, 2.05, 4.91, 7.78, 11.26, 14.75, 16.35, 17.95, 19.48,
243 		21.01, 22.48, 23.94, 25.45, 26.96, 25.72, 24.49, 27.18, 29.87, 39.59,
244 		49.31, 52.91, 56.51, 58.27, 60.03, 58.93, 57.82, 66.32, 74.82, 81.04,
245 		87.25, 88.93, 90.61, 90.99, 91.37, 93.24, 95.11, 93.54, 91.96, 93.84,
246 		95.72, 96.17, 96.61, 96.87, 97.13, 99.61, 102.10, 101.43, 100.75, 101.54,
247 		102.32, 101.16, 100.00, 98.87, 97.74, 98.33, 98.92, 96.21, 93.50, 95.59,
248 		97.69, 98.48, 99.27, 99.16, 99.04, 97.38, 95.72, 97.29, 98.86, 97.26,
249 		95.67, 96.93, 98.19, 100.60, 103.00, 101.07, 99.13, 93.26, 87.38, 89.49,
250 		91.60, 92.25, 92.89, 84.87, 76.85, 81.68, 86.51, 89.55, 92.58, 85.40,
251 		78.23, 67.96, 57.69, 70.31, 82.92, 80.60, 78.27, 78.91, 79.55, 76.48,
252 		73.40, 68.66, 63.92, 67.35, 70.78, 72.61, 74.44
253 	}
254 };
255 
256 /* D50M2 illuminant spectra, UV filtered */
257 /* Computed from il_D50 */
258 static xspect il_D50M2 = {
259 	0, 0.0, 0.0,
260 	0.0
261 };
262 
263 
264 /* CIE 15.2-1986 Table 1.1 */
265 /* Part 2: CIE Standard Illuminant D65 relative spectral power distribution */
266 static xspect il_D65 = {
267 	107, 300.0, 830.0,	/* 107 bands from 300 to 830 nm in 5nm steps */
268 	100.0,				/* Arbitrary factor */
269 	{
270 		0.03410, 1.66430, 3.29450, 11.76520, 20.23600,
271 		28.64470, 37.05350, 38.50110, 39.94880, 42.43020,
272 		44.91170, 45.77500, 46.63830, 49.36370, 52.08910,
273 		51.03230, 49.97550, 52.31180, 54.64820, 68.70150,
274 		82.75490, 87.12040, 91.48600, 92.45890, 93.43180,
275 		90.05700, 86.68230, 95.77360, 104.86500, 110.93600,
276 		117.00800, 117.41000, 117.81200, 116.33600, 114.86100,
277 		115.39200, 115.92300, 112.36700, 108.81100, 109.08200,
278 		109.35400, 108.57800, 107.80200, 106.29600, 104.79000,
279 		106.23900, 107.68900, 106.04700, 104.40500, 104.22500,
280 		104.04600, 102.02300, 100.00000, 98.16710, 96.33420,
281 		96.06110, 95.78800, 92.23680, 88.68560, 89.34590,
282 		90.00620, 89.80260, 89.59910, 88.64890, 87.69870,
283 		85.49360, 83.28860, 83.49390, 83.69920, 81.86300,
284 		80.02680, 80.12070, 80.21460, 81.24620, 82.27780,
285 		80.28100, 78.28420, 74.00270, 69.72130, 70.66520,
286 		71.60910, 72.97900, 74.34900, 67.97650, 61.60400,
287 		65.74480, 69.88560, 72.48630, 75.08700, 69.33980,
288 		63.59270, 55.00540, 46.41820, 56.61180, 66.80540,
289 		65.09410, 63.38280, 63.84340, 64.30400, 61.87790,
290 		59.45190, 55.70540, 51.95900, 54.69980, 57.44060,
291 		58.87650, 60.31250
292 	}
293 };
294 
295 /* General temperature Daylight spectra (Using OLDER CIE 1960 u,v CCT) */
296 /* 300 - 830nm ub 5nm intervals. */
297 /* Fill in the given xspect with the specified daylight illuminant */
298 /* Return nz if temperature is out of range */
daylight_old_il(xspect * sp,double ct)299 static int daylight_old_il(xspect *sp, double ct) {
300 	static double s0[107] = {
301 		0.04, 3.02, 6.00, 17.80, 29.60, 42.45, 55.30, 56.30, 57.30, 59.55,
302 		61.80, 61.65, 61.50, 65.15, 68.80, 66.10, 63.40, 64.60, 65.80, 80.30,
303 		94.80, 99.80, 104.80, 105.35, 105.90, 101.35, 96.80, 105.35, 113.90, 119.75,
304 		125.60, 125.55, 125.50, 123.40, 121.30, 121.30, 121.30, 117.40, 113.50, 113.30,
305 		113.10, 111.95, 110.80, 108.65, 106.50, 107.65, 108.80, 107.05, 105.30, 104.85,
306 		104.40, 102.20, 100.00, 98.00, 96.00, 95.55, 95.10, 92.10, 89.10, 89.80,
307 		90.50, 90.40, 90.30, 89.35, 88.40, 86.20, 84.00, 84.55, 85.10, 83.50,
308 		81.90, 82.25, 82.60, 83.75, 84.90, 83.10, 81.30, 76.60, 71.90, 73.10,
309 		74.30, 75.35, 76.40, 69.85, 63.30, 67.50, 71.70, 74.35, 77.00, 71.10,
310 		65.20, 56.45, 47.70, 58.15, 68.60, 66.80, 65.00, 65.50, 66.00, 63.50,
311 		61.00, 57.15, 53.30, 56.10, 58.90, 60.40, 61.90
312 	};
313 	static double s1[107] = {
314 		0.02, 2.26, 4.50, 13.45, 22.40, 32.20, 42.00, 41.30, 40.60, 41.10,
315 		41.60, 39.80, 38.00, 40.20, 42.40, 40.45, 38.50, 36.75, 35.00, 39.20,
316 		43.40, 44.85, 46.30, 45.10, 43.90, 40.50, 37.10, 36.90, 36.70, 36.30,
317 		35.90, 34.25, 32.60, 30.25, 27.90, 26.10, 24.30, 22.20, 20.10, 18.15,
318 		16.20, 14.70, 13.20, 10.90, 8.60, 7.35, 6.10, 5.15, 4.20, 3.05,
319 		1.90, 0.95, 0.00, -0.80, -1.60, -2.55, -3.50, -3.50, -3.50, -4.65,
320 		-5.80, -6.50, -7.20, -7.90, -8.60, -9.05, -9.50, -10.20, -10.90, -10.80,
321 		-10.70, -11.35, -12.00, -13.00, -14.00, -13.80, -13.60, -12.80, -12.00, -12.65,
322 		-13.30, -13.10, -12.90, -11.75, -10.60, -11.10, -11.60, -11.90, -12.20, -11.20,
323 		-10.20, -9.00, -7.80, -9.50, -11.20, -10.80, -10.40, -10.50, -10.60, -10.15,
324 		-9.70, -9.00, -8.30, -8.80, -9.30, -9.55, -9.80
325 	};
326 	static double s2[107] = {
327 		0.00, 1.00, 2.00, 3.00, 4.00, 6.25, 8.50, 8.15, 7.80, 7.25,
328 		6.70, 6.00, 5.30, 5.70, 6.10, 4.55, 3.00, 2.10, 1.20, 0.05,
329 		-1.10, -0.80, -0.50, -0.60, -0.70, -0.95, -1.20, -1.90, -2.60, -2.75,
330 		-2.90, -2.85, -2.80, -2.70, -2.60, -2.60, -2.60, -2.20, -1.80, -1.65,
331 		-1.50, -1.40, -1.30, -1.25, -1.20, -1.10, -1.00, -0.75, -0.50, -0.40,
332 		-0.30, -0.15, 0.00, 0.10, 0.20, 0.35, 0.50, 1.30, 2.10, 2.65,
333 		3.20, 3.65, 4.10, 4.40, 4.70, 4.90, 5.10, 5.90, 6.70, 7.00,
334 		7.30, 7.95, 8.60, 9.20, 9.80, 10.00, 10.20, 9.25, 8.30, 8.95,
335 		9.60, 9.05, 8.50, 7.75, 7.00, 7.30, 7.60, 7.80, 8.00, 7.35,
336 		6.70, 5.95, 5.20, 6.30, 7.40, 7.10, 6.80, 6.90, 7.00, 6.70,
337 		6.40, 5.95, 5.50, 5.80, 6.10, 6.30, 6.50
338 	};
339 	int i;
340 	double xd, yd;
341 	double m1, m2;
342 
343 	if (ct < 2500.0 || ct > 25000.0) {		/* Only accurate down to about 4000 */
344 		return 1;
345 	}
346 
347 	/* Compute chromaticity coordinates */
348 	if (ct < 7000.0) {
349 		xd = -4.6070e9/(ct * ct * ct) + 2.9678e6/(ct * ct) + 0.09911e3/ct + 0.244063;
350 	} else {
351 		xd = -2.0064e9/(ct * ct * ct) + 1.9018e6/(ct * ct) + 0.24748e3/ct + 0.237040;
352 	}
353 	yd = -3.000 * xd * xd + 2.870 * xd - 0.275;
354 
355 	/* Compute m factors */
356 	m1 = (-1.7703 * xd + 5.9114 * yd - 1.3515)/(0.2562 * xd - 0.7341 * yd + 0.0241);
357 	m2 = (-31.4424 * xd + 30.0717 * yd + 0.0300)/(0.2562 * xd - 0.7341 * yd + 0.0241);
358 
359 	/* Compute spectral values */
360 	for (i = 0; i < 107; i++) {
361 		sp->spec[i] = s0[i] + m1 * s1[i] + m2 * s2[i];
362 	}
363 	sp->spec_n = 107;
364 	sp->spec_wl_short = 300.0;
365 	sp->spec_wl_long = 830;
366 	sp->norm = 100.0;		/* Arbitrary */
367 
368 	return 0;
369 }
370 
371 
372 /* General temperature Daylight spectra from CIE 15.2004 Appendix C. */
373 /* - uses improved interpolation. Assumes 1931 observer & 1 nm spacing. */
374 /* 300 - 830nm ub 5nm intervals. */
375 /* Fill in the given xspect with the specified daylight illuminant */
376 /* Return nz if temperature is out of range */
daylight_il(xspect * sp,double ct)377 static int daylight_il(xspect *sp, double ct) {
378 	static double s0[107] = {
379 		0.04000, -0.15625, 6.00000, 16.56625, 29.60000,
380 		43.80000, 55.30000, 57.62500, 57.30000, 59.69375,
381 		61.80000, 61.47500, 61.50000, 65.46875, 68.80000,
382 		66.40625, 63.40000, 62.45000, 65.80000, 79.82500,
383 		94.80000, 101.54375, 104.80000, 106.54375, 105.90000,
384 		100.35000, 96.80000, 104.05000, 113.90000, 120.82500,
385 		125.60000, 126.54375, 125.50000, 123.39375, 121.30000,
386 		121.52500, 121.30000, 117.42500, 113.50000, 112.95625,
387 		113.10000, 112.19375, 110.80000, 108.36250, 106.50000,
388 		107.60000, 108.80000, 107.25000, 105.30000, 104.90625,
389 		104.40000, 102.39375, 100.00000, 97.78125, 96.00000,
390 		95.67500, 95.10000, 91.95625, 89.10000, 89.43750,
391 		90.50000, 90.60625, 90.30000, 89.61250, 88.40000,
392 		86.01250, 84.00000, 84.47500, 85.10000, 83.52500,
393 		81.90000, 81.90625, 82.60000, 84.01875, 84.90000,
394 		83.83125, 81.30000, 76.22500, 71.90000, 72.38125,
395 		74.30000, 76.31875, 76.40000, 69.45625, 63.30000,
396 		66.35000, 71.70000, 75.61250, 77.00000, 72.52500,
397 		65.20000, 54.40625, 47.70000, 57.28125, 68.60000,
398 		68.04375, 65.00000, 65.58750, 66.00000, 64.04375,
399 		61.00000, 56.48750, 53.30000, 55.43125, 58.90000,
400 		61.71875, 61.90000
401 	};
402 
403 	static double s1[107] = {
404 		0.02000, -0.15000, 4.50000, 12.50500, 22.40000,
405 		33.40625, 42.00000, 42.46250, 40.60000, 41.23750,
406 		41.60000, 39.58750, 38.00000, 40.21875, 42.40000,
407 		40.94375, 38.50000, 35.98125, 35.00000, 38.80000,
408 		43.40000, 45.52500, 46.30000, 45.70625, 43.90000,
409 		40.37500, 37.10000, 36.52500, 36.70000, 36.48125,
410 		35.90000, 34.49375, 32.60000, 30.26875, 27.90000,
411 		26.06875, 24.30000, 22.21875, 20.10000, 18.07500,
412 		16.20000, 14.74375, 13.20000, 10.86875, 8.60000,
413 		7.18125, 6.10000, 5.13750, 4.20000, 3.05000,
414 		1.90000, 0.90625, 0.00000, -0.80000, -1.60000,
415 		-2.65000, -3.50000, -3.47500, -3.50000, -4.56250,
416 		-5.80000, -6.55625, -7.20000, -7.93125, -8.60000,
417 		-9.05000, -9.50000, -10.26875, -10.90000, -10.80625,
418 		-10.70000, -11.21250, -12.00000, -13.10625, -14.00000,
419 		-14.02500, -13.60000, -12.69375, -12.00000, -12.57500,
420 		-13.30000, -13.32500, -12.90000, -11.66250, -10.60000,
421 		-10.91875, -11.60000, -12.08750, -12.20000, -11.38750,
422 		-10.20000, -8.66250, -7.80000, -9.40000, -11.20000,
423 		-11.00000, -10.40000, -10.50625, -10.60000, -10.25000,
424 		-9.70000, -8.88125, -8.30000, -8.68125, -9.30000,
425 		-9.79375, -9.80000
426 	};
427 
428 	static double s2[107] = {
429 		0.00000, 1.15625, 2.00000, 2.84375, 4.00000,
430 		6.41875, 8.50000, 8.50000, 7.80000, 7.29375,
431 		6.70000, 5.88125, 5.30000, 5.80625, 6.10000,
432 		4.71250, 3.00000, 2.05000, 1.20000, -0.10000,
433 		-1.10000, -0.93125, -0.50000, -0.53125, -0.70000,
434 		-0.87500, -1.20000, -1.91250, -2.60000, -2.84375,
435 		-2.90000, -2.88125, -2.80000, -2.69375, -2.60000,
436 		-2.63750, -2.60000, -2.21875, -1.80000, -1.61250,
437 		-1.50000, -1.38750, -1.30000, -1.25000, -1.20000,
438 		-1.12500, -1.00000, -0.75000, -0.50000, -0.38750,
439 		-0.30000, -0.15000, 0.00000, 0.10000, 0.20000,
440 		0.26250, 0.50000, 1.25000, 2.10000, 2.69375,
441 		3.20000, 3.68125, 4.10000, 4.43125, 4.70000,
442 		4.83750, 5.10000, 5.88750, 6.70000, 7.01875,
443 		7.30000, 7.91250, 8.60000, 9.25625, 9.80000,
444 		10.19375, 10.20000, 9.19375, 8.30000, 8.90000,
445 		9.60000, 9.22500, 8.50000, 7.64375, 7.00000,
446 		7.18125, 7.60000, 7.91875, 8.00000, 7.46875,
447 		6.70000, 5.73125, 5.20000, 6.24375, 7.40000,
448 		7.22500, 6.80000, 6.90000, 7.00000, 6.76875,
449 		6.40000, 5.87500, 5.50000, 5.71875, 6.10000,
450 		6.43125, 6.50000,
451 	};
452 
453 	/* M values for [1nm,5nm][1931,1964][M1,M2][g, h, i, j, k, l] */
454 	double ms[2][2][2][6] = {
455 		{		/* 1nm */
456 			{
457 				{ -1.77864, 5.90745, -1.34666, 0.25540, -0.73218, 0.02387 },
458 				{ -31.44505, 30.06408, 0.03656, 0.25540, -0.73218, 0.02387 }
459 			},
460 			{
461 				{ -1.57049, 5.56450, -1.31211, 0.21249, -0.71591, 0.04663 },
462 				{ -30.15166, 31.07906, -0.73912, 0.21249, -0.71591, 0.04663 }
463 			}
464 		},
465 		{		/* 5nm */
466 			{
467 				{ -1.77861, 5.90757, -1.34674, 0.25539, -0.73217, 0.02387 },
468 				{ -31.44464, 30.06400, 0.03638, 0.25539, -0.73217, 0.02387 }
469 			},
470 			{
471 				{ -1.57049, 5.56460, -1.31215, 0.21250, -0.71592, 0.04663 },
472 				{ -30.15139, 31.07931, -0.73928, 0.21250, -0.71592, 0.04663 }
473 			}
474 		}
475 	};
476 
477 	int i;
478 	double xd, yd;
479 	int obs = 0;		/* 1931 */
480 	int sint = 0;		/* 1nm */
481 	double m1, m2;
482 
483 	if (ct < 2500.0 || ct > 25000.0) {		/* Only accurate down to about 4000 */
484 		return 1;
485 	}
486 
487 	/* Compute chromaticity coordinates */
488 	if (ct < 7000.0) {
489 		xd = -4.6070e9/(ct * ct * ct) + 2.9678e6/(ct * ct) + 0.09911e3/ct + 0.244063;
490 	} else {
491 		xd = -2.0064e9/(ct * ct * ct) + 1.9018e6/(ct * ct) + 0.24748e3/ct + 0.237040;
492 	}
493 	yd = -3.000 * xd * xd + 2.870 * xd - 0.275;
494 
495 	/* Compute m factors */
496 	m1 = (ms[sint][obs][0][0] * xd + ms[sint][obs][0][1] * yd + ms[sint][obs][0][2])
497 	   / (ms[sint][obs][0][3] * xd + ms[sint][obs][0][4] * yd + ms[sint][obs][0][5]);
498 	m2 = (ms[sint][obs][1][0] * xd + ms[sint][obs][1][1] * yd + ms[sint][obs][1][2])
499 	   / (ms[sint][obs][1][3] * xd + ms[sint][obs][1][4] * yd + ms[sint][obs][1][5]);
500 
501 	/* Compute spectral values */
502 	for (i = 0; i < 107; i++) {
503 		sp->spec[i] = s0[i] + m1 * s1[i] + m2 * s2[i];
504 	}
505 
506 	sp->spec_n = 107;
507 	sp->spec_wl_short = 300.0;
508 	sp->spec_wl_long = 830;
509 	sp->norm = 100.0;		/* Arbitrary */
510 
511 	return 0;
512 }
513 
514 /* General temperature Planckian (black body) spectra using CIE 15:2004 */
515 /* Fill in the given xspect with the specified Planckian illuminant */
516 /* normalised so that 560nm = 100. */
517 /* Return nz if temperature is out of range */
planckian_il(xspect * sp,double ct)518 static int planckian_il(xspect *sp, double ct) {
519 	int i;
520 	double wl, norm;
521 
522 	if (ct < 1.0 || ct > 1e6)	/* set some arbitrary limits */
523 		return 1;
524 
525 	/* Set out targets */
526 	sp->spec_n = 531;		/* 1nm */
527 	sp->spec_wl_short = 300.0;
528 	sp->spec_wl_long = 830;
529 
530 	/* Compute spectral values using Plank's radiation law: */
531 	/* Normalise numbers by energy at 560 nm */
532 	norm = pow(560e-9, -5.0) / (exp(1.4388e-2 / (560e-9 * ct)) - 1.0);
533 	for (i = 0; i < sp->spec_n; i++) {
534 		wl = 1e-9 * XSPECT_XWL(sp, i);			/* Wavelength in meters */
535 		sp->spec[i] = 100.0 * pow(wl, -5.0) / (exp(1.4388e-2 / (wl * ct)) - 1.0);
536 		sp->spec[i] /= norm;
537 
538 	}
539 	sp->norm = 100.0;		/* value at 560 nm */
540 
541 	return 0;
542 }
543 
544 /* General temperature Planckian (black body) spectra using older formulation */
545 /* Fill in the given xspect with the specified Planckian illuminant */
546 /* normalised so that 560nm = 100. */
547 /* Return nz if temperature is out of range */
planckian_old_il(xspect * sp,double ct)548 static int planckian_old_il(xspect *sp, double ct) {
549 	int i;
550 	double wl, norm;
551 
552 	if (ct < 1.0 || ct > 1e6)	/* set some arbitrary limits */
553 		return 1;
554 
555 	/* Set out targets */
556 	sp->spec_n = 531;		/* 1nm */
557 	sp->spec_wl_short = 300.0;
558 	sp->spec_wl_long = 830;
559 
560 	/* Compute spectral values using Plank's radiation law: */
561 	/* Normalise numbers by energy at 560 nm */
562 	norm = pow(560e-9, -5.0) / (exp(1.4350e-2 / (560e-9 * ct)) - 1.0);
563 	for (i = 0; i < sp->spec_n; i++) {
564 		wl = 1e-9 * XSPECT_XWL(sp, i);			/* Wavelength in meters */
565 		sp->spec[i] = 100.0 * pow(wl, -5.0) / (exp(1.4350e-2 / (wl * ct)) - 1.0);
566 		sp->spec[i] /= norm;
567 
568 	}
569 	sp->norm = 100.0;		/* value at 560 nm */
570 
571 	return 0;
572 }
573 
574 
575 #ifndef SALONEINSTLIB
576 
577 /* CIE F5 */
578 /* Fluorescent, Standard, 6350K, CRI 72 */
579 static xspect il_F5 = {
580 	107, 300.0, 830.0,	/* 109 bands from 300 to 830 nm in 5nm steps */
581 	20.0,		/* Arbitrary scale factor */
582 	{
583 /* 300 */	0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
584 /* 340 */	0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
585 /* 380 */	1.87, 2.35, 2.92, 3.45, 5.10, 18.91, 6.00, 6.11, 6.85, 7.58,
586 /* 430 */	8.31, 40.76, 16.06, 10.32, 10.91, 11.40, 11.83, 12.17, 12.40, 12.54,
587 /* 480 */	12.58, 12.52, 12.47, 12.20, 11.89, 11.61, 11.33, 11.10, 10.96, 10.97,
588 /* 530 */	11.16, 11.54, 12.12, 27.78, 17.73, 14.47, 15.20, 15.77, 16.10, 18.54,
589 /* 580 */	19.50, 15.39, 14.64, 13.72, 12.69, 11.57, 10.45, 9.35, 8.29, 7.32,
590 /* 630 */	6.41, 5.63, 4.90, 4.26, 3.72, 3.25, 2.83, 2.49, 2.19, 1.93,
591 /* 680 */	1.71, 1.52, 1.48, 1.26, 1.13, 1.05, 0.96, 0.85, 0.78, 0.72,
592 /* 730 */	0.68, 0.67, 0.65, 0.61, 0.62, 0.59, 0.62, 0.64, 0.55, 0.47,
593 /* 780 */	0.40,
594 /* 785 */	0.0, 0.0, 0.0, 0.0, 0.0,
595 /* 810 */	0.0, 0.0, 0.0, 0.0, 0.0
596 	}
597 };
598 
599 
600 /* CIE F8 */
601 /* Fluorescent, Wide band 5000K, CRI 95 */
602 static xspect il_F8 = {
603 	107, 300.0, 830.0,	/* 109 bands from 300 to 830 nm in 5nm steps */
604 	30.0,		/* Arbitrary scale factor */
605 	{
606 /* 300 */	0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
607 /* 340 */	0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
608 /* 380 */	1.21, 1.5, 1.81, 2.13, 3.17, 13.08, 3.83, 3.45, 3.86, 4.42,
609 /* 430 */	5.09, 34.10, 12.42, 7.68, 8.6, 9.46, 10.24, 10.84, 11.33, 11.71,
610 /* 480 */	11.98, 12.17, 12.28, 12.32, 12.35, 12.44, 12.55, 12.68, 12.77, 12.72,
611 /* 530 */	12.60, 12.43, 12.22, 28.96, 16.51, 11.79, 11.76, 11.77, 11.84, 14.61,
612 /* 580 */	16.11, 12.34, 12.53, 12.72, 12.92, 13.12, 13.34, 13.61, 13.87, 14.07,
613 /* 630 */	14.20, 14.16, 14.13, 14.34, 14.50, 14.46, 14.00, 12.58, 10.99, 9.98,
614 /* 680 */	9.22, 8.62, 8.07, 7.39, 6.71, 6.16, 5.63, 5.03, 4.46, 4.02,
615 /* 730 */	3.66, 3.36, 3.09, 2.85, 2.65, 2.51, 2.37, 2.15, 1.89, 1.61,
616 /* 780 */	1.32,
617 /* 785 */	0.0, 0.0, 0.0, 0.0, 0.0,
618 /* 810 */	0.0, 0.0, 0.0, 0.0, 0.0
619 	}
620 };
621 
622 
623 
624 /* CIE F10 */
625 /* Fluorescent, Narrow band 5000K, CRI 81 */
626 static xspect il_F10 = {
627 	107, 300.0, 830.0,	/* 109 bands from 300 to 830 nm in 5nm steps */
628 	30.0,		/* Arbitrary scale factor */
629 	{
630 		0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
631 		0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
632 		1.11, 0.80, 0.62, 0.57, 1.48, 12.16, 2.12, 2.70, 3.74, 5.14,
633 		6.75, 34.39, 14.86, 10.40, 10.76, 10.67, 10.11, 9.27, 8.29, 7.29,
634 		7.91, 16.64, 16.73, 10.44, 5.94, 3.34, 2.35, 1.88, 1.59, 1.47,
635 		1.80, 5.71, 40.98, 73.69, 33.61, 8.24, 3.38, 2.47, 2.14, 4.86,
636 		11.45, 14.79, 12.16, 8.97, 6.5, 8.31, 44.12, 34.55, 12.09, 12.15,
637 		10.52, 4.43, 1.95, 2.19, 3.19, 2.77, 2.29, 2.00, 1.52, 1.35,
638 		1.47, 1.79, 1.74, 1.02, 1.14, 3.32, 4.49, 2.05, 0.49, 0.24,
639 		0.21, 0.21, 0.24, 0.24, 0.21, 0.17, 0.21, 0.22, 0.17, 0.12,
640 		0.09,
641 		0.0, 0.0, 0.0, 0.0, 0.0,
642 		0.0, 0.0, 0.0, 0.0, 0.0
643 	}
644 };
645 
646 /* Spectrocam Xenon Lamp */
647 static xspect il_Spectrocam = {
648    95, 325.0, 795.0,   /* 95 bands from 325 to 795 nm in 5nm steps */
649    1.0,		/* Arbitrary scale factor */
650    {
651 	   0.220794, 0.240550, 0.281212, 0.363042, 0.493282,
652 	   0.582279, 0.657489, 0.715563, 0.797559, 0.916343,
653 	   1.066625, 1.228461, 1.298467, 1.373143, 1.457366,
654 	   1.496117, 1.509290, 1.573544, 1.596359, 1.495740,
655 	   1.477898, 1.521371, 1.479780, 1.453196, 1.532119,
656 	   1.548128, 1.503433, 1.428481, 1.357290, 1.354425,
657 	   1.317263, 1.237048, 1.169737, 1.109248, 1.085784,
658 	   1.080186, 1.104001, 1.131713, 1.161153, 1.158589,
659 	   1.148998, 1.123934, 1.077395, 1.017907, 1.026532,
660 	   1.045921, 1.083780, 1.081868, 1.048489, 1.021549,
661 	   0.993572, 0.956559, 0.942657, 0.952544, 0.957087,
662 	   0.958472, 0.945666, 0.923988, 0.890418, 0.852044,
663 	   0.812935, 0.792055, 0.791141, 0.825459, 0.829230,
664 	   0.818171, 0.851752, 0.913113, 1.038844, 1.116913,
665 	   1.164211, 1.133376, 1.109062, 1.129427, 1.086885,
666 	   0.991213, 0.924226, 0.875499, 0.894231, 0.922219,
667 	   0.960372, 0.896142, 0.819477, 0.879305, 0.912777,
668 	   0.908489, 0.775942, 0.598118, 0.532988, 0.484102,
669 	   0.465986, 0.414848, 0.346473, 0.324622, 0.309978
670    }
671 };
672 
673 #endif /* !SALONEINSTLIB */
674 
675 /* Apply ISO 13655:2009 UV filter to the given spectrum. */
676 /* The filter is applied point by point. */
uv_filter(xspect * dst,xspect * src)677 static void uv_filter(xspect *dst, xspect *src) {
678 	int i;
679 
680 	XSPECT_COPY_INFO(dst, src);
681 	for (i = 0; i < src->spec_n; i++) {
682 		double wl = XSPECT_XWL(src, i);
683 		double ff = 1.0;
684 
685 		if (wl <= 395.0) {
686 			ff = 0.0;
687 		} else if (wl < 425.0) {
688 			ff = (wl - 395.0)/(425.0 - 395.0);
689 			ff = ff * ff * (3.0 - 2.0 * ff);    /* Cubic spline */
690 		}
691 		dst->spec[i] = ff * src->spec[i];
692 	}
693 }
694 
695 /* Fill in an xpsect with a standard illuminant spectrum */
696 /* return 0 on sucecss, nz if not matched */
standardIlluminant(xspect * sp,icxIllumeType ilType,double temp)697 int standardIlluminant(
698 xspect *sp,					/* Xspect to fill in */
699 icxIllumeType ilType,		/* Type of illuminant */
700 double temp					/* Optional temperature in degrees kelvin, for Dtemp and Ptemp */
701 ) {
702 	switch (ilType) {
703 	    case icxIT_none:
704 			return 1;
705 	    case icxIT_custom:
706 			return 1;
707 	    case icxIT_A:
708 			*sp = il_A;		/* Struct copy */
709 			return 0;
710 	    case icxIT_C:
711 			*sp = il_C;		/* " */
712 			return 0;
713 	    case icxIT_default:
714 	    case icxIT_D50:
715 			*sp = il_D50;	/* etc */
716 			return 0;
717 	    case icxIT_D50M2:
718 			if (il_D50M2.spec_n == 0)
719 				uv_filter(&il_D50M2, &il_D50);
720 			*sp = il_D50M2;
721 			return 0;
722 	    case icxIT_D55:
723 			return daylight_il(sp, 5500.0);
724 	    case icxIT_D65:
725 			*sp = il_D65;
726 			return 0;
727 	    case icxIT_D75:
728 			return daylight_il(sp, 7500.0);
729 	    case icxIT_E:
730 			*sp = il_none;
731 			return 0;
732 #ifndef SALONEINSTLIB
733 	    case icxIT_F5:
734 			*sp = il_F5;
735 			return 0;
736 	    case icxIT_F8:
737 			*sp = il_F8;
738 			return 0;
739 	    case icxIT_F10:
740 			*sp = il_F10;
741 			return 0;
742 		case icxIT_Spectrocam:
743 			*sp = il_Spectrocam;
744 			return 0;
745 #endif
746 		case icxIT_ODtemp:
747 			return daylight_old_il(sp, temp);
748 		case icxIT_Dtemp:
749 			return daylight_il(sp, temp);
750 		case icxIT_OPtemp:
751 			return planckian_old_il(sp, temp);
752 		case icxIT_Ptemp:
753 			return planckian_il(sp, temp);
754 	}
755 	return 1;
756 }
757 
758 /* ------------- */
759 /* Observer Data */
760 
761 /* Standard CIE 1931 2 degree */
762 static xspect ob_CIE_1931_2[3] = {
763 	{
764 		471, 360.0, 830.0,	/* 471 bands from 360 to 830 nm in 1nm steps */
765 		1.0,				/* Scale factor */
766 		{
767 			0.000129900000, 0.000145847000, 0.000163802100, 0.000184003700, 0.000206690200,
768 			0.000232100000, 0.000260728000, 0.000293075000, 0.000329388000, 0.000369914000,
769 			0.000414900000, 0.000464158700, 0.000518986000, 0.000581854000, 0.000655234700,
770 			0.000741600000, 0.000845029600, 0.000964526800, 0.001094949000, 0.001231154000,
771 			0.001368000000, 0.001502050000, 0.001642328000, 0.001802382000, 0.001995757000,
772 			0.002236000000, 0.002535385000, 0.002892603000, 0.003300829000, 0.003753236000,
773 			0.004243000000, 0.004762389000, 0.005330048000, 0.005978712000, 0.006741117000,
774 			0.007650000000, 0.008751373000, 0.010028880000, 0.011421700000, 0.012869010000,
775 			0.014310000000, 0.015704430000, 0.017147440000, 0.018781220000, 0.020748010000,
776 			0.023190000000, 0.026207360000, 0.029782480000, 0.033880920000, 0.038468240000,
777 			0.043510000000, 0.048995600000, 0.055022600000, 0.061718800000, 0.069212000000,
778 			0.077630000000, 0.086958110000, 0.097176720000, 0.108406300000, 0.120767200000,
779 			0.134380000000, 0.149358200000, 0.165395700000, 0.181983100000, 0.198611000000,
780 			0.214770000000, 0.230186800000, 0.244879700000, 0.258777300000, 0.271807900000,
781 			0.283900000000, 0.294943800000, 0.304896500000, 0.313787300000, 0.321645400000,
782 			0.328500000000, 0.334351300000, 0.339210100000, 0.343121300000, 0.346129600000,
783 			0.348280000000, 0.349599900000, 0.350147400000, 0.350013000000, 0.349287000000,
784 			0.348060000000, 0.346373300000, 0.344262400000, 0.341808800000, 0.339094100000,
785 			0.336200000000, 0.333197700000, 0.330041100000, 0.326635700000, 0.322886800000,
786 			0.318700000000, 0.314025100000, 0.308884000000, 0.303290400000, 0.297257900000,
787 			0.290800000000, 0.283970100000, 0.276721400000, 0.268917800000, 0.260422700000,
788 			0.251100000000, 0.240847500000, 0.229851200000, 0.218407200000, 0.206811500000,
789 			0.195360000000, 0.184213600000, 0.173327300000, 0.162688100000, 0.152283300000,
790 			0.142100000000, 0.132178600000, 0.122569600000, 0.113275200000, 0.104297900000,
791 			0.095640000000, 0.087299550000, 0.079308040000, 0.071717760000, 0.064580990000,
792 			0.057950010000, 0.051862110000, 0.046281520000, 0.041150880000, 0.036412830000,
793 			0.032010000000, 0.027917200000, 0.024144400000, 0.020687000000, 0.017540400000,
794 			0.014700000000, 0.012161790000, 0.009919960000, 0.007967240000, 0.006296346000,
795 			0.004900000000, 0.003777173000, 0.002945320000, 0.002424880000, 0.002236293000,
796 			0.002400000000, 0.002925520000, 0.003836560000, 0.005174840000, 0.006982080000,
797 			0.009300000000, 0.012149490000, 0.015535880000, 0.019477520000, 0.023992770000,
798 			0.029100000000, 0.034814850000, 0.041120160000, 0.047985040000, 0.055378610000,
799 			0.063270000000, 0.071635010000, 0.080462240000, 0.089739960000, 0.099456450000,
800 			0.109600000000, 0.120167400000, 0.131114500000, 0.142367900000, 0.153854200000,
801 			0.165500000000, 0.177257100000, 0.189140000000, 0.201169400000, 0.213365800000,
802 			0.225749900000, 0.238320900000, 0.251066800000, 0.263992200000, 0.277101700000,
803 			0.290400000000, 0.303891200000, 0.317572600000, 0.331438400000, 0.345482800000,
804 			0.359700000000, 0.374083900000, 0.388639600000, 0.403378400000, 0.418311500000,
805 			0.433449900000, 0.448795300000, 0.464336000000, 0.480064000000, 0.495971300000,
806 			0.512050100000, 0.528295900000, 0.544691600000, 0.561209400000, 0.577821500000,
807 			0.594500000000, 0.611220900000, 0.627975800000, 0.644760200000, 0.661569700000,
808 			0.678400000000, 0.695239200000, 0.712058600000, 0.728828400000, 0.745518800000,
809 			0.762100000000, 0.778543200000, 0.794825600000, 0.810926400000, 0.826824800000,
810 			0.842500000000, 0.857932500000, 0.873081600000, 0.887894400000, 0.902318100000,
811 			0.916300000000, 0.929799500000, 0.942798400000, 0.955277600000, 0.967217900000,
812 			0.978600000000, 0.989385600000, 0.999548800000, 1.009089200000, 1.018006400000,
813 			1.026300000000, 1.033982700000, 1.040986000000, 1.047188000000, 1.052466700000,
814 			1.056700000000, 1.059794400000, 1.061799200000, 1.062806800000, 1.062909600000,
815 			1.062200000000, 1.060735200000, 1.058443600000, 1.055224400000, 1.050976800000,
816 			1.045600000000, 1.039036900000, 1.031360800000, 1.022666200000, 1.013047700000,
817 			1.002600000000, 0.991367500000, 0.979331400000, 0.966491600000, 0.952847900000,
818 			0.938400000000, 0.923194000000, 0.907244000000, 0.890502000000, 0.872920000000,
819 			0.854449900000, 0.835084000000, 0.814946000000, 0.794186000000, 0.772954000000,
820 			0.751400000000, 0.729583600000, 0.707588800000, 0.685602200000, 0.663810400000,
821 			0.642400000000, 0.621514900000, 0.601113800000, 0.581105200000, 0.561397700000,
822 			0.541900000000, 0.522599500000, 0.503546400000, 0.484743600000, 0.466193900000,
823 			0.447900000000, 0.429861300000, 0.412098000000, 0.394644000000, 0.377533300000,
824 			0.360800000000, 0.344456300000, 0.328516800000, 0.313019200000, 0.298001100000,
825 			0.283500000000, 0.269544800000, 0.256118400000, 0.243189600000, 0.230727200000,
826 			0.218700000000, 0.207097100000, 0.195923200000, 0.185170800000, 0.174832300000,
827 			0.164900000000, 0.155366700000, 0.146230000000, 0.137490000000, 0.129146700000,
828 			0.121200000000, 0.113639700000, 0.106465000000, 0.099690440000, 0.093330610000,
829 			0.087400000000, 0.081900960000, 0.076804280000, 0.072077120000, 0.067686640000,
830 			0.063600000000, 0.059806850000, 0.056282160000, 0.052971040000, 0.049818610000,
831 			0.046770000000, 0.043784050000, 0.040875360000, 0.038072640000, 0.035404610000,
832 			0.032900000000, 0.030564190000, 0.028380560000, 0.026344840000, 0.024452750000,
833 			0.022700000000, 0.021084290000, 0.019599880000, 0.018237320000, 0.016987170000,
834 			0.015840000000, 0.014790640000, 0.013831320000, 0.012948680000, 0.012129200000,
835 			0.011359160000, 0.010629350000, 0.009938846000, 0.009288422000, 0.008678854000,
836 			0.008110916000, 0.007582388000, 0.007088746000, 0.006627313000, 0.006195408000,
837 			0.005790346000, 0.005409826000, 0.005052583000, 0.004717512000, 0.004403507000,
838 			0.004109457000, 0.003833913000, 0.003575748000, 0.003334342000, 0.003109075000,
839 			0.002899327000, 0.002704348000, 0.002523020000, 0.002354168000, 0.002196616000,
840 			0.002049190000, 0.001910960000, 0.001781438000, 0.001660110000, 0.001546459000,
841 			0.001439971000, 0.001340042000, 0.001246275000, 0.001158471000, 0.001076430000,
842 			0.000999949300, 0.000928735800, 0.000862433200, 0.000800750300, 0.000743396000,
843 			0.000690078600, 0.000640515600, 0.000594502100, 0.000551864600, 0.000512429000,
844 			0.000476021300, 0.000442453600, 0.000411511700, 0.000382981400, 0.000356649100,
845 			0.000332301100, 0.000309758600, 0.000288887100, 0.000269539400, 0.000251568200,
846 			0.000234826100, 0.000219171000, 0.000204525800, 0.000190840500, 0.000178065400,
847 			0.000166150500, 0.000155023600, 0.000144621900, 0.000134909800, 0.000125852000,
848 			0.000117413000, 0.000109551500, 0.000102224500, 0.000095394450, 0.000089023900,
849 			0.000083075270, 0.000077512690, 0.000072313040, 0.000067457780, 0.000062928440,
850 			0.000058706520, 0.000054770280, 0.000051099180, 0.000047676540, 0.000044485670,
851 			0.000041509940, 0.000038733240, 0.000036142030, 0.000033723520, 0.000031464870,
852 			0.000029353260, 0.000027375730, 0.000025524330, 0.000023793760, 0.000022178700,
853 			0.000020673830, 0.000019272260, 0.000017966400, 0.000016749910, 0.000015616480,
854 			0.000014559770, 0.000013573870, 0.000012654360, 0.000011797230, 0.000010998440,
855 			0.000010253980, 0.000009559646, 0.000008912044, 0.000008308358, 0.000007745769,
856 			0.000007221456, 0.000006732475, 0.000006276423, 0.000005851304, 0.000005455118,
857 			0.000005085868, 0.000004741466, 0.000004420236, 0.000004120783, 0.000003841716,
858 			0.000003581652, 0.000003339127, 0.000003112949, 0.000002902121, 0.000002705645,
859 			0.000002522525, 0.000002351726, 0.000002192415, 0.000002043902, 0.000001905497,
860 			0.000001776509, 0.000001656215, 0.000001544022, 0.000001439440, 0.000001341977,
861 			0.000001251141
862 		}
863 	},
864 	{
865 		471, 360.0, 830.0,	/* 471 bands from 360 to 830 nm in 1nm steps */
866 		1.0,				/* Scale factor */
867 		{
868 			0.000003917000, 0.000004393581, 0.000004929604, 0.000005532136, 0.000006208245,
869 			0.000006965000, 0.000007813219, 0.000008767336, 0.000009839844, 0.000011043230,
870 			0.000012390000, 0.000013886410, 0.000015557280, 0.000017442960, 0.000019583750,
871 			0.000022020000, 0.000024839650, 0.000028041260, 0.000031531040, 0.000035215210,
872 			0.000039000000, 0.000042826400, 0.000046914600, 0.000051589600, 0.000057176400,
873 			0.000064000000, 0.000072344210, 0.000082212240, 0.000093508160, 0.000106136100,
874 			0.000120000000, 0.000134984000, 0.000151492000, 0.000170208000, 0.000191816000,
875 			0.000217000000, 0.000246906700, 0.000281240000, 0.000318520000, 0.000357266700,
876 			0.000396000000, 0.000433714700, 0.000473024000, 0.000517876000, 0.000572218700,
877 			0.000640000000, 0.000724560000, 0.000825500000, 0.000941160000, 0.001069880000,
878 			0.001210000000, 0.001362091000, 0.001530752000, 0.001720368000, 0.001935323000,
879 			0.002180000000, 0.002454800000, 0.002764000000, 0.003117800000, 0.003526400000,
880 			0.004000000000, 0.004546240000, 0.005159320000, 0.005829280000, 0.006546160000,
881 			0.007300000000, 0.008086507000, 0.008908720000, 0.009767680000, 0.010664430000,
882 			0.011600000000, 0.012573170000, 0.013582720000, 0.014629680000, 0.015715090000,
883 			0.016840000000, 0.018007360000, 0.019214480000, 0.020453920000, 0.021718240000,
884 			0.023000000000, 0.024294610000, 0.025610240000, 0.026958570000, 0.028351250000,
885 			0.029800000000, 0.031310830000, 0.032883680000, 0.034521120000, 0.036225710000,
886 			0.038000000000, 0.039846670000, 0.041768000000, 0.043766000000, 0.045842670000,
887 			0.048000000000, 0.050243680000, 0.052573040000, 0.054980560000, 0.057458720000,
888 			0.060000000000, 0.062601970000, 0.065277520000, 0.068042080000, 0.070911090000,
889 			0.073900000000, 0.077016000000, 0.080266400000, 0.083666800000, 0.087232800000,
890 			0.090980000000, 0.094917550000, 0.099045840000, 0.103367400000, 0.107884600000,
891 			0.112600000000, 0.117532000000, 0.122674400000, 0.127992800000, 0.133452800000,
892 			0.139020000000, 0.144676400000, 0.150469300000, 0.156461900000, 0.162717700000,
893 			0.169300000000, 0.176243100000, 0.183558100000, 0.191273500000, 0.199418000000,
894 			0.208020000000, 0.217119900000, 0.226734500000, 0.236857100000, 0.247481200000,
895 			0.258600000000, 0.270184900000, 0.282293900000, 0.295050500000, 0.308578000000,
896 			0.323000000000, 0.338402100000, 0.354685800000, 0.371698600000, 0.389287500000,
897 			0.407300000000, 0.425629900000, 0.444309600000, 0.463394400000, 0.482939500000,
898 			0.503000000000, 0.523569300000, 0.544512000000, 0.565690000000, 0.586965300000,
899 			0.608200000000, 0.629345600000, 0.650306800000, 0.670875200000, 0.690842400000,
900 			0.710000000000, 0.728185200000, 0.745463600000, 0.761969400000, 0.777836800000,
901 			0.793200000000, 0.808110400000, 0.822496200000, 0.836306800000, 0.849491600000,
902 			0.862000000000, 0.873810800000, 0.884962400000, 0.895493600000, 0.905443200000,
903 			0.914850100000, 0.923734800000, 0.932092400000, 0.939922600000, 0.947225200000,
904 			0.954000000000, 0.960256100000, 0.966007400000, 0.971260600000, 0.976022500000,
905 			0.980300000000, 0.984092400000, 0.987418200000, 0.990312800000, 0.992811600000,
906 			0.994950100000, 0.996710800000, 0.998098300000, 0.999112000000, 0.999748200000,
907 			1.000000000000, 0.999856700000, 0.999304600000, 0.998325500000, 0.996898700000,
908 			0.995000000000, 0.992600500000, 0.989742600000, 0.986444400000, 0.982724100000,
909 			0.978600000000, 0.974083700000, 0.969171200000, 0.963856800000, 0.958134900000,
910 			0.952000000000, 0.945450400000, 0.938499200000, 0.931162800000, 0.923457600000,
911 			0.915400000000, 0.907006400000, 0.898277200000, 0.889204800000, 0.879781600000,
912 			0.870000000000, 0.859861300000, 0.849392000000, 0.838622000000, 0.827581300000,
913 			0.816300000000, 0.804794700000, 0.793082000000, 0.781192000000, 0.769154700000,
914 			0.757000000000, 0.744754100000, 0.732422400000, 0.720003600000, 0.707496500000,
915 			0.694900000000, 0.682219200000, 0.669471600000, 0.656674400000, 0.643844800000,
916 			0.631000000000, 0.618155500000, 0.605314400000, 0.592475600000, 0.579637900000,
917 			0.566800000000, 0.553961100000, 0.541137200000, 0.528352800000, 0.515632300000,
918 			0.503000000000, 0.490468800000, 0.478030400000, 0.465677600000, 0.453403200000,
919 			0.441200000000, 0.429080000000, 0.417036000000, 0.405032000000, 0.393032000000,
920 			0.381000000000, 0.368918400000, 0.356827200000, 0.344776800000, 0.332817600000,
921 			0.321000000000, 0.309338100000, 0.297850400000, 0.286593600000, 0.275624500000,
922 			0.265000000000, 0.254763200000, 0.244889600000, 0.235334400000, 0.226052800000,
923 			0.217000000000, 0.208161600000, 0.199548800000, 0.191155200000, 0.182974400000,
924 			0.175000000000, 0.167223500000, 0.159646400000, 0.152277600000, 0.145125900000,
925 			0.138200000000, 0.131500300000, 0.125024800000, 0.118779200000, 0.112769100000,
926 			0.107000000000, 0.101476200000, 0.096188640000, 0.091122960000, 0.086264850000,
927 			0.081600000000, 0.077120640000, 0.072825520000, 0.068710080000, 0.064769760000,
928 			0.061000000000, 0.057396210000, 0.053955040000, 0.050673760000, 0.047549650000,
929 			0.044580000000, 0.041758720000, 0.039084960000, 0.036563840000, 0.034200480000,
930 			0.032000000000, 0.029962610000, 0.028076640000, 0.026329360000, 0.024708050000,
931 			0.023200000000, 0.021800770000, 0.020501120000, 0.019281080000, 0.018120690000,
932 			0.017000000000, 0.015903790000, 0.014837180000, 0.013810680000, 0.012834780000,
933 			0.011920000000, 0.011068310000, 0.010273390000, 0.009533311000, 0.008846157000,
934 			0.008210000000, 0.007623781000, 0.007085424000, 0.006591476000, 0.006138485000,
935 			0.005723000000, 0.005343059000, 0.004995796000, 0.004676404000, 0.004380075000,
936 			0.004102000000, 0.003838453000, 0.003589099000, 0.003354219000, 0.003134093000,
937 			0.002929000000, 0.002738139000, 0.002559876000, 0.002393244000, 0.002237275000,
938 			0.002091000000, 0.001953587000, 0.001824580000, 0.001703580000, 0.001590187000,
939 			0.001484000000, 0.001384496000, 0.001291268000, 0.001204092000, 0.001122744000,
940 			0.001047000000, 0.000976589600, 0.000911108800, 0.000850133200, 0.000793238400,
941 			0.000740000000, 0.000690082700, 0.000643310000, 0.000599496000, 0.000558454700,
942 			0.000520000000, 0.000483913600, 0.000450052800, 0.000418345200, 0.000388718400,
943 			0.000361100000, 0.000335383500, 0.000311440400, 0.000289165600, 0.000268453900,
944 			0.000249200000, 0.000231301900, 0.000214685600, 0.000199288400, 0.000185047500,
945 			0.000171900000, 0.000159778100, 0.000148604400, 0.000138301600, 0.000128792500,
946 			0.000120000000, 0.000111859500, 0.000104322400, 0.000097335600, 0.000090845870,
947 			0.000084800000, 0.000079146670, 0.000073858000, 0.000068916000, 0.000064302670,
948 			0.000060000000, 0.000055981870, 0.000052225600, 0.000048718400, 0.000045447470,
949 			0.000042400000, 0.000039561040, 0.000036915120, 0.000034448680, 0.000032148160,
950 			0.000030000000, 0.000027991250, 0.000026113560, 0.000024360240, 0.000022724610,
951 			0.000021200000, 0.000019778550, 0.000018452850, 0.000017216870, 0.000016064590,
952 			0.000014990000, 0.000013987280, 0.000013051550, 0.000012178180, 0.000011362540,
953 			0.000010600000, 0.000009885877, 0.000009217304, 0.000008592362, 0.000008009133,
954 			0.000007465700, 0.000006959567, 0.000006487995, 0.000006048699, 0.000005639396,
955 			0.000005257800, 0.000004901771, 0.000004569720, 0.000004260194, 0.000003971739,
956 			0.000003702900, 0.000003452163, 0.000003218302, 0.000003000300, 0.000002797139,
957 			0.000002607800, 0.000002431220, 0.000002266531, 0.000002113013, 0.000001969943,
958 			0.000001836600, 0.000001712230, 0.000001596228, 0.000001488090, 0.000001387314,
959 			0.000001293400, 0.000001205820, 0.000001124143, 0.000001048009, 0.000000977058,
960 			0.000000910930, 0.000000849251, 0.000000791721, 0.000000738090, 0.000000688110,
961 			0.000000641530, 0.000000598090, 0.000000557575, 0.000000519808, 0.000000484612,
962 			0.000000451810
963 		}
964 	},
965 	{
966 		471, 360.0, 830.0,	/* 471 bands from 360 to 830 nm in 1nm steps */
967 		1.0,				/* Scale factor */
968 		{
969 			0.000606100000, 0.000680879200, 0.000765145600, 0.000860012400, 0.000966592800,
970 			0.001086000000, 0.001220586000, 0.001372729000, 0.001543579000, 0.001734286000,
971 			0.001946000000, 0.002177777000, 0.002435809000, 0.002731953000, 0.003078064000,
972 			0.003486000000, 0.003975227000, 0.004540880000, 0.005158320000, 0.005802907000,
973 			0.006450001000, 0.007083216000, 0.007745488000, 0.008501152000, 0.009414544000,
974 			0.010549990000, 0.011965800000, 0.013655870000, 0.015588050000, 0.017730150000,
975 			0.020050010000, 0.022511360000, 0.025202880000, 0.028279720000, 0.031897040000,
976 			0.036210000000, 0.041437710000, 0.047503720000, 0.054119880000, 0.060998030000,
977 			0.067850010000, 0.074486320000, 0.081361560000, 0.089153640000, 0.098540480000,
978 			0.110200000000, 0.124613300000, 0.141701700000, 0.161303500000, 0.183256800000,
979 			0.207400000000, 0.233692100000, 0.262611400000, 0.294774600000, 0.330798500000,
980 			0.371300000000, 0.416209100000, 0.465464200000, 0.519694800000, 0.579530300000,
981 			0.645600000000, 0.718483800000, 0.796713300000, 0.877845900000, 0.959439000000,
982 			1.039050100000, 1.115367300000, 1.188497100000, 1.258123300000, 1.323929600000,
983 			1.385600000000, 1.442635200000, 1.494803500000, 1.542190300000, 1.584880700000,
984 			1.622960000000, 1.656404800000, 1.685295900000, 1.709874500000, 1.730382100000,
985 			1.747060000000, 1.760044600000, 1.769623300000, 1.776263700000, 1.780433400000,
986 			1.782600000000, 1.782968200000, 1.781699800000, 1.779198200000, 1.775867100000,
987 			1.772110000000, 1.768258900000, 1.764039000000, 1.758943800000, 1.752466300000,
988 			1.744100000000, 1.733559500000, 1.720858100000, 1.705936900000, 1.688737200000,
989 			1.669200000000, 1.647528700000, 1.623412700000, 1.596022300000, 1.564528000000,
990 			1.528100000000, 1.486111400000, 1.439521500000, 1.389879900000, 1.338736200000,
991 			1.287640000000, 1.237422300000, 1.187824300000, 1.138761100000, 1.090148000000,
992 			1.041900000000, 0.994197600000, 0.947347300000, 0.901453100000, 0.856619300000,
993 			0.812950100000, 0.770517300000, 0.729444800000, 0.689913600000, 0.652104900000,
994 			0.616200000000, 0.582328600000, 0.550416200000, 0.520337600000, 0.491967300000,
995 			0.465180000000, 0.439924600000, 0.416183600000, 0.393882200000, 0.372945900000,
996 			0.353300000000, 0.334857800000, 0.317552100000, 0.301337500000, 0.286168600000,
997 			0.272000000000, 0.258817100000, 0.246483800000, 0.234771800000, 0.223453300000,
998 			0.212300000000, 0.201169200000, 0.190119600000, 0.179225400000, 0.168560800000,
999 			0.158200000000, 0.148138300000, 0.138375800000, 0.128994200000, 0.120075100000,
1000 			0.111700000000, 0.103904800000, 0.096667480000, 0.089982720000, 0.083845310000,
1001 			0.078249990000, 0.073208990000, 0.068678160000, 0.064567840000, 0.060788350000,
1002 			0.057250010000, 0.053904350000, 0.050746640000, 0.047752760000, 0.044898590000,
1003 			0.042160000000, 0.039507280000, 0.036935640000, 0.034458360000, 0.032088720000,
1004 			0.029840000000, 0.027711810000, 0.025694440000, 0.023787160000, 0.021989250000,
1005 			0.020300000000, 0.018718050000, 0.017240360000, 0.015863640000, 0.014584610000,
1006 			0.013400000000, 0.012307230000, 0.011301880000, 0.010377920000, 0.009529306000,
1007 			0.008749999000, 0.008035200000, 0.007381600000, 0.006785400000, 0.006242800000,
1008 			0.005749999000, 0.005303600000, 0.004899800000, 0.004534200000, 0.004202400000,
1009 			0.003900000000, 0.003623200000, 0.003370600000, 0.003141400000, 0.002934800000,
1010 			0.002749999000, 0.002585200000, 0.002438600000, 0.002309400000, 0.002196800000,
1011 			0.002100000000, 0.002017733000, 0.001948200000, 0.001889800000, 0.001840933000,
1012 			0.001800000000, 0.001766267000, 0.001737800000, 0.001711200000, 0.001683067000,
1013 			0.001650001000, 0.001610133000, 0.001564400000, 0.001513600000, 0.001458533000,
1014 			0.001400000000, 0.001336667000, 0.001270000000, 0.001205000000, 0.001146667000,
1015 			0.001100000000, 0.001068800000, 0.001049400000, 0.001035600000, 0.001021200000,
1016 			0.001000000000, 0.000968640000, 0.000929920000, 0.000886880000, 0.000842560000,
1017 			0.000800000000, 0.000760960000, 0.000723680000, 0.000685920000, 0.000645440000,
1018 			0.000600000000, 0.000547866700, 0.000491600000, 0.000435400000, 0.000383466700,
1019 			0.000340000000, 0.000307253300, 0.000283160000, 0.000265440000, 0.000251813300,
1020 			0.000240000000, 0.000229546700, 0.000220640000, 0.000211960000, 0.000202186700,
1021 			0.000190000000, 0.000174213300, 0.000155640000, 0.000135960000, 0.000116853300,
1022 			0.000100000000, 0.000086133330, 0.000074600000, 0.000065000000, 0.000056933330,
1023 			0.000049999990, 0.000044160000, 0.000039480000, 0.000035720000, 0.000032640000,
1024 			0.000030000000, 0.000027653330, 0.000025560000, 0.000023640000, 0.000021813330,
1025 			0.000020000000, 0.000018133330, 0.000016200000, 0.000014200000, 0.000012133330,
1026 			0.000010000000, 0.000007733333, 0.000005400000, 0.000003200000, 0.000001333333,
1027 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1028 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1029 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1030 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1031 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1032 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1033 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1034 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1035 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1036 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1037 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1038 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1039 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1040 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1041 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1042 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1043 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1044 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1045 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1046 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1047 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1048 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1049 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1050 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1051 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1052 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1053 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1054 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1055 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1056 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1057 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1058 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1059 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1060 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1061 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1062 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1063 			0.000000000000
1064 		}
1065 	}
1066 };
1067 
1068 /* Standard CIE 1964 10 degree */
1069 static xspect ob_CIE_1964_10[3] = {
1070 	{
1071 		471, 360.0, 830.0,	/* 471 bands from 360 to 830 nm in 1nm steps */
1072 		1.0,				/* Scale factor */
1073 		{
1074 			0.000000122200, 0.000000185138, 0.000000278830, 0.000000417470, 0.000000621330,
1075 			0.000000919270, 0.000001351980, 0.000001976540, 0.000002872500, 0.000004149500,
1076 			0.000005958600, 0.000008505600, 0.000012068600, 0.000017022600, 0.000023868000,
1077 			0.000033266000, 0.000046087000, 0.000063472000, 0.000086892000, 0.000118246000,
1078 			0.000159952000, 0.000215080000, 0.000287490000, 0.000381990000, 0.000504550000,
1079 			0.000662440000, 0.000864500000, 0.001121500000, 0.001446160000, 0.001853590000,
1080 			0.002361600000, 0.002990600000, 0.003764500000, 0.004710200000, 0.005858100000,
1081 			0.007242300000, 0.008899600000, 0.010870900000, 0.013198900000, 0.015929200000,
1082 			0.019109700000, 0.022788000000, 0.027011000000, 0.031829000000, 0.037278000000,
1083 			0.043400000000, 0.050223000000, 0.057764000000, 0.066038000000, 0.075033000000,
1084 			0.084736000000, 0.095041000000, 0.105836000000, 0.117066000000, 0.128682000000,
1085 			0.140638000000, 0.152893000000, 0.165416000000, 0.178191000000, 0.191214000000,
1086 			0.204492000000, 0.217650000000, 0.230267000000, 0.242311000000, 0.253793000000,
1087 			0.264737000000, 0.275195000000, 0.285301000000, 0.295143000000, 0.304869000000,
1088 			0.314679000000, 0.324355000000, 0.333570000000, 0.342243000000, 0.350312000000,
1089 			0.357719000000, 0.364482000000, 0.370493000000, 0.375727000000, 0.380158000000,
1090 			0.383734000000, 0.386327000000, 0.387858000000, 0.388396000000, 0.387978000000,
1091 			0.386726000000, 0.384696000000, 0.382006000000, 0.378709000000, 0.374915000000,
1092 			0.370702000000, 0.366089000000, 0.361045000000, 0.355518000000, 0.349486000000,
1093 			0.342957000000, 0.335893000000, 0.328284000000, 0.320150000000, 0.311475000000,
1094 			0.302273000000, 0.292858000000, 0.283502000000, 0.274044000000, 0.264263000000,
1095 			0.254085000000, 0.243392000000, 0.232187000000, 0.220488000000, 0.208198000000,
1096 			0.195618000000, 0.183034000000, 0.170222000000, 0.157348000000, 0.144650000000,
1097 			0.132349000000, 0.120584000000, 0.109456000000, 0.099042000000, 0.089388000000,
1098 			0.080507000000, 0.072034000000, 0.063710000000, 0.055694000000, 0.048117000000,
1099 			0.041072000000, 0.034642000000, 0.028896000000, 0.023876000000, 0.019628000000,
1100 			0.016172000000, 0.013300000000, 0.010759000000, 0.008542000000, 0.006661000000,
1101 			0.005132000000, 0.003982000000, 0.003239000000, 0.002934000000, 0.003114000000,
1102 			0.003816000000, 0.005095000000, 0.006936000000, 0.009299000000, 0.012147000000,
1103 			0.015444000000, 0.019156000000, 0.023250000000, 0.027690000000, 0.032444000000,
1104 			0.037465000000, 0.042956000000, 0.049114000000, 0.055920000000, 0.063349000000,
1105 			0.071358000000, 0.079901000000, 0.088909000000, 0.098293000000, 0.107949000000,
1106 			0.117749000000, 0.127839000000, 0.138450000000, 0.149516000000, 0.161041000000,
1107 			0.172953000000, 0.185209000000, 0.197755000000, 0.210538000000, 0.223460000000,
1108 			0.236491000000, 0.249633000000, 0.262972000000, 0.276515000000, 0.290269000000,
1109 			0.304213000000, 0.318361000000, 0.332705000000, 0.347232000000, 0.361926000000,
1110 			0.376772000000, 0.391683000000, 0.406594000000, 0.421539000000, 0.436517000000,
1111 			0.451584000000, 0.466782000000, 0.482147000000, 0.497738000000, 0.513606000000,
1112 			0.529826000000, 0.546440000000, 0.563426000000, 0.580726000000, 0.598290000000,
1113 			0.616053000000, 0.633948000000, 0.651901000000, 0.669824000000, 0.687632000000,
1114 			0.705224000000, 0.722773000000, 0.740483000000, 0.758273000000, 0.776083000000,
1115 			0.793832000000, 0.811436000000, 0.828822000000, 0.845879000000, 0.862525000000,
1116 			0.878655000000, 0.894208000000, 0.909206000000, 0.923672000000, 0.937638000000,
1117 			0.951162000000, 0.964283000000, 0.977068000000, 0.989590000000, 1.001910000000,
1118 			1.014160000000, 1.026500000000, 1.038800000000, 1.051000000000, 1.062900000000,
1119 			1.074300000000, 1.085200000000, 1.095200000000, 1.104200000000, 1.112000000000,
1120 			1.118520000000, 1.123800000000, 1.128000000000, 1.131100000000, 1.133200000000,
1121 			1.134300000000, 1.134300000000, 1.133300000000, 1.131200000000, 1.128100000000,
1122 			1.123990000000, 1.118900000000, 1.112900000000, 1.105900000000, 1.098000000000,
1123 			1.089100000000, 1.079200000000, 1.068400000000, 1.056700000000, 1.044000000000,
1124 			1.030480000000, 1.016000000000, 1.000800000000, 0.984790000000, 0.968080000000,
1125 			0.950740000000, 0.932800000000, 0.914340000000, 0.895390000000, 0.876030000000,
1126 			0.856297000000, 0.836350000000, 0.816290000000, 0.796050000000, 0.775610000000,
1127 			0.754930000000, 0.733990000000, 0.712780000000, 0.691290000000, 0.669520000000,
1128 			0.647467000000, 0.625110000000, 0.602520000000, 0.579890000000, 0.557370000000,
1129 			0.535110000000, 0.513240000000, 0.491860000000, 0.471080000000, 0.450960000000,
1130 			0.431567000000, 0.412870000000, 0.394750000000, 0.377210000000, 0.360190000000,
1131 			0.343690000000, 0.327690000000, 0.312170000000, 0.297110000000, 0.282500000000,
1132 			0.268329000000, 0.254590000000, 0.241300000000, 0.228480000000, 0.216140000000,
1133 			0.204300000000, 0.192950000000, 0.182110000000, 0.171770000000, 0.161920000000,
1134 			0.152568000000, 0.143670000000, 0.135200000000, 0.127130000000, 0.119480000000,
1135 			0.112210000000, 0.105310000000, 0.098786000000, 0.092610000000, 0.086773000000,
1136 			0.081260600000, 0.076048000000, 0.071114000000, 0.066454000000, 0.062062000000,
1137 			0.057930000000, 0.054050000000, 0.050412000000, 0.047006000000, 0.043823000000,
1138 			0.040850800000, 0.038072000000, 0.035468000000, 0.033031000000, 0.030753000000,
1139 			0.028623000000, 0.026635000000, 0.024781000000, 0.023052000000, 0.021441000000,
1140 			0.019941300000, 0.018544000000, 0.017241000000, 0.016027000000, 0.014896000000,
1141 			0.013842000000, 0.012862000000, 0.011949000000, 0.011100000000, 0.010311000000,
1142 			0.009576880000, 0.008894000000, 0.008258100000, 0.007666400000, 0.007116300000,
1143 			0.006605200000, 0.006130600000, 0.005690300000, 0.005281900000, 0.004903300000,
1144 			0.004552630000, 0.004227500000, 0.003925800000, 0.003645700000, 0.003385900000,
1145 			0.003144700000, 0.002920800000, 0.002713000000, 0.002520200000, 0.002341100000,
1146 			0.002174960000, 0.002020600000, 0.001877300000, 0.001744100000, 0.001620500000,
1147 			0.001505700000, 0.001399200000, 0.001300400000, 0.001208700000, 0.001123600000,
1148 			0.001044760000, 0.000971560000, 0.000903600000, 0.000840480000, 0.000781870000,
1149 			0.000727450000, 0.000676900000, 0.000629960000, 0.000586370000, 0.000545870000,
1150 			0.000508258000, 0.000473300000, 0.000440800000, 0.000410580000, 0.000382490000,
1151 			0.000356380000, 0.000332110000, 0.000309550000, 0.000288580000, 0.000269090000,
1152 			0.000250969000, 0.000234130000, 0.000218470000, 0.000203910000, 0.000190350000,
1153 			0.000177730000, 0.000165970000, 0.000155020000, 0.000144800000, 0.000135280000,
1154 			0.000126390000, 0.000118100000, 0.000110370000, 0.000103150000, 0.000096427000,
1155 			0.000090151000, 0.000084294000, 0.000078830000, 0.000073729000, 0.000068969000,
1156 			0.000064525800, 0.000060376000, 0.000056500000, 0.000052880000, 0.000049498000,
1157 			0.000046339000, 0.000043389000, 0.000040634000, 0.000038060000, 0.000035657000,
1158 			0.000033411700, 0.000031315000, 0.000029355000, 0.000027524000, 0.000025811000,
1159 			0.000024209000, 0.000022711000, 0.000021308000, 0.000019994000, 0.000018764000,
1160 			0.000017611500, 0.000016532000, 0.000015521000, 0.000014574000, 0.000013686000,
1161 			0.000012855000, 0.000012075000, 0.000011345000, 0.000010659000, 0.000010017000,
1162 			0.000009413630, 0.000008847900, 0.000008317100, 0.000007819000, 0.000007351600,
1163 			0.000006913000, 0.000006501500, 0.000006115300, 0.000005752900, 0.000005412700,
1164 			0.000005093470, 0.000004793800, 0.000004512500, 0.000004248300, 0.000004000200,
1165 			0.000003767100, 0.000003548000, 0.000003342100, 0.000003148500, 0.000002966500,
1166 			0.000002795310, 0.000002634500, 0.000002483400, 0.000002341400, 0.000002207800,
1167 			0.000002082000, 0.000001963600, 0.000001851900, 0.000001746500, 0.000001647100,
1168 			0.000001553140
1169 		}
1170 	},
1171 	{
1172 		471, 360.0, 830.0,	/* 471 bands from 360 to 830 nm in 1nm steps */
1173 		1.0,				/* Scale factor */
1174 		{
1175 			0.000000013398, 0.000000020294, 0.000000030560, 0.000000045740, 0.000000068050,
1176 			0.000000100650, 0.000000147980, 0.000000216270, 0.000000314200, 0.000000453700,
1177 			0.000000651100, 0.000000928800, 0.000001317500, 0.000001857200, 0.000002602000,
1178 			0.000003625000, 0.000005019000, 0.000006907000, 0.000009449000, 0.000012848000,
1179 			0.000017364000, 0.000023327000, 0.000031150000, 0.000041350000, 0.000054560000,
1180 			0.000071560000, 0.000093300000, 0.000120870000, 0.000155640000, 0.000199200000,
1181 			0.000253400000, 0.000320200000, 0.000402400000, 0.000502300000, 0.000623200000,
1182 			0.000768500000, 0.000941700000, 0.001147800000, 0.001390300000, 0.001674000000,
1183 			0.002004400000, 0.002386000000, 0.002822000000, 0.003319000000, 0.003880000000,
1184 			0.004509000000, 0.005209000000, 0.005985000000, 0.006833000000, 0.007757000000,
1185 			0.008756000000, 0.009816000000, 0.010918000000, 0.012058000000, 0.013237000000,
1186 			0.014456000000, 0.015717000000, 0.017025000000, 0.018399000000, 0.019848000000,
1187 			0.021391000000, 0.022992000000, 0.024598000000, 0.026213000000, 0.027841000000,
1188 			0.029497000000, 0.031195000000, 0.032927000000, 0.034738000000, 0.036654000000,
1189 			0.038676000000, 0.040792000000, 0.042946000000, 0.045114000000, 0.047333000000,
1190 			0.049602000000, 0.051934000000, 0.054337000000, 0.056822000000, 0.059399000000,
1191 			0.062077000000, 0.064737000000, 0.067285000000, 0.069764000000, 0.072218000000,
1192 			0.074704000000, 0.077272000000, 0.079979000000, 0.082874000000, 0.086000000000,
1193 			0.089456000000, 0.092947000000, 0.096275000000, 0.099535000000, 0.102829000000,
1194 			0.106256000000, 0.109901000000, 0.113835000000, 0.118167000000, 0.122932000000,
1195 			0.128201000000, 0.133457000000, 0.138323000000, 0.143042000000, 0.147787000000,
1196 			0.152761000000, 0.158102000000, 0.163941000000, 0.170362000000, 0.177425000000,
1197 			0.185190000000, 0.193025000000, 0.200313000000, 0.207156000000, 0.213644000000,
1198 			0.219940000000, 0.226170000000, 0.232467000000, 0.239025000000, 0.245997000000,
1199 			0.253589000000, 0.261876000000, 0.270643000000, 0.279645000000, 0.288694000000,
1200 			0.297665000000, 0.306469000000, 0.315035000000, 0.323335000000, 0.331366000000,
1201 			0.339133000000, 0.347860000000, 0.358326000000, 0.370001000000, 0.382464000000,
1202 			0.395379000000, 0.408482000000, 0.421588000000, 0.434619000000, 0.447601000000,
1203 			0.460777000000, 0.474340000000, 0.488200000000, 0.502340000000, 0.516740000000,
1204 			0.531360000000, 0.546190000000, 0.561180000000, 0.576290000000, 0.591500000000,
1205 			0.606741000000, 0.622150000000, 0.637830000000, 0.653710000000, 0.669680000000,
1206 			0.685660000000, 0.701550000000, 0.717230000000, 0.732570000000, 0.747460000000,
1207 			0.761757000000, 0.775340000000, 0.788220000000, 0.800460000000, 0.812140000000,
1208 			0.823330000000, 0.834120000000, 0.844600000000, 0.854870000000, 0.865040000000,
1209 			0.875211000000, 0.885370000000, 0.895370000000, 0.905150000000, 0.914650000000,
1210 			0.923810000000, 0.932550000000, 0.940810000000, 0.948520000000, 0.955600000000,
1211 			0.961988000000, 0.967540000000, 0.972230000000, 0.976170000000, 0.979460000000,
1212 			0.982200000000, 0.984520000000, 0.986520000000, 0.988320000000, 0.990020000000,
1213 			0.991761000000, 0.993530000000, 0.995230000000, 0.996770000000, 0.998090000000,
1214 			0.999110000000, 0.999770000000, 1.000000000000, 0.999710000000, 0.998850000000,
1215 			0.997340000000, 0.995260000000, 0.992740000000, 0.989750000000, 0.986300000000,
1216 			0.982380000000, 0.977980000000, 0.973110000000, 0.967740000000, 0.961890000000,
1217 			0.955552000000, 0.948601000000, 0.940981000000, 0.932798000000, 0.924158000000,
1218 			0.915175000000, 0.905954000000, 0.896608000000, 0.887249000000, 0.877986000000,
1219 			0.868934000000, 0.860164000000, 0.851519000000, 0.842963000000, 0.834393000000,
1220 			0.825623000000, 0.816764000000, 0.807544000000, 0.797947000000, 0.787893000000,
1221 			0.777405000000, 0.766490000000, 0.755309000000, 0.743845000000, 0.732190000000,
1222 			0.720353000000, 0.708281000000, 0.696055000000, 0.683621000000, 0.671048000000,
1223 			0.658341000000, 0.645545000000, 0.632718000000, 0.619815000000, 0.606887000000,
1224 			0.593878000000, 0.580781000000, 0.567653000000, 0.554490000000, 0.541228000000,
1225 			0.527963000000, 0.514634000000, 0.501363000000, 0.488124000000, 0.474935000000,
1226 			0.461834000000, 0.448823000000, 0.435917000000, 0.423153000000, 0.410526000000,
1227 			0.398057000000, 0.385835000000, 0.373951000000, 0.362311000000, 0.350863000000,
1228 			0.339554000000, 0.328309000000, 0.317118000000, 0.305936000000, 0.294737000000,
1229 			0.283493000000, 0.272222000000, 0.260990000000, 0.249877000000, 0.238946000000,
1230 			0.228254000000, 0.217853000000, 0.207780000000, 0.198072000000, 0.188748000000,
1231 			0.179828000000, 0.171285000000, 0.163059000000, 0.155151000000, 0.147535000000,
1232 			0.140211000000, 0.133170000000, 0.126400000000, 0.119892000000, 0.113640000000,
1233 			0.107633000000, 0.101870000000, 0.096347000000, 0.091063000000, 0.086010000000,
1234 			0.081187000000, 0.076583000000, 0.072198000000, 0.068024000000, 0.064052000000,
1235 			0.060281000000, 0.056697000000, 0.053292000000, 0.050059000000, 0.046998000000,
1236 			0.044096000000, 0.041345000000, 0.038750700000, 0.036297800000, 0.033983200000,
1237 			0.031800400000, 0.029739500000, 0.027791800000, 0.025955100000, 0.024226300000,
1238 			0.022601700000, 0.021077900000, 0.019650500000, 0.018315300000, 0.017068600000,
1239 			0.015905100000, 0.014818300000, 0.013800800000, 0.012849500000, 0.011960700000,
1240 			0.011130300000, 0.010355500000, 0.009633200000, 0.008959900000, 0.008332400000,
1241 			0.007748800000, 0.007204600000, 0.006697500000, 0.006225100000, 0.005785000000,
1242 			0.005375100000, 0.004994100000, 0.004639200000, 0.004309300000, 0.004002800000,
1243 			0.003717740000, 0.003452620000, 0.003205830000, 0.002976230000, 0.002762810000,
1244 			0.002564560000, 0.002380480000, 0.002209710000, 0.002051320000, 0.001904490000,
1245 			0.001768470000, 0.001642360000, 0.001525350000, 0.001416720000, 0.001315950000,
1246 			0.001222390000, 0.001135550000, 0.001054940000, 0.000980140000, 0.000910660000,
1247 			0.000846190000, 0.000786290000, 0.000730680000, 0.000678990000, 0.000631010000,
1248 			0.000586440000, 0.000545110000, 0.000506720000, 0.000471110000, 0.000438050000,
1249 			0.000407410000, 0.000378962000, 0.000352543000, 0.000328001000, 0.000305208000,
1250 			0.000284041000, 0.000264375000, 0.000246109000, 0.000229143000, 0.000213376000,
1251 			0.000198730000, 0.000185115000, 0.000172454000, 0.000160678000, 0.000149730000,
1252 			0.000139550000, 0.000130086000, 0.000121290000, 0.000113106000, 0.000105501000,
1253 			0.000098428000, 0.000091853000, 0.000085738000, 0.000080048000, 0.000074751000,
1254 			0.000069819000, 0.000065222000, 0.000060939000, 0.000056942000, 0.000053217000,
1255 			0.000049737000, 0.000046491000, 0.000043464000, 0.000040635000, 0.000038000000,
1256 			0.000035540500, 0.000033244800, 0.000031100600, 0.000029099000, 0.000027230700,
1257 			0.000025486000, 0.000023856100, 0.000022333200, 0.000020910400, 0.000019580800,
1258 			0.000018338400, 0.000017177700, 0.000016093400, 0.000015080000, 0.000014133600,
1259 			0.000013249000, 0.000012422600, 0.000011649900, 0.000010927700, 0.000010251900,
1260 			0.000009619600, 0.000009028100, 0.000008474000, 0.000007954800, 0.000007468600,
1261 			0.000007012800, 0.000006585800, 0.000006185700, 0.000005810700, 0.000005459000,
1262 			0.000005129800, 0.000004820600, 0.000004531200, 0.000004259100, 0.000004004200,
1263 			0.000003764730, 0.000003539950, 0.000003329140, 0.000003131150, 0.000002945290,
1264 			0.000002770810, 0.000002607050, 0.000002453290, 0.000002308940, 0.000002173380,
1265 			0.000002046130, 0.000001926620, 0.000001814400, 0.000001708950, 0.000001609880,
1266 			0.000001516770, 0.000001429210, 0.000001346860, 0.000001269450, 0.000001196620,
1267 			0.000001128090, 0.000001063680, 0.000001003130, 0.000000946220, 0.000000892630,
1268 			0.000000842160, 0.000000794640, 0.000000749780, 0.000000707440, 0.000000667480,
1269 			0.000000629700
1270 		}
1271 	},
1272 	{
1273 		471, 360.0, 830.0,	/* 471 bands from 360 to 830 nm in 1nm steps */
1274 		1.0,				/* Scale factor */
1275 		{
1276 			0.000000535027, 0.000000810720, 0.000001221200, 0.000001828700, 0.000002722200,
1277 			0.000004028300, 0.000005925700, 0.000008665100, 0.000012596000, 0.000018201000,
1278 			0.000026143700, 0.000037330000, 0.000052987000, 0.000074764000, 0.000104870000,
1279 			0.000146220000, 0.000202660000, 0.000279230000, 0.000382450000, 0.000520720000,
1280 			0.000704776000, 0.000948230000, 0.001268200000, 0.001686100000, 0.002228500000,
1281 			0.002927800000, 0.003823700000, 0.004964200000, 0.006406700000, 0.008219300000,
1282 			0.010482200000, 0.013289000000, 0.016747000000, 0.020980000000, 0.026127000000,
1283 			0.032344000000, 0.039802000000, 0.048691000000, 0.059210000000, 0.071576000000,
1284 			0.086010900000, 0.102740000000, 0.122000000000, 0.144020000000, 0.168990000000,
1285 			0.197120000000, 0.228570000000, 0.263470000000, 0.301900000000, 0.343870000000,
1286 			0.389366000000, 0.437970000000, 0.489220000000, 0.542900000000, 0.598810000000,
1287 			0.656760000000, 0.716580000000, 0.778120000000, 0.841310000000, 0.906110000000,
1288 			0.972542000000, 1.038900000000, 1.103100000000, 1.165100000000, 1.224900000000,
1289 			1.282500000000, 1.338200000000, 1.392600000000, 1.446100000000, 1.499400000000,
1290 			1.553480000000, 1.607200000000, 1.658900000000, 1.708200000000, 1.754800000000,
1291 			1.798500000000, 1.839200000000, 1.876600000000, 1.910500000000, 1.940800000000,
1292 			1.967280000000, 1.989100000000, 2.005700000000, 2.017400000000, 2.024400000000,
1293 			2.027300000000, 2.026400000000, 2.022300000000, 2.015300000000, 2.006000000000,
1294 			1.994800000000, 1.981400000000, 1.965300000000, 1.946400000000, 1.924800000000,
1295 			1.900700000000, 1.874100000000, 1.845100000000, 1.813900000000, 1.780600000000,
1296 			1.745370000000, 1.709100000000, 1.672300000000, 1.634700000000, 1.595600000000,
1297 			1.554900000000, 1.512200000000, 1.467300000000, 1.419900000000, 1.370000000000,
1298 			1.317560000000, 1.262400000000, 1.205000000000, 1.146600000000, 1.088000000000,
1299 			1.030200000000, 0.973830000000, 0.919430000000, 0.867460000000, 0.818280000000,
1300 			0.772125000000, 0.728290000000, 0.686040000000, 0.645530000000, 0.606850000000,
1301 			0.570060000000, 0.535220000000, 0.502340000000, 0.471400000000, 0.442390000000,
1302 			0.415254000000, 0.390024000000, 0.366399000000, 0.344015000000, 0.322689000000,
1303 			0.302356000000, 0.283036000000, 0.264816000000, 0.247848000000, 0.232318000000,
1304 			0.218502000000, 0.205851000000, 0.193596000000, 0.181736000000, 0.170281000000,
1305 			0.159249000000, 0.148673000000, 0.138609000000, 0.129096000000, 0.120215000000,
1306 			0.112044000000, 0.104710000000, 0.098196000000, 0.092361000000, 0.087088000000,
1307 			0.082248000000, 0.077744000000, 0.073456000000, 0.069268000000, 0.065060000000,
1308 			0.060709000000, 0.056457000000, 0.052609000000, 0.049122000000, 0.045954000000,
1309 			0.043050000000, 0.040368000000, 0.037839000000, 0.035384000000, 0.032949000000,
1310 			0.030451000000, 0.028029000000, 0.025862000000, 0.023920000000, 0.022174000000,
1311 			0.020584000000, 0.019127000000, 0.017740000000, 0.016403000000, 0.015064000000,
1312 			0.013676000000, 0.012308000000, 0.011056000000, 0.009915000000, 0.008872000000,
1313 			0.007918000000, 0.007030000000, 0.006223000000, 0.005453000000, 0.004714000000,
1314 			0.003988000000, 0.003289000000, 0.002646000000, 0.002063000000, 0.001533000000,
1315 			0.001091000000, 0.000711000000, 0.000407000000, 0.000184000000, 0.000047000000,
1316 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1317 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1318 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1319 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1320 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1321 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1322 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1323 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1324 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1325 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1326 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1327 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1328 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1329 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1330 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1331 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1332 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1333 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1334 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1335 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1336 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1337 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1338 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1339 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1340 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1341 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1342 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1343 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1344 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1345 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1346 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1347 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1348 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1349 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1350 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1351 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1352 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1353 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1354 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1355 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1356 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1357 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1358 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1359 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1360 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1361 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1362 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1363 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1364 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1365 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1366 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1367 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1368 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1369 			0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000, 0.000000000000,
1370 			0.000000000000
1371 		}
1372 	}
1373 };
1374 
1375 #ifndef SALONEINSTLIB
1376 /* Standard CIE 1964 10 degree observer, */
1377 /* adjusted for compatibility with 2 degree observer. */
1378 /* This has a problem in that it will return -ve XYZ values !! */
1379 static xspect ob_CIE_1964_10c[3] = {
1380 	{
1381 		471, 360.0, 830.0,	/* 471 bands from 360 to 830 nm in 1nm steps */
1382 		1.0,				/* Scale factor */
1383 		{
1384 			0.000000, 0.000000, 0.000000, 0.000000, 0.000001,
1385 			0.000001, 0.000001, 0.000002, 0.000003, 0.000004,
1386 			0.000006, 0.000008, 0.000012, 0.000016, 0.000023,
1387 			0.000032, 0.000044, 0.000061, 0.000083, 0.000114,
1388 			0.000154, 0.000207, 0.000276, 0.000367, 0.000485,
1389 			0.000636, 0.000830, 0.001077, 0.001389, 0.001780,
1390 			0.002268, 0.002872, 0.003616, 0.004524, 0.005626,
1391 			0.006956, 0.008547, 0.010440, 0.012675, 0.015297,
1392 			0.018351, 0.021882, 0.025937, 0.030562, 0.035793,
1393 			0.041670, 0.048218, 0.055455, 0.063395, 0.072026,
1394 			0.081334, 0.091218, 0.101571, 0.112339, 0.123475,
1395 			0.134934, 0.146676, 0.158671, 0.170901, 0.183362,
1396 			0.196059, 0.208632, 0.220678, 0.232166, 0.243106,
1397 			0.253521, 0.263459, 0.273052, 0.282379, 0.291584,
1398 			0.300858, 0.309993, 0.318677, 0.326834, 0.334402,
1399 			0.341323, 0.347615, 0.353171, 0.357967, 0.361976,
1400 			0.365148, 0.367370, 0.368575, 0.368826, 0.368155,
1401 			0.366675, 0.364435, 0.361545, 0.358052, 0.354057,
1402 			0.349627, 0.344810, 0.339593, 0.333917, 0.327752,
1403 			0.321095, 0.313902, 0.306154, 0.297863, 0.289008,
1404 			0.279595, 0.269978, 0.260456, 0.250851, 0.240930,
1405 			0.230604, 0.219745, 0.208345, 0.196419, 0.183863,
1406 			0.170973, 0.158090, 0.145040, 0.131973, 0.119113,
1407 			0.106660, 0.094739, 0.083435, 0.072806, 0.062881,
1408 			0.053655, 0.044761, 0.035965, 0.027445, 0.019347,
1409 			0.011775, 0.004818, -0.001448, -0.006980, -0.011730,
1410 			-0.015680, -0.019142, -0.022434, -0.025515, -0.028335,
1411 			-0.030850, -0.033009, -0.034770, -0.036095, -0.036941,
1412 			-0.037294, -0.037113, -0.036399, -0.035191, -0.033525,
1413 			-0.031433, -0.028948, -0.026100, -0.022920, -0.019440,
1414 			-0.015700, -0.011512, -0.006687, -0.001238, 0.004822,
1415 			0.011455, 0.018627, 0.026279, 0.034335, 0.042701,
1416 			0.051262, 0.060174, 0.069663, 0.079658, 0.090158,
1417 			0.101084, 0.112386, 0.124002, 0.135873, 0.147891,
1418 			0.160018, 0.172256, 0.184702, 0.197370, 0.210271,
1419 			0.223389, 0.236747, 0.250340, 0.264164, 0.278208,
1420 			0.292463, 0.306856, 0.321322, 0.335886, 0.350539,
1421 			0.365327, 0.380281, 0.395429, 0.410820, 0.426495,
1422 			0.442517, 0.458930, 0.475719, 0.492834, 0.510231,
1423 			0.527852, 0.545635, 0.563512, 0.581404, 0.599231,
1424 			0.616897, 0.634569, 0.652440, 0.670431, 0.688482,
1425 			0.706512, 0.724440, 0.742190, 0.759656, 0.776754,
1426 			0.793379, 0.809482, 0.825090, 0.840216, 0.854883,
1427 			0.869139, 0.883013, 0.896564, 0.909854, 0.922934,
1428 			0.935926, 0.948983, 0.961990, 0.974889, 0.987491,
1429 			0.999611, 1.011241, 1.022004, 1.031804, 1.040446,
1430 			1.047851, 1.054056, 1.059207, 1.063287, 1.066386,
1431 			1.068504, 1.069546, 1.069604, 1.068584, 1.066579,
1432 			1.063578, 1.059609, 1.054735, 1.048871, 1.042112,
1433 			1.034363, 1.025625, 1.015993, 1.005466, 0.993951,
1434 			0.981619, 0.968336, 0.954330, 0.939514, 0.923995,
1435 			0.907841, 0.891082, 0.873794, 0.856007, 0.837798,
1436 			0.819205, 0.800376, 0.781406, 0.762235, 0.742849,
1437 			0.723211, 0.703308, 0.683132, 0.662676, 0.641942,
1438 			0.620930, 0.599617, 0.578068, 0.556470, 0.534965,
1439 			0.513699, 0.492797, 0.472355, 0.452479, 0.433228,
1440 			0.414667, 0.396767, 0.379415, 0.362613, 0.346305,
1441 			0.330490, 0.315149, 0.300263, 0.285813, 0.271789,
1442 			0.258182, 0.244984, 0.232213, 0.219890, 0.208026,
1443 			0.196640, 0.185723, 0.175297, 0.165350, 0.155874,
1444 			0.146878, 0.138317, 0.130168, 0.122403, 0.115042,
1445 			0.108045, 0.101405, 0.095126, 0.089181, 0.083563,
1446 			0.078256, 0.073238, 0.068488, 0.064001, 0.059773,
1447 			0.055794, 0.052058, 0.048555, 0.045275, 0.042210,
1448 			0.039347, 0.036671, 0.034163, 0.031816, 0.029622,
1449 			0.027571, 0.025656, 0.023870, 0.022205, 0.020653,
1450 			0.019209, 0.017863, 0.016608, 0.015438, 0.014349,
1451 			0.013334, 0.012390, 0.011510, 0.010693, 0.009933,
1452 			0.009225, 0.008568, 0.007955, 0.007385, 0.006855,
1453 			0.006363, 0.005906, 0.005481, 0.005088, 0.004723,
1454 			0.004385, 0.004072, 0.003782, 0.003512, 0.003261,
1455 			0.003029, 0.002813, 0.002613, 0.002428, 0.002255,
1456 			0.002095, 0.001946, 0.001808, 0.001680, 0.001561,
1457 			0.001450, 0.001348, 0.001253, 0.001164, 0.001082,
1458 			0.001006, 0.000936, 0.000870, 0.000809, 0.000753,
1459 			0.000701, 0.000652, 0.000607, 0.000565, 0.000526,
1460 			0.000489, 0.000456, 0.000425, 0.000395, 0.000368,
1461 			0.000343, 0.000320, 0.000298, 0.000278, 0.000259,
1462 			0.000242, 0.000225, 0.000210, 0.000196, 0.000183,
1463 			0.000171, 0.000160, 0.000149, 0.000139, 0.000130,
1464 			0.000122, 0.000114, 0.000106, 0.000099, 0.000093,
1465 			0.000087, 0.000081, 0.000076, 0.000071, 0.000066,
1466 			0.000062, 0.000058, 0.000054, 0.000051, 0.000048,
1467 			0.000045, 0.000042, 0.000039, 0.000037, 0.000034,
1468 			0.000032, 0.000030, 0.000028, 0.000026, 0.000025,
1469 			0.000023, 0.000022, 0.000021, 0.000019, 0.000018,
1470 			0.000017, 0.000016, 0.000015, 0.000014, 0.000013,
1471 			0.000012, 0.000012, 0.000011, 0.000010, 0.000010,
1472 			0.000009, 0.000009, 0.000008, 0.000008, 0.000007,
1473 			0.000007, 0.000006, 0.000006, 0.000006, 0.000005,
1474 			0.000005, 0.000005, 0.000004, 0.000004, 0.000004,
1475 			0.000004, 0.000003, 0.000003, 0.000003, 0.000003,
1476 			0.000003, 0.000003, 0.000002, 0.000002, 0.000002,
1477 			0.000002, 0.000002, 0.000002, 0.000002, 0.000002,
1478 			0.000001
1479 		}
1480 	},
1481 	{
1482 		471, 360.0, 830.0,	/* 471 bands from 360 to 830 nm in 1nm steps */
1483 		1.0,				/* Scale factor */
1484 		{
1485 			-0.000000, -0.000000, -0.000000, -0.000000, -0.000000,
1486 			-0.000000, -0.000000, -0.000000, -0.000000, -0.000000,
1487 			-0.000000, -0.000000, -0.000001, -0.000001, -0.000001,
1488 			-0.000002, -0.000003, -0.000004, -0.000005, -0.000007,
1489 			-0.000009, -0.000012, -0.000017, -0.000022, -0.000029,
1490 			-0.000039, -0.000051, -0.000066, -0.000086, -0.000111,
1491 			-0.000142, -0.000181, -0.000229, -0.000289, -0.000362,
1492 			-0.000452, -0.000560, -0.000690, -0.000845, -0.001028,
1493 			-0.001243, -0.001494, -0.001786, -0.002121, -0.002505,
1494 			-0.002940, -0.003430, -0.003976, -0.004584, -0.005251,
1495 			-0.005978, -0.006763, -0.007608, -0.008509, -0.009457,
1496 			-0.010445, -0.011465, -0.012506, -0.013548, -0.014581,
1497 			-0.015588, -0.016540, -0.017410, -0.018194, -0.018887,
1498 			-0.019474, -0.019954, -0.020356, -0.020652, -0.020844,
1499 			-0.020966, -0.020987, -0.020899, -0.020710, -0.020374,
1500 			-0.019885, -0.019227, -0.018381, -0.017329, -0.016059,
1501 			-0.014554, -0.012894, -0.011147, -0.009284, -0.007270,
1502 			-0.005073, -0.002659, 0.000006, 0.002956, 0.006209,
1503 			0.009845, 0.013596, 0.017297, 0.021039, 0.024915,
1504 			0.029010, 0.033403, 0.038157, 0.043368, 0.049064,
1505 			0.055306, 0.061573, 0.067495, 0.073309, 0.079203,
1506 			0.085372, 0.091959, 0.099098, 0.106881, 0.115363,
1507 			0.124611, 0.134041, 0.143043, 0.151664, 0.159962,
1508 			0.168055, 0.176039, 0.184021, 0.192166, 0.200605,
1509 			0.209524, 0.219014, 0.228895, 0.238933, 0.248950,
1510 			0.258827, 0.268480, 0.277842, 0.286890, 0.295622,
1511 			0.304046, 0.313314, 0.324171, 0.336130, 0.348800,
1512 			0.361865, 0.375076, 0.388254, 0.401320, 0.414291,
1513 			0.427388, 0.440818, 0.454528, 0.468501, 0.482717,
1514 			0.497136, 0.511747, 0.526497, 0.541348, 0.556275,
1515 			0.571209, 0.586279, 0.601590, 0.617079, 0.632648,
1516 			0.648223, 0.663715, 0.679010, 0.693991, 0.708553,
1517 			0.722563, 0.735901, 0.748570, 0.760630, 0.772158,
1518 			0.783222, 0.793907, 0.804300, 0.814498, 0.824603,
1519 			0.834716, 0.844817, 0.854762, 0.864494, 0.873959,
1520 			0.883100, 0.891844, 0.900135, 0.907907, 0.915088,
1521 			0.921619, 0.927360, 0.932278, 0.936482, 0.940066,
1522 			0.943128, 0.945794, 0.948157, 0.950335, 0.952425,
1523 			0.954563, 0.956738, 0.958855, 0.960827, 0.962596,
1524 			0.964083, 0.965229, 0.965966, 0.966206, 0.965899,
1525 			0.964967, 0.963491, 0.961602, 0.959270, 0.956503,
1526 			0.953289, 0.949616, 0.945492, 0.940884, 0.935810,
1527 			0.930259, 0.924111, 0.917313, 0.909967, 0.902174,
1528 			0.894043, 0.885675, 0.877179, 0.868664, 0.860233,
1529 			0.852001, 0.844039, 0.836194, 0.828430, 0.820645,
1530 			0.812656, 0.804568, 0.796113, 0.787273, 0.777966,
1531 			0.768211, 0.758017, 0.747540, 0.736765, 0.725779,
1532 			0.714594, 0.703154, 0.691541, 0.679699, 0.667698,
1533 			0.655540, 0.643271, 0.630947, 0.618523, 0.606050,
1534 			0.593471, 0.580782, 0.568037, 0.555234, 0.542308,
1535 			0.529357, 0.516318, 0.503314, 0.490317, 0.477348,
1536 			0.464445, 0.451610, 0.438859, 0.426230, 0.413718,
1537 			0.401346, 0.389202, 0.377375, 0.365775, 0.354350,
1538 			0.343050, 0.331804, 0.320601, 0.309399, 0.298173,
1539 			0.286897, 0.275586, 0.264305, 0.253136, 0.242143,
1540 			0.231384, 0.220911, 0.210763, 0.200977, 0.191575,
1541 			0.182575, 0.173953, 0.165647, 0.157658, 0.149962,
1542 			0.142556, 0.135433, 0.128580, 0.121988, 0.115652,
1543 			0.109560, 0.103711, 0.098103, 0.092734, 0.087598,
1544 			0.082694, 0.078011, 0.073550, 0.069303, 0.065262,
1545 			0.061425, 0.057778, 0.054312, 0.051021, 0.047905,
1546 			0.044950, 0.042148, 0.039506, 0.037007, 0.034649,
1547 			0.032426, 0.030326, 0.028341, 0.026469, 0.024707,
1548 			0.023051, 0.021498, 0.020042, 0.018681, 0.017410,
1549 			0.016224, 0.015115, 0.014078, 0.013108, 0.012201,
1550 			0.011354, 0.010564, 0.009827, 0.009140, 0.008500,
1551 			0.007905, 0.007350, 0.006833, 0.006351, 0.005902,
1552 			0.005484, 0.005095, 0.004733, 0.004397, 0.004084,
1553 			0.003793, 0.003523, 0.003271, 0.003036, 0.002819,
1554 			0.002616, 0.002429, 0.002254, 0.002093, 0.001943,
1555 			0.001804, 0.001676, 0.001556, 0.001445, 0.001342,
1556 			0.001247, 0.001158, 0.001076, 0.001000, 0.000929,
1557 			0.000863, 0.000802, 0.000745, 0.000693, 0.000644,
1558 			0.000598, 0.000556, 0.000517, 0.000481, 0.000447,
1559 			0.000416, 0.000387, 0.000360, 0.000335, 0.000311,
1560 			0.000290, 0.000270, 0.000251, 0.000234, 0.000218,
1561 			0.000203, 0.000189, 0.000176, 0.000164, 0.000153,
1562 			0.000142, 0.000133, 0.000124, 0.000115, 0.000108,
1563 			0.000100, 0.000094, 0.000087, 0.000082, 0.000076,
1564 			0.000071, 0.000066, 0.000062, 0.000058, 0.000054,
1565 			0.000051, 0.000047, 0.000044, 0.000041, 0.000039,
1566 			0.000036, 0.000034, 0.000032, 0.000030, 0.000028,
1567 			0.000026, 0.000024, 0.000023, 0.000021, 0.000020,
1568 			0.000019, 0.000018, 0.000016, 0.000015, 0.000014,
1569 			0.000013, 0.000013, 0.000012, 0.000011, 0.000010,
1570 			0.000010, 0.000009, 0.000009, 0.000008, 0.000008,
1571 			0.000007, 0.000007, 0.000006, 0.000006, 0.000006,
1572 			0.000005, 0.000005, 0.000005, 0.000004, 0.000004,
1573 			0.000004, 0.000004, 0.000003, 0.000003, 0.000003,
1574 			0.000003, 0.000003, 0.000002, 0.000002, 0.000002,
1575 			0.000002, 0.000002, 0.000002, 0.000002, 0.000002,
1576 			0.000002, 0.000001, 0.000001, 0.000001, 0.000001,
1577 			0.000001, 0.000001, 0.000001, 0.000001, 0.000001,
1578 			0.000001, 0.000001, 0.000001, 0.000001, 0.000001,
1579 			0.000001
1580 		}
1581 	},
1582 	{
1583 		471, 360.0, 830.0,	/* 471 bands from 360 to 830 nm in 1nm steps */
1584 		1.0,				/* Scale factor */
1585 		{
1586 			0.000000, 0.000001, 0.000001, 0.000002, 0.000002,
1587 			0.000004, 0.000005, 0.000008, 0.000011, 0.000017,
1588 			0.000024, 0.000034, 0.000048, 0.000068, 0.000095,
1589 			0.000133, 0.000184, 0.000253, 0.000347, 0.000473,
1590 			0.000640, 0.000861, 0.001151, 0.001530, 0.002023,
1591 			0.002657, 0.003470, 0.004505, 0.005815, 0.007460,
1592 			0.009514, 0.012061, 0.015200, 0.019042, 0.023714,
1593 			0.029357, 0.036126, 0.044195, 0.053743, 0.064968,
1594 			0.078071, 0.093257, 0.110741, 0.130730, 0.153398,
1595 			0.178935, 0.207487, 0.239172, 0.274063, 0.312169,
1596 			0.353478, 0.397611, 0.444150, 0.492897, 0.543671,
1597 			0.596302, 0.650635, 0.706534, 0.763936, 0.822806,
1598 			0.883165, 0.943463, 1.001808, 1.058162, 1.112525,
1599 			1.164898, 1.215552, 1.265032, 1.313703, 1.362201,
1600 			1.411414, 1.460308, 1.507373, 1.552264, 1.594709,
1601 			1.634529, 1.671632, 1.705747, 1.736693, 1.764380,
1602 			1.788610, 1.808612, 1.823873, 1.834684, 1.841230,
1603 			1.844058, 1.843442, 1.839930, 1.833797, 1.825590,
1604 			1.815677, 1.803767, 1.789396, 1.772476, 1.753107,
1605 			1.731476, 1.707589, 1.681541, 1.653519, 1.623619,
1606 			1.591997, 1.559431, 1.526359, 1.492551, 1.457384,
1607 			1.420779, 1.382383, 1.342017, 1.299412, 1.254573,
1608 			1.207456, 1.157853, 1.106181, 1.053574, 1.000759,
1609 			0.948651, 0.897828, 0.848786, 0.801953, 0.757664,
1610 			0.716144, 0.676765, 0.638856, 0.602538, 0.567881,
1611 			0.534929, 0.503728, 0.474283, 0.446572, 0.420583,
1612 			0.396265, 0.373716, 0.352709, 0.332886, 0.314056,
1613 			0.296143, 0.279152, 0.263152, 0.248277, 0.234696,
1614 			0.222673, 0.211713, 0.201107, 0.190856, 0.180969,
1615 			0.171463, 0.162367, 0.153733, 0.145596, 0.138030,
1616 			0.131104, 0.124934, 0.119502, 0.114675, 0.110342,
1617 			0.106383, 0.102706, 0.099197, 0.095748, 0.092248,
1618 			0.088582, 0.084959, 0.081651, 0.078623, 0.075842,
1619 			0.073262, 0.070852, 0.068555, 0.066306, 0.064065,
1620 			0.061762, 0.059523, 0.057502, 0.055668, 0.053992,
1621 			0.052433, 0.050967, 0.049534, 0.048112, 0.046651,
1622 			0.045104, 0.043532, 0.042023, 0.040577, 0.039188,
1623 			0.037849, 0.036544, 0.035292, 0.034054, 0.032828,
1624 			0.031603, 0.030388, 0.029205, 0.028058, 0.026937,
1625 			0.025874, 0.024845, 0.023862, 0.022928, 0.022050,
1626 			0.021230, 0.020427, 0.019595, 0.018738, 0.017856,
1627 			0.016954, 0.016034, 0.015099, 0.014153, 0.013199,
1628 			0.012241, 0.011277, 0.010301, 0.009319, 0.008334,
1629 			0.007350, 0.006370, 0.005397, 0.004434, 0.003484,
1630 			0.002547, 0.001621, 0.000702, -0.000208, -0.001107,
1631 			-0.001996, -0.002870, -0.003725, -0.004559, -0.005368,
1632 			-0.006147, -0.006898, -0.007619, -0.008311, -0.008971,
1633 			-0.009601, -0.010199, -0.010764, -0.011296, -0.011794,
1634 			-0.012259, -0.012690, -0.013085, -0.013445, -0.013769,
1635 			-0.014058, -0.014311, -0.014530, -0.014715, -0.014865,
1636 			-0.014982, -0.015064, -0.015114, -0.015131, -0.015117,
1637 			-0.015074, -0.015002, -0.014904, -0.014780, -0.014633,
1638 			-0.014462, -0.014272, -0.014059, -0.013828, -0.013579,
1639 			-0.013314, -0.013035, -0.012743, -0.012439, -0.012124,
1640 			-0.011801, -0.011467, -0.011122, -0.010769, -0.010411,
1641 			-0.010052, -0.009695, -0.009340, -0.008992, -0.008650,
1642 			-0.008318, -0.007995, -0.007679, -0.007371, -0.007069,
1643 			-0.006773, -0.006483, -0.006199, -0.005920, -0.005647,
1644 			-0.005378, -0.005116, -0.004859, -0.004609, -0.004366,
1645 			-0.004133, -0.003908, -0.003692, -0.003486, -0.003290,
1646 			-0.003104, -0.002926, -0.002757, -0.002595, -0.002441,
1647 			-0.002294, -0.002155, -0.002023, -0.001898, -0.001780,
1648 			-0.001668, -0.001562, -0.001462, -0.001367, -0.001277,
1649 			-0.001193, -0.001113, -0.001039, -0.000969, -0.000904,
1650 			-0.000843, -0.000786, -0.000732, -0.000682, -0.000635,
1651 			-0.000591, -0.000550, -0.000512, -0.000476, -0.000443,
1652 			-0.000412, -0.000383, -0.000356, -0.000331, -0.000308,
1653 			-0.000286, -0.000266, -0.000247, -0.000230, -0.000213,
1654 			-0.000198, -0.000184, -0.000171, -0.000159, -0.000147,
1655 			-0.000137, -0.000127, -0.000118, -0.000109, -0.000101,
1656 			-0.000094, -0.000087, -0.000081, -0.000075, -0.000070,
1657 			-0.000065, -0.000060, -0.000056, -0.000052, -0.000048,
1658 			-0.000045, -0.000042, -0.000039, -0.000036, -0.000033,
1659 			-0.000031, -0.000029, -0.000027, -0.000025, -0.000023,
1660 			-0.000022, -0.000020, -0.000019, -0.000017, -0.000016,
1661 			-0.000015, -0.000014, -0.000013, -0.000012, -0.000011,
1662 			-0.000010, -0.000010, -0.000009, -0.000008, -0.000008,
1663 			-0.000007, -0.000007, -0.000006, -0.000006, -0.000006,
1664 			-0.000005, -0.000005, -0.000004, -0.000004, -0.000004,
1665 			-0.000004, -0.000003, -0.000003, -0.000003, -0.000003,
1666 			-0.000003, -0.000002, -0.000002, -0.000002, -0.000002,
1667 			-0.000002, -0.000002, -0.000002, -0.000002, -0.000001,
1668 			-0.000001, -0.000001, -0.000001, -0.000001, -0.000001,
1669 			-0.000001, -0.000001, -0.000001, -0.000001, -0.000001,
1670 			-0.000001, -0.000001, -0.000001, -0.000001, -0.000001,
1671 			-0.000000, -0.000000, -0.000000, -0.000000, -0.000000,
1672 			-0.000000, -0.000000, -0.000000, -0.000000, -0.000000,
1673 			-0.000000, -0.000000, -0.000000, -0.000000, -0.000000,
1674 			-0.000000, -0.000000, -0.000000, -0.000000, -0.000000,
1675 			-0.000000, -0.000000, -0.000000, -0.000000, -0.000000,
1676 			-0.000000, -0.000000, -0.000000, -0.000000, -0.000000,
1677 			-0.000000, -0.000000, -0.000000, -0.000000, -0.000000,
1678 			-0.000000, -0.000000, -0.000000, -0.000000, -0.000000,
1679 			-0.000000, -0.000000, -0.000000, -0.000000, -0.000000,
1680 			-0.000000
1681 		}
1682 	}
1683 };
1684 
1685 /* Judd & Voss 1978 2 degree */
1686 static xspect ob_Judd_Voss_2[3] = {
1687 	{
1688 		90, 380.0, 825.0,	/* 90 bands from 380 to 825 nm in 5nm steps */
1689 		1.0,				/* Scale factor */
1690 		{
1691 			2.689900e-003, 5.310500e-003, 1.078100e-002, 2.079200e-002, 3.798100e-002,
1692 			6.315700e-002, 9.994100e-002, 1.582400e-001, 2.294800e-001, 2.810800e-001,
1693 			3.109500e-001, 3.307200e-001, 3.333600e-001, 3.167200e-001, 2.888200e-001,
1694 			2.596900e-001, 2.327600e-001, 2.099900e-001, 1.747600e-001, 1.328700e-001,
1695 			9.194400e-002, 5.698500e-002, 3.173100e-002, 1.461300e-002, 4.849100e-003,
1696 			2.321500e-003, 9.289900e-003, 2.927800e-002, 6.379100e-002, 1.108100e-001,
1697 			1.669200e-001, 2.276800e-001, 2.926900e-001, 3.622500e-001, 4.363500e-001,
1698 			5.151300e-001, 5.974800e-001, 6.812100e-001, 7.642500e-001, 8.439400e-001,
1699 			9.163500e-001, 9.770300e-001, 1.023000e+000, 1.051300e+000, 1.055000e+000,
1700 			1.036200e+000, 9.923900e-001, 9.286100e-001, 8.434600e-001, 7.398300e-001,
1701 			6.328900e-001, 5.335100e-001, 4.406200e-001, 3.545300e-001, 2.786200e-001,
1702 			2.148500e-001, 1.616100e-001, 1.182000e-001, 8.575300e-002, 6.307700e-002,
1703 			4.583400e-002, 3.205700e-002, 2.218700e-002, 1.561200e-002, 1.109800e-002,
1704 			7.923300e-003, 5.653100e-003, 4.003900e-003, 2.825300e-003, 1.994700e-003,
1705 			1.399400e-003, 9.698000e-004, 6.684700e-004, 4.614100e-004, 3.207300e-004,
1706 			2.257300e-004, 1.597300e-004, 1.127500e-004, 7.951300e-005, 5.608700e-005,
1707 			3.954100e-005, 2.785200e-005, 1.959700e-005, 1.377000e-005, 9.670000e-006,
1708 			6.791800e-006, 4.770600e-006, 3.355000e-006, 2.353400e-006, 1.637700e-006
1709 		}
1710 	},
1711 	{
1712 		90, 380.0, 825.0,	/* 90 bands from 380 to 825 nm in 5nm steps */
1713 		1.0,				/* Scale factor */
1714 		{
1715 			2.000000e-004, 3.955600e-004, 8.000000e-004, 1.545700e-003, 2.800000e-003,
1716 			4.656200e-003, 7.400000e-003, 1.177900e-002, 1.750000e-002, 2.267800e-002,
1717 			2.730000e-002, 3.258400e-002, 3.790000e-002, 4.239100e-002, 4.680000e-002,
1718 			5.212200e-002, 6.000000e-002, 7.294200e-002, 9.098000e-002, 1.128400e-001,
1719 			1.390200e-001, 1.698700e-001, 2.080200e-001, 2.580800e-001, 3.230000e-001,
1720 			4.054000e-001, 5.030000e-001, 6.081100e-001, 7.100000e-001, 7.951000e-001,
1721 			8.620000e-001, 9.150500e-001, 9.540000e-001, 9.800400e-001, 9.949500e-001,
1722 			1.000100e+000, 9.950000e-001, 9.787500e-001, 9.520000e-001, 9.155800e-001,
1723 			8.700000e-001, 8.162300e-001, 7.570000e-001, 6.948300e-001, 6.310000e-001,
1724 			5.665400e-001, 5.030000e-001, 4.417200e-001, 3.810000e-001, 3.205200e-001,
1725 			2.650000e-001, 2.170200e-001, 1.750000e-001, 1.381200e-001, 1.070000e-001,
1726 			8.165200e-002, 6.100000e-002, 4.432700e-002, 3.200000e-002, 2.345400e-002,
1727 			1.700000e-002, 1.187200e-002, 8.210000e-003, 5.772300e-003, 4.102000e-003,
1728 			2.929100e-003, 2.091000e-003, 1.482200e-003, 1.047000e-003, 7.401500e-004,
1729 			5.200000e-004, 3.609300e-004, 2.492000e-004, 1.723100e-004, 1.200000e-004,
1730 			8.462000e-005, 6.000000e-005, 4.244600e-005, 3.000000e-005, 2.121000e-005,
1731 			1.498900e-005, 1.058400e-005, 7.465600e-006, 5.259200e-006, 3.702800e-006,
1732 			2.607600e-006, 1.836500e-006, 1.295000e-006, 9.109200e-007, 6.356400e-007
1733 		}
1734 	},
1735 	{
1736 		90, 380.0, 825.0,	/* 90 bands from 380 to 825 nm in 5nm steps */
1737 		1.0,				/* Scale factor */
1738 		{
1739 			1.226000e-002, 2.422200e-002, 4.925000e-002, 9.513500e-002, 1.740900e-001,
1740 			2.901300e-001, 4.605300e-001, 7.316600e-001, 1.065800e+000, 1.314600e+000,
1741 			1.467200e+000, 1.579600e+000, 1.616600e+000, 1.568200e+000, 1.471700e+000,
1742 			1.374000e+000, 1.291700e+000, 1.235600e+000, 1.113800e+000, 9.422000e-001,
1743 			7.559600e-001, 5.864000e-001, 4.466900e-001, 3.411600e-001, 2.643700e-001,
1744 			2.059400e-001, 1.544500e-001, 1.091800e-001, 7.658500e-002, 5.622700e-002,
1745 			4.136600e-002, 2.935300e-002, 2.004200e-002, 1.331200e-002, 8.782300e-003,
1746 			5.857300e-003, 4.049300e-003, 2.921700e-003, 2.277100e-003, 1.970600e-003,
1747 			1.806600e-003, 1.544900e-003, 1.234800e-003, 1.117700e-003, 9.056400e-004,
1748 			6.946700e-004, 4.288500e-004, 3.181700e-004, 2.559800e-004, 1.567900e-004,
1749 			9.769400e-005, 6.894400e-005, 5.116500e-005, 3.601600e-005, 2.423800e-005,
1750 			1.691500e-005, 1.190600e-005, 8.148900e-006, 5.600600e-006, 3.954400e-006,
1751 			2.791200e-006, 1.917600e-006, 1.313500e-006, 9.151900e-007, 6.476700e-007,
1752 			4.635200e-007, 3.330400e-007, 2.382300e-007, 1.702600e-007, 1.220700e-007,
1753 			8.710700e-008, 6.145500e-008, 4.316200e-008, 3.037900e-008, 2.155400e-008,
1754 			1.549300e-008, 1.120400e-008, 8.087300e-009, 5.834000e-009, 4.211000e-009,
1755 			3.038300e-009, 2.190700e-009, 1.577800e-009, 1.134800e-009, 8.156500e-010,
1756 			5.862600e-010, 4.213800e-010, 3.031900e-010, 2.175300e-010, 1.547600e-010
1757 		}
1758 	}
1759 };
1760 
1761 
1762 /* Stiles & Burch 1955 2 degree, */
1763 /* rotated to align with 1931 XYZ space, */
1764 /* using Mark Shaw's matrix. */
1765 static xspect ob_Stiles_Burch_2[3] = {
1766 	{
1767 		69, 390.0, 730.0,	/* 69 bands from 390 to 730 nm in 5nm steps */
1768 		1.0,				/* Scale factor */
1769 		{
1770 			0.005035, 0.012873, 0.025933, 0.054264, 0.093147,
1771 			0.144597, 0.207609, 0.266538, 0.303933, 0.336185,
1772 			0.356549, 0.364180, 0.328209, 0.286053, 0.262928,
1773 			0.210562, 0.182549, 0.131014, 0.081974, 0.045980,
1774 			0.020673, 0.008302, 0.004814, 0.008248, 0.024412,
1775 			0.050113, 0.084255, 0.131255, 0.186757, 0.243224,
1776 			0.298768, 0.359848, 0.428510, 0.500880, 0.571271,
1777 			0.650846, 0.742250, 0.829040, 0.905369, 0.971275,
1778 			1.024797, 1.060952, 1.071632, 1.054762, 1.012750,
1779 			0.947501, 0.861487, 0.761200, 0.654122, 0.548338,
1780 			0.450269, 0.361237, 0.281687, 0.213565, 0.158588,
1781 			0.115934, 0.083874, 0.060355, 0.043191, 0.030661,
1782 			0.021532, 0.014822, 0.010047, 0.006832, 0.004755,
1783 			0.003363, 0.002330, 0.001623, 0.001136
1784 		}
1785 	},
1786 	{
1787 		69, 390.0, 730.0,	/* 69 bands from 390 to 730 nm in 5nm steps */
1788 		1.0,				/* Scale factor */
1789 		{
1790 			0.000021, 0.000137, 0.000267, 0.000499, 0.000959,
1791 			-0.000352, -0.000535, -0.002306, -0.001139, 0.001507,
1792 			0.007142, 0.012389, 0.022879, 0.037200, 0.054616,
1793 			0.080087, 0.108008, 0.140411, 0.170719, 0.199791,
1794 			0.240641, 0.297681, 0.367645, 0.455184, 0.546333,
1795 			0.641762, 0.736259, 0.813393, 0.873858, 0.911828,
1796 			0.931983, 0.954960, 0.971754, 0.970171, 0.950790,
1797 			0.937240, 0.932444, 0.903026, 0.857070, 0.815886,
1798 			0.769666, 0.712437, 0.651257, 0.588631, 0.523557,
1799 			0.457801, 0.393963, 0.332964, 0.275541, 0.223722,
1800 			0.179091, 0.140943, 0.108310, 0.081218, 0.059780,
1801 			0.043398, 0.031238, 0.022406, 0.016003, 0.011340,
1802 			0.007953, 0.005473, 0.003713, 0.002527, 0.001759,
1803 			0.001244, 0.000863, 0.000602, 0.000422
1804 		}
1805 	},
1806 	{
1807 		69, 390.0, 730.0,	/* 69 bands from 390 to 730 nm in 5nm steps */
1808 		1.0,				/* Scale factor */
1809 		{
1810 			0.023163, 0.059308, 0.118897, 0.250907, 0.433765,
1811 			0.684409, 0.999185, 1.308097, 1.518706, 1.707302,
1812 			1.840521, 1.906560, 1.756384, 1.578949, 1.505983,
1813 			1.283002, 1.178612, 0.947751, 0.709500, 0.529689,
1814 			0.398963, 0.310980, 0.240664, 0.188969, 0.145151,
1815 			0.110796, 0.087421, 0.069953, 0.059951, 0.051960,
1816 			0.042905, 0.037710, 0.033821, 0.028764, 0.023371,
1817 			0.018909, 0.015103, 0.009656, 0.003595, -0.001221,
1818 			-0.005978, -0.010905, -0.014270, -0.016302, -0.018412,
1819 			-0.019889, -0.019510, -0.017854, -0.015815, -0.013632,
1820 			-0.011388, -0.009171, -0.007076, -0.005238, -0.003775,
1821 			-0.002692, -0.001946, -0.001447, -0.001074, -0.000766,
1822 			-0.000527, -0.000357, -0.000242, -0.000164, -0.000113,
1823 			-0.000077, -0.000051, -0.000034, -0.000023
1824 		}
1825 	}
1826 };
1827 
1828 /* Shaw & Fairchild 1997 2 degree observer. */
1829 /* From Mark Shaw's Masters thesis: */
1830 /* "Evaluating the 1931 CIE Color Matching Functions" */
1831 static xspect ob_Shaw_Fairchild_2[3] = {
1832 	{
1833 		61, 400.0, 700.0,	/* 61 bands from 400 to 700 nm in 5nm steps */
1834 		1.0,				/* Scale factor */
1835 		{
1836 			0.050035085, 0.10599540, 0.17570524, 0.26369069, 0.34385256,
1837 			0.36314044, 0.35022338, 0.35921696, 0.37057582, 0.37027683,
1838 			0.31092719, 0.24467905, 0.21495057, 0.16408854, 0.15609086,
1839 			0.10496585, 0.053550350, 0.016029866, -0.010473666, -0.020635411,
1840 			-0.020599591, -0.010774255, 0.013507015, 0.045305699, 0.082609321,
1841 			0.13244251, 0.18966495, 0.24710489, 0.30272442, 0.36362744,
1842 			0.43329425, 0.50816654, 0.57883305, 0.66085495, 0.75701632,
1843 			0.84336950, 0.91608703, 0.98348582, 1.0386456, 1.0699974,
1844 			1.0751974, 1.0492333, 1.0010173, 0.92955516, 0.83907524,
1845 			0.74332961, 0.64179542, 0.53031723, 0.42814376, 0.34048130,
1846 			0.26368241, 0.19677558, 0.14402031, 0.10472063, 0.076398767,
1847 			0.054311075, 0.037000030, 0.026240015, 0.018750015, 0.012892199,
1848 			0.0081198003
1849 		}
1850 	},
1851 	{
1852 		61, 400.0, 700.0,	/* 61 bands from 400 to 700 nm in 5nm steps */
1853 		1.0,				/* Scale factor */
1854 		{
1855 			0.00073439190, 0.0010295739, 0.0011050375, -0.00057123313, -0.0015421159,
1856 			-0.0050492258, -0.0060441241, -0.0050340813, -0.00046015829, 0.0043453053,
1857 			0.014594307, 0.028653705, 0.047841334, 0.078039315, 0.11339641,
1858 			0.15326829, 0.18931877, 0.22596008, 0.26950734, 0.32894461,
1859 			0.39924943, 0.48161678, 0.56603317, 0.65284913, 0.73864212,
1860 			0.80870955, 0.86388621, 0.90168525, 0.92331427, 0.94508269,
1861 			0.96035974, 0.96084837, 0.94474215, 0.93248079, 0.92686312,
1862 			0.89683591, 0.85193527, 0.81446493, 0.77206051, 0.71732417,
1863 			0.65749412, 0.59544590, 0.53033945, 0.46382662, 0.39929743,
1864 			0.33905951, 0.28179144, 0.22775797, 0.18104592, 0.14195030,
1865 			0.10887196, 0.081491712, 0.059933233, 0.043516174, 0.031399280,
1866 			0.022402933, 0.015787610, 0.011178068, 0.0078482427, 0.0054361119,
1867 			0.0036285556
1868 		}
1869 	},
1870 	{
1871 		61, 400.0, 700.0,	/* 61 bands from 400 to 700 nm in 5nm steps */
1872 		1.0,				/* Scale factor */
1873 		{
1874 			0.19346810, 0.37355444, 0.62641781, 0.98559734, 1.3578634,
1875 			1.5413908, 1.6258281, 1.7422823, 1.8184109, 1.7982693,
1876 			1.6624945, 1.4917210, 1.3537111, 1.2543216, 1.1444894,
1877 			0.94078221, 0.73058355, 0.55774101, 0.42026628, 0.31970216,
1878 			0.24388223, 0.18951860, 0.14567319, 0.11603887, 0.094972125,
1879 			0.077803903, 0.065288720, 0.055235267, 0.046945157, 0.039405440,
1880 			0.033042398, 0.026944585, 0.021626844, 0.016807242, 0.011642648,
1881 			0.0061489002, 0.00061480026, -0.0044002687, -0.0090514735, -0.013048603,
1882 			-0.016063598, -0.018035874, -0.019053770, -0.019163305, -0.018371066,
1883 			-0.016810570, -0.014805852, -0.012650736, -0.010513405, -0.0085481723,
1884 			-0.0067628649, -0.0051813692, -0.0038792081, -0.0028536093, -0.0020731313,
1885 			-0.0014924891, -0.0010704383, -0.00075273042, -0.00052400943, -0.00036054897,
1886 			-0.00025295701
1887 		}
1888 	}
1889 };
1890 
1891 /* EBU standard camera curves - 2012 */
1892 /* from Tech 3355 */
1893 static xspect ob_EBU_2012[3] = {
1894 	{
1895 		77, 380.0, 760.0,	/* 77 bands from 380 to 760 nm in 5nm steps */
1896 		1.0,				/* Scale factor */
1897 		{
1898 			0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
1899 			0.000000, 0.000450, 0.001000, 0.001230, 0.001300,
1900 			0.001300, 0.001190, 0.001120, 0.001040, 0.000930,
1901 			0.000860, 0.000820, 0.000820, 0.000890, 0.000890,
1902 			0.000970, 0.000890, 0.000890, 0.000890, 0.000930,
1903 			0.001040, 0.001120, 0.001340, 0.001490, 0.001710,
1904 			0.001790, 0.001670, 0.001410, 0.001150, 0.001120,
1905 			0.001190, 0.001710, 0.005920, 0.015630, 0.032310,
1906 			0.054310, 0.067330, 0.072830, 0.073060, 0.071650,
1907 			0.068640, 0.063800, 0.059260, 0.054600, 0.049390,
1908 			0.044370, 0.039570, 0.034540, 0.029440, 0.025030,
1909 			0.021030, 0.017900, 0.014960, 0.012170, 0.009710,
1910 			0.007740, 0.005880, 0.004350, 0.002900, 0.002000,
1911 			0.001340, 0.000950, 0.000710, 0.000530, 0.000440,
1912 			0.000310, 0.000190, 0.000060, 0.000000, 0.000000,
1913 			0.000000, 0.000000
1914 		}
1915 	},
1916 	{
1917 		77, 380.0, 760.0,	/* 77 bands from 380 to 760 nm in 5nm steps */
1918 		1.0,				/* Scale factor */
1919 		{
1920 			0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
1921 			0.000000, 0.000110, 0.000211, 0.000321, 0.000482,
1922 			0.000562, 0.000633, 0.000753, 0.000934, 0.001175,
1923 			0.001386, 0.001777, 0.002239, 0.002902, 0.003555,
1924 			0.004488, 0.006175, 0.010664, 0.021297, 0.036343,
1925 			0.046681, 0.054634, 0.059594, 0.062114, 0.063761,
1926 			0.065066, 0.066341, 0.067426, 0.068018, 0.068109,
1927 			0.066994, 0.063530, 0.054222, 0.041319, 0.025210,
1928 			0.013264, 0.007350, 0.004418, 0.002611, 0.001707,
1929 			0.001084, 0.000482, 0.000030, 0.000011, 0.000008,
1930 			0.000006, 0.000003, 0.000000, 0.000000, 0.000000,
1931 			0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
1932 			0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
1933 			0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
1934 			0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
1935 			0.000000, 0.000000
1936 		}
1937 	},
1938 	{
1939 		77, 380.0, 760.0,	/* 77 bands from 380 to 760 nm in 5nm steps */
1940 		1.0,				/* Scale factor */
1941 		{
1942 			0.000000, 0.000215, 0.000649, 0.001397, 0.003902,
1943 			0.007905, 0.014223, 0.021958, 0.029294, 0.036253,
1944 			0.042739, 0.048916, 0.055513, 0.061881, 0.068628,
1945 			0.073179, 0.075694, 0.077461, 0.078010, 0.074377,
1946 			0.066582, 0.053601, 0.036619, 0.022597, 0.012366,
1947 			0.008274, 0.006138, 0.004461, 0.003254, 0.002455,
1948 			0.001996, 0.001707, 0.001407, 0.001228, 0.000998,
1949 			0.000928, 0.000779, 0.000599, 0.000489, 0.000369,
1950 			0.000329, 0.000260, 0.000190, 0.000110, 0.000070,
1951 			0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
1952 			0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
1953 			0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
1954 			0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
1955 			0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
1956 			0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
1957 			0.000000, 0.000000
1958 		}
1959 	}
1960 };
1961 
1962 #ifdef NEVER
1963 
1964 CIE TC 1-36 proposed
1965 2-deg XYZ CMFs transformed from the CIE (2006) 2-deg LMS cone fundamentals
1966 
1967 390	3.769647E-03	4.146161E-04	1.847260E-02
1968 391	4.532416E-03	5.028333E-04	2.221101E-02
1969 392	5.446553E-03	6.084991E-04	2.669819E-02
1970 393	6.538868E-03	7.344436E-04	3.206937E-02
1971 394	7.839699E-03	8.837389E-04	3.847832E-02
1972 395	9.382967E-03	1.059646E-03	4.609784E-02
1973 396	1.120608E-02	1.265532E-03	5.511953E-02
1974 397	1.334965E-02	1.504753E-03	6.575257E-02
1975 398	1.585690E-02	1.780493E-03	7.822113E-02
1976 399	1.877286E-02	2.095572E-03	9.276013E-02
1977 400	2.214302E-02	2.452194E-03	1.096090E-01
1978 401	2.601285E-02	2.852216E-03	1.290077E-01
1979 402	3.043036E-02	3.299115E-03	1.512047E-01
1980 403	3.544325E-02	3.797466E-03	1.764441E-01
1981 404	4.109640E-02	4.352768E-03	2.049517E-01
1982 405	4.742986E-02	4.971717E-03	2.369246E-01
1983 406	5.447394E-02	5.661014E-03	2.725123E-01
1984 407	6.223612E-02	6.421615E-03	3.117820E-01
1985 408	7.070048E-02	7.250312E-03	3.547064E-01
1986 409	7.982513E-02	8.140173E-03	4.011473E-01
1987 410	8.953803E-02	9.079860E-03	4.508369E-01
1988 411	9.974848E-02	1.005608E-02	5.034164E-01
1989 412	1.104019E-01	1.106456E-02	5.586361E-01
1990 413	1.214566E-01	1.210522E-02	6.162734E-01
1991 414	1.328741E-01	1.318014E-02	6.760982E-01
1992 415	1.446214E-01	1.429377E-02	7.378822E-01
1993 416	1.566468E-01	1.545004E-02	8.013019E-01
1994 417	1.687901E-01	1.664093E-02	8.655573E-01
1995 418	1.808328E-01	1.785302E-02	9.295791E-01
1996 419	1.925216E-01	1.907018E-02	9.921293E-01
1997 420	2.035729E-01	2.027369E-02	1.051821E+00
1998 421	2.137531E-01	2.144805E-02	1.107509E+00
1999 422	2.231348E-01	2.260041E-02	1.159527E+00
2000 423	2.319245E-01	2.374789E-02	1.208869E+00
2001 424	2.403892E-01	2.491247E-02	1.256834E+00
2002 425	2.488523E-01	2.612106E-02	1.305008E+00
2003 426	2.575896E-01	2.739923E-02	1.354758E+00
2004 427	2.664991E-01	2.874993E-02	1.405594E+00
2005 428	2.753532E-01	3.016909E-02	1.456414E+00
2006 429	2.838921E-01	3.165145E-02	1.505960E+00
2007 430	2.918246E-01	3.319038E-02	1.552826E+00
2008 431	2.989200E-01	3.477912E-02	1.595902E+00
2009 432	3.052993E-01	3.641495E-02	1.635768E+00
2010 433	3.112031E-01	3.809569E-02	1.673573E+00
2011 434	3.169047E-01	3.981843E-02	1.710604E+00
2012 435	3.227087E-01	4.157940E-02	1.748280E+00
2013 436	3.288194E-01	4.337098E-02	1.787504E+00
2014 437	3.349242E-01	4.517180E-02	1.826609E+00
2015 438	3.405452E-01	4.695420E-02	1.863108E+00
2016 439	3.451688E-01	4.868718E-02	1.894332E+00
2017 440	3.482554E-01	5.033657E-02	1.917479E+00
2018 441	3.494153E-01	5.187611E-02	1.930529E+00
2019 442	3.489075E-01	5.332218E-02	1.934819E+00
2020 443	3.471746E-01	5.470603E-02	1.932650E+00
2021 444	3.446705E-01	5.606335E-02	1.926395E+00
2022 445	3.418483E-01	5.743393E-02	1.918437E+00
2023 446	3.390240E-01	5.885107E-02	1.910430E+00
2024 447	3.359926E-01	6.030809E-02	1.901224E+00
2025 448	3.324276E-01	6.178644E-02	1.889000E+00
2026 449	3.280157E-01	6.326570E-02	1.871996E+00
2027 450	3.224637E-01	6.472352E-02	1.848545E+00
2028 451	3.156225E-01	6.614749E-02	1.817792E+00
2029 452	3.078201E-01	6.757256E-02	1.781627E+00
2030 453	2.994771E-01	6.904928E-02	1.742514E+00
2031 454	2.909776E-01	7.063280E-02	1.702749E+00
2032 455	2.826646E-01	7.238339E-02	1.664439E+00
2033 456	2.747962E-01	7.435960E-02	1.629207E+00
2034 457	2.674312E-01	7.659383E-02	1.597360E+00
2035 458	2.605847E-01	7.911436E-02	1.568896E+00
2036 459	2.542749E-01	8.195345E-02	1.543823E+00
2037 460	2.485254E-01	8.514816E-02	1.522157E+00
2038 461	2.433039E-01	8.872657E-02	1.503611E+00
2039 462	2.383414E-01	9.266008E-02	1.486673E+00
2040 463	2.333253E-01	9.689723E-02	1.469595E+00
2041 464	2.279619E-01	1.013746E-01	1.450709E+00
2042 465	2.219781E-01	1.060145E-01	1.428440E+00
2043 466	2.151735E-01	1.107377E-01	1.401587E+00
2044 467	2.075619E-01	1.155111E-01	1.370094E+00
2045 468	1.992183E-01	1.203122E-01	1.334220E+00
2046 469	1.902290E-01	1.251161E-01	1.294275E+00
2047 470	1.806905E-01	1.298957E-01	1.250610E+00
2048 471	1.707154E-01	1.346299E-01	1.203696E+00
2049 472	1.604471E-01	1.393309E-01	1.154316E+00
2050 473	1.500244E-01	1.440235E-01	1.103284E+00
2051 474	1.395705E-01	1.487372E-01	1.051347E+00
2052 475	1.291920E-01	1.535066E-01	9.991789E-01
2053 476	1.189859E-01	1.583644E-01	9.473958E-01
2054 477	1.090615E-01	1.633199E-01	8.966222E-01
2055 478	9.951424E-02	1.683761E-01	8.473981E-01
2056 479	9.041850E-02	1.735365E-01	8.001576E-01
2057 480	8.182895E-02	1.788048E-01	7.552379E-01
2058 481	7.376817E-02	1.841819E-01	7.127879E-01
2059 482	6.619477E-02	1.896559E-01	6.725198E-01
2060 483	5.906380E-02	1.952101E-01	6.340976E-01
2061 484	5.234242E-02	2.008259E-01	5.972433E-01
2062 485	4.600865E-02	2.064828E-01	5.617313E-01
2063 486	4.006154E-02	2.121826E-01	5.274921E-01
2064 487	3.454373E-02	2.180279E-01	4.948809E-01
2065 488	2.949091E-02	2.241586E-01	4.642586E-01
2066 489	2.492140E-02	2.307302E-01	4.358841E-01
2067 490	2.083981E-02	2.379160E-01	4.099313E-01
2068 491	1.723591E-02	2.458706E-01	3.864261E-01
2069 492	1.407924E-02	2.546023E-01	3.650566E-01
2070 493	1.134516E-02	2.640760E-01	3.454812E-01
2071 494	9.019658E-03	2.742490E-01	3.274095E-01
2072 495	7.097731E-03	2.850680E-01	3.105939E-01
2073 496	5.571145E-03	2.964837E-01	2.948102E-01
2074 497	4.394566E-03	3.085010E-01	2.798194E-01
2075 498	3.516303E-03	3.211393E-01	2.654100E-01
2076 499	2.887638E-03	3.344175E-01	2.514084E-01
2077 500	2.461588E-03	3.483536E-01	2.376753E-01
2078 501	2.206348E-03	3.629601E-01	2.241211E-01
2079 502	2.149559E-03	3.782275E-01	2.107484E-01
2080 503	2.337091E-03	3.941359E-01	1.975839E-01
2081 504	2.818931E-03	4.106582E-01	1.846574E-01
2082 505	3.649178E-03	4.277595E-01	1.720018E-01
2083 506	4.891359E-03	4.453993E-01	1.596918E-01
2084 507	6.629364E-03	4.635396E-01	1.479415E-01
2085 508	8.942902E-03	4.821376E-01	1.369428E-01
2086 509	1.190224E-02	5.011430E-01	1.268279E-01
2087 510	1.556989E-02	5.204972E-01	1.176796E-01
2088 511	1.997668E-02	5.401387E-01	1.094970E-01
2089 512	2.504698E-02	5.600208E-01	1.020943E-01
2090 513	3.067530E-02	5.800972E-01	9.527993E-02
2091 514	3.674999E-02	6.003172E-01	8.890075E-02
2092 515	4.315171E-02	6.206256E-01	8.283548E-02
2093 516	4.978584E-02	6.409398E-01	7.700982E-02
2094 517	5.668554E-02	6.610772E-01	7.144001E-02
2095 518	6.391651E-02	6.808134E-01	6.615436E-02
2096 519	7.154352E-02	6.999044E-01	6.117199E-02
2097 520	7.962917E-02	7.180890E-01	5.650407E-02
2098 521	8.821473E-02	7.351593E-01	5.215121E-02
2099 522	9.726978E-02	7.511821E-01	4.809566E-02
2100 523	1.067504E-01	7.663143E-01	4.431720E-02
2101 524	1.166192E-01	7.807352E-01	4.079734E-02
2102 525	1.268468E-01	7.946448E-01	3.751912E-02
2103 526	1.374060E-01	8.082074E-01	3.446846E-02
2104 527	1.482471E-01	8.213817E-01	3.163764E-02
2105 528	1.593076E-01	8.340701E-01	2.901901E-02
2106 529	1.705181E-01	8.461711E-01	2.660364E-02
2107 530	1.818026E-01	8.575799E-01	2.438164E-02
2108 531	1.931090E-01	8.682408E-01	2.234097E-02
2109 532	2.045085E-01	8.783061E-01	2.046415E-02
2110 533	2.161166E-01	8.879907E-01	1.873456E-02
2111 534	2.280650E-01	8.975211E-01	1.713788E-02
2112 535	2.405015E-01	9.071347E-01	1.566174E-02
2113 536	2.535441E-01	9.169947E-01	1.429644E-02
2114 537	2.671300E-01	9.269295E-01	1.303702E-02
2115 538	2.811351E-01	9.366731E-01	1.187897E-02
2116 539	2.954164E-01	9.459482E-01	1.081725E-02
2117 540	3.098117E-01	9.544675E-01	9.846470E-03
2118 541	3.241678E-01	9.619834E-01	8.960687E-03
2119 542	3.384319E-01	9.684390E-01	8.152811E-03
2120 543	3.525786E-01	9.738289E-01	7.416025E-03
2121 544	3.665839E-01	9.781519E-01	6.744115E-03
2122 545	3.804244E-01	9.814106E-01	6.131421E-03
2123 546	3.940988E-01	9.836669E-01	5.572778E-03
2124 547	4.076972E-01	9.852081E-01	5.063463E-03
2125 548	4.213484E-01	9.863813E-01	4.599169E-03
2126 549	4.352003E-01	9.875357E-01	4.175971E-03
2127 550	4.494206E-01	9.890228E-01	3.790291E-03
2128 551	4.641616E-01	9.910811E-01	3.438952E-03
2129 552	4.794395E-01	9.934913E-01	3.119341E-03
2130 553	4.952180E-01	9.959172E-01	2.829038E-03
2131 554	5.114395E-01	9.980205E-01	2.565722E-03
2132 555	5.280233E-01	9.994608E-01	2.327186E-03
2133 556	5.448696E-01	9.999930E-01	2.111280E-03
2134 557	5.618898E-01	9.997557E-01	1.915766E-03
2135 558	5.790137E-01	9.989839E-01	1.738589E-03
2136 559	5.961882E-01	9.979123E-01	1.577920E-03
2137 560	6.133784E-01	9.967737E-01	1.432128E-03
2138 561	6.305897E-01	9.957356E-01	1.299781E-03
2139 562	6.479223E-01	9.947115E-01	1.179667E-03
2140 563	6.654866E-01	9.935534E-01	1.070694E-03
2141 564	6.833782E-01	9.921156E-01	9.718623E-04
2142 565	7.016774E-01	9.902549E-01	8.822531E-04
2143 566	7.204110E-01	9.878596E-01	8.010231E-04
2144 567	7.394495E-01	9.849324E-01	7.273884E-04
2145 568	7.586285E-01	9.815036E-01	6.606347E-04
2146 569	7.777885E-01	9.776035E-01	6.001146E-04
2147 570	7.967750E-01	9.732611E-01	5.452416E-04
2148 571	8.154530E-01	9.684764E-01	4.954847E-04
2149 572	8.337389E-01	9.631369E-01	4.503642E-04
2150 573	8.515493E-01	9.571062E-01	4.094455E-04
2151 574	8.687862E-01	9.502540E-01	3.723345E-04
2152 575	8.853376E-01	9.424569E-01	3.386739E-04
2153 576	9.011588E-01	9.336897E-01	3.081396E-04
2154 577	9.165278E-01	9.242893E-01	2.804370E-04
2155 578	9.318245E-01	9.146707E-01	2.552996E-04
2156 579	9.474524E-01	9.052333E-01	2.324859E-04
2157 580	9.638388E-01	8.963613E-01	2.117772E-04
2158 581	9.812596E-01	8.883069E-01	1.929758E-04
2159 582	9.992953E-01	8.808462E-01	1.759024E-04
2160 583	1.017343E+00	8.736445E-01	1.603947E-04
2161 584	1.034790E+00	8.663755E-01	1.463059E-04
2162 585	1.051011E+00	8.587203E-01	1.335031E-04
2163 586	1.065522E+00	8.504295E-01	1.218660E-04
2164 587	1.078421E+00	8.415047E-01	1.112857E-04
2165 588	1.089944E+00	8.320109E-01	1.016634E-04
2166 589	1.100320E+00	8.220154E-01	9.291003E-05
2167 590	1.109767E+00	8.115868E-01	8.494468E-05
2168 591	1.118438E+00	8.007874E-01	7.769425E-05
2169 592	1.126266E+00	7.896515E-01	7.109247E-05
2170 593	1.133138E+00	7.782053E-01	6.507936E-05
2171 594	1.138952E+00	7.664733E-01	5.960061E-05
2172 595	1.143620E+00	7.544785E-01	5.460706E-05
2173 596	1.147095E+00	7.422473E-01	5.005417E-05
2174 597	1.149464E+00	7.298229E-01	4.590157E-05
2175 598	1.150838E+00	7.172525E-01	4.211268E-05
2176 599	1.151326E+00	7.045818E-01	3.865437E-05
2177 600	1.151033E+00	6.918553E-01	3.549661E-05
2178 601	1.150002E+00	6.791009E-01	3.261220E-05
2179 602	1.148061E+00	6.662846E-01	2.997643E-05
2180 603	1.144998E+00	6.533595E-01	2.756693E-05
2181 604	1.140622E+00	6.402807E-01	2.536339E-05
2182 605	1.134757E+00	6.270066E-01	2.334738E-05
2183 606	1.127298E+00	6.135148E-01	2.150221E-05
2184 607	1.118342E+00	5.998494E-01	1.981268E-05
2185 608	1.108033E+00	5.860682E-01	1.826500E-05
2186 609	1.096515E+00	5.722261E-01	1.684667E-05
2187 610	1.083928E+00	5.583746E-01	1.554631E-05
2188 611	1.070387E+00	5.445535E-01	1.435360E-05
2189 612	1.055934E+00	5.307673E-01	1.325915E-05
2190 613	1.040592E+00	5.170130E-01	1.225443E-05
2191 614	1.024385E+00	5.032889E-01	1.133169E-05
2192 615	1.007344E+00	4.895950E-01	1.048387E-05
2193 616	9.895268E-01	4.759442E-01	0.000000E+00
2194 617	9.711213E-01	4.623958E-01	0.000000E+00
2195 618	9.523257E-01	4.490154E-01	0.000000E+00
2196 619	9.333248E-01	4.358622E-01	0.000000E+00
2197 620	9.142877E-01	4.229897E-01	0.000000E+00
2198 621	8.952798E-01	4.104152E-01	0.000000E+00
2199 622	8.760157E-01	3.980356E-01	0.000000E+00
2200 623	8.561607E-01	3.857300E-01	0.000000E+00
2201 624	8.354235E-01	3.733907E-01	0.000000E+00
2202 625	8.135565E-01	3.609245E-01	0.000000E+00
2203 626	7.904565E-01	3.482860E-01	0.000000E+00
2204 627	7.664364E-01	3.355702E-01	0.000000E+00
2205 628	7.418777E-01	3.228963E-01	0.000000E+00
2206 629	7.171219E-01	3.103704E-01	0.000000E+00
2207 630	6.924717E-01	2.980865E-01	0.000000E+00
2208 631	6.681600E-01	2.861160E-01	0.000000E+00
2209 632	6.442697E-01	2.744822E-01	0.000000E+00
2210 633	6.208450E-01	2.631953E-01	0.000000E+00
2211 634	5.979243E-01	2.522628E-01	0.000000E+00
2212 635	5.755410E-01	2.416902E-01	0.000000E+00
2213 636	5.537296E-01	2.314809E-01	0.000000E+00
2214 637	5.325412E-01	2.216378E-01	0.000000E+00
2215 638	5.120218E-01	2.121622E-01	0.000000E+00
2216 639	4.922070E-01	2.030542E-01	0.000000E+00
2217 640	4.731224E-01	1.943124E-01	0.000000E+00
2218 641	4.547417E-01	1.859227E-01	0.000000E+00
2219 642	4.368719E-01	1.778274E-01	0.000000E+00
2220 643	4.193121E-01	1.699654E-01	0.000000E+00
2221 644	4.018980E-01	1.622841E-01	0.000000E+00
2222 645	3.844986E-01	1.547397E-01	0.000000E+00
2223 646	3.670592E-01	1.473081E-01	0.000000E+00
2224 647	3.497167E-01	1.400169E-01	0.000000E+00
2225 648	3.326305E-01	1.329013E-01	0.000000E+00
2226 649	3.159341E-01	1.259913E-01	0.000000E+00
2227 650	2.997374E-01	1.193120E-01	0.000000E+00
2228 651	2.841189E-01	1.128820E-01	0.000000E+00
2229 652	2.691053E-01	1.067113E-01	0.000000E+00
2230 653	2.547077E-01	1.008052E-01	0.000000E+00
2231 654	2.409319E-01	9.516653E-02	0.000000E+00
2232 655	2.277792E-01	8.979594E-02	0.000000E+00
2233 656	2.152431E-01	8.469044E-02	0.000000E+00
2234 657	2.033010E-01	7.984009E-02	0.000000E+00
2235 658	1.919276E-01	7.523372E-02	0.000000E+00
2236 659	1.810987E-01	7.086061E-02	0.000000E+00
2237 660	1.707914E-01	6.671045E-02	0.000000E+00
2238 661	1.609842E-01	6.277360E-02	0.000000E+00
2239 662	1.516577E-01	5.904179E-02	0.000000E+00
2240 663	1.427936E-01	5.550703E-02	0.000000E+00
2241 664	1.343737E-01	5.216139E-02	0.000000E+00
2242 665	1.263808E-01	4.899699E-02	0.000000E+00
2243 666	1.187979E-01	4.600578E-02	0.000000E+00
2244 667	1.116088E-01	4.317885E-02	0.000000E+00
2245 668	1.047975E-01	4.050755E-02	0.000000E+00
2246 669	9.834835E-02	3.798376E-02	0.000000E+00
2247 670	9.224597E-02	3.559982E-02	0.000000E+00
2248 671	8.647506E-02	3.334856E-02	0.000000E+00
2249 672	8.101986E-02	3.122332E-02	0.000000E+00
2250 673	7.586514E-02	2.921780E-02	0.000000E+00
2251 674	7.099633E-02	2.732601E-02	0.000000E+00
2252 675	6.639960E-02	2.554223E-02	0.000000E+00
2253 676	6.206225E-02	2.386121E-02	0.000000E+00
2254 677	5.797409E-02	2.227859E-02	0.000000E+00
2255 678	5.412533E-02	2.079020E-02	0.000000E+00
2256 679	5.050600E-02	1.939185E-02	0.000000E+00
2257 680	4.710606E-02	1.807939E-02	0.000000E+00
2258 681	4.391411E-02	1.684817E-02	0.000000E+00
2259 682	4.091411E-02	1.569188E-02	0.000000E+00
2260 683	3.809067E-02	1.460446E-02	0.000000E+00
2261 684	3.543034E-02	1.358062E-02	0.000000E+00
2262 685	3.292138E-02	1.261573E-02	0.000000E+00
2263 686	3.055672E-02	1.170696E-02	0.000000E+00
2264 687	2.834146E-02	1.085608E-02	0.000000E+00
2265 688	2.628033E-02	1.006476E-02	0.000000E+00
2266 689	2.437465E-02	9.333376E-03	0.000000E+00
2267 690	2.262306E-02	8.661284E-03	0.000000E+00
2268 691	2.101935E-02	8.046048E-03	0.000000E+00
2269 692	1.954647E-02	7.481130E-03	0.000000E+00
2270 693	1.818727E-02	6.959987E-03	0.000000E+00
2271 694	1.692727E-02	6.477070E-03	0.000000E+00
2272 695	1.575417E-02	6.027677E-03	0.000000E+00
2273 696	1.465854E-02	5.608169E-03	0.000000E+00
2274 697	1.363571E-02	5.216691E-03	0.000000E+00
2275 698	1.268205E-02	4.851785E-03	0.000000E+00
2276 699	1.179394E-02	4.512008E-03	0.000000E+00
2277 700	1.096778E-02	4.195941E-03	0.000000E+00
2278 701	1.019964E-02	3.902057E-03	0.000000E+00
2279 702	9.484317E-03	3.628371E-03	0.000000E+00
2280 703	8.816851E-03	3.373005E-03	0.000000E+00
2281 704	8.192921E-03	3.134315E-03	0.000000E+00
2282 705	7.608750E-03	2.910864E-03	0.000000E+00
2283 706	7.061391E-03	2.701528E-03	0.000000E+00
2284 707	6.549509E-03	2.505796E-03	0.000000E+00
2285 708	6.071970E-03	2.323231E-03	0.000000E+00
2286 709	5.627476E-03	2.153333E-03	0.000000E+00
2287 710	5.214608E-03	1.995557E-03	0.000000E+00
2288 711	4.831848E-03	1.849316E-03	0.000000E+00
2289 712	4.477579E-03	1.713976E-03	0.000000E+00
2290 713	4.150166E-03	1.588899E-03	0.000000E+00
2291 714	3.847988E-03	1.473453E-03	0.000000E+00
2292 715	3.569452E-03	1.367022E-03	0.000000E+00
2293 716	3.312857E-03	1.268954E-03	0.000000E+00
2294 717	3.076022E-03	1.178421E-03	0.000000E+00
2295 718	2.856894E-03	1.094644E-03	0.000000E+00
2296 719	2.653681E-03	1.016943E-03	0.000000E+00
2297 720	2.464821E-03	9.447269E-04	0.000000E+00
2298 721	2.289060E-03	8.775171E-04	0.000000E+00
2299 722	2.125694E-03	8.150438E-04	0.000000E+00
2300 723	1.974121E-03	7.570755E-04	0.000000E+00
2301 724	1.833723E-03	7.033755E-04	0.000000E+00
2302 725	1.703876E-03	6.537050E-04	0.000000E+00
2303 726	1.583904E-03	6.078048E-04	0.000000E+00
2304 727	1.472939E-03	5.653435E-04	0.000000E+00
2305 728	1.370151E-03	5.260046E-04	0.000000E+00
2306 729	1.274803E-03	4.895061E-04	0.000000E+00
2307 730	1.186238E-03	4.555970E-04	0.000000E+00
2308 731	1.103871E-03	4.240548E-04	0.000000E+00
2309 732	1.027194E-03	3.946860E-04	0.000000E+00
2310 733	9.557493E-04	3.673178E-04	0.000000E+00
2311 734	8.891262E-04	3.417941E-04	0.000000E+00
2312 735	8.269535E-04	3.179738E-04	0.000000E+00
2313 736	7.689351E-04	2.957441E-04	0.000000E+00
2314 737	7.149425E-04	2.750558E-04	0.000000E+00
2315 738	6.648590E-04	2.558640E-04	0.000000E+00
2316 739	6.185421E-04	2.381142E-04	0.000000E+00
2317 740	5.758303E-04	2.217445E-04	0.000000E+00
2318 741	5.365046E-04	2.066711E-04	0.000000E+00
2319 742	5.001842E-04	1.927474E-04	0.000000E+00
2320 743	4.665005E-04	1.798315E-04	0.000000E+00
2321 744	4.351386E-04	1.678023E-04	0.000000E+00
2322 745	4.058303E-04	1.565566E-04	0.000000E+00
2323 746	3.783733E-04	1.460168E-04	0.000000E+00
2324 747	3.526892E-04	1.361535E-04	0.000000E+00
2325 748	3.287199E-04	1.269451E-04	0.000000E+00
2326 749	3.063998E-04	1.183671E-04	0.000000E+00
2327 750	2.856577E-04	1.103928E-04	0.000000E+00
2328 751	2.664108E-04	1.029908E-04	0.000000E+00
2329 752	2.485462E-04	9.611836E-05	0.000000E+00
2330 753	2.319529E-04	8.973323E-05	0.000000E+00
2331 754	2.165300E-04	8.379694E-05	0.000000E+00
2332 755	2.021853E-04	7.827442E-05	0.000000E+00
2333 756	1.888338E-04	7.313312E-05	0.000000E+00
2334 757	1.763935E-04	6.834142E-05	0.000000E+00
2335 758	1.647895E-04	6.387035E-05	0.000000E+00
2336 759	1.539542E-04	5.969389E-05	0.000000E+00
2337 760	1.438270E-04	5.578862E-05	0.000000E+00
2338 761	1.343572E-04	5.213509E-05	0.000000E+00
2339 762	1.255141E-04	4.872179E-05	0.000000E+00
2340 763	1.172706E-04	4.553845E-05	0.000000E+00
2341 764	1.095983E-04	4.257443E-05	0.000000E+00
2342 765	1.024685E-04	3.981884E-05	0.000000E+00
2343 766	9.584715E-05	3.725877E-05	0.000000E+00
2344 767	8.968316E-05	3.487467E-05	0.000000E+00
2345 768	8.392734E-05	3.264765E-05	0.000000E+00
2346 769	7.853708E-05	3.056140E-05	0.000000E+00
2347 770	7.347551E-05	2.860175E-05	0.000000E+00
2348 771	6.871576E-05	2.675841E-05	0.000000E+00
2349 772	6.425257E-05	2.502943E-05	0.000000E+00
2350 773	6.008292E-05	2.341373E-05	0.000000E+00
2351 774	5.620098E-05	2.190914E-05	0.000000E+00
2352 775	5.259870E-05	2.051259E-05	0.000000E+00
2353 776	4.926279E-05	1.921902E-05	0.000000E+00
2354 777	4.616623E-05	1.801796E-05	0.000000E+00
2355 778	4.328212E-05	1.689899E-05	0.000000E+00
2356 779	4.058715E-05	1.585309E-05	0.000000E+00
2357 780	3.806114E-05	1.487243E-05	0.000000E+00
2358 781	3.568818E-05	1.395085E-05	0.000000E+00
2359 782	3.346023E-05	1.308528E-05	0.000000E+00
2360 783	3.137090E-05	1.227327E-05	0.000000E+00
2361 784	2.941371E-05	1.151233E-05	0.000000E+00
2362 785	2.758222E-05	1.080001E-05	0.000000E+00
2363 786	2.586951E-05	1.013364E-05	0.000000E+00
2364 787	2.426701E-05	9.509919E-06	0.000000E+00
2365 788	2.276639E-05	8.925630E-06	0.000000E+00
2366 789	2.136009E-05	8.377852E-06	0.000000E+00
2367 790	2.004122E-05	7.863920E-06	0.000000E+00
2368 791	1.880380E-05	7.381539E-06	0.000000E+00
2369 792	1.764358E-05	6.929096E-06	0.000000E+00
2370 793	1.655671E-05	6.505136E-06	0.000000E+00
2371 794	1.553939E-05	6.108221E-06	0.000000E+00
2372 795	1.458792E-05	5.736935E-06	0.000000E+00
2373 796	1.369853E-05	5.389831E-06	0.000000E+00
2374 797	1.286705E-05	5.065269E-06	0.000000E+00
2375 798	1.208947E-05	4.761667E-06	0.000000E+00
2376 799	1.136207E-05	4.477561E-06	0.000000E+00
2377 800	1.068141E-05	4.211597E-06	0.000000E+00
2378 801	1.004411E-05	3.962457E-06	0.000000E+00
2379 802	9.446399E-06	3.728674E-06	0.000000E+00
2380 803	8.884754E-06	3.508881E-06	0.000000E+00
2381 804	8.356050E-06	3.301868E-06	0.000000E+00
2382 805	7.857521E-06	3.106561E-06	0.000000E+00
2383 806	7.386996E-06	2.922119E-06	0.000000E+00
2384 807	6.943576E-06	2.748208E-06	0.000000E+00
2385 808	6.526548E-06	2.584560E-06	0.000000E+00
2386 809	6.135087E-06	2.430867E-06	0.000000E+00
2387 810	5.768284E-06	2.286786E-06	0.000000E+00
2388 811	5.425069E-06	2.151905E-06	0.000000E+00
2389 812	5.103974E-06	2.025656E-06	0.000000E+00
2390 813	4.803525E-06	1.907464E-06	0.000000E+00
2391 814	4.522350E-06	1.796794E-06	0.000000E+00
2392 815	4.259166E-06	1.693147E-06	0.000000E+00
2393 816	4.012715E-06	1.596032E-06	0.000000E+00
2394 817	3.781597E-06	1.504903E-06	0.000000E+00
2395 818	3.564496E-06	1.419245E-06	0.000000E+00
2396 819	3.360236E-06	1.338600E-06	0.000000E+00
2397 820	3.167765E-06	1.262556E-06	0.000000E+00
2398 821	2.986206E-06	1.190771E-06	0.000000E+00
2399 822	2.814999E-06	1.123031E-06	0.000000E+00
2400 823	2.653663E-06	1.059151E-06	0.000000E+00
2401 824	2.501725E-06	9.989507E-07	0.000000E+00
2402 825	2.358723E-06	9.422514E-07	0.000000E+00
2403 826	2.224206E-06	8.888804E-07	0.000000E+00
2404 827	2.097737E-06	8.386690E-07	0.000000E+00
2405 828	1.978894E-06	7.914539E-07	0.000000E+00
2406 829	1.867268E-06	7.470770E-07	0.000000E+00
2407 830	1.762465E-06	7.053860E-07	0.000000E+00
2408 
2409 CIE TC 1-36 proposed
2410 10-deg XYZ CMFs transformed from the CIE (2006) 2-deg LMS cone fundamentals
2411 
2412 390	2.952420E-03	4.076779E-04	1.318752E-02
2413 391	3.577275E-03	4.977769E-04	1.597879E-02
2414 392	4.332146E-03	6.064754E-04	1.935758E-02
2415 393	5.241609E-03	7.370040E-04	2.343758E-02
2416 394	6.333902E-03	8.929388E-04	2.835021E-02
2417 395	7.641137E-03	1.078166E-03	3.424588E-02
2418 396	9.199401E-03	1.296816E-03	4.129467E-02
2419 397	1.104869E-02	1.553159E-03	4.968641E-02
2420 398	1.323262E-02	1.851463E-03	5.962964E-02
2421 399	1.579791E-02	2.195795E-03	7.134926E-02
2422 400	1.879338E-02	2.589775E-03	8.508254E-02
2423 401	2.226949E-02	3.036799E-03	1.010753E-01
2424 402	2.627978E-02	3.541926E-03	1.195838E-01
2425 403	3.087862E-02	4.111422E-03	1.408647E-01
2426 404	3.611890E-02	4.752618E-03	1.651644E-01
2427 405	4.204986E-02	5.474207E-03	1.927065E-01
2428 406	4.871256E-02	6.285034E-03	2.236782E-01
2429 407	5.612868E-02	7.188068E-03	2.582109E-01
2430 408	6.429866E-02	8.181786E-03	2.963632E-01
2431 409	7.319818E-02	9.260417E-03	3.381018E-01
2432 410	8.277331E-02	1.041303E-02	3.832822E-01
2433 411	9.295327E-02	1.162642E-02	4.316884E-01
2434 412	1.037137E-01	1.289884E-02	4.832440E-01
2435 413	1.150520E-01	1.423442E-02	5.379345E-01
2436 414	1.269771E-01	1.564080E-02	5.957740E-01
2437 415	1.395127E-01	1.712968E-02	6.568187E-01
2438 416	1.526661E-01	1.871265E-02	7.210459E-01
2439 417	1.663054E-01	2.038394E-02	7.878635E-01
2440 418	1.802197E-01	2.212935E-02	8.563391E-01
2441 419	1.941448E-01	2.392985E-02	9.253017E-01
2442 420	2.077647E-01	2.576133E-02	9.933444E-01
2443 421	2.207911E-01	2.760156E-02	1.059178E+00
2444 422	2.332355E-01	2.945513E-02	1.122832E+00
2445 423	2.452462E-01	3.133884E-02	1.184947E+00
2446 424	2.570397E-01	3.327575E-02	1.246476E+00
2447 425	2.688989E-01	3.529554E-02	1.308674E+00
2448 426	2.810677E-01	3.742705E-02	1.372628E+00
2449 427	2.933967E-01	3.967137E-02	1.437661E+00
2450 428	3.055933E-01	4.201998E-02	1.502449E+00
2451 429	3.173165E-01	4.446166E-02	1.565456E+00
2452 430	3.281798E-01	4.698226E-02	1.624940E+00
2453 431	3.378678E-01	4.956742E-02	1.679488E+00
2454 432	3.465097E-01	5.221219E-02	1.729668E+00
2455 433	3.543953E-01	5.491387E-02	1.776755E+00
2456 434	3.618655E-01	5.766919E-02	1.822228E+00
2457 435	3.693084E-01	6.047429E-02	1.867751E+00
2458 436	3.770107E-01	6.332195E-02	1.914504E+00
2459 437	3.846850E-01	6.619271E-02	1.961055E+00
2460 438	3.918591E-01	6.906185E-02	2.005136E+00
2461 439	3.980192E-01	7.190190E-02	2.044296E+00
2462 440	4.026189E-01	7.468288E-02	2.075946E+00
2463 441	4.052637E-01	7.738452E-02	2.098231E+00
2464 442	4.062482E-01	8.003601E-02	2.112591E+00
2465 443	4.060660E-01	8.268524E-02	2.121427E+00
2466 444	4.052283E-01	8.538745E-02	2.127239E+00
2467 445	4.042529E-01	8.820537E-02	2.132574E+00
2468 446	4.034808E-01	9.118925E-02	2.139093E+00
2469 447	4.025362E-01	9.431041E-02	2.144815E+00
2470 448	4.008675E-01	9.751346E-02	2.146832E+00
2471 449	3.979327E-01	1.007349E-01	2.142250E+00
2472 450	3.932139E-01	1.039030E-01	2.128264E+00
2473 451	3.864108E-01	1.069639E-01	2.103205E+00
2474 452	3.779513E-01	1.099676E-01	2.069388E+00
2475 453	3.684176E-01	1.129992E-01	2.030030E+00
2476 454	3.583473E-01	1.161541E-01	1.988178E+00
2477 455	3.482214E-01	1.195389E-01	1.946651E+00
2478 456	3.383830E-01	1.232503E-01	1.907521E+00
2479 457	3.288309E-01	1.273047E-01	1.870689E+00
2480 458	3.194977E-01	1.316964E-01	1.835578E+00
2481 459	3.103345E-01	1.364178E-01	1.801657E+00
2482 460	3.013112E-01	1.414586E-01	1.768440E+00
2483 461	2.923754E-01	1.468003E-01	1.735338E+00
2484 462	2.833273E-01	1.524002E-01	1.701254E+00
2485 463	2.739463E-01	1.582021E-01	1.665053E+00
2486 464	2.640352E-01	1.641400E-01	1.625712E+00
2487 465	2.534221E-01	1.701373E-01	1.582342E+00
2488 466	2.420135E-01	1.761233E-01	1.534439E+00
2489 467	2.299346E-01	1.820896E-01	1.482544E+00
2490 468	2.173617E-01	1.880463E-01	1.427438E+00
2491 469	2.044672E-01	1.940065E-01	1.369876E+00
2492 470	1.914176E-01	1.999859E-01	1.310576E+00
2493 471	1.783672E-01	2.060054E-01	1.250226E+00
2494 472	1.654407E-01	2.120981E-01	1.189511E+00
2495 473	1.527391E-01	2.183041E-01	1.129050E+00
2496 474	1.403439E-01	2.246686E-01	1.069379E+00
2497 475	1.283167E-01	2.312426E-01	1.010952E+00
2498 476	1.167124E-01	2.380741E-01	9.541809E-01
2499 477	1.056121E-01	2.451798E-01	8.995253E-01
2500 478	9.508569E-02	2.525682E-01	8.473720E-01
2501 479	8.518206E-02	2.602479E-01	7.980093E-01
2502 480	7.593120E-02	2.682271E-01	7.516389E-01
2503 481	6.733159E-02	2.765005E-01	7.082645E-01
2504 482	5.932018E-02	2.850035E-01	6.673867E-01
2505 483	5.184106E-02	2.936475E-01	6.284798E-01
2506 484	4.486119E-02	3.023319E-01	5.911174E-01
2507 485	3.836770E-02	3.109438E-01	5.549619E-01
2508 486	3.237296E-02	3.194105E-01	5.198843E-01
2509 487	2.692095E-02	3.278683E-01	4.862772E-01
2510 488	2.204070E-02	3.365263E-01	4.545497E-01
2511 489	1.773951E-02	3.456176E-01	4.249955E-01
2512 490	1.400745E-02	3.554018E-01	3.978114E-01
2513 491	1.082291E-02	3.660893E-01	3.730218E-01
2514 492	8.168996E-03	3.775857E-01	3.502618E-01
2515 493	6.044623E-03	3.896960E-01	3.291407E-01
2516 494	4.462638E-03	4.021947E-01	3.093356E-01
2517 495	3.446810E-03	4.148227E-01	2.905816E-01
2518 496	3.009513E-03	4.273539E-01	2.726773E-01
2519 497	3.090744E-03	4.398206E-01	2.555143E-01
2520 498	3.611221E-03	4.523360E-01	2.390188E-01
2521 499	4.491435E-03	4.650298E-01	2.231335E-01
2522 500	5.652072E-03	4.780482E-01	2.078158E-01
2523 501	7.035322E-03	4.915173E-01	1.930407E-01
2524 502	8.669631E-03	5.054224E-01	1.788089E-01
2525 503	1.060755E-02	5.197057E-01	1.651287E-01
2526 504	1.290468E-02	5.343012E-01	1.520103E-01
2527 505	1.561956E-02	5.491344E-01	1.394643E-01
2528 506	1.881640E-02	5.641302E-01	1.275353E-01
2529 507	2.256923E-02	5.792416E-01	1.163771E-01
2530 508	2.694456E-02	5.944264E-01	1.061161E-01
2531 509	3.199910E-02	6.096388E-01	9.682266E-02
2532 510	3.778185E-02	6.248296E-01	8.852389E-02
2533 511	4.430635E-02	6.399656E-01	8.118263E-02
2534 512	5.146516E-02	6.550943E-01	7.463132E-02
2535 513	5.912224E-02	6.702903E-01	6.870644E-02
2536 514	6.714220E-02	6.856375E-01	6.327834E-02
2537 515	7.538941E-02	7.012292E-01	5.824484E-02
2538 516	8.376697E-02	7.171103E-01	5.353812E-02
2539 517	9.233581E-02	7.330917E-01	4.914863E-02
2540 518	1.011940E-01	7.489041E-01	4.507511E-02
2541 519	1.104362E-01	7.642530E-01	4.131175E-02
2542 520	1.201511E-01	7.788199E-01	3.784916E-02
2543 521	1.303960E-01	7.923410E-01	3.467234E-02
2544 522	1.411310E-01	8.048510E-01	3.175471E-02
2545 523	1.522944E-01	8.164747E-01	2.907029E-02
2546 524	1.638288E-01	8.273520E-01	2.659651E-02
2547 525	1.756832E-01	8.376358E-01	2.431375E-02
2548 526	1.878114E-01	8.474653E-01	2.220677E-02
2549 527	2.001621E-01	8.568868E-01	2.026852E-02
2550 528	2.126822E-01	8.659242E-01	1.849246E-02
2551 529	2.253199E-01	8.746041E-01	1.687084E-02
2552 530	2.380254E-01	8.829552E-01	1.539505E-02
2553 531	2.507787E-01	8.910274E-01	1.405450E-02
2554 532	2.636778E-01	8.989495E-01	1.283354E-02
2555 533	2.768607E-01	9.068753E-01	1.171754E-02
2556 534	2.904792E-01	9.149652E-01	1.069415E-02
2557 535	3.046991E-01	9.233858E-01	9.753000E-03
2558 536	3.196485E-01	9.322325E-01	8.886096E-03
2559 537	3.352447E-01	9.412862E-01	8.089323E-03
2560 538	3.513290E-01	9.502378E-01	7.359131E-03
2561 539	3.677148E-01	9.587647E-01	6.691736E-03
2562 540	3.841856E-01	9.665325E-01	6.083223E-03
2563 541	4.005312E-01	9.732504E-01	5.529423E-03
2564 542	4.166669E-01	9.788415E-01	5.025504E-03
2565 543	4.325420E-01	9.832867E-01	4.566879E-03
2566 544	4.481063E-01	9.865720E-01	4.149405E-03
2567 545	4.633109E-01	9.886887E-01	3.769336E-03
2568 546	4.781440E-01	9.897056E-01	3.423302E-03
2569 547	4.927483E-01	9.899849E-01	3.108313E-03
2570 548	5.073315E-01	9.899624E-01	2.821650E-03
2571 549	5.221315E-01	9.900731E-01	2.560830E-03
2572 550	5.374170E-01	9.907500E-01	2.323578E-03
2573 551	5.534217E-01	9.922826E-01	2.107847E-03
2574 552	5.701242E-01	9.943837E-01	1.911867E-03
2575 553	5.874093E-01	9.966221E-01	1.734006E-03
2576 554	6.051269E-01	9.985649E-01	1.572736E-03
2577 555	6.230892E-01	9.997775E-01	1.426627E-03
2578 556	6.410999E-01	9.999440E-01	1.294325E-03
2579 557	6.590659E-01	9.992200E-01	1.174475E-03
2580 558	6.769436E-01	9.978793E-01	1.065842E-03
2581 559	6.947143E-01	9.961934E-01	9.673215E-04
2582 560	7.123849E-01	9.944304E-01	8.779264E-04
2583 561	7.299978E-01	9.927831E-01	7.967847E-04
2584 562	7.476478E-01	9.911578E-01	7.231502E-04
2585 563	7.654250E-01	9.893925E-01	6.563501E-04
2586 564	7.834009E-01	9.873288E-01	5.957678E-04
2587 565	8.016277E-01	9.848127E-01	5.408385E-04
2588 566	8.201041E-01	9.817253E-01	4.910441E-04
2589 567	8.386843E-01	9.780714E-01	4.459046E-04
2590 568	8.571936E-01	9.738860E-01	4.049826E-04
2591 569	8.754652E-01	9.692028E-01	3.678818E-04
2592 570	8.933408E-01	9.640545E-01	3.342429E-04
2593 571	9.106772E-01	9.584409E-01	3.037407E-04
2594 572	9.273554E-01	9.522379E-01	2.760809E-04
2595 573	9.432502E-01	9.452968E-01	2.509970E-04
2596 574	9.582244E-01	9.374773E-01	2.282474E-04
2597 575	9.721304E-01	9.286495E-01	2.076129E-04
2598 576	9.849237E-01	9.187953E-01	1.888948E-04
2599 577	9.970067E-01	9.083014E-01	1.719127E-04
2600 578	1.008907E+00	8.976352E-01	1.565030E-04
2601 579	1.021163E+00	8.872401E-01	1.425177E-04
2602 580	1.034327E+00	8.775360E-01	1.298230E-04
2603 581	1.048753E+00	8.687920E-01	1.182974E-04
2604 582	1.063937E+00	8.607474E-01	1.078310E-04
2605 583	1.079166E+00	8.530233E-01	9.832455E-05
2606 584	1.093723E+00	8.452535E-01	8.968787E-05
2607 585	1.106886E+00	8.370838E-01	8.183954E-05
2608 586	1.118106E+00	8.282409E-01	7.470582E-05
2609 587	1.127493E+00	8.187320E-01	6.821991E-05
2610 588	1.135317E+00	8.086352E-01	6.232132E-05
2611 589	1.141838E+00	7.980296E-01	5.695534E-05
2612 590	1.147304E+00	7.869950E-01	5.207245E-05
2613 591	1.151897E+00	7.756040E-01	4.762781E-05
2614 592	1.155582E+00	7.638996E-01	4.358082E-05
2615 593	1.158284E+00	7.519157E-01	3.989468E-05
2616 594	1.159934E+00	7.396832E-01	3.653612E-05
2617 595	1.160477E+00	7.272309E-01	3.347499E-05
2618 596	1.159890E+00	7.145878E-01	3.068400E-05
2619 597	1.158259E+00	7.017926E-01	2.813839E-05
2620 598	1.155692E+00	6.888866E-01	2.581574E-05
2621 599	1.152293E+00	6.759103E-01	2.369574E-05
2622 600	1.148163E+00	6.629035E-01	2.175998E-05
2623 601	1.143345E+00	6.498911E-01	1.999179E-05
2624 602	1.137685E+00	6.368410E-01	1.837603E-05
2625 603	1.130993E+00	6.237092E-01	1.689896E-05
2626 604	1.123097E+00	6.104541E-01	1.554815E-05
2627 605	1.113846E+00	5.970375E-01	1.431231E-05
2628 606	1.103152E+00	5.834395E-01	1.318119E-05
2629 607	1.091121E+00	5.697044E-01	1.214548E-05
2630 608	1.077902E+00	5.558892E-01	1.119673E-05
2631 609	1.063644E+00	5.420475E-01	1.032727E-05
2632 610	1.048485E+00	5.282296E-01	9.530130E-06
2633 611	1.032546E+00	5.144746E-01	8.798979E-06
2634 612	1.015870E+00	5.007881E-01	8.128065E-06
2635 613	9.984859E-01	4.871687E-01	7.512160E-06
2636 614	9.804227E-01	4.736160E-01	6.946506E-06
2637 615	9.617111E-01	4.601308E-01	6.426776E-06
2638 616	9.424119E-01	4.467260E-01	0.000000E+00
2639 617	9.227049E-01	4.334589E-01	0.000000E+00
2640 618	9.027804E-01	4.203919E-01	0.000000E+00
2641 619	8.828123E-01	4.075810E-01	0.000000E+00
2642 620	8.629581E-01	3.950755E-01	0.000000E+00
2643 621	8.432731E-01	3.828894E-01	0.000000E+00
2644 622	8.234742E-01	3.709190E-01	0.000000E+00
2645 623	8.032342E-01	3.590447E-01	0.000000E+00
2646 624	7.822715E-01	3.471615E-01	0.000000E+00
2647 625	7.603498E-01	3.351794E-01	0.000000E+00
2648 626	7.373739E-01	3.230562E-01	0.000000E+00
2649 627	7.136470E-01	3.108859E-01	0.000000E+00
2650 628	6.895336E-01	2.987840E-01	0.000000E+00
2651 629	6.653567E-01	2.868527E-01	0.000000E+00
2652 630	6.413984E-01	2.751807E-01	0.000000E+00
2653 631	6.178723E-01	2.638343E-01	0.000000E+00
2654 632	5.948484E-01	2.528330E-01	0.000000E+00
2655 633	5.723600E-01	2.421835E-01	0.000000E+00
2656 634	5.504353E-01	2.318904E-01	0.000000E+00
2657 635	5.290979E-01	2.219564E-01	0.000000E+00
2658 636	5.083728E-01	2.123826E-01	0.000000E+00
2659 637	4.883006E-01	2.031698E-01	0.000000E+00
2660 638	4.689171E-01	1.943179E-01	0.000000E+00
2661 639	4.502486E-01	1.858250E-01	0.000000E+00
2662 640	4.323126E-01	1.776882E-01	0.000000E+00
2663 641	4.150790E-01	1.698926E-01	0.000000E+00
2664 642	3.983657E-01	1.623822E-01	0.000000E+00
2665 643	3.819846E-01	1.550986E-01	0.000000E+00
2666 644	3.657821E-01	1.479918E-01	0.000000E+00
2667 645	3.496358E-01	1.410203E-01	0.000000E+00
2668 646	3.334937E-01	1.341614E-01	0.000000E+00
2669 647	3.174776E-01	1.274401E-01	0.000000E+00
2670 648	3.017298E-01	1.208887E-01	0.000000E+00
2671 649	2.863684E-01	1.145345E-01	0.000000E+00
2672 650	2.714900E-01	1.083996E-01	0.000000E+00
2673 651	2.571632E-01	1.025007E-01	0.000000E+00
2674 652	2.434102E-01	9.684588E-02	0.000000E+00
2675 653	2.302389E-01	9.143944E-02	0.000000E+00
2676 654	2.176527E-01	8.628318E-02	0.000000E+00
2677 655	2.056507E-01	8.137687E-02	0.000000E+00
2678 656	1.942251E-01	7.671708E-02	0.000000E+00
2679 657	1.833530E-01	7.229404E-02	0.000000E+00
2680 658	1.730097E-01	6.809696E-02	0.000000E+00
2681 659	1.631716E-01	6.411549E-02	0.000000E+00
2682 660	1.538163E-01	6.033976E-02	0.000000E+00
2683 661	1.449230E-01	5.676054E-02	0.000000E+00
2684 662	1.364729E-01	5.336992E-02	0.000000E+00
2685 663	1.284483E-01	5.016027E-02	0.000000E+00
2686 664	1.208320E-01	4.712405E-02	0.000000E+00
2687 665	1.136072E-01	4.425383E-02	0.000000E+00
2688 666	1.067579E-01	4.154205E-02	0.000000E+00
2689 667	1.002685E-01	3.898042E-02	0.000000E+00
2690 668	9.412394E-02	3.656091E-02	0.000000E+00
2691 669	8.830929E-02	3.427597E-02	0.000000E+00
2692 670	8.281010E-02	3.211852E-02	0.000000E+00
2693 671	7.761208E-02	3.008192E-02	0.000000E+00
2694 672	7.270064E-02	2.816001E-02	0.000000E+00
2695 673	6.806167E-02	2.634698E-02	0.000000E+00
2696 674	6.368176E-02	2.463731E-02	0.000000E+00
2697 675	5.954815E-02	2.302574E-02	0.000000E+00
2698 676	5.564917E-02	2.150743E-02	0.000000E+00
2699 677	5.197543E-02	2.007838E-02	0.000000E+00
2700 678	4.851788E-02	1.873474E-02	0.000000E+00
2701 679	4.526737E-02	1.747269E-02	0.000000E+00
2702 680	4.221473E-02	1.628841E-02	0.000000E+00
2703 681	3.934954E-02	1.517767E-02	0.000000E+00
2704 682	3.665730E-02	1.413473E-02	0.000000E+00
2705 683	3.412407E-02	1.315408E-02	0.000000E+00
2706 684	3.173768E-02	1.223092E-02	0.000000E+00
2707 685	2.948752E-02	1.136106E-02	0.000000E+00
2708 686	2.736717E-02	1.054190E-02	0.000000E+00
2709 687	2.538113E-02	9.775050E-03	0.000000E+00
2710 688	2.353356E-02	9.061962E-03	0.000000E+00
2711 689	2.182558E-02	8.402962E-03	0.000000E+00
2712 690	2.025590E-02	7.797457E-03	0.000000E+00
2713 691	1.881892E-02	7.243230E-03	0.000000E+00
2714 692	1.749930E-02	6.734381E-03	0.000000E+00
2715 693	1.628167E-02	6.265001E-03	0.000000E+00
2716 694	1.515301E-02	5.830085E-03	0.000000E+00
2717 695	1.410230E-02	5.425391E-03	0.000000E+00
2718 696	1.312106E-02	5.047634E-03	0.000000E+00
2719 697	1.220509E-02	4.695140E-03	0.000000E+00
2720 698	1.135114E-02	4.366592E-03	0.000000E+00
2721 699	1.055593E-02	4.060685E-03	0.000000E+00
2722 700	9.816228E-03	3.776140E-03	0.000000E+00
2723 701	9.128517E-03	3.511578E-03	0.000000E+00
2724 702	8.488116E-03	3.265211E-03	0.000000E+00
2725 703	7.890589E-03	3.035344E-03	0.000000E+00
2726 704	7.332061E-03	2.820496E-03	0.000000E+00
2727 705	6.809147E-03	2.619372E-03	0.000000E+00
2728 706	6.319204E-03	2.430960E-03	0.000000E+00
2729 707	5.861036E-03	2.254796E-03	0.000000E+00
2730 708	5.433624E-03	2.090489E-03	0.000000E+00
2731 709	5.035802E-03	1.937586E-03	0.000000E+00
2732 710	4.666298E-03	1.795595E-03	0.000000E+00
2733 711	4.323750E-03	1.663989E-03	0.000000E+00
2734 712	4.006709E-03	1.542195E-03	0.000000E+00
2735 713	3.713708E-03	1.429639E-03	0.000000E+00
2736 714	3.443294E-03	1.325752E-03	0.000000E+00
2737 715	3.194041E-03	1.229980E-03	0.000000E+00
2738 716	2.964424E-03	1.141734E-03	0.000000E+00
2739 717	2.752492E-03	1.060269E-03	0.000000E+00
2740 718	2.556406E-03	9.848854E-04	0.000000E+00
2741 719	2.374564E-03	9.149703E-04	0.000000E+00
2742 720	2.205568E-03	8.499903E-04	0.000000E+00
2743 721	2.048294E-03	7.895158E-04	0.000000E+00
2744 722	1.902113E-03	7.333038E-04	0.000000E+00
2745 723	1.766485E-03	6.811458E-04	0.000000E+00
2746 724	1.640857E-03	6.328287E-04	0.000000E+00
2747 725	1.524672E-03	5.881375E-04	0.000000E+00
2748 726	1.417322E-03	5.468389E-04	0.000000E+00
2749 727	1.318031E-03	5.086349E-04	0.000000E+00
2750 728	1.226059E-03	4.732403E-04	0.000000E+00
2751 729	1.140743E-03	4.404016E-04	0.000000E+00
2752 730	1.061495E-03	4.098928E-04	0.000000E+00
2753 731	9.877949E-04	3.815137E-04	0.000000E+00
2754 732	9.191847E-04	3.550902E-04	0.000000E+00
2755 733	8.552568E-04	3.304668E-04	0.000000E+00
2756 734	7.956433E-04	3.075030E-04	0.000000E+00
2757 735	7.400120E-04	2.860718E-04	0.000000E+00
2758 736	6.880980E-04	2.660718E-04	0.000000E+00
2759 737	6.397864E-04	2.474586E-04	0.000000E+00
2760 738	5.949726E-04	2.301919E-04	0.000000E+00
2761 739	5.535291E-04	2.142225E-04	0.000000E+00
2762 740	5.153113E-04	1.994949E-04	0.000000E+00
2763 741	4.801234E-04	1.859336E-04	0.000000E+00
2764 742	4.476245E-04	1.734067E-04	0.000000E+00
2765 743	4.174846E-04	1.617865E-04	0.000000E+00
2766 744	3.894221E-04	1.509641E-04	0.000000E+00
2767 745	3.631969E-04	1.408466E-04	0.000000E+00
2768 746	3.386279E-04	1.313642E-04	0.000000E+00
2769 747	3.156452E-04	1.224905E-04	0.000000E+00
2770 748	2.941966E-04	1.142060E-04	0.000000E+00
2771 749	2.742235E-04	1.064886E-04	0.000000E+00
2772 750	2.556624E-04	9.931439E-05	0.000000E+00
2773 751	2.384390E-04	9.265512E-05	0.000000E+00
2774 752	2.224525E-04	8.647225E-05	0.000000E+00
2775 753	2.076036E-04	8.072780E-05	0.000000E+00
2776 754	1.938018E-04	7.538716E-05	0.000000E+00
2777 755	1.809649E-04	7.041878E-05	0.000000E+00
2778 756	1.690167E-04	6.579338E-05	0.000000E+00
2779 757	1.578839E-04	6.148250E-05	0.000000E+00
2780 758	1.474993E-04	5.746008E-05	0.000000E+00
2781 759	1.378026E-04	5.370272E-05	0.000000E+00
2782 760	1.287394E-04	5.018934E-05	0.000000E+00
2783 761	1.202644E-04	4.690245E-05	0.000000E+00
2784 762	1.123502E-04	4.383167E-05	0.000000E+00
2785 763	1.049725E-04	4.096780E-05	0.000000E+00
2786 764	9.810596E-05	3.830123E-05	0.000000E+00
2787 765	9.172477E-05	3.582218E-05	0.000000E+00
2788 766	8.579861E-05	3.351903E-05	0.000000E+00
2789 767	8.028174E-05	3.137419E-05	0.000000E+00
2790 768	7.513013E-05	2.937068E-05	0.000000E+00
2791 769	7.030565E-05	2.749380E-05	0.000000E+00
2792 770	6.577532E-05	2.573083E-05	0.000000E+00
2793 771	6.151508E-05	2.407249E-05	0.000000E+00
2794 772	5.752025E-05	2.251704E-05	0.000000E+00
2795 773	5.378813E-05	2.106350E-05	0.000000E+00
2796 774	5.031350E-05	1.970991E-05	0.000000E+00
2797 775	4.708916E-05	1.845353E-05	0.000000E+00
2798 776	4.410322E-05	1.728979E-05	0.000000E+00
2799 777	4.133150E-05	1.620928E-05	0.000000E+00
2800 778	3.874992E-05	1.520262E-05	0.000000E+00
2801 779	3.633762E-05	1.426169E-05	0.000000E+00
2802 780	3.407653E-05	1.337946E-05	0.000000E+00
2803 781	3.195242E-05	1.255038E-05	0.000000E+00
2804 782	2.995808E-05	1.177169E-05	0.000000E+00
2805 783	2.808781E-05	1.104118E-05	0.000000E+00
2806 784	2.633581E-05	1.035662E-05	0.000000E+00
2807 785	2.469630E-05	9.715798E-06	0.000000E+00
2808 786	2.316311E-05	9.116316E-06	0.000000E+00
2809 787	2.172855E-05	8.555201E-06	0.000000E+00
2810 788	2.038519E-05	8.029561E-06	0.000000E+00
2811 789	1.912625E-05	7.536768E-06	0.000000E+00
2812 790	1.794555E-05	7.074424E-06	0.000000E+00
2813 791	1.683776E-05	6.640464E-06	0.000000E+00
2814 792	1.579907E-05	6.233437E-06	0.000000E+00
2815 793	1.482604E-05	5.852035E-06	0.000000E+00
2816 794	1.391527E-05	5.494963E-06	0.000000E+00
2817 795	1.306345E-05	5.160948E-06	0.000000E+00
2818 796	1.226720E-05	4.848687E-06	0.000000E+00
2819 797	1.152279E-05	4.556705E-06	0.000000E+00
2820 798	1.082663E-05	4.283580E-06	0.000000E+00
2821 799	1.017540E-05	4.027993E-06	0.000000E+00
2822 800	9.565993E-06	3.788729E-06	0.000000E+00
2823 801	8.995405E-06	3.564599E-06	0.000000E+00
2824 802	8.460253E-06	3.354285E-06	0.000000E+00
2825 803	7.957382E-06	3.156557E-06	0.000000E+00
2826 804	7.483997E-06	2.970326E-06	0.000000E+00
2827 805	7.037621E-06	2.794625E-06	0.000000E+00
2828 806	6.616311E-06	2.628701E-06	0.000000E+00
2829 807	6.219265E-06	2.472248E-06	0.000000E+00
2830 808	5.845844E-06	2.325030E-06	0.000000E+00
2831 809	5.495311E-06	2.186768E-06	0.000000E+00
2832 810	5.166853E-06	2.057152E-06	0.000000E+00
2833 811	4.859511E-06	1.935813E-06	0.000000E+00
2834 812	4.571973E-06	1.822239E-06	0.000000E+00
2835 813	4.302920E-06	1.715914E-06	0.000000E+00
2836 814	4.051121E-06	1.616355E-06	0.000000E+00
2837 815	3.815429E-06	1.523114E-06	0.000000E+00
2838 816	3.594719E-06	1.435750E-06	0.000000E+00
2839 817	3.387736E-06	1.353771E-06	0.000000E+00
2840 818	3.193301E-06	1.276714E-06	0.000000E+00
2841 819	3.010363E-06	1.204166E-06	0.000000E+00
2842 820	2.837980E-06	1.135758E-06	0.000000E+00
2843 821	2.675365E-06	1.071181E-06	0.000000E+00
2844 822	2.522020E-06	1.010243E-06	0.000000E+00
2845 823	2.377511E-06	9.527779E-07	0.000000E+00
2846 824	2.241417E-06	8.986224E-07	0.000000E+00
2847 825	2.113325E-06	8.476168E-07	0.000000E+00
2848 826	1.992830E-06	7.996052E-07	0.000000E+00
2849 827	1.879542E-06	7.544361E-07	0.000000E+00
2850 828	1.773083E-06	7.119624E-07	0.000000E+00
2851 829	1.673086E-06	6.720421E-07	0.000000E+00
2852 830	1.579199E-06	6.345380E-07	0.000000E+00
2853 #endif /* NEVER */
2854 #endif /* !SALONEINSTLIB */
2855 
2856 /* Return pointers to three xpsects with a standard observer weighting curves */
2857 /* return 0 on sucecss, nz if not matched */
2858 int standardObserver(
2859 xspect *sp[3],				/* Return 3 pointers */
2860 icxObserverType obType		/* Type of observer */
2861 ) {
2862 	switch (obType) {
2863     	case icxOT_custom:
2864 			return 1;
2865     	case icxOT_none:
2866 			return 1;
2867     	case icxOT_default:
2868     	case icxOT_CIE_1931_2:
2869 			sp[0] = &ob_CIE_1931_2[0];
2870 			sp[1] = &ob_CIE_1931_2[1];
2871 			sp[2] = &ob_CIE_1931_2[2];
2872 			return 0;
2873     	case icxOT_CIE_1964_10:
2874 			sp[0] = &ob_CIE_1964_10[0];
2875 			sp[1] = &ob_CIE_1964_10[1];
2876 			sp[2] = &ob_CIE_1964_10[2];
2877 			return 0;
2878 #ifndef SALONEINSTLIB
2879     	case icxOT_Stiles_Burch_2:
2880 			sp[0] = &ob_Stiles_Burch_2[0];
2881 			sp[1] = &ob_Stiles_Burch_2[1];
2882 			sp[2] = &ob_Stiles_Burch_2[2];
2883 			return 0;
2884     	case icxOT_Judd_Voss_2:
2885 			sp[0] = &ob_Judd_Voss_2[0];
2886 			sp[1] = &ob_Judd_Voss_2[1];
2887 			sp[2] = &ob_Judd_Voss_2[2];
2888 			return 0;
2889     	case icxOT_CIE_1964_10c:
2890 			sp[0] = &ob_CIE_1964_10c[0];
2891 			sp[1] = &ob_CIE_1964_10c[1];
2892 			sp[2] = &ob_CIE_1964_10c[2];
2893 			return 0;
2894     	case icxOT_Shaw_Fairchild_2:
2895 			sp[0] = &ob_Shaw_Fairchild_2[0];
2896 			sp[1] = &ob_Shaw_Fairchild_2[1];
2897 			sp[2] = &ob_Shaw_Fairchild_2[2];
2898 			return 0;
2899     	case icxOT_EBU_2012:
2900 			sp[0] = &ob_EBU_2012[0];
2901 			sp[1] = &ob_EBU_2012[1];
2902 			sp[2] = &ob_EBU_2012[2];
2903 			return 0;
2904 #endif /* !SALONEINSTLIB */
2905 		default:
2906 			return 1;
2907 	}
2908 }
2909 
2910 /* Return a string describing the standard observer */
standardObserverDescription(icxObserverType obType)2911 char *standardObserverDescription(icxObserverType obType) {
2912 	switch (obType) {
2913     	case icxOT_custom:
2914 			return "Custom observer";
2915     	case icxOT_none:
2916 			return "No observer";
2917     	case icxOT_default:
2918     	case icxOT_CIE_1931_2:
2919 			return "CIE 1931 2 degree observer";
2920     	case icxOT_CIE_1964_10:
2921 			return "CIE 1964 10 degree observer";
2922 #ifndef SALONEINSTLIB
2923     	case icxOT_Stiles_Burch_2:
2924 			return "Stiles & Burch 1955 2 degree observer (aligned)";
2925     	case icxOT_Judd_Voss_2:
2926 			return "Judd & Voss 1978 2 degree observer";
2927     	case icxOT_CIE_1964_10c:
2928 			return "CIE 1964 10 degree observer (aligned)";
2929     	case icxOT_Shaw_Fairchild_2:
2930 			return "Shaw & Fairchild 1997 2 degree observer";
2931     	case icxOT_EBU_2012:
2932 			return "EBU Standard Camera 2012";
2933 #endif /* !SALONEINSTLIB */
2934 	}
2935 	return "Unknown observer";
2936 }
2937 
2938 
2939 #ifndef SALONEINSTLIB
2940 /* ----------------------------------- */
2941 /* Standard refelective sample spectra */
2942 
2943 /* Ra CRI Test Color Samples */
2944 static xspect CIE1995_TCS[] = {
2945 
2946 	/* TCS01  7.5 R 6/4  Light greyish red */
2947 	{
2948 		95, 360.0, 830.0,	/* 95 bands from 360 to 830 nm in 5nm steps */
2949 		1.0,				/* Scale factor */
2950 
2951 		{
2952 			0.12, 0.14, 0.16, 0.19, 0.22, 0.24, 0.25, 0.26, 0.26, 0.25,
2953 			0.25, 0.25, 0.24, 0.24, 0.24, 0.23, 0.23, 0.23, 0.23, 0.22,
2954 			0.22, 0.22, 0.22, 0.21, 0.21, 0.21, 0.22, 0.22, 0.22, 0.23,
2955 			0.23, 0.23, 0.23, 0.23, 0.23, 0.23, 0.24, 0.25, 0.25, 0.26,
2956 			0.27, 0.28, 0.3, 0.32, 0.34, 0.37, 0.39, 0.41, 0.42, 0.44,
2957 			0.44, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45,
2958 			0.45, 0.45, 0.45, 0.45, 0.46, 0.46, 0.46, 0.46, 0.46, 0.46,
2959 			0.46, 0.47, 0.47, 0.47, 0.47, 0.47, 0.47, 0.47, 0.47, 0.47,
2960 			0.47, 0.47, 0.47, 0.47, 0.47, 0.47, 0.47, 0.47, 0.47, 0.47,
2961 			0.47, 0.47, 0.47, 0.46, 0.46
2962 		}
2963 	},
2964 	/* TCS02  5 Y6/4  Dark greyish yellow */
2965 	{
2966 		95, 360.0, 830.0,	/* 95 bands from 360 to 830 nm in 5nm steps */
2967 		1.0,				/* Scale factor */
2968 
2969 		{
2970 			0.05, 0.06, 0.06, 0.06, 0.07, 0.08, 0.09, 0.1, 0.11, 0.12,
2971 			0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.13, 0.13,
2972 			0.13, 0.13, 0.14, 0.14, 0.15, 0.16, 0.17, 0.19, 0.21, 0.23,
2973 			0.24, 0.25, 0.26, 0.26, 0.27, 0.27, 0.27, 0.28, 0.28, 0.29,
2974 			0.3, 0.31, 0.32, 0.33, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34,
2975 			0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34,
2976 			0.33, 0.33, 0.33, 0.33, 0.33, 0.33, 0.33, 0.33, 0.33, 0.33,
2977 			0.33, 0.33, 0.32, 0.32, 0.32, 0.32, 0.32, 0.32, 0.32, 0.32,
2978 			0.32, 0.32, 0.32, 0.31, 0.31, 0.31, 0.31, 0.31, 0.31, 0.31,
2979 			0.31, 0.31, 0.31, 0.31, 0.31
2980 		}
2981 	},
2982 	/* TCS03  5 GY 6/8  Strong yellow green */
2983 	{
2984 		95, 360.0, 830.0,	/* 95 bands from 360 to 830 nm in 5nm steps */
2985 		1.0,				/* Scale factor */
2986 
2987 		{
2988 			0.06, 0.06, 0.06, 0.06, 0.07, 0.07, 0.07, 0.07, 0.07, 0.07,
2989 			0.07, 0.07, 0.07, 0.07, 0.07, 0.07, 0.07, 0.07, 0.07, 0.08,
2990 			0.08, 0.08, 0.09, 0.09, 0.11, 0.13, 0.15, 0.17, 0.2, 0.22,
2991 			0.24, 0.26, 0.28, 0.3, 0.34, 0.37, 0.39, 0.4, 0.4, 0.39,
2992 			0.38, 0.37, 0.35, 0.33, 0.32, 0.3, 0.29, 0.27, 0.26, 0.26,
2993 			0.25, 0.25, 0.24, 0.24, 0.23, 0.22, 0.22, 0.22, 0.22, 0.22,
2994 			0.22, 0.22, 0.23, 0.24, 0.25, 0.27, 0.29, 0.31, 0.34, 0.37,
2995 			0.39, 0.41, 0.43, 0.45, 0.46, 0.47, 0.48, 0.49, 0.49, 0.5,
2996 			0.5, 0.5, 0.51, 0.51, 0.52, 0.52, 0.52, 0.53, 0.53, 0.54,
2997 			0.54, 0.54, 0.55, 0.55, 0.56
2998 		}
2999 	},
3000 	/* TCS04  2.5 G 6/6  Moderate yellowish green */
3001 	{
3002 		95, 360.0, 830.0,	/* 95 bands from 360 to 830 nm in 5nm steps */
3003 		1.0,				/* Scale factor */
3004 
3005 		{
3006 			0.06, 0.06, 0.06, 0.07, 0.07, 0.08, 0.09, 0.11, 0.12, 0.12,
3007 			0.12, 0.13, 0.13, 0.13, 0.14, 0.14, 0.14, 0.15, 0.16, 0.17,
3008 			0.19, 0.21, 0.23, 0.25, 0.28, 0.31, 0.33, 0.35, 0.37, 0.38,
3009 			0.39, 0.39, 0.4, 0.39, 0.39, 0.38, 0.37, 0.35, 0.34, 0.33,
3010 			0.31, 0.3, 0.28, 0.26, 0.25, 0.23, 0.21, 0.2, 0.19, 0.18,
3011 			0.17, 0.16, 0.16, 0.16, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15,
3012 			0.15, 0.15, 0.15, 0.15, 0.16, 0.16, 0.17, 0.17, 0.17, 0.17,
3013 			0.17, 0.17, 0.17, 0.16, 0.16, 0.17, 0.17, 0.17, 0.18, 0.18,
3014 			0.19, 0.19, 0.19, 0.19, 0.2, 0.2, 0.2, 0.21, 0.22, 0.23,
3015 			0.23, 0.24, 0.25, 0.26, 0.27
3016 		}
3017 	},
3018 	/* TCS05  10 BG 6/4  Light bluish green */
3019 	{
3020 		95, 360.0, 830.0,	/* 95 bands from 360 to 830 nm in 5nm steps */
3021 		1.0,				/* Scale factor */
3022 
3023 		{
3024 			0.14, 0.19, 0.23, 0.27, 0.3, 0.31, 0.31, 0.31, 0.31, 0.32,
3025 			0.32, 0.32, 0.33, 0.33, 0.33, 0.34, 0.35, 0.35, 0.36, 0.37,
3026 			0.38, 0.39, 0.4, 0.41, 0.42, 0.42, 0.42, 0.42, 0.41, 0.41,
3027 			0.4, 0.4, 0.39, 0.38, 0.37, 0.36, 0.35, 0.34, 0.33, 0.32,
3028 			0.31, 0.3, 0.28, 0.27, 0.26, 0.25, 0.23, 0.22, 0.21, 0.2,
3029 			0.19, 0.19, 0.19, 0.18, 0.18, 0.18, 0.18, 0.18, 0.18, 0.18,
3030 			0.18, 0.18, 0.18, 0.18, 0.19, 0.19, 0.19, 0.2, 0.2, 0.2,
3031 			0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.21,
3032 			0.21, 0.21, 0.22, 0.22, 0.22, 0.22, 0.23, 0.23, 0.24, 0.24,
3033 			0.25, 0.26, 0.27, 0.27, 0.28
3034 		}
3035 	},
3036 	/* TCS06  5 PB 6/8  Light blue */
3037 	{
3038 		95, 360.0, 830.0,	/* 95 bands from 360 to 830 nm in 5nm steps */
3039 		1.0,				/* Scale factor */
3040 
3041 		{
3042 			0.08, 0.08, 0.09, 0.11, 0.15, 0.2, 0.27, 0.34, 0.41, 0.46,
3043 			0.49, 0.51, 0.52, 0.52, 0.53, 0.54, 0.54, 0.55, 0.56, 0.56,
3044 			0.55, 0.55, 0.54, 0.53, 0.52, 0.5, 0.49, 0.47, 0.45, 0.43,
3045 			0.41, 0.4, 0.38, 0.36, 0.34, 0.33, 0.31, 0.29, 0.28, 0.27,
3046 			0.25, 0.24, 0.23, 0.23, 0.23, 0.22, 0.22, 0.22, 0.22, 0.22,
3047 			0.22, 0.22, 0.22, 0.23, 0.23, 0.24, 0.24, 0.25, 0.26, 0.26,
3048 			0.27, 0.27, 0.28, 0.28, 0.28, 0.29, 0.29, 0.3, 0.3, 0.31,
3049 			0.33, 0.34, 0.35, 0.36, 0.38, 0.39, 0.4, 0.41, 0.43, 0.44,
3050 			0.45, 0.46, 0.47, 0.48, 0.49, 0.49, 0.5, 0.51, 0.51, 0.52,
3051 			0.52, 0.53, 0.53, 0.53, 0.54
3052 		}
3053 	},
3054 	/* TCS07  2.5 P 6/8 Y6/4  Light violet */
3055 	{
3056 		95, 360.0, 830.0,	/* 95 bands from 360 to 830 nm in 5nm steps */
3057 		1.0,				/* Scale factor */
3058 
3059 		{
3060 			0.15, 0.18, 0.22, 0.29, 0.38, 0.46, 0.52, 0.55, 0.55, 0.56,
3061 			0.56, 0.56, 0.56, 0.56, 0.56, 0.55, 0.54, 0.54, 0.52, 0.51,
3062 			0.49, 0.47, 0.45, 0.43, 0.41, 0.39, 0.36, 0.34, 0.32, 0.31,
3063 			0.3, 0.29, 0.28, 0.27, 0.27, 0.26, 0.26, 0.26, 0.26, 0.26,
3064 			0.26, 0.26, 0.26, 0.25, 0.25, 0.26, 0.27, 0.28, 0.3, 0.32,
3065 			0.34, 0.36, 0.38, 0.39, 0.4, 0.41, 0.42, 0.43, 0.44, 0.45,
3066 			0.45, 0.46, 0.46, 0.47, 0.47, 0.47, 0.47, 0.48, 0.48, 0.49,
3067 			0.5, 0.5, 0.51, 0.52, 0.53, 0.53, 0.54, 0.55, 0.55, 0.56,
3068 			0.57, 0.57, 0.58, 0.58, 0.58, 0.58, 0.59, 0.59, 0.59, 0.59,
3069 			0.59, 0.59, 0.59, 0.59, 0.59
3070 		}
3071 	},
3072 	/* TCS08  10 P 6/8  Light reddish purple */
3073 	{
3074 		95, 360.0, 830.0,	/* 95 bands from 360 to 830 nm in 5nm steps */
3075 		1.0,				/* Scale factor */
3076 
3077 		{
3078 			0.08, 0.08, 0.08, 0.09, 0.1, 0.13, 0.17, 0.24, 0.32, 0.42,
3079 			0.46, 0.48, 0.49, 0.49, 0.48, 0.47, 0.46, 0.45, 0.44, 0.43,
3080 			0.41, 0.4, 0.38, 0.37, 0.35, 0.34, 0.33, 0.31, 0.3, 0.29,
3081 			0.28, 0.28, 0.27, 0.26, 0.26, 0.25, 0.25, 0.25, 0.25, 0.26,
3082 			0.26, 0.27, 0.27, 0.27, 0.28, 0.28, 0.3, 0.32, 0.35, 0.38,
3083 			0.43, 0.48, 0.53, 0.57, 0.6, 0.63, 0.65, 0.66, 0.68, 0.69,
3084 			0.69, 0.7, 0.71, 0.71, 0.71, 0.72, 0.72, 0.72, 0.72, 0.72,
3085 			0.72, 0.72, 0.73, 0.73, 0.73, 0.73, 0.73, 0.73, 0.73, 0.73,
3086 			0.73, 0.73, 0.73, 0.73, 0.73, 0.73, 0.73, 0.73, 0.73, 0.73,
3087 			0.73, 0.73, 0.73, 0.73, 0.73
3088 		}
3089 	},
3090 	/* TCS09  4.5 R 4/13  Strong red */
3091 	{
3092 		95, 360.0, 830.0,	/* 95 bands from 360 to 830 nm in 5nm steps */
3093 		1.0,				/* Scale factor */
3094 
3095 		{
3096 			0.069, 0.072, 0.073, 0.070, 0.066, 0.062, 0.058, 0.055, 0.052, 0.052,
3097 			0.051, 0.050, 0.050, 0.049, 0.048, 0.047, 0.046, 0.044, 0.042, 0.041,
3098 			0.038, 0.035, 0.033, 0.031, 0.030, 0.029, 0.028, 0.028, 0.028, 0.029,
3099 			0.030, 0.030, 0.031, 0.031, 0.032, 0.032, 0.033, 0.034, 0.035, 0.037,
3100 			0.041, 0.044, 0.048, 0.052, 0.060, 0.076, 0.102, 0.136, 0.190, 0.256,
3101 			0.336, 0.418, 0.505, 0.581, 0.641, 0.682, 0.717, 0.740, 0.758, 0.770,
3102 			0.781, 0.790, 0.797, 0.803, 0.809, 0.814, 0.819, 0.824, 0.828, 0.830,
3103 			0.831, 0.833, 0.835, 0.836, 0.836, 0.837, 0.838, 0.839, 0.839, 0.839,
3104 			0.839, 0.839, 0.839, 0.839, 0.839, 0.839, 0.839, 0.839, 0.839, 0.839,
3105 			0.838, 0.837, 0.837, 0.836, 0.836
3106 		}
3107 	},
3108 	/* TCS10  5 Y 8/10  Strong yellow */
3109 	{
3110 		95, 360.0, 830.0,	/* 95 bands from 360 to 830 nm in 5nm steps */
3111 		1.0,				/* Scale factor */
3112 
3113 		{
3114 			0.04, 0.04, 0.05, 0.05, 0.05, 0.05, 0.06, 0.06, 0.07, 0.07,
3115 			0.07, 0.07, 0.07, 0.07, 0.07, 0.07, 0.08, 0.08, 0.08, 0.09,
3116 			0.1, 0.1, 0.11, 0.13, 0.14, 0.16, 0.19, 0.22, 0.26, 0.31,
3117 			0.37, 0.42, 0.47, 0.51, 0.55, 0.58, 0.61, 0.63, 0.65, 0.67,
3118 			0.68, 0.69, 0.69, 0.7, 0.7, 0.7, 0.71, 0.71, 0.71, 0.71,
3119 			0.71, 0.71, 0.71, 0.71, 0.71, 0.71, 0.71, 0.71, 0.72, 0.72,
3120 			0.72, 0.72, 0.73, 0.73, 0.73, 0.74, 0.74, 0.74, 0.75, 0.75,
3121 			0.75, 0.75, 0.75, 0.75, 0.76, 0.76, 0.76, 0.76, 0.76, 0.76,
3122 			0.76, 0.76, 0.76, 0.76, 0.76, 0.76, 0.76, 0.76, 0.76, 0.76,
3123 			0.76, 0.76, 0.76, 0.76, 0.76
3124 		}
3125 	},
3126 	/* TCS11  4.5 G 5/8  Strong green */
3127 	{
3128 		95, 360.0, 830.0,	/* 95 bands from 360 to 830 nm in 5nm steps */
3129 		1.0,				/* Scale factor */
3130 
3131 		{
3132 			0.07, 0.08, 0.09, 0.1, 0.11, 0.12, 0.13, 0.13, 0.13, 0.12,
3133 			0.12, 0.11, 0.11, 0.11, 0.1, 0.1, 0.11, 0.11, 0.11, 0.12,
3134 			0.12, 0.13, 0.15, 0.17, 0.19, 0.22, 0.25, 0.29, 0.33, 0.35,
3135 			0.36, 0.35, 0.35, 0.33, 0.31, 0.29, 0.27, 0.25, 0.23, 0.21,
3136 			0.19, 0.17, 0.15, 0.14, 0.13, 0.11, 0.11, 0.1, 0.1, 0.09,
3137 			0.09, 0.09, 0.09, 0.08, 0.08, 0.08, 0.08, 0.08, 0.08, 0.08,
3138 			0.08, 0.08, 0.09, 0.09, 0.1, 0.11, 0.13, 0.14, 0.16, 0.18,
3139 			0.2, 0.22, 0.24, 0.26, 0.27, 0.28, 0.29, 0.3, 0.31, 0.31,
3140 			0.32, 0.32, 0.33, 0.33, 0.34, 0.34, 0.35, 0.35, 0.36, 0.37,
3141 			0.37, 0.38, 0.39, 0.4, 0.4
3142 		}
3143 	},
3144 	/* TCS12  3 PB 3/11  Strong blue */
3145 	{
3146 		95, 360.0, 830.0,	/* 95 bands from 360 to 830 nm in 5nm steps */
3147 		1.0,				/* Scale factor */
3148 
3149 		{
3150 			0.19, 0.18, 0.16, 0.14, 0.12, 0.1, 0.09, 0.08, 0.08, 0.07,
3151 			0.06, 0.07, 0.08, 0.09, 0.12, 0.16, 0.21, 0.26, 0.3, 0.33,
3152 			0.35, 0.35, 0.34, 0.33, 0.31, 0.28, 0.26, 0.23, 0.2, 0.18,
3153 			0.15, 0.13, 0.11, 0.09, 0.08, 0.06, 0.05, 0.04, 0.04, 0.03,
3154 			0.03, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02,
3155 			0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02,
3156 			0.02, 0.02, 0.03, 0.03, 0.04, 0.04, 0.06, 0.07, 0.1, 0.13,
3157 			0.17, 0.21, 0.26, 0.31, 0.35, 0.4, 0.45, 0.49, 0.52, 0.55,
3158 			0.58, 0.6, 0.62, 0.63, 0.65, 0.66, 0.67, 0.67, 0.68, 0.69,
3159 			0.69, 0.69, 0.7, 0.7, 0.7
3160 		}
3161 	},
3162 	/* TCS13  5 YR 8/4  Light yellowish pink */
3163 	{
3164 		95, 360.0, 830.0,	/* 95 bands from 360 to 830 nm in 5nm steps */
3165 		1.0,				/* Scale factor */
3166 
3167 		{
3168 			0.07, 0.08, 0.08, 0.09, 0.1, 0.13, 0.16, 0.21, 0.26, 0.31,
3169 			0.34, 0.35, 0.36, 0.36, 0.36, 0.37, 0.37, 0.37, 0.37, 0.37,
3170 			0.38, 0.38, 0.38, 0.39, 0.4, 0.41, 0.42, 0.43, 0.44, 0.45,
3171 			0.46, 0.47, 0.47, 0.47, 0.47, 0.48, 0.48, 0.49, 0.51, 0.53,
3172 			0.55, 0.58, 0.62, 0.65, 0.68, 0.7, 0.72, 0.73, 0.74, 0.74,
3173 			0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75,
3174 			0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75,
3175 			0.75, 0.74, 0.74, 0.74, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75,
3176 			0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75,
3177 			0.75, 0.75, 0.75, 0.75, 0.75
3178 		}
3179 	},
3180 	/* TCS14  5 GY 4/4  Moderate olive green */
3181 	{
3182 		95, 360.0, 830.0,	/* 95 bands from 360 to 830 nm in 5nm steps */
3183 		1.0,				/* Scale factor */
3184 
3185 		{
3186 			0.04, 0.04, 0.04, 0.04, 0.04, 0.04, 0.04, 0.04, 0.04, 0.04,
3187 			0.04, 0.04, 0.04, 0.04, 0.04, 0.04, 0.04, 0.05, 0.05, 0.05,
3188 			0.05, 0.05, 0.05, 0.05, 0.06, 0.06, 0.06, 0.07, 0.08, 0.08,
3189 			0.09, 0.1, 0.11, 0.12, 0.13, 0.14, 0.15, 0.15, 0.16, 0.15,
3190 			0.15, 0.14, 0.13, 0.13, 0.12, 0.11, 0.11, 0.1, 0.1, 0.1,
3191 			0.09, 0.09, 0.09, 0.09, 0.09, 0.09, 0.08, 0.08, 0.08, 0.08,
3192 			0.09, 0.09, 0.09, 0.1, 0.1, 0.11, 0.12, 0.14, 0.15, 0.17,
3193 			0.19, 0.21, 0.23, 0.24, 0.26, 0.28, 0.29, 0.31, 0.33, 0.34,
3194 			0.35, 0.37, 0.38, 0.39, 0.4, 0.41, 0.42, 0.42, 0.43, 0.43,
3195 			0.44, 0.44, 0.45, 0.45, 0.45
3196 		}
3197 	},
3198 	/* TCS15  1 YR 6/4  Asian skin - JIS standard */
3199 	{
3200 		95, 360.0, 830.0,	/* 95 bands from 360 to 830 nm in 5nm steps */
3201 		1.0,				/* Scale factor */
3202 
3203 		{
3204 			0, 0, 0, 0, 0.13, 0.14, 0.15, 0.15, 0.16, 0.16,
3205 			0.16, 0.17, 0.17, 0.18, 0.18, 0.19, 0.2, 0.21, 0.22, 0.23,
3206 			0.24, 0.24, 0.25, 0.25, 0.26, 0.26, 0.27, 0.28, 0.28, 0.29,
3207 			0.3, 0.3, 0.3, 0.29, 0.28, 0.28, 0.27, 0.28, 0.28, 0.29,
3208 			0.29, 0.29, 0.29, 0.28, 0.29, 0.31, 0.35, 0.4, 0.44, 0.47,
3209 			0.49, 0.51, 0.52, 0.54, 0.54, 0.55, 0.56, 0.57, 0.57, 0.58,
3210 			0.58, 0.59, 0.59, 0.59, 0.6, 0.6, 0.61, 0.61, 0.61, 0.61,
3211 			0.62, 0.62, 0.62, 0.62, 0.62, 0.61, 0.61, 0.61, 0.61, 0.61,
3212 			0.61, 0.61, 0.61, 0.61, 0.61, 0, 0, 0, 0, 0,
3213 			0, 0, 0, 0, 0
3214 		}
3215 	}
3216 };
3217 
3218 /* EBU TLCI ColorChecker samples */
3219 static xspect TLCI_2012_TCS[] = {
3220 
3221 	/* 1 Dark skin */
3222 	{
3223 		77, 380.0, 760.0,	/* 77 bands from 380 to 760 nm in 5nm steps */
3224 		1.0,				/* Scale factor */
3225 		{
3226 			0.05400, 0.05700, 0.06300, 0.06600, 0.07500,
3227 			0.07800, 0.07800, 0.07600, 0.07400, 0.07000,
3228 			0.06600, 0.06400, 0.06200, 0.06000, 0.05900,
3229 			0.06000, 0.05800, 0.06000, 0.06000, 0.06200,
3230 			0.05800, 0.06300, 0.06300, 0.06700, 0.06800,
3231 			0.07000, 0.07200, 0.07700, 0.07900, 0.08100,
3232 			0.08100, 0.08300, 0.08300, 0.08400, 0.08400,
3233 			0.08800, 0.09300, 0.09800, 0.10400, 0.11100,
3234 			0.12100, 0.12700, 0.13300, 0.14000, 0.14400,
3235 			0.14900, 0.15100, 0.15400, 0.16000, 0.16400,
3236 			0.17000, 0.17500, 0.17900, 0.18400, 0.19300,
3237 			0.20300, 0.21300, 0.22000, 0.23600, 0.24100,
3238 			0.24800, 0.25700, 0.26900, 0.28000, 0.28900,
3239 			0.30000, 0.31400, 0.33700, 0.34600, 0.36100,
3240 			0.38200, 0.40400, 0.42500, 0.43900, 0.46400,
3241 			0.47600, 0.49000
3242 		}
3243 	},
3244 	/* 2 Light skin */
3245 	{
3246 		77, 380.0, 760.0,	/* 77 bands from 380 to 760 nm in 5nm steps */
3247 		1.0,				/* Scale factor */
3248 		{
3249 			0.09200, 0.10900, 0.13400, 0.16100, 0.18600,
3250 			0.20000, 0.20500, 0.20600, 0.20700, 0.20900,
3251 			0.21100, 0.21300, 0.21600, 0.22100, 0.22700,
3252 			0.23700, 0.24600, 0.25900, 0.27300, 0.28500,
3253 			0.29400, 0.30400, 0.30500, 0.30900, 0.31400,
3254 			0.32300, 0.33400, 0.34000, 0.33200, 0.31600,
3255 			0.30000, 0.29200, 0.29000, 0.29500, 0.30000,
3256 			0.30200, 0.29700, 0.29500, 0.30400, 0.32800,
3257 			0.36500, 0.40900, 0.45000, 0.48800, 0.52000,
3258 			0.54000, 0.55600, 0.56600, 0.57400, 0.58200,
3259 			0.59300, 0.60200, 0.60700, 0.62500, 0.63100,
3260 			0.63900, 0.65500, 0.66100, 0.68700, 0.69300,
3261 			0.71100, 0.72200, 0.73700, 0.75700, 0.76800,
3262 			0.78600, 0.79800, 0.81500, 0.82200, 0.82300,
3263 			0.83500, 0.84500, 0.85500, 0.84800, 0.86200,
3264 			0.86100, 0.86800
3265 		}
3266 	},
3267 	/* 3 Blue sky */
3268 	{
3269 		77, 380.0, 760.0,	/* 77 bands from 380 to 760 nm in 5nm steps */
3270 		1.0,				/* Scale factor */
3271 		{
3272 			0.10500, 0.12700, 0.16400, 0.21300, 0.27100,
3273 			0.31400, 0.33300, 0.34400, 0.34500, 0.34400,
3274 			0.34600, 0.34600, 0.34700, 0.34300, 0.33700,
3275 			0.33300, 0.32700, 0.32400, 0.31900, 0.30600,
3276 			0.29000, 0.28800, 0.28000, 0.27400, 0.26500,
3277 			0.25800, 0.25000, 0.24000, 0.22900, 0.22000,
3278 			0.21200, 0.20700, 0.20300, 0.19800, 0.19300,
3279 			0.19100, 0.18700, 0.18100, 0.17400, 0.17000,
3280 			0.16700, 0.16200, 0.15800, 0.16100, 0.15600,
3281 			0.15200, 0.15000, 0.14500, 0.14200, 0.13700,
3282 			0.13300, 0.13200, 0.12600, 0.12700, 0.12100,
3283 			0.11800, 0.11500, 0.11500, 0.11200, 0.11000,
3284 			0.11000, 0.10900, 0.10800, 0.10800, 0.10600,
3285 			0.10500, 0.10500, 0.10600, 0.10600, 0.10500,
3286 			0.10700, 0.10500, 0.10600, 0.10500, 0.10800,
3287 			0.10700, 0.11000
3288 		}
3289 	},
3290 	/* 4 Foliage */
3291 	{
3292 		77, 380.0, 760.0,	/* 77 bands from 380 to 760 nm in 5nm steps */
3293 		1.0,				/* Scale factor */
3294 		{
3295 			0.05000, 0.05200, 0.05200, 0.05000, 0.05200,
3296 			0.05200, 0.05200, 0.05300, 0.05100, 0.05300,
3297 			0.05300, 0.05300, 0.05500, 0.05800, 0.05900,
3298 			0.06100, 0.06000, 0.06300, 0.06300, 0.06700,
3299 			0.06500, 0.06700, 0.06900, 0.07200, 0.07700,
3300 			0.08800, 0.10500, 0.13200, 0.15900, 0.18200,
3301 			0.19500, 0.19900, 0.19100, 0.18000, 0.16700,
3302 			0.15600, 0.14400, 0.13300, 0.13100, 0.13000,
3303 			0.12900, 0.12300, 0.11800, 0.11400, 0.11000,
3304 			0.10200, 0.10100, 0.10300, 0.10400, 0.10500,
3305 			0.10500, 0.10600, 0.10200, 0.10200, 0.10100,
3306 			0.10100, 0.10100, 0.10100, 0.10700, 0.11500,
3307 			0.13200, 0.15200, 0.18500, 0.23300, 0.28300,
3308 			0.33900, 0.38300, 0.41900, 0.44400, 0.44500,
3309 			0.46500, 0.47300, 0.47700, 0.48000, 0.48900,
3310 			0.49200, 0.49800
3311 		}
3312 	},
3313 	/* 5 Blue flower */
3314 	{
3315 		77, 380.0, 760.0,	/* 77 bands from 380 to 760 nm in 5nm steps */
3316 		1.0,				/* Scale factor */
3317 		{
3318 			0.10100, 0.12700, 0.17000, 0.23300, 0.31000,
3319 			0.37300, 0.40900, 0.42400, 0.43200, 0.43700,
3320 			0.43700, 0.43800, 0.43700, 0.43200, 0.42800,
3321 			0.42300, 0.41700, 0.41200, 0.40500, 0.39500,
3322 			0.38000, 0.37300, 0.36400, 0.35500, 0.34200,
3323 			0.33300, 0.31600, 0.29600, 0.26700, 0.24500,
3324 			0.22700, 0.21200, 0.20600, 0.20300, 0.20300,
3325 			0.20400, 0.19600, 0.19000, 0.19000, 0.19400,
3326 			0.20100, 0.21000, 0.21600, 0.22500, 0.22800,
3327 			0.23200, 0.23800, 0.24000, 0.23600, 0.23600,
3328 			0.24000, 0.24800, 0.26100, 0.28900, 0.32200,
3329 			0.36200, 0.40700, 0.44600, 0.48800, 0.51200,
3330 			0.54600, 0.54600, 0.55500, 0.56300, 0.56400,
3331 			0.57500, 0.57800, 0.58600, 0.59000, 0.58900,
3332 			0.60100, 0.60400, 0.60600, 0.60500, 0.61400,
3333 			0.61600, 0.61700
3334 		}
3335 	},
3336 	/* 6 Bluish green */
3337 	{
3338 		77, 380.0, 760.0,	/* 77 bands from 380 to 760 nm in 5nm steps */
3339 		1.0,				/* Scale factor */
3340 		{
3341 			0.10800, 0.13200, 0.16800, 0.21300, 0.26000,
3342 			0.29200, 0.30800, 0.31700, 0.32000, 0.32800,
3343 			0.33600, 0.34200, 0.35200, 0.36000, 0.37100,
3344 			0.38600, 0.40500, 0.43300, 0.46500, 0.49700,
3345 			0.52800, 0.55700, 0.57600, 0.59100, 0.58600,
3346 			0.59100, 0.58600, 0.58200, 0.56700, 0.55900,
3347 			0.54500, 0.53300, 0.51200, 0.49200, 0.47200,
3348 			0.44500, 0.42900, 0.40200, 0.38000, 0.35500,
3349 			0.33200, 0.30900, 0.28400, 0.26200, 0.24700,
3350 			0.23300, 0.22400, 0.21700, 0.21200, 0.20900,
3351 			0.20700, 0.20500, 0.20000, 0.19800, 0.19900,
3352 			0.19700, 0.19900, 0.20300, 0.21000, 0.21600,
3353 			0.21800, 0.22600, 0.23200, 0.23600, 0.23800,
3354 			0.24200, 0.24200, 0.23900, 0.23200, 0.22700,
3355 			0.22900, 0.23000, 0.23700, 0.24800, 0.25600,
3356 			0.26900, 0.27400
3357 		}
3358 	},
3359 	/* 7 Orange */
3360 	{
3361 		77, 380.0, 760.0,	/* 77 bands from 380 to 760 nm in 5nm steps */
3362 		1.0,				/* Scale factor */
3363 		{
3364 			0.05200, 0.05400, 0.05200, 0.05000, 0.05200,
3365 			0.05200, 0.05200, 0.05100, 0.05000, 0.05000,
3366 			0.05200, 0.05000, 0.05100, 0.05100, 0.05200,
3367 			0.05100, 0.05100, 0.05300, 0.05300, 0.05400,
3368 			0.05500, 0.05600, 0.05500, 0.05800, 0.06100,
3369 			0.06300, 0.06800, 0.07700, 0.08600, 0.09800,
3370 			0.12000, 0.14500, 0.17500, 0.20600, 0.23600,
3371 			0.27000, 0.30200, 0.34100, 0.37500, 0.41000,
3372 			0.44000, 0.46700, 0.48800, 0.50900, 0.51800,
3373 			0.53200, 0.54000, 0.55100, 0.55700, 0.56200,
3374 			0.56800, 0.57500, 0.58100, 0.58400, 0.58500,
3375 			0.59000, 0.60100, 0.59600, 0.60000, 0.59600,
3376 			0.60400, 0.60300, 0.60600, 0.60700, 0.60800,
3377 			0.61500, 0.61700, 0.62100, 0.62200, 0.61900,
3378 			0.62500, 0.62800, 0.63000, 0.62700, 0.63500,
3379 			0.63900, 0.64000
3380 		}
3381 	},
3382 	/* 8 Purplish blue */
3383 	{
3384 		77, 380.0, 760.0,	/* 77 bands from 380 to 760 nm in 5nm steps */
3385 		1.0,				/* Scale factor */
3386 		{
3387 			0.09400, 0.11300, 0.14100, 0.18600, 0.23500,
3388 			0.27500, 0.29700, 0.31600, 0.31700, 0.33300,
3389 			0.34600, 0.35500, 0.36800, 0.37800, 0.38100,
3390 			0.37700, 0.36800, 0.35600, 0.34000, 0.32200,
3391 			0.29600, 0.26900, 0.24100, 0.22000, 0.19700,
3392 			0.18200, 0.16600, 0.15100, 0.13800, 0.12700,
3393 			0.12000, 0.11500, 0.10800, 0.10400, 0.10100,
3394 			0.09500, 0.09000, 0.08400, 0.08200, 0.08100,
3395 			0.08100, 0.08100, 0.08100, 0.08300, 0.08300,
3396 			0.08000, 0.07900, 0.08000, 0.08100, 0.08100,
3397 			0.08400, 0.08900, 0.09200, 0.09600, 0.10300,
3398 			0.10700, 0.11200, 0.11100, 0.11200, 0.10900,
3399 			0.10400, 0.10200, 0.09900, 0.09900, 0.10000,
3400 			0.10000, 0.10300, 0.10600, 0.10900, 0.11300,
3401 			0.12200, 0.12700, 0.13800, 0.15300, 0.17300,
3402 			0.19300, 0.21500
3403 		}
3404 	},
3405 	/* 9 Moderate red */
3406 	{
3407 		77, 380.0, 760.0,	/* 77 bands from 380 to 760 nm in 5nm steps */
3408 		1.0,				/* Scale factor */
3409 		{
3410 			0.08800, 0.10200, 0.12100, 0.13600, 0.15100,
3411 			0.15300, 0.15100, 0.14400, 0.14200, 0.14100,
3412 			0.13900, 0.13500, 0.13600, 0.13500, 0.13300,
3413 			0.13200, 0.12900, 0.13000, 0.12900, 0.12700,
3414 			0.12100, 0.11800, 0.10900, 0.10500, 0.10500,
3415 			0.10400, 0.10100, 0.10000, 0.09400, 0.09100,
3416 			0.08900, 0.09200, 0.09500, 0.09700, 0.10400,
3417 			0.10900, 0.11100, 0.11300, 0.11600, 0.13400,
3418 			0.16700, 0.22300, 0.29100, 0.36200, 0.42600,
3419 			0.47400, 0.51100, 0.53700, 0.55100, 0.56200,
3420 			0.56500, 0.57000, 0.57500, 0.57400, 0.57900,
3421 			0.57700, 0.57900, 0.57700, 0.58000, 0.58100,
3422 			0.57900, 0.58100, 0.58100, 0.58300, 0.58100,
3423 			0.58100, 0.58000, 0.58600, 0.58500, 0.58400,
3424 			0.58900, 0.58700, 0.59000, 0.58200, 0.58900,
3425 			0.59200, 0.59000
3426 		}
3427 	},
3428 	/* 10 Purple */
3429 	{
3430 		77, 380.0, 760.0,	/* 77 bands from 380 to 760 nm in 5nm steps */
3431 		1.0,				/* Scale factor */
3432 		{
3433 			0.08300, 0.10000, 0.12500, 0.15400, 0.18300,
3434 			0.19800, 0.20600, 0.20700, 0.20700, 0.20100,
3435 			0.19400, 0.18400, 0.17500, 0.16300, 0.15400,
3436 			0.14200, 0.12900, 0.12000, 0.10900, 0.10200,
3437 			0.09500, 0.09000, 0.08100, 0.07700, 0.07000,
3438 			0.06700, 0.06500, 0.06300, 0.05900, 0.05800,
3439 			0.05600, 0.05300, 0.05200, 0.05200, 0.05100,
3440 			0.05300, 0.05500, 0.05600, 0.05400, 0.05200,
3441 			0.05300, 0.04900, 0.05100, 0.05500, 0.05800,
3442 			0.06300, 0.07300, 0.08700, 0.10300, 0.12000,
3443 			0.13700, 0.14900, 0.16100, 0.17500, 0.18800,
3444 			0.19700, 0.20800, 0.21800, 0.22900, 0.24100,
3445 			0.24900, 0.26200, 0.27200, 0.28400, 0.29200,
3446 			0.30400, 0.31200, 0.32500, 0.32900, 0.33300,
3447 			0.34300, 0.34600, 0.35000, 0.35000, 0.35900,
3448 			0.36000, 0.36200
3449 		}
3450 	},
3451 	/* 11 Yellow green */
3452 	{
3453 		77, 380.0, 760.0,	/* 77 bands from 380 to 760 nm in 5nm steps */
3454 		1.0,				/* Scale factor */
3455 		{
3456 			0.04500, 0.04800, 0.05000, 0.05000, 0.05400,
3457 			0.05300, 0.05300, 0.05500, 0.05300, 0.05700,
3458 			0.05900, 0.05900, 0.06200, 0.06500, 0.07000,
3459 			0.07500, 0.08100, 0.09200, 0.10200, 0.11600,
3460 			0.13600, 0.15800, 0.18500, 0.22500, 0.27400,
3461 			0.32800, 0.39000, 0.44600, 0.48500, 0.51100,
3462 			0.52900, 0.53800, 0.53900, 0.53500, 0.52600,
3463 			0.52100, 0.51100, 0.50000, 0.48400, 0.46700,
3464 			0.45000, 0.43500, 0.41200, 0.39500, 0.37700,
3465 			0.36300, 0.35200, 0.34600, 0.33900, 0.33700,
3466 			0.33700, 0.33100, 0.32600, 0.32200, 0.32300,
3467 			0.32000, 0.32500, 0.32700, 0.33400, 0.34000,
3468 			0.34700, 0.35500, 0.36200, 0.36900, 0.37300,
3469 			0.37600, 0.37500, 0.37900, 0.37200, 0.36500,
3470 			0.36700, 0.37500, 0.37900, 0.38800, 0.40300,
3471 			0.41500, 0.43000
3472 		}
3473 	},
3474 	/* 12 Orange yellow */
3475 	{
3476 		77, 380.0, 760.0,	/* 77 bands from 380 to 760 nm in 5nm steps */
3477 		1.0,				/* Scale factor */
3478 		{
3479 			0.04900, 0.05200, 0.05400, 0.05500, 0.05400,
3480 			0.05700, 0.05700, 0.05900, 0.05700, 0.05700,
3481 			0.05900, 0.05700, 0.05800, 0.06000, 0.06100,
3482 			0.06100, 0.06200, 0.06700, 0.07200, 0.08100,
3483 			0.08800, 0.09800, 0.10600, 0.11200, 0.12000,
3484 			0.13000, 0.14300, 0.16300, 0.18800, 0.21800,
3485 			0.25600, 0.30400, 0.35100, 0.39900, 0.44200,
3486 			0.47600, 0.50500, 0.53200, 0.54400, 0.56100,
3487 			0.57900, 0.53900, 0.59700, 0.60400, 0.61700,
3488 			0.61700, 0.61800, 0.62400, 0.62500, 0.63000,
3489 			0.64700, 0.63500, 0.63800, 0.64200, 0.64900,
3490 			0.65000, 0.64900, 0.65000, 0.67700, 0.65700,
3491 			0.65300, 0.65900, 0.65800, 0.66200, 0.66100,
3492 			0.66600, 0.66800, 0.67200, 0.67100, 0.66700,
3493 			0.67700, 0.67800, 0.68200, 0.67800, 0.68600,
3494 			0.69300, 0.69000
3495 		}
3496 	},
3497 	/* 13 Blue */
3498 	{
3499 		77, 380.0, 760.0,	/* 77 bands from 380 to 760 nm in 5nm steps */
3500 		1.0,				/* Scale factor */
3501 		{
3502 			0.06800, 0.08400, 0.10400, 0.12700, 0.15600,
3503 			0.17800, 0.19400, 0.20900, 0.22100, 0.23400,
3504 			0.25000, 0.26400, 0.28700, 0.30800, 0.31800,
3505 			0.32300, 0.31700, 0.30300, 0.27600, 0.25500,
3506 			0.22500, 0.19300, 0.16000, 0.13900, 0.11700,
3507 			0.10400, 0.08700, 0.07700, 0.06600, 0.06000,
3508 			0.05600, 0.05300, 0.05000, 0.04700, 0.04500,
3509 			0.04200, 0.04300, 0.04000, 0.04000, 0.03800,
3510 			0.03800, 0.03700, 0.03600, 0.03700, 0.03800,
3511 			0.03600, 0.03700, 0.03700, 0.03700, 0.03900,
3512 			0.03900, 0.04200, 0.04000, 0.04200, 0.04400,
3513 			0.04500, 0.04700, 0.04800, 0.05000, 0.04800,
3514 			0.04600, 0.05000, 0.04800, 0.05100, 0.04900,
3515 			0.05200, 0.05400, 0.05700, 0.06000, 0.06500,
3516 			0.06900, 0.07600, 0.08700, 0.10200, 0.12300,
3517 			0.14700, 0.17400
3518 		}
3519 	},
3520 	/* 14 Green */
3521 	{
3522 		77, 380.0, 760.0,	/* 77 bands from 380 to 760 nm in 5nm steps */
3523 		1.0,				/* Scale factor */
3524 		{
3525 			0.04500, 0.04800, 0.05400, 0.05400, 0.05700,
3526 			0.05900, 0.06000, 0.06000, 0.06000, 0.06200,
3527 			0.05400, 0.06400, 0.06900, 0.07000, 0.07500,
3528 			0.07900, 0.08300, 0.09000, 0.09900, 0.10900,
3529 			0.12000, 0.13200, 0.14400, 0.15800, 0.17500,
3530 			0.19600, 0.23100, 0.27200, 0.30700, 0.33800,
3531 			0.35200, 0.35700, 0.35300, 0.34100, 0.32300,
3532 			0.30500, 0.28600, 0.26500, 0.24400, 0.22400,
3533 			0.20300, 0.18000, 0.16100, 0.14400, 0.12400,
3534 			0.10800, 0.09800, 0.08900, 0.08400, 0.08000,
3535 			0.07600, 0.07500, 0.07100, 0.07100, 0.07000,
3536 			0.06700, 0.06700, 0.06700, 0.06800, 0.07000,
3537 			0.07000, 0.07400, 0.07600, 0.07900, 0.08000,
3538 			0.08200, 0.08600, 0.08500, 0.08300, 0.08100,
3539 			0.08100, 0.08100, 0.08300, 0.08600, 0.09100,
3540 			0.09400, 0.09800
3541 		}
3542 	},
3543 	/* 15 Red */
3544 	{
3545 		77, 380.0, 760.0,	/* 77 bands from 380 to 760 nm in 5nm steps */
3546 		1.0,				/* Scale factor */
3547 		{
3548 			0.04300, 0.04500, 0.04600, 0.04500, 0.04700,
3549 			0.04600, 0.04800, 0.04600, 0.04600, 0.04600,
3550 			0.04800, 0.04400, 0.04600, 0.04700, 0.04700,
3551 			0.04700, 0.04600, 0.04600, 0.04400, 0.04400,
3552 			0.04000, 0.04200, 0.03900, 0.04000, 0.04000,
3553 			0.03900, 0.04000, 0.04000, 0.03800, 0.03800,
3554 			0.03900, 0.03800, 0.04000, 0.04000, 0.04100,
3555 			0.04200, 0.04400, 0.04600, 0.04700, 0.05400,
3556 			0.06400, 0.08100, 0.11200, 0.15600, 0.21600,
3557 			0.28300, 0.35800, 0.43400, 0.49900, 0.54900,
3558 			0.58500, 0.60700, 0.62400, 0.63300, 0.65000,
3559 			0.65200, 0.65200, 0.65600, 0.66100, 0.66600,
3560 			0.66400, 0.67100, 0.67100, 0.67700, 0.67300,
3561 			0.67800, 0.68000, 0.68900, 0.68800, 0.68500,
3562 			0.69100, 0.69400, 0.69600, 0.69200, 0.69800,
3563 			0.70400, 0.70000
3564 		}
3565 	},
3566 	/* 16 Yellow */
3567 	{
3568 		77, 380.0, 760.0,	/* 77 bands from 380 to 760 nm in 5nm steps */
3569 		1.0,				/* Scale factor */
3570 		{
3571 			0.04700, 0.04700, 0.04800, 0.04700, 0.05000,
3572 			0.05200, 0.05200, 0.05100, 0.05100, 0.05300,
3573 			0.05300, 0.05300, 0.05700, 0.05600, 0.05800,
3574 			0.06000, 0.06200, 0.06700, 0.07600, 0.09000,
3575 			0.10900, 0.14200, 0.18300, 0.22800, 0.27400,
3576 			0.31900, 0.36000, 0.40500, 0.44300, 0.47500,
3577 			0.51000, 0.54400, 0.57100, 0.59400, 0.61200,
3578 			0.63000, 0.64600, 0.65600, 0.66800, 0.67700,
3579 			0.69100, 0.69600, 0.70100, 0.70200, 0.72900,
3580 			0.70100, 0.70400, 0.70700, 0.70800, 0.71300,
3581 			0.72100, 0.71600, 0.71700, 0.71800, 0.72600,
3582 			0.72900, 0.73000, 0.72800, 0.74700, 0.73900,
3583 			0.73700, 0.74300, 0.74000, 0.75600, 0.74200,
3584 			0.74900, 0.75100, 0.75300, 0.75400, 0.75000,
3585 			0.76000, 0.76200, 0.76900, 0.76200, 0.77400,
3586 			0.77600, 0.77900
3587 		}
3588 	},
3589 	/* 17 Magenta */
3590 	{
3591 		77, 380.0, 760.0,	/* 77 bands from 380 to 760 nm in 5nm steps */
3592 		1.0,				/* Scale factor */
3593 		{
3594 			0.10600, 0.12900, 0.16800, 0.22900, 0.29700,
3595 			0.34600, 0.36700, 0.37200, 0.37700, 0.37300,
3596 			0.36200, 0.35100, 0.34000, 0.32300, 0.30600,
3597 			0.29300, 0.27600, 0.25900, 0.25000, 0.23400,
3598 			0.22000, 0.20600, 0.19000, 0.17900, 0.16900,
3599 			0.16300, 0.15200, 0.14000, 0.12600, 0.11300,
3600 			0.10400, 0.09800, 0.09800, 0.10200, 0.10400,
3601 			0.10300, 0.10400, 0.10300, 0.10600, 0.11800,
3602 			0.14000, 0.17000, 0.21200, 0.25700, 0.31300,
3603 			0.35400, 0.40300, 0.45700, 0.50100, 0.54600,
3604 			0.58700, 0.61200, 0.63700, 0.65500, 0.67700,
3605 			0.68400, 0.69300, 0.69500, 0.71400, 0.71000,
3606 			0.72000, 0.71500, 0.71400, 0.73900, 0.71900,
3607 			0.72600, 0.72800, 0.73300, 0.73700, 0.73200,
3608 			0.74300, 0.74200, 0.74800, 0.74100, 0.75300,
3609 			0.75400, 0.76100
3610 		}
3611 	},
3612 	/* 18 Cyan */
3613 	{
3614 		77, 380.0, 760.0,	/* 77 bands from 380 to 760 nm in 5nm steps */
3615 		1.0,				/* Scale factor */
3616 		{
3617 			0.08500, 0.10200, 0.13000, 0.16300, 0.20100,
3618 			0.22800, 0.24700, 0.25400, 0.26200, 0.27800,
3619 			0.28200, 0.30000, 0.31900, 0.33200, 0.34800,
3620 			0.36300, 0.38200, 0.40100, 0.41900, 0.43100,
3621 			0.43800, 0.44100, 0.43800, 0.42900, 0.41500,
3622 			0.40400, 0.38100, 0.35800, 0.33900, 0.31600,
3623 			0.28800, 0.26200, 0.23600, 0.21000, 0.18600,
3624 			0.16200, 0.14200, 0.12900, 0.11600, 0.10500,
3625 			0.09900, 0.09200, 0.08800, 0.08600, 0.08100,
3626 			0.07700, 0.07800, 0.07600, 0.07600, 0.07600,
3627 			0.07600, 0.07600, 0.07600, 0.07700, 0.07800,
3628 			0.07700, 0.08100, 0.08000, 0.08100, 0.07900,
3629 			0.07900, 0.07900, 0.07700, 0.07600, 0.07500,
3630 			0.07400, 0.07400, 0.07600, 0.07700, 0.08100,
3631 			0.08400, 0.09000, 0.09800, 0.11100, 0.13000,
3632 			0.15100, 0.17900
3633 		}
3634 	},
3635 	/* 19 White */
3636 	{
3637 		77, 380.0, 760.0,	/* 77 bands from 380 to 760 nm in 5nm steps */
3638 		1.0,				/* Scale factor */
3639 		{
3640 			0.12600, 0.16900, 0.21200, 0.26400, 0.31800,
3641 			0.49100, 0.66400, 0.75700, 0.85100, 0.86800,
3642 			0.88700, 0.88800, 0.89000, 0.89300, 0.89500,
3643 			0.89600, 0.89800, 0.90000, 0.90200, 0.90000,
3644 			0.89700, 0.90400, 0.90100, 0.90000, 0.90000,
3645 			0.89800, 0.89700, 0.90000, 0.90200, 0.90200,
3646 			0.90100, 0.90000, 0.89900, 0.89600, 0.89300,
3647 			0.89500, 0.89800, 0.90000, 0.90200, 0.90400,
3648 			0.90500, 0.90600, 0.90700, 0.90500, 0.90300,
3649 			0.90400, 0.90500, 0.90700, 0.89800, 0.89700,
3650 			0.89600, 0.89800, 0.90000, 0.90000, 0.89900,
3651 			0.90100, 0.90400, 0.90400, 0.90500, 0.90200,
3652 			0.89900, 0.89900, 0.90000, 0.89900, 0.89800,
3653 			0.89800, 0.89900, 0.89800, 0.89800, 0.89900,
3654 			0.90100, 0.89800, 0.89600, 0.89500, 0.89800,
3655 			0.89900, 0.89800
3656 		}
3657 	},
3658 	/* 20 Neutral 8 */
3659 	{
3660 		77, 380.0, 760.0,	/* 77 bands from 380 to 760 nm in 5nm steps */
3661 		1.0,				/* Scale factor */
3662 		{
3663 			0.08400, 0.11300, 0.14100, 0.17600, 0.21100,
3664 			0.32700, 0.44200, 0.50400, 0.56700, 0.57800,
3665 			0.59000, 0.59100, 0.59200, 0.59400, 0.59500,
3666 			0.59600, 0.59700, 0.59900, 0.60000, 0.59900,
3667 			0.59700, 0.60200, 0.59900, 0.59900, 0.59900,
3668 			0.59700, 0.59700, 0.59900, 0.60000, 0.60000,
3669 			0.59900, 0.59900, 0.59800, 0.59600, 0.59400,
3670 			0.59500, 0.59700, 0.59900, 0.60000, 0.60200,
3671 			0.60200, 0.60300, 0.60400, 0.60200, 0.60100,
3672 			0.60200, 0.60200, 0.60400, 0.59700, 0.59700,
3673 			0.59600, 0.59700, 0.59900, 0.59900, 0.59800,
3674 			0.59900, 0.60200, 0.60200, 0.60200, 0.60000,
3675 			0.59800, 0.59800, 0.59900, 0.59800, 0.59700,
3676 			0.59700, 0.59800, 0.59700, 0.59700, 0.59800,
3677 			0.59900, 0.59700, 0.59600, 0.59500, 0.59700,
3678 			0.59800, 0.59700
3679 		}
3680 	},
3681 	/* 21 Neutral 6.5 */
3682 	{
3683 		77, 380.0, 760.0,	/* 77 bands from 380 to 760 nm in 5nm steps */
3684 		1.0,				/* Scale factor */
3685 		{
3686 			0.05100, 0.06800, 0.08500, 0.10600, 0.12800,
3687 			0.19800, 0.26700, 0.30500, 0.34200, 0.34900,
3688 			0.35700, 0.35700, 0.35800, 0.35900, 0.36000,
3689 			0.36000, 0.36100, 0.36200, 0.36300, 0.36200,
3690 			0.36100, 0.36400, 0.36200, 0.36200, 0.36200,
3691 			0.36100, 0.36100, 0.36200, 0.36300, 0.36300,
3692 			0.36200, 0.36200, 0.36100, 0.36000, 0.35900,
3693 			0.36000, 0.36100, 0.36200, 0.36300, 0.36400,
3694 			0.36400, 0.36400, 0.36500, 0.36400, 0.36300,
3695 			0.36400, 0.36400, 0.36500, 0.36100, 0.36100,
3696 			0.36000, 0.36100, 0.36200, 0.36200, 0.36100,
3697 			0.36200, 0.36400, 0.36400, 0.36400, 0.36300,
3698 			0.36100, 0.36100, 0.36200, 0.36100, 0.36100,
3699 			0.36100, 0.36100, 0.36100, 0.36100, 0.36100,
3700 			0.36200, 0.36100, 0.36000, 0.36000, 0.36100,
3701 			0.36100, 0.36100
3702 		}
3703 	},
3704 	/* 22 Neutral 5 */
3705 	{
3706 		77, 380.0, 760.0,	/* 77 bands from 380 to 760 nm in 5nm steps */
3707 		1.0,				/* Scale factor */
3708 		{
3709 			0.02770, 0.03720, 0.04650, 0.05800, 0.06980,
3710 			0.10790, 0.14570, 0.16630, 0.18690, 0.19070,
3711 			0.19470, 0.19490, 0.19540, 0.19600, 0.19650,
3712 			0.19670, 0.19710, 0.19760, 0.19800, 0.19760,
3713 			0.19690, 0.19850, 0.19780, 0.19760, 0.19760,
3714 			0.19710, 0.19690, 0.19760, 0.19800, 0.19800,
3715 			0.19780, 0.19760, 0.19740, 0.19670, 0.19600,
3716 			0.19650, 0.19710, 0.19760, 0.19800, 0.19850,
3717 			0.19870, 0.19890, 0.19910, 0.19870, 0.19820,
3718 			0.19850, 0.19870, 0.19910, 0.19710, 0.19690,
3719 			0.19670, 0.19710, 0.19760, 0.19760, 0.19740,
3720 			0.19780, 0.19850, 0.19850, 0.19870, 0.19800,
3721 			0.19740, 0.19740, 0.19760, 0.19740, 0.19710,
3722 			0.19710, 0.19740, 0.19710, 0.19710, 0.19740,
3723 			0.19780, 0.19710, 0.19670, 0.19650, 0.19710,
3724 			0.19740, 0.19710
3725 		}
3726 	},
3727 	/* 23 Neutral 3.5 */
3728 	{
3729 		77, 380.0, 760.0,	/* 77 bands from 380 to 760 nm in 5nm steps */
3730 		1.0,				/* Scale factor */
3731 		{
3732 			0.01260, 0.01690, 0.02120, 0.02640, 0.03180,
3733 			0.04910, 0.06640, 0.07570, 0.08510, 0.08680,
3734 			0.08860, 0.08870, 0.08890, 0.08930, 0.08950,
3735 			0.08960, 0.08980, 0.09000, 0.09020, 0.09000,
3736 			0.08970, 0.09040, 0.09010, 0.09000, 0.09000,
3737 			0.08980, 0.08970, 0.09000, 0.09020, 0.09020,
3738 			0.09010, 0.09000, 0.08990, 0.08960, 0.08930,
3739 			0.08950, 0.08980, 0.09000, 0.09020, 0.09040,
3740 			0.09050, 0.09060, 0.09070, 0.09050, 0.09030,
3741 			0.09040, 0.09050, 0.09070, 0.08980, 0.08970,
3742 			0.08960, 0.08980, 0.09000, 0.09000, 0.08990,
3743 			0.09010, 0.09040, 0.09040, 0.09050, 0.09020,
3744 			0.08990, 0.08990, 0.09000, 0.08990, 0.08980,
3745 			0.08980, 0.08990, 0.08980, 0.08980, 0.08990,
3746 			0.09010, 0.08980, 0.08960, 0.08950, 0.08980,
3747 			0.08990, 0.08980
3748 		}
3749 	},
3750 	/* 24 Black */
3751 	{
3752 		77, 380.0, 760.0,	/* 77 bands from 380 to 760 nm in 5nm steps */
3753 		1.0,				/* Scale factor */
3754 		{
3755 			0.00439, 0.00589, 0.00737, 0.00919, 0.01105,
3756 			0.01708, 0.02308, 0.02635, 0.02961, 0.03020,
3757 			0.03084, 0.03087, 0.03094, 0.03105, 0.03112,
3758 			0.03115, 0.03122, 0.03129, 0.03136, 0.03129,
3759 			0.03119, 0.03143, 0.03133, 0.03129, 0.03129,
3760 			0.03122, 0.03119, 0.03129, 0.03136, 0.03136,
3761 			0.03133, 0.03129, 0.03126, 0.03115, 0.03105,
3762 			0.03112, 0.03122, 0.03129, 0.03136, 0.03143,
3763 			0.03147, 0.03150, 0.03154, 0.03147, 0.03140,
3764 			0.03143, 0.03147, 0.03154, 0.03122, 0.03119,
3765 			0.03115, 0.03122, 0.03129, 0.03129, 0.03126,
3766 			0.03133, 0.03143, 0.03143, 0.03147, 0.03136,
3767 			0.03126, 0.03126, 0.03129, 0.03126, 0.03122,
3768 			0.03122, 0.03126, 0.03122, 0.03122, 0.03126,
3769 			0.03133, 0.03122, 0.03115, 0.03112, 0.03122,
3770 			0.03126, 0.03122
3771 		}
3772 	}
3773 };
3774 
3775 /* -------------------------------- */
3776 /* Fluorescent Whitening Agent Data */
3777 
3778 /* Generic stimulation/exitation spectrum, used in FWA. */
3779 /* This is also used to estimate the UV content of an illuminant, */
3780 /* by its FWA effect (illumread) */
3781 static xspect FWA1_stim = {
3782 	14, 290.0, 420.0,	/* 14 bands from 290 to 420 nm in 10nm steps */
3783 	1.0,				/* Scale factor */
3784 	{
3785 /* 290 */   0.000000,
3786 /* 300 */	0.075000, 0.158000, 0.228000, 0.318638, 0.393663,
3787 /* 350 */	0.460003, 0.524409, 0.550955, 0.540374, 0.497947,
3788 /* 400 */	0.412503, 0.265935, 0.000000
3789 	}
3790 };
3791 
3792 /* !!! This is not normally used !!! */
3793 #ifdef STOCKFWA			/* Use table shape as FWA basis, rather than estimating from spectrum. */
3794 
3795 /* Generic emmission spectrum */
3796 static xspect FWA1_emit = {
3797 	17, 390.0, 550.0,	/* 17 bands from 390 to 550 nm in 10nm steps */
3798 	1.0,				/* Scale factor */
3799 	{
3800 #ifdef NEVER
3801 /* 390 */	0.00000,
3802 /* 400 */	0.08989,  0.27831,  0.45278,  0.494,   0.496,
3803 /* 450 */	0.36872,  0.30495,  0.226,    0.1676,  0.1216,
3804 /* 500 */	0.08515,  0.06877,  0.04930,  0.0246,  0.0123,
3805 /* 550 */	0.00000
3806 #else
3807 	/* Hacked */
3808 /* 390 */	0.00000,
3809 /* 400 */	0.01089,  0.15000,  0.20278,  0.374,   0.496,
3810 /* 450 */	0.38000,  0.27495,  0.186,    0.1376,  0.1016,
3811 /* 500 */	0.08515,  0.06877,  0.04930,  0.0246,  0.0123,
3812 /* 550 */	0.00000
3813 #endif
3814 	}
3815 };
3816 
3817 #endif /* STOCKFWA */
3818 
3819 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
3820 /* Return a string describing the inst_meas_type */
meas_type2str(inst_meas_type mt)3821 char *meas_type2str(inst_meas_type mt) {
3822 
3823 	switch (mt) {
3824 		case inst_mrt_none:
3825 			return "None";
3826 		case inst_mrt_emission:
3827 			return "Emission";
3828 		case inst_mrt_ambient:
3829 			return "Ambient";
3830 		case inst_mrt_emission_flash:
3831 			return "Emission Flash";
3832 		case inst_mrt_ambient_flash:
3833 			return "Ambient Flash";
3834 		case inst_mrt_reflective:
3835 			return "Reflective";
3836 		case inst_mrt_transmissive:
3837 			return "Transmissive";
3838 		case inst_mrt_sensitivity:
3839 			return "Sensitivity";
3840 		case inst_mrt_frequency:
3841 			return "Frequency";
3842 	}
3843 	return "Unknown";
3844 }
3845 
3846 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
3847 /* save a set of spectrum to a CGATS file */
3848 /* type 0 = SPECT, 1 = CMF */
3849 /* Return NZ on error */
write_nxspect(char * fname,inst_meas_type mt,xspect * sp,int nspec,int type)3850 int write_nxspect(char *fname, inst_meas_type mt, xspect *sp, int nspec, int type) {
3851 	char buf[100];
3852 	time_t clk = time(0);
3853 	struct tm *tsp = localtime(&clk);
3854 	char *atm = asctime(tsp); /* Ascii time */
3855 	cgats *ocg;				/* output cgats structure */
3856 	cgats_set_elem *setel;	/* Array of set value elements */
3857 	int i, j;
3858 
3859 	/* Setup output cgats file */
3860 	ocg = new_cgats();				/* Create a CGATS structure */
3861 	if (type != 0)
3862 		ocg->add_other(ocg, "CMF"); 	/* our special type is spectral color matching func */
3863 	else
3864 		ocg->add_other(ocg, "SPECT"); 	/* our special type is spectral power or reflectance */
3865 	ocg->add_table(ocg, tt_other, 0);	/* Start the first table */
3866 
3867 	ocg->add_kword(ocg, 0, "DESCRIPTOR", "Argyll Spectral power/reflectance information",NULL);
3868 	ocg->add_kword(ocg, 0, "ORIGINATOR", "Argyll CMS", NULL);
3869 	atm[strlen(atm)-1] = '\000';	/* Remove \n from end */
3870 	ocg->add_kword(ocg, 0, "CREATED",atm, NULL);
3871 
3872 	if (mt != inst_mrt_none) {
3873 		char *tag = NULL;
3874 		switch (mt) {
3875 			case inst_mrt_emission:
3876 				tag = "EMISSION";	break;
3877 			case inst_mrt_ambient:
3878 				tag = "AMBIENT";	break;
3879 			case inst_mrt_emission_flash:
3880 				tag = "EMISSION_FLASH";	break;
3881 			case inst_mrt_ambient_flash:
3882 				tag = "AMBIENT_FLASH";	break;
3883 			case inst_mrt_reflective:
3884 				tag = "REFLECTIVE";	break;
3885 			case inst_mrt_transmissive:
3886 				tag = "TRANSMISSIVE";	break;
3887 			case inst_mrt_sensitivity:
3888 				tag = "SENSITIVITY";	break;
3889 			default:
3890 				break;
3891 		}
3892 		if (tag != NULL)
3893 			ocg->add_kword(ocg, 0, "MEAS_TYPE",tag, NULL);
3894 	}
3895 
3896 	sprintf(buf,"%d", sp->spec_n);
3897 	ocg->add_kword(ocg, 0, "SPECTRAL_BANDS",buf, NULL);
3898 
3899 	sprintf(buf,"%d", sp->spec_n);
3900 	ocg->add_kword(ocg, 0, "SPECTRAL_BANDS",buf, NULL);
3901 	sprintf(buf,"%f", sp->spec_wl_short);
3902 	ocg->add_kword(ocg, 0, "SPECTRAL_START_NM",buf, NULL);
3903 	sprintf(buf,"%f", sp->spec_wl_long);
3904 	ocg->add_kword(ocg, 0, "SPECTRAL_END_NM",buf, NULL);
3905 	sprintf(buf,"%f", sp->norm);
3906 	ocg->add_kword(ocg, 0, "SPECTRAL_NORM",buf, NULL);
3907 
3908 	/* Should we adda A COORD field for "CMF" and an INDEX field for "SPECT" ? */
3909 
3910 	/* Generate fields for spectral values */
3911 	for (i = 0; i < sp->spec_n; i++) {
3912 		int nm;
3913 
3914 		/* Compute nearest integer wavelength */
3915 		nm = (int)(XSPECT_XWL(sp, i) + 0.5);
3916 		sprintf(buf,"SPEC_%03d",nm);
3917 		ocg->add_field(ocg, 0, buf, r_t);
3918 	}
3919 
3920 	if ((setel = (cgats_set_elem *)malloc(sizeof(cgats_set_elem) * sp->spec_n)) == NULL) {
3921 		ocg->del(ocg);
3922 		return 1;
3923 	}
3924 
3925 	for (j = 0; j < nspec; j++) {
3926 		for (i = 0; i < sp[j].spec_n; i++) {
3927 			setel[i].d = sp[j].spec[i];
3928 		}
3929 		ocg->add_setarr(ocg, 0, setel);
3930 	}
3931 
3932 	if (ocg->write_name(ocg, fname)) {
3933 		DBGF((DBGA,"CGATS file write error : %s\n",ocg->err));
3934 		return 1;
3935 	}
3936 
3937 	free(setel);
3938 	ocg->del(ocg);		/* Clean up */
3939 
3940 	return 0;
3941 }
3942 
3943 /* Restore a set of spectrum from a CGATS file. */
3944 /* Up to nspec will be restored starting at offset off. */
3945 /* The number restored from the file will be written to *nret */
3946 /* File type: 0 = any, mask: 1 = SPECT, 2 = CMF, 4 = ccss */
3947 /* (Note that not all ccss information is read. Use ccss->read_ccss() for this. */
3948 /* Return NZ on error */
3949 /* (Would be nice to return an error message!) */
read_nxspect(xspect * sp,inst_meas_type * mt,char * fname,int * nret,int off,int nspec,int type)3950 int read_nxspect(xspect *sp, inst_meas_type *mt, char *fname,
3951                  int *nret, int off, int nspec, int type) {
3952 	cgats *icg;				/* input cgats structure */
3953 	char buf[100];
3954 	int sflds[XSPECT_MAX_BANDS];
3955 	int i, j, ii;
3956 	xspect proto;
3957 
3958 	/* Open and look at the spectrum file */
3959 	if ((icg = new_cgats()) == NULL) {	/* Create a CGATS structure */
3960 		DBG("new_cgats() failed");
3961 		icg->del(icg);
3962 		return 1;
3963 	}
3964 	if (type == 0) {
3965 		icg->add_other(icg, "");    /* Allow any signature file */
3966 	} else {
3967 		if (type & 1)
3968 			icg->add_other(icg, "SPECT");	/* Spectrum file */
3969 		if (type & 2)
3970 			icg->add_other(icg, "CMF");		/* Color Matching Functions */
3971 		if (type & 4)
3972 			icg->add_other(icg, "CCSS");    /* Color Correction Spectral Samples */
3973 	}
3974 
3975 	if (icg->read_name(icg, fname)) {
3976 		DBGF((DBGA,"CGATS file read error : %s\n",icg->err));
3977 		icg->del(icg);
3978 		return 1;
3979 	}
3980 
3981 	if (icg->ntables != 1) {
3982 		DBG("Input file doesn't contain exactly one table\n");
3983 		icg->del(icg);
3984 		return 1;
3985 	}
3986 
3987 	if (mt != NULL && (ii = icg->find_kword(icg, 0, "MEAS_TYPE")) >= 0) {
3988 
3989 		if (strcmp(icg->t[0].kdata[ii], "EMISSION") == 0)
3990 			*mt = inst_mrt_emission;
3991 		else if (strcmp(icg->t[0].kdata[ii], "AMBIENT") == 0)
3992 			*mt = inst_mrt_ambient;
3993 		else if (strcmp(icg->t[0].kdata[ii], "EMISSION_FLASH") == 0)
3994 			*mt = inst_mrt_emission_flash;
3995 		else if (strcmp(icg->t[0].kdata[ii], "AMBIENT_FLASH") == 0)
3996 			*mt = inst_mrt_ambient_flash;
3997 		else if (strcmp(icg->t[0].kdata[ii], "REFLECTIVE") == 0)
3998 			*mt = inst_mrt_reflective;
3999 		else if (strcmp(icg->t[0].kdata[ii], "TRANSMISSIVE") == 0)
4000 			*mt = inst_mrt_transmissive;
4001 		else if (strcmp(icg->t[0].kdata[ii], "SENSITIVITY") == 0)
4002 			*mt = inst_mrt_sensitivity;
4003 		else
4004 			*mt = inst_mrt_none;
4005 	}
4006 
4007 	if ((ii = icg->find_kword(icg, 0, "SPECTRAL_BANDS")) < 0) {
4008 		DBG ("Input file doesn't contain keyword SPECTRAL_BANDS\n");
4009 		icg->del(icg);
4010 		return 1;
4011 	}
4012 	proto.spec_n = atoi(icg->t[0].kdata[ii]);
4013 	if ((ii = icg->find_kword(icg, 0, "SPECTRAL_START_NM")) < 0) {
4014 		DBG("Input file doesn't contain keyword SPECTRAL_START_NM\n");
4015 		icg->del(icg);
4016 		return 1;
4017 	}
4018 	proto.spec_wl_short = atof(icg->t[0].kdata[ii]);
4019 	if ((ii = icg->find_kword(icg, 0, "SPECTRAL_END_NM")) < 0) {
4020 		DBG("Input file doesn't contain keyword SPECTRAL_END_NM\n");
4021 		icg->del(icg);
4022 		return 1;
4023 	}
4024 	proto.spec_wl_long = atof(icg->t[0].kdata[ii]);
4025 
4026 	if ((ii = icg->find_kword(icg, 0, "SPECTRAL_NORM")) < 0) {
4027 		DBG("Input file doesn't contain keyword SPECTRAL_NORM - assuming 1.0\n");
4028 		proto.norm = 1.0;
4029 	} else {
4030 		proto.norm = atof(icg->t[0].kdata[ii]);
4031 	}
4032 
4033 	/* Find the fields for spectral values */
4034 	for (i = 0; i < proto.spec_n; i++) {
4035 		int nm, fi;
4036 
4037 		/* Compute nearest integer wavelength */
4038 		nm = (int)(XSPECT_XWL(&proto, i) + 0.5);
4039 		sprintf(buf,"SPEC_%03d",nm);
4040 
4041 		if ((fi = icg->find_field(icg, 0, buf)) < 0) {
4042 			DBGF((DBGA,"Input file doesn't contain field %s\n",buf));
4043 			icg->del(icg);
4044 			return 1;
4045 		}
4046 
4047 		if (icg->t[0].ftype[fi] != r_t) {
4048 			DBGF((DBGA,"Field %s in specrum is wrong type - should be a float\n",buf));
4049 			icg->del(icg);
4050 			return 1;
4051 		}
4052 		sflds[i] = fi;
4053 	}
4054 
4055 	/* Read all the spectra */
4056 	for (j = off; j < (off + nspec) && j < icg->t[0].nsets; j++) {
4057 
4058 		XSPECT_COPY_INFO(&sp[j-off], &proto);
4059 
4060 		for (i = 0; i < proto.spec_n; i++) {
4061 			sp[j-off].spec[i] = *((double *)icg->t[0].fdata[j][sflds[i]]);
4062 		}
4063 	}
4064 	if (nret != NULL)
4065 		*nret = j - off;
4066 
4067 	icg->del(icg);
4068 
4069 	return 0;
4070 }
4071 
4072 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
4073 
4074 /* save a spectrum to a CGATS file */
4075 /* Return NZ on error */
write_xspect(char * fname,inst_meas_type mt,xspect * sp)4076 int write_xspect(char *fname, inst_meas_type mt, xspect *sp) {
4077 	return write_nxspect(fname, mt, sp, 1, 0);
4078 }
4079 
4080 /* restore a spectrum from a CGATS file */
4081 /* Return NZ on error */
4082 /* (Would be nice to return an error message!) */
read_xspect(xspect * sp,inst_meas_type * mt,char * fname)4083 int read_xspect(xspect *sp, inst_meas_type *mt, char *fname) {
4084 	int rv, nret;
4085 
4086 	if ((rv = read_nxspect(sp, mt, fname, &nret, 0, 1, 1)) != 0)
4087 		return rv;
4088 	if (nret != 1) {
4089 		DBG("Didn't read one spectra\n");
4090 		return 1;
4091 	}
4092 
4093 	return 0;
4094 }
4095 
4096 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
4097 /* save a set of 3 spectrum to a CGATS CMF file */
4098 /* Return NZ on error */
write_cmf(char * fname,xspect sp[3])4099 int write_cmf(char *fname, xspect sp[3]) {
4100 	return write_nxspect(fname, inst_mrt_sensitivity, sp, 3, 1);
4101 }
4102 
4103 /* restore a spectrum from a CGATS file */
4104 /* Return NZ on error */
4105 /* (Would be nice to return an error message!) */
read_cmf(xspect sp[3],char * fname)4106 int read_cmf(xspect sp[3], char *fname) {
4107 	inst_meas_type mt;
4108 	int rv, nret;
4109 
4110 	/* Hmm. Should we check inst_meas_type is none || sensitivity ? */
4111 	if ((rv = read_nxspect(sp, &mt, fname, &nret, 0, 3, 2)) != 0) {
4112 		DBG("read_nxspect failed\n");
4113 		return rv;
4114 	}
4115 	if (mt != inst_mrt_none && mt != inst_mrt_sensitivity) {
4116 		DBG("read_nxspect - wrong measurement type\n");
4117 		return 1;
4118 	}
4119 	if (nret != 3) {
4120 		DBG("Didn't read three spectra\n");
4121 		return 1;
4122 	}
4123 
4124 	return 0;
4125 }
4126 
4127 /* ------------- */
4128 #endif /* !SALONEINSTLIB */
4129 
4130 
4131 /* Get a raw 3rd order polinomial interpolated spectrum value. */
4132 /* Return NZ if value is valid, Z and xtrapolated value */
4133 /* if outside the range */
4134 /* NOTE: Returned value isn't normalised by sp->norm */
getval_raw_xspec_poly3(xspect * sp,double * rv,double xw)4135 static int getval_raw_xspec_poly3(xspect *sp, double *rv, double xw) {
4136 	int i, rc = 1;
4137 	double spcing, f;
4138 #ifdef NEVER
4139 	double w1, w2, w3;		/* For Hermite curves */
4140 #endif
4141 	double y[4], yw;
4142 	double x[4];
4143 
4144 	if (xw < sp->spec_wl_short) {
4145 		xw = sp->spec_wl_short;
4146 		rc = 0;
4147 	}
4148 
4149 	if (xw > sp->spec_wl_long) {
4150 		xw = sp->spec_wl_long;
4151 		rc = 0;
4152 	}
4153 
4154 	/* Compute fraction 0.0 - 1.0 out of known spectrum. */
4155 	/* Place it so that the target wavelength lands in middle section */
4156 	/* of Lagrange basis points. */
4157 	spcing = (sp->spec_wl_long - sp->spec_wl_short)/(sp->spec_n-1.0);
4158 	f = (xw - sp->spec_wl_short) / (sp->spec_wl_long - sp->spec_wl_short);
4159 	f *= (sp->spec_n - 1.0);
4160 	i = (int)floor(f);			/* Base grid coordinate */
4161 
4162 	if (i < 1)					/* Limit to valid Lagrange basis index range, */
4163 		i = 1;					/* and extrapolate from that at ends. */
4164 	else if (i > (sp->spec_n - 3))
4165 		i = (sp->spec_n - 3);
4166 
4167 	/* Setup the surrounding values */
4168 	x[0] = sp->spec_wl_short + (i-1) * spcing;
4169 	y[0] = sp->spec[i-1];
4170 	x[1] = sp->spec_wl_short + i * spcing;
4171 	y[1] = sp->spec[i];
4172 	x[2] = sp->spec_wl_short + (i+1) * spcing;
4173 	y[2] = sp->spec[i+1];
4174 	x[3] = sp->spec_wl_short + (i+2) * spcing;
4175 	y[3] = sp->spec[i+2];
4176 
4177 #ifndef NEVER
4178 	/* Compute interpolated value using Lagrange: */
4179 	yw = y[0] * (xw-x[1]) * (xw-x[2]) * (xw-x[3])/((x[0]-x[1]) * (x[0]-x[2]) * (x[0]-x[3]))
4180 	   + y[1] * (xw-x[0]) * (xw-x[2]) * (xw-x[3])/((x[1]-x[0]) * (x[1]-x[2]) * (x[1]-x[3]))
4181 	   + y[2] * (xw-x[0]) * (xw-x[1]) * (xw-x[3])/((x[2]-x[0]) * (x[2]-x[1]) * (x[2]-x[3]))
4182 	   + y[3] * (xw-x[0]) * (xw-x[1]) * (xw-x[2])/((x[3]-x[0]) * (x[3]-x[1]) * (x[3]-x[2]));
4183 #else
4184 	/* Use Hermite curves */
4185 	y[0] = 0.5 * (y[2] - y[0]);			/* Convert to tangent */
4186 	y[3] = 0.5 * (y[3] - y[1]);			/* Not sure about the best weighting here ... */
4187 
4188 	w1 = f - (double)i;			/* Interpolation weighting factor, 0.0 - 1.0 */
4189 	w2 = w1 * w1;
4190 	w3 = w2 * w1;
4191 	yw = y[0] * (w3 - 2.0 * w2 + w1)
4192 	   + y[1] * (2.0 * w3 - 3.0 * w2 + 1.0)
4193 	   + y[2] * (-2.0 * w3 + 3.0 * w2)
4194 	   + y[3] * (w3 - w2);
4195 #endif
4196 
4197 #ifdef NEVER	// ~~99
4198 	/* Calibration issues or interpolation overshoot can give -ve values, */
4199 	/* so protect against this. */
4200 	/* On the other hand, not allowing -ve values wrecks black level */
4201 	/* by not averaging out the noise. */
4202 	if (yw < 0.0)
4203 		yw = 0.0;
4204 #endif /* NEVER */
4205 
4206 	*rv = yw;
4207 	return rc;
4208 }
4209 
4210 /* Get a raw linearly interpolated spectrum value. */
4211 /* Return NZ if value is valid, Z and last valid value */
4212 /* if outside the range */
4213 /* NOTE: Returned value isn't normalised by sp->norm */
getval_raw_xspec_lin(xspect * sp,double * rv,double wl)4214 static int getval_raw_xspec_lin(xspect *sp, double *rv, double wl) {
4215 	int i, rc = 1;
4216 	double f, w;
4217 
4218 	if (wl < sp->spec_wl_short) {
4219 		wl = sp->spec_wl_short;
4220 		rc = 0;
4221 	}
4222 
4223 	if (wl > sp->spec_wl_long) {
4224 		wl = sp->spec_wl_long;
4225 		rc = 0;
4226 	}
4227 
4228 	/* Compute fraction 0.0 - 1.0 out of known spectrum */
4229 	f = (wl - sp->spec_wl_short) / (sp->spec_wl_long - sp->spec_wl_short);
4230 	f *= (sp->spec_n - 1.0);
4231 	i = (int)floor(f);			/* Base grid coordinate */
4232 
4233 	if (i < 0)					/* Limit to valid cube base index range */
4234 		i = 0;
4235 	else if (i > (sp->spec_n - 2))
4236 		i = (sp->spec_n - 2);
4237 
4238 	w = f - (double)i;			/* Interpolation weighting factor */
4239 
4240 	/* Compute interpolated value */
4241 	*rv = (1.0 - w) * sp->spec[i] + w * sp->spec[i+1];
4242 
4243 #ifdef NEVER
4244 	/* Calibration issues or interpolation overshoot can give -ve values, */
4245 	/* so protect against this. */
4246 	/* On the other hand, not allowing -ve values wrecks black level */
4247 	/* by not averaging out the noise. */
4248 	if (*rv < 0.0)
4249 		*rv = 0.0;
4250 #endif /* NEVER */
4251 
4252 	return rc;
4253 }
4254 
4255 /* Get a raw linearly interpolated spectrum value x 3. */
4256 /* Return NZ if value is valid, Z and last valid value */
4257 /* if outside the range */
4258 /* NOTE: Returned value isn't normalised by sp->norm */
getval_raw_xspec3_lin(xspect * sp,double * rv,double wl)4259 static int getval_raw_xspec3_lin(xspect *sp, double *rv, double wl) {
4260 	int i, rc = 1;
4261 	double f, w;
4262 
4263 	if (wl < sp[0].spec_wl_short) {
4264 		wl = sp[0].spec_wl_short;
4265 		rc = 0;
4266 	}
4267 
4268 	if (wl > sp[0].spec_wl_long) {
4269 		wl = sp[0].spec_wl_long;
4270 		rc = 0;
4271 	}
4272 
4273 	/* Compute fraction 0.0 - 1.0 out of known spectrum */
4274 	f = (wl - sp[0].spec_wl_short) / (sp[0].spec_wl_long - sp[0].spec_wl_short);
4275 	f *= (sp[0].spec_n - 1.0);
4276 	i = (int)floor(f);			/* Base grid coordinate */
4277 
4278 	if (i < 0)					/* Limit to valid cube base index range */
4279 		i = 0;
4280 	else if (i > (sp[0].spec_n - 2))
4281 		i = (sp[0].spec_n - 2);
4282 
4283 	w = f - (double)i;			/* Interpolation weighting factor */
4284 
4285 	/* Compute interpolated value */
4286 	rv[0] = (1.0 - w) * sp[0].spec[i] + w * sp[0].spec[i+1];
4287 	rv[1] = (1.0 - w) * sp[1].spec[i] + w * sp[1].spec[i+1];
4288 	rv[2] = (1.0 - w) * sp[2].spec[i] + w * sp[2].spec[i+1];
4289 
4290 	return rc;
4291 }
4292 
4293 #ifdef NEVER	/* Nearest neighbor resampler, for testing */
4294 /* Get a raw nearest-neighbor interpolated spectrum value. */
4295 /* Return NZ if value is valid, Z and last valid value */
4296 /* if outside the range */
4297 /* NOTE: Returned value isn't normalised by sp->norm */
getval_raw_xspec_nn(xspect * sp,double * rv,double wl)4298 static int getval_raw_xspec_nn(xspect *sp, double *rv, double wl) {
4299 	int i, rc = 1;
4300 	double f;
4301 
4302 	if (wl < sp->spec_wl_short) {
4303 		wl = sp->spec_wl_short;
4304 		rc = 0;
4305 	}
4306 
4307 	if (wl > sp->spec_wl_long) {
4308 		wl = sp->spec_wl_long;
4309 		rc = 0;
4310 	}
4311 
4312 	/* Compute fraction 0.0 - 1.0 out of known spectrum */
4313 	f = (wl - sp->spec_wl_short) / (sp->spec_wl_long - sp->spec_wl_short);
4314 	f *= (sp->spec_n - 1.0);
4315 	i = (int)floor(f + 0.5);	/* Base grid coordinate */
4316 
4317 	if (i < 0)					/* Limit to valid cube base index range */
4318 		i = 0;
4319 	else if (i > (sp->spec_n - 1))
4320 		i = (sp->spec_n - 1);
4321 
4322 	/* Compute interpolated value */
4323 	*rv = sp->spec[i];
4324 
4325 #ifdef NEVER
4326 	/* Calibration issues or interpolation overshoot can give -ve values, */
4327 	/* so protect against this. */
4328 	/* On the other hand, not allowing -ve values wrecks black level */
4329 	/* by not averaging out the noise. */
4330 	if (*rv < 0.0)
4331 		*rv = 0.0;
4332 #endif /* NEVER */
4333 
4334 	return rc;
4335 }
4336 #endif /* NEVER */
4337 
4338 /* Call the appropriate interpolation routine */
4339 /* Return NZ if value is valid, Z and last valid value */
4340 /* if outside the range */
4341 /* NOTE: Returned value isn't normalised by sp->norm */
getval_raw_xspec(xspect * sp,double * rv,double wl)4342 static int getval_raw_xspec(xspect *sp, double *rv, double wl) {
4343 	double spcg = (sp->spec_wl_long - sp->spec_wl_short)/(sp->spec_n-1.0);
4344 
4345 	if (spcg < 5.01) {
4346 		return getval_raw_xspec_lin(sp, rv, wl);
4347 	} else {
4348 		return getval_raw_xspec_poly3(sp, rv, wl);
4349 	}
4350 }
4351 
4352 /* Get a (normalised) linearly or poly interpolated spectrum value. */
4353 /* Return NZ if value is valid, Z and last valid value */
4354 /* if outside the range */
getval_xspec(xspect * sp,double * rv,double wl)4355 static int getval_xspec(xspect *sp, double *rv, double wl) {
4356 	int sv = getval_raw_xspec(sp, rv, wl);
4357 	*rv /= sp->norm;
4358 	return sv;
4359 }
4360 
4361 /* Public function to get a spectrum value. */
4362 /* Return a spectrum value at the given wavelenth. It */
4363 /* may have been interpolated or extrapolated. */
4364 /* Returned value isn't normalised by sp->norm */
value_xspect(xspect * sp,double wl)4365 double value_xspect(xspect *sp, double wl) {
4366 	double rv;
4367 	getval_raw_xspec(sp, &rv, wl);
4368 	return rv;
4369 }
4370 
4371 /* Get a (normalised) linearly interpolated spectrum value. */
4372 /* Return NZ if value is valid, Z and last valid value */
4373 /* if outside the range */
getval_lxspec(xspect * sp,double * rv,double wl)4374 static int getval_lxspec(xspect *sp, double *rv, double wl) {
4375 	int sv = getval_raw_xspec_lin(sp, rv, wl);
4376 	*rv /= sp->norm;
4377 	return sv;
4378 }
4379 
4380 /* De-noramlize and set normalisation factor to 1.0 */
xspect_denorm(xspect * sp)4381 void xspect_denorm(xspect *sp) {
4382 	int i;
4383 
4384 	for (i = 0; i < sp->spec_n; i++) {
4385 		sp->spec[i] /= sp->norm;
4386 	}
4387 	sp->norm = 1.0;
4388 }
4389 
4390 #ifndef SALONEINSTLIB
4391 
4392 /* Convert from one xspect type to another (targ type) */
4393 /* Linear or polinomial interpolation will be used as appropriate */
4394 /* (converted to targ norm too) */
xspect2xspect(xspect * dst,xspect * targ,xspect * src)4395 void xspect2xspect(xspect *dst, xspect *targ, xspect *src) {
4396 	xspect dd;
4397 	int i;
4398 
4399 	dd.spec_n        = targ->spec_n;
4400 	dd.spec_wl_short = targ->spec_wl_short;
4401 	dd.spec_wl_long  = targ->spec_wl_long;
4402 	dd.norm          = targ->norm;
4403 
4404 	if (targ->spec_n != src->spec_n
4405 	 || targ->spec_wl_short != src->spec_wl_short
4406 	 || targ->spec_wl_long != src->spec_wl_long) {
4407 		for (i = 0; i < targ->spec_n; i++) {
4408 			double ww = XSPECT_XWL(targ, i);
4409 			getval_raw_xspec(src, &dd.spec[i], ww);
4410 		}
4411 	} else {
4412 		for (i = 0; i < targ->spec_n; i++)
4413 			dd.spec[i] = src->spec[i];
4414 	}
4415 	if (targ->norm != src->norm) {
4416 		for (i = 0; i < targ->spec_n; i++)
4417 			dd.spec[i] *= targ->norm/src->norm;
4418 	}
4419 	*dst = dd;
4420 }
4421 
4422 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
4423 /* Plot up to 3 spectra */
xspect_plot_w(xspect * sp1,xspect * sp2,xspect * sp3,int wait)4424 void xspect_plot_w(xspect *sp1, xspect *sp2, xspect *sp3, int wait) {
4425 	static double xx[XSPECT_MAX_BANDS];
4426 	static double y1[XSPECT_MAX_BANDS];
4427 	static double y2[XSPECT_MAX_BANDS];
4428 	static double y3[XSPECT_MAX_BANDS];
4429 	int j;
4430 	double wl, wlshort, wllong;
4431 	double ymax = 0.0;
4432 
4433 	if (sp1 == NULL)
4434 		return;
4435 
4436 	wlshort = sp1->spec_wl_short;
4437 	wllong = sp1->spec_wl_long;
4438 
4439 	if (sp2 != NULL) {
4440 		if (sp2->spec_wl_short < wlshort)
4441 			wlshort = sp2->spec_wl_short;
4442 		if (sp2->spec_wl_long > wllong)
4443 			wllong = sp2->spec_wl_long;
4444 	}
4445 
4446 	if (sp3 != NULL) {
4447 		if (sp3->spec_wl_short < wlshort)
4448 			wlshort = sp3->spec_wl_short;
4449 		if (sp3->spec_wl_long > wllong)
4450 			wllong = sp3->spec_wl_long;
4451 	}
4452 
4453 	wlshort = floor(wlshort + 0.5);
4454 	wllong = floor(wllong + 0.5);
4455 
4456 	/* Compute at 1nm intervals over the whole range covered */
4457 	for (j = 0, wl = wlshort; j < XSPECT_MAX_BANDS && wl < wllong; j++, wl += 1.0) {
4458 #if defined(__APPLE__) && defined(__POWERPC__)
4459 		gcc_bug_fix(j);
4460 #endif
4461 		xx[j] = wl;
4462 		y1[j] = value_xspect(sp1, wl);
4463 		if (y1[j] > ymax)
4464 			ymax = y1[j];
4465 		if (sp2 != NULL) {
4466 			y2[j] = value_xspect(sp2, wl);
4467 			if (y2[j] > ymax)
4468 				ymax = y2[j];
4469 		}
4470 		if (sp3 != NULL) {
4471 			y3[j] = value_xspect(sp3, wl);
4472 			if (y3[j] > ymax)
4473 				ymax = y3[j];
4474 		}
4475 	}
4476 //	do_plot(xx, y1, sp2 != NULL ? y2 : NULL, sp3 != NULL ? y3 : NULL, j);
4477 	do_plot_x(xx, y1, sp2 != NULL ? y2 : NULL, sp3 != NULL ? y3 : NULL, j,
4478 	                                    wait, 0.0,  -1.0,  0.0, ymax, 1.0);
4479 }
4480 
4481 /* Plot up to 3 spectra & wait for key */
xspect_plot(xspect * sp1,xspect * sp2,xspect * sp3)4482 void xspect_plot(xspect *sp1, xspect *sp2, xspect *sp3) {
4483 	xspect_plot_w(sp1, sp2, sp3, 1);
4484 }
4485 
4486 /* Plot up to 10 spectra */
xspect_plot10(xspect * sp,int n)4487 void xspect_plot10(xspect *sp, int n) {
4488 	double xx[XSPECT_MAX_BANDS];
4489 	double *yp[10];
4490 	double yy[10][XSPECT_MAX_BANDS];
4491 	double wl, wlshort, wllong;
4492 	int i, j;
4493 
4494 	for (i = 0; i < 10; i++)
4495 		yp[i] = NULL;
4496 
4497 	if (sp == NULL)
4498 		return;
4499 
4500 	wlshort = sp->spec_wl_short;
4501 	wllong = sp->spec_wl_long;
4502 
4503 	for (i = 0; i < n; i++) {
4504 		if (sp[i].spec_wl_short < wlshort)
4505 			wlshort = sp[i].spec_wl_short;
4506 		if (sp[i].spec_wl_long > wllong)
4507 			wllong = sp[i].spec_wl_long;
4508 	}
4509 
4510 	wlshort = floor(wlshort + 0.5);
4511 	wllong = floor(wllong + 0.5);
4512 
4513 	/* Compute at 1nm intervals over the whole range covered */
4514 	for (j = 0, wl = wlshort; j < XSPECT_MAX_BANDS && wl < wllong; j++, wl += 1.0) {
4515 #if defined(__APPLE__) && defined(__POWERPC__)
4516 		gcc_bug_fix(j);
4517 #endif
4518 		xx[j] = wl;
4519 		for (i = 0; i < n; i++) {
4520 			yp[i] = yy[i];
4521 			yy[i][j] = value_xspect(&sp[i], wl);
4522 		}
4523 	}
4524 	do_plot10(xx, yp[0], yp[1], yp[2], yp[3], yp[4],
4525 	              yp[5], yp[6], yp[7], yp[8], yp[9], j, 0);
4526 }
4527 
4528 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
4529 
4530 /* Given an emission spectrum, set the UV output to the given level. */
4531 /* The shape of the UV is taken from FWA1_stim, and the level is */
4532 /* with respect to the Y of the input spectrum. */
4533 /* The output range is extended to accomodate the UV wavelengths */
xsp_setUV(xspect * out,xspect * in,double uvlevel)4534 void xsp_setUV(xspect *out, xspect *in, double uvlevel) {
4535 	int i, xs, xe;
4536 	double ww, avg;
4537 	xspect cin;				/* Copy of in */
4538 
4539 	cin = *in;
4540 
4541 	/* Compute the average of the input spectrum */
4542 	for (avg = 0.0, i = 0; i < cin.spec_n; i++)
4543 		avg += cin.spec[i];
4544 	avg /= cin.spec_n;
4545 
4546 	if (avg < 1e-5)	/* Make it do something with 0.0 */
4547 		avg = 1e-5;
4548 
4549 	/* Copy and Extend the range */
4550 	*out = cin;
4551 	i = (int)floor(XSPECT_XDIX(out, FWA1_stim.spec_wl_short));
4552 	ww = XSPECT_XWL(out, i);
4553 	if (i < 0)
4554 		out->spec_n -= i;
4555 	out->spec_wl_short = ww;
4556 
4557 	/* Copy from input and merge in the UV */
4558 	for (i = 0; i < out->spec_n; i++) {
4559 		double inv, uvv, bl, nbl, outv;
4560 
4561 		ww = XSPECT_XWL(out, i);
4562 		getval_raw_xspec_lin(&cin, &inv, ww);
4563 		getval_raw_xspec_lin(&FWA1_stim, &uvv, ww);
4564 
4565 		/* Input illuminant with no Uv */
4566 		out->spec[i] = inv;
4567 
4568 		/* Taper measured illum out */
4569 		bl = (ww - FWA1_stim.spec_wl_short)/(FWA1_stim.spec_wl_long - FWA1_stim.spec_wl_short);
4570 		bl = bl < 0.0 ? 0.0 : (bl > 1.0 ? 1.0 : bl);
4571 		inv *= bl;
4572 
4573 		/* Add/subtract UV in */
4574 		outv = inv + uvv * uvlevel * avg;;
4575 
4576 		/* Protect against creating negative output */
4577 		if (outv >= out->spec[i])
4578 			out->spec[i] = outv;
4579 	}
4580 }
4581 
4582 
4583 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
4584 
4585 /* Set Media White. This enables extracting and applying the */
4586 /* colorant reflectance value from/to the meadia. */
4587 // ~~99 this is confused. ->media is set from ->imedia in fwa setup.
4588 // ~~99 what's going on here ? The API needs fixing.
xsp2cie_set_mw(xsp2cie * p,xspect * media)4589 static int xsp2cie_set_mw(xsp2cie *p,	/* this */
4590 xspect *media		/* Spectrum of plain media measured under that instrument */
4591 ) {
4592 	p->media = *media;		/* Take copy of media white */
4593 	return 0;
4594 }
4595 
4596 /* Extract the colorant reflectance value from the media. Takes FWA */
4597 /* into account if set. Media white or FWA must be set. */
xsp2cie_extract(xsp2cie * p,xspect * out,xspect * in)4598 static int xsp2cie_extract(xsp2cie *p,	/* this */
4599 xspect *out,			/* Extracted colorant refl. spectrum */
4600 xspect *in				/* Spectrum to be converted, normalised by norm */
4601 ) {
4602 	int j;
4603 
4604 	if (p->media.spec_n == 0)
4605 		return 1;
4606 
4607 	if (p->media.spec_n != in->spec_n
4608 	 || p->media.spec_wl_short != in->spec_wl_short
4609 	 || p->media.spec_wl_long != in->spec_wl_long)
4610 		return 1;
4611 
4612 	*out = *in;
4613 
4614 	/* Divide out the media */
4615 	for (j = 0; j < p->media.spec_n; j++) {
4616 		if (p->media.spec[j] < 0.01)
4617 			out->spec[j] = in->spec[j] / 0.01;
4618 		else
4619 			out->spec[j] = in->spec[j] / p->media.spec[j];
4620 	}
4621 
4622 	out->norm = in->norm / p->media.norm;
4623 	return 0;
4624 }
4625 
4626 
4627 /* Apply the colorant reflectance value from the media. Takes FWA */
4628 /* into account if set. Media white or FWA must be set. */
xsp2cie_apply(xsp2cie * p,xspect * out,xspect * in)4629 static int xsp2cie_apply(xsp2cie *p,	/* this */
4630 xspect *out,			/* Applied refl. spectrum */
4631 xspect *in				/* Colorant reflectance to be applied */
4632 ) {
4633 	int j;
4634 
4635 	if (p->media.spec_n == 0)
4636 		return 1;
4637 
4638 	if (p->media.spec_n != in->spec_n
4639 	 || p->media.spec_wl_short != in->spec_wl_short
4640 	 || p->media.spec_wl_long != in->spec_wl_long)
4641 		return 1;
4642 
4643 	*out = *in;
4644 
4645 	/* Multiply in the media */
4646 	for (j = 0; j < p->media.spec_n; j++) {
4647 		if (p->media.spec[j] < 0.01)
4648 			out->spec[j] = in->spec[j] * 0.01;
4649 		else
4650 			out->spec[j] = in->spec[j] * p->media.spec[j];
4651 	}
4652 
4653 	out->norm = in->norm * p->media.norm;
4654 	return 0;
4655 }
4656 
4657 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
4658 static void xsp2cie_fwa_convert(xsp2cie *p, double *out, xspect *in);
4659 static void xsp2cie_fwa_sconvert(xsp2cie *p, xspect *sout, double *out, xspect *in);
4660 static int xsp2cie_fwa_extract(xsp2cie *p, xspect *out, xspect *in);
4661 static int xsp2cie_fwa_apply(xsp2cie *p, xspect *out, xspect *in);
4662 
4663 /* Set Fluorescent Whitening Agent compensation. */
4664 /* This attempts to compensate for the presense of */
4665 /* Fluorescent whitner in the media, under the possibly */
4666 /* different level of UV radiation of the illuminant being */
4667 /* simulated in the conversion from spectral absorbition */
4668 /* to CIE values, from the illuminant that the media was */
4669 /* measured under by the spectrometer. */
4670 /* Note that the media input spectrum normalisation value is used. */
4671 /* return nz if error */
4672 
4673 /*
4674 
4675 	Limitations of current FWA model:
4676 
4677 	Scattering: The inking model assumes that the inks are purely
4678 	absorbtive. If instead they have a significant scattering
4679 	component, then the FWA effect will be over estimated,
4680 	as it will be assumed that more UV is reaching the substrate
4681 	and not being filtered by the colorant.
4682 
4683 	Colorant UV transparency: The current model assumes that
4684 	the filtering behaviour of the ink can be extrapolated
4685 	from the blue reflectance. It could be that inks behave
4686 	quite differently, filtering more or less in UV than
4687 	they do in blue. Different inks might have different characteristics.
4688 
4689 	Solution: A solution would be to add a colorant correction model,
4690 	that takes as input the colorant levels. To create the model,
4691 	illumread would be augmented to read (say) 50% colorant swatches
4692 	as well as white, and use the discrepancy between the non-corrected
4693 	FWA spectrum and the actual spectrum under the illuminant to
4694 	create the correction model. This could be fine tuned by doing
4695 	similar measurements of neutral patches.
4696 
4697 	Other possible limitations:
4698 
4699 	Instrument illuminant spectrum shape:
4700 	It is assumed it is stable and 'A' like. Aging of
4701 	the lamp may invalidate this assumption ?
4702 
4703  */
4704 
4705 /*
4706    See page 248 of the Proceedings of the IS&T/SID
4707    11th Color Imaging Conference, November 2003:
4708    "A Practical Approach to Measuring and Modelling Paper Fluorescense
4709    for Improved Colorimetric Characterisation of Printing Processes"
4710    ISBN: 0-89208-248-8
4711    for more information about the fwa compensation approach.
4712  */
4713 
xsp2cie_set_fwa_imp(xsp2cie * p)4714 static int xsp2cie_set_fwa_imp(xsp2cie *p) {
4715 	double ww;
4716 	int i, j;
4717 	int flag;
4718 	double aw = 0.0, bw = 0.0; /* Points wavelength */
4719 	double ar, br;		/* Points reflection */
4720 #ifdef STOCKFWA			/* Use table shape */
4721 	double Em;			/* Emmision multiplier */
4722 #endif
4723 #ifdef DOPLOT
4724 	double xx[XSPECT_MAX_BANDS];
4725 	double y1[XSPECT_MAX_BANDS];
4726 	double y2[XSPECT_MAX_BANDS];
4727 	double y3[XSPECT_MAX_BANDS];
4728 	double y4[XSPECT_MAX_BANDS];
4729 #endif /* DOPLOT */
4730 
4731 #ifdef WRITE_FWA1_STIM
4732 	write_xspect("fwa1_stip.sp", &FWA1_stim);
4733 #endif
4734 
4735 	DBG("set_fwa started\n");
4736 
4737 	p->fwa_bw = 1.0;			/* Intergrate over 1nm bands */
4738 	p->oillum = p->illuminant;	/* Take copy of observer illuminant */
4739 	xspect_denorm(&p->oillum);
4740 	if (p->tillum.spec_n == 0) {	/* If not set by set_fwa(), copy observer illuminant */
4741 		p->tillum = p->oillum;		/* as target/simulated instrument illuminant. */
4742 		DBG("using observer illum as FWA target\n");
4743 	}
4744 
4745 	/* Compute Y = 1 normalised instrument illuminant spectrum */
4746 	{
4747 		double scale = 0.0;
4748 		double Iim;		/* illuminant multiplier */
4749 
4750 		Iim = 0.0;
4751 		for (ww = p->spec_wl_short; ww <= p->spec_wl_long; ww += p->spec_bw) {
4752 			double O, I;
4753 			getval_lxspec(&p->iillum, &I, ww);
4754 			getval_lxspec(&p->observer[1], &O, ww);
4755 			scale += O;			/* Integrate Y observer values */
4756 			Iim += O * I;
4757 		}
4758 		Iim /= scale;			/* Scale Y observer to unity */
4759 
4760 		Iim = 1.0/Iim;			/* Scale factor to make illuminant integral 1.0 */
4761 
4762 		for (j = 0; j < p->iillum.spec_n; j++)
4763 			p->iillum.spec[j] *= Iim;
4764 		DBGF((DBGA,"Instrument Illum normal multiplier Iim = %f\n",Iim));
4765 	}
4766 
4767 	/* Compute Y = 1 normalised target illuminant spectrum */
4768 	{
4769 		double scale;
4770 		double Itm;		/* illuminant multiplier */
4771 
4772 		scale = 0.0;
4773 		Itm = 0.0;
4774 		for (ww = p->spec_wl_short; ww <= p->spec_wl_long; ww += p->spec_bw) {
4775 			double O, I;
4776 			getval_lxspec(&p->tillum, &I, ww);
4777 			getval_lxspec(&p->observer[1], &O, ww);
4778 			scale += O;			/* Integrate Y observer values */
4779 			Itm += O * I;
4780 		}
4781 		Itm /= scale;			/* Scale Y observer to unity */
4782 		Itm = 1.0/Itm;			/* Scale factor to make illuminant integral 1.0 */
4783 
4784 		for (j = 0; j < p->tillum.spec_n; j++)
4785 			p->tillum.spec[j] *= Itm;
4786 	}
4787 
4788 	/* Check if the instrument and target/simulated illuminant are the same. */
4789 	/* If they are, FWA compensation can be bypassed. */
4790 	/* (We check for an almost exact matcg on the assumption that these will */
4791 	/* both be xspect presets) */
4792 #define DEQ(A, B)  (fabs(A - B) < 1e-6)
4793 	p->insteqtarget = 0;
4794 	if (p->iillum.spec_n == p->tillum.spec_n
4795 	 && DEQ(p->iillum.spec_wl_short, p->tillum.spec_wl_short)
4796 	 && DEQ(p->iillum.spec_wl_long, p->tillum.spec_wl_long)) {
4797 		for (i = 0; i < p->iillum.spec_n; i++) {
4798 			if (!DEQ(p->tillum.spec[i], p->iillum.spec[i]))
4799 				break;
4800 		}
4801 		if (i >= p->iillum.spec_n) {
4802 			p->insteqtarget = 1;
4803 			DBGF((DBGA,"###### inst equals target illuminant #####\n"));
4804 		}
4805 	}
4806 #undef DEQ
4807 
4808 	/* Compute Y = 1 normalised observer illuminant spectrum */
4809 	{
4810 		double scale;
4811 		double Itm;		/* Target illuminant multiplier */
4812 
4813 		scale = 0.0;
4814 		Itm = 0.0;
4815 		for (ww = p->spec_wl_short; ww <= p->spec_wl_long; ww += p->spec_bw) {
4816 			double O, I;
4817 			getval_lxspec(&p->oillum, &I, ww);
4818 			getval_lxspec(&p->observer[1], &O, ww);
4819 			scale += O;			/* Integrate Y observer values */
4820 			Itm += O * I;
4821 		}
4822 		Itm /= scale;			/* Scale Y observer to unity */
4823 		Itm = 1.0/Itm;			/* Scale factor to make illuminant integral 1.0 */
4824 
4825 		for (j = 0; j < p->oillum.spec_n; j++)
4826 			p->oillum.spec[j] *= Itm;
4827 	}
4828 
4829 	/* Estimate the amount of generic FWA in the media. */
4830 	/* and also compute an estimated media minus FWA spectrum */
4831 	/* by creating a target white line from the media spectrum */
4832 
4833 	/* This is quite good for "normal" media, which has a fairly */
4834 	/* flat underlying (non FWA) response, but doesn't work so */
4835 	/* well for meadia that rolls off at short wavelengths and uses */
4836 	/* FWA to compensate for this. */
4837 
4838 	/* Find darkest point between 450 and 510nm */
4839 	ar = 1e6;
4840 	for (ww = 450.0; ww <= 510.0; ww += p->fwa_bw) {
4841 		double rr;
4842 		getval_lxspec(&p->imedia, &rr, ww);
4843 		DBGF((DBGA,"media %f = %f\n",ww,rr));
4844 
4845 		if (rr < ar) {
4846 			aw = ww;
4847 			ar = rr;
4848 		}
4849 	}
4850 
4851 	/* Find lightest point between A point+70 and 650 */
4852 	br = -1.0;
4853 	for (ww = aw+70.0; ww <= 630.0; ww += p->fwa_bw) {
4854 		double rr;
4855 		getval_lxspec(&p->imedia, &rr, ww);
4856 		DBGF((DBGA,"media %f = %f\n",ww,rr));
4857 		if (rr > br) {
4858 			bw = ww;
4859 			br = rr;
4860 		}
4861 	}
4862 	if (br < ar)
4863 		br = ar;		/* Make flat rather than slope to the right */
4864 
4865 	DBGF((DBGA,"Cuttoff line params: A = %f %f, B = %f %f\n", aw, ar, bw, br));
4866 
4867 #ifdef STOCKFWA			/* Use table shape as FWA basis */
4868 
4869 	/* Compute an Em that explains the bump over the flat line */
4870 	Em = 0.0;
4871 	for (ww = FWA1_emit.spec_wl_short; ww <= (FWA1_emit.spec_wl_long - 100.0); ww += p->fwa_bw) {
4872 		double Rl, rr;
4873 
4874 		/* Compute value of line at this wavelength */
4875 		Rl = (ww - aw)/(bw - aw) * (br - ar) + ar;
4876 
4877 		getval_lxspec(&p->imedia, &rr, ww);		/* Media at this point */
4878 
4879 		if (rr > Rl) {	/* Media is over the line */
4880 			double Ii;
4881 			double Eu;
4882 			double mm;
4883 
4884 			getval_lxspec(&p->iillum, &Ii, ww);	/* Normalised illuminant at this wavelength */
4885 			if (Ii < 1e-9)
4886 				Ii = 1e-9;
4887 			getval_lxspec(&FWA1_emit, &Eu, ww);	/* FWA emission at this wavelength */
4888 			mm = ((rr - Rl) * Ii)/Eu;
4889 			if (mm > Em) {
4890 				DBGF((DBGA,"Update Em to %f at %fnm for target %f\n",mm,ww,rr-Rl));
4891 				Em = mm;		/* Greater multiplier to explain bump */
4892 			}
4893 		}
4894 	}
4895 	DBGF((DBGA,"Em = %f\n",Em));
4896 
4897 	/* Setup spectrum to hold result over exected range */
4898 	/* and base media reflectance */
4899 	p->media = p->imedia;		/* Take copy of media white */
4900 	p->emits = p->imedia;		/* Structure copy */
4901 	xspect_denorm(&p->media);	/* Set norm to 1.0 */
4902 	xspect_denorm(&p->emits);
4903 
4904 	/* Copy emission spectra that explains bump over line */
4905 	/* plus estimated media without FWA spectrum. */
4906 	for (i = 0; i < p->media.spec_n; i++) {
4907 		double Eu, Ii;
4908 		double Rm, Rmb;
4909 
4910 #if defined(__APPLE__) && defined(__POWERPC__)
4911 		gcc_bug_fix(i);
4912 #endif
4913 
4914 		ww = (p->media.spec_wl_long - p->media.spec_wl_short)
4915 		   * ((double)i/(p->media.spec_n-1.0)) + p->media.spec_wl_short;
4916 
4917 		getval_lxspec(&FWA1_emit, &Eu, ww);	/* FWA emission at this wavelength */
4918 		Eu *= Em;
4919 		p->emits.spec[i] = p->emits.norm * Eu;	/* Remember FWA spectrum */
4920 
4921 		Rm = p->media.spec[i]/p->media.norm; 	/* Media at this point */
4922 		getval_lxspec(&p->iillum, &Ii, ww);	/* Normalised illuminant at this wavelength */
4923 		if (Ii < 1e-9)
4924 			Ii = 1e-9;
4925 		Rm *= Ii;						/* Light reflected from media */
4926 
4927 		Rmb = Rm - Eu;					/* Convert media to base media */
4928 		if (Rmb < 0.01)
4929 			Rmb = 0.01;					/* This would be silly */
4930 		p->media.spec[i] = p->media.norm * Rmb/Ii;	/* Convert media to base media */
4931 		DBGF((DBGA,"ww %f, Eu %f, Rm %f, Rmb %f\n",ww, Eu, Rm, Rmb));
4932 
4933 	}
4934 	/* Prevent silliness */
4935 	p->emits.spec[0] = 0.0;
4936 	p->emits.spec[p->emits.spec_n-1] = 0.0;
4937 
4938 #else /* Not STOCK_FWA */
4939 	/* Setup spectrum to hold result over exected range */
4940 	/* and base media reflectance */
4941 	p->media = p->imedia;	/* Take copy of media white */
4942 	p->emits = p->imedia;	/* Structure copy */
4943 	xspect_denorm(&p->media);	/* Set norm to 1.0 */
4944 	xspect_denorm(&p->emits);
4945 
4946 	/* Compute emission spectra that explains bump over line */
4947 	/* plus estimated media without FWA spectrum. */
4948 	/* Do this from long to short to allow for "filter off" trigger */
4949 	flag = 1;		/* Filter is active */
4950 	for (i = (p->media.spec_n-1); i >= 0; i--) {
4951 		double Rl, Rm, Rmb;
4952 		double fwi = 25.0;			/* Smoothing filter width +/- */
4953 		int fres = 5;				/* Smoothing filter resolution */
4954 		double tweight;
4955 
4956 #if defined(__APPLE__) && defined(__POWERPC__)
4957 		gcc_bug_fix(i);
4958 #endif
4959 		/* Wavelength we're generating */
4960 		ww = (p->media.spec_wl_long - p->media.spec_wl_short)
4961 		   * ((double)i/(p->media.spec_n-1.0)) + p->media.spec_wl_short;
4962 
4963 		/* Compute the base media estimate at this point from */
4964 		/* the triangular smoothed filter of the smaller of the */
4965 		/* measured media and the line */
4966 		tweight = 0.0;
4967 		Rmb = 0.0;
4968 		for (j = -fres;  j <= fres; j++) {
4969 			double fww, weight;
4970 
4971 #if defined(__APPLE__) && defined(__POWERPC__)
4972 			gcc_bug_fix(j);
4973 #endif
4974 			fww = ww + (double)j/(double)fres * fwi;
4975 			weight = 1.0 - fabs((double)j/(double)fres);
4976 
4977 			Rl = (fww - aw)/(bw - aw) * (br - ar) + ar;		/* Line at this point */
4978 			getval_lxspec(&p->imedia, &Rm, fww);					/* Media at this point */
4979 
4980 			if (Rm < Rl)
4981 				Rl = Rm;
4982 
4983 			Rmb += Rl * weight;
4984 			tweight += weight;
4985 		}
4986 		Rmb /= tweight;						/* Base media estimate */
4987 
4988 		/* Compute value of line and media at this wavelength */
4989 		Rl = (ww - aw)/(bw - aw) * (br - ar) + ar;		/* Line at this point */
4990 
4991 		getval_lxspec(&p->imedia, &Rm, ww);		/* Media at this point */
4992 		DBGF((DBGA,"ww %f, Rl %f, Rm %f, Rmb %f\n",ww,Rl,Rm,Rmb));
4993 
4994 		/* Stop following the filter once the actual media has crossed over it */
4995 		if (ww < 450.0 && Rm < Rmb)
4996 			flag = 0;
4997 
4998 		/* Don't follow smoothed at long wl or if media has caught up to filtered */
4999 		if (flag == 0 || ww > 570.0)
5000 			Rmb = Rm;
5001 
5002 		if (Rm > Rmb && ww <= 570.0) { 	/* Media is over the line */
5003 			double Ii;
5004 
5005 			p->media.spec[i] = p->media.norm * Rmb;		/* Convert media to base media */
5006 			getval_lxspec(&p->iillum, &Ii, ww);	/* Normalised illuminant at this wavelength */
5007 			if (Ii < 1e-9)
5008 				Ii = 1e-9;
5009 
5010 			p->emits.spec[i] = p->emits.norm * (Rm - Rmb) * Ii;
5011 			DBGF((DBGA,"ww %fnm, Rm %f, Rmb %f, Eu %f\n",ww, Rm, Rmb, p->emits.spec[i]/p->emits.norm));
5012 
5013 		} else {
5014 			p->emits.spec[i] = 0.0;
5015 		}
5016 #ifdef DOPLOT
5017 		xx[i] = ww;
5018 		y1[i] = Rl;
5019 		y2[i] = Rm;
5020 		y3[i] = Rmb;
5021 		y4[i] = p->emits.spec[i]/p->emits.norm;
5022 #endif
5023 	}
5024 #ifdef DOPLOT
5025 	printf("Estimated vs. real media spectrum calculation\n");
5026 	do_plot6(xx,y1,y2,y3,y4,NULL,NULL,p->media.spec_n);
5027 #endif
5028 	/* Prevent silliness */
5029 	p->emits.spec[0] = 0.0;
5030 	p->emits.spec[p->emits.spec_n-1] = 0.0;
5031 #endif /* !STOCKFWA */
5032 
5033 	/* Compute level of UV stimulating FWA */
5034 	p->Sm = 0.0;
5035 	for (ww = FWA1_stim.spec_wl_short; ww <= FWA1_stim.spec_wl_long; ww += p->fwa_bw) {
5036 		double Ii;
5037 		double Su;
5038 
5039 		getval_lxspec(&p->iillum, &Ii, ww);	/* Normalised illuminant at this wavelength */
5040 		if (Ii < 1e-9)
5041 			Ii = 1e-9;
5042 		getval_lxspec(&FWA1_stim, &Su, ww);	/* FWA stimulation profile at this wavelength */
5043 		p->Sm += Su * Ii;
5044 	}
5045 	DBGF((DBGA,"Sm = %f\n",p->Sm));
5046 
5047 	/* Compute FWA content of this media, for information purposes */
5048 	p->FWAc = 0.0;
5049 	for (ww = p->emits.spec_wl_short; ww <= p->emits.spec_wl_long; ww += p->fwa_bw) {
5050 		double Eu;
5051 
5052 		getval_lxspec(&p->emits, &Eu, ww);	/* FWA emission at this wavelength */
5053 		p->FWAc += Eu;
5054 	}
5055 	p->FWAc /= p->Sm;		/* Divided by stimulation */
5056 	DBGF((DBGA,"FWA content = %f\n",p->FWAc));
5057 
5058 	/* Turn on FWA compensation */
5059 	p->convert  = xsp2cie_fwa_convert;
5060 	p->sconvert = xsp2cie_fwa_sconvert;
5061 	p->extract  = xsp2cie_fwa_extract;
5062 	p->apply    = xsp2cie_fwa_apply;
5063 
5064 #if defined(DOPLOT) || defined(DEBUG)
5065 	/* Print the estimated vs. real media spectrum */
5066 	for (i = 0, ww = p->media.spec_wl_short; ww <= p->media.spec_wl_long; ww += 1.0, i++) {
5067 		double Rm;		/* Real media reflectance */
5068 		double Rmb;		/* Media reflectance without FWA */
5069 		double Rmd;		/* Estimated media reflectance with FWA */
5070 		double Ii;
5071 		double Eu;
5072 
5073 		getval_lxspec(&p->imedia, &Rm, ww);	/* Media at this point */
5074 		getval_lxspec(&p->media, &Rmb, ww);	/* Base Media */
5075 		getval_lxspec(&p->iillum, &Ii, ww);	/* Normalised illuminant at this wavelength */
5076 		if (Ii < 1e-9)
5077 			Ii = 1e-9;
5078 		getval_lxspec(&p->emits, &Eu, ww);	/* FWA emission at this wavelength */
5079 
5080 		Rmd = ((Ii * Rmb) + Eu)/Ii;			/* Base Media plus FWA */
5081 		DBGF((DBGA,"%fnm, is %f should be %f, Rmb %f, Eu %f\n",ww, Rm, Rmd, Rmb, Eu));
5082 
5083 #ifdef DOPLOT
5084 		xx[i] = ww;
5085 //		y1[i] = Rm;
5086 		y1[i] = Rmb;
5087 		y2[i] = Eu;
5088 		y3[i] = Rmd;
5089 #endif
5090 	}
5091 #ifdef DOPLOT
5092 	printf("Estimated vs. real media spectrum\n");
5093 	do_plot(xx,y1,y2,y3,i);
5094 #endif
5095 #endif /* DEBUG */
5096 
5097 	DBGF((DBGA,"We're done\n"));
5098 	return 0;
5099 }
5100 
5101 /* Set FWA given instrument illuminant and white media measurement */
xsp2cie_set_fwa(xsp2cie * p,xspect * iillum,xspect * tillum,xspect * media)5102 static int xsp2cie_set_fwa(xsp2cie *p,	/* this */
5103 xspect *iillum,		/* Spectrum of instrument illuminent */
5104 xspect *tillum,		/* Spectrum of target/simulated instrument illuminant */
5105 					/* NULL to use observer model illuminant. */
5106 xspect *media		/* Spectrum of plain media measured under that instrument */
5107 ) {
5108 	p->iillum = *iillum;			/* Take copy of instrument illuminant */
5109 	xspect_denorm(&p->iillum);		/* Remove normalisation factor */
5110 	if (tillum != NULL) {
5111 		p->tillum = *tillum;		/* Take copy of target/simulated instrument illuminant */
5112 		xspect_denorm(&p->tillum);	/* Remove normalisation factor */
5113 	} else {
5114 		p->tillum.spec_n = 0;		/* Use observer model illum. as FWA source */
5115 	}
5116 	p->imedia = *media;		/* Take copy of measured media */
5117 
5118 	return xsp2cie_set_fwa_imp(p);
5119 }
5120 
5121 /* Set FWA given updated conversion illuminants. */
5122 /* We assume that xsp2cie_set_fwa has been called first. */
xsp2cie_update_fwa_custillum(xsp2cie * p,xspect * tillum,xspect * custIllum)5123 static int xsp2cie_update_fwa_custillum(
5124 xsp2cie *p,	/* this */
5125 xspect *tillum,		/* Spectrum of target/simulated instrument illuminant, */
5126                     /* NULL to use previous set_fwa() value. */
5127 xspect *custIllum	/* Spectrum of observer model illuminant */
5128 					/* NULL to use previous new_xsp2cie() value. */
5129 ) {
5130 	if (tillum != NULL) {
5131 		p->tillum = *tillum;		/* Take copy of target/simulated instrument illuminant */
5132 		xspect_denorm(&p->tillum);	/* Remove normalisation factor */
5133 	} else {
5134 		p->tillum.spec_n = 0;		/* Use observer model illum. as FWA source */
5135 	}
5136 
5137 	if (custIllum != NULL) {
5138 		p->illuminant = *custIllum;		/* Updated observer model illuminant */
5139 	}
5140 
5141 	return xsp2cie_set_fwa_imp(p);
5142 }
5143 
5144 /* Get Fluorescent Whitening Agent compensation information */
5145 /* return NZ if error */
xsp2cie_get_fwa_info(xsp2cie * p,double * FWAc)5146 static void xsp2cie_get_fwa_info(
5147 xsp2cie *p,
5148 double *FWAc) {
5149 
5150 	if (FWAc != NULL)
5151 		*FWAc = p->FWAc;
5152 }
5153 
5154 /* Do the FWA corrected spectral to CIE conversion. */
5155 /* If the instrument and target illuminant are the same, */
5156 /* then FWA correction is bypassed. */
5157 /* Note that the input spectrum normalisation value is used. */
5158 /* Emissive spectral values are assumed to be in mW/nm, and sampled */
5159 /* rather than integrated if they are not at 1nm spacing. */
xsp2cie_fwa_sconvert(xsp2cie * p,xspect * sout,double * out,xspect * in)5160 static void xsp2cie_fwa_sconvert(
5161 xsp2cie *p,			/* this */
5162 xspect *sout,		/* Return corrected input spectrum (may be NULL, or same as imput) */
5163 double *out,		/* Return XYZ or D50 Lab value (may be NULL) */
5164 xspect *in			/* Spectrum to be converted */
5165 ) {
5166 	double ww;
5167 	int i, j, k;
5168 	double Emc, Smc;	/* Emission and Stimulation multipiers for instrument meas. */
5169 	double Emct, Smct;	/* Emission and Stimulation multipiers for target illum. */
5170 	double scale = 0.0;
5171 	xspect tsout;		/* Temporary sout */
5172 	double wout[3];		/* Working CIE out */
5173 #ifdef DEBUG
5174 	double chout[3];	/* Out check values */
5175 	double oout[3];
5176 #endif /* DEBUG */
5177 #ifdef DOPLOT_ALL_FWA
5178 	double xx[XSPECT_MAX_BANDS];
5179 	double y1[XSPECT_MAX_BANDS];
5180 	double y2[XSPECT_MAX_BANDS];
5181 	double y3[XSPECT_MAX_BANDS];
5182 	int plix = 0;
5183 #endif /* DOPLOT_ALL_FWA */
5184 
5185 	tsout.spec_n = 0;
5186 	tsout.spec_wl_short = 0.0;
5187 	tsout.spec_wl_long = 0.0;
5188 	tsout.norm = 0.0;
5189 
5190 #define MIN_ILLUM 1e-8		/* Minimum assumed illumination level at wavelength */
5191 #define MIN_REFL  1e-6		/* Minimum assumed reflectance at wavelength */
5192 
5193 	/* With colorant, estimate stimulation level of FWA for instrument illuminant */
5194 	/* and for target illuminant. Because the colorant estimate depends on the FWA */
5195 	/* estimate, and the FWA emissions can contribute to FWA stimulation, */
5196 	/* we itterate a few times to allow this to converge. */
5197 	Emc = Emct = 0.0;
5198 	for (k = 0; k < 4; k++) {
5199 		Smct = Smc = 0.0;
5200 		for (ww = FWA1_stim.spec_wl_short; ww <= FWA1_stim.spec_wl_long; ww += p->fwa_bw) {
5201 			double Kc;		/* FWA contribution for instrument illum */
5202 			double Kct;		/* FWA contribution for target illum */
5203 			double Ii;		/* Instrument illuminant level */
5204 			double It;		/* Target illuminant level */
5205 			double Eu;		/* FWA emmission profile */
5206 			double Rc;		/* Measured reflectance under inst. illum. */
5207 			double Rmb;		/* Media reflectance measured on instrument */
5208 			double Rcch;	/* Half colorant reflectance value */
5209 			double Su;		/* FWA sensitivity */
5210 
5211 			getval_lxspec(&p->emits, &Eu, ww);	/* FWA emission at this wavelength */
5212 			Kc  = Emc * Eu;						/* FWA contribution under inst. illum. */
5213 			Kct = Emct * Eu;					/* FWA contribution under target illum. */
5214 
5215 			getval_lxspec(&p->iillum, &Ii, ww);	/* Normalised instr. illuminant at wavelength */
5216 			if (Ii < MIN_ILLUM)
5217 				Ii = MIN_ILLUM;
5218 
5219 			getval_lxspec(&p->tillum, &It, ww);/* Normalised target. illuminant at wavelength */
5220 			if (It < MIN_ILLUM)
5221 				It = MIN_ILLUM;
5222 
5223 			getval_lxspec(&p->media, &Rmb, ww);	/* Base media reflectance at this wavelength */
5224 			if (Rmb < MIN_REFL)
5225 				Rmb = MIN_REFL;
5226 
5227 			getval_lxspec(in, &Rc, ww)	;		/* Media + colorant reflectance at wavelength */
5228 			if (Rc < 0.0)
5229 				Rc = 0.0;
5230 
5231 #ifdef NEVER
5232 			Rcch = sqrt(Rc/Rmb);				/* Half reflectance estimate (valid if no FWA) */
5233 
5234 #else
5235 			/* Solve for underlying colorant half reflectance, discounting FWA */
5236 			if (Rmb <= MIN_REFL) /* Hmm. */
5237 				Rcch = sqrt(fabs(Rmb));
5238 			else
5239 				Rcch = (-Kc + sqrt(Kc * Kc + 4.0 * Ii * Ii * Rmb * Rc))/(2.0 * Ii * Rmb);
5240 #endif
5241 
5242 			getval_lxspec(&FWA1_stim, &Su, ww);	/* FWA stimulation sensitivity this wavelength */
5243 
5244 
5245 			Smc  += Su * (Ii * Rcch + Kc);
5246 			Smct += Su * (It * Rcch + Kct);
5247 			DBGF((DBGA,"at %.1fnm, Rmb %f, Rc %f, Rch %f, Rcch %f, Ii %f, It %f, Kct %f, Smc %f, Smct %f,\n",ww,Rmb,Rc,sqrt(Rc),Rcch,Ii,It,Kct,Su * (Ii * Rcch + Kc),Su * (It * Rcch + Kct)));
5248 		}
5249 		Emc  = Smc/p->Sm;	/* FWA Emmsion muliplier with colorant for instr. illum. */
5250 		Emct = Smct/p->Sm;	/* FWA Emmsion muliplier with colorant for target illum. */
5251 
5252 		DBGF((DBGA,"Itteration %d, Smc %f, Smct %f, Emc %f, Emct %f\n\n",k, Smc,Smct,Emc,Emct));
5253 	}
5254 
5255 	for (j = 0; j < 3; j++) {
5256 		wout[j] = 0.0;
5257 #ifdef DEBUG
5258 		chout[j] = 0.0;
5259 #endif /* DEBUG */
5260 	}
5261 
5262 	/* Compute CIE output over observer range in bw increments */
5263 	scale = 0.0;
5264 	for (ww = p->spec_wl_short; ww <= p->spec_wl_long; ww += p->spec_bw) {
5265 		double Kc;		/* FWA contribution for instrument illum */
5266 		double Kct;		/* FWA contribution for target illum */
5267 		double Ii;		/* Instrument illuminant level */
5268 		double It;		/* Target illuminant level */
5269 		double Io;		/* Observer illuminant level */
5270 		double Rmb;		/* Base media reflectance estimate */
5271 		double Eu;		/* FWA emmission profile */
5272 		double Rc;		/* Measured reflectance under inst. illum. */
5273 		/*     Rch         Measured half reflectance under inst. illum */
5274 		double Rcch;	/* Corrected Rc colorant half reflectance */
5275 		double Rct;		/* Corrected Rc for target illuminant */
5276 
5277 		getval_lxspec(&p->emits, &Eu, ww);	/* FWA emission at this wavelength */
5278 		Kc  = Emc * Eu;						/* FWA contribution under inst. illum. */
5279 		Kct = Emct * Eu;					/* FWA contribution under target illum. */
5280 
5281 		getval_lxspec(&p->iillum, &Ii, ww);	/* Normalised instr. illuminant at wavelength */
5282 		if (Ii < MIN_ILLUM)
5283 			Ii = MIN_ILLUM;
5284 
5285 		getval_lxspec(&p->tillum, &It, ww);/* Normalised target. illuminant at wavelength */
5286 		if (It < MIN_ILLUM)
5287 			It = MIN_ILLUM;
5288 
5289 		getval_lxspec(&p->media, &Rmb, ww);	/* Base media reflectance at this wavelength */
5290 		if (Rmb < MIN_REFL)
5291 			Rmb = MIN_REFL;
5292 
5293 		getval_lxspec(in, &Rc, ww)	;		/* Media + colorant reflectance at wavelength */
5294 		if (Rc < 0.0)
5295 			Rc = 0.0;
5296 
5297 		/* Solve for underlying colorant half transmittance, discounting FWA */
5298 		if (Rmb <= MIN_REFL) /* Hmm. */
5299 			Rcch = sqrt(fabs(Rmb));
5300 		else
5301 			Rcch = (-Kc + sqrt(Kc * Kc + 4.0 * Ii * Ii * Rmb * Rc))/(2.0 * Ii * Rmb);
5302 
5303 		/* Estimated corrected reflectance */
5304 		Rct = ((It * Rcch * Rmb + Kct) * Rcch)/It;
5305 
5306 		DBGF((DBGA,"at %.1fnm, Rmb %f, Rc %f, Rch %f, Rcch %f, Ii %f, It %f, Kct %f, Rct %f\n",ww,Rmb,Rc,sqrt(Rc),Rcch,Ii,It,Kct,Rct));
5307 
5308 		if (p->insteqtarget)		/* Ignore FWA corrected value if same illuminant */
5309 			Rct = Rc;
5310 
5311 #ifdef DOPLOT_ALL_FWA
5312 		xx[plix] = ww;
5313 		y1[plix] = Rc;			/* Uncorrected reflectance */
5314 //		y2[plix] = Rct - Rc;	/* Difference between corrected and uncorrected */
5315 //		y2[plix] = Rcch * Rcch;		/* Estimated underlying colorant reflectance without FWA */
5316 //		y2[plix] = Rmb;			/* Base media relectance estimate */
5317 		y2[plix] = Kct;			/* FWA contribution under target illuminant */
5318 		y3[plix++] = Rct;		/* Corrected reflectance */
5319 #endif /* DOPLOT_ALL_FWA */
5320 
5321 		/* Observer illuminant */
5322 		getval_lxspec(&p->oillum, &Io, ww);	/* Normalised observer illuminant */
5323 
5324 		/* Compute CIE result */
5325 		for (j = 0; j < 3; j++) {
5326 			double O;
5327 			getval_lxspec(&p->observer[j], &O, ww);
5328 			if (j == 1)
5329 				scale += Io * O;			/* Integrate Y illuminant/observer values */
5330 			wout[j] += Rct * Io * O;		/* Corrected refl. * Observer illuminant */
5331 #ifdef DEBUG
5332 			chout[j] += Rc * It * O;
5333 #endif /* DEBUG */
5334 		}
5335 	}
5336 	if (p->isemis) {
5337 		scale = 0.683002;		/* Convert from mW/m^2 to Lumens/m^2 */
5338 								/* (== 683 Luments/Watt/m^2) */
5339 	} else {
5340 		scale = 1.0/scale;
5341 	}
5342 	for (j = 0; j < 3; j++) {	/* Scale for illuminant/observer normalisation of Y */
5343 		wout[j] *= scale;
5344 #ifdef CLAMP_XYZ
5345 		if (p->clamp && wout[j] < 0.0)
5346 			wout[j] = 0.0;		/* Just to be sure we don't get silly values */
5347 #endif /* CLAMP_XYZ */
5348 	}
5349 
5350 #ifdef DEBUG
5351 	for (j = 0; j < 3; j++) {	/* Scale for illuminant/observer normalisation of Y */
5352 		chout[j] *= scale;
5353 #ifdef CLAMP_XYZ
5354 		if (p->clamp && chout[j] < 0.0)
5355 			chout[j] = 0.0;		/* Just to be sure we don't get silly values */
5356 #endif /* CLAMP_XYZ */
5357 	}
5358 	icmXYZ2Lab(&icmD50, oout, wout);
5359 	icmXYZ2Lab(&icmD50, chout, chout);
5360 	DBGF((DBGA,"Compensated %f %f %f, uncompensated %f %f %f\n",
5361 	oout[0], oout[1], oout[2], chout[0], chout[1], chout[2]));
5362 #endif /* DEBUG */
5363 
5364 #ifdef DOPLOT_ALL_FWA
5365 	printf("FWA compensated spectrum for sample\n");
5366 	do_plot(xx,y1,y2,y3,plix);
5367 #endif /* DOPLOT_ALL_FWA */
5368 
5369 	/* Do it again for output over optional returned spectrum range */
5370 	if (sout != NULL) {
5371 		tsout.spec_n        = in->spec_n;
5372 		tsout.spec_wl_short = in->spec_wl_short;
5373 		tsout.spec_wl_long  = in->spec_wl_long;
5374 		tsout.norm          = in->norm;
5375 
5376 		for (i = 0; i < in->spec_n; i++) {
5377 			double Kc;		/* FWA contribution for instrument illum */
5378 			double Kct;		/* FWA contribution for target illum */
5379 			double Ii;		/* Instrument illuminant level */
5380 			double It;		/* Target/simulated instrument illuminant level */
5381 			double Rmb;		/* Base media reflectance estimate */
5382 			double Eu;		/* FWA emmission profile */
5383 			double Rc;		/* Reflectance under inst. illum. */
5384 			double Rcch;	/* Corrected Rc half reflectance */
5385 			double Rct;		/* Corrected Rc for target illuminant */
5386 
5387 #if defined(__APPLE__) && defined(__POWERPC__)
5388 			gcc_bug_fix(i);
5389 #endif
5390 			ww = (in->spec_wl_long - in->spec_wl_short)
5391 			   * ((double)i/(in->spec_n-1.0)) + in->spec_wl_short;
5392 
5393 			getval_lxspec(&p->emits, &Eu, ww);	/* FWA emission at this wavelength */
5394 			Kc  = Emc * Eu;				/* FWA contribution under inst. illum. */
5395 			Kct = Emct * Eu;			/* FWA contribution under target illum. */
5396 
5397 			getval_lxspec(&p->iillum, &Ii, ww);	/* Normalised instr. illuminant at wavelength */
5398 			if (Ii < MIN_ILLUM)
5399 				Ii = MIN_ILLUM;
5400 
5401 			getval_lxspec(&p->tillum, &It, ww);/* Normalised target. illuminant at wavelength */
5402 			if (It < MIN_ILLUM)
5403 				It = MIN_ILLUM;
5404 
5405 			getval_lxspec(&p->media, &Rmb, ww);	/* Base media reflectance at this wavelength */
5406 			if (Rmb < MIN_REFL)
5407 				Rmb = MIN_REFL;
5408 
5409 			getval_lxspec(in, &Rc, ww)	;		/* Media + colorant reflectance at wavelength */
5410 			if (Rc < 0.0)
5411 				Rc = 0.0;
5412 
5413 			if (Rmb < MIN_REFL) /* Hmm. */
5414 				Rcch = sqrt(fabs(Rmb));
5415 			else
5416 				Rcch = (-Kc + sqrt(Kc * Kc + 4.0 * Ii * Ii * Rmb * Rc))/(2.0 * Ii * Rmb);
5417 
5418 			Rct = ((It * Rcch * Rmb + Kct) * Rcch)/It;
5419 
5420 			if (p->insteqtarget)		/* Ignore FWA corrected value if same illuminant */
5421 				Rct = Rc;
5422 
5423 			tsout.spec[i] = tsout.norm * Rct;
5424 		}
5425 	}
5426 
5427 	/* If Lab is target, convert to D50 Lab */
5428 	if (p->doLab) {
5429 		icmXYZ2Lab(&icmD50, wout, wout);
5430 	}
5431 
5432 	if (out != NULL) {
5433 		out[0] = wout[0];
5434 		out[1] = wout[1];
5435 		out[2] = wout[2];
5436 	}
5437 
5438 	if (sout != NULL) {
5439 		*sout = tsout;		/* Structure copy */
5440 	}
5441 
5442 #undef MIN_ILLUM
5443 #undef MIN_REFL
5444 
5445 }
5446 
5447 /* Normal conversion without returning spectrum */
xsp2cie_fwa_convert(xsp2cie * p,double * out,xspect * in)5448 static void xsp2cie_fwa_convert(xsp2cie *p, double *out, xspect *in) {
5449 	xsp2cie_fwa_sconvert(p, NULL, out, in);
5450 }
5451 
5452 /* Extract the colorant reflectance value from the media. Takes FWA */
5453 /* into account if set. FWA must be set. */
xsp2cie_fwa_extract(xsp2cie * p,xspect * out,xspect * in)5454 static int xsp2cie_fwa_extract(xsp2cie *p,	/* this */
5455 xspect *out,			/* Extracted colorant refl. spectrum */
5456 xspect *in				/* Spectrum to be converted, normalised by norm */
5457 ) {
5458 	double ww;
5459 	int i, j, k;
5460 	double Emc, Smc;	/* Emission and Stimulation multipiers for instrument meas. */
5461 
5462 #ifdef DOPLOT_ALL_FWA
5463 	double xx[XSPECT_MAX_BANDS];
5464 	double y1[XSPECT_MAX_BANDS];
5465 	double y2[XSPECT_MAX_BANDS];
5466 	double y3[XSPECT_MAX_BANDS];
5467 	int plix = 0;
5468 #endif /* DOPLOT_ALL_FWA */
5469 
5470 	/* With colorant, estimate stimulation level of FWA for instrument illuminant */
5471 	/* and for target illuminant. Because the colorant estimate depends on the FWA */
5472 	/* estimate, and the FWA emissions can contribute to FWA stimulation, */
5473 	/* we itterate a few times to allow this to converge. */
5474 	Emc = 0.0;
5475 	for (k = 0; k < 4; k++) {
5476 		Smc = 0.0;
5477 		for (ww = FWA1_stim.spec_wl_short; ww <= FWA1_stim.spec_wl_long; ww += p->fwa_bw) {
5478 			double Kc;		/* FWA contribution for instrument illum */
5479 			double Ii;		/* Instrument illuminant level */
5480 			double Su;		/* FWA sensitivity */
5481 			double Rmb;		/* Media reflectance measured on instrument */
5482 			double Eu;		/* FWA emmission profile */
5483 			double Rc;		/* Reflectance under inst. illum. */
5484 			double Rcch;	/* Half colorant reflectance value */
5485 
5486 			getval_lxspec(&p->emits, &Eu, ww);	/* FWA emission at this wavelength */
5487 			Kc  = Emc * Eu;						/* FWA contribution under inst. illum. */
5488 
5489 			getval_lxspec(&p->media, &Rmb, ww);	/* Base Media */
5490 			getval_lxspec(in, &Rc, ww);			/* Media + colorant reflectance at wavelength + FWA */
5491 			getval_lxspec(&p->iillum, &Ii, ww);	/* Normalised instrument illuminant */
5492 			if (Ii < 1e-9)
5493 				Ii = 1e-9;
5494 
5495 			if (Rmb < 1e-9) /* Hmm. */
5496 				Rcch = sqrt(fabs(Rmb));
5497 			else
5498 				Rcch = (-Kc + sqrt(Kc * Kc + 4.0 * Ii * Ii * Rmb * Rc))/(2.0 * Ii * Rmb);
5499 
5500 			getval_lxspec(&FWA1_stim, &Su, ww);	/* FWA stimulation sensitivity this wavelength */
5501 			Smc  += Su * (Ii * Rcch + Kc);
5502 
5503 //DBGF((DBGA,"ww = %f, Rmb %f, Rcch %f, Ii %f, Su %f, Smc %f\n", ww,Rmb,Rcch,Ii,Su,Smc));
5504 		}
5505 		Emc  = Smc/p->Sm;	/* FWA Emmsion muliplier with colorant for instr. illum. */
5506 	}
5507 
5508 	DBGF((DBGA,"extract:\n"));
5509 	DBGF((DBGA,"Smc = %f\n",Smc));
5510 	DBGF((DBGA,"Emc = %f\n",Emc));
5511 
5512 	out->spec_n = in->spec_n;
5513 	out->spec_wl_short = in->spec_wl_short;
5514 	out->spec_wl_long = in->spec_wl_long;
5515 	out->norm = in->norm;
5516 
5517 	for (i = 0; i < in->spec_n; i++) {
5518 		double Kc;		/* FWA contribution for instrument illum */
5519 		double Ii;		/* Instrument illuminant level */
5520 		double Rmb;		/* Base media reflectance estimate */
5521 		double Eu;		/* FWA emmission profile */
5522 		double Rc;		/* Reflectance under inst. illum. */
5523 		double Rcch;	/* Corrected Rc half reflectance */
5524 
5525 #if defined(__APPLE__) && defined(__POWERPC__)
5526 		gcc_bug_fix(i);
5527 #endif
5528 		ww = (in->spec_wl_long - in->spec_wl_short)
5529 		   * ((double)i/(in->spec_n-1.0)) + in->spec_wl_short;
5530 
5531 		getval_lxspec(&p->emits, &Eu, ww);	/* FWA emission at this wavelength */
5532 		Kc  = Emc * Eu;						/* FWA contribution under inst. illum. */
5533 
5534 		getval_lxspec(&p->media, &Rmb, ww);	/* Base Media */
5535 		getval_lxspec(in, &Rc, ww);			/* Media + colorant reflectance at wavelength + FWA */
5536 		getval_lxspec(&p->iillum, &Ii, ww);	/* Normalised instrument illuminant */
5537 		if (Ii < 1e-9)
5538 			Ii = 1e-9;
5539 
5540 		if (Rmb < 1e-9) /* Hmm. */
5541 			Rcch = sqrt(fabs(Rmb));
5542 		else
5543 			Rcch = (-Kc + sqrt(Kc * Kc + 4.0 * Ii * Ii * Rmb * Rc))/(2.0 * Ii * Rmb);
5544 
5545 		Rcch *= Rcch;	/* Full reflectance value */
5546 
5547 		out->spec[i] = out->norm * Rcch;
5548 
5549 #ifdef DOPLOT_ALL_FWA
5550 		xx[plix] = ww;
5551 		y1[plix] = Rmb;			/* Base media */
5552 		y2[plix] = Rc;			/* Uncorrected reflectance */
5553 		y3[plix] = Rcch;		/* Underlying colorant reflectance without FWA */
5554 		plix++;
5555 #endif /* DOPLOT_ALL_FWA */
5556 	}
5557 #ifdef DOPLOT_ALL_FWA
5558 	printf("FWA compensated extraction for sample\n");
5559 	do_plot(xx,y1,y2,y3,plix);
5560 #endif /* DOPLOT_ALL_FWA */
5561 	return 0;
5562 }
5563 
5564 
5565 /* Apply the colorant reflectance value from the media. Takes FWA */
5566 /* into account if set. DOESN'T convert to FWA target illumination! */
5567 /* FWA must be set. */
xsp2cie_fwa_apply(xsp2cie * p,xspect * out,xspect * in)5568 static int xsp2cie_fwa_apply(xsp2cie *p,	/* this */
5569 xspect *out,			/* Applied refl. spectrum */
5570 xspect *in				/* Colorant reflectance to be applied */
5571 ) {
5572 	double ww;
5573 	int i, j, k;
5574 	double Emc, Smc;	/* Emission and Stimulation multipiers for instrument meas. */
5575 
5576 #ifdef DOPLOT_ALL_FWA
5577 	double xx[XSPECT_MAX_BANDS];
5578 	double y1[XSPECT_MAX_BANDS];
5579 	double y2[XSPECT_MAX_BANDS];
5580 	double y3[XSPECT_MAX_BANDS];
5581 	int plix = 0;
5582 #endif /* DOPLOT_ALL_FWA */
5583 
5584 	/* With colorant, estimate stimulation level of FWA for instrument illuminant. */
5585 	/* We itterate a few times to allow for FWA self stimulation. */
5586 	Emc = 0.0;
5587 	for (k = 0; k < 4; k++) {
5588 		Smc = 0.0;
5589 		for (ww = FWA1_stim.spec_wl_short; ww <= FWA1_stim.spec_wl_long; ww += p->fwa_bw) {
5590 			double Kc;		/* FWA contribution for instrument illum */
5591 			double Ii;		/* Instrument illuminant level */
5592 			double Eu;		/* FWA emmission profile */
5593 			double Su;		/* FWA sensitivity */
5594 			double Rcch;	/* Half colorant reflectance value */
5595 
5596 			getval_lxspec(&p->emits, &Eu, ww);	/* FWA emission at this wavelength */
5597 			Kc  = Emc * Eu;						/* FWA contribution under inst. illum. */
5598 
5599 			getval_lxspec(in, &Rcch, ww);		/* Colorant reflectance at wavelength */
5600 			Rcch = sqrt(Rcch);					/* Half reflectance estimate (valid if no FWA) */
5601 
5602 			getval_lxspec(&p->iillum, &Ii, ww);	/* Normalised instr. illuminant at wavelength */
5603 			if (Ii < 1e-9)
5604 				Ii = 1e-9;
5605 
5606 			getval_lxspec(&FWA1_stim, &Su, ww);	/* FWA stimulation sensitivity this wavelength */
5607 			Smc  += Su * (Ii * Rcch + Kc);
5608 //DBGF((DBGA,"ww = %f, Rcch %f, Ii %f, Su %f, Smc %f\n", ww,Rcch,Ii,Su,Smc));
5609 		}
5610 		Emc  = Smc/p->Sm;	/* FWA Emmsion muliplier with colorant for instr. illum. */
5611 	}
5612 
5613 	DBGF((DBGA,"apply:\n"));
5614 	DBGF((DBGA,"Smc = %f\n",Smc));
5615 	DBGF((DBGA,"Emc = %f\n",Emc));
5616 
5617 	out->spec_n = in->spec_n;
5618 	out->spec_wl_short = in->spec_wl_short;
5619 	out->spec_wl_long = in->spec_wl_long;
5620 	out->norm = in->norm;
5621 
5622 	for (i = 0; i < in->spec_n; i++) {
5623 		double Kc;		/* FWA contribution for instrument illum */
5624 		double Ii;		/* Instrument illuminant level */
5625 		double Rmb;		/* Base media reflectance estimate */
5626 		double Eu;		/* FWA emmission profile */
5627 		double Rc;		/* Reflectance under inst. illum. */
5628 		double Rcch;	/* Rc half reflectance */
5629 		double RcI;		/* Reconstituted Rc for inst. illuminant times illuminant */
5630 
5631 #if defined(__APPLE__) && defined(__POWERPC__)
5632 		gcc_bug_fix(i);
5633 #endif
5634 		ww = (in->spec_wl_long - in->spec_wl_short)
5635 		   * ((double)i/(in->spec_n-1.0)) + in->spec_wl_short;
5636 
5637 		getval_lxspec(&p->emits, &Eu, ww);	/* FWA emission at this wavelength */
5638 		Kc  = Emc * Eu;						/* FWA contribution under inst. illum. */
5639 
5640 		getval_lxspec(&p->media, &Rmb, ww);	/* Base Media */
5641 		getval_lxspec(in, &Rcch, ww);		/* Colorant reflectance at wavelength */
5642 		Rcch = sqrt(Rcch);					/* Half reflectance at wavelength */
5643 		if (Rmb < 1e-9) /* Hmm. */
5644 			Rcch = sqrt(fabs(Rmb));
5645 
5646 		getval_lxspec(&p->iillum, &Ii, ww);	/* Normalised instrument illuminant */
5647 		if (Ii < 1e-9)
5648 			Ii = 1e-9;
5649 
5650 		RcI = (Ii * Rcch * Rmb + Kc) * Rcch;
5651 
5652 		out->spec[i] = out->norm * RcI/Ii;		/* Reconstituted reflectance */
5653 #ifdef DOPLOT_ALL_FWA
5654 		xx[plix] = ww;
5655 		y1[plix] = Rmb;			/* Base media */
5656 		y2[plix] = Rcch;		/* Underlying colorant reflectance without FWA */
5657 		y3[plix] = RcI/Ii;		/* Reconstituted reflectance */
5658 		plix++;
5659 #endif /* DOPLOT_ALL_FWA */
5660 	}
5661 #ifdef DOPLOT_ALL_FWA
5662 	printf("FWA compensated application for sample\n");
5663 	do_plot(xx,y1,y2,y3,plix);
5664 #endif /* DOPLOT_ALL_FWA */
5665 
5666 	return 0;
5667 }
5668 
5669 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
5670 #endif /* !SALONEINSTLIB */
5671 
5672 /* Override the integration wavelength range and step size */
xsp2cie_set_int_steps(xsp2cie * p,double bw,double wl_short,double wl_long)5673 static void xsp2cie_set_int_steps(
5674 xsp2cie *p,			/* this */
5675 double bw,			/* Integration step size (nm) */
5676 double wl_short,	/* Starting nm */
5677 double wl_long		/* Ending nm */
5678 ) {
5679 	p->spec_bw		 = bw;
5680 	p->spec_wl_short = wl_short;
5681 	p->spec_wl_long  = wl_long;
5682 }
5683 
5684 /* Do the normal spectral to CIE conversion. */
5685 /* Note that the input spectrum normalisation value is used. */
5686 /* Emissive spectral values are assumed to be in mW/nm, and sampled */
5687 /* rather than integrated if they are not at 1nm spacing. */
xsp2cie_sconvert(xsp2cie * p,xspect * sout,double * out,xspect * in)5688 void xsp2cie_sconvert(
5689 xsp2cie *p,			/* this */
5690 xspect *sout,		/* Return input spectrum (may be NULL) */
5691 double *out,		/* Return XYZ or D50 Lab value */
5692 xspect *in			/* Spectrum to be converted */
5693 ) {
5694 	int j;
5695 	double scale = 0.0;
5696 
5697 	/* Compute the XYZ values (normalised to 1.0) */
5698 	for (j = 0; j < 3; j++) {
5699 		double ww;
5700 
5701 		/* Integrate at 1nm intervals over the observer range (as */
5702 		/* per CIE recommendations). Lower resolution spectra are */
5703 		/* upsampled using linear/3rd order polinomial interpolated */
5704 		/* (also as per CIE recommendations), and consistent (?) with the */
5705 		/* assumption of a triangular spectral response made in the */
5706 		/* ANSI CGATS.5-1993 spec. If illumninant or material spectra */
5707 		/* values are truncated at the extremes, then the last valid values */
5708 		/* are used, also consistent with CIE and ANSI CGATS recommendations. */
5709 		out[j] = 0.0;
5710 		for (ww = p->spec_wl_short; ww <= p->spec_wl_long; ww += p->spec_bw) {
5711 			double I = 1.0, O, S;
5712 			if (!p->isemis)
5713 				getval_xspec(&p->illuminant, &I, ww);
5714 			getval_xspec(&p->observer[j], &O, ww);
5715 			getval_xspec(in, &S, ww);
5716 			if (j == 1)
5717 				scale += I * O;			/* Integrate Y illuminant * observer values */
5718 			out[j] += I * O * S;
5719 		}
5720 	}
5721 	if (p->isemis) {
5722 		// Hmm. Should we really make scale += O for this case and then
5723 		// scale = 0.683002/scale ??
5724 		scale = 0.683002;	/* Convert from mW/m^2 to Lumens/m^2 */
5725 							/* (== 683 Luments/Watt/m^2) */
5726 	} else {
5727 		scale = 1.0/scale;
5728 	}
5729 	for (j = 0; j < 3; j++) {	/* Scale for illuminant/observer normalisation of Y */
5730 		out[j] *= scale;
5731 #ifdef CLAMP_XYZ
5732 		if (p->clamp && out[j] < 0.0)
5733 			out[j] = 0.0;		/* Just to be sure we don't get silly values */
5734 #endif /* CLAMP_XYZ */
5735 	}
5736 
5737 	/* If Lab is target, convert to D50 Lab */
5738 	if (p->doLab) {
5739 		icmXYZ2Lab(&icmD50, out, out);
5740 	}
5741 
5742 	if (sout != NULL) {
5743 		*sout = *in;	/* Structure copy */
5744 	}
5745 }
5746 
5747 /* Normal Tristumulus conversion */
xsp2cie_convert(xsp2cie * p,double * out,xspect * in)5748 void xsp2cie_convert(xsp2cie *p, double *out, xspect *in) {
5749 	xsp2cie_sconvert(p, NULL, out, in);
5750 }
5751 
5752 /* Return the illuminant XYZ being used in the CIE XYZ/Lab conversion. */
5753 /* Note that this will returne the 'E' illuminant XYZ for emissive. */
xsp2cie_get_cie_il(xsp2cie * p,double * xyz)5754 void xsp2cie_get_cie_il(xsp2cie *p, double *xyz) {
5755 	xspect sp;
5756 
5757 	standardIlluminant(&sp, icxIT_E, 0.0);
5758 	p->convert(p, xyz, &sp);
5759 	if (p->doLab)
5760 		icmLab2XYZ(&icmD50, xyz, xyz);
5761 }
5762 
xsp2cie_del(xsp2cie * p)5763 void xsp2cie_del(
5764 xsp2cie *p
5765 ) {
5766 	free(p);
5767 	return;
5768 }
5769 
5770 /* Create and return a new spectral conversion object */
new_xsp2cie(icxIllumeType ilType,xspect * custIllum,icxObserverType obType,xspect custObserver[3],icColorSpaceSignature rcs,icxClamping clamp)5771 xsp2cie *new_xsp2cie(
5772 icxIllumeType ilType,			/* Illuminant */
5773 xspect        *custIllum,		/* Custom illuminant if ilType == icxIT_custom */
5774 icxObserverType obType,			/* Observer */
5775 xspect        custObserver[3],	/* Custom observer if obType == icxOT_custom */
5776 icColorSpaceSignature  rcs,		/* Return color space, icSigXYZData or D50 icSigLabData */
5777 								/* ** Must be icSigXYZData if SALONEINSTLIB ** */
5778 icxClamping clamp				/* NZ to clamp XYZ/Lab to be +ve */
5779 ) {
5780 	xsp2cie *p;
5781 
5782 	if ((p = (xsp2cie *) calloc(1,sizeof(xsp2cie))) == NULL)
5783 		return NULL;
5784 
5785 	p->isemis = 0;
5786 	switch (ilType) {
5787 	    case icxIT_none:
5788 			p->illuminant = il_none;			/* Emissive */
5789 			p->isemis = 1;
5790 			break;
5791 	    case icxIT_custom:
5792 			p->illuminant = *custIllum;			/* Struct copy */
5793 			break;
5794 	    case icxIT_A:
5795 			p->illuminant = il_A;
5796 			break;
5797 	    case icxIT_C:
5798 			p->illuminant = il_C;
5799 			break;
5800 	    case icxIT_default:
5801 	    case icxIT_D50:
5802 			p->illuminant = il_D50;
5803 			break;
5804 	    case icxIT_D50M2:
5805 			if (il_D50M2.spec_n == 0)
5806 				uv_filter(&il_D50M2, &il_D50);
5807 			p->illuminant = il_D50M2;
5808 			break;
5809 	    case icxIT_D55:
5810 			daylight_il(&p->illuminant, 5500.0);
5811 			break;
5812 	    case icxIT_D65:
5813 			p->illuminant = il_D65;
5814 			break;
5815 	    case icxIT_D75:
5816 			daylight_il(&p->illuminant, 7500.0);
5817 	    case icxIT_E:
5818 			p->illuminant = il_none;
5819 			break;
5820 #ifndef SALONEINSTLIB
5821 	    case icxIT_F5:
5822 			p->illuminant = il_F5;
5823 			break;
5824 	    case icxIT_F8:
5825 			p->illuminant = il_F8;
5826 			break;
5827 	    case icxIT_F10:
5828 			p->illuminant = il_F10;
5829 			break;
5830 		case icxIT_Spectrocam:
5831 			p->illuminant = il_Spectrocam;
5832 			break;
5833 #endif /* !SALONEINSTLIB */
5834 		default:
5835 			DBGF((DBGA,"new_xsp2cie() unrecognised illuminant 0x%x\n",ilType));
5836 			free(p);
5837 			return NULL;
5838 	}
5839 
5840 	/* Do 3 structure copies to record observer sensitivity curves */
5841 	switch (obType) {
5842     	case icxOT_custom:
5843 			p->observer[0] = custObserver[0];
5844 			p->observer[1] = custObserver[1];
5845 			p->observer[2] = custObserver[2];
5846 			break;
5847     	case icxOT_default:
5848     	case icxOT_CIE_1931_2:
5849 			p->observer[0] = ob_CIE_1931_2[0];
5850 			p->observer[1] = ob_CIE_1931_2[1];
5851 			p->observer[2] = ob_CIE_1931_2[2];
5852 			break;
5853     	case icxOT_CIE_1964_10:
5854 			p->observer[0] = ob_CIE_1964_10[0];
5855 			p->observer[1] = ob_CIE_1964_10[1];
5856 			p->observer[2] = ob_CIE_1964_10[2];
5857 			break;
5858 #ifndef SALONEINSTLIB
5859     	case icxOT_Stiles_Burch_2:
5860 			p->observer[0] = ob_Stiles_Burch_2[0];
5861 			p->observer[1] = ob_Stiles_Burch_2[1];
5862 			p->observer[2] = ob_Stiles_Burch_2[2];
5863 			break;
5864     	case icxOT_Judd_Voss_2:
5865 			p->observer[0] = ob_Judd_Voss_2[0];
5866 			p->observer[1] = ob_Judd_Voss_2[1];
5867 			p->observer[2] = ob_Judd_Voss_2[2];
5868 			break;
5869     	case icxOT_CIE_1964_10c:
5870 			p->observer[0] = ob_CIE_1964_10c[0];
5871 			p->observer[1] = ob_CIE_1964_10c[1];
5872 			p->observer[2] = ob_CIE_1964_10c[2];
5873 			break;
5874     	case icxOT_Shaw_Fairchild_2:
5875 			p->observer[0] = ob_Shaw_Fairchild_2[0];
5876 			p->observer[1] = ob_Shaw_Fairchild_2[1];
5877 			p->observer[2] = ob_Shaw_Fairchild_2[2];
5878 			break;
5879     	case icxOT_EBU_2012:
5880 			p->observer[0] = ob_EBU_2012[0];
5881 			p->observer[1] = ob_EBU_2012[1];
5882 			p->observer[2] = ob_EBU_2012[2];
5883 			break;
5884 #endif /* !SALONEINSTLIB */
5885 		default:
5886 			DBGF((DBGA,"new_xsp2cie() unrecognised observer type 0x%x\n",obType));
5887 			free(p);
5888 			return NULL;
5889 	}
5890 
5891 	if (rcs == icSigXYZData)
5892 		p->doLab = 0;
5893 #ifndef SALONEINSTLIB
5894 	else if (rcs == icSigLabData)
5895 		p->doLab = 1;
5896 #endif /* !SALONEINSTLIB */
5897 	else {
5898 		DBGF((DBGA,"new_xsp2cie() unrecognised CIE type 0x%x",rcs));
5899 		free(p);
5900 		return NULL;
5901 	}
5902 
5903 	p->clamp = clamp;
5904 
5905 	p->spec_bw       = 1.0;				/* 1nm integration */
5906 	p->spec_wl_short = p->observer[1].spec_wl_short;
5907 	p->spec_wl_long  = p->observer[1].spec_wl_long;
5908 
5909 	p->set_int_steps = xsp2cie_set_int_steps;
5910 	p->convert       = xsp2cie_convert;
5911 	p->sconvert      = xsp2cie_sconvert;
5912 	p->get_cie_il    = xsp2cie_get_cie_il;
5913 #ifndef SALONEINSTLIB
5914 	p->set_mw        = xsp2cie_set_mw;		/* Default no media white */
5915 	p->set_fwa       = xsp2cie_set_fwa;		/* Default no FWA compensation */
5916 	p->update_fwa_custillum = xsp2cie_update_fwa_custillum;
5917 	p->get_fwa_info  = xsp2cie_get_fwa_info;
5918 	p->extract       = xsp2cie_extract;
5919 	p->apply         = xsp2cie_apply;
5920 #endif /* !SALONEINSTLIB */
5921 	p->del           = xsp2cie_del;
5922 
5923 	return p;
5924 }
5925 
5926 
5927 #ifndef SALONEINSTLIB
5928 
5929 /* -------------------------------------------------------- */
5930 
5931 /* Return the spectrum locus range for the given observer */
5932 /* return 0 on sucecss, nz if observer not known */
icx_spectrum_locus_range(double * min_wl,double * max_wl,icxObserverType obType)5933 int icx_spectrum_locus_range(double *min_wl, double *max_wl, icxObserverType obType) {
5934 	xspect *sp[3];
5935 	if (standardObserver(sp, obType))
5936 		return 1;
5937 	if (min_wl != NULL)
5938 		*min_wl = sp[0]->spec_wl_short;
5939 	if (max_wl != NULL)
5940 		*max_wl = sp[0]->spec_wl_long;
5941 
5942 	return 0;
5943 }
5944 
5945 /* Return an XYZ that is on the spectrum locus for the given observer. */
5946 /* wl is the input wavelength in the range icx_spectrum_locus_range(), */
5947 /* and return clipped result if outside this range. */
5948 /* Return nz if observer unknown. */
icx_spectrum_locus(double xyz[3],double wl,icxObserverType obType)5949 int icx_spectrum_locus(double xyz[3], double wl, icxObserverType obType) {
5950 	xspect *sp[3];
5951 
5952 	DBGF((DBGA,"icx_chrom_locus got obs %d wl %f\n",obType, wl));
5953 
5954 	if (standardObserver(sp, obType))
5955 		return 1;
5956 
5957 	if (wl < sp[0]->spec_wl_short)
5958 		wl = sp[0]->spec_wl_short;
5959 	if (wl > sp[0]->spec_wl_long)
5960 		wl = sp[0]->spec_wl_long;
5961 
5962 	xyz[0] = value_xspect(sp[0], wl);
5963 	xyz[1] = value_xspect(sp[1], wl);
5964 	xyz[2] = value_xspect(sp[2], wl);
5965 
5966 	DBGF((DBGA,"returning %f %f %f\n", xyz[0], xyz[1], xyz[2]));
5967 
5968 	return 0;
5969 }
5970 
5971 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
5972 /* Pre-calculated spectral locuses of Daylight and Plankian at 5 Mired intervals, */
5973 /* used by the fast but slightly less accurate CCT support icx_XYZ2ill_ct2() */
5974 /* Created using illlocus.c */
5975 
5976 /* These aren't actually spectrum, they are XYZ values */
5977 /* indexed by temperature in Mired */
5978 
5979 static xspect illoc_Plankian_CIE_1931_2[3] = {
5980 	{
5981 		481, 40.000000, 1000.000000,
5982 		1.0,
5983 		{
5984 			1.001190, 1.000021, 0.998861, 0.997711, 0.996571,
5985 			0.995444, 0.994330, 0.993229, 0.992143, 0.991072,
5986 			0.990017, 0.988980, 0.987961, 0.986960, 0.985979,
5987 			0.985018, 0.984078, 0.983159, 0.982263, 0.981390,
5988 			0.980540, 0.979714, 0.978913, 0.978137, 0.977387,
5989 			0.976663, 0.975965, 0.975295, 0.974652, 0.974036,
5990 			0.973449, 0.972890, 0.972359, 0.971858, 0.971385,
5991 			0.970942, 0.970529, 0.970145, 0.969791, 0.969468,
5992 			0.969174, 0.968910, 0.968677, 0.968474, 0.968301,
5993 			0.968159, 0.968047, 0.967965, 0.967914, 0.967893,
5994 			0.967902, 0.967941, 0.968010, 0.968109, 0.968238,
5995 			0.968396, 0.968584, 0.968802, 0.969049, 0.969325,
5996 			0.969629, 0.969963, 0.970325, 0.970715, 0.971134,
5997 			0.971581, 0.972055, 0.972558, 0.973087, 0.973644,
5998 			0.974227, 0.974838, 0.975475, 0.976138, 0.976827,
5999 			0.977542, 0.978282, 0.979048, 0.979839, 0.980655,
6000 			0.981495, 0.982360, 0.983249, 0.984162, 0.985098,
6001 			0.986058, 0.987041, 0.988047, 0.989076, 0.990127,
6002 			0.991200, 0.992295, 0.993412, 0.994551, 0.995711,
6003 			0.996891, 0.998093, 0.999315, 1.000557, 1.001820,
6004 			1.003102, 1.004404, 1.005726, 1.007066, 1.008426,
6005 			1.009804, 1.011201, 1.012616, 1.014050, 1.015501,
6006 			1.016970, 1.018456, 1.019960, 1.021480, 1.023018,
6007 			1.024572, 1.026143, 1.027729, 1.029332, 1.030951,
6008 			1.032586, 1.034236, 1.035901, 1.037581, 1.039276,
6009 			1.040986, 1.042711, 1.044450, 1.046203, 1.047970,
6010 			1.049751, 1.051546, 1.053354, 1.055175, 1.057010,
6011 			1.058857, 1.060718, 1.062591, 1.064477, 1.066375,
6012 			1.068285, 1.070207, 1.072141, 1.074087, 1.076045,
6013 			1.078013, 1.079994, 1.081985, 1.083987, 1.086000,
6014 			1.088024, 1.090059, 1.092103, 1.094159, 1.096224,
6015 			1.098299, 1.100384, 1.102479, 1.104584, 1.106698,
6016 			1.108822, 1.110954, 1.113096, 1.115247, 1.117407,
6017 			1.119575, 1.121752, 1.123938, 1.126132, 1.128334,
6018 			1.130544, 1.132763, 1.134989, 1.137223, 1.139465,
6019 			1.141715, 1.143972, 1.146236, 1.148508, 1.150786,
6020 			1.153072, 1.155365, 1.157665, 1.159971, 1.162284,
6021 			1.164604, 1.166930, 1.169263, 1.171601, 1.173946,
6022 			1.176297, 1.178654, 1.181017, 1.183386, 1.185760,
6023 			1.188140, 1.190526, 1.192917, 1.195313, 1.197715,
6024 			1.200122, 1.202534, 1.204951, 1.207372, 1.209799,
6025 			1.212231, 1.214667, 1.217107, 1.219553, 1.222002,
6026 			1.224456, 1.226915, 1.229377, 1.231844, 1.234315,
6027 			1.236790, 1.239268, 1.241751, 1.244237, 1.246727,
6028 			1.249221, 1.251718, 1.254219, 1.256723, 1.259230,
6029 			1.261741, 1.264255, 1.266772, 1.269292, 1.271816,
6030 			1.274342, 1.276871, 1.279403, 1.281938, 1.284475,
6031 			1.287015, 1.289558, 1.292103, 1.294651, 1.297201,
6032 			1.299753, 1.302308, 1.304865, 1.307424, 1.309985,
6033 			1.312548, 1.315113, 1.317681, 1.320250, 1.322821,
6034 			1.325393, 1.327968, 1.330544, 1.333122, 1.335701,
6035 			1.338282, 1.340865, 1.343448, 1.346034, 1.348620,
6036 			1.351208, 1.353797, 1.356387, 1.358979, 1.361571,
6037 			1.364165, 1.366759, 1.369355, 1.371951, 1.374548,
6038 			1.377146, 1.379745, 1.382345, 1.384945, 1.387546,
6039 			1.390147, 1.392749, 1.395352, 1.397955, 1.400559,
6040 			1.403162, 1.405767, 1.408371, 1.410976, 1.413581,
6041 			1.416186, 1.418792, 1.421397, 1.424003, 1.426609,
6042 			1.429214, 1.431820, 1.434425, 1.437031, 1.439636,
6043 			1.442241, 1.444846, 1.447451, 1.450055, 1.452659,
6044 			1.455263, 1.457866, 1.460469, 1.463072, 1.465674,
6045 			1.468275, 1.470876, 1.473477, 1.476077, 1.478676,
6046 			1.481274, 1.483872, 1.486469, 1.489065, 1.491661,
6047 			1.494255, 1.496849, 1.499442, 1.502034, 1.504625,
6048 			1.507215, 1.509804, 1.512392, 1.514979, 1.517565,
6049 			1.520150, 1.522734, 1.525316, 1.527898, 1.530478,
6050 			1.533057, 1.535634, 1.538211, 1.540786, 1.543359,
6051 			1.545932, 1.548503, 1.551072, 1.553640, 1.556207,
6052 			1.558772, 1.561335, 1.563897, 1.566458, 1.569017,
6053 			1.571574, 1.574130, 1.576684, 1.579236, 1.581787,
6054 			1.584336, 1.586883, 1.589429, 1.591972, 1.594514,
6055 			1.597054, 1.599593, 1.602129, 1.604664, 1.607196,
6056 			1.609727, 1.612256, 1.614782, 1.617307, 1.619830,
6057 			1.622351, 1.624869, 1.627386, 1.629901, 1.632413,
6058 			1.634924, 1.637432, 1.639938, 1.642442, 1.644944,
6059 			1.647444, 1.649941, 1.652436, 1.654929, 1.657420,
6060 			1.659908, 1.662394, 1.664878, 1.667359, 1.669838,
6061 			1.672315, 1.674790, 1.677261, 1.679731, 1.682198,
6062 			1.684663, 1.687125, 1.689585, 1.692042, 1.694497,
6063 			1.696949, 1.699399, 1.701846, 1.704291, 1.706733,
6064 			1.709173, 1.711610, 1.714044, 1.716476, 1.718905,
6065 			1.721331, 1.723755, 1.726176, 1.728594, 1.731010,
6066 			1.733423, 1.735833, 1.738241, 1.740646, 1.743048,
6067 			1.745447, 1.747844, 1.750238, 1.752629, 1.755017,
6068 			1.757402, 1.759785, 1.762164, 1.764541, 1.766915,
6069 			1.769286, 1.771654, 1.774019, 1.776382, 1.778741,
6070 			1.781098, 1.783451, 1.785802, 1.788150, 1.790494,
6071 			1.792836, 1.795175, 1.797511, 1.799843, 1.802173,
6072 			1.804500, 1.806824, 1.809144, 1.811462, 1.813777,
6073 			1.816088, 1.818397, 1.820702, 1.823004, 1.825303,
6074 			1.827600, 1.829893, 1.832182, 1.834469, 1.836753,
6075 			1.839033, 1.841311, 1.843585, 1.845856, 1.848124,
6076 			1.850388, 1.852650, 1.854908, 1.857163, 1.859415,
6077 			1.861664, 1.863909, 1.866152, 1.868391, 1.870627,
6078 			1.872859, 1.875088, 1.877315, 1.879537, 1.881757,
6079 			1.883973, 1.886186, 1.888396, 1.890603, 1.892806,
6080 			1.895006
6081 		}
6082 	},
6083 	{
6084 		481, 40.000000, 1000.000000,
6085 		1.0,
6086 		{
6087 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6088 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6089 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6090 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6091 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6092 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6093 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6094 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6095 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6096 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6097 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6098 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6099 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6100 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6101 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6102 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6103 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6104 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6105 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6106 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6107 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6108 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6109 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6110 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6111 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6112 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6113 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6114 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6115 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6116 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6117 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6118 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6119 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6120 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6121 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6122 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6123 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6124 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6125 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6126 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6127 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6128 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6129 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6130 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6131 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6132 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6133 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6134 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6135 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6136 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6137 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6138 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6139 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6140 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6141 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6142 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6143 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6144 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6145 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6146 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6147 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6148 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6149 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6150 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6151 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6152 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6153 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6154 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6155 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6156 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6157 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6158 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6159 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6160 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6161 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6162 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6163 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6164 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6165 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6166 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6167 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6168 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6169 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6170 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6171 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6172 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6173 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6174 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6175 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6176 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6177 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6178 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6179 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6180 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6181 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6182 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6183 			1.000000
6184 		}
6185 	},
6186 	{
6187 		481, 40.000000, 1000.000000,
6188 		1.0,
6189 		{
6190 			1.963589, 1.948210, 1.932763, 1.917253, 1.901688,
6191 			1.886072, 1.870411, 1.854712, 1.838981, 1.823223,
6192 			1.807443, 1.791649, 1.775844, 1.760035, 1.744226,
6193 			1.728424, 1.712632, 1.696857, 1.681103, 1.665375,
6194 			1.649677, 1.634014, 1.618391, 1.602811, 1.587278,
6195 			1.571797, 1.556372, 1.541005, 1.525701, 1.510463,
6196 			1.495294, 1.480197, 1.465176, 1.450233, 1.435370,
6197 			1.420591, 1.405897, 1.391292, 1.376777, 1.362354,
6198 			1.348026, 1.333793, 1.319659, 1.305623, 1.291689,
6199 			1.277856, 1.264128, 1.250503, 1.236985, 1.223573,
6200 			1.210269, 1.197073, 1.183986, 1.171008, 1.158141,
6201 			1.145385, 1.132739, 1.120205, 1.107783, 1.095472,
6202 			1.083273, 1.071187, 1.059212, 1.047349, 1.035599,
6203 			1.023960, 1.012432, 1.001016, 0.989711, 0.978517,
6204 			0.967433, 0.956459, 0.945595, 0.934840, 0.924194,
6205 			0.913655, 0.903225, 0.892901, 0.882684, 0.872572,
6206 			0.862566, 0.852664, 0.842867, 0.833172, 0.823580,
6207 			0.814090, 0.804701, 0.795412, 0.786223, 0.777133,
6208 			0.768140, 0.759245, 0.750447, 0.741744, 0.733136,
6209 			0.724623, 0.716202, 0.707875, 0.699638, 0.691493,
6210 			0.683438, 0.675472, 0.667595, 0.659805, 0.652102,
6211 			0.644486, 0.636954, 0.629507, 0.622143, 0.614862,
6212 			0.607663, 0.600545, 0.593508, 0.586550, 0.579671,
6213 			0.572870, 0.566146, 0.559498, 0.552926, 0.546429,
6214 			0.540006, 0.533656, 0.527379, 0.521173, 0.515039,
6215 			0.508975, 0.502980, 0.497055, 0.491197, 0.485407,
6216 			0.479683, 0.474025, 0.468433, 0.462905, 0.457441,
6217 			0.452040, 0.446701, 0.441424, 0.436208, 0.431053,
6218 			0.425958, 0.420921, 0.415943, 0.411023, 0.406160,
6219 			0.401354, 0.396604, 0.391908, 0.387268, 0.382682,
6220 			0.378149, 0.373669, 0.369241, 0.364865, 0.360540,
6221 			0.356266, 0.352042, 0.347867, 0.343741, 0.339663,
6222 			0.335634, 0.331651, 0.327715, 0.323825, 0.319981,
6223 			0.316182, 0.312428, 0.308718, 0.305051, 0.301428,
6224 			0.297847, 0.294308, 0.290811, 0.287356, 0.283941,
6225 			0.280566, 0.277231, 0.273935, 0.270678, 0.267460,
6226 			0.264279, 0.261137, 0.258031, 0.254962, 0.251929,
6227 			0.248932, 0.245971, 0.243045, 0.240153, 0.237295,
6228 			0.234472, 0.231682, 0.228924, 0.226200, 0.223508,
6229 			0.220848, 0.218219, 0.215621, 0.213055, 0.210519,
6230 			0.208013, 0.205536, 0.203089, 0.200672, 0.198282,
6231 			0.195922, 0.193589, 0.191284, 0.189007, 0.186756,
6232 			0.184533, 0.182336, 0.180165, 0.178020, 0.175900,
6233 			0.173806, 0.171737, 0.169692, 0.167672, 0.165676,
6234 			0.163703, 0.161754, 0.159829, 0.157926, 0.156046,
6235 			0.154189, 0.152353, 0.150540, 0.148748, 0.146978,
6236 			0.145229, 0.143501, 0.141793, 0.140106, 0.138439,
6237 			0.136792, 0.135164, 0.133556, 0.131968, 0.130398,
6238 			0.128847, 0.127315, 0.125801, 0.124305, 0.122827,
6239 			0.121366, 0.119924, 0.118498, 0.117090, 0.115698,
6240 			0.114323, 0.112965, 0.111623, 0.110297, 0.108987,
6241 			0.107692, 0.106413, 0.105150, 0.103901, 0.102668,
6242 			0.101449, 0.100245, 0.099055, 0.097880, 0.096719,
6243 			0.095571, 0.094438, 0.093318, 0.092212, 0.091118,
6244 			0.090038, 0.088971, 0.087917, 0.086875, 0.085846,
6245 			0.084829, 0.083825, 0.082832, 0.081852, 0.080883,
6246 			0.079926, 0.078980, 0.078046, 0.077123, 0.076211,
6247 			0.075310, 0.074419, 0.073540, 0.072671, 0.071812,
6248 			0.070964, 0.070126, 0.069298, 0.068480, 0.067672,
6249 			0.066874, 0.066085, 0.065306, 0.064536, 0.063775,
6250 			0.063023, 0.062281, 0.061547, 0.060822, 0.060106,
6251 			0.059399, 0.058700, 0.058009, 0.057327, 0.056653,
6252 			0.055987, 0.055329, 0.054679, 0.054036, 0.053402,
6253 			0.052775, 0.052156, 0.051544, 0.050939, 0.050342,
6254 			0.049752, 0.049169, 0.048593, 0.048023, 0.047461,
6255 			0.046906, 0.046357, 0.045814, 0.045279, 0.044749,
6256 			0.044226, 0.043710, 0.043199, 0.042695, 0.042197,
6257 			0.041704, 0.041218, 0.040737, 0.040262, 0.039793,
6258 			0.039330, 0.038872, 0.038420, 0.037973, 0.037531,
6259 			0.037095, 0.036664, 0.036238, 0.035817, 0.035401,
6260 			0.034990, 0.034584, 0.034183, 0.033787, 0.033396,
6261 			0.033009, 0.032627, 0.032249, 0.031876, 0.031508,
6262 			0.031144, 0.030784, 0.030428, 0.030077, 0.029730,
6263 			0.029387, 0.029049, 0.028714, 0.028383, 0.028056,
6264 			0.027734, 0.027415, 0.027100, 0.026788, 0.026480,
6265 			0.026177, 0.025876, 0.025579, 0.025286, 0.024996,
6266 			0.024710, 0.024427, 0.024148, 0.023872, 0.023599,
6267 			0.023329, 0.023063, 0.022800, 0.022540, 0.022283,
6268 			0.022029, 0.021778, 0.021530, 0.021285, 0.021043,
6269 			0.020804, 0.020568, 0.020334, 0.020104, 0.019876,
6270 			0.019651, 0.019428, 0.019208, 0.018991, 0.018776,
6271 			0.018564, 0.018354, 0.018147, 0.017942, 0.017740,
6272 			0.017540, 0.017343, 0.017148, 0.016955, 0.016764,
6273 			0.016576, 0.016390, 0.016206, 0.016024, 0.015845,
6274 			0.015668, 0.015492, 0.015319, 0.015148, 0.014979,
6275 			0.014811, 0.014646, 0.014483, 0.014322, 0.014162,
6276 			0.014005, 0.013849, 0.013695, 0.013543, 0.013393,
6277 			0.013245, 0.013098, 0.012953, 0.012810, 0.012668,
6278 			0.012528, 0.012390, 0.012253, 0.012118, 0.011985,
6279 			0.011853, 0.011723, 0.011594, 0.011467, 0.011341,
6280 			0.011217, 0.011094, 0.010972, 0.010852, 0.010734,
6281 			0.010617, 0.010501, 0.010386, 0.010273, 0.010161,
6282 			0.010051, 0.009942, 0.009834, 0.009727, 0.009621,
6283 			0.009517, 0.009414, 0.009312, 0.009212, 0.009112,
6284 			0.009014, 0.008917, 0.008821, 0.008726, 0.008632,
6285 			0.008540, 0.008448, 0.008357, 0.008268, 0.008180,
6286 			0.008092
6287 		}
6288 	}
6289 };
6290 
6291 static xspect illoc_Daylight_CIE_1931_2[3] = {
6292 	{
6293 		181, 40.000000, 400.000000,
6294 		1.0,
6295 		{
6296 			0.980513, 0.979463, 0.978420, 0.977383, 0.976353,
6297 			0.975333, 0.974322, 0.973321, 0.972332, 0.971354,
6298 			0.970390, 0.969439, 0.968503, 0.967582, 0.966676,
6299 			0.965787, 0.964916, 0.964062, 0.963227, 0.962412,
6300 			0.961616, 0.960840, 0.960086, 0.959353, 0.958642,
6301 			0.957953, 0.957288, 0.956646, 0.956029, 0.955436,
6302 			0.954867, 0.954325, 0.953808, 0.953317, 0.952852,
6303 			0.952415, 0.952005, 0.951622, 0.951268, 0.950941,
6304 			0.950643, 0.950374, 0.950135, 0.949924, 0.949743,
6305 			0.949592, 0.949471, 0.949381, 0.949321, 0.949292,
6306 			0.949293, 0.949326, 0.949391, 0.949486, 0.949613,
6307 			0.949771, 0.949961, 0.950182, 0.950435, 0.950720,
6308 			0.951037, 0.951386, 0.951766, 0.952178, 0.952622,
6309 			0.953098, 0.953606, 0.954145, 0.954716, 0.955318,
6310 			0.955951, 0.956616, 0.957312, 0.958039, 0.958797,
6311 			0.959585, 0.960405, 0.961254, 0.962134, 0.963043,
6312 			0.963982, 0.964951, 0.965949, 0.966977, 0.968033,
6313 			0.969117, 0.970230, 0.971371, 0.972540, 0.973736,
6314 			0.974959, 0.976209, 0.977486, 0.978788, 0.980117,
6315 			0.981471, 0.982850, 0.984254, 0.985682, 0.987134,
6316 			0.988610, 0.990109, 0.991631, 0.993175, 0.994740,
6317 			0.996328, 0.997936, 0.999565, 1.001214, 1.002882,
6318 			1.004570, 1.006276, 1.008000, 1.009741, 1.011500,
6319 			1.013275, 1.015066, 1.016872, 1.018693, 1.020528,
6320 			1.022376, 1.024238, 1.026112, 1.027997, 1.029894,
6321 			1.031800, 1.033717, 1.035642, 1.037576, 1.039518,
6322 			1.041466, 1.043421, 1.045381, 1.047345, 1.049314,
6323 			1.051286, 1.053260, 1.055236, 1.057212, 1.059189,
6324 			1.061165, 1.063139, 1.065110, 1.067079, 1.069042,
6325 			1.071001, 1.072954, 1.074900, 1.076838, 1.078767,
6326 			1.080687, 1.082596, 1.084493, 1.086378, 1.088250,
6327 			1.090107, 1.091949, 1.093774, 1.095582, 1.097372,
6328 			1.099142, 1.100892, 1.102620, 1.104327, 1.106009,
6329 			1.107668, 1.109300, 1.110907, 1.112485, 1.114036,
6330 			1.115556, 1.117047, 1.118505, 1.119931, 1.121323,
6331 			1.122681, 1.124003, 1.125288, 1.126535, 1.127744,
6332 			1.128913
6333 		}
6334 	},
6335 	{
6336 		181, 40.000000, 400.000000,
6337 		1.0,
6338 		{
6339 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6340 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6341 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6342 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6343 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6344 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6345 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6346 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6347 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6348 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6349 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6350 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6351 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6352 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6353 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6354 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6355 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6356 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6357 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6358 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6359 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6360 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6361 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6362 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6363 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6364 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6365 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6366 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6367 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6368 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6369 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6370 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6371 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6372 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6373 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6374 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6375 			1.000000
6376 		}
6377 	},
6378 	{
6379 		181, 40.000000, 400.000000,
6380 		1.0,
6381 		{
6382 			1.943602, 1.928150, 1.912613, 1.897001, 1.881321,
6383 			1.865580, 1.849784, 1.833942, 1.818059, 1.802142,
6384 			1.786198, 1.770233, 1.754253, 1.738263, 1.722270,
6385 			1.706279, 1.690295, 1.674323, 1.658369, 1.642436,
6386 			1.626531, 1.610657, 1.594819, 1.579020, 1.563266,
6387 			1.547559, 1.531903, 1.516302, 1.500760, 1.485279,
6388 			1.469863, 1.454514, 1.439236, 1.424031, 1.408902,
6389 			1.393851, 1.378881, 1.363993, 1.349191, 1.334475,
6390 			1.319847, 1.305310, 1.290866, 1.276515, 1.262259,
6391 			1.248099, 1.234037, 1.220075, 1.206212, 1.192450,
6392 			1.178790, 1.165233, 1.151811, 1.138526, 1.125350,
6393 			1.112284, 1.099330, 1.086490, 1.073764, 1.061153,
6394 			1.048660, 1.036283, 1.024025, 1.011886, 0.999866,
6395 			0.987966, 0.976187, 0.964529, 0.952992, 0.941577,
6396 			0.930283, 0.919111, 0.908061, 0.897132, 0.886325,
6397 			0.875640, 0.865075, 0.854632, 0.844310, 0.834108,
6398 			0.824027, 0.814065, 0.804222, 0.794499, 0.784893,
6399 			0.775406, 0.766036, 0.756782, 0.747645, 0.738623,
6400 			0.729716, 0.720923, 0.712244, 0.703678, 0.695223,
6401 			0.686881, 0.678648, 0.670526, 0.662513, 0.654608,
6402 			0.646811, 0.639121, 0.631537, 0.624058, 0.616683,
6403 			0.609412, 0.602244, 0.595178, 0.588213, 0.581349,
6404 			0.574584, 0.567919, 0.561351, 0.554880, 0.548506,
6405 			0.542227, 0.536043, 0.529953, 0.523956, 0.518051,
6406 			0.512238, 0.506516, 0.500884, 0.495341, 0.489887,
6407 			0.484521, 0.479241, 0.474048, 0.468940, 0.463917,
6408 			0.458978, 0.454122, 0.449349, 0.444657, 0.440047,
6409 			0.435518, 0.431068, 0.426697, 0.422405, 0.418191,
6410 			0.414054, 0.409993, 0.406009, 0.402099, 0.398265,
6411 			0.394504, 0.390817, 0.387203, 0.383662, 0.380192,
6412 			0.376793, 0.373466, 0.370208, 0.367020, 0.363902,
6413 			0.360852, 0.357870, 0.354957, 0.352110, 0.349331,
6414 			0.346618, 0.343971, 0.341389, 0.338873, 0.336422,
6415 			0.334036, 0.331714, 0.329455, 0.327260, 0.325129,
6416 			0.323060, 0.321055, 0.319111, 0.317230, 0.315412,
6417 			0.313654, 0.311959, 0.310325, 0.308753, 0.307241,
6418 			0.305791
6419 		}
6420 	}
6421 };
6422 
6423 static xspect illoc_OPlankian_CIE_1931_2[3] = {
6424 	{
6425 		481, 40.000000, 1000.000000,
6426 		1.0,
6427 		{
6428 			1.001252, 1.000085, 0.998928, 0.997780, 0.996643,
6429 			0.995518, 0.994406, 0.993307, 0.992222, 0.991153,
6430 			0.990100, 0.989064, 0.988046, 0.987046, 0.986066,
6431 			0.985106, 0.984166, 0.983248, 0.982352, 0.981479,
6432 			0.980629, 0.979803, 0.979001, 0.978224, 0.977473,
6433 			0.976748, 0.976049, 0.975377, 0.974732, 0.974114,
6434 			0.973525, 0.972963, 0.972430, 0.971926, 0.971451,
6435 			0.971005, 0.970588, 0.970201, 0.969844, 0.969516,
6436 			0.969218, 0.968951, 0.968713, 0.968506, 0.968328,
6437 			0.968181, 0.968064, 0.967978, 0.967921, 0.967894,
6438 			0.967898, 0.967931, 0.967995, 0.968088, 0.968210,
6439 			0.968363, 0.968544, 0.968755, 0.968995, 0.969265,
6440 			0.969562, 0.969889, 0.970244, 0.970627, 0.971039,
6441 			0.971478, 0.971945, 0.972440, 0.972962, 0.973510,
6442 			0.974086, 0.974689, 0.975317, 0.975972, 0.976653,
6443 			0.977360, 0.978092, 0.978850, 0.979632, 0.980439,
6444 			0.981271, 0.982127, 0.983007, 0.983911, 0.984839,
6445 			0.985790, 0.986764, 0.987761, 0.988780, 0.989822,
6446 			0.990886, 0.991972, 0.993080, 0.994209, 0.995359,
6447 			0.996531, 0.997723, 0.998935, 1.000168, 1.001421,
6448 			1.002694, 1.003986, 1.005298, 1.006629, 1.007979,
6449 			1.009347, 1.010734, 1.012140, 1.013563, 1.015004,
6450 			1.016463, 1.017940, 1.019434, 1.020944, 1.022472,
6451 			1.024016, 1.025577, 1.027153, 1.028746, 1.030355,
6452 			1.031979, 1.033619, 1.035274, 1.036945, 1.038630,
6453 			1.040330, 1.042044, 1.043773, 1.045516, 1.047273,
6454 			1.049044, 1.050828, 1.052626, 1.054437, 1.056262,
6455 			1.058099, 1.059950, 1.061813, 1.063688, 1.065576,
6456 			1.067476, 1.069388, 1.071312, 1.073248, 1.075195,
6457 			1.077154, 1.079124, 1.081105, 1.083097, 1.085100,
6458 			1.087114, 1.089138, 1.091173, 1.093218, 1.095274,
6459 			1.097339, 1.099414, 1.101499, 1.103593, 1.105697,
6460 			1.107811, 1.109934, 1.112065, 1.114206, 1.116356,
6461 			1.118514, 1.120682, 1.122857, 1.125041, 1.127233,
6462 			1.129434, 1.131643, 1.133859, 1.136083, 1.138315,
6463 			1.140555, 1.142802, 1.145057, 1.147319, 1.149588,
6464 			1.151864, 1.154147, 1.156437, 1.158734, 1.161037,
6465 			1.163347, 1.165664, 1.167987, 1.170316, 1.172651,
6466 			1.174993, 1.177340, 1.179694, 1.182053, 1.184418,
6467 			1.186788, 1.189164, 1.191546, 1.193933, 1.196325,
6468 			1.198723, 1.201125, 1.203533, 1.205945, 1.208363,
6469 			1.210785, 1.213212, 1.215644, 1.218080, 1.220520,
6470 			1.222965, 1.225414, 1.227868, 1.230326, 1.232787,
6471 			1.235253, 1.237723, 1.240197, 1.242674, 1.245155,
6472 			1.247640, 1.250128, 1.252620, 1.255115, 1.257614,
6473 			1.260116, 1.262621, 1.265130, 1.267641, 1.270156,
6474 			1.272674, 1.275194, 1.277717, 1.280244, 1.282773,
6475 			1.285304, 1.287838, 1.290375, 1.292914, 1.295456,
6476 			1.298000, 1.300546, 1.303095, 1.305646, 1.308199,
6477 			1.310754, 1.313311, 1.315870, 1.318431, 1.320994,
6478 			1.323559, 1.326125, 1.328693, 1.331263, 1.333835,
6479 			1.336408, 1.338982, 1.341558, 1.344135, 1.346714,
6480 			1.349294, 1.351876, 1.354458, 1.357042, 1.359627,
6481 			1.362212, 1.364799, 1.367387, 1.369976, 1.372566,
6482 			1.375156, 1.377748, 1.380340, 1.382933, 1.385526,
6483 			1.388120, 1.390715, 1.393311, 1.395906, 1.398503,
6484 			1.401099, 1.403696, 1.406294, 1.408892, 1.411490,
6485 			1.414088, 1.416686, 1.419285, 1.421883, 1.424482,
6486 			1.427081, 1.429680, 1.432278, 1.434877, 1.437476,
6487 			1.440074, 1.442672, 1.445270, 1.447868, 1.450465,
6488 			1.453063, 1.455659, 1.458256, 1.460852, 1.463447,
6489 			1.466042, 1.468637, 1.471231, 1.473824, 1.476417,
6490 			1.479009, 1.481601, 1.484192, 1.486782, 1.489371,
6491 			1.491960, 1.494547, 1.497134, 1.499720, 1.502305,
6492 			1.504889, 1.507473, 1.510055, 1.512636, 1.515216,
6493 			1.517795, 1.520373, 1.522950, 1.525525, 1.528100,
6494 			1.530673, 1.533245, 1.535816, 1.538385, 1.540953,
6495 			1.543520, 1.546085, 1.548649, 1.551212, 1.553773,
6496 			1.556333, 1.558891, 1.561448, 1.564003, 1.566557,
6497 			1.569109, 1.571660, 1.574208, 1.576756, 1.579301,
6498 			1.581845, 1.584387, 1.586928, 1.589467, 1.592004,
6499 			1.594539, 1.597072, 1.599604, 1.602133, 1.604661,
6500 			1.607187, 1.609711, 1.612233, 1.614753, 1.617271,
6501 			1.619788, 1.622302, 1.624814, 1.627324, 1.629832,
6502 			1.632338, 1.634842, 1.637344, 1.639843, 1.642341,
6503 			1.644836, 1.647329, 1.649820, 1.652309, 1.654795,
6504 			1.657279, 1.659761, 1.662241, 1.664718, 1.667193,
6505 			1.669666, 1.672136, 1.674604, 1.677070, 1.679533,
6506 			1.681994, 1.684452, 1.686908, 1.689362, 1.691813,
6507 			1.694261, 1.696707, 1.699151, 1.701592, 1.704030,
6508 			1.706466, 1.708900, 1.711331, 1.713759, 1.716184,
6509 			1.718607, 1.721028, 1.723445, 1.725860, 1.728273,
6510 			1.730683, 1.733090, 1.735494, 1.737896, 1.740294,
6511 			1.742691, 1.745084, 1.747475, 1.749862, 1.752248,
6512 			1.754630, 1.757009, 1.759386, 1.761760, 1.764131,
6513 			1.766499, 1.768864, 1.771227, 1.773586, 1.775943,
6514 			1.778297, 1.780648, 1.782995, 1.785340, 1.787683,
6515 			1.790022, 1.792358, 1.794691, 1.797021, 1.799349,
6516 			1.801673, 1.803994, 1.806312, 1.808627, 1.810940,
6517 			1.813249, 1.815555, 1.817858, 1.820158, 1.822455,
6518 			1.824749, 1.827040, 1.829327, 1.831612, 1.833893,
6519 			1.836172, 1.838447, 1.840719, 1.842988, 1.845254,
6520 			1.847517, 1.849776, 1.852033, 1.854286, 1.856536,
6521 			1.858783, 1.861027, 1.863267, 1.865504, 1.867738,
6522 			1.869969, 1.872197, 1.874421, 1.876643, 1.878860,
6523 			1.881075, 1.883287, 1.885495, 1.887700, 1.889901,
6524 			1.892100
6525 		}
6526 	},
6527 	{
6528 		481, 40.000000, 1000.000000,
6529 		1.0,
6530 		{
6531 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6532 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6533 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6534 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6535 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6536 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6537 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6538 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6539 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6540 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6541 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6542 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6543 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6544 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6545 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6546 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6547 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6548 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6549 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6550 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6551 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6552 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6553 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6554 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6555 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6556 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6557 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6558 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6559 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6560 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6561 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6562 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6563 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6564 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6565 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6566 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6567 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6568 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6569 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6570 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6571 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6572 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6573 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6574 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6575 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6576 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6577 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6578 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6579 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6580 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6581 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6582 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6583 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6584 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6585 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6586 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6587 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6588 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6589 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6590 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6591 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6592 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6593 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6594 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6595 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6596 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6597 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6598 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6599 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6600 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6601 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6602 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6603 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6604 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6605 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6606 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6607 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6608 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6609 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6610 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6611 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6612 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6613 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6614 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6615 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6616 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6617 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6618 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6619 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6620 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6621 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6622 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6623 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6624 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6625 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6626 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6627 			1.000000
6628 		}
6629 	},
6630 	{
6631 		481, 40.000000, 1000.000000,
6632 		1.0,
6633 		{
6634 			1.964399, 1.949065, 1.933662, 1.918197, 1.902676,
6635 			1.887104, 1.871488, 1.855833, 1.840145, 1.824431,
6636 			1.808694, 1.792942, 1.777180, 1.761413, 1.745646,
6637 			1.729884, 1.714133, 1.698398, 1.682683, 1.666994,
6638 			1.651334, 1.635709, 1.620122, 1.604578, 1.589081,
6639 			1.573634, 1.558243, 1.542909, 1.527638, 1.512431,
6640 			1.497293, 1.482226, 1.467234, 1.452320, 1.437485,
6641 			1.422732, 1.408065, 1.393485, 1.378994, 1.364595,
6642 			1.350290, 1.336080, 1.321966, 1.307952, 1.294037,
6643 			1.280224, 1.266513, 1.252907, 1.239405, 1.226009,
6644 			1.212720, 1.199539, 1.186466, 1.173502, 1.160647,
6645 			1.147903, 1.135268, 1.122745, 1.110333, 1.098031,
6646 			1.085841, 1.073763, 1.061796, 1.049940, 1.038196,
6647 			1.026563, 1.015041, 1.003630, 0.992329, 0.981138,
6648 			0.970058, 0.959087, 0.948225, 0.937472, 0.926827,
6649 			0.916289, 0.905859, 0.895535, 0.885318, 0.875206,
6650 			0.865199, 0.855295, 0.845496, 0.835799, 0.826205,
6651 			0.816712, 0.807319, 0.798027, 0.788834, 0.779739,
6652 			0.770743, 0.761843, 0.753039, 0.744331, 0.735718,
6653 			0.727199, 0.718772, 0.710438, 0.702195, 0.694043,
6654 			0.685981, 0.678008, 0.670124, 0.662326, 0.654616,
6655 			0.646991, 0.639451, 0.631995, 0.624623, 0.617333,
6656 			0.610126, 0.602999, 0.595952, 0.588985, 0.582096,
6657 			0.575286, 0.568552, 0.561895, 0.555313, 0.548805,
6658 			0.542372, 0.536012, 0.529725, 0.523509, 0.517364,
6659 			0.511289, 0.505284, 0.499347, 0.493478, 0.487677,
6660 			0.481943, 0.476274, 0.470670, 0.465131, 0.459655,
6661 			0.454243, 0.448893, 0.443605, 0.438378, 0.433211,
6662 			0.428104, 0.423056, 0.418066, 0.413134, 0.408260,
6663 			0.403442, 0.398679, 0.393972, 0.389320, 0.384722,
6664 			0.380177, 0.375686, 0.371246, 0.366858, 0.362522,
6665 			0.358235, 0.353999, 0.349812, 0.345675, 0.341585,
6666 			0.337543, 0.333549, 0.329601, 0.325700, 0.321844,
6667 			0.318033, 0.314267, 0.310545, 0.306866, 0.303231,
6668 			0.299639, 0.296088, 0.292580, 0.289112, 0.285685,
6669 			0.282299, 0.278952, 0.275645, 0.272376, 0.269147,
6670 			0.265955, 0.262800, 0.259683, 0.256603, 0.253559,
6671 			0.250551, 0.247578, 0.244640, 0.241737, 0.238869,
6672 			0.236034, 0.233232, 0.230464, 0.227729, 0.225026,
6673 			0.222354, 0.219715, 0.217106, 0.214529, 0.211982,
6674 			0.209465, 0.206978, 0.204520, 0.202092, 0.199692,
6675 			0.197321, 0.194978, 0.192663, 0.190375, 0.188114,
6676 			0.185880, 0.183673, 0.181492, 0.179337, 0.177207,
6677 			0.175103, 0.173024, 0.170969, 0.168939, 0.166933,
6678 			0.164951, 0.162992, 0.161057, 0.159145, 0.157255,
6679 			0.155388, 0.153543, 0.151720, 0.149919, 0.148140,
6680 			0.146381, 0.144644, 0.142927, 0.141231, 0.139555,
6681 			0.137899, 0.136262, 0.134646, 0.133048, 0.131470,
6682 			0.129910, 0.128369, 0.126846, 0.125342, 0.123855,
6683 			0.122387, 0.120935, 0.119502, 0.118085, 0.116685,
6684 			0.115302, 0.113935, 0.112585, 0.111251, 0.109933,
6685 			0.108631, 0.107344, 0.106072, 0.104816, 0.103575,
6686 			0.102349, 0.101137, 0.099940, 0.098757, 0.097588,
6687 			0.096434, 0.095293, 0.094166, 0.093052, 0.091952,
6688 			0.090864, 0.089790, 0.088729, 0.087680, 0.086644,
6689 			0.085620, 0.084609, 0.083610, 0.082622, 0.081647,
6690 			0.080683, 0.079731, 0.078790, 0.077860, 0.076942,
6691 			0.076035, 0.075138, 0.074252, 0.073377, 0.072512,
6692 			0.071658, 0.070814, 0.069980, 0.069156, 0.068342,
6693 			0.067537, 0.066743, 0.065958, 0.065182, 0.064415,
6694 			0.063658, 0.062910, 0.062171, 0.061440, 0.060718,
6695 			0.060006, 0.059301, 0.058605, 0.057917, 0.057238,
6696 			0.056567, 0.055904, 0.055248, 0.054601, 0.053961,
6697 			0.053329, 0.052705, 0.052088, 0.051478, 0.050876,
6698 			0.050281, 0.049693, 0.049113, 0.048539, 0.047972,
6699 			0.047411, 0.046858, 0.046311, 0.045771, 0.045237,
6700 			0.044710, 0.044188, 0.043674, 0.043165, 0.042662,
6701 			0.042166, 0.041675, 0.041190, 0.040711, 0.040238,
6702 			0.039770, 0.039308, 0.038852, 0.038401, 0.037955,
6703 			0.037515, 0.037080, 0.036650, 0.036226, 0.035806,
6704 			0.035392, 0.034982, 0.034577, 0.034177, 0.033782,
6705 			0.033392, 0.033006, 0.032625, 0.032249, 0.031877,
6706 			0.031509, 0.031146, 0.030787, 0.030432, 0.030082,
6707 			0.029736, 0.029394, 0.029056, 0.028722, 0.028392,
6708 			0.028066, 0.027744, 0.027426, 0.027111, 0.026801,
6709 			0.026494, 0.026190, 0.025891, 0.025594, 0.025302,
6710 			0.025013, 0.024727, 0.024445, 0.024166, 0.023890,
6711 			0.023618, 0.023349, 0.023083, 0.022820, 0.022560,
6712 			0.022304, 0.022050, 0.021800, 0.021553, 0.021308,
6713 			0.021066, 0.020828, 0.020592, 0.020359, 0.020128,
6714 			0.019901, 0.019676, 0.019453, 0.019234, 0.019017,
6715 			0.018802, 0.018590, 0.018381, 0.018174, 0.017970,
6716 			0.017767, 0.017568, 0.017371, 0.017176, 0.016983,
6717 			0.016793, 0.016604, 0.016418, 0.016235, 0.016053,
6718 			0.015874, 0.015697, 0.015521, 0.015348, 0.015177,
6719 			0.015008, 0.014841, 0.014676, 0.014513, 0.014352,
6720 			0.014192, 0.014035, 0.013879, 0.013725, 0.013574,
6721 			0.013423, 0.013275, 0.013128, 0.012983, 0.012840,
6722 			0.012699, 0.012559, 0.012420, 0.012284, 0.012149,
6723 			0.012015, 0.011883, 0.011753, 0.011624, 0.011497,
6724 			0.011371, 0.011247, 0.011124, 0.011002, 0.010882,
6725 			0.010764, 0.010647, 0.010531, 0.010416, 0.010303,
6726 			0.010191, 0.010081, 0.009971, 0.009863, 0.009756,
6727 			0.009651, 0.009547, 0.009444, 0.009342, 0.009241,
6728 			0.009142, 0.009043, 0.008946, 0.008850, 0.008755,
6729 			0.008661, 0.008568, 0.008477, 0.008386, 0.008296,
6730 			0.008208
6731 		}
6732 	}
6733 };
6734 
6735 static xspect illoc_ODaylight_CIE_1931_2[3] = {
6736 	{
6737 		181, 40.000000, 400.000000,
6738 		1.0,
6739 		{
6740 			0.980733, 0.979686, 0.978644, 0.977610, 0.976584,
6741 			0.975566, 0.974557, 0.973559, 0.972572, 0.971597,
6742 			0.970635, 0.969687, 0.968753, 0.967834, 0.966931,
6743 			0.966045, 0.965176, 0.964324, 0.963492, 0.962678,
6744 			0.961884, 0.961111, 0.960358, 0.959627, 0.958918,
6745 			0.958232, 0.957568, 0.956929, 0.956313, 0.955721,
6746 			0.955155, 0.954614, 0.954098, 0.953609, 0.953146,
6747 			0.952710, 0.952302, 0.951920, 0.951567, 0.951242,
6748 			0.950945, 0.950677, 0.950439, 0.950229, 0.950049,
6749 			0.949899, 0.949779, 0.949690, 0.949630, 0.949602,
6750 			0.949604, 0.949638, 0.949703, 0.949799, 0.949926,
6751 			0.950085, 0.950275, 0.950497, 0.950750, 0.951035,
6752 			0.951352, 0.951701, 0.952081, 0.952493, 0.952937,
6753 			0.953413, 0.953920, 0.954459, 0.955030, 0.955632,
6754 			0.956265, 0.956929, 0.957625, 0.958351, 0.959108,
6755 			0.959896, 0.960715, 0.961563, 0.962442, 0.963351,
6756 			0.964289, 0.965257, 0.966254, 0.967281, 0.968336,
6757 			0.969419, 0.970531, 0.971670, 0.972838, 0.974033,
6758 			0.975254, 0.976503, 0.977778, 0.979079, 0.980406,
6759 			0.981759, 0.983136, 0.984538, 0.985965, 0.987415,
6760 			0.988889, 0.990386, 0.991906, 0.993448, 0.995012,
6761 			0.996597, 0.998203, 0.999830, 1.001477, 1.003143,
6762 			1.004828, 1.006532, 1.008254, 1.009993, 1.011749,
6763 			1.013522, 1.015310, 1.017114, 1.018932, 1.020765,
6764 			1.022611, 1.024470, 1.026341, 1.028223, 1.030117,
6765 			1.032021, 1.033935, 1.035858, 1.037789, 1.039727,
6766 			1.041673, 1.043625, 1.045582, 1.047543, 1.049509,
6767 			1.051478, 1.053449, 1.055422, 1.057396, 1.059369,
6768 			1.061342, 1.063313, 1.065282, 1.067247, 1.069208,
6769 			1.071163, 1.073113, 1.075056, 1.076991, 1.078917,
6770 			1.080834, 1.082740, 1.084634, 1.086516, 1.088385,
6771 			1.090239, 1.092078, 1.093900, 1.095705, 1.097492,
6772 			1.099259, 1.101006, 1.102732, 1.104435, 1.106115,
6773 			1.107771, 1.109401, 1.111004, 1.112581, 1.114128,
6774 			1.115647, 1.117134, 1.118590, 1.120014, 1.121404,
6775 			1.122759, 1.124078, 1.125361, 1.126607, 1.127813,
6776 			1.128981
6777 		}
6778 	},
6779 	{
6780 		181, 40.000000, 400.000000,
6781 		1.0,
6782 		{
6783 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6784 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6785 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6786 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6787 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6788 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6789 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6790 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6791 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6792 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6793 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6794 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6795 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6796 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6797 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6798 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6799 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6800 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6801 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6802 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6803 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6804 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6805 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6806 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6807 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6808 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6809 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6810 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6811 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6812 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6813 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6814 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6815 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6816 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6817 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6818 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6819 			1.000000
6820 		}
6821 	},
6822 	{
6823 		181, 40.000000, 400.000000,
6824 		1.0,
6825 		{
6826 			1.945100, 1.929640, 1.914098, 1.898479, 1.882791,
6827 			1.867042, 1.851240, 1.835389, 1.819499, 1.803574,
6828 			1.787622, 1.771648, 1.755660, 1.739661, 1.723659,
6829 			1.707659, 1.691666, 1.675685, 1.659721, 1.643779,
6830 			1.627864, 1.611981, 1.596132, 1.580324, 1.564559,
6831 			1.548842, 1.533176, 1.517564, 1.502011, 1.486520,
6832 			1.471093, 1.455733, 1.440444, 1.425228, 1.410088,
6833 			1.395026, 1.380044, 1.365145, 1.350331, 1.335604,
6834 			1.320965, 1.306416, 1.291960, 1.277597, 1.263330,
6835 			1.249158, 1.235085, 1.221110, 1.207236, 1.193462,
6836 			1.179790, 1.166222, 1.152787, 1.139490, 1.126302,
6837 			1.113225, 1.100260, 1.087407, 1.074669, 1.062047,
6838 			1.049542, 1.037153, 1.024884, 1.012733, 1.000701,
6839 			0.988790, 0.977000, 0.965330, 0.953782, 0.942355,
6840 			0.931050, 0.919867, 0.908805, 0.897866, 0.887048,
6841 			0.876351, 0.865776, 0.855322, 0.844989, 0.834777,
6842 			0.824684, 0.814712, 0.804859, 0.795125, 0.785509,
6843 			0.776012, 0.766631, 0.757368, 0.748221, 0.739189,
6844 			0.730272, 0.721470, 0.712781, 0.704205, 0.695742,
6845 			0.687390, 0.679148, 0.671017, 0.662995, 0.655081,
6846 			0.647275, 0.639576, 0.631984, 0.624496, 0.617113,
6847 			0.609834, 0.602658, 0.595584, 0.588611, 0.581739,
6848 			0.574967, 0.568293, 0.561718, 0.555239, 0.548858,
6849 			0.542572, 0.536381, 0.530283, 0.524280, 0.518368,
6850 			0.512549, 0.506820, 0.501181, 0.495632, 0.490171,
6851 			0.484799, 0.479513, 0.474313, 0.469200, 0.464171,
6852 			0.459226, 0.454364, 0.449586, 0.444889, 0.440273,
6853 			0.435739, 0.431284, 0.426908, 0.422611, 0.418392,
6854 			0.414250, 0.410184, 0.406195, 0.402281, 0.398442,
6855 			0.394677, 0.390986, 0.387368, 0.383822, 0.380348,
6856 			0.376946, 0.373614, 0.370353, 0.367162, 0.364039,
6857 			0.360986, 0.358001, 0.355084, 0.352234, 0.349451,
6858 			0.346735, 0.344085, 0.341501, 0.338982, 0.336528,
6859 			0.334139, 0.331814, 0.329553, 0.327356, 0.325222,
6860 			0.323151, 0.321143, 0.319198, 0.317315, 0.315494,
6861 			0.313734, 0.312037, 0.310401, 0.308827, 0.307314,
6862 			0.305862
6863 		}
6864 	}
6865 };
6866 
6867 static xspect illoc_Plankian_CIE_1964_10[3] = {
6868 	{
6869 		481, 40.000000, 1000.000000,
6870 		1.0,
6871 		{
6872 			0.981980, 0.981153, 0.980335, 0.979528, 0.978732,
6873 			0.977948, 0.977178, 0.976421, 0.975679, 0.974952,
6874 			0.974241, 0.973547, 0.972870, 0.972212, 0.971572,
6875 			0.970952, 0.970352, 0.969772, 0.969214, 0.968677,
6876 			0.968163, 0.967671, 0.967202, 0.966758, 0.966337,
6877 			0.965941, 0.965570, 0.965224, 0.964903, 0.964609,
6878 			0.964340, 0.964098, 0.963883, 0.963694, 0.963532,
6879 			0.963398, 0.963291, 0.963212, 0.963160, 0.963136,
6880 			0.963140, 0.963172, 0.963231, 0.963319, 0.963434,
6881 			0.963578, 0.963749, 0.963948, 0.964175, 0.964430,
6882 			0.964713, 0.965023, 0.965361, 0.965726, 0.966119,
6883 			0.966539, 0.966986, 0.967460, 0.967960, 0.968487,
6884 			0.969041, 0.969621, 0.970227, 0.970859, 0.971517,
6885 			0.972201, 0.972910, 0.973644, 0.974402, 0.975186,
6886 			0.975994, 0.976827, 0.977683, 0.978564, 0.979468,
6887 			0.980396, 0.981347, 0.982320, 0.983317, 0.984336,
6888 			0.985378, 0.986441, 0.987526, 0.988633, 0.989762,
6889 			0.990911, 0.992081, 0.993272, 0.994484, 0.995715,
6890 			0.996967, 0.998238, 0.999529, 1.000840, 1.002169,
6891 			1.003517, 1.004884, 1.006269, 1.007672, 1.009094,
6892 			1.010533, 1.011989, 1.013463, 1.014954, 1.016462,
6893 			1.017986, 1.019527, 1.021084, 1.022657, 1.024246,
6894 			1.025851, 1.027470, 1.029106, 1.030756, 1.032421,
6895 			1.034101, 1.035795, 1.037503, 1.039225, 1.040961,
6896 			1.042711, 1.044475, 1.046251, 1.048041, 1.049844,
6897 			1.051659, 1.053487, 1.055327, 1.057180, 1.059045,
6898 			1.060921, 1.062809, 1.064709, 1.066621, 1.068543,
6899 			1.070476, 1.072421, 1.074376, 1.076342, 1.078318,
6900 			1.080304, 1.082300, 1.084307, 1.086323, 1.088349,
6901 			1.090384, 1.092429, 1.094483, 1.096546, 1.098618,
6902 			1.100699, 1.102789, 1.104887, 1.106993, 1.109108,
6903 			1.111231, 1.113362, 1.115500, 1.117647, 1.119801,
6904 			1.121962, 1.124131, 1.126307, 1.128491, 1.130681,
6905 			1.132878, 1.135082, 1.137292, 1.139509, 1.141733,
6906 			1.143962, 1.146198, 1.148440, 1.150688, 1.152942,
6907 			1.155202, 1.157467, 1.159737, 1.162013, 1.164295,
6908 			1.166582, 1.168873, 1.171170, 1.173472, 1.175778,
6909 			1.178090, 1.180405, 1.182726, 1.185051, 1.187380,
6910 			1.189713, 1.192051, 1.194392, 1.196738, 1.199088,
6911 			1.201441, 1.203798, 1.206159, 1.208523, 1.210891,
6912 			1.213262, 1.215636, 1.218014, 1.220394, 1.222778,
6913 			1.225165, 1.227554, 1.229947, 1.232342, 1.234740,
6914 			1.237140, 1.239543, 1.241949, 1.244357, 1.246767,
6915 			1.249179, 1.251594, 1.254010, 1.256429, 1.258849,
6916 			1.261272, 1.263696, 1.266122, 1.268550, 1.270979,
6917 			1.273410, 1.275843, 1.278276, 1.280712, 1.283148,
6918 			1.285586, 1.288025, 1.290465, 1.292906, 1.295348,
6919 			1.297792, 1.300236, 1.302681, 1.305126, 1.307573,
6920 			1.310020, 1.312468, 1.314916, 1.317365, 1.319814,
6921 			1.322264, 1.324714, 1.327165, 1.329615, 1.332066,
6922 			1.334517, 1.336969, 1.339420, 1.341871, 1.344323,
6923 			1.346774, 1.349225, 1.351676, 1.354127, 1.356578,
6924 			1.359028, 1.361478, 1.363927, 1.366377, 1.368825,
6925 			1.371274, 1.373721, 1.376168, 1.378615, 1.381061,
6926 			1.383506, 1.385950, 1.388394, 1.390837, 1.393279,
6927 			1.395720, 1.398160, 1.400599, 1.403038, 1.405475,
6928 			1.407911, 1.410346, 1.412780, 1.415213, 1.417644,
6929 			1.420075, 1.422504, 1.424931, 1.427358, 1.429783,
6930 			1.432207, 1.434629, 1.437050, 1.439469, 1.441887,
6931 			1.444304, 1.446718, 1.449131, 1.451543, 1.453953,
6932 			1.456361, 1.458768, 1.461173, 1.463576, 1.465977,
6933 			1.468376, 1.470774, 1.473170, 1.475564, 1.477956,
6934 			1.480346, 1.482734, 1.485120, 1.487504, 1.489886,
6935 			1.492266, 1.494644, 1.497020, 1.499393, 1.501765,
6936 			1.504134, 1.506501, 1.508867, 1.511229, 1.513590,
6937 			1.515948, 1.518304, 1.520658, 1.523009, 1.525358,
6938 			1.527705, 1.530049, 1.532391, 1.534730, 1.537067,
6939 			1.539402, 1.541734, 1.544064, 1.546391, 1.548715,
6940 			1.551037, 1.553357, 1.555674, 1.557988, 1.560300,
6941 			1.562609, 1.564915, 1.567219, 1.569520, 1.571818,
6942 			1.574114, 1.576407, 1.578698, 1.580985, 1.583270,
6943 			1.585552, 1.587831, 1.590108, 1.592381, 1.594652,
6944 			1.596920, 1.599185, 1.601448, 1.603707, 1.605964,
6945 			1.608217, 1.610468, 1.612716, 1.614961, 1.617203,
6946 			1.619442, 1.621678, 1.623911, 1.626141, 1.628368,
6947 			1.630592, 1.632813, 1.635031, 1.637247, 1.639459,
6948 			1.641668, 1.643873, 1.646076, 1.648276, 1.650473,
6949 			1.652666, 1.654857, 1.657044, 1.659228, 1.661409,
6950 			1.663587, 1.665762, 1.667934, 1.670103, 1.672268,
6951 			1.674430, 1.676589, 1.678745, 1.680897, 1.683047,
6952 			1.685193, 1.687336, 1.689476, 1.691612, 1.693746,
6953 			1.695876, 1.698003, 1.700126, 1.702246, 1.704363,
6954 			1.706477, 1.708588, 1.710695, 1.712799, 1.714899,
6955 			1.716997, 1.719091, 1.721182, 1.723269, 1.725353,
6956 			1.727434, 1.729511, 1.731586, 1.733656, 1.735724,
6957 			1.737788, 1.739849, 1.741906, 1.743960, 1.746011,
6958 			1.748058, 1.750102, 1.752143, 1.754180, 1.756214,
6959 			1.758245, 1.760272, 1.762296, 1.764316, 1.766333,
6960 			1.768347, 1.770357, 1.772364, 1.774367, 1.776367,
6961 			1.778364, 1.780357, 1.782347, 1.784334, 1.786317,
6962 			1.788296, 1.790272, 1.792245, 1.794214, 1.796180,
6963 			1.798143, 1.800102, 1.802058, 1.804010, 1.805959,
6964 			1.807904, 1.809846, 1.811785, 1.813720, 1.815652,
6965 			1.817580, 1.819505, 1.821426, 1.823344, 1.825259,
6966 			1.827170, 1.829078, 1.830982, 1.832883, 1.834780,
6967 			1.836674, 1.838565, 1.840452, 1.842335, 1.844216,
6968 			1.846092
6969 		}
6970 	},
6971 	{
6972 		481, 40.000000, 1000.000000,
6973 		1.0,
6974 		{
6975 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6976 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6977 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6978 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6979 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6980 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6981 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6982 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6983 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6984 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6985 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6986 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6987 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6988 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6989 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6990 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6991 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6992 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6993 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6994 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6995 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6996 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6997 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6998 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
6999 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7000 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7001 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7002 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7003 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7004 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7005 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7006 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7007 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7008 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7009 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7010 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7011 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7012 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7013 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7014 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7015 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7016 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7017 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7018 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7019 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7020 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7021 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7022 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7023 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7024 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7025 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7026 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7027 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7028 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7029 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7030 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7031 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7032 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7033 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7034 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7035 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7036 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7037 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7038 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7039 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7040 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7041 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7042 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7043 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7044 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7045 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7046 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7047 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7048 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7049 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7050 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7051 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7052 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7053 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7054 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7055 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7056 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7057 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7058 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7059 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7060 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7061 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7062 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7063 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7064 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7065 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7066 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7067 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7068 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7069 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7070 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7071 			1.000000
7072 		}
7073 	},
7074 	{
7075 		481, 40.000000, 1000.000000,
7076 		1.0,
7077 		{
7078 			1.923654, 1.909157, 1.894584, 1.879941, 1.865235,
7079 			1.850470, 1.835651, 1.820786, 1.805878, 1.790933,
7080 			1.775958, 1.760956, 1.745934, 1.730896, 1.715848,
7081 			1.700795, 1.685741, 1.670691, 1.655651, 1.640624,
7082 			1.625615, 1.610629, 1.595669, 1.580741, 1.565847,
7083 			1.550992, 1.536180, 1.521413, 1.506697, 1.492034,
7084 			1.477427, 1.462880, 1.448395, 1.433975, 1.419624,
7085 			1.405344, 1.391137, 1.377005, 1.362952, 1.348979,
7086 			1.335088, 1.321281, 1.307560, 1.293927, 1.280383,
7087 			1.266930, 1.253569, 1.240302, 1.227130, 1.214053,
7088 			1.201074, 1.188192, 1.175410, 1.162727, 1.150144,
7089 			1.137662, 1.125282, 1.113004, 1.100828, 1.088756,
7090 			1.076786, 1.064920, 1.053158, 1.041499, 1.029944,
7091 			1.018493, 1.007146, 0.995903, 0.984764, 0.973728,
7092 			0.962796, 0.951967, 0.941240, 0.930617, 0.920096,
7093 			0.909677, 0.899359, 0.889143, 0.879028, 0.869013,
7094 			0.859098, 0.849282, 0.839565, 0.829947, 0.820426,
7095 			0.811003, 0.801676, 0.792445, 0.783310, 0.774269,
7096 			0.765323, 0.756470, 0.747710, 0.739042, 0.730466,
7097 			0.721980, 0.713585, 0.705279, 0.697062, 0.688933,
7098 			0.680891, 0.672936, 0.665067, 0.657283, 0.649583,
7099 			0.641968, 0.634435, 0.626984, 0.619616, 0.612328,
7100 			0.605120, 0.597991, 0.590942, 0.583970, 0.577075,
7101 			0.570257, 0.563515, 0.556848, 0.550255, 0.543736,
7102 			0.537290, 0.530916, 0.524614, 0.518382, 0.512221,
7103 			0.506129, 0.500106, 0.494151, 0.488264, 0.482443,
7104 			0.476688, 0.470999, 0.465374, 0.459814, 0.454317,
7105 			0.448883, 0.443510, 0.438200, 0.432950, 0.427760,
7106 			0.422630, 0.417559, 0.412547, 0.407592, 0.402694,
7107 			0.397852, 0.393067, 0.388337, 0.383662, 0.379041,
7108 			0.374473, 0.369959, 0.365497, 0.361086, 0.356728,
7109 			0.352420, 0.348162, 0.343953, 0.339794, 0.335684,
7110 			0.331622, 0.327607, 0.323639, 0.319718, 0.315842,
7111 			0.312013, 0.308228, 0.304487, 0.300791, 0.297138,
7112 			0.293529, 0.289961, 0.286436, 0.282953, 0.279511,
7113 			0.276109, 0.272748, 0.269426, 0.266144, 0.262900,
7114 			0.259696, 0.256529, 0.253400, 0.250308, 0.247252,
7115 			0.244234, 0.241251, 0.238303, 0.235391, 0.232513,
7116 			0.229670, 0.226861, 0.224085, 0.221343, 0.218633,
7117 			0.215956, 0.213311, 0.210697, 0.208115, 0.205564,
7118 			0.203043, 0.200553, 0.198092, 0.195661, 0.193260,
7119 			0.190887, 0.188543, 0.186227, 0.183939, 0.181678,
7120 			0.179445, 0.177238, 0.175059, 0.172905, 0.170778,
7121 			0.168676, 0.166600, 0.164549, 0.162523, 0.160521,
7122 			0.158544, 0.156590, 0.154660, 0.152754, 0.150871,
7123 			0.149010, 0.147172, 0.145357, 0.143563, 0.141792,
7124 			0.140042, 0.138313, 0.136605, 0.134918, 0.133252,
7125 			0.131606, 0.129980, 0.128373, 0.126787, 0.125220,
7126 			0.123672, 0.122142, 0.120632, 0.119140, 0.117666,
7127 			0.116210, 0.114772, 0.113352, 0.111949, 0.110563,
7128 			0.109194, 0.107842, 0.106507, 0.105188, 0.103885,
7129 			0.102598, 0.101327, 0.100071, 0.098831, 0.097606,
7130 			0.096397, 0.095202, 0.094021, 0.092856, 0.091704,
7131 			0.090567, 0.089444, 0.088335, 0.087239, 0.086157,
7132 			0.085088, 0.084032, 0.082989, 0.081960, 0.080942,
7133 			0.079938, 0.078946, 0.077966, 0.076998, 0.076042,
7134 			0.075098, 0.074166, 0.073245, 0.072335, 0.071437,
7135 			0.070550, 0.069674, 0.068808, 0.067954, 0.067110,
7136 			0.066276, 0.065453, 0.064640, 0.063837, 0.063044,
7137 			0.062260, 0.061487, 0.060723, 0.059969, 0.059223,
7138 			0.058488, 0.057761, 0.057043, 0.056334, 0.055634,
7139 			0.054943, 0.054260, 0.053586, 0.052920, 0.052263,
7140 			0.051613, 0.050972, 0.050338, 0.049713, 0.049095,
7141 			0.048485, 0.047883, 0.047288, 0.046700, 0.046120,
7142 			0.045547, 0.044981, 0.044422, 0.043870, 0.043325,
7143 			0.042787, 0.042255, 0.041730, 0.041212, 0.040700,
7144 			0.040194, 0.039695, 0.039202, 0.038715, 0.038234,
7145 			0.037760, 0.037291, 0.036828, 0.036370, 0.035919,
7146 			0.035473, 0.035032, 0.034597, 0.034168, 0.033744,
7147 			0.033325, 0.032911, 0.032503, 0.032099, 0.031701,
7148 			0.031308, 0.030919, 0.030536, 0.030157, 0.029783,
7149 			0.029413, 0.029048, 0.028688, 0.028332, 0.027981,
7150 			0.027634, 0.027291, 0.026953, 0.026619, 0.026289,
7151 			0.025963, 0.025642, 0.025324, 0.025010, 0.024700,
7152 			0.024394, 0.024092, 0.023794, 0.023499, 0.023208,
7153 			0.022921, 0.022637, 0.022357, 0.022080, 0.021807,
7154 			0.021537, 0.021270, 0.021007, 0.020747, 0.020491,
7155 			0.020237, 0.019987, 0.019740, 0.019496, 0.019255,
7156 			0.019017, 0.018782, 0.018550, 0.018321, 0.018094,
7157 			0.017871, 0.017650, 0.017432, 0.017217, 0.017004,
7158 			0.016795, 0.016587, 0.016383, 0.016181, 0.015981,
7159 			0.015784, 0.015589, 0.015397, 0.015207, 0.015020,
7160 			0.014835, 0.014652, 0.014471, 0.014293, 0.014117,
7161 			0.013943, 0.013771, 0.013602, 0.013434, 0.013269,
7162 			0.013106, 0.012944, 0.012785, 0.012628, 0.012473,
7163 			0.012319, 0.012168, 0.012018, 0.011871, 0.011725,
7164 			0.011581, 0.011438, 0.011298, 0.011159, 0.011022,
7165 			0.010887, 0.010753, 0.010621, 0.010491, 0.010363,
7166 			0.010235, 0.010110, 0.009986, 0.009864, 0.009743,
7167 			0.009623, 0.009506, 0.009389, 0.009274, 0.009161,
7168 			0.009048, 0.008938, 0.008828, 0.008720, 0.008614,
7169 			0.008508, 0.008404, 0.008302, 0.008200, 0.008100,
7170 			0.008001, 0.007903, 0.007807, 0.007712, 0.007617,
7171 			0.007524, 0.007433, 0.007342, 0.007252, 0.007164,
7172 			0.007077, 0.006990, 0.006905, 0.006821, 0.006738,
7173 			0.006656, 0.006575, 0.006495, 0.006416, 0.006338,
7174 			0.006261
7175 		}
7176 	}
7177 };
7178 
7179 static xspect illoc_Daylight_CIE_1964_10[3] = {
7180 	{
7181 		181, 40.000000, 400.000000,
7182 		1.0,
7183 		{
7184 			0.954594, 0.954039, 0.953491, 0.952950, 0.952416,
7185 			0.951891, 0.951374, 0.950867, 0.950370, 0.949884,
7186 			0.949409, 0.948945, 0.948494, 0.948056, 0.947632,
7187 			0.947221, 0.946825, 0.946444, 0.946078, 0.945729,
7188 			0.945395, 0.945079, 0.944780, 0.944498, 0.944235,
7189 			0.943990, 0.943765, 0.943558, 0.943372, 0.943205,
7190 			0.943059, 0.942934, 0.942830, 0.942748, 0.942687,
7191 			0.942649, 0.942633, 0.942639, 0.942669, 0.942722,
7192 			0.942799, 0.942900, 0.943024, 0.943174, 0.943347,
7193 			0.943546, 0.943770, 0.944019, 0.944293, 0.944594,
7194 			0.944920, 0.945273, 0.945651, 0.946054, 0.946484,
7195 			0.946940, 0.947423, 0.947932, 0.948468, 0.949031,
7196 			0.949620, 0.950237, 0.950880, 0.951550, 0.952247,
7197 			0.952971, 0.953722, 0.954499, 0.955304, 0.956135,
7198 			0.956992, 0.957876, 0.958787, 0.959724, 0.960688,
7199 			0.961677, 0.962693, 0.963735, 0.964802, 0.965895,
7200 			0.967013, 0.968157, 0.969326, 0.970520, 0.971739,
7201 			0.972982, 0.974249, 0.975541, 0.976856, 0.978195,
7202 			0.979557, 0.980943, 0.982351, 0.983782, 0.985235,
7203 			0.986710, 0.988207, 0.989725, 0.991264, 0.992823,
7204 			0.994403, 0.996003, 0.997623, 0.999262, 1.000920,
7205 			1.002596, 1.004290, 1.006002, 1.007731, 1.009477,
7206 			1.011239, 1.013018, 1.014811, 1.016620, 1.018443,
7207 			1.020280, 1.022130, 1.023993, 1.025869, 1.027757,
7208 			1.029655, 1.031565, 1.033485, 1.035414, 1.037353,
7209 			1.039299, 1.041254, 1.043215, 1.045183, 1.047157,
7210 			1.049136, 1.051120, 1.053107, 1.055098, 1.057090,
7211 			1.059085, 1.061080, 1.063076, 1.065071, 1.067064,
7212 			1.069055, 1.071044, 1.073028, 1.075009, 1.076983,
7213 			1.078952, 1.080913, 1.082866, 1.084811, 1.086746,
7214 			1.088670, 1.090583, 1.092484, 1.094371, 1.096244,
7215 			1.098102, 1.099944, 1.101768, 1.103575, 1.105363,
7216 			1.107131, 1.108878, 1.110603, 1.112305, 1.113984,
7217 			1.115638, 1.117266, 1.118867, 1.120440, 1.121985,
7218 			1.123500, 1.124984, 1.126436, 1.127856, 1.129241,
7219 			1.130592, 1.131908, 1.133186, 1.134427, 1.135629,
7220 			1.136792
7221 		}
7222 	},
7223 	{
7224 		181, 40.000000, 400.000000,
7225 		1.0,
7226 		{
7227 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7228 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7229 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7230 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7231 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7232 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7233 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7234 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7235 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7236 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7237 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7238 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7239 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7240 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7241 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7242 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7243 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7244 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7245 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7246 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7247 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7248 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7249 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7250 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7251 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7252 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7253 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7254 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7255 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7256 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7257 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7258 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7259 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7260 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7261 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7262 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7263 			1.000000
7264 		}
7265 	},
7266 	{
7267 		181, 40.000000, 400.000000,
7268 		1.0,
7269 		{
7270 			1.879446, 1.865348, 1.851156, 1.836877, 1.822518,
7271 			1.808084, 1.793581, 1.779017, 1.764398, 1.749728,
7272 			1.735014, 1.720261, 1.705476, 1.690662, 1.675827,
7273 			1.660974, 1.646108, 1.631236, 1.616360, 1.601486,
7274 			1.586618, 1.571761, 1.556919, 1.542095, 1.527294,
7275 			1.512519, 1.497775, 1.483064, 1.468390, 1.453756,
7276 			1.439166, 1.424623, 1.410129, 1.395688, 1.381302,
7277 			1.366973, 1.352705, 1.338499, 1.324359, 1.310286,
7278 			1.296282, 1.282349, 1.268490, 1.254705, 1.240998,
7279 			1.227369, 1.213820, 1.200353, 1.186968, 1.173668,
7280 			1.160454, 1.147326, 1.134316, 1.121427, 1.108633,
7281 			1.095933, 1.083332, 1.070830, 1.058428, 1.046129,
7282 			1.033933, 1.021842, 1.009857, 0.997979, 0.986209,
7283 			0.974548, 0.962996, 0.951555, 0.940225, 0.929007,
7284 			0.917901, 0.906907, 0.896026, 0.885259, 0.874605,
7285 			0.864065, 0.853639, 0.843326, 0.833128, 0.823044,
7286 			0.813073, 0.803217, 0.793474, 0.783845, 0.774329,
7287 			0.764926, 0.755636, 0.746458, 0.737392, 0.728439,
7288 			0.719596, 0.710865, 0.702244, 0.693733, 0.685332,
7289 			0.677040, 0.668856, 0.660780, 0.652812, 0.644950,
7290 			0.637194, 0.629545, 0.622000, 0.614559, 0.607222,
7291 			0.599989, 0.592857, 0.585828, 0.578899, 0.572071,
7292 			0.565342, 0.558713, 0.552181, 0.545747, 0.539410,
7293 			0.533170, 0.527024, 0.520973, 0.515017, 0.509153,
7294 			0.503382, 0.497703, 0.492115, 0.486617, 0.481209,
7295 			0.475890, 0.470659, 0.465515, 0.460458, 0.455487,
7296 			0.450602, 0.445801, 0.441084, 0.436451, 0.431899,
7297 			0.427430, 0.423042, 0.418734, 0.414506, 0.410357,
7298 			0.406287, 0.402294, 0.398378, 0.394539, 0.390776,
7299 			0.387087, 0.383474, 0.379934, 0.376467, 0.373074,
7300 			0.369752, 0.366502, 0.363322, 0.360213, 0.357174,
7301 			0.354204, 0.351303, 0.348469, 0.345704, 0.343005,
7302 			0.340373, 0.337807, 0.335306, 0.332871, 0.330501,
7303 			0.328194, 0.325951, 0.323772, 0.321656, 0.319602,
7304 			0.317611, 0.315681, 0.313813, 0.312005, 0.310259,
7305 			0.308574, 0.306948, 0.305383, 0.303877, 0.302431,
7306 			0.301045
7307 		}
7308 	}
7309 };
7310 
7311 static xspect illoc_OPlankian_CIE_1964_10[3] = {
7312 	{
7313 		481, 40.000000, 1000.000000,
7314 		1.0,
7315 		{
7316 			0.982024, 0.981198, 0.980382, 0.979576, 0.978782,
7317 			0.978000, 0.977230, 0.976474, 0.975733, 0.975007,
7318 			0.974297, 0.973603, 0.972927, 0.972268, 0.971629,
7319 			0.971008, 0.970408, 0.969828, 0.969269, 0.968731,
7320 			0.968216, 0.967723, 0.967253, 0.966807, 0.966385,
7321 			0.965987, 0.965613, 0.965265, 0.964942, 0.964645,
7322 			0.964374, 0.964129, 0.963911, 0.963719, 0.963554,
7323 			0.963416, 0.963305, 0.963222, 0.963166, 0.963138,
7324 			0.963138, 0.963165, 0.963220, 0.963302, 0.963413,
7325 			0.963551, 0.963717, 0.963911, 0.964133, 0.964382,
7326 			0.964659, 0.964963, 0.965295, 0.965654, 0.966040,
7327 			0.966453, 0.966894, 0.967361, 0.967855, 0.968375,
7328 			0.968922, 0.969495, 0.970094, 0.970719, 0.971369,
7329 			0.972045, 0.972746, 0.973473, 0.974224, 0.975000,
7330 			0.975800, 0.976625, 0.977473, 0.978346, 0.979242,
7331 			0.980161, 0.981103, 0.982069, 0.983057, 0.984068,
7332 			0.985100, 0.986155, 0.987232, 0.988330, 0.989450,
7333 			0.990590, 0.991752, 0.992934, 0.994136, 0.995359,
7334 			0.996601, 0.997864, 0.999146, 1.000447, 1.001767,
7335 			1.003106, 1.004463, 1.005839, 1.007233, 1.008645,
7336 			1.010075, 1.011522, 1.012986, 1.014468, 1.015966,
7337 			1.017481, 1.019012, 1.020560, 1.022123, 1.023703,
7338 			1.025298, 1.026908, 1.028534, 1.030175, 1.031830,
7339 			1.033500, 1.035184, 1.036883, 1.038596, 1.040322,
7340 			1.042063, 1.043816, 1.045583, 1.047363, 1.049156,
7341 			1.050962, 1.052781, 1.054611, 1.056454, 1.058309,
7342 			1.060176, 1.062055, 1.063945, 1.065847, 1.067760,
7343 			1.069684, 1.071618, 1.073564, 1.075520, 1.077487,
7344 			1.079463, 1.081450, 1.083447, 1.085454, 1.087470,
7345 			1.089496, 1.091532, 1.093576, 1.095630, 1.097692,
7346 			1.099764, 1.101844, 1.103933, 1.106030, 1.108135,
7347 			1.110249, 1.112370, 1.114500, 1.116637, 1.118782,
7348 			1.120934, 1.123094, 1.125260, 1.127435, 1.129616,
7349 			1.131804, 1.133998, 1.136200, 1.138408, 1.140622,
7350 			1.142843, 1.145070, 1.147303, 1.149542, 1.151787,
7351 			1.154037, 1.156293, 1.158555, 1.160823, 1.163095,
7352 			1.165373, 1.167656, 1.169944, 1.172237, 1.174535,
7353 			1.176838, 1.179145, 1.181457, 1.183773, 1.186094,
7354 			1.188419, 1.190748, 1.193081, 1.195418, 1.197759,
7355 			1.200104, 1.202453, 1.204805, 1.207161, 1.209521,
7356 			1.211884, 1.214250, 1.216619, 1.218992, 1.221367,
7357 			1.223746, 1.226128, 1.228512, 1.230899, 1.233289,
7358 			1.235682, 1.238077, 1.240475, 1.242875, 1.245277,
7359 			1.247682, 1.250088, 1.252497, 1.254908, 1.257321,
7360 			1.259736, 1.262153, 1.264571, 1.266992, 1.269414,
7361 			1.271837, 1.274262, 1.276689, 1.279116, 1.281546,
7362 			1.283976, 1.286408, 1.288841, 1.291275, 1.293710,
7363 			1.296146, 1.298583, 1.301021, 1.303460, 1.305899,
7364 			1.308340, 1.310780, 1.313222, 1.315664, 1.318106,
7365 			1.320549, 1.322993, 1.325437, 1.327881, 1.330325,
7366 			1.332770, 1.335214, 1.337659, 1.340104, 1.342549,
7367 			1.344994, 1.347438, 1.349883, 1.352328, 1.354772,
7368 			1.357216, 1.359660, 1.362103, 1.364546, 1.366989,
7369 			1.369431, 1.371872, 1.374314, 1.376754, 1.379194,
7370 			1.381633, 1.384072, 1.386509, 1.388946, 1.391383,
7371 			1.393818, 1.396252, 1.398686, 1.401119, 1.403550,
7372 			1.405981, 1.408410, 1.410839, 1.413266, 1.415692,
7373 			1.418117, 1.420541, 1.422963, 1.425384, 1.427804,
7374 			1.430222, 1.432640, 1.435055, 1.437469, 1.439882,
7375 			1.442293, 1.444703, 1.447111, 1.449518, 1.451923,
7376 			1.454326, 1.456728, 1.459128, 1.461526, 1.463922,
7377 			1.466317, 1.468710, 1.471101, 1.473490, 1.475877,
7378 			1.478263, 1.480646, 1.483028, 1.485407, 1.487785,
7379 			1.490160, 1.492534, 1.494905, 1.497274, 1.499642,
7380 			1.502007, 1.504370, 1.506730, 1.509089, 1.511445,
7381 			1.513799, 1.516151, 1.518501, 1.520848, 1.523193,
7382 			1.525536, 1.527876, 1.530214, 1.532549, 1.534883,
7383 			1.537213, 1.539541, 1.541867, 1.544191, 1.546511,
7384 			1.548830, 1.551145, 1.553459, 1.555769, 1.558077,
7385 			1.560383, 1.562686, 1.564986, 1.567284, 1.569579,
7386 			1.571871, 1.574160, 1.576447, 1.578732, 1.581013,
7387 			1.583292, 1.585568, 1.587841, 1.590111, 1.592379,
7388 			1.594644, 1.596906, 1.599165, 1.601422, 1.603675,
7389 			1.605926, 1.608173, 1.610418, 1.612660, 1.614899,
7390 			1.617135, 1.619369, 1.621599, 1.623826, 1.626051,
7391 			1.628272, 1.630490, 1.632706, 1.634918, 1.637127,
7392 			1.639334, 1.641537, 1.643737, 1.645935, 1.648129,
7393 			1.650320, 1.652508, 1.654693, 1.656875, 1.659053,
7394 			1.661229, 1.663401, 1.665571, 1.667737, 1.669900,
7395 			1.672060, 1.674217, 1.676370, 1.678521, 1.680668,
7396 			1.682812, 1.684953, 1.687091, 1.689225, 1.691357,
7397 			1.693485, 1.695609, 1.697731, 1.699849, 1.701965,
7398 			1.704076, 1.706185, 1.708290, 1.710393, 1.712491,
7399 			1.714587, 1.716679, 1.718768, 1.720854, 1.722936,
7400 			1.725016, 1.727091, 1.729164, 1.731233, 1.733299,
7401 			1.735362, 1.737421, 1.739477, 1.741530, 1.743579,
7402 			1.745625, 1.747667, 1.749707, 1.751743, 1.753775,
7403 			1.755804, 1.757830, 1.759853, 1.761872, 1.763888,
7404 			1.765900, 1.767909, 1.769915, 1.771917, 1.773916,
7405 			1.775911, 1.777904, 1.779892, 1.781878, 1.783860,
7406 			1.785838, 1.787814, 1.789785, 1.791754, 1.793719,
7407 			1.795680, 1.797639, 1.799593, 1.801545, 1.803493,
7408 			1.805437, 1.807379, 1.809316, 1.811251, 1.813182,
7409 			1.815109, 1.817034, 1.818954, 1.820872, 1.822786,
7410 			1.824696, 1.826603, 1.828507, 1.830407, 1.832304,
7411 			1.834197, 1.836087, 1.837974, 1.839857, 1.841737,
7412 			1.843613
7413 		}
7414 	},
7415 	{
7416 		481, 40.000000, 1000.000000,
7417 		1.0,
7418 		{
7419 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7420 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7421 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7422 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7423 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7424 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7425 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7426 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7427 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7428 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7429 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7430 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7431 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7432 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7433 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7434 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7435 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7436 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7437 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7438 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7439 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7440 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7441 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7442 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7443 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7444 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7445 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7446 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7447 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7448 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7449 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7450 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7451 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7452 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7453 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7454 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7455 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7456 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7457 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7458 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7459 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7460 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7461 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7462 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7463 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7464 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7465 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7466 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7467 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7468 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7469 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7470 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7471 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7472 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7473 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7474 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7475 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7476 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7477 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7478 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7479 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7480 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7481 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7482 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7483 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7484 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7485 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7486 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7487 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7488 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7489 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7490 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7491 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7492 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7493 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7494 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7495 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7496 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7497 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7498 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7499 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7500 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7501 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7502 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7503 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7504 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7505 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7506 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7507 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7508 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7509 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7510 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7511 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7512 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7513 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7514 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7515 			1.000000
7516 		}
7517 	},
7518 	{
7519 		481, 40.000000, 1000.000000,
7520 		1.0,
7521 		{
7522 			1.924417, 1.909963, 1.895433, 1.880833, 1.866169,
7523 			1.851446, 1.836670, 1.821847, 1.806982, 1.792079,
7524 			1.777145, 1.762185, 1.747204, 1.732207, 1.717200,
7525 			1.702186, 1.687172, 1.672162, 1.657160, 1.642171,
7526 			1.627200, 1.612250, 1.597327, 1.582434, 1.567576,
7527 			1.552755, 1.537977, 1.523244, 1.508560, 1.493928,
7528 			1.479353, 1.464836, 1.450380, 1.435990, 1.421667,
7529 			1.407414, 1.393233, 1.379128, 1.365099, 1.351151,
7530 			1.337283, 1.323499, 1.309801, 1.296189, 1.282666,
7531 			1.269233, 1.255891, 1.242643, 1.229488, 1.216429,
7532 			1.203466, 1.190600, 1.177833, 1.165164, 1.152595,
7533 			1.140127, 1.127759, 1.115493, 1.103328, 1.091266,
7534 			1.079307, 1.067450, 1.055696, 1.044046, 1.032499,
7535 			1.021055, 1.009714, 0.998477, 0.987344, 0.976313,
7536 			0.965385, 0.954560, 0.943837, 0.933217, 0.922698,
7537 			0.912282, 0.901966, 0.891751, 0.881636, 0.871622,
7538 			0.861707, 0.851891, 0.842173, 0.832554, 0.823032,
7539 			0.813606, 0.804277, 0.795044, 0.785906, 0.776862,
7540 			0.767912, 0.759056, 0.750292, 0.741619, 0.733038,
7541 			0.724548, 0.716148, 0.707836, 0.699613, 0.691478,
7542 			0.683430, 0.675469, 0.667593, 0.659802, 0.652096,
7543 			0.644473, 0.636932, 0.629474, 0.622098, 0.614802,
7544 			0.607586, 0.600449, 0.593390, 0.586410, 0.579507,
7545 			0.572679, 0.565928, 0.559252, 0.552649, 0.546121,
7546 			0.539665, 0.533281, 0.526969, 0.520728, 0.514556,
7547 			0.508454, 0.502421, 0.496455, 0.490557, 0.484726,
7548 			0.478960, 0.473260, 0.467625, 0.462053, 0.456545,
7549 			0.451100, 0.445716, 0.440394, 0.435133, 0.429932,
7550 			0.424791, 0.419708, 0.414684, 0.409718, 0.404808,
7551 			0.399955, 0.395158, 0.390417, 0.385730, 0.381097,
7552 			0.376517, 0.371991, 0.367517, 0.363095, 0.358724,
7553 			0.354404, 0.350135, 0.345915, 0.341744, 0.337621,
7554 			0.333547, 0.329520, 0.325540, 0.321607, 0.317720,
7555 			0.313878, 0.310081, 0.306329, 0.302621, 0.298956,
7556 			0.295335, 0.291756, 0.288219, 0.284723, 0.281269,
7557 			0.277856, 0.274483, 0.271149, 0.267855, 0.264600,
7558 			0.261384, 0.258205, 0.255064, 0.251961, 0.248894,
7559 			0.245864, 0.242869, 0.239910, 0.236986, 0.234097,
7560 			0.231243, 0.228422, 0.225635, 0.222881, 0.220161,
7561 			0.217472, 0.214816, 0.212191, 0.209598, 0.207035,
7562 			0.204504, 0.202002, 0.199531, 0.197089, 0.194677,
7563 			0.192293, 0.189938, 0.187612, 0.185313, 0.183042,
7564 			0.180798, 0.178581, 0.176391, 0.174227, 0.172090,
7565 			0.169978, 0.167891, 0.165830, 0.163794, 0.161782,
7566 			0.159794, 0.157831, 0.155891, 0.153975, 0.152082,
7567 			0.150211, 0.148364, 0.146539, 0.144736, 0.142954,
7568 			0.141195, 0.139457, 0.137739, 0.136043, 0.134367,
7569 			0.132712, 0.131077, 0.129462, 0.127866, 0.126290,
7570 			0.124733, 0.123194, 0.121675, 0.120174, 0.118692,
7571 			0.117227, 0.115781, 0.114352, 0.112940, 0.111546,
7572 			0.110169, 0.108808, 0.107465, 0.106137, 0.104826,
7573 			0.103531, 0.102252, 0.100988, 0.099740, 0.098508,
7574 			0.097290, 0.096087, 0.094899, 0.093726, 0.092567,
7575 			0.091422, 0.090291, 0.089174, 0.088071, 0.086981,
7576 			0.085905, 0.084842, 0.083792, 0.082755, 0.081731,
7577 			0.080719, 0.079720, 0.078733, 0.077759, 0.076796,
7578 			0.075845, 0.074906, 0.073978, 0.073062, 0.072157,
7579 			0.071264, 0.070381, 0.069509, 0.068648, 0.067798,
7580 			0.066958, 0.066128, 0.065309, 0.064500, 0.063701,
7581 			0.062911, 0.062132, 0.061362, 0.060602, 0.059851,
7582 			0.059109, 0.058376, 0.057653, 0.056938, 0.056233,
7583 			0.055536, 0.054848, 0.054168, 0.053497, 0.052834,
7584 			0.052179, 0.051532, 0.050893, 0.050263, 0.049640,
7585 			0.049025, 0.048417, 0.047817, 0.047224, 0.046639,
7586 			0.046061, 0.045490, 0.044927, 0.044370, 0.043820,
7587 			0.043277, 0.042741, 0.042211, 0.041688, 0.041172,
7588 			0.040662, 0.040158, 0.039660, 0.039169, 0.038684,
7589 			0.038205, 0.037731, 0.037264, 0.036802, 0.036347,
7590 			0.035897, 0.035452, 0.035013, 0.034579, 0.034151,
7591 			0.033728, 0.033311, 0.032899, 0.032491, 0.032089,
7592 			0.031692, 0.031300, 0.030912, 0.030530, 0.030152,
7593 			0.029779, 0.029411, 0.029047, 0.028688, 0.028333,
7594 			0.027982, 0.027636, 0.027295, 0.026957, 0.026624,
7595 			0.026295, 0.025970, 0.025649, 0.025332, 0.025019,
7596 			0.024709, 0.024404, 0.024103, 0.023805, 0.023511,
7597 			0.023221, 0.022934, 0.022651, 0.022371, 0.022095,
7598 			0.021822, 0.021553, 0.021287, 0.021024, 0.020765,
7599 			0.020509, 0.020256, 0.020006, 0.019759, 0.019515,
7600 			0.019275, 0.019037, 0.018803, 0.018571, 0.018342,
7601 			0.018116, 0.017893, 0.017672, 0.017455, 0.017240,
7602 			0.017028, 0.016818, 0.016611, 0.016406, 0.016205,
7603 			0.016005, 0.015808, 0.015614, 0.015422, 0.015232,
7604 			0.015045, 0.014860, 0.014677, 0.014497, 0.014319,
7605 			0.014143, 0.013969, 0.013798, 0.013628, 0.013461,
7606 			0.013296, 0.013132, 0.012971, 0.012812, 0.012655,
7607 			0.012500, 0.012346, 0.012195, 0.012046, 0.011898,
7608 			0.011752, 0.011608, 0.011466, 0.011325, 0.011187,
7609 			0.011050, 0.010915, 0.010781, 0.010649, 0.010519,
7610 			0.010390, 0.010263, 0.010137, 0.010013, 0.009891,
7611 			0.009770, 0.009651, 0.009533, 0.009416, 0.009301,
7612 			0.009188, 0.009076, 0.008965, 0.008856, 0.008747,
7613 			0.008641, 0.008535, 0.008431, 0.008328, 0.008227,
7614 			0.008127, 0.008028, 0.007930, 0.007833, 0.007738,
7615 			0.007644, 0.007551, 0.007459, 0.007368, 0.007278,
7616 			0.007190, 0.007102, 0.007016, 0.006931, 0.006847,
7617 			0.006763, 0.006681, 0.006600, 0.006520, 0.006441,
7618 			0.006363
7619 		}
7620 	}
7621 };
7622 
7623 static xspect illoc_ODaylight_CIE_1964_10[3] = {
7624 	{
7625 		181, 40.000000, 400.000000,
7626 		1.0,
7627 		{
7628 			0.954689, 0.954137, 0.953592, 0.953054, 0.952523,
7629 			0.952001, 0.951488, 0.950984, 0.950490, 0.950007,
7630 			0.949535, 0.949074, 0.948627, 0.948192, 0.947770,
7631 			0.947363, 0.946970, 0.946591, 0.946229, 0.945882,
7632 			0.945551, 0.945238, 0.944942, 0.944663, 0.944402,
7633 			0.944161, 0.943938, 0.943734, 0.943550, 0.943386,
7634 			0.943243, 0.943120, 0.943019, 0.942939, 0.942880,
7635 			0.942844, 0.942831, 0.942840, 0.942872, 0.942927,
7636 			0.943006, 0.943109, 0.943235, 0.943387, 0.943562,
7637 			0.943763, 0.943988, 0.944239, 0.944516, 0.944818,
7638 			0.945146, 0.945500, 0.945880, 0.946285, 0.946716,
7639 			0.947174, 0.947658, 0.948168, 0.948706, 0.949270,
7640 			0.949861, 0.950478, 0.951123, 0.951794, 0.952492,
7641 			0.953217, 0.953969, 0.954747, 0.955552, 0.956384,
7642 			0.957242, 0.958127, 0.959039, 0.959976, 0.960940,
7643 			0.961930, 0.962946, 0.963988, 0.965056, 0.966149,
7644 			0.967268, 0.968412, 0.969581, 0.970775, 0.971994,
7645 			0.973237, 0.974504, 0.975796, 0.977111, 0.978450,
7646 			0.979812, 0.981197, 0.982605, 0.984035, 0.985488,
7647 			0.986963, 0.988459, 0.989976, 0.991515, 0.993074,
7648 			0.994653, 0.996252, 0.997871, 0.999509, 1.001166,
7649 			1.002842, 1.004535, 1.006246, 1.007974, 1.009719,
7650 			1.011480, 1.013257, 1.015050, 1.016857, 1.018679,
7651 			1.020514, 1.022363, 1.024225, 1.026100, 1.027986,
7652 			1.029883, 1.031791, 1.033710, 1.035637, 1.037574,
7653 			1.039519, 1.041472, 1.043432, 1.045399, 1.047371,
7654 			1.049348, 1.051330, 1.053315, 1.055304, 1.057295,
7655 			1.059288, 1.061281, 1.063275, 1.065268, 1.067259,
7656 			1.069249, 1.071235, 1.073218, 1.075196, 1.077168,
7657 			1.079135, 1.081094, 1.083046, 1.084988, 1.086921,
7658 			1.088844, 1.090754, 1.092653, 1.094538, 1.096409,
7659 			1.098265, 1.100105, 1.101927, 1.103732, 1.105518,
7660 			1.107284, 1.109029, 1.110752, 1.112453, 1.114129,
7661 			1.115781, 1.117407, 1.119007, 1.120578, 1.122121,
7662 			1.123634, 1.125116, 1.126567, 1.127985, 1.129369,
7663 			1.130718, 1.132032, 1.133309, 1.134548, 1.135749,
7664 			1.136910
7665 		}
7666 	},
7667 	{
7668 		181, 40.000000, 400.000000,
7669 		1.0,
7670 		{
7671 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7672 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7673 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7674 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7675 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7676 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7677 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7678 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7679 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7680 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7681 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7682 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7683 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7684 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7685 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7686 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7687 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7688 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7689 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7690 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7691 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7692 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7693 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7694 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7695 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7696 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7697 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7698 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7699 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7700 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7701 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7702 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7703 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7704 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7705 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7706 			1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
7707 			1.000000
7708 		}
7709 	},
7710 	{
7711 		181, 40.000000, 400.000000,
7712 		1.0,
7713 		{
7714 			1.880550, 1.866451, 1.852259, 1.837979, 1.823618,
7715 			1.809182, 1.794679, 1.780113, 1.765491, 1.750820,
7716 			1.736104, 1.721349, 1.706561, 1.691745, 1.676907,
7717 			1.662051, 1.647182, 1.632306, 1.617427, 1.602550,
7718 			1.587679, 1.572818, 1.557971, 1.543143, 1.528338,
7719 			1.513559, 1.498810, 1.484094, 1.469415, 1.454777,
7720 			1.440182, 1.425633, 1.411134, 1.396687, 1.382295,
7721 			1.367961, 1.353687, 1.339475, 1.325329, 1.311249,
7722 			1.297239, 1.283299, 1.269433, 1.255642, 1.241928,
7723 			1.228292, 1.214736, 1.201262, 1.187870, 1.174563,
7724 			1.161341, 1.148206, 1.135188, 1.122292, 1.109489,
7725 			1.096782, 1.084173, 1.071663, 1.059253, 1.046946,
7726 			1.034742, 1.022643, 1.010649, 0.998763, 0.986985,
7727 			0.975315, 0.963755, 0.952306, 0.940967, 0.929740,
7728 			0.918626, 0.907623, 0.896734, 0.885958, 0.875296,
7729 			0.864747, 0.854312, 0.843991, 0.833784, 0.823691,
7730 			0.813712, 0.803847, 0.794095, 0.784457, 0.774933,
7731 			0.765521, 0.756222, 0.747036, 0.737962, 0.729000,
7732 			0.720149, 0.711409, 0.702779, 0.694260, 0.685850,
7733 			0.677549, 0.669357, 0.661272, 0.653296, 0.645425,
7734 			0.637662, 0.630004, 0.622450, 0.615002, 0.607657,
7735 			0.600415, 0.593275, 0.586237, 0.579301, 0.572464,
7736 			0.565728, 0.559090, 0.552551, 0.546109, 0.539764,
7737 			0.533516, 0.527363, 0.521304, 0.515340, 0.509469,
7738 			0.503690, 0.498004, 0.492408, 0.486903, 0.481488,
7739 			0.476161, 0.470923, 0.465772, 0.460709, 0.455731,
7740 			0.450839, 0.446031, 0.441307, 0.436667, 0.432109,
7741 			0.427633, 0.423238, 0.418924, 0.414689, 0.410534,
7742 			0.406457, 0.402459, 0.398537, 0.394691, 0.390922,
7743 			0.387228, 0.383608, 0.380063, 0.376591, 0.373191,
7744 			0.369864, 0.366608, 0.363424, 0.360309, 0.357265,
7745 			0.354290, 0.351383, 0.348545, 0.345774, 0.343071,
7746 			0.340434, 0.337863, 0.335359, 0.332919, 0.330544,
7747 			0.328233, 0.325986, 0.323803, 0.321683, 0.319625,
7748 			0.317629, 0.315696, 0.313824, 0.312014, 0.310264,
7749 			0.308575, 0.306946, 0.305378, 0.303869, 0.302420,
7750 			0.301031
7751 		}
7752 	}
7753 };
7754 
7755 /* - - - - - - - - - - - - - - - - - - - - - - - - - */
7756 /* Fast but slightly less accurate CCT support */
7757 
7758 /* Context for optimiser callback */
7759 typedef struct {
7760 	xspect *iloc;			/* Locus to match to */
7761 	double xyz[3];			/* Target XYZ */
7762 	icmXYZNumber XYZ;		/* Target as XYZ number for DE wp */
7763 	int viscct;				/* nz to use visual best match color temperature */
7764 } cct2ctx;
7765 
cct2_func(void * fdata,double tp[])7766 static double cct2_func(void *fdata, double tp[]) {
7767 	cct2ctx *x = (cct2ctx *)fdata;
7768 	double xyz[3];		/* Current value */
7769 	double lab1[3], lab2[3];
7770 	double rv = 0.0;
7771 	icmXYZNumber *wp = &x->XYZ;
7772 
7773 	/* Get XYZ for given temp in Mired. */
7774 	/* Will clip to limits of locus */
7775 	getval_raw_xspec3_lin(x->iloc, xyz, tp[0]);
7776 
7777 	xyz[0] /= xyz[1];
7778 	xyz[2] /= xyz[1];
7779 	xyz[1] /= xyz[1];
7780 
7781 	/* Compute the color difference to the target */
7782 	if (x->viscct) {
7783 		/* Use modern CIEDE2000 color difference - gives a better visual match */
7784 		icmXYZ2Lab(wp, lab1, x->xyz);
7785 		icmXYZ2Lab(wp, lab2, xyz);
7786 		rv = icmCIE2Ksq(lab1, lab2);
7787 	} else {
7788 		/* Use original CIE 1960 UCS space color difference */
7789 		icmXYZ21960UCS(lab1, x->xyz);
7790 		icmXYZ21960UCS(lab2, xyz);
7791 		rv = icmLabDEsq(lab1, lab2);
7792 	}
7793 
7794 	/* Discourage going beyond ends of locus */
7795 	if (tp[0] < x->iloc->spec_wl_short ) {
7796 		rv += 5000.0 * (x->iloc->spec_wl_short - tp[0]);
7797 	} else if (tp[0] > x->iloc->spec_wl_long) {
7798 		rv += 5000.0 * (tp[0] - x->iloc->spec_wl_long);
7799 	}
7800 
7801 //a1logd(g_log, 1, " cct2_func returning %f for temp = %f\n",rv,1e6/tp[0]);
7802 //DBGF((DBGA,"returning %f for temp = %f\n",rv,tp[0]));
7803 	return rv;
7804 
7805 }
7806 
7807 /* Given a particular locus indexed in Mired, */
7808 /* return the closest color temperature to the XYZ. */
7809 /* Return -1.0 on erorr */
icx_XYZ2ill_ct3(double txyz[3],xspect * iloc,double xyz[3],int viscct)7810 static double icx_XYZ2ill_ct3(
7811 double txyz[3],			/* If not NULL, return the XYZ of the locus temperature */
7812 xspect *iloc,			/* Locus to match to */
7813 double xyz[3],			/* Input XYZ value in given observer space. */
7814 int viscct				/* nz to use visual CIEDE2000, 0 to use CCT CIE 1960 UCS. */
7815 ) {
7816 	cct2ctx x;			/* Context for callback */
7817 	double cp[1], s[1];
7818 	double rv;
7819 	int i;
7820 	double tc, ber, bct = 0.0;
7821 
7822 	x.viscct = viscct;
7823 	x.iloc = iloc;
7824 	icmAry2Ary(x.xyz, xyz);
7825 
7826 	/* Normalise target */
7827 	x.xyz[0] /= x.xyz[1];
7828 	x.xyz[2] /= x.xyz[1];
7829 	x.xyz[1] /= x.xyz[1];
7830 
7831 	/* Convert to XYZ number for DE wp */
7832 	icmAry2XYZ(x.XYZ, x.xyz);
7833 
7834 	/* Do some start samples, to avoid getting trapped in local minima */
7835 	for (ber = 1e9, i = 0; i < 6; i++) {
7836 		double er;
7837 		tc = x.iloc[0].spec_wl_short
7838 		   + i/(6-1.0) * (x.iloc[0].spec_wl_long - x.iloc[0].spec_wl_short);
7839 		if ((er = cct2_func((void *)&x, &tc)) < ber) {
7840 			ber = er;
7841 			bct = tc;
7842 		}
7843 //a1logd(g_log, 1, " starting tc = %f, err = %f\n",1e6/tc,er);
7844 //DBGF((DBGA,"tc = %f, er = %f\n",1e6/tc,er));
7845 	}
7846 	cp[0] = bct;
7847 	s[0] = 20.0;
7848 
7849 	/* Locate the CCT in Mired */
7850 	if (powell(&rv, 1, cp, s, 0.01, 1000, cct2_func, (void *)&x, NULL, NULL) != 0) {
7851 		return -1.0;
7852 	}
7853 
7854 	if(txyz != NULL) {
7855 		/* Return the closest value on the locus */
7856 		getval_raw_xspec3_lin(x.iloc, txyz, cp[0]);
7857 		txyz[0] /= txyz[1];
7858 		txyz[2] /= txyz[1];
7859 		txyz[1] /= txyz[1];
7860 	}
7861 
7862 //a1logd(g_log, 1, " returning %f with error %f delta E94 %f\n",1e6/cp[0],sqrt(rv));
7863 //DBGF((DBGA,"returning %f with error %f delta E94 %f\n",cp[0],sqrt(rv)));
7864 	return 1e6/cp[0];
7865 }
7866 
7867 /* Given a choice of temperature dependent illuminant (icxIT_[O]Dtemp or icxIT_[O]Ptemp), */
7868 /* return the closest correlated color temperature to the XYZ. */
7869 /* An observer type can be chosen for interpretting the spectrum of the input and */
7870 /* the illuminant. */
7871 /* Return -1.0 on erorr */
7872 /* (Faster, slightly less accurate version of icx_XYZ2ill_ct()) */
icx_XYZ2ill_ct2(double txyz[3],icxIllumeType ilType,icxObserverType obType,double xyz[3],int viscct)7873 double icx_XYZ2ill_ct2(
7874 double txyz[3],			/* If not NULL, return the XYZ of the locus temperature */
7875 icxIllumeType ilType,	/* Type of illuminant, icxIT_[O]Dtemp or icxIT_[O]Ptemp */
7876 icxObserverType obType,	/* Observer, CIE_1931_2 or CIE_1964_10 */
7877 double xyz[3],			/* Input XYZ value in given observer space. */
7878 int viscct				/* nz to use visual CIEDE2000, 0 to use CCT CIE 1960 UCS. */
7879 ) {
7880 	xspect *iloc = NULL;
7881 
7882 	if (ilType != icxIT_Dtemp && ilType != icxIT_Ptemp
7883 	 && ilType != icxIT_ODtemp && ilType != icxIT_OPtemp)
7884 		return -1.0;
7885 	if (obType != icxOT_CIE_1931_2 && obType != icxOT_CIE_1964_10)
7886 		return -1.0;
7887 
7888 	/* Locus to use */
7889 	if (obType == icxOT_CIE_1931_2) {
7890 		if (ilType == icxIT_Dtemp) {
7891 			iloc = illoc_Daylight_CIE_1931_2;
7892 		} else if (ilType == icxIT_Ptemp) {
7893 			iloc = illoc_Plankian_CIE_1931_2;
7894 		} else if (ilType == icxIT_ODtemp) {
7895 			iloc = illoc_ODaylight_CIE_1931_2;
7896 		} else if (ilType == icxIT_OPtemp) {
7897 			iloc = illoc_OPlankian_CIE_1931_2;
7898 		}
7899 	} else {
7900 		if (ilType == icxIT_Dtemp) {
7901 			iloc = illoc_Daylight_CIE_1964_10;
7902 		} else if (ilType == icxIT_Ptemp) {
7903 			iloc = illoc_Plankian_CIE_1964_10;
7904 		} else if (ilType == icxIT_ODtemp) {
7905 			iloc = illoc_ODaylight_CIE_1964_10;
7906 		} else if (ilType == icxIT_OPtemp) {
7907 			iloc = illoc_OPlankian_CIE_1964_10;
7908 		}
7909 	}
7910 
7911 	/* Let icx_XYZ2ill_ct3() do all the hard work */
7912 	return icx_XYZ2ill_ct3(txyz, iloc, xyz, viscct);
7913 }
7914 
7915 /* Given a choice of temperature dependent illuminant (icxIT_[O]Dtemp or icxIT_[O]Ptemp), */
7916 /* a color temperature and a Y value, return the corresponding XYZ */
7917 /* An observer type can be chosen for interpretting the spectrum of the input and */
7918 /* the illuminant. */
7919 /* Return xyz[0] = -1.0 on erorr */
7920 /* (Faster, slightly less accrurate alternative to standardIlluminant()) */
icx_ill_ct2XYZ(double xyz[3],icxIllumeType ilType,icxObserverType obType,int viscct,double tin,double Yin)7921 void icx_ill_ct2XYZ(
7922 double xyz[3],			/* Return the XYZ value */
7923 icxIllumeType ilType,	/* Type of illuminant, icxIT_[O]Dtemp or icxIT_[O]Ptemp */
7924 icxObserverType obType,	/* Observer, CIE_1931_2 or CIE_1964_10 */
7925 int viscct,				/* nz to use visual CIEDE2000, 0 to use CCT CIE 1960 UCS. */
7926 double tin,				/* Input temperature */
7927 double Yin				/* Input Y value */
7928 ) {
7929 	xspect *iloc;			/* Locus to match to */
7930 
7931 	double cp[1], s[1];
7932 
7933 	if (ilType != icxIT_Dtemp && ilType != icxIT_Ptemp
7934 	 && ilType != icxIT_ODtemp && ilType != icxIT_OPtemp) {
7935 		xyz[0] = -1.0;
7936 		return;
7937 	}
7938 	if (obType != icxOT_CIE_1931_2 && obType != icxOT_CIE_1964_10) {
7939 		xyz[0] = -1.0;
7940 		return;
7941 	}
7942 
7943 	/* Locus to use */
7944 	if (obType == icxOT_CIE_1931_2) {
7945 		if (ilType == icxIT_Dtemp) {
7946 			iloc = illoc_Daylight_CIE_1931_2;
7947 		} else if (ilType == icxIT_Ptemp) {
7948 			iloc = illoc_Plankian_CIE_1931_2;
7949 		} else if (ilType == icxIT_ODtemp) {
7950 			iloc = illoc_ODaylight_CIE_1931_2;
7951 		} else if (ilType == icxIT_OPtemp) {
7952 			iloc = illoc_OPlankian_CIE_1931_2;
7953 		}
7954 	} else {
7955 		if (ilType == icxIT_Dtemp) {
7956 			iloc = illoc_Daylight_CIE_1964_10;
7957 		} else if (ilType == icxIT_Ptemp) {
7958 			iloc = illoc_Plankian_CIE_1964_10;
7959 		} else if (ilType == icxIT_ODtemp) {
7960 			iloc = illoc_ODaylight_CIE_1964_10;
7961 		} else if (ilType == icxIT_OPtemp) {
7962 			iloc = illoc_OPlankian_CIE_1964_10;
7963 		}
7964 	}
7965 
7966 	/* Convert temperature to mired */
7967 	tin =  1e6/tin;
7968 
7969 	/* Get XYZ for given temp in Mired. */
7970 	/* Will clip to limits of locus */
7971 	getval_raw_xspec3_lin(iloc, xyz, tin);
7972 
7973 	/* Scale by Yin */
7974 	xyz[0] *= Yin/xyz[1];
7975 	xyz[2] *= Yin/xyz[1];
7976 	xyz[1] = Yin;
7977 }
7978 
7979 /* - - - - - - - - - - - - - - - - - - - - - - - - - */
7980 /* Spectral and illuminant chromaticity locus support */
7981 
7982 /* All the nomenclature is for spectral locus, */
7983 /* but we use the same mechanism for a Daylight or */
7984 /* Plankian illuminant locus, substituting temp/Mired for wavelength/nm */
7985 
7986 /* Chromaticity locus poligon vertex */
7987 typedef struct {
7988 	double xy[2];				/* xy, u'v' value */
7989 	double xy_n[2];				/* xy, u'v' inwards normal direction */
7990 	double dist;				/* Accumulated distance */
7991 	double rgb[3];				/* Representative color at this point */
7992 } xslvtx;
7993 
7994 /* Vertex bounding box */
7995 typedef struct {
7996 	int ix;						/* Starting index of vertex */
7997 	int n;						/* Number of vertexes in box */
7998 	double xmin;
7999 	double ymin;
8000 	double xmax;
8001 	double ymax;
8002 } xslbbx;
8003 
8004 #define SLOC_BBXN 19			/* 19 vertexes per bounding box */
8005 
8006 /* Chromaticity locus poligon cache */
8007 struct _xslpoly {
8008 	int    sp;					/* 0 = Spectral Locus, 1 = Daylight, 2 = Plankian */
8009 	icxObserverType obType;		/* Type of observer */
8010 	int    uv;					/* 0 = xy, 1 = u'v' space */
8011 	int    n;					/* Number of vertexes, 0 if uninit */
8012 	double wl_short;			/* First reading wavelength in nm (shortest)/ smallest Mired */
8013 	double wl_long;				/* Last reading wavelength in nm (longest)/ largest Mired */
8014 	double xmin, xmax, ymin, ymax;	/* xy Boundint box */
8015 	double tx[3], ty[3];		/* xy Fast inner triangle test, RGB (spectral locus) */
8016 	double be[3][3];    		/* xy baricentric equations of triangle (spectral locus) */
8017 //	double eed[3];				/* xy Distance of triangle points to 0.3, 0.3 (spectral locus) */
8018 	xslvtx v[XSPECT_MAX_BANDS]; /* vertex values */
8019 	int    nbb;					/* Number of bounding boxes */
8020 	xslbbx bb[XSPECT_MAX_BANDS/SLOC_BBXN + 1]; /* Bounding boxes */
8021 	double d_max;				/* Maximum distance */
8022 	double rv[XSPECT_MAX_BANDS];	/* distance to wl reverse lookup */
8023 };
8024 
8025 /* Init a xslpoly */
8026 /* Return nz on error */
icx_init_locus_poly(xslpoly * p)8027 static int icx_init_locus_poly(
8028 	xslpoly *p
8029 ) {
8030 //	static CRITICAL_SECTION lock = { NULL, -1 };
8031 	static amutex_static(lock);
8032 
8033 //	InitializeCriticalSection(&(lock));
8034 
8035 	/* Prevent threads trying to multiply initialise the xslpoly */
8036 //	EnterCriticalSection(&(lock));
8037 	amutex_lock(lock);
8038 
8039 	if (p->n == 0) {
8040 		int i0, in;
8041 		double wl_short, wl_long;
8042 		int ii, i, j, c;
8043 		double Yxy[3];
8044 		double xyz[3];
8045 		xspect *sp[3];
8046 		double tt[3][3];
8047 		double dist = 0.0;
8048 
8049 		if (standardObserver(sp, p->obType)) {
8050 			amutex_unlock(lock);
8051 			return 1;
8052 		}
8053 
8054 		if (p->sp == 0) {	/* If spectral locus */
8055 			i0 = 0;
8056 			in = sp[0]->spec_n;
8057 			wl_short = sp[0]->spec_wl_short;
8058 			wl_long = sp[0]->spec_wl_long;
8059 
8060 			/* Limit the range to 400 - 700, as the locus is not well behaved outside that */
8061 			if (wl_short < 400.0) {
8062 				i0 = (int)ceil(XSPECT_DIX(sp[0]->spec_wl_short, sp[0]->spec_wl_long, sp[0]->spec_n, 400.0));
8063 				wl_short = XSPECT_WL(sp[0]->spec_wl_short, sp[0]->spec_wl_long, sp[0]->spec_n, i0);
8064 			}
8065 			if (wl_long > 700.0) {
8066 				in = (int)ceil(XSPECT_DIX(sp[0]->spec_wl_short, sp[0]->spec_wl_long, sp[0]->spec_n, 700.0));
8067 				wl_long = XSPECT_WL(sp[0]->spec_wl_short, sp[0]->spec_wl_long, sp[0]->spec_n, in);
8068 				in++;
8069 			}
8070 
8071 			p->n = in - i0;
8072 			p->wl_short = wl_short;
8073 			p->wl_long = wl_long;
8074 			p->xmin = p->ymin = 1e6;
8075 			p->xmax = p->ymax = -1e6;
8076 
8077 			/* Compute xy, and accumulated distance along locus */
8078 			for (ii = 0, i = i0; i < in; i++, ii++) {
8079 				double wl = XSPECT_WL(p->wl_short, p->wl_long, p->n, ii);
8080 
8081 				xyz[0] = sp[0]->spec[i];
8082 				xyz[1] = sp[1]->spec[i];
8083 				xyz[2] = sp[2]->spec[i];
8084 
8085 				if (p->uv == 0)
8086 					icmXYZ2Yxy(Yxy, xyz);
8087 				else
8088 					icmXYZ21976UCS(Yxy, xyz);
8089 				p->v[ii].xy[0] = Yxy[1];
8090 				p->v[ii].xy[1] = Yxy[2];
8091 
8092 				if (ii == 0) {
8093 					p->v[ii].dist = 0.0;
8094 				} else {
8095 					double d0, d1;
8096 					d0 = p->v[ii].xy[0] - p->v[ii-1].xy[0];
8097 					d1 = p->v[ii].xy[1] - p->v[ii-1].xy[1];
8098 					dist += sqrt(d0 * d0 + d1 * d1);
8099 					p->v[ii].dist = dist;
8100 				}
8101 
8102 				/* Compute a display color */
8103 				icx_wl2RGB_ds(p->v[ii].rgb, wl, 0.1);
8104 
8105 //a1logd(g_log, 1, " [%d] = %f %f, dist %f\n",i,p->v[ii].xy[0],p->v[ii].xy[1],p->v[ii].dist);
8106 				if (Yxy[1] < p->xmin)
8107 					p->xmin = Yxy[1];
8108 				if (Yxy[1] > p->xmax)
8109 					p->xmax = Yxy[1];
8110 				if (Yxy[2] < p->ymin)
8111 					p->ymin = Yxy[2];
8112 				if (Yxy[2] > p->ymax)
8113 					p->ymax = Yxy[2];
8114 			}
8115 
8116 		} else {	/* Daylight or Plankian locus */
8117 			xspect *iloc;
8118 			icxIllumeType ilType = p->sp == 1 ? icxIT_Dtemp : icxIT_Ptemp;
8119 
8120 			if (p->obType == icxOT_CIE_1931_2) {
8121 				if (ilType == icxIT_Dtemp) {
8122 					iloc = illoc_Daylight_CIE_1931_2;
8123 				} else {
8124 					iloc = illoc_Plankian_CIE_1931_2;
8125 				}
8126 			} else {
8127 				if (ilType == icxIT_Dtemp) {
8128 					iloc = illoc_Daylight_CIE_1964_10;
8129 				} else {
8130 					iloc = illoc_Plankian_CIE_1964_10;
8131 				}
8132 			}
8133 
8134 			i0 = 0;
8135 			in = iloc[0].spec_n;
8136 			wl_short = iloc[0].spec_wl_short;
8137 			wl_long = iloc[0].spec_wl_long;
8138 
8139 			p->n = in - i0;
8140 			p->wl_short = wl_short;
8141 			p->wl_long = wl_long;
8142 			p->xmin = p->ymin = 1e6;
8143 			p->xmax = p->ymax = -1e6;
8144 
8145 			/* Compute xy/u'v', and accumulated distance along locus */
8146 			for (ii = 0, i = i0; i < in; i++, ii++) {
8147 				double xyz[3];
8148 				double temp;
8149 
8150 				xyz[0] = iloc[0].spec[i];
8151 				xyz[1] = iloc[1].spec[i];
8152 				xyz[2] = iloc[2].spec[i];
8153 
8154 				if (p->uv == 0)
8155 					icmXYZ2Yxy(Yxy, xyz);
8156 				else
8157 					icmXYZ21976UCS(Yxy, xyz);
8158 				p->v[ii].xy[0] = Yxy[1];
8159 				p->v[ii].xy[1] = Yxy[2];
8160 
8161 				if (ii == 0) {
8162 					p->v[ii].dist = 0.0;
8163 				} else {
8164 					double d0, d1;
8165 					d0 = p->v[ii].xy[0] - p->v[ii-1].xy[0];
8166 					d1 = p->v[ii].xy[1] - p->v[ii-1].xy[1];
8167 					dist += sqrt(d0 * d0 + d1 * d1);
8168 					p->v[ii].dist = dist;
8169 				}
8170 
8171 				/* Compute a display color */
8172 				icx_XYZ2RGB_ds(p->v[ii].rgb, xyz, 0.1);
8173 
8174 //a1logd(g_log, 1, " [%d] Mired %f = %f %f, dist %f\n",i,XSPECT_WL(wl_short, wl_long, in, i),p->v[ii].xy[0],p->v[ii].xy[1],p->v[ii].dist);
8175 				if (Yxy[1] < p->xmin)
8176 					p->xmin = Yxy[1];
8177 				if (Yxy[1] > p->xmax)
8178 					p->xmax = Yxy[1];
8179 				if (Yxy[2] < p->ymin)
8180 					p->ymin = Yxy[2];
8181 				if (Yxy[2] > p->ymax)
8182 					p->ymax = Yxy[2];
8183 			}
8184 		}
8185 
8186 		/* Compute bounding boxes */
8187 		for (i = ii = 0; i < p->n;) {
8188 			int m;
8189 			p->bb[ii].ix = i;
8190 			p->bb[ii].xmin = p->bb[ii].ymin = 1e6;
8191 			p->bb[ii].xmax = p->bb[ii].ymax = -1e6;
8192 			for (m = 0; m < SLOC_BBXN && i < p->n; i++, m++) {
8193 				if (p->v[i].xy[0] < p->bb[ii].xmin)
8194 					p->bb[ii].xmin = p->v[i].xy[0];
8195 				if (p->v[i].xy[1] < p->bb[ii].ymin)
8196 					p->bb[ii].ymin = p->v[i].xy[1];
8197 				if (p->v[i].xy[0] > p->bb[ii].xmax)
8198 					p->bb[ii].xmax = p->v[i].xy[0];
8199 				if (p->v[i].xy[1] > p->bb[ii].ymax)
8200 					p->bb[ii].ymax = p->v[i].xy[1];
8201 			}
8202 			p->bb[ii++].n = m;
8203 		}
8204 		p->nbb = ii;
8205 
8206 //for (i = 0; i < p->nbb; i++)
8207 //a1logd(g_log, 1,"bb %d: n = %d, bb %f %f %f %f",i,p->bb[i].n, p->bb[i].xmin,p->bb[i].xmax,p->bb[i].ymin,p->bb[i].ymax);
8208 
8209 		/* Compute reverse lookup of distance to wavelength/temp */
8210 		{
8211 			p->d_max = p->v[p->n-1].dist;
8212 
8213 //a1logd(g_log, 1,"d_max = %f\n",p->d_max);
8214 
8215 			p->rv[0] = 0.0;
8216 			for (i = 1; i < XSPECT_MAX_BANDS; i++)
8217 				p->rv[i] = -1.0;
8218 
8219 			/* Create search start points */
8220 			for (i = 0; i < p->n; i++) {
8221 				int ix;
8222 				ix = (int)floor(XSPECT_DIX(0.0, p->d_max, XSPECT_MAX_BANDS,  p->v[i].dist));
8223 				if (p->rv[ix] < 0.0 || (double)i < p->rv[ix]) {
8224 					p->rv[ix] = (double)i;
8225 //a1logd(g_log, 1,"ix %d dist %f start ix %d\n",ix,p->v[i].dist,i);
8226 				}
8227 			}
8228 
8229 			/* Go through start points and create interpolated points */
8230 			for (i = XSPECT_MAX_BANDS-2; i > 0; i--) {
8231 				double d, wl0, d0, wl1, d1, bl, wl;
8232 				int j, ix;
8233 
8234 				d = XSPECT_WL(0.0, p->d_max, XSPECT_MAX_BANDS, i);	/* Distance of this cell */
8235 
8236 				/* Find a search start point - skip any empty slots */
8237 				for (j = i; j >= 0; j--) {
8238 					ix = (int)p->rv[j];
8239 					if (ix >= 0)
8240 						break;
8241 				}
8242 				if (j < 0)
8243 					ix = 0;
8244 
8245 				for (; ix >= 0; ix--) {
8246 					d0 = p->v[ix].dist;
8247 					if (d0 <= d)
8248 						break;
8249 				}
8250 				if (ix < 0)
8251 					ix = 0;
8252 				wl0 = XSPECT_WL(wl_short, wl_long, p->n, ix);
8253 
8254 				/* Locate the fwd point after this entries distance */
8255 				for (j = ix+1; j < p->n; j++) {
8256 					d1 = p->v[j].dist;
8257 					if (d1 >= d)
8258 						break;
8259 				}
8260 				if (j >= p->n) {
8261 					d1 = p->d_max;
8262 					j--;
8263 					if (ix == j) {
8264 						ix--;
8265 						wl0 = XSPECT_WL(wl_short, wl_long, p->n, ix);
8266 						d0 = p->v[ix].dist;
8267 					}
8268 				}
8269 				wl1 = XSPECT_WL(wl_short, wl_long, p->n, j);
8270 
8271 				/* Linearly interpolate for this entries distance */
8272 				bl = (d - d0)/(d1 - d0);
8273 //a1logd(g_log, 1,"rv ix %d, d %f, bl %f, ixs %d - %d, ds %f - %f, wls %f - %f\n",i,d,bl, ix,j,d0,d1,wl0,wl1);
8274 				wl = (1.0 - bl) * wl0 + bl * wl1;
8275 				p->rv[i] = wl;
8276 			}
8277 			p->rv[0] = wl_short;
8278 			p->rv[XSPECT_MAX_BANDS-1] = wl_long;
8279 
8280 //for (i = 0; i < XSPECT_MAX_BANDS; i++)
8281 //	a1logd(g_log, 1,"rv %d = %f\n",i,p->rv[i]);
8282 		}
8283 
8284 		/* Compute outward normals, and delta wl/delta dist */
8285 		for (i = 0; i < p->n; i++) {
8286 			int span = 1;
8287 			double pn[2], mm;
8288 
8289 			if (i < 50)		/* Hack to straighten up 400nm */
8290 				span = 20;
8291 
8292 			i0 = i - span;
8293 			in = i + span;
8294 			if (i0 < 0) {
8295 				i0 = 0;
8296 				in = i0 + 2 * span;
8297 			}
8298 			if (in > (p->n-1)) {
8299 				in = (p->n-1);
8300 				i0 = in - 2 * span;
8301 			}
8302 			pn[0] =   p->v[in].xy[1] - p->v[i0].xy[1];
8303 			pn[1] = -(p->v[in].xy[0] - p->v[i0].xy[0]);
8304 
8305 //	a1logd(g_log, 1,"i0 = %d, in = %d\n",i0, in);
8306 //	a1logd(g_log, 1,"i0 %d = %f %f\n",i0,p->v[i0].xy[0],p->v[i0].xy[1]);
8307 //	a1logd(g_log, 1,"in %d = %f %f\n",in,p->v[in].xy[0],p->v[i0].xy[1]);
8308 //	a1logd(g_log, 1,"pn = %f %f\n",pn[0],pn[1]);
8309 
8310 			mm = sqrt(pn[0] * pn[0] + pn[1] * pn[1]);
8311 			pn[0] /= mm;
8312 			pn[1] /= mm;
8313 
8314 			p->v[i].xy_n[0] = pn[0];
8315 			p->v[i].xy_n[1] = pn[1];
8316 		}
8317 
8318 #ifdef NEVER
8319 		/* Compute v2 sub sampled values */
8320 #endif
8321 
8322 		if (p->sp == 0) {	/* If spectral locus */
8323 			/* Select 3 points for inner triangle in RGB order */
8324 			p->tx[0] = p->v[p->n - 1].xy[0];
8325 			p->ty[0] = p->v[p->n - 1].xy[1];
8326 
8327 			xyz[0] = value_xspect(sp[0], 517.0);
8328 			xyz[1] = value_xspect(sp[1], 517.0);
8329 			xyz[2] = value_xspect(sp[2], 517.0);
8330 			if (p->uv == 0)
8331 				icmXYZ2Yxy(Yxy, xyz);
8332 			else
8333 				icmXYZ21976UCS(Yxy, xyz);
8334 			p->tx[1] = Yxy[1];
8335 			p->ty[1] = Yxy[2];
8336 
8337 			p->tx[2] = p->v[0].xy[0];
8338 			p->ty[2] = p->v[0].xy[1];
8339 
8340 			/* Compute distance from triangles to 0.3, 0.3 */
8341 //			for (i = 0; i < 3; i++) {
8342 //				p->eed[i] = sqrt((p->tx[i] - 0.3) * (p->tx[i] - 0.3)
8343 //				                  + (p->ty[i] - 0.3) * (p->ty[i] - 0.3));
8344 //			}
8345 
8346 			/* Compute baricentric equations */
8347 			for (i = 0; i < 3; i++) {
8348 				tt[0][i] = p->tx[i];
8349 				tt[1][i] = p->ty[i];
8350 				tt[2][i] = 1.0;
8351 			}
8352 			if (icmInverse3x3(p->be, tt)) {
8353 				a1loge(g_log, 2, "icx_init_locus_poly: Matrix inversion failed");
8354 				amutex_unlock(lock);
8355 				return 2;
8356 			}
8357 
8358 			/* Compute baricentric of 0.3 0.3 */
8359 			/* (Not currently used. How to move center to 0.3 0.3 ?? */
8360 //			for (i = 0; i < 3; i++)
8361 //				p->eed[i] = p->be[i][0] * 0.3 + p->be[i][1] * 0.3 + p->be[i][2];
8362 		}
8363 	}
8364 	amutex_unlock(lock);
8365 	return 0;
8366 }
8367 
8368 /* Spectral locus */
8369 static xslpoly splo_CIE_1931_2_xy       = { 0, icxOT_CIE_1931_2,       0, 0 };
8370 static xslpoly splo_CIE_1931_2_uv       = { 0, icxOT_CIE_1931_2,       1, 0 };
8371 static xslpoly splo_CIE_1964_10_xy      = { 0, icxOT_CIE_1964_10,      0, 0 };
8372 static xslpoly splo_CIE_1964_10_uv      = { 0, icxOT_CIE_1964_10,      1, 0 };
8373 static xslpoly splo_Stiles_Burch_2_xy   = { 0, icxOT_Stiles_Burch_2,   0, 0 };
8374 static xslpoly splo_Stiles_Burch_2_uv   = { 0, icxOT_Stiles_Burch_2,   1, 0 };
8375 static xslpoly splo_Judd_Voss_2_xy      = { 0, icxOT_Judd_Voss_2,      0, 0 };
8376 static xslpoly splo_Judd_Voss_2_uv      = { 0, icxOT_Judd_Voss_2,      1, 0 };
8377 static xslpoly splo_CIE_1964_10c_xy     = { 0, icxOT_CIE_1964_10c,     0, 0 };
8378 static xslpoly splo_CIE_1964_10c_uv     = { 0, icxOT_CIE_1964_10c,     1, 0 };
8379 static xslpoly splo_Shaw_Fairchild_2_xy = { 0, icxOT_Shaw_Fairchild_2, 0, 0 };
8380 static xslpoly splo_Shaw_Fairchild_2_uv = { 0, icxOT_Shaw_Fairchild_2, 1, 0 };
8381 
8382 /* Illuminant locus */
8383 static xslpoly illo_D_CIE_1931_2_xy       = { 1, icxOT_CIE_1931_2,     0, 0 };
8384 static xslpoly illo_D_CIE_1931_2_uv       = { 1, icxOT_CIE_1931_2,     1, 0 };
8385 static xslpoly illo_D_CIE_1964_10_xy      = { 1, icxOT_CIE_1964_10,    0, 0 };
8386 static xslpoly illo_D_CIE_1964_10_uv      = { 1, icxOT_CIE_1964_10,    1, 0 };
8387 static xslpoly illo_P_CIE_1931_2_xy       = { 2, icxOT_CIE_1931_2,     0, 0 };
8388 static xslpoly illo_P_CIE_1931_2_uv       = { 2, icxOT_CIE_1931_2,     1, 0 };
8389 static xslpoly illo_P_CIE_1964_10_xy      = { 2, icxOT_CIE_1964_10,    0, 0 };
8390 static xslpoly illo_P_CIE_1964_10_uv      = { 2, icxOT_CIE_1964_10,    1, 0 };
8391 
8392 /* Return a pointer to the (static) chromaticity locus poligon */
8393 /* return NULL on failure. */
chrom_locus_poligon(icxLocusType loty,icxObserverType obType,int uv)8394 xslpoly *chrom_locus_poligon(
8395 icxLocusType loty,			/* Locus type, 1 = spectral, 2 = Daylight, 3 = Plankian */
8396 icxObserverType obType,		/* Type of observer */
8397 int uv						/* 0 = xy, 1 = u'v' space */
8398 ) {
8399 	xslpoly *rv = NULL;
8400 
8401 	if (loty == icxLT_none)
8402 		return NULL;
8403 
8404 	switch (obType) {
8405     	case icxOT_default:
8406     	case icxOT_CIE_1931_2:
8407 			if (uv == 0) {
8408 				if (loty == icxLT_spectral)
8409 					rv = &splo_CIE_1931_2_xy;
8410 				else if (loty == icxLT_daylight)
8411 					rv = &illo_D_CIE_1931_2_xy;
8412 				else if (loty == icxLT_plankian)
8413 					rv = &illo_P_CIE_1931_2_xy;
8414 			} else {
8415 				if (loty == icxLT_spectral)
8416 					rv = &splo_CIE_1931_2_uv;
8417 				else if (loty == icxLT_daylight)
8418 					rv = &illo_D_CIE_1931_2_uv;
8419 				else if (loty == icxLT_plankian)
8420 					rv = &illo_P_CIE_1931_2_uv;
8421 			}
8422 			break;
8423     	case icxOT_CIE_1964_10:
8424 			if (uv == 0) {
8425 				if (loty == icxLT_spectral)
8426 					rv = &splo_CIE_1964_10_xy;
8427 				else if (loty == icxLT_daylight)
8428 					rv = &illo_D_CIE_1964_10_xy;
8429 				else if (loty == icxLT_plankian)
8430 					rv = &illo_P_CIE_1964_10_xy;
8431 			} else {
8432 				if (loty == icxLT_spectral)
8433 					rv = &splo_CIE_1964_10_uv;
8434 				else if (loty == icxLT_daylight)
8435 					rv = &illo_D_CIE_1964_10_uv;
8436 				else if (loty == icxLT_plankian)
8437 					rv = &illo_P_CIE_1964_10_uv;
8438 			}
8439 			break;
8440 		default:
8441 			rv = NULL;
8442 	}
8443 	if (rv == NULL)
8444 		return rv;
8445 
8446 
8447 	if (rv->n == 0 && icx_init_locus_poly(rv))
8448 		return NULL;
8449 
8450 	return rv;
8451 }
8452 
8453 
8454 /* Determine whether the given XYZ is outside the spectrum locus */
8455 /* Return 0 if within locus */
8456 /* Return 1 if outside locus */
icx_outside_spec_locus(xslpoly * p,double xyz[3])8457 int icx_outside_spec_locus(xslpoly *p, double xyz[3]) {
8458 	int i, j, c;
8459 	xslpoly *poly;
8460 	double Yxy[3];
8461 
8462 	icmXYZ2Yxy(Yxy, xyz);
8463 
8464 	/* Quick test - bounding box */
8465 	if (Yxy[1] < p->xmin || Yxy[1] > p->xmax
8466 	 || Yxy[2] < p->ymin || Yxy[2] > p->ymax)
8467 		return 1;
8468 
8469 	/* Quick test - inner triangle */
8470 	for (c = 1, i = 0, j = 3-1; i < 3; j = i++) {
8471 		if ( ((p->ty[i] > Yxy[2]) != (p->ty[j] > Yxy[2]))
8472 		   && (Yxy[1] < (p->tx[j] - p->tx[i]) * (Yxy[2] - p->ty[i])
8473 			        / (p->ty[j] - p->ty[i]) + p->tx[i]) )
8474 		c = !c;
8475 	}
8476 	if (c == 0)
8477 		return 0;
8478 
8479 	/* Do point in poligon test */
8480 	/* (This could be speeded up in many ways) */
8481 	for (c = 1, i = 0, j = p->n-1; i < p->n; j = i++) {
8482 		if ( ((p->v[i].xy[1] > Yxy[2]) != (p->v[j].xy[1] > Yxy[2]))
8483 		   && (Yxy[1] < (p->v[j].xy[0] - p->v[i].xy[0]) * (Yxy[2] - p->v[i].xy[1])
8484 			        / (p->v[j].xy[1] - p->v[i].xy[1]) + p->v[i].xy[0]) )
8485 		c = !c;
8486 	}
8487 
8488 	return c;
8489 }
8490 
8491 /* -------------------------------------------------------- */
8492 
8493 
8494 /* Status T log10 weightings */
8495 /* CMY + ISO V */
8496 static xspect denT[4] = {
8497 	{
8498 		44, 340.0, 770.0,	/* 44 bands from 340 to 770 nm in 10nm steps */
8499 		1.0,				/* Log10 Scale factor */
8500 		{
8501 			-10.0,
8502 			-10.0, -10.0, -10.0, -10.0, -10.0,
8503 			-10.0, -10.0, -10.0, -10.0, -10.0,
8504 			-10.0, -10.0, -10.0, -10.0, -10.0,
8505 			-10.0, -10.0, -10.0, -10.0, -10.0,
8506 			-10.0, 0.500, 1.778, 2.653, 4.477,
8507 			5.000, 4.929, 4.740, 4.398, 4.000,
8508 			3.699, 3.176, 2.699, 2.477, 2.176,
8509 			1.699, 1.000, 0.500, -10.0, -10.0,
8510 			-10.0, -10.0, -10.0
8511 		}
8512 	},
8513 	{
8514 		44, 340.0, 770.0,	/* 44 bands from 340 to 770 nm in 10nm steps */
8515 		1.0,				/* Log10 Scale factor */
8516 		{
8517 			-10.0,
8518 			-10.0, -10.0, -10.0, -10.0, -10.0,
8519 			-10.0, -10.0, -10.0, -10.0, -10.0,
8520 			-10.0, -10.0, 0.500, 3.000, 3.699,
8521 			4.447, 4.833, 4.964, 5.000, 4.944,
8522 			4.820, 4.623, 4.342, 3.954, 3.398,
8523 			2.845, 1.954, 1.000, 0.500, -10.0,
8524 			-10.0, -10.0, -10.0, -10.0, -10.0,
8525 			-10.0, -10.0, -10.0, -10.0, -10.0,
8526 			-10.0, -10.0, -10.0
8527 		}
8528 	},
8529 	{
8530 		44, 340.0, 770.0,	/* 44 bands from 340 to 770 nm in 10nm steps */
8531 		1.0,				/* Log10 Scale factor */
8532 		{
8533 			0.500,
8534 			1.000, 1.301, 2.000, 2.477, 3.176,
8535 			3.778, 4.230, 4.602, 4.778, 4.914,
8536 			4.973, 5.000, 4.987, 4.929, 4.813,
8537 			4.602, 4.255, 3.699, 2.301, 1.602,
8538 			0.500, -10.0, -10.0, -10.0, -10.0,
8539 			-10.0, -10.0, -10.0, -10.0, -10.0,
8540 			-10.0, -10.0, -10.0, -10.0, -10.0,
8541 			-10.0, -10.0, -10.0, -10.0, -10.0,
8542 			-10.0, -10.0, -10.0
8543 		}
8544 	},
8545 	{
8546 		44, 340.0, 770.0,	/* 44 bands from 340 to 770 nm in 10nm steps */
8547 		1.0,				/* Log10 Scale factor */
8548 		{
8549 			-10.0,
8550 			-10.0, -10.0, -10.0, -10.0, -10.0,
8551 			0.500, 1.332, 1.914, 2.447, 2.881,
8552 			3.090, 3.346, 3.582, 3.818, 4.041,
8553 			4.276, 4.513, 4.702, 4.825, 4.905,
8554 			4.957, 4.989, 5.000, 4.989, 4.956,
8555 			4.902, 4.827, 4.731, 4.593, 4.433,
8556 			4.238, 4.013, 3.749, 3.490, 3.188,
8557 			2.901, 2.622, 2.334, 2.041, 1.732,
8558 			1.431, 1.146, 0.500
8559 		}
8560 	}
8561 };
8562 
8563 
8564 /* Given a reflectance or transmition spectral product, (Relative */
8565 /* to the scale factor), return status T CMYV log10 density values */
xsp_Tdensity(double * out,xspect * in)8566 void xsp_Tdensity(
8567 double *out,			/* Return CMYV density */
8568 xspect *in				/* Spectral product to be converted */
8569 ) {
8570 	int j;
8571 
8572 	/* Compute the CMYV values (normalised to 1.0) */
8573 	for (j = 0; j < 4; j++) {
8574 		double ww;
8575 		double sum;
8576 
8577 		/* Integrate at 1nm intervals */
8578 		sum = out[j] = 0.0;
8579 		for (ww = denT[j].spec_wl_short; ww <= denT[j].spec_wl_long; ww += 1.0) {
8580 			double W, S;
8581 
8582 			getval_xspec(&denT[j], &W, ww);
8583 			getval_xspec(in, &S, ww);
8584 			W = pow(10.0, W);			/* Convert from log to linear weighting */
8585 			sum += W;					/* Sum of weightings */
8586 			out[j] += S * W;
8587 		}
8588 		out[j] /= sum;		/* Normalise */
8589 		if (out[j] < 1e-8)
8590 			out[j] = 1e-8;			/* Just to be sure we don't get silly values */
8591 		else if (out[j] > 2.0)
8592 			out[j] = 2.0;
8593 
8594 		out[j] = -log10(out[j]);		/* Convert to density */
8595 	}
8596 }
8597 
8598 /* XYZ to status T density aproximate conversion matrix */
8599 /* (Note we're multiplying by a 0.83 factor below to */
8600 /* avoid some limiting for some XYZ values) */
8601 static double xyz2tden[4][3] = {
8602 	{  1.750557, -0.361811, -0.265150 },	/* Red density */
8603 	{ -0.919004,  1.861722,  0.105787 },	/* Green density */
8604 	{ -0.047821,  0.093820,  1.163331 },	/* Blue density */
8605 	{  0.369966,  0.708047, -0.076312 }		/* Visual density */
8606 };
8607 
8608 /* Given a reflectance or transmission XYZ value, */
8609 /* return approximate status T CMYV log10 density values */
icx_XYZ2Tdens(double * out,double * in)8610 void icx_XYZ2Tdens(
8611 double *out,			/* Return aproximate CMYV log10 density */
8612 double *in				/* Input XYZ values */
8613 ) {
8614 	int i, j;
8615 	double den[4];
8616 
8617 //DBGF((DBGA,"icx_XYZ2den got %f %f %f\n",in[0],in[1],in[2]));
8618 	for (i = 0; i < 4; i++) {
8619 
8620 		den[i] = 0.0;
8621 		for (j = 0; j < 3; j++)
8622 			den[i] += 0.83 * xyz2tden[i][j] * in[j];
8623 
8624 //DBGF((DBGA,"icx_XYZ2den raw den %d = %f\n",i,den[i]));
8625 		if (den[i] < 0.00001)
8626 			den[i] = 0.00001;		/* Just to be sure we don't get silly values */
8627 		else if (den[i] > 1.0)
8628 			den[i] = 1.0;
8629 
8630 		out[i] = -log10(den[i]);	/* Convert to density */
8631 	}
8632 //DBGF((DBGA,"icx_XYZ2den returning densities %f %f %f\n",out[0],out[1],out[2]));
8633 }
8634 
8635 /* Given a reflectance or transmission XYZ value, */
8636 /* return log10 XYZ density values */
icx_XYZ2dens(double * out,double * in)8637 void icx_XYZ2dens(
8638 double *out,			/* Return log10 XYZ density */
8639 double *in				/* Input XYZ values */
8640 ) {
8641 	int i;
8642 	double den[3];
8643 
8644 	for (i = 0; i < 3; i++) {
8645 
8646 		den[i] = in[i];
8647 
8648 		if (den[i] < 0.00001)
8649 			den[i] = 0.00001;		/* Just to be sure we don't get silly values */
8650 		else if (den[i] > 1.0)
8651 			den[i] = 1.0;
8652 
8653 		out[i] = -log10(den[i]);	/* Convert to density */
8654 	}
8655 }
8656 
8657 /* Given an XYZ value, return sRGB values. */
8658 /* This is a little slow if wp used */
icx_XYZ2sRGB(double * out,double * wp,double * in)8659 void icx_XYZ2sRGB(
8660 double *out,			/* Return sRGB values */
8661 double *wp,				/* Input XYZ white point (D65 used if NULL) */
8662 double *in				/* Input XYZ values */
8663 ) {
8664 	int i, j;
8665 	double XYZ[3];
8666 	double d65[3] = { 0.950543, 1.0, 1.089303 };	/* D65 */
8667 	double mat[3][3] = {				/* sRGB absolute XYZ->RGB ? */
8668 		{  3.2406, -1.5372, -0.4986 },
8669 		{ -0.9689,  1.8758,  0.0415 },
8670 		{  0.0557, -0.2040,  1.0570 }
8671 	};
8672 
8673 	/* Do a simple Von Kries between input white point and D65 */
8674 	if (wp != NULL) {
8675 		icmXYZNumber dst, src;
8676 		double vkmat[3][3];
8677 
8678 		icmAry2XYZ(src, wp);
8679 		icmAry2XYZ(dst, d65);
8680 		icmChromAdaptMatrix(ICM_CAM_BRADFORD | ICM_CAM_BRADFORD, dst, src, vkmat);
8681 		icmMulBy3x3(XYZ, vkmat, in);
8682 	} else {
8683 		for (j = 0; j < 3; j++)
8684 			XYZ[j] = in[j];
8685 	}
8686 
8687 	/* Convert to sRGB cromaticities */
8688 	for (i = 0; i < 3; i++) {
8689 		out[i] = 0.0;
8690 		for (j = 0; j < 3; j++) {
8691 			out[i] += XYZ[j] * mat[i][j];
8692 		}
8693 	}
8694 
8695 	/* Apply gamma */
8696 	for (j = 0; j < 3; j++) {
8697 		if (out[j] <= (0.03928/12.92)) {
8698 			out[j] *= 12.92;
8699 			if (out[j] < 0.0)
8700 				out[j] = 0.0;
8701 		} else {
8702 			out[j] = pow(out[j], 1.0/2.4) * 1.055 - 0.055;
8703 			if (out[j] > 1.0)
8704 				out[j] = 1.0;
8705 		}
8706 	}
8707 }
8708 
8709 /* Given an RGB value, return XYZ values. */
8710 /* This is a little slow */
icx_sRGB2XYZ(double * out,double * wp,double * in)8711 void icx_sRGB2XYZ(
8712 double *out,			/* Return XYZ values */
8713 double *wp,				/* Output XYZ white point (D65 used if NULL, othewise Bradford) */
8714 double *in				/* Input sRGB values */
8715 ) {
8716 	int i, j;
8717 	double tmp[3];
8718 	double d65[3] = { 0.950543, 1.0, 1.089303 };	/* D65 */
8719 	double imat[3][3] = {				/* sRGB absolute XYZ->RGB */
8720 		{ 0.4124, 0.3576, 0.1805 },
8721 		{ 0.2126, 0.7152, 0.0722 },
8722 		{ 0.0193, 0.1192, 0.9505 }
8723 	};
8724 
8725 	/* Undo gamma */
8726 	for (j = 0; j < 3; j++) {
8727 		if (in[j] < 0.04045)
8728 			tmp[j] = in[j]/12.92;
8729 		else
8730 			tmp[j] = pow((in[j] + 0.055)/1.055, 2.4);
8731 	}
8732 
8733 	/* Convert to XYZ cromaticities */
8734 	for (i = 0; i < 3; i++) {
8735 		out[i] = 0.0;
8736 		for (j = 0; j < 3; j++) {
8737 			out[i] += tmp[j] * imat[i][j];
8738 		}
8739 	}
8740 
8741 	/* Do a simple Bradford between D65 and wp */
8742 	if (wp != NULL) {
8743 		icmXYZNumber dst, src;
8744 		double vkmat[3][3];
8745 
8746 		icmAry2XYZ(src, d65);
8747 		icmAry2XYZ(dst, wp);
8748 		icmChromAdaptMatrix(ICM_CAM_BRADFORD, dst, src, vkmat);
8749 		icmMulBy3x3(out, vkmat, out);
8750 	}
8751 }
8752 
8753 /* Given an XYZ value, return approximate RGB value */
8754 /* Desaurate to white by the given amount */
icx_XYZ2RGB_ds(double * out,double * in,double desat)8755 void icx_XYZ2RGB_ds(
8756 double *out,			/* Return approximate sRGB values */
8757 double *in,				/* Input XYZ */
8758 double desat			/* 0.0 = full saturation, 1.0 = white */
8759 ) {
8760 	int i, j;
8761 	double mat[3][3] = {		/* XYZ to D65 sRGB */
8762 		{  1.490715, -0.075680, -0.313279 },		/* Triangle that occupies spectrum locus */
8763 		{ -0.492678,  1.364383,  0.095391 },
8764 		{  0.049610, -0.137386,  1.001080 }
8765 	};
8766 	double white[3] = { 1.0, 1.0, 1.0 } ;
8767 	double max;
8768 
8769 	/* Normalize */
8770 	in[0] /= in[1];
8771 	in[2] /= in[1];
8772 	in[1]  = 1.0;
8773 
8774 //a1logd(g_log, 1,"icx_XYZ2sRGB_ds: norm XYZ %f %f %f\n", in[0], in[1], in[2]);
8775 
8776 	/* Convert to sRGB cromaticities */
8777 	for (i = 0; i < 3; i++) {
8778 		out[i] = 0.0;
8779 		for (j = 0; j < 3; j++) {
8780 			out[i] += in[j] * mat[i][j];
8781 		}
8782 	}
8783 //a1logd(g_log, 1,"icx_XYZ2sRGB_ds: raw RGB %f %f %f\n", out[0], out[1], out[2]);
8784 
8785 	/* Clip */
8786 	max = -1e6;
8787 	for (i = 0; i < 3; i++) {
8788 		if (out[i] > max)
8789 			max = out[i];
8790 	}
8791 	for (i = 0; i < 3; i++) {
8792 		out[i] /= max;
8793 		if (out[i] < 0.0)
8794 			out[i] = 0.0;
8795 	}
8796 //a1logd(g_log, 1,"icx_XYZ2sRGB_ds: clip RGB %f %f %f\n", out[0], out[1], out[2]);
8797 
8798 	/* Desaturate */
8799 	icmBlend3(out, out, white, desat);
8800 
8801 //a1logd(g_log, 1,"icx_XYZ2sRGB_ds: desat RGB %f %f %f\n", out[0], out[1], out[2]);
8802 
8803 	/* Apply gamma */
8804 	for (j = 0; j < 3; j++) {
8805 		if (out[j] <= (0.03928/12.92)) {
8806 			out[j] *= 12.92;
8807 			if (out[j] < 0.0)
8808 				out[j] = 0.0;
8809 		} else {
8810 			out[j] = pow(out[j], 1.0/2.4) * 1.055 - 0.055;
8811 			if (out[j] > 1.0)
8812 				out[j] = 1.0;
8813 		}
8814 	}
8815 
8816 //a1logd(g_log, 1,"icx_XYZ2sRGB_ds: final RGB %f %f %f\n", out[0], out[1], out[2]);
8817 }
8818 
8819 /* Given a wavelengthm return approximate RGB value */
8820 /* Desaurate to white by the given amount */
icx_wl2RGB_ds(double * out,double wl,double desat)8821 void icx_wl2RGB_ds(
8822 double *out,			/* Return approximate sRGB values */
8823 double wl,				/* Input wavelength in nm */
8824 double desat			/* 0.0 = full saturation, 1.0 = white */
8825 ) {
8826 	double XYZ[3];
8827 
8828 	icx_spectrum_locus(XYZ, wl, icxOT_CIE_1931_2);
8829 //a1logd(g_log, 1,"cx_wl2sRGB_ds: wl %f -> XYZ %f %f %f\n",wl, XYZ[0], XYZ[1], XYZ[2]);
8830 
8831 	icx_XYZ2RGB_ds(out, XYZ, desat);
8832 }
8833 
8834 /* ------------------- */
8835 
8836 #ifdef NEVER	/* Deprecated */
8837 
8838 /* Given a daylight color temperature in degrees K, */
8839 /* return the corresponding XYZ value (standard 2 degree observer) */
icx_DTEMP2XYZ(double * out,double ct)8840 void icx_DTEMP2XYZ(
8841 double *out,			/* Return XYZ value with Y == 1, -1 on error */
8842 double ct				/* Input temperature in degrees K */
8843 ) {
8844 	double Yxy[3];
8845 
8846 	if (ct < 2500.0 || ct > 25000.0) {		/* Only accurate down to 4000 */
8847 		out[0] = out[1] = out[2] = -1.0;
8848 		return;
8849 	}
8850 
8851 //DBGF((DBGA,"computing temperature %f\n",ct));
8852 	/* Compute chromaticity coordinates */
8853 	if (ct < 7000.0) {
8854 		Yxy[1] = -4.6070e9/(ct * ct * ct) + 2.9678e6/(ct * ct) + 0.09911e3/ct + 0.244063;
8855 	} else {
8856 		Yxy[1] = -2.0064e9/(ct * ct * ct) + 1.9018e6/(ct * ct) + 0.24748e3/ct + 0.237040;
8857 	}
8858 	Yxy[2] = -3.000 * Yxy[1] * Yxy[1] + 2.870 * Yxy[1] - 0.275;
8859 
8860 	Yxy[0] = 1.0;
8861 //DBGF((DBGA,"Yxy = %f %f %f\n",Yxy[0],Yxy[1],Yxy[2]));
8862 
8863 	/* Convert to XYZ */
8864 	icmYxy2XYZ(out, Yxy);
8865 
8866 //DBGF((DBGA,"XYZ = %f %f %f\n",out[0],out[1],out[2]));
8867 }
8868 
8869 #endif
8870 
8871 /* - - - - - - - - - - - - - - - - - - - - - - - - - - */
8872 
8873 /* Given a reflectance/transmittance spectrum, */
8874 /* an illuminant definition and an observer model, return */
8875 /* the XYZ value for that spectrum. */
8876 /* Return 0 on sucess, 1 on error */
8877 /* (One shot version of xsp2cie etc.) */
icx_sp2XYZ(double xyz[3],icxObserverType obType,xspect custObserver[3],icxIllumeType ilType,double ct,xspect * custIllum,xspect * sp)8878 int icx_sp2XYZ(
8879 double xyz[3],			/* Return XYZ value */
8880 icxObserverType obType,	/* Observer */
8881 xspect custObserver[3],	/* Optional custom observer */
8882 icxIllumeType ilType,	/* Type of illuminant, icxIT_[O]Dtemp or icxIT_[O]Ptemp */
8883 double ct,				/* Input temperature in degrees K */
8884 xspect *custIllum,		/* Optional custom illuminant */
8885 xspect *sp				/* Spectrum to be converted */
8886 ) {
8887 	xspect ill;			/* Xspect to fill in */
8888 	xsp2cie *conv;		/* Means of converting spectrum to XYZ */
8889 
8890 	if (ilType == icxIT_custom)
8891 		ill = *custIllum;
8892 	else if (standardIlluminant(&ill, ilType, ct) != 0)
8893 		return 1;
8894 
8895 	if ((conv = new_xsp2cie(icxIT_custom, &ill, obType, custObserver, icSigXYZData, 1)) == NULL)
8896 		return 1;
8897 
8898 	conv->convert(conv, xyz, sp);
8899 
8900 	conv->del(conv);
8901 
8902 	return 0;
8903 }
8904 
8905 /* - - - - - - - - - - - - - - - - - - - - - - - - - - */
8906 
8907 /* Given an illuminant definition and an observer model, return */
8908 /* the normalised XYZ value for that spectrum. */
8909 /* Return 0 on sucess, 1 on error */
8910 /* (One shot version of xsp2cie etc.) */
icx_ill_sp2XYZ(double xyz[3],icxObserverType obType,xspect custObserver[3],icxIllumeType ilType,double ct,xspect * custIllum)8911 int icx_ill_sp2XYZ(
8912 double xyz[3],			/* Return XYZ value with Y == 1 */
8913 icxObserverType obType,	/* Observer */
8914 xspect custObserver[3],	/* Optional custom observer */
8915 icxIllumeType ilType,	/* Type of illuminant, icxIT_[O]Dtemp or icxIT_[O]Ptemp */
8916 double ct,				/* Input temperature in degrees K */
8917 xspect *custIllum		/* Optional custom illuminant */
8918 ) {
8919 	xspect sp;			/* Xspect to fill in */
8920 	xsp2cie *conv;		/* Means of converting spectrum to XYZ */
8921 
8922 	if (ilType == icxIT_custom)
8923 		sp = *custIllum;
8924 	else if (standardIlluminant(&sp, ilType, ct) != 0)
8925 		return 1;
8926 
8927 	if ((conv = new_xsp2cie(icxIT_none, NULL, obType, custObserver, icSigXYZData, 1)) == NULL)
8928 		return 1;
8929 
8930 	conv->convert(conv, xyz, &sp);
8931 
8932 	conv->del(conv);
8933 
8934 	/* Normalise */
8935 	xyz[0] /= xyz[1];
8936 	xyz[2] /= xyz[1];
8937 	xyz[1] /= xyz[1];
8938 
8939 	return 0;
8940 }
8941 
8942 /* - - - - - - - - - - - - - - - - - - - - - - - - - - */
8943 /* Aproximate CCT using polinomial. No good < 3000K */
8944 #ifdef NEVER
8945 /* Hernndez-Andrs, Lee & Romero exponential approximation (more fragile) */
aprox_CCT_Yxy(double Yxy[3])8946 static double aprox_CCT_Yxy(double Yxy[3]) {
8947 	double xe = 0.3366;
8948 	double ye = 0.1735;
8949 	double A0 = -949.86315;
8950 	double A1 = 6253.80338;
8951 	double t1 = 0.92159;
8952 	double A2 = 28.70599;
8953 	double t2 = 0.20039;
8954 	double A3 = 0.00004;
8955 	double t3 = 0.07125;
8956 	double n;
8957 	double cct;
8958 
8959 	n = (Yxy[1] - xe)/(Yxy[2] - ye);
8960 	cct = A0 + A1 * exp(-n/t1) + A2 * exp(-n/t2) + A3 * exp(-n/t3);
8961 
8962 	return cct;
8963 }
8964 #else
8965 /* McCamy's cubic approximation: (more robust) */
aprox_CCT_Yxy(double Yxy[3])8966 static double aprox_CCT_Yxy(double Yxy[3]) {
8967 	double n;
8968 	double cct;
8969 
8970 	n = (Yxy[1] - 0.3320)/(Yxy[2] - 0.1858);
8971 	cct = -449.0 * n * n * n + 3525.0 * n * n - 6823.3 * n + 5520.33;
8972 	return cct;
8973 }
8974 #endif
8975 
aprox_CCT(double xyz[3])8976 double aprox_CCT(double xyz[3]) {
8977 	double Yxy[3];
8978 
8979 	icmXYZ2Yxy(Yxy, xyz);
8980 
8981 	return aprox_CCT_Yxy(Yxy);
8982 }
8983 
8984 /* Aproximate x,y from CCT using Kim et al's cubic spline. */
8985 /* Invalid < 1667 and > 25000 */
8986 /* (Doesn't set Yxy[0]) */
aprox_plankian(double Yxy[3],double ct)8987 void aprox_plankian(double Yxy[3], double ct) {
8988 	double t1 = 1e3/ct;
8989 	double t2 = t1 * t1;
8990 	double t3 = t2 * t1;
8991 	double xc, xc2, xc3, yc;
8992 
8993 	if (ct <= 4000.0)
8994 		xc = -0.2661239 * t3 - 0.2343580 * t2 + 0.8776956 * t1 + 0.179910;
8995 	else
8996 		xc = -3.0258469 * t3 + 2.1070379 * t2 + 0.2226347 * t2 + 0.240390;
8997 
8998 	xc2 = xc * xc;
8999 	xc3 = xc2 * xc;
9000 
9001 	if (ct <= 2222.0)
9002 		yc = -1.1063814 * xc3 - 1.34811020 * xc2 + 2.18555832 * xc - 0.20219683;
9003 	else if (ct <= 4000.0)
9004 		yc = -0.9549476 * xc3 - 1.37418593 * xc2 + 2.09137015 * xc - 0.16748867;
9005 	else
9006 		yc = 3.0817580 * xc3 - 5.87338670 * xc2 + 3.75112997 * xc - 0.37001483;
9007 
9008 	Yxy[1] = xc;
9009 	Yxy[2] = yc;
9010 }
9011 
9012 /* - - - - - - - - - - - - - - - - - - - - - - - - - - */
9013 /* Full precision CCT */
9014 
9015 /* Context for optimiser callback */
9016 typedef struct {
9017 	icxIllumeType ilType;	/* Type of illuminant, icxIT_[O]Dtemp or icx[O]IT_Ptemp */
9018 	double xyz[3];			/* Target XYZ */
9019 	icmXYZNumber XYZ;		/* Target as XYZ number */
9020 	xsp2cie *conv;			/* Means of converting spectrum to XYZ */
9021 	int viscct;				/* nz to use visual best match color temperature */
9022 } cctctx;
9023 
cct_func(void * fdata,double tp[])9024 static double cct_func(void *fdata, double tp[]) {
9025 	cctctx *x = (cctctx *)fdata;
9026 	double xyz[3];		/* Current value */
9027 	double lab1[3], lab2[3];
9028 	xspect sp;
9029 	double rv = 0.0;
9030 	icmXYZNumber *wp = &x->XYZ;
9031 
9032 	/* Compute the XYZ for the given temperature */
9033 	if (x->ilType == icxIT_Dtemp) {
9034 		if (daylight_il(&sp, tp[0]) != 0)
9035 			rv = 1e6;
9036 	} else if (x->ilType == icxIT_Ptemp) {
9037 		if (planckian_il(&sp, tp[0]) != 0)
9038 			rv = 1e6;
9039 	} else if (x->ilType == icxIT_ODtemp) {
9040 		if (daylight_old_il(&sp, tp[0]) != 0)
9041 			rv = 1e6;
9042 	} else if (x->ilType == icxIT_OPtemp) {
9043 		if (planckian_old_il(&sp, tp[0]) != 0)
9044 			rv = 1e6;
9045 	}
9046 
9047 	if (rv == 0.0) {
9048 		x->conv->convert(x->conv, xyz, &sp);
9049 		xyz[0] /= xyz[1];
9050 		xyz[2] /= xyz[1];
9051 		xyz[1] /= xyz[1];
9052 		/* Compute the color difference to the target */
9053 		if (x->viscct) {
9054 			/* Use modern CIEDE2000 color difference - gives a better visual match */
9055 			icmXYZ2Lab(wp, lab1, x->xyz);
9056 			icmXYZ2Lab(wp, lab2, xyz);
9057 			rv = icmCIE2Ksq(lab1, lab2);
9058 		} else {
9059 			/* Use original CIE 1960 UCS space color difference */
9060 			icmXYZ21960UCS(lab1, x->xyz);
9061 			icmXYZ21960UCS(lab2, xyz);
9062 			rv = icmLabDEsq(lab1, lab2);
9063 		}
9064 	}
9065 
9066 //DBGF((DBGA,"returning %f for temp = %f\n",rv,tp[0]));
9067 	return rv;
9068 
9069 }
9070 
9071 /* Given a choice of temperature dependent illuminant (icxIT_[O]Dtemp or icxIT_[O]Ptemp), */
9072 /* return the closest correlated color temperature to the given spectrum or XYZ. */
9073 /* An observer type can be chosen for interpretting the spectrum of the input and */
9074 /* the illuminant. */
9075 /* Return -1 on erorr */
icx_XYZ2ill_ct(double txyz[3],icxIllumeType ilType,icxObserverType obType,xspect custObserver[3],double xyz[3],xspect * insp,int viscct)9076 double icx_XYZ2ill_ct(
9077 double txyz[3],			/* If not NULL, return the XYZ of the locus temperature */
9078 icxIllumeType ilType,	/* Type of illuminant, icxIT_[O]Dtemp or icx[O]IT_Ptemp */
9079 icxObserverType obType,	/* Observer */
9080 xspect custObserver[3],	/* Optional custom observer */
9081 double xyz[3],			/* Input XYZ value, NULL if spectrum intead */
9082 xspect *insp,			/* Input spectrum value, NULL if xyz[] instead */
9083 int viscct				/* nz to use visual CIEDE2000, 0 to use CCT CIE 1960 UCS. */
9084 ) {
9085 	cctctx x;			/* Context for callback */
9086 	double cp[1], s[1];
9087 	double rv;
9088 	int i;
9089 	double tc, ber, bct = 0.0;
9090 
9091 	x.viscct = viscct;
9092 
9093 	if (ilType != icxIT_Dtemp && ilType != icxIT_Ptemp
9094 	 && ilType != icxIT_ODtemp && ilType != icxIT_OPtemp)
9095 		return -1.0;
9096 	x.ilType = ilType;
9097 
9098 	if ((x.conv = new_xsp2cie(icxIT_none, NULL, obType, custObserver, icSigXYZData, 1)) == NULL)
9099 		return -1;
9100 
9101 	if (xyz == NULL) {
9102 		if (insp == NULL)
9103 			return -1.0;
9104 		x.conv->convert(x.conv, x.xyz, insp);
9105 	} else {
9106 		icmAry2Ary(x.xyz, xyz);
9107 	}
9108 //printf("~1 aprox CCT = %f\n",aprox_CCT(x.xyz));
9109 
9110 	/* Normalise target */
9111 	x.xyz[0] /= x.xyz[1];
9112 	x.xyz[2] /= x.xyz[1];
9113 	x.xyz[1] /= x.xyz[1];
9114 	icmAry2XYZ(x.XYZ, x.xyz);
9115 
9116 	/* Do some start samples, to avoid getting trapped in local minima */
9117 	for (ber = 1e9, i = 0; i < 6; i++) {
9118 		double er;
9119 		tc = 1000.0 + i * 2000.0;
9120 		if ((er = cct_func((void *)&x, &tc)) < ber) {
9121 			ber = er;
9122 			bct = tc;
9123 		}
9124 //DBGF((DBGA,"tc = %f, er = %f\n",tc,er));
9125 	}
9126 	cp[0] = bct;
9127 	s[0] = 500.0;
9128 
9129 	/* Locate the CCT */
9130 	if (powell(&rv, 1, cp, s, 0.01, 1000, cct_func, (void *)&x, NULL, NULL) != 0) {
9131 		x.conv->del(x.conv);
9132 		return -1.0;
9133 	}
9134 
9135 	if (txyz != NULL) {
9136 		xspect sp;
9137 		if (x.ilType == icxIT_Dtemp) {
9138 			if (daylight_il(&sp, cp[0]) != 0) {
9139 				x.conv->del(x.conv);
9140 				txyz[0] = txyz[2] = txyz[1] = cp[0] = 0.0;
9141 				return cp[0];
9142 			}
9143 		} else if (x.ilType == icxIT_Ptemp) {
9144 			if (planckian_il(&sp, cp[0]) != 0) {
9145 				x.conv->del(x.conv);
9146 				txyz[0] = txyz[2] = txyz[1] = cp[0] = 0.0;
9147 				return cp[0];
9148 			}
9149 		} else if (x.ilType == icxIT_ODtemp) {
9150 			if (daylight_old_il(&sp, cp[0]) != 0) {
9151 				x.conv->del(x.conv);
9152 				txyz[0] = txyz[2] = txyz[1] = cp[0] = 0.0;
9153 				return cp[0];
9154 			}
9155 		} else if (x.ilType == icxIT_OPtemp) {
9156 			if (planckian_old_il(&sp, cp[0]) != 0) {
9157 				x.conv->del(x.conv);
9158 				txyz[0] = txyz[2] = txyz[1] = cp[0] = 0.0;
9159 				return cp[0];
9160 			}
9161 		}
9162 		x.conv->convert(x.conv, txyz, &sp);
9163 		/* Make sure locus XYZ is Normalised */
9164 		txyz[0] /= txyz[1];
9165 		txyz[2] /= txyz[1];
9166 		txyz[1] /= txyz[1];
9167 	}
9168 	x.conv->del(x.conv);
9169 
9170 //DBGF((DBGA,"returning CT %f with error %f\n",cp[0],sqrt(rv)));
9171 	return cp[0];
9172 }
9173 
9174 /* - - - - - - - - - - - - - - - - - - - - - - - - - - */
9175 /* Convert UCS Yuv to chromatic adaptation Ycd */
UCSYuv2Ycd(double * out,double * in)9176 static void UCSYuv2Ycd(double *out, double *in) {
9177 	double u, v;
9178 	u = in[1];
9179 	v = in[2];
9180 
9181 	out[0] = in[0];
9182 	out[1] = (4.0 - u - 10.0 * v)/v;
9183 	out[2] = (1.708 * v - 1.481 * u + 0.404)/v;
9184 }
9185 
9186 /* Compute the CIE1995 CRI: Ra */
9187 /* Return < 0.0 on error */
9188 /* If invalid is not NULL, set it to nz if CRI */
9189 /* is invalid because the sample is not white enough. */
icx_CIE1995_CRI(int * invalid,double cris[14],xspect * sample)9190 double icx_CIE1995_CRI(
9191 int *invalid,			/* if not NULL, set to nz if invalid */
9192 double cris[14],		/* If not NULL, return the TCS01-14 CRI's */
9193 xspect *sample			/* Illuminant sample to compute CRI of */
9194 ) {
9195 	int i;
9196 	double cct;
9197 	xspect wts;			/* Reference white spectrum */
9198 	xsp2cie *tocie;
9199 	double wt[3];		/* Reference white in CIE 1960 UCS */
9200 	icmXYZNumber wtn;
9201 	double wt_Ycd[3];	/* Ycd reference white */
9202 	double sa[3];		/* Sample white in CIE 1960 UCS */
9203 	double sa_Ycd[3];	/* Ycd sample white */
9204 	double dc;			/* delta of sample to reference white in 1960 UCS */
9205 	double ref[14][3];	/* reference XYZ/1964 color space */
9206 	double sam[14][3];	/* sample XYZ/1964 color space */
9207 	double c_ad, d_ad;	/* Chromatic adaptation scaling factors */
9208 	double cri = 0.0;
9209 	double sampnorm;	/* Original sample norm value */
9210 
9211 //DBGF((DBGA,"icx_CIE1995_CRI called\n"));
9212 
9213 	if ((tocie = new_xsp2cie(icxIT_none, NULL, icxOT_CIE_1931_2, NULL, icSigXYZData, 1)) == NULL)
9214 		return -1.0;
9215 
9216 	/* Compute the XYZ of the sample */
9217 	tocie->convert(tocie, sa, sample);
9218 
9219 	if ((cct = icx_XYZ2ill_ct(NULL, icxIT_Ptemp, icxOT_CIE_1931_2, NULL, sa, NULL, 0)) < 0.0)
9220 		return -1.0;
9221 
9222 //DBGF((DBGA,"CCT = %f\n", cct));
9223 
9224 	/* Create a reference white spectrum with the same CCT */
9225 	if (cct < 5000.0) {
9226 		if (planckian_il(&wts, cct))
9227 			return -1.0;
9228 	} else {
9229 		if (daylight_il(&wts, cct))
9230 			return -1.0;
9231 	}
9232 
9233 	/* Compute the XYZ of the reference white */
9234 	tocie->convert(tocie, wt, &wts);
9235 
9236 //DBGF((DBGA,"XYZ white = %f %f %f\n",wt[0],wt[1],wt[2]));
9237 //DBGF((DBGA,"XYZ sampl = %f %f %f\n",sa[0],sa[1],sa[2]));
9238 
9239 	/* Normalize the spectra so as to create a normalized white */
9240 	wts.norm *= wt[1];
9241 	sampnorm = sample->norm;		/* Save this so we can restore it */
9242 	sample->norm *= sa[1];
9243 	tocie->convert(tocie, wt, &wts);
9244 	tocie->convert(tocie, sa, sample);
9245 	tocie->del(tocie);
9246 
9247 //DBGF((DBGA,"norm XYZ white = %f %f %f\n",wt[0],wt[1],wt[2]));
9248 //DBGF((DBGA,"norm XYZ sampl = %f %f %f\n",sa[0],sa[1],sa[2]));
9249 
9250 	/* Convert to perceptual CIE 1960 UCS */
9251 	icmAry2XYZ(wtn, wt);		/* Use reference white as UCS white */
9252 	icmXYZ21960UCS(wt, wt);		/* 1960 UCS Yuv reference white */
9253 	UCSYuv2Ycd(wt_Ycd, wt);		/* Ycd version for chromatic adapation */
9254 	icmXYZ21960UCS(sa, sa);		/* 1960 UCS Yuv sample white */
9255 	UCSYuv2Ycd(sa_Ycd, sa);		/* Ycd version for chromatic adapation */
9256 
9257 	c_ad = wt_Ycd[1]/sa_Ycd[1];	/* Chromatic adaptation scaling factors */
9258 	d_ad = wt_Ycd[2]/sa_Ycd[2];
9259 
9260 //DBGF((DBGA,"UCS white = %f %f %f\n",wt[0],wt[1],wt[2]));
9261 //DBGF((DBGA,"UCS sampl = %f %f %f\n",sa[0],sa[1],sa[2]));
9262 
9263 	dc = sqrt((wt[1] - sa[1]) * (wt[1] - sa[1]) + (wt[2] - sa[2]) * (wt[2] - sa[2]));
9264 
9265 //DBGF((DBGA,"dc = %f\n",dc));
9266 //if (dc > 0.0054) DBGF((DBGA,"CRI is invalid\n"));
9267 
9268 	/* If dc > 0.0054 we should abort computing the CRI, */
9269 	/* but this means we fail on lots of real world lighting. */
9270 	if (invalid != NULL) {
9271 		if (dc > 0.0054)
9272 			*invalid = 1;
9273 		else
9274 			*invalid = 0;
9275 	}
9276 
9277 	/* Check out the delta E for each reflective sample */
9278 	if ((tocie = new_xsp2cie(icxIT_custom, &wts, icxOT_CIE_1931_2, NULL, icSigXYZData, 1)) == NULL) {
9279 		sample->norm = sampnorm;		/* Restore this */
9280 		return -1.0;
9281 	}
9282 
9283 	/* We compute the CRI of each of the 14 samples, */
9284 	/* even though only the first 8 are used to compute Ra */
9285 	for (i = 0; i < 14; i++) {
9286 		tocie->convert(tocie, ref[i], &CIE1995_TCS[i]);
9287 		icmXYZ21964WUV(&wtn, ref[i], ref[i]);
9288 //DBGF((DBGA,"ref samp %d = WUV %f %f %f\n", i,ref[i][0],ref[i][1],ref[i][2]));
9289 	}
9290 	tocie->del(tocie);
9291 
9292 	if ((tocie = new_xsp2cie(icxIT_custom, sample, icxOT_CIE_1931_2, NULL, icSigXYZData, 1)) == NULL) {
9293 		sample->norm = sampnorm;		/* Restore this */
9294 		return -1.0;
9295 	}
9296 	for (i = 0; i < 14; i++) {
9297 		double c, d;
9298 		tocie->convert(tocie, sam[i], &CIE1995_TCS[i]);
9299 
9300 		icmXYZ21960UCS(sam[i], sam[i]);
9301 
9302 		/* Do chromatic adaptation */
9303 		UCSYuv2Ycd(sam[i], sam[i]);
9304 		c = sam[i][1];
9305 		d = sam[i][2];
9306 		sam[i][1] = (10.872 + 0.404 * c * c_ad - 4.0 * d * d_ad)/
9307 		            (16.518 + 1.481 * c * c_ad - 1.0 * d * d_ad);
9308 
9309 		sam[i][2] = (5.520)/
9310 		            (16.518 + 1.481 * c * c_ad - 1.0 * d * d_ad);
9311 
9312 		icm1960UCS21964WUV(&wtn, sam[i], sam[i]);
9313 
9314 //DBGF((DBGA,"sam samp %d = WUV %f %f %f\n", i,sam[i][0],sam[i][1],sam[i][2]));
9315 	}
9316 	tocie->del(tocie);
9317 
9318 	/* Compute the CRI of all 14, but only average the first 8. */
9319 	for (i = 0; i < 14; i++) {
9320 		double de, tcri;
9321 
9322 		de = icmLabDE(ref[i], sam[i]);
9323 		tcri = 100.0 - 4.6 * de;
9324 //DBGF((DBGA,"sample %d: de = %f, CRI = %f\n",i,de,tcri));
9325 		if (cris != NULL) {
9326 			/* Should we clip -ve values ? */
9327 			cris[i] = tcri;
9328 		}
9329 		if (i < 8)
9330 			cri += tcri;
9331 	}
9332 	cri /= 8.0;
9333 
9334 //DBGF((DBGA,"average CRI of first 8 = %f\n",cri));
9335 	if (cri < 0.0)
9336 		cri = -1.0;
9337 
9338 //DBGF((DBGA,"returning CRI = %f\n",cri));
9339 	sample->norm = sampnorm;		/* Restore this */
9340 	return cri;
9341 }
9342 
9343 /* - - - - - - - - - - - - - - - - - - - - - - - - - - */
9344 
9345 /* EBU TLCI-2012 - used for the assessment of light sources for use in television lighting */
9346 
9347 /* Camera and display model. Converts camera RGB into XYZ */
TLCI_camdisp(double * out,double * in,double * wb)9348 static void TLCI_camdisp(double *out, double *in, double *wb) {
9349 	double cam[3][3] = {
9350 		{ 1.182, -0.209, 0.027 },
9351 		{ 0.107,  0.890, 0.003 },
9352 		{ 0.040, -0.134, 1.094 }
9353 	};
9354 	double a = (1.0 - 90.0/100)/3.0;
9355 	double aa = 1.0 - 2.0 * a;
9356 	double sat[3][3] = {
9357 		{ aa, a,  a  },
9358 		{ a,  aa, a  },
9359 		{ a,  a,  aa }
9360 	};
9361 	double disp[3][3] = {
9362 		{ 0.412391, 0.357584, 0.180481 },
9363 		{ 0.212639, 0.715169, 0.072192 },
9364 		{ 0.019331, 0.119195, 0.950532 }
9365 	};
9366 	int i;
9367 
9368 //DBGF((DBGA,"raw camera RGB %f %f %f\n",in[0],in[1],in[2]));
9369 	icmMul3(out, wb, in);			/* Apply white balance */
9370 //DBGF((DBGA,"white balanced camera RGB %f %f %f\n",out[0],out[1],out[2]));
9371 	icmMulBy3x3(out, cam, out);		/* Camera matrix RGB->RGB*/
9372 //DBGF((DBGA,"Rec709 optimized camera RGB %f %f %f\n",out[0],out[1],out[2]));
9373 	icmMulBy3x3(out, sat, out);		/* Saturation matrix */
9374 //DBGF((DBGA,"Sat adjusted Rec709 camera RGB %f %f %f\n",out[0],out[1],out[2]));
9375 
9376 	for (i = 0; i < 3; i++) {		/* Camera OETF */
9377 		if (out[i] < 0.018)
9378 			out[i] = 4.5 * out[i];
9379 		else
9380 			out[i] = 1.099 * pow(out[i], 0.45) - 0.099;
9381 	}
9382 //DBGF((DBGA,"Gamma encoded Rec709 camera RGB %f %f %f\n",out[0],out[1],out[2]));
9383 	for (i = 0; i < 3; i++) {		/* Display OETF */
9384 		if (out[i] < 0.0)
9385 			out[i] = 0.0;
9386 		else
9387 			out[i] = pow(out[i], 2.4);
9388 	}
9389 //DBGF((DBGA,"Display RGB %f %f %f\n",out[0],out[1],out[2]));
9390 	icmMulBy3x3(out, disp, out);		/* Display matrix RGB->XYZ */
9391 	{
9392 		double lab[3];
9393 		icmXYZ2Lab(&icmD65, lab, out);
9394 //DBGF((DBGA,"Lab %f %f %f\n", lab[0], lab[1], lab[2]));
9395 	}
9396 }
9397 
9398 /* Compute the EBU Television Lighting Consistency Index TLCI-2012 Qa (R 137) */
9399 /* Return < 0.0 on error */
9400 /* If invalid is not NULL, set it to nz if TLCI is invalid because the sample is */
9401 /* not white enough. */
9402 /* While it is not clear from the specification itself, it appears that it is expected */
9403 /* that the accuracy of this computation be deliberately crippled to 5nm integration, */
9404 /* resulting in agreement with TLCI-2012.exe is within 0.01 Qa. */
9405 /* When computed to higher 1nm accuracy, the resulting Qa values are typically 0.6-0.8 greater. */
icx_EBU2012_TLCI(int * invalid,xspect * sample)9406 double icx_EBU2012_TLCI(
9407 int *invalid,			/* if not NULL, set to nz if invalid */
9408 xspect *sample			/* Illuminant sample to compute TLCI of */
9409 ) {
9410 	int i;
9411 	double cct;
9412 
9413 	xsp2cie *tocie;		/* spectral to XYZ conversion */
9414 
9415 	xspect wts;			/* Reference white spectrum */
9416 	double wt[3];		/* Reference white in CIE 1960 UCS */
9417 	xsp2cie *reftoRGB;	/* Spectrum to reference camera RGB */
9418 	double refwb[3];	/* Reference camera RGB white balance scale */
9419 	icmXYZNumber wtn;	/* Lab reference white XYZ */
9420 
9421 	double sa[3];		/* Sample white in CIE 1960 UCS */
9422 	xsp2cie *satoRGB;	/* Spectrum to sample camera RGB */
9423 	double sawb[3];		/* Sample camera RGB white balance scale */
9424 
9425 	double dc;			/* delta of sample to reference white in 1960 UCS */
9426 	double ref[24][3];	/* reference XYZ/1964 color space */
9427 	double sam[24][3];	/* sample XYZ/1964 color space */
9428 	double c_ad, d_ad;	/* Chromatic adaptation scaling factors */
9429 	double tlci = 0.0;
9430 	double sampnorm;	/* Original sample norm value */
9431 
9432 	int dolowres = 1;	/* [1] Use 5nm integration for better match with TLCI-2012.exe */
9433 
9434 //DBGF((DBGA,"icx_EBU2012_TLCI called\n"));
9435 
9436 	/* Create spectral to XYZ for UCS space delta */
9437 	if ((tocie = new_xsp2cie(icxIT_none, NULL, icxOT_CIE_1931_2, NULL, icSigXYZData, 1)) == NULL) {
9438 //DBGF((DBGA,"Ref new_xsp2cie failed\n"));
9439 		return -1.0;
9440 	}
9441 
9442 	/* Compute the XYZ of the sample */
9443 	tocie->convert(tocie, sa, sample);
9444 
9445 	/* Find the standard 2 degree observer (Old) Plankian CCT */
9446 	/* (This is a few degrees lower than the current Plankian CCT) */
9447 	if ((cct = icx_XYZ2ill_ct(NULL, icxIT_OPtemp, icxOT_CIE_1931_2, NULL, sa, NULL, 0)) < 0.0)
9448 	{
9449 //DBGF((DBGA,"Ref icx_XYZ2ill_ct failed\n"));
9450 		return -1.0;
9451 	}
9452 //DBGF((DBGA,"CCT = %f\n", cct));
9453 
9454 	/* If it is 5000 or over, use the CDT instead, */
9455 	if (cct > 5000.0) {
9456 		if ((cct = icx_XYZ2ill_ct(NULL, icxIT_Dtemp, icxOT_CIE_1931_2, NULL, sa, NULL, 0)) < 0.0)
9457 		{
9458 //DBGF((DBGA,"Ref icx_XYZ2ill_ct failed\n"));
9459 			return -1.0;
9460 		}
9461 //DBGF((DBGA,"CDT = %f\n", cct));
9462 	}
9463 
9464 	/* Create a reference white spectrum with the same CCT. */
9465 	if (cct < 3400.0) {
9466 		if (planckian_old_il(&wts, cct)) {
9467 //DBGF((DBGA,"planckian_old_il failed\n"));
9468 			return -1.0;
9469 		}
9470 	} else if (cct > 5000.0) {
9471 		if (daylight_il(&wts, cct)) {
9472 //DBGF((DBGA,"daylight_il failed\n"));
9473 			return -1.0;
9474 		}
9475 	/* It's a blend between plankian(3400) and daylight(5000) */
9476 	} else {
9477 		double dwt;			/* Blend weight */
9478 		xspect dwts;
9479 		if (planckian_old_il(&wts, 3400.0)) {
9480 //DBGF((DBGA,"planckian_il failed\n"));
9481 			return -1.0;
9482 		}
9483 		if (daylight_il(&dwts, 5000.0)) {
9484 //DBGF((DBGA,"daylight_il failed\n"));
9485 			return -1.0;
9486 		}
9487 
9488 		dwt = (cct - 3400)/(5000.0 - 3400.0);
9489 //DBGF((DBGA,"creating hybrid spectrum with %f Plankian & %f Daylight\n",(1.0 - dwt),dwt));
9490 		for (i = 0; i < wts.spec_n; i++) {
9491 			double wl = XSPECT_XWL(&wts, i);			/* Wavelength in meters */
9492 			wts.spec[i] = dwt * value_xspect(&dwts, wl) + (1.0 - dwt) * wts.spec[i];
9493 		}
9494 	}
9495 
9496 	/* Compute the XYZ of the reference white */
9497 	tocie->convert(tocie, wt, &wts);
9498 
9499 //DBGF((DBGA,"XYZ white = %f %f %f\n",wt[0],wt[1],wt[2]));
9500 //DBGF((DBGA,"XYZ sampl = %f %f %f\n",sa[0],sa[1],sa[2]));
9501 
9502 	/* Normalize the spectra so as to create a normalized white */
9503 	wts.norm *= wt[1];
9504 	sampnorm = sample->norm;		/* Save this so we can restore it */
9505 	sample->norm *= sa[1];
9506 	tocie->convert(tocie, wt, &wts);
9507 	tocie->convert(tocie, sa, sample);
9508 	tocie->del(tocie);
9509 	tocie = NULL;
9510 
9511 //DBGF((DBGA,"norm XYZ white = %f %f %f\n",wt[0],wt[1],wt[2]));
9512 //DBGF((DBGA,"norm XYZ sampl = %f %f %f\n",sa[0],sa[1],sa[2]));
9513 
9514 	/* Convert to perceptual CIE 1960 UCS */
9515 	icmXYZ21960UCS(wt, wt);		/* 1960 UCS Yuv reference white */
9516 	icmXYZ21960UCS(sa, sa);		/* 1960 UCS Yuv sample white */
9517 
9518 //DBGF((DBGA,"UCS white = %f %f %f\n",wt[0],wt[1],wt[2]));
9519 //DBGF((DBGA,"UCS sampl = %f %f %f\n",sa[0],sa[1],sa[2]));
9520 
9521 	dc = sqrt((wt[1] - sa[1]) * (wt[1] - sa[1]) + (wt[2] - sa[2]) * (wt[2] - sa[2]));
9522 
9523 //DBGF((DBGA,"dc = %f (normalized dist %f)\n",dc,dc/0.0054));
9524 //if (dc > 0.0054) DBGF((DBGA,"TLCI is invalid\n"));
9525 
9526 	/* If dc > 0.0054 we should abort computing the TLCI, */
9527 	/* but this means we fail on lots of real world lighting. */
9528 	if (invalid != NULL) {
9529 		if (dc > 0.0054)
9530 			*invalid = 1;
9531 		else
9532 			*invalid = 0;
9533 	}
9534 
9535 	/* Create spectral to camera RGB conversion for reference and sample illuminants */
9536 	/* Note that xsp2cie will normalise the values such that the "Y" value */
9537 	/* (actually G here) to be 1.0 for the perfect diffusor for the given illuminant, */
9538 	/* but that the white balancing scaling would do this anyway. */
9539 	if ((reftoRGB = new_xsp2cie(icxIT_custom, &wts, icxOT_EBU_2012, NULL, icSigXYZData, 1)) == NULL) {
9540 //DBGF((DBGA,"new_xsp2cie for ref failed\n"));
9541 		sample->norm = sampnorm;		/* Restore this */
9542 		return -1.0;
9543 	}
9544 	if ((satoRGB = new_xsp2cie(icxIT_custom, sample, icxOT_EBU_2012, NULL, icSigXYZData, 1)) == NULL) {
9545 //DBGF((DBGA,"new_xsp2cie for samp failed\n"));
9546 		sample->norm = sampnorm;		/* Restore this */
9547 		reftoRGB->del(reftoRGB);
9548 		return -1.0;
9549 	}
9550 
9551 	/* Emulate TLCI-2012.exe */
9552 	if (dolowres) {
9553 		reftoRGB->set_int_steps(reftoRGB, 5.0, 380.0, 760.0);
9554 		satoRGB->set_int_steps(satoRGB, 5.0, 380.0, 760.0);
9555 	}
9556 
9557 	/* Compute a white balance for the reference and sample illuminants */
9558 	/* such that 90% spectral flat produce camera RGB = 1.0 for the perfect reflector */
9559 	reftoRGB->convert(reftoRGB, refwb, &il_none);
9560 //DBGF((DBGA,"Ref white RGB = %f %f %f\n",refwb[0],refwb[1],refwb[2]));
9561 	refwb[0] = 1.0/(0.9 * refwb[0]);		/* White balance scale factors */
9562 	refwb[1] = 1.0/(0.9 * refwb[1]);
9563 	refwb[2] = 1.0/(0.9 * refwb[2]);
9564 //DBGF((DBGA,"Ref white balance scale = %f %f %f\n",refwb[0],refwb[1],refwb[2]));
9565 
9566 	satoRGB->convert(satoRGB, sawb, &il_none);
9567 //DBGF((DBGA,"Samp white RGB = %f %f %f\n",sawb[0],sawb[1],sawb[2]));
9568 	sawb[0] = 1.0/(0.9 * sawb[0]);		/* White balance scale factors */
9569 	sawb[1] = 1.0/(0.9 * sawb[1]);
9570 	sawb[2] = 1.0/(0.9 * sawb[2]);
9571 //DBGF((DBGA,"Samp white balance scale = %f %f %f\n",sawb[0],sawb[1],sawb[2]));
9572 
9573 	/* Compute the display reference white (should be D65) */
9574 	{
9575 		double dispw[3] = { 1.0, 1.0, 1.0 };
9576 
9577 		TLCI_camdisp(dispw, dispw, dispw);	/* Display white XYZ */
9578 		icmAry2XYZ(wtn, dispw);		/* Reference Lab white */
9579 //DBGF((DBGA,"display white XYZ %f %f %f\n", dispw[0], dispw[1], dispw[2]));
9580 	}
9581 
9582 	/* Compute the XYZ and DE for all 24 samples, */
9583 	/* but sum TLCI for only the first 18 samples */
9584 	tlci = 0.0;
9585 	for (i = 0; i < 24; i++) {
9586 		double de;
9587 
9588 //DBGF((DBGA,"\npatch %d\n",i+1));
9589 		reftoRGB->convert(reftoRGB, ref[i], &TLCI_2012_TCS[i]);
9590 		TLCI_camdisp(ref[i], ref[i], refwb);
9591 //DBGF((DBGA,"Ref[%d] XYZ = %f %f %f\n\n",i,ref[i][0],ref[i][1],ref[i][2]));
9592 
9593 		satoRGB->convert(satoRGB, sam[i], &TLCI_2012_TCS[i]);
9594 		TLCI_camdisp(sam[i], sam[i], sawb);
9595 //DBGF((DBGA,"Samp[%d] XYZ = %f %f %f\n\n",i,sam[i][0],sam[i][1],sam[i][2]));
9596 
9597 #ifdef DEBUG
9598 //		{
9599 //			double lab[3];
9600 //			icmXYZ2Lab(&wtn, lab, ref[i]);
9601 //			fprintf(stderr,"~1 ref Lab %f %f %f\n", lab[0], lab[1], lab[2]);
9602 //			icmXYZ2Lab(&wtn, lab, sam[i]);
9603 //			fprintf(stderr,"~1 sam Lab %f %f %f\n", lab[0], lab[1], lab[2]);
9604 //		}
9605 #endif /* DEBUG */
9606 
9607 		de = icmXYZCIE2K(&wtn, ref[i], sam[i]);
9608 //DBGF((DBGA,"%d: DE2K = %f\n",i+1,de));
9609 //DBGF((DBGA,"%d: Q = %f\n",i+1,100.0/(1.0 + pow(de/3.16, 2.4))));
9610 
9611 		if (i < 18)
9612 			tlci += pow(de, 4.0);
9613 	}
9614 	tlci = pow(tlci/18.0, 1.0/4.0);		/* Power average */
9615 //DBGF((DBGA,"Power average = %f\n",tlci));
9616 
9617 	tlci = 100.0/(1.0 + pow(tlci/3.16, 2.4));
9618 
9619 	reftoRGB->del(reftoRGB);
9620 	satoRGB->del(satoRGB);
9621 
9622 //DBGF((DBGA,"returning TLCI = %f\n",tlci));
9623 	sample->norm = sampnorm;		/* Restore this */
9624 	return tlci;
9625 }
9626 
9627 /* - - - - - - - - - - - - - - - - - - - - - - - - - - */
9628 /* Compute Australian Radiation Protection and Nuclear Safety Agency (ARPANSA) */
9629 /* Exposure to Ultraviolet Radiation exposure limits from a spectrum in mw/m-2/nm. */
9630 /* To be accurate, the spectrum must capture any significant */
9631 /* exposure wavelengths between 180 - 400 nm */
9632 
9633 /* Raw RSE from Table 1 of "Radiation Protection Series No. 12 December 2006" */
9634 struct {
9635 	double wl;			/* Wavelength */
9636 	double rse;			/* Relative Spectral Effectiveness */
9637 } raw_rse[57] = {
9638 	{ 180.0, 0.012 },
9639 	{ 190.0, 0.019 },
9640 	{ 200.0, 0.030 },
9641 	{ 205.0, 0.051 },
9642 	{ 210.0, 0.075 },
9643 	{ 215.0, 0.095 },
9644 	{ 220.0, 0.120 },
9645 	{ 225.0, 0.150 },
9646 	{ 230.0, 0.190 },
9647 	{ 235.0, 0.240 },
9648 	{ 240.0, 0.300 },
9649 	{ 245.0, 0.360 },
9650 	{ 250.0, 0.430 },
9651 	{ 254.0, 0.500 },
9652 	{ 255.0, 0.520 },
9653 	{ 260.0, 0.650 },
9654 	{ 265.0, 0.810 },
9655 	{ 270.0, 1.000 },
9656 	{ 275.0, 0.960 },
9657 	{ 280.0, 0.880 },
9658 	{ 285.0, 0.770 },
9659 	{ 290.0, 0.640 },
9660 	{ 295.0, 0.540 },
9661 	{ 297.0, 0.460 },
9662 	{ 300.0, 0.300 },
9663 	{ 303.0, 0.120 },
9664 	{ 305.0, 0.060 },
9665 	{ 308.0, 0.026 },
9666 	{ 310.0, 0.015 },
9667 	{ 313.0, 0.006 },
9668 	{ 315.0, 0.003 },
9669 	{ 316.0, 0.0024 },
9670 	{ 317.0, 0.0020 },
9671 	{ 318.0, 0.0016 },
9672 	{ 319.0, 0.0012 },
9673 	{ 320.0, 0.0010 },
9674 	{ 322.0, 0.00067 },
9675 	{ 323.0, 0.00054 },
9676 	{ 325.0, 0.00050 },
9677 	{ 328.0, 0.00044 },
9678 	{ 330.0, 0.00041 },
9679 	{ 333.0, 0.00037 },
9680 	{ 335.0, 0.00034 },
9681 	{ 340.0, 0.00028 },
9682 	{ 345.0, 0.00024 },
9683 	{ 350.0, 0.00020 },
9684 	{ 355.0, 0.00016 },
9685 	{ 360.0, 0.00013 },
9686 	{ 365.0, 0.00011 },
9687 	{ 370.0, 0.000093 },
9688 	{ 375.0, 0.000077 },
9689 	{ 380.0, 0.000064 },
9690 	{ 385.0, 0.000053 },
9691 	{ 390.0, 0.000044 },
9692 	{ 395.0, 0.000036 },
9693 	{ 400.0, 0.000030 }
9694 };
9695 
9696 /* Compute 1nm sampling rse from raw table using linear interpolation */
compute_rse(xspect * dst)9697 static void compute_rse(xspect *dst) {
9698 	int i;
9699 
9700 	dst->spec_n = 221;
9701 	dst->spec_wl_short = 180.0;
9702 	dst->spec_wl_long = 400.0;
9703 	dst->norm = 1.0;
9704 
9705 	/* Linearly interpolate between each raw point */
9706 	for (i = 0; i < (57-1); i++) {
9707 		int j, n, ix;
9708 
9709 		n = (int)(raw_rse[i+1].wl - raw_rse[i].wl + 0.5);
9710 		for (j = 0; j <= n; j++) {
9711 			double bl = j/(double)n;
9712 			double wl = raw_rse[i].wl + j;
9713 
9714 			ix = XSPECT_XIX(dst, wl);
9715 			dst->spec[ix] = (1.0 - bl) * raw_rse[i].rse + bl * raw_rse[i+1].rse;
9716 
9717 //a1logd(g_log, 1,"UV rse ix %d wl %f rse = %f\n",ix,wl,dst->spec[ix]);
9718 		}
9719 	}
9720 }
9721 
9722 xspect ARPANSA_rse = { 0 };
9723 
9724 /* Return the maximum 24 hour exposure in seconds. */
9725 /* Maximum return value is 8 hours */
9726 /* Returns -1.0 if the source sample doesn't go down to at least 350 nm */
icx_ARPANSA_UV_exp(xspect * sample)9727 double icx_ARPANSA_UV_exp(
9728 xspect *sample			/* Illuminant sample to compute UV_exp of */
9729 ) {
9730 	double wl_short, wl_long;
9731 	double effwpsm;					/* Effective Watt/m^2 */
9732 	double wl;
9733 	double secs;
9734 	if (ARPANSA_rse.spec_n == 0)
9735 		compute_rse(&ARPANSA_rse);
9736 
9737 	wl_short = ARPANSA_rse.spec_wl_short;
9738 	wl_long = ARPANSA_rse.spec_wl_long;
9739 
9740 	if (sample->spec_wl_short > wl_short)
9741 		wl_short = sample->spec_wl_short;
9742 
9743 	if (wl_short > 350.0)
9744 		return -1.0;
9745 
9746 	effwpsm = 0.0;
9747 	for (wl = wl_short; wl <= (wl_long + 1e-6); wl++)
9748 		effwpsm += value_xspect(sample, wl) * value_xspect(&ARPANSA_rse, wl);
9749 
9750 	effwpsm /= 1000.0;		/* Convert to W from mW */
9751 
9752 	secs = 30.0/effwpsm;
9753 
9754 	if (secs > (8 * 60 * 60))	/* Limit to 8 hours */
9755 		secs = 8 * 60 * 60;
9756 
9757 	return secs;
9758 }
9759 
9760 #endif /* !SALONEINSTLIB */
9761 
9762 
9763 
9764 
9765 
9766