]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Use fixed_int_power instead of re-implementing it.
authorMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Sat, 17 Nov 2012 21:04:26 +0000 (21:04 +0000)
committerMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Sat, 17 Nov 2012 21:04:26 +0000 (21:04 +0000)
git-svn-id: https://svn.dealii.org/trunk@27558 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/include/deal.II/base/quadrature.h
deal.II/include/deal.II/base/utilities.h
deal.II/source/base/quadrature.cc

index 43384cdd1cef63c3a8a114dad41a5f02de04428f..6d891868fe443ca1b920a4961bd82d17b2cfd555 100644 (file)
@@ -52,7 +52,7 @@ DEAL_II_NAMESPACE_OPEN
  * degree of polynomials integrated exactly. This number is given in
  * the documentation of each formula. The order of the integration
  * error is <tt>m+1</tt>, that is, the error is the size of the cell
- * two the <tt>m+1</tt> by the Bramble-Hilbert Lemma. The number
+ * to the <tt>m+1</tt> by the Bramble-Hilbert Lemma. The number
  * <tt>m</tt> is to be found in the documentation of each concrete
  * formula. For the optimal formulæ QGauss we have $m = 2N-1$, where
  * N is the constructor parameter to QGauss. The tensor product
index 8bd5a226a9095531625b67b68f47a8c70330bbae..7d1b02b985c524f6a0dd71537ecd2c362c450cf5 100644 (file)
@@ -193,12 +193,14 @@ namespace Utilities
                                     * number by a template expression where
                                     * both the number <code>a</code> and the
                                     * power <code>N</code> are compile-time
-                                    * constants. This gives compile-time
-                                    * knowledge of the result of the power
-                                    * operation.
+                                    * constants. This computes the result of
+                                    * the power operation at compile time,
+                                    * enables its use e.g. in other
+                                    * templates.
                                     *
-                                    * Use this function as in
-                                    * <code>fixed_int_power@<a,N@>::value</code>.
+                                    * Use this function with the arguments
+                                    * <code>fixed_int_power@<5,2@>::value</code>
+                                    * to compute 5<sup>2</sup>.
                                     */
   template <int a, int N>
   struct fixed_int_power
index 29f23cb9394cc53237950d6609f4b86fd8caf5ae..928d6b3b68cf9f6cbf02758742decea30c4a31a6 100644 (file)
@@ -16,6 +16,7 @@
 #include <deal.II/base/quadrature.h>
 #include <deal.II/base/qprojector.h>
 #include <deal.II/base/memory_consumption.h>
+#include <deal.II/base/utilities.h>
 
 #include <cmath>
 #include <cstdlib>
 DEAL_II_NAMESPACE_OPEN
 
 
-namespace
-{
-/**
- * Integer to the power of dim
- */
-  template <int dim>
-  inline unsigned int dimpow (unsigned int n)
-  {
-    unsigned int result = n;
-    for (unsigned int i=1;i<dim;++i)
-      result *= n;
-    return result;
-  }
-}
-
-
 template <>
 Quadrature<0>::Quadrature (const unsigned int n_q)
                 :
@@ -222,8 +207,8 @@ template <int dim>
 Quadrature<dim>::Quadrature (const Quadrature<dim != 1 ? 1 : 0> &q)
                 :
                 Subscriptor(),
-                quadrature_points (dimpow<dim>(q.size())),
-                weights (dimpow<dim>(q.size()))
+                quadrature_points (Utilities::fixed_power<dim>(q.size())),
+                weights (Utilities::fixed_power<dim>(q.size()))
 {
   Assert (dim <= 3, ExcNotImplemented());
 

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.