--- /dev/null
+New: Amend VectorizedArray with a default constructor and
+a constructor taking a scalar value.
+<br>
+(Peter Munch, 2019/07/29)
// (as well as with switched arguments and double<->float).
using product_type = typename ProductType<Number, OtherNumber>::type;
SymmetricTensor<rank_, dim, product_type> tt(t);
- // we used to shorten the following by 'tt *= product_type(factor);'
- // which requires that a converting constructor
- // 'product_type::product_type(const OtherNumber) is defined.
- // however, a user-defined constructor is not allowed for aggregates,
- // e.g. VectorizedArray. therefore, we work around this issue using a
- // copy-assignment operator 'product_type::operator=(const OtherNumber)'
- // which we assume to be defined.
- product_type new_factor;
- new_factor = factor;
- tt *= new_factor;
+ tt *= product_type(factor);
return tt;
}
// POD means that there should be no user-defined constructors, destructors
// and copy functions (the standard is somewhat relaxed in C++2011, though).
+ /**
+ * Default empty constructor, leaving the data in an uninitialized state
+ * similar to float/double.
+ */
+ VectorizedArray() = default;
+
+ /**
+ * Construct an array with the given scalar broadcast to all lanes
+ */
+ VectorizedArray(const Number scalar)
+ {
+ this->operator=(scalar);
+ }
+
/**
* This function assigns a scalar to this class.
*/
*/
static const unsigned int n_array_elements = 8;
+ /**
+ * Default empty constructor, leaving the data in an uninitialized state
+ * similar to float/double.
+ */
+ VectorizedArray() = default;
+
+ /**
+ * Construct an array with the given scalar broadcast to all lanes
+ */
+ VectorizedArray(const double scalar)
+ {
+ this->operator=(scalar);
+ }
+
/**
* This function can be used to set all data fields to a given scalar.
*/
*/
static const unsigned int n_array_elements = 16;
+ /**
+ * Default empty constructor, leaving the data in an uninitialized state
+ * similar to float/double.
+ */
+ VectorizedArray() = default;
+
+ /**
+ * Construct an array with the given scalar broadcast to all lanes
+ */
+ VectorizedArray(const float scalar)
+ {
+ this->operator=(scalar);
+ }
+
/**
* This function can be used to set all data fields to a given scalar.
*/
*/
static const unsigned int n_array_elements = 4;
+ /**
+ * Default empty constructor, leaving the data in an uninitialized state
+ * similar to float/double.
+ */
+ VectorizedArray() = default;
+
+ /**
+ * Construct an array with the given scalar broadcast to all lanes
+ */
+ VectorizedArray(const double scalar)
+ {
+ this->operator=(scalar);
+ }
+
/**
* This function can be used to set all data fields to a given scalar.
*/
*/
static const unsigned int n_array_elements = 8;
+ /**
+ * Default empty constructor, leaving the data in an uninitialized state
+ * similar to float/double.
+ */
+ VectorizedArray() = default;
+
+ /**
+ * Construct an array with the given scalar broadcast to all lanes
+ */
+ VectorizedArray(const float scalar)
+ {
+ this->operator=(scalar);
+ }
+
/**
* This function can be used to set all data fields to a given scalar.
*/
*/
static const unsigned int n_array_elements = 2;
+ /**
+ * Default empty constructor, leaving the data in an uninitialized state
+ * similar to float/double.
+ */
+ VectorizedArray() = default;
+
+ /**
+ * Construct an array with the given scalar broadcast to all lanes
+ */
+ VectorizedArray(const double scalar)
+ {
+ this->operator=(scalar);
+ }
+
/**
* This function can be used to set all data fields to a given scalar.
*/
* This function can be used to set all data fields to a given scalar.
*/
+ /**
+ * Default empty constructor, leaving the data in an uninitialized state
+ * similar to float/double.
+ */
+ VectorizedArray() = default;
+
+ /**
+ * Construct an array with the given scalar broadcast to all lanes
+ */
+ VectorizedArray(const float scalar)
+ {
+ this->operator=(scalar);
+ }
+
DEAL_II_ALWAYS_INLINE
VectorizedArray &
operator=(const float x)
*/
static const unsigned int n_array_elements = 2;
+ /**
+ * Default empty constructor, leaving the data in an uninitialized state
+ * similar to float/double.
+ */
+ VectorizedArray() = default;
+
+ /**
+ * Construct an array with the given scalar broadcast to all lanes
+ */
+ VectorizedArray(const double scalar)
+ {
+ this->operator=(scalar);
+ }
+
/**
* This function assigns a scalar to this class.
*/
*/
static const unsigned int n_array_elements = 4;
+ /**
+ * Default empty constructor, leaving the data in an uninitialized state
+ * similar to float/double.
+ */
+ VectorizedArray() = default;
+
+ /**
+ * Construct an array with the given scalar broadcast to all lanes
+ */
+ VectorizedArray(const float scalar)
+ {
+ this->operator=(scalar);
+ }
+
/**
* This function assigns a scalar to this class.
*/
test()
{
do_test(make_vectorized_array<double>(2.0), 2.0);
+ do_test(VectorizedArray<double>(2.0), 2.0);
#if DEAL_II_COMPILER_VECTORIZATION_LEVEL >= 3 && defined(__AVX512F__)
do_test(make_vectorized_array<VectorizedArray<double, 8>>(2.0), 2.0);
+ do_test(VectorizedArray<double, 8>(2.0), 2.0);
#endif
#if DEAL_II_COMPILER_VECTORIZATION_LEVEL >= 2 && defined(__AVX__)
do_test(make_vectorized_array<VectorizedArray<double, 4>>(2.0), 2.0);
+ do_test(VectorizedArray<double, 4>(2.0), 2.0);
#endif
#if DEAL_II_COMPILER_VECTORIZATION_LEVEL >= 1 && defined(__SSE2__)
do_test(make_vectorized_array<VectorizedArray<double, 2>>(2.0), 2.0);
+ do_test(VectorizedArray<double, 2>(2.0), 2.0);
#endif
do_test(make_vectorized_array<VectorizedArray<double, 1>>(2.0), 2.0);
+ do_test(VectorizedArray<double, 1>(2.0), 2.0);
}
};
test()
{
do_test(make_vectorized_array<float>(2.0), 2.0);
+ do_test(VectorizedArray<float>(2.0), 2.0);
#if DEAL_II_COMPILER_VECTORIZATION_LEVEL >= 3 && defined(__AVX512F__)
do_test(make_vectorized_array<VectorizedArray<float, 16>>(2.0), 2.0);
+ do_test(VectorizedArray<float, 16>(2.0), 2.0);
#endif
#if DEAL_II_COMPILER_VECTORIZATION_LEVEL >= 2 && defined(__AVX__)
do_test(make_vectorized_array<VectorizedArray<float, 8>>(2.0), 2.0);
+ do_test(VectorizedArray<float, 8>(2.0), 2.0);
#endif
#if DEAL_II_COMPILER_VECTORIZATION_LEVEL >= 1 && defined(__SSE2__)
do_test(make_vectorized_array<VectorizedArray<float, 4>>(2.0), 2.0);
+ do_test(VectorizedArray<float, 4>(2.0), 2.0);
#endif
do_test(make_vectorized_array<VectorizedArray<float, 1>>(2.0), 2.0);
+ do_test(VectorizedArray<float, 1>(2.0), 2.0);
}
};
DEAL::double:
DEAL:: test 1 array elements
DEAL:: test 1 array elements
+DEAL:: test 1 array elements
+DEAL:: test 1 array elements
DEAL::float:
DEAL:: test 1 array elements
DEAL:: test 1 array elements
+DEAL:: test 1 array elements
+DEAL:: test 1 array elements
DEAL::double:
DEAL:: test 4 array elements
DEAL:: test 4 array elements
+DEAL:: test 4 array elements
+DEAL:: test 4 array elements
DEAL:: test 2 array elements
+DEAL:: test 2 array elements
+DEAL:: test 1 array elements
DEAL:: test 1 array elements
DEAL::float:
DEAL:: test 8 array elements
DEAL:: test 8 array elements
+DEAL:: test 8 array elements
+DEAL:: test 8 array elements
DEAL:: test 4 array elements
+DEAL:: test 4 array elements
+DEAL:: test 1 array elements
DEAL:: test 1 array elements
DEAL::double:
DEAL:: test 8 array elements
DEAL:: test 8 array elements
+DEAL:: test 8 array elements
+DEAL:: test 8 array elements
+DEAL:: test 4 array elements
DEAL:: test 4 array elements
DEAL:: test 2 array elements
+DEAL:: test 2 array elements
+DEAL:: test 1 array elements
DEAL:: test 1 array elements
DEAL::float:
DEAL:: test 16 array elements
DEAL:: test 16 array elements
+DEAL:: test 16 array elements
+DEAL:: test 16 array elements
+DEAL:: test 8 array elements
DEAL:: test 8 array elements
DEAL:: test 4 array elements
+DEAL:: test 4 array elements
+DEAL:: test 1 array elements
DEAL:: test 1 array elements
DEAL::double:
DEAL:: test 2 array elements
DEAL:: test 2 array elements
+DEAL:: test 2 array elements
+DEAL:: test 2 array elements
+DEAL:: test 1 array elements
DEAL:: test 1 array elements
DEAL::float:
DEAL:: test 4 array elements
DEAL:: test 4 array elements
+DEAL:: test 4 array elements
+DEAL:: test 4 array elements
+DEAL:: test 1 array elements
DEAL:: test 1 array elements