casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Constants.h
Go to the documentation of this file.
00001 //# Constants.h: Mathematical and numerical constants
00002 //# Copyright (C) 1993,1994,1995,1997,1998,1999,2000,2001
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id: Constants.h 20734 2009-09-28 23:44:40Z Malte.Marquarding $
00027 
00028 #ifndef CASA_CONSTANTS_H
00029 #define CASA_CONSTANTS_H
00030 
00031 #include <casa/aips.h>
00032 
00033 #if defined (sun) && ! defined (AIPS_SOLARIS) 
00034 #   include <sys/limits.h>
00035 #else
00036 #   include <limits.h>
00037 #endif
00038 
00039 #include <float.h>
00040 #if !defined(AIPS_DARWIN) && !defined(AIPS_BSD)
00041 #include <values.h>
00042 #endif
00043 
00044 #if defined (AIPS_OSF)
00045 #   define LN_MAXFLOAT (M_LN2 * FMAXEXP)
00046 #   define LN_MINFLOAT (M_LN2 * (FMINEXP -1))
00047 #endif
00048 
00049 namespace casa { //# NAMESPACE CASA - BEGIN
00050 
00051 // <summary>Mathematical and numerical constants.</summary>
00052 
00053 // <use visibility=export>
00054 
00055 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tConstants" demos="">
00056 
00057 //# // <prerequisite>
00058 //# // </prerequisite>
00059 
00060 //# // <etymology>
00061 //# // </etymology>
00062 
00063 // <synopsis>
00064 // The constants and conversion factors are defined here as double precision
00065 // values.  Where single precision calculations are done in a situation where
00066 // processing speed is of concern, for example within the inner loop of an
00067 // expensive algorithm, a separate single precision variable should be defined
00068 // for use within the loop.
00069 //
00070 // </synopsis>
00071 //
00072 // <note role=warning> The following list is generated by hand, and may be incomplete.
00073 // After future revision of ccx2html the real data will be displayed </note>
00074 
00075 // <h3>Floating point limits</h3>
00076 // <srcblock>
00077 // flt_min              the minimum single precision floating point number, 
00078 //                      excluding denormalised numbers
00079 // minfloat             the minimum single precision floating point number, 
00080 //                      including denormalised numbers
00081 // dbl_min              the minimum double precision floating point number,
00082 //                      excluding denormalised numbers
00083 // mindouble            the minimum double precision floating point number,
00084 //                      including denormalised numbers
00085 // flt_max              the maximum single precision floating point number 
00086 // dbl_max              the maximum double precision floating point number 
00087 // flt_epsilon          Minimum single precision floating point number X
00088 //                      such that 1+X does not equal X
00089 // dbl_epsilon          Minimum double precision floating point number X
00090 //                      such that 1+X does not equal X
00091 // </srcblock>
00092 // <h3> Irrationals </h3>
00093 // <srcblock>
00094 // sqrt2                sqrt(2)
00095 // sqrt3                sqrt(3)
00096 // _1_sqrt2             1/sqrt(2)
00097 // _1_sqrt3             1/sqrt(3)
00098 // </srcblock>
00099 
00100 // <h3>Pi and functions thereof</h3>
00101 // <srcblock>
00102 // pi                   pi
00103 // _2pi                 2*pi
00104 // pi_2                 pi/2
00105 // pi_4                 pi/4
00106 // _1_pi                1/pi
00107 // _2_pi                2/pi
00108 // _1_sqrtpi            1/sqrt(pi)
00109 // _2_sqrtpi            2/sqrt(pi)
00110 // </srcblock>
00111 
00112 // <h3>e and functions thereof</h3>
00113 // <srcblock>
00114 // e                    e
00115 // ln2                  ln(2)
00116 // ln10                 ln(10)
00117 // log2e                log2(e)
00118 // log10e               log10(e)
00119 // </srcblock>
00120 
00121 // <h3>gamma and functions thereof</h3>
00122 // <srcblock>
00123 // gamma                gamma
00124 // lngamma              ln(gamma)
00125 // etogamma             e**gamma
00126 // </srcblock>
00127 
00128 // <h3>Fundamental physical constants (SI units)</h3>
00129 // <note role=warning> Preserved for legacy reasons only.
00130 // See <linkto class=QC>QC class</linkto> for other physical constants. </note>
00131 // <srcblock>
00132 // c                    velocity of light (m/s)
00133 // </srcblock>
00134 
00135 // <h3>Numerical conversion factors</h3>
00136 // <srcblock>
00137 // yotta                e+24 (Y)
00138 // zetta                e+21 (Z)
00139 // exa                  e+18 (E)
00140 // peta                 e+15 (P)
00141 // tera                 e+12 (T)
00142 // giga                 e+09 (G)
00143 // mega                 e+06 (M)
00144 // kilo                 e+03 (k)
00145 // hecto                e+02 (h)
00146 // deka                 e+01 (da)
00147 // deci                 e-01 (d)
00148 // centi                e-02 (c)
00149 // milli                e-03 (m)
00150 // micro                e-06 (u)
00151 // nano                 e-09 (n)
00152 // pico                 e-12 (p)
00153 // femto                e-15 (f)
00154 // atto                 e-18 (a)
00155 // zepto                e-21 (z)
00156 // yocto                e-24 (y)
00157 // </srcblock>
00158 
00159 // <h3>Angular measure</h3>
00160 // <srcblock>
00161 // radian               radian
00162 // circle               circle
00163 // degree               degree
00164 // arcmin               arcminute
00165 // arcsec               arcsecond
00166 // </srcblock>
00167 
00168 // <h3>Solid angular measure</h3>
00169 // <srcblock>
00170 // steradian            steradian
00171 // sphere               sphere
00172 // square_degree        square degree
00173 // square_arcmin        square arcminute
00174 // square_arcsec        square arcsecond
00175 // </srcblock>
00176 
00177 // <h3>Time interval</h3>
00178 // <srcblock>
00179 // second               second
00180 // minute               minute
00181 // hour                 hour
00182 // day                  day
00183 // </srcblock>
00184 
00185 // <h3> Machine constants </h3>
00186 //
00187 // Implementation-defined limits usually defined in <src><limits.h></src>,
00188 // <src><float.h></src>, and <src><values.h></src> as preprocessor
00189 // defines. They are 
00190 // Inclusion of <src><casa/BasicSL/Constants.h</src> is
00191 // sufficient to ensure that they are defined for any particular
00192 // implementation, and the correct functioning of the <src>tConstants</src>
00193 // test program guarantees this.
00194 //
00195 // In future use will be made of the (standard) <em>numeric_limits</em>
00196 // template from the <src><limits></src> include file.
00197 
00198 // <srcblock>
00199 //
00200 // Refer to Section 3.2c, pp28-30 of
00201 // "The Annotated C++ Reference Manual",
00202 // Ellis, M.A., and Stroustrup, B.,
00203 // Addison-Wesley Publishing Company, 1990.
00204 // IBSN 0-201-51459-1.
00205 //
00206 //    and
00207 //
00208 // Appendix B11, pp257-8 of
00209 // "The C Programming Language", 2nd ed.,
00210 // Kernighan, B.W., and Ritchie, D.M.,
00211 // Prentice Hall Software Series, 1988.
00212 // IBSN 0-13-110362-8.
00213 //
00214 // </srcblock>
00215 
00216 // <h3> Constants defined in limits.h </h3>
00217 // (these are part of the ANSI C and hence POSIX standards).
00218 // Acceptable limits defined by the standard are quoted.
00219 // <srcblock>
00220 //
00221 // CHAR_BIT              8  Maximum bits in a byte.
00222 // CHAR_MIN           0 or  Minimum value of 'char'.
00223 //               SCHAR_MIN
00224 // CHAR_MAX   UCHAR_MAX or  Maximum value of 'char'.
00225 //               SCHAR_MAX
00226 // SCHAR_MIN          -127  Minimum value of 'signed char'.
00227 // SCHAR_MAX          +127  Maximum value of 'signed char'.
00228 // UCHAR_MAX           255  Maximum value of 'unsigned char'.
00229 // MB_LEN_MAX               Maximum bytes in multibyte character.
00230 //
00231 // SHRT_MIN         -32767  Minimum value of 'short'.
00232 // SHRT_MAX         +32767  Maximum value of 'short'.
00233 // USHRT_MAX         65535  Maximum value of 'unsigned short'.
00234 //
00235 // INT_MIN          -32767  Minimum value of 'int'.
00236 // INT_MAX          +32767  Maximum value of 'int'.
00237 // UINT_MAX          65535  Maximum value of 'unsigned int'.
00238 //
00239 // LONG_MIN    -2147483647  Minimum value of 'long'.
00240 // LONG_MAX    +2147483647  Maximum value of 'long'.
00241 // ULONG_MAX    4294967295  Maximum value of 'unsigned long'.
00242 //
00243 // </srcblock>
00244 
00245 // <h3> Constants defined in float.h </h3>
00246 // (these are part of the ANSI C and hence POSIX standards).
00247 // Acceptable limits defined by the standard are quoted.
00248 // <srcblock>
00249 //
00250 // FLT_RADIX             2  Radix of exponent representation.
00251 // FLT_ROUNDS               Floating point rounding mode for addition
00252 //                            -1: indeterminate
00253 //                             0: towards zero
00254 //                             1: to nearest
00255 //                             2: toward +infinity
00256 //                             3: toward -infinity
00257 //
00258 // FLT_MIN_EXP              Minimum negative integer N such that FLT_RADIX
00259 // DBL_MIN_EXP              raised to the Nth minus 1 is a normalized
00260 // LDBL_MIN_EXP             floating point number.
00261 //
00262 // FLT_MAX_EXP              Maximum integer N such that FLT_RADIX raised to
00263 // DBL_MAX_EXP              the Nth minus 1 is representable.
00264 // LDBL_MAX_EXP
00265 //
00266 // FLT_MIN_10_EXP      -37  Minimum negative integer N such that 10 raised
00267 // DBL_MIN_10_EXP      -37  to the Nth is in the range of normalized
00268 // LDBL_MIN_10_EXP     -37  floating point numbers.
00269 //
00270 // FLT_MAX_10_EXP       37  Maximum integer N such that 10 raised to the
00271 // DBL_MAX_10_EXP       37  Nth minus 1 is representable.
00272 // LDBL_MAX_10_EXP      37
00273 //
00274 // FLT_MANT_DIG             Number of base FLT_RADIX digits in mantissa.
00275 // DBL_MANT_DIG
00276 // LDBL_MANT_DIG 
00277 //
00278 // FLT_DIG               6  Decimal digits of precision.
00279 // DBL_DIG              10
00280 // LDBL_DIG             10
00281 //
00282 // FLT_EPSILON        1E-5  Minimum floating point number X such  that
00283 // (use C::flt_epsilon in preference to this)
00284 // DBL_EPSILON        1E-9  1.0 + X does not equal 1.0.
00285 // (use C::dbl_epsilon in preference to this)
00286 // LDBL_EPSILON       1E-9
00287 //
00288 // FLT_MIN           1E-37  Minimum normalized positive floating point
00289 // (use C::flt_min in preference to this)
00290 // DBL_MIN           1E-37  number
00291 // (use C::dbl_min in preference to this)
00292 // LDBL_MIN          1E-37
00293 //
00294 // FLT_MAX           1E+37  Maximum representable floating point number.
00295 // (use C::flt_max in preference to this)
00296 // DBL_MAX           1E+37
00297 // (use C::dbl_max in preference to this)
00298 // LDBL_MAX          1E+37
00299 //
00300 // </srcblock>
00301 
00302 // <h3> Constants defined in values.h </h3>
00303 // (not part of the POSIX standard).
00304 // <note role=warning> These constants will disappear in the near future.
00305 // Do not use them in new code. </note>
00306 
00307 // <srcblock>
00308 //
00309 // HIBITS            Value of a short integer with only the high-order
00310 //                   bit set (in most implementations, 0x8000).
00311 //
00312 // HIBITL            Value of a long integer with only the high-order
00313 //                   bit set (in most implementations, 0x80000000).
00314 //
00315 // MAXSHORT          Maximum value of a signed short integer (in most
00316 //                   implementations, 0x7FFF = 32767).
00317 //
00318 // MAXLONG           Maximum value of a signed long integer (in most
00319 //                   implementations, 0x7FFFFFFF = 2147483647).
00320 //
00321 // MAXINT            Maximum value of a signed regular integer (usually
00322 //                   the same as MAXSHORT or MAXLONG).
00323 //
00324 // MINFLOAT          Minimum positive value of a single-precision
00325 //                   floating-point number (use C::minfloat in preference 
00326 //                   to this)
00327 //
00328 // MINDOUBLE         Minimum positive value of a double-precision
00329 //                   floating-point number (use C::mindouble in preference 
00330 //                   to this)
00331 //
00332 // MAXFLOAT          Maximum value of a single-precision floating-point number
00333 //
00334 // MAXDOUBLE         Maximum value of a double-precision floating-point number
00335 //
00336 // FSIGNIF           Number of significant bits in the mantissa of a
00337 //                   single-precision floating-point number.
00338 //
00339 // DSIGNIF           Number of significant bits in the mantissa of a
00340 //                   double-precision floating-point number.
00341 // </srcblock>
00342 
00343 // <note role=tip>
00344 // Once cxx2html accepts the namespace type, the Dummy_Constants_Class can be
00345 // removed.<br>
00346 // Anyway, to use a constant (e.g. pi) use the C::pi construct now and later.
00347 // </note>
00348 
00349 
00350 class Dummy_Constants_class {
00351 };
00352 
00353 namespace C {
00354   //#--------------------------------------------------------------------
00355   //  Mathematical constants
00356   //#--------------------------------------------------------------------
00357   //# <group>
00358   
00359   // Irrationals:
00360   // <group>
00361   // sqrt(2)
00362   extern const Double sqrt2;
00363   // sqrt(3)
00364   extern const Double sqrt3;
00365   // 1/sqrt(2)
00366   extern const Double _1_sqrt2;
00367   // 1/sqrt(3)
00368   extern const Double _1_sqrt3;
00369   // </group>
00370 
00371   // Pi and functions thereof:
00372   // <group>
00373   // pi
00374   extern const Double pi;
00375   // 2*pi
00376   extern const Double _2pi;
00377   // pi/2
00378   extern const Double pi_2;
00379   // pi/4
00380   extern const Double pi_4;
00381   // 1/pi
00382   extern const Double _1_pi;
00383   // 2/pi
00384   extern const Double _2_pi;
00385   // 1/sqrt(pi)
00386   extern const Double _1_sqrtpi;
00387   // 2/sqrt(pi)
00388   extern const Double _2_sqrtpi;
00389   // </group>
00390   
00391   // e and functions thereof:
00392   // <group>
00393   // e
00394   extern const Double e;
00395   // ln(2)
00396   extern const Double ln2;  
00397   // ln(10)
00398   extern const Double ln10; 
00399   // log2(e)
00400   extern const Double log2e; 
00401   // log10(e)
00402   extern const Double log10e;
00403   // </group>
00404   
00405   // gamma and functions thereof:
00406   // <group>
00407   // gamma
00408   extern const Double gamma;
00409   // ln(gamma)
00410   extern const Double lngamma;
00411   // e**gamma
00412   extern const Double etogamma;
00413   // </group>
00414   
00415   //#--------------------------------------------------------------------
00416   //# Mathematical constants
00417   //#--------------------------------------------------------------------
00418   //# </group>
00419   
00420   
00421   //#--------------------------------------------------------------------
00422   //  Machine constants
00423   //#--------------------------------------------------------------------
00424   //# <group>
00425   // floating point limits
00426   // <group>
00427   // the minimum single precision floating point number, 
00428   // excluding denormalised numbers
00429   extern const Double flt_min;
00430   // the minimum single precision floating point number, 
00431   // including denormalised numbers
00432   extern const Double minfloat;
00433   // the minimum double precision floating point number,
00434   // excluding denormalised numbers
00435   extern const Double dbl_min;
00436   // the minimum double precision floating point number,
00437   // including denormalised numbers
00438   extern const Double mindouble;
00439   // the maximum single precision floating point number 
00440   extern const Double  flt_max;
00441   // the maximum double precision floating point number 
00442   extern const Double  dbl_max;
00443   // Minimum single precision floating point number X such that 1+X does not
00444   // equal X
00445   extern const Double flt_epsilon;
00446   // Minimum double precision floating point number X such that 1+X does not
00447   // equal X
00448   extern const Double dbl_epsilon;
00449   // </group>
00450   
00451   //#--------------------------------------------------------------------
00452   //# Machine constants
00453   //#--------------------------------------------------------------------
00454   //# </group>
00455   
00456   //#--------------------------------------------------------------------
00457   //#  Physical constants, and quantities
00458   //#--------------------------------------------------------------------
00459   //# <group>
00460   
00461   // Fundamental physical constants (SI units):
00462   // <group>
00463   // velocity of light -- for legacy reasons only -- refer to PC
00464   extern const Double c;
00465   // </group>
00466   
00467   //#--------------------------------------------------------------------
00468   //# Physical constants, and quantities
00469   //#--------------------------------------------------------------------
00470   //# </group>
00471   
00472   
00473   
00474   //#--------------------------------------------------------------------
00475   //#  Physical units
00476   //#--------------------------------------------------------------------
00477   //# <group>
00478   
00479   //#-----------------------------
00480   //#  Numerical conversion factors
00481   //#-----------------------------
00482   //# <group>
00483   
00484   //  Numerical conversion factors
00485   // <group>
00486   // e+24 (Y)
00487   extern const Double yotta;
00488   // e+21 (Z)
00489   extern const Double zetta;
00490   // e+18 (E)
00491   extern const Double exa;
00492   // e+15 (P)
00493   extern const Double peta;
00494   // e+12 (T)
00495   extern const Double tera;
00496   // e+09 (G)
00497   extern const Double giga;
00498   // e+06 (M)
00499   extern const Double mega;
00500   // e+03 (k)
00501   extern const Double kilo;
00502   // e+02 (h)
00503   extern const Double hecto;
00504   // e+01 (da)
00505   extern const Double deka;
00506   // e-01 (d)
00507   extern const Double deci;
00508   // e-02 (c)
00509   extern const Double centi;
00510   // e-03 (m)
00511   extern const Double milli;
00512   // e-06 (u)
00513   extern const Double micro;
00514   // e-09 (n)
00515   extern const Double nano;
00516   // e-12 (p)
00517   extern const Double pico;
00518   // e-15 (f)
00519   extern const Double femto;
00520   // e-18 (a)
00521   extern const Double atto;
00522   // e-21 (z)
00523   extern const Double zepto;
00524   // e-24 (y)
00525   extern const Double yocto;
00526   // </group>
00527   
00528   // Angular measure:
00529   // <group>
00530   // radian
00531   extern const Double radian;
00532   // circle
00533   extern const Double circle; 
00534   // degree
00535   extern const Double degree;
00536   // arcminute
00537   extern const Double arcmin;
00538   // arcsecond
00539   extern const Double arcsec;
00540   // </group>
00541   
00542   // Solid angular measure:
00543   // <group>
00544   // steradian
00545   extern const Double steradian;
00546   // sphere
00547   extern const Double sphere;
00548   // square degree
00549   extern const Double square_degree;
00550   // square arcminute
00551   extern const Double square_arcmin;
00552   // square arcsecond
00553   extern const Double square_arcsec;
00554   // </group>
00555   
00556   //#-----------------------------
00557   //# Numerical conversion factors
00558   //#-----------------------------
00559   //# </group>
00560   
00561   
00562   //#----------------------------
00563   //#  Physical conversion factors
00564   //#----------------------------
00565   //# <group>
00566   
00567   // Time interval [T]:
00568   // <group>
00569   // second
00570   extern const Double second;
00571   // minute
00572   extern const Double minute;
00573   // hour
00574   extern const Double hour;
00575   // day
00576   extern const Double day;
00577   // </group>
00578   
00579   //#----------------------------
00580   //# Physical conversion factors
00581   //#----------------------------
00582   //# <group>
00583   
00584   //#--------------------------------------------------------------------
00585   //# Physical units
00586   //#--------------------------------------------------------------------
00587   //# <group>
00588   
00589 }
00590 
00591 
00592 } //# NAMESPACE CASA - END
00593 
00594 #endif