From bd4fc625235602c867178e141739954b9d6bf4a5 Mon Sep 17 00:00:00 2001 From: guido Date: Fri, 2 Jul 1999 09:17:28 +0000 Subject: [PATCH] Raw access functions saver than Wolfgang's git-svn-id: https://svn.dealii.org/trunk@1527 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/lac/include/lac/sparse_matrix.h | 95 +++++++++++++++++++++---- 1 file changed, 83 insertions(+), 12 deletions(-) diff --git a/deal.II/lac/include/lac/sparse_matrix.h b/deal.II/lac/include/lac/sparse_matrix.h index f16d3070cd..729a43ac95 100644 --- a/deal.II/lac/include/lac/sparse_matrix.h +++ b/deal.II/lac/include/lac/sparse_matrix.h @@ -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 inline @@ -1240,7 +1298,8 @@ number SparseMatrix::diag_element (const unsigned int i) const { template inline -number & SparseMatrix::diag_element (const unsigned int i) { +number & SparseMatrix::diag_element (const unsigned int i) +{ Assert (cols != 0, ExcMatrixNotInitialized()); Assert (m() == n(), ExcMatrixNotSquare()); Assert (i::diag_element (const unsigned int i) { }; +template +inline +number +SparseMatrix::raw_entry(unsigned int row, unsigned int index) const +{ + Assert(rowrows, ExcIndexRange(row,0,cols->rows)); + Assert(indexrow_length(row), ExcIndexRange(index,0,cols->row_length(row))); + + return val[cols->rowstart[row]+index]; +} + + template inline -- 2.39.5