From: Matthias Maier Date: Fri, 4 Sep 2015 04:26:41 +0000 (-0500) Subject: Bugfix: Update Point documentation, fix norm, norm_square X-Git-Tag: v8.4.0-rc2~466^2~21 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7d5183c5638bf1c073d83def3d78295f32b7b2c7;p=dealii.git Bugfix: Update Point documentation, fix norm, norm_square Both are supposed to return a real valued scalar product. Update documentation and implementation accordingly. --- 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);