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