casacore
Constants.h
Go to the documentation of this file.
1 //# Constants.h: Mathematical and numerical constants
2 //# Copyright (C) 1993,1994,1995,1997,1998,1999,2000,2001
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id$
27 
28 #ifndef CASA_CONSTANTS_H
29 #define CASA_CONSTANTS_H
30 
31 #include <casacore/casa/aips.h>
32 
33 #if defined (sun) && ! defined (AIPS_SOLARIS)
34 # include <sys/limits.h>
35 #else
36 # include <limits.h>
37 #endif
38 
39 #include <float.h>
40 #if !defined(AIPS_DARWIN) && !defined(AIPS_BSD)
41 #include <values.h>
42 #endif
43 
44 #if defined (AIPS_OSF)
45 # define LN_MAXFLOAT (M_LN2 * FMAXEXP)
46 # define LN_MINFLOAT (M_LN2 * (FMINEXP -1))
47 #endif
48 
49 namespace casacore { //# NAMESPACE CASACORE - BEGIN
50 
51 // <summary>Mathematical and numerical constants.</summary>
52 
53 // <use visibility=export>
54 
55 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tConstants" demos="">
56 
57 //# // <prerequisite>
58 //# // </prerequisite>
59 
60 //# // <etymology>
61 //# // </etymology>
62 
63 // <synopsis>
64 // The constants and conversion factors are defined here as double precision
65 // values. Where single precision calculations are done in a situation where
66 // processing speed is of concern, for example within the inner loop of an
67 // expensive algorithm, a separate single precision variable should be defined
68 // for use within the loop.
69 //
70 // </synopsis>
71 //
72 // <note role=warning> The following list is generated by hand, and may be incomplete.
73 // After future revision of ccx2html the real data will be displayed </note>
74 
75 // <h3>Floating point limits</h3>
76 // <srcblock>
77 // flt_min the minimum single precision floating point number,
78 // excluding denormalised numbers
79 // minfloat the minimum single precision floating point number,
80 // including denormalised numbers
81 // dbl_min the minimum double precision floating point number,
82 // excluding denormalised numbers
83 // mindouble the minimum double precision floating point number,
84 // including denormalised numbers
85 // flt_max the maximum single precision floating point number
86 // dbl_max the maximum double precision floating point number
87 // flt_epsilon Minimum single precision floating point number X
88 // such that 1+X does not equal X
89 // dbl_epsilon Minimum double precision floating point number X
90 // such that 1+X does not equal X
91 // </srcblock>
92 // <h3> Irrationals </h3>
93 // <srcblock>
94 // sqrt2 sqrt(2)
95 // sqrt3 sqrt(3)
96 // _1_sqrt2 1/sqrt(2)
97 // _1_sqrt3 1/sqrt(3)
98 // </srcblock>
99 
100 // <h3>Pi and functions thereof</h3>
101 // <srcblock>
102 // pi pi
103 // _2pi 2*pi
104 // pi_2 pi/2
105 // pi_4 pi/4
106 // _1_pi 1/pi
107 // _2_pi 2/pi
108 // _1_sqrtpi 1/sqrt(pi)
109 // _2_sqrtpi 2/sqrt(pi)
110 // </srcblock>
111 
112 // <h3>e and functions thereof</h3>
113 // <srcblock>
114 // e e
115 // ln2 ln(2)
116 // ln10 ln(10)
117 // log2e log2(e)
118 // log10e log10(e)
119 // </srcblock>
120 
121 // <h3>gamma and functions thereof</h3>
122 // <srcblock>
123 // gamma gamma
124 // lngamma ln(gamma)
125 // etogamma e**gamma
126 // </srcblock>
127 
128 // <h3>Fundamental physical constants (SI units)</h3>
129 // <note role=warning> Preserved for legacy reasons only.
130 // See <linkto class=QC>QC class</linkto> for other physical constants. </note>
131 // <srcblock>
132 // c velocity of light (m/s)
133 // </srcblock>
134 
135 // <h3>Numerical conversion factors</h3>
136 // <srcblock>
137 // yotta e+24 (Y)
138 // zetta e+21 (Z)
139 // exa e+18 (E)
140 // peta e+15 (P)
141 // tera e+12 (T)
142 // giga e+09 (G)
143 // mega e+06 (M)
144 // kilo e+03 (k)
145 // hecto e+02 (h)
146 // deka e+01 (da)
147 // deci e-01 (d)
148 // centi e-02 (c)
149 // milli e-03 (m)
150 // micro e-06 (u)
151 // nano e-09 (n)
152 // pico e-12 (p)
153 // femto e-15 (f)
154 // atto e-18 (a)
155 // zepto e-21 (z)
156 // yocto e-24 (y)
157 // </srcblock>
158 
159 // <h3>Angular measure</h3>
160 // <srcblock>
161 // radian radian
162 // circle circle
163 // degree degree
164 // arcmin arcminute
165 // arcsec arcsecond
166 // </srcblock>
167 
168 // <h3>Solid angular measure</h3>
169 // <srcblock>
170 // steradian steradian
171 // sphere sphere
172 // square_degree square degree
173 // square_arcmin square arcminute
174 // square_arcsec square arcsecond
175 // </srcblock>
176 
177 // <h3>Time interval</h3>
178 // <srcblock>
179 // second second
180 // minute minute
181 // hour hour
182 // day day
183 // </srcblock>
184 
185 // <h3> Machine constants </h3>
186 //
187 // Implementation-defined limits usually defined in <src><limits.h></src>,
188 // <src><float.h></src>, and <src><values.h></src> as preprocessor
189 // defines. They are
190 // Inclusion of <src><casa/BasicSL/Constants.h</src> is
191 // sufficient to ensure that they are defined for any particular
192 // implementation, and the correct functioning of the <src>tConstants</src>
193 // test program guarantees this.
194 //
195 // In future use will be made of the (standard) <em>numeric_limits</em>
196 // template from the <src><limits></src> include file.
197 
198 // <srcblock>
199 //
200 // Refer to Section 3.2c, pp28-30 of
201 // "The Annotated C++ Reference Manual",
202 // Ellis, M.A., and Stroustrup, B.,
203 // Addison-Wesley Publishing Company, 1990.
204 // IBSN 0-201-51459-1.
205 //
206 // and
207 //
208 // Appendix B11, pp257-8 of
209 // "The C Programming Language", 2nd ed.,
210 // Kernighan, B.W., and Ritchie, D.M.,
211 // Prentice Hall Software Series, 1988.
212 // IBSN 0-13-110362-8.
213 //
214 // </srcblock>
215 
216 // <h3> Constants defined in limits.h </h3>
217 // (these are part of the ANSI C and hence POSIX standards).
218 // Acceptable limits defined by the standard are quoted.
219 // <srcblock>
220 //
221 // CHAR_BIT 8 Maximum bits in a byte.
222 // CHAR_MIN 0 or Minimum value of 'char'.
223 // SCHAR_MIN
224 // CHAR_MAX UCHAR_MAX or Maximum value of 'char'.
225 // SCHAR_MAX
226 // SCHAR_MIN -127 Minimum value of 'signed char'.
227 // SCHAR_MAX +127 Maximum value of 'signed char'.
228 // UCHAR_MAX 255 Maximum value of 'unsigned char'.
229 // MB_LEN_MAX Maximum bytes in multibyte character.
230 //
231 // SHRT_MIN -32767 Minimum value of 'short'.
232 // SHRT_MAX +32767 Maximum value of 'short'.
233 // USHRT_MAX 65535 Maximum value of 'unsigned short'.
234 //
235 // INT_MIN -32767 Minimum value of 'int'.
236 // INT_MAX +32767 Maximum value of 'int'.
237 // UINT_MAX 65535 Maximum value of 'unsigned int'.
238 //
239 // LONG_MIN -2147483647 Minimum value of 'long'.
240 // LONG_MAX +2147483647 Maximum value of 'long'.
241 // ULONG_MAX 4294967295 Maximum value of 'unsigned long'.
242 //
243 // </srcblock>
244 
245 // <h3> Constants defined in float.h </h3>
246 // (these are part of the ANSI C and hence POSIX standards).
247 // Acceptable limits defined by the standard are quoted.
248 // <srcblock>
249 //
250 // FLT_RADIX 2 Radix of exponent representation.
251 // FLT_ROUNDS Floating point rounding mode for addition
252 // -1: indeterminate
253 // 0: towards zero
254 // 1: to nearest
255 // 2: toward +infinity
256 // 3: toward -infinity
257 //
258 // FLT_MIN_EXP Minimum negative integer N such that FLT_RADIX
259 // DBL_MIN_EXP raised to the Nth minus 1 is a normalized
260 // LDBL_MIN_EXP floating point number.
261 //
262 // FLT_MAX_EXP Maximum integer N such that FLT_RADIX raised to
263 // DBL_MAX_EXP the Nth minus 1 is representable.
264 // LDBL_MAX_EXP
265 //
266 // FLT_MIN_10_EXP -37 Minimum negative integer N such that 10 raised
267 // DBL_MIN_10_EXP -37 to the Nth is in the range of normalized
268 // LDBL_MIN_10_EXP -37 floating point numbers.
269 //
270 // FLT_MAX_10_EXP 37 Maximum integer N such that 10 raised to the
271 // DBL_MAX_10_EXP 37 Nth minus 1 is representable.
272 // LDBL_MAX_10_EXP 37
273 //
274 // FLT_MANT_DIG Number of base FLT_RADIX digits in mantissa.
275 // DBL_MANT_DIG
276 // LDBL_MANT_DIG
277 //
278 // FLT_DIG 6 Decimal digits of precision.
279 // DBL_DIG 10
280 // LDBL_DIG 10
281 //
282 // FLT_EPSILON 1E-5 Minimum floating point number X such that
283 // (use C::flt_epsilon in preference to this)
284 // DBL_EPSILON 1E-9 1.0 + X does not equal 1.0.
285 // (use C::dbl_epsilon in preference to this)
286 // LDBL_EPSILON 1E-9
287 //
288 // FLT_MIN 1E-37 Minimum normalized positive floating point
289 // (use C::flt_min in preference to this)
290 // DBL_MIN 1E-37 number
291 // (use C::dbl_min in preference to this)
292 // LDBL_MIN 1E-37
293 //
294 // FLT_MAX 1E+37 Maximum representable floating point number.
295 // (use C::flt_max in preference to this)
296 // DBL_MAX 1E+37
297 // (use C::dbl_max in preference to this)
298 // LDBL_MAX 1E+37
299 //
300 // </srcblock>
301 
302 // <h3> Constants defined in values.h </h3>
303 // (not part of the POSIX standard).
304 // <note role=warning> These constants will disappear in the near future.
305 // Do not use them in new code. </note>
306 
307 // <srcblock>
308 //
309 // HIBITS Value of a short integer with only the high-order
310 // bit set (in most implementations, 0x8000).
311 //
312 // HIBITL Value of a long integer with only the high-order
313 // bit set (in most implementations, 0x80000000).
314 //
315 // MAXSHORT Maximum value of a signed short integer (in most
316 // implementations, 0x7FFF = 32767).
317 //
318 // MAXLONG Maximum value of a signed long integer (in most
319 // implementations, 0x7FFFFFFF = 2147483647).
320 //
321 // MAXINT Maximum value of a signed regular integer (usually
322 // the same as MAXSHORT or MAXLONG).
323 //
324 // MINFLOAT Minimum positive value of a single-precision
325 // floating-point number (use C::minfloat in preference
326 // to this)
327 //
328 // MINDOUBLE Minimum positive value of a double-precision
329 // floating-point number (use C::mindouble in preference
330 // to this)
331 //
332 // MAXFLOAT Maximum value of a single-precision floating-point number
333 //
334 // MAXDOUBLE Maximum value of a double-precision floating-point number
335 //
336 // FSIGNIF Number of significant bits in the mantissa of a
337 // single-precision floating-point number.
338 //
339 // DSIGNIF Number of significant bits in the mantissa of a
340 // double-precision floating-point number.
341 // </srcblock>
342 
343 // <note role=tip>
344 // Once cxx2html accepts the namespace type, the Dummy_Constants_Class can be
345 // removed.<br>
346 // Anyway, to use a constant (e.g. pi) use the C::pi construct now and later.
347 // </note>
348 
349 
351 };
352 
353 namespace C {
354  //#--------------------------------------------------------------------
355  // Mathematical constants
356  //#--------------------------------------------------------------------
357  //# <group>
358 
359  // Irrationals:
360  // <group>
361  // sqrt(2)
362  extern const Double sqrt2;
363  // sqrt(3)
364  extern const Double sqrt3;
365  // 1/sqrt(2)
366  extern const Double _1_sqrt2;
367  // 1/sqrt(3)
368  extern const Double _1_sqrt3;
369  // </group>
370 
371  // Pi and functions thereof:
372  // <group>
373  // pi
374  extern const Double pi;
375  // 2*pi
376  extern const Double _2pi;
377  // pi/2
378  extern const Double pi_2;
379  // pi/4
380  extern const Double pi_4;
381  // 1/pi
382  extern const Double _1_pi;
383  // 2/pi
384  extern const Double _2_pi;
385  // 1/sqrt(pi)
386  extern const Double _1_sqrtpi;
387  // 2/sqrt(pi)
388  extern const Double _2_sqrtpi;
389  // </group>
390 
391  // e and functions thereof:
392  // <group>
393  // e
394  extern const Double e;
395  // ln(2)
396  extern const Double ln2;
397  // ln(10)
398  extern const Double ln10;
399  // log2(e)
400  extern const Double log2e;
401  // log10(e)
402  extern const Double log10e;
403  // </group>
404 
405  // gamma and functions thereof:
406  // <group>
407  // gamma
408  extern const Double gamma;
409  // ln(gamma)
410  extern const Double lngamma;
411  // e**gamma
412  extern const Double etogamma;
413  // </group>
414 
415  //#--------------------------------------------------------------------
416  //# Mathematical constants
417  //#--------------------------------------------------------------------
418  //# </group>
419 
420 
421  //#--------------------------------------------------------------------
422  // Machine constants
423  //#--------------------------------------------------------------------
424  //# <group>
425  // floating point limits
426  // <group>
427  // the minimum single precision floating point number,
428  // excluding denormalised numbers
429  extern const Double flt_min;
430  // the minimum single precision floating point number,
431  // including denormalised numbers
432  extern const Double minfloat;
433  // the minimum double precision floating point number,
434  // excluding denormalised numbers
435  extern const Double dbl_min;
436  // the minimum double precision floating point number,
437  // including denormalised numbers
438  extern const Double mindouble;
439  // the maximum single precision floating point number
440  extern const Double flt_max;
441  // the maximum double precision floating point number
442  extern const Double dbl_max;
443  // Minimum single precision floating point number X such that 1+X does not
444  // equal X
445  extern const Double flt_epsilon;
446  // Minimum double precision floating point number X such that 1+X does not
447  // equal X
448  extern const Double dbl_epsilon;
449  // </group>
450 
451  //#--------------------------------------------------------------------
452  //# Machine constants
453  //#--------------------------------------------------------------------
454  //# </group>
455 
456  //#--------------------------------------------------------------------
457  //# Physical constants, and quantities
458  //#--------------------------------------------------------------------
459  //# <group>
460 
461  // Fundamental physical constants (SI units):
462  // <group>
463  // velocity of light -- for legacy reasons only -- refer to PC
464  extern const Double c;
465  // </group>
466 
467  //#--------------------------------------------------------------------
468  //# Physical constants, and quantities
469  //#--------------------------------------------------------------------
470  //# </group>
471 
472 
473 
474  //#--------------------------------------------------------------------
475  //# Physical units
476  //#--------------------------------------------------------------------
477  //# <group>
478 
479  //#-----------------------------
480  //# Numerical conversion factors
481  //#-----------------------------
482  //# <group>
483 
484  // Numerical conversion factors
485  // <group>
486  // e+24 (Y)
487  extern const Double yotta;
488  // e+21 (Z)
489  extern const Double zetta;
490  // e+18 (E)
491  extern const Double exa;
492  // e+15 (P)
493  extern const Double peta;
494  // e+12 (T)
495  extern const Double tera;
496  // e+09 (G)
497  extern const Double giga;
498  // e+06 (M)
499  extern const Double mega;
500  // e+03 (k)
501  extern const Double kilo;
502  // e+02 (h)
503  extern const Double hecto;
504  // e+01 (da)
505  extern const Double deka;
506  // e-01 (d)
507  extern const Double deci;
508  // e-02 (c)
509  extern const Double centi;
510  // e-03 (m)
511  extern const Double milli;
512  // e-06 (u)
513  extern const Double micro;
514  // e-09 (n)
515  extern const Double nano;
516  // e-12 (p)
517  extern const Double pico;
518  // e-15 (f)
519  extern const Double femto;
520  // e-18 (a)
521  extern const Double atto;
522  // e-21 (z)
523  extern const Double zepto;
524  // e-24 (y)
525  extern const Double yocto;
526  // </group>
527 
528  // Angular measure:
529  // <group>
530  // radian
531  extern const Double radian;
532  // circle
533  extern const Double circle;
534  // degree
535  extern const Double degree;
536  // arcminute
537  extern const Double arcmin;
538  // arcsecond
539  extern const Double arcsec;
540  // </group>
541 
542  // Solid angular measure:
543  // <group>
544  // steradian
545  extern const Double steradian;
546  // sphere
547  extern const Double sphere;
548  // square degree
549  extern const Double square_degree;
550  // square arcminute
551  extern const Double square_arcmin;
552  // square arcsecond
553  extern const Double square_arcsec;
554  // </group>
555 
556  //#-----------------------------
557  //# Numerical conversion factors
558  //#-----------------------------
559  //# </group>
560 
561 
562  //#----------------------------
563  //# Physical conversion factors
564  //#----------------------------
565  //# <group>
566 
567  // Time interval [T]:
568  // <group>
569  // second
570  extern const Double second;
571  // minute
572  extern const Double minute;
573  // hour
574  extern const Double hour;
575  // day
576  extern const Double day;
577  // Difference between Julian Day and Modified Julian Day
578  extern const Double MJD0;
579  // </group>
580 
581  //#----------------------------
582  //# Physical conversion factors
583  //#----------------------------
584  //# <group>
585 
586  //#--------------------------------------------------------------------
587  //# Physical units
588  //#--------------------------------------------------------------------
589  //# <group>
590 
591 }
592 
593 
594 } //# NAMESPACE CASACORE - END
595 
596 #endif
const Double peta
e+15 (P)
const Double flt_max
the maximum single precision floating point number
const Double flt_epsilon
Minimum single precision floating point number X such that 1+X does not equal X.
const Double micro
e-06 (u)
const Double milli
e-03 (m)
const Double ln2
ln(2)
const Double circle
circle
const Double hour
hour
const Double _1_sqrt2
1/sqrt(2)
const Double sphere
sphere
const Double nano
e-09 (n)
const Double yocto
e-24 (y)
const Double deci
e-01 (d)
Mathematical and numerical constants.
Definition: Constants.h:350
const Double giga
e+09 (G)
const Double degree
degree
const Double gamma
gamma and functions thereof:
const Double femto
e-15 (f)
const Double dbl_min
the minimum double precision floating point number, excluding denormalised numbers ...
const Double zepto
e-21 (z)
const Double pi_2
pi/2
const Double log10e
log10(e)
const Double steradian
Solid angular measure:
const Double mindouble
the minimum double precision floating point number, including denormalised numbers ...
const Double minute
minute
const Double kilo
e+03 (k)
const Double sqrt2
Mathematical constants.
const Double arcsec
arcsecond
const Double pi
Pi and functions thereof:
const Double _2pi
2*pi
const Double _1_sqrt3
1/sqrt(3)
const Double radian
Angular measure:
const Double _2_pi
2/pi
const Double _1_pi
1/pi
const Double mega
e+06 (M)
const Double deka
e+01 (da)
const Double zetta
e+21 (Z)
const Double dbl_max
the maximum double precision floating point number
const Double square_arcmin
square arcminute
const Double exa
e+18 (E)
double Double
Definition: aipstype.h:52
const Double lngamma
ln(gamma)
const Double pico
e-12 (p)
const Double square_degree
square degree
const Double _1_sqrtpi
1/sqrt(pi)
const Double etogamma
e**gamma
const Double tera
e+12 (T)
const Double sqrt3
sqrt(3)
const Double hecto
e+02 (h)
const Double second
Time interval [T]:
const Double yotta
Numerical conversion factors.
const Double log2e
log2(e)
const Double atto
e-18 (a)
TableExprNode day(const TableExprNode &node)
Definition: ExprNode.h:1580
const Double e
e and functions thereof:
const Double _2_sqrtpi
2/sqrt(pi)
const Double flt_min
Machine constants.
const Double c
Fundamental physical constants (SI units):
const Double minfloat
the minimum single precision floating point number, including denormalised numbers ...
const Double square_arcsec
square arcsecond
const Double centi
e-02 (c)
const Double ln10
ln(10)
const Double MJD0
Difference between Julian Day and Modified Julian Day.
const Double dbl_epsilon
Minimum double precision floating point number X such that 1+X does not equal X.
this file contains all the compiler specific defines
Definition: mainpage.dox:28
const Double arcmin
arcminute
const Double pi_4
pi/4