*/
double & operator () (const unsigned int index);
+/*
+ * Plus and minus operators are re-implemented from Tensor<1,dim>
+ * to avoid additional casting.
+ */
+
/**
* Add two point vectors. If possible, use
* @p{operator +=} instead since this does not
*/
Point<dim> operator - (const Point<dim> &) const;
+ /**
+ * The opposite vector.
+ */
+ Point<dim> operator - () const;
+
/**
* Multiply by a factor. If possible, use
* @p{operator *=} instead since this does not
+template <int dim>
+inline
+Point<dim> Point<dim>::operator - () const
+{
+ return (Point<dim>(*this) -(*(Tensor<1,dim>*)this));
+};
+
+
+
template <int dim>
inline
Point<dim> Point<dim>::operator * (const double factor) const
*/
Tensor<rank_,dim> operator - (const Tensor<rank_,dim> &) const;
+ /**
+ * Invert all entries of a tensor.
+ */
+ Tensor<rank_,dim> operator - () const;
+
/**
* Fill a vector with all tensor elements.
*
};
+template <int rank_, int dim>
+inline
+Tensor<rank_,dim>
+Tensor<rank_,dim>::operator - () const
+{
+ Tensor<rank_,dim> tmp;
+
+ for (unsigned int i=0; i<dim; ++i)
+ tmp.subtensor[i] = -subtensor[i];
+
+ return tmp;
+};
+
+
template <int rank_, int dim>
inline
void Tensor<rank_,dim>::clear ()
*/
Tensor<1,dim> operator - (const Tensor<1,dim> &) const;
+ /**
+ * Tensor with inverted entries.
+ */
+ Tensor<1,dim> operator - () const;
+
/**
* Reset all values to zero.
*/
+template <int dim>
+inline
+Tensor<1,dim> Tensor<1,dim>::operator - () const
+{
+ Tensor<1,dim> result;
+ for (unsigned int i=0; i<dim; ++i)
+ result.values[i] = -values[i];
+ return result;
+};
+
+
+
template <int dim>
inline
void Tensor<1,dim>::clear ()