From: Wolfgang Bangerth Date: Thu, 16 Feb 2006 23:49:37 +0000 (+0000) Subject: Rename Vector::dim and Vector::maxdim to Vector::vec_size and Vector::max_vec_size... X-Git-Tag: v8.0.0~12291 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a081f03f686c34ff3aaccb9a0705c56789885d68;p=dealii.git Rename Vector::dim and Vector::maxdim to Vector::vec_size and Vector::max_vec_size. I've found error messages where it was completely confusing to see dim==0, although I was sure that I am in 3d :-) git-svn-id: https://svn.dealii.org/trunk@12391 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/lac/include/lac/vector.h b/deal.II/lac/include/lac/vector.h index e521412141..90b4bf10ca 100644 --- a/deal.II/lac/include/lac/vector.h +++ b/deal.II/lac/include/lac/vector.h @@ -710,13 +710,13 @@ class Vector * vector. Get this number by * calling size(). */ - unsigned int dim; + unsigned int vec_size; /** * Amount of memory actually * reserved for this vector. This * number may be greater than - * @p dim if a @p reinit was + * @p vec_size if a @p reinit was * called with less memory * requirements than the vector * needed last time. At present @@ -724,7 +724,7 @@ class Vector * memory when the number of * needed elements is reduced. */ - unsigned int maxdim; + unsigned int max_vec_size; /** * Pointer to the array of @@ -753,8 +753,8 @@ template inline Vector::Vector () : - dim(0), - maxdim(0), + vec_size(0), + max_vec_size(0), val(0) {} @@ -764,8 +764,8 @@ template template Vector::Vector (const InputIterator first, const InputIterator last) : - dim (0), - maxdim (0), + vec_size (0), + max_vec_size (0), val (0) { // allocate memory. do not @@ -781,8 +781,8 @@ template inline Vector::Vector (const unsigned int n) : - dim(0), - maxdim(0), + vec_size(0), + max_vec_size(0), val(0) { reinit (n, false); @@ -811,18 +811,18 @@ void Vector::reinit (const unsigned int n, const bool fast) { if (val) delete[] val; val = 0; - maxdim = dim = 0; + max_vec_size = vec_size = 0; return; }; - if (n>maxdim) + if (n>max_vec_size) { if (val) delete[] val; val = new value_type[n]; Assert (val != 0, ExcOutOfMemory()); - maxdim = n; + max_vec_size = n; }; - dim = n; + vec_size = n; if (fast == false) *this = 0; } @@ -834,8 +834,8 @@ inline Vector & Vector::operator = (const Number s) { if (s != 0.) - Assert (dim!=0, ExcEmptyObject()); - if (dim!=0) + Assert (vec_size!=0, ExcEmptyObject()); + if (vec_size!=0) std::fill (begin(), end(), s); return *this; } @@ -846,7 +846,7 @@ template inline unsigned int Vector::size () const { - return dim; + return vec_size; } @@ -876,7 +876,7 @@ inline typename Vector::iterator Vector::end () { - return &val[dim]; + return &val[vec_size]; } @@ -886,7 +886,7 @@ inline typename Vector::const_iterator Vector::end () const { - return &val[dim]; + return &val[vec_size]; } @@ -895,7 +895,7 @@ template inline Number Vector::operator() (const unsigned int i) const { - Assert (i inline Number& Vector::operator() (const unsigned int i) { - Assert (i Vector::Vector (const Vector& v) : - dim(v.size()), - maxdim(v.size()), + vec_size(v.size()), + max_vec_size(v.size()), val(0) { - if (dim != 0) + if (vec_size != 0) { - val = new Number[maxdim]; + val = new Number[max_vec_size]; Assert (val != 0, ExcOutOfMemory()); std::copy (v.begin(), v.end(), begin()); } @@ -73,13 +73,13 @@ template template Vector::Vector (const Vector& v) : - dim(v.size()), - maxdim(v.size()), + vec_size(v.size()), + max_vec_size(v.size()), val(0) { - if (dim != 0) + if (vec_size != 0) { - val = new Number[maxdim]; + val = new Number[max_vec_size]; Assert (val != 0, ExcOutOfMemory()); std::copy (v.begin(), v.end(), begin()); } @@ -92,13 +92,13 @@ Vector::Vector (const Vector& v) template Vector::Vector (const PETScWrappers::Vector &v) : - dim(v.size()), - maxdim(v.size()), + vec_size(v.size()), + max_vec_size(v.size()), val(0) { - if (dim != 0) + if (vec_size != 0) { - val = new Number[maxdim]; + val = new Number[max_vec_size]; Assert (val != 0, ExcOutOfMemory()); // get a representation of the vector @@ -107,7 +107,7 @@ Vector::Vector (const PETScWrappers::Vector &v) int ierr = VecGetArray (static_cast(v), &start_ptr); AssertThrow (ierr == 0, ExcPETScError(ierr)); - std::copy (start_ptr, start_ptr+dim, begin()); + std::copy (start_ptr, start_ptr+vec_size, begin()); // restore the representation of the // vector @@ -121,8 +121,8 @@ Vector::Vector (const PETScWrappers::Vector &v) template Vector::Vector (const PETScWrappers::MPI::Vector &v) : - dim(0), - maxdim(0), + vec_size(0), + max_vec_size(0), val(0) { if (v.size() != 0) @@ -151,8 +151,8 @@ template void Vector::swap (Vector &v) { - std::swap (dim, v.dim); - std::swap (maxdim, v.maxdim); + std::swap (vec_size, v.vec_size); + std::swap (max_vec_size, v.max_vec_size); std::swap (val, v.val); } @@ -162,7 +162,7 @@ template bool Vector::all_zero () const { - Assert (dim!=0, ExcEmptyObject()); + Assert (vec_size!=0, ExcEmptyObject()); const_iterator p = begin(), e = end(); @@ -178,7 +178,7 @@ template bool Vector::is_non_negative () const { - Assert (dim!=0, ExcEmptyObject()); + Assert (vec_size!=0, ExcEmptyObject()); const_iterator p = begin(), e = end(); @@ -194,12 +194,12 @@ template template Number Vector::operator * (const Vector& v) const { - Assert (dim!=0, ExcEmptyObject()); + Assert (vec_size!=0, ExcEmptyObject()); if (this == reinterpret_cast*>(&v)) return norm_sqr(); - Assert (dim == v.size(), ExcDimensionMismatch(dim, v.size())); + Assert (vec_size == v.size(), ExcDimensionMismatch(vec_size, v.size())); Number sum0 = 0, sum1 = 0, @@ -210,7 +210,7 @@ Number Vector::operator * (const Vector& v) const // allowing pipelined commands to be // executed in parallel const_iterator ptr = begin(), - eptr = ptr + (dim/4)*4; + eptr = ptr + (vec_size/4)*4; typename Vector::const_iterator vptr = v.begin(); while (ptr!=eptr) { @@ -230,7 +230,7 @@ Number Vector::operator * (const Vector& v) const template Number Vector::norm_sqr () const { - Assert (dim!=0, ExcEmptyObject()); + Assert (vec_size!=0, ExcEmptyObject()); Number sum0 = 0, sum1 = 0, @@ -241,7 +241,7 @@ Number Vector::norm_sqr () const // allowing pipelined commands to be // executed in parallel const_iterator ptr = begin(), - eptr = ptr + (dim/4)*4; + eptr = ptr + (vec_size/4)*4; while (ptr!=eptr) { sum0 += internal::VectorHelper::sqr(*ptr++); @@ -260,7 +260,7 @@ Number Vector::norm_sqr () const template Number Vector::mean_value () const { - Assert (dim!=0, ExcEmptyObject()); + Assert (vec_size!=0, ExcEmptyObject()); Number sum0 = 0, sum1 = 0, @@ -271,7 +271,7 @@ Number Vector::mean_value () const // allowing pipelined commands to be // executed in parallel const_iterator ptr = begin(), - eptr = ptr + (dim/4)*4; + eptr = ptr + (vec_size/4)*4; while (ptr!=eptr) { sum0 += *ptr++; @@ -291,7 +291,7 @@ Number Vector::mean_value () const template Number Vector::l1_norm () const { - Assert (dim!=0, ExcEmptyObject()); + Assert (vec_size!=0, ExcEmptyObject()); Number sum0 = 0, sum1 = 0, @@ -302,7 +302,7 @@ Number Vector::l1_norm () const // allowing pipelined commands to be // executed in parallel const_iterator ptr = begin(), - eptr = ptr + (dim/4)*4; + eptr = ptr + (vec_size/4)*4; while (ptr!=eptr) { sum0 += std::fabs(*ptr++); @@ -328,7 +328,7 @@ Number Vector::l2_norm () const template Number Vector::lp_norm (const Number p) const { - Assert (dim!=0, ExcEmptyObject()); + Assert (vec_size!=0, ExcEmptyObject()); Number sum0 = 0, sum1 = 0, @@ -339,7 +339,7 @@ Number Vector::lp_norm (const Number p) const // allowing pipelined commands to be // executed in parallel const_iterator ptr = begin(), - eptr = ptr + (dim/4)*4; + eptr = ptr + (vec_size/4)*4; while (ptr!=eptr) { sum0 += std::pow(std::fabs(*ptr++), p); @@ -359,13 +359,13 @@ Number Vector::lp_norm (const Number p) const template Number Vector::linfty_norm () const { - Assert (dim!=0, ExcEmptyObject()); + Assert (vec_size!=0, ExcEmptyObject()); Number max0=0., max1=0., max2=0., max3=0.; - for (unsigned int i=0; i<(dim/4); ++i) + for (unsigned int i=0; i<(vec_size/4); ++i) { if (max0::linfty_norm () const if (max3::linfty_norm () const template Vector& Vector::operator += (const Vector& v) { - Assert (dim!=0, ExcEmptyObject()); + Assert (vec_size!=0, ExcEmptyObject()); add (v); return *this; @@ -395,8 +395,8 @@ Vector& Vector::operator += (const Vector& v) template Vector& Vector::operator -= (const Vector& v) { - Assert (dim!=0, ExcEmptyObject()); - Assert (dim == v.dim, ExcDimensionMismatch(dim, v.dim)); + Assert (vec_size!=0, ExcEmptyObject()); + Assert (vec_size == v.vec_size, ExcDimensionMismatch(vec_size, v.vec_size)); iterator i_ptr = begin(), i_end = end(); @@ -411,7 +411,7 @@ Vector& Vector::operator -= (const Vector& v) template void Vector::add (const Number v) { - Assert (dim!=0, ExcEmptyObject()); + Assert (vec_size!=0, ExcEmptyObject()); iterator i_ptr = begin(), i_end = end(); @@ -423,8 +423,8 @@ void Vector::add (const Number v) template void Vector::add (const Vector& v) { - Assert (dim!=0, ExcEmptyObject()); - Assert (dim == v.dim, ExcDimensionMismatch(dim, v.dim)); + Assert (vec_size!=0, ExcEmptyObject()); + Assert (vec_size == v.vec_size, ExcDimensionMismatch(vec_size, v.vec_size)); iterator i_ptr = begin(), i_end = end(); @@ -437,8 +437,8 @@ void Vector::add (const Vector& v) template void Vector::add (const Number a, const Vector& v) { - Assert (dim!=0, ExcEmptyObject()); - Assert (dim == v.dim, ExcDimensionMismatch(dim, v.dim)); + Assert (vec_size!=0, ExcEmptyObject()); + Assert (vec_size == v.vec_size, ExcDimensionMismatch(vec_size, v.vec_size)); iterator i_ptr = begin(), i_end = end(); @@ -452,9 +452,9 @@ template void Vector::add (const Number a, const Vector& v, const Number b, const Vector& w) { - Assert (dim!=0, ExcEmptyObject()); - Assert (dim == v.dim, ExcDimensionMismatch(dim, v.dim)); - Assert (dim == w.dim, ExcDimensionMismatch(dim, w.dim)); + Assert (vec_size!=0, ExcEmptyObject()); + Assert (vec_size == v.vec_size, ExcDimensionMismatch(vec_size, v.vec_size)); + Assert (vec_size == w.vec_size, ExcDimensionMismatch(vec_size, w.vec_size)); iterator i_ptr = begin(), i_end = end(); const_iterator v_ptr = v.begin(), @@ -467,8 +467,8 @@ void Vector::add (const Number a, const Vector& v, template void Vector::sadd (const Number x, const Vector& v) { - Assert (dim!=0, ExcEmptyObject()); - Assert (dim == v.dim, ExcDimensionMismatch(dim, v.dim)); + Assert (vec_size!=0, ExcEmptyObject()); + Assert (vec_size == v.vec_size, ExcDimensionMismatch(vec_size, v.vec_size)); iterator i_ptr = begin(), i_end = end(); const_iterator v_ptr = v.begin(); @@ -481,8 +481,8 @@ template void Vector::sadd (const Number x, const Number a, const Vector& v) { - Assert (dim!=0, ExcEmptyObject()); - Assert (dim == v.dim, ExcDimensionMismatch(dim, v.dim)); + Assert (vec_size!=0, ExcEmptyObject()); + Assert (vec_size == v.vec_size, ExcDimensionMismatch(vec_size, v.vec_size)); iterator i_ptr = begin(), i_end = end(); const_iterator v_ptr = v.begin(); @@ -496,9 +496,9 @@ void Vector::sadd (const Number x, const Number a, const Vector& v, const Number b, const Vector& w) { - Assert (dim!=0, ExcEmptyObject()); - Assert (dim == v.dim, ExcDimensionMismatch(dim, v.dim)); - Assert (dim == w.dim, ExcDimensionMismatch(dim, w.dim)); + Assert (vec_size!=0, ExcEmptyObject()); + Assert (vec_size == v.vec_size, ExcDimensionMismatch(vec_size, v.vec_size)); + Assert (vec_size == w.vec_size, ExcDimensionMismatch(vec_size, w.vec_size)); iterator i_ptr = begin(), i_end = end(); const_iterator v_ptr = v.begin(), @@ -514,10 +514,10 @@ void Vector::sadd (const Number x, const Number a, const Vector& w, const Number c, const Vector& y) { - Assert (dim!=0, ExcEmptyObject()); - Assert (dim == v.dim, ExcDimensionMismatch(dim, v.dim)); - Assert (dim == w.dim, ExcDimensionMismatch(dim, w.dim)); - Assert (dim == y.dim, ExcDimensionMismatch(dim, y.dim)); + Assert (vec_size!=0, ExcEmptyObject()); + Assert (vec_size == v.vec_size, ExcDimensionMismatch(vec_size, v.vec_size)); + Assert (vec_size == w.vec_size, ExcDimensionMismatch(vec_size, w.vec_size)); + Assert (vec_size == y.vec_size, ExcDimensionMismatch(vec_size, y.vec_size)); iterator i_ptr = begin(), i_end = end(); const_iterator v_ptr = v.begin(), @@ -533,7 +533,7 @@ void Vector::sadd (const Number x, const Number a, template void Vector::scale (const Number factor) { - Assert (dim!=0, ExcEmptyObject()); + Assert (vec_size!=0, ExcEmptyObject()); iterator ptr = begin(); const const_iterator eptr = end(); @@ -547,8 +547,8 @@ template template void Vector::scale (const Vector &s) { - Assert (dim!=0, ExcEmptyObject()); - Assert (dim == s.dim, ExcDimensionMismatch(dim, s.dim)); + Assert (vec_size!=0, ExcEmptyObject()); + Assert (vec_size == s.vec_size, ExcDimensionMismatch(vec_size, s.vec_size)); iterator ptr = begin(); const const_iterator eptr = end(); @@ -563,9 +563,9 @@ template void Vector::equ (const Number a, const Vector& u, const Number b, const Vector& v) { - Assert (dim!=0, ExcEmptyObject()); - Assert (dim == u.dim, ExcDimensionMismatch(dim, u.dim)); - Assert (dim == v.dim, ExcDimensionMismatch(dim, v.dim)); + Assert (vec_size!=0, ExcEmptyObject()); + Assert (vec_size == u.vec_size, ExcDimensionMismatch(vec_size, u.vec_size)); + Assert (vec_size == v.vec_size, ExcDimensionMismatch(vec_size, v.vec_size)); iterator i_ptr = begin(), i_end = end(); const_iterator u_ptr = u.begin(), @@ -580,8 +580,8 @@ template template void Vector::equ (const Number a, const Vector& u) { - Assert (dim!=0, ExcEmptyObject()); - Assert (dim == u.dim, ExcDimensionMismatch(dim, u.dim)); + Assert (vec_size!=0, ExcEmptyObject()); + Assert (vec_size == u.vec_size, ExcDimensionMismatch(vec_size, u.vec_size)); iterator i_ptr = begin(), i_end = end(); typename Vector::const_iterator u_ptr = u.begin(); @@ -594,8 +594,8 @@ void Vector::equ (const Number a, const Vector& u) template void Vector::ratio (const Vector &a, const Vector &b) { - Assert (dim!=0, ExcEmptyObject()); - Assert (a.dim == b.dim, ExcDimensionMismatch (a.dim, b.dim)); + Assert (vec_size!=0, ExcEmptyObject()); + Assert (a.vec_size == b.vec_size, ExcDimensionMismatch (a.vec_size, b.vec_size)); // no need to reinit with zeros, since // we overwrite them anyway @@ -614,9 +614,9 @@ template Vector& Vector::operator = (const Vector& v) { - if (v.dim != dim) - reinit (v.dim, true); - if (dim!=0) + if (v.vec_size != vec_size) + reinit (v.vec_size, true); + if (vec_size!=0) std::copy (v.begin(), v.end(), begin()); return *this; @@ -629,9 +629,9 @@ template Vector& Vector::operator = (const Vector& v) { - if (v.size() != dim) + if (v.size() != vec_size) reinit (v.size(), true); - if (dim!=0) + if (vec_size!=0) std::copy (v.begin(), v.end(), begin()); return *this; @@ -645,9 +645,9 @@ template Vector & Vector::operator = (const PETScWrappers::Vector &v) { - if (v.size() != dim) + if (v.size() != vec_size) reinit (v.size(), true); - if (dim != 0) + if (vec_size != 0) { // get a representation of the vector // and copy it @@ -655,7 +655,7 @@ Vector::operator = (const PETScWrappers::Vector &v) int ierr = VecGetArray (static_cast(v), &start_ptr); AssertThrow (ierr == 0, ExcPETScError(ierr)); - std::copy (start_ptr, start_ptr+dim, begin()); + std::copy (start_ptr, start_ptr+vec_size, begin()); // restore the representation of the // vector @@ -689,10 +689,10 @@ template bool Vector::operator == (const Vector& v) const { - Assert (dim!=0, ExcEmptyObject()); - Assert (dim == v.size(), ExcDimensionMismatch(dim, v.size())); + Assert (vec_size!=0, ExcEmptyObject()); + Assert (vec_size == v.size(), ExcDimensionMismatch(vec_size, v.size())); - for (unsigned int i=0; i::operator == (const Vector& v) const template void Vector::print (const char* format) const { - Assert (dim!=0, ExcEmptyObject()); + Assert (vec_size!=0, ExcEmptyObject()); if (!format) format = " %5.2f"; for (unsigned int j=0;j::print (std::ostream &out, const bool scientific, const bool across) const { - Assert (dim!=0, ExcEmptyObject()); + Assert (vec_size!=0, ExcEmptyObject()); AssertThrow (out, ExcIO()); std::ios::fmtflags old_flags = out.flags(); @@ -815,7 +815,7 @@ template unsigned int Vector::memory_consumption () const { - return sizeof(*this) + (maxdim * sizeof(Number)); + return sizeof(*this) + (max_vec_size * sizeof(Number)); }