- PETScWrappers::MPI::Vector constructors and reinit variants.
- SparseMatrixIterators::Accessor and SparseMatrixIterators::Iterator
constructors.
- - SparseMatrix::raw_entry.
+ - SparseMatrix::raw_entry and SparseMatrix::global_entry.
<br>
<em>With headers in <code>deal.II/deal.II/</code>:</em>
// ---------------------------------------------------------------------
//
-// Copyright (C) 1999 - 2014 by the deal.II authors
+// Copyright (C) 1999 - 2015 by the deal.II authors
//
// This file is part of the deal.II library.
//
*/
number &diag_element (const size_type i);
- /**
- * This is for hackers. Get access to the <i>i</i>th element of this matrix.
- * The elements are stored in a consecutive way, refer to the
- * SparsityPattern class for more details.
- *
- * You should use this interface very carefully and only if you are
- * absolutely sure to know what you do. You should also note that the
- * structure of these arrays may change over time. If you change the layout
- * yourself, you should also rename this function to avoid programs relying
- * on outdated information!
- *
- * @deprecated Use iterator or const_iterator instead!
- */
- number global_entry (const size_type i) const DEAL_II_DEPRECATED;
-
- /**
- * Same as above, but with write access. You certainly know what you do?
- *
- * @deprecated Use iterator or const_iterator instead!
- */
- number &global_entry (const size_type i) DEAL_II_DEPRECATED;
-
//@}
/**
* @name Multiplications
-template <typename number>
-inline
-number SparseMatrix<number>::global_entry (const size_type j) const
-{
- Assert (cols != 0, ExcNotInitialized());
- Assert (j < cols->n_nonzero_elements(),
- ExcIndexRange (j, 0, cols->n_nonzero_elements()));
-
- return val[j];
-}
-
-
-
-template <typename number>
-inline
-number &SparseMatrix<number>::global_entry (const size_type j)
-{
- Assert (cols != 0, ExcNotInitialized());
- Assert (j < cols->n_nonzero_elements(),
- ExcIndexRange (j, 0, cols->n_nonzero_elements()));
-
- return val[j];
-}
-
-
-
template <typename number>
template <typename ForwardIterator>
void
// ---------------------------------------------------------------------
//
-// Copyright (C) 2000 - 2014 by the deal.II authors
+// Copyright (C) 2000 - 2015 by the deal.II authors
//
// This file is part of the deal.II library.
//
// multiply matrix by 100 to
// make test more sensitive
deallog << "Matrix: " << std::endl;
- for (unsigned int i=0; i<matrix.n_nonzero_elements(); ++i)
- deallog << matrix.global_entry(i) * 100
+ for (SparseMatrix<double>::const_iterator p=matrix.begin();
+ p!=matrix.end(); ++p)
+ deallog << p->value() * 100
<< std::endl;
deallog << "RHS vector: " << std::endl;
// ---------------------------------------------------------------------
//
-// Copyright (C) 2000 - 2014 by the deal.II authors
+// Copyright (C) 2000 - 2015 by the deal.II authors
//
// This file is part of the deal.II library.
//
// multiply matrix by 100 to
// make test more sensitive
deallog << "Matrix: " << std::endl;
- for (unsigned int i=0; i<matrix.n_nonzero_elements(); ++i)
- deallog << matrix.global_entry(i) * 100
+ for (SparseMatrix<double>::const_iterator p=matrix.begin();
+ p!=matrix.end(); ++p)
+ deallog << p->value() * 100
<< std::endl;
}
// multiply matrix by 100 to
// make test more sensitive
deallog << "Matrix: " << std::endl;
- for (unsigned int i=0; i<matrix.n_nonzero_elements(); ++i)
- deallog << matrix.global_entry(i) * 100
+ for (SparseMatrix<double>::const_iterator p=matrix.begin();
+ p!=matrix.end(); ++p)
+ deallog << p->value() * 100
<< std::endl;
deallog << "RHS vector: " << std::endl;
// multiply matrix by 100 to
// make test more sensitive
deallog << "Matrix: " << std::endl;
- for (unsigned int i=0; i<matrix.n_nonzero_elements(); ++i)
- deallog << matrix.global_entry(i) * 100
+ for (SparseMatrix<double>::const_iterator p=matrix.begin();
+ p!=matrix.end(); ++p)
+ deallog << p->value() * 100
<< std::endl;
}
// ---------------------------------------------------------------------
//
-// Copyright (C) 2000 - 2014 by the deal.II authors
+// Copyright (C) 2000 - 2015 by the deal.II authors
//
// This file is part of the deal.II library.
//
// multiply matrix by 100 to
// make test more sensitive
deallog << "Matrix: " << std::endl;
- for (unsigned int i=0; i<matrix.n_nonzero_elements(); ++i)
- deallog << matrix.global_entry(i) * 100
+ for (SparseMatrix<double>::const_iterator p=matrix.begin();
+ p!=matrix.end(); ++p)
+ deallog << p->value() * 100
<< std::endl;
deallog << "RHS vector: " << std::endl;
// ---------------------------------------------------------------------
//
-// Copyright (C) 2000 - 2014 by the deal.II authors
+// Copyright (C) 2000 - 2015 by the deal.II authors
//
// This file is part of the deal.II library.
//
// multiply matrix by 100 to
// make test more sensitive
deallog << "Matrix: " << std::endl;
- for (unsigned int i=0; i<matrix.n_nonzero_elements(); ++i)
- deallog << matrix.global_entry(i) * 100
+ for (SparseMatrix<double>::const_iterator p=matrix.begin();
+ p!=matrix.end(); ++p)
+ deallog << p->value() * 100
<< std::endl;
}
// multiply matrix by 100 to
// make test more sensitive
deallog << "Matrix: " << std::endl;
- for (unsigned int i=0; i<matrix.n_nonzero_elements(); ++i)
- deallog << matrix.global_entry(i) * 100
+ for (SparseMatrix<double>::const_iterator p=matrix.begin();
+ p!=matrix.end(); ++p)
+ deallog << p->value() * 100
<< std::endl;
deallog << "RHS vector: " << std::endl;
// multiply matrix by 100 to
// make test more sensitive
deallog << "Matrix: " << std::endl;
- for (unsigned int i=0; i<matrix.n_nonzero_elements(); ++i)
- deallog << matrix.global_entry(i) * 100
+ for (SparseMatrix<double>::const_iterator p=matrix.begin();
+ p!=matrix.end(); ++p)
+ deallog << p->value() * 100
<< std::endl;
}
// ---------------------------------------------------------------------
//
-// Copyright (C) 2000 - 2014 by the deal.II authors
+// Copyright (C) 2000 - 2015 by the deal.II authors
//
// This file is part of the deal.II library.
//
// multiply matrix by 100 to
// make test more sensitive
deallog << "Matrix: " << std::endl;
- for (unsigned int i=0; i<matrix.n_nonzero_elements(); ++i)
- deallog << matrix.global_entry(i) * 100
+ for (SparseMatrix<double>::const_iterator p=matrix.begin();
+ p!=matrix.end(); ++p)
+ deallog << p->value() * 100
<< std::endl;
deallog << "RHS vector: " << std::endl;
// ---------------------------------------------------------------------
//
-// Copyright (C) 2000 - 2014 by the deal.II authors
+// Copyright (C) 2000 - 2015 by the deal.II authors
//
// This file is part of the deal.II library.
//
// multiply matrix by 100 to
// make test more sensitive
deallog << "Matrix: " << std::endl;
- for (unsigned int i=0; i<matrix.n_nonzero_elements(); ++i)
- deallog << matrix.global_entry(i) * 100
+ for (SparseMatrix<double>::const_iterator p=matrix.begin();
+ p!=matrix.end(); ++p)
+ deallog << p->value() * 100
<< std::endl;
}
// multiply matrix by 100 to
// make test more sensitive
deallog << "Matrix: " << std::endl;
- for (unsigned int i=0; i<matrix.n_nonzero_elements(); ++i)
- deallog << matrix.global_entry(i) * 100
+ for (SparseMatrix<double>::const_iterator p=matrix.begin();
+ p!=matrix.end(); ++p)
+ deallog << p->value() * 100
<< std::endl;
deallog << "RHS vector: " << std::endl;
// multiply matrix by 100 to
// make test more sensitive
deallog << "Matrix: " << std::endl;
- for (unsigned int i=0; i<matrix.n_nonzero_elements(); ++i)
- deallog << matrix.global_entry(i) * 100
+ for (SparseMatrix<double>::const_iterator p=matrix.begin();
+ p!=matrix.end(); ++p)
+ deallog << p->value() * 100
<< std::endl;
}
// ---------------------------------------------------------------------
//
-// Copyright (C) 2000 - 2014 by the deal.II authors
+// Copyright (C) 2000 - 2015 by the deal.II authors
//
// This file is part of the deal.II library.
//
// multiply matrix by 100 to
// make test more sensitive
deallog << "Matrix: " << std::endl;
- for (unsigned int i=0; i<matrix.n_nonzero_elements(); ++i)
- deallog << matrix.global_entry(i) * 100
+ for (SparseMatrix<double>::const_iterator p=matrix.begin();
+ p!=matrix.end(); ++p)
+ deallog << p->value() * 100
<< std::endl;
deallog << "RHS vector: " << std::endl;
// ---------------------------------------------------------------------
//
-// Copyright (C) 2000 - 2014 by the deal.II authors
+// Copyright (C) 2000 - 2015 by the deal.II authors
//
// This file is part of the deal.II library.
//
// multiply matrix by 100 to
// make test more sensitive
deallog << "Matrix: " << std::endl;
- for (unsigned int i=0; i<matrix.n_nonzero_elements(); ++i)
- deallog << matrix.global_entry(i) * 100
+ for (SparseMatrix<double>::const_iterator p=matrix.begin();
+ p!=matrix.end(); ++p)
+ deallog << p->value() * 100
<< std::endl;
}
// multiply matrix by 100 to
// make test more sensitive
deallog << "Matrix: " << std::endl;
- for (unsigned int i=0; i<matrix.n_nonzero_elements(); ++i)
- deallog << matrix.global_entry(i) * 100
+ for (SparseMatrix<double>::const_iterator p=matrix.begin();
+ p!=matrix.end(); ++p)
+ deallog << p->value() * 100
<< std::endl;
deallog << "RHS vector: " << std::endl;
// multiply matrix by 100 to
// make test more sensitive
deallog << "Matrix: " << std::endl;
- for (unsigned int i=0; i<matrix.n_nonzero_elements(); ++i)
- deallog << matrix.global_entry(i) * 100
+ for (SparseMatrix<double>::const_iterator p=matrix.begin();
+ p!=matrix.end(); ++p)
+ deallog << p->value() * 100
<< std::endl;
}
// multiply matrix by 100 to
// make test more sensitive
deallog << "Matrix: " << std::endl;
- for (unsigned int i=0; i<matrix.n_nonzero_elements(); ++i)
- deallog << matrix.global_entry(i) * 100
+ for (SparseMatrix<double>::const_iterator p=matrix.begin();
+ p!=matrix.end(); ++p)
+ deallog << p->value() * 100
<< std::endl;
}
// range of 1 or below,
// multiply matrix by 100 to
// make test more sensitive
- for (unsigned int i=0; i<matrix.n_nonzero_elements(); ++i)
- matrix.global_entry(i) *= 100;
+ matrix *= 100;
// finally write out matrix
matrix.print (deallog.get_file_stream());
// range of 1 or below,
// multiply matrix by 100 to
// make test more sensitive
- for (unsigned int i=0; i<matrix.n_nonzero_elements(); ++i)
- deallog.get_file_stream() << matrix.global_entry(i) * 100
- << std::endl;
+ for (SparseMatrix<double>::const_iterator p=matrix.begin();
+ p!=matrix.end(); ++p)
+ deallog.get_file_stream() << p->value() * 100
+ << std::endl;
};
if (dim > 1)
// reduce the amount of data
// written out a little bit, only
// write every so-many-th element
- for (unsigned int i=0; i<A1.n_nonzero_elements(); ++i)
+ SparseMatrix<double>::const_iterator p1 = A1.begin(),
+ p2 = A2.begin(),
+ p3 = A3.begin();
+ for (unsigned int i=0; i<A1.n_nonzero_elements(); ++i, ++p1, ++p2, ++p3)
{
if (i % (dim*dim*dim) == 0)
- deallog << i << ' ' << A1.global_entry(i) << std::endl;
- Assert (A1.global_entry(i) == A2.global_entry(i),
+ deallog << i << ' ' << p1->value() << std::endl;
+ Assert (p1->value() == p2->value(),
ExcInternalError());
- Assert (A1.global_entry(i) == A3.global_entry(i),
+ Assert (p1->value() == p3->value(),
ExcInternalError());
};
}
// ---------------------------------------------------------------------
//
-// Copyright (C) 2001 - 2014 by the deal.II authors
+// Copyright (C) 2001 - 2015 by the deal.II authors
//
// This file is part of the deal.II library.
//
// reduce the amount of data
// written out a little bit, only
// write every so-many-th element
- for (unsigned int i=0; i<A2.n_nonzero_elements(); ++i)
+ SparseMatrix<double>::const_iterator p2 = A2.begin(),
+ p3 = A3.begin();
+ for (unsigned int i=0; i<A2.n_nonzero_elements(); ++i, ++p2, ++p3)
{
if (i % (dim*dim*dim) == 0)
- deallog << i << ' ' << A2.global_entry(i) << std::endl;
- Assert (A3.global_entry(i) == A2.global_entry(i),
+ deallog << i << ' ' << p2->value() << std::endl;
+ Assert (p3->value() == p2->value(),
ExcInternalError());
};
}
// ---------------------------------------------------------------------
//
-// Copyright (C) 2000 - 2014 by the deal.II authors
+// Copyright (C) 2000 - 2015 by the deal.II authors
//
// This file is part of the deal.II library.
//
// multiply matrix by 100 to
// make test more sensitive
deallog << "Matrix: " << std::endl;
- for (unsigned int i=0; i<matrix.n_nonzero_elements(); ++i)
- deallog << matrix.global_entry(i) * 100
+ for (SparseMatrix<double>::const_iterator p=matrix.begin();
+ p!=matrix.end(); ++p)
+ deallog << p->value() * 100
<< std::endl;
deallog << "RHS vector: " << std::endl;
// ---------------------------------------------------------------------
//
-// Copyright (C) 2000 - 2014 by the deal.II authors
+// Copyright (C) 2000 - 2015 by the deal.II authors
//
// This file is part of the deal.II library.
//
// multiply matrix by 100 to
// make test more sensitive
deallog << "Matrix: " << std::endl;
- for (unsigned int i=0; i<matrix.n_nonzero_elements(); ++i)
- deallog << matrix.global_entry(i) * 100
+ for (SparseMatrix<double>::const_iterator p=matrix.begin();
+ p!=matrix.end(); ++p)
+ deallog << p->value() * 100
<< std::endl;
}
// multiply matrix by 100 to
// make test more sensitive
deallog << "Matrix: " << std::endl;
- for (unsigned int i=0; i<matrix.n_nonzero_elements(); ++i)
- deallog << matrix.global_entry(i) * 100
+ for (SparseMatrix<double>::const_iterator p=matrix.begin();
+ p!=matrix.end(); ++p)
+ deallog << p->value() * 100
<< std::endl;
deallog << "RHS vector: " << std::endl;
// multiply matrix by 100 to
// make test more sensitive
deallog << "Matrix: " << std::endl;
- for (unsigned int i=0; i<matrix.n_nonzero_elements(); ++i)
- deallog << matrix.global_entry(i) * 100
+ for (SparseMatrix<double>::const_iterator p=matrix.begin();
+ p!=matrix.end(); ++p)
+ deallog << p->value() * 100
<< std::endl;
}
// ---------------------------------------------------------------------
//
-// Copyright (C) 2000 - 2014 by the deal.II authors
+// Copyright (C) 2000 - 2015 by the deal.II authors
//
// This file is part of the deal.II library.
//
// multiply matrix by 100 to
// make test more sensitive
deallog << "Matrix: " << std::endl;
- for (unsigned int i=0; i<matrix.n_nonzero_elements(); ++i)
- deallog << matrix.global_entry(i) * 100
+ for (SparseMatrix<double>::const_iterator p=matrix.begin();
+ p!=matrix.end(); ++p)
+ deallog << p->value() * 100
<< std::endl;
deallog << "RHS vector: " << std::endl;
// ---------------------------------------------------------------------
//
-// Copyright (C) 2000 - 2014 by the deal.II authors
+// Copyright (C) 2000 - 2015 by the deal.II authors
//
// This file is part of the deal.II library.
//
// multiply matrix by 100 to
// make test more sensitive
deallog << "Matrix: " << std::endl;
- for (unsigned int i=0; i<matrix.n_nonzero_elements(); ++i)
- deallog << matrix.global_entry(i) * 100
+ for (SparseMatrix<double>::const_iterator p=matrix.begin();
+ p!=matrix.end(); ++p)
+ deallog << p->value() * 100
<< std::endl;
}
// multiply matrix by 100 to
// make test more sensitive
deallog << "Matrix: " << std::endl;
- for (unsigned int i=0; i<matrix.n_nonzero_elements(); ++i)
- deallog << matrix.global_entry(i) * 100
+ for (SparseMatrix<double>::const_iterator p=matrix.begin();
+ p!=matrix.end(); ++p)
+ deallog << p->value() * 100
<< std::endl;
deallog << "RHS vector: " << std::endl;
// multiply matrix by 100 to
// make test more sensitive
deallog << "Matrix: " << std::endl;
- for (unsigned int i=0; i<matrix.n_nonzero_elements(); ++i)
- deallog << matrix.global_entry(i) * 100
+ for (SparseMatrix<double>::const_iterator p=matrix.begin();
+ p!=matrix.end(); ++p)
+ deallog << p->value() * 100
<< std::endl;
}
// ---------------------------------------------------------------------
//
-// Copyright (C) 2000 - 2014 by the deal.II authors
+// Copyright (C) 2000 - 2015 by the deal.II authors
//
// This file is part of the deal.II library.
//
// multiply matrix by 100 to
// make test more sensitive
deallog << "Matrix: " << std::endl;
- for (unsigned int i=0; i<matrix.n_nonzero_elements(); ++i)
- deallog << matrix.global_entry(i) * 100
+ for (SparseMatrix<double>::const_iterator p=matrix.begin();
+ p!=matrix.end(); ++p)
+ deallog << p->value() * 100
<< std::endl;
deallog << "RHS vector: " << std::endl;
// ---------------------------------------------------------------------
//
-// Copyright (C) 2000 - 2014 by the deal.II authors
+// Copyright (C) 2000 - 2015 by the deal.II authors
//
// This file is part of the deal.II library.
//
// multiply matrix by 100 to
// make test more sensitive
deallog << "Matrix: " << std::endl;
- for (unsigned int i=0; i<matrix.n_nonzero_elements(); ++i)
- deallog << matrix.global_entry(i) * 100
+ for (SparseMatrix<double>::const_iterator p=matrix.begin();
+ p!=matrix.end(); ++p)
+ deallog << p->value() * 100
<< std::endl;
}
// multiply matrix by 100 to
// make test more sensitive
deallog << "Matrix: " << std::endl;
- for (unsigned int i=0; i<matrix.n_nonzero_elements(); ++i)
- deallog << matrix.global_entry(i) * 100
+ for (SparseMatrix<double>::const_iterator p=matrix.begin();
+ p!=matrix.end(); ++p)
+ deallog << p->value() * 100
<< std::endl;
deallog << "RHS vector: " << std::endl;
// multiply matrix by 100 to
// make test more sensitive
deallog << "Matrix: " << std::endl;
- for (unsigned int i=0; i<matrix.n_nonzero_elements(); ++i)
- deallog << matrix.global_entry(i) * 100
+ for (SparseMatrix<double>::const_iterator p=matrix.begin();
+ p!=matrix.end(); ++p)
+ deallog << p->value() * 100
<< std::endl;
}
// ---------------------------------------------------------------------
//
-// Copyright (C) 2000 - 2014 by the deal.II authors
+// Copyright (C) 2000 - 2015 by the deal.II authors
//
// This file is part of the deal.II library.
//
// multiply matrix by 100 to
// make test more sensitive
deallog << "Matrix: " << std::endl;
- for (unsigned int i=0; i<matrix.n_nonzero_elements(); ++i)
- deallog << matrix.global_entry(i) * 100
+ for (SparseMatrix<double>::const_iterator p=matrix.begin();
+ p!=matrix.end(); ++p)
+ deallog << p->value() * 100
<< std::endl;
deallog << "RHS vector: " << std::endl;
// ---------------------------------------------------------------------
//
-// Copyright (C) 2000 - 2014 by the deal.II authors
+// Copyright (C) 2000 - 2015 by the deal.II authors
//
// This file is part of the deal.II library.
//
// multiply matrix by 100 to
// make test more sensitive
deallog << "Matrix: " << std::endl;
- for (unsigned int i=0; i<matrix.n_nonzero_elements(); ++i)
- deallog << matrix.global_entry(i) * 100
+ for (SparseMatrix<double>::const_iterator p=matrix.begin();
+ p!=matrix.end(); ++p)
+ deallog << p->value() * 100
<< std::endl;
}
// multiply matrix by 100 to
// make test more sensitive
deallog << "Matrix: " << std::endl;
- for (unsigned int i=0; i<matrix.n_nonzero_elements(); ++i)
- deallog << matrix.global_entry(i) * 100
+ for (SparseMatrix<double>::const_iterator p=matrix.begin();
+ p!=matrix.end(); ++p)
+ deallog << p->value() * 100
<< std::endl;
deallog << "RHS vector: " << std::endl;
// multiply matrix by 100 to
// make test more sensitive
deallog << "Matrix: " << std::endl;
- for (unsigned int i=0; i<matrix.n_nonzero_elements(); ++i)
- deallog << matrix.global_entry(i) * 100
+ for (SparseMatrix<double>::const_iterator p=matrix.begin();
+ p!=matrix.end(); ++p)
+ deallog << p->value() * 100
<< std::endl;
}
// multiply matrix by 100 to
// make test more sensitive
deallog << "Matrix: " << std::endl;
- for (unsigned int i=0; i<matrix.n_nonzero_elements(); ++i)
- deallog << matrix.global_entry(i) * 100
+ for (SparseMatrix<double>::const_iterator p=matrix.begin();
+ p!=matrix.end(); ++p)
+ deallog << p->value() * 100
<< std::endl;
}
// range of 1 or below,
// multiply matrix by 100 to
// make test more sensitive
- for (unsigned int i=0; i<matrix.n_nonzero_elements(); ++i)
- matrix.global_entry(i) *= 100;
+ matrix *= 100;
// finally write out matrix
matrix.print (deallog.get_file_stream());
// range of 1 or below,
// multiply matrix by 100 to
// make test more sensitive
- for (unsigned int i=0; i<matrix.n_nonzero_elements(); ++i)
- deallog.get_file_stream() << matrix.global_entry(i) * 100
- << std::endl;
+ for (SparseMatrix<double>::const_iterator p=matrix.begin();
+ p!=matrix.end(); ++p)
+ deallog.get_file_stream() << p->value() * 100
+ << std::endl;
};
if (dim > 1)
// range of 1 or below,
// multiply matrix by 100 to
// make test more sensitive
- for (unsigned int i=0; i<matrix.n_nonzero_elements(); ++i)
- matrix.global_entry(i) *= 100;
+ matrix *= 100;
// finally write out matrix
matrix.print (deallog.get_file_stream());
// range of 1 or below,
// multiply matrix by 100 to
// make test more sensitive
- for (unsigned int i=0; i<matrix.n_nonzero_elements(); ++i)
- deallog.get_file_stream() << matrix.global_entry(i) * 100
- << std::endl;
+ for (SparseMatrix<double>::const_iterator p=matrix.begin();
+ p!=matrix.end(); ++p)
+ deallog.get_file_stream() << p->value() * 100
+ << std::endl;
};
if (dim > 1)
// ---------------------------------------------------------------------
//
-// Copyright (C) 1998 - 2014 by the deal.II authors
+// Copyright (C) 1998 - 2015 by the deal.II authors
//
// This file is part of the deal.II library.
//
std::remove ("sparse_matrices.tmp");
- for (unsigned int i=0; i<A.n_nonzero_elements(); ++i)
- if (std::fabs(A.global_entry(i) - A_tmp.global_entry(i)) <=
- std::fabs(1e-14*A.global_entry(i)))
+ SparseMatrix<double>::const_iterator p =A.begin(),
+ p_tmp=A_tmp.begin();
+ for (; p!=A.end(); ++p, ++p_tmp)
+ if (std::fabs(p->value() - p_tmp->value()) <=
+ std::fabs(1e-14*p->value()))
deallog << "write/read-error at global position "
- << i << std::endl;
+ << (p-A.begin()) << std::endl;
}