From a75e6c903bfda580fc6953e3d3d1b6a621f7dd40 Mon Sep 17 00:00:00 2001 From: guido Date: Thu, 8 Jun 2006 08:00:26 +0000 Subject: [PATCH] add primitive of polynomials git-svn-id: https://svn.dealii.org/trunk@13204 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/base/include/base/polynomial.h | 14 +++++++++++--- deal.II/base/source/polynomial.cc | 15 ++++++++++++++- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/deal.II/base/include/base/polynomial.h b/deal.II/base/include/base/polynomial.h index 85df4e4c69..f8c9c722e7 100644 --- a/deal.II/base/include/base/polynomial.h +++ b/deal.II/base/include/base/polynomial.h @@ -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 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 derivative () const; + /** + * Compute the primitive of a + * polynomial. the coefficient + * of the zero order term of + * the polynomial is zero. + */ + Polynomial primitive () const; + /** * Multiply with a scalar. */ diff --git a/deal.II/base/source/polynomial.cc b/deal.II/base/source/polynomial.cc index b57c923841..2c98b7ebdb 100644 --- a/deal.II/base/source/polynomial.cc +++ b/deal.II/base/source/polynomial.cc @@ -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 + Polynomial + Polynomial::primitive () const + { + std::vector newcoefficients (coefficients.size()+1); + newcoefficients[0] = 0.; + for (unsigned int i=0 ; i (newcoefficients); + } + + template void Polynomial::print (std::ostream& out) const -- 2.39.5