void dVector::reinit (const unsigned int n, const bool fast)
{
Assert (n>0, ExcInvalidNumber(n));
+
if (n>maxdim)
{
if (val) delete[] val;
dVector& dVector::operator += (const dVector& v)
{
- if (v.dim != dim) reinit(v,1);
+ if (v.dim != dim)
+ reinit (v, true);
for (unsigned int i=0; i<dim; ++i)
val[i] += v.val[i];
dVector& dVector::operator -= (const dVector& v)
{
- if (v.dim != dim) reinit(v,1);
+ if (v.dim != dim)
+ reinit (v, true);
for (unsigned int i=0; i<dim; ++i)
val[i] -= v.val[i];
-void dVector::equ (const double a, const dVector& u,
- const double b, const dVector& v)
+void dVector::scale (const double factor)
{
- Assert (dim == v.dim, ExcDimensionsDontMatch(dim, v.dim));
for (unsigned int i=0; i<dim; ++i)
- val[i] = a*u.val[i] + b*v.val[i];
+ val[i] *= factor;
}
-void dVector::scale (const double factor)
+void dVector::equ (const double a, const dVector& u,
+ const double b, const dVector& v)
{
+ Assert (dim == v.dim, ExcDimensionsDontMatch(dim, v.dim));
for (unsigned int i=0; i<dim; ++i)
- val[i] *= factor;
+ val[i] = a*u.val[i] + b*v.val[i];
}
+void dVector::ratio (const dVector &a, const dVector &b) {
+ Assert (a.dim == b.dim, ExcDimensionsDontMatch (a.dim, b.dim));
+
+ // no need to reinit with zeros, since
+ // we overwrite them anyway
+ reinit (a.size(), true);
+ for (unsigned int i=0; i<dim; ++i)
+ val[i] = a.val[i] / b.val[i];
+};
+
+
+
dVector& dVector::operator = (const double s)
{
for (unsigned int i=0; i<dim; ++i)
dVector& dVector::operator = (const dVector& v)
{
- if (v.dim != dim) reinit(v,1);
+ if (v.dim != dim)
+ reinit (v, true);
for (unsigned int i=0; i<dim; ++i)
val[i] = v.val[i];