* @p{BlockVector}, then an additional parameter selects a single
* component for this operation.
*
- * @author Guido Kanschat, 2002
+ * @author Guido Kanschat, 2002, 2003
*/
class MeanValueFilter : public Subscriptor
{
*/
MeanValueFilter(unsigned int component = static_cast<unsigned int>(-1));
+ /**
+ * Subtract mean value from @p{v}.
+ */
+ template <typename number>
+ void filter (Vector<number>& v) const;
+
+ /**
+ * Subtract mean value from @p{v}.
+ */
+ template <typename number>
+ void filter (BlockVector<number>& v) const;
+
/**
* Return the source vector with
* subtracted mean value.
#include <lac/block_vector.h>
+template <typename number>
+void
+MeanValueFilter::filter(Vector<number>& v) const
+{
+ number mean = v.mean_value();
+
+ for (unsigned int i=0;i<v.size();++i)
+ v(i) -= mean;
+}
+
+
+
template <typename number>
void
MeanValueFilter::vmult(Vector<number>& dst,
+template <typename number>
+void
+MeanValueFilter::filter(BlockVector<number>& v) const
+{
+ Assert (component != static_cast<unsigned int>(-1),
+ ExcNotInitialized());
+
+ for (unsigned int i=0;i<v.n_blocks();++i)
+ if (i == component)
+ vmult(v.block(i), v.block(i));
+ else
+ v.block(i) = v.block(i);
+}
+
+
+
template <typename number>
void
MeanValueFilter::vmult(BlockVector<number>& dst,
component(component)
{}
+template void MeanValueFilter::filter(Vector<float>&) const;
+template void MeanValueFilter::filter(Vector<double>&) const;
+template void MeanValueFilter::filter(BlockVector<float>&) const;
+template void MeanValueFilter::filter(BlockVector<double>&) const;
template void MeanValueFilter::vmult(Vector<float>&,
const Vector<float>&) const;
template void MeanValueFilter::vmult(Vector<double>&,