number2 matrix_scalar_product (const Vector<number2> &u,
const Vector<number2> &v) const;
+ /**
+ * Symmetrize the matrix by
+ * forming the mean value between
+ * the existing matrix and its
+ * transpose, $A = \frac 12(A+A^T)$.
+ *
+ * Obviously the matrix must be
+ * square for this operation.
+ */
+ void symmetrize ();
+
/**
* Return the $l_1$-norm of the matrix, i.e.
* $|M|_1=max_{all columns j}\sum_{all
/**
* A=Inverse(A). Inversion of
- * this matrix by
- * Gauss-Jordan algorithm with
- * partial pivoting. This
- * process is well-behaved for
- * positive definite matrices,
- * but be aware of round-off
- * errors in the indefinite case.
+ * this matrix by Gauss-Jordan
+ * algorithm with partial
+ * pivoting. This process is
+ * well-behaved for positive
+ * definite matrices, but be
+ * aware of round-off errors in
+ * the indefinite case.
*
* The numerical effort to invert
* an @p{n x n} matrix is of the
void gauss_jordan ();
/**
- * Computes the determinant of a matrix.
- * This is only implemented for one two and
- * three dimensions, since for higher
- * dimensions the numerical work explodes.
- * Obviously, the matrix needs to be square
- * for this function.
+ * Computes the determinant of a
+ * matrix. This is only
+ * implemented for one, two, and
+ * three dimensions, since for
+ * higher dimensions the
+ * numerical work explodes.
+ * Obviously, the matrix needs to
+ * be square for this function.
*/
double determinant () const;
const Vector<number3>& b) const;
/**
- * Forward elimination of lower triangle.
- * Inverts the lower triangle of a
- * quadratic matrix.
+ * Forward elimination of lower
+ * triangle. Inverts the lower
+ * triangle of a quadratic
+ * matrix.
*
- * If the matrix has more columns than rows,
- * this function only operates on the left
- * square submatrix. If there are more rows,
- * the upper square part of the matrix
- * is considered
+ * If the matrix has more columns
+ * than rows, this function only
+ * operates on the left square
+ * submatrix. If there are more
+ * rows, the upper square part of
+ * the matrix is considered
*/
template<typename number2>
void forward (Vector<number2> &dst,
/**
* QR-factorization of a matrix.
- * The orthogonal transformation Q is
- * applied to the vector y and this matrix.
+ * The orthogonal transformation
+ * Q is applied to the vector y
+ * and this matrix.
*
- * After execution of householder, the upper
- * triangle contains the resulting matrix R,
- * the lower the incomplete factorization
+ * After execution of
+ * householder, the upper
+ * triangle contains the
+ * resulting matrix R, the lower
+ * the incomplete factorization
* matrices.
*/
template<typename number2>
}
+
template <typename number>
template <typename number2>
-void FullMatrix<number>::forward (Vector<number2>& dst,
- const Vector<number2>& src) const
+void FullMatrix<number>::forward (Vector<number2> &dst,
+ const Vector<number2> &src) const
{
Assert (data() != 0, ExcEmptyMatrix());
- Assert(dst.size() == m(), ExcDimensionMismatch(dst.size(), m()));
- Assert(src.size() == n(), ExcDimensionMismatch(src.size(), n()));
+ Assert (dst.size() == m(), ExcDimensionMismatch(dst.size(), m()));
+ Assert (src.size() == n(), ExcDimensionMismatch(src.size(), n()));
unsigned int i,j;
unsigned int nu = ( (m()<n()) ? m() : n());
}
+
template <typename number>
template <typename number2>
-void FullMatrix<number>::backward (Vector<number2>& dst,
- const Vector<number2>& src) const
+void FullMatrix<number>::backward (Vector<number2> &dst,
+ const Vector<number2> &src) const
{
Assert (data() != 0, ExcEmptyMatrix());
}
-/* template <typename number> */
-/* template <typename number2> */
-/* FullMatrix<number>& */
-/* FullMatrix<number>::operator = (const FullMatrix<number2>& m) */
-/* { */
-
-/* } */
-
template <typename number>
template <typename number2>
-void FullMatrix<number>::fill (const FullMatrix<number2>& src,
- const unsigned int i,
- const unsigned int j)
+void FullMatrix<number>::fill (const FullMatrix<number2> &src,
+ const unsigned int i,
+ const unsigned int j)
{
Assert (n() >= src.n() + j, ExcInvalidDestination(n(), src.n(), j));
Assert (m() >= src.m() + i, ExcInvalidDestination(m(), src.m(), i));
};
+
+template <typename number>
+void
+FullMatrix<number>::symmetrize ()
+{
+ Assert (m() == n(), ExcNotQuadratic());
+
+ const unsigned int N = m();
+ for (unsigned int i=0; i<N; ++i)
+ for (unsigned int j=i+1; j<N; ++j)
+ {
+ const number t = (el(i,j) + el(j,i)) / 2;
+ el(i,j) = el(j,i) = t;
+ };
+};
+
+
template <typename number>
number FullMatrix<number>::l1_norm () const
{