Dear Wolfgang,
I'll soon download the "current subversion repository" and send you the "context
diff".
I have downloaded the current subversion repository and applied the modifications.
svn diff >> diff generates the attached file. Is it the one you need?
Also, I have introduced a couple flags in the documentation of SMEZ so it is
consistent with the one of SM. Are you interested? If yes, how can I commit the
first patch and create a second one?
Sorry: I have only used git so far and am not familiar at all with svn.
Martin.
Index: include/deal.II/lac/sparse_matrix_ez.h
===================================================================
--- include/deal.II/lac/sparse_matrix_ez.h (revision 23675)
+++ include/deal.II/lac/sparse_matrix_ez.h (working copy)
@@ -451,6 +451,18 @@
*/
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,
Index: include/deal.II/lac/sparse_matrix_ez.templates.h
===================================================================
--- include/deal.II/lac/sparse_matrix_ez.templates.h (revision 23675)
+++ include/deal.II/lac/sparse_matrix_ez.templates.h (working copy)
@@ -385,7 +385,33 @@
}
+
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(
unsigned int& used,
Index: include/deal.II/lac/sparse_matrix.h
===================================================================
--- include/deal.II/lac/sparse_matrix.h (revision 23675)
+++ include/deal.II/lac/sparse_matrix.h (working copy)
@@ -749,15 +749,21 @@
*/
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;
/**
Index: include/deal.II/lac/sparse_direct.h
===================================================================
--- include/deal.II/lac/sparse_direct.h (revision 23675)
+++ include/deal.II/lac/sparse_direct.h (working copy)
@@ -21,6 +21,7 @@
#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
@@ -1241,13 +1242,17 @@
* 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> &);
template <typename number>
Index: include/deal.II/lac/sparse_matrix.templates.h
===================================================================
--- include/deal.II/lac/sparse_matrix.templates.h (revision 23675)
+++ include/deal.II/lac/sparse_matrix.templates.h (working copy)
@@ -216,6 +216,16 @@
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
{
Assert (cols != 0, ExcNotInitialized());
Index: include/deal.II/lac/block_sparse_matrix.h
===================================================================
--- include/deal.II/lac/block_sparse_matrix.h (revision 23675)
+++ include/deal.II/lac/block_sparse_matrix.h (working copy)
@@ -192,6 +192,12 @@
*/
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
Index: include/deal.II/lac/block_sparse_matrix.templates.h
===================================================================
--- include/deal.II/lac/block_sparse_matrix.templates.h (revision 23675)
+++ include/deal.II/lac/block_sparse_matrix.templates.h (working copy)
@@ -129,6 +129,15 @@
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
{
return sparsity_pattern->n_nonzero_elements ();
Index: source/lac/sparse_direct.cc
===================================================================
--- source/lac/sparse_direct.cc (revision 23675)
+++ source/lac/sparse_direct.cc (working copy)
@@ -1603,6 +1603,27 @@
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::
sort_arrays (const BlockSparseMatrix<number> &matrix)
{
// the case for block matrices is a
@@ -1691,13 +1712,13 @@
// 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());
@@ -2028,6 +2049,8 @@
InstantiateUMFPACK(SparseMatrix<double>);
InstantiateUMFPACK(SparseMatrix<float>);
+InstantiateUMFPACK(SparseMatrixEZ<double>);
+InstantiateUMFPACK(SparseMatrixEZ<float>);
InstantiateUMFPACK(BlockSparseMatrix<double>);
InstantiateUMFPACK(BlockSparseMatrix<float>);
Index: include/deal.II/lac/sparse_matrix_ez.h
===================================================================
--- include/deal.II/lac/sparse_matrix_ez.h (revision 23675)
+++ include/deal.II/lac/sparse_matrix_ez.h (working copy)
@@ -451,6 +451,18 @@
*/
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,
Index: include/deal.II/lac/sparse_matrix_ez.templates.h
===================================================================
--- include/deal.II/lac/sparse_matrix_ez.templates.h (revision 23675)
+++ include/deal.II/lac/sparse_matrix_ez.templates.h (working copy)
@@ -385,7 +385,33 @@
}
+
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(
unsigned int& used,
Index: include/deal.II/lac/sparse_matrix.h
===================================================================
--- include/deal.II/lac/sparse_matrix.h (revision 23675)
+++ include/deal.II/lac/sparse_matrix.h (working copy)
@@ -749,15 +749,21 @@
*/
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;
/**
Index: include/deal.II/lac/sparse_direct.h
===================================================================
--- include/deal.II/lac/sparse_direct.h (revision 23675)
+++ include/deal.II/lac/sparse_direct.h (working copy)
@@ -21,6 +21,7 @@
#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
@@ -1241,13 +1242,17 @@
* 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> &);
template <typename number>
Index: include/deal.II/lac/sparse_matrix.templates.h
===================================================================
--- include/deal.II/lac/sparse_matrix.templates.h (revision 23675)
+++ include/deal.II/lac/sparse_matrix.templates.h (working copy)
@@ -216,6 +216,16 @@
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
{
Assert (cols != 0, ExcNotInitialized());
Index: include/deal.II/lac/block_sparse_matrix.h
===================================================================
--- include/deal.II/lac/block_sparse_matrix.h (revision 23675)
+++ include/deal.II/lac/block_sparse_matrix.h (working copy)
@@ -192,6 +192,12 @@
*/
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
Index: include/deal.II/lac/block_sparse_matrix.templates.h
===================================================================
--- include/deal.II/lac/block_sparse_matrix.templates.h (revision 23675)
+++ include/deal.II/lac/block_sparse_matrix.templates.h (working copy)
@@ -129,6 +129,15 @@
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
{
return sparsity_pattern->n_nonzero_elements ();
Index: source/lac/sparse_direct.cc
===================================================================
--- source/lac/sparse_direct.cc (revision 23675)
+++ source/lac/sparse_direct.cc (working copy)
@@ -1603,6 +1603,27 @@
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::
sort_arrays (const BlockSparseMatrix<number> &matrix)
{
// the case for block matrices is a
@@ -1691,13 +1712,13 @@
// 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());
@@ -2028,6 +2049,8 @@
InstantiateUMFPACK(SparseMatrix<double>);
InstantiateUMFPACK(SparseMatrix<float>);
+InstantiateUMFPACK(SparseMatrixEZ<double>);
+InstantiateUMFPACK(SparseMatrixEZ<float>);
InstantiateUMFPACK(BlockSparseMatrix<double>);
InstantiateUMFPACK(BlockSparseMatrix<float>);
_______________________________________________
dealii mailing list http://poisson.dealii.org/mailman/listinfo/dealii