2008-06-02 22:54:52 +08:00
|
|
|
// This file is part of Eigen, a lightweight C++ template library
|
2009-05-23 02:25:33 +08:00
|
|
|
// for linear algebra.
|
2008-06-02 22:54:52 +08:00
|
|
|
//
|
2010-06-25 05:21:58 +08:00
|
|
|
// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
|
2008-06-02 22:54:52 +08:00
|
|
|
//
|
2012-07-14 02:42:47 +08:00
|
|
|
// This Source Code Form is subject to the terms of the Mozilla
|
|
|
|
// 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/.
|
2008-06-02 22:54:52 +08:00
|
|
|
|
|
|
|
#include "main.h"
|
|
|
|
|
2008-06-06 21:10:00 +08:00
|
|
|
template<typename MatrixType> void verifySizeOf(const MatrixType&)
|
2008-06-02 22:54:52 +08:00
|
|
|
{
|
|
|
|
typedef typename MatrixType::Scalar Scalar;
|
|
|
|
if (MatrixType::RowsAtCompileTime!=Dynamic && MatrixType::ColsAtCompileTime!=Dynamic)
|
2014-04-25 20:05:54 +08:00
|
|
|
VERIFY_IS_EQUAL(std::ptrdiff_t(sizeof(MatrixType)),std::ptrdiff_t(sizeof(Scalar))*std::ptrdiff_t(MatrixType::SizeAtCompileTime));
|
2008-06-02 22:54:52 +08:00
|
|
|
else
|
2018-07-12 23:16:40 +08:00
|
|
|
VERIFY_IS_EQUAL(sizeof(MatrixType),sizeof(Scalar*) + 2 * sizeof(Index));
|
2008-06-02 22:54:52 +08:00
|
|
|
}
|
|
|
|
|
2018-07-17 20:46:15 +08:00
|
|
|
EIGEN_DECLARE_TEST(sizeof)
|
2008-06-02 22:54:52 +08:00
|
|
|
{
|
2009-10-29 06:19:29 +08:00
|
|
|
CALL_SUBTEST(verifySizeOf(Matrix<float, 1, 1>()) );
|
2015-07-29 16:22:25 +08:00
|
|
|
CALL_SUBTEST(verifySizeOf(Array<float, 2, 1>()) );
|
|
|
|
CALL_SUBTEST(verifySizeOf(Array<float, 3, 1>()) );
|
|
|
|
CALL_SUBTEST(verifySizeOf(Array<float, 4, 1>()) );
|
|
|
|
CALL_SUBTEST(verifySizeOf(Array<float, 5, 1>()) );
|
|
|
|
CALL_SUBTEST(verifySizeOf(Array<float, 6, 1>()) );
|
|
|
|
CALL_SUBTEST(verifySizeOf(Array<float, 7, 1>()) );
|
|
|
|
CALL_SUBTEST(verifySizeOf(Array<float, 8, 1>()) );
|
|
|
|
CALL_SUBTEST(verifySizeOf(Array<float, 9, 1>()) );
|
|
|
|
CALL_SUBTEST(verifySizeOf(Array<float, 10, 1>()) );
|
|
|
|
CALL_SUBTEST(verifySizeOf(Array<float, 11, 1>()) );
|
|
|
|
CALL_SUBTEST(verifySizeOf(Array<float, 12, 1>()) );
|
2014-03-08 06:09:39 +08:00
|
|
|
CALL_SUBTEST(verifySizeOf(Vector2d()) );
|
|
|
|
CALL_SUBTEST(verifySizeOf(Vector4f()) );
|
2009-10-29 06:19:29 +08:00
|
|
|
CALL_SUBTEST(verifySizeOf(Matrix4d()) );
|
|
|
|
CALL_SUBTEST(verifySizeOf(Matrix<double, 4, 2>()) );
|
|
|
|
CALL_SUBTEST(verifySizeOf(Matrix<bool, 7, 5>()) );
|
|
|
|
CALL_SUBTEST(verifySizeOf(MatrixXcf(3, 3)) );
|
|
|
|
CALL_SUBTEST(verifySizeOf(MatrixXi(8, 12)) );
|
|
|
|
CALL_SUBTEST(verifySizeOf(MatrixXcd(20, 20)) );
|
|
|
|
CALL_SUBTEST(verifySizeOf(Matrix<float, 100, 100>()) );
|
2009-05-20 21:41:23 +08:00
|
|
|
|
|
|
|
VERIFY(sizeof(std::complex<float>) == 2*sizeof(float));
|
|
|
|
VERIFY(sizeof(std::complex<double>) == 2*sizeof(double));
|
2008-06-02 22:54:52 +08:00
|
|
|
}
|