From 7d5183c5638bf1c073d83def3d78295f32b7b2c7 Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Thu, 3 Sep 2015 23:26:41 -0500 Subject: [PATCH] Bugfix: Update Point documentation, fix norm, norm_square Both are supposed to return a real valued scalar product. Update documentation and implementation accordingly. --- include/deal.II/base/point.h | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/include/deal.II/base/point.h b/include/deal.II/base/point.h index 723a339a8e..66c83dbfb8 100644 --- a/include/deal.II/base/point.h +++ b/include/deal.II/base/point.h @@ -217,16 +217,22 @@ public: /** * Return the scalar product of this point vector with itself, i.e. the - * square, or the square of the norm. + * square, or the square of the norm. In case of a complex number type it + * is equivalent to the contraction of this point vector with a complex + * conjugate of itself. + * + * @note This function is equivalent to + * Tensor::norm_square() which returns the square of the + * Frobenius norm. */ - Number square () const; + typename Tensor<1, dim, Number>::real_type square () const; /** * Return the Euclidean distance of this point to the point * p, i.e. the l_2 norm of the difference between the * vectors representing the two points. */ - Number distance (const Point &p) const; + typename Tensor<1, dim, Number>::real_type distance (const Point &p) const; /** * @} @@ -438,27 +444,24 @@ Point::operator * (const Tensor<1,dim,Number> &p) const template inline -Number +typename Tensor<1, dim, Number>::real_type Point::square () const { - Number q = Number(); - for (unsigned int i=0; i::abs_square(this->values[i]); - return q; + return this->norm_square(); } template inline -Number +typename Tensor<1, dim, Number>::real_type Point::distance (const Point &p) const { Number sum = Number(); for (unsigned int i=0; ivalues[i]-p(i); - sum += diff*diff; + sum += numbers::NumberTraits::abs_square (diff); } return std::sqrt(sum); -- 2.39.5