]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Unify the places where we use pi.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 12 Sep 2002 22:46:44 +0000 (22:46 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 12 Sep 2002 22:46:44 +0000 (22:46 +0000)
git-svn-id: https://svn.dealii.org/trunk@6417 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/base/include/base/config.h.in
deal.II/base/source/data_out_base.cc
deal.II/base/source/function_lib_cutoff.cc
deal.II/configure
deal.II/configure.in
deal.II/deal.II/source/grid/grid_generator.cc
deal.II/deal.II/source/grid/grid_out.cc
deal.II/deal.II/source/numerics/data_out_rotation.cc
deal.II/deal.II/source/numerics/derivative_approximation.cc

index d7a8f74822330205e37aff47147296de519c15a1..8c15a906eee5c6a1b01ad900708125dc9ec02f2b 100644 (file)
 #undef __PRETTY_FUNCTION__
 
 
-
+/**
+ * Have a namespace into which we declare some numeric constants, such
+ * as pi. Unfortunately, these are not always available, on all systems
+ * or depending on compiler flags, so we duplicate their declarations
+ * here to make them unconditionally available to all other parts of the
+ * library.
+ *
+ * The constants defined here are a subset of the  constants sometimes
+ * declared in the system include file , but without the 
+ * prefix .
+ */
+namespace deal_II_numbers {
+                                             /**
+                                              * e
+                                              */
+  static const double  E       = 2.7182818284590452354;
+
+                                             /**
+                                              * log_2 e
+                                              */
+  static const double  LOG2E   = 1.4426950408889634074;
+
+                                             /**
+                                              * log_10 e
+                                              */
+  static const double  LOG10E  = 0.43429448190325182765;
+
+                                             /**
+                                              * log_e 2
+                                              */
+  static const double  LN2     = 0.69314718055994530942;
+
+                                             /**
+                                              * log_e 10
+                                              */
+  static const double  LN10    = 2.30258509299404568402;
+
+                                             /**
+                                              * pi
+                                              */
+  static const double  PI      = 3.14159265358979323846;
+
+                                             /**
+                                              * pi/2
+                                              */
+  static const double  PI_2    = 1.57079632679489661923;
+
+                                             /**
+                                              * pi/4
+                                              */
+  static const double  PI_4    = 0.78539816339744830962;
+
+                                             /**
+                                              * sqrt(2)
+                                              */
+  static const double  SQRT2   = 1.41421356237309504880;
+
+                                             /**
+                                              * 1/sqrt(2)
+                                              */
+  static const double  SQRT1_2 = 0.70710678118654752440;
+};
 #endif
 
index 2cafaf692924777db6ae7041e909357780efebef..12feb958d6ef2f0745fb08fcee2f6359efc0ed7e 100644 (file)
@@ -1760,8 +1760,7 @@ void DataOutBase::write_eps (const std::vector<Patch<dim,spacedim> > &patches,
                                                   // the height field, I don't know
                                                   // it.
                  EpsCell2d eps_cell;
-//TODO:[?] Unify the various places where PI is defined to a central instance  
-                 const double pi = 3.141592653589793238462;
+                 const double pi = deal_II_numbers::PI;
                  const double cx = -std::cos(pi-flags.azimut_angle * 2*pi / 360.),
                               cz = -std::cos(flags.turn_angle * 2*pi / 360.),
                               sx = std::sin(pi-flags.azimut_angle * 2*pi / 360.),
index e122076160c1dbac3f2c788e4afbd0147a97c658..9c9e2ae8fc9a2958986b95226f0077643b3f3834 100644 (file)
 #include <cmath>
 
 
-// in strict ANSI C mode, the following constants are not defined by
-// default, so we do it ourselves
-//TODO:[?] Unify the various places where PI is defined to a central instance 
-#ifndef M_PI
-#  define      M_PI            3.14159265358979323846
-#endif
-
-#ifndef M_PI_2
-#  define      M_PI_2          1.57079632679489661923
-#endif
-
-#ifndef M_E
-#  define       M_E             2.7182818284590452354
-#endif
 
 namespace Functions
 {
@@ -239,7 +225,7 @@ namespace Functions
        if (d>=r)
          return 0.;
        const double e = -r*r/(r*r-d*d);
-       return  ((e<-50) ? 0. : M_E * exp(e));
+       return  ((e<-50) ? 0. : deal_II_numbers::E * exp(e));
       }
     return 0.;
   }
@@ -267,7 +253,7 @@ namespace Functions
              values[i] = 0.;
            } else {
              const double e = -r*r/(r*r-d*d);
-             values[i] = (e<-50) ? 0. : M_E * exp(e);
+             values[i] = (e<-50) ? 0. : deal_II_numbers::E * exp(e);
            }
        }
     else
@@ -294,7 +280,7 @@ namespace Functions
          {
            e = -r*r/(r*r-d*d);
            if (e>-50)
-             val = M_E * exp(e);
+             val = deal_II_numbers::E * exp(e);
          }
 
        if (this->selected==CutOffFunctionBase<dim>::no_component)
index 51648cfd7f0870b20591a11630e6ddcfd3d14cbf..52ac087fed80f36a34fbf48cedf7ec59a5bc8619 100755 (executable)
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.in Revision: 1.119 .
+# From configure.in Revision: 1.120 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.53a.
 #
index e64f48b2f9f6c0ebc552af466d8dbaaf4f9b723a..7fb5765ed7adb1cce2a741d514f349f309fe21a3 100644 (file)
@@ -398,7 +398,68 @@ AH_TOP(
 
 AH_BOTTOM(
 [
-
+/**
+ * Have a namespace into which we declare some numeric constants, such
+ * as pi. Unfortunately, these are not always available, on all systems
+ * or depending on compiler flags, so we duplicate their declarations
+ * here to make them unconditionally available to all other parts of the
+ * library.
+ *
+ * The constants defined here are a subset of the @p{M_XXX} constants sometimes
+ * declared in the system include file @p{math.h}, but without the 
+ * prefix @p{M_}.
+ */
+namespace deal_II_numbers {
+                                             /**
+                                              * e
+                                              */
+  static const double  E       = 2.7182818284590452354;
+
+                                             /**
+                                              * log_2 e
+                                              */
+  static const double  LOG2E   = 1.4426950408889634074;
+
+                                             /**
+                                              * log_10 e
+                                              */
+  static const double  LOG10E  = 0.43429448190325182765;
+
+                                             /**
+                                              * log_e 2
+                                              */
+  static const double  LN2     = 0.69314718055994530942;
+
+                                             /**
+                                              * log_e 10
+                                              */
+  static const double  LN10    = 2.30258509299404568402;
+
+                                             /**
+                                              * pi
+                                              */
+  static const double  PI      = 3.14159265358979323846;
+
+                                             /**
+                                              * pi/2
+                                              */
+  static const double  PI_2    = 1.57079632679489661923;
+
+                                             /**
+                                              * pi/4
+                                              */
+  static const double  PI_4    = 0.78539816339744830962;
+
+                                             /**
+                                              * sqrt(2)
+                                              */
+  static const double  SQRT2   = 1.41421356237309504880;
+
+                                             /**
+                                              * 1/sqrt(2)
+                                              */
+  static const double  SQRT1_2 = 0.70710678118654752440;
+};
 #endif
 ])
 
index 497d6f9e9b0cd38e398df82b106351accf0f97f0..b7d5ba629be1f2377bece2ad479a9feda7479402 100644 (file)
@@ -371,8 +371,7 @@ void GridGenerator::hyper_shell (Triangulation<2>   &tria,
   Assert ((inner_radius > 0) && (inner_radius < outer_radius),
          ExcInvalidRadii ());
   
-//TODO:[?] Unify the various places where PI is defined to a central instance  
-  const double pi = 3.141592653589793238462;
+  const double pi = deal_II_numbers::PI;
   
                                   // determine the number of cells
                                   // for the grid. if not provided by
@@ -465,7 +464,7 @@ GridGenerator::half_hyper_shell (Triangulation<2>   &tria,
   Assert ((inner_radius > 0) && (inner_radius < outer_radius),
          ExcInvalidRadii ());
   
-  const double pi     = 3.14159265359;
+  const double pi     = deal_II_numbers::PI;
                                   // determine the number of cells
                                   // for the grid. if not provided by
                                   // the user determine it such that
index 7f3468a47fa32bac00524ff03ccf84b41eeb12cf..68014e6a0eb098c5f7623278c7b40303630a92e5 100644 (file)
@@ -889,8 +889,7 @@ void GridOut::write_eps (const Triangulation<dim> &tria,
                                         // is in direction of the viewer, but
                                         // I am too tired at present to fix
                                         // this
-//TODO:[?] Unify the various places where PI is defined to a central instance  
-       const double pi = 3.141592653589793238462;
+       const double pi = deal_II_numbers::PI;
        const double z_angle    = eps_flags_3.azimut_angle;
        const double turn_angle = eps_flags_3.turn_angle;
        const Point<dim> view_direction(-std::sin(z_angle * 2.*pi / 360.) * std::sin(turn_angle * 2.*pi / 360.),
index c07fad9426a318873310f80496b847b11ffd0697..92dff26e014f8604531c4212d4588d630a170946 100644 (file)
@@ -67,18 +67,19 @@ void DataOutRotation<dim>::build_some_patches (Data data)
                                   // place. for simplicity add the
                                   // initial direction at the end
                                   // again
-//TODO:[?] Unify the various places where PI is defined to a central instance  
-  const double pi = 3.141592653589793238462;
   std::vector<Point<dim+1> > angle_directions (n_patches_per_circle+1);
   for (unsigned int i=0; i<=n_patches_per_circle; ++i)
     {
-      angle_directions[i][0] = std::cos(2*pi*i/n_patches_per_circle);
-      angle_directions[i][1] = std::sin(2*pi*i/n_patches_per_circle);
+      angle_directions[i][0] = std::cos(2*deal_II_numbers::PI *
+                                        i/n_patches_per_circle);
+      angle_directions[i][1] = std::sin(2*deal_II_numbers::PI *
+                                        i/n_patches_per_circle);
     };
   
   
   unsigned int cell_number = 0;
-  typename std::vector< ::DataOutBase::Patch<dim+1> >::iterator patch = this->patches.begin();
+  typename std::vector< ::DataOutBase::Patch<dim+1> >::iterator
+    patch = this->patches.begin();
   typename DoFHandler<dim>::cell_iterator cell=first_cell();
 
                                   // get first cell in this thread
index 72b8c8dbeff74c91a0f19f780cd5eddb81252b00..663bdc90ef7b5569d410e87b7f31720a31ed23ea 100644 (file)
@@ -275,8 +275,6 @@ C DEFINE A TEST MATRIX
   
 */
 
-//TODO:[?] Unify the various places where PI is defined to a central instance  
-  const double pi = 3.141592653589793238462;
   const double am = trace(d) / 3.;
 
                                   // s := d - trace(d) I
@@ -328,8 +326,8 @@ C DEFINE A TEST MATRIX
        {
          const double theta = std::acos(XX) / 3.;
          EE[0] = am + R*std::cos(theta);
-         EE[1] = am + R*std::cos(theta + 2./3.*pi);
-         EE[2] = am + R*std::cos(theta + 4./3.*pi);
+         EE[1] = am + R*std::cos(theta + 2./3.*deal_II_numbers::PI);
+         EE[2] = am + R*std::cos(theta + 4./3.*deal_II_numbers::PI);
        };
     };
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.