]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Raw access functions saver than Wolfgang's
authorguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 2 Jul 1999 09:17:28 +0000 (09:17 +0000)
committerguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 2 Jul 1999 09:17:28 +0000 (09:17 +0000)
git-svn-id: https://svn.dealii.org/trunk@1527 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/sparse_matrix.h

index f16d3070cdc4df8a0e9e9b5d096387ad99fb222a..729a43ac9568c26c0b7bd8662492c073dc15e283 100644 (file)
@@ -287,6 +287,18 @@ class SparseMatrixStruct : public Subscriptor
                                      */
     unsigned int n_cols () const;
 
+                                    /**
+                                     * Number of entries in a specific row.
+                                     */
+    unsigned int row_length(unsigned int row) const;
+
+                                    /**
+                                     * Access to column nuber field.
+                                     * Return the column number of
+                                     * the #index#th entry in #row#.
+                                     */
+    unsigned int column_number(unsigned int row, unsigned int index) const;
+
                                     /**
                                      * Compute the bandwidth of the matrix
                                      * represented by this structure. The
@@ -318,10 +330,14 @@ class SparseMatrixStruct : public Subscriptor
     bool is_compressed () const;
     
                                     /**
-                                     * This is kind of an expert mode: get
+                                     * This is kind of an expert mode. Get
                                      * access to the rowstart array, but
                                      * readonly.
                                      *
+                                     * Use of this function is highly
+                                     * deprecated. Use #row_length#
+                                     * and #column_number# instead.
+                                     *
                                      * Though the return value is declared
                                      * #const#, you should be aware that it
                                      * may change if you call any nonconstant
@@ -336,8 +352,7 @@ class SparseMatrixStruct : public Subscriptor
                                      * If you change the layout yourself, you
                                      * should also rename this function to
                                      * avoid programs relying on outdated
-                                     * information!
-                                     */
+                                     * information!  */
     const unsigned int * get_rowstart_indices () const;
 
                                     /**
@@ -345,6 +360,10 @@ class SparseMatrixStruct : public Subscriptor
                                      * access to the colnums array, but
                                      * readonly.
                                      *
+                                     * Use of this function is highly
+                                     * deprecated. Use #row_length#
+                                     * and #column_number# instead.
+                                     *
                                      * Though the return value is declared
                                      * #const#, you should be aware that it
                                      * may change if you call any nonconstant
@@ -792,9 +811,21 @@ class SparseMatrix : public Subscriptor
                                      * reference. You're sure what you do?
                                      */
     number & diag_element (const unsigned int i);
+
+                                    /**
+                                     * Access to values in internal
+                                     * mode.  Returns the value of
+                                     * the #index#th entry in
+                                     * #row#. Here, #index refers to
+                                     * the internal representation of
+                                     * the matrix, not the column. Be
+                                     * sure to understand what you are
+                                     * doing here.
+                                     */
+    number raw_entry(unsigned int row, unsigned int index) const;
     
                                     /**
-                                     * This is kind of an expert mode: get
+                                     * This is for hackers. Get
                                      * access to the #i#th element of this
                                      * matrix. The elements are stored in
                                      * a consecutive way, refer to the
@@ -808,8 +839,7 @@ class SparseMatrix : public Subscriptor
                                      * If you change the layout yourself, you
                                      * should also rename this function to
                                      * avoid programs relying on outdated
-                                     * information!
-                                     */
+                                     * information!  */
     number global_entry (const unsigned int i) const;
 
                                     /**
@@ -1126,39 +1156,67 @@ class SparseMatrix : public Subscriptor
 
 
 inline
-unsigned int SparseMatrixStruct::n_rows () const {
+unsigned int
+SparseMatrixStruct::n_rows () const
+{
   return rows;
 };
 
 
 
 inline
-unsigned int SparseMatrixStruct::n_cols () const {
+unsigned int
+SparseMatrixStruct::n_cols () const
+{
   return cols;
 };
 
 
 
 inline
-bool SparseMatrixStruct::is_compressed () const {
+bool
+SparseMatrixStruct::is_compressed () const
+{
   return compressed;
 };
 
 
 
 inline
-const unsigned int * SparseMatrixStruct::get_rowstart_indices () const {
+const unsigned int *
+SparseMatrixStruct::get_rowstart_indices () const
+{
   return rowstart;
 };
 
 
 
 inline
-const int * SparseMatrixStruct::get_column_numbers () const {
+const int *
+SparseMatrixStruct::get_column_numbers () const
+{
   return colnums;
 };
 
 
+inline
+unsigned int
+SparseMatrixStruct::row_length(unsigned int row) const
+{
+  Assert(row<rows, ExcIndexRange(row,0,rows));
+  return rowstart[row+1]-rowstart[row];
+}
+
+inline
+unsigned int
+SparseMatrixStruct::column_number(unsigned int row, unsigned int index) const
+{
+  Assert(row<rows, ExcIndexRange(row,0,rows));
+  Assert(index<row_length(row), ExcIndexRange(index,0,row_length(row)));
+
+  return colnums[rowstart[row]+index];
+}
+
 
 template <typename number>
 inline
@@ -1240,7 +1298,8 @@ number SparseMatrix<number>::diag_element (const unsigned int i) const {
 
 template <typename number>
 inline
-number & SparseMatrix<number>::diag_element (const unsigned int i) {
+number & SparseMatrix<number>::diag_element (const unsigned int i)
+{
   Assert (cols != 0, ExcMatrixNotInitialized());
   Assert (m() == n(), ExcMatrixNotSquare());
   Assert (i<max_len, ExcInvalidIndex1(i));
@@ -1252,6 +1311,18 @@ number & SparseMatrix<number>::diag_element (const unsigned int i) {
 };
 
 
+template <typename number>
+inline
+number
+SparseMatrix<number>::raw_entry(unsigned int row, unsigned int index) const
+{
+  Assert(row<cols->rows, ExcIndexRange(row,0,cols->rows));
+  Assert(index<cols->row_length(row), ExcIndexRange(index,0,cols->row_length(row)));
+
+  return val[cols->rowstart[row]+index];
+}
+
+
 
 template <typename number>
 inline

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.