From 44861dcbfeee041223c4aac1ee075e92fa4daa01 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 18 Sep 2016 12:42:15 +0200 Subject: update --- eigen/test/eigen2/eigen2_alignedbox.cpp | 60 +++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 eigen/test/eigen2/eigen2_alignedbox.cpp (limited to 'eigen/test/eigen2/eigen2_alignedbox.cpp') diff --git a/eigen/test/eigen2/eigen2_alignedbox.cpp b/eigen/test/eigen2/eigen2_alignedbox.cpp new file mode 100644 index 0000000..35043b9 --- /dev/null +++ b/eigen/test/eigen2/eigen2_alignedbox.cpp @@ -0,0 +1,60 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. Eigen itself is part of the KDE project. +// +// Copyright (C) 2008 Gael Guennebaud +// +// 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/. + +#include "main.h" +#include +#include +#include + +template void alignedbox(const BoxType& _box) +{ + /* this test covers the following files: + AlignedBox.h + */ + + const int dim = _box.dim(); + typedef typename BoxType::Scalar Scalar; + typedef typename NumTraits::Real RealScalar; + typedef Matrix VectorType; + + VectorType p0 = VectorType::Random(dim); + VectorType p1 = VectorType::Random(dim); + RealScalar s1 = ei_random(0,1); + + BoxType b0(dim); + BoxType b1(VectorType::Random(dim),VectorType::Random(dim)); + BoxType b2; + + b0.extend(p0); + b0.extend(p1); + VERIFY(b0.contains(p0*s1+(Scalar(1)-s1)*p1)); + VERIFY(!b0.contains(p0 + (1+s1)*(p1-p0))); + + (b2 = b0).extend(b1); + VERIFY(b2.contains(b0)); + VERIFY(b2.contains(b1)); + VERIFY_IS_APPROX(b2.clamp(b0), b0); + + // casting + const int Dim = BoxType::AmbientDimAtCompileTime; + typedef typename GetDifferentType::type OtherScalar; + AlignedBox hp1f = b0.template cast(); + VERIFY_IS_APPROX(hp1f.template cast(),b0); + AlignedBox hp1d = b0.template cast(); + VERIFY_IS_APPROX(hp1d.template cast(),b0); +} + +void test_eigen2_alignedbox() +{ + for(int i = 0; i < g_repeat; i++) { + CALL_SUBTEST_1( alignedbox(AlignedBox()) ); + CALL_SUBTEST_2( alignedbox(AlignedBox()) ); + CALL_SUBTEST_3( alignedbox(AlignedBox()) ); + } +} -- cgit v1.2.3