From 771999b8f5da1f3a31eae419dbe07859475ef2ea Mon Sep 17 00:00:00 2001 From: wolf Date: Mon, 12 May 2003 21:37:35 +0000 Subject: [PATCH] Remove template arg from Polynomials::Legendre and Polynomials::Hierarchical git-svn-id: https://svn.dealii.org/trunk@7639 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/base/include/base/polynomial.h | 20 ++-- deal.II/base/source/polynomial.cc | 136 +++++++++++-------------- deal.II/doc/news/2002/c-3-4.html | 9 ++ 3 files changed, 79 insertions(+), 86 deletions(-) diff --git a/deal.II/base/include/base/polynomial.h b/deal.II/base/include/base/polynomial.h index ee6f29dd39..fb9e31e016 100644 --- a/deal.II/base/include/base/polynomial.h +++ b/deal.II/base/include/base/polynomial.h @@ -282,8 +282,7 @@ namespace Polynomials * * @author Guido Kanschat, 2000 */ - template - class Legendre : public Polynomial + class Legendre : public Polynomial { public: /** @@ -305,14 +304,14 @@ namespace Polynomials * classes. */ static - std::vector > + std::vector > generate_complete_basis (const unsigned int degree); private: /** * Coefficients for the interval $[0,1]$. */ - static std::vector *> shifted_coefficients; + static std::vector *> shifted_coefficients; /** * Vector with already computed @@ -324,7 +323,7 @@ namespace Polynomials * vectors in order to simplify * programming multithread-safe. */ - static std::vector *> recursive_coefficients; + static std::vector *> recursive_coefficients; /** * Compute coefficients recursively. @@ -338,7 +337,7 @@ namespace Polynomials * constructor of * @ref{Polynomial}. */ - static const std::vector & + static const std::vector & get_coefficients (const unsigned int k); }; @@ -384,8 +383,7 @@ namespace Polynomials * * @author Brian Carnes, 2002 */ - template - class Hierarchical : public Polynomial + class Hierarchical : public Polynomial { public: /** @@ -416,7 +414,7 @@ namespace Polynomials * classes. */ static - std::vector > + std::vector > generate_complete_basis (const unsigned int degree); private: @@ -432,10 +430,10 @@ namespace Polynomials * constructor of * @ref{Polynomial}. */ - static const std::vector & + static const std::vector & get_coefficients (const unsigned int k); - static std::vector *> recursive_coefficients; + static std::vector *> recursive_coefficients; }; } diff --git a/deal.II/base/source/polynomial.cc b/deal.II/base/source/polynomial.cc index 373485c3c9..1792e49d27 100644 --- a/deal.II/base/source/polynomial.cc +++ b/deal.II/base/source/polynomial.cc @@ -252,7 +252,8 @@ namespace Polynomials // ------------------ class LagrangeEquidistant --------------- // LagrangeEquidistant::LagrangeEquidistant (const unsigned int n, - const unsigned int support_point): + const unsigned int support_point) + : Polynomial(compute_coefficients(n,support_point)) {} @@ -514,20 +515,23 @@ namespace Polynomials // Reserve space for polynomials up to degree 19. Should be sufficient // for the start. - template - std::vector *> - Legendre::recursive_coefficients( - 20, static_cast*>(0)); - template - std::vector *> - Legendre::shifted_coefficients( - 20, static_cast*>(0)); + std::vector *> + Legendre::recursive_coefficients(20, + static_cast*>(0)); + std::vector *> + Legendre::shifted_coefficients(20, + static_cast*>(0)); + Legendre::Legendre (const unsigned int k) + : + Polynomial (get_coefficients(k)) + {} - template + + void - Legendre::compute_coefficients (const unsigned int k_) + Legendre::compute_coefficients (const unsigned int k_) { // make sure we call the // Polynomial::shift function @@ -572,10 +576,10 @@ namespace Polynomials // later assign it to the // coefficients array to // make it const - std::vector *c0 = new std::vector(1); + std::vector *c0 = new std::vector(1); (*c0)[0] = 1.; - std::vector *c1 = new std::vector(2); + std::vector *c1 = new std::vector(2); (*c1)[0] = 0.; (*c1)[1] = 1.; @@ -585,14 +589,14 @@ namespace Polynomials recursive_coefficients[1] = c1; // Compute polynomials // orthogonal on [0,1] - c0 = new std::vector(*c0); - c1 = new std::vector(*c1); + c0 = new std::vector(*c0); + c1 = new std::vector(*c1); - Polynomial::template shift (*c0, -1.); - Polynomial::scale(*c0, 2.); - Polynomial::template shift (*c1, -1.); - Polynomial::scale(*c1, 2.); - Polynomial::multiply(*c1, std::sqrt(3.)); + Polynomial::shift (*c0, -1.); + Polynomial::scale(*c0, 2.); + Polynomial::shift (*c1, -1.); + Polynomial::scale(*c1, 2.); + Polynomial::multiply(*c1, std::sqrt(3.)); shifted_coefficients[0]=c0; shifted_coefficients[1]=c1; } @@ -610,11 +614,11 @@ namespace Polynomials compute_coefficients(k-1); coefficients_lock.acquire (); - std::vector *ck = new std::vector(k+1); + std::vector *ck = new std::vector(k+1); - const number a = 1./(k); - const number b = a*(2*k-1); - const number c = a*(k-1); + const double a = 1./(k); + const double b = a*(2*k-1); + const double c = a*(k-1); (*ck)[k] = b*(*recursive_coefficients[k-1])[k-1]; (*ck)[k-1] = b*(*recursive_coefficients[k-1])[k-2]; @@ -631,10 +635,10 @@ namespace Polynomials recursive_coefficients[k] = ck; // and compute the // coefficients for [0,1] - ck = new std::vector(*ck); - Polynomial::template shift (*ck, -1.); - Polynomial::scale(*ck, 2.); - Polynomial::multiply(*ck, std::sqrt(2.*k+1.)); + ck = new std::vector(*ck); + Polynomial::shift (*ck, -1.); + Polynomial::scale(*ck, 2.); + Polynomial::multiply(*ck, std::sqrt(2.*k+1.)); shifted_coefficients[k] = ck; }; }; @@ -642,9 +646,8 @@ namespace Polynomials - template - const std::vector & - Legendre::get_coefficients (const unsigned int k) + const std::vector & + Legendre::get_coefficients (const unsigned int k) { // first make sure the coefficients // get computed if so necessary @@ -659,22 +662,13 @@ namespace Polynomials - template - Legendre::Legendre (const unsigned int k) - : - Polynomial (get_coefficients(k)) - {} - - - - template - std::vector > - Legendre::generate_complete_basis (const unsigned int degree) + std::vector > + Legendre::generate_complete_basis (const unsigned int degree) { std::vector > v; v.reserve(degree+1); for (unsigned int i=0; i<=degree; ++i) - v.push_back (Legendre(i)); + v.push_back (Legendre(i)); return v; } @@ -686,16 +680,21 @@ namespace Polynomials // Reserve space for polynomials up to degree 19. Should be sufficient // for the start. - template - std::vector *> - Hierarchical::recursive_coefficients( - 20, static_cast*>(0)); + std::vector *> + Hierarchical::recursive_coefficients( + 20, static_cast*>(0)); + + + + Hierarchical::Hierarchical (const unsigned int k) + : + Polynomial (get_coefficients(k)) + {} - template void - Hierarchical::compute_coefficients (const unsigned int k_) + Hierarchical::compute_coefficients (const unsigned int k_) { unsigned int k = k_; @@ -730,11 +729,11 @@ namespace Polynomials // later assign it to the // coefficients array to // make it const - std::vector *c0 = new std::vector(2); + std::vector *c0 = new std::vector(2); (*c0)[0] = 1.; (*c0)[1] = -1.; - std::vector *c1 = new std::vector(2); + std::vector *c1 = new std::vector(2); (*c1)[0] = 0.; (*c1)[1] = 1.; @@ -749,9 +748,9 @@ namespace Polynomials compute_coefficients(1); coefficients_lock.acquire (); - std::vector *c2 = new std::vector(3); + std::vector *c2 = new std::vector(3); - const number a = 1.; //1./8.; + const double a = 1.; //1./8.; (*c2)[0] = 0.*a; (*c2)[1] = -4.*a; @@ -773,9 +772,9 @@ namespace Polynomials compute_coefficients(k-1); coefficients_lock.acquire (); - std::vector *ck = new std::vector(k+1); + std::vector *ck = new std::vector(k+1); - const number a = 1.; //1./(2.*k); + const double a = 1.; //1./(2.*k); (*ck)[0] = - a*(*recursive_coefficients[k-1])[0]; @@ -789,7 +788,7 @@ namespace Polynomials // basis fcn phi_2 if ( (k%2) == 0 ) { - number b = 1.; //8.; + double b = 1.; //8.; //for (unsigned int i=1; i<=k; i++) // b /= 2.*i; @@ -807,9 +806,8 @@ namespace Polynomials - template - const typename std::vector & - Hierarchical::get_coefficients (const unsigned int k) + const std::vector & + Hierarchical::get_coefficients (const unsigned int k) { // first make sure the coefficients // get computed if so necessary @@ -819,7 +817,7 @@ namespace Polynomials // of coefficients. do that in a MT // safe way coefficients_lock.acquire (); - const std::vector *p = recursive_coefficients[k]; + const std::vector *p = recursive_coefficients[k]; coefficients_lock.release (); // return the object pointed @@ -831,17 +829,8 @@ namespace Polynomials - template - Hierarchical::Hierarchical (const unsigned int k) - : - Polynomial (get_coefficients(k)) - {} - - - - template - std::vector > - Hierarchical::generate_complete_basis (const unsigned int degree) + std::vector > + Hierarchical::generate_complete_basis (const unsigned int degree) { if (degree==0) // create constant @@ -860,7 +849,7 @@ namespace Polynomials std::vector > v; v.reserve(degree+1); for (unsigned int i=0; i<=degree; ++i) - v.push_back (Hierarchical(i)); + v.push_back (Hierarchical(i)); return v; } } @@ -882,7 +871,4 @@ namespace Polynomials template void Polynomial::shift(const long double offset); template void Polynomial::shift(const long double offset); template void Polynomial::shift(const long double offset); - - template class Legendre; - template class Hierarchical; } diff --git a/deal.II/doc/news/2002/c-3-4.html b/deal.II/doc/news/2002/c-3-4.html index a986b9ed1c..fbf918d598 100644 --- a/deal.II/doc/news/2002/c-3-4.html +++ b/deal.II/doc/news/2002/c-3-4.html @@ -327,6 +327,15 @@ contributor's names are abbreviated by WB (Wolfgang Bangerth), GK

base

    +
  1. + Changed: The Polynomials::Legendre + class lost its template argument and is now just a regular + class. There was no real good reason for the template argument, + it had just crept in. +
    + (WB 2003/05/12) +

    +
  2. New: There is now a class AnisotropicPolynomials that constructs a higher -- 2.39.5