:
BlockVectorBase<Vector<Number> > ()
{
- this->components.resize (v.num_blocks);
+ this->components.resize (v.n_blocks());
this->block_indices = v.block_indices;
- this->num_blocks = v.num_blocks;
- for (unsigned int i=0; i<this->num_blocks; ++i)
+ for (unsigned int i=0; i<this->n_blocks(); ++i)
this->components[i] = v.components[i];
}
const bool fast)
{
this->block_indices.reinit (n);
- this->num_blocks = n.size();
- if (this->components.size() != this->num_blocks)
- this->components.resize(this->num_blocks);
+ if (this->components.size() != this->n_blocks())
+ this->components.resize(this->n_blocks());
- for (unsigned int i=0; i<this->num_blocks; ++i)
+ for (unsigned int i=0; i<this->n_blocks(); ++i)
this->components[i].reinit(n[i], fast);
}
const bool fast)
{
this->block_indices = v.get_block_indices();
- this->num_blocks = v.n_blocks();
- if (this->components.size() != this->num_blocks)
- this->components.resize(this->num_blocks);
+ if (this->components.size() != this->n_blocks())
+ this->components.resize(this->n_blocks());
- for (unsigned int i=0;i<this->num_blocks;++i)
+ for (unsigned int i=0;i<this->n_blocks();++i)
this->block(i).reinit(v.block(i), fast);
}
template <typename Number>
void BlockVector<Number>::swap (BlockVector<Number> &v)
{
- Assert (this->num_blocks == v.num_blocks,
- ExcDimensionMismatch(this->num_blocks, v.num_blocks));
+ Assert (this->n_blocks() == v.n_blocks(),
+ ExcDimensionMismatch(this->n_blocks(), v.n_blocks()));
- for (unsigned int i=0; i<this->num_blocks; ++i)
+ for (unsigned int i=0; i<this->n_blocks(); ++i)
::swap (this->components[i], v.components[i]);
::swap (this->block_indices, v.block_indices);
}
const bool scientific,
const bool across) const
{
- for (unsigned int i=0;i<this->num_blocks;++i)
+ for (unsigned int i=0;i<this->n_blocks();++i)
{
if (across)
out << 'C' << i << ':';
template <typename Number>
void BlockVector<Number>::block_write (std::ostream &out) const
{
- for (unsigned int i=0;i<this->num_blocks;++i)
+ for (unsigned int i=0;i<this->n_blocks();++i)
this->components[i].block_write(out);
}
template <typename Number>
void BlockVector<Number>::block_read (std::istream &in)
{
- for (unsigned int i=0;i<this->num_blocks;++i)
+ for (unsigned int i=0;i<this->n_blocks();++i)
this->components[i].block_read(in);
}
unsigned int
BlockVector<Number>::memory_consumption () const
{
- unsigned int mem = sizeof(this->num_blocks);
+ unsigned int mem = sizeof(this->n_blocks());
for (unsigned int i=0; i<this->components.size(); ++i)
mem += MemoryConsumption::memory_consumption (this->components[i]);
mem += MemoryConsumption::memory_consumption (this->block_indices);
* different blocks.
*/
BlockIndices block_indices;
-
- /**
- * The number of blocks. This
- * number is redundant to
- * <tt>components.size()</tt> and stored
- * here for convenience.
- */
- unsigned int num_blocks;
/**
* Make the iterator class a
unsigned int
BlockVectorBase<VectorType>::n_blocks () const
{
- return num_blocks;
+ return block_indices.size();
}
typename BlockVectorBase<VectorType>::BlockType &
BlockVectorBase<VectorType>::block (const unsigned int i)
{
- Assert(i<num_blocks, ExcIndexRange(i,0,num_blocks));
+ Assert(i<n_blocks(), ExcIndexRange(i,0,n_blocks()));
return components[i];
}
const typename BlockVectorBase<VectorType>::BlockType &
BlockVectorBase<VectorType>::block (const unsigned int i) const
{
- Assert(i<num_blocks, ExcIndexRange(i,0,num_blocks));
+ Assert(i<n_blocks(), ExcIndexRange(i,0,n_blocks()));
return components[i];
}
void
BlockVectorBase<VectorType>::collect_sizes ()
{
- std::vector<unsigned int> sizes (num_blocks);
+ std::vector<unsigned int> sizes (n_blocks());
- for (unsigned int i=0; i<num_blocks; ++i)
+ for (unsigned int i=0; i<n_blocks(); ++i)
sizes[i] = block(i).size();
block_indices.reinit(sizes);
void
BlockVectorBase<VectorType>::clear ()
{
- for (unsigned int i=0;i<num_blocks;++i)
+ for (unsigned int i=0;i<n_blocks();++i)
components[i].clear();
}
bool
BlockVectorBase<VectorType>::all_zero () const
{
- for (unsigned int i=0;i<num_blocks;++i)
+ for (unsigned int i=0;i<n_blocks();++i)
if (components[i].all_zero() == false)
return false;
bool
BlockVectorBase<VectorType>::is_non_negative () const
{
- for (unsigned int i=0;i<num_blocks;++i)
+ for (unsigned int i=0;i<n_blocks();++i)
if (components[i].is_non_negative() == false)
return false;
BlockVectorBase<VectorType>::
operator * (const BlockVectorBase<VectorType>& v) const
{
- Assert (num_blocks == v.num_blocks,
- ExcDimensionMismatch(num_blocks, v.num_blocks));
+ Assert (n_blocks() == v.n_blocks(),
+ ExcDimensionMismatch(n_blocks(), v.n_blocks()));
value_type sum = 0.;
- for (unsigned int i=0;i<num_blocks;++i)
+ for (unsigned int i=0;i<n_blocks();++i)
sum += components[i]*v.components[i];
return sum;
BlockVectorBase<VectorType>::norm_sqr () const
{
value_type sum = 0.;
- for (unsigned int i=0;i<num_blocks;++i)
+ for (unsigned int i=0;i<n_blocks();++i)
sum += components[i].norm_sqr();
return sum;
BlockVectorBase<VectorType>::mean_value () const
{
value_type sum = 0.;
- for (unsigned int i=0;i<num_blocks;++i)
+ for (unsigned int i=0;i<n_blocks();++i)
sum += components[i].mean_value() * components[i].size();
return sum/size();
BlockVectorBase<VectorType>::l1_norm () const
{
value_type sum = 0.;
- for (unsigned int i=0;i<num_blocks;++i)
+ for (unsigned int i=0;i<n_blocks();++i)
sum += components[i].l1_norm();
return sum;
BlockVectorBase<VectorType>::linfty_norm () const
{
value_type sum = 0.;
- for (unsigned int i=0;i<num_blocks;++i)
+ for (unsigned int i=0;i<n_blocks();++i)
{
value_type newval = components[i].linfty_norm();
if (sum<newval)
BlockVectorBase<VectorType> &
BlockVectorBase<VectorType>::operator -= (const BlockVectorBase<VectorType>& v)
{
- Assert (num_blocks == v.num_blocks,
- ExcDimensionMismatch(num_blocks, v.num_blocks));
+ Assert (n_blocks() == v.n_blocks(),
+ ExcDimensionMismatch(n_blocks(), v.n_blocks()));
- for (unsigned int i=0;i<num_blocks;++i)
+ for (unsigned int i=0;i<n_blocks();++i)
{
components[i] -= v.components[i];
}
template <class VectorType>
void BlockVectorBase<VectorType>::add (const value_type a)
{
- for (unsigned int i=0;i<num_blocks;++i)
+ for (unsigned int i=0;i<n_blocks();++i)
{
components[i].add(a);
}
template <class VectorType>
void BlockVectorBase<VectorType>::add (const BlockVectorBase<VectorType>& v)
{
- Assert (num_blocks == v.num_blocks,
- ExcDimensionMismatch(num_blocks, v.num_blocks));
+ Assert (n_blocks() == v.n_blocks(),
+ ExcDimensionMismatch(n_blocks(), v.n_blocks()));
- for (unsigned int i=0;i<num_blocks;++i)
+ for (unsigned int i=0;i<n_blocks();++i)
{
components[i].add(v.components[i]);
}
void BlockVectorBase<VectorType>::add (const value_type a,
const BlockVectorBase<VectorType>& v)
{
- Assert (num_blocks == v.num_blocks,
- ExcDimensionMismatch(num_blocks, v.num_blocks));
+ Assert (n_blocks() == v.n_blocks(),
+ ExcDimensionMismatch(n_blocks(), v.n_blocks()));
- for (unsigned int i=0;i<num_blocks;++i)
+ for (unsigned int i=0;i<n_blocks();++i)
{
components[i].add(a, v.components[i]);
}
const value_type b,
const BlockVectorBase<VectorType>& w)
{
- Assert (num_blocks == v.num_blocks,
- ExcDimensionMismatch(num_blocks, v.num_blocks));
- Assert (num_blocks == w.num_blocks,
- ExcDimensionMismatch(num_blocks, w.num_blocks));
+ Assert (n_blocks() == v.n_blocks(),
+ ExcDimensionMismatch(n_blocks(), v.n_blocks()));
+ Assert (n_blocks() == w.n_blocks(),
+ ExcDimensionMismatch(n_blocks(), w.n_blocks()));
- for (unsigned int i=0;i<num_blocks;++i)
+ for (unsigned int i=0;i<n_blocks();++i)
{
components[i].add(a, v.components[i], b, w.components[i]);
}
void BlockVectorBase<VectorType>::sadd (const value_type x,
const BlockVectorBase<VectorType>& v)
{
- Assert (num_blocks == v.num_blocks,
- ExcDimensionMismatch(num_blocks, v.num_blocks));
+ Assert (n_blocks() == v.n_blocks(),
+ ExcDimensionMismatch(n_blocks(), v.n_blocks()));
- for (unsigned int i=0;i<num_blocks;++i)
+ for (unsigned int i=0;i<n_blocks();++i)
{
components[i].sadd(x, v.components[i]);
}
void BlockVectorBase<VectorType>::sadd (const value_type x, const value_type a,
const BlockVectorBase<VectorType>& v)
{
- Assert (num_blocks == v.num_blocks,
- ExcDimensionMismatch(num_blocks, v.num_blocks));
+ Assert (n_blocks() == v.n_blocks(),
+ ExcDimensionMismatch(n_blocks(), v.n_blocks()));
- for (unsigned int i=0;i<num_blocks;++i)
+ for (unsigned int i=0;i<n_blocks();++i)
{
components[i].sadd(x, a, v.components[i]);
}
const value_type b,
const BlockVectorBase<VectorType>& w)
{
- Assert (num_blocks == v.num_blocks,
- ExcDimensionMismatch(num_blocks, v.num_blocks));
- Assert (num_blocks == w.num_blocks,
- ExcDimensionMismatch(num_blocks, w.num_blocks));
+ Assert (n_blocks() == v.n_blocks(),
+ ExcDimensionMismatch(n_blocks(), v.n_blocks()));
+ Assert (n_blocks() == w.n_blocks(),
+ ExcDimensionMismatch(n_blocks(), w.n_blocks()));
- for (unsigned int i=0;i<num_blocks;++i)
+ for (unsigned int i=0;i<n_blocks();++i)
{
components[i].sadd(x, a, v.components[i], b, w.components[i]);
}
const value_type c,
const BlockVectorBase<VectorType>& y)
{
- Assert (num_blocks == v.num_blocks,
- ExcDimensionMismatch(num_blocks, v.num_blocks));
- Assert (num_blocks == w.num_blocks,
- ExcDimensionMismatch(num_blocks, w.num_blocks));
- Assert (num_blocks == y.num_blocks,
- ExcDimensionMismatch(num_blocks, y.num_blocks));
+ Assert (n_blocks() == v.n_blocks(),
+ ExcDimensionMismatch(n_blocks(), v.n_blocks()));
+ Assert (n_blocks() == w.n_blocks(),
+ ExcDimensionMismatch(n_blocks(), w.n_blocks()));
+ Assert (n_blocks() == y.n_blocks(),
+ ExcDimensionMismatch(n_blocks(), y.n_blocks()));
- for (unsigned int i=0;i<num_blocks;++i)
+ for (unsigned int i=0;i<n_blocks();++i)
{
components[i].sadd(x, a, v.components[i],
b, w.components[i], c, y.components[i]);
template <class BlockVector2>
void BlockVectorBase<VectorType>::scale (const BlockVector2 &v)
{
- Assert (num_blocks == v.num_blocks,
- ExcDimensionMismatch(num_blocks, v.num_blocks));
- for (unsigned int i=0;i<num_blocks;++i)
+ Assert (n_blocks() == v.n_blocks(),
+ ExcDimensionMismatch(n_blocks(), v.n_blocks()));
+ for (unsigned int i=0;i<n_blocks();++i)
components[i].scale(v.block(i));
}
const value_type b,
const BlockVectorBase<VectorType>& w)
{
- Assert (num_blocks == v.num_blocks,
- ExcDimensionMismatch(num_blocks, v.num_blocks));
- Assert (num_blocks == w.num_blocks,
- ExcDimensionMismatch(num_blocks, w.num_blocks));
+ Assert (n_blocks() == v.n_blocks(),
+ ExcDimensionMismatch(n_blocks(), v.n_blocks()));
+ Assert (n_blocks() == w.n_blocks(),
+ ExcDimensionMismatch(n_blocks(), w.n_blocks()));
- for (unsigned int i=0;i<num_blocks;++i)
+ for (unsigned int i=0;i<n_blocks();++i)
{
components[i].equ( a, v.components[i], b, w.components[i]);
}
void BlockVectorBase<VectorType>::equ (const value_type a,
const BlockVector2 &v)
{
- Assert (num_blocks == v.num_blocks,
- ExcDimensionMismatch(num_blocks, v.num_blocks));
+ Assert (n_blocks() == v.n_blocks(),
+ ExcDimensionMismatch(n_blocks(), v.n_blocks()));
- for (unsigned int i=0;i<num_blocks;++i)
+ for (unsigned int i=0;i<n_blocks();++i)
components[i].equ( a, v.components[i]);
}
BlockVectorBase<VectorType>&
BlockVectorBase<VectorType>::operator = (const value_type s)
{
- for (unsigned int i=0;i<num_blocks;++i)
+ for (unsigned int i=0;i<n_blocks();++i)
components[i] = s;
return *this;
BlockVectorBase<VectorType>&
BlockVectorBase<VectorType>::operator = (const BlockVectorBase<VectorType>& v)
{
- Assert (num_blocks == v.num_blocks,
- ExcDimensionMismatch(num_blocks, v.num_blocks));
+ Assert (n_blocks() == v.n_blocks(),
+ ExcDimensionMismatch(n_blocks(), v.n_blocks()));
- for (unsigned int i=0;i<num_blocks;++i)
+ for (unsigned int i=0;i<n_blocks();++i)
{
components[i] = v.components[i];
}
BlockVectorBase<VectorType>&
BlockVectorBase<VectorType>::operator = (const BlockVectorBase<VectorType2> &v)
{
- Assert (num_blocks == v.num_blocks,
- ExcDimensionMismatch(num_blocks, v.num_blocks));
+ Assert (n_blocks() == v.n_blocks(),
+ ExcDimensionMismatch(n_blocks(), v.n_blocks()));
- for (unsigned int i=0;i<num_blocks;++i)
+ for (unsigned int i=0;i<n_blocks();++i)
components[i] = v.components[i];
return *this;
Assert (block_indices == v.block_indices,
ExcNotmatchingBlockSizes());
- for (unsigned int i=0;i<num_blocks;++i)
+ for (unsigned int i=0;i<n_blocks();++i)
if ( ! (components[i] == v.components[i]))
return false;
BlockVectorBase<VectorType> &
BlockVectorBase<VectorType>::operator *= (const value_type factor)
{
- for (unsigned int i=0;i<num_blocks;++i)
+ for (unsigned int i=0;i<n_blocks();++i)
components[i] *= factor;
return *this;
BlockVectorBase<VectorType> &
BlockVectorBase<VectorType>::operator /= (const value_type factor)
{
- for (unsigned int i=0;i<num_blocks;++i)
+ for (unsigned int i=0;i<n_blocks();++i)
components[i] /= factor;
return *this;