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

Generated on Mon Sep 1 22:33:38 2008 for NRAOCASA by  doxygen 1.5.1