From: wolf Date: Mon, 3 Jul 2000 07:07:09 +0000 (+0000) Subject: Simpler implementation of the square of x. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3d78df2b5a270739e0622f6db150a8697a2285f1;p=dealii-svn.git Simpler implementation of the square of x. git-svn-id: https://svn.dealii.org/trunk@3119 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/base/source/function_lib.cc b/deal.II/base/source/function_lib.cc index 5dfefbf5c1..1f3845a959 100644 --- a/deal.II/base/source/function_lib.cc +++ b/deal.II/base/source/function_lib.cc @@ -86,27 +86,11 @@ Tensor<1,dim> SquareFunction::gradient (const Point &p, const unsigned int) const { - Tensor<1,dim> result; - switch(dim) - { - case 1: - result[0] = 2.*p(0); - break; - case 2: - result[0] = 2.*p(0); - result[1] = 2.*p(1); - break; - case 3: - result[0] = 2.*p(0); - result[1] = 2.*p(1); - result[2] = 2.*p(2); - break; - default: - Assert(false, ExcNotImplemented()); - } - return result; + return p*2; } + + template void SquareFunction::gradient_list (const vector > &points, @@ -116,31 +100,14 @@ SquareFunction::gradient_list (const vector > &points, Assert (gradients.size() == points.size(), ExcDimensionMismatch(gradients.size(), points.size())); - for (unsigned int i=0;i& p = points[i]; - switch(dim) - { - case 1: - gradients[i][0] = 2.*p(0); - break; - case 2: - gradients[i][0] = 2.*p(0); - gradients[i][1] = 2.*p(1); - break; - case 3: - gradients[i][0] = 2.*p(0); - gradients[i][1] = 2.*p(1); - gradients[i][2] = 2.*p(2); - break; - default: - Assert(false, ExcNotImplemented()); - } - } + for (unsigned int i=0; i double PillowFunction::value (const Point &p,