From aebdb0642402e49ded58db98dd29c67cd76d204a Mon Sep 17 00:00:00 2001 From: Rasmus Munk Larsen Date: Tue, 14 Aug 2018 12:06:39 -0700 Subject: [PATCH] Fix a few compiler warnings in CXX11 tests. --- unsupported/test/cxx11_tensor_contraction.cpp | 4 +-- unsupported/test/cxx11_tensor_convolution.cpp | 2 +- unsupported/test/cxx11_tensor_index_list.cpp | 1 - unsupported/test/kronecker_product.cpp | 27 ++++++++++--------- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/unsupported/test/cxx11_tensor_contraction.cpp b/unsupported/test/cxx11_tensor_contraction.cpp index d4cfbd0da..2e918eb30 100644 --- a/unsupported/test/cxx11_tensor_contraction.cpp +++ b/unsupported/test/cxx11_tensor_contraction.cpp @@ -471,7 +471,7 @@ static void test_tensor_product() mat1.setRandom(); mat2.setRandom(); - Tensor result = mat1.contract(mat2, Eigen::array{{}}); + Tensor result = mat1.contract(mat2, Eigen::array{}); VERIFY_IS_EQUAL(result.dimension(0), 2); VERIFY_IS_EQUAL(result.dimension(1), 3); @@ -553,7 +553,7 @@ static void test_large_contraction_with_output_kernel() { m_result = m_left * m_right; - for (size_t i = 0; i < t_result.dimensions().TotalSize(); i++) { + for (std::ptrdiff_t i = 0; i < t_result.dimensions().TotalSize(); i++) { VERIFY(&t_result.data()[i] != &m_result.data()[i]); VERIFY_IS_APPROX(t_result.data()[i], std::sqrt(m_result.data()[i])); } diff --git a/unsupported/test/cxx11_tensor_convolution.cpp b/unsupported/test/cxx11_tensor_convolution.cpp index 01bc77bc1..9fe980648 100644 --- a/unsupported/test/cxx11_tensor_convolution.cpp +++ b/unsupported/test/cxx11_tensor_convolution.cpp @@ -25,7 +25,7 @@ static void test_evals() Tensor result(2,3); result.setZero(); - Eigen::array::Index, 1> dims3{{0}}; + Eigen::array::Index, 1> dims3{0}; typedef TensorEvaluator Evaluator; Evaluator eval(input.convolve(kernel, dims3), DefaultDevice()); diff --git a/unsupported/test/cxx11_tensor_index_list.cpp b/unsupported/test/cxx11_tensor_index_list.cpp index e81fa5e40..294677a4d 100644 --- a/unsupported/test/cxx11_tensor_index_list.cpp +++ b/unsupported/test/cxx11_tensor_index_list.cpp @@ -170,7 +170,6 @@ static void test_type2indexpair_list() typedef Eigen::IndexPairList, Eigen::IndexPair, Eigen::type2indexpair<2,12>> Dims2_b; typedef Eigen::IndexPairList, Eigen::type2indexpair<1,11>, Eigen::IndexPair> Dims2_c; - Dims0 d0; Dims2_a d2_a; Dims2_b d2_b; diff --git a/unsupported/test/kronecker_product.cpp b/unsupported/test/kronecker_product.cpp index 4f143b6de..1a936ed25 100644 --- a/unsupported/test/kronecker_product.cpp +++ b/unsupported/test/kronecker_product.cpp @@ -9,6 +9,9 @@ // Public License v. 2.0. If a copy of the MPL was not distributed // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include "main.h" + #ifdef EIGEN_TEST_PART_1 #include "sparse.h" @@ -95,7 +98,7 @@ EIGEN_DECLARE_TEST(kronecker_product) SM_a.insert(1,0) = DM_a.coeffRef(1,0) = -0.9076572187376921; SM_a.insert(1,1) = DM_a.coeffRef(1,1) = 0.6469156566545853; SM_a.insert(1,2) = DM_a.coeffRef(1,2) = -0.3658010398782789; - + MatrixXd DM_b(3,2); SparseMatrix SM_b(3,2); SM_b.insert(0,0) = DM_b.coeffRef(0,0) = 0.9004440976767099; @@ -165,7 +168,7 @@ EIGEN_DECLARE_TEST(kronecker_product) SM_a.insert(0,3) = -0.2; SM_a.insert(2,4) = 0.3; SM_a.finalize(); - + SM_b.insert(0,0) = 0.4; SM_b.insert(2,1) = -0.5; SM_b.finalize(); @@ -183,7 +186,7 @@ EIGEN_DECLARE_TEST(kronecker_product) DM_b2.resize(4,8); DM_ab2 = kroneckerProduct(DM_a2,DM_b2); CALL_SUBTEST(check_dimension(DM_ab2,10*4,9*8)); - + for(int i = 0; i < g_repeat; i++) { double density = Eigen::internal::random(0.01,0.5); @@ -196,35 +199,35 @@ EIGEN_DECLARE_TEST(kronecker_product) MatrixXf dA(ra,ca), dB(rb,cb), dC; initSparse(density, dA, sA); initSparse(density, dB, sB); - + sC = kroneckerProduct(sA,sB); dC = kroneckerProduct(dA,dB); VERIFY_IS_APPROX(MatrixXf(sC),dC); - + sC = kroneckerProduct(sA.transpose(),sB); dC = kroneckerProduct(dA.transpose(),dB); VERIFY_IS_APPROX(MatrixXf(sC),dC); - + sC = kroneckerProduct(sA.transpose(),sB.transpose()); dC = kroneckerProduct(dA.transpose(),dB.transpose()); VERIFY_IS_APPROX(MatrixXf(sC),dC); - + sC = kroneckerProduct(sA,sB.transpose()); dC = kroneckerProduct(dA,dB.transpose()); VERIFY_IS_APPROX(MatrixXf(sC),dC); - + sC2 = kroneckerProduct(sA,sB); dC = kroneckerProduct(dA,dB); VERIFY_IS_APPROX(MatrixXf(sC2),dC); - + sC2 = kroneckerProduct(dA,sB); dC = kroneckerProduct(dA,dB); VERIFY_IS_APPROX(MatrixXf(sC2),dC); - + sC2 = kroneckerProduct(sA,dB); dC = kroneckerProduct(dA,dB); VERIFY_IS_APPROX(MatrixXf(sC2),dC); - + sC2 = kroneckerProduct(2*sA,sB); dC = kroneckerProduct(2*dA,dB); VERIFY_IS_APPROX(MatrixXf(sC2),dC); @@ -236,8 +239,6 @@ EIGEN_DECLARE_TEST(kronecker_product) #ifdef EIGEN_TEST_PART_2 // simply check that for a dense kronecker product, sparse module is not needed - -#include "main.h" #include EIGEN_DECLARE_TEST(kronecker_product)