*/
bool compressed;
+ /**
+ * An internal Trilinos vector
+ * that is used for
+ * accelerating vmult_add
+ * functions (do not need to
+ * allocate too many temporary
+ * vectors).
+ */
+ mutable VectorBase temp_vector;
+
public:
/**
* A sparse matrix object in
{
Assert (&src != &dst, ExcSourceEqualsDestination());
- VectorBase tmp(dst);
+ temp_vector.reinit(dst);
+
vmult (dst, src);
- dst += tmp;
+ dst += temp_vector;
}
{
Assert (&src != &dst, ExcSourceEqualsDestination());
- VectorBase tmp(dst);
+ temp_vector.reinit(dst);
+
vmult (dst, src);
- dst += tmp;
+ dst += temp_vector;
}
TrilinosScalar
SparseMatrix::matrix_norm_square (const VectorBase &v) const
{
- VectorBase tmp (v);
- vmult (tmp, v);
- return tmp*v;
+ Assert (row_map.SameAs(col_map),
+ ExcDimensionMismatch(row_map.NumGlobalElements(),
+ col_map.NumGlobalElements()));
+
+ temp_vector.reinit(v);
+
+ vmult (temp_vector, v);
+ return temp_vector*v;
}
SparseMatrix::matrix_scalar_product (const VectorBase &u,
const VectorBase &v) const
{
- VectorBase tmp (v);
- vmult (tmp, v);
- return u*tmp;
+ Assert (row_map.SameAs(col_map),
+ ExcDimensionMismatch(row_map.NumGlobalElements(),
+ col_map.NumGlobalElements()));
+
+ temp_vector.reinit(v);
+
+ vmult (temp_vector, v);
+ return u*temp_vector;
}