// Enable the EnableIfScalar type trait for VectorizedArray<Number> such
// that it can be used as a Number type in Tensor<rank,dim,Number>, etc.
-template <typename Number, int width>
+template <typename Number, std::size_t width>
struct EnableIfScalar<VectorizedArray<Number, width>>
{
using type = VectorizedArray<typename EnableIfScalar<Number>::type, width>;
* @param data The actual VectorizedArray.
* @param lane A pointer to the current lane.
*/
- VectorizedArrayIterator(T &data, const unsigned int lane)
+ VectorizedArrayIterator(T &data, const std::size_t lane)
: data(&data)
, lane(lane)
{}
* reference to <tt>*this</tt>.
*/
VectorizedArrayIterator<T> &
- operator+=(const unsigned int offset)
+ operator+=(const std::size_t offset)
{
AssertIndexRange(lane + offset, T::size() + 1);
lane += offset;
* Create new iterator, which is shifted by @p offset.
*/
VectorizedArrayIterator<T>
- operator+(const unsigned int offset) const
+ operator+(const std::size_t &offset) const
{
AssertIndexRange(lane + offset, T::size() + 1);
return VectorizedArrayIterator<T>(*data, lane + offset);
/**
* Compute distance between this iterator and iterator @p other.
*/
- unsigned int
+ std::ptrdiff_t
operator-(const VectorizedArrayIterator<T> &other) const
{
- AssertIndexRange(other.lane, lane + 1);
- return lane - other.lane;
+ return static_cast<std::ptrdiff_t>(lane) -
+ static_cast<ptrdiff_t>(other.lane);
}
private:
/**
* Pointer to the current lane.
*/
- unsigned int lane;
+ std::size_t lane;
};
* Return the number of elements in the array stored in the variable
* n_array_elements of VectorizedArray.
*/
- static constexpr unsigned int
+ static constexpr std::size_t
size()
{
return T::n_array_elements;
*
* @author Katharina Kormann, Martin Kronbichler, Peter Munch, 2010, 2011, 2019
*/
-template <typename Number, int width>
+template <typename Number, std::size_t width>
class VectorizedArray
: public VectorizedArrayBase<VectorizedArray<Number, width>>
{
}
// Make a few functions friends.
- template <typename Number2, int width2>
+ template <typename Number2, std::size_t width2>
friend VectorizedArray<Number2, width2>
std::sqrt(const VectorizedArray<Number2, width2> &);
- template <typename Number2, int width2>
+ template <typename Number2, std::size_t width2>
friend VectorizedArray<Number2, width2>
std::abs(const VectorizedArray<Number2, width2> &);
- template <typename Number2, int width2>
+ template <typename Number2, std::size_t width2>
friend VectorizedArray<Number2, width2>
std::max(const VectorizedArray<Number2, width2> &,
const VectorizedArray<Number2, width2> &);
- template <typename Number2, int width2>
+ template <typename Number2, std::size_t width2>
friend VectorizedArray<Number2, width2>
std::min(const VectorizedArray<Number2, width2> &,
const VectorizedArray<Number2, width2> &);
// We need to have a separate declaration for static const members
-template <typename Number, int width>
+template <typename Number, std::size_t width>
const unsigned int VectorizedArray<Number, width>::n_array_elements;
*
* @relatesalso VectorizedArray
*/
-template <
- typename Number,
- int width = internal::VectorizedArrayWidthSpecifier<Number>::max_width>
+template <typename Number,
+ std::size_t width =
+ internal::VectorizedArrayWidthSpecifier<Number>::max_width>
inline DEAL_II_ALWAYS_INLINE VectorizedArray<Number, width>
make_vectorized_array(const Number &u)
{
* out.data[v] = ptrs[v][offset];
* @endcode
*/
-template <typename Number, int width, std::size_t width_>
+template <typename Number, std::size_t width>
inline DEAL_II_ALWAYS_INLINE void
-gather(VectorizedArray<Number, width> & out,
- const std::array<Number *, width_> &ptrs,
- const unsigned int offset)
+gather(VectorizedArray<Number, width> & out,
+ const std::array<Number *, width> &ptrs,
+ const unsigned int offset)
{
- static_assert(width == width_, "Length of input vector do not match!");
-
- for (unsigned int v = 0; v < width_; v++)
+ for (unsigned int v = 0; v < width; v++)
out.data[v] = ptrs[v][offset];
}
*
* @relatesalso VectorizedArray
*/
-template <typename Number, int width>
+template <typename Number, std::size_t width>
inline DEAL_II_ALWAYS_INLINE void
vectorized_load_and_transpose(const unsigned int n_entries,
const Number * in,
* of pointers and no assumption can be made that they belong to the same array,
* i.e., they can have their origin in different memory allocations.
*/
-template <typename Number, int width, std::size_t width_>
+template <typename Number, std::size_t width>
inline DEAL_II_ALWAYS_INLINE void
-vectorized_load_and_transpose(const unsigned int n_entries,
- const std::array<Number *, width_> &in,
- VectorizedArray<Number, width> * out)
+vectorized_load_and_transpose(const unsigned int n_entries,
+ const std::array<Number *, width> &in,
+ VectorizedArray<Number, width> * out)
{
- static_assert(width == width_, "Length of input vector do not match!");
-
for (unsigned int i = 0; i < n_entries; ++i)
for (unsigned int v = 0;
v < VectorizedArray<Number, width>::n_array_elements;
*
* @relatesalso VectorizedArray
*/
-template <typename Number, int width>
+template <typename Number, std::size_t width>
inline DEAL_II_ALWAYS_INLINE void
vectorized_transpose_and_store(const bool add_into,
const unsigned int n_entries,
* of pointers and no assumption can be made that they belong to the same array,
* i.e., they can have their origin in different memory allocations.
*/
-template <typename Number, int width, std::size_t width_>
+template <typename Number, std::size_t width>
inline DEAL_II_ALWAYS_INLINE void
vectorized_transpose_and_store(const bool add_into,
const unsigned int n_entries,
const VectorizedArray<Number, width> *in,
- std::array<Number *, width_> & out)
+ std::array<Number *, width> & out)
{
- static_assert(width == width_, "Length of input vector do not match!");
-
if (add_into)
for (unsigned int i = 0; i < n_entries; ++i)
for (unsigned int v = 0;
}
// Make a few functions friends.
- template <typename Number2, int width2>
+ template <typename Number2, std::size_t width2>
friend VectorizedArray<Number2, width2>
std::sqrt(const VectorizedArray<Number2, width2> &);
- template <typename Number2, int width2>
+ template <typename Number2, std::size_t width2>
friend VectorizedArray<Number2, width2>
std::abs(const VectorizedArray<Number2, width2> &);
- template <typename Number2, int width2>
+ template <typename Number2, std::size_t width2>
friend VectorizedArray<Number2, width2>
std::max(const VectorizedArray<Number2, width2> &,
const VectorizedArray<Number2, width2> &);
- template <typename Number2, int width2>
+ template <typename Number2, std::size_t width2>
friend VectorizedArray<Number2, width2>
std::min(const VectorizedArray<Number2, width2> &,
const VectorizedArray<Number2, width2> &);
}
// Make a few functions friends.
- template <typename Number2, int width2>
+ template <typename Number2, std::size_t width2>
friend VectorizedArray<Number2, width2>
std::sqrt(const VectorizedArray<Number2, width2> &);
- template <typename Number2, int width2>
+ template <typename Number2, std::size_t width2>
friend VectorizedArray<Number2, width2>
std::abs(const VectorizedArray<Number2, width2> &);
- template <typename Number2, int width2>
+ template <typename Number2, std::size_t width2>
friend VectorizedArray<Number2, width2>
std::max(const VectorizedArray<Number2, width2> &,
const VectorizedArray<Number2, width2> &);
- template <typename Number2, int width2>
+ template <typename Number2, std::size_t width2>
friend VectorizedArray<Number2, width2>
std::min(const VectorizedArray<Number2, width2> &,
const VectorizedArray<Number2, width2> &);
}
// Make a few functions friends.
- template <typename Number2, int width2>
+ template <typename Number2, std::size_t width2>
friend VectorizedArray<Number2, width2>
std::sqrt(const VectorizedArray<Number2, width2> &);
- template <typename Number2, int width2>
+ template <typename Number2, std::size_t width2>
friend VectorizedArray<Number2, width2>
std::abs(const VectorizedArray<Number2, width2> &);
- template <typename Number2, int width2>
+ template <typename Number2, std::size_t width2>
friend VectorizedArray<Number2, width2>
std::max(const VectorizedArray<Number2, width2> &,
const VectorizedArray<Number2, width2> &);
- template <typename Number2, int width2>
+ template <typename Number2, std::size_t width2>
friend VectorizedArray<Number2, width2>
std::min(const VectorizedArray<Number2, width2> &,
const VectorizedArray<Number2, width2> &);
}
// Make a few functions friends.
- template <typename Number2, int width2>
+ template <typename Number2, std::size_t width2>
friend VectorizedArray<Number2, width2>
std::sqrt(const VectorizedArray<Number2, width2> &);
- template <typename Number2, int width2>
+ template <typename Number2, std::size_t width2>
friend VectorizedArray<Number2, width2>
std::abs(const VectorizedArray<Number2, width2> &);
- template <typename Number2, int width2>
+ template <typename Number2, std::size_t width2>
friend VectorizedArray<Number2, width2>
std::max(const VectorizedArray<Number2, width2> &,
const VectorizedArray<Number2, width2> &);
- template <typename Number2, int width2>
+ template <typename Number2, std::size_t width2>
friend VectorizedArray<Number2, width2>
std::min(const VectorizedArray<Number2, width2> &,
const VectorizedArray<Number2, width2> &);
}
// Make a few functions friends.
- template <typename Number2, int width2>
+ template <typename Number2, std::size_t width2>
friend VectorizedArray<Number2, width2>
std::sqrt(const VectorizedArray<Number2, width2> &);
- template <typename Number2, int width2>
+ template <typename Number2, std::size_t width2>
friend VectorizedArray<Number2, width2>
std::abs(const VectorizedArray<Number2, width2> &);
- template <typename Number2, int width2>
+ template <typename Number2, std::size_t width2>
friend VectorizedArray<Number2, width2>
std::max(const VectorizedArray<Number2, width2> &,
const VectorizedArray<Number2, width2> &);
- template <typename Number2, int width2>
+ template <typename Number2, std::size_t width2>
friend VectorizedArray<Number2, width2>
std::min(const VectorizedArray<Number2, width2> &,
const VectorizedArray<Number2, width2> &);
}
// Make a few functions friends.
- template <typename Number2, int width2>
+ template <typename Number2, std::size_t width2>
friend VectorizedArray<Number2, width2>
std::sqrt(const VectorizedArray<Number2, width2> &);
- template <typename Number2, int width2>
+ template <typename Number2, std::size_t width2>
friend VectorizedArray<Number2, width2>
std::abs(const VectorizedArray<Number2, width2> &);
- template <typename Number2, int width2>
+ template <typename Number2, std::size_t width2>
friend VectorizedArray<Number2, width2>
std::max(const VectorizedArray<Number2, width2> &,
const VectorizedArray<Number2, width2> &);
- template <typename Number2, int width2>
+ template <typename Number2, std::size_t width2>
friend VectorizedArray<Number2, width2>
std::min(const VectorizedArray<Number2, width2> &,
const VectorizedArray<Number2, width2> &);
}
// Make a few functions friends.
- template <typename Number2, int width2>
+ template <typename Number2, std::size_t width2>
friend VectorizedArray<Number2, width2>
std::sqrt(const VectorizedArray<Number2, width2> &);
- template <typename Number2, int width2>
+ template <typename Number2, std::size_t width2>
friend VectorizedArray<Number2, width2>
std::abs(const VectorizedArray<Number2, width2> &);
- template <typename Number2, int width2>
+ template <typename Number2, std::size_t width2>
friend VectorizedArray<Number2, width2>
std::max(const VectorizedArray<Number2, width2> &,
const VectorizedArray<Number2, width2> &);
- template <typename Number2, int width2>
+ template <typename Number2, std::size_t width2>
friend VectorizedArray<Number2, width2>
std::min(const VectorizedArray<Number2, width2> &,
const VectorizedArray<Number2, width2> &);
}
// Make a few functions friends.
- template <typename Number2, int width2>
+ template <typename Number2, std::size_t width2>
friend VectorizedArray<Number2, width2>
std::sqrt(const VectorizedArray<Number2, width2> &);
- template <typename Number2, int width2>
+ template <typename Number2, std::size_t width2>
friend VectorizedArray<Number2, width2>
std::abs(const VectorizedArray<Number2, width2> &);
- template <typename Number2, int width2>
+ template <typename Number2, std::size_t width2>
friend VectorizedArray<Number2, width2>
std::max(const VectorizedArray<Number2, width2> &,
const VectorizedArray<Number2, width2> &);
- template <typename Number2, int width2>
+ template <typename Number2, std::size_t width2>
friend VectorizedArray<Number2, width2>
std::min(const VectorizedArray<Number2, width2> &,
const VectorizedArray<Number2, width2> &);
*
* @relatesalso VectorizedArray
*/
-template <typename Number, int width>
+template <typename Number, std::size_t width>
inline DEAL_II_ALWAYS_INLINE bool
operator==(const VectorizedArray<Number, width> &lhs,
const VectorizedArray<Number, width> &rhs)
*
* @relatesalso VectorizedArray
*/
-template <typename Number, int width>
+template <typename Number, std::size_t width>
inline DEAL_II_ALWAYS_INLINE VectorizedArray<Number, width>
operator+(const VectorizedArray<Number, width> &u,
const VectorizedArray<Number, width> &v)
*
* @relatesalso VectorizedArray
*/
-template <typename Number, int width>
+template <typename Number, std::size_t width>
inline DEAL_II_ALWAYS_INLINE VectorizedArray<Number, width>
operator-(const VectorizedArray<Number, width> &u,
const VectorizedArray<Number, width> &v)
*
* @relatesalso VectorizedArray
*/
-template <typename Number, int width>
+template <typename Number, std::size_t width>
inline DEAL_II_ALWAYS_INLINE VectorizedArray<Number, width>
operator*(const VectorizedArray<Number, width> &u,
const VectorizedArray<Number, width> &v)
*
* @relatesalso VectorizedArray
*/
-template <typename Number, int width>
+template <typename Number, std::size_t width>
inline DEAL_II_ALWAYS_INLINE VectorizedArray<Number, width>
operator/(const VectorizedArray<Number, width> &u,
const VectorizedArray<Number, width> &v)
*
* @relatesalso VectorizedArray
*/
-template <typename Number, int width>
+template <typename Number, std::size_t width>
inline DEAL_II_ALWAYS_INLINE VectorizedArray<Number, width>
operator+(const Number &u, const VectorizedArray<Number, width> &v)
{
*
* @relatesalso VectorizedArray
*/
-template <int width>
+template <std::size_t width>
inline DEAL_II_ALWAYS_INLINE VectorizedArray<float, width>
operator+(const double u, const VectorizedArray<float, width> &v)
{
*
* @relatesalso VectorizedArray
*/
-template <typename Number, int width>
+template <typename Number, std::size_t width>
inline DEAL_II_ALWAYS_INLINE VectorizedArray<Number, width>
operator+(const VectorizedArray<Number, width> &v, const Number &u)
{
*
* @relatesalso VectorizedArray
*/
-template <int width>
+template <std::size_t width>
inline DEAL_II_ALWAYS_INLINE VectorizedArray<float, width>
operator+(const VectorizedArray<float, width> &v, const double u)
{
*
* @relatesalso VectorizedArray
*/
-template <typename Number, int width>
+template <typename Number, std::size_t width>
inline DEAL_II_ALWAYS_INLINE VectorizedArray<Number, width>
operator-(const Number &u, const VectorizedArray<Number, width> &v)
{
*
* @relatesalso VectorizedArray
*/
-template <int width>
+template <std::size_t width>
inline DEAL_II_ALWAYS_INLINE VectorizedArray<float, width>
operator-(const double u, const VectorizedArray<float, width> &v)
{
*
* @relatesalso VectorizedArray
*/
-template <typename Number, int width>
+template <typename Number, std::size_t width>
inline DEAL_II_ALWAYS_INLINE VectorizedArray<Number, width>
operator-(const VectorizedArray<Number, width> &v, const Number &u)
{
*
* @relatesalso VectorizedArray
*/
-template <int width>
+template <std::size_t width>
inline DEAL_II_ALWAYS_INLINE VectorizedArray<float, width>
operator-(const VectorizedArray<float, width> &v, const double u)
{
*
* @relatesalso VectorizedArray
*/
-template <typename Number, int width>
+template <typename Number, std::size_t width>
inline DEAL_II_ALWAYS_INLINE VectorizedArray<Number, width>
operator*(const Number &u, const VectorizedArray<Number, width> &v)
{
*
* @relatesalso VectorizedArray
*/
-template <int width>
+template <std::size_t width>
inline DEAL_II_ALWAYS_INLINE VectorizedArray<float, width>
operator*(const double u, const VectorizedArray<float, width> &v)
{
*
* @relatesalso VectorizedArray
*/
-template <typename Number, int width>
+template <typename Number, std::size_t width>
inline DEAL_II_ALWAYS_INLINE VectorizedArray<Number, width>
operator*(const VectorizedArray<Number, width> &v, const Number &u)
{
*
* @relatesalso VectorizedArray
*/
-template <int width>
+template <std::size_t width>
inline DEAL_II_ALWAYS_INLINE VectorizedArray<float, width>
operator*(const VectorizedArray<float, width> &v, const double u)
{
*
* @relatesalso VectorizedArray
*/
-template <typename Number, int width>
+template <typename Number, std::size_t width>
inline DEAL_II_ALWAYS_INLINE VectorizedArray<Number, width>
operator/(const Number &u, const VectorizedArray<Number, width> &v)
{
*
* @relatesalso VectorizedArray
*/
-template <int width>
+template <std::size_t width>
inline DEAL_II_ALWAYS_INLINE VectorizedArray<float, width>
operator/(const double u, const VectorizedArray<float, width> &v)
{
*
* @relatesalso VectorizedArray
*/
-template <typename Number, int width>
+template <typename Number, std::size_t width>
inline DEAL_II_ALWAYS_INLINE VectorizedArray<Number, width>
operator/(const VectorizedArray<Number, width> &v, const Number &u)
{
*
* @relatesalso VectorizedArray
*/
-template <int width>
+template <std::size_t width>
inline DEAL_II_ALWAYS_INLINE VectorizedArray<float, width>
operator/(const VectorizedArray<float, width> &v, const double u)
{
*
* @relatesalso VectorizedArray
*/
-template <typename Number, int width>
+template <typename Number, std::size_t width>
inline DEAL_II_ALWAYS_INLINE VectorizedArray<Number, width>
operator+(const VectorizedArray<Number, width> &u)
{
*
* @relatesalso VectorizedArray
*/
-template <typename Number, int width>
+template <typename Number, std::size_t width>
inline DEAL_II_ALWAYS_INLINE VectorizedArray<Number, width>
operator-(const VectorizedArray<Number, width> &u)
{
*
* @relatesalso VectorizedArray
*/
-template <typename Number, int width>
+template <typename Number, std::size_t width>
inline std::ostream &
operator<<(std::ostream &out, const VectorizedArray<Number, width> &p)
{
*
* @relatesalso VectorizedArray
*/
- template <typename Number, int width>
+ template <typename Number, std::size_t width>
inline ::dealii::VectorizedArray<Number, width>
sin(const ::dealii::VectorizedArray<Number, width> &x)
{
*
* @relatesalso VectorizedArray
*/
- template <typename Number, int width>
+ template <typename Number, std::size_t width>
inline ::dealii::VectorizedArray<Number, width>
cos(const ::dealii::VectorizedArray<Number, width> &x)
{
*
* @relatesalso VectorizedArray
*/
- template <typename Number, int width>
+ template <typename Number, std::size_t width>
inline ::dealii::VectorizedArray<Number, width>
tan(const ::dealii::VectorizedArray<Number, width> &x)
{
*
* @relatesalso VectorizedArray
*/
- template <typename Number, int width>
+ template <typename Number, std::size_t width>
inline ::dealii::VectorizedArray<Number, width>
exp(const ::dealii::VectorizedArray<Number, width> &x)
{
*
* @relatesalso VectorizedArray
*/
- template <typename Number, int width>
+ template <typename Number, std::size_t width>
inline ::dealii::VectorizedArray<Number, width>
log(const ::dealii::VectorizedArray<Number, width> &x)
{
*
* @relatesalso VectorizedArray
*/
- template <typename Number, int width>
+ template <typename Number, std::size_t width>
inline ::dealii::VectorizedArray<Number, width>
sqrt(const ::dealii::VectorizedArray<Number, width> &x)
{
*
* @relatesalso VectorizedArray
*/
- template <typename Number, int width>
+ template <typename Number, std::size_t width>
inline ::dealii::VectorizedArray<Number, width>
pow(const ::dealii::VectorizedArray<Number, width> &x, const Number p)
{
*
* @relatesalso VectorizedArray
*/
- template <typename Number, int width>
+ template <typename Number, std::size_t width>
inline ::dealii::VectorizedArray<Number, width>
abs(const ::dealii::VectorizedArray<Number, width> &x)
{
*
* @relatesalso VectorizedArray
*/
- template <typename Number, int width>
+ template <typename Number, std::size_t width>
inline ::dealii::VectorizedArray<Number, width>
max(const ::dealii::VectorizedArray<Number, width> &x,
const ::dealii::VectorizedArray<Number, width> &y)
*
* @relatesalso VectorizedArray
*/
- template <typename Number, int width>
+ template <typename Number, std::size_t width>
inline ::dealii::VectorizedArray<Number, width>
min(const ::dealii::VectorizedArray<Number, width> &x,
const ::dealii::VectorizedArray<Number, width> &y)
{
using iterator_category = random_access_iterator_tag;
using value_type = typename T::value_type;
- using difference_type = unsigned int;
+ using difference_type = std::ptrdiff_t;
};
} // namespace std