ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
Engineering.php
Go to the documentation of this file.
1 <?php
30 if (!defined('PHPEXCEL_ROOT')) {
34  define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
35  require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
36 }
37 
38 
40 define('EULER', 2.71828182845904523536);
41 
42 
51 
52  private static $_conversionUnits = array( 'g' => array( 'Group' => 'Mass', 'Unit Name' => 'Gram', 'AllowPrefix' => True ),
53  'sg' => array( 'Group' => 'Mass', 'Unit Name' => 'Slug', 'AllowPrefix' => False ),
54  'lbm' => array( 'Group' => 'Mass', 'Unit Name' => 'Pound mass (avoirdupois)', 'AllowPrefix' => False ),
55  'u' => array( 'Group' => 'Mass', 'Unit Name' => 'U (atomic mass unit)', 'AllowPrefix' => True ),
56  'ozm' => array( 'Group' => 'Mass', 'Unit Name' => 'Ounce mass (avoirdupois)', 'AllowPrefix' => False ),
57  'm' => array( 'Group' => 'Distance', 'Unit Name' => 'Meter', 'AllowPrefix' => True ),
58  'mi' => array( 'Group' => 'Distance', 'Unit Name' => 'Statute mile', 'AllowPrefix' => False ),
59  'Nmi' => array( 'Group' => 'Distance', 'Unit Name' => 'Nautical mile', 'AllowPrefix' => False ),
60  'in' => array( 'Group' => 'Distance', 'Unit Name' => 'Inch', 'AllowPrefix' => False ),
61  'ft' => array( 'Group' => 'Distance', 'Unit Name' => 'Foot', 'AllowPrefix' => False ),
62  'yd' => array( 'Group' => 'Distance', 'Unit Name' => 'Yard', 'AllowPrefix' => False ),
63  'ang' => array( 'Group' => 'Distance', 'Unit Name' => 'Angstrom', 'AllowPrefix' => True ),
64  'Pica' => array( 'Group' => 'Distance', 'Unit Name' => 'Pica (1/72 in)', 'AllowPrefix' => False ),
65  'yr' => array( 'Group' => 'Time', 'Unit Name' => 'Year', 'AllowPrefix' => False ),
66  'day' => array( 'Group' => 'Time', 'Unit Name' => 'Day', 'AllowPrefix' => False ),
67  'hr' => array( 'Group' => 'Time', 'Unit Name' => 'Hour', 'AllowPrefix' => False ),
68  'mn' => array( 'Group' => 'Time', 'Unit Name' => 'Minute', 'AllowPrefix' => False ),
69  'sec' => array( 'Group' => 'Time', 'Unit Name' => 'Second', 'AllowPrefix' => True ),
70  'Pa' => array( 'Group' => 'Pressure', 'Unit Name' => 'Pascal', 'AllowPrefix' => True ),
71  'p' => array( 'Group' => 'Pressure', 'Unit Name' => 'Pascal', 'AllowPrefix' => True ),
72  'atm' => array( 'Group' => 'Pressure', 'Unit Name' => 'Atmosphere', 'AllowPrefix' => True ),
73  'at' => array( 'Group' => 'Pressure', 'Unit Name' => 'Atmosphere', 'AllowPrefix' => True ),
74  'mmHg' => array( 'Group' => 'Pressure', 'Unit Name' => 'mm of Mercury', 'AllowPrefix' => True ),
75  'N' => array( 'Group' => 'Force', 'Unit Name' => 'Newton', 'AllowPrefix' => True ),
76  'dyn' => array( 'Group' => 'Force', 'Unit Name' => 'Dyne', 'AllowPrefix' => True ),
77  'dy' => array( 'Group' => 'Force', 'Unit Name' => 'Dyne', 'AllowPrefix' => True ),
78  'lbf' => array( 'Group' => 'Force', 'Unit Name' => 'Pound force', 'AllowPrefix' => False ),
79  'J' => array( 'Group' => 'Energy', 'Unit Name' => 'Joule', 'AllowPrefix' => True ),
80  'e' => array( 'Group' => 'Energy', 'Unit Name' => 'Erg', 'AllowPrefix' => True ),
81  'c' => array( 'Group' => 'Energy', 'Unit Name' => 'Thermodynamic calorie', 'AllowPrefix' => True ),
82  'cal' => array( 'Group' => 'Energy', 'Unit Name' => 'IT calorie', 'AllowPrefix' => True ),
83  'eV' => array( 'Group' => 'Energy', 'Unit Name' => 'Electron volt', 'AllowPrefix' => True ),
84  'ev' => array( 'Group' => 'Energy', 'Unit Name' => 'Electron volt', 'AllowPrefix' => True ),
85  'HPh' => array( 'Group' => 'Energy', 'Unit Name' => 'Horsepower-hour', 'AllowPrefix' => False ),
86  'hh' => array( 'Group' => 'Energy', 'Unit Name' => 'Horsepower-hour', 'AllowPrefix' => False ),
87  'Wh' => array( 'Group' => 'Energy', 'Unit Name' => 'Watt-hour', 'AllowPrefix' => True ),
88  'wh' => array( 'Group' => 'Energy', 'Unit Name' => 'Watt-hour', 'AllowPrefix' => True ),
89  'flb' => array( 'Group' => 'Energy', 'Unit Name' => 'Foot-pound', 'AllowPrefix' => False ),
90  'BTU' => array( 'Group' => 'Energy', 'Unit Name' => 'BTU', 'AllowPrefix' => False ),
91  'btu' => array( 'Group' => 'Energy', 'Unit Name' => 'BTU', 'AllowPrefix' => False ),
92  'HP' => array( 'Group' => 'Power', 'Unit Name' => 'Horsepower', 'AllowPrefix' => False ),
93  'h' => array( 'Group' => 'Power', 'Unit Name' => 'Horsepower', 'AllowPrefix' => False ),
94  'W' => array( 'Group' => 'Power', 'Unit Name' => 'Watt', 'AllowPrefix' => True ),
95  'w' => array( 'Group' => 'Power', 'Unit Name' => 'Watt', 'AllowPrefix' => True ),
96  'T' => array( 'Group' => 'Magnetism', 'Unit Name' => 'Tesla', 'AllowPrefix' => True ),
97  'ga' => array( 'Group' => 'Magnetism', 'Unit Name' => 'Gauss', 'AllowPrefix' => True ),
98  'C' => array( 'Group' => 'Temperature', 'Unit Name' => 'Celsius', 'AllowPrefix' => False ),
99  'cel' => array( 'Group' => 'Temperature', 'Unit Name' => 'Celsius', 'AllowPrefix' => False ),
100  'F' => array( 'Group' => 'Temperature', 'Unit Name' => 'Fahrenheit', 'AllowPrefix' => False ),
101  'fah' => array( 'Group' => 'Temperature', 'Unit Name' => 'Fahrenheit', 'AllowPrefix' => False ),
102  'K' => array( 'Group' => 'Temperature', 'Unit Name' => 'Kelvin', 'AllowPrefix' => False ),
103  'kel' => array( 'Group' => 'Temperature', 'Unit Name' => 'Kelvin', 'AllowPrefix' => False ),
104  'tsp' => array( 'Group' => 'Liquid', 'Unit Name' => 'Teaspoon', 'AllowPrefix' => False ),
105  'tbs' => array( 'Group' => 'Liquid', 'Unit Name' => 'Tablespoon', 'AllowPrefix' => False ),
106  'oz' => array( 'Group' => 'Liquid', 'Unit Name' => 'Fluid Ounce', 'AllowPrefix' => False ),
107  'cup' => array( 'Group' => 'Liquid', 'Unit Name' => 'Cup', 'AllowPrefix' => False ),
108  'pt' => array( 'Group' => 'Liquid', 'Unit Name' => 'U.S. Pint', 'AllowPrefix' => False ),
109  'us_pt' => array( 'Group' => 'Liquid', 'Unit Name' => 'U.S. Pint', 'AllowPrefix' => False ),
110  'uk_pt' => array( 'Group' => 'Liquid', 'Unit Name' => 'U.K. Pint', 'AllowPrefix' => False ),
111  'qt' => array( 'Group' => 'Liquid', 'Unit Name' => 'Quart', 'AllowPrefix' => False ),
112  'gal' => array( 'Group' => 'Liquid', 'Unit Name' => 'Gallon', 'AllowPrefix' => False ),
113  'l' => array( 'Group' => 'Liquid', 'Unit Name' => 'Litre', 'AllowPrefix' => True ),
114  'lt' => array( 'Group' => 'Liquid', 'Unit Name' => 'Litre', 'AllowPrefix' => True )
115  );
116 
117  private static $_conversionMultipliers = array( 'Y' => array( 'multiplier' => 1E24, 'name' => 'yotta' ),
118  'Z' => array( 'multiplier' => 1E21, 'name' => 'zetta' ),
119  'E' => array( 'multiplier' => 1E18, 'name' => 'exa' ),
120  'P' => array( 'multiplier' => 1E15, 'name' => 'peta' ),
121  'T' => array( 'multiplier' => 1E12, 'name' => 'tera' ),
122  'G' => array( 'multiplier' => 1E9, 'name' => 'giga' ),
123  'M' => array( 'multiplier' => 1E6, 'name' => 'mega' ),
124  'k' => array( 'multiplier' => 1E3, 'name' => 'kilo' ),
125  'h' => array( 'multiplier' => 1E2, 'name' => 'hecto' ),
126  'e' => array( 'multiplier' => 1E1, 'name' => 'deka' ),
127  'd' => array( 'multiplier' => 1E-1, 'name' => 'deci' ),
128  'c' => array( 'multiplier' => 1E-2, 'name' => 'centi' ),
129  'm' => array( 'multiplier' => 1E-3, 'name' => 'milli' ),
130  'u' => array( 'multiplier' => 1E-6, 'name' => 'micro' ),
131  'n' => array( 'multiplier' => 1E-9, 'name' => 'nano' ),
132  'p' => array( 'multiplier' => 1E-12, 'name' => 'pico' ),
133  'f' => array( 'multiplier' => 1E-15, 'name' => 'femto' ),
134  'a' => array( 'multiplier' => 1E-18, 'name' => 'atto' ),
135  'z' => array( 'multiplier' => 1E-21, 'name' => 'zepto' ),
136  'y' => array( 'multiplier' => 1E-24, 'name' => 'yocto' )
137  );
138 
139  private static $_unitConversions = array( 'Mass' => array( 'g' => array( 'g' => 1.0,
140  'sg' => 6.85220500053478E-05,
141  'lbm' => 2.20462291469134E-03,
142  'u' => 6.02217000000000E+23,
143  'ozm' => 3.52739718003627E-02
144  ),
145  'sg' => array( 'g' => 1.45938424189287E+04,
146  'sg' => 1.0,
147  'lbm' => 3.21739194101647E+01,
148  'u' => 8.78866000000000E+27,
149  'ozm' => 5.14782785944229E+02
150  ),
151  'lbm' => array( 'g' => 4.5359230974881148E+02,
152  'sg' => 3.10810749306493E-02,
153  'lbm' => 1.0,
154  'u' => 2.73161000000000E+26,
155  'ozm' => 1.60000023429410E+01
156  ),
157  'u' => array( 'g' => 1.66053100460465E-24,
158  'sg' => 1.13782988532950E-28,
159  'lbm' => 3.66084470330684E-27,
160  'u' => 1.0,
161  'ozm' => 5.85735238300524E-26
162  ),
163  'ozm' => array( 'g' => 2.83495152079732E+01,
164  'sg' => 1.94256689870811E-03,
165  'lbm' => 6.24999908478882E-02,
166  'u' => 1.70725600000000E+25,
167  'ozm' => 1.0
168  )
169  ),
170  'Distance' => array( 'm' => array( 'm' => 1.0,
171  'mi' => 6.21371192237334E-04,
172  'Nmi' => 5.39956803455724E-04,
173  'in' => 3.93700787401575E+01,
174  'ft' => 3.28083989501312E+00,
175  'yd' => 1.09361329797891E+00,
176  'ang' => 1.00000000000000E+10,
177  'Pica' => 2.83464566929116E+03
178  ),
179  'mi' => array( 'm' => 1.60934400000000E+03,
180  'mi' => 1.0,
181  'Nmi' => 8.68976241900648E-01,
182  'in' => 6.33600000000000E+04,
183  'ft' => 5.28000000000000E+03,
184  'yd' => 1.76000000000000E+03,
185  'ang' => 1.60934400000000E+13,
186  'Pica' => 4.56191999999971E+06
187  ),
188  'Nmi' => array( 'm' => 1.85200000000000E+03,
189  'mi' => 1.15077944802354E+00,
190  'Nmi' => 1.0,
191  'in' => 7.29133858267717E+04,
192  'ft' => 6.07611548556430E+03,
193  'yd' => 2.02537182785694E+03,
194  'ang' => 1.85200000000000E+13,
195  'Pica' => 5.24976377952723E+06
196  ),
197  'in' => array( 'm' => 2.54000000000000E-02,
198  'mi' => 1.57828282828283E-05,
199  'Nmi' => 1.37149028077754E-05,
200  'in' => 1.0,
201  'ft' => 8.33333333333333E-02,
202  'yd' => 2.77777777686643E-02,
203  'ang' => 2.54000000000000E+08,
204  'Pica' => 7.19999999999955E+01
205  ),
206  'ft' => array( 'm' => 3.04800000000000E-01,
207  'mi' => 1.89393939393939E-04,
208  'Nmi' => 1.64578833693305E-04,
209  'in' => 1.20000000000000E+01,
210  'ft' => 1.0,
211  'yd' => 3.33333333223972E-01,
212  'ang' => 3.04800000000000E+09,
213  'Pica' => 8.63999999999946E+02
214  ),
215  'yd' => array( 'm' => 9.14400000300000E-01,
216  'mi' => 5.68181818368230E-04,
217  'Nmi' => 4.93736501241901E-04,
218  'in' => 3.60000000118110E+01,
219  'ft' => 3.00000000000000E+00,
220  'yd' => 1.0,
221  'ang' => 9.14400000300000E+09,
222  'Pica' => 2.59200000085023E+03
223  ),
224  'ang' => array( 'm' => 1.00000000000000E-10,
225  'mi' => 6.21371192237334E-14,
226  'Nmi' => 5.39956803455724E-14,
227  'in' => 3.93700787401575E-09,
228  'ft' => 3.28083989501312E-10,
229  'yd' => 1.09361329797891E-10,
230  'ang' => 1.0,
231  'Pica' => 2.83464566929116E-07
232  ),
233  'Pica' => array( 'm' => 3.52777777777800E-04,
234  'mi' => 2.19205948372629E-07,
235  'Nmi' => 1.90484761219114E-07,
236  'in' => 1.38888888888898E-02,
237  'ft' => 1.15740740740748E-03,
238  'yd' => 3.85802469009251E-04,
239  'ang' => 3.52777777777800E+06,
240  'Pica' => 1.0
241  )
242  ),
243  'Time' => array( 'yr' => array( 'yr' => 1.0,
244  'day' => 365.25,
245  'hr' => 8766.0,
246  'mn' => 525960.0,
247  'sec' => 31557600.0
248  ),
249  'day' => array( 'yr' => 2.73785078713210E-03,
250  'day' => 1.0,
251  'hr' => 24.0,
252  'mn' => 1440.0,
253  'sec' => 86400.0
254  ),
255  'hr' => array( 'yr' => 1.14077116130504E-04,
256  'day' => 4.16666666666667E-02,
257  'hr' => 1.0,
258  'mn' => 60.0,
259  'sec' => 3600.0
260  ),
261  'mn' => array( 'yr' => 1.90128526884174E-06,
262  'day' => 6.94444444444444E-04,
263  'hr' => 1.66666666666667E-02,
264  'mn' => 1.0,
265  'sec' => 60.0
266  ),
267  'sec' => array( 'yr' => 3.16880878140289E-08,
268  'day' => 1.15740740740741E-05,
269  'hr' => 2.77777777777778E-04,
270  'mn' => 1.66666666666667E-02,
271  'sec' => 1.0
272  )
273  ),
274  'Pressure' => array( 'Pa' => array( 'Pa' => 1.0,
275  'p' => 1.0,
276  'atm' => 9.86923299998193E-06,
277  'at' => 9.86923299998193E-06,
278  'mmHg' => 7.50061707998627E-03
279  ),
280  'p' => array( 'Pa' => 1.0,
281  'p' => 1.0,
282  'atm' => 9.86923299998193E-06,
283  'at' => 9.86923299998193E-06,
284  'mmHg' => 7.50061707998627E-03
285  ),
286  'atm' => array( 'Pa' => 1.01324996583000E+05,
287  'p' => 1.01324996583000E+05,
288  'atm' => 1.0,
289  'at' => 1.0,
290  'mmHg' => 760.0
291  ),
292  'at' => array( 'Pa' => 1.01324996583000E+05,
293  'p' => 1.01324996583000E+05,
294  'atm' => 1.0,
295  'at' => 1.0,
296  'mmHg' => 760.0
297  ),
298  'mmHg' => array( 'Pa' => 1.33322363925000E+02,
299  'p' => 1.33322363925000E+02,
300  'atm' => 1.31578947368421E-03,
301  'at' => 1.31578947368421E-03,
302  'mmHg' => 1.0
303  )
304  ),
305  'Force' => array( 'N' => array( 'N' => 1.0,
306  'dyn' => 1.0E+5,
307  'dy' => 1.0E+5,
308  'lbf' => 2.24808923655339E-01
309  ),
310  'dyn' => array( 'N' => 1.0E-5,
311  'dyn' => 1.0,
312  'dy' => 1.0,
313  'lbf' => 2.24808923655339E-06
314  ),
315  'dy' => array( 'N' => 1.0E-5,
316  'dyn' => 1.0,
317  'dy' => 1.0,
318  'lbf' => 2.24808923655339E-06
319  ),
320  'lbf' => array( 'N' => 4.448222,
321  'dyn' => 4.448222E+5,
322  'dy' => 4.448222E+5,
323  'lbf' => 1.0
324  )
325  ),
326  'Energy' => array( 'J' => array( 'J' => 1.0,
327  'e' => 9.99999519343231E+06,
328  'c' => 2.39006249473467E-01,
329  'cal' => 2.38846190642017E-01,
330  'eV' => 6.24145700000000E+18,
331  'ev' => 6.24145700000000E+18,
332  'HPh' => 3.72506430801000E-07,
333  'hh' => 3.72506430801000E-07,
334  'Wh' => 2.77777916238711E-04,
335  'wh' => 2.77777916238711E-04,
336  'flb' => 2.37304222192651E+01,
337  'BTU' => 9.47815067349015E-04,
338  'btu' => 9.47815067349015E-04
339  ),
340  'e' => array( 'J' => 1.00000048065700E-07,
341  'e' => 1.0,
342  'c' => 2.39006364353494E-08,
343  'cal' => 2.38846305445111E-08,
344  'eV' => 6.24146000000000E+11,
345  'ev' => 6.24146000000000E+11,
346  'HPh' => 3.72506609848824E-14,
347  'hh' => 3.72506609848824E-14,
348  'Wh' => 2.77778049754611E-11,
349  'wh' => 2.77778049754611E-11,
350  'flb' => 2.37304336254586E-06,
351  'BTU' => 9.47815522922962E-11,
352  'btu' => 9.47815522922962E-11
353  ),
354  'c' => array( 'J' => 4.18399101363672E+00,
355  'e' => 4.18398900257312E+07,
356  'c' => 1.0,
357  'cal' => 9.99330315287563E-01,
358  'eV' => 2.61142000000000E+19,
359  'ev' => 2.61142000000000E+19,
360  'HPh' => 1.55856355899327E-06,
361  'hh' => 1.55856355899327E-06,
362  'Wh' => 1.16222030532950E-03,
363  'wh' => 1.16222030532950E-03,
364  'flb' => 9.92878733152102E+01,
365  'BTU' => 3.96564972437776E-03,
366  'btu' => 3.96564972437776E-03
367  ),
368  'cal' => array( 'J' => 4.18679484613929E+00,
369  'e' => 4.18679283372801E+07,
370  'c' => 1.00067013349059E+00,
371  'cal' => 1.0,
372  'eV' => 2.61317000000000E+19,
373  'ev' => 2.61317000000000E+19,
374  'HPh' => 1.55960800463137E-06,
375  'hh' => 1.55960800463137E-06,
376  'Wh' => 1.16299914807955E-03,
377  'wh' => 1.16299914807955E-03,
378  'flb' => 9.93544094443283E+01,
379  'BTU' => 3.96830723907002E-03,
380  'btu' => 3.96830723907002E-03
381  ),
382  'eV' => array( 'J' => 1.60219000146921E-19,
383  'e' => 1.60218923136574E-12,
384  'c' => 3.82933423195043E-20,
385  'cal' => 3.82676978535648E-20,
386  'eV' => 1.0,
387  'ev' => 1.0,
388  'HPh' => 5.96826078912344E-26,
389  'hh' => 5.96826078912344E-26,
390  'Wh' => 4.45053000026614E-23,
391  'wh' => 4.45053000026614E-23,
392  'flb' => 3.80206452103492E-18,
393  'BTU' => 1.51857982414846E-22,
394  'btu' => 1.51857982414846E-22
395  ),
396  'ev' => array( 'J' => 1.60219000146921E-19,
397  'e' => 1.60218923136574E-12,
398  'c' => 3.82933423195043E-20,
399  'cal' => 3.82676978535648E-20,
400  'eV' => 1.0,
401  'ev' => 1.0,
402  'HPh' => 5.96826078912344E-26,
403  'hh' => 5.96826078912344E-26,
404  'Wh' => 4.45053000026614E-23,
405  'wh' => 4.45053000026614E-23,
406  'flb' => 3.80206452103492E-18,
407  'BTU' => 1.51857982414846E-22,
408  'btu' => 1.51857982414846E-22
409  ),
410  'HPh' => array( 'J' => 2.68451741316170E+06,
411  'e' => 2.68451612283024E+13,
412  'c' => 6.41616438565991E+05,
413  'cal' => 6.41186757845835E+05,
414  'eV' => 1.67553000000000E+25,
415  'ev' => 1.67553000000000E+25,
416  'HPh' => 1.0,
417  'hh' => 1.0,
418  'Wh' => 7.45699653134593E+02,
419  'wh' => 7.45699653134593E+02,
420  'flb' => 6.37047316692964E+07,
421  'BTU' => 2.54442605275546E+03,
422  'btu' => 2.54442605275546E+03
423  ),
424  'hh' => array( 'J' => 2.68451741316170E+06,
425  'e' => 2.68451612283024E+13,
426  'c' => 6.41616438565991E+05,
427  'cal' => 6.41186757845835E+05,
428  'eV' => 1.67553000000000E+25,
429  'ev' => 1.67553000000000E+25,
430  'HPh' => 1.0,
431  'hh' => 1.0,
432  'Wh' => 7.45699653134593E+02,
433  'wh' => 7.45699653134593E+02,
434  'flb' => 6.37047316692964E+07,
435  'BTU' => 2.54442605275546E+03,
436  'btu' => 2.54442605275546E+03
437  ),
438  'Wh' => array( 'J' => 3.59999820554720E+03,
439  'e' => 3.59999647518369E+10,
440  'c' => 8.60422069219046E+02,
441  'cal' => 8.59845857713046E+02,
442  'eV' => 2.24692340000000E+22,
443  'ev' => 2.24692340000000E+22,
444  'HPh' => 1.34102248243839E-03,
445  'hh' => 1.34102248243839E-03,
446  'Wh' => 1.0,
447  'wh' => 1.0,
448  'flb' => 8.54294774062316E+04,
449  'BTU' => 3.41213254164705E+00,
450  'btu' => 3.41213254164705E+00
451  ),
452  'wh' => array( 'J' => 3.59999820554720E+03,
453  'e' => 3.59999647518369E+10,
454  'c' => 8.60422069219046E+02,
455  'cal' => 8.59845857713046E+02,
456  'eV' => 2.24692340000000E+22,
457  'ev' => 2.24692340000000E+22,
458  'HPh' => 1.34102248243839E-03,
459  'hh' => 1.34102248243839E-03,
460  'Wh' => 1.0,
461  'wh' => 1.0,
462  'flb' => 8.54294774062316E+04,
463  'BTU' => 3.41213254164705E+00,
464  'btu' => 3.41213254164705E+00
465  ),
466  'flb' => array( 'J' => 4.21400003236424E-02,
467  'e' => 4.21399800687660E+05,
468  'c' => 1.00717234301644E-02,
469  'cal' => 1.00649785509554E-02,
470  'eV' => 2.63015000000000E+17,
471  'ev' => 2.63015000000000E+17,
472  'HPh' => 1.56974211145130E-08,
473  'hh' => 1.56974211145130E-08,
474  'Wh' => 1.17055614802000E-05,
475  'wh' => 1.17055614802000E-05,
476  'flb' => 1.0,
477  'BTU' => 3.99409272448406E-05,
478  'btu' => 3.99409272448406E-05
479  ),
480  'BTU' => array( 'J' => 1.05505813786749E+03,
481  'e' => 1.05505763074665E+10,
482  'c' => 2.52165488508168E+02,
483  'cal' => 2.51996617135510E+02,
484  'eV' => 6.58510000000000E+21,
485  'ev' => 6.58510000000000E+21,
486  'HPh' => 3.93015941224568E-04,
487  'hh' => 3.93015941224568E-04,
488  'Wh' => 2.93071851047526E-01,
489  'wh' => 2.93071851047526E-01,
490  'flb' => 2.50369750774671E+04,
491  'BTU' => 1.0,
492  'btu' => 1.0,
493  ),
494  'btu' => array( 'J' => 1.05505813786749E+03,
495  'e' => 1.05505763074665E+10,
496  'c' => 2.52165488508168E+02,
497  'cal' => 2.51996617135510E+02,
498  'eV' => 6.58510000000000E+21,
499  'ev' => 6.58510000000000E+21,
500  'HPh' => 3.93015941224568E-04,
501  'hh' => 3.93015941224568E-04,
502  'Wh' => 2.93071851047526E-01,
503  'wh' => 2.93071851047526E-01,
504  'flb' => 2.50369750774671E+04,
505  'BTU' => 1.0,
506  'btu' => 1.0,
507  )
508  ),
509  'Power' => array( 'HP' => array( 'HP' => 1.0,
510  'h' => 1.0,
511  'W' => 7.45701000000000E+02,
512  'w' => 7.45701000000000E+02
513  ),
514  'h' => array( 'HP' => 1.0,
515  'h' => 1.0,
516  'W' => 7.45701000000000E+02,
517  'w' => 7.45701000000000E+02
518  ),
519  'W' => array( 'HP' => 1.34102006031908E-03,
520  'h' => 1.34102006031908E-03,
521  'W' => 1.0,
522  'w' => 1.0
523  ),
524  'w' => array( 'HP' => 1.34102006031908E-03,
525  'h' => 1.34102006031908E-03,
526  'W' => 1.0,
527  'w' => 1.0
528  )
529  ),
530  'Magnetism' => array( 'T' => array( 'T' => 1.0,
531  'ga' => 10000.0
532  ),
533  'ga' => array( 'T' => 0.0001,
534  'ga' => 1.0
535  )
536  ),
537  'Liquid' => array( 'tsp' => array( 'tsp' => 1.0,
538  'tbs' => 3.33333333333333E-01,
539  'oz' => 1.66666666666667E-01,
540  'cup' => 2.08333333333333E-02,
541  'pt' => 1.04166666666667E-02,
542  'us_pt' => 1.04166666666667E-02,
543  'uk_pt' => 8.67558516821960E-03,
544  'qt' => 5.20833333333333E-03,
545  'gal' => 1.30208333333333E-03,
546  'l' => 4.92999408400710E-03,
547  'lt' => 4.92999408400710E-03
548  ),
549  'tbs' => array( 'tsp' => 3.00000000000000E+00,
550  'tbs' => 1.0,
551  'oz' => 5.00000000000000E-01,
552  'cup' => 6.25000000000000E-02,
553  'pt' => 3.12500000000000E-02,
554  'us_pt' => 3.12500000000000E-02,
555  'uk_pt' => 2.60267555046588E-02,
556  'qt' => 1.56250000000000E-02,
557  'gal' => 3.90625000000000E-03,
558  'l' => 1.47899822520213E-02,
559  'lt' => 1.47899822520213E-02
560  ),
561  'oz' => array( 'tsp' => 6.00000000000000E+00,
562  'tbs' => 2.00000000000000E+00,
563  'oz' => 1.0,
564  'cup' => 1.25000000000000E-01,
565  'pt' => 6.25000000000000E-02,
566  'us_pt' => 6.25000000000000E-02,
567  'uk_pt' => 5.20535110093176E-02,
568  'qt' => 3.12500000000000E-02,
569  'gal' => 7.81250000000000E-03,
570  'l' => 2.95799645040426E-02,
571  'lt' => 2.95799645040426E-02
572  ),
573  'cup' => array( 'tsp' => 4.80000000000000E+01,
574  'tbs' => 1.60000000000000E+01,
575  'oz' => 8.00000000000000E+00,
576  'cup' => 1.0,
577  'pt' => 5.00000000000000E-01,
578  'us_pt' => 5.00000000000000E-01,
579  'uk_pt' => 4.16428088074541E-01,
580  'qt' => 2.50000000000000E-01,
581  'gal' => 6.25000000000000E-02,
582  'l' => 2.36639716032341E-01,
583  'lt' => 2.36639716032341E-01
584  ),
585  'pt' => array( 'tsp' => 9.60000000000000E+01,
586  'tbs' => 3.20000000000000E+01,
587  'oz' => 1.60000000000000E+01,
588  'cup' => 2.00000000000000E+00,
589  'pt' => 1.0,
590  'us_pt' => 1.0,
591  'uk_pt' => 8.32856176149081E-01,
592  'qt' => 5.00000000000000E-01,
593  'gal' => 1.25000000000000E-01,
594  'l' => 4.73279432064682E-01,
595  'lt' => 4.73279432064682E-01
596  ),
597  'us_pt' => array( 'tsp' => 9.60000000000000E+01,
598  'tbs' => 3.20000000000000E+01,
599  'oz' => 1.60000000000000E+01,
600  'cup' => 2.00000000000000E+00,
601  'pt' => 1.0,
602  'us_pt' => 1.0,
603  'uk_pt' => 8.32856176149081E-01,
604  'qt' => 5.00000000000000E-01,
605  'gal' => 1.25000000000000E-01,
606  'l' => 4.73279432064682E-01,
607  'lt' => 4.73279432064682E-01
608  ),
609  'uk_pt' => array( 'tsp' => 1.15266000000000E+02,
610  'tbs' => 3.84220000000000E+01,
611  'oz' => 1.92110000000000E+01,
612  'cup' => 2.40137500000000E+00,
613  'pt' => 1.20068750000000E+00,
614  'us_pt' => 1.20068750000000E+00,
615  'uk_pt' => 1.0,
616  'qt' => 6.00343750000000E-01,
617  'gal' => 1.50085937500000E-01,
618  'l' => 5.68260698087162E-01,
619  'lt' => 5.68260698087162E-01
620  ),
621  'qt' => array( 'tsp' => 1.92000000000000E+02,
622  'tbs' => 6.40000000000000E+01,
623  'oz' => 3.20000000000000E+01,
624  'cup' => 4.00000000000000E+00,
625  'pt' => 2.00000000000000E+00,
626  'us_pt' => 2.00000000000000E+00,
627  'uk_pt' => 1.66571235229816E+00,
628  'qt' => 1.0,
629  'gal' => 2.50000000000000E-01,
630  'l' => 9.46558864129363E-01,
631  'lt' => 9.46558864129363E-01
632  ),
633  'gal' => array( 'tsp' => 7.68000000000000E+02,
634  'tbs' => 2.56000000000000E+02,
635  'oz' => 1.28000000000000E+02,
636  'cup' => 1.60000000000000E+01,
637  'pt' => 8.00000000000000E+00,
638  'us_pt' => 8.00000000000000E+00,
639  'uk_pt' => 6.66284940919265E+00,
640  'qt' => 4.00000000000000E+00,
641  'gal' => 1.0,
642  'l' => 3.78623545651745E+00,
643  'lt' => 3.78623545651745E+00
644  ),
645  'l' => array( 'tsp' => 2.02840000000000E+02,
646  'tbs' => 6.76133333333333E+01,
647  'oz' => 3.38066666666667E+01,
648  'cup' => 4.22583333333333E+00,
649  'pt' => 2.11291666666667E+00,
650  'us_pt' => 2.11291666666667E+00,
651  'uk_pt' => 1.75975569552166E+00,
652  'qt' => 1.05645833333333E+00,
653  'gal' => 2.64114583333333E-01,
654  'l' => 1.0,
655  'lt' => 1.0
656  ),
657  'lt' => array( 'tsp' => 2.02840000000000E+02,
658  'tbs' => 6.76133333333333E+01,
659  'oz' => 3.38066666666667E+01,
660  'cup' => 4.22583333333333E+00,
661  'pt' => 2.11291666666667E+00,
662  'us_pt' => 2.11291666666667E+00,
663  'uk_pt' => 1.75975569552166E+00,
664  'qt' => 1.05645833333333E+00,
665  'gal' => 2.64114583333333E-01,
666  'l' => 1.0,
667  'lt' => 1.0
668  )
669  )
670  );
671 
672 
673  public static function _parseComplex($complexNumber) {
674  $workString = (string) $complexNumber;
675 
676  $realNumber = $imaginary = 0;
677  // Extract the suffix, if there is one
678  $suffix = substr($workString,-1);
679  if (!is_numeric($suffix)) {
680  $workString = substr($workString,0,-1);
681  } else {
682  $suffix = '';
683  }
684 
685  // Split the input into its Real and Imaginary components
686  $leadingSign = 0;
687  if (strlen($workString) > 0) {
688  $leadingSign = (($workString{0} == '+') || ($workString{0} == '-')) ? 1 : 0;
689  }
690  $power = '';
691  $realNumber = strtok($workString, '+-');
692  if (strtoupper(substr($realNumber,-1)) == 'E') {
693  $power = strtok('+-');
694  ++$leadingSign;
695  }
696 
697  $realNumber = substr($workString,0,strlen($realNumber)+strlen($power)+$leadingSign);
698 
699  if ($suffix != '') {
700  $imaginary = substr($workString,strlen($realNumber));
701 
702  if (($imaginary == '') && (($realNumber == '') || ($realNumber == '+') || ($realNumber == '-'))) {
703  $imaginary = $realNumber.'1';
704  $realNumber = '0';
705  } else if ($imaginary == '') {
706  $imaginary = $realNumber;
707  $realNumber = '0';
708  } elseif (($imaginary == '+') || ($imaginary == '-')) {
709  $imaginary .= '1';
710  }
711  }
712 
713  return array( 'real' => $realNumber,
714  'imaginary' => $imaginary,
715  'suffix' => $suffix
716  );
717  } // function _parseComplex()
718 
719 
720  private static function _cleanComplex($complexNumber) {
721  if ($complexNumber{0} == '+') $complexNumber = substr($complexNumber,1);
722  if ($complexNumber{0} == '0') $complexNumber = substr($complexNumber,1);
723  if ($complexNumber{0} == '.') $complexNumber = '0'.$complexNumber;
724  if ($complexNumber{0} == '+') $complexNumber = substr($complexNumber,1);
725  return $complexNumber;
726  }
727 
728 
729  private static function _nbrConversionFormat($xVal,$places) {
730  if (!is_null($places)) {
731  if (strlen($xVal) <= $places) {
732  return substr(str_pad($xVal,$places,'0',STR_PAD_LEFT),-10);
733  } else {
735  }
736  }
737 
738  return substr($xVal,-10);
739  } // function _nbrConversionFormat()
740 
741 
751  public static function BESSELI($x, $n) {
753  $n = (is_null($n)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($n);
754 
755  if ((is_numeric($x)) && (is_numeric($n))) {
756  $n = floor($n);
757  if ($n < 0) {
759  }
760  $f_2_PI = 2 * M_PI;
761 
762  if (abs($x) <= 30) {
763  $fTerm = pow($x / 2, $n) / PHPExcel_Calculation_MathTrig::FACT($n);
764  $nK = 1;
765  $fResult = $fTerm;
766  $fSqrX = ($x * $x) / 4;
767  do {
768  $fTerm *= $fSqrX;
769  $fTerm /= ($nK * ($nK + $n));
770  $fResult += $fTerm;
771  } while ((abs($fTerm) > 1e-10) && (++$nK < 100));
772  } else {
773  $fXAbs = abs($x);
774  $fResult = exp($fXAbs) / sqrt($f_2_PI * $fXAbs);
775  if (($n && 1) && ($x < 0)) {
776  $fResult = -$fResult;
777  }
778  }
779  return $fResult;
780  }
782  } // function BESSELI()
783 
784 
794  public static function BESSELJ($x, $n) {
796  $n = (is_null($n)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($n);
797 
798  if ((is_numeric($x)) && (is_numeric($n))) {
799  $n = floor($n);
800  if ($n < 0) {
802  }
803  $f_PI_DIV_2 = M_PI / 2;
804  $f_PI_DIV_4 = M_PI / 4;
805 
806  $fResult = 0;
807  if (abs($x) <= 30) {
808  $fTerm = pow($x / 2, $n) / PHPExcel_Calculation_MathTrig::FACT($n);
809  $nK = 1;
810  $fResult = $fTerm;
811  $fSqrX = ($x * $x) / -4;
812  do {
813  $fTerm *= $fSqrX;
814  $fTerm /= ($nK * ($nK + $n));
815  $fResult += $fTerm;
816  } while ((abs($fTerm) > 1e-10) && (++$nK < 100));
817  } else {
818  $fXAbs = abs($x);
819  $fResult = sqrt(M_2DIVPI / $fXAbs) * cos($fXAbs - $n * $f_PI_DIV_2 - $f_PI_DIV_4);
820  if (($n && 1) && ($x < 0)) {
821  $fResult = -$fResult;
822  }
823  }
824  return $fResult;
825  }
827  } // function BESSELJ()
828 
829 
830  private static function _Besselk0($fNum) {
831  if ($fNum <= 2) {
832  $fNum2 = $fNum * 0.5;
833  $y = ($fNum2 * $fNum2);
834  $fRet = -log($fNum2) * self::BESSELI($fNum, 0) +
835  (-0.57721566 + $y * (0.42278420 + $y * (0.23069756 + $y * (0.3488590e-1 + $y * (0.262698e-2 + $y *
836  (0.10750e-3 + $y * 0.74e-5))))));
837  } else {
838  $y = 2 / $fNum;
839  $fRet = exp(-$fNum) / sqrt($fNum) *
840  (1.25331414 + $y * (-0.7832358e-1 + $y * (0.2189568e-1 + $y * (-0.1062446e-1 + $y *
841  (0.587872e-2 + $y * (-0.251540e-2 + $y * 0.53208e-3))))));
842  }
843  return $fRet;
844  } // function _Besselk0()
845 
846 
847  private static function _Besselk1($fNum) {
848  if ($fNum <= 2) {
849  $fNum2 = $fNum * 0.5;
850  $y = ($fNum2 * $fNum2);
851  $fRet = log($fNum2) * self::BESSELI($fNum, 1) +
852  (1 + $y * (0.15443144 + $y * (-0.67278579 + $y * (-0.18156897 + $y * (-0.1919402e-1 + $y *
853  (-0.110404e-2 + $y * (-0.4686e-4))))))) / $fNum;
854  } else {
855  $y = 2 / $fNum;
856  $fRet = exp(-$fNum) / sqrt($fNum) *
857  (1.25331414 + $y * (0.23498619 + $y * (-0.3655620e-1 + $y * (0.1504268e-1 + $y * (-0.780353e-2 + $y *
858  (0.325614e-2 + $y * (-0.68245e-3)))))));
859  }
860  return $fRet;
861  } // function _Besselk1()
862 
863 
873  public static function BESSELK($x, $ord) {
875  $ord = (is_null($ord)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($ord);
876 
877  if ((is_numeric($x)) && (is_numeric($ord))) {
878  if (($ord < 0) || ($x == 0.0)) {
880  }
881 
882  switch(floor($ord)) {
883  case 0 : return self::_Besselk0($x);
884  break;
885  case 1 : return self::_Besselk1($x);
886  break;
887  default : $fTox = 2 / $x;
888  $fBkm = self::_Besselk0($x);
889  $fBk = self::_Besselk1($x);
890  for ($n = 1; $n < $ord; ++$n) {
891  $fBkp = $fBkm + $n * $fTox * $fBk;
892  $fBkm = $fBk;
893  $fBk = $fBkp;
894  }
895  }
896  return $fBk;
897  }
899  } // function BESSELK()
900 
901 
902  private static function _Bessely0($fNum) {
903  if ($fNum < 8.0) {
904  $y = ($fNum * $fNum);
905  $f1 = -2957821389.0 + $y * (7062834065.0 + $y * (-512359803.6 + $y * (10879881.29 + $y * (-86327.92757 + $y * 228.4622733))));
906  $f2 = 40076544269.0 + $y * (745249964.8 + $y * (7189466.438 + $y * (47447.26470 + $y * (226.1030244 + $y))));
907  $fRet = $f1 / $f2 + M_2DIVPI * self::BESSELJ($fNum, 0) * log($fNum);
908  } else {
909  $z = 8.0 / $fNum;
910  $y = ($z * $z);
911  $xx = $fNum - 0.785398164;
912  $f1 = 1 + $y * (-0.1098628627e-2 + $y * (0.2734510407e-4 + $y * (-0.2073370639e-5 + $y * 0.2093887211e-6)));
913  $f2 = -0.1562499995e-1 + $y * (0.1430488765e-3 + $y * (-0.6911147651e-5 + $y * (0.7621095161e-6 + $y * (-0.934945152e-7))));
914  $fRet = sqrt(M_2DIVPI / $fNum) * (sin($xx) * $f1 + $z * cos($xx) * $f2);
915  }
916  return $fRet;
917  } // function _Bessely0()
918 
919 
920  private static function _Bessely1($fNum) {
921  if ($fNum < 8.0) {
922  $y = ($fNum * $fNum);
923  $f1 = $fNum * (-0.4900604943e13 + $y * (0.1275274390e13 + $y * (-0.5153438139e11 + $y * (0.7349264551e9 + $y *
924  (-0.4237922726e7 + $y * 0.8511937935e4)))));
925  $f2 = 0.2499580570e14 + $y * (0.4244419664e12 + $y * (0.3733650367e10 + $y * (0.2245904002e8 + $y *
926  (0.1020426050e6 + $y * (0.3549632885e3 + $y)))));
927  $fRet = $f1 / $f2 + M_2DIVPI * ( self::BESSELJ($fNum, 1) * log($fNum) - 1 / $fNum);
928  } else {
929  $z = 8.0 / $fNum;
930  $y = ($z * $z);
931  $xx = $fNum - 2.356194491;
932  $f1 = 1 + $y * (0.183105e-2 + $y * (-0.3516396496e-4 + $y * (0.2457520174e-5 + $y * (-0.240337019e6))));
933  $f2 = 0.04687499995 + $y * (-0.2002690873e-3 + $y * (0.8449199096e-5 + $y * (-0.88228987e-6 + $y * 0.105787412e-6)));
934  $fRet = sqrt(M_2DIVPI / $fNum) * (sin($xx) * $f1 + $z * cos($xx) * $f2);
935  #i12430# ...but this seems to work much better.
936 // $fRet = sqrt(M_2DIVPI / $fNum) * sin($fNum - 2.356194491);
937  }
938  return $fRet;
939  } // function _Bessely1()
940 
941 
951  public static function BESSELY($x, $ord) {
953  $ord = (is_null($ord)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($ord);
954 
955  if ((is_numeric($x)) && (is_numeric($ord))) {
956  if (($ord < 0) || ($x == 0.0)) {
958  }
959 
960  switch(floor($ord)) {
961  case 0 : return self::_Bessely0($x);
962  break;
963  case 1 : return self::_Bessely1($x);
964  break;
965  default: $fTox = 2 / $x;
966  $fBym = self::_Bessely0($x);
967  $fBy = self::_Bessely1($x);
968  for ($n = 1; $n < $ord; ++$n) {
969  $fByp = $n * $fTox * $fBy - $fBym;
970  $fBym = $fBy;
971  $fBy = $fByp;
972  }
973  }
974  return $fBy;
975  }
977  } // function BESSELY()
978 
979 
988  public static function BINTODEC($x) {
990 
991  if (is_bool($x)) {
993  $x = (int) $x;
994  } else {
996  }
997  }
999  $x = floor($x);
1000  }
1001  $x = (string) $x;
1002  if (strlen($x) > preg_match_all('/[01]/',$x,$out)) {
1004  }
1005  if (strlen($x) > 10) {
1007  } elseif (strlen($x) == 10) {
1008  // Two's Complement
1009  $x = substr($x,-9);
1010  return '-'.(512-bindec($x));
1011  }
1012  return bindec($x);
1013  } // function BINTODEC()
1014 
1015 
1024  public static function BINTOHEX($x, $places=null) {
1027 
1028  if (is_bool($x)) {
1030  $x = (int) $x;
1031  } else {
1033  }
1034  }
1036  $x = floor($x);
1037  }
1038  $x = (string) $x;
1039  if (strlen($x) > preg_match_all('/[01]/',$x,$out)) {
1041  }
1042  if (strlen($x) > 10) {
1044  } elseif (strlen($x) == 10) {
1045  // Two's Complement
1046  return str_repeat('F',8).substr(strtoupper(dechex(bindec(substr($x,-9)))),-2);
1047  }
1048  $hexVal = (string) strtoupper(dechex(bindec($x)));
1049 
1050  return self::_nbrConversionFormat($hexVal,$places);
1051  } // function BINTOHEX()
1052 
1053 
1062  public static function BINTOOCT($x, $places=null) {
1065 
1066  if (is_bool($x)) {
1068  $x = (int) $x;
1069  } else {
1071  }
1072  }
1074  $x = floor($x);
1075  }
1076  $x = (string) $x;
1077  if (strlen($x) > preg_match_all('/[01]/',$x,$out)) {
1079  }
1080  if (strlen($x) > 10) {
1082  } elseif (strlen($x) == 10) {
1083  // Two's Complement
1084  return str_repeat('7',7).substr(strtoupper(decoct(bindec(substr($x,-9)))),-3);
1085  }
1086  $octVal = (string) decoct(bindec($x));
1087 
1088  return self::_nbrConversionFormat($octVal,$places);
1089  } // function BINTOOCT()
1090 
1091 
1100  public static function DECTOBIN($x, $places=null) {
1103 
1104  if (is_bool($x)) {
1106  $x = (int) $x;
1107  } else {
1109  }
1110  }
1111  $x = (string) $x;
1112  if (strlen($x) > preg_match_all('/[-0123456789.]/',$x,$out)) {
1114  }
1115  $x = (string) floor($x);
1116  $r = decbin($x);
1117  if (strlen($r) == 32) {
1118  // Two's Complement
1119  $r = substr($r,-10);
1120  } elseif (strlen($r) > 11) {
1122  }
1123 
1124  return self::_nbrConversionFormat($r,$places);
1125  } // function DECTOBIN()
1126 
1127 
1136  public static function DECTOHEX($x, $places=null) {
1139 
1140  if (is_bool($x)) {
1142  $x = (int) $x;
1143  } else {
1145  }
1146  }
1147  $x = (string) $x;
1148  if (strlen($x) > preg_match_all('/[-0123456789.]/',$x,$out)) {
1150  }
1151  $x = (string) floor($x);
1152  $r = strtoupper(dechex($x));
1153  if (strlen($r) == 8) {
1154  // Two's Complement
1155  $r = 'FF'.$r;
1156  }
1157 
1158  return self::_nbrConversionFormat($r,$places);
1159  } // function DECTOHEX()
1160 
1161 
1170  public static function DECTOOCT($x, $places=null) {
1173 
1174  if (is_bool($x)) {
1176  $x = (int) $x;
1177  } else {
1179  }
1180  }
1181  $x = (string) $x;
1182  if (strlen($x) > preg_match_all('/[-0123456789.]/',$x,$out)) {
1184  }
1185  $x = (string) floor($x);
1186  $r = decoct($x);
1187  if (strlen($r) == 11) {
1188  // Two's Complement
1189  $r = substr($r,-10);
1190  }
1191 
1192  return self::_nbrConversionFormat($r,$places);
1193  } // function DECTOOCT()
1194 
1195 
1204  public static function HEXTOBIN($x, $places=null) {
1207 
1208  if (is_bool($x)) {
1210  }
1211  $x = (string) $x;
1212  if (strlen($x) > preg_match_all('/[0123456789ABCDEF]/',strtoupper($x),$out)) {
1214  }
1215  $binVal = decbin(hexdec($x));
1216 
1217  return substr(self::_nbrConversionFormat($binVal,$places),-10);
1218  } // function HEXTOBIN()
1219 
1220 
1229  public static function HEXTODEC($x) {
1231 
1232  if (is_bool($x)) {
1234  }
1235  $x = (string) $x;
1236  if (strlen($x) > preg_match_all('/[0123456789ABCDEF]/',strtoupper($x),$out)) {
1238  }
1239  return hexdec($x);
1240  } // function HEXTODEC()
1241 
1242 
1251  public static function HEXTOOCT($x, $places=null) {
1254 
1255  if (is_bool($x)) {
1257  }
1258  $x = (string) $x;
1259  if (strlen($x) > preg_match_all('/[0123456789ABCDEF]/',strtoupper($x),$out)) {
1261  }
1262  $octVal = decoct(hexdec($x));
1263 
1264  return self::_nbrConversionFormat($octVal,$places);
1265  } // function HEXTOOCT()
1266 
1267 
1276  public static function OCTTOBIN($x, $places=null) {
1279 
1280  if (is_bool($x)) {
1282  }
1283  $x = (string) $x;
1284  if (preg_match_all('/[01234567]/',$x,$out) != strlen($x)) {
1286  }
1287  $r = decbin(octdec($x));
1288 
1289  return self::_nbrConversionFormat($r,$places);
1290  } // function OCTTOBIN()
1291 
1292 
1301  public static function OCTTODEC($x) {
1303 
1304  if (is_bool($x)) {
1306  }
1307  $x = (string) $x;
1308  if (preg_match_all('/[01234567]/',$x,$out) != strlen($x)) {
1310  }
1311  return octdec($x);
1312  } // function OCTTODEC()
1313 
1314 
1323  public static function OCTTOHEX($x, $places=null) {
1326 
1327  if (is_bool($x)) {
1329  }
1330  $x = (string) $x;
1331  if (preg_match_all('/[01234567]/',$x,$out) != strlen($x)) {
1333  }
1334  $hexVal = strtoupper(dechex(octdec($x)));
1335 
1336  return self::_nbrConversionFormat($hexVal,$places);
1337  } // function OCTTOHEX()
1338 
1339 
1350  public static function COMPLEX($realNumber=0.0, $imaginary=0.0, $suffix='i') {
1351  $realNumber = (is_null($realNumber)) ? 0.0 : (float) PHPExcel_Calculation_Functions::flattenSingleValue($realNumber);
1352  $imaginary = (is_null($imaginary)) ? 0.0 : (float) PHPExcel_Calculation_Functions::flattenSingleValue($imaginary);
1353  $suffix = (is_null($suffix)) ? 'i' : PHPExcel_Calculation_Functions::flattenSingleValue($suffix);
1354 
1355  if (((is_numeric($realNumber)) && (is_numeric($imaginary))) &&
1356  (($suffix == 'i') || ($suffix == 'j') || ($suffix == ''))) {
1357  if ($suffix == '') $suffix = 'i';
1358  if ($realNumber == 0.0) {
1359  if ($imaginary == 0.0) {
1360  return (string) '0';
1361  } elseif ($imaginary == 1.0) {
1362  return (string) $suffix;
1363  } elseif ($imaginary == -1.0) {
1364  return (string) '-'.$suffix;
1365  }
1366  return (string) $imaginary.$suffix;
1367  } elseif ($imaginary == 0.0) {
1368  return (string) $realNumber;
1369  } elseif ($imaginary == 1.0) {
1370  return (string) $realNumber.'+'.$suffix;
1371  } elseif ($imaginary == -1.0) {
1372  return (string) $realNumber.'-'.$suffix;
1373  }
1374  if ($imaginary > 0) { $imaginary = (string) '+'.$imaginary; }
1375  return (string) $realNumber.$imaginary.$suffix;
1376  }
1377 
1379  } // function COMPLEX()
1380 
1381 
1390  public static function IMAGINARY($complexNumber) {
1391  $complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
1392 
1393  $parsedComplex = self::_parseComplex($complexNumber);
1394  if (!is_array($parsedComplex)) {
1395  return $parsedComplex;
1396  }
1397  return $parsedComplex['imaginary'];
1398  } // function IMAGINARY()
1399 
1400 
1409  public static function IMREAL($complexNumber) {
1410  $complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
1411 
1412  $parsedComplex = self::_parseComplex($complexNumber);
1413  if (!is_array($parsedComplex)) {
1414  return $parsedComplex;
1415  }
1416  return $parsedComplex['real'];
1417  } // function IMREAL()
1418 
1419 
1428  public static function IMABS($complexNumber) {
1429  $complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
1430 
1431  $parsedComplex = self::_parseComplex($complexNumber);
1432  if (!is_array($parsedComplex)) {
1433  return $parsedComplex;
1434  }
1435  return sqrt(($parsedComplex['real'] * $parsedComplex['real']) + ($parsedComplex['imaginary'] * $parsedComplex['imaginary']));
1436  } // function IMABS()
1437 
1438 
1447  public static function IMARGUMENT($complexNumber) {
1448  $complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
1449 
1450  $parsedComplex = self::_parseComplex($complexNumber);
1451  if (!is_array($parsedComplex)) {
1452  return $parsedComplex;
1453  }
1454 
1455  if ($parsedComplex['real'] == 0.0) {
1456  if ($parsedComplex['imaginary'] == 0.0) {
1457  return 0.0;
1458  } elseif($parsedComplex['imaginary'] < 0.0) {
1459  return M_PI / -2;
1460  } else {
1461  return M_PI / 2;
1462  }
1463  } elseif ($parsedComplex['real'] > 0.0) {
1464  return atan($parsedComplex['imaginary'] / $parsedComplex['real']);
1465  } elseif ($parsedComplex['imaginary'] < 0.0) {
1466  return 0 - (M_PI - atan(abs($parsedComplex['imaginary']) / abs($parsedComplex['real'])));
1467  } else {
1468  return M_PI - atan($parsedComplex['imaginary'] / abs($parsedComplex['real']));
1469  }
1470  } // function IMARGUMENT()
1471 
1472 
1481  public static function IMCONJUGATE($complexNumber) {
1482  $complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
1483 
1484  $parsedComplex = self::_parseComplex($complexNumber);
1485 
1486  if (!is_array($parsedComplex)) {
1487  return $parsedComplex;
1488  }
1489 
1490  if ($parsedComplex['imaginary'] == 0.0) {
1491  return $parsedComplex['real'];
1492  } else {
1493  return self::_cleanComplex(self::COMPLEX($parsedComplex['real'], 0 - $parsedComplex['imaginary'], $parsedComplex['suffix']));
1494  }
1495  } // function IMCONJUGATE()
1496 
1497 
1506  public static function IMCOS($complexNumber) {
1507  $complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
1508 
1509  $parsedComplex = self::_parseComplex($complexNumber);
1510  if (!is_array($parsedComplex)) {
1511  return $parsedComplex;
1512  }
1513 
1514  if ($parsedComplex['imaginary'] == 0.0) {
1515  return cos($parsedComplex['real']);
1516  } else {
1517  return self::IMCONJUGATE(self::COMPLEX(cos($parsedComplex['real']) * cosh($parsedComplex['imaginary']),sin($parsedComplex['real']) * sinh($parsedComplex['imaginary']),$parsedComplex['suffix']));
1518  }
1519  } // function IMCOS()
1520 
1521 
1530  public static function IMSIN($complexNumber) {
1531  $complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
1532 
1533  $parsedComplex = self::_parseComplex($complexNumber);
1534  if (!is_array($parsedComplex)) {
1535  return $parsedComplex;
1536  }
1537 
1538  if ($parsedComplex['imaginary'] == 0.0) {
1539  return sin($parsedComplex['real']);
1540  } else {
1541  return self::COMPLEX(sin($parsedComplex['real']) * cosh($parsedComplex['imaginary']),cos($parsedComplex['real']) * sinh($parsedComplex['imaginary']),$parsedComplex['suffix']);
1542  }
1543  } // function IMSIN()
1544 
1545 
1554  public static function IMSQRT($complexNumber) {
1555  $complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
1556 
1557  $parsedComplex = self::_parseComplex($complexNumber);
1558  if (!is_array($parsedComplex)) {
1559  return $parsedComplex;
1560  }
1561 
1562  $theta = self::IMARGUMENT($complexNumber);
1563  $d1 = cos($theta / 2);
1564  $d2 = sin($theta / 2);
1565  $r = sqrt(sqrt(($parsedComplex['real'] * $parsedComplex['real']) + ($parsedComplex['imaginary'] * $parsedComplex['imaginary'])));
1566 
1567  if ($parsedComplex['suffix'] == '') {
1568  return self::COMPLEX($d1 * $r,$d2 * $r);
1569  } else {
1570  return self::COMPLEX($d1 * $r,$d2 * $r,$parsedComplex['suffix']);
1571  }
1572  } // function IMSQRT()
1573 
1574 
1583  public static function IMLN($complexNumber) {
1584  $complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
1585 
1586  $parsedComplex = self::_parseComplex($complexNumber);
1587  if (!is_array($parsedComplex)) {
1588  return $parsedComplex;
1589  }
1590 
1591  if (($parsedComplex['real'] == 0.0) && ($parsedComplex['imaginary'] == 0.0)) {
1593  }
1594 
1595  $logR = log(sqrt(($parsedComplex['real'] * $parsedComplex['real']) + ($parsedComplex['imaginary'] * $parsedComplex['imaginary'])));
1596  $t = self::IMARGUMENT($complexNumber);
1597 
1598  if ($parsedComplex['suffix'] == '') {
1599  return self::COMPLEX($logR,$t);
1600  } else {
1601  return self::COMPLEX($logR,$t,$parsedComplex['suffix']);
1602  }
1603  } // function IMLN()
1604 
1605 
1614  public static function IMLOG10($complexNumber) {
1615  $complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
1616 
1617  $parsedComplex = self::_parseComplex($complexNumber);
1618  if (!is_array($parsedComplex)) {
1619  return $parsedComplex;
1620  }
1621 
1622  if (($parsedComplex['real'] == 0.0) && ($parsedComplex['imaginary'] == 0.0)) {
1624  } elseif (($parsedComplex['real'] > 0.0) && ($parsedComplex['imaginary'] == 0.0)) {
1625  return log10($parsedComplex['real']);
1626  }
1627 
1628  return self::IMPRODUCT(log10(EULER),self::IMLN($complexNumber));
1629  } // function IMLOG10()
1630 
1631 
1640  public static function IMLOG2($complexNumber) {
1641  $complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
1642 
1643  $parsedComplex = self::_parseComplex($complexNumber);
1644  if (!is_array($parsedComplex)) {
1645  return $parsedComplex;
1646  }
1647 
1648  if (($parsedComplex['real'] == 0.0) && ($parsedComplex['imaginary'] == 0.0)) {
1650  } elseif (($parsedComplex['real'] > 0.0) && ($parsedComplex['imaginary'] == 0.0)) {
1651  return log($parsedComplex['real'],2);
1652  }
1653 
1654  return self::IMPRODUCT(log(EULER,2),self::IMLN($complexNumber));
1655  } // function IMLOG2()
1656 
1657 
1666  public static function IMEXP($complexNumber) {
1667  $complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
1668 
1669  $parsedComplex = self::_parseComplex($complexNumber);
1670  if (!is_array($parsedComplex)) {
1671  return $parsedComplex;
1672  }
1673 
1674  if (($parsedComplex['real'] == 0.0) && ($parsedComplex['imaginary'] == 0.0)) {
1675  return '1';
1676  }
1677 
1678  $e = exp($parsedComplex['real']);
1679  $eX = $e * cos($parsedComplex['imaginary']);
1680  $eY = $e * sin($parsedComplex['imaginary']);
1681 
1682  if ($parsedComplex['suffix'] == '') {
1683  return self::COMPLEX($eX,$eY);
1684  } else {
1685  return self::COMPLEX($eX,$eY,$parsedComplex['suffix']);
1686  }
1687  } // function IMEXP()
1688 
1689 
1698  public static function IMPOWER($complexNumber,$realNumber) {
1699  $complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
1700  $realNumber = PHPExcel_Calculation_Functions::flattenSingleValue($realNumber);
1701 
1702  if (!is_numeric($realNumber)) {
1704  }
1705 
1706  $parsedComplex = self::_parseComplex($complexNumber);
1707  if (!is_array($parsedComplex)) {
1708  return $parsedComplex;
1709  }
1710 
1711  $r = sqrt(($parsedComplex['real'] * $parsedComplex['real']) + ($parsedComplex['imaginary'] * $parsedComplex['imaginary']));
1712  $rPower = pow($r,$realNumber);
1713  $theta = self::IMARGUMENT($complexNumber) * $realNumber;
1714  if ($theta == 0) {
1715  return 1;
1716  } elseif ($parsedComplex['imaginary'] == 0.0) {
1717  return self::COMPLEX($rPower * cos($theta),$rPower * sin($theta),$parsedComplex['suffix']);
1718  } else {
1719  return self::COMPLEX($rPower * cos($theta),$rPower * sin($theta),$parsedComplex['suffix']);
1720  }
1721  } // function IMPOWER()
1722 
1723 
1733  public static function IMDIV($complexDividend,$complexDivisor) {
1734  $complexDividend = PHPExcel_Calculation_Functions::flattenSingleValue($complexDividend);
1735  $complexDivisor = PHPExcel_Calculation_Functions::flattenSingleValue($complexDivisor);
1736 
1737  $parsedComplexDividend = self::_parseComplex($complexDividend);
1738  if (!is_array($parsedComplexDividend)) {
1739  return $parsedComplexDividend;
1740  }
1741 
1742  $parsedComplexDivisor = self::_parseComplex($complexDivisor);
1743  if (!is_array($parsedComplexDivisor)) {
1744  return $parsedComplexDividend;
1745  }
1746 
1747  if (($parsedComplexDividend['suffix'] != '') && ($parsedComplexDivisor['suffix'] != '') &&
1748  ($parsedComplexDividend['suffix'] != $parsedComplexDivisor['suffix'])) {
1750  }
1751  if (($parsedComplexDividend['suffix'] != '') && ($parsedComplexDivisor['suffix'] == '')) {
1752  $parsedComplexDivisor['suffix'] = $parsedComplexDividend['suffix'];
1753  }
1754 
1755  $d1 = ($parsedComplexDividend['real'] * $parsedComplexDivisor['real']) + ($parsedComplexDividend['imaginary'] * $parsedComplexDivisor['imaginary']);
1756  $d2 = ($parsedComplexDividend['imaginary'] * $parsedComplexDivisor['real']) - ($parsedComplexDividend['real'] * $parsedComplexDivisor['imaginary']);
1757  $d3 = ($parsedComplexDivisor['real'] * $parsedComplexDivisor['real']) + ($parsedComplexDivisor['imaginary'] * $parsedComplexDivisor['imaginary']);
1758 
1759  $r = $d1/$d3;
1760  $i = $d2/$d3;
1761 
1762  if ($i > 0.0) {
1763  return self::_cleanComplex($r.'+'.$i.$parsedComplexDivisor['suffix']);
1764  } elseif ($i < 0.0) {
1765  return self::_cleanComplex($r.$i.$parsedComplexDivisor['suffix']);
1766  } else {
1767  return $r;
1768  }
1769  } // function IMDIV()
1770 
1771 
1781  public static function IMSUB($complexNumber1,$complexNumber2) {
1782  $complexNumber1 = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber1);
1783  $complexNumber2 = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber2);
1784 
1785  $parsedComplex1 = self::_parseComplex($complexNumber1);
1786  if (!is_array($parsedComplex1)) {
1787  return $parsedComplex1;
1788  }
1789 
1790  $parsedComplex2 = self::_parseComplex($complexNumber2);
1791  if (!is_array($parsedComplex2)) {
1792  return $parsedComplex2;
1793  }
1794 
1795  if ((($parsedComplex1['suffix'] != '') && ($parsedComplex2['suffix'] != '')) &&
1796  ($parsedComplex1['suffix'] != $parsedComplex2['suffix'])) {
1798  } elseif (($parsedComplex1['suffix'] == '') && ($parsedComplex2['suffix'] != '')) {
1799  $parsedComplex1['suffix'] = $parsedComplex2['suffix'];
1800  }
1801 
1802  $d1 = $parsedComplex1['real'] - $parsedComplex2['real'];
1803  $d2 = $parsedComplex1['imaginary'] - $parsedComplex2['imaginary'];
1804 
1805  return self::COMPLEX($d1,$d2,$parsedComplex1['suffix']);
1806  } // function IMSUB()
1807 
1808 
1817  public static function IMSUM() {
1818  // Return value
1819  $returnValue = self::_parseComplex('0');
1820  $activeSuffix = '';
1821 
1822  // Loop through the arguments
1823  $aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
1824  foreach ($aArgs as $arg) {
1825  $parsedComplex = self::_parseComplex($arg);
1826  if (!is_array($parsedComplex)) {
1827  return $parsedComplex;
1828  }
1829 
1830  if ($activeSuffix == '') {
1831  $activeSuffix = $parsedComplex['suffix'];
1832  } elseif (($parsedComplex['suffix'] != '') && ($activeSuffix != $parsedComplex['suffix'])) {
1834  }
1835 
1836  $returnValue['real'] += $parsedComplex['real'];
1837  $returnValue['imaginary'] += $parsedComplex['imaginary'];
1838  }
1839 
1840  if ($returnValue['imaginary'] == 0.0) { $activeSuffix = ''; }
1841  return self::COMPLEX($returnValue['real'],$returnValue['imaginary'],$activeSuffix);
1842  } // function IMSUM()
1843 
1844 
1853  public static function IMPRODUCT() {
1854  // Return value
1855  $returnValue = self::_parseComplex('1');
1856  $activeSuffix = '';
1857 
1858  // Loop through the arguments
1859  $aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
1860  foreach ($aArgs as $arg) {
1861  $parsedComplex = self::_parseComplex($arg);
1862  if (!is_array($parsedComplex)) {
1863  return $parsedComplex;
1864  }
1865  $workValue = $returnValue;
1866  if (($parsedComplex['suffix'] != '') && ($activeSuffix == '')) {
1867  $activeSuffix = $parsedComplex['suffix'];
1868  } elseif (($parsedComplex['suffix'] != '') && ($activeSuffix != $parsedComplex['suffix'])) {
1870  }
1871  $returnValue['real'] = ($workValue['real'] * $parsedComplex['real']) - ($workValue['imaginary'] * $parsedComplex['imaginary']);
1872  $returnValue['imaginary'] = ($workValue['real'] * $parsedComplex['imaginary']) + ($workValue['imaginary'] * $parsedComplex['real']);
1873  }
1874 
1875  if ($returnValue['imaginary'] == 0.0) { $activeSuffix = ''; }
1876  return self::COMPLEX($returnValue['real'],$returnValue['imaginary'],$activeSuffix);
1877  } // function IMPRODUCT()
1878 
1879 
1889  public static function DELTA($a, $b=0) {
1892 
1893  return (int) ($a == $b);
1894  } // function DELTA()
1895 
1896 
1906  public static function GESTEP($number, $step=0) {
1909 
1910  return (int) ($number >= $step);
1911  } // function GESTEP()
1912 
1913 
1914  //
1915  // Private method to calculate the erf value
1916  //
1917  private static $_two_sqrtpi = 1.128379167095512574;
1918 
1919  public static function _erfVal($x) {
1920  if (abs($x) > 2.2) {
1921  return 1 - self::_erfcVal($x);
1922  }
1923  $sum = $term = $x;
1924  $xsqr = ($x * $x);
1925  $j = 1;
1926  do {
1927  $term *= $xsqr / $j;
1928  $sum -= $term / (2 * $j + 1);
1929  ++$j;
1930  $term *= $xsqr / $j;
1931  $sum += $term / (2 * $j + 1);
1932  ++$j;
1933  if ($sum == 0.0) {
1934  break;
1935  }
1936  } while (abs($term / $sum) > PRECISION);
1937  return self::$_two_sqrtpi * $sum;
1938  } // function _erfVal()
1939 
1940 
1951  public static function ERF($lower, $upper = null) {
1954 
1955  if (is_numeric($lower)) {
1956  if ($lower < 0) {
1958  }
1959  if (is_null($upper)) {
1960  return self::_erfVal($lower);
1961  }
1962  if (is_numeric($upper)) {
1963  if ($upper < 0) {
1965  }
1966  return self::_erfVal($upper) - self::_erfVal($lower);
1967  }
1968  }
1970  } // function ERF()
1971 
1972 
1973  //
1974  // Private method to calculate the erfc value
1975  //
1976  private static $_one_sqrtpi = 0.564189583547756287;
1977 
1978  private static function _erfcVal($x) {
1979  if (abs($x) < 2.2) {
1980  return 1 - self::_erfVal($x);
1981  }
1982  if ($x < 0) {
1983  return 2 - self::ERFC(-$x);
1984  }
1985  $a = $n = 1;
1986  $b = $c = $x;
1987  $d = ($x * $x) + 0.5;
1988  $q1 = $q2 = $b / $d;
1989  $t = 0;
1990  do {
1991  $t = $a * $n + $b * $x;
1992  $a = $b;
1993  $b = $t;
1994  $t = $c * $n + $d * $x;
1995  $c = $d;
1996  $d = $t;
1997  $n += 0.5;
1998  $q1 = $q2;
1999  $q2 = $b / $d;
2000  } while ((abs($q1 - $q2) / $q2) > PRECISION);
2001  return self::$_one_sqrtpi * exp(-$x * $x) * $q2;
2002  } // function _erfcVal()
2003 
2004 
2013  public static function ERFC($x) {
2015 
2016  if (is_numeric($x)) {
2017  if ($x < 0) {
2019  }
2020  return self::_erfcVal($x);
2021  }
2023  } // function ERFC()
2024 
2025 
2031  public static function getConversionGroups() {
2032  $conversionGroups = array();
2033  foreach(self::$_conversionUnits as $conversionUnit) {
2034  $conversionGroups[] = $conversionUnit['Group'];
2035  }
2036  return array_merge(array_unique($conversionGroups));
2037  } // function getConversionGroups()
2038 
2039 
2045  public static function getConversionGroupUnits($group = NULL) {
2046  $conversionGroups = array();
2047  foreach(self::$_conversionUnits as $conversionUnit => $conversionGroup) {
2048  if ((is_null($group)) || ($conversionGroup['Group'] == $group)) {
2049  $conversionGroups[$conversionGroup['Group']][] = $conversionUnit;
2050  }
2051  }
2052  return $conversionGroups;
2053  } // function getConversionGroupUnits()
2054 
2055 
2061  public static function getConversionGroupUnitDetails($group = NULL) {
2062  $conversionGroups = array();
2063  foreach(self::$_conversionUnits as $conversionUnit => $conversionGroup) {
2064  if ((is_null($group)) || ($conversionGroup['Group'] == $group)) {
2065  $conversionGroups[$conversionGroup['Group']][] = array( 'unit' => $conversionUnit,
2066  'description' => $conversionGroup['Unit Name']
2067  );
2068  }
2069  }
2070  return $conversionGroups;
2071  } // function getConversionGroupUnitDetails()
2072 
2073 
2079  public static function getConversionMultipliers() {
2081  } // function getConversionGroups()
2082 
2083 
2092  public static function CONVERTUOM($value, $fromUOM, $toUOM) {
2096 
2097  if (!is_numeric($value)) {
2099  }
2100  $fromMultiplier = 1;
2101  if (isset(self::$_conversionUnits[$fromUOM])) {
2102  $unitGroup1 = self::$_conversionUnits[$fromUOM]['Group'];
2103  } else {
2104  $fromMultiplier = substr($fromUOM,0,1);
2105  $fromUOM = substr($fromUOM,1);
2106  if (isset(self::$_conversionMultipliers[$fromMultiplier])) {
2107  $fromMultiplier = self::$_conversionMultipliers[$fromMultiplier]['multiplier'];
2108  } else {
2110  }
2111  if ((isset(self::$_conversionUnits[$fromUOM])) && (self::$_conversionUnits[$fromUOM]['AllowPrefix'])) {
2112  $unitGroup1 = self::$_conversionUnits[$fromUOM]['Group'];
2113  } else {
2115  }
2116  }
2117  $value *= $fromMultiplier;
2118 
2119  $toMultiplier = 1;
2120  if (isset(self::$_conversionUnits[$toUOM])) {
2121  $unitGroup2 = self::$_conversionUnits[$toUOM]['Group'];
2122  } else {
2123  $toMultiplier = substr($toUOM,0,1);
2124  $toUOM = substr($toUOM,1);
2125  if (isset(self::$_conversionMultipliers[$toMultiplier])) {
2126  $toMultiplier = self::$_conversionMultipliers[$toMultiplier]['multiplier'];
2127  } else {
2129  }
2130  if ((isset(self::$_conversionUnits[$toUOM])) && (self::$_conversionUnits[$toUOM]['AllowPrefix'])) {
2131  $unitGroup2 = self::$_conversionUnits[$toUOM]['Group'];
2132  } else {
2134  }
2135  }
2136  if ($unitGroup1 != $unitGroup2) {
2138  }
2139 
2140  if ($fromUOM == $toUOM) {
2141  return 1.0;
2142  } elseif ($unitGroup1 == 'Temperature') {
2143  if (($fromUOM == 'F') || ($fromUOM == 'fah')) {
2144  if (($toUOM == 'F') || ($toUOM == 'fah')) {
2145  return 1.0;
2146  } else {
2147  $value = (($value - 32) / 1.8);
2148  if (($toUOM == 'K') || ($toUOM == 'kel')) {
2149  $value += 273.15;
2150  }
2151  return $value;
2152  }
2153  } elseif ((($fromUOM == 'K') || ($fromUOM == 'kel')) &&
2154  (($toUOM == 'K') || ($toUOM == 'kel'))) {
2155  return 1.0;
2156  } elseif ((($fromUOM == 'C') || ($fromUOM == 'cel')) &&
2157  (($toUOM == 'C') || ($toUOM == 'cel'))) {
2158  return 1.0;
2159  }
2160  if (($toUOM == 'F') || ($toUOM == 'fah')) {
2161  if (($fromUOM == 'K') || ($fromUOM == 'kel')) {
2162  $value -= 273.15;
2163  }
2164  return ($value * 1.8) + 32;
2165  }
2166  if (($toUOM == 'C') || ($toUOM == 'cel')) {
2167  return $value - 273.15;
2168  }
2169  return $value + 273.15;
2170  }
2171  return ($value * self::$_unitConversions[$unitGroup1][$fromUOM][$toUOM]) / $toMultiplier;
2172  } // function CONVERTUOM()
2173 
2174 } // class PHPExcel_Calculation_Engineering