Vector<Number> & operator= (const Vector<Number2>& V);
/**
- * $U = U * V$: scalar product.
+ * Return the scalar product of
+ * two vectors. The return type
+ * is the underlying type of
+ * @p{this} vector, so the return
+ * type and the accuracy with
+ * which it the result is
+ * computed depend on the order
+ * of the arguments of this
+ * vector.
*/
- Number operator* (const Vector<Number>& V) const;
+ template <typename Number2>
+ Number operator* (const Vector<Number2> &V) const;
/**
* Return square of the $l_2$-norm.
template <typename Number>
-Number Vector<Number>::operator * (const Vector<Number>& v) const
+template <typename Number2>
+Number Vector<Number>::operator * (const Vector<Number2>& v) const
{
Assert (dim!=0, ExcEmptyVector());
-
- if (&v == this)
+
+ if (this == reinterpret_cast<const Vector<Number>*>(&v))
return norm_sqr();
- Assert (dim == v.dim, ExcDimensionMismatch(dim, v.dim));
+ Assert (dim == v.size(), ExcDimensionMismatch(dim, v.size()));
Number sum0 = 0,
sum1 = 0,
// allowing pipelined commands to be
// executed in parallel
const_iterator ptr = begin(),
- vptr = v.begin(),
eptr = ptr + (dim/4)*4;
+ typename Vector<Number2>::const_iterator vptr = v.begin();
while (ptr!=eptr)
{
sum0 += (*ptr++ * *vptr++);
// explicit instantiations
template class Vector<double>;
template Vector<double>& Vector<double>::operator=(const Vector<float>&);
+template double Vector<double>::operator*(const Vector<float>&) const;
+template double Vector<double>::operator*(const Vector<double>&) const;
template class Vector<float>;
template Vector<float>& Vector<float>::operator=(const Vector<double>&);
+template float Vector<float>::operator*(const Vector<float>&) const;
+template float Vector<float>::operator*(const Vector<double>&) const;
// see the .h file for why these functions are disabled.
// template Vector<float>::Vector (const Vector<double>& v);
// explicit instantiations
template class Vector<long double>;
+
template Vector<long double>& Vector<long double>::operator=(const Vector<float>&);
template Vector<long double>& Vector<long double>::operator=(const Vector<double>&);
template Vector<double>& Vector<double>::operator=(const Vector<long double>&);
template Vector<float>& Vector<float>::operator=(const Vector<long double>&);
+
+template float Vector<float>::operator * (const Vector<long double> &) const;
+template double Vector<double>::operator * (const Vector<long double> &) const;
+template long double Vector<long double>::operator * (const Vector<float> &) const;
+template long double Vector<long double>::operator * (const Vector<double> &) const;
// see the .h file for why these functions are disabled.
// template Vector<float>::Vector (const Vector<double>& v);
// template Vector<double>::Vector (const Vector<float>& v);