constexpr DEAL_II_CUDA_HOST_DEV real_type
norm_square() const;
+ /**
+ * Fill a range with all tensor elements. Since this type of Tensor only has
+ * one entry this just copies the value of this tensor into <tt>*begin</tt>.
+ *
+ * The template type Number must be convertible to the type of
+ * <tt>*begin</tt>.
+ */
+ template <class Iterator>
+ void
+ unroll(const Iterator begin, const Iterator end) const;
+
/**
* Read or write the data of this object to or from a stream for the purpose
* of serialization using the [BOOST serialization
* This function unrolls all tensor entries into a single, linearly numbered
* vector. As usual in C++, the rightmost index of the tensor marches
* fastest.
+ *
+ * @deprecated Use the more general function that takes a pair of iterators
+ * instead.
*/
template <typename OtherNumber>
- void
+ DEAL_II_DEPRECATED_EARLY void
unroll(Vector<OtherNumber> &result) const;
+ /**
+ * Fill a range with all tensor elements.
+ *
+ * This function unrolls all tensor entries into a single, linearly numbered
+ * sequence. The order of the elements is the one given by
+ * component_to_unrolled_index().
+ *
+ * The template type Number must be convertible to the type of
+ * <tt>*begin</tt>.
+ */
+ template <class Iterator>
+ void
+ unroll(const Iterator begin, const Iterator end) const;
+
/**
* Return an unrolled index in the range $[0,\text{dim}^{\text{rank}}-1]$
* for the element of the tensor indexed by the argument to the function.
}
+
template <int dim, typename Number>
template <typename OtherNumber>
constexpr inline DEAL_II_ALWAYS_INLINE
}
+
template <int dim, typename Number>
template <typename Iterator>
Iterator
{
Assert(dim != 0,
ExcMessage("Cannot unroll an object of type Tensor<0,0,Number>"));
- Assert(current != end, ExcMessage("Cannot put value in end iterator"));
+ Assert(std::distance(current, end) >= 1,
+ ExcMessage("The provided iterator range must contain at least one "
+ "element."));
*current = value;
- return current + 1;
+ return std::next(current);
}
+
template <int dim, typename Number>
constexpr inline void
Tensor<0, dim, Number>::clear()
}
+
+template <int dim, typename Number>
+template <class Iterator>
+inline void
+Tensor<0, dim, Number>::unroll(const Iterator begin, const Iterator end) const
+{
+ AssertDimension(std::distance(begin, end), n_independent_components);
+ unroll_recursion(begin, end);
+}
+
+
+
template <int dim, typename Number>
template <class Archive>
inline void
}
+
template <int rank_, int dim, typename Number>
template <typename OtherNumber>
inline void
Tensor<rank_, dim, Number>::unroll(Vector<OtherNumber> &result) const
{
- AssertDimension(result.size(),
- (Utilities::fixed_power<rank_, unsigned int>(dim)));
+ unroll(result.begin(), result.end());
+}
+
+
- unroll_recursion(result.begin(), result.end());
+template <int rank_, int dim, typename Number>
+template <class Iterator>
+inline void
+Tensor<rank_, dim, Number>::unroll(const Iterator begin,
+ const Iterator end) const
+{
+ AssertDimension(std::distance(begin, end), n_independent_components);
+ unroll_recursion(begin, end);
}
+
template <int rank_, int dim, typename Number>
template <typename Iterator>
Iterator