]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
BlockMatrixEZ operational
authorguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 11 Mar 2003 13:48:57 +0000 (13:48 +0000)
committerguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 11 Mar 2003 13:48:57 +0000 (13:48 +0000)
git-svn-id: https://svn.dealii.org/trunk@7314 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/block_sparse_matrix_ez.h
deal.II/lac/include/lac/sparse_matrix_ez.h
deal.II/lac/include/lac/sparse_matrix_ez.templates.h
deal.II/lac/source/sparse_matrix_ez.double.cc
deal.II/lac/source/sparse_matrix_ez.float.cc

index 7c883083f9db4c58b2fd621873d800aea67b18c6..1356c11d85eb019e42793a8d012b2030fac21ebb 100644 (file)
@@ -328,10 +328,10 @@ template <typename Number>
 inline
 SparseMatrixEZ<Number> &
 BlockSparseMatrixEZ<Number>::block (const unsigned int row,
-                                 const unsigned int column)
+                                   const unsigned int column)
 {
-  Assert (row<n_rows(), ExcIndexRange (row, 0, n_rows()));
-  Assert (column<n_cols(), ExcIndexRange (column, 0, n_cols()));
+  Assert (row<n_block_rows(), ExcIndexRange (row, 0, n_block_rows()));
+  Assert (column<n_block_cols(), ExcIndexRange (column, 0, n_block_cols()));
   
   return blocks[row][column];
 };
@@ -342,10 +342,10 @@ template <typename Number>
 inline
 const SparseMatrixEZ<Number> &
 BlockSparseMatrixEZ<Number>::block (const unsigned int row,
-                                 const unsigned int column) const
+                                   const unsigned int column) const
 {
-  Assert (row<n_rows(), ExcIndexRange (row, 0, n_rows()));
-  Assert (column<n_cols(), ExcIndexRange (column, 0, n_cols()));
+  Assert (row<n_block_rows(), ExcIndexRange (row, 0, n_block_rows()));
+  Assert (column<n_block_cols(), ExcIndexRange (column, 0, n_block_cols()));
   
   return blocks[row][column];
 };
index 0d92598250fe46d32ce75d48caf39c328b6abdc3..96ea314fe90c6b3358e99f06d5de808dd4fabd71 100644 (file)
@@ -886,9 +886,13 @@ class SparseMatrixEZ : public Subscriptor
                                      */
     DeclException2 (ExcInvalidEntry,
                    int, int,
-                   << "The entry with index <" << arg1 << ',' << arg2
-                   << "> does not exist.");
+                   << "The entry with index (" << arg1 << ',' << arg2
+                   << ") does not exist.");
 
+    DeclException2(ExcEntryAllocationFailure,
+                  int, int,
+                  << "An entry with index (" << arg1 << ',' << arg2
+                  << ") cannot be allocated.");
   private:
                                     /**
                                      * Find an entry. Return a
@@ -1222,6 +1226,9 @@ SparseMatrixEZ<number>::allocate (const unsigned int row,
     {
       if (end >= row_info[row+1].start)
        {
+         // Failure if increment 0
+         Assert(increment!=0,ExcEntryAllocationFailure(row,col));
+         
                                           // Insert new entries
          data.insert(data.begin()+end, increment, Entry());
                                           // Update starts of
@@ -1441,48 +1448,5 @@ SparseMatrixEZ<number>::conjugate_add (const MATRIXA& A,
 }
 
 
-template <typename number>
-template <class STREAM>
-void
-SparseMatrixEZ<number>::print_statistics(STREAM& out, bool full)
-{
-  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 entries_used = 0;
-  unsigned int max_length = 0;
-  for (; row != endrow ; ++ row)
-    {
-      entries_used += row->length;
-      if (max_length < row->length)
-       max_length = row->length;
-    }
-  
-                                  // Number of entries allocated is
-                                  // position of last entry used
-  --row;
-  unsigned int entries_alloc = row->start + row->length;
-
-  out << "SparseMatrixEZ:used     entries:" << entries_used << std::endl
-      << "SparseMatrixEZ:alloc    entries:" << entries_alloc << std::endl
-      << "SparseMatrixEZ:reserved entries:" << data.capacity() << std::endl;
-  
-  if (full)
-    {
-      std::vector<unsigned int> length_used (max_length+1);
-      
-      for (row = row_info.begin() ; row != endrow; ++row)
-       {
-         ++length_used[row->length];
-       }
-      for (unsigned int i=0; i< length_used.size();++i)
-       if (length_used[i] != 0)
-         out << "SparseMatrixEZ:entries\t" << i
-             << "\trows\t" << length_used[i]
-             << std::endl;
-    }
-}
-
 #endif
 /*----------------------------   sparse_matrix.h     ---------------------------*/
index b492c30fad8f3edcf97ab42adee237f00466af0e..40b6bc6a819c4d96afd33b933f6f66f1078259da 100644 (file)
@@ -55,9 +55,9 @@ SparseMatrixEZ<number>::~SparseMatrixEZ()
 
 template <typename number>
 SparseMatrixEZ<number>&
-SparseMatrixEZ<number>::operator= (const SparseMatrixEZ<number>&)
+SparseMatrixEZ<number>::operator= (const SparseMatrixEZ<number>& m)
 {
-  Assert (false, ExcNotImplemented());
+  Assert (m.empty(), ExcInvalidConstructorCall());
   return *this;
 }
 
@@ -74,8 +74,6 @@ SparseMatrixEZ<number>::reinit(unsigned int n_rows,
     default_row_length = 5;
   if (default_increment == Entry::invalid)
     default_increment = 4;
-  if (default_increment == 0)
-    default_increment = 4;
   increment = default_increment;
   
   n_columns = n_cols;
@@ -360,4 +358,48 @@ SparseMatrixEZ<number>::memory_consumption() const
 }
 
 
+template <typename number>
+template <class STREAM>
+void
+SparseMatrixEZ<number>::print_statistics(STREAM& out, bool full)
+{
+  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 entries_used = 0;
+  unsigned int max_length = 0;
+  for (; row != endrow ; ++ row)
+    {
+      entries_used += row->length;
+      if (max_length < row->length)
+       max_length = row->length;
+    }
+  
+                                  // Number of entries allocated is
+                                  // position of last entry used
+  --row;
+  unsigned int entries_alloc = row->start + row->length;
+
+  out << "SparseMatrixEZ:used     entries:" << entries_used << std::endl
+      << "SparseMatrixEZ:alloc    entries:" << entries_alloc << std::endl
+      << "SparseMatrixEZ:reserved entries:" << data.capacity() << std::endl;
+  
+  if (full)
+    {
+      std::vector<unsigned int> length_used (max_length+1);
+      
+      for (row = row_info.begin() ; row != endrow; ++row)
+       {
+         ++length_used[row->length];
+       }
+      for (unsigned int i=0; i< length_used.size();++i)
+       if (length_used[i] != 0)
+         out << "SparseMatrixEZ:entries\t" << i
+             << "\trows\t" << length_used[i]
+             << std::endl;
+    }
+}
+
+
 #endif // __deal2__sparse_matrix_ez_templates_h
index e42957d5e97a7b54b55e2e23a59b41e35e1ba687..92530119b42767747f6217eb1e29e0b12f18c650 100644 (file)
@@ -1,4 +1,4 @@
-//----------------------------  sparse_matrix_ez.double.cc  ---------------------------
+//------------------------------------------------------------------------
 //    $Id$
 //    Version: $Name$
 //
@@ -9,14 +9,19 @@
 //    to the file deal.II/doc/license.html for the  text  and
 //    further information on this license.
 //
-//----------------------------  sparse_matrix_ez.double.cc  ---------------------------
+//------------------------------------------------------------------------
 
 
+#include <base/logstream.h>
 #include <lac/sparse_matrix_ez.templates.h>
+#include <iostream>
 
 #define TYPEMAT double
 
 template class SparseMatrixEZ<TYPEMAT>;
+template void SparseMatrixEZ<TYPEMAT>::print_statistics(ostream&, bool);
+template void SparseMatrixEZ<TYPEMAT>::print_statistics(LogStream&, bool);
+
 
 #define TYPE2 float
 
index e20c9c683431c772dc3d6fe7d24714d9848a303e..ddb2ddde1c6667fb997b4506e1eb4a64bd1a213b 100644 (file)
@@ -1,4 +1,4 @@
-//----------------------------  sparse_matrix_ez.float.cc  ---------------------------
+//-------------------------------------------------------------------------
 //    $Id$
 //    Version: $Name$
 //
@@ -9,14 +9,17 @@
 //    to the file deal.II/doc/license.html for the  text  and
 //    further information on this license.
 //
-//----------------------------  sparse_matrix_ez.float.cc  ---------------------------
-
+//-------------------------------------------------------------------------
 
+#include <base/logstream.h>
 #include <lac/sparse_matrix_ez.templates.h>
+#include <iostream>
 
 #define TYPEMAT float
 
 template class SparseMatrixEZ<TYPEMAT>;
+template void SparseMatrixEZ<TYPEMAT>::print_statistics(ostream&, bool);
+template void SparseMatrixEZ<TYPEMAT>::print_statistics(LogStream&, bool);
 
 #define TYPE2 float
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.