ReadWriteVector<Number> &operator = (const Number s);
/**
- * Returns the size of the vector, equal to number of elements in
- * the vector.
+ * Returns the size of the vector.
+ *
+ * Note that the result is not equal to the number of element stored locally.
+ * The latter information is returned by n_elements()
+ */
+ size_type size() const;
+
+ /**
+ * Return the number of elements stored locally.
*/
- size_type size () const;
+ size_type n_elements() const;
/**
* Return the IndexSet that stores the indices of the elements stored.
* Make the @p ReadWriteVector class a bit like the <tt>vector<></tt> class of
* the C++ standard library by returning iterators to the start and end
* of the <i>locally stored</i> elements of this vector.
- *
- * It holds that end() - begin() == size().
*/
iterator begin ();
ReadWriteVector<Number> &
ReadWriteVector<Number>::operator= (const ReadWriteVector<Number> &in_vector)
{
- resize_val(in_vector.size());
+ resize_val(in_vector.n_elements());
stored_elements = in_vector.get_stored_elements();
std::copy(in_vector.begin(),in_vector.end(),begin());
ReadWriteVector<Number> &
ReadWriteVector<Number>::operator= (const ReadWriteVector<Number2> &in_vector)
{
- resize_val(in_vector.size());
+ resize_val(in_vector.n_elements());
stored_elements = in_vector.get_stored_elements();
std::copy(in_vector.begin(),in_vector.end(),begin());
template <typename Number>
inline
typename ReadWriteVector<Number>::size_type
- ReadWriteVector<Number>::size () const
+ ReadWriteVector<Number>::size() const
+ {
+ return stored_elements.size();
+ }
+
+
+
+ template <typename Number>
+ inline
+ typename ReadWriteVector<Number>::size_type
+ ReadWriteVector<Number>::n_elements() const
{
return stored_elements.n_elements();
}
typename ReadWriteVector<Number>::iterator
ReadWriteVector<Number>::end ()
{
- return &val[this->size()];
+ return &val[this->n_elements()];
}
typename ReadWriteVector<Number>::const_iterator
ReadWriteVector<Number>::end () const
{
- return &val[this->size()];
+ return &val[this->n_elements()];
}
Number
ReadWriteVector<Number>::local_element (const size_type local_index) const
{
- AssertIndexRange (local_index, this->size());
+ AssertIndexRange (local_index, this->n_elements());
return val[local_index];
}
Number &
ReadWriteVector<Number>::local_element (const size_type local_index)
{
- AssertIndexRange (local_index, this->size());
+ AssertIndexRange (local_index, this->n_elements());
return val[local_index];
}
const bool fast)
{
// check whether we need to reallocate
- resize_val (size);
+ resize_val(size);
stored_elements = complete_index_set(size);
ReadWriteVector<Number>::reinit (const ReadWriteVector<Number2> &v,
const bool fast)
{
- resize_val (v.size());
+ resize_val(v.n_elements());
stored_elements = v.get_stored_elements();
#ifdef DEAL_II_WITH_MPI
// Copy the off-processor elements if necessary
- if (intersection_size != size())
+ if (intersection_size != n_elements())
{
Epetra_BlockMap source_map = trilinos_vec.trilinos_vector().Map();
std::vector<size_type> off_proc_indices(readwrite_indices.size());
ReadWriteVector<Number>::memory_consumption () const
{
std::size_t memory = sizeof(*this);
- memory += sizeof (Number) * static_cast<std::size_t>(this->size());
+ memory += sizeof (Number) * static_cast<std::size_t>(this->n_elements());
memory += stored_elements.memory_consumption();
out << "IndexSet: ";
stored_elements.print(out);
out << std::endl;
- for (unsigned int i=0; i<this->size(); ++i)
+ for (unsigned int i=0; i<this->n_elements(); ++i)
out << val[i] << std::endl;
out << std::flush;
is.add_range(10,15);
LinearAlgebra::ReadWriteVector<double> double_vector(is);
LinearAlgebra::ReadWriteVector<float> float_vector(float_size);
- deallog << "double_size " << double_vector.size() <<std::endl;
- deallog << "float_size " << float_vector.size() <<std::endl;
+ deallog << "double_size " << double_vector.n_elements() <<std::endl;
+ deallog << "float_size " << float_vector.n_elements() <<std::endl;
double_vector = 0.;
- for (unsigned int i=0; i<double_vector.size(); ++i)
+ for (unsigned int i=0; i<double_vector.n_elements(); ++i)
double_vector.local_element(i) += i;
- for (unsigned int i=0; i<float_vector.size(); ++i)
+ for (unsigned int i=0; i<float_vector.n_elements(); ++i)
float_vector[i] = i;
double_vector.print(deallog.get_file_stream());
LinearAlgebra::ReadWriteVector<double> double_vector2(double_vector);
double_vector2.print(deallog.get_file_stream());
- for (unsigned int i=0; i<double_vector.size(); ++i)
+ for (unsigned int i=0; i<double_vector.n_elements(); ++i)
double_vector2.local_element(i) += i;
double_vector = double_vector2;
double_vector.print(deallog.get_file_stream());