30 if (!defined(
'PHPEXCEL_ROOT')) {
34 define(
'PHPEXCEL_ROOT', dirname(__FILE__) .
'/../../');
35 require(PHPEXCEL_ROOT .
'PHPExcel/Autoloader.php');
40 define(
'EULER', 2.71828182845904523536);
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 )
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' )
140 'sg' => 6.85220500053478E-05,
141 'lbm' => 2.20462291469134E-03,
142 'u' => 6.02217000000000E+23,
143 'ozm' => 3.52739718003627E-02
145 'sg' => array(
'g' => 1.45938424189287E+04,
147 'lbm' => 3.21739194101647E+01,
148 'u' => 8.78866000000000E+27,
149 'ozm' => 5.14782785944229E+02
151 'lbm' => array(
'g' => 4.5359230974881148E+02,
152 'sg' => 3.10810749306493E-02,
154 'u' => 2.73161000000000E+26,
155 'ozm' => 1.60000023429410E+01
157 'u' => array(
'g' => 1.66053100460465E-24,
158 'sg' => 1.13782988532950E-28,
159 'lbm' => 3.66084470330684E-27,
161 'ozm' => 5.85735238300524E-26
163 'ozm' => array(
'g' => 2.83495152079732E+01,
164 'sg' => 1.94256689870811E-03,
165 'lbm' => 6.24999908478882E-02,
166 'u' => 1.70725600000000E+25,
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
179 'mi' => array(
'm' => 1.60934400000000E+03,
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
188 'Nmi' => array(
'm' => 1.85200000000000E+03,
189 'mi' => 1.15077944802354E+00,
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
197 'in' => array(
'm' => 2.54000000000000E-02,
198 'mi' => 1.57828282828283E-05,
199 'Nmi' => 1.37149028077754E-05,
201 'ft' => 8.33333333333333E-02,
202 'yd' => 2.77777777686643E-02,
203 'ang' => 2.54000000000000E+08,
204 'Pica' => 7.19999999999955E+01
206 'ft' => array(
'm' => 3.04800000000000E-01,
207 'mi' => 1.89393939393939E-04,
208 'Nmi' => 1.64578833693305E-04,
209 'in' => 1.20000000000000E+01,
211 'yd' => 3.33333333223972E-01,
212 'ang' => 3.04800000000000E+09,
213 'Pica' => 8.63999999999946E+02
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,
221 'ang' => 9.14400000300000E+09,
222 'Pica' => 2.59200000085023E+03
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,
231 'Pica' => 2.83464566929116E-07
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,
243 'Time' => array(
'yr' => array(
'yr' => 1.0,
249 'day' => array(
'yr' => 2.73785078713210E-03,
255 'hr' => array(
'yr' => 1.14077116130504E-04,
256 'day' => 4.16666666666667E-02,
261 'mn' => array(
'yr' => 1.90128526884174E-06,
262 'day' => 6.94444444444444E-04,
263 'hr' => 1.66666666666667E-02,
267 'sec' => array(
'yr' => 3.16880878140289E-08,
268 'day' => 1.15740740740741E-05,
269 'hr' => 2.77777777777778E-04,
270 'mn' => 1.66666666666667E-02,
274 'Pressure' => array(
'Pa' => array(
'Pa' => 1.0,
276 'atm' => 9.86923299998193E-06,
277 'at' => 9.86923299998193E-06,
278 'mmHg' => 7.50061707998627E-03
280 'p' => array(
'Pa' => 1.0,
282 'atm' => 9.86923299998193E-06,
283 'at' => 9.86923299998193E-06,
284 'mmHg' => 7.50061707998627E-03
286 'atm' => array(
'Pa' => 1.01324996583000E+05,
287 'p' => 1.01324996583000E+05,
292 'at' => array(
'Pa' => 1.01324996583000E+05,
293 'p' => 1.01324996583000E+05,
298 'mmHg' => array(
'Pa' => 1.33322363925000E+02,
299 'p' => 1.33322363925000E+02,
300 'atm' => 1.31578947368421E-03,
301 'at' => 1.31578947368421E-03,
305 'Force' => array(
'N' => array(
'N' => 1.0,
308 'lbf' => 2.24808923655339E-01
310 'dyn' => array(
'N' => 1.0E-5,
313 'lbf' => 2.24808923655339E-06
315 'dy' => array(
'N' => 1.0E-5,
318 'lbf' => 2.24808923655339E-06
320 'lbf' => array(
'N' => 4.448222,
321 'dyn' => 4.448222E+5,
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
340 'e' => array(
'J' => 1.00000048065700E-07,
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
354 'c' => array(
'J' => 4.18399101363672E+00,
355 'e' => 4.18398900257312E+07,
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
368 'cal' => array(
'J' => 4.18679484613929E+00,
369 'e' => 4.18679283372801E+07,
370 'c' => 1.00067013349059E+00,
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
382 'eV' => array(
'J' => 1.60219000146921E-19,
383 'e' => 1.60218923136574E-12,
384 'c' => 3.82933423195043E-20,
385 'cal' => 3.82676978535648E-20,
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
396 'ev' => array(
'J' => 1.60219000146921E-19,
397 'e' => 1.60218923136574E-12,
398 'c' => 3.82933423195043E-20,
399 'cal' => 3.82676978535648E-20,
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
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,
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
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,
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
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,
448 'flb' => 8.54294774062316E+04,
449 'BTU' => 3.41213254164705E+00,
450 'btu' => 3.41213254164705E+00
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,
462 'flb' => 8.54294774062316E+04,
463 'BTU' => 3.41213254164705E+00,
464 'btu' => 3.41213254164705E+00
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,
477 'BTU' => 3.99409272448406E-05,
478 'btu' => 3.99409272448406E-05
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,
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,
509 'Power' => array(
'HP' => array(
'HP' => 1.0,
511 'W' => 7.45701000000000E+02,
512 'w' => 7.45701000000000E+02
514 'h' => array(
'HP' => 1.0,
516 'W' => 7.45701000000000E+02,
517 'w' => 7.45701000000000E+02
519 'W' => array(
'HP' => 1.34102006031908E-03,
520 'h' => 1.34102006031908E-03,
524 'w' => array(
'HP' => 1.34102006031908E-03,
525 'h' => 1.34102006031908E-03,
530 'Magnetism' => array(
'T' => array(
'T' => 1.0,
533 'ga' => array(
'T' => 0.0001,
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
549 'tbs' => array(
'tsp' => 3.00000000000000E+00,
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
561 'oz' => array(
'tsp' => 6.00000000000000E+00,
562 'tbs' => 2.00000000000000E+00,
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
573 'cup' => array(
'tsp' => 4.80000000000000E+01,
574 'tbs' => 1.60000000000000E+01,
575 'oz' => 8.00000000000000E+00,
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
585 'pt' => array(
'tsp' => 9.60000000000000E+01,
586 'tbs' => 3.20000000000000E+01,
587 'oz' => 1.60000000000000E+01,
588 'cup' => 2.00000000000000E+00,
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
597 'us_pt' => array(
'tsp' => 9.60000000000000E+01,
598 'tbs' => 3.20000000000000E+01,
599 'oz' => 1.60000000000000E+01,
600 'cup' => 2.00000000000000E+00,
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
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,
616 'qt' => 6.00343750000000E-01,
617 'gal' => 1.50085937500000E-01,
618 'l' => 5.68260698087162E-01,
619 'lt' => 5.68260698087162E-01
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,
629 'gal' => 2.50000000000000E-01,
630 'l' => 9.46558864129363E-01,
631 'lt' => 9.46558864129363E-01
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,
642 'l' => 3.78623545651745E+00,
643 'lt' => 3.78623545651745E+00
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,
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,
674 $workString = (string) $complexNumber;
676 $realNumber = $imaginary = 0;
678 $suffix = substr($workString,-1);
679 if (!is_numeric($suffix)) {
680 $workString = substr($workString,0,-1);
687 if (strlen($workString) > 0) {
688 $leadingSign = (($workString{0} ==
'+') || ($workString{0} ==
'-')) ? 1 : 0;
691 $realNumber = strtok($workString,
'+-');
692 if (strtoupper(substr($realNumber,-1)) ==
'E') {
693 $power = strtok(
'+-');
697 $realNumber = substr($workString,0,strlen($realNumber)+strlen($power)+$leadingSign);
700 $imaginary = substr($workString,strlen($realNumber));
702 if (($imaginary ==
'') && (($realNumber ==
'') || ($realNumber ==
'+') || ($realNumber ==
'-'))) {
703 $imaginary = $realNumber.
'1';
705 }
else if ($imaginary ==
'') {
706 $imaginary = $realNumber;
708 } elseif (($imaginary ==
'+') || ($imaginary ==
'-')) {
713 return array(
'real' => $realNumber,
714 'imaginary' => $imaginary,
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;
730 if (!is_null($places)) {
731 if (strlen($xVal) <= $places) {
732 return substr(str_pad($xVal,$places,
'0',STR_PAD_LEFT),-10);
738 return substr($xVal,-10);
755 if ((is_numeric(
$x)) && (is_numeric($n))) {
766 $fSqrX = (
$x *
$x) / 4;
769 $fTerm /= ($nK * ($nK + $n));
771 }
while ((abs($fTerm) > 1e-10) && (++$nK < 100));
774 $fResult = exp($fXAbs) / sqrt($f_2_PI * $fXAbs);
775 if (($n && 1) && (
$x < 0)) {
776 $fResult = -$fResult;
798 if ((is_numeric(
$x)) && (is_numeric($n))) {
803 $f_PI_DIV_2 = M_PI / 2;
804 $f_PI_DIV_4 = M_PI / 4;
811 $fSqrX = (
$x *
$x) / -4;
814 $fTerm /= ($nK * ($nK + $n));
816 }
while ((abs($fTerm) > 1e-10) && (++$nK < 100));
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;
832 $fNum2 = $fNum * 0.5;
833 $y = ($fNum2 * $fNum2);
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))))));
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))))));
849 $fNum2 = $fNum * 0.5;
850 $y = ($fNum2 * $fNum2);
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;
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)))))));
877 if ((is_numeric(
$x)) && (is_numeric($ord))) {
878 if (($ord < 0) || (
$x == 0.0)) {
882 switch(floor($ord)) {
887 default : $fTox = 2 /
$x;
890 for ($n = 1; $n < $ord; ++$n) {
891 $fBkp = $fBkm + $n * $fTox * $fBk;
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))));
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);
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)))));
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.
955 if ((is_numeric(
$x)) && (is_numeric($ord))) {
956 if (($ord < 0) || (
$x == 0.0)) {
960 switch(floor($ord)) {
965 default: $fTox = 2 /
$x;
968 for ($n = 1; $n < $ord; ++$n) {
969 $fByp = $n * $fTox * $fBy - $fBym;
1002 if (strlen(
$x) > preg_match_all(
'/[01]/',
$x,
$out)) {
1005 if (strlen(
$x) > 10) {
1007 } elseif (strlen(
$x) == 10) {
1010 return '-'.(512-bindec(
$x));
1039 if (strlen(
$x) > preg_match_all(
'/[01]/',
$x,
$out)) {
1042 if (strlen(
$x) > 10) {
1044 } elseif (strlen(
$x) == 10) {
1046 return str_repeat(
'F',8).substr(strtoupper(dechex(bindec(substr(
$x,-9)))),-2);
1048 $hexVal = (string) strtoupper(dechex(bindec(
$x)));
1077 if (strlen(
$x) > preg_match_all(
'/[01]/',
$x,
$out)) {
1080 if (strlen(
$x) > 10) {
1082 } elseif (strlen(
$x) == 10) {
1084 return str_repeat(
'7',7).substr(strtoupper(decoct(bindec(substr(
$x,-9)))),-3);
1086 $octVal = (string) decoct(bindec(
$x));
1112 if (strlen(
$x) > preg_match_all(
'/[-0123456789.]/',
$x,
$out)) {
1115 $x = (string) floor(
$x);
1117 if (strlen($r) == 32) {
1119 $r = substr($r,-10);
1120 } elseif (strlen($r) > 11) {
1148 if (strlen(
$x) > preg_match_all(
'/[-0123456789.]/',
$x,
$out)) {
1151 $x = (string) floor(
$x);
1152 $r = strtoupper(dechex(
$x));
1153 if (strlen($r) == 8) {
1182 if (strlen(
$x) > preg_match_all(
'/[-0123456789.]/',
$x,
$out)) {
1185 $x = (string) floor(
$x);
1187 if (strlen($r) == 11) {
1189 $r = substr($r,-10);
1212 if (strlen(
$x) > preg_match_all(
'/[0123456789ABCDEF]/',strtoupper(
$x),
$out)) {
1215 $binVal = decbin(hexdec(
$x));
1217 return substr(self::_nbrConversionFormat($binVal,$places),-10);
1236 if (strlen(
$x) > preg_match_all(
'/[0123456789ABCDEF]/',strtoupper(
$x),
$out)) {
1259 if (strlen(
$x) > preg_match_all(
'/[0123456789ABCDEF]/',strtoupper(
$x),
$out)) {
1262 $octVal = decoct(hexdec(
$x));
1284 if (preg_match_all(
'/[01234567]/',
$x,
$out) != strlen(
$x)) {
1287 $r = decbin(octdec(
$x));
1308 if (preg_match_all(
'/[01234567]/',
$x,
$out) != strlen(
$x)) {
1331 if (preg_match_all(
'/[01234567]/',
$x,
$out) != strlen(
$x)) {
1334 $hexVal = strtoupper(dechex(octdec(
$x)));
1350 public static function COMPLEX($realNumber=0.0, $imaginary=0.0, $suffix=
'i') {
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;
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;
1374 if ($imaginary > 0) { $imaginary = (string)
'+'.$imaginary; }
1375 return (
string) $realNumber.$imaginary.$suffix;
1394 if (!is_array($parsedComplex)) {
1395 return $parsedComplex;
1397 return $parsedComplex[
'imaginary'];
1409 public static function IMREAL($complexNumber) {
1413 if (!is_array($parsedComplex)) {
1414 return $parsedComplex;
1416 return $parsedComplex[
'real'];
1428 public static function IMABS($complexNumber) {
1432 if (!is_array($parsedComplex)) {
1433 return $parsedComplex;
1435 return sqrt(($parsedComplex[
'real'] * $parsedComplex[
'real']) + ($parsedComplex[
'imaginary'] * $parsedComplex[
'imaginary']));
1451 if (!is_array($parsedComplex)) {
1452 return $parsedComplex;
1455 if ($parsedComplex[
'real'] == 0.0) {
1456 if ($parsedComplex[
'imaginary'] == 0.0) {
1458 } elseif($parsedComplex[
'imaginary'] < 0.0) {
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'])));
1468 return M_PI - atan($parsedComplex[
'imaginary'] / abs($parsedComplex[
'real']));
1486 if (!is_array($parsedComplex)) {
1487 return $parsedComplex;
1490 if ($parsedComplex[
'imaginary'] == 0.0) {
1491 return $parsedComplex[
'real'];
1493 return self::_cleanComplex(self::COMPLEX($parsedComplex[
'real'], 0 - $parsedComplex[
'imaginary'], $parsedComplex[
'suffix']));
1506 public static function IMCOS($complexNumber) {
1510 if (!is_array($parsedComplex)) {
1511 return $parsedComplex;
1514 if ($parsedComplex[
'imaginary'] == 0.0) {
1515 return cos($parsedComplex[
'real']);
1517 return self::IMCONJUGATE(self::COMPLEX(cos($parsedComplex[
'real']) * cosh($parsedComplex[
'imaginary']),sin($parsedComplex[
'real']) * sinh($parsedComplex[
'imaginary']),$parsedComplex[
'suffix']));
1530 public static function IMSIN($complexNumber) {
1534 if (!is_array($parsedComplex)) {
1535 return $parsedComplex;
1538 if ($parsedComplex[
'imaginary'] == 0.0) {
1539 return sin($parsedComplex[
'real']);
1541 return self::COMPLEX(sin($parsedComplex[
'real']) * cosh($parsedComplex[
'imaginary']),cos($parsedComplex[
'real']) * sinh($parsedComplex[
'imaginary']),$parsedComplex[
'suffix']);
1554 public static function IMSQRT($complexNumber) {
1558 if (!is_array($parsedComplex)) {
1559 return $parsedComplex;
1563 $d1 = cos($theta / 2);
1564 $d2 = sin($theta / 2);
1565 $r = sqrt(sqrt(($parsedComplex[
'real'] * $parsedComplex[
'real']) + ($parsedComplex[
'imaginary'] * $parsedComplex[
'imaginary'])));
1567 if ($parsedComplex[
'suffix'] ==
'') {
1570 return self::COMPLEX($d1 * $r,$d2 * $r,$parsedComplex[
'suffix']);
1583 public static function IMLN($complexNumber) {
1587 if (!is_array($parsedComplex)) {
1588 return $parsedComplex;
1591 if (($parsedComplex[
'real'] == 0.0) && ($parsedComplex[
'imaginary'] == 0.0)) {
1595 $logR = log(sqrt(($parsedComplex[
'real'] * $parsedComplex[
'real']) + ($parsedComplex[
'imaginary'] * $parsedComplex[
'imaginary'])));
1598 if ($parsedComplex[
'suffix'] ==
'') {
1618 if (!is_array($parsedComplex)) {
1619 return $parsedComplex;
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']);
1640 public static function IMLOG2($complexNumber) {
1644 if (!is_array($parsedComplex)) {
1645 return $parsedComplex;
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);
1666 public static function IMEXP($complexNumber) {
1670 if (!is_array($parsedComplex)) {
1671 return $parsedComplex;
1674 if (($parsedComplex[
'real'] == 0.0) && ($parsedComplex[
'imaginary'] == 0.0)) {
1678 $e = exp($parsedComplex[
'real']);
1679 $eX = $e * cos($parsedComplex[
'imaginary']);
1680 $eY = $e * sin($parsedComplex[
'imaginary']);
1682 if ($parsedComplex[
'suffix'] ==
'') {
1698 public static function IMPOWER($complexNumber,$realNumber) {
1702 if (!is_numeric($realNumber)) {
1707 if (!is_array($parsedComplex)) {
1708 return $parsedComplex;
1711 $r = sqrt(($parsedComplex[
'real'] * $parsedComplex[
'real']) + ($parsedComplex[
'imaginary'] * $parsedComplex[
'imaginary']));
1712 $rPower = pow($r,$realNumber);
1716 } elseif ($parsedComplex[
'imaginary'] == 0.0) {
1717 return self::COMPLEX($rPower * cos($theta),$rPower * sin($theta),$parsedComplex[
'suffix']);
1719 return self::COMPLEX($rPower * cos($theta),$rPower * sin($theta),$parsedComplex[
'suffix']);
1733 public static function IMDIV($complexDividend,$complexDivisor) {
1738 if (!is_array($parsedComplexDividend)) {
1739 return $parsedComplexDividend;
1743 if (!is_array($parsedComplexDivisor)) {
1744 return $parsedComplexDividend;
1747 if (($parsedComplexDividend[
'suffix'] !=
'') && ($parsedComplexDivisor[
'suffix'] !=
'') &&
1748 ($parsedComplexDividend[
'suffix'] != $parsedComplexDivisor[
'suffix'])) {
1751 if (($parsedComplexDividend[
'suffix'] !=
'') && ($parsedComplexDivisor[
'suffix'] ==
'')) {
1752 $parsedComplexDivisor[
'suffix'] = $parsedComplexDividend[
'suffix'];
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']);
1764 } elseif ($i < 0.0) {
1781 public static function IMSUB($complexNumber1,$complexNumber2) {
1786 if (!is_array($parsedComplex1)) {
1787 return $parsedComplex1;
1791 if (!is_array($parsedComplex2)) {
1792 return $parsedComplex2;
1795 if ((($parsedComplex1[
'suffix'] !=
'') && ($parsedComplex2[
'suffix'] !=
'')) &&
1796 ($parsedComplex1[
'suffix'] != $parsedComplex2[
'suffix'])) {
1798 } elseif (($parsedComplex1[
'suffix'] ==
'') && ($parsedComplex2[
'suffix'] !=
'')) {
1799 $parsedComplex1[
'suffix'] = $parsedComplex2[
'suffix'];
1802 $d1 = $parsedComplex1[
'real'] - $parsedComplex2[
'real'];
1803 $d2 = $parsedComplex1[
'imaginary'] - $parsedComplex2[
'imaginary'];
1824 foreach ($aArgs as
$arg) {
1826 if (!is_array($parsedComplex)) {
1827 return $parsedComplex;
1830 if ($activeSuffix ==
'') {
1831 $activeSuffix = $parsedComplex[
'suffix'];
1832 } elseif (($parsedComplex[
'suffix'] !=
'') && ($activeSuffix != $parsedComplex[
'suffix'])) {
1836 $returnValue[
'real'] += $parsedComplex[
'real'];
1837 $returnValue[
'imaginary'] += $parsedComplex[
'imaginary'];
1840 if ($returnValue[
'imaginary'] == 0.0) { $activeSuffix =
''; }
1841 return self::COMPLEX($returnValue[
'real'],$returnValue[
'imaginary'],$activeSuffix);
1860 foreach ($aArgs as
$arg) {
1862 if (!is_array($parsedComplex)) {
1863 return $parsedComplex;
1865 $workValue = $returnValue;
1866 if (($parsedComplex[
'suffix'] !=
'') && ($activeSuffix ==
'')) {
1867 $activeSuffix = $parsedComplex[
'suffix'];
1868 } elseif (($parsedComplex[
'suffix'] !=
'') && ($activeSuffix != $parsedComplex[
'suffix'])) {
1871 $returnValue[
'real'] = ($workValue[
'real'] * $parsedComplex[
'real']) - ($workValue[
'imaginary'] * $parsedComplex[
'imaginary']);
1872 $returnValue[
'imaginary'] = ($workValue[
'real'] * $parsedComplex[
'imaginary']) + ($workValue[
'imaginary'] * $parsedComplex[
'real']);
1875 if ($returnValue[
'imaginary'] == 0.0) { $activeSuffix =
''; }
1876 return self::COMPLEX($returnValue[
'real'],$returnValue[
'imaginary'],$activeSuffix);
1889 public static function DELTA($a, $b=0) {
1893 return (
int) ($a == $b);
1906 public static function GESTEP($number, $step=0) {
1910 return (
int) ($number >= $step);
1920 if (abs(
$x) > 2.2) {
1927 $term *= $xsqr / $j;
1928 $sum -= $term / (2 * $j + 1);
1930 $term *= $xsqr / $j;
1931 $sum += $term / (2 * $j + 1);
1936 }
while (abs($term / $sum) >
PRECISION);
1937 return self::$_two_sqrtpi * $sum;
1951 public static function ERF($lower, $upper = null) {
1955 if (is_numeric($lower)) {
1959 if (is_null($upper)) {
1962 if (is_numeric($upper)) {
1979 if (abs(
$x) < 2.2) {
1988 $q1 = $q2 = $b /
$d;
1991 $t = $a * $n + $b *
$x;
2000 }
while ((abs($q1 - $q2) / $q2) >
PRECISION);
2001 return self::$_one_sqrtpi * exp(-
$x *
$x) * $q2;
2016 if (is_numeric(
$x)) {
2032 $conversionGroups = array();
2033 foreach(self::$_conversionUnits as $conversionUnit) {
2034 $conversionGroups[] = $conversionUnit[
'Group'];
2036 return array_merge(array_unique($conversionGroups));
2046 $conversionGroups = array();
2047 foreach(self::$_conversionUnits as $conversionUnit => $conversionGroup) {
2048 if ((is_null($group)) || ($conversionGroup[
'Group'] == $group)) {
2049 $conversionGroups[$conversionGroup[
'Group']][] = $conversionUnit;
2052 return $conversionGroups;
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']
2070 return $conversionGroups;
2097 if (!is_numeric($value)) {
2100 $fromMultiplier = 1;
2101 if (isset(self::$_conversionUnits[$fromUOM])) {
2102 $unitGroup1 = self::$_conversionUnits[$fromUOM][
'Group'];
2104 $fromMultiplier = substr($fromUOM,0,1);
2105 $fromUOM = substr($fromUOM,1);
2106 if (isset(self::$_conversionMultipliers[$fromMultiplier])) {
2107 $fromMultiplier = self::$_conversionMultipliers[$fromMultiplier][
'multiplier'];
2111 if ((isset(self::$_conversionUnits[$fromUOM])) && (self::$_conversionUnits[$fromUOM][
'AllowPrefix'])) {
2112 $unitGroup1 = self::$_conversionUnits[$fromUOM][
'Group'];
2117 $value *= $fromMultiplier;
2120 if (isset(self::$_conversionUnits[$toUOM])) {
2121 $unitGroup2 = self::$_conversionUnits[$toUOM][
'Group'];
2123 $toMultiplier = substr($toUOM,0,1);
2124 $toUOM = substr($toUOM,1);
2125 if (isset(self::$_conversionMultipliers[$toMultiplier])) {
2126 $toMultiplier = self::$_conversionMultipliers[$toMultiplier][
'multiplier'];
2130 if ((isset(self::$_conversionUnits[$toUOM])) && (self::$_conversionUnits[$toUOM][
'AllowPrefix'])) {
2131 $unitGroup2 = self::$_conversionUnits[$toUOM][
'Group'];
2136 if ($unitGroup1 != $unitGroup2) {
2140 if ($fromUOM == $toUOM) {
2142 } elseif ($unitGroup1 ==
'Temperature') {
2143 if (($fromUOM ==
'F') || ($fromUOM ==
'fah')) {
2144 if (($toUOM ==
'F') || ($toUOM ==
'fah')) {
2147 $value = (($value - 32) / 1.8);
2148 if (($toUOM ==
'K') || ($toUOM ==
'kel')) {
2153 } elseif ((($fromUOM ==
'K') || ($fromUOM ==
'kel')) &&
2154 (($toUOM ==
'K') || ($toUOM ==
'kel'))) {
2156 } elseif ((($fromUOM ==
'C') || ($fromUOM ==
'cel')) &&
2157 (($toUOM ==
'C') || ($toUOM ==
'cel'))) {
2160 if (($toUOM ==
'F') || ($toUOM ==
'fah')) {
2161 if (($fromUOM ==
'K') || ($fromUOM ==
'kel')) {
2164 return ($value * 1.8) + 32;
2166 if (($toUOM ==
'C') || ($toUOM ==
'cel')) {
2167 return $value - 273.15;
2169 return $value + 273.15;
2171 return ($value * self::$_unitConversions[$unitGroup1][$fromUOM][$toUOM]) / $toMultiplier;