<h3>deal.II</h3>
<ol>
+ <li> <p> Improved: <code class="class">VectorTools</code>::<code
+ class="member">integrate_difference</code> can compute <i>L<sup>p</sup></i>
+ and <i>W<sup>1,p</sup></i> norms for arbitrary <i>p</i>. The function
+ receives an additional optional argument <i>p</i> for this. All previous
+ fuctionality remains unchanged, although the code has been cleaned up a bit.
+ <br>
+ (GK 2002/08/01)
+ </p>
+
<li> <p> New: The <code class="class">GridTools</code> class now
offers functions to apply general transformations to all
vertices of a triangulation, and also more specialized
Number norm_sqr () const;
/**
- * Return the mean value of the elements of
+ * Mean value of the elements of
* this vector.
*/
Number mean_value () const;
/**
- * Return the $l_1$-norm of the vector, i.e.
- * the sum of the absolute values.
+ * $l_1$-norm of the vector.
+ * The sum of the absolute values.
*/
Number l1_norm () const;
/**
- * Return the $l_2$-norm of the vector, i.e.
- * the square root of the sum of the
+ * $l_2$-norm of the vector. The
+ * square root of the sum of the
* squares of the elements.
*/
Number l2_norm () const;
/**
- * Return the maximum absolute value of the
- * elements of this vector, which is the
- * $l_\infty$-norm of a vector.
+ * $l_p$-norm of the vector. The
+ * pth root of the sum of the pth
+ * powers of the absolute values
+ * of the elements.
+ */
+ Number lp_norm (double p) const;
+
+ /**
+ * Maximum absolute value of the
+ * elements.
*/
Number linfty_norm () const;
};
+template <typename Number>
+Number Vector<Number>::lp_norm (double p) const
+{
+ Assert (dim!=0, ExcEmptyVector());
+
+ Number sum0 = 0,
+ sum1 = 0,
+ sum2 = 0,
+ sum3 = 0;
+
+ // use modern processors better by
+ // allowing pipelined commands to be
+ // executed in parallel
+ const_iterator ptr = begin(),
+ eptr = ptr + (dim/4)*4;
+ while (ptr!=eptr)
+ {
+ sum0 += std::pow(std::fabs(*ptr++), p);
+ sum1 += std::pow(std::fabs(*ptr++), p);
+ sum2 += std::pow(std::fabs(*ptr++), p);
+ sum3 += std::pow(std::fabs(*ptr++), p);
+ };
+ // add up remaining elements
+ while (ptr != end())
+ sum0 += pow(std::fabs(*ptr++), p);
+
+ return pow(sum0+sum1+sum2+sum3, 1./p);
+};
+
+
template <typename Number>
Number Vector<Number>::linfty_norm () const {
Assert (dim!=0, ExcEmptyVector());