*/
template<typename number2>
double matrix_scalar_product (const Vector<number2> &u, const Vector<number2> &v) const;
+
+ /**
+ * Return the l1-norm of the matrix, i.e.
+ * $|M|_1=max_{all columns j}\sum_{all
+ * rows i} |M_ij|$,
+ * (max. sum of columns).
+ * This is the
+ * natural matrix norm that is compatible
+ * to the l1-norm for vectors, i.e.
+ * $|Mv|_1\leq |M|_1 |v|_1$.
+ * (cf. Rannacher Numerik0)
+ */
+ number l1_norm () const;
+
+ /**
+ * Return the linfty-norm of the
+ * matrix, i.e.
+ * $|M|_infty=max_{all rows i}\sum_{all
+ * columns j} |M_ij|$,
+ * (max. sum of rows).
+ * This is the
+ * natural matrix norm that is compatible
+ * to the linfty-norm of vectors, i.e.
+ * $|Mv|_infty \leq |M|_infty |v|_infty$.
+ * (cf. Rannacher Numerik0)
+ */
+ number linfty_norm () const;
/**
* A=Inverse(A). Inversion of this by
};
+template <typename number>
+number FullMatrix<number>::l1_norm () const
+{
+ number sum=0, max=0;
+ const unsigned int n_rows = m(), n_cols = n();
+
+ for (unsigned int col=0; col<n_cols; ++col)
+ {
+ sum=0;
+ for (unsigned int row=0; row<n_rows; ++row)
+ sum += fabs(el(row,col));
+ if (sum > max)
+ max = sum;
+ }
+ return max;
+};
+
+
+template <typename number>
+number FullMatrix<number>::linfty_norm () const
+{
+ number sum=0, max=0;
+ const unsigned int n_rows = m(), n_cols = n();
+
+ for (unsigned int row=0; row<n_rows; ++row)
+ {
+ sum=0;
+ for (unsigned int col=0; col<n_cols; ++col)
+ sum += fabs(el(row,col));
+ if (sum > max)
+ max = sum;
+ }
+ return max;
+};
+
template <typename number>
void
*/
template <typename somenumber>
double matrix_norm (const Vector<somenumber> &v) const;
-
+
+ /**
+ * Return the l1-norm of the matrix, i.e.
+ * $|M|_1=max_{all columns j}\sum_{all
+ * rows i} |M_ij|$,
+ * (max. sum of columns).
+ * This is the
+ * natural matrix norm that is compatible
+ * to the l1-norm for vectors, i.e.
+ * $|Mv|_1\leq |M|_1 |v|_1$.
+ * (cf. Rannacher Numerik0)
+ */
+ number l1_norm () const;
+
+ /**
+ * Return the linfty-norm of the
+ * matrix, i.e.
+ * $|M|_infty=max_{all rows i}\sum_{all
+ * columns j} |M_ij|$,
+ * (max. sum of rows).
+ * This is the
+ * natural matrix norm that is compatible
+ * to the linfty-norm of vectors, i.e.
+ * $|Mv|_infty \leq |M|_infty |v|_infty$.
+ * (cf. Rannacher Numerik0)
+ */
+ number linfty_norm () const;
+
//
template <typename somenumber>
double residual (Vector<somenumber>& dst, const Vector<somenumber>& x,
};
+template <typename number>
+number SparseMatrix<number>::l1_norm () const
+{
+ Assert (cols != 0, ExcMatrixNotInitialized());
+ Assert (val != 0, ExcMatrixNotInitialized());
+
+ Vector<number> column_sums(n());
+ const unsigned int n_rows = m();
+ for (unsigned int row=0; row<n_rows; ++row)
+ for (unsigned int j=cols->rowstart[row]; j<cols->rowstart[row+1] ; ++j)
+ column_sums(cols->colnums[j])+=fabs(val[j]);
+
+ return column_sums.linfty_norm();
+};
+
+
+template <typename number>
+number SparseMatrix<number>::linfty_norm () const
+{
+ Assert (cols != 0, ExcMatrixNotInitialized());
+ Assert (val != 0, ExcMatrixNotInitialized());
+
+ const number *val_ptr = &val[cols->rowstart[0]];
+
+ number sum, max=0;
+ const unsigned int n_rows = m();
+ for (unsigned int row=0; row<n_rows; ++row)
+ {
+ sum=0;
+ const number *const val_end_of_row = &val[cols->rowstart[row+1]];
+ while (val_ptr != val_end_of_row)
+ sum += fabs(*val_ptr++);
+ if (sum > max)
+ max = sum;
+ }
+ return max;
+};
+
template <typename number>
template <typename somenumber>