<ol>
+<li> New: The SparseDirectUMFPACK class can now also deal with matrices
+provided in SparseMatrixEZ format.
+<br>
+(Martin Genet, 2011/05/04)
+
<li> New: The new tutorial program step-46 shows how to couple different
models defined on subsets of
the domain, in this case Stokes flow around an elastic solid. The
*/
bool empty () const;
+ /**
+ * Return the number of entries
+ * in a specific row.
+ */
+ unsigned int get_row_length (const unsigned int row) const;
+
/**
* Return the number of nonzero
* elements of this
+template <typename number>
+unsigned int
+BlockSparseMatrix<number>::get_row_length (const unsigned int row) const
+{
+ return sparsity_pattern->row_length(row);
+}
+
+
+
template <typename number>
unsigned int
BlockSparseMatrix<number>::n_nonzero_elements () const
#include <base/thread_management.h>
#include <lac/vector.h>
#include <lac/sparse_matrix.h>
+#include <lac/sparse_matrix_ez.h>
#include <lac/block_sparse_matrix.h>
#ifdef DEAL_II_USE_MUMPS
* Make sure that the arrays Ai
* and Ap are sorted in each
* row. UMFPACK wants it this
- * way. We need to have two
+ * way. We need to have three
* versions of this function, one
- * for the usual SparseMatrix and
+ * for the usual SparseMatrix, one
+ * for the SparseMatrixEZ, and
* one for the BlockSparseMatrix
* classes
*/
+ template <typename number>
+ void sort_arrays (const SparseMatrixEZ<number> &);
+
template <typename number>
void sort_arrays (const SparseMatrix<number> &);
*/
unsigned int n () const;
- /**
- * Return the number of nonzero
- * elements of this
- * matrix. Actually, it returns
- * the number of entries in the
- * sparsity pattern; if any of
- * the entries should happen to
- * be zero, it is counted anyway.
- */
+ /**
+ * Return the number of entries
+ * in a specific row.
+ */
+ unsigned int get_row_length (const unsigned int row) const;
+
+ /**
+ * Return the number of nonzero
+ * elements of this
+ * matrix. Actually, it returns
+ * the number of entries in the
+ * sparsity pattern; if any of
+ * the entries should happen to
+ * be zero, it is counted anyway.
+ */
unsigned int n_nonzero_elements () const;
/**
+template <typename number>
+unsigned int
+SparseMatrix<number>::get_row_length (const unsigned int row) const
+{
+ Assert (cols != 0, ExcNotInitialized());
+ return cols->row_length(row);
+}
+
+
+
template <typename number>
unsigned int
SparseMatrix<number>::n_nonzero_elements () const
*/
unsigned int n () const;
+ /**
+ * Return the number of entries
+ * in a specific row.
+ */
+ unsigned int get_row_length (const unsigned int row) const;
+
+ /**
+ * Return the number of nonzero
+ * elements of this matrix.
+ */
+ unsigned int n_nonzero_elements () const;
+
/**
* Set the element <tt>(i,j)</tt> to
* @p value. Allocates the entry,
}
+
+template <typename number>
+unsigned int
+SparseMatrixEZ<number>::get_row_length (const unsigned int row) const
+{
+ return row_info[row].length;
+}
+
+
+
+template <typename number>
+unsigned int
+SparseMatrixEZ<number>::n_nonzero_elements() const
+{
+ typename std::vector<RowInfo>::const_iterator row = row_info.begin();
+ const typename std::vector<RowInfo>::const_iterator endrow = row_info.end();
+
+ // Add up entries actually used
+ unsigned int used = 0;
+ for (; row != endrow ; ++ row)
+ used += row->length;
+ return used;
+}
+
+
+
template <typename number>
void
SparseMatrixEZ<number>::compute_statistics(
+template <typename number>
+void
+SparseDirectUMFPACK::
+sort_arrays (const SparseMatrixEZ<number> &matrix)
+{
+ //same thing for SparseMatrixEZ
+ for (unsigned int row=0; row<matrix.m(); ++row)
+ {
+ long int cursor = Ap[row];
+ while ((cursor < Ap[row+1]-1) &&
+ (Ai[cursor] > Ai[cursor+1]))
+ {
+ std::swap (Ai[cursor], Ai[cursor+1]);
+ std::swap (Ax[cursor], Ax[cursor+1]);
+ ++cursor;
+ }
+ }
+}
+
+
+
template <typename number>
void
SparseDirectUMFPACK::
// anyway. people are supposed to provide
// accurate sparsity patterns.
Ap.resize (N+1);
- Ai.resize (matrix.get_sparsity_pattern().n_nonzero_elements());
- Ax.resize (matrix.get_sparsity_pattern().n_nonzero_elements());
+ Ai.resize (matrix.n_nonzero_elements());
+ Ax.resize (matrix.n_nonzero_elements());
// first fill row lengths array
Ap[0] = 0;
for (unsigned int row=1; row<=N; ++row)
- Ap[row] = Ap[row-1] + matrix.get_sparsity_pattern().row_length(row-1);
+ Ap[row] = Ap[row-1] + matrix.get_row_length(row-1);
Assert (static_cast<unsigned int>(Ap.back()) == Ai.size(),
ExcInternalError());
InstantiateUMFPACK(SparseMatrix<double>);
InstantiateUMFPACK(SparseMatrix<float>);
+InstantiateUMFPACK(SparseMatrixEZ<double>);
+InstantiateUMFPACK(SparseMatrixEZ<float>);
InstantiateUMFPACK(BlockSparseMatrix<double>);
InstantiateUMFPACK(BlockSparseMatrix<float>);