]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Use Utilities::fixed_power
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 26 Jun 2007 05:05:31 +0000 (05:05 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 26 Jun 2007 05:05:31 +0000 (05:05 +0000)
git-svn-id: https://svn.dealii.org/trunk@14809 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/source/fe/fe_abf.cc
deal.II/deal.II/source/fe/fe_raviart_thomas.cc
deal.II/deal.II/source/fe/mapping_q.cc

index ce9c2b20c9d6bc64f44795d4b61ea0f1c52757d3..d229bef1fe8b38061dd0b40fa64027a783ea5751 100644 (file)
@@ -11,6 +11,7 @@
 //
 //---------------------------------------------------------------------------
 
+#include <base/utilities.h>
 #include <base/quadrature.h>
 #include <base/quadrature_lib.h>
 #include <base/qprojector.h>
@@ -413,7 +414,7 @@ FE_ABF<dim>::initialize_restriction()
                                                   // have to do it here.
                  this->restriction[child](face*this->dofs_per_face+i_face,
                                     i_child)
-                   += std::pow(.5, dim-1.) * q_sub.weight(k)
+                   += Utilities::fixed_power<dim-1>(.5) * q_sub.weight(k)
                    * cached_values(i_child, k)
                    * this->shape_value_component(face*this->dofs_per_face+i_face,
                                                  q_sub.point(k),
index 5dba3929a835839de20c7c463f872a72c11b4706..bc4ceb87daf354214fbfe54c32f276470cdc6ede 100644 (file)
@@ -11,6 +11,7 @@
 //
 //---------------------------------------------------------------------------
 
+#include <base/utilities.h>
 #include <base/quadrature.h>
 #include <base/quadrature_lib.h>
 #include <base/qprojector.h>
@@ -336,7 +337,7 @@ FE_RaviartThomas<dim>::initialize_restriction()
                                                   // have to do it here.
                  this->restriction[child](face*this->dofs_per_face+i_face,
                                     i_child)
-                   += std::pow(.5, dim-1.) * q_sub.weight(k)
+                   += Utilities::fixed_power<dim-1>(.5) * q_sub.weight(k)
                    * cached_values(i_child, k)
                    * this->shape_value_component(face*this->dofs_per_face+i_face,
                                                  q_sub.point(k),
index 3b0f604b6ddac912721eb9962b547516f0e75c13..7b027cd1fc1e365be18114cbb17d74fed56fbb34 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors
+//    Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -11,8 +11,8 @@
 //
 //---------------------------------------------------------------------------
 
-#include <fe/mapping_q.h>
-#include <fe/fe_q.h>
+
+#include <base/utilities.h>
 #include <base/polynomial.h>
 #include <base/quadrature.h>
 #include <base/quadrature_lib.h>
@@ -23,6 +23,8 @@
 #include <grid/tria_boundary.h>
 #include <dofs/dof_accessor.h>
 #include <fe/fe_tools.h>
+#include <fe/mapping_q.h>
+#include <fe/fe_q.h>
 
 #include <numeric>
 #include <memory>
@@ -93,34 +95,15 @@ MappingQ<1>::~MappingQ ()
 
 
 
-template<typename number>
-number power(const number x, const unsigned int y)
-{
-                                  // since the power to which x is
-                                  // raised is usually the space
-                                  // dimension, and since this is
-                                  // rarely larger than three, the
-                                  // following code is optimal and
-                                  // cannot be further optimized by
-                                  // grouping of operands to reduce
-                                  // the number of multiplications
-                                  // from O(x) to O(log x)
-  number value=1;
-  for (unsigned int i=0; i<y; ++i)
-    value *= x;
-  return value;
-}
-
-
 template<int dim>
 MappingQ<dim>::MappingQ (const unsigned int p)
                 :
                degree(p),
-               n_inner(power(degree-1, dim)),
+               n_inner(Utilities::fixed_power<dim>(degree-1)),
                n_outer((dim==2) ? 4+4*(degree-1)
                        :8+12*(degree-1)+6*(degree-1)*(degree-1)),
                tensor_pols(0),
-               n_shape_functions(power(degree+1,dim)),
+               n_shape_functions(Utilities::fixed_power<dim>(degree+1)),
                renumber(0)
 {
                                   // Construct the tensor product

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.