]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
add primitive of polynomials
authorguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 8 Jun 2006 08:00:26 +0000 (08:00 +0000)
committerguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 8 Jun 2006 08:00:26 +0000 (08:00 +0000)
git-svn-id: https://svn.dealii.org/trunk@13204 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/base/include/base/polynomial.h
deal.II/base/source/polynomial.cc

index 85df4e4c693e0e32e03141ed9e04963f9843e03a..f8c9c722e7ec5a38e1bebc25c6af6bd48894a374 100644 (file)
@@ -42,7 +42,7 @@ namespace Polynomials
  * happens through the Horner scheme which provides both numerical
  * stability and a minimal number of numerical operations.
  *
- * @author Ralf Hartmann, Guido Kanschat, 2000
+ * @author Ralf Hartmann, Guido Kanschat, 2000, 2006
  */
   template <typename number>
   class Polynomial : public Subscriptor
@@ -159,11 +159,19 @@ namespace Polynomials
       void shift (const number2 offset);
 
                                       /**
-                                       * Compute the derivative of
-                                       * the polynomial.
+                                       * Compute the derivative of a
+                                       * polynomial.
                                        */
       Polynomial<number> derivative () const;
 
+                                      /**
+                                       * Compute the primitive of a
+                                       * polynomial. the coefficient
+                                       * of the zero order term of
+                                       * the polynomial is zero.
+                                       */
+      Polynomial<number> primitive () const;
+
                                       /**
                                        * Multiply with a scalar.
                                        */
index b57c923841aedc1aa3b7df9bf91dbaa557fa3ade..2c98b7ebdbd143eeb7147fb361d15b089672ae3d 100644 (file)
@@ -2,7 +2,7 @@
 //      $Id$   
 //    Version: $Name$
 //
-//    Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 by the deal.II authors
+//    Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -314,6 +314,19 @@ namespace Polynomials
   }
   
 
+  template <typename number>
+  Polynomial<number>
+  Polynomial<number>::primitive () const
+  {
+    std::vector<number> newcoefficients (coefficients.size()+1);
+    newcoefficients[0] = 0.;
+    for (unsigned int i=0 ; i<coefficients.size() ; ++i)
+      newcoefficients[i+1] = coefficients[i]/(i+1.);
+
+    return Polynomial<number> (newcoefficients);
+  }
+  
+
   template <typename number>
   void
   Polynomial<number>::print (std::ostream& out) const

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.