Fix a few compiler warnings in CXX11 tests.

This commit is contained in:
Rasmus Munk Larsen 2018-08-14 12:06:39 -07:00
parent 59bba77ead
commit aebdb06424
4 changed files with 17 additions and 17 deletions

View File

@ -471,7 +471,7 @@ static void test_tensor_product()
mat1.setRandom(); mat1.setRandom();
mat2.setRandom(); mat2.setRandom();
Tensor<float, 4, DataLayout> result = mat1.contract(mat2, Eigen::array<DimPair, 0>{{}}); Tensor<float, 4, DataLayout> result = mat1.contract(mat2, Eigen::array<DimPair, 0>{});
VERIFY_IS_EQUAL(result.dimension(0), 2); VERIFY_IS_EQUAL(result.dimension(0), 2);
VERIFY_IS_EQUAL(result.dimension(1), 3); 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; 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(&t_result.data()[i] != &m_result.data()[i]);
VERIFY_IS_APPROX(t_result.data()[i], std::sqrt(m_result.data()[i])); VERIFY_IS_APPROX(t_result.data()[i], std::sqrt(m_result.data()[i]));
} }

View File

@ -25,7 +25,7 @@ static void test_evals()
Tensor<float, 2, DataLayout> result(2,3); Tensor<float, 2, DataLayout> result(2,3);
result.setZero(); result.setZero();
Eigen::array<Tensor<float, 2>::Index, 1> dims3{{0}}; Eigen::array<Tensor<float, 2>::Index, 1> dims3{0};
typedef TensorEvaluator<decltype(input.convolve(kernel, dims3)), DefaultDevice> Evaluator; typedef TensorEvaluator<decltype(input.convolve(kernel, dims3)), DefaultDevice> Evaluator;
Evaluator eval(input.convolve(kernel, dims3), DefaultDevice()); Evaluator eval(input.convolve(kernel, dims3), DefaultDevice());

View File

@ -170,7 +170,6 @@ static void test_type2indexpair_list()
typedef Eigen::IndexPairList<Eigen::type2indexpair<0,10>, Eigen::IndexPair<DenseIndex>, Eigen::type2indexpair<2,12>> Dims2_b; typedef Eigen::IndexPairList<Eigen::type2indexpair<0,10>, Eigen::IndexPair<DenseIndex>, Eigen::type2indexpair<2,12>> Dims2_b;
typedef Eigen::IndexPairList<Eigen::IndexPair<DenseIndex>, Eigen::type2indexpair<1,11>, Eigen::IndexPair<DenseIndex>> Dims2_c; typedef Eigen::IndexPairList<Eigen::IndexPair<DenseIndex>, Eigen::type2indexpair<1,11>, Eigen::IndexPair<DenseIndex>> Dims2_c;
Dims0 d0;
Dims2_a d2_a; Dims2_a d2_a;
Dims2_b d2_b; Dims2_b d2_b;

View File

@ -9,6 +9,9 @@
// Public License v. 2.0. If a copy of the MPL was not distributed // 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/. // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
#include "main.h"
#ifdef EIGEN_TEST_PART_1 #ifdef EIGEN_TEST_PART_1
#include "sparse.h" #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,0) = DM_a.coeffRef(1,0) = -0.9076572187376921;
SM_a.insert(1,1) = DM_a.coeffRef(1,1) = 0.6469156566545853; SM_a.insert(1,1) = DM_a.coeffRef(1,1) = 0.6469156566545853;
SM_a.insert(1,2) = DM_a.coeffRef(1,2) = -0.3658010398782789; SM_a.insert(1,2) = DM_a.coeffRef(1,2) = -0.3658010398782789;
MatrixXd DM_b(3,2); MatrixXd DM_b(3,2);
SparseMatrix<double> SM_b(3,2); SparseMatrix<double> SM_b(3,2);
SM_b.insert(0,0) = DM_b.coeffRef(0,0) = 0.9004440976767099; 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(0,3) = -0.2;
SM_a.insert(2,4) = 0.3; SM_a.insert(2,4) = 0.3;
SM_a.finalize(); SM_a.finalize();
SM_b.insert(0,0) = 0.4; SM_b.insert(0,0) = 0.4;
SM_b.insert(2,1) = -0.5; SM_b.insert(2,1) = -0.5;
SM_b.finalize(); SM_b.finalize();
@ -183,7 +186,7 @@ EIGEN_DECLARE_TEST(kronecker_product)
DM_b2.resize(4,8); DM_b2.resize(4,8);
DM_ab2 = kroneckerProduct(DM_a2,DM_b2); DM_ab2 = kroneckerProduct(DM_a2,DM_b2);
CALL_SUBTEST(check_dimension(DM_ab2,10*4,9*8)); CALL_SUBTEST(check_dimension(DM_ab2,10*4,9*8));
for(int i = 0; i < g_repeat; i++) for(int i = 0; i < g_repeat; i++)
{ {
double density = Eigen::internal::random<double>(0.01,0.5); double density = Eigen::internal::random<double>(0.01,0.5);
@ -196,35 +199,35 @@ EIGEN_DECLARE_TEST(kronecker_product)
MatrixXf dA(ra,ca), dB(rb,cb), dC; MatrixXf dA(ra,ca), dB(rb,cb), dC;
initSparse(density, dA, sA); initSparse(density, dA, sA);
initSparse(density, dB, sB); initSparse(density, dB, sB);
sC = kroneckerProduct(sA,sB); sC = kroneckerProduct(sA,sB);
dC = kroneckerProduct(dA,dB); dC = kroneckerProduct(dA,dB);
VERIFY_IS_APPROX(MatrixXf(sC),dC); VERIFY_IS_APPROX(MatrixXf(sC),dC);
sC = kroneckerProduct(sA.transpose(),sB); sC = kroneckerProduct(sA.transpose(),sB);
dC = kroneckerProduct(dA.transpose(),dB); dC = kroneckerProduct(dA.transpose(),dB);
VERIFY_IS_APPROX(MatrixXf(sC),dC); VERIFY_IS_APPROX(MatrixXf(sC),dC);
sC = kroneckerProduct(sA.transpose(),sB.transpose()); sC = kroneckerProduct(sA.transpose(),sB.transpose());
dC = kroneckerProduct(dA.transpose(),dB.transpose()); dC = kroneckerProduct(dA.transpose(),dB.transpose());
VERIFY_IS_APPROX(MatrixXf(sC),dC); VERIFY_IS_APPROX(MatrixXf(sC),dC);
sC = kroneckerProduct(sA,sB.transpose()); sC = kroneckerProduct(sA,sB.transpose());
dC = kroneckerProduct(dA,dB.transpose()); dC = kroneckerProduct(dA,dB.transpose());
VERIFY_IS_APPROX(MatrixXf(sC),dC); VERIFY_IS_APPROX(MatrixXf(sC),dC);
sC2 = kroneckerProduct(sA,sB); sC2 = kroneckerProduct(sA,sB);
dC = kroneckerProduct(dA,dB); dC = kroneckerProduct(dA,dB);
VERIFY_IS_APPROX(MatrixXf(sC2),dC); VERIFY_IS_APPROX(MatrixXf(sC2),dC);
sC2 = kroneckerProduct(dA,sB); sC2 = kroneckerProduct(dA,sB);
dC = kroneckerProduct(dA,dB); dC = kroneckerProduct(dA,dB);
VERIFY_IS_APPROX(MatrixXf(sC2),dC); VERIFY_IS_APPROX(MatrixXf(sC2),dC);
sC2 = kroneckerProduct(sA,dB); sC2 = kroneckerProduct(sA,dB);
dC = kroneckerProduct(dA,dB); dC = kroneckerProduct(dA,dB);
VERIFY_IS_APPROX(MatrixXf(sC2),dC); VERIFY_IS_APPROX(MatrixXf(sC2),dC);
sC2 = kroneckerProduct(2*sA,sB); sC2 = kroneckerProduct(2*sA,sB);
dC = kroneckerProduct(2*dA,dB); dC = kroneckerProduct(2*dA,dB);
VERIFY_IS_APPROX(MatrixXf(sC2),dC); VERIFY_IS_APPROX(MatrixXf(sC2),dC);
@ -236,8 +239,6 @@ EIGEN_DECLARE_TEST(kronecker_product)
#ifdef EIGEN_TEST_PART_2 #ifdef EIGEN_TEST_PART_2
// simply check that for a dense kronecker product, sparse module is not needed // simply check that for a dense kronecker product, sparse module is not needed
#include "main.h"
#include <Eigen/KroneckerProduct> #include <Eigen/KroneckerProduct>
EIGEN_DECLARE_TEST(kronecker_product) EIGEN_DECLARE_TEST(kronecker_product)