mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Clang-format tests, examples, libraries, benchmarks, etc.
This commit is contained in:
committed by
Rasmus Munk Larsen
parent
3252ecc7a4
commit
46e9cdb7fe
@@ -11,36 +11,33 @@
|
||||
|
||||
#include <Eigen/CXX11/Tensor>
|
||||
|
||||
template<typename Scalar>
|
||||
static void test_default()
|
||||
{
|
||||
template <typename Scalar>
|
||||
static void test_default() {
|
||||
Tensor<Scalar, 1> vec(6);
|
||||
vec.setRandom();
|
||||
|
||||
// Fixme: we should check that the generated numbers follow a uniform
|
||||
// distribution instead.
|
||||
for (int i = 1; i < 6; ++i) {
|
||||
VERIFY_IS_NOT_EQUAL(vec(i), vec(i-1));
|
||||
VERIFY_IS_NOT_EQUAL(vec(i), vec(i - 1));
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Scalar>
|
||||
static void test_normal()
|
||||
{
|
||||
template <typename Scalar>
|
||||
static void test_normal() {
|
||||
Tensor<Scalar, 1> vec(6);
|
||||
vec.template setRandom<Eigen::internal::NormalRandomGenerator<Scalar>>();
|
||||
|
||||
// Fixme: we should check that the generated numbers follow a gaussian
|
||||
// distribution instead.
|
||||
for (int i = 1; i < 6; ++i) {
|
||||
VERIFY_IS_NOT_EQUAL(vec(i), vec(i-1));
|
||||
VERIFY_IS_NOT_EQUAL(vec(i), vec(i - 1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct MyGenerator {
|
||||
MyGenerator() { }
|
||||
MyGenerator(const MyGenerator&) { }
|
||||
MyGenerator() {}
|
||||
MyGenerator(const MyGenerator&) {}
|
||||
|
||||
// Return a random value to be used. "element_location" is the
|
||||
// location of the entry to set in the tensor, it can typically
|
||||
@@ -50,8 +47,8 @@ struct MyGenerator {
|
||||
}
|
||||
|
||||
// Same as above but generates several numbers at a time.
|
||||
internal::packet_traits<int>::type packetOp(
|
||||
Eigen::DenseIndex packet_location, Eigen::DenseIndex /*unused*/ = 0) const {
|
||||
internal::packet_traits<int>::type packetOp(Eigen::DenseIndex packet_location,
|
||||
Eigen::DenseIndex /*unused*/ = 0) const {
|
||||
const int packetSize = internal::packet_traits<int>::size;
|
||||
EIGEN_ALIGN_MAX int values[packetSize];
|
||||
for (int i = 0; i < packetSize; ++i) {
|
||||
@@ -61,19 +58,16 @@ struct MyGenerator {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
static void test_custom()
|
||||
{
|
||||
static void test_custom() {
|
||||
Tensor<int, 1> vec(6);
|
||||
vec.setRandom<MyGenerator>();
|
||||
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
VERIFY_IS_EQUAL(vec(i), 3*i);
|
||||
VERIFY_IS_EQUAL(vec(i), 3 * i);
|
||||
}
|
||||
}
|
||||
|
||||
EIGEN_DECLARE_TEST(cxx11_tensor_random)
|
||||
{
|
||||
EIGEN_DECLARE_TEST(cxx11_tensor_random) {
|
||||
CALL_SUBTEST((test_default<float>()));
|
||||
CALL_SUBTEST((test_normal<float>()));
|
||||
CALL_SUBTEST((test_default<double>()));
|
||||
|
||||
Reference in New Issue
Block a user