aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Benoit Steiner <benoit.steiner.goog@gmail.com>2014-08-13 22:25:29 -0700
committerGravatar Benoit Steiner <benoit.steiner.goog@gmail.com>2014-08-13 22:25:29 -0700
commit16047c8d4a916baa200036c4d5501707b3552720 (patch)
treee8dc65e4de304a16247f71ca5f40c5194b1aad5e
parent916ef48846b40f690f41583d288eb1c3c40db0a3 (diff)
parente51da9c3a8b448bc06110f1a7376211dcd32cc0e (diff)
Pulled in the latest changes from the Eigen trunk
-rw-r--r--CMakeLists.txt15
-rw-r--r--Eigen/Array11
-rw-r--r--Eigen/Core53
-rw-r--r--Eigen/Eigen2Support82
-rw-r--r--Eigen/Geometry40
-rw-r--r--Eigen/LU4
-rw-r--r--Eigen/LeastSquares32
-rw-r--r--Eigen/QR8
-rw-r--r--Eigen/SVD4
-rw-r--r--Eigen/src/Cholesky/LDLT.h62
-rw-r--r--Eigen/src/Cholesky/LLT.h11
-rw-r--r--Eigen/src/Core/Array.h38
-rw-r--r--Eigen/src/Core/Assign_MKL.h1
-rw-r--r--Eigen/src/Core/DenseBase.h11
-rw-r--r--Eigen/src/Core/DenseCoeffsBase.h4
-rw-r--r--Eigen/src/Core/DiagonalMatrix.h15
-rw-r--r--Eigen/src/Core/Dot.h28
-rw-r--r--Eigen/src/Core/GeneralProduct.h4
-rw-r--r--[-rwxr-xr-x]Eigen/src/Core/GenericPacketMath.h8
-rw-r--r--Eigen/src/Core/GlobalFunctions.h1
-rw-r--r--Eigen/src/Core/Map.h18
-rw-r--r--Eigen/src/Core/Matrix.h57
-rw-r--r--Eigen/src/Core/MatrixBase.h78
-rw-r--r--Eigen/src/Core/NumTraits.h7
-rw-r--r--Eigen/src/Core/PermutationMatrix.h60
-rw-r--r--Eigen/src/Core/PlainObjectBase.h77
-rw-r--r--Eigen/src/Core/ProductBase.h6
-rw-r--r--Eigen/src/Core/Ref.h18
-rw-r--r--Eigen/src/Core/SelfAdjointView.h25
-rw-r--r--Eigen/src/Core/Transpositions.h77
-rw-r--r--Eigen/src/Core/TriangularMatrix.h72
-rw-r--r--Eigen/src/Core/VectorwiseOp.h2
-rw-r--r--Eigen/src/Core/Visitor.h2
-rw-r--r--Eigen/src/Core/arch/AVX/Complex.h8
-rw-r--r--Eigen/src/Core/arch/AVX/PacketMath.h8
-rw-r--r--Eigen/src/Core/arch/AltiVec/Complex.h15
-rwxr-xr-xEigen/src/Core/arch/AltiVec/PacketMath.h34
-rw-r--r--Eigen/src/Core/arch/NEON/Complex.h4
-rw-r--r--Eigen/src/Core/arch/NEON/PacketMath.h8
-rw-r--r--Eigen/src/Core/arch/SSE/Complex.h4
-rwxr-xr-xEigen/src/Core/arch/SSE/PacketMath.h12
-rw-r--r--Eigen/src/Core/functors/NullaryFunctors.h4
-rw-r--r--Eigen/src/Core/functors/UnaryFunctors.h20
-rw-r--r--Eigen/src/Core/products/SelfadjointMatrixVector.h4
-rw-r--r--Eigen/src/Core/products/TriangularMatrixVector.h2
-rw-r--r--Eigen/src/Core/products/TriangularMatrixVector_MKL.h2
-rw-r--r--Eigen/src/Core/util/ForwardDeclarations.h35
-rw-r--r--Eigen/src/Core/util/Macros.h12
-rw-r--r--Eigen/src/Core/util/Memory.h111
-rw-r--r--Eigen/src/Core/util/Meta.h28
-rw-r--r--Eigen/src/Core/util/StaticAssert.h11
-rw-r--r--Eigen/src/Eigen2Support/Block.h126
-rw-r--r--Eigen/src/Eigen2Support/CMakeLists.txt8
-rw-r--r--Eigen/src/Eigen2Support/Cwise.h192
-rw-r--r--Eigen/src/Eigen2Support/CwiseOperators.h298
-rw-r--r--Eigen/src/Eigen2Support/Geometry/AlignedBox.h159
-rw-r--r--Eigen/src/Eigen2Support/Geometry/All.h115
-rw-r--r--Eigen/src/Eigen2Support/Geometry/AngleAxis.h228
-rw-r--r--Eigen/src/Eigen2Support/Geometry/CMakeLists.txt6
-rw-r--r--Eigen/src/Eigen2Support/Geometry/Hyperplane.h254
-rw-r--r--Eigen/src/Eigen2Support/Geometry/ParametrizedLine.h141
-rw-r--r--Eigen/src/Eigen2Support/Geometry/Quaternion.h495
-rw-r--r--Eigen/src/Eigen2Support/Geometry/Rotation2D.h145
-rw-r--r--Eigen/src/Eigen2Support/Geometry/RotationBase.h123
-rw-r--r--Eigen/src/Eigen2Support/Geometry/Scaling.h167
-rw-r--r--Eigen/src/Eigen2Support/Geometry/Transform.h786
-rw-r--r--Eigen/src/Eigen2Support/Geometry/Translation.h184
-rw-r--r--Eigen/src/Eigen2Support/LU.h120
-rw-r--r--Eigen/src/Eigen2Support/Lazy.h71
-rw-r--r--Eigen/src/Eigen2Support/LeastSquares.h170
-rw-r--r--Eigen/src/Eigen2Support/Macros.h20
-rw-r--r--Eigen/src/Eigen2Support/MathFunctions.h57
-rw-r--r--Eigen/src/Eigen2Support/Memory.h45
-rw-r--r--Eigen/src/Eigen2Support/Meta.h75
-rw-r--r--Eigen/src/Eigen2Support/Minor.h117
-rw-r--r--Eigen/src/Eigen2Support/QR.h67
-rw-r--r--Eigen/src/Eigen2Support/SVD.h637
-rw-r--r--Eigen/src/Eigen2Support/TriangularSolver.h42
-rw-r--r--Eigen/src/Eigen2Support/VectorBlock.h94
-rw-r--r--Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h36
-rw-r--r--Eigen/src/Geometry/AngleAxis.h28
-rw-r--r--Eigen/src/IterativeLinearSolvers/BasicPreconditioners.h4
-rw-r--r--Eigen/src/IterativeLinearSolvers/BiCGSTAB.h3
-rw-r--r--Eigen/src/Jacobi/Jacobi.h2
-rw-r--r--Eigen/src/LU/PartialPivLU.h9
-rw-r--r--Eigen/src/OrderingMethods/Ordering.h12
-rw-r--r--Eigen/src/SVD/JacobiSVD.h12
-rw-r--r--Eigen/src/SparseCholesky/SimplicialCholesky.h42
-rw-r--r--Eigen/src/SparseCore/CompressedStorage.h4
-rw-r--r--Eigen/src/SparseCore/SparseBlock.h41
-rw-r--r--Eigen/src/SparseCore/SparseCwiseBinaryOp.h11
-rw-r--r--Eigen/src/SparseCore/SparseDenseProduct.h39
-rw-r--r--Eigen/src/SparseCore/SparseDiagonalProduct.h14
-rw-r--r--Eigen/src/SparseCore/SparseMatrix.h16
-rw-r--r--Eigen/src/SparseCore/SparseMatrixBase.h29
-rw-r--r--Eigen/src/SparseCore/SparseSelfAdjointView.h2
-rw-r--r--Eigen/src/SparseCore/SparseUtil.h7
-rw-r--r--Eigen/src/SparseCore/TriangularSolver.h54
-rw-r--r--Eigen/src/SparseQR/SparseQR.h131
-rw-r--r--Eigen/src/plugins/ArrayCwiseUnaryOps.h12
-rw-r--r--bench/btl/cmake/FindACML.cmake2
-rw-r--r--bench/btl/cmake/FindATLAS.cmake13
-rw-r--r--bench/btl/cmake/FindCBLAS.cmake1
-rw-r--r--bench/btl/cmake/FindOPENBLAS.cmake2
-rw-r--r--blas/level1_impl.h4
-rw-r--r--blas/level3_impl.h2
-rw-r--r--cmake/Eigen3Config.cmake.in40
-rw-r--r--cmake/FindCholmod.cmake2
-rw-r--r--cmake/FindFFTW.cmake2
-rw-r--r--cmake/FindMetis.cmake38
-rw-r--r--doc/A05_PortingFrom2To3.dox7
-rw-r--r--doc/A10_Eigen2SupportModes.dox93
-rw-r--r--doc/CMakeLists.txt8
-rw-r--r--doc/Doxyfile.in16
-rw-r--r--doc/Manual.dox3
-rw-r--r--doc/PreprocessorDirectives.dox26
-rw-r--r--doc/SparseLinearSystems.dox13
-rw-r--r--doc/TopicLinearAlgebraDecompositions.dox4
-rw-r--r--doc/TutorialLinearAlgebra.dox26
-rw-r--r--doc/examples/MatrixBase_cwise_const.cpp18
-rw-r--r--doc/snippets/Cwise_atan.cpp2
-rw-r--r--test/CMakeLists.txt16
-rw-r--r--test/array.cpp1
-rw-r--r--test/basicstuff.cpp72
-rw-r--r--test/block.cpp10
-rw-r--r--test/cholesky.cpp24
-rw-r--r--test/ctorleak.cpp51
-rw-r--r--test/cwiseop.cpp182
-rw-r--r--test/dynalloc.cpp33
-rw-r--r--test/eigen2/CMakeLists.txt65
-rw-r--r--test/eigen2/eigen2_adjoint.cpp101
-rw-r--r--test/eigen2/eigen2_alignedbox.cpp60
-rw-r--r--test/eigen2/eigen2_array.cpp142
-rw-r--r--test/eigen2/eigen2_basicstuff.cpp108
-rw-r--r--test/eigen2/eigen2_bug_132.cpp26
-rw-r--r--test/eigen2/eigen2_cholesky.cpp113
-rw-r--r--test/eigen2/eigen2_commainitializer.cpp46
-rw-r--r--test/eigen2/eigen2_cwiseop.cpp158
-rw-r--r--test/eigen2/eigen2_determinant.cpp61
-rw-r--r--test/eigen2/eigen2_dynalloc.cpp131
-rw-r--r--test/eigen2/eigen2_eigensolver.cpp146
-rw-r--r--test/eigen2/eigen2_first_aligned.cpp49
-rw-r--r--test/eigen2/eigen2_geometry.cpp431
-rw-r--r--test/eigen2/eigen2_geometry_with_eigen2_prefix.cpp434
-rw-r--r--test/eigen2/eigen2_hyperplane.cpp126
-rw-r--r--test/eigen2/eigen2_inverse.cpp63
-rw-r--r--test/eigen2/eigen2_linearstructure.cpp84
-rw-r--r--test/eigen2/eigen2_lu.cpp122
-rw-r--r--test/eigen2/eigen2_map.cpp114
-rw-r--r--test/eigen2/eigen2_meta.cpp60
-rw-r--r--test/eigen2/eigen2_miscmatrices.cpp48
-rw-r--r--test/eigen2/eigen2_mixingtypes.cpp77
-rw-r--r--test/eigen2/eigen2_newstdvector.cpp149
-rw-r--r--test/eigen2/eigen2_nomalloc.cpp63
-rw-r--r--test/eigen2/eigen2_packetmath.cpp132
-rw-r--r--test/eigen2/eigen2_parametrizedline.cpp62
-rw-r--r--test/eigen2/eigen2_prec_inverse_4x4.cpp84
-rw-r--r--test/eigen2/eigen2_product_large.cpp45
-rw-r--r--test/eigen2/eigen2_product_small.cpp22
-rw-r--r--test/eigen2/eigen2_qr.cpp69
-rw-r--r--test/eigen2/eigen2_qtvector.cpp158
-rw-r--r--test/eigen2/eigen2_regression.cpp136
-rw-r--r--test/eigen2/eigen2_sizeof.cpp31
-rw-r--r--test/eigen2/eigen2_smallvectors.cpp42
-rw-r--r--test/eigen2/eigen2_sparse_basic.cpp317
-rw-r--r--test/eigen2/eigen2_sparse_product.cpp115
-rw-r--r--test/eigen2/eigen2_sparse_solvers.cpp200
-rw-r--r--test/eigen2/eigen2_sparse_vector.cpp84
-rw-r--r--test/eigen2/eigen2_stdvector.cpp148
-rw-r--r--test/eigen2/eigen2_submatrices.cpp148
-rw-r--r--test/eigen2/eigen2_sum.cpp71
-rw-r--r--test/eigen2/eigen2_svd.cpp87
-rw-r--r--test/eigen2/eigen2_swap.cpp83
-rw-r--r--test/eigen2/eigen2_triangular.cpp158
-rw-r--r--test/eigen2/eigen2_unalignedassert.cpp116
-rw-r--r--test/eigen2/eigen2_visitor.cpp116
-rw-r--r--test/eigen2/gsl_helper.h175
-rw-r--r--test/eigen2/main.h399
-rw-r--r--test/eigen2/product.h132
-rw-r--r--test/eigen2/sparse.h154
-rw-r--r--test/jacobisvd.cpp88
-rw-r--r--test/main.h16
-rw-r--r--test/mapstaticmethods.cpp6
-rw-r--r--test/meta.cpp24
-rw-r--r--test/packetmath.cpp15
-rw-r--r--test/product_large.cpp9
-rw-r--r--test/product_notemporary.cpp5
-rw-r--r--test/product_trsolve.cpp18
-rw-r--r--test/ref.cpp5
-rw-r--r--test/simplicial_cholesky.cpp41
-rw-r--r--test/sparse.h4
-rw-r--r--test/sparse_basic.cpp8
-rw-r--r--test/sparse_product.cpp66
-rw-r--r--test/sparseqr.cpp35
-rw-r--r--test/triangular.cpp7
-rw-r--r--test/vectorization_logic.cpp6
-rw-r--r--unsupported/Eigen/CXX11/Core1
-rw-r--r--unsupported/Eigen/MPRealSupport57
-rw-r--r--unsupported/Eigen/SVD4
-rw-r--r--unsupported/Eigen/src/IterativeSolvers/GMRES.h12
-rw-r--r--unsupported/Eigen/src/IterativeSolvers/Scaling.h6
-rw-r--r--unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h4
-rw-r--r--unsupported/Eigen/src/SparseExtra/MarketIO.h9
-rw-r--r--unsupported/Eigen/src/Splines/Spline.h64
-rw-r--r--unsupported/Eigen/src/Splines/SplineFitting.h274
-rw-r--r--unsupported/Eigen/src/Splines/SplineFwd.h3
-rw-r--r--unsupported/doc/Overview.dox11
-rw-r--r--unsupported/test/CMakeLists.txt4
-rw-r--r--unsupported/test/mpreal/mpreal.h1054
-rw-r--r--unsupported/test/mpreal_support.cpp3
-rw-r--r--unsupported/test/splines.cpp73
211 files changed, 2333 insertions, 13274 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a719e47fd..96d6c8701 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -108,7 +108,8 @@ endif()
set(EIGEN_TEST_MAX_SIZE "320" CACHE STRING "Maximal matrix/vector size, default is 320")
macro(ei_add_cxx_compiler_flag FLAG)
- string(REGEX REPLACE "-" "" SFLAG ${FLAG})
+ string(REGEX REPLACE "-" "" SFLAG1 ${FLAG})
+ string(REGEX REPLACE "\\+" "p" SFLAG ${SFLAG1})
check_cxx_compiler_flag(${FLAG} COMPILER_SUPPORT_${SFLAG})
if(COMPILER_SUPPORT_${SFLAG})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAG}")
@@ -118,7 +119,7 @@ endmacro(ei_add_cxx_compiler_flag)
if(NOT MSVC)
# We assume that other compilers are partly compatible with GNUCC
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions")
+# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions")
set(CMAKE_CXX_FLAGS_DEBUG "-g3")
set(CMAKE_CXX_FLAGS_RELEASE "-g0 -O2")
@@ -142,6 +143,9 @@ if(NOT MSVC)
ei_add_cxx_compiler_flag("-Wpointer-arith")
ei_add_cxx_compiler_flag("-Wwrite-strings")
ei_add_cxx_compiler_flag("-Wformat-security")
+ ei_add_cxx_compiler_flag("-Wshorten-64-to-32")
+ ei_add_cxx_compiler_flag("-Wenum-conversion")
+ ei_add_cxx_compiler_flag("-Wc++11-extensions")
ei_add_cxx_compiler_flag("-Wno-psabi")
ei_add_cxx_compiler_flag("-Wno-variadic-macros")
@@ -153,6 +157,7 @@ if(NOT MSVC)
ei_add_cxx_compiler_flag("-wd981") # disable ICC's "operands are evaluated in unspecified order" remark
ei_add_cxx_compiler_flag("-wd2304") # disbale ICC's "warning #2304: non-explicit constructor with single argument may cause implicit type conversion" produced by -Wnon-virtual-dtor
+
# The -ansi flag must be added last, otherwise it is also used as a linker flag by check_cxx_compiler_flag making it fails
# Moreover we should not set both -strict-ansi and -ansi
check_cxx_compiler_flag("-strict-ansi" COMPILER_SUPPORT_STRICTANSI)
@@ -296,6 +301,12 @@ if(EIGEN_TEST_NO_EXPLICIT_ALIGNMENT)
message(STATUS "Disabling alignment in tests/examples")
endif()
+option(EIGEN_TEST_NO_EXCEPTIONS "Disables C++ exceptions" OFF)
+if(EIGEN_TEST_NO_EXCEPTIONS)
+ ei_add_cxx_compiler_flag("-fno-exceptions")
+ message(STATUS "Disabling exceptions in tests/examples")
+endif()
+
option(EIGEN_TEST_C++0x "Enables all C++0x features." OFF)
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
diff --git a/Eigen/Array b/Eigen/Array
deleted file mode 100644
index 3d004fb69..000000000
--- a/Eigen/Array
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef EIGEN_ARRAY_MODULE_H
-#define EIGEN_ARRAY_MODULE_H
-
-// include Core first to handle Eigen2 support macros
-#include "Core"
-
-#ifndef EIGEN2_SUPPORT
- #error The Eigen/Array header does no longer exist in Eigen3. All that functionality has moved to Eigen/Core.
-#endif
-
-#endif // EIGEN_ARRAY_MODULE_H
diff --git a/Eigen/Core b/Eigen/Core
index 661c7812e..9a73fe37b 100644
--- a/Eigen/Core
+++ b/Eigen/Core
@@ -42,6 +42,14 @@
#define EIGEN_USING_STD_MATH(FUNC) using std::FUNC;
#endif
+#if (defined(_CPPUNWIND) || defined(__EXCEPTIONS)) && !defined(__CUDA_ARCH__)
+ #define EIGEN_EXCEPTIONS
+#endif
+
+#ifdef EIGEN_EXCEPTIONS
+ #include <new>
+#endif
+
// then include this file where all our macros are defined. It's really important to do it first because
// it's where we do all the alignment settings (platform detection and honoring the user's will if he
// defined e.g. EIGEN_DONT_ALIGN) so it needs to be done before we do anything with vectorization.
@@ -205,18 +213,10 @@
#endif
// required for __cpuid, needs to be included after cmath
-#if defined(_MSC_VER) && (defined(_M_IX86)||defined(_M_X64))
+#if defined(_MSC_VER) && (defined(_M_IX86)||defined(_M_X64)) && (!defined(_WIN32_WCE))
#include <intrin.h>
#endif
-#if (defined(_CPPUNWIND) || defined(__EXCEPTIONS)) && !defined(__CUDA_ARCH__)
- #define EIGEN_EXCEPTIONS
-#endif
-
-#ifdef EIGEN_EXCEPTIONS
- #include <new>
-#endif
-
/** \brief Namespace containing all symbols from the %Eigen library. */
namespace Eigen {
@@ -244,34 +244,9 @@ inline static const char *SimdInstructionSetsInUse(void) {
} // end namespace Eigen
-#define STAGE10_FULL_EIGEN2_API 10
-#define STAGE20_RESOLVE_API_CONFLICTS 20
-#define STAGE30_FULL_EIGEN3_API 30
-#define STAGE40_FULL_EIGEN3_STRICTNESS 40
-#define STAGE99_NO_EIGEN2_SUPPORT 99
-
-#if defined EIGEN2_SUPPORT_STAGE40_FULL_EIGEN3_STRICTNESS
- #define EIGEN2_SUPPORT
- #define EIGEN2_SUPPORT_STAGE STAGE40_FULL_EIGEN3_STRICTNESS
-#elif defined EIGEN2_SUPPORT_STAGE30_FULL_EIGEN3_API
- #define EIGEN2_SUPPORT
- #define EIGEN2_SUPPORT_STAGE STAGE30_FULL_EIGEN3_API
-#elif defined EIGEN2_SUPPORT_STAGE20_RESOLVE_API_CONFLICTS
- #define EIGEN2_SUPPORT
- #define EIGEN2_SUPPORT_STAGE STAGE20_RESOLVE_API_CONFLICTS
-#elif defined EIGEN2_SUPPORT_STAGE10_FULL_EIGEN2_API
- #define EIGEN2_SUPPORT
- #define EIGEN2_SUPPORT_STAGE STAGE10_FULL_EIGEN2_API
-#elif defined EIGEN2_SUPPORT
- // default to stage 3, that's what it's always meant
- #define EIGEN2_SUPPORT_STAGE30_FULL_EIGEN3_API
- #define EIGEN2_SUPPORT_STAGE STAGE30_FULL_EIGEN3_API
-#else
- #define EIGEN2_SUPPORT_STAGE STAGE99_NO_EIGEN2_SUPPORT
-#endif
-
-#ifdef EIGEN2_SUPPORT
-#undef minor
+#if defined EIGEN2_SUPPORT_STAGE40_FULL_EIGEN3_STRICTNESS || defined EIGEN2_SUPPORT_STAGE30_FULL_EIGEN3_API || defined EIGEN2_SUPPORT_STAGE20_RESOLVE_API_CONFLICTS || defined EIGEN2_SUPPORT_STAGE10_FULL_EIGEN2_API || defined EIGEN2_SUPPORT
+// This will generate an error message:
+#error Eigen2-support is only available up to version 3.2. Please go to "http://eigen.tuxfamily.org/index.php?title=Eigen2" for further information
#endif
// we use size_t frequently and we'll never remember to prepend it with std:: everytime just to
@@ -429,8 +404,4 @@ using std::ptrdiff_t;
#include "src/Core/util/ReenableStupidWarnings.h"
-#ifdef EIGEN2_SUPPORT
-#include "Eigen2Support"
-#endif
-
#endif // EIGEN_CORE_H
diff --git a/Eigen/Eigen2Support b/Eigen/Eigen2Support
deleted file mode 100644
index 36156d29a..000000000
--- a/Eigen/Eigen2Support
+++ /dev/null
@@ -1,82 +0,0 @@
-// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra.
-//
-// Copyright (C) 2009 Gael Guennebaud <gael.guennebaud@inria.fr>
-//
-// 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/.
-
-#ifndef EIGEN2SUPPORT_H
-#define EIGEN2SUPPORT_H
-
-#if (!defined(EIGEN2_SUPPORT)) || (!defined(EIGEN_CORE_H))
-#error Eigen2 support must be enabled by defining EIGEN2_SUPPORT before including any Eigen header
-#endif
-
-#include "src/Core/util/DisableStupidWarnings.h"
-
-/** \ingroup Support_modules
- * \defgroup Eigen2Support_Module Eigen2 support module
- * This module provides a couple of deprecated functions improving the compatibility with Eigen2.
- *
- * To use it, define EIGEN2_SUPPORT before including any Eigen header
- * \code
- * #define EIGEN2_SUPPORT
- * \endcode
- *
- */
-
-#include "src/Eigen2Support/Macros.h"
-#include "src/Eigen2Support/Memory.h"
-#include "src/Eigen2Support/Meta.h"
-#include "src/Eigen2Support/Lazy.h"
-#include "src/Eigen2Support/Cwise.h"
-#include "src/Eigen2Support/CwiseOperators.h"
-#include "src/Eigen2Support/TriangularSolver.h"
-#include "src/Eigen2Support/Block.h"
-#include "src/Eigen2Support/VectorBlock.h"
-#include "src/Eigen2Support/Minor.h"
-#include "src/Eigen2Support/MathFunctions.h"
-
-
-#include "src/Core/util/ReenableStupidWarnings.h"
-
-// Eigen2 used to include iostream
-#include<iostream>
-
-#define EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, SizeSuffix) \
-using Eigen::Matrix##SizeSuffix##TypeSuffix; \
-using Eigen::Vector##SizeSuffix##TypeSuffix; \
-using Eigen::RowVector##SizeSuffix##TypeSuffix;
-
-#define EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(TypeSuffix) \
-EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 2) \
-EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 3) \
-EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 4) \
-EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, X) \
-
-#define EIGEN_USING_MATRIX_TYPEDEFS \
-EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(i) \
-EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(f) \
-EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(d) \
-EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(cf) \
-EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(cd)
-
-#define USING_PART_OF_NAMESPACE_EIGEN \
-EIGEN_USING_MATRIX_TYPEDEFS \
-using Eigen::Matrix; \
-using Eigen::MatrixBase; \
-using Eigen::ei_random; \
-using Eigen::ei_real; \
-using Eigen::ei_imag; \
-using Eigen::ei_conj; \
-using Eigen::ei_abs; \
-using Eigen::ei_abs2; \
-using Eigen::ei_sqrt; \
-using Eigen::ei_exp; \
-using Eigen::ei_log; \
-using Eigen::ei_sin; \
-using Eigen::ei_cos;
-
-#endif // EIGEN2SUPPORT_H
diff --git a/Eigen/Geometry b/Eigen/Geometry
index f9bc6fc57..1c642b7ee 100644
--- a/Eigen/Geometry
+++ b/Eigen/Geometry
@@ -33,29 +33,23 @@
#include "src/Geometry/OrthoMethods.h"
#include "src/Geometry/EulerAngles.h"
-#if EIGEN2_SUPPORT_STAGE > STAGE20_RESOLVE_API_CONFLICTS
- #include "src/Geometry/Homogeneous.h"
- #include "src/Geometry/RotationBase.h"
- #include "src/Geometry/Rotation2D.h"
- #include "src/Geometry/Quaternion.h"
- #include "src/Geometry/AngleAxis.h"
- #include "src/Geometry/Transform.h"
- #include "src/Geometry/Translation.h"
- #include "src/Geometry/Scaling.h"
- #include "src/Geometry/Hyperplane.h"
- #include "src/Geometry/ParametrizedLine.h"
- #include "src/Geometry/AlignedBox.h"
- #include "src/Geometry/Umeyama.h"
-
- // Use the SSE optimized version whenever possible. At the moment the
- // SSE version doesn't compile when AVX is enabled
- #if defined EIGEN_VECTORIZE_SSE && !defined EIGEN_VECTORIZE_AVX
- #include "src/Geometry/arch/Geometry_SSE.h"
- #endif
-#endif
-
-#ifdef EIGEN2_SUPPORT
-#include "src/Eigen2Support/Geometry/All.h"
+#include "src/Geometry/Homogeneous.h"
+#include "src/Geometry/RotationBase.h"
+#include "src/Geometry/Rotation2D.h"
+#include "src/Geometry/Quaternion.h"
+#include "src/Geometry/AngleAxis.h"
+#include "src/Geometry/Transform.h"
+#include "src/Geometry/Translation.h"
+#include "src/Geometry/Scaling.h"
+#include "src/Geometry/Hyperplane.h"
+#include "src/Geometry/ParametrizedLine.h"
+#include "src/Geometry/AlignedBox.h"
+#include "src/Geometry/Umeyama.h"
+
+// Use the SSE optimized version whenever possible. At the moment the
+// SSE version doesn't compile when AVX is enabled
+#if defined EIGEN_VECTORIZE_SSE && !defined EIGEN_VECTORIZE_AVX
+#include "src/Geometry/arch/Geometry_SSE.h"
#endif
#include "src/Core/util/ReenableStupidWarnings.h"
diff --git a/Eigen/LU b/Eigen/LU
index e5c3f32f7..29a98cb9a 100644
--- a/Eigen/LU
+++ b/Eigen/LU
@@ -33,10 +33,6 @@
#include "src/LU/arch/Inverse_SSE.h"
#endif
-#ifdef EIGEN2_SUPPORT
- #include "src/Eigen2Support/LU.h"
-#endif
-
#include "src/Core/util/ReenableStupidWarnings.h"
#endif // EIGEN_LU_MODULE_H
diff --git a/Eigen/LeastSquares b/Eigen/LeastSquares
deleted file mode 100644
index 35137c25d..000000000
--- a/Eigen/LeastSquares
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef EIGEN_REGRESSION_MODULE_H
-#define EIGEN_REGRESSION_MODULE_H
-
-#ifndef EIGEN2_SUPPORT
-#error LeastSquares is only available in Eigen2 support mode (define EIGEN2_SUPPORT)
-#endif
-
-// exclude from normal eigen3-only documentation
-#ifdef EIGEN2_SUPPORT
-
-#include "Core"
-
-#include "src/Core/util/DisableStupidWarnings.h"
-
-#include "Eigenvalues"
-#include "Geometry"
-
-/** \defgroup LeastSquares_Module LeastSquares module
- * This module provides linear regression and related features.
- *
- * \code
- * #include <Eigen/LeastSquares>
- * \endcode
- */
-
-#include "src/Eigen2Support/LeastSquares.h"
-
-#include "src/Core/util/ReenableStupidWarnings.h"
-
-#endif // EIGEN2_SUPPORT
-
-#endif // EIGEN_REGRESSION_MODULE_H
diff --git a/Eigen/QR b/Eigen/QR
index 8c7c6162e..4c2533610 100644
--- a/Eigen/QR
+++ b/Eigen/QR
@@ -33,15 +33,7 @@
#include "src/QR/ColPivHouseholderQR_MKL.h"
#endif
-#ifdef EIGEN2_SUPPORT
-#include "src/Eigen2Support/QR.h"
-#endif
-
#include "src/Core/util/ReenableStupidWarnings.h"
-#ifdef EIGEN2_SUPPORT
-#include "Eigenvalues"
-#endif
-
#endif // EIGEN_QR_MODULE_H
/* vim: set filetype=cpp et sw=2 ts=2 ai: */
diff --git a/Eigen/SVD b/Eigen/SVD
index fd310017a..5eee46df5 100644
--- a/Eigen/SVD
+++ b/Eigen/SVD
@@ -27,10 +27,6 @@
#endif
#include "src/SVD/UpperBidiagonalization.h"
-#ifdef EIGEN2_SUPPORT
-#include "src/Eigen2Support/SVD.h"
-#endif
-
#include "src/Core/util/ReenableStupidWarnings.h"
#endif // EIGEN_SVD_MODULE_H
diff --git a/Eigen/src/Cholesky/LDLT.h b/Eigen/src/Cholesky/LDLT.h
index efac7fe40..aa9784e54 100644
--- a/Eigen/src/Cholesky/LDLT.h
+++ b/Eigen/src/Cholesky/LDLT.h
@@ -151,13 +151,6 @@ template<typename _MatrixType, int _UpLo> class LDLT
eigen_assert(m_isInitialized && "LDLT is not initialized.");
return m_sign == internal::PositiveSemiDef || m_sign == internal::ZeroSign;
}
-
- #ifdef EIGEN2_SUPPORT
- inline bool isPositiveDefinite() const
- {
- return isPositive();
- }
- #endif
/** \returns true if the matrix is negative (semidefinite) */
inline bool isNegative(void) const
@@ -191,15 +184,6 @@ template<typename _MatrixType, int _UpLo> class LDLT
return internal::solve_retval<LDLT, Rhs>(*this, b.derived());
}
- #ifdef EIGEN2_SUPPORT
- template<typename OtherDerived, typename ResultType>
- bool solve(const MatrixBase<OtherDerived>& b, ResultType *result) const
- {
- *result = this->solve(b);
- return true;
- }
- #endif
-
template<typename Derived>
bool solveInPlace(MatrixBase<Derived> &bAndX) const;
@@ -262,6 +246,7 @@ template<> struct ldlt_inplace<Lower>
typedef typename MatrixType::Scalar Scalar;
typedef typename MatrixType::RealScalar RealScalar;
typedef typename MatrixType::Index Index;
+ typedef typename TranspositionType::StorageIndexType IndexType;
eigen_assert(mat.rows()==mat.cols());
const Index size = mat.rows();
@@ -274,24 +259,14 @@ template<> struct ldlt_inplace<Lower>
return true;
}
- RealScalar cutoff(0), biggest_in_corner;
-
for (Index k = 0; k < size; ++k)
{
// Find largest diagonal element
Index index_of_biggest_in_corner;
- biggest_in_corner = mat.diagonal().tail(size-k).cwiseAbs().maxCoeff(&index_of_biggest_in_corner);
+ mat.diagonal().tail(size-k).cwiseAbs().maxCoeff(&index_of_biggest_in_corner);
index_of_biggest_in_corner += k;
- if(k == 0)
- {
- // The biggest overall is the point of reference to which further diagonals
- // are compared; if any diagonal is negligible compared
- // to the largest overall, the algorithm bails.
- cutoff = abs(NumTraits<Scalar>::epsilon() * biggest_in_corner);
- }
-
- transpositions.coeffRef(k) = index_of_biggest_in_corner;
+ transpositions.coeffRef(k) = IndexType(index_of_biggest_in_corner);
if(k != index_of_biggest_in_corner)
{
// apply the transposition while taking care to consider only
@@ -300,7 +275,7 @@ template<> struct ldlt_inplace<Lower>
mat.row(k).head(k).swap(mat.row(index_of_biggest_in_corner).head(k));
mat.col(k).tail(s).swap(mat.col(index_of_biggest_in_corner).tail(s));
std::swap(mat.coeffRef(k,k),mat.coeffRef(index_of_biggest_in_corner,index_of_biggest_in_corner));
- for(int i=k+1;i<index_of_biggest_in_corner;++i)
+ for(Index i=k+1;i<index_of_biggest_in_corner;++i)
{
Scalar tmp = mat.coeffRef(i,k);
mat.coeffRef(i,k) = numext::conj(mat.coeffRef(index_of_biggest_in_corner,i));
@@ -321,16 +296,20 @@ template<> struct ldlt_inplace<Lower>
if(k>0)
{
- temp.head(k) = mat.diagonal().head(k).asDiagonal() * A10.adjoint();
+ temp.head(k) = mat.diagonal().real().head(k).asDiagonal() * A10.adjoint();
mat.coeffRef(k,k) -= (A10 * temp.head(k)).value();
if(rs>0)
A21.noalias() -= A20 * temp.head(k);
}
- if((rs>0) && (abs(mat.coeffRef(k,k)) > cutoff))
- A21 /= mat.coeffRef(k,k);
-
+ // In some previous versions of Eigen (e.g., 3.2.1), the scaling was omitted if the pivot
+ // was smaller than the cutoff value. However, soince LDLT is not rank-revealing
+ // we should only make sure we do not introduce INF or NaN values.
+ // LAPACK also uses 0 as the cutoff value.
RealScalar realAkk = numext::real(mat.coeffRef(k,k));
+ if((rs>0) && (abs(realAkk) > RealScalar(0)))
+ A21 /= realAkk;
+
if (sign == PositiveSemiDef) {
if (realAkk < 0) sign = Indefinite;
} else if (sign == NegativeSemiDef) {
@@ -464,6 +443,7 @@ template<typename MatrixType, int _UpLo>
template<typename Derived>
LDLT<MatrixType,_UpLo>& LDLT<MatrixType,_UpLo>::rankUpdate(const MatrixBase<Derived>& w, const typename NumTraits<typename MatrixType::Scalar>::Real& sigma)
{
+ typedef typename TranspositionType::StorageIndexType IndexType;
const Index size = w.rows();
if (m_isInitialized)
{
@@ -475,7 +455,7 @@ LDLT<MatrixType,_UpLo>& LDLT<MatrixType,_UpLo>::rankUpdate(const MatrixBase<Deri
m_matrix.setZero();
m_transpositions.resize(size);
for (Index i = 0; i < size; i++)
- m_transpositions.coeffRef(i) = i;
+ m_transpositions.coeffRef(i) = IndexType(i);
m_temporary.resize(size);
m_sign = sigma>=0 ? internal::PositiveSemiDef : internal::NegativeSemiDef;
m_isInitialized = true;
@@ -508,11 +488,15 @@ struct solve_retval<LDLT<_MatrixType,_UpLo>, Rhs>
using std::abs;
EIGEN_USING_STD_MATH(max);
typedef typename LDLTType::MatrixType MatrixType;
- typedef typename LDLTType::Scalar Scalar;
typedef typename LDLTType::RealScalar RealScalar;
- const Diagonal<const MatrixType> vectorD = dec().vectorD();
- RealScalar tolerance = (max)(vectorD.array().abs().maxCoeff() * NumTraits<Scalar>::epsilon(),
- RealScalar(1) / NumTraits<RealScalar>::highest()); // motivated by LAPACK's xGELSS
+ const typename Diagonal<const MatrixType>::RealReturnType vectorD(dec().vectorD());
+ // In some previous versions, tolerance was set to the max of 1/highest and the maximal diagonal entry * epsilon
+ // as motivated by LAPACK's xGELSS:
+ // RealScalar tolerance = (max)(vectorD.array().abs().maxCoeff() *NumTraits<RealScalar>::epsilon(),RealScalar(1) / NumTraits<RealScalar>::highest());
+ // However, LDLT is not rank revealing, and so adjusting the tolerance wrt to the highest
+ // diagonal element is not well justified and to numerical issues in some cases.
+ // Moreover, Lapack's xSYTRS routines use 0 for the tolerance.
+ RealScalar tolerance = RealScalar(1) / NumTraits<RealScalar>::highest();
for (Index i = 0; i < vectorD.size(); ++i) {
if(abs(vectorD(i)) > tolerance)
dst.row(i) /= vectorD(i);
@@ -570,7 +554,7 @@ MatrixType LDLT<MatrixType,_UpLo>::reconstructedMatrix() const
// L^* P
res = matrixU() * res;
// D(L^*P)
- res = vectorD().asDiagonal() * res;
+ res = vectorD().real().asDiagonal() * res;
// L(DL^*P)
res = matrixL() * res;
// P^T (LDL^*P)
diff --git a/Eigen/src/Cholesky/LLT.h b/Eigen/src/Cholesky/LLT.h
index 45ed8438f..38e820165 100644
--- a/Eigen/src/Cholesky/LLT.h
+++ b/Eigen/src/Cholesky/LLT.h
@@ -127,17 +127,6 @@ template<typename _MatrixType, int _UpLo> class LLT
return internal::solve_retval<LLT, Rhs>(*this, b.derived());
}
- #ifdef EIGEN2_SUPPORT
- template<typename OtherDerived, typename ResultType>
- bool solve(const MatrixBase<OtherDerived>& b, ResultType *result) const
- {
- *result = this->solve(b);
- return true;
- }
-
- bool isPositiveDefinite() const { return true; }
- #endif
-
template<typename Derived>
void solveInPlace(MatrixBase<Derived> &bAndX) const;
diff --git a/Eigen/src/Core/Array.h b/Eigen/src/Core/Array.h
index 8d2906a10..28d6f1443 100644
--- a/Eigen/src/Core/Array.h
+++ b/Eigen/src/Core/Array.h
@@ -144,24 +144,16 @@ class Array
}
#endif
- /** Constructs a vector or row-vector with given dimension. \only_for_vectors
- *
- * Note that this is only useful for dynamic-size vectors. For fixed-size vectors,
- * it is redundant to pass the dimension here, so it makes more sense to use the default
- * constructor Matrix() instead.
- */
+
+ #ifndef EIGEN_PARSED_BY_DOXYGEN
+ template<typename T>
EIGEN_DEVICE_FUNC
- EIGEN_STRONG_INLINE explicit Array(Index dim)
- : Base(dim, RowsAtCompileTime == 1 ? 1 : dim, ColsAtCompileTime == 1 ? 1 : dim)
+ EIGEN_STRONG_INLINE explicit Array(const T& x)
{
Base::_check_template_params();
- EIGEN_STATIC_ASSERT_VECTOR_ONLY(Array)
- eigen_assert(dim >= 0);
- eigen_assert(SizeAtCompileTime == Dynamic || SizeAtCompileTime == dim);
- EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
+ Base::template _init1<T>(x);
}
- #ifndef EIGEN_PARSED_BY_DOXYGEN
template<typename T0, typename T1>
EIGEN_DEVICE_FUNC
EIGEN_STRONG_INLINE Array(const T0& val0, const T1& val1)
@@ -170,11 +162,23 @@ class Array
this->template _init2<T0,T1>(val0, val1);
}
#else
- /** constructs an uninitialized matrix with \a rows rows and \a cols columns.
+ /** \brief Constructs a fixed-sized array initialized with coefficients starting at \a data */
+ EIGEN_DEVICE_FUNC explicit Array(const Scalar *data);
+ /** Constructs a vector or row-vector with given dimension. \only_for_vectors
*
- * This is useful for dynamic-size matrices. For fixed-size matrices,
+ * Note that this is only useful for dynamic-size vectors. For fixed-size vectors,
+ * it is redundant to pass the dimension here, so it makes more sense to use the default
+ * constructor Array() instead.
+ */
+ EIGEN_DEVICE_FUNC
+ EIGEN_STRONG_INLINE explicit Array(Index dim);
+ /** constructs an initialized 1x1 Array with the given coefficient */
+ Array(const Scalar& value);
+ /** constructs an uninitialized array with \a rows rows and \a cols columns.
+ *
+ * This is useful for dynamic-size arrays. For fixed-size arrays,
* it is redundant to pass these parameters, so one should use the default constructor
- * Matrix() instead. */
+ * Array() instead. */
Array(Index rows, Index cols);
/** constructs an initialized 2D vector with given coefficients */
Array(const Scalar& val0, const Scalar& val1);
@@ -202,8 +206,6 @@ class Array
m_storage.data()[3] = val3;
}
- EIGEN_DEVICE_FUNC explicit Array(const Scalar *data);
-
/** Constructor copying the value of the expression \a other */
template<typename OtherDerived>
EIGEN_DEVICE_FUNC
diff --git a/Eigen/src/Core/Assign_MKL.h b/Eigen/src/Core/Assign_MKL.h
index 7772951b9..97134ffd7 100644
--- a/Eigen/src/Core/Assign_MKL.h
+++ b/Eigen/src/Core/Assign_MKL.h
@@ -202,6 +202,7 @@ EIGEN_MKL_VML_DECLARE_UNARY_CALLS_LA(asin, Asin)
EIGEN_MKL_VML_DECLARE_UNARY_CALLS_LA(cos, Cos)
EIGEN_MKL_VML_DECLARE_UNARY_CALLS_LA(acos, Acos)
EIGEN_MKL_VML_DECLARE_UNARY_CALLS_LA(tan, Tan)
+EIGEN_MKL_VML_DECLARE_UNARY_CALLS_LA(atan, Atan)
//EIGEN_MKL_VML_DECLARE_UNARY_CALLS(abs, Abs)
EIGEN_MKL_VML_DECLARE_UNARY_CALLS_LA(exp, Exp)
EIGEN_MKL_VML_DECLARE_UNARY_CALLS_LA(log, Ln)
diff --git a/Eigen/src/Core/DenseBase.h b/Eigen/src/Core/DenseBase.h
index 4794c2f13..bd5dd14ed 100644
--- a/Eigen/src/Core/DenseBase.h
+++ b/Eigen/src/Core/DenseBase.h
@@ -506,17 +506,6 @@ template<typename Derived> class DenseBase
# endif
#undef EIGEN_CURRENT_STORAGE_BASE_CLASS
-#ifdef EIGEN2_SUPPORT
-
- Block<Derived> corner(CornerType type, Index cRows, Index cCols);
- const Block<Derived> corner(CornerType type, Index cRows, Index cCols) const;
- template<int CRows, int CCols>
- Block<Derived, CRows, CCols> corner(CornerType type);
- template<int CRows, int CCols>
- const Block<Derived, CRows, CCols> corner(CornerType type) const;
-
-#endif // EIGEN2_SUPPORT
-
// disable the use of evalTo for dense objects with a nice compilation error
template<typename Dest>
diff --git a/Eigen/src/Core/DenseCoeffsBase.h b/Eigen/src/Core/DenseCoeffsBase.h
index efabb5e67..4e986e875 100644
--- a/Eigen/src/Core/DenseCoeffsBase.h
+++ b/Eigen/src/Core/DenseCoeffsBase.h
@@ -156,10 +156,8 @@ class DenseCoeffsBase<Derived,ReadOnlyAccessors> : public EigenBase<Derived>
EIGEN_STRONG_INLINE CoeffReturnType
operator[](Index index) const
{
- #ifndef EIGEN2_SUPPORT
EIGEN_STATIC_ASSERT(Derived::IsVectorAtCompileTime,
THE_BRACKET_OPERATOR_IS_ONLY_FOR_VECTORS__USE_THE_PARENTHESIS_OPERATOR_INSTEAD)
- #endif
eigen_assert(index >= 0 && index < size());
return derived().coeff(index);
}
@@ -388,10 +386,8 @@ class DenseCoeffsBase<Derived, WriteAccessors> : public DenseCoeffsBase<Derived,
EIGEN_STRONG_INLINE Scalar&
operator[](Index index)
{
- #ifndef EIGEN2_SUPPORT
EIGEN_STATIC_ASSERT(Derived::IsVectorAtCompileTime,
THE_BRACKET_OPERATOR_IS_ONLY_FOR_VECTORS__USE_THE_PARENTHESIS_OPERATOR_INSTEAD)
- #endif
eigen_assert(index >= 0 && index < size());
return derived().coeffRef(index);
}
diff --git a/Eigen/src/Core/DiagonalMatrix.h b/Eigen/src/Core/DiagonalMatrix.h
index f7ac22f8b..96b65483d 100644
--- a/Eigen/src/Core/DiagonalMatrix.h
+++ b/Eigen/src/Core/DiagonalMatrix.h
@@ -95,21 +95,6 @@ class DiagonalBase : public EigenBase<Derived>
{
return other.diagonal() * scalar;
}
-
- #ifdef EIGEN2_SUPPORT
- template<typename OtherDerived>
- EIGEN_DEVICE_FUNC
- bool isApprox(const DiagonalBase<OtherDerived>& other, typename NumTraits<Scalar>::Real precision = NumTraits<Scalar>::dummy_precision()) const
- {
- return diagonal().isApprox(other.diagonal(), precision);
- }
- template<typename OtherDerived>
- EIGEN_DEVICE_FUNC
- bool isApprox(const MatrixBase<OtherDerived>& other, typename NumTraits<Scalar>::Real precision = NumTraits<Scalar>::dummy_precision()) const
- {
- return toDenseMatrix().isApprox(other, precision);
- }
- #endif
};
template<typename Derived>
diff --git a/Eigen/src/Core/Dot.h b/Eigen/src/Core/Dot.h
index 718de5d1a..db16e4acc 100644
--- a/Eigen/src/Core/Dot.h
+++ b/Eigen/src/Core/Dot.h
@@ -76,34 +76,6 @@ MatrixBase<Derived>::dot(const MatrixBase<OtherDerived>& other) const
return internal::dot_nocheck<Derived,OtherDerived>::run(*this, other);
}
-#ifdef EIGEN2_SUPPORT
-/** \returns the dot product of *this with other, with the Eigen2 convention that the dot product is linear in the first variable
- * (conjugating the second variable). Of course this only makes a difference in the complex case.
- *
- * This method is only available in EIGEN2_SUPPORT mode.
- *
- * \only_for_vectors
- *
- * \sa dot()
- */
-template<typename Derived>
-template<typename OtherDerived>
-typename internal::traits<Derived>::Scalar
-MatrixBase<Derived>::eigen2_dot(const MatrixBase<OtherDerived>& other) const
-{
- EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
- EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
- EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(Derived,OtherDerived)
- EIGEN_STATIC_ASSERT((internal::is_same<Scalar, typename OtherDerived::Scalar>::value),
- YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
-
- eigen_assert(size() == other.size());
-
- return internal::dot_nocheck<OtherDerived,Derived>::run(other,*this);
-}
-#endif
-
-
//---------- implementation of L2 norm and related functions ----------
/** \returns, for vectors, the squared \em l2 norm of \c *this, and for matrices the Frobenius norm.
diff --git a/Eigen/src/Core/GeneralProduct.h b/Eigen/src/Core/GeneralProduct.h
index 229d12c3f..624b8b6e8 100644
--- a/Eigen/src/Core/GeneralProduct.h
+++ b/Eigen/src/Core/GeneralProduct.h
@@ -445,7 +445,7 @@ template<> struct gemv_selector<OnTheRight,ColMajor,true>
if(!evalToDest)
{
#ifdef EIGEN_DENSE_STORAGE_CTOR_PLUGIN
- int size = dest.size();
+ Index size = dest.size();
EIGEN_DENSE_STORAGE_CTOR_PLUGIN
#endif
if(!alphaIsCompatible)
@@ -510,7 +510,7 @@ template<> struct gemv_selector<OnTheRight,RowMajor,true>
if(!DirectlyUseRhs)
{
#ifdef EIGEN_DENSE_STORAGE_CTOR_PLUGIN
- int size = actualRhs.size();
+ Index size = actualRhs.size();
EIGEN_DENSE_STORAGE_CTOR_PLUGIN
#endif
Map<typename _ActualRhsType::PlainObject>(actualRhsPtr, actualRhs.size()) = actualRhs;
diff --git a/Eigen/src/Core/GenericPacketMath.h b/Eigen/src/Core/GenericPacketMath.h
index 0869dd49f..6ec29d0fd 100755..100644
--- a/Eigen/src/Core/GenericPacketMath.h
+++ b/Eigen/src/Core/GenericPacketMath.h
@@ -234,10 +234,10 @@ template<typename Scalar, typename Packet> EIGEN_DEVICE_FUNC inline void pstore(
template<typename Scalar, typename Packet> EIGEN_DEVICE_FUNC inline void pstoreu(Scalar* to, const Packet& from)
{ (*to) = from; }
- template<typename Scalar, typename Packet> EIGEN_DEVICE_FUNC inline Packet pgather(const Scalar* from, int /*stride*/)
+ template<typename Scalar, typename Packet> EIGEN_DEVICE_FUNC inline Packet pgather(const Scalar* from, DenseIndex /*stride*/)
{ return ploadu<Packet>(from); }
- template<typename Scalar, typename Packet> EIGEN_DEVICE_FUNC inline void pscatter(Scalar* to, const Packet& from, int /*stride*/)
+ template<typename Scalar, typename Packet> EIGEN_DEVICE_FUNC inline void pscatter(Scalar* to, const Packet& from, DenseIndex /*stride*/)
{ pstore(to, from); }
/** \internal tries to do cache prefetching of \a addr */
@@ -319,6 +319,10 @@ Packet pasin(const Packet& a) { using std::asin; return asin(a); }
template<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS
Packet pacos(const Packet& a) { using std::acos; return acos(a); }
+/** \internal \returns the atan of \a a (coeff-wise) */
+template<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS
+Packet patan(const Packet& a) { using std::atan; return atan(a); }
+
/** \internal \returns the exp of \a a (coeff-wise) */
template<typename Packet> EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS
Packet pexp(const Packet& a) { using std::exp; return exp(a); }
diff --git a/Eigen/src/Core/GlobalFunctions.h b/Eigen/src/Core/GlobalFunctions.h
index 2acf97723..2067a2a6e 100644
--- a/Eigen/src/Core/GlobalFunctions.h
+++ b/Eigen/src/Core/GlobalFunctions.h
@@ -45,6 +45,7 @@ namespace Eigen
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(asin,scalar_asin_op)
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(acos,scalar_acos_op)
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(tan,scalar_tan_op)
+ EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(atan,scalar_atan_op)
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(exp,scalar_exp_op)
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(log,scalar_log_op)
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(abs,scalar_abs_op)
diff --git a/Eigen/src/Core/Map.h b/Eigen/src/Core/Map.h
index c75a5e95f..ced1b76ba 100644
--- a/Eigen/src/Core/Map.h
+++ b/Eigen/src/Core/Map.h
@@ -110,14 +110,9 @@ template<typename PlainObjectType, int MapOptions, typename StrideType> class Ma
EIGEN_DENSE_PUBLIC_INTERFACE(Map)
typedef typename Base::PointerType PointerType;
-#if EIGEN2_SUPPORT_STAGE <= STAGE30_FULL_EIGEN3_API
- typedef const Scalar* PointerArgType;
- inline PointerType cast_to_pointer_type(PointerArgType ptr) { return const_cast<PointerType>(ptr); }
-#else
typedef PointerType PointerArgType;
EIGEN_DEVICE_FUNC
inline PointerType cast_to_pointer_type(PointerArgType ptr) { return ptr; }
-#endif
EIGEN_DEVICE_FUNC
inline Index innerStride() const
@@ -179,19 +174,6 @@ template<typename PlainObjectType, int MapOptions, typename StrideType> class Ma
StrideType m_stride;
};
-template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
-inline Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>
- ::Array(const Scalar *data)
-{
- this->_set_noalias(Eigen::Map<const Array>(data));
-}
-
-template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
-inline Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>
- ::Matrix(const Scalar *data)
-{
- this->_set_noalias(Eigen::Map<const Matrix>(data));
-}
} // end namespace Eigen
diff --git a/Eigen/src/Core/Matrix.h b/Eigen/src/Core/Matrix.h
index c2cedbf6a..8c95ee3ca 100644
--- a/Eigen/src/Core/Matrix.h
+++ b/Eigen/src/Core/Matrix.h
@@ -232,24 +232,17 @@ class Matrix
}
#endif
- /** \brief Constructs a vector or row-vector with given dimension. \only_for_vectors
- *
- * Note that this is only useful for dynamic-size vectors. For fixed-size vectors,
- * it is redundant to pass the dimension here, so it makes more sense to use the default
- * constructor Matrix() instead.
- */
+ #ifndef EIGEN_PARSED_BY_DOXYGEN
+
+ // This constructor is for both 1x1 matrices and dynamic vectors
+ template<typename T>
EIGEN_DEVICE_FUNC
- EIGEN_STRONG_INLINE explicit Matrix(Index dim)
- : Base(dim, RowsAtCompileTime == 1 ? 1 : dim, ColsAtCompileTime == 1 ? 1 : dim)
+ EIGEN_STRONG_INLINE explicit Matrix(const T& x)
{
Base::_check_template_params();
- EIGEN_STATIC_ASSERT_VECTOR_ONLY(Matrix)
- eigen_assert(dim >= 0);
- eigen_assert(SizeAtCompileTime == Dynamic || SizeAtCompileTime == dim);
- EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
+ Base::template _init1<T>(x);
}
- #ifndef EIGEN_PARSED_BY_DOXYGEN
template<typename T0, typename T1>
EIGEN_DEVICE_FUNC
EIGEN_STRONG_INLINE Matrix(const T0& x, const T1& y)
@@ -258,13 +251,40 @@ class Matrix
Base::template _init2<T0,T1>(x, y);
}
#else
+ /** \brief Constructs a fixed-sized matrix initialized with coefficients starting at \a data */
+ EIGEN_DEVICE_FUNC
+ explicit Matrix(const Scalar *data);
+
+ /** \brief Constructs a vector or row-vector with given dimension. \only_for_vectors
+ *
+ * This is useful for dynamic-size vectors. For fixed-size vectors,
+ * it is redundant to pass these parameters, so one should use the default constructor
+ * Matrix() instead.
+ *
+ * \warning This constructor is disabled for fixed-size \c 1x1 matrices. For instance,
+ * calling Matrix<double,1,1>(1) will call the initialization constructor: Matrix(const Scalar&).
+ * For fixed-size \c 1x1 matrices it is thefore recommended to use the default
+ * constructor Matrix() instead, especilly when using one of the non standard
+ * \c EIGEN_INITIALIZE_MATRICES_BY_{ZERO,\c NAN} macros (see \ref TopicPreprocessorDirectives).
+ */
+ EIGEN_STRONG_INLINE explicit Matrix(Index dim);
+ /** \brief Constructs an initialized 1x1 matrix with the given coefficient */
+ Matrix(const Scalar& x);
/** \brief Constructs an uninitialized matrix with \a rows rows and \a cols columns.
*
* This is useful for dynamic-size matrices. For fixed-size matrices,
* it is redundant to pass these parameters, so one should use the default constructor
- * Matrix() instead. */
+ * Matrix() instead.
+ *
+ * \warning This constructor is disabled for fixed-size \c 1x2 and \c 2x1 vectors. For instance,
+ * calling Matrix2f(2,1) will call the initialization constructor: Matrix(const Scalar& x, const Scalar& y).
+ * For fixed-size \c 1x2 or \c 2x1 vectors it is thefore recommended to use the default
+ * constructor Matrix() instead, especilly when using one of the non standard
+ * \c EIGEN_INITIALIZE_MATRICES_BY_{ZERO,\c NAN} macros (see \ref TopicPreprocessorDirectives).
+ */
EIGEN_DEVICE_FUNC
Matrix(Index rows, Index cols);
+
/** \brief Constructs an initialized 2D vector with given coefficients */
Matrix(const Scalar& x, const Scalar& y);
#endif
@@ -291,8 +311,6 @@ class Matrix
m_storage.data()[3] = w;
}
- EIGEN_DEVICE_FUNC
- explicit Matrix(const Scalar *data);
/** \brief Constructor copying the value of the expression \a other */
template<typename OtherDerived>
@@ -362,13 +380,6 @@ class Matrix
EIGEN_DEVICE_FUNC
Matrix& operator=(const RotationBase<OtherDerived,ColsAtCompileTime>& r);
- #ifdef EIGEN2_SUPPORT
- template<typename OtherDerived>
- explicit Matrix(const eigen2_RotationBase<OtherDerived,ColsAtCompileTime>& r);
- template<typename OtherDerived>
- Matrix& operator=(const eigen2_RotationBase<OtherDerived,ColsAtCompileTime>& r);
- #endif
-
// allow to extend Matrix outside Eigen
#ifdef EIGEN_MATRIX_PLUGIN
#include EIGEN_MATRIX_PLUGIN
diff --git a/Eigen/src/Core/MatrixBase.h b/Eigen/src/Core/MatrixBase.h
index 172929562..f5987d194 100644
--- a/Eigen/src/Core/MatrixBase.h
+++ b/Eigen/src/Core/MatrixBase.h
@@ -221,11 +221,6 @@ template<typename Derived> class MatrixBase
typename internal::scalar_product_traits<typename internal::traits<Derived>::Scalar,typename internal::traits<OtherDerived>::Scalar>::ReturnType
dot(const MatrixBase<OtherDerived>& other) const;
- #ifdef EIGEN2_SUPPORT
- template<typename OtherDerived>
- Scalar eigen2_dot(const MatrixBase<OtherDerived>& other) const;
- #endif
-
EIGEN_DEVICE_FUNC RealScalar squaredNorm() const;
EIGEN_DEVICE_FUNC RealScalar norm() const;
RealScalar stableNorm() const;
@@ -269,17 +264,6 @@ template<typename Derived> class MatrixBase
typename ConstDiagonalIndexReturnType<DynamicIndex>::Type diagonal(Index index) const;
#endif
- #ifdef EIGEN2_SUPPORT
- template<unsigned int Mode> typename internal::eigen2_part_return_type<Derived, Mode>::type part();
- template<unsigned int Mode> const typename internal::eigen2_part_return_type<Derived, Mode>::type part() const;
-
- // huuuge hack. make Eigen2's matrix.part<Diagonal>() work in eigen3. Problem: Diagonal is now a class template instead
- // of an integer constant. Solution: overload the part() method template wrt template parameters list.
- template<template<typename T, int N> class U>
- const DiagonalWrapper<ConstDiagonalReturnType> part() const
- { return diagonal().asDiagonal(); }
- #endif // EIGEN2_SUPPORT
-
template<unsigned int Mode> struct TriangularViewReturnType { typedef TriangularView<Derived, Mode> Type; };
template<unsigned int Mode> struct ConstTriangularViewReturnType { typedef const TriangularView<const Derived, Mode> Type; };
@@ -373,24 +357,7 @@ template<typename Derived> class MatrixBase
EIGEN_DEVICE_FUNC const FullPivLU<PlainObject> fullPivLu() const;
EIGEN_DEVICE_FUNC const PartialPivLU<PlainObject> partialPivLu() const;
- #if EIGEN2_SUPPORT_STAGE < STAGE20_RESOLVE_API_CONFLICTS
- const LU<PlainObject> lu() const;
- #endif
-
- #ifdef EIGEN2_SUPPORT
- const LU<PlainObject> eigen2_lu() const;
- #endif
-
- #if EIGEN2_SUPPORT_STAGE > STAGE20_RESOLVE_API_CONFLICTS
const PartialPivLU<PlainObject> lu() const;
- #endif
-
- #ifdef EIGEN2_SUPPORT
- template<typename ResultType>
- void computeInverse(MatrixBase<ResultType> *result) const {
- *result = this->inverse();
- }
- #endif
EIGEN_DEVICE_FUNC
const internal::inverse_impl<Derived> inverse() const;
@@ -419,10 +386,6 @@ template<typename Derived> class MatrixBase
const HouseholderQR<PlainObject> householderQr() const;
const ColPivHouseholderQR<PlainObject> colPivHouseholderQr() const;
const FullPivHouseholderQR<PlainObject> fullPivHouseholderQr() const;
-
- #ifdef EIGEN2_SUPPORT
- const QR<PlainObject> qr() const;
- #endif
EigenvaluesReturnType eigenvalues() const;
RealScalar operatorNorm() const;
@@ -431,10 +394,6 @@ template<typename Derived> class MatrixBase
JacobiSVD<PlainObject> jacobiSvd(unsigned int computationOptions = 0) const;
- #ifdef EIGEN2_SUPPORT
- SVD<PlainObject> svd() const;
- #endif
-
/////////// Geometry module ///////////
#ifndef EIGEN_PARSED_BY_DOXYGEN
@@ -458,13 +417,11 @@ template<typename Derived> class MatrixBase
Matrix<Scalar,3,1> eulerAngles(Index a0, Index a1, Index a2) const;
- #if EIGEN2_SUPPORT_STAGE > STAGE20_RESOLVE_API_CONFLICTS
ScalarMultipleReturnType operator*(const UniformScaling<Scalar>& s) const;
// put this as separate enum value to work around possible GCC 4.3 bug (?)
enum { HomogeneousReturnTypeDirection = ColsAtCompileTime==1?Vertical:Horizontal };
typedef Homogeneous<Derived, HomogeneousReturnTypeDirection> HomogeneousReturnType;
HomogeneousReturnType homogeneous() const;
- #endif
enum {
SizeMinusOne = SizeAtCompileTime==Dynamic ? Dynamic : SizeAtCompileTime-1
@@ -513,41 +470,6 @@ template<typename Derived> class MatrixBase
const MatrixPowerReturnValue<Derived> pow(const RealScalar& p) const;
const MatrixComplexPowerReturnValue<Derived> pow(const std::complex<RealScalar>& p) const;
-#ifdef EIGEN2_SUPPORT
- template<typename ProductDerived, typename Lhs, typename Rhs>
- Derived& operator+=(const Flagged<ProductBase<ProductDerived, Lhs,Rhs>, 0,
- EvalBeforeAssigningBit>& other);
-
- template<typename ProductDerived, typename Lhs, typename Rhs>
- Derived& operator-=(const Flagged<ProductBase<ProductDerived, Lhs,Rhs>, 0,
- EvalBeforeAssigningBit>& other);
-
- /** \deprecated because .lazy() is deprecated
- * Overloaded for cache friendly product evaluation */
- template<typename OtherDerived>
- Derived& lazyAssign(const Flagged<OtherDerived, 0, EvalBeforeAssigningBit>& other)
- { return lazyAssign(other._expression()); }
-
- template<unsigned int Added>
- const Flagged<Derived, Added, 0> marked() const;
- const Flagged<Derived, 0, EvalBeforeAssigningBit> lazy() const;
-
- inline const Cwise<Derived> cwise() const;
- inline Cwise<Derived> cwise();
-
- VectorBlock<Derived> start(Index size);
- const VectorBlock<const Derived> start(Index size) const;
- VectorBlock<Derived> end(Index size);
- const VectorBlock<const Derived> end(Index size) const;
- template<int Size> VectorBlock<Derived,Size> start();
- template<int Size> const VectorBlock<const Derived,Size> start() const;
- template<int Size> VectorBlock<Derived,Size> end();
- template<int Size> const VectorBlock<const Derived,Size> end() const;
-
- Minor<Derived> minor(Index row, Index col);
- const Minor<Derived> minor(Index row, Index col) const;
-#endif
-
protected:
EIGEN_DEVICE_FUNC MatrixBase() : Base() {}
diff --git a/Eigen/src/Core/NumTraits.h b/Eigen/src/Core/NumTraits.h
index 2b6633c9c..a04227f57 100644
--- a/Eigen/src/Core/NumTraits.h
+++ b/Eigen/src/Core/NumTraits.h
@@ -85,13 +85,6 @@ template<typename T> struct GenericNumTraits
}
static inline T highest() { return (std::numeric_limits<T>::max)(); }
static inline T lowest() { return IsInteger ? (std::numeric_limits<T>::min)() : (-(std::numeric_limits<T>::max)()); }
-
-#ifdef EIGEN2_SUPPORT
- enum {
- HasFloatingPoint = !IsInteger
- };
- typedef NonInteger FloatingPoint;
-#endif
};
template<typename T> struct NumTraits : GenericNumTraits<T>
diff --git a/Eigen/src/Core/PermutationMatrix.h b/Eigen/src/Core/PermutationMatrix.h
index 1297b8413..8aa4c8bc5 100644
--- a/Eigen/src/Core/PermutationMatrix.h
+++ b/Eigen/src/Core/PermutationMatrix.h
@@ -66,11 +66,11 @@ class PermutationBase : public EigenBase<Derived>
MaxRowsAtCompileTime = Traits::MaxRowsAtCompileTime,
MaxColsAtCompileTime = Traits::MaxColsAtCompileTime
};
- typedef typename Traits::Scalar Scalar;
+ typedef typename Traits::StorageIndexType StorageIndexType;
typedef typename Traits::Index Index;
- typedef Matrix<Scalar,RowsAtCompileTime,ColsAtCompileTime,0,MaxRowsAtCompileTime,MaxColsAtCompileTime>
+ typedef Matrix<StorageIndexType,RowsAtCompileTime,ColsAtCompileTime,0,MaxRowsAtCompileTime,MaxColsAtCompileTime>
DenseMatrixType;
- typedef PermutationMatrix<IndicesType::SizeAtCompileTime,IndicesType::MaxSizeAtCompileTime,Index>
+ typedef PermutationMatrix<IndicesType::SizeAtCompileTime,IndicesType::MaxSizeAtCompileTime,StorageIndexType>
PlainPermutationType;
using Base::derived;
#endif
@@ -147,7 +147,7 @@ class PermutationBase : public EigenBase<Derived>
/** Sets *this to be the identity permutation matrix */
void setIdentity()
{
- for(Index i = 0; i < size(); ++i)
+ for(StorageIndexType i = 0; i < size(); ++i)
indices().coeffRef(i) = i;
}
@@ -173,8 +173,8 @@ class PermutationBase : public EigenBase<Derived>
eigen_assert(i>=0 && j>=0 && i<size() && j<size());
for(Index k = 0; k < size(); ++k)
{
- if(indices().coeff(k) == i) indices().coeffRef(k) = j;
- else if(indices().coeff(k) == j) indices().coeffRef(k) = i;
+ if(indices().coeff(k) == i) indices().coeffRef(k) = StorageIndexType(j);
+ else if(indices().coeff(k) == j) indices().coeffRef(k) = StorageIndexType(i);
}
return derived();
}
@@ -262,7 +262,7 @@ class PermutationBase : public EigenBase<Derived>
*
* \param SizeAtCompileTime the number of rows/cols, or Dynamic
* \param MaxSizeAtCompileTime the maximum number of rows/cols, or Dynamic. This optional parameter defaults to SizeAtCompileTime. Most of the time, you should not have to specify it.
- * \param IndexType the interger type of the indices
+ * \param StorageIndexType the integer type of the indices
*
* This class represents a permutation matrix, internally stored as a vector of integers.
*
@@ -270,17 +270,18 @@ class PermutationBase : public EigenBase<Derived>
*/
namespace internal {
-template<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename IndexType>
-struct traits<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime, IndexType> >
- : traits<Matrix<IndexType,SizeAtCompileTime,SizeAtCompileTime,0,MaxSizeAtCompileTime,MaxSizeAtCompileTime> >
+template<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename _StorageIndexType>
+struct traits<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime, _StorageIndexType> >
+ : traits<Matrix<_StorageIndexType,SizeAtCompileTime,SizeAtCompileTime,0,MaxSizeAtCompileTime,MaxSizeAtCompileTime> >
{
- typedef IndexType Index;
- typedef Matrix<IndexType, SizeAtCompileTime, 1, 0, MaxSizeAtCompileTime, 1> IndicesType;
+ typedef Matrix<_StorageIndexType, SizeAtCompileTime, 1, 0, MaxSizeAtCompileTime, 1> IndicesType;
+ typedef typename IndicesType::Index Index;
+ typedef _StorageIndexType StorageIndexType;
};
}
-template<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename IndexType>
-class PermutationMatrix : public PermutationBase<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime, IndexType> >
+template<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename _StorageIndexType>
+class PermutationMatrix : public PermutationBase<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime, _StorageIndexType> >
{
typedef PermutationBase<PermutationMatrix> Base;
typedef internal::traits<PermutationMatrix> Traits;
@@ -288,6 +289,8 @@ class PermutationMatrix : public PermutationBase<PermutationMatrix<SizeAtCompile
#ifndef EIGEN_PARSED_BY_DOXYGEN
typedef typename Traits::IndicesType IndicesType;
+ typedef typename Traits::StorageIndexType StorageIndexType;
+ typedef typename Traits::Index Index;
#endif
inline PermutationMatrix()
@@ -295,7 +298,7 @@ class PermutationMatrix : public PermutationBase<PermutationMatrix<SizeAtCompile
/** Constructs an uninitialized permutation matrix of given size.
*/
- inline PermutationMatrix(int size) : m_indices(size)
+ inline PermutationMatrix(Index size) : m_indices(size)
{}
/** Copy constructor. */
@@ -384,18 +387,19 @@ class PermutationMatrix : public PermutationBase<PermutationMatrix<SizeAtCompile
namespace internal {
-template<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename IndexType, int _PacketAccess>
-struct traits<Map<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime, IndexType>,_PacketAccess> >
- : traits<Matrix<IndexType,SizeAtCompileTime,SizeAtCompileTime,0,MaxSizeAtCompileTime,MaxSizeAtCompileTime> >
+template<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename _StorageIndexType, int _PacketAccess>
+struct traits<Map<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime, _StorageIndexType>,_PacketAccess> >
+ : traits<Matrix<_StorageIndexType,SizeAtCompileTime,SizeAtCompileTime,0,MaxSizeAtCompileTime,MaxSizeAtCompileTime> >
{
- typedef IndexType Index;
- typedef Map<const Matrix<IndexType, SizeAtCompileTime, 1, 0, MaxSizeAtCompileTime, 1>, _PacketAccess> IndicesType;
+ typedef Map<const Matrix<_StorageIndexType, SizeAtCompileTime, 1, 0, MaxSizeAtCompileTime, 1>, _PacketAccess> IndicesType;
+ typedef typename IndicesType::Index Index;
+ typedef _StorageIndexType StorageIndexType;
};
}
-template<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename IndexType, int _PacketAccess>
-class Map<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime, IndexType>,_PacketAccess>
- : public PermutationBase<Map<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime, IndexType>,_PacketAccess> >
+template<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename _StorageIndexType, int _PacketAccess>
+class Map<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime, _StorageIndexType>,_PacketAccess>
+ : public PermutationBase<Map<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime, _StorageIndexType>,_PacketAccess> >
{
typedef PermutationBase<Map> Base;
typedef internal::traits<Map> Traits;
@@ -403,14 +407,15 @@ class Map<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime, IndexType>,
#ifndef EIGEN_PARSED_BY_DOXYGEN
typedef typename Traits::IndicesType IndicesType;
- typedef typename IndicesType::Scalar Index;
+ typedef typename IndicesType::Scalar StorageIndexType;
+ typedef typename IndicesType::Index Index;
#endif
- inline Map(const Index* indicesPtr)
+ inline Map(const StorageIndexType* indicesPtr)
: m_indices(indicesPtr)
{}
- inline Map(const Index* indicesPtr, Index size)
+ inline Map(const StorageIndexType* indicesPtr, Index size)
: m_indices(indicesPtr,size)
{}
@@ -466,7 +471,8 @@ struct traits<PermutationWrapper<_IndicesType> >
{
typedef PermutationStorage StorageKind;
typedef typename _IndicesType::Scalar Scalar;
- typedef typename _IndicesType::Scalar Index;
+ typedef typename _IndicesType::Scalar StorageIndexType;
+ typedef typename _IndicesType::Index Index;
typedef _IndicesType IndicesType;
enum {
RowsAtCompileTime = _IndicesType::SizeAtCompileTime,
diff --git a/Eigen/src/Core/PlainObjectBase.h b/Eigen/src/Core/PlainObjectBase.h
index 0305066ba..69f34bd3e 100644
--- a/Eigen/src/Core/PlainObjectBase.h
+++ b/Eigen/src/Core/PlainObjectBase.h
@@ -681,6 +681,7 @@ class PlainObjectBase : public internal::dense_xpr_base<Derived>::type
FLOATING_POINT_ARGUMENT_PASSED__INTEGER_WAS_EXPECTED)
resize(nbRows,nbCols);
}
+
template<typename T0, typename T1>
EIGEN_DEVICE_FUNC
EIGEN_STRONG_INLINE void _init2(const Scalar& val0, const Scalar& val1, typename internal::enable_if<Base::SizeAtCompileTime==2,T0>::type* = 0)
@@ -689,6 +690,82 @@ class PlainObjectBase : public internal::dense_xpr_base<Derived>::type
m_storage.data()[0] = val0;
m_storage.data()[1] = val1;
}
+
+ template<typename T0, typename T1>
+ EIGEN_DEVICE_FUNC
+ EIGEN_STRONG_INLINE void _init2(const Index& val0, const Index& val1,
+ typename internal::enable_if< (!internal::is_same<Index,Scalar>::value)
+ && (internal::is_same<T0,Index>::value)
+ && (internal::is_same<T1,Index>::value)
+ && Base::SizeAtCompileTime==2,T1>::type* = 0)
+ {
+ EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(PlainObjectBase, 2)
+ m_storage.data()[0] = Scalar(val0);
+ m_storage.data()[1] = Scalar(val1);
+ }
+
+ template<typename T>
+ EIGEN_DEVICE_FUNC
+ EIGEN_STRONG_INLINE void _init1(Index size, typename internal::enable_if<Base::SizeAtCompileTime!=1 || !internal::is_convertible<T, Scalar>::value,T>::type* = 0)
+ {
+ // NOTE MSVC 2008 complains if we directly put bool(NumTraits<T>::IsInteger) as the EIGEN_STATIC_ASSERT argument.
+ const bool is_integer = NumTraits<T>::IsInteger;
+ EIGEN_STATIC_ASSERT(is_integer,
+ FLOATING_POINT_ARGUMENT_PASSED__INTEGER_WAS_EXPECTED)
+ resize(size);
+ }
+ template<typename T>
+ EIGEN_DEVICE_FUNC
+ EIGEN_STRONG_INLINE void _init1(const Scalar& val0, typename internal::enable_if<Base::SizeAtCompileTime==1 && internal::is_convertible<T, Scalar>::value,T>::type* = 0)
+ {
+ EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(PlainObjectBase, 1)
+ m_storage.data()[0] = val0;
+ }
+
+ template<typename T>
+ EIGEN_DEVICE_FUNC
+ EIGEN_STRONG_INLINE void _init1(const Index& val0,
+ typename internal::enable_if< (!internal::is_same<Index,Scalar>::value)
+ && (internal::is_same<Index,T>::value)
+ && Base::SizeAtCompileTime==1
+ && internal::is_convertible<T, Scalar>::value,T*>::type* = 0)
+ {
+ EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(PlainObjectBase, 1)
+ m_storage.data()[0] = Scalar(val0);
+ }
+
+ template<typename T>
+ EIGEN_DEVICE_FUNC
+ EIGEN_STRONG_INLINE void _init1(const Scalar* data){
+ this->_set_noalias(ConstMapType(data));
+ }
+
+ template<typename T, typename OtherDerived>
+ EIGEN_DEVICE_FUNC
+ EIGEN_STRONG_INLINE void _init1(const DenseBase<OtherDerived>& other){
+ this->_set_noalias(other);
+ }
+
+ template<typename T, typename OtherDerived>
+ EIGEN_DEVICE_FUNC
+ EIGEN_STRONG_INLINE void _init1(const EigenBase<OtherDerived>& other){
+ this->derived() = other;
+ }
+
+ template<typename T, typename OtherDerived>
+ EIGEN_DEVICE_FUNC
+ EIGEN_STRONG_INLINE void _init1(const ReturnByValue<OtherDerived>& other)
+ {
+ resize(other.rows(), other.cols());
+ other.evalTo(this->derived());
+ }
+
+ template<typename T, typename OtherDerived, int ColsAtCompileTime>
+ EIGEN_DEVICE_FUNC
+ EIGEN_STRONG_INLINE void _init1(const RotationBase<OtherDerived,ColsAtCompileTime>& r)
+ {
+ this->derived() = r;
+ }
template<typename MatrixTypeA, typename MatrixTypeB, bool SwapPointers>
friend struct internal::matrix_swap_impl;
diff --git a/Eigen/src/Core/ProductBase.h b/Eigen/src/Core/ProductBase.h
index a494b5f87..483914a9b 100644
--- a/Eigen/src/Core/ProductBase.h
+++ b/Eigen/src/Core/ProductBase.h
@@ -131,17 +131,13 @@ class ProductBase : public MatrixBase<Derived>
const Diagonal<FullyLazyCoeffBaseProductType,Dynamic> diagonal(Index index) const
{ return FullyLazyCoeffBaseProductType(m_lhs, m_rhs).diagonal(index); }
- // restrict coeff accessors to 1x1 expressions. No need to care about mutators here since this isnt a Lvalue expression
+ // restrict coeff accessors to 1x1 expressions. No need to care about mutators here since this isn't an Lvalue expression
typename Base::CoeffReturnType coeff(Index row, Index col) const
{
-#ifdef EIGEN2_SUPPORT
- return lhs().row(row).cwiseProduct(rhs().col(col).transpose()).sum();
-#else
EIGEN_STATIC_ASSERT_SIZE_1x1(Derived)
eigen_assert(this->rows() == 1 && this->cols() == 1);
Matrix<Scalar,1,1> result = *this;
return result.coeff(row,col);
-#endif
}
typename Base::CoeffReturnType coeff(Index i) const
diff --git a/Eigen/src/Core/Ref.h b/Eigen/src/Core/Ref.h
index cd6d949c4..92614c6e2 100644
--- a/Eigen/src/Core/Ref.h
+++ b/Eigen/src/Core/Ref.h
@@ -19,17 +19,17 @@ template<typename PlainObjectType, int Options = 0,
/** \class Ref
* \ingroup Core_Module
*
- * \brief A matrix or vector expression mapping an existing expressions
+ * \brief A matrix or vector expression mapping an existing expression
*
* \tparam PlainObjectType the equivalent matrix type of the mapped data
* \tparam Options specifies whether the pointer is \c #Aligned, or \c #Unaligned.
* The default is \c #Unaligned.
* \tparam StrideType optionally specifies strides. By default, Ref implies a contiguous storage along the inner dimension (inner stride==1),
- * but accept a variable outer stride (leading dimension).
+ * but accepts a variable outer stride (leading dimension).
* This can be overridden by specifying strides.
* The type passed here must be a specialization of the Stride template, see examples below.
*
- * This class permits to write non template functions taking Eigen's object as parameters while limiting the number of copies.
+ * This class provides a way to write non-template functions taking Eigen objects as parameters while limiting the number of copies.
* A Ref<> object can represent either a const expression or a l-value:
* \code
* // in-out argument:
@@ -39,10 +39,10 @@ template<typename PlainObjectType, int Options = 0,
* void foo2(const Ref<const VectorXf>& x);
* \endcode
*
- * In the in-out case, the input argument must satisfies the constraints of the actual Ref<> type, otherwise a compilation issue will be triggered.
+ * In the in-out case, the input argument must satisfy the constraints of the actual Ref<> type, otherwise a compilation issue will be triggered.
* By default, a Ref<VectorXf> can reference any dense vector expression of float having a contiguous memory layout.
- * Likewise, a Ref<MatrixXf> can reference any column major dense matrix expression of float whose column's elements are contiguously stored with
- * the possibility to have a constant space inbetween each column, i.e.: the inner stride mmust be equal to 1, but the outer-stride (or leading dimension),
+ * Likewise, a Ref<MatrixXf> can reference any column-major dense matrix expression of float whose column's elements are contiguously stored with
+ * the possibility to have a constant space in-between each column, i.e. the inner stride must be equal to 1, but the outer stride (or leading dimension)
* can be greater than the number of rows.
*
* In the const case, if the input expression does not match the above requirement, then it is evaluated into a temporary before being passed to the function.
@@ -58,15 +58,15 @@ template<typename PlainObjectType, int Options = 0,
* foo2(A.col().segment(2,4)); // No temporary
* \endcode
*
- * The range of inputs that can be referenced without temporary can be enlarged using the last two template parameter.
+ * The range of inputs that can be referenced without temporary can be enlarged using the last two template parameters.
* Here is an example accepting an innerstride!=1:
* \code
* // in-out argument:
* void foo3(Ref<VectorXf,0,InnerStride<> > x);
* foo3(A.row()); // OK
* \endcode
- * The downside here is that the function foo3 might be significantly slower than foo1 because it won't be able to exploit vectorization, and will involved more
- * expensive address computations even if the input is contiguously stored in memory. To overcome this issue, one might propose to overloads internally calling a
+ * The downside here is that the function foo3 might be significantly slower than foo1 because it won't be able to exploit vectorization, and will involve more
+ * expensive address computations even if the input is contiguously stored in memory. To overcome this issue, one might propose to overload internally calling a
* template function, e.g.:
* \code
* // in the .h:
diff --git a/Eigen/src/Core/SelfAdjointView.h b/Eigen/src/Core/SelfAdjointView.h
index 8231e3f5c..6c2733650 100644
--- a/Eigen/src/Core/SelfAdjointView.h
+++ b/Eigen/src/Core/SelfAdjointView.h
@@ -177,31 +177,6 @@ template<typename MatrixType, unsigned int UpLo> class SelfAdjointView
EigenvaluesReturnType eigenvalues() const;
EIGEN_DEVICE_FUNC
RealScalar operatorNorm() const;
-
- #ifdef EIGEN2_SUPPORT
- template<typename OtherDerived>
- EIGEN_DEVICE_FUNC
- SelfAdjointView& operator=(const MatrixBase<OtherDerived>& other)
- {
- enum {
- OtherPart = UpLo == Upper ? StrictlyLower : StrictlyUpper
- };
- m_matrix.const_cast_derived().template triangularView<UpLo>() = other;
- m_matrix.const_cast_derived().template triangularView<OtherPart>() = other.adjoint();
- return *this;
- }
- template<typename OtherMatrixType, unsigned int OtherMode>
- EIGEN_DEVICE_FUNC
- SelfAdjointView& operator=(const TriangularView<OtherMatrixType, OtherMode>& other)
- {
- enum {
- OtherPart = UpLo == Upper ? StrictlyLower : StrictlyUpper
- };
- m_matrix.const_cast_derived().template triangularView<UpLo>() = other.toDenseMatrix();
- m_matrix.const_cast_derived().template triangularView<OtherPart>() = other.toDenseMatrix().adjoint();
- return *this;
- }
- #endif
protected:
MatrixTypeNested m_matrix;
diff --git a/Eigen/src/Core/Transpositions.h b/Eigen/src/Core/Transpositions.h
index e4ba0756f..92261118f 100644
--- a/Eigen/src/Core/Transpositions.h
+++ b/Eigen/src/Core/Transpositions.h
@@ -53,7 +53,8 @@ class TranspositionsBase
public:
typedef typename Traits::IndicesType IndicesType;
- typedef typename IndicesType::Scalar Index;
+ typedef typename IndicesType::Scalar StorageIndexType;
+ typedef typename IndicesType::Index Index;
Derived& derived() { return *static_cast<Derived*>(this); }
const Derived& derived() const { return *static_cast<const Derived*>(this); }
@@ -81,17 +82,17 @@ class TranspositionsBase
inline Index size() const { return indices().size(); }
/** Direct access to the underlying index vector */
- inline const Index& coeff(Index i) const { return indices().coeff(i); }
+ inline const StorageIndexType& coeff(Index i) const { return indices().coeff(i); }
/** Direct access to the underlying index vector */
- inline Index& coeffRef(Index i) { return indices().coeffRef(i); }
+ inline StorageIndexType& coeffRef(Index i) { return indices().coeffRef(i); }
/** Direct access to the underlying index vector */
- inline const Index& operator()(Index i) const { return indices()(i); }
+ inline const StorageIndexType& operator()(Index i) const { return indices()(i); }
/** Direct access to the underlying index vector */
- inline Index& operator()(Index i) { return indices()(i); }
+ inline StorageIndexType& operator()(Index i) { return indices()(i); }
/** Direct access to the underlying index vector */
- inline const Index& operator[](Index i) const { return indices()(i); }
+ inline const StorageIndexType& operator[](Index i) const { return indices()(i); }
/** Direct access to the underlying index vector */
- inline Index& operator[](Index i) { return indices()(i); }
+ inline StorageIndexType& operator[](Index i) { return indices()(i); }
/** const version of indices(). */
const IndicesType& indices() const { return derived().indices(); }
@@ -99,7 +100,7 @@ class TranspositionsBase
IndicesType& indices() { return derived().indices(); }
/** Resizes to given size. */
- inline void resize(int newSize)
+ inline void resize(Index newSize)
{
indices().resize(newSize);
}
@@ -107,7 +108,7 @@ class TranspositionsBase
/** Sets \c *this to represents an identity transformation */
void setIdentity()
{
- for(int i = 0; i < indices().size(); ++i)
+ for(StorageIndexType i = 0; i < indices().size(); ++i)
coeffRef(i) = i;
}
@@ -144,23 +145,26 @@ class TranspositionsBase
};
namespace internal {
-template<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename IndexType>
-struct traits<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,IndexType> >
+template<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename _StorageIndexType>
+struct traits<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,_StorageIndexType> >
{
- typedef IndexType Index;
- typedef Matrix<Index, SizeAtCompileTime, 1, 0, MaxSizeAtCompileTime, 1> IndicesType;
+ typedef Matrix<_StorageIndexType, SizeAtCompileTime, 1, 0, MaxSizeAtCompileTime, 1> IndicesType;
+ typedef typename IndicesType::Index Index;
+ typedef _StorageIndexType StorageIndexType;
};
}
-template<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename IndexType>
-class Transpositions : public TranspositionsBase<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,IndexType> >
+template<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename _StorageIndexType>
+class Transpositions : public TranspositionsBase<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,_StorageIndexType> >
{
typedef internal::traits<Transpositions> Traits;
public:
typedef TranspositionsBase<Transpositions> Base;
typedef typename Traits::IndicesType IndicesType;
- typedef typename IndicesType::Scalar Index;
+ typedef typename IndicesType::Scalar StorageIndexType;
+ typedef typename IndicesType::Index Index;
+
inline Transpositions() {}
@@ -215,30 +219,32 @@ class Transpositions : public TranspositionsBase<Transpositions<SizeAtCompileTim
namespace internal {
-template<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename IndexType, int _PacketAccess>
-struct traits<Map<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,IndexType>,_PacketAccess> >
+template<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename _StorageIndexType, int _PacketAccess>
+struct traits<Map<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,_StorageIndexType>,_PacketAccess> >
{
- typedef IndexType Index;
- typedef Map<const Matrix<Index,SizeAtCompileTime,1,0,MaxSizeAtCompileTime,1>, _PacketAccess> IndicesType;
+ typedef Map<const Matrix<_StorageIndexType,SizeAtCompileTime,1,0,MaxSizeAtCompileTime,1>, _PacketAccess> IndicesType;
+ typedef typename IndicesType::Index Index;
+ typedef _StorageIndexType StorageIndexType;
};
}
-template<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename IndexType, int PacketAccess>
-class Map<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,IndexType>,PacketAccess>
- : public TranspositionsBase<Map<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,IndexType>,PacketAccess> >
+template<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename _StorageIndexType, int PacketAccess>
+class Map<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,_StorageIndexType>,PacketAccess>
+ : public TranspositionsBase<Map<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,_StorageIndexType>,PacketAccess> >
{
typedef internal::traits<Map> Traits;
public:
typedef TranspositionsBase<Map> Base;
typedef typename Traits::IndicesType IndicesType;
- typedef typename IndicesType::Scalar Index;
+ typedef typename IndicesType::Scalar StorageIndexType;
+ typedef typename IndicesType::Index Index;
- inline Map(const Index* indicesPtr)
+ inline Map(const StorageIndexType* indicesPtr)
: m_indices(indicesPtr)
{}
- inline Map(const Index* indicesPtr, Index size)
+ inline Map(const StorageIndexType* indicesPtr, Index size)
: m_indices(indicesPtr,size)
{}
@@ -275,7 +281,8 @@ namespace internal {
template<typename _IndicesType>
struct traits<TranspositionsWrapper<_IndicesType> >
{
- typedef typename _IndicesType::Scalar Index;
+ typedef typename _IndicesType::Scalar StorageIndexType;
+ typedef typename _IndicesType::Index Index;
typedef _IndicesType IndicesType;
};
}
@@ -289,7 +296,8 @@ class TranspositionsWrapper
typedef TranspositionsBase<TranspositionsWrapper> Base;
typedef typename Traits::IndicesType IndicesType;
- typedef typename IndicesType::Scalar Index;
+ typedef typename IndicesType::Scalar StorageIndexType;
+ typedef typename IndicesType::Index Index;
inline TranspositionsWrapper(IndicesType& a_indices)
: m_indices(a_indices)
@@ -363,24 +371,25 @@ struct transposition_matrix_product_retval
{
typedef typename remove_all<typename MatrixType::Nested>::type MatrixTypeNestedCleaned;
typedef typename TranspositionType::Index Index;
+ typedef typename TranspositionType::StorageIndexType StorageIndexType;
transposition_matrix_product_retval(const TranspositionType& tr, const MatrixType& matrix)
: m_transpositions(tr), m_matrix(matrix)
{}
- inline int rows() const { return m_matrix.rows(); }
- inline int cols() const { return m_matrix.cols(); }
+ inline Index rows() const { return m_matrix.rows(); }
+ inline Index cols() const { return m_matrix.cols(); }
template<typename Dest> inline void evalTo(Dest& dst) const
{
- const int size = m_transpositions.size();
- Index j = 0;
+ const Index size = m_transpositions.size();
+ StorageIndexType j = 0;
if(!(is_same<MatrixTypeNestedCleaned,Dest>::value && extract_data(dst) == extract_data(m_matrix)))
dst = m_matrix;
- for(int k=(Transposed?size-1:0) ; Transposed?k>=0:k<size ; Transposed?--k:++k)
- if((j=m_transpositions.coeff(k))!=k)
+ for(Index k=(Transposed?size-1:0) ; Transposed?k>=0:k<size ; Transposed?--k:++k)
+ if(Index(j=m_transpositions.coeff(k))!=k)
{
if(Side==OnTheLeft)
dst.row(k).swap(dst.row(j));
diff --git a/Eigen/src/Core/TriangularMatrix.h b/Eigen/src/Core/TriangularMatrix.h
index 1d6e34650..72792d21b 100644
--- a/Eigen/src/Core/TriangularMatrix.h
+++ b/Eigen/src/Core/TriangularMatrix.h
@@ -323,54 +323,25 @@ template<typename _MatrixType, unsigned int _Mode> class TriangularView
/** Efficient triangular matrix times vector/matrix product */
template<typename OtherDerived>
EIGEN_DEVICE_FUNC
- TriangularProduct<Mode,true,MatrixType,false,OtherDerived, OtherDerived::IsVectorAtCompileTime>
+ TriangularProduct<Mode, true, MatrixType, false, OtherDerived, OtherDerived::ColsAtCompileTime==1>
operator*(const MatrixBase<OtherDerived>& rhs) const
{
return TriangularProduct
- <Mode,true,MatrixType,false,OtherDerived,OtherDerived::IsVectorAtCompileTime>
+ <Mode, true, MatrixType, false, OtherDerived, OtherDerived::ColsAtCompileTime==1>
(m_matrix, rhs.derived());
}
/** Efficient vector/matrix times triangular matrix product */
template<typename OtherDerived> friend
EIGEN_DEVICE_FUNC
- TriangularProduct<Mode,false,OtherDerived,OtherDerived::IsVectorAtCompileTime,MatrixType,false>
+ TriangularProduct<Mode, false, OtherDerived, OtherDerived::RowsAtCompileTime==1, MatrixType, false>
operator*(const MatrixBase<OtherDerived>& lhs, const TriangularView& rhs)
{
return TriangularProduct
- <Mode,false,OtherDerived,OtherDerived::IsVectorAtCompileTime,MatrixType,false>
+ <Mode, false, OtherDerived, OtherDerived::RowsAtCompileTime==1, MatrixType, false>
(lhs.derived(),rhs.m_matrix);
}
- #ifdef EIGEN2_SUPPORT
- template<typename OtherDerived>
- struct eigen2_product_return_type
- {
- typedef typename TriangularView<MatrixType,Mode>::DenseMatrixType DenseMatrixType;
- typedef typename OtherDerived::PlainObject::DenseType OtherPlainObject;
- typedef typename ProductReturnType<DenseMatrixType, OtherPlainObject>::Type ProdRetType;
- typedef typename ProdRetType::PlainObject type;
- };
- template<typename OtherDerived>
- const typename eigen2_product_return_type<OtherDerived>::type
- operator*(const EigenBase<OtherDerived>& rhs) const
- {
- typename OtherDerived::PlainObject::DenseType rhsPlainObject;
- rhs.evalTo(rhsPlainObject);
- return this->toDenseMatrix() * rhsPlainObject;
- }
- template<typename OtherMatrixType>
- bool isApprox(const TriangularView<OtherMatrixType, Mode>& other, typename NumTraits<Scalar>::Real precision = NumTraits<Scalar>::dummy_precision()) const
- {
- return this->toDenseMatrix().isApprox(other.toDenseMatrix(), precision);
- }
- template<typename OtherDerived>
- bool isApprox(const MatrixBase<OtherDerived>& other, typename NumTraits<Scalar>::Real precision = NumTraits<Scalar>::dummy_precision()) const
- {
- return this->toDenseMatrix().isApprox(other, precision);
- }
- #endif // EIGEN2_SUPPORT
-
template<int Side, typename Other>
EIGEN_DEVICE_FUNC
inline const internal::triangular_solve_retval<Side,TriangularView, Other>
@@ -780,41 +751,6 @@ void TriangularBase<Derived>::evalToLazy(MatrixBase<DenseDerived> &other) const
* Implementation of MatrixBase methods
***************************************************************************/
-#ifdef EIGEN2_SUPPORT
-
-// implementation of part<>(), including the SelfAdjoint case.
-
-namespace internal {
-template<typename MatrixType, unsigned int Mode>
-struct eigen2_part_return_type
-{
- typedef TriangularView<MatrixType, Mode> type;
-};
-
-template<typename MatrixType>
-struct eigen2_part_return_type<MatrixType, SelfAdjoint>
-{
- typedef SelfAdjointView<MatrixType, Upper> type;
-};
-}
-
-/** \deprecated use MatrixBase::triangularView() */
-template<typename Derived>
-template<unsigned int Mode>
-const typename internal::eigen2_part_return_type<Derived, Mode>::type MatrixBase<Derived>::part() const
-{
- return derived();
-}
-
-/** \deprecated use MatrixBase::triangularView() */
-template<typename Derived>
-template<unsigned int Mode>
-typename internal::eigen2_part_return_type<Derived, Mode>::type MatrixBase<Derived>::part()
-{
- return derived();
-}
-#endif
-
/**
* \returns an expression of a triangular view extracted from the current matrix
*
diff --git a/Eigen/src/Core/VectorwiseOp.h b/Eigen/src/Core/VectorwiseOp.h
index f25ddca17..52eb4f604 100644
--- a/Eigen/src/Core/VectorwiseOp.h
+++ b/Eigen/src/Core/VectorwiseOp.h
@@ -560,9 +560,7 @@ template<typename ExpressionType, int Direction> class VectorwiseOp
/////////// Geometry module ///////////
- #if EIGEN2_SUPPORT_STAGE > STAGE20_RESOLVE_API_CONFLICTS
Homogeneous<ExpressionType,Direction> homogeneous() const;
- #endif
typedef typename ExpressionType::PlainObject CrossReturnType;
template<typename OtherDerived>
diff --git a/Eigen/src/Core/Visitor.h b/Eigen/src/Core/Visitor.h
index 64867b7a2..6f4b9ec35 100644
--- a/Eigen/src/Core/Visitor.h
+++ b/Eigen/src/Core/Visitor.h
@@ -194,7 +194,7 @@ DenseBase<Derived>::minCoeff(IndexType* index) const
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
internal::min_coeff_visitor<Derived> minVisitor;
this->visit(minVisitor);
- *index = (RowsAtCompileTime==1) ? minVisitor.col : minVisitor.row;
+ *index = IndexType((RowsAtCompileTime==1) ? minVisitor.col : minVisitor.row);
return minVisitor.res;
}
diff --git a/Eigen/src/Core/arch/AVX/Complex.h b/Eigen/src/Core/arch/AVX/Complex.h
index 9ced85132..aa5aa1e34 100644
--- a/Eigen/src/Core/arch/AVX/Complex.h
+++ b/Eigen/src/Core/arch/AVX/Complex.h
@@ -92,7 +92,7 @@ template<> EIGEN_STRONG_INLINE Packet4cf ploaddup<Packet4cf>(const std::complex<
template<> EIGEN_STRONG_INLINE void pstore <std::complex<float> >(std::complex<float>* to, const Packet4cf& from) { EIGEN_DEBUG_ALIGNED_STORE pstore(&numext::real_ref(*to), from.v); }
template<> EIGEN_STRONG_INLINE void pstoreu<std::complex<float> >(std::complex<float>* to, const Packet4cf& from) { EIGEN_DEBUG_UNALIGNED_STORE pstoreu(&numext::real_ref(*to), from.v); }
-template<> EIGEN_DEVICE_FUNC inline Packet4cf pgather<std::complex<float>, Packet4cf>(const std::complex<float>* from, int stride)
+template<> EIGEN_DEVICE_FUNC inline Packet4cf pgather<std::complex<float>, Packet4cf>(const std::complex<float>* from, DenseIndex stride)
{
return Packet4cf(_mm256_set_ps(std::imag(from[3*stride]), std::real(from[3*stride]),
std::imag(from[2*stride]), std::real(from[2*stride]),
@@ -100,7 +100,7 @@ template<> EIGEN_DEVICE_FUNC inline Packet4cf pgather<std::complex<float>, Packe
std::imag(from[0*stride]), std::real(from[0*stride])));
}
-template<> EIGEN_DEVICE_FUNC inline void pscatter<std::complex<float>, Packet4cf>(std::complex<float>* to, const Packet4cf& from, int stride)
+template<> EIGEN_DEVICE_FUNC inline void pscatter<std::complex<float>, Packet4cf>(std::complex<float>* to, const Packet4cf& from, DenseIndex stride)
{
__m128 low = _mm256_extractf128_ps(from.v, 0);
to[stride*0] = std::complex<float>(_mm_cvtss_f32(_mm_shuffle_ps(low, low, 0)),
@@ -310,13 +310,13 @@ template<> EIGEN_STRONG_INLINE Packet2cd ploaddup<Packet2cd>(const std::complex<
template<> EIGEN_STRONG_INLINE void pstore <std::complex<double> >(std::complex<double> * to, const Packet2cd& from) { EIGEN_DEBUG_ALIGNED_STORE pstore((double*)to, from.v); }
template<> EIGEN_STRONG_INLINE void pstoreu<std::complex<double> >(std::complex<double> * to, const Packet2cd& from) { EIGEN_DEBUG_UNALIGNED_STORE pstoreu((double*)to, from.v); }
-template<> EIGEN_DEVICE_FUNC inline Packet2cd pgather<std::complex<double>, Packet2cd>(const std::complex<double>* from, int stride)
+template<> EIGEN_DEVICE_FUNC inline Packet2cd pgather<std::complex<double>, Packet2cd>(const std::complex<double>* from, DenseIndex stride)
{
return Packet2cd(_mm256_set_pd(std::imag(from[1*stride]), std::real(from[1*stride]),
std::imag(from[0*stride]), std::real(from[0*stride])));
}
-template<> EIGEN_DEVICE_FUNC inline void pscatter<std::complex<double>, Packet2cd>(std::complex<double>* to, const Packet2cd& from, int stride)
+template<> EIGEN_DEVICE_FUNC inline void pscatter<std::complex<double>, Packet2cd>(std::complex<double>* to, const Packet2cd& from, DenseIndex stride)
{
__m128d low = _mm256_extractf128_pd(from.v, 0);
to[stride*0] = std::complex<double>(_mm_cvtsd_f64(low), _mm_cvtsd_f64(_mm_shuffle_pd(low, low, 1)));
diff --git a/Eigen/src/Core/arch/AVX/PacketMath.h b/Eigen/src/Core/arch/AVX/PacketMath.h
index 74d3746d9..170302f7f 100644
--- a/Eigen/src/Core/arch/AVX/PacketMath.h
+++ b/Eigen/src/Core/arch/AVX/PacketMath.h
@@ -226,17 +226,17 @@ template<> EIGEN_STRONG_INLINE void pstoreu<int>(int* to, const Packet8i&
// NOTE: leverage _mm256_i32gather_ps and _mm256_i32gather_pd if AVX2 instructions are available
// NOTE: for the record the following seems to be slower: return _mm256_i32gather_ps(from, _mm256_set1_epi32(stride), 4);
-template<> EIGEN_DEVICE_FUNC inline Packet8f pgather<float, Packet8f>(const float* from, int stride)
+template<> EIGEN_DEVICE_FUNC inline Packet8f pgather<float, Packet8f>(const float* from, DenseIndex stride)
{
return _mm256_set_ps(from[7*stride], from[6*stride], from[5*stride], from[4*stride],
from[3*stride], from[2*stride], from[1*stride], from[0*stride]);
}
-template<> EIGEN_DEVICE_FUNC inline Packet4d pgather<double, Packet4d>(const double* from, int stride)
+template<> EIGEN_DEVICE_FUNC inline Packet4d pgather<double, Packet4d>(const double* from, DenseIndex stride)
{
return _mm256_set_pd(from[3*stride], from[2*stride], from[1*stride], from[0*stride]);
}
-template<> EIGEN_DEVICE_FUNC inline void pscatter<float, Packet8f>(float* to, const Packet8f& from, int stride)
+template<> EIGEN_DEVICE_FUNC inline void pscatter<float, Packet8f>(float* to, const Packet8f& from, DenseIndex stride)
{
__m128 low = _mm256_extractf128_ps(from, 0);
to[stride*0] = _mm_cvtss_f32(low);
@@ -250,7 +250,7 @@ template<> EIGEN_DEVICE_FUNC inline void pscatter<float, Packet8f>(float* to, co
to[stride*6] = _mm_cvtss_f32(_mm_shuffle_ps(high, high, 2));
to[stride*7] = _mm_cvtss_f32(_mm_shuffle_ps(high, high, 3));
}
-template<> EIGEN_DEVICE_FUNC inline void pscatter<double, Packet4d>(double* to, const Packet4d& from, int stride)
+template<> EIGEN_DEVICE_FUNC inline void pscatter<double, Packet4d>(double* to, const Packet4d& from, DenseIndex stride)
{
__m128d low = _mm256_extractf128_pd(from, 0);
to[stride*0] = _mm_cvtsd_f64(low);
diff --git a/Eigen/src/Core/arch/AltiVec/Complex.h b/Eigen/src/Core/arch/AltiVec/Complex.h
index 5409ddedd..13b874d0c 100644
--- a/Eigen/src/Core/arch/AltiVec/Complex.h
+++ b/Eigen/src/Core/arch/AltiVec/Complex.h
@@ -16,13 +16,14 @@ namespace internal {
static Packet4ui p4ui_CONJ_XOR = vec_mergeh((Packet4ui)p4i_ZERO, (Packet4ui)p4f_ZERO_);//{ 0x00000000, 0x80000000, 0x00000000, 0x80000000 };
static Packet16uc p16uc_COMPLEX_RE = vec_sld((Packet16uc) vec_splat((Packet4ui)p16uc_FORWARD, 0), (Packet16uc) vec_splat((Packet4ui)p16uc_FORWARD, 2), 8);//{ 0,1,2,3, 0,1,2,3, 8,9,10,11, 8,9,10,11 };
-static Packet16uc p16uc_COMPLEX_IM = vec_sld((Packet16uc) vec_splat((Packet4ui)p16uc_FORWARD, 1), (Packet16uc) vec_splat((Packet4ui)p16uc_FORWARD, 3), 8);//{ 4,5,6,7, 4,5,6,7, 12,13,14,15, 12,13,14,15 };
+static Packet16uc p16uc_COMPLEX_IM = vec_sld(p16uc_DUPLICATE, (Packet16uc) vec_splat((Packet4ui)p16uc_FORWARD, 3), 8);//{ 4,5,6,7, 4,5,6,7, 12,13,14,15, 12,13,14,15 };
static Packet16uc p16uc_COMPLEX_REV = vec_sld(p16uc_REVERSE, p16uc_REVERSE, 8);//{ 4,5,6,7, 0,1,2,3, 12,13,14,15, 8,9,10,11 };
static Packet16uc p16uc_COMPLEX_REV2 = vec_sld(p16uc_FORWARD, p16uc_FORWARD, 8);//{ 8,9,10,11, 12,13,14,15, 0,1,2,3, 4,5,6,7 };
-static Packet16uc p16uc_PSET_HI = (Packet16uc) vec_mergeh((Packet4ui) vec_splat((Packet4ui)p16uc_FORWARD, 0), (Packet4ui) vec_splat((Packet4ui)p16uc_FORWARD, 1));//{ 0,1,2,3, 4,5,6,7, 0,1,2,3, 4,5,6,7 };
-static Packet16uc p16uc_PSET_LO = (Packet16uc) vec_mergeh((Packet4ui) vec_splat((Packet4ui)p16uc_FORWARD, 2), (Packet4ui) vec_splat((Packet4ui)p16uc_FORWARD, 3));//{ 8,9,10,11, 12,13,14,15, 8,9,10,11, 12,13,14,15 };
-static Packet16uc p16uc_COMPLEX_TRANSPOSE_0 = { 0,1,2,3, 4,5,6,7, 16,17,18,19, 20,21,22,23};
-static Packet16uc p16uc_COMPLEX_TRANSPOSE_1 = { 8,9,10,11, 12,13,14,15, 24,25,26,27, 28,29,30,31};
+static Packet16uc p16uc_PSET_HI = (Packet16uc) vec_mergeh((Packet4ui)p16uc_COMPLEX_RE, (Packet4ui)p16uc_COMPLEX_IM);//{ 0,1,2,3, 4,5,6,7, 0,1,2,3, 4,5,6,7 };
+static Packet16uc p16uc_PSET_LO = (Packet16uc) vec_mergel((Packet4ui)p16uc_COMPLEX_RE, (Packet4ui)p16uc_COMPLEX_IM);//{ 8,9,10,11, 12,13,14,15, 8,9,10,11, 12,13,14,15 };
+static Packet16uc p16uc_COMPLEX_MASK16 = vec_sld((Packet16uc)p4i_ZERO, vec_splat((Packet16uc) vec_abs(p4i_MINUS16), 3), 8);//{ 0,0,0,0, 0,0,0,0, 16,16,16,16, 16,16,16,16};
+static Packet16uc p16uc_COMPLEX_TRANSPOSE_0 = vec_add(p16uc_PSET_HI, p16uc_COMPLEX_MASK16);//{ 0,1,2,3, 4,5,6,7, 16,17,18,19, 20,21,22,23};
+static Packet16uc p16uc_COMPLEX_TRANSPOSE_1 = vec_add(p16uc_PSET_LO, p16uc_COMPLEX_MASK16);//{ 8,9,10,11, 12,13,14,15, 24,25,26,27, 28,29,30,31};
//---------- float ----------
struct Packet2cf
@@ -68,14 +69,14 @@ template<> EIGEN_STRONG_INLINE Packet2cf pset1<Packet2cf>(const std::complex<flo
return res;
}
-template<> EIGEN_DEVICE_FUNC inline Packet2cf pgather<std::complex<float>, Packet2cf>(const std::complex<float>* from, int stride)
+template<> EIGEN_DEVICE_FUNC inline Packet2cf pgather<std::complex<float>, Packet2cf>(const std::complex<float>* from, DenseIndex stride)
{
std::complex<float> EIGEN_ALIGN16 af[2];
af[0] = from[0*stride];
af[1] = from[1*stride];
return Packet2cf(vec_ld(0, (const float*)af));
}
-template<> EIGEN_DEVICE_FUNC inline void pscatter<std::complex<float>, Packet2cf>(std::complex<float>* to, const Packet2cf& from, int stride)
+template<> EIGEN_DEVICE_FUNC inline void pscatter<std::complex<float>, Packet2cf>(std::complex<float>* to, const Packet2cf& from, DenseIndex stride)
{
std::complex<float> EIGEN_ALIGN16 af[2];
vec_st(from.v, 0, (float*)af);
diff --git a/Eigen/src/Core/arch/AltiVec/PacketMath.h b/Eigen/src/Core/arch/AltiVec/PacketMath.h
index 0e9adf450..b43e8ace3 100755
--- a/Eigen/src/Core/arch/AltiVec/PacketMath.h
+++ b/Eigen/src/Core/arch/AltiVec/PacketMath.h
@@ -1,7 +1,7 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra.
//
-// Copyright (C) 2008 Konstantinos Margaritis <markos@codex.gr>
+// Copyright (C) 2008-2014 Konstantinos Margaritis <markos@freevec.org>
//
// 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
@@ -62,17 +62,17 @@ typedef __vector unsigned char Packet16uc;
// Define global static constants:
static Packet4f p4f_COUNTDOWN = { 0.0, 1.0, 2.0, 3.0 };
static Packet4i p4i_COUNTDOWN = { 0, 1, 2, 3 };
-static Packet16uc p16uc_REVERSE = {12,13,14,15, 8,9,10,11, 4,5,6,7, 0,1,2,3};
-static Packet16uc p16uc_FORWARD = vec_lvsl(0, (float*)0);
-static Packet16uc p16uc_DUPLICATE = {0,1,2,3, 0,1,2,3, 4,5,6,7, 4,5,6,7};
-
-static _EIGEN_DECLARE_CONST_FAST_Packet4f(ZERO, 0);
-static _EIGEN_DECLARE_CONST_FAST_Packet4i(ZERO, 0);
-static _EIGEN_DECLARE_CONST_FAST_Packet4i(ONE,1);
-static _EIGEN_DECLARE_CONST_FAST_Packet4i(MINUS16,-16);
-static _EIGEN_DECLARE_CONST_FAST_Packet4i(MINUS1,-1);
-static Packet4f p4f_ONE = vec_ctf(p4i_ONE, 0);
-static Packet4f p4f_ZERO_ = (Packet4f) vec_sl((Packet4ui)p4i_MINUS1, (Packet4ui)p4i_MINUS1);
+static Packet16uc p16uc_REVERSE = { 12,13,14,15, 8,9,10,11, 4,5,6,7, 0,1,2,3};
+static Packet16uc p16uc_FORWARD = vec_lvsl(0, (float*)0); //{ 0,1,2,3, 4,5,6,7, 8,9,10,11, 12,13,14,15}
+static Packet16uc p16uc_DUPLICATE = { 0,1,2,3, 0,1,2,3, 4,5,6,7, 4,5,6,7};
+
+static _EIGEN_DECLARE_CONST_FAST_Packet4f(ZERO, 0); //{ 0.0, 0.0, 0.0, 0.0}
+static _EIGEN_DECLARE_CONST_FAST_Packet4i(ZERO, 0); //{ 0, 0, 0, 0,}
+static _EIGEN_DECLARE_CONST_FAST_Packet4i(ONE,1); //{ 1, 1, 1, 1}
+static _EIGEN_DECLARE_CONST_FAST_Packet4i(MINUS16,-16); //{ -16, -16, -16, -16}
+static _EIGEN_DECLARE_CONST_FAST_Packet4i(MINUS1,-1); //{ -1, -1, -1, -1}
+static Packet4f p4f_ONE = vec_ctf(p4i_ONE, 0); //{ 1.0, 1.0, 1.0, 1.0}
+static Packet4f p4f_ZERO_ = (Packet4f) vec_sl((Packet4ui)p4i_MINUS1, (Packet4ui)p4i_MINUS1); //{ 0x80000000, 0x80000000, 0x80000000, 0x80000000}
template<> struct packet_traits<float> : default_packet_traits
{
@@ -82,8 +82,10 @@ template<> struct packet_traits<float> : default_packet_traits
Vectorizable = 1,
AlignedOnScalar = 1,
size=4,
+ HasHalfPacket=0,
// FIXME check the Has*
+ HasDiv = 1,
HasSin = 0,
HasCos = 0,
HasLog = 0,
@@ -190,7 +192,7 @@ pbroadcast4<Packet4i>(const int *a,
a3 = vec_splat(a3, 3);
}
-template<> EIGEN_DEVICE_FUNC inline Packet4f pgather<float, Packet4f>(const float* from, int stride)
+template<> EIGEN_DEVICE_FUNC inline Packet4f pgather<float, Packet4f>(const float* from, DenseIndex stride)
{
float EIGEN_ALIGN16 af[4];
af[0] = from[0*stride];
@@ -199,7 +201,7 @@ template<> EIGEN_DEVICE_FUNC inline Packet4f pgather<float, Packet4f>(const floa
af[3] = from[3*stride];
return vec_ld(0, af);
}
-template<> EIGEN_DEVICE_FUNC inline Packet4i pgather<int, Packet4i>(const int* from, int stride)
+template<> EIGEN_DEVICE_FUNC inline Packet4i pgather<int, Packet4i>(const int* from, DenseIndex stride)
{
int EIGEN_ALIGN16 ai[4];
ai[0] = from[0*stride];
@@ -208,7 +210,7 @@ template<> EIGEN_DEVICE_FUNC inline Packet4i pgather<int, Packet4i>(const int* f
ai[3] = from[3*stride];
return vec_ld(0, ai);
}
-template<> EIGEN_DEVICE_FUNC inline void pscatter<float, Packet4f>(float* to, const Packet4f& from, int stride)
+template<> EIGEN_DEVICE_FUNC inline void pscatter<float, Packet4f>(float* to, const Packet4f& from, DenseIndex stride)
{
float EIGEN_ALIGN16 af[4];
vec_st(from, 0, af);
@@ -217,7 +219,7 @@ template<> EIGEN_DEVICE_FUNC inline void pscatter<float, Packet4f>(float* to, co
to[2*stride] = af[2];
to[3*stride] = af[3];
}
-template<> EIGEN_DEVICE_FUNC inline void pscatter<int, Packet4i>(int* to, const Packet4i& from, int stride)
+template<> EIGEN_DEVICE_FUNC inline void pscatter<int, Packet4i>(int* to, const Packet4i& from, DenseIndex stride)
{
int EIGEN_ALIGN16 ai[4];
vec_st(from, 0, ai);
diff --git a/Eigen/src/Core/arch/NEON/Complex.h b/Eigen/src/Core/arch/NEON/Complex.h
index 259f2e7b8..42e7733d7 100644
--- a/Eigen/src/Core/arch/NEON/Complex.h
+++ b/Eigen/src/Core/arch/NEON/Complex.h
@@ -111,7 +111,7 @@ template<> EIGEN_STRONG_INLINE Packet2cf ploaddup<Packet2cf>(const std::complex<
template<> EIGEN_STRONG_INLINE void pstore <std::complex<float> >(std::complex<float> * to, const Packet2cf& from) { EIGEN_DEBUG_ALIGNED_STORE pstore((float*)to, from.v); }
template<> EIGEN_STRONG_INLINE void pstoreu<std::complex<float> >(std::complex<float> * to, const Packet2cf& from) { EIGEN_DEBUG_UNALIGNED_STORE pstoreu((float*)to, from.v); }
-template<> EIGEN_DEVICE_FUNC inline Packet2cf pgather<std::complex<float>, Packet2cf>(const std::complex<float>* from, int stride)
+template<> EIGEN_DEVICE_FUNC inline Packet2cf pgather<std::complex<float>, Packet2cf>(const std::complex<float>* from, DenseIndex stride)
{
Packet4f res;
res = vsetq_lane_f32(std::real(from[0*stride]), res, 0);
@@ -121,7 +121,7 @@ template<> EIGEN_DEVICE_FUNC inline Packet2cf pgather<std::complex<float>, Packe
return Packet2cf(res);
}
-template<> EIGEN_DEVICE_FUNC inline void pscatter<std::complex<float>, Packet2cf>(std::complex<float>* to, const Packet2cf& from, int stride)
+template<> EIGEN_DEVICE_FUNC inline void pscatter<std::complex<float>, Packet2cf>(std::complex<float>* to, const Packet2cf& from, DenseIndex stride)
{
to[stride*0] = std::complex<float>(vgetq_lane_f32(from.v, 0), vgetq_lane_f32(from.v, 1));
to[stride*1] = std::complex<float>(vgetq_lane_f32(from.v, 2), vgetq_lane_f32(from.v, 3));
diff --git a/Eigen/src/Core/arch/NEON/PacketMath.h b/Eigen/src/Core/arch/NEON/PacketMath.h
index e5eb06f36..380b76ae9 100644
--- a/Eigen/src/Core/arch/NEON/PacketMath.h
+++ b/Eigen/src/Core/arch/NEON/PacketMath.h
@@ -222,7 +222,7 @@ template<> EIGEN_STRONG_INLINE void pstore<int>(int* to, const Packet4i& f
template<> EIGEN_STRONG_INLINE void pstoreu<float>(float* to, const Packet4f& from) { EIGEN_DEBUG_UNALIGNED_STORE vst1q_f32(to, from); }
template<> EIGEN_STRONG_INLINE void pstoreu<int>(int* to, const Packet4i& from) { EIGEN_DEBUG_UNALIGNED_STORE vst1q_s32(to, from); }
-template<> EIGEN_DEVICE_FUNC inline Packet4f pgather<float, Packet4f>(const float* from, int stride)
+template<> EIGEN_DEVICE_FUNC inline Packet4f pgather<float, Packet4f>(const float* from, DenseIndex stride)
{
Packet4f res;
res = vsetq_lane_f32(from[0*stride], res, 0);
@@ -231,7 +231,7 @@ template<> EIGEN_DEVICE_FUNC inline Packet4f pgather<float, Packet4f>(const floa
res = vsetq_lane_f32(from[3*stride], res, 3);
return res;
}
-template<> EIGEN_DEVICE_FUNC inline Packet4i pgather<int, Packet4i>(const int* from, int stride)
+template<> EIGEN_DEVICE_FUNC inline Packet4i pgather<int, Packet4i>(const int* from, DenseIndex stride)
{
Packet4i res;
res = vsetq_lane_s32(from[0*stride], res, 0);
@@ -241,14 +241,14 @@ template<> EIGEN_DEVICE_FUNC inline Packet4i pgather<int, Packet4i>(const int* f
return res;
}
-template<> EIGEN_DEVICE_FUNC inline void pscatter<float, Packet4f>(float* to, const Packet4f& from, int stride)
+template<> EIGEN_DEVICE_FUNC inline void pscatter<float, Packet4f>(float* to, const Packet4f& from, DenseIndex stride)
{
to[stride*0] = vgetq_lane_f32(from, 0);
to[stride*1] = vgetq_lane_f32(from, 1);
to[stride*2] = vgetq_lane_f32(from, 2);
to[stride*3] = vgetq_lane_f32(from, 3);
}
-template<> EIGEN_DEVICE_FUNC inline void pscatter<int, Packet4i>(int* to, const Packet4i& from, int stride)
+template<> EIGEN_DEVICE_FUNC inline void pscatter<int, Packet4i>(int* to, const Packet4i& from, DenseIndex stride)
{
to[stride*0] = vgetq_lane_s32(from, 0);
to[stride*1] = vgetq_lane_s32(from, 1);
diff --git a/Eigen/src/Core/arch/SSE/Complex.h b/Eigen/src/Core/arch/SSE/Complex.h
index 0bc03cf9e..565e448fe 100644
--- a/Eigen/src/Core/arch/SSE/Complex.h
+++ b/Eigen/src/Core/arch/SSE/Complex.h
@@ -115,13 +115,13 @@ template<> EIGEN_STRONG_INLINE void pstore <std::complex<float> >(std::complex<f
template<> EIGEN_STRONG_INLINE void pstoreu<std::complex<float> >(std::complex<float> * to, const Packet2cf& from) { EIGEN_DEBUG_UNALIGNED_STORE pstoreu(&numext::real_ref(*to), Packet4f(from.v)); }
-template<> EIGEN_DEVICE_FUNC inline Packet2cf pgather<std::complex<float>, Packet2cf>(const std::complex<float>* from, int stride)
+template<> EIGEN_DEVICE_FUNC inline Packet2cf pgather<std::complex<float>, Packet2cf>(const std::complex<float>* from, DenseIndex stride)
{
return Packet2cf(_mm_set_ps(std::imag(from[1*stride]), std::real(from[1*stride]),
std::imag(from[0*stride]), std::real(from[0*stride])));
}
-template<> EIGEN_DEVICE_FUNC inline void pscatter<std::complex<float>, Packet2cf>(std::complex<float>* to, const Packet2cf& from, int stride)
+template<> EIGEN_DEVICE_FUNC inline void pscatter<std::complex<float>, Packet2cf>(std::complex<float>* to, const Packet2cf& from, DenseIndex stride)
{
to[stride*0] = std::complex<float>(_mm_cvtss_f32(_mm_shuffle_ps(from.v, from.v, 0)),
_mm_cvtss_f32(_mm_shuffle_ps(from.v, from.v, 1)));
diff --git a/Eigen/src/Core/arch/SSE/PacketMath.h b/Eigen/src/Core/arch/SSE/PacketMath.h
index 1124b24df..6923c88ec 100755
--- a/Eigen/src/Core/arch/SSE/PacketMath.h
+++ b/Eigen/src/Core/arch/SSE/PacketMath.h
@@ -387,32 +387,32 @@ template<> EIGEN_STRONG_INLINE void pstoreu<double>(double* to, const Packet2d&
template<> EIGEN_STRONG_INLINE void pstoreu<float>(float* to, const Packet4f& from) { EIGEN_DEBUG_UNALIGNED_STORE pstoreu(reinterpret_cast<double*>(to), Packet2d(_mm_castps_pd(from))); }
template<> EIGEN_STRONG_INLINE void pstoreu<int>(int* to, const Packet4i& from) { EIGEN_DEBUG_UNALIGNED_STORE pstoreu(reinterpret_cast<double*>(to), Packet2d(_mm_castsi128_pd(from))); }
-template<> EIGEN_DEVICE_FUNC inline Packet4f pgather<float, Packet4f>(const float* from, int stride)
+template<> EIGEN_DEVICE_FUNC inline Packet4f pgather<float, Packet4f>(const float* from, DenseIndex stride)
{
return _mm_set_ps(from[3*stride], from[2*stride], from[1*stride], from[0*stride]);
}
-template<> EIGEN_DEVICE_FUNC inline Packet2d pgather<double, Packet2d>(const double* from, int stride)
+template<> EIGEN_DEVICE_FUNC inline Packet2d pgather<double, Packet2d>(const double* from, DenseIndex stride)
{
return _mm_set_pd(from[1*stride], from[0*stride]);
}
-template<> EIGEN_DEVICE_FUNC inline Packet4i pgather<int, Packet4i>(const int* from, int stride)
+template<> EIGEN_DEVICE_FUNC inline Packet4i pgather<int, Packet4i>(const int* from, DenseIndex stride)
{
return _mm_set_epi32(from[3*stride], from[2*stride], from[1*stride], from[0*stride]);
}
-template<> EIGEN_DEVICE_FUNC inline void pscatter<float, Packet4f>(float* to, const Packet4f& from, int stride)
+template<> EIGEN_DEVICE_FUNC inline void pscatter<float, Packet4f>(float* to, const Packet4f& from, DenseIndex stride)
{
to[stride*0] = _mm_cvtss_f32(from);
to[stride*1] = _mm_cvtss_f32(_mm_shuffle_ps(from, from, 1));
to[stride*2] = _mm_cvtss_f32(_mm_shuffle_ps(from, from, 2));
to[stride*3] = _mm_cvtss_f32(_mm_shuffle_ps(from, from, 3));
}
-template<> EIGEN_DEVICE_FUNC inline void pscatter<double, Packet2d>(double* to, const Packet2d& from, int stride)
+template<> EIGEN_DEVICE_FUNC inline void pscatter<double, Packet2d>(double* to, const Packet2d& from, DenseIndex stride)
{
to[stride*0] = _mm_cvtsd_f64(from);
to[stride*1] = _mm_cvtsd_f64(_mm_shuffle_pd(from, from, 1));
}
-template<> EIGEN_DEVICE_FUNC inline void pscatter<int, Packet4i>(int* to, const Packet4i& from, int stride)
+template<> EIGEN_DEVICE_FUNC inline void pscatter<int, Packet4i>(int* to, const Packet4i& from, DenseIndex stride)
{
to[stride*0] = _mm_cvtsi128_si32(from);
to[stride*1] = _mm_cvtsi128_si32(_mm_shuffle_epi32(from, 1));
diff --git a/Eigen/src/Core/functors/NullaryFunctors.h b/Eigen/src/Core/functors/NullaryFunctors.h
index 950acd93b..be03fbf52 100644
--- a/Eigen/src/Core/functors/NullaryFunctors.h
+++ b/Eigen/src/Core/functors/NullaryFunctors.h
@@ -92,7 +92,7 @@ struct linspaced_op_impl<Scalar,true>
template<typename Index>
EIGEN_STRONG_INLINE const Packet packetOp(Index i) const
- { return internal::padd(m_lowPacket, pmul(m_stepPacket, padd(pset1<Packet>(i),m_interPacket))); }
+ { return internal::padd(m_lowPacket, pmul(m_stepPacket, padd(pset1<Packet>(Scalar(i)),m_interPacket))); }
const Scalar m_low;
const Scalar m_step;
@@ -112,7 +112,7 @@ template <typename Scalar, bool RandomAccess> struct functor_traits< linspaced_o
template <typename Scalar, bool RandomAccess> struct linspaced_op
{
typedef typename packet_traits<Scalar>::type Packet;
- linspaced_op(const Scalar& low, const Scalar& high, DenseIndex num_steps) : impl((num_steps==1 ? high : low), (num_steps==1 ? Scalar() : (high-low)/(num_steps-1))) {}
+ linspaced_op(const Scalar& low, const Scalar& high, DenseIndex num_steps) : impl((num_steps==1 ? high : low), (num_steps==1 ? Scalar() : (high-low)/Scalar(num_steps-1))) {}
template<typename Index>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator() (Index i) const { return impl(i); }
diff --git a/Eigen/src/Core/functors/UnaryFunctors.h b/Eigen/src/Core/functors/UnaryFunctors.h
index a0fcea3f9..ec42e6850 100644
--- a/Eigen/src/Core/functors/UnaryFunctors.h
+++ b/Eigen/src/Core/functors/UnaryFunctors.h
@@ -320,6 +320,26 @@ struct functor_traits<scalar_asin_op<Scalar> >
};
};
+
+/** \internal
+ * \brief Template functor to compute the atan of a scalar
+ * \sa class CwiseUnaryOp, ArrayBase::atan()
+ */
+template<typename Scalar> struct scalar_atan_op {
+ EIGEN_EMPTY_STRUCT_CTOR(scalar_atan_op)
+ inline const Scalar operator() (const Scalar& a) const { using std::atan; return atan(a); }
+ typedef typename packet_traits<Scalar>::type Packet;
+ inline Packet packetOp(const Packet& a) const { return internal::patan(a); }
+};
+template<typename Scalar>
+struct functor_traits<scalar_atan_op<Scalar> >
+{
+ enum {
+ Cost = 5 * NumTraits<Scalar>::MulCost,
+ PacketAccess = packet_traits<Scalar>::HasATan
+ };
+};
+
/** \internal
* \brief Template functor to compute the inverse of a scalar
* \sa class CwiseUnaryOp, Cwise::inverse()
diff --git a/Eigen/src/Core/products/SelfadjointMatrixVector.h b/Eigen/src/Core/products/SelfadjointMatrixVector.h
index fdc81205a..26e787949 100644
--- a/Eigen/src/Core/products/SelfadjointMatrixVector.h
+++ b/Eigen/src/Core/products/SelfadjointMatrixVector.h
@@ -218,7 +218,7 @@ struct SelfadjointProductMatrix<Lhs,LhsMode,false,Rhs,0,true>
if(!EvalToDest)
{
#ifdef EIGEN_DENSE_STORAGE_CTOR_PLUGIN
- int size = dest.size();
+ Index size = dest.size();
EIGEN_DENSE_STORAGE_CTOR_PLUGIN
#endif
MappedDest(actualDestPtr, dest.size()) = dest;
@@ -227,7 +227,7 @@ struct SelfadjointProductMatrix<Lhs,LhsMode,false,Rhs,0,true>
if(!UseRhs)
{
#ifdef EIGEN_DENSE_STORAGE_CTOR_PLUGIN
- int size = rhs.size();
+ Index size = rhs.size();
EIGEN_DENSE_STORAGE_CTOR_PLUGIN
#endif
Map<typename _ActualRhsType::PlainObject>(actualRhsPtr, rhs.size()) = rhs;
diff --git a/Eigen/src/Core/products/TriangularMatrixVector.h b/Eigen/src/Core/products/TriangularMatrixVector.h
index 6117d5a82..817768481 100644
--- a/Eigen/src/Core/products/TriangularMatrixVector.h
+++ b/Eigen/src/Core/products/TriangularMatrixVector.h
@@ -322,7 +322,7 @@ template<> struct trmv_selector<RowMajor>
if(!DirectlyUseRhs)
{
#ifdef EIGEN_DENSE_STORAGE_CTOR_PLUGIN
- int size = actualRhs.size();
+ Index size = actualRhs.size();
EIGEN_DENSE_STORAGE_CTOR_PLUGIN
#endif
Map<typename _ActualRhsType::PlainObject>(actualRhsPtr, actualRhs.size()) = actualRhs;
diff --git a/Eigen/src/Core/products/TriangularMatrixVector_MKL.h b/Eigen/src/Core/products/TriangularMatrixVector_MKL.h
index 09f110da7..3672b1240 100644
--- a/Eigen/src/Core/products/TriangularMatrixVector_MKL.h
+++ b/Eigen/src/Core/products/TriangularMatrixVector_MKL.h
@@ -129,7 +129,6 @@ struct triangular_matrix_vector_product_trmv<Index,Mode,EIGTYPE,ConjLhs,EIGTYPE,
MKLPREFIX##axpy(&n, &alpha_,(const MKLTYPE*)x, &incx, (MKLTYPE*)_res, &incy); \
/* Non-square case - doesn't fit to MKL ?TRMV. Fall to default triangular product*/ \
if (size<(std::max)(rows,cols)) { \
- typedef Matrix<EIGTYPE, Dynamic, Dynamic> MatrixLhs; \
if (ConjRhs) x_tmp = rhs.conjugate(); else x_tmp = rhs; \
x = x_tmp.data(); \
if (size<rows) { \
@@ -214,7 +213,6 @@ struct triangular_matrix_vector_product_trmv<Index,Mode,EIGTYPE,ConjLhs,EIGTYPE,
MKLPREFIX##axpy(&n, &alpha_,(const MKLTYPE*)x, &incx, (MKLTYPE*)_res, &incy); \
/* Non-square case - doesn't fit to MKL ?TRMV. Fall to default triangular product*/ \
if (size<(std::max)(rows,cols)) { \
- typedef Matrix<EIGTYPE, Dynamic, Dynamic> MatrixLhs; \
if (ConjRhs) x_tmp = rhs.conjugate(); else x_tmp = rhs; \
x = x_tmp.data(); \
if (size<rows) { \
diff --git a/Eigen/src/Core/util/ForwardDeclarations.h b/Eigen/src/Core/util/ForwardDeclarations.h
index 0a2144c69..33deb88ec 100644
--- a/Eigen/src/Core/util/ForwardDeclarations.h
+++ b/Eigen/src/Core/util/ForwardDeclarations.h
@@ -236,35 +236,12 @@ template<typename Scalar> class Rotation2D;
template<typename Scalar> class AngleAxis;
template<typename Scalar,int Dim> class Translation;
-#ifdef EIGEN2_SUPPORT
-template<typename Derived, int _Dim> class eigen2_RotationBase;
-template<typename Lhs, typename Rhs> class eigen2_Cross;
-template<typename Scalar> class eigen2_Quaternion;
-template<typename Scalar> class eigen2_Rotation2D;
-template<typename Scalar> class eigen2_AngleAxis;
-template<typename Scalar,int Dim> class eigen2_Transform;
-template <typename _Scalar, int _AmbientDim> class eigen2_ParametrizedLine;
-template <typename _Scalar, int _AmbientDim> class eigen2_Hyperplane;
-template<typename Scalar,int Dim> class eigen2_Translation;
-template<typename Scalar,int Dim> class eigen2_Scaling;
-#endif
-
-#if EIGEN2_SUPPORT_STAGE < STAGE20_RESOLVE_API_CONFLICTS
-template<typename Scalar> class Quaternion;
-template<typename Scalar,int Dim> class Transform;
-template <typename _Scalar, int _AmbientDim> class ParametrizedLine;
-template <typename _Scalar, int _AmbientDim> class Hyperplane;
-template<typename Scalar,int Dim> class Scaling;
-#endif
-
-#if EIGEN2_SUPPORT_STAGE > STAGE20_RESOLVE_API_CONFLICTS
template<typename Scalar, int Options = AutoAlign> class Quaternion;
template<typename Scalar,int Dim,int Mode,int _Options=AutoAlign> class Transform;
template <typename _Scalar, int _AmbientDim, int Options=AutoAlign> class ParametrizedLine;
template <typename _Scalar, int _AmbientDim, int Options=AutoAlign> class Hyperplane;
template<typename Scalar> class UniformScaling;
template<typename MatrixType,int Direction> class Homogeneous;
-#endif
// MatrixFunctions module
template<typename Derived> struct MatrixExponentialReturnValue;
@@ -283,18 +260,6 @@ struct stem_function
};
}
-
-#ifdef EIGEN2_SUPPORT
-template<typename ExpressionType> class Cwise;
-template<typename MatrixType> class Minor;
-template<typename MatrixType> class LU;
-template<typename MatrixType> class QR;
-template<typename MatrixType> class SVD;
-namespace internal {
-template<typename MatrixType, unsigned int Mode> struct eigen2_part_return_type;
-}
-#endif
-
} // end namespace Eigen
#endif // EIGEN_FORWARDDECLARATIONS_H
diff --git a/Eigen/src/Core/util/Macros.h b/Eigen/src/Core/util/Macros.h
index b1c01c02a..c80aa5129 100644
--- a/Eigen/src/Core/util/Macros.h
+++ b/Eigen/src/Core/util/Macros.h
@@ -457,4 +457,16 @@ namespace Eigen {
const RHS \
>
+#ifdef EIGEN_EXCEPTIONS
+# define EIGEN_THROW_X(X) throw X
+# define EIGEN_THROW throw
+# define EIGEN_TRY try
+# define EIGEN_CATCH(X) catch (X)
+#else
+# define EIGEN_THROW_X(X) std::abort()
+# define EIGEN_THROW std::abort()
+# define EIGEN_TRY if (true)
+# define EIGEN_CATCH(X) else
+#endif
+
#endif // EIGEN_MACROS_H
diff --git a/Eigen/src/Core/util/Memory.h b/Eigen/src/Core/util/Memory.h
index 390b60c74..810ee786b 100644
--- a/Eigen/src/Core/util/Memory.h
+++ b/Eigen/src/Core/util/Memory.h
@@ -338,15 +338,6 @@ template<> inline void* conditional_aligned_realloc<false>(void* ptr, size_t new
*** Construction/destruction of array elements ***
*****************************************************************************/
-/** \internal Constructs the elements of an array.
- * The \a size parameter tells on how many objects to call the constructor of T.
- */
-template<typename T> inline T* construct_elements_of_array(T *ptr, size_t size)
-{
- for (size_t i=0; i < size; ++i) ::new (ptr + i) T;
- return ptr;
-}
-
/** \internal Destructs the elements of an array.
* The \a size parameters tells on how many objects to call the destructor of T.
*/
@@ -357,6 +348,24 @@ template<typename T> inline void destruct_elements_of_array(T *ptr, size_t size)
while(size) ptr[--size].~T();
}
+/** \internal Constructs the elements of an array.
+ * The \a size parameter tells on how many objects to call the constructor of T.
+ */
+template<typename T> inline T* construct_elements_of_array(T *ptr, size_t size)
+{
+ size_t i;
+ EIGEN_TRY
+ {
+ for (i = 0; i < size; ++i) ::new (ptr + i) T;
+ return ptr;
+ }
+ EIGEN_CATCH(...)
+ {
+ destruct_elements_of_array(ptr, i);
+ EIGEN_THROW;
+ }
+}
+
/*****************************************************************************
*** Implementation of aligned new/delete-like functions ***
*****************************************************************************/
@@ -376,14 +385,30 @@ template<typename T> inline T* aligned_new(size_t size)
{
check_size_for_overflow<T>(size);
T *result = reinterpret_cast<T*>(aligned_malloc(sizeof(T)*size));
- return construct_elements_of_array(result, size);
+ EIGEN_TRY
+ {
+ return construct_elements_of_array(result, size);
+ }
+ EIGEN_CATCH(...)
+ {
+ aligned_free(result);
+ EIGEN_THROW;
+ }
}
template<typename T, bool Align> inline T* conditional_aligned_new(size_t size)
{
check_size_for_overflow<T>(size);
T *result = reinterpret_cast<T*>(conditional_aligned_malloc<Align>(sizeof(T)*size));
- return construct_elements_of_array(result, size);
+ EIGEN_TRY
+ {
+ return construct_elements_of_array(result, size);
+ }
+ EIGEN_CATCH(...)
+ {
+ conditional_aligned_free<Align>(result);
+ EIGEN_THROW;
+ }
}
/** \internal Deletes objects constructed with aligned_new
@@ -412,7 +437,17 @@ template<typename T, bool Align> inline T* conditional_aligned_realloc_new(T* pt
destruct_elements_of_array(pts+new_size, old_size-new_size);
T *result = reinterpret_cast<T*>(conditional_aligned_realloc<Align>(reinterpret_cast<void*>(pts), sizeof(T)*new_size, sizeof(T)*old_size));
if(new_size > old_size)
- construct_elements_of_array(result+old_size, new_size-old_size);
+ {
+ EIGEN_TRY
+ {
+ construct_elements_of_array(result+old_size, new_size-old_size);
+ }
+ EIGEN_CATCH(...)
+ {
+ conditional_aligned_free<Align>(result);
+ EIGEN_THROW;
+ }
+ }
return result;
}
@@ -422,7 +457,17 @@ template<typename T, bool Align> inline T* conditional_aligned_new_auto(size_t s
check_size_for_overflow<T>(size);
T *result = reinterpret_cast<T*>(conditional_aligned_malloc<Align>(sizeof(T)*size));
if(NumTraits<T>::RequireInitialization)
- construct_elements_of_array(result, size);
+ {
+ EIGEN_TRY
+ {
+ construct_elements_of_array(result, size);
+ }
+ EIGEN_CATCH(...)
+ {
+ conditional_aligned_free<Align>(result);
+ EIGEN_THROW;
+ }
+ }
return result;
}
@@ -434,7 +479,17 @@ template<typename T, bool Align> inline T* conditional_aligned_realloc_new_auto(
destruct_elements_of_array(pts+new_size, old_size-new_size);
T *result = reinterpret_cast<T*>(conditional_aligned_realloc<Align>(reinterpret_cast<void*>(pts), sizeof(T)*new_size, sizeof(T)*old_size));
if(NumTraits<T>::RequireInitialization && (new_size > old_size))
- construct_elements_of_array(result+old_size, new_size-old_size);
+ {
+ EIGEN_TRY
+ {
+ construct_elements_of_array(result+old_size, new_size-old_size);
+ }
+ EIGEN_CATCH(...)
+ {
+ conditional_aligned_free<Align>(result);
+ EIGEN_THROW;
+ }
+ }
return result;
}
@@ -552,7 +607,7 @@ template<typename T> struct smart_memmove_helper<T,false> {
// you can overwrite Eigen's default behavior regarding alloca by defining EIGEN_ALLOCA
// to the appropriate stack allocation function
#ifndef EIGEN_ALLOCA
- #if (defined __linux__) || (defined __APPLE__)
+ #if (defined __linux__) || (defined __APPLE__) || (defined alloca)
#define EIGEN_ALLOCA alloca
#elif defined(_MSC_VER)
#define EIGEN_ALLOCA _alloca
@@ -607,12 +662,9 @@ template<typename T> class aligned_stack_memory_handler
* The underlying stack allocation function can controlled with the EIGEN_ALLOCA preprocessor token.
*/
#ifdef EIGEN_ALLOCA
- // The native alloca() that comes with llvm aligns buffer on 16 bytes even when AVX is enabled.
-#if defined(__arm__) || defined(_WIN32) || EIGEN_ALIGN_BYTES > 16
- #define EIGEN_ALIGNED_ALLOCA(SIZE) reinterpret_cast<void*>((reinterpret_cast<size_t>(EIGEN_ALLOCA(SIZE+EIGEN_ALIGN_BYTES)) & ~(size_t(EIGEN_ALIGN_BYTES-1))) + EIGEN_ALIGN_BYTES)
- #else
- #define EIGEN_ALIGNED_ALLOCA EIGEN_ALLOCA
- #endif
+ // We always manually re-align the result of EIGEN_ALLOCA.
+ // If alloca is already aligned, the compiler should be smart enough to optimize away the re-alignment.
+ #define EIGEN_ALIGNED_ALLOCA(SIZE) reinterpret_cast<void*>((reinterpret_cast<size_t>(EIGEN_ALLOCA(SIZE+EIGEN_ALIGN_BYTES-1)) + EIGEN_ALIGN_BYTES-1) & ~(size_t(EIGEN_ALIGN_BYTES-1)))
#define ei_declare_aligned_stack_constructed_variable(TYPE,NAME,SIZE,BUFFER) \
Eigen::internal::check_size_for_overflow<TYPE>(SIZE); \
@@ -637,20 +689,11 @@ template<typename T> class aligned_stack_memory_handler
*****************************************************************************/
#if EIGEN_ALIGN
- #ifdef EIGEN_EXCEPTIONS
- #define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_NOTHROW(NeedsToAlign) \
+ #define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_NOTHROW(NeedsToAlign) \
void* operator new(size_t size, const std::nothrow_t&) throw() { \
- try { return Eigen::internal::conditional_aligned_malloc<NeedsToAlign>(size); } \
- catch (...) { return 0; } \
- return 0; \
+ EIGEN_TRY { return Eigen::internal::conditional_aligned_malloc<NeedsToAlign>(size); } \
+ EIGEN_CATCH (...) { return 0; } \
}
- #else
- #define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_NOTHROW(NeedsToAlign) \
- void* operator new(size_t size, const std::nothrow_t&) throw() { \
- return Eigen::internal::conditional_aligned_malloc<NeedsToAlign>(size); \
- }
- #endif
-
#define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(NeedsToAlign) \
void *operator new(size_t size) { \
return Eigen::internal::conditional_aligned_malloc<NeedsToAlign>(size); \
@@ -660,6 +703,8 @@ template<typename T> class aligned_stack_memory_handler
} \
void operator delete(void * ptr) throw() { Eigen::internal::conditional_aligned_free<NeedsToAlign>(ptr); } \
void operator delete[](void * ptr) throw() { Eigen::internal::conditional_aligned_free<NeedsToAlign>(ptr); } \
+ void operator delete(void * ptr, std::size_t /* sz */) throw() { Eigen::internal::conditional_aligned_free<NeedsToAlign>(ptr); } \
+ void operator delete[](void * ptr, std::size_t /* sz */) throw() { Eigen::internal::conditional_aligned_free<NeedsToAlign>(ptr); } \
/* in-place new and delete. since (at least afaik) there is no actual */ \
/* memory allocated we can safely let the default implementation handle */ \
/* this particular case. */ \
diff --git a/Eigen/src/Core/util/Meta.h b/Eigen/src/Core/util/Meta.h
index e4e4d4a87..b99b8849e 100644
--- a/Eigen/src/Core/util/Meta.h
+++ b/Eigen/src/Core/util/Meta.h
@@ -80,6 +80,34 @@ template<typename T> struct add_const_on_value_type<T*> { typedef T const
template<typename T> struct add_const_on_value_type<T* const> { typedef T const* const type; };
template<typename T> struct add_const_on_value_type<T const* const> { typedef T const* const type; };
+
+template<typename From, typename To>
+struct is_convertible_impl
+{
+private:
+ struct any_conversion
+ {
+ template <typename T> any_conversion(const volatile T&);
+ template <typename T> any_conversion(T&);
+ };
+ struct yes {int a[1];};
+ struct no {int a[2];};
+
+ static yes test(const To&, int);
+ static no test(any_conversion, ...);
+
+public:
+ static From ms_from;
+ enum { value = sizeof(test(ms_from, 0))==sizeof(yes) };
+};
+
+template<typename From, typename To>
+struct is_convertible
+{
+ enum { value = is_convertible_impl<typename remove_all<From>::type,
+ typename remove_all<To >::type>::value };
+};
+
/** \internal Allows to enable/disable an overload
* according to a compile time condition.
*/
diff --git a/Eigen/src/Core/util/StaticAssert.h b/Eigen/src/Core/util/StaticAssert.h
index 8872c5b64..59aa0811c 100644
--- a/Eigen/src/Core/util/StaticAssert.h
+++ b/Eigen/src/Core/util/StaticAssert.h
@@ -107,9 +107,9 @@
{Eigen::internal::static_assertion<bool(CONDITION)>::MSG;}
#else
-
+ // In some cases clang interprets bool(CONDITION) as function declaration
#define EIGEN_STATIC_ASSERT(CONDITION,MSG) \
- if (Eigen::internal::static_assertion<bool(CONDITION)>::MSG) {}
+ if (Eigen::internal::static_assertion<static_cast<bool>(CONDITION)>::MSG) {}
#endif
@@ -168,13 +168,8 @@
) \
)
-#ifdef EIGEN2_SUPPORT
- #define EIGEN_STATIC_ASSERT_NON_INTEGER(TYPE) \
- eigen_assert(!NumTraits<Scalar>::IsInteger);
-#else
- #define EIGEN_STATIC_ASSERT_NON_INTEGER(TYPE) \
+#define EIGEN_STATIC_ASSERT_NON_INTEGER(TYPE) \
EIGEN_STATIC_ASSERT(!NumTraits<TYPE>::IsInteger, THIS_FUNCTION_IS_NOT_FOR_INTEGER_NUMERIC_TYPES)
-#endif
// static assertion failing if it is guaranteed at compile-time that the two matrix expression types have different sizes
diff --git a/Eigen/src/Eigen2Support/Block.h b/Eigen/src/Eigen2Support/Block.h
deleted file mode 100644
index 604456f40..000000000
--- a/Eigen/src/Eigen2Support/Block.h
+++ /dev/null
@@ -1,126 +0,0 @@
-// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra.
-//
-// Copyright (C) 2008-2009 Gael Guennebaud <gael.guennebaud@inria.fr>
-// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
-//
-// 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/.
-
-#ifndef EIGEN_BLOCK2_H
-#define EIGEN_BLOCK2_H
-
-namespace Eigen {
-
-/** \returns a dynamic-size expression of a corner of *this.
- *
- * \param type the type of corner. Can be \a Eigen::TopLeft, \a Eigen::TopRight,
- * \a Eigen::BottomLeft, \a Eigen::BottomRight.
- * \param cRows the number of rows in the corner
- * \param cCols the number of columns in the corner
- *
- * Example: \include MatrixBase_corner_enum_int_int.cpp
- * Output: \verbinclude MatrixBase_corner_enum_int_int.out
- *
- * \note Even though the returned expression has dynamic size, in the case
- * when it is applied to a fixed-size matrix, it inherits a fixed maximal size,
- * which means that evaluating it does not cause a dynamic memory allocation.
- *
- * \sa class Block, block(Index,Index,Index,Index)
- */
-template<typename Derived>
-inline Block<Derived> DenseBase<Derived>
- ::corner(CornerType type, Index cRows, Index cCols)
-{
- switch(type)
- {
- default:
- eigen_assert(false && "Bad corner type.");
- case TopLeft:
- return Block<Derived>(derived(), 0, 0, cRows, cCols);
- case TopRight:
- return Block<Derived>(derived(), 0, cols() - cCols, cRows, cCols);
- case BottomLeft:
- return Block<Derived>(derived(), rows() - cRows, 0, cRows, cCols);
- case BottomRight:
- return Block<Derived>(derived(), rows() - cRows, cols() - cCols, cRows, cCols);
- }
-}
-
-/** This is the const version of corner(CornerType, Index, Index).*/
-template<typename Derived>
-inline const Block<Derived>
-DenseBase<Derived>::corner(CornerType type, Index cRows, Index cCols) const
-{
- switch(type)
- {
- default:
- eigen_assert(false && "Bad corner type.");
- case TopLeft:
- return Block<Derived>(derived(), 0, 0, cRows, cCols);
- case TopRight:
- return Block<Derived>(derived(), 0, cols() - cCols, cRows, cCols);
- case BottomLeft:
- return Block<Derived>(derived(), rows() - cRows, 0, cRows, cCols);
- case BottomRight:
- return Block<Derived>(derived(), rows() - cRows, cols() - cCols, cRows, cCols);
- }
-}
-
-/** \returns a fixed-size expression of a corner of *this.
- *
- * \param type the type of corner. Can be \a Eigen::TopLeft, \a Eigen::TopRight,
- * \a Eigen::BottomLeft, \a Eigen::BottomRight.
- *
- * The template parameters CRows and CCols arethe number of rows and columns in the corner.
- *
- * Example: \include MatrixBase_template_int_int_corner_enum.cpp
- * Output: \verbinclude MatrixBase_template_int_int_corner_enum.out
- *
- * \sa class Block, block(Index,Index,Index,Index)
- */
-template<typename Derived>
-template<int CRows, int CCols>
-inline Block<Derived, CRows, CCols>
-DenseBase<Derived>::corner(CornerType type)
-{
- switch(type)
- {
- default:
- eigen_assert(false && "Bad corner type.");
- case TopLeft:
- return Block<Derived, CRows, CCols>(derived(), 0, 0);
- case TopRight:
- return Block<Derived, CRows, CCols>(derived(), 0, cols() - CCols);
- case BottomLeft:
- return Block<Derived, CRows, CCols>(derived(), rows() - CRows, 0);
- case BottomRight:
- return Block<Derived, CRows, CCols>(derived(), rows() - CRows, cols() - CCols);
- }
-}
-
-/** This is the const version of corner<int, int>(CornerType).*/
-template<typename Derived>
-template<int CRows, int CCols>
-inline const Block<Derived, CRows, CCols>
-DenseBase<Derived>::corner(CornerType type) const
-{
- switch(type)
- {
- default:
- eigen_assert(false && "Bad corner type.");
- case TopLeft:
- return Block<Derived, CRows, CCols>(derived(), 0, 0);
- case TopRight:
- return Block<Derived, CRows, CCols>(derived(), 0, cols() - CCols);
- case BottomLeft:
- return Block<Derived, CRows, CCols>(derived(), rows() - CRows, 0);
- case BottomRight:
- return Block<Derived, CRows, CCols>(derived(), rows() - CRows, cols() - CCols);
- }
-}
-
-} // end namespace Eigen
-
-#endif // EIGEN_BLOCK2_H
diff --git a/Eigen/src/Eigen2Support/CMakeLists.txt b/Eigen/src/Eigen2Support/CMakeLists.txt
deleted file mode 100644
index 7ae41b3cb..000000000
--- a/Eigen/src/Eigen2Support/CMakeLists.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-FILE(GLOB Eigen_Eigen2Support_SRCS "*.h")
-
-INSTALL(FILES
- ${Eigen_Eigen2Support_SRCS}
- DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Eigen2Support COMPONENT Devel
- )
-
-ADD_SUBDIRECTORY(Geometry) \ No newline at end of file
diff --git a/Eigen/src/Eigen2Support/Cwise.h b/Eigen/src/Eigen2Support/Cwise.h
deleted file mode 100644
index d95009b6e..000000000
--- a/Eigen/src/Eigen2Support/Cwise.h
+++ /dev/null
@@ -1,192 +0,0 @@
-// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra.
-//
-// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
-// Copyright (C) 2008 Benoit Jacob <jacob.benoit.1@gmail.com>
-//
-// 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/.
-
-#ifndef EIGEN_CWISE_H
-#define EIGEN_CWISE_H
-
-namespace Eigen {
-
-/** \internal
- * convenient macro to defined the return type of a cwise binary operation */
-#define EIGEN_CWISE_BINOP_RETURN_TYPE(OP) \
- CwiseBinaryOp<OP<typename internal::traits<ExpressionType>::Scalar>, ExpressionType, OtherDerived>
-
-/** \internal
- * convenient macro to defined the return type of a cwise unary operation */
-#define EIGEN_CWISE_UNOP_RETURN_TYPE(OP) \
- CwiseUnaryOp<OP<typename internal::traits<ExpressionType>::Scalar>, ExpressionType>
-
-/** \internal
- * convenient macro to defined the return type of a cwise comparison to a scalar */
-#define EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(OP) \
- CwiseBinaryOp<OP<typename internal::traits<ExpressionType>::Scalar>, ExpressionType, \
- typename ExpressionType::ConstantReturnType >
-
-/** \class Cwise
- *
- * \brief Pseudo expression providing additional coefficient-wise operations
- *
- * \param ExpressionType the type of the object on which to do coefficient-wise operations
- *
- * This class represents an expression with additional coefficient-wise features.
- * It is the return type of MatrixBase::cwise()
- * and most of the time this is the only way it is used.
- *
- * Example: \include MatrixBase_cwise_const.cpp
- * Output: \verbinclude MatrixBase_cwise_const.out
- *
- * This class can be extended with the help of the plugin mechanism described on the page
- * \ref TopicCustomizingEigen by defining the preprocessor symbol \c EIGEN_CWISE_PLUGIN.
- *
- * \sa MatrixBase::cwise() const, MatrixBase::cwise()
- */
-template<typename ExpressionType> class Cwise
-{
- public:
-
- typedef typename internal::traits<ExpressionType>::Scalar Scalar;
- typedef typename internal::conditional<internal::must_nest_by_value<ExpressionType>::ret,
- ExpressionType, const ExpressionType&>::type ExpressionTypeNested;
- typedef CwiseUnaryOp<internal::scalar_add_op<Scalar>, ExpressionType> ScalarAddReturnType;
-
- inline Cwise(const ExpressionType& matrix) : m_matrix(matrix) {}
-
- /** \internal */
- inline const ExpressionType& _expression() const { return m_matrix; }
-
- template<typename OtherDerived>
- const EIGEN_CWISE_PRODUCT_RETURN_TYPE(ExpressionType,OtherDerived)
- operator*(const MatrixBase<OtherDerived> &other) const;
-
- template<typename OtherDerived>
- const EIGEN_CWISE_BINOP_RETURN_TYPE(internal::scalar_quotient_op)
- operator/(const MatrixBase<OtherDerived> &other) const;
-
- /** \deprecated ArrayBase::min() */
- template<typename OtherDerived>
- const EIGEN_CWISE_BINOP_RETURN_TYPE(internal::scalar_min_op)
- (min)(const MatrixBase<OtherDerived> &other) const
- { return EIGEN_CWISE_BINOP_RETURN_TYPE(internal::scalar_min_op)(_expression(), other.derived()); }
-
- /** \deprecated ArrayBase::max() */
- template<typename OtherDerived>
- const EIGEN_CWISE_BINOP_RETURN_TYPE(internal::scalar_max_op)
- (max)(const MatrixBase<OtherDerived> &other) const
- { return EIGEN_CWISE_BINOP_RETURN_TYPE(internal::scalar_max_op)(_expression(), other.derived()); }
-
- const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_abs_op) abs() const;
- const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_abs2_op) abs2() const;
- const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_square_op) square() const;
- const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_cube_op) cube() const;
- const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_inverse_op) inverse() const;
- const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_sqrt_op) sqrt() const;
- const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_exp_op) exp() const;
- const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_log_op) log() const;
- const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_cos_op) cos() const;
- const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_sin_op) sin() const;
- const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_pow_op) pow(const Scalar& exponent) const;
-
- const ScalarAddReturnType
- operator+(const Scalar& scalar) const;
-
- /** \relates Cwise */
- friend const ScalarAddReturnType
- operator+(const Scalar& scalar, const Cwise& mat)
- { return mat + scalar; }
-
- ExpressionType& operator+=(const Scalar& scalar);
-
- const ScalarAddReturnType
- operator-(const Scalar& scalar) const;
-
- ExpressionType& operator-=(const Scalar& scalar);
-
- template<typename OtherDerived>
- inline ExpressionType& operator*=(const MatrixBase<OtherDerived> &other);
-
- template<typename OtherDerived>
- inline ExpressionType& operator/=(const MatrixBase<OtherDerived> &other);
-
- template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less)
- operator<(const MatrixBase<OtherDerived>& other) const;
-
- template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less_equal)
- operator<=(const MatrixBase<OtherDerived>& other) const;
-
- template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater)
- operator>(const MatrixBase<OtherDerived>& other) const;
-
- template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater_equal)
- operator>=(const MatrixBase<OtherDerived>& other) const;
-
- template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::equal_to)
- operator==(const MatrixBase<OtherDerived>& other) const;
-
- template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::not_equal_to)
- operator!=(const MatrixBase<OtherDerived>& other) const;
-
- // comparisons to a scalar value
- const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less)
- operator<(Scalar s) const;
-
- const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less_equal)
- operator<=(Scalar s) const;
-
- const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater)
- operator>(Scalar s) const;
-
- const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater_equal)
- operator>=(Scalar s) const;
-
- const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::equal_to)
- operator==(Scalar s) const;
-
- const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::not_equal_to)
- operator!=(Scalar s) const;
-
- // allow to extend Cwise outside Eigen
- #ifdef EIGEN_CWISE_PLUGIN
- #include EIGEN_CWISE_PLUGIN
- #endif
-
- protected:
- ExpressionTypeNested m_matrix;
-};
-
-
-/** \returns a Cwise wrapper of *this providing additional coefficient-wise operations
- *
- * Example: \include MatrixBase_cwise_const.cpp
- * Output: \verbinclude MatrixBase_cwise_const.out
- *
- * \sa class Cwise, cwise()
- */
-template<typename Derived>
-inline const Cwise<Derived> MatrixBase<Derived>::cwise() const
-{
- return derived();
-}
-
-/** \returns a Cwise wrapper of *this providing additional coefficient-wise operations
- *
- * Example: \include MatrixBase_cwise.cpp
- * Output: \verbinclude MatrixBase_cwise.out
- *
- * \sa class Cwise, cwise() const
- */
-template<typename Derived>
-inline Cwise<Derived> MatrixBase<Derived>::cwise()
-{
- return derived();
-}
-
-} // end namespace Eigen
-
-#endif // EIGEN_CWISE_H
diff --git a/Eigen/src/Eigen2Support/CwiseOperators.h b/Eigen/src/Eigen2Support/CwiseOperators.h
deleted file mode 100644
index 482f30648..000000000
--- a/Eigen/src/Eigen2Support/CwiseOperators.h
+++ /dev/null
@@ -1,298 +0,0 @@
-// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra.
-//
-// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
-//
-// 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/.
-
-#ifndef EIGEN_ARRAY_CWISE_OPERATORS_H
-#define EIGEN_ARRAY_CWISE_OPERATORS_H
-
-namespace Eigen {
-
-/***************************************************************************
-* The following functions were defined in Core
-***************************************************************************/
-
-
-/** \deprecated ArrayBase::abs() */
-template<typename ExpressionType>
-EIGEN_STRONG_INLINE const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_abs_op)
-Cwise<ExpressionType>::abs() const
-{
- return _expression();
-}
-
-/** \deprecated ArrayBase::abs2() */
-template<typename ExpressionType>
-EIGEN_STRONG_INLINE const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_abs2_op)
-Cwise<ExpressionType>::abs2() const
-{
- return _expression();
-}
-
-/** \deprecated ArrayBase::exp() */
-template<typename ExpressionType>
-inline const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_exp_op)
-Cwise<ExpressionType>::exp() const
-{
- return _expression();
-}
-
-/** \deprecated ArrayBase::log() */
-template<typename ExpressionType>
-inline const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_log_op)
-Cwise<ExpressionType>::log() const
-{
- return _expression();
-}
-
-/** \deprecated ArrayBase::operator*() */
-template<typename ExpressionType>
-template<typename OtherDerived>
-EIGEN_STRONG_INLINE const EIGEN_CWISE_PRODUCT_RETURN_TYPE(ExpressionType,OtherDerived)
-Cwise<ExpressionType>::operator*(const MatrixBase<OtherDerived> &other) const
-{
- return EIGEN_CWISE_PRODUCT_RETURN_TYPE(ExpressionType,OtherDerived)(_expression(), other.derived());
-}
-
-/** \deprecated ArrayBase::operator/() */
-template<typename ExpressionType>
-template<typename OtherDerived>
-EIGEN_STRONG_INLINE const EIGEN_CWISE_BINOP_RETURN_TYPE(internal::scalar_quotient_op)
-Cwise<ExpressionType>::operator/(const MatrixBase<OtherDerived> &other) const
-{
- return EIGEN_CWISE_BINOP_RETURN_TYPE(internal::scalar_quotient_op)(_expression(), other.derived());
-}
-
-/** \deprecated ArrayBase::operator*=() */
-template<typename ExpressionType>
-template<typename OtherDerived>
-inline ExpressionType& Cwise<ExpressionType>::operator*=(const MatrixBase<OtherDerived> &other)
-{
- return m_matrix.const_cast_derived() = *this * other;
-}
-
-/** \deprecated ArrayBase::operator/=() */
-template<typename ExpressionType>
-template<typename OtherDerived>
-inline ExpressionType& Cwise<ExpressionType>::operator/=(const MatrixBase<OtherDerived> &other)
-{
- return m_matrix.const_cast_derived() = *this / other;
-}
-
-/***************************************************************************
-* The following functions were defined in Array
-***************************************************************************/
-
-// -- unary operators --
-
-/** \deprecated ArrayBase::sqrt() */
-template<typename ExpressionType>
-inline const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_sqrt_op)
-Cwise<ExpressionType>::sqrt() const
-{
- return _expression();
-}
-
-/** \deprecated ArrayBase::cos() */
-template<typename ExpressionType>
-inline const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_cos_op)
-Cwise<ExpressionType>::cos() const
-{
- return _expression();
-}
-
-
-/** \deprecated ArrayBase::sin() */
-template<typename ExpressionType>
-inline const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_sin_op)
-Cwise<ExpressionType>::sin() const
-{
- return _expression();
-}
-
-
-/** \deprecated ArrayBase::log() */
-template<typename ExpressionType>
-inline const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_pow_op)
-Cwise<ExpressionType>::pow(const Scalar& exponent) const
-{
- return EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_pow_op)(_expression(), internal::scalar_pow_op<Scalar>(exponent));
-}
-
-
-/** \deprecated ArrayBase::inverse() */
-template<typename ExpressionType>
-inline const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_inverse_op)
-Cwise<ExpressionType>::inverse() const
-{
- return _expression();
-}
-
-/** \deprecated ArrayBase::square() */
-template<typename ExpressionType>
-inline const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_square_op)
-Cwise<ExpressionType>::square() const
-{
- return _expression();
-}
-
-/** \deprecated ArrayBase::cube() */
-template<typename ExpressionType>
-inline const EIGEN_CWISE_UNOP_RETURN_TYPE(internal::scalar_cube_op)
-Cwise<ExpressionType>::cube() const
-{
- return _expression();
-}
-
-
-// -- binary operators --
-
-/** \deprecated ArrayBase::operator<() */
-template<typename ExpressionType>
-template<typename OtherDerived>
-inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less)
-Cwise<ExpressionType>::operator<(const MatrixBase<OtherDerived> &other) const
-{
- return EIGEN_CWISE_BINOP_RETURN_TYPE(std::less)(_expression(), other.derived());
-}
-
-/** \deprecated ArrayBase::<=() */
-template<typename ExpressionType>
-template<typename OtherDerived>
-inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less_equal)
-Cwise<ExpressionType>::operator<=(const MatrixBase<OtherDerived> &other) const
-{
- return EIGEN_CWISE_BINOP_RETURN_TYPE(std::less_equal)(_expression(), other.derived());
-}
-
-/** \deprecated ArrayBase::operator>() */
-template<typename ExpressionType>
-template<typename OtherDerived>
-inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater)
-Cwise<ExpressionType>::operator>(const MatrixBase<OtherDerived> &other) const
-{
- return EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater)(_expression(), other.derived());
-}
-
-/** \deprecated ArrayBase::operator>=() */
-template<typename ExpressionType>
-template<typename OtherDerived>
-inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater_equal)
-Cwise<ExpressionType>::operator>=(const MatrixBase<OtherDerived> &other) const
-{
- return EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater_equal)(_expression(), other.derived());
-}
-
-/** \deprecated ArrayBase::operator==() */
-template<typename ExpressionType>
-template<typename OtherDerived>
-inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::equal_to)
-Cwise<ExpressionType>::operator==(const MatrixBase<OtherDerived> &other) const
-{
- return EIGEN_CWISE_BINOP_RETURN_TYPE(std::equal_to)(_expression(), other.derived());
-}
-
-/** \deprecated ArrayBase::operator!=() */
-template<typename ExpressionType>
-template<typename OtherDerived>
-inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::not_equal_to)
-Cwise<ExpressionType>::operator!=(const MatrixBase<OtherDerived> &other) const
-{
- return EIGEN_CWISE_BINOP_RETURN_TYPE(std::not_equal_to)(_expression(), other.derived());
-}
-
-// comparisons to scalar value
-
-/** \deprecated ArrayBase::operator<(Scalar) */
-template<typename ExpressionType>
-inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less)
-Cwise<ExpressionType>::operator<(Scalar s) const
-{
- return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less)(_expression(),
- typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s));
-}
-
-/** \deprecated ArrayBase::operator<=(Scalar) */
-template<typename ExpressionType>
-inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less_equal)
-Cwise<ExpressionType>::operator<=(Scalar s) const
-{
- return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less_equal)(_expression(),
- typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s));
-}
-
-/** \deprecated ArrayBase::operator>(Scalar) */
-template<typename ExpressionType>
-inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater)
-Cwise<ExpressionType>::operator>(Scalar s) const
-{
- return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater)(_expression(),
- typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s));
-}
-
-/** \deprecated ArrayBase::operator>=(Scalar) */
-template<typename ExpressionType>
-inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater_equal)
-Cwise<ExpressionType>::operator>=(Scalar s) const
-{
- return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater_equal)(_expression(),
- typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s));
-}
-
-/** \deprecated ArrayBase::operator==(Scalar) */
-template<typename ExpressionType>
-inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::equal_to)
-Cwise<ExpressionType>::operator==(Scalar s) const
-{
- return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::equal_to)(_expression(),
- typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s));
-}
-
-/** \deprecated ArrayBase::operator!=(Scalar) */
-template<typename ExpressionType>
-inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::not_equal_to)
-Cwise<ExpressionType>::operator!=(Scalar s) const
-{
- return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::not_equal_to)(_expression(),
- typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s));
-}
-
-// scalar addition
-
-/** \deprecated ArrayBase::operator+(Scalar) */
-template<typename ExpressionType>
-inline const typename Cwise<ExpressionType>::ScalarAddReturnType
-Cwise<ExpressionType>::operator+(const Scalar& scalar) const
-{
- return typename Cwise<ExpressionType>::ScalarAddReturnType(m_matrix, internal::scalar_add_op<Scalar>(scalar));
-}
-
-/** \deprecated ArrayBase::operator+=(Scalar) */
-template<typename ExpressionType>
-inline ExpressionType& Cwise<ExpressionType>::operator+=(const Scalar& scalar)
-{
- return m_matrix.const_cast_derived() = *this + scalar;
-}
-
-/** \deprecated ArrayBase::operator-(Scalar) */
-template<typename ExpressionType>
-inline const typename Cwise<ExpressionType>::ScalarAddReturnType
-Cwise<ExpressionType>::operator-(const Scalar& scalar) const
-{
- return *this + (-scalar);
-}
-
-/** \deprecated ArrayBase::operator-=(Scalar) */
-template<typename ExpressionType>
-inline ExpressionType& Cwise<ExpressionType>::operator-=(const Scalar& scalar)
-{
- return m_matrix.const_cast_derived() = *this - scalar;
-}
-
-} // end namespace Eigen
-
-#endif // EIGEN_ARRAY_CWISE_OPERATORS_H
diff --git a/Eigen/src/Eigen2Support/Geometry/AlignedBox.h b/Eigen/src/Eigen2Support/Geometry/AlignedBox.h
deleted file mode 100644
index 2e4309dd9..000000000
--- a/Eigen/src/Eigen2Support/Geometry/AlignedBox.h
+++ /dev/null
@@ -1,159 +0,0 @@
-// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra.
-//
-// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
-//
-// 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/.
-
-// no include guard, we'll include this twice from All.h from Eigen2Support, and it's internal anyway
-
-namespace Eigen {
-
-/** \geometry_module \ingroup Geometry_Module
- * \nonstableyet
- *
- * \class AlignedBox
- *
- * \brief An axis aligned box
- *
- * \param _Scalar the type of the scalar coefficients
- * \param _AmbientDim the dimension of the ambient space, can be a compile time value or Dynamic.
- *
- * This class represents an axis aligned box as a pair of the minimal and maximal corners.
- */
-template <typename _Scalar, int _AmbientDim>
-class AlignedBox
-{
-public:
-EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_AmbientDim==Dynamic ? Dynamic : _AmbientDim+1)
- enum { AmbientDimAtCompileTime = _AmbientDim };
- typedef _Scalar Scalar;
- typedef typename NumTraits<Scalar>::Real RealScalar;
- typedef Matrix<Scalar,AmbientDimAtCompileTime,1> VectorType;
-
- /** Default constructor initializing a null box. */
- inline AlignedBox()
- { if (AmbientDimAtCompileTime!=Dynamic) setNull(); }
-
- /** Constructs a null box with \a _dim the dimension of the ambient space. */
- inline explicit AlignedBox(int _dim) : m_min(_dim), m_max(_dim)
- { setNull(); }
-
- /** Constructs a box with extremities \a _min and \a _max. */
- inline AlignedBox(const VectorType& _min, const VectorType& _max) : m_min(_min), m_max(_max) {}
-
- /** Constructs a box containing a single point \a p. */
- inline explicit AlignedBox(const VectorType& p) : m_min(p), m_max(p) {}
-
- ~AlignedBox() {}
-
- /** \returns the dimension in which the box holds */
- inline int dim() const { return AmbientDimAtCompileTime==Dynamic ? m_min.size()-1 : AmbientDimAtCompileTime; }
-
- /** \returns true if the box is null, i.e, empty. */
- inline bool isNull() const { return (m_min.cwise() > m_max).any(); }
-
- /** Makes \c *this a null/empty box. */
- inline void setNull()
- {
- m_min.setConstant( (std::numeric_limits<Scalar>::max)());
- m_max.setConstant(-(std::numeric_limits<Scalar>::max)());
- }
-
- /** \returns the minimal corner */
- inline const VectorType& (min)() const { return m_min; }
- /** \returns a non const reference to the minimal corner */
- inline VectorType& (min)() { return m_min; }
- /** \returns the maximal corner */
- inline const VectorType& (max)() const { return m_max; }
- /** \returns a non const reference to the maximal corner */
- inline VectorType& (max)() { return m_max; }
-
- /** \returns true if the point \a p is inside the box \c *this. */
- inline bool contains(const VectorType& p) const
- { return (m_min.cwise()<=p).all() && (p.cwise()<=m_max).all(); }
-
- /** \returns true if the box \a b is entirely inside the box \c *this. */
- inline bool contains(const AlignedBox& b) const
- { return (m_min.cwise()<=(b.min)()).all() && ((b.max)().cwise()<=m_max).all(); }
-
- /** Extends \c *this such that it contains the point \a p and returns a reference to \c *this. */
- inline AlignedBox& extend(const VectorType& p)
- { m_min = (m_min.cwise().min)(p); m_max = (m_max.cwise().max)(p); return *this; }
-
- /** Extends \c *this such that it contains the box \a b and returns a reference to \c *this. */
- inline AlignedBox& extend(const AlignedBox& b)
- { m_min = (m_min.cwise().min)(b.m_min); m_max = (m_max.cwise().max)(b.m_max); return *this; }
-
- /** Clamps \c *this by the box \a b and returns a reference to \c *this. */
- inline AlignedBox& clamp(const AlignedBox& b)
- { m_min = (m_min.cwise().max)(b.m_min); m_max = (m_max.cwise().min)(b.m_max); return *this; }
-
- /** Translate \c *this by the vector \a t and returns a reference to \c *this. */
- inline AlignedBox& translate(const VectorType& t)
- { m_min += t; m_max += t; return *this; }
-
- /** \returns the squared distance between the point \a p and the box \c *this,
- * and zero if \a p is inside the box.
- * \sa exteriorDistance()
- */
- inline Scalar squaredExteriorDistance(const VectorType& p) const;
-
- /** \returns the distance between the point \a p and the box \c *this,
- * and zero if \a p is inside the box.
- * \sa squaredExteriorDistance()
- */
- inline Scalar exteriorDistance(const VectorType& p) const
- { return ei_sqrt(squaredExteriorDistance(p)); }
-
- /** \returns \c *this with scalar type casted to \a NewScalarType
- *
- * Note that if \a NewScalarType is equal to the current scalar type of \c *this
- * then this function smartly returns a const reference to \c *this.
- */
- template<typename NewScalarType>
- inline typename internal::cast_return_type<AlignedBox,
- AlignedBox<NewScalarType,AmbientDimAtCompileTime> >::type cast() const
- {
- return typename internal::cast_return_type<AlignedBox,
- AlignedBox<NewScalarType,AmbientDimAtCompileTime> >::type(*this);
- }
-
- /** Copy constructor with scalar type conversion */
- template<typename OtherScalarType>
- inline explicit AlignedBox(const AlignedBox<OtherScalarType,AmbientDimAtCompileTime>& other)
- {
- m_min = (other.min)().template cast<Scalar>();
- m_max = (other.max)().template cast<Scalar>();
- }
-
- /** \returns \c true if \c *this is approximately equal to \a other, within the precision
- * determined by \a prec.
- *
- * \sa MatrixBase::isApprox() */
- bool isApprox(const AlignedBox& other, typename NumTraits<Scalar>::Real prec = precision<Scalar>()) const
- { return m_min.isApprox(other.m_min, prec) && m_max.isApprox(other.m_max, prec); }
-
-protected:
-
- VectorType m_min, m_max;
-};
-
-template<typename Scalar,int AmbiantDim>
-inline Scalar AlignedBox<Scalar,AmbiantDim>::squaredExteriorDistance(const VectorType& p) const
-{
- Scalar dist2(0);
- Scalar aux;
- for (int k=0; k<dim(); ++k)
- {
- if ((aux = (p[k]-m_min[k]))<Scalar(0))
- dist2 += aux*aux;
- else if ( (aux = (m_max[k]-p[k]))<Scalar(0))
- dist2 += aux*aux;
- }
- return dist2;
-}
-
-} // end namespace Eigen
diff --git a/Eigen/src/Eigen2Support/Geometry/All.h b/Eigen/src/Eigen2Support/Geometry/All.h
deleted file mode 100644
index e0b00fccc..000000000
--- a/Eigen/src/Eigen2Support/Geometry/All.h
+++ /dev/null
@@ -1,115 +0,0 @@
-#ifndef EIGEN2_GEOMETRY_MODULE_H
-#define EIGEN2_GEOMETRY_MODULE_H
-
-#include <limits>
-
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
-#if EIGEN2_SUPPORT_STAGE < STAGE20_RESOLVE_API_CONFLICTS
-#include "RotationBase.h"
-#include "Rotation2D.h"
-#include "Quaternion.h"
-#include "AngleAxis.h"
-#include "Transform.h"
-#include "Translation.h"
-#include "Scaling.h"
-#include "AlignedBox.h"
-#include "Hyperplane.h"
-#include "ParametrizedLine.h"
-#endif
-
-
-#define RotationBase eigen2_RotationBase
-#define Rotation2D eigen2_Rotation2D
-#define Rotation2Df eigen2_Rotation2Df
-#define Rotation2Dd eigen2_Rotation2Dd
-
-#define Quaternion eigen2_Quaternion
-#define Quaternionf eigen2_Quaternionf
-#define Quaterniond eigen2_Quaterniond
-
-#define AngleAxis eigen2_AngleAxis
-#define AngleAxisf eigen2_AngleAxisf
-#define AngleAxisd eigen2_AngleAxisd
-
-#define Transform eigen2_Transform
-#define Transform2f eigen2_Transform2f
-#define Transform2d eigen2_Transform2d
-#define Transform3f eigen2_Transform3f
-#define Transform3d eigen2_Transform3d
-
-#define Translation eigen2_Translation
-#define Translation2f eigen2_Translation2f
-#define Translation2d eigen2_Translation2d
-#define Translation3f eigen2_Translation3f
-#define Translation3d eigen2_Translation3d
-
-#define Scaling eigen2_Scaling
-#define Scaling2f eigen2_Scaling2f
-#define Scaling2d eigen2_Scaling2d
-#define Scaling3f eigen2_Scaling3f
-#define Scaling3d eigen2_Scaling3d
-
-#define AlignedBox eigen2_AlignedBox
-
-#define Hyperplane eigen2_Hyperplane
-#define ParametrizedLine eigen2_ParametrizedLine
-
-#define ei_toRotationMatrix eigen2_ei_toRotationMatrix
-#define ei_quaternion_assign_impl eigen2_ei_quaternion_assign_impl
-#define ei_transform_product_impl eigen2_ei_transform_product_impl
-
-#include "RotationBase.h"
-#include "Rotation2D.h"
-#include "Quaternion.h"
-#include "AngleAxis.h"
-#include "Transform.h"
-#include "Translation.h"
-#include "Scaling.h"
-#include "AlignedBox.h"
-#include "Hyperplane.h"
-#include "ParametrizedLine.h"
-
-#undef ei_toRotationMatrix
-#undef ei_quaternion_assign_impl
-#undef ei_transform_product_impl
-
-#undef RotationBase
-#undef Rotation2D
-#undef Rotation2Df
-#undef Rotation2Dd
-
-#undef Quaternion
-#undef Quaternionf
-#undef Quaterniond
-
-#undef AngleAxis
-#undef AngleAxisf
-#undef AngleAxisd
-
-#undef Transform
-#undef Transform2f
-#undef Transform2d
-#undef Transform3f
-#undef Transform3d
-
-#undef Translation
-#undef Translation2f
-#undef Translation2d
-#undef Translation3f
-#undef Translation3d
-
-#undef Scaling
-#undef Scaling2f
-#undef Scaling2d
-#undef Scaling3f
-#undef Scaling3d
-
-#undef AlignedBox
-
-#undef Hyperplane
-#undef ParametrizedLine
-
-#endif // EIGEN2_GEOMETRY_MODULE_H
diff --git a/Eigen/src/Eigen2Support/Geometry/AngleAxis.h b/Eigen/src/Eigen2Support/Geometry/AngleAxis.h
deleted file mode 100644
index a0b4ac44e..000000000
--- a/Eigen/src/Eigen2Support/Geometry/AngleAxis.h
+++ /dev/null
@@ -1,228 +0,0 @@
-// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra.
-//
-// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
-//
-// 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/.
-
-// no include guard, we'll include this twice from All.h from Eigen2Support, and it's internal anyway
-
-namespace Eigen {
-
-/** \geometry_module \ingroup Geometry_Module
- *
- * \class AngleAxis
- *
- * \brief Represents a 3D rotation as a rotation angle around an arbitrary 3D axis
- *
- * \param _Scalar the scalar type, i.e., the type of the coefficients.
- *
- * The following two typedefs are provided for convenience:
- * \li \c AngleAxisf for \c float
- * \li \c AngleAxisd for \c double
- *
- * \addexample AngleAxisForEuler \label How to define a rotation from Euler-angles
- *
- * Combined with MatrixBase::Unit{X,Y,Z}, AngleAxis can be used to easily
- * mimic Euler-angles. Here is an example:
- * \include AngleAxis_mimic_euler.cpp
- * Output: \verbinclude AngleAxis_mimic_euler.out
- *
- * \note This class is not aimed to be used to store a rotation transformation,
- * but rather to make easier the creation of other rotation (Quaternion, rotation Matrix)
- * and transformation objects.
- *
- * \sa class Quaternion, class Transform, MatrixBase::UnitX()
- */
-
-template<typename _Scalar> struct ei_traits<AngleAxis<_Scalar> >
-{
- typedef _Scalar Scalar;
-};
-
-template<typename _Scalar>
-class AngleAxis : public RotationBase<AngleAxis<_Scalar>,3>
-{
- typedef RotationBase<AngleAxis<_Scalar>,3> Base;
-
-public:
-
- using Base::operator*;
-
- enum { Dim = 3 };
- /** the scalar type of the coefficients */
- typedef _Scalar Scalar;
- typedef Matrix<Scalar,3,3> Matrix3;
- typedef Matrix<Scalar,3,1> Vector3;
- typedef Quaternion<Scalar> QuaternionType;
-
-protected:
-
- Vector3 m_axis;
- Scalar m_angle;
-
-public:
-
- /** Default constructor without initialization. */
- AngleAxis() {}
-
- /** Constructs and initialize the angle-axis rotation from an \a angle in radian
- * and an \a axis which must be normalized. */
- template<typename Derived>
- inline AngleAxis(Scalar angle, const MatrixBase<Derived>& axis) : m_axis(axis), m_angle(angle)
- {
- using std::sqrt;
- using std::abs;
- // since we compare against 1, this is equal to computing the relative error
- eigen_assert( abs(m_axis.derived().squaredNorm() - 1) < sqrt( NumTraits<Scalar>::dummy_precision() ) );
- }
-
- /** Constructs and initialize the angle-axis rotation from a quaternion \a q. */
- inline AngleAxis(const QuaternionType& q) { *this = q; }
-
- /** Constructs and initialize the angle-axis rotation from a 3x3 rotation matrix. */
- template<typename Derived>
- inline explicit AngleAxis(const MatrixBase<Derived>& m) { *this = m; }
-
- Scalar angle() const { return m_angle; }
- Scalar& angle() { return m_angle; }
-
- const Vector3& axis() const { return m_axis; }
- Vector3& axis() { return m_axis; }
-
- /** Concatenates two rotations */
- inline QuaternionType operator* (const AngleAxis& other) const
- { return QuaternionType(*this) * QuaternionType(other); }
-
- /** Concatenates two rotations */
- inline QuaternionType operator* (const QuaternionType& other) const
- { return QuaternionType(*this) * other; }
-
- /** Concatenates two rotations */
- friend inline QuaternionType operator* (const QuaternionType& a, const AngleAxis& b)
- { return a * QuaternionType(b); }
-
- /** Concatenates two rotations */
- inline Matrix3 operator* (const Matrix3& other) const
- { return toRotationMatrix() * other; }
-
- /** Concatenates two rotations */
- inline friend Matrix3 operator* (const Matrix3& a, const AngleAxis& b)
- { return a * b.toRotationMatrix(); }
-
- /** Applies rotation to vector */
- inline Vector3 operator* (const Vector3& other) const
- { return toRotationMatrix() * other; }
-
- /** \returns the inverse rotation, i.e., an angle-axis with opposite rotation angle */
- AngleAxis inverse() const
- { return AngleAxis(-m_angle, m_axis); }
-
- AngleAxis& operator=(const QuaternionType& q);
- template<typename Derived>
- AngleAxis& operator=(const MatrixBase<Derived>& m);
-
- template<typename Derived>
- AngleAxis& fromRotationMatrix(const MatrixBase<Derived>& m);
- Matrix3 toRotationMatrix(void) const;
-
- /** \returns \c *this with scalar type casted to \a NewScalarType
- *
- * Note that if \a NewScalarType is equal to the current scalar type of \c *this
- * then this function smartly returns a const reference to \c *this.
- */
- template<typename NewScalarType>
- inline typename internal::cast_return_type<AngleAxis,AngleAxis<NewScalarType> >::type cast() const
- { return typename internal::cast_return_type<AngleAxis,AngleAxis<NewScalarType> >::type(*this); }
-
- /** Copy constructor with scalar type conversion */
- template<typename OtherScalarType>
- inline explicit AngleAxis(const AngleAxis<OtherScalarType>& other)
- {
- m_axis = other.axis().template cast<Scalar>();
- m_angle = Scalar(other.angle());
- }
-
- /** \returns \c true if \c *this is approximately equal to \a other, within the precision
- * determined by \a prec.
- *
- * \sa MatrixBase::isApprox() */
- bool isApprox(const AngleAxis& other, typename NumTraits<Scalar>::Real prec = precision<Scalar>()) const
- { return m_axis.isApprox(other.m_axis, prec) && ei_isApprox(m_angle,other.m_angle, prec); }
-};
-
-/** \ingroup Geometry_Module
- * single precision angle-axis type */
-typedef AngleAxis<float> AngleAxisf;
-/** \ingroup Geometry_Module
- * double precision angle-axis type */
-typedef AngleAxis<double> AngleAxisd;
-
-/** Set \c *this from a quaternion.
- * The axis is normalized.
- */
-template<typename Scalar>
-AngleAxis<Scalar>& AngleAxis<Scalar>::operator=(const QuaternionType& q)
-{
- Scalar n2 = q.vec().squaredNorm();
- if (n2 < precision<Scalar>()*precision<Scalar>())
- {
- m_angle = 0;
- m_axis << 1, 0, 0;
- }
- else
- {
- m_angle = 2*std::acos(q.w());
- m_axis = q.vec() / ei_sqrt(n2);
-
- using std::sqrt;
- using std::abs;
- // since we compare against 1, this is equal to computing the relative error
- eigen_assert( abs(m_axis.derived().squaredNorm() - 1) < sqrt( NumTraits<Scalar>::dummy_precision() ) );
- }
- return *this;
-}
-
-/** Set \c *this from a 3x3 rotation matrix \a mat.
- */
-template<typename Scalar>
-template<typename Derived>
-AngleAxis<Scalar>& AngleAxis<Scalar>::operator=(const MatrixBase<Derived>& mat)
-{
- // Since a direct conversion would not be really faster,
- // let's use the robust Quaternion implementation:
- return *this = QuaternionType(mat);
-}
-
-/** Constructs and \returns an equivalent 3x3 rotation matrix.
- */
-template<typename Scalar>
-typename AngleAxis<Scalar>::Matrix3
-AngleAxis<Scalar>::toRotationMatrix(void) const
-{
- Matrix3 res;
- Vector3 sin_axis = ei_sin(m_angle) * m_axis;
- Scalar c = ei_cos(m_angle);
- Vector3 cos1_axis = (Scalar(1)-c) * m_axis;
-
- Scalar tmp;
- tmp = cos1_axis.x() * m_axis.y();
- res.coeffRef(0,1) = tmp - sin_axis.z();
- res.coeffRef(1,0) = tmp + sin_axis.z();
-
- tmp = cos1_axis.x() * m_axis.z();
- res.coeffRef(0,2) = tmp + sin_axis.y();
- res.coeffRef(2,0) = tmp - sin_axis.y();
-
- tmp = cos1_axis.y() * m_axis.z();
- res.coeffRef(1,2) = tmp - sin_axis.x();
- res.coeffRef(2,1) = tmp + sin_axis.x();
-
- res.diagonal() = (cos1_axis.cwise() * m_axis).cwise() + c;
-
- return res;
-}
-
-} // end namespace Eigen
diff --git a/Eigen/src/Eigen2Support/Geometry/CMakeLists.txt b/Eigen/src/Eigen2Support/Geometry/CMakeLists.txt
deleted file mode 100644
index c347a8f26..000000000
--- a/Eigen/src/Eigen2Support/Geometry/CMakeLists.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-FILE(GLOB Eigen_Eigen2Support_Geometry_SRCS "*.h")
-
-INSTALL(FILES
- ${Eigen_Eigen2Support_Geometry_SRCS}
- DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Eigen2Support/Geometry
- )
diff --git a/Eigen/src/Eigen2Support/Geometry/Hyperplane.h b/Eigen/src/Eigen2Support/Geometry/Hyperplane.h
deleted file mode 100644
index b95bf00ec..000000000
--- a/Eigen/src/Eigen2Support/Geometry/Hyperplane.h
+++ /dev/null
@@ -1,254 +0,0 @@
-// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra.
-//
-// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
-// Copyright (C) 2008 Benoit Jacob <jacob.benoit.1@gmail.com>
-//
-// 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/.
-
-// no include guard, we'll include this twice from All.h from Eigen2Support, and it's internal anyway
-
-namespace Eigen {
-
-/** \geometry_module \ingroup Geometry_Module
- *
- * \class Hyperplane
- *
- * \brief A hyperplane
- *
- * A hyperplane is an affine subspace of dimension n-1 in a space of dimension n.
- * For example, a hyperplane in a plane is a line; a hyperplane in 3-space is a plane.
- *
- * \param _Scalar the scalar type, i.e., the type of the coefficients
- * \param _AmbientDim the dimension of the ambient space, can be a compile time value or Dynamic.
- * Notice that the dimension of the hyperplane is _AmbientDim-1.
- *
- * This class represents an hyperplane as the zero set of the implicit equation
- * \f$ n \cdot x + d = 0 \f$ where \f$ n \f$ is a unit normal vector of the plane (linear part)
- * and \f$ d \f$ is the distance (offset) to the origin.
- */
-template <typename _Scalar, int _AmbientDim>
-class Hyperplane
-{
-public:
- EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_AmbientDim==Dynamic ? Dynamic : _AmbientDim+1)
- enum { AmbientDimAtCompileTime = _AmbientDim };
- typedef _Scalar Scalar;
- typedef typename NumTraits<Scalar>::Real RealScalar;
- typedef Matrix<Scalar,AmbientDimAtCompileTime,1> VectorType;
- typedef Matrix<Scalar,int(AmbientDimAtCompileTime)==Dynamic
- ? Dynamic
- : int(AmbientDimAtCompileTime)+1,1> Coefficients;
- typedef Block<Coefficients,AmbientDimAtCompileTime,1> NormalReturnType;
-
- /** Default constructor without initialization */
- inline Hyperplane() {}
-
- /** Constructs a dynamic-size hyperplane with \a _dim the dimension
- * of the ambient space */
- inline explicit Hyperplane(int _dim) : m_coeffs(_dim+1) {}
-
- /** Construct a plane from its normal \a n and a point \a e onto the plane.
- * \warning the vector normal is assumed to be normalized.
- */
- inline Hyperplane(const VectorType& n, const VectorType& e)
- : m_coeffs(n.size()+1)
- {
- normal() = n;
- offset() = -e.eigen2_dot(n);
- }
-
- /** Constructs a plane from its normal \a n and distance to the origin \a d
- * such that the algebraic equation of the plane is \f$ n \cdot x + d = 0 \f$.
- * \warning the vector normal is assumed to be normalized.
- */
- inline Hyperplane(const VectorType& n, Scalar d)
- : m_coeffs(n.size()+1)
- {
- normal() = n;
- offset() = d;
- }
-
- /** Constructs a hyperplane passing through the two points. If the dimension of the ambient space
- * is greater than 2, then there isn't uniqueness, so an arbitrary choice is made.
- */
- static inline Hyperplane Through(const VectorType& p0, const VectorType& p1)
- {
- Hyperplane result(p0.size());
- result.normal() = (p1 - p0).unitOrthogonal();
- result.offset() = -result.normal().eigen2_dot(p0);
- return result;
- }
-
- /** Constructs a hyperplane passing through the three points. The dimension of the ambient space
- * is required to be exactly 3.
- */
- static inline Hyperplane Through(const VectorType& p0, const VectorType& p1, const VectorType& p2)
- {
- EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(VectorType, 3)
- Hyperplane result(p0.size());
- result.normal() = (p2 - p0).cross(p1 - p0).normalized();
- result.offset() = -result.normal().eigen2_dot(p0);
- return result;
- }
-
- /** Constructs a hyperplane passing through the parametrized line \a parametrized.
- * If the dimension of the ambient space is greater than 2, then there isn't uniqueness,
- * so an arbitrary choice is made.
- */
- // FIXME to be consitent with the rest this could be implemented as a static Through function ??
- explicit Hyperplane(const ParametrizedLine<Scalar, AmbientDimAtCompileTime>& parametrized)
- {
- normal() = parametrized.direction().unitOrthogonal();
- offset() = -normal().eigen2_dot(parametrized.origin());
- }
-
- ~Hyperplane() {}
-
- /** \returns the dimension in which the plane holds */
- inline int dim() const { return int(AmbientDimAtCompileTime)==Dynamic ? m_coeffs.size()-1 : int(AmbientDimAtCompileTime); }
-
- /** normalizes \c *this */
- void normalize(void)
- {
- m_coeffs /= normal().norm();
- }
-
- /** \returns the signed distance between the plane \c *this and a point \a p.
- * \sa absDistance()
- */
- inline Scalar signedDistance(const VectorType& p) const { return p.eigen2_dot(normal()) + offset(); }
-
- /** \returns the absolute distance between the plane \c *this and a point \a p.
- * \sa signedDistance()
- */
- inline Scalar absDistance(const VectorType& p) const { return ei_abs(signedDistance(p)); }
-
- /** \returns the projection of a point \a p onto the plane \c *this.
- */
- inline VectorType projection(const VectorType& p) const { return p - signedDistance(p) * normal(); }
-
- /** \returns a constant reference to the unit normal vector of the plane, which corresponds
- * to the linear part of the implicit equation.
- */
- inline const NormalReturnType normal() const { return NormalReturnType(*const_cast<Coefficients*>(&m_coeffs),0,0,dim(),1); }
-
- /** \returns a non-constant reference to the unit normal vector of the plane, which corresponds
- * to the linear part of the implicit equation.
- */
- inline NormalReturnType normal() { return NormalReturnType(m_coeffs,0,0,dim(),1); }
-
- /** \returns the distance to the origin, which is also the "constant term" of the implicit equation
- * \warning the vector normal is assumed to be normalized.
- */
- inline const Scalar& offset() const { return m_coeffs.coeff(dim()); }
-
- /** \returns a non-constant reference to the distance to the origin, which is also the constant part
- * of the implicit equation */
- inline Scalar& offset() { return m_coeffs(dim()); }
-
- /** \returns a constant reference to the coefficients c_i of the plane equation:
- * \f$ c_0*x_0 + ... + c_{d-1}*x_{d-1} + c_d = 0 \f$
- */
- inline const Coefficients& coeffs() const { return m_coeffs; }
-
- /** \returns a non-constant reference to the coefficients c_i of the plane equation:
- * \f$ c_0*x_0 + ... + c_{d-1}*x_{d-1} + c_d = 0 \f$
- */
- inline Coefficients& coeffs() { return m_coeffs; }
-
- /** \returns the intersection of *this with \a other.
- *
- * \warning The ambient space must be a plane, i.e. have dimension 2, so that \c *this and \a other are lines.
- *
- * \note If \a other is approximately parallel to *this, this method will return any point on *this.
- */
- VectorType intersection(const Hyperplane& other)
- {
- EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(VectorType, 2)
- Scalar det = coeffs().coeff(0) * other.coeffs().coeff(1) - coeffs().coeff(1) * other.coeffs().coeff(0);
- // since the line equations ax+by=c are normalized with a^2+b^2=1, the following tests
- // whether the two lines are approximately parallel.
- if(ei_isMuchSmallerThan(det, Scalar(1)))
- { // special case where the two lines are approximately parallel. Pick any point on the first line.
- if(ei_abs(coeffs().coeff(1))>ei_abs(coeffs().coeff(0)))
- return VectorType(coeffs().coeff(1), -coeffs().coeff(2)/coeffs().coeff(1)-coeffs().coeff(0));
- else
- return VectorType(-coeffs().coeff(2)/coeffs().coeff(0)-coeffs().coeff(1), coeffs().coeff(0));
- }
- else
- { // general case
- Scalar invdet = Scalar(1) / det;
- return VectorType(invdet*(coeffs().coeff(1)*other.coeffs().coeff(2)-other.coeffs().coeff(1)*coeffs().coeff(2)),
- invdet*(other.coeffs().coeff(0)*coeffs().coeff(2)-coeffs().coeff(0)*other.coeffs().coeff(2)));
- }
- }
-
- /** Applies the transformation matrix \a mat to \c *this and returns a reference to \c *this.
- *
- * \param mat the Dim x Dim transformation matrix
- * \param traits specifies whether the matrix \a mat represents an Isometry
- * or a more generic Affine transformation. The default is Affine.
- */
- template<typename XprType>
- inline Hyperplane& transform(const MatrixBase<XprType>& mat, TransformTraits traits = Affine)
- {
- if (traits==Affine)
- normal() = mat.inverse().transpose() * normal();
- else if (traits==Isometry)
- normal() = mat * normal();
- else
- {
- ei_assert("invalid traits value in Hyperplane::transform()");
- }
- return *this;
- }
-
- /** Applies the transformation \a t to \c *this and returns a reference to \c *this.
- *
- * \param t the transformation of dimension Dim
- * \param traits specifies whether the transformation \a t represents an Isometry
- * or a more generic Affine transformation. The default is Affine.
- * Other kind of transformations are not supported.
- */
- inline Hyperplane& transform(const Transform<Scalar,AmbientDimAtCompileTime>& t,
- TransformTraits traits = Affine)
- {
- transform(t.linear(), traits);
- offset() -= t.translation().eigen2_dot(normal());
- return *this;
- }
-
- /** \returns \c *this with scalar type casted to \a NewScalarType
- *
- * Note that if \a NewScalarType is equal to the current scalar type of \c *this
- * then this function smartly returns a const reference to \c *this.
- */
- template<typename NewScalarType>
- inline typename internal::cast_return_type<Hyperplane,
- Hyperplane<NewScalarType,AmbientDimAtCompileTime> >::type cast() const
- {
- return typename internal::cast_return_type<Hyperplane,
- Hyperplane<NewScalarType,AmbientDimAtCompileTime> >::type(*this);
- }
-
- /** Copy constructor with scalar type conversion */
- template<typename OtherScalarType>
- inline explicit Hyperplane(const Hyperplane<OtherScalarType,AmbientDimAtCompileTime>& other)
- { m_coeffs = other.coeffs().template cast<Scalar>(); }
-
- /** \returns \c true if \c *this is approximately equal to \a other, within the precision
- * determined by \a prec.
- *
- * \sa MatrixBase::isApprox() */
- bool isApprox(const Hyperplane& other, typename NumTraits<Scalar>::Real prec = precision<Scalar>()) const
- { return m_coeffs.isApprox(other.m_coeffs, prec); }
-
-protected:
-
- Coefficients m_coeffs;
-};
-
-} // end namespace Eigen
diff --git a/Eigen/src/Eigen2Support/Geometry/ParametrizedLine.h b/Eigen/src/Eigen2Support/Geometry/ParametrizedLine.h
deleted file mode 100644
index 9b57b7e0b..000000000
--- a/Eigen/src/Eigen2Support/Geometry/ParametrizedLine.h
+++ /dev/null
@@ -1,141 +0,0 @@
-// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra.
-//
-// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
-// Copyright (C) 2008 Benoit Jacob <jacob.benoit.1@gmail.com>
-//
-// 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/.
-
-// no include guard, we'll include this twice from All.h from Eigen2Support, and it's internal anyway
-
-namespace Eigen {
-
-/** \geometry_module \ingroup Geometry_Module
- *
- * \class ParametrizedLine
- *
- * \brief A parametrized line
- *
- * A parametrized line is defined by an origin point \f$ \mathbf{o} \f$ and a unit
- * direction vector \f$ \mathbf{d} \f$ such that the line corresponds to
- * the set \f$ l(t) = \mathbf{o} + t \mathbf{d} \f$, \f$ l \in \mathbf{R} \f$.
- *
- * \param _Scalar the scalar type, i.e., the type of the coefficients
- * \param _AmbientDim the dimension of the ambient space, can be a compile time value or Dynamic.
- */
-template <typename _Scalar, int _AmbientDim>
-class ParametrizedLine
-{
-public:
- EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_AmbientDim)
- enum { AmbientDimAtCompileTime = _AmbientDim };
- typedef _Scalar Scalar;
- typedef typename NumTraits<Scalar>::Real RealScalar;
- typedef Matrix<Scalar,AmbientDimAtCompileTime,1> VectorType;
-
- /** Default constructor without initialization */
- inline ParametrizedLine() {}
-
- /** Constructs a dynamic-size line with \a _dim the dimension
- * of the ambient space */
- inline explicit ParametrizedLine(int _dim) : m_origin(_dim), m_direction(_dim) {}
-
- /** Initializes a parametrized line of direction \a direction and origin \a origin.
- * \warning the vector direction is assumed to be normalized.
- */
- ParametrizedLine(const VectorType& origin, const VectorType& direction)
- : m_origin(origin), m_direction(direction) {}
-
- explicit ParametrizedLine(const Hyperplane<_Scalar, _AmbientDim>& hyperplane);
-
- /** Constructs a parametrized line going from \a p0 to \a p1. */
- static inline ParametrizedLine Through(const VectorType& p0, const VectorType& p1)
- { return ParametrizedLine(p0, (p1-p0).normalized()); }
-
- ~ParametrizedLine() {}
-
- /** \returns the dimension in which the line holds */
- inline int dim() const { return m_direction.size(); }
-
- const VectorType& origin() const { return m_origin; }
- VectorType& origin() { return m_origin; }
-
- const VectorType& direction() const { return m_direction; }
- VectorType& direction() { return m_direction; }
-
- /** \returns the squared distance of a point \a p to its projection onto the line \c *this.
- * \sa distance()
- */
- RealScalar squaredDistance(const VectorType& p) const
- {
- VectorType diff = p-origin();
- return (diff - diff.eigen2_dot(direction())* direction()).squaredNorm();
- }
- /** \returns the distance of a point \a p to its projection onto the line \c *this.
- * \sa squaredDistance()
- */
- RealScalar distance(const VectorType& p) const { return ei_sqrt(squaredDistance(p)); }
-
- /** \returns the projection of a point \a p onto the line \c *this. */
- VectorType projection(const VectorType& p) const
- { return origin() + (p-origin()).eigen2_dot(direction()) * direction(); }
-
- Scalar intersection(const Hyperplane<_Scalar, _AmbientDim>& hyperplane);
-
- /** \returns \c *this with scalar type casted to \a NewScalarType
- *
- * Note that if \a NewScalarType is equal to the current scalar type of \c *this
- * then this function smartly returns a const reference to \c *this.
- */
- template<typename NewScalarType>
- inline typename internal::cast_return_type<ParametrizedLine,
- ParametrizedLine<NewScalarType,AmbientDimAtCompileTime> >::type cast() const
- {
- return typename internal::cast_return_type<ParametrizedLine,
- ParametrizedLine<NewScalarType,AmbientDimAtCompileTime> >::type(*this);
- }
-
- /** Copy constructor with scalar type conversion */
- template<typename OtherScalarType>
- inline explicit ParametrizedLine(const ParametrizedLine<OtherScalarType,AmbientDimAtCompileTime>& other)
- {
- m_origin = other.origin().template cast<Scalar>();
- m_direction = other.direction().template cast<Scalar>();
- }
-
- /** \returns \c true if \c *this is approximately equal to \a other, within the precision
- * determined by \a prec.
- *
- * \sa MatrixBase::isApprox() */
- bool isApprox(const ParametrizedLine& other, typename NumTraits<Scalar>::Real prec = precision<Scalar>()) const
- { return m_origin.isApprox(other.m_origin, prec) && m_direction.isApprox(other.m_direction, prec); }
-
-protected:
-
- VectorType m_origin, m_direction;
-};
-
-/** Constructs a parametrized line from a 2D hyperplane
- *
- * \warning the ambient space must have dimension 2 such that the hyperplane actually describes a line
- */
-template <typename _Scalar, int _AmbientDim>
-inline ParametrizedLine<_Scalar, _AmbientDim>::ParametrizedLine(const Hyperplane<_Scalar, _AmbientDim>& hyperplane)
-{
- EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(VectorType, 2)
- direction() = hyperplane.normal().unitOrthogonal();
- origin() = -hyperplane.normal()*hyperplane.offset();
-}
-
-/** \returns the parameter value of the intersection between \c *this and the given hyperplane
- */
-template <typename _Scalar, int _AmbientDim>
-inline _Scalar ParametrizedLine<_Scalar, _AmbientDim>::intersection(const Hyperplane<_Scalar, _AmbientDim>& hyperplane)
-{
- return -(hyperplane.offset()+origin().eigen2_dot(hyperplane.normal()))
- /(direction().eigen2_dot(hyperplane.normal()));
-}
-
-} // end namespace Eigen
diff --git a/Eigen/src/Eigen2Support/Geometry/Quaternion.h b/Eigen/src/Eigen2Support/Geometry/Quaternion.h
deleted file mode 100644
index 4b6390cf1..000000000
--- a/Eigen/src/Eigen2Support/Geometry/Quaternion.h
+++ /dev/null
@@ -1,495 +0,0 @@
-// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra.
-//
-// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
-//
-// 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/.
-
-// no include guard, we'll include this twice from All.h from Eigen2Support, and it's internal anyway
-
-namespace Eigen {
-
-template<typename Other,
- int OtherRows=Other::RowsAtCompileTime,
- int OtherCols=Other::ColsAtCompileTime>
-struct ei_quaternion_assign_impl;
-
-/** \geometry_module \ingroup Geometry_Module
- *
- * \class Quaternion
- *
- * \brief The quaternion class used to represent 3D orientations and rotations
- *
- * \param _Scalar the scalar type, i.e., the type of the coefficients
- *
- * This class represents a quaternion \f$ w+xi+yj+zk \f$ that is a convenient representation of
- * orientations and rotations of objects in three dimensions. Compared to other representations
- * like Euler angles or 3x3 matrices, quatertions offer the following advantages:
- * \li \b compact storage (4 scalars)
- * \li \b efficient to compose (28 flops),
- * \li \b stable spherical interpolation
- *
- * The following two typedefs are provided for convenience:
- * \li \c Quaternionf for \c float
- * \li \c Quaterniond for \c double
- *
- * \sa class AngleAxis, class Transform
- */
-
-template<typename _Scalar> struct ei_traits<Quaternion<_Scalar> >
-{
- typedef _Scalar Scalar;
-};
-
-template<typename _Scalar>
-class Quaternion : public RotationBase<Quaternion<_Scalar>,3>
-{
- typedef RotationBase<Quaternion<_Scalar>,3> Base;
-
-public:
- EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,4)
-
- using Base::operator*;
-
- /** the scalar type of the coefficients */
- typedef _Scalar Scalar;
-
- /** the type of the Coefficients 4-vector */
- typedef Matrix<Scalar, 4, 1> Coefficients;
- /** the type of a 3D vector */
- typedef Matrix<Scalar,3,1> Vector3;
- /** the equivalent rotation matrix type */
- typedef Matrix<Scalar,3,3> Matrix3;
- /** the equivalent angle-axis type */
- typedef AngleAxis<Scalar> AngleAxisType;
-
- /** \returns the \c x coefficient */
- inline Scalar x() const { return m_coeffs.coeff(0); }
- /** \returns the \c y coefficient */
- inline Scalar y() const { return m_coeffs.coeff(1); }
- /** \returns the \c z coefficient */
- inline Scalar z() const { return m_coeffs.coeff(2); }
- /** \returns the \c w coefficient */
- inline Scalar w() const { return m_coeffs.coeff(3); }
-
- /** \returns a reference to the \c x coefficient */
- inline Scalar& x() { return m_coeffs.coeffRef(0); }
- /** \returns a reference to the \c y coefficient */
- inline Scalar& y() { return m_coeffs.coeffRef(1); }
- /** \returns a reference to the \c z coefficient */
- inline Scalar& z() { return m_coeffs.coeffRef(2); }
- /** \returns a reference to the \c w coefficient */
- inline Scalar& w() { return m_coeffs.coeffRef(3); }
-
- /** \returns a read-only vector expression of the imaginary part (x,y,z) */
- inline const Block<const Coefficients,3,1> vec() const { return m_coeffs.template start<3>(); }
-
- /** \returns a vector expression of the imaginary part (x,y,z) */
- inline Block<Coefficients,3,1> vec() { return m_coeffs.template start<3>(); }
-
- /** \returns a read-only vector expression of the coefficients (x,y,z,w) */
- inline const Coefficients& coeffs() const { return m_coeffs; }
-
- /** \returns a vector expression of the coefficients (x,y,z,w) */
- inline Coefficients& coeffs() { return m_coeffs; }
-
- /** Default constructor leaving the quaternion uninitialized. */
- inline Quaternion() {}
-
- /** Constructs and initializes the quaternion \f$ w+xi+yj+zk \f$ from
- * its four coefficients \a w, \a x, \a y and \a z.
- *
- * \warning Note the order of the arguments: the real \a w coefficient first,
- * while internally the coefficients are stored in the following order:
- * [\c x, \c y, \c z, \c w]
- */
- inline Quaternion(Scalar w, Scalar x, Scalar y, Scalar z)
- { m_coeffs << x, y, z, w; }
-
- /** Copy constructor */
- inline Quaternion(const Quaternion& other) { m_coeffs = other.m_coeffs; }
-
- /** Constructs and initializes a quaternion from the angle-axis \a aa */
- explicit inline Quaternion(const AngleAxisType& aa) { *this = aa; }
-
- /** Constructs and initializes a quaternion from either:
- * - a rotation matrix expression,
- * - a 4D vector expression representing quaternion coefficients.
- * \sa operator=(MatrixBase<Derived>)
- */
- template<typename Derived>
- explicit inline Quaternion(const MatrixBase<Derived>& other) { *this = other; }
-
- Quaternion& operator=(const Quaternion& other);
- Quaternion& operator=(const AngleAxisType& aa);
- template<typename Derived>
- Quaternion& operator=(const MatrixBase<Derived>& m);
-
- /** \returns a quaternion representing an identity rotation
- * \sa MatrixBase::Identity()
- */
- static inline Quaternion Identity() { return Quaternion(1, 0, 0, 0); }
-
- /** \sa Quaternion::Identity(), MatrixBase::setIdentity()
- */
- inline Quaternion& setIdentity() { m_coeffs << 0, 0, 0, 1; return *this; }
-
- /** \returns the squared norm of the quaternion's coefficients
- * \sa Quaternion::norm(), MatrixBase::squaredNorm()
- */
- inline Scalar squaredNorm() const { return m_coeffs.squaredNorm(); }
-
- /** \returns the norm of the quaternion's coefficients
- * \sa Quaternion::squaredNorm(), MatrixBase::norm()
- */
- inline Scalar norm() const { return m_coeffs.norm(); }
-
- /** Normalizes the quaternion \c *this
- * \sa normalized(), MatrixBase::normalize() */
- inline void normalize() { m_coeffs.normalize(); }
- /** \returns a normalized version of \c *this
- * \sa normalize(), MatrixBase::normalized() */
- inline Quaternion normalized() const { return Quaternion(m_coeffs.normalized()); }
-
- /** \returns the dot product of \c *this and \a other
- * Geometrically speaking, the dot product of two unit quaternions
- * corresponds to the cosine of half the angle between the two rotations.
- * \sa angularDistance()
- */
- inline Scalar eigen2_dot(const Quaternion& other) const { return m_coeffs.eigen2_dot(other.m_coeffs); }
-
- inline Scalar angularDistance(const Quaternion& other) const;
-
- Matrix3 toRotationMatrix(void) const;
-
- template<typename Derived1, typename Derived2>
- Quaternion& setFromTwoVectors(const MatrixBase<Derived1>& a, const MatrixBase<Derived2>& b);
-
- inline Quaternion operator* (const Quaternion& q) const;
- inline Quaternion& operator*= (const Quaternion& q);
-
- Quaternion inverse(void) const;
- Quaternion conjugate(void) const;
-
- Quaternion slerp(Scalar t, const Quaternion& other) const;
-
- template<typename Derived>
- Vector3 operator* (const MatrixBase<Derived>& vec) const;
-
- /** \returns \c *this with scalar type casted to \a NewScalarType
- *
- * Note that if \a NewScalarType is equal to the current scalar type of \c *this
- * then this function smartly returns a const reference to \c *this.
- */
- template<typename NewScalarType>
- inline typename internal::cast_return_type<Quaternion,Quaternion<NewScalarType> >::type cast() const
- { return typename internal::cast_return_type<Quaternion,Quaternion<NewScalarType> >::type(*this); }
-
- /** Copy constructor with scalar type conversion */
- template<typename OtherScalarType>
- inline explicit Quaternion(const Quaternion<OtherScalarType>& other)
- { m_coeffs = other.coeffs().template cast<Scalar>(); }
-
- /** \returns \c true if \c *this is approximately equal to \a other, within the precision
- * determined by \a prec.
- *
- * \sa MatrixBase::isApprox() */
- bool isApprox(const Quaternion& other, typename NumTraits<Scalar>::Real prec = precision<Scalar>()) const
- { return m_coeffs.isApprox(other.m_coeffs, prec); }
-
-protected:
- Coefficients m_coeffs;
-};
-
-/** \ingroup Geometry_Module
- * single precision quaternion type */
-typedef Quaternion<float> Quaternionf;
-/** \ingroup Geometry_Module
- * double precision quaternion type */
-typedef Quaternion<double> Quaterniond;
-
-// Generic Quaternion * Quaternion product
-template<typename Scalar> inline Quaternion<Scalar>
-ei_quaternion_product(const Quaternion<Scalar>& a, const Quaternion<Scalar>& b)
-{
- return Quaternion<Scalar>
- (
- a.w() * b.w() - a.x() * b.x() - a.y() * b.y() - a.z() * b.z(),
- a.w() * b.x() + a.x() * b.w() + a.y() * b.z() - a.z() * b.y(),
- a.w() * b.y() + a.y() * b.w() + a.z() * b.x() - a.x() * b.z(),
- a.w() * b.z() + a.z() * b.w() + a.x() * b.y() - a.y() * b.x()
- );
-}
-
-/** \returns the concatenation of two rotations as a quaternion-quaternion product */
-template <typename Scalar>
-inline Quaternion<Scalar> Quaternion<Scalar>::operator* (const Quaternion& other) const
-{
- return ei_quaternion_product(*this,other);
-}
-
-/** \sa operator*(Quaternion) */
-template <typename Scalar>
-inline Quaternion<Scalar>& Quaternion<Scalar>::operator*= (const Quaternion& other)
-{
- return (*this = *this * other);
-}
-
-/** Rotation of a vector by a quaternion.
- * \remarks If the quaternion is used to rotate several points (>1)
- * then it is much more efficient to first convert it to a 3x3 Matrix.
- * Comparison of the operation cost for n transformations:
- * - Quaternion: 30n
- * - Via a Matrix3: 24 + 15n
- */
-template <typename Scalar>
-template<typename Derived>
-inline typename Quaternion<Scalar>::Vector3
-Quaternion<Scalar>::operator* (const MatrixBase<Derived>& v) const
-{
- // Note that this algorithm comes from the optimization by hand
- // of the conversion to a Matrix followed by a Matrix/Vector product.
- // It appears to be much faster than the common algorithm found
- // in the litterature (30 versus 39 flops). It also requires two
- // Vector3 as temporaries.
- Vector3 uv;
- uv = 2 * this->vec().cross(v);
- return v + this->w() * uv + this->vec().cross(uv);
-}
-
-template<typename Scalar>
-inline Quaternion<Scalar>& Quaternion<Scalar>::operator=(const Quaternion& other)
-{
- m_coeffs = other.m_coeffs;
- return *this;
-}
-
-/** Set \c *this from an angle-axis \a aa and returns a reference to \c *this
- */
-template<typename Scalar>
-inline Quaternion<Scalar>& Quaternion<Scalar>::operator=(const AngleAxisType& aa)
-{
- Scalar ha = Scalar(0.5)*aa.angle(); // Scalar(0.5) to suppress precision loss warnings
- this->w() = ei_cos(ha);
- this->vec() = ei_sin(ha) * aa.axis();
- return *this;
-}
-
-/** Set \c *this from the expression \a xpr:
- * - if \a xpr is a 4x1 vector, then \a xpr is assumed to be a quaternion
- * - if \a xpr is a 3x3 matrix, then \a xpr is assumed to be rotation matrix
- * and \a xpr is converted to a quaternion
- */
-template<typename Scalar>
-template<typename Derived>
-inline Quaternion<Scalar>& Quaternion<Scalar>::operator=(const MatrixBase<Derived>& xpr)
-{
- ei_quaternion_assign_impl<Derived>::run(*this, xpr.derived());
- return *this;
-}
-
-/** Convert the quaternion to a 3x3 rotation matrix */
-template<typename Scalar>
-inline typename Quaternion<Scalar>::Matrix3
-Quaternion<Scalar>::toRotationMatrix(void) const
-{
- // NOTE if inlined, then gcc 4.2 and 4.4 get rid of the temporary (not gcc 4.3 !!)
- // if not inlined then the cost of the return by value is huge ~ +35%,
- // however, not inlining this function is an order of magnitude slower, so
- // it has to be inlined, and so the return by value is not an issue
- Matrix3 res;
-
- const Scalar tx = Scalar(2)*this->x();
- const Scalar ty = Scalar(2)*this->y();
- const Scalar tz = Scalar(2)*this->z();
- const Scalar twx = tx*this->w();
- const Scalar twy = ty*this->w();
- const Scalar twz = tz*this->w();
- const Scalar txx = tx*this->x();
- const Scalar txy = ty*this->x();
- const Scalar txz = tz*this->x();
- const Scalar tyy = ty*this->y();
- const Scalar tyz = tz*this->y();
- const Scalar tzz = tz*this->z();
-
- res.coeffRef(0,0) = Scalar(1)-(tyy+tzz);
- res.coeffRef(0,1) = txy-twz;
- res.coeffRef(0,2) = txz+twy;
- res.coeffRef(1,0) = txy+twz;
- res.coeffRef(1,1) = Scalar(1)-(txx+tzz);
- res.coeffRef(1,2) = tyz-twx;
- res.coeffRef(2,0) = txz-twy;
- res.coeffRef(2,1) = tyz+twx;
- res.coeffRef(2,2) = Scalar(1)-(txx+tyy);
-
- return res;
-}
-
-/** Sets *this to be a quaternion representing a rotation sending the vector \a a to the vector \a b.
- *
- * \returns a reference to *this.
- *
- * Note that the two input vectors do \b not have to be normalized.
- */
-template<typename Scalar>
-template<typename Derived1, typename Derived2>
-inline Quaternion<Scalar>& Quaternion<Scalar>::setFromTwoVectors(const MatrixBase<Derived1>& a, const MatrixBase<Derived2>& b)
-{
- Vector3 v0 = a.normalized();
- Vector3 v1 = b.normalized();
- Scalar c = v0.eigen2_dot(v1);
-
- // if dot == 1, vectors are the same
- if (ei_isApprox(c,Scalar(1)))
- {
- // set to identity
- this->w() = 1; this->vec().setZero();
- return *this;
- }
- // if dot == -1, vectors are opposites
- if (ei_isApprox(c,Scalar(-1)))
- {
- this->vec() = v0.unitOrthogonal();
- this->w() = 0;
- return *this;
- }
-
- Vector3 axis = v0.cross(v1);
- Scalar s = ei_sqrt((Scalar(1)+c)*Scalar(2));
- Scalar invs = Scalar(1)/s;
- this->vec() = axis * invs;
- this->w() = s * Scalar(0.5);
-
- return *this;
-}
-
-/** \returns the multiplicative inverse of \c *this
- * Note that in most cases, i.e., if you simply want the opposite rotation,
- * and/or the quaternion is normalized, then it is enough to use the conjugate.
- *
- * \sa Quaternion::conjugate()
- */
-template <typename Scalar>
-inline Quaternion<Scalar> Quaternion<Scalar>::inverse() const
-{
- // FIXME should this function be called multiplicativeInverse and conjugate() be called inverse() or opposite() ??
- Scalar n2 = this->squaredNorm();
- if (n2 > 0)
- return Quaternion(conjugate().coeffs() / n2);
- else
- {
- // return an invalid result to flag the error
- return Quaternion(Coefficients::Zero());
- }
-}
-
-/** \returns the conjugate of the \c *this which is equal to the multiplicative inverse
- * if the quaternion is normalized.
- * The conjugate of a quaternion represents the opposite rotation.
- *
- * \sa Quaternion::inverse()
- */
-template <typename Scalar>
-inline Quaternion<Scalar> Quaternion<Scalar>::conjugate() const
-{
- return Quaternion(this->w(),-this->x(),-this->y(),-this->z());
-}
-
-/** \returns the angle (in radian) between two rotations
- * \sa eigen2_dot()
- */
-template <typename Scalar>
-inline Scalar Quaternion<Scalar>::angularDistance(const Quaternion& other) const
-{
- double d = ei_abs(this->eigen2_dot(other));
- if (d>=1.0)
- return 0;
- return Scalar(2) * std::acos(d);
-}
-
-/** \returns the spherical linear interpolation between the two quaternions
- * \c *this and \a other at the parameter \a t
- */
-template <typename Scalar>
-Quaternion<Scalar> Quaternion<Scalar>::slerp(Scalar t, const Quaternion& other) const
-{
- static const Scalar one = Scalar(1) - machine_epsilon<Scalar>();
- Scalar d = this->eigen2_dot(other);
- Scalar absD = ei_abs(d);
-
- Scalar scale0;
- Scalar scale1;
-
- if (absD>=one)
- {
- scale0 = Scalar(1) - t;
- scale1 = t;
- }
- else
- {
- // theta is the angle between the 2 quaternions
- Scalar theta = std::acos(absD);
- Scalar sinTheta = ei_sin(theta);
-
- scale0 = ei_sin( ( Scalar(1) - t ) * theta) / sinTheta;
- scale1 = ei_sin( ( t * theta) ) / sinTheta;
- if (d<0)
- scale1 = -scale1;
- }
-
- return Quaternion<Scalar>(scale0 * coeffs() + scale1 * other.coeffs());
-}
-
-// set from a rotation matrix
-template<typename Other>
-struct ei_quaternion_assign_impl<Other,3,3>
-{
- typedef typename Other::Scalar Scalar;
- static inline void run(Quaternion<Scalar>& q, const Other& mat)
- {
- // This algorithm comes from "Quaternion Calculus and Fast Animation",
- // Ken Shoemake, 1987 SIGGRAPH course notes
- Scalar t = mat.trace();
- if (t > 0)
- {
- t = ei_sqrt(t + Scalar(1.0));
- q.w() = Scalar(0.5)*t;
- t = Scalar(0.5)/t;
- q.x() = (mat.coeff(2,1) - mat.coeff(1,2)) * t;
- q.y() = (mat.coeff(0,2) - mat.coeff(2,0)) * t;
- q.z() = (mat.coeff(1,0) - mat.coeff(0,1)) * t;
- }
- else
- {
- int i = 0;
- if (mat.coeff(1,1) > mat.coeff(0,0))
- i = 1;
- if (mat.coeff(2,2) > mat.coeff(i,i))
- i = 2;
- int j = (i+1)%3;
- int k = (j+1)%3;
-
- t = ei_sqrt(mat.coeff(i,i)-mat.coeff(j,j)-mat.coeff(k,k) + Scalar(1.0));
- q.coeffs().coeffRef(i) = Scalar(0.5) * t;
- t = Scalar(0.5)/t;
- q.w() = (mat.coeff(k,j)-mat.coeff(j,k))*t;
- q.coeffs().coeffRef(j) = (mat.coeff(j,i)+mat.coeff(i,j))*t;
- q.coeffs().coeffRef(k) = (mat.coeff(k,i)+mat.coeff(i,k))*t;
- }
- }
-};
-
-// set from a vector of coefficients assumed to be a quaternion
-template<typename Other>
-struct ei_quaternion_assign_impl<Other,4,1>
-{
- typedef typename Other::Scalar Scalar;
- static inline void run(Quaternion<Scalar>& q, const Other& vec)
- {
- q.coeffs() = vec;
- }
-};
-
-} // end namespace Eigen
diff --git a/Eigen/src/Eigen2Support/Geometry/Rotation2D.h b/Eigen/src/Eigen2Support/Geometry/Rotation2D.h
deleted file mode 100644
index 19b8582a1..000000000
--- a/Eigen/src/Eigen2Support/Geometry/Rotation2D.h
+++ /dev/null
@@ -1,145 +0,0 @@
-// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra.
-//
-// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
-//
-// 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/.
-
-// no include guard, we'll include this twice from All.h from Eigen2Support, and it's internal anyway
-
-namespace Eigen {
-
-/** \geometry_module \ingroup Geometry_Module
- *
- * \class Rotation2D
- *
- * \brief Represents a rotation/orientation in a 2 dimensional space.
- *
- * \param _Scalar the scalar type, i.e., the type of the coefficients
- *
- * This class is equivalent to a single scalar representing a counter clock wise rotation
- * as a single angle in radian. It provides some additional features such as the automatic
- * conversion from/to a 2x2 rotation matrix. Moreover this class aims to provide a similar
- * interface to Quaternion in order to facilitate the writing of generic algorithms
- * dealing with rotations.
- *
- * \sa class Quaternion, class Transform
- */
-template<typename _Scalar> struct ei_traits<Rotation2D<_Scalar> >
-{
- typedef _Scalar Scalar;
-};
-
-template<typename _Scalar>
-class Rotation2D : public RotationBase<Rotation2D<_Scalar>,2>
-{
- typedef RotationBase<Rotation2D<_Scalar>,2> Base;
-
-public:
-
- using Base::operator*;
-
- enum { Dim = 2 };
- /** the scalar type of the coefficients */
- typedef _Scalar Scalar;
- typedef Matrix<Scalar,2,1> Vector2;
- typedef Matrix<Scalar,2,2> Matrix2;
-
-protected:
-
- Scalar m_angle;
-
-public:
-
- /** Construct a 2D counter clock wise rotation from the angle \a a in radian. */
- inline Rotation2D(Scalar a) : m_angle(a) {}
-
- /** \returns the rotation angle */
- inline Scalar angle() const { return m_angle; }
-
- /** \returns a read-write reference to the rotation angle */
- inline Scalar& angle() { return m_angle; }
-
- /** \returns the inverse rotation */
- inline Rotation2D inverse() const { return -m_angle; }
-
- /** Concatenates two rotations */
- inline Rotation2D operator*(const Rotation2D& other) const
- { return m_angle + other.m_angle; }
-
- /** Concatenates two rotations */
- inline Rotation2D& operator*=(const Rotation2D& other)
- { return m_angle += other.m_angle; return *this; }
-
- /** Applies the rotation to a 2D vector */
- Vector2 operator* (const Vector2& vec) const
- { return toRotationMatrix() * vec; }
-
- template<typename Derived>
- Rotation2D& fromRotationMatrix(const MatrixBase<Derived>& m);
- Matrix2 toRotationMatrix(void) const;
-
- /** \returns the spherical interpolation between \c *this and \a other using
- * parameter \a t. It is in fact equivalent to a linear interpolation.
- */
- inline Rotation2D slerp(Scalar t, const Rotation2D& other) const
- { return m_angle * (1-t) + other.angle() * t; }
-
- /** \returns \c *this with scalar type casted to \a NewScalarType
- *
- * Note that if \a NewScalarType is equal to the current scalar type of \c *this
- * then this function smartly returns a const reference to \c *this.
- */
- template<typename NewScalarType>
- inline typename internal::cast_return_type<Rotation2D,Rotation2D<NewScalarType> >::type cast() const
- { return typename internal::cast_return_type<Rotation2D,Rotation2D<NewScalarType> >::type(*this); }
-
- /** Copy constructor with scalar type conversion */
- template<typename OtherScalarType>
- inline explicit Rotation2D(const Rotation2D<OtherScalarType>& other)
- {
- m_angle = Scalar(other.angle());
- }
-
- /** \returns \c true if \c *this is approximately equal to \a other, within the precision
- * determined by \a prec.
- *
- * \sa MatrixBase::isApprox() */
- bool isApprox(const Rotation2D& other, typename NumTraits<Scalar>::Real prec = precision<Scalar>()) const
- { return ei_isApprox(m_angle,other.m_angle, prec); }
-};
-
-/** \ingroup Geometry_Module
- * single precision 2D rotation type */
-typedef Rotation2D<float> Rotation2Df;
-/** \ingroup Geometry_Module
- * double precision 2D rotation type */
-typedef Rotation2D<double> Rotation2Dd;
-
-/** Set \c *this from a 2x2 rotation matrix \a mat.
- * In other words, this function extract the rotation angle
- * from the rotation matrix.
- */
-template<typename Scalar>
-template<typename Derived>
-Rotation2D<Scalar>& Rotation2D<Scalar>::fromRotationMatrix(const MatrixBase<Derived>& mat)
-{
- EIGEN_STATIC_ASSERT(Derived::RowsAtCompileTime==2 && Derived::ColsAtCompileTime==2,YOU_MADE_A_PROGRAMMING_MISTAKE)
- m_angle = ei_atan2(mat.coeff(1,0), mat.coeff(0,0));
- return *this;
-}
-
-/** Constructs and \returns an equivalent 2x2 rotation matrix.
- */
-template<typename Scalar>
-typename Rotation2D<Scalar>::Matrix2
-Rotation2D<Scalar>::toRotationMatrix(void) const
-{
- Scalar sinA = ei_sin(m_angle);
- Scalar cosA = ei_cos(m_angle);
- return (Matrix2() << cosA, -sinA, sinA, cosA).finished();
-}
-
-} // end namespace Eigen
diff --git a/Eigen/src/Eigen2Support/Geometry/RotationBase.h b/Eigen/src/Eigen2Support/Geometry/RotationBase.h
deleted file mode 100644
index b1c8f38da..000000000
--- a/Eigen/src/Eigen2Support/Geometry/RotationBase.h
+++ /dev/null
@@ -1,123 +0,0 @@
-// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra.
-//
-// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
-//
-// 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/.
-
-// no include guard, we'll include this twice from All.h from Eigen2Support, and it's internal anyway
-
-namespace Eigen {
-
-// this file aims to contains the various representations of rotation/orientation
-// in 2D and 3D space excepted Matrix and Quaternion.
-
-/** \class RotationBase
- *
- * \brief Common base class for compact rotation representations
- *
- * \param Derived is the derived type, i.e., a rotation type
- * \param _Dim the dimension of the space
- */
-template<typename Derived, int _Dim>
-class RotationBase
-{
- public:
- enum { Dim = _Dim };
- /** the scalar type of the coefficients */
- typedef typename ei_traits<Derived>::Scalar Scalar;
-
- /** corresponding linear transformation matrix type */
- typedef Matrix<Scalar,Dim,Dim> RotationMatrixType;
-
- inline const Derived& derived() const { return *static_cast<const Derived*>(this); }
- inline Derived& derived() { return *static_cast<Derived*>(this); }
-
- /** \returns an equivalent rotation matrix */
- inline RotationMatrixType toRotationMatrix() const { return derived().toRotationMatrix(); }
-
- /** \returns the inverse rotation */
- inline Derived inverse() const { return derived().inverse(); }
-
- /** \returns the concatenation of the rotation \c *this with a translation \a t */
- inline Transform<Scalar,Dim> operator*(const Translation<Scalar,Dim>& t) const
- { return toRotationMatrix() * t; }
-
- /** \returns the concatenation of the rotation \c *this with a scaling \a s */
- inline RotationMatrixType operator*(const Scaling<Scalar,Dim>& s) const
- { return toRotationMatrix() * s; }
-
- /** \returns the concatenation of the rotation \c *this with an affine transformation \a t */
- inline Transform<Scalar,Dim> operator*(const Transform<Scalar,Dim>& t) const
- { return toRotationMatrix() * t; }
-};
-
-/** \geometry_module
- *
- * Constructs a Dim x Dim rotation matrix from the rotation \a r
- */
-template<typename _Scalar, int _Rows, int _Cols, int _Storage, int _MaxRows, int _MaxCols>
-template<typename OtherDerived>
-Matrix<_Scalar, _Rows, _Cols, _Storage, _MaxRows, _MaxCols>
-::Matrix(const RotationBase<OtherDerived,ColsAtCompileTime>& r)
-{
- EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Matrix,int(OtherDerived::Dim),int(OtherDerived::Dim))
- *this = r.toRotationMatrix();
-}
-
-/** \geometry_module
- *
- * Set a Dim x Dim rotation matrix from the rotation \a r
- */
-template<typename _Scalar, int _Rows, int _Cols, int _Storage, int _MaxRows, int _MaxCols>
-template<typename OtherDerived>
-Matrix<_Scalar, _Rows, _Cols, _Storage, _MaxRows, _MaxCols>&
-Matrix<_Scalar, _Rows, _Cols, _Storage, _MaxRows, _MaxCols>
-::operator=(const RotationBase<OtherDerived,ColsAtCompileTime>& r)
-{
- EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Matrix,int(OtherDerived::Dim),int(OtherDerived::Dim))
- return *this = r.toRotationMatrix();
-}
-
-/** \internal
- *
- * Helper function to return an arbitrary rotation object to a rotation matrix.
- *
- * \param Scalar the numeric type of the matrix coefficients
- * \param Dim the dimension of the current space
- *
- * It returns a Dim x Dim fixed size matrix.
- *
- * Default specializations are provided for:
- * - any scalar type (2D),
- * - any matrix expression,
- * - any type based on RotationBase (e.g., Quaternion, AngleAxis, Rotation2D)
- *
- * Currently ei_toRotationMatrix is only used by Transform.
- *
- * \sa class Transform, class Rotation2D, class Quaternion, class AngleAxis
- */
-template<typename Scalar, int Dim>
-static inline Matrix<Scalar,2,2> ei_toRotationMatrix(const Scalar& s)
-{
- EIGEN_STATIC_ASSERT(Dim==2,YOU_MADE_A_PROGRAMMING_MISTAKE)
- return Rotation2D<Scalar>(s).toRotationMatrix();
-}
-
-template<typename Scalar, int Dim, typename OtherDerived>
-static inline Matrix<Scalar,Dim,Dim> ei_toRotationMatrix(const RotationBase<OtherDerived,Dim>& r)
-{
- return r.toRotationMatrix();
-}
-
-template<typename Scalar, int Dim, typename OtherDerived>
-static inline const MatrixBase<OtherDerived>& ei_toRotationMatrix(const MatrixBase<OtherDerived>& mat)
-{
- EIGEN_STATIC_ASSERT(OtherDerived::RowsAtCompileTime==Dim && OtherDerived::ColsAtCompileTime==Dim,
- YOU_MADE_A_PROGRAMMING_MISTAKE)
- return mat;
-}
-
-} // end namespace Eigen
diff --git a/Eigen/src/Eigen2Support/Geometry/Scaling.h b/Eigen/src/Eigen2Support/Geometry/Scaling.h
deleted file mode 100644
index b8fa6cd3f..000000000
--- a/Eigen/src/Eigen2Support/Geometry/Scaling.h
+++ /dev/null
@@ -1,167 +0,0 @@
-// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra.
-//
-// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
-//
-// 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/.
-
-// no include guard, we'll include this twice from All.h from Eigen2Support, and it's internal anyway
-
-namespace Eigen {
-
-/** \geometry_module \ingroup Geometry_Module
- *
- * \class Scaling
- *
- * \brief Represents a possibly non uniform scaling transformation
- *
- * \param _Scalar the scalar type, i.e., the type of the coefficients.
- * \param _Dim the dimension of the space, can be a compile time value or Dynamic
- *
- * \note This class is not aimed to be used to store a scaling transformation,
- * but rather to make easier the constructions and updates of Transform objects.
- *
- * \sa class Translation, class Transform
- */
-template<typename _Scalar, int _Dim>
-class Scaling
-{
-public:
- EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_Dim)
- /** dimension of the space */
- enum { Dim = _Dim };
- /** the scalar type of the coefficients */
- typedef _Scalar Scalar;
- /** corresponding vector type */
- typedef Matrix<Scalar,Dim,1> VectorType;
- /** corresponding linear transformation matrix type */
- typedef Matrix<Scalar,Dim,Dim> LinearMatrixType;
- /** corresponding translation type */
- typedef Translation<Scalar,Dim> TranslationType;
- /** corresponding affine transformation type */
- typedef Transform<Scalar,Dim> TransformType;
-
-protected:
-
- VectorType m_coeffs;
-
-public:
-
- /** Default constructor without initialization. */
- Scaling() {}
- /** Constructs and initialize a uniform scaling transformation */
- explicit inline Scaling(const Scalar& s) { m_coeffs.setConstant(s); }
- /** 2D only */
- inline Scaling(const Scalar& sx, const Scalar& sy)
- {
- ei_assert(Dim==2);
- m_coeffs.x() = sx;
- m_coeffs.y() = sy;
- }
- /** 3D only */
- inline Scaling(const Scalar& sx, const Scalar& sy, const Scalar& sz)
- {
- ei_assert(Dim==3);
- m_coeffs.x() = sx;
- m_coeffs.y() = sy;
- m_coeffs.z() = sz;
- }
- /** Constructs and initialize the scaling transformation from a vector of scaling coefficients */
- explicit inline Scaling(const VectorType& coeffs) : m_coeffs(coeffs) {}
-
- const VectorType& coeffs() const { return m_coeffs; }
- VectorType& coeffs() { return m_coeffs; }
-
- /** Concatenates two scaling */
- inline Scaling operator* (const Scaling& other) const
- { return Scaling(coeffs().cwise() * other.coeffs()); }
-
- /** Concatenates a scaling and a translation */
- inline TransformType operator* (const TranslationType& t) const;
-
- /** Concatenates a scaling and an affine transformation */
- inline TransformType operator* (const TransformType& t) const;
-
- /** Concatenates a scaling and a linear transformation matrix */
- // TODO returns an expression
- inline LinearMatrixType operator* (const LinearMatrixType& other) const
- { return coeffs().asDiagonal() * other; }
-
- /** Concatenates a linear transformation matrix and a scaling */
- // TODO returns an expression
- friend inline LinearMatrixType operator* (const LinearMatrixType& other, const Scaling& s)
- { return other * s.coeffs().asDiagonal(); }
-
- template<typename Derived>
- inline LinearMatrixType operator*(const RotationBase<Derived,Dim>& r) const
- { return *this * r.toRotationMatrix(); }
-
- /** Applies scaling to vector */
- inline VectorType operator* (const VectorType& other) const
- { return coeffs().asDiagonal() * other; }
-
- /** \returns the inverse scaling */
- inline Scaling inverse() const
- { return Scaling(coeffs().cwise().inverse()); }
-
- inline Scaling& operator=(const Scaling& other)
- {
- m_coeffs = other.m_coeffs;
- return *this;
- }
-
- /** \returns \c *this with scalar type casted to \a NewScalarType
- *
- * Note that if \a NewScalarType is equal to the current scalar type of \c *this
- * then this function smartly returns a const reference to \c *this.
- */
- template<typename NewScalarType>
- inline typename internal::cast_return_type<Scaling,Scaling<NewScalarType,Dim> >::type cast() const
- { return typename internal::cast_return_type<Scaling,Scaling<NewScalarType,Dim> >::type(*this); }
-
- /** Copy constructor with scalar type conversion */
- template<typename OtherScalarType>
- inline explicit Scaling(const Scaling<OtherScalarType,Dim>& other)
- { m_coeffs = other.coeffs().template cast<Scalar>(); }
-
- /** \returns \c true if \c *this is approximately equal to \a other, within the precision
- * determined by \a prec.
- *
- * \sa MatrixBase::isApprox() */
- bool isApprox(const Scaling& other, typename NumTraits<Scalar>::Real prec = precision<Scalar>()) const
- { return m_coeffs.isApprox(other.m_coeffs, prec); }
-
-};
-
-/** \addtogroup Geometry_Module */
-//@{
-typedef Scaling<float, 2> Scaling2f;
-typedef Scaling<double,2> Scaling2d;
-typedef Scaling<float, 3> Scaling3f;
-typedef Scaling<double,3> Scaling3d;
-//@}
-
-template<typename Scalar, int Dim>
-inline typename Scaling<Scalar,Dim>::TransformType
-Scaling<Scalar,Dim>::operator* (const TranslationType& t) const
-{
- TransformType res;
- res.matrix().setZero();
- res.linear().diagonal() = coeffs();
- res.translation() = m_coeffs.cwise() * t.vector();
- res(Dim,Dim) = Scalar(1);
- return res;
-}
-
-template<typename Scalar, int Dim>
-inline typename Scaling<Scalar,Dim>::TransformType
-Scaling<Scalar,Dim>::operator* (const TransformType& t) const
-{
- TransformType res = t;
- res.prescale(m_coeffs);
- return res;
-}
-
-} // end namespace Eigen
diff --git a/Eigen/src/Eigen2Support/Geometry/Transform.h b/Eigen/src/Eigen2Support/Geometry/Transform.h
deleted file mode 100644
index fab60b251..000000000
--- a/Eigen/src/Eigen2Support/Geometry/Transform.h
+++ /dev/null
@@ -1,786 +0,0 @@
-// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra.
-//
-// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
-// Copyright (C) 2009 Benoit Jacob <jacob.benoit.1@gmail.com>
-//
-// 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/.
-
-// no include guard, we'll include this twice from All.h from Eigen2Support, and it's internal anyway
-
-namespace Eigen {
-
-// Note that we have to pass Dim and HDim because it is not allowed to use a template
-// parameter to define a template specialization. To be more precise, in the following
-// specializations, it is not allowed to use Dim+1 instead of HDim.
-template< typename Other,
- int Dim,
- int HDim,
- int OtherRows=Other::RowsAtCompileTime,
- int OtherCols=Other::ColsAtCompileTime>
-struct ei_transform_product_impl;
-
-/** \geometry_module \ingroup Geometry_Module
- *
- * \class Transform
- *
- * \brief Represents an homogeneous transformation in a N dimensional space
- *
- * \param _Scalar the scalar type, i.e., the type of the coefficients
- * \param _Dim the dimension of the space
- *
- * The homography is internally represented and stored as a (Dim+1)^2 matrix which
- * is available through the matrix() method.
- *
- * Conversion methods from/to Qt's QMatrix and QTransform are available if the
- * preprocessor token EIGEN_QT_SUPPORT is defined.
- *
- * \sa class Matrix, class Quaternion
- */
-template<typename _Scalar, int _Dim>
-class Transform
-{
-public:
- EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_Dim==Dynamic ? Dynamic : (_Dim+1)*(_Dim+1))
- enum {
- Dim = _Dim, ///< space dimension in which the transformation holds
- HDim = _Dim+1 ///< size of a respective homogeneous vector
- };
- /** the scalar type of the coefficients */
- typedef _Scalar Scalar;
- /** type of the matrix used to represent the transformation */
- typedef Matrix<Scalar,HDim,HDim> MatrixType;
- /** type of the matrix used to represent the linear part of the transformation */
- typedef Matrix<Scalar,Dim,Dim> LinearMatrixType;
- /** type of read/write reference to the linear part of the transformation */
- typedef Block<MatrixType,Dim,Dim> LinearPart;
- /** type of read/write reference to the linear part of the transformation */
- typedef const Block<const MatrixType,Dim,Dim> ConstLinearPart;
- /** type of a vector */
- typedef Matrix<Scalar,Dim,1> VectorType;
- /** type of a read/write reference to the translation part of the rotation */
- typedef Block<MatrixType,Dim,1> TranslationPart;
- /** type of a read/write reference to the translation part of the rotation */
- typedef const Block<const MatrixType,Dim,1> ConstTranslationPart;
- /** corresponding translation type */
- typedef Translation<Scalar,Dim> TranslationType;
- /** corresponding scaling transformation type */
- typedef Scaling<Scalar,Dim> ScalingType;
-
-protected:
-
- MatrixType m_matrix;
-
-public:
-
- /** Default constructor without initialization of the coefficients. */
- inline Transform() { }
-
- inline Transform(const Transform& other)
- {
- m_matrix = other.m_matrix;
- }
-
- inline explicit Transform(const TranslationType& t) { *this = t; }
- inline explicit Transform(const ScalingType& s) { *this = s; }
- template<typename Derived>
- inline explicit Transform(const RotationBase<Derived, Dim>& r) { *this = r; }
-
- inline Transform& operator=(const Transform& other)
- { m_matrix = other.m_matrix; return *this; }
-
- template<typename OtherDerived, bool BigMatrix> // MSVC 2005 will commit suicide if BigMatrix has a default value
- struct construct_from_matrix
- {
- static inline void run(Transform *transform, const MatrixBase<OtherDerived>& other)
- {
- transform->matrix() = other;
- }
- };
-
- template<typename OtherDerived> struct construct_from_matrix<OtherDerived, true>
- {
- static inline void run(Transform *transform, const MatrixBase<OtherDerived>& other)
- {
- transform->linear() = other;
- transform->translation().setZero();
- transform->matrix()(Dim,Dim) = Scalar(1);
- transform->matrix().template block<1,Dim>(Dim,0).setZero();
- }
- };
-
- /** Constructs and initializes a transformation from a Dim^2 or a (Dim+1)^2 matrix. */
- template<typename OtherDerived>
- inline explicit Transform(const MatrixBase<OtherDerived>& other)
- {
- construct_from_matrix<OtherDerived, int(OtherDerived::RowsAtCompileTime) == Dim>::run(this, other);
- }
-
- /** Set \c *this from a (Dim+1)^2 matrix. */
- template<typename OtherDerived>
- inline Transform& operator=(const MatrixBase<OtherDerived>& other)
- { m_matrix = other; return *this; }
-
- #ifdef EIGEN_QT_SUPPORT
- inline Transform(const QMatrix& other);
- inline Transform& operator=(const QMatrix& other);
- inline QMatrix toQMatrix(void) const;
- inline Transform(const QTransform& other);
- inline Transform& operator=(const QTransform& other);
- inline QTransform toQTransform(void) const;
- #endif
-
- /** shortcut for m_matrix(row,col);
- * \sa MatrixBase::operaror(int,int) const */
- inline Scalar operator() (int row, int col) const { return m_matrix(row,col); }
- /** shortcut for m_matrix(row,col);
- * \sa MatrixBase::operaror(int,int) */
- inline Scalar& operator() (int row, int col) { return m_matrix(row,col); }
-
- /** \returns a read-only expression of the transformation matrix */
- inline const MatrixType& matrix() const { return m_matrix; }
- /** \returns a writable expression of the transformation matrix */
- inline MatrixType& matrix() { return m_matrix; }
-
- /** \returns a read-only expression of the linear (linear) part of the transformation */
- inline ConstLinearPart linear() const { return m_matrix.template block<Dim,Dim>(0,0); }
- /** \returns a writable expression of the linear (linear) part of the transformation */
- inline LinearPart linear() { return m_matrix.template block<Dim,Dim>(0,0); }
-
- /** \returns a read-only expression of the translation vector of the transformation */
- inline ConstTranslationPart translation() const { return m_matrix.template block<Dim,1>(0,Dim); }
- /** \returns a writable expression of the translation vector of the transformation */
- inline TranslationPart translation() { return m_matrix.template block<Dim,1>(0,Dim); }
-
- /** \returns an expression of the product between the transform \c *this and a matrix expression \a other
- *
- * The right hand side \a other might be either:
- * \li a vector of size Dim,
- * \li an homogeneous vector of size Dim+1,
- * \li a transformation matrix of size Dim+1 x Dim+1.
- */
- // note: this function is defined here because some compilers cannot find the respective declaration
- template<typename OtherDerived>
- inline const typename ei_transform_product_impl<OtherDerived,_Dim,_Dim+1>::ResultType
- operator * (const MatrixBase<OtherDerived> &other) const
- { return ei_transform_product_impl<OtherDerived,Dim,HDim>::run(*this,other.derived()); }
-
- /** \returns the product expression of a transformation matrix \a a times a transform \a b
- * The transformation matrix \a a must have a Dim+1 x Dim+1 sizes. */
- template<typename OtherDerived>
- friend inline const typename ProductReturnType<OtherDerived,MatrixType>::Type
- operator * (const MatrixBase<OtherDerived> &a, const Transform &b)
- { return a.derived() * b.matrix(); }
-
- /** Contatenates two transformations */
- inline const Transform
- operator * (const Transform& other) const
- { return Transform(m_matrix * other.matrix()); }
-
- /** \sa MatrixBase::setIdentity() */
- void setIdentity() { m_matrix.setIdentity(); }
- static const typename MatrixType::IdentityReturnType Identity()
- {
- return MatrixType::Identity();
- }
-
- template<typename OtherDerived>
- inline Transform& scale(const MatrixBase<OtherDerived> &other);
-
- template<typename OtherDerived>
- inline Transform& prescale(const MatrixBase<OtherDerived> &other);
-
- inline Transform& scale(Scalar s);
- inline Transform& prescale(Scalar s);
-
- template<typename OtherDerived>
- inline Transform& translate(const MatrixBase<OtherDerived> &other);
-
- template<typename OtherDerived>
- inline Transform& pretranslate(const MatrixBase<OtherDerived> &other);
-
- template<typename RotationType>
- inline Transform& rotate(const RotationType& rotation);
-
- template<typename RotationType>
- inline Transform& prerotate(const RotationType& rotation);
-
- Transform& shear(Scalar sx, Scalar sy);
- Transform& preshear(Scalar sx, Scalar sy);
-
- inline Transform& operator=(const TranslationType& t);
- inline Transform& operator*=(const TranslationType& t) { return translate(t.vector()); }
- inline Transform operator*(const TranslationType& t) const;
-
- inline Transform& operator=(const ScalingType& t);
- inline Transform& operator*=(const ScalingType& s) { return scale(s.coeffs()); }
- inline Transform operator*(const ScalingType& s) const;
- friend inline Transform operator*(const LinearMatrixType& mat, const Transform& t)
- {
- Transform res = t;
- res.matrix().row(Dim) = t.matrix().row(Dim);
- res.matrix().template block<Dim,HDim>(0,0) = (mat * t.matrix().template block<Dim,HDim>(0,0)).lazy();
- return res;
- }
-
- template<typename Derived>
- inline Transform& operator=(const RotationBase<Derived,Dim>& r);
- template<typename Derived>
- inline Transform& operator*=(const RotationBase<Derived,Dim>& r) { return rotate(r.toRotationMatrix()); }
- template<typename Derived>
- inline Transform operator*(const RotationBase<Derived,Dim>& r) const;
-
- LinearMatrixType rotation() const;
- template<typename RotationMatrixType, typename ScalingMatrixType>
- void computeRotationScaling(RotationMatrixType *rotation, ScalingMatrixType *scaling) const;
- template<typename ScalingMatrixType, typename RotationMatrixType>
- void computeScalingRotation(ScalingMatrixType *scaling, RotationMatrixType *rotation) const;
-
- template<typename PositionDerived, typename OrientationType, typename ScaleDerived>
- Transform& fromPositionOrientationScale(const MatrixBase<PositionDerived> &position,
- const OrientationType& orientation, const MatrixBase<ScaleDerived> &scale);
-
- inline const MatrixType inverse(TransformTraits traits = Affine) const;
-
- /** \returns a const pointer to the column major internal matrix */
- const Scalar* data() const { return m_matrix.data(); }
- /** \returns a non-const pointer to the column major internal matrix */
- Scalar* data() { return m_matrix.data(); }
-
- /** \returns \c *this with scalar type casted to \a NewScalarType
- *
- * Note that if \a NewScalarType is equal to the current scalar type of \c *this
- * then this function smartly returns a const reference to \c *this.
- */
- template<typename NewScalarType>
- inline typename internal::cast_return_type<Transform,Transform<NewScalarType,Dim> >::type cast() const
- { return typename internal::cast_return_type<Transform,Transform<NewScalarType,Dim> >::type(*this); }
-
- /** Copy constructor with scalar type conversion */
- template<typename OtherScalarType>
- inline explicit Transform(const Transform<OtherScalarType,Dim>& other)
- { m_matrix = other.matrix().template cast<Scalar>(); }
-
- /** \returns \c true if \c *this is approximately equal to \a other, within the precision
- * determined by \a prec.
- *
- * \sa MatrixBase::isApprox() */
- bool isApprox(const Transform& other, typename NumTraits<Scalar>::Real prec = precision<Scalar>()) const
- { return m_matrix.isApprox(other.m_matrix, prec); }
-
- #ifdef EIGEN_TRANSFORM_PLUGIN
- #include EIGEN_TRANSFORM_PLUGIN
- #endif
-
-protected:
-
-};
-
-/** \ingroup Geometry_Module */
-typedef Transform<float,2> Transform2f;
-/** \ingroup Geometry_Module */
-typedef Transform<float,3> Transform3f;
-/** \ingroup Geometry_Module */
-typedef Transform<double,2> Transform2d;
-/** \ingroup Geometry_Module */
-typedef Transform<double,3> Transform3d;
-
-/**************************
-*** Optional QT support ***
-**************************/
-
-#ifdef EIGEN_QT_SUPPORT
-/** Initialises \c *this from a QMatrix assuming the dimension is 2.
- *
- * This function is available only if the token EIGEN_QT_SUPPORT is defined.
- */
-template<typename Scalar, int Dim>
-Transform<Scalar,Dim>::Transform(const QMatrix& other)
-{
- *this = other;
-}
-
-/** Set \c *this from a QMatrix assuming the dimension is 2.
- *
- * This function is available only if the token EIGEN_QT_SUPPORT is defined.
- */
-template<typename Scalar, int Dim>
-Transform<Scalar,Dim>& Transform<Scalar,Dim>::operator=(const QMatrix& other)
-{
- EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
- m_matrix << other.m11(), other.m21(), other.dx(),
- other.m12(), other.m22(), other.dy(),
- 0, 0, 1;
- return *this;
-}
-
-/** \returns a QMatrix from \c *this assuming the dimension is 2.
- *
- * \warning this convertion might loss data if \c *this is not affine
- *
- * This function is available only if the token EIGEN_QT_SUPPORT is defined.
- */
-template<typename Scalar, int Dim>
-QMatrix Transform<Scalar,Dim>::toQMatrix(void) const
-{
- EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
- return QMatrix(m_matrix.coeff(0,0), m_matrix.coeff(1,0),
- m_matrix.coeff(0,1), m_matrix.coeff(1,1),
- m_matrix.coeff(0,2), m_matrix.coeff(1,2));
-}
-
-/** Initialises \c *this from a QTransform assuming the dimension is 2.
- *
- * This function is available only if the token EIGEN_QT_SUPPORT is defined.
- */
-template<typename Scalar, int Dim>
-Transform<Scalar,Dim>::Transform(const QTransform& other)
-{
- *this = other;
-}
-
-/** Set \c *this from a QTransform assuming the dimension is 2.
- *
- * This function is available only if the token EIGEN_QT_SUPPORT is defined.
- */
-template<typename Scalar, int Dim>
-Transform<Scalar,Dim>& Transform<Scalar,Dim>::operator=(const QTransform& other)
-{
- EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
- m_matrix << other.m11(), other.m21(), other.dx(),
- other.m12(), other.m22(), other.dy(),
- other.m13(), other.m23(), other.m33();
- return *this;
-}
-
-/** \returns a QTransform from \c *this assuming the dimension is 2.
- *
- * This function is available only if the token EIGEN_QT_SUPPORT is defined.
- */
-template<typename Scalar, int Dim>
-QTransform Transform<Scalar,Dim>::toQTransform(void) const
-{
- EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
- return QTransform(m_matrix.coeff(0,0), m_matrix.coeff(1,0), m_matrix.coeff(2,0),
- m_matrix.coeff(0,1), m_matrix.coeff(1,1), m_matrix.coeff(2,1),
- m_matrix.coeff(0,2), m_matrix.coeff(1,2), m_matrix.coeff(2,2));
-}
-#endif
-
-/*********************
-*** Procedural API ***
-*********************/
-
-/** Applies on the right the non uniform scale transformation represented
- * by the vector \a other to \c *this and returns a reference to \c *this.
- * \sa prescale()
- */
-template<typename Scalar, int Dim>
-template<typename OtherDerived>
-Transform<Scalar,Dim>&
-Transform<Scalar,Dim>::scale(const MatrixBase<OtherDerived> &other)
-{
- EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,int(Dim))
- linear() = (linear() * other.asDiagonal()).lazy();
- return *this;
-}
-
-/** Applies on the right a uniform scale of a factor \a c to \c *this
- * and returns a reference to \c *this.
- * \sa prescale(Scalar)
- */
-template<typename Scalar, int Dim>
-inline Transform<Scalar,Dim>& Transform<Scalar,Dim>::scale(Scalar s)
-{
- linear() *= s;
- return *this;
-}
-
-/** Applies on the left the non uniform scale transformation represented
- * by the vector \a other to \c *this and returns a reference to \c *this.
- * \sa scale()
- */
-template<typename Scalar, int Dim>
-template<typename OtherDerived>
-Transform<Scalar,Dim>&
-Transform<Scalar,Dim>::prescale(const MatrixBase<OtherDerived> &other)
-{
- EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,int(Dim))
- m_matrix.template block<Dim,HDim>(0,0) = (other.asDiagonal() * m_matrix.template block<Dim,HDim>(0,0)).lazy();
- return *this;
-}
-
-/** Applies on the left a uniform scale of a factor \a c to \c *this
- * and returns a reference to \c *this.
- * \sa scale(Scalar)
- */
-template<typename Scalar, int Dim>
-inline Transform<Scalar,Dim>& Transform<Scalar,Dim>::prescale(Scalar s)
-{
- m_matrix.template corner<Dim,HDim>(TopLeft) *= s;
- return *this;
-}
-
-/** Applies on the right the translation matrix represented by the vector \a other
- * to \c *this and returns a reference to \c *this.
- * \sa pretranslate()
- */
-template<typename Scalar, int Dim>
-template<typename OtherDerived>
-Transform<Scalar,Dim>&
-Transform<Scalar,Dim>::translate(const MatrixBase<OtherDerived> &other)
-{
- EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,int(Dim))
- translation() += linear() * other;
- return *this;
-}
-
-/** Applies on the left the translation matrix represented by the vector \a other
- * to \c *this and returns a reference to \c *this.
- * \sa translate()
- */
-template<typename Scalar, int Dim>
-template<typename OtherDerived>
-Transform<Scalar,Dim>&
-Transform<Scalar,Dim>::pretranslate(const MatrixBase<OtherDerived> &other)
-{
- EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,int(Dim))
- translation() += other;
- return *this;
-}
-
-/** Applies on the right the rotation represented by the rotation \a rotation
- * to \c *this and returns a reference to \c *this.
- *
- * The template parameter \a RotationType is the type of the rotation which
- * must be known by ei_toRotationMatrix<>.
- *
- * Natively supported types includes:
- * - any scalar (2D),
- * - a Dim x Dim matrix expression,
- * - a Quaternion (3D),
- * - a AngleAxis (3D)
- *
- * This mechanism is easily extendable to support user types such as Euler angles,
- * or a pair of Quaternion for 4D rotations.
- *
- * \sa rotate(Scalar), class Quaternion, class AngleAxis, prerotate(RotationType)
- */
-template<typename Scalar, int Dim>
-template<typename RotationType>
-Transform<Scalar,Dim>&
-Transform<Scalar,Dim>::rotate(const RotationType& rotation)
-{
- linear() *= ei_toRotationMatrix<Scalar,Dim>(rotation);
- return *this;
-}
-
-/** Applies on the left the rotation represented by the rotation \a rotation
- * to \c *this and returns a reference to \c *this.
- *
- * See rotate() for further details.
- *
- * \sa rotate()
- */
-template<typename Scalar, int Dim>
-template<typename RotationType>
-Transform<Scalar,Dim>&
-Transform<Scalar,Dim>::prerotate(const RotationType& rotation)
-{
- m_matrix.template block<Dim,HDim>(0,0) = ei_toRotationMatrix<Scalar,Dim>(rotation)
- * m_matrix.template block<Dim,HDim>(0,0);
- return *this;
-}
-
-/** Applies on the right the shear transformation represented
- * by the vector \a other to \c *this and returns a reference to \c *this.
- * \warning 2D only.
- * \sa preshear()
- */
-template<typename Scalar, int Dim>
-Transform<Scalar,Dim>&
-Transform<Scalar,Dim>::shear(Scalar sx, Scalar sy)
-{
- EIGEN_STATIC_ASSERT(int(Dim)==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
- VectorType tmp = linear().col(0)*sy + linear().col(1);
- linear() << linear().col(0) + linear().col(1)*sx, tmp;
- return *this;
-}
-
-/** Applies on the left the shear transformation represented
- * by the vector \a other to \c *this and returns a reference to \c *this.
- * \warning 2D only.
- * \sa shear()
- */
-template<typename Scalar, int Dim>
-Transform<Scalar,Dim>&
-Transform<Scalar,Dim>::preshear(Scalar sx, Scalar sy)
-{
- EIGEN_STATIC_ASSERT(int(Dim)==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
- m_matrix.template block<Dim,HDim>(0,0) = LinearMatrixType(1, sx, sy, 1) * m_matrix.template block<Dim,HDim>(0,0);
- return *this;
-}
-
-/******************************************************
-*** Scaling, Translation and Rotation compatibility ***
-******************************************************/
-
-template<typename Scalar, int Dim>
-inline Transform<Scalar,Dim>& Transform<Scalar,Dim>::operator=(const TranslationType& t)
-{
- linear().setIdentity();
- translation() = t.vector();
- m_matrix.template block<1,Dim>(Dim,0).setZero();
- m_matrix(Dim,Dim) = Scalar(1);
- return *this;
-}
-
-template<typename Scalar, int Dim>
-inline Transform<Scalar,Dim> Transform<Scalar,Dim>::operator*(const TranslationType& t) const
-{
- Transform res = *this;
- res.translate(t.vector());
- return res;
-}
-
-template<typename Scalar, int Dim>
-inline Transform<Scalar,Dim>& Transform<Scalar,Dim>::operator=(const ScalingType& s)
-{
- m_matrix.setZero();
- linear().diagonal() = s.coeffs();
- m_matrix.coeffRef(Dim,Dim) = Scalar(1);
- return *this;
-}
-
-template<typename Scalar, int Dim>
-inline Transform<Scalar,Dim> Transform<Scalar,Dim>::operator*(const ScalingType& s) const
-{
- Transform res = *this;
- res.scale(s.coeffs());
- return res;
-}
-
-template<typename Scalar, int Dim>
-template<typename Derived>
-inline Transform<Scalar,Dim>& Transform<Scalar,Dim>::operator=(const RotationBase<Derived,Dim>& r)
-{
- linear() = ei_toRotationMatrix<Scalar,Dim>(r);
- translation().setZero();
- m_matrix.template block<1,Dim>(Dim,0).setZero();
- m_matrix.coeffRef(Dim,Dim) = Scalar(1);
- return *this;
-}
-
-template<typename Scalar, int Dim>
-template<typename Derived>
-inline Transform<Scalar,Dim> Transform<Scalar,Dim>::operator*(const RotationBase<Derived,Dim>& r) const
-{
- Transform res = *this;
- res.rotate(r.derived());
- return res;
-}
-
-/************************
-*** Special functions ***
-************************/
-
-/** \returns the rotation part of the transformation
- * \nonstableyet
- *
- * \svd_module
- *
- * \sa computeRotationScaling(), computeScalingRotation(), class SVD
- */
-template<typename Scalar, int Dim>
-typename Transform<Scalar,Dim>::LinearMatrixType
-Transform<Scalar,Dim>::rotation() const
-{
- LinearMatrixType result;
- computeRotationScaling(&result, (LinearMatrixType*)0);
- return result;
-}
-
-
-/** decomposes the linear part of the transformation as a product rotation x scaling, the scaling being
- * not necessarily positive.
- *
- * If either pointer is zero, the corresponding computation is skipped.
- *
- * \nonstableyet
- *
- * \svd_module
- *
- * \sa computeScalingRotation(), rotation(), class SVD
- */
-template<typename Scalar, int Dim>
-template<typename RotationMatrixType, typename ScalingMatrixType>
-void Transform<Scalar,Dim>::computeRotationScaling(RotationMatrixType *rotation, ScalingMatrixType *scaling) const
-{
- JacobiSVD<LinearMatrixType> svd(linear(), ComputeFullU|ComputeFullV);
- Scalar x = (svd.matrixU() * svd.matrixV().adjoint()).determinant(); // so x has absolute value 1
- Matrix<Scalar, Dim, 1> sv(svd.singularValues());
- sv.coeffRef(0) *= x;
- if(scaling)
- {
- scaling->noalias() = svd.matrixV() * sv.asDiagonal() * svd.matrixV().adjoint();
- }
- if(rotation)
- {
- LinearMatrixType m(svd.matrixU());
- m.col(0) /= x;
- rotation->noalias() = m * svd.matrixV().adjoint();
- }
-}
-
-/** decomposes the linear part of the transformation as a product rotation x scaling, the scaling being
- * not necessarily positive.
- *
- * If either pointer is zero, the corresponding computation is skipped.
- *
- * \nonstableyet
- *
- * \svd_module
- *
- * \sa computeRotationScaling(), rotation(), class SVD
- */
-template<typename Scalar, int Dim>
-template<typename ScalingMatrixType, typename RotationMatrixType>
-void Transform<Scalar,Dim>::computeScalingRotation(ScalingMatrixType *scaling, RotationMatrixType *rotation) const
-{
- JacobiSVD<LinearMatrixType> svd(linear(), ComputeFullU|ComputeFullV);
- Scalar x = (svd.matrixU() * svd.matrixV().adjoint()).determinant(); // so x has absolute value 1
- Matrix<Scalar, Dim, 1> sv(svd.singularValues());
- sv.coeffRef(0) *= x;
- if(scaling)
- {
- scaling->noalias() = svd.matrixU() * sv.asDiagonal() * svd.matrixU().adjoint();
- }
- if(rotation)
- {
- LinearMatrixType m(svd.matrixU());
- m.col(0) /= x;
- rotation->noalias() = m * svd.matrixV().adjoint();
- }
-}
-
-/** Convenient method to set \c *this from a position, orientation and scale
- * of a 3D object.
- */
-template<typename Scalar, int Dim>
-template<typename PositionDerived, typename OrientationType, typename ScaleDerived>
-Transform<Scalar,Dim>&
-Transform<Scalar,Dim>::fromPositionOrientationScale(const MatrixBase<PositionDerived> &position,
- const OrientationType& orientation, const MatrixBase<ScaleDerived> &scale)
-{
- linear() = ei_toRotationMatrix<Scalar,Dim>(orientation);
- linear() *= scale.asDiagonal();
- translation() = position;
- m_matrix.template block<1,Dim>(Dim,0).setZero();
- m_matrix(Dim,Dim) = Scalar(1);
- return *this;
-}
-
-/** \nonstableyet
- *
- * \returns the inverse transformation matrix according to some given knowledge
- * on \c *this.
- *
- * \param traits allows to optimize the inversion process when the transformion
- * is known to be not a general transformation. The possible values are:
- * - Projective if the transformation is not necessarily affine, i.e., if the
- * last row is not guaranteed to be [0 ... 0 1]
- * - Affine is the default, the last row is assumed to be [0 ... 0 1]
- * - Isometry if the transformation is only a concatenations of translations
- * and rotations.
- *
- * \warning unless \a traits is always set to NoShear or NoScaling, this function
- * requires the generic inverse method of MatrixBase defined in the LU module. If
- * you forget to include this module, then you will get hard to debug linking errors.
- *
- * \sa MatrixBase::inverse()
- */
-template<typename Scalar, int Dim>
-inline const typename Transform<Scalar,Dim>::MatrixType
-Transform<Scalar,Dim>::inverse(TransformTraits traits) const
-{
- if (traits == Projective)
- {
- return m_matrix.inverse();
- }
- else
- {
- MatrixType res;
- if (traits == Affine)
- {
- res.template corner<Dim,Dim>(TopLeft) = linear().inverse();
- }
- else if (traits == Isometry)
- {
- res.template corner<Dim,Dim>(TopLeft) = linear().transpose();
- }
- else
- {
- ei_assert("invalid traits value in Transform::inverse()");
- }
- // translation and remaining parts
- res.template corner<Dim,1>(TopRight) = - res.template corner<Dim,Dim>(TopLeft) * translation();
- res.template corner<1,Dim>(BottomLeft).setZero();
- res.coeffRef(Dim,Dim) = Scalar(1);
- return res;
- }
-}
-
-/*****************************************************
-*** Specializations of operator* with a MatrixBase ***
-*****************************************************/
-
-template<typename Other, int Dim, int HDim>
-struct ei_transform_product_impl<Other,Dim,HDim, HDim,HDim>
-{
- typedef Transform<typename Other::Scalar,Dim> TransformType;
- typedef typename TransformType::MatrixType MatrixType;
- typedef typename ProductReturnType<MatrixType,Other>::Type ResultType;
- static ResultType run(const TransformType& tr, const Other& other)
- { return tr.matrix() * other; }
-};
-
-template<typename Other, int Dim, int HDim>
-struct ei_transform_product_impl<Other,Dim,HDim, Dim,Dim>
-{
- typedef Transform<typename Other::Scalar,Dim> TransformType;
- typedef typename TransformType::MatrixType MatrixType;
- typedef TransformType ResultType;
- static ResultType run(const TransformType& tr, const Other& other)
- {
- TransformType res;
- res.translation() = tr.translation();
- res.matrix().row(Dim) = tr.matrix().row(Dim);
- res.linear() = (tr.linear() * other).lazy();
- return res;
- }
-};
-
-template<typename Other, int Dim, int HDim>
-struct ei_transform_product_impl<Other,Dim,HDim, HDim,1>
-{
- typedef Transform<typename Other::Scalar,Dim> TransformType;
- typedef typename TransformType::MatrixType MatrixType;
- typedef typename ProductReturnType<MatrixType,Other>::Type ResultType;
- static ResultType run(const TransformType& tr, const Other& other)
- { return tr.matrix() * other; }
-};
-
-template<typename Other, int Dim, int HDim>
-struct ei_transform_product_impl<Other,Dim,HDim, Dim,1>
-{
- typedef typename Other::Scalar Scalar;
- typedef Transform<Scalar,Dim> TransformType;
- typedef Matrix<Scalar,Dim,1> ResultType;
- static ResultType run(const TransformType& tr, const Other& other)
- { return ((tr.linear() * other) + tr.translation())
- * (Scalar(1) / ( (tr.matrix().template block<1,Dim>(Dim,0) * other).coeff(0) + tr.matrix().coeff(Dim,Dim))); }
-};
-
-} // end namespace Eigen
diff --git a/Eigen/src/Eigen2Support/Geometry/Translation.h b/Eigen/src/Eigen2Support/Geometry/Translation.h
deleted file mode 100644
index 2b9859f6f..000000000
--- a/Eigen/src/Eigen2Support/Geometry/Translation.h
+++ /dev/null
@@ -1,184 +0,0 @@
-// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra.
-//
-// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
-//
-// 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/.
-
-// no include guard, we'll include this twice from All.h from Eigen2Support, and it's internal anyway
-
-namespace Eigen {
-
-/** \geometry_module \ingroup Geometry_Module
- *
- * \class Translation
- *
- * \brief Represents a translation transformation
- *
- * \param _Scalar the scalar type, i.e., the type of the coefficients.
- * \param _Dim the dimension of the space, can be a compile time value or Dynamic
- *
- * \note This class is not aimed to be used to store a translation transformation,
- * but rather to make easier the constructions and updates of Transform objects.
- *
- * \sa class Scaling, class Transform
- */
-template<typename _Scalar, int _Dim>
-class Translation
-{
-public:
- EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_Dim)
- /** dimension of the space */
- enum { Dim = _Dim };
- /** the scalar type of the coefficients */
- typedef _Scalar Scalar;
- /** corresponding vector type */
- typedef Matrix<Scalar,Dim,1> VectorType;
- /** corresponding linear transformation matrix type */
- typedef Matrix<Scalar,Dim,Dim> LinearMatrixType;
- /** corresponding scaling transformation type */
- typedef Scaling<Scalar,Dim> ScalingType;
- /** corresponding affine transformation type */
- typedef Transform<Scalar,Dim> TransformType;
-
-protected:
-
- VectorType m_coeffs;
-
-public:
-
- /** Default constructor without initialization. */
- Translation() {}
- /** */
- inline Translation(const Scalar& sx, const Scalar& sy)
- {
- ei_assert(Dim==2);
- m_coeffs.x() = sx;
- m_coeffs.y() = sy;
- }
- /** */
- inline Translation(const Scalar& sx, const Scalar& sy, const Scalar& sz)
- {
- ei_assert(Dim==3);
- m_coeffs.x() = sx;
- m_coeffs.y() = sy;
- m_coeffs.z() = sz;
- }
- /** Constructs and initialize the scaling transformation from a vector of scaling coefficients */
- explicit inline Translation(const VectorType& vector) : m_coeffs(vector) {}
-
- const VectorType& vector() const { return m_coeffs; }
- VectorType& vector() { return m_coeffs; }
-
- /** Concatenates two translation */
- inline Translation operator* (const Translation& other) const
- { return Translation(m_coeffs + other.m_coeffs); }
-
- /** Concatenates a translation and a scaling */
- inline TransformType operator* (const ScalingType& other) const;
-
- /** Concatenates a translation and a linear transformation */
- inline TransformType operator* (const LinearMatrixType& linear) const;
-
- template<typename Derived>
- inline TransformType operator*(const RotationBase<Derived,Dim>& r) const
- { return *this * r.toRotationMatrix(); }
-
- /** Concatenates a linear transformation and a translation */
- // its a nightmare to define a templated friend function outside its declaration
- friend inline TransformType operator* (const LinearMatrixType& linear, const Translation& t)
- {
- TransformType res;
- res.matrix().setZero();
- res.linear() = linear;
- res.translation() = linear * t.m_coeffs;
- res.matrix().row(Dim).setZero();
- res(Dim,Dim) = Scalar(1);
- return res;
- }
-
- /** Concatenates a translation and an affine transformation */
- inline TransformType operator* (const TransformType& t) const;
-
- /** Applies translation to vector */
- inline VectorType operator* (const VectorType& other) const
- { return m_coeffs + other; }
-
- /** \returns the inverse translation (opposite) */
- Translation inverse() const { return Translation(-m_coeffs); }
-
- Translation& operator=(const Translation& other)
- {
- m_coeffs = other.m_coeffs;
- return *this;
- }
-
- /** \returns \c *this with scalar type casted to \a NewScalarType
- *
- * Note that if \a NewScalarType is equal to the current scalar type of \c *this
- * then this function smartly returns a const reference to \c *this.
- */
- template<typename NewScalarType>
- inline typename internal::cast_return_type<Translation,Translation<NewScalarType,Dim> >::type cast() const
- { return typename internal::cast_return_type<Translation,Translation<NewScalarType,Dim> >::type(*this); }
-
- /** Copy constructor with scalar type conversion */
- template<typename OtherScalarType>
- inline explicit Translation(const Translation<OtherScalarType,Dim>& other)
- { m_coeffs = other.vector().template cast<Scalar>(); }
-
- /** \returns \c true if \c *this is approximately equal to \a other, within the precision
- * determined by \a prec.
- *
- * \sa MatrixBase::isApprox() */
- bool isApprox(const Translation& other, typename NumTraits<Scalar>::Real prec = precision<Scalar>()) const
- { return m_coeffs.isApprox(other.m_coeffs, prec); }
-
-};
-
-/** \addtogroup Geometry_Module */
-//@{
-typedef Translation<float, 2> Translation2f;
-typedef Translation<double,2> Translation2d;
-typedef Translation<float, 3> Translation3f;
-typedef Translation<double,3> Translation3d;
-//@}
-
-
-template<typename Scalar, int Dim>
-inline typename Translation<Scalar,Dim>::TransformType
-Translation<Scalar,Dim>::operator* (const ScalingType& other) const
-{
- TransformType res;
- res.matrix().setZero();
- res.linear().diagonal() = other.coeffs();
- res.translation() = m_coeffs;
- res(Dim,Dim) = Scalar(1);
- return res;
-}
-
-template<typename Scalar, int Dim>
-inline typename Translation<Scalar,Dim>::TransformType
-Translation<Scalar,Dim>::operator* (const LinearMatrixType& linear) const
-{
- TransformType res;
- res.matrix().setZero();
- res.linear() = linear;
- res.translation() = m_coeffs;
- res.matrix().row(Dim).setZero();
- res(Dim,Dim) = Scalar(1);
- return res;
-}
-
-template<typename Scalar, int Dim>
-inline typename Translation<Scalar,Dim>::TransformType
-Translation<Scalar,Dim>::operator* (const TransformType& t) const
-{
- TransformType res = t;
- res.pretranslate(m_coeffs);
- return res;
-}
-
-} // end namespace Eigen
diff --git a/Eigen/src/Eigen2Support/LU.h b/Eigen/src/Eigen2Support/LU.h
deleted file mode 100644
index 49f19ad76..000000000
--- a/Eigen/src/Eigen2Support/LU.h
+++ /dev/null
@@ -1,120 +0,0 @@
-// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra.
-//
-// Copyright (C) 2011 Benoit Jacob <jacob.benoit.1@gmail.com>
-//
-// 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/.
-
-#ifndef EIGEN2_LU_H
-#define EIGEN2_LU_H
-
-namespace Eigen {
-
-template<typename MatrixType>
-class LU : public FullPivLU<MatrixType>
-{
- public:
-
- typedef typename MatrixType::Scalar Scalar;
- typedef typename NumTraits<typename MatrixType::Scalar>::Real RealScalar;
- typedef Matrix<int, 1, MatrixType::ColsAtCompileTime, MatrixType::Options, 1, MatrixType::MaxColsAtCompileTime> IntRowVectorType;
- typedef Matrix<int, MatrixType::RowsAtCompileTime, 1, MatrixType::Options, MatrixType::MaxRowsAtCompileTime, 1> IntColVectorType;
- typedef Matrix<Scalar, 1, MatrixType::ColsAtCompileTime, MatrixType::Options, 1, MatrixType::MaxColsAtCompileTime> RowVectorType;
- typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, 1, MatrixType::Options, MatrixType::MaxRowsAtCompileTime, 1> ColVectorType;
-
- typedef Matrix<typename MatrixType::Scalar,
- MatrixType::ColsAtCompileTime, // the number of rows in the "kernel matrix" is the number of cols of the original matrix
- // so that the product "matrix * kernel = zero" makes sense
- Dynamic, // we don't know at compile-time the dimension of the kernel
- MatrixType::Options,
- MatrixType::MaxColsAtCompileTime, // see explanation for 2nd template parameter
- MatrixType::MaxColsAtCompileTime // the kernel is a subspace of the domain space, whose dimension is the number
- // of columns of the original matrix
- > KernelResultType;
-
- typedef Matrix<typename MatrixType::Scalar,
- MatrixType::RowsAtCompileTime, // the image is a subspace of the destination space, whose dimension is the number
- // of rows of the original matrix
- Dynamic, // we don't know at compile time the dimension of the image (the rank)
- MatrixType::Options,
- MatrixType::MaxRowsAtCompileTime, // the image matrix will consist of columns from the original matrix,
- MatrixType::MaxColsAtCompileTime // so it has the same number of rows and at most as many columns.
- > ImageResultType;
-
- typedef FullPivLU<MatrixType> Base;
-
- template<typename T>
- explicit LU(const T& t) : Base(t), m_originalMatrix(t) {}
-
- template<typename OtherDerived, typename ResultType>
- bool solve(const MatrixBase<OtherDerived>& b, ResultType *result) const
- {
- *result = static_cast<const Base*>(this)->solve(b);
- return true;
- }
-
- template<typename ResultType>
- inline void computeInverse(ResultType *result) const
- {
- solve(MatrixType::Identity(this->rows(), this->cols()), result);
- }
-
- template<typename KernelMatrixType>
- void computeKernel(KernelMatrixType *result) const
- {
- *result = static_cast<const Base*>(this)->kernel();
- }
-
- template<typename ImageMatrixType>
- void computeImage(ImageMatrixType *result) const
- {
- *result = static_cast<const Base*>(this)->image(m_originalMatrix);
- }
-
- const ImageResultType image() const
- {
- return static_cast<const Base*>(this)->image(m_originalMatrix);
- }
-
- const MatrixType& m_originalMatrix;
-};
-
-#if EIGEN2_SUPPORT_STAGE < STAGE20_RESOLVE_API_CONFLICTS
-/** \lu_module
- *
- * Synonym of partialPivLu().
- *
- * \return the partial-pivoting LU decomposition of \c *this.
- *
- * \sa class PartialPivLU
- */
-template<typename Derived>
-inline const LU<typename MatrixBase<Derived>::PlainObject>
-MatrixBase<Derived>::lu() const
-{
- return LU<PlainObject>(eval());
-}
-#endif
-
-#ifdef EIGEN2_SUPPORT
-/** \lu_module
- *
- * Synonym of partialPivLu().
- *
- * \return the partial-pivoting LU decomposition of \c *this.
- *
- * \sa class PartialPivLU
- */
-template<typename Derived>
-inline const LU<typename MatrixBase<Derived>::PlainObject>
-MatrixBase<Derived>::eigen2_lu() const
-{
- return LU<PlainObject>(eval());
-}
-#endif
-
-} // end namespace Eigen
-
-#endif // EIGEN2_LU_H
diff --git a/Eigen/src/Eigen2Support/Lazy.h b/Eigen/src/Eigen2Support/Lazy.h
deleted file mode 100644
index 593fc78e6..000000000
--- a/Eigen/src/Eigen2Support/Lazy.h
+++ /dev/null
@@ -1,71 +0,0 @@
-// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra.
-//
-// Copyright (C) 2008 Benoit Jacob <jacob.benoit.1@gmail.com>
-//
-// 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/.
-
-#ifndef EIGEN_LAZY_H
-#define EIGEN_LAZY_H
-
-namespace Eigen {
-
-/** \deprecated it is only used by lazy() which is deprecated
- *
- * \returns an expression of *this with added flags
- *
- * Example: \include MatrixBase_marked.cpp
- * Output: \verbinclude MatrixBase_marked.out
- *
- * \sa class Flagged, extract(), part()
- */
-template<typename Derived>
-template<unsigned int Added>
-inline const Flagged<Derived, Added, 0>
-MatrixBase<Derived>::marked() const
-{
- return derived();
-}
-
-/** \deprecated use MatrixBase::noalias()
- *
- * \returns an expression of *this with the EvalBeforeAssigningBit flag removed.
- *
- * Example: \include MatrixBase_lazy.cpp
- * Output: \verbinclude MatrixBase_lazy.out
- *
- * \sa class Flagged, marked()
- */
-template<typename Derived>
-inline const Flagged<Derived, 0, EvalBeforeAssigningBit>
-MatrixBase<Derived>::lazy() const
-{
- return derived();
-}
-
-
-/** \internal
- * Overloaded to perform an efficient C += (A*B).lazy() */
-template<typename Derived>
-template<typename ProductDerived, typename Lhs, typename Rhs>
-Derived& MatrixBase<Derived>::operator+=(const Flagged<ProductBase<ProductDerived, Lhs,Rhs>, 0,
- EvalBeforeAssigningBit>& other)
-{
- other._expression().derived().addTo(derived()); return derived();
-}
-
-/** \internal
- * Overloaded to perform an efficient C -= (A*B).lazy() */
-template<typename Derived>
-template<typename ProductDerived, typename Lhs, typename Rhs>
-Derived& MatrixBase<Derived>::operator-=(const Flagged<ProductBase<ProductDerived, Lhs,Rhs>, 0,
- EvalBeforeAssigningBit>& other)
-{
- other._expression().derived().subTo(derived()); return derived();
-}
-
-} // end namespace Eigen
-
-#endif // EIGEN_LAZY_H
diff --git a/Eigen/src/Eigen2Support/LeastSquares.h b/Eigen/src/Eigen2Support/LeastSquares.h
deleted file mode 100644
index 0e6fdb488..000000000
--- a/Eigen/src/Eigen2Support/LeastSquares.h
+++ /dev/null
@@ -1,170 +0,0 @@
-// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra.
-//
-// Copyright (C) 2006-2009 Benoit Jacob <jacob.benoit.1@gmail.com>
-//
-// 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/.
-
-#ifndef EIGEN2_LEASTSQUARES_H
-#define EIGEN2_LEASTSQUARES_H
-
-namespace Eigen {
-
-/** \ingroup LeastSquares_Module
- *
- * \leastsquares_module
- *
- * For a set of points, this function tries to express
- * one of the coords as a linear (affine) function of the other coords.
- *
- * This is best explained by an example. This function works in full
- * generality, for points in a space of arbitrary dimension, and also over
- * the complex numbers, but for this example we will work in dimension 3
- * over the real numbers (doubles).
- *
- * So let us work with the following set of 5 points given by their
- * \f$(x,y,z)\f$ coordinates:
- * @code
- Vector3d points[5];
- points[0] = Vector3d( 3.02, 6.89, -4.32 );
- points[1] = Vector3d( 2.01, 5.39, -3.79 );
- points[2] = Vector3d( 2.41, 6.01, -4.01 );
- points[3] = Vector3d( 2.09, 5.55, -3.86 );
- points[4] = Vector3d( 2.58, 6.32, -4.10 );
- * @endcode
- * Suppose that we want to express the second coordinate (\f$y\f$) as a linear
- * expression in \f$x\f$ and \f$z\f$, that is,
- * \f[ y=ax+bz+c \f]
- * for some constants \f$a,b,c\f$. Thus, we want to find the best possible
- * constants \f$a,b,c\f$ so that the plane of equation \f$y=ax+bz+c\f$ fits
- * best the five above points. To do that, call this function as follows:
- * @code
- Vector3d coeffs; // will store the coefficients a, b, c
- linearRegression(
- 5,
- &points,
- &coeffs,
- 1 // the coord to express as a function of
- // the other ones. 0 means x, 1 means y, 2 means z.
- );
- * @endcode
- * Now the vector \a coeffs is approximately
- * \f$( 0.495 , -1.927 , -2.906 )\f$.
- * Thus, we get \f$a=0.495, b = -1.927, c = -2.906\f$. Let us check for
- * instance how near points[0] is from the plane of equation \f$y=ax+bz+c\f$.
- * Looking at the coords of points[0], we see that:
- * \f[ax+bz+c = 0.495 * 3.02 + (-1.927) * (-4.32) + (-2.906) = 6.91.\f]
- * On the other hand, we have \f$y=6.89\f$. We see that the values
- * \f$6.91\f$ and \f$6.89\f$
- * are near, so points[0] is very near the plane of equation \f$y=ax+bz+c\f$.
- *
- * Let's now describe precisely the parameters:
- * @param numPoints the number of points
- * @param points the array of pointers to the points on which to perform the linear regression
- * @param result pointer to the vector in which to store the result.
- This vector must be of the same type and size as the
- data points. The meaning of its coords is as follows.
- For brevity, let \f$n=Size\f$,
- \f$r_i=result[i]\f$,
- and \f$f=funcOfOthers\f$. Denote by
- \f$x_0,\ldots,x_{n-1}\f$
- the n coordinates in the n-dimensional space.
- Then the resulting equation is:
- \f[ x_f = r_0 x_0 + \cdots + r_{f-1}x_{f-1}
- + r_{f+1}x_{f+1} + \cdots + r_{n-1}x_{n-1} + r_n. \f]
- * @param funcOfOthers Determines which coord to express as a function of the
- others. Coords are numbered starting from 0, so that a
- value of 0 means \f$x\f$, 1 means \f$y\f$,
- 2 means \f$z\f$, ...
- *
- * \sa fitHyperplane()
- */
-template<typename VectorType>
-void linearRegression(int numPoints,
- VectorType **points,
- VectorType *result,
- int funcOfOthers )
-{
- typedef typename VectorType::Scalar Scalar;
- typedef Hyperplane<Scalar, VectorType::SizeAtCompileTime> HyperplaneType;
- const int size = points[0]->size();
- result->resize(size);
- HyperplaneType h(size);
- fitHyperplane(numPoints, points, &h);
- for(int i = 0; i < funcOfOthers; i++)
- result->coeffRef(i) = - h.coeffs()[i] / h.coeffs()[funcOfOthers];
- for(int i = funcOfOthers; i < size; i++)
- result->coeffRef(i) = - h.coeffs()[i+1] / h.coeffs()[funcOfOthers];
-}
-
-/** \ingroup LeastSquares_Module
- *
- * \leastsquares_module
- *
- * This function is quite similar to linearRegression(), so we refer to the
- * documentation of this function and only list here the differences.
- *
- * The main difference from linearRegression() is that this function doesn't
- * take a \a funcOfOthers argument. Instead, it finds a general equation
- * of the form
- * \f[ r_0 x_0 + \cdots + r_{n-1}x_{n-1} + r_n = 0, \f]
- * where \f$n=Size\f$, \f$r_i=retCoefficients[i]\f$, and we denote by
- * \f$x_0,\ldots,x_{n-1}\f$ the n coordinates in the n-dimensional space.
- *
- * Thus, the vector \a retCoefficients has size \f$n+1\f$, which is another
- * difference from linearRegression().
- *
- * In practice, this function performs an hyper-plane fit in a total least square sense
- * via the following steps:
- * 1 - center the data to the mean
- * 2 - compute the covariance matrix
- * 3 - pick the eigenvector corresponding to the smallest eigenvalue of the covariance matrix
- * The ratio of the smallest eigenvalue and the second one gives us a hint about the relevance
- * of the solution. This value is optionally returned in \a soundness.
- *
- * \sa linearRegression()
- */
-template<typename VectorType, typename HyperplaneType>
-void fitHyperplane(int numPoints,
- VectorType **points,
- HyperplaneType *result,
- typename NumTraits<typename VectorType::Scalar>::Real* soundness = 0)
-{
- typedef typename VectorType::Scalar Scalar;
- typedef Matrix<Scalar,VectorType::SizeAtCompileTime,VectorType::SizeAtCompileTime> CovMatrixType;
- EIGEN_STATIC_ASSERT_VECTOR_ONLY(VectorType)
- ei_assert(numPoints >= 1);
- int size = points[0]->size();
- ei_assert(size+1 == result->coeffs().size());
-
- // compute the mean of the data
- VectorType mean = VectorType::Zero(size);
- for(int i = 0; i < numPoints; ++i)
- mean += *(points[i]);
- mean /= numPoints;
-
- // compute the covariance matrix
- CovMatrixType covMat = CovMatrixType::Zero(size, size);
- VectorType remean = VectorType::Zero(size);
- for(int i = 0; i < numPoints; ++i)
- {
- VectorType diff = (*(points[i]) - mean).conjugate();
- covMat += diff * diff.adjoint();
- }
-
- // now we just have to pick the eigen vector with smallest eigen value
- SelfAdjointEigenSolver<CovMatrixType> eig(covMat);
- result->normal() = eig.eigenvectors().col(0);
- if (soundness)
- *soundness = eig.eigenvalues().coeff(0)/eig.eigenvalues().coeff(1);
-
- // let's compute the constant coefficient such that the
- // plane pass trough the mean point:
- result->offset() = - (result->normal().cwise()* mean).sum();
-}
-
-} // end namespace Eigen
-
-#endif // EIGEN2_LEASTSQUARES_H
diff --git a/Eigen/src/Eigen2Support/Macros.h b/Eigen/src/Eigen2Support/Macros.h
deleted file mode 100644
index 351c32afb..000000000
--- a/Eigen/src/Eigen2Support/Macros.h
+++ /dev/null
@@ -1,20 +0,0 @@
-// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra.
-//
-// Copyright (C) 2011 Benoit Jacob <jacob.benoit.1@gmail.com>
-//
-// 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/.
-
-#ifndef EIGEN2_MACROS_H
-#define EIGEN2_MACROS_H
-
-#define ei_assert eigen_assert
-#define ei_internal_assert eigen_internal_assert
-
-#define EIGEN_ALIGN_128 EIGEN_ALIGN16
-
-#define EIGEN_ARCH_WANTS_ALIGNMENT EIGEN_ALIGN_STATICALLY
-
-#endif // EIGEN2_MACROS_H
diff --git a/Eigen/src/Eigen2Support/MathFunctions.h b/Eigen/src/Eigen2Support/MathFunctions.h
deleted file mode 100644
index 3544af253..000000000
--- a/Eigen/src/Eigen2Support/MathFunctions.h
+++ /dev/null
@@ -1,57 +0,0 @@
-// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra.
-//
-// Copyright (C) 2010 Gael Guennebaud <gael.guennebaud@inria.fr>
-//
-// 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/.
-
-#ifndef EIGEN2_MATH_FUNCTIONS_H
-#define EIGEN2_MATH_FUNCTIONS_H
-
-namespace Eigen {
-
-template<typename T> inline typename NumTraits<T>::Real ei_real(const T& x) { return numext::real(x); }
-template<typename T> inline typename NumTraits<T>::Real ei_imag(const T& x) { return numext::imag(x); }
-template<typename T> inline T ei_conj(const T& x) { return numext::conj(x); }
-template<typename T> inline typename NumTraits<T>::Real ei_abs (const T& x) { using std::abs; return abs(x); }
-template<typename T> inline typename NumTraits<T>::Real ei_abs2(const T& x) { return numext::abs2(x); }
-template<typename T> inline T ei_sqrt(const T& x) { using std::sqrt; return sqrt(x); }
-template<typename T> inline T ei_exp (const T& x) { using std::exp; return exp(x); }
-template<typename T> inline T ei_log (const T& x) { using std::log; return log(x); }
-template<typename T> inline T ei_sin (const T& x) { using std::sin; return sin(x); }
-template<typename T> inline T ei_cos (const T& x) { using std::cos; return cos(x); }
-template<typename T> inline T ei_atan2(const T& x,const T& y) { using std::atan2; return atan2(x,y); }
-template<typename T> inline T ei_pow (const T& x,const T& y) { return numext::pow(x,y); }
-template<typename T> inline T ei_random () { return internal::random<T>(); }
-template<typename T> inline T ei_random (const T& x, const T& y) { return internal::random(x, y); }
-
-template<typename T> inline T precision () { return NumTraits<T>::dummy_precision(); }
-template<typename T> inline T machine_epsilon () { return NumTraits<T>::epsilon(); }
-
-
-template<typename Scalar, typename OtherScalar>
-inline bool ei_isMuchSmallerThan(const Scalar& x, const OtherScalar& y,
- typename NumTraits<Scalar>::Real precision = NumTraits<Scalar>::dummy_precision())
-{
- return internal::isMuchSmallerThan(x, y, precision);
-}
-
-template<typename Scalar>
-inline bool ei_isApprox(const Scalar& x, const Scalar& y,
- typename NumTraits<Scalar>::Real precision = NumTraits<Scalar>::dummy_precision())
-{
- return internal::isApprox(x, y, precision);
-}
-
-template<typename Scalar>
-inline bool ei_isApproxOrLessThan(const Scalar& x, const Scalar& y,
- typename NumTraits<Scalar>::Real precision = NumTraits<Scalar>::dummy_precision())
-{
- return internal::isApproxOrLessThan(x, y, precision);
-}
-
-} // end namespace Eigen
-
-#endif // EIGEN2_MATH_FUNCTIONS_H
diff --git a/Eigen/src/Eigen2Support/Memory.h b/Eigen/src/Eigen2Support/Memory.h
deleted file mode 100644
index f86372b6b..000000000
--- a/Eigen/src/Eigen2Support/Memory.h
+++ /dev/null
@@ -1,45 +0,0 @@
-// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra.
-//
-// Copyright (C) 2011 Benoit Jacob <jacob.benoit.1@gmail.com>
-//
-// 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/.
-
-#ifndef EIGEN2_MEMORY_H
-#define EIGEN2_MEMORY_H
-
-namespace Eigen {
-
-inline void* ei_aligned_malloc(size_t size) { return internal::aligned_malloc(size); }
-inline void ei_aligned_free(void *ptr) { internal::aligned_free(ptr); }
-inline void* ei_aligned_realloc(void *ptr, size_t new_size, size_t old_size) { return internal::aligned_realloc(ptr, new_size, old_size); }
-inline void* ei_handmade_aligned_malloc(size_t size) { return internal::handmade_aligned_malloc(size); }
-inline void ei_handmade_aligned_free(void *ptr) { internal::handmade_aligned_free(ptr); }
-
-template<bool Align> inline void* ei_conditional_aligned_malloc(size_t size)
-{
- return internal::conditional_aligned_malloc<Align>(size);
-}
-template<bool Align> inline void ei_conditional_aligned_free(void *ptr)
-{
- internal::conditional_aligned_free<Align>(ptr);
-}
-template<bool Align> inline void* ei_conditional_aligned_realloc(void* ptr, size_t new_size, size_t old_size)
-{
- return internal::conditional_aligned_realloc<Align>(ptr, new_size, old_size);
-}
-
-template<typename T> inline T* ei_aligned_new(size_t size)
-{
- return internal::aligned_new<T>(size);
-}
-template<typename T> inline void ei_aligned_delete(T *ptr, size_t size)
-{
- return internal::aligned_delete(ptr, size);
-}
-
-} // end namespace Eigen
-
-#endif // EIGEN2_MACROS_H
diff --git a/Eigen/src/Eigen2Support/Meta.h b/Eigen/src/Eigen2Support/Meta.h
deleted file mode 100644
index fa37cfc96..000000000
--- a/Eigen/src/Eigen2Support/Meta.h
+++ /dev/null
@@ -1,75 +0,0 @@
-// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra.
-//
-// Copyright (C) 2011 Benoit Jacob <jacob.benoit.1@gmail.com>
-//
-// 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/.
-
-#ifndef EIGEN2_META_H
-#define EIGEN2_META_H
-
-namespace Eigen {
-
-template<typename T>
-struct ei_traits : internal::traits<T>
-{};
-
-struct ei_meta_true { enum { ret = 1 }; };
-struct ei_meta_false { enum { ret = 0 }; };
-
-template<bool Condition, typename Then, typename Else>
-struct ei_meta_if { typedef Then ret; };
-
-template<typename Then, typename Else>
-struct ei_meta_if <false, Then, Else> { typedef Else ret; };
-
-template<typename T, typename U> struct ei_is_same_type { enum { ret = 0 }; };
-template<typename T> struct ei_is_same_type<T,T> { enum { ret = 1 }; };
-
-template<typename T> struct ei_unref { typedef T type; };
-template<typename T> struct ei_unref<T&> { typedef T type; };
-
-template<typename T> struct ei_unpointer { typedef T type; };
-template<typename T> struct ei_unpointer<T*> { typedef T type; };
-template<typename T> struct ei_unpointer<T*const> { typedef T type; };
-
-template<typename T> struct ei_unconst { typedef T type; };
-template<typename T> struct ei_unconst<const T> { typedef T type; };
-template<typename T> struct ei_unconst<T const &> { typedef T & type; };
-template<typename T> struct ei_unconst<T const *> { typedef T * type; };
-
-template<typename T> struct ei_cleantype { typedef T type; };
-template<typename T> struct ei_cleantype<const T> { typedef typename ei_cleantype<T>::type type; };
-template<typename T> struct ei_cleantype<const T&> { typedef typename ei_cleantype<T>::type type; };
-template<typename T> struct ei_cleantype<T&> { typedef typename ei_cleantype<T>::type type; };
-template<typename T> struct ei_cleantype<const T*> { typedef typename ei_cleantype<T>::type type; };
-template<typename T> struct ei_cleantype<T*> { typedef typename ei_cleantype<T>::type type; };
-
-/** \internal In short, it computes int(sqrt(\a Y)) with \a Y an integer.
- * Usage example: \code ei_meta_sqrt<1023>::ret \endcode
- */
-template<int Y,
- int InfX = 0,
- int SupX = ((Y==1) ? 1 : Y/2),
- bool Done = ((SupX-InfX)<=1 ? true : ((SupX*SupX <= Y) && ((SupX+1)*(SupX+1) > Y))) >
- // use ?: instead of || just to shut up a stupid gcc 4.3 warning
-class ei_meta_sqrt
-{
- enum {
- MidX = (InfX+SupX)/2,
- TakeInf = MidX*MidX > Y ? 1 : 0,
- NewInf = int(TakeInf) ? InfX : int(MidX),
- NewSup = int(TakeInf) ? int(MidX) : SupX
- };
- public:
- enum { ret = ei_meta_sqrt<Y,NewInf,NewSup>::ret };
-};
-
-template<int Y, int InfX, int SupX>
-class ei_meta_sqrt<Y, InfX, SupX, true> { public: enum { ret = (SupX*SupX <= Y) ? SupX : InfX }; };
-
-} // end namespace Eigen
-
-#endif // EIGEN2_META_H
diff --git a/Eigen/src/Eigen2Support/Minor.h b/Eigen/src/Eigen2Support/Minor.h
deleted file mode 100644
index 4cded5734..000000000
--- a/Eigen/src/Eigen2Support/Minor.h
+++ /dev/null
@@ -1,117 +0,0 @@
-// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra.
-//
-// Copyright (C) 2006-2009 Benoit Jacob <jacob.benoit.1@gmail.com>
-//
-// 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/.
-
-#ifndef EIGEN_MINOR_H
-#define EIGEN_MINOR_H
-
-namespace Eigen {
-
-/**
- * \class Minor
- *
- * \brief Expression of a minor
- *
- * \param MatrixType the type of the object in which we are taking a minor
- *
- * This class represents an expression of a minor. It is the return
- * type of MatrixBase::minor() and most of the time this is the only way it
- * is used.
- *
- * \sa MatrixBase::minor()
- */
-
-namespace internal {
-template<typename MatrixType>
-struct traits<Minor<MatrixType> >
- : traits<MatrixType>
-{
- typedef typename nested<MatrixType>::type MatrixTypeNested;
- typedef typename remove_reference<MatrixTypeNested>::type _MatrixTypeNested;
- typedef typename MatrixType::StorageKind StorageKind;
- enum {
- RowsAtCompileTime = (MatrixType::RowsAtCompileTime != Dynamic) ?
- int(MatrixType::RowsAtCompileTime) - 1 : Dynamic,
- ColsAtCompileTime = (MatrixType::ColsAtCompileTime != Dynamic) ?
- int(MatrixType::ColsAtCompileTime) - 1 : Dynamic,
- MaxRowsAtCompileTime = (MatrixType::MaxRowsAtCompileTime != Dynamic) ?
- int(MatrixType::MaxRowsAtCompileTime) - 1 : Dynamic,
- MaxColsAtCompileTime = (MatrixType::MaxColsAtCompileTime != Dynamic) ?
- int(MatrixType::MaxColsAtCompileTime) - 1 : Dynamic,
- Flags = _MatrixTypeNested::Flags & (HereditaryBits | LvalueBit),
- CoeffReadCost = _MatrixTypeNested::CoeffReadCost // minor is used typically on tiny matrices,
- // where loops are unrolled and the 'if' evaluates at compile time
- };
-};
-}
-
-template<typename MatrixType> class Minor
- : public MatrixBase<Minor<MatrixType> >
-{
- public:
-
- typedef MatrixBase<Minor> Base;
- EIGEN_DENSE_PUBLIC_INTERFACE(Minor)
-
- inline Minor(const MatrixType& matrix,
- Index row, Index col)
- : m_matrix(matrix), m_row(row), m_col(col)
- {
- eigen_assert(row >= 0 && row < matrix.rows()
- && col >= 0 && col < matrix.cols());
- }
-
- EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Minor)
-
- inline Index rows() const { return m_matrix.rows() - 1; }
- inline Index cols() const { return m_matrix.cols() - 1; }
-
- inline Scalar& coeffRef(Index row, Index col)
- {
- return m_matrix.const_cast_derived().coeffRef(row + (row >= m_row), col + (col >= m_col));
- }
-
- inline const Scalar coeff(Index row, Index col) const
- {
- return m_matrix.coeff(row + (row >= m_row), col + (col >= m_col));
- }
-
- protected:
- const typename MatrixType::Nested m_matrix;
- const Index m_row, m_col;
-};
-
-/**
- * \return an expression of the (\a row, \a col)-minor of *this,
- * i.e. an expression constructed from *this by removing the specified
- * row and column.
- *
- * Example: \include MatrixBase_minor.cpp
- * Output: \verbinclude MatrixBase_minor.out
- *
- * \sa class Minor
- */
-template<typename Derived>
-inline Minor<Derived>
-MatrixBase<Derived>::minor(Index row, Index col)
-{
- return Minor<Derived>(derived(), row, col);
-}
-
-/**
- * This is the const version of minor(). */
-template<typename Derived>
-inline const Minor<Derived>
-MatrixBase<Derived>::minor(Index row, Index col) const
-{
- return Minor<Derived>(derived(), row, col);
-}
-
-} // end namespace Eigen
-
-#endif // EIGEN_MINOR_H
diff --git a/Eigen/src/Eigen2Support/QR.h b/Eigen/src/Eigen2Support/QR.h
deleted file mode 100644
index 2042c9851..000000000
--- a/Eigen/src/Eigen2Support/QR.h
+++ /dev/null
@@ -1,67 +0,0 @@
-// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra.
-//
-// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
-// Copyright (C) 2011 Benoit Jacob <jacob.benoit.1@gmail.com>
-//
-// 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/.
-
-#ifndef EIGEN2_QR_H
-#define EIGEN2_QR_H
-
-namespace Eigen {
-
-template<typename MatrixType>
-class QR : public HouseholderQR<MatrixType>
-{
- public:
-
- typedef HouseholderQR<MatrixType> Base;
- typedef Block<const MatrixType, MatrixType::ColsAtCompileTime, MatrixType::ColsAtCompileTime> MatrixRBlockType;
-
- QR() : Base() {}
-
- template<typename T>
- explicit QR(const T& t) : Base(t) {}
-
- template<typename OtherDerived, typename ResultType>
- bool solve(const MatrixBase<OtherDerived>& b, ResultType *result) const
- {
- *result = static_cast<const Base*>(this)->solve(b);
- return true;
- }
-
- MatrixType matrixQ(void) const {
- MatrixType ret = MatrixType::Identity(this->rows(), this->cols());
- ret = this->householderQ() * ret;
- return ret;
- }
-
- bool isFullRank() const {
- return true;
- }
-
- const TriangularView<MatrixRBlockType, UpperTriangular>
- matrixR(void) const
- {
- int cols = this->cols();
- return MatrixRBlockType(this->matrixQR(), 0, 0, cols, cols).template triangularView<UpperTriangular>();
- }
-};
-
-/** \return the QR decomposition of \c *this.
- *
- * \sa class QR
- */
-template<typename Derived>
-const QR<typename MatrixBase<Derived>::PlainObject>
-MatrixBase<Derived>::qr() const
-{
- return QR<PlainObject>(eval());
-}
-
-} // end namespace Eigen
-
-#endif // EIGEN2_QR_H
diff --git a/Eigen/src/Eigen2Support/SVD.h b/Eigen/src/Eigen2Support/SVD.h
deleted file mode 100644
index 3d03d2288..000000000
--- a/Eigen/src/Eigen2Support/SVD.h
+++ /dev/null
@@ -1,637 +0,0 @@
-// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra.
-//
-// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
-//
-// 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/.
-
-#ifndef EIGEN2_SVD_H
-#define EIGEN2_SVD_H
-
-namespace Eigen {
-
-/** \ingroup SVD_Module
- * \nonstableyet
- *
- * \class SVD
- *
- * \brief Standard SVD decomposition of a matrix and associated features
- *
- * \param MatrixType the type of the matrix of which we are computing the SVD decomposition
- *
- * This class performs a standard SVD decomposition of a real matrix A of size \c M x \c N
- * with \c M \>= \c N.
- *
- *
- * \sa MatrixBase::SVD()
- */
-template<typename MatrixType> class SVD
-{
- private:
- typedef typename MatrixType::Scalar Scalar;
- typedef typename NumTraits<typename MatrixType::Scalar>::Real RealScalar;
-
- enum {
- PacketSize = internal::packet_traits<Scalar>::size,
- AlignmentMask = int(PacketSize)-1,
- MinSize = EIGEN_SIZE_MIN_PREFER_DYNAMIC(MatrixType::RowsAtCompileTime, MatrixType::ColsAtCompileTime)
- };
-
- typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, 1> ColVector;
- typedef Matrix<Scalar, MatrixType::ColsAtCompileTime, 1> RowVector;
-
- typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, MinSize> MatrixUType;
- typedef Matrix<Scalar, MatrixType::ColsAtCompileTime, MatrixType::ColsAtCompileTime> MatrixVType;
- typedef Matrix<Scalar, MinSize, 1> SingularValuesType;
-
- public:
-
- SVD() {} // a user who relied on compiler-generated default compiler reported problems with MSVC in 2.0.7
-
- SVD(const MatrixType& matrix)
- : m_matU(matrix.rows(), (std::min)(matrix.rows(), matrix.cols())),
- m_matV(matrix.cols(),matrix.cols()),
- m_sigma((std::min)(matrix.rows(),matrix.cols()))
- {
- compute(matrix);
- }
-
- template<typename OtherDerived, typename ResultType>
- bool solve(const MatrixBase<OtherDerived> &b, ResultType* result) const;
-
- const MatrixUType& matrixU() const { return m_matU; }
- const SingularValuesType& singularValues() const { return m_sigma; }
- const MatrixVType& matrixV() const { return m_matV; }
-
- void compute(const MatrixType& matrix);
- SVD& sort();
-
- template<typename UnitaryType, typename PositiveType>
- void computeUnitaryPositive(UnitaryType *unitary, PositiveType *positive) const;
- template<typename PositiveType, typename UnitaryType>
- void computePositiveUnitary(PositiveType *positive, UnitaryType *unitary) const;
- template<typename RotationType, typename ScalingType>
- void computeRotationScaling(RotationType *unitary, ScalingType *positive) const;
- template<typename ScalingType, typename RotationType>
- void computeScalingRotation(ScalingType *positive, RotationType *unitary) const;
-
- protected:
- /** \internal */
- MatrixUType m_matU;
- /** \internal */
- MatrixVType m_matV;
- /** \internal */
- SingularValuesType m_sigma;
-};
-
-/** Computes / recomputes the SVD decomposition A = U S V^* of \a matrix
- *
- * \note this code has been adapted from JAMA (public domain)
- */
-template<typename MatrixType>
-void SVD<MatrixType>::compute(const MatrixType& matrix)
-{
- const int m = matrix.rows();
- const int n = matrix.cols();
- const int nu = (std::min)(m,n);
- ei_assert(m>=n && "In Eigen 2.0, SVD only works for MxN matrices with M>=N. Sorry!");
- ei_assert(m>1 && "In Eigen 2.0, SVD doesn't work on 1x1 matrices");
-
- m_matU.resize(m, nu);
- m_matU.setZero();
- m_sigma.resize((std::min)(m,n));
- m_matV.resize(n,n);
-
- RowVector e(n);
- ColVector work(m);
- MatrixType matA(matrix);
- const bool wantu = true;
- const bool wantv = true;
- int i=0, j=0, k=0;
-
- // Reduce A to bidiagonal form, storing the diagonal elements
- // in s and the super-diagonal elements in e.
- int nct = (std::min)(m-1,n);
- int nrt = (std::max)(0,(std::min)(n-2,m));
- for (k = 0; k < (std::max)(nct,nrt); ++k)
- {
- if (k < nct)
- {
- // Compute the transformation for the k-th column and
- // place the k-th diagonal in m_sigma[k].
- m_sigma[k] = matA.col(k).end(m-k).norm();
- if (m_sigma[k] != 0.0) // FIXME
- {
- if (matA(k,k) < 0.0)
- m_sigma[k] = -m_sigma[k];
- matA.col(k).end(m-k) /= m_sigma[k];
- matA(k,k) += 1.0;
- }
- m_sigma[k] = -m_sigma[k];
- }
-
- for (j = k+1; j < n; ++j)
- {
- if ((k < nct) && (m_sigma[k] != 0.0))
- {
- // Apply the transformation.
- Scalar t = matA.col(k).end(m-k).eigen2_dot(matA.col(j).end(m-k)); // FIXME dot product or cwise prod + .sum() ??
- t = -t/matA(k,k);
- matA.col(j).end(m-k) += t * matA.col(k).end(m-k);
- }
-
- // Place the k-th row of A into e for the
- // subsequent calculation of the row transformation.
- e[j] = matA(k,j);
- }
-
- // Place the transformation in U for subsequent back multiplication.
- if (wantu & (k < nct))
- m_matU.col(k).end(m-k) = matA.col(k).end(m-k);
-
- if (k < nrt)
- {
- // Compute the k-th row transformation and place the
- // k-th super-diagonal in e[k].
- e[k] = e.end(n-k-1).norm();
- if (e[k] != 0.0)
- {
- if (e[k+1] < 0.0)
- e[k] = -e[k];
- e.end(n-k-1) /= e[k];
- e[k+1] += 1.0;
- }
- e[k] = -e[k];
- if ((k+1 < m) & (e[k] != 0.0))
- {
- // Apply the transformation.
- work.end(m-k-1) = matA.corner(BottomRight,m-k-1,n-k-1) * e.end(n-k-1);
- for (j = k+1; j < n; ++j)
- matA.col(j).end(m-k-1) += (-e[j]/e[k+1]) * work.end(m-k-1);
- }
-
- // Place the transformation in V for subsequent back multiplication.
- if (wantv)
- m_matV.col(k).end(n-k-1) = e.end(n-k-1);
- }
- }
-
-
- // Set up the final bidiagonal matrix or order p.
- int p = (std::min)(n,m+1);
- if (nct < n)
- m_sigma[nct] = matA(nct,nct);
- if (m < p)
- m_sigma[p-1] = 0.0;
- if (nrt+1 < p)
- e[nrt] = matA(nrt,p-1);
- e[p-1] = 0.0;
-
- // If required, generate U.
- if (wantu)
- {
- for (j = nct; j < nu; ++j)
- {
- m_matU.col(j).setZero();
- m_matU(j,j) = 1.0;
- }
- for (k = nct-1; k >= 0; k--)
- {
- if (m_sigma[k] != 0.0)
- {
- for (j = k+1; j < nu; ++j)
- {
- Scalar t = m_matU.col(k).end(m-k).eigen2_dot(m_matU.col(j).end(m-k)); // FIXME is it really a dot product we want ?
- t = -t/m_matU(k,k);
- m_matU.col(j).end(m-k) += t * m_matU.col(k).end(m-k);
- }
- m_matU.col(k).end(m-k) = - m_matU.col(k).end(m-k);
- m_matU(k,k) = Scalar(1) + m_matU(k,k);
- if (k-1>0)
- m_matU.col(k).start(k-1).setZero();
- }
- else
- {
- m_matU.col(k).setZero();
- m_matU(k,k) = 1.0;
- }
- }
- }
-
- // If required, generate V.
- if (wantv)
- {
- for (k = n-1; k >= 0; k--)
- {
- if ((k < nrt) & (e[k] != 0.0))
- {
- for (j = k+1; j < nu; ++j)
- {
- Scalar t = m_matV.col(k).end(n-k-1).eigen2_dot(m_matV.col(j).end(n-k-1)); // FIXME is it really a dot product we want ?
- t = -t/m_matV(k+1,k);
- m_matV.col(j).end(n-k-1) += t * m_matV.col(k).end(n-k-1);
- }
- }
- m_matV.col(k).setZero();
- m_matV(k,k) = 1.0;
- }
- }
-
- // Main iteration loop for the singular values.
- int pp = p-1;
- int iter = 0;
- Scalar eps = ei_pow(Scalar(2),ei_is_same_type<Scalar,float>::ret ? Scalar(-23) : Scalar(-52));
- while (p > 0)
- {
- int k=0;
- int kase=0;
-
- // Here is where a test for too many iterations would go.
-
- // This section of the program inspects for
- // negligible elements in the s and e arrays. On
- // completion the variables kase and k are set as follows.
-
- // kase = 1 if s(p) and e[k-1] are negligible and k<p
- // kase = 2 if s(k) is negligible and k<p
- // kase = 3 if e[k-1] is negligible, k<p, and
- // s(k), ..., s(p) are not negligible (qr step).
- // kase = 4 if e(p-1) is negligible (convergence).
-
- for (k = p-2; k >= -1; --k)
- {
- if (k == -1)
- break;
- if (ei_abs(e[k]) <= eps*(ei_abs(m_sigma[k]) + ei_abs(m_sigma[k+1])))
- {
- e[k] = 0.0;
- break;
- }
- }
- if (k == p-2)
- {
- kase = 4;
- }
- else
- {
- int ks;
- for (ks = p-1; ks >= k; --ks)
- {
- if (ks == k)
- break;
- Scalar t = (ks != p ? ei_abs(e[ks]) : Scalar(0)) + (ks != k+1 ? ei_abs(e[ks-1]) : Scalar(0));
- if (ei_abs(m_sigma[ks]) <= eps*t)
- {
- m_sigma[ks] = 0.0;
- break;
- }
- }
- if (ks == k)
- {
- kase = 3;
- }
- else if (ks == p-1)
- {
- kase = 1;
- }
- else
- {
- kase = 2;
- k = ks;
- }
- }
- ++k;
-
- // Perform the task indicated by kase.
- switch (kase)
- {
-
- // Deflate negligible s(p).
- case 1:
- {
- Scalar f(e[p-2]);
- e[p-2] = 0.0;
- for (j = p-2; j >= k; --j)
- {
- Scalar t(numext::hypot(m_sigma[j],f));
- Scalar cs(m_sigma[j]/t);
- Scalar sn(f/t);
- m_sigma[j] = t;
- if (j != k)
- {
- f = -sn*e[j-1];
- e[j-1] = cs*e[j-1];
- }
- if (wantv)
- {
- for (i = 0; i < n; ++i)
- {
- t = cs*m_matV(i,j) + sn*m_matV(i,p-1);
- m_matV(i,p-1) = -sn*m_matV(i,j) + cs*m_matV(i,p-1);
- m_matV(i,j) = t;
- }
- }
- }
- }
- break;
-
- // Split at negligible s(k).
- case 2:
- {
- Scalar f(e[k-1]);
- e[k-1] = 0.0;
- for (j = k; j < p; ++j)
- {
- Scalar t(numext::hypot(m_sigma[j],f));
- Scalar cs( m_sigma[j]/t);
- Scalar sn(f/t);
- m_sigma[j] = t;
- f = -sn*e[j];
- e[j] = cs*e[j];
- if (wantu)
- {
- for (i = 0; i < m; ++i)
- {
- t = cs*m_matU(i,j) + sn*m_matU(i,k-1);
- m_matU(i,k-1) = -sn*m_matU(i,j) + cs*m_matU(i,k-1);
- m_matU(i,j) = t;
- }
- }
- }
- }
- break;
-
- // Perform one qr step.
- case 3:
- {
- // Calculate the shift.
- Scalar scale = (std::max)((std::max)((std::max)((std::max)(
- ei_abs(m_sigma[p-1]),ei_abs(m_sigma[p-2])),ei_abs(e[p-2])),
- ei_abs(m_sigma[k])),ei_abs(e[k]));
- Scalar sp = m_sigma[p-1]/scale;
- Scalar spm1 = m_sigma[p-2]/scale;
- Scalar epm1 = e[p-2]/scale;
- Scalar sk = m_sigma[k]/scale;
- Scalar ek = e[k]/scale;
- Scalar b = ((spm1 + sp)*(spm1 - sp) + epm1*epm1)/Scalar(2);
- Scalar c = (sp*epm1)*(sp*epm1);
- Scalar shift(0);
- if ((b != 0.0) || (c != 0.0))
- {
- shift = ei_sqrt(b*b + c);
- if (b < 0.0)
- shift = -shift;
- shift = c/(b + shift);
- }
- Scalar f = (sk + sp)*(sk - sp) + shift;
- Scalar g = sk*ek;
-
- // Chase zeros.
-
- for (j = k; j < p-1; ++j)
- {
- Scalar t = numext::hypot(f,g);
- Scalar cs = f/t;
- Scalar sn = g/t;
- if (j != k)
- e[j-1] = t;
- f = cs*m_sigma[j] + sn*e[j];
- e[j] = cs*e[j] - sn*m_sigma[j];
- g = sn*m_sigma[j+1];
- m_sigma[j+1] = cs*m_sigma[j+1];
- if (wantv)
- {
- for (i = 0; i < n; ++i)
- {
- t = cs*m_matV(i,j) + sn*m_matV(i,j+1);
- m_matV(i,j+1) = -sn*m_matV(i,j) + cs*m_matV(i,j+1);
- m_matV(i,j) = t;
- }
- }
- t = numext::hypot(f,g);
- cs = f/t;
- sn = g/t;
- m_sigma[j] = t;
- f = cs*e[j] + sn*m_sigma[j+1];
- m_sigma[j+1] = -sn*e[j] + cs*m_sigma[j+1];
- g = sn*e[j+1];
- e[j+1] = cs*e[j+1];
- if (wantu && (j < m-1))
- {
- for (i = 0; i < m; ++i)
- {
- t = cs*m_matU(i,j) + sn*m_matU(i,j+1);
- m_matU(i,j+1) = -sn*m_matU(i,j) + cs*m_matU(i,j+1);
- m_matU(i,j) = t;
- }
- }
- }
- e[p-2] = f;
- iter = iter + 1;
- }
- break;
-
- // Convergence.
- case 4:
- {
- // Make the singular values positive.
- if (m_sigma[k] <= 0.0)
- {
- m_sigma[k] = m_sigma[k] < Scalar(0) ? -m_sigma[k] : Scalar(0);
- if (wantv)
- m_matV.col(k).start(pp+1) = -m_matV.col(k).start(pp+1);
- }
-
- // Order the singular values.
- while (k < pp)
- {
- if (m_sigma[k] >= m_sigma[k+1])
- break;
- Scalar t = m_sigma[k];
- m_sigma[k] = m_sigma[k+1];
- m_sigma[k+1] = t;
- if (wantv && (k < n-1))
- m_matV.col(k).swap(m_matV.col(k+1));
- if (wantu && (k < m-1))
- m_matU.col(k).swap(m_matU.col(k+1));
- ++k;
- }
- iter = 0;
- p--;
- }
- break;
- } // end big switch
- } // end iterations
-}
-
-template<typename MatrixType>
-SVD<MatrixType>& SVD<MatrixType>::sort()
-{
- int mu = m_matU.rows();
- int mv = m_matV.rows();
- int n = m_matU.cols();
-
- for (int i=0; i<n; ++i)
- {
- int k = i;
- Scalar p = m_sigma.coeff(i);
-
- for (int j=i+1; j<n; ++j)
- {
- if (m_sigma.coeff(j) > p)
- {
- k = j;
- p = m_sigma.coeff(j);
- }
- }
- if (k != i)
- {
- m_sigma.coeffRef(k) = m_sigma.coeff(i); // i.e.
- m_sigma.coeffRef(i) = p; // swaps the i-th and the k-th elements
-
- int j = mu;
- for(int s=0; j!=0; ++s, --j)
- std::swap(m_matU.coeffRef(s,i), m_matU.coeffRef(s,k));
-
- j = mv;
- for (int s=0; j!=0; ++s, --j)
- std::swap(m_matV.coeffRef(s,i), m_matV.coeffRef(s,k));
- }
- }
- return *this;
-}
-
-/** \returns the solution of \f$ A x = b \f$ using the current SVD decomposition of A.
- * The parts of the solution corresponding to zero singular values are ignored.
- *
- * \sa MatrixBase::svd(), LU::solve(), LLT::solve()
- */
-template<typename MatrixType>
-template<typename OtherDerived, typename ResultType>
-bool SVD<MatrixType>::solve(const MatrixBase<OtherDerived> &b, ResultType* result) const
-{
- ei_assert(b.rows() == m_matU.rows());
-
- Scalar maxVal = m_sigma.cwise().abs().maxCoeff();
- for (int j=0; j<b.cols(); ++j)
- {
- Matrix<Scalar,MatrixUType::RowsAtCompileTime,1> aux = m_matU.transpose() * b.col(j);
-
- for (int i = 0; i <m_matU.cols(); ++i)
- {
- Scalar si = m_sigma.coeff(i);
- if (ei_isMuchSmallerThan(ei_abs(si),maxVal))
- aux.coeffRef(i) = 0;
- else
- aux.coeffRef(i) /= si;
- }
-
- result->col(j) = m_matV * aux;
- }
- return true;
-}
-
-/** Computes the polar decomposition of the matrix, as a product unitary x positive.
- *
- * If either pointer is zero, the corresponding computation is skipped.
- *
- * Only for square matrices.
- *
- * \sa computePositiveUnitary(), computeRotationScaling()
- */
-template<typename MatrixType>
-template<typename UnitaryType, typename PositiveType>
-void SVD<MatrixType>::computeUnitaryPositive(UnitaryType *unitary,
- PositiveType *positive) const
-{
- ei_assert(m_matU.cols() == m_matV.cols() && "Polar decomposition is only for square matrices");
- if(unitary) *unitary = m_matU * m_matV.adjoint();
- if(positive) *positive = m_matV * m_sigma.asDiagonal() * m_matV.adjoint();
-}
-
-/** Computes the polar decomposition of the matrix, as a product positive x unitary.
- *
- * If either pointer is zero, the corresponding computation is skipped.
- *
- * Only for square matrices.
- *
- * \sa computeUnitaryPositive(), computeRotationScaling()
- */
-template<typename MatrixType>
-template<typename UnitaryType, typename PositiveType>
-void SVD<MatrixType>::computePositiveUnitary(UnitaryType *positive,
- PositiveType *unitary) const
-{
- ei_assert(m_matU.rows() == m_matV.rows() && "Polar decomposition is only for square matrices");
- if(unitary) *unitary = m_matU * m_matV.adjoint();
- if(positive) *positive = m_matU * m_sigma.asDiagonal() * m_matU.adjoint();
-}
-
-/** decomposes the matrix as a product rotation x scaling, the scaling being
- * not necessarily positive.
- *
- * If either pointer is zero, the corresponding computation is skipped.
- *
- * This method requires the Geometry module.
- *
- * \sa computeScalingRotation(), computeUnitaryPositive()
- */
-template<typename MatrixType>
-template<typename RotationType, typename ScalingType>
-void SVD<MatrixType>::computeRotationScaling(RotationType *rotation, ScalingType *scaling) const
-{
- ei_assert(m_matU.rows() == m_matV.rows() && "Polar decomposition is only for square matrices");
- Scalar x = (m_matU * m_matV.adjoint()).determinant(); // so x has absolute value 1
- Matrix<Scalar, MatrixType::RowsAtCompileTime, 1> sv(m_sigma);
- sv.coeffRef(0) *= x;
- if(scaling) scaling->lazyAssign(m_matV * sv.asDiagonal() * m_matV.adjoint());
- if(rotation)
- {
- MatrixType m(m_matU);
- m.col(0) /= x;
- rotation->lazyAssign(m * m_matV.adjoint());
- }
-}
-
-/** decomposes the matrix as a product scaling x rotation, the scaling being
- * not necessarily positive.
- *
- * If either pointer is zero, the corresponding computation is skipped.
- *
- * This method requires the Geometry module.
- *
- * \sa computeRotationScaling(), computeUnitaryPositive()
- */
-template<typename MatrixType>
-template<typename ScalingType, typename RotationType>
-void SVD<MatrixType>::computeScalingRotation(ScalingType *scaling, RotationType *rotation) const
-{
- ei_assert(m_matU.rows() == m_matV.rows() && "Polar decomposition is only for square matrices");
- Scalar x = (m_matU * m_matV.adjoint()).determinant(); // so x has absolute value 1
- Matrix<Scalar, MatrixType::RowsAtCompileTime, 1> sv(m_sigma);
- sv.coeffRef(0) *= x;
- if(scaling) scaling->lazyAssign(m_matU * sv.asDiagonal() * m_matU.adjoint());
- if(rotation)
- {
- MatrixType m(m_matU);
- m.col(0) /= x;
- rotation->lazyAssign(m * m_matV.adjoint());
- }
-}
-
-
-/** \svd_module
- * \returns the SVD decomposition of \c *this
- */
-template<typename Derived>
-inline SVD<typename MatrixBase<Derived>::PlainObject>
-MatrixBase<Derived>::svd() const
-{
- return SVD<PlainObject>(derived());
-}
-
-} // end namespace Eigen
-
-#endif // EIGEN2_SVD_H
diff --git a/Eigen/src/Eigen2Support/TriangularSolver.h b/Eigen/src/Eigen2Support/TriangularSolver.h
deleted file mode 100644
index ebbeb3b49..000000000
--- a/Eigen/src/Eigen2Support/TriangularSolver.h
+++ /dev/null
@@ -1,42 +0,0 @@
-// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra.
-//
-// Copyright (C) 2010 Gael Guennebaud <gael.guennebaud@inria.fr>
-//
-// 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/.
-
-#ifndef EIGEN_TRIANGULAR_SOLVER2_H
-#define EIGEN_TRIANGULAR_SOLVER2_H
-
-namespace Eigen {
-
-const unsigned int UnitDiagBit = UnitDiag;
-const unsigned int SelfAdjointBit = SelfAdjoint;
-const unsigned int UpperTriangularBit = Upper;
-const unsigned int LowerTriangularBit = Lower;
-
-const unsigned int UpperTriangular = Upper;
-const unsigned int LowerTriangular = Lower;
-const unsigned int UnitUpperTriangular = UnitUpper;
-const unsigned int UnitLowerTriangular = UnitLower;
-
-template<typename ExpressionType, unsigned int Added, unsigned int Removed>
-template<typename OtherDerived>
-typename ExpressionType::PlainObject
-Flagged<ExpressionType,Added,Removed>::solveTriangular(const MatrixBase<OtherDerived>& other) const
-{
- return m_matrix.template triangularView<Added>().solve(other.derived());
-}
-
-template<typename ExpressionType, unsigned int Added, unsigned int Removed>
-template<typename OtherDerived>
-void Flagged<ExpressionType,Added,Removed>::solveTriangularInPlace(const MatrixBase<OtherDerived>& other) const
-{
- m_matrix.template triangularView<Added>().solveInPlace(other.derived());
-}
-
-} // end namespace Eigen
-
-#endif // EIGEN_TRIANGULAR_SOLVER2_H
diff --git a/Eigen/src/Eigen2Support/VectorBlock.h b/Eigen/src/Eigen2Support/VectorBlock.h
deleted file mode 100644
index 71a8080a9..000000000
--- a/Eigen/src/Eigen2Support/VectorBlock.h
+++ /dev/null
@@ -1,94 +0,0 @@
-// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra.
-//
-// Copyright (C) 2008-2009 Gael Guennebaud <gael.guennebaud@inria.fr>
-// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
-//
-// 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/.
-
-#ifndef EIGEN2_VECTORBLOCK_H
-#define EIGEN2_VECTORBLOCK_H
-
-namespace Eigen {
-
-/** \deprecated use DenseMase::head(Index) */
-template<typename Derived>
-inline VectorBlock<Derived>
-MatrixBase<Derived>::start(Index size)
-{
- EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
- return VectorBlock<Derived>(derived(), 0, size);
-}
-
-/** \deprecated use DenseMase::head(Index) */
-template<typename Derived>
-inline const VectorBlock<const Derived>
-MatrixBase<Derived>::start(Index size) const
-{
- EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
- return VectorBlock<const Derived>(derived(), 0, size);
-}
-
-/** \deprecated use DenseMase::tail(Index) */
-template<typename Derived>
-inline VectorBlock<Derived>
-MatrixBase<Derived>::end(Index size)
-{
- EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
- return VectorBlock<Derived>(derived(), this->size() - size, size);
-}
-
-/** \deprecated use DenseMase::tail(Index) */
-template<typename Derived>
-inline const VectorBlock<const Derived>
-MatrixBase<Derived>::end(Index size) const
-{
- EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
- return VectorBlock<const Derived>(derived(), this->size() - size, size);
-}
-
-/** \deprecated use DenseMase::head() */
-template<typename Derived>
-template<int Size>
-inline VectorBlock<Derived,Size>
-MatrixBase<Derived>::start()
-{
- EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
- return VectorBlock<Derived,Size>(derived(), 0);
-}
-
-/** \deprecated use DenseMase::head() */
-template<typename Derived>
-template<int Size>
-inline const VectorBlock<const Derived,Size>
-MatrixBase<Derived>::start() const
-{
- EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
- return VectorBlock<const Derived,Size>(derived(), 0);
-}
-
-/** \deprecated use DenseMase::tail() */
-template<typename Derived>
-template<int Size>
-inline VectorBlock<Derived,Size>
-MatrixBase<Derived>::end()
-{
- EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
- return VectorBlock<Derived, Size>(derived(), size() - Size);
-}
-
-/** \deprecated use DenseMase::tail() */
-template<typename Derived>
-template<int Size>
-inline const VectorBlock<const Derived,Size>
-MatrixBase<Derived>::end() const
-{
- EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
- return VectorBlock<const Derived, Size>(derived(), size() - Size);
-}
-
-} // end namespace Eigen
-
-#endif // EIGEN2_VECTORBLOCK_H
diff --git a/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h b/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h
index b8146d04d..fc8ecaa6f 100644
--- a/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h
+++ b/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h
@@ -346,40 +346,6 @@ template<typename _MatrixType> class SelfAdjointEigenSolver
*/
static const int m_maxIterations = 30;
- #ifdef EIGEN2_SUPPORT
- EIGEN_DEVICE_FUNC
- SelfAdjointEigenSolver(const MatrixType& matrix, bool computeEigenvectors)
- : m_eivec(matrix.rows(), matrix.cols()),
- m_eivalues(matrix.cols()),
- m_subdiag(matrix.rows() > 1 ? matrix.rows() - 1 : 1),
- m_isInitialized(false)
- {
- compute(matrix, computeEigenvectors);
- }
-
- EIGEN_DEVICE_FUNC
- SelfAdjointEigenSolver(const MatrixType& matA, const MatrixType& matB, bool computeEigenvectors = true)
- : m_eivec(matA.cols(), matA.cols()),
- m_eivalues(matA.cols()),
- m_subdiag(matA.cols() > 1 ? matA.cols() - 1 : 1),
- m_isInitialized(false)
- {
- static_cast<GeneralizedSelfAdjointEigenSolver<MatrixType>*>(this)->compute(matA, matB, computeEigenvectors ? ComputeEigenvectors : EigenvaluesOnly);
- }
-
- EIGEN_DEVICE_FUNC
- void compute(const MatrixType& matrix, bool computeEigenvectors)
- {
- compute(matrix, computeEigenvectors ? ComputeEigenvectors : EigenvaluesOnly);
- }
-
- EIGEN_DEVICE_FUNC
- void compute(const MatrixType& matA, const MatrixType& matB, bool computeEigenvectors = true)
- {
- compute(matA, matB, computeEigenvectors ? ComputeEigenvectors : EigenvaluesOnly);
- }
- #endif // EIGEN2_SUPPORT
-
protected:
MatrixType m_eivec;
RealVectorType m_eivalues;
@@ -389,6 +355,7 @@ template<typename _MatrixType> class SelfAdjointEigenSolver
bool m_eigenvectorsOk;
};
+namespace internal {
/** \internal
*
* \eigenvalues_module \ingroup Eigenvalues_Module
@@ -405,7 +372,6 @@ template<typename _MatrixType> class SelfAdjointEigenSolver
* Implemented from Golub's "Matrix Computations", algorithm 8.3.2:
* "implicit symmetric QR step with Wilkinson shift"
*/
-namespace internal {
template<int StorageOrder,typename RealScalar, typename Scalar, typename Index>
EIGEN_DEVICE_FUNC
static void tridiagonal_qr_step(RealScalar* diag, RealScalar* subdiag, Index start, Index end, Scalar* matrixQ, Index n);
diff --git a/Eigen/src/Geometry/AngleAxis.h b/Eigen/src/Geometry/AngleAxis.h
index b42048c55..636712c2b 100644
--- a/Eigen/src/Geometry/AngleAxis.h
+++ b/Eigen/src/Geometry/AngleAxis.h
@@ -77,7 +77,9 @@ public:
* represents an invalid rotation. */
template<typename Derived>
inline AngleAxis(const Scalar& angle, const MatrixBase<Derived>& axis) : m_axis(axis), m_angle(angle) {}
- /** Constructs and initialize the angle-axis rotation from a quaternion \a q. */
+ /** Constructs and initialize the angle-axis rotation from a quaternion \a q.
+ * This function implicitly normalizes the quaternion \a q.
+ */
template<typename QuatDerived> inline explicit AngleAxis(const QuaternionBase<QuatDerived>& q) { *this = q; }
/** Constructs and initialize the angle-axis rotation from a 3x3 rotation matrix. */
template<typename Derived>
@@ -149,29 +151,27 @@ typedef AngleAxis<float> AngleAxisf;
typedef AngleAxis<double> AngleAxisd;
/** Set \c *this from a \b unit quaternion.
- * The axis is normalized.
+ * The resulting axis is normalized.
*
- * \warning As any other method dealing with quaternion, if the input quaternion
- * is not normalized then the result is undefined.
+ * This function implicitly normalizes the quaternion \a q.
*/
template<typename Scalar>
template<typename QuatDerived>
AngleAxis<Scalar>& AngleAxis<Scalar>::operator=(const QuaternionBase<QuatDerived>& q)
{
- using std::acos;
- EIGEN_USING_STD_MATH(min);
- EIGEN_USING_STD_MATH(max);
- using std::sqrt;
- Scalar n2 = q.vec().squaredNorm();
- if (n2 < NumTraits<Scalar>::dummy_precision()*NumTraits<Scalar>::dummy_precision())
+ using std::atan2;
+ Scalar n = q.vec().norm();
+ if(n<NumTraits<Scalar>::epsilon())
+ n = q.vec().stableNorm();
+ if (n > Scalar(0))
{
- m_angle = Scalar(0);
- m_axis << Scalar(1), Scalar(0), Scalar(0);
+ m_angle = Scalar(2)*atan2(n, q.w());
+ m_axis = q.vec() / n;
}
else
{
- m_angle = Scalar(2)*acos((min)((max)(Scalar(-1),q.w()),Scalar(1)));
- m_axis = q.vec() / sqrt(n2);
+ m_angle = 0;
+ m_axis << 1, 0, 0;
}
return *this;
}
diff --git a/Eigen/src/IterativeLinearSolvers/BasicPreconditioners.h b/Eigen/src/IterativeLinearSolvers/BasicPreconditioners.h
index 73ca9bfde..1f3c060d0 100644
--- a/Eigen/src/IterativeLinearSolvers/BasicPreconditioners.h
+++ b/Eigen/src/IterativeLinearSolvers/BasicPreconditioners.h
@@ -65,10 +65,10 @@ class DiagonalPreconditioner
{
typename MatType::InnerIterator it(mat,j);
while(it && it.index()!=j) ++it;
- if(it && it.index()==j)
+ if(it && it.index()==j && it.value()!=Scalar(0))
m_invdiag(j) = Scalar(1)/it.value();
else
- m_invdiag(j) = 0;
+ m_invdiag(j) = Scalar(1);
}
m_isInitialized = true;
return *this;
diff --git a/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h b/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h
index 7a46b51fa..dc524c225 100644
--- a/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h
+++ b/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h
@@ -61,6 +61,7 @@ bool bicgstab(const MatrixType& mat, const Rhs& rhs, Dest& x,
VectorType s(n), t(n);
RealScalar tol2 = tol*tol;
+ RealScalar eps2 = NumTraits<Scalar>::epsilon()*NumTraits<Scalar>::epsilon();
int i = 0;
int restarts = 0;
@@ -69,7 +70,7 @@ bool bicgstab(const MatrixType& mat, const Rhs& rhs, Dest& x,
Scalar rho_old = rho;
rho = r0.dot(r);
- if (internal::isMuchSmallerThan(rho,r0_sqnorm))
+ if (abs(rho) < eps2*r0_sqnorm)
{
// The new residual vector became too orthogonal to the arbitrarily choosen direction r0
// Let's restart with a new r0:
diff --git a/Eigen/src/Jacobi/Jacobi.h b/Eigen/src/Jacobi/Jacobi.h
index 956f72d57..da9fb53d0 100644
--- a/Eigen/src/Jacobi/Jacobi.h
+++ b/Eigen/src/Jacobi/Jacobi.h
@@ -255,13 +255,13 @@ void JacobiRotation<Scalar>::makeGivens(const Scalar& p, const Scalar& q, Scalar
* Implementation of MatrixBase methods
****************************************************************************************/
+namespace internal {
/** \jacobi_module
* Applies the clock wise 2D rotation \a j to the set of 2D vectors of cordinates \a x and \a y:
* \f$ \left ( \begin{array}{cc} x \\ y \end{array} \right ) = J \left ( \begin{array}{cc} x \\ y \end{array} \right ) \f$
*
* \sa MatrixBase::applyOnTheLeft(), MatrixBase::applyOnTheRight()
*/
-namespace internal {
template<typename VectorX, typename VectorY, typename OtherScalar>
void apply_rotation_in_the_plane(VectorX& _x, VectorY& _y, const JacobiRotation<OtherScalar>& j);
}
diff --git a/Eigen/src/LU/PartialPivLU.h b/Eigen/src/LU/PartialPivLU.h
index 1d389ecac..2f65c3a49 100644
--- a/Eigen/src/LU/PartialPivLU.h
+++ b/Eigen/src/LU/PartialPivLU.h
@@ -371,13 +371,13 @@ struct partial_lu_impl
/** \internal performs the LU decomposition with partial pivoting in-place.
*/
template<typename MatrixType, typename TranspositionType>
-void partial_lu_inplace(MatrixType& lu, TranspositionType& row_transpositions, typename TranspositionType::Index& nb_transpositions)
+void partial_lu_inplace(MatrixType& lu, TranspositionType& row_transpositions, typename TranspositionType::StorageIndexType& nb_transpositions)
{
eigen_assert(lu.cols() == row_transpositions.size());
eigen_assert((&row_transpositions.coeffRef(1)-&row_transpositions.coeffRef(0)) == 1);
partial_lu_impl
- <typename MatrixType::Scalar, MatrixType::Flags&RowMajorBit?RowMajor:ColMajor, typename TranspositionType::Index>
+ <typename MatrixType::Scalar, MatrixType::Flags&RowMajorBit?RowMajor:ColMajor, typename TranspositionType::StorageIndexType>
::blocked_lu(lu.rows(), lu.cols(), &lu.coeffRef(0,0), lu.outerStride(), &row_transpositions.coeffRef(0), nb_transpositions);
}
@@ -396,7 +396,7 @@ PartialPivLU<MatrixType>& PartialPivLU<MatrixType>::compute(const MatrixType& ma
m_rowsTranspositions.resize(size);
- typename TranspositionType::Index nb_transpositions;
+ typename TranspositionType::StorageIndexType nb_transpositions;
internal::partial_lu_inplace(m_lu, m_rowsTranspositions, nb_transpositions);
m_det_p = (nb_transpositions%2) ? -1 : 1;
@@ -481,7 +481,6 @@ MatrixBase<Derived>::partialPivLu() const
}
#endif
-#if EIGEN2_SUPPORT_STAGE > STAGE20_RESOLVE_API_CONFLICTS
/** \lu_module
*
* Synonym of partialPivLu().
@@ -499,8 +498,6 @@ MatrixBase<Derived>::lu() const
}
#endif
-#endif
-
} // end namespace Eigen
#endif // EIGEN_PARTIALLU_H
diff --git a/Eigen/src/OrderingMethods/Ordering.h b/Eigen/src/OrderingMethods/Ordering.h
index b4da6531a..f3c31f9cb 100644
--- a/Eigen/src/OrderingMethods/Ordering.h
+++ b/Eigen/src/OrderingMethods/Ordering.h
@@ -109,7 +109,7 @@ class NaturalOrdering
* \class COLAMDOrdering
*
* Functor computing the \em column \em approximate \em minimum \em degree ordering
- * The matrix should be in column-major format
+ * The matrix should be in column-major and \b compressed format (see SparseMatrix::makeCompressed()).
*/
template<typename Index>
class COLAMDOrdering
@@ -118,10 +118,14 @@ class COLAMDOrdering
typedef PermutationMatrix<Dynamic, Dynamic, Index> PermutationType;
typedef Matrix<Index, Dynamic, 1> IndexVector;
- /** Compute the permutation vector form a sparse matrix */
+ /** Compute the permutation vector \a perm form the sparse matrix \a mat
+ * \warning The input sparse matrix \a mat must be in compressed mode (see SparseMatrix::makeCompressed()).
+ */
template <typename MatrixType>
void operator() (const MatrixType& mat, PermutationType& perm)
{
+ eigen_assert(mat.isCompressed() && "COLAMDOrdering requires a sparse matrix in compressed mode. Call .makeCompressed() before passing it to COLAMDOrdering");
+
Index m = mat.rows();
Index n = mat.cols();
Index nnz = mat.nonZeros();
@@ -132,12 +136,12 @@ class COLAMDOrdering
Index stats [COLAMD_STATS];
internal::colamd_set_defaults(knobs);
- Index info;
IndexVector p(n+1), A(Alen);
for(Index i=0; i <= n; i++) p(i) = mat.outerIndexPtr()[i];
for(Index i=0; i < nnz; i++) A(i) = mat.innerIndexPtr()[i];
// Call Colamd routine to compute the ordering
- info = internal::colamd(m, n, Alen, A.data(), p.data(), knobs, stats);
+ Index info = internal::colamd(m, n, Alen, A.data(), p.data(), knobs, stats);
+ EIGEN_UNUSED_VARIABLE(info);
eigen_assert( info && "COLAMD failed " );
perm.resize(n);
diff --git a/Eigen/src/SVD/JacobiSVD.h b/Eigen/src/SVD/JacobiSVD.h
index 439eb5d29..412daa746 100644
--- a/Eigen/src/SVD/JacobiSVD.h
+++ b/Eigen/src/SVD/JacobiSVD.h
@@ -375,17 +375,19 @@ struct svd_precondition_2x2_block_to_be_real<MatrixType, QRPreconditioner, true>
Scalar z;
JacobiRotation<Scalar> rot;
RealScalar n = sqrt(numext::abs2(work_matrix.coeff(p,p)) + numext::abs2(work_matrix.coeff(q,p)));
+
if(n==0)
{
z = abs(work_matrix.coeff(p,q)) / work_matrix.coeff(p,q);
work_matrix.row(p) *= z;
if(svd.computeU()) svd.m_matrixU.col(p) *= conj(z);
if(work_matrix.coeff(q,q)!=Scalar(0))
+ {
z = abs(work_matrix.coeff(q,q)) / work_matrix.coeff(q,q);
- else
- z = Scalar(0);
- work_matrix.row(q) *= z;
- if(svd.computeU()) svd.m_matrixU.col(q) *= conj(z);
+ work_matrix.row(q) *= z;
+ if(svd.computeU()) svd.m_matrixU.col(q) *= conj(z);
+ }
+ // otherwise the second row is already zero, so we have nothing to do.
}
else
{
@@ -835,7 +837,7 @@ JacobiSVD<MatrixType, QRPreconditioner>::compute(const MatrixType& matrix, unsig
if(m_computeThinV) m_matrixV.setIdentity(m_cols, m_diagSize);
}
- // Scaling factor to reducover/under-flows
+ // Scaling factor to reduce over/under-flows
RealScalar scale = m_workMatrix.cwiseAbs().maxCoeff();
if(scale==RealScalar(0)) scale = RealScalar(1);
m_workMatrix /= scale;
diff --git a/Eigen/src/SparseCholesky/SimplicialCholesky.h b/Eigen/src/SparseCholesky/SimplicialCholesky.h
index f41d7e010..e1f96ba5a 100644
--- a/Eigen/src/SparseCholesky/SimplicialCholesky.h
+++ b/Eigen/src/SparseCholesky/SimplicialCholesky.h
@@ -37,6 +37,7 @@ class SimplicialCholeskyBase : internal::noncopyable
{
public:
typedef typename internal::traits<Derived>::MatrixType MatrixType;
+ typedef typename internal::traits<Derived>::OrderingType OrderingType;
enum { UpLo = internal::traits<Derived>::UpLo };
typedef typename MatrixType::Scalar Scalar;
typedef typename MatrixType::RealScalar RealScalar;
@@ -240,15 +241,16 @@ class SimplicialCholeskyBase : internal::noncopyable
RealScalar m_shiftScale;
};
-template<typename _MatrixType, int _UpLo = Lower> class SimplicialLLT;
-template<typename _MatrixType, int _UpLo = Lower> class SimplicialLDLT;
-template<typename _MatrixType, int _UpLo = Lower> class SimplicialCholesky;
+template<typename _MatrixType, int _UpLo = Lower, typename _Ordering = AMDOrdering<typename _MatrixType::Index> > class SimplicialLLT;
+template<typename _MatrixType, int _UpLo = Lower, typename _Ordering = AMDOrdering<typename _MatrixType::Index> > class SimplicialLDLT;
+template<typename _MatrixType, int _UpLo = Lower, typename _Ordering = AMDOrdering<typename _MatrixType::Index> > class SimplicialCholesky;
namespace internal {
-template<typename _MatrixType, int _UpLo> struct traits<SimplicialLLT<_MatrixType,_UpLo> >
+template<typename _MatrixType, int _UpLo, typename _Ordering> struct traits<SimplicialLLT<_MatrixType,_UpLo,_Ordering> >
{
typedef _MatrixType MatrixType;
+ typedef _Ordering OrderingType;
enum { UpLo = _UpLo };
typedef typename MatrixType::Scalar Scalar;
typedef typename MatrixType::Index Index;
@@ -259,9 +261,10 @@ template<typename _MatrixType, int _UpLo> struct traits<SimplicialLLT<_MatrixTyp
static inline MatrixU getU(const MatrixType& m) { return m.adjoint(); }
};
-template<typename _MatrixType,int _UpLo> struct traits<SimplicialLDLT<_MatrixType,_UpLo> >
+template<typename _MatrixType,int _UpLo, typename _Ordering> struct traits<SimplicialLDLT<_MatrixType,_UpLo,_Ordering> >
{
typedef _MatrixType MatrixType;
+ typedef _Ordering OrderingType;
enum { UpLo = _UpLo };
typedef typename MatrixType::Scalar Scalar;
typedef typename MatrixType::Index Index;
@@ -272,9 +275,10 @@ template<typename _MatrixType,int _UpLo> struct traits<SimplicialLDLT<_MatrixTyp
static inline MatrixU getU(const MatrixType& m) { return m.adjoint(); }
};
-template<typename _MatrixType, int _UpLo> struct traits<SimplicialCholesky<_MatrixType,_UpLo> >
+template<typename _MatrixType, int _UpLo, typename _Ordering> struct traits<SimplicialCholesky<_MatrixType,_UpLo,_Ordering> >
{
typedef _MatrixType MatrixType;
+ typedef _Ordering OrderingType;
enum { UpLo = _UpLo };
};
@@ -294,11 +298,12 @@ template<typename _MatrixType, int _UpLo> struct traits<SimplicialCholesky<_Matr
* \tparam _MatrixType the type of the sparse matrix A, it must be a SparseMatrix<>
* \tparam _UpLo the triangular part that will be used for the computations. It can be Lower
* or Upper. Default is Lower.
+ * \tparam _Ordering The ordering method to use, either AMDOrdering<> or NaturalOrdering<>. Default is AMDOrdering<>
*
- * \sa class SimplicialLDLT
+ * \sa class SimplicialLDLT, class AMDOrdering, class NaturalOrdering
*/
-template<typename _MatrixType, int _UpLo>
- class SimplicialLLT : public SimplicialCholeskyBase<SimplicialLLT<_MatrixType,_UpLo> >
+template<typename _MatrixType, int _UpLo, typename _Ordering>
+ class SimplicialLLT : public SimplicialCholeskyBase<SimplicialLLT<_MatrixType,_UpLo,_Ordering> >
{
public:
typedef _MatrixType MatrixType;
@@ -382,11 +387,12 @@ public:
* \tparam _MatrixType the type of the sparse matrix A, it must be a SparseMatrix<>
* \tparam _UpLo the triangular part that will be used for the computations. It can be Lower
* or Upper. Default is Lower.
+ * \tparam _Ordering The ordering method to use, either AMDOrdering<> or NaturalOrdering<>. Default is AMDOrdering<>
*
- * \sa class SimplicialLLT
+ * \sa class SimplicialLLT, class AMDOrdering, class NaturalOrdering
*/
-template<typename _MatrixType, int _UpLo>
- class SimplicialLDLT : public SimplicialCholeskyBase<SimplicialLDLT<_MatrixType,_UpLo> >
+template<typename _MatrixType, int _UpLo, typename _Ordering>
+ class SimplicialLDLT : public SimplicialCholeskyBase<SimplicialLDLT<_MatrixType,_UpLo,_Ordering> >
{
public:
typedef _MatrixType MatrixType;
@@ -467,8 +473,8 @@ public:
*
* \sa class SimplicialLDLT, class SimplicialLLT
*/
-template<typename _MatrixType, int _UpLo>
- class SimplicialCholesky : public SimplicialCholeskyBase<SimplicialCholesky<_MatrixType,_UpLo> >
+template<typename _MatrixType, int _UpLo, typename _Ordering>
+ class SimplicialCholesky : public SimplicialCholeskyBase<SimplicialCholesky<_MatrixType,_UpLo,_Ordering> >
{
public:
typedef _MatrixType MatrixType;
@@ -612,15 +618,13 @@ void SimplicialCholeskyBase<Derived>::ordering(const MatrixType& a, CholMatrixTy
{
eigen_assert(a.rows()==a.cols());
const Index size = a.rows();
- // TODO allows to configure the permutation
// Note that amd compute the inverse permutation
{
CholMatrixType C;
C = a.template selfadjointView<UpLo>();
- // remove diagonal entries:
- // seems not to be needed
- // C.prune(keep_diag());
- internal::minimum_degree_ordering(C, m_Pinv);
+
+ OrderingType ordering;
+ ordering(C,m_Pinv);
}
if(m_Pinv.size()>0)
diff --git a/Eigen/src/SparseCore/CompressedStorage.h b/Eigen/src/SparseCore/CompressedStorage.h
index 10d516a66..a667cb56e 100644
--- a/Eigen/src/SparseCore/CompressedStorage.h
+++ b/Eigen/src/SparseCore/CompressedStorage.h
@@ -83,10 +83,10 @@ class CompressedStorage
reallocate(m_size);
}
- void resize(size_t size, float reserveSizeFactor = 0)
+ void resize(size_t size, double reserveSizeFactor = 0)
{
if (m_allocatedSize<size)
- reallocate(size + size_t(reserveSizeFactor*size));
+ reallocate(size + size_t(reserveSizeFactor*double(size)));
m_size = size;
}
diff --git a/Eigen/src/SparseCore/SparseBlock.h b/Eigen/src/SparseCore/SparseBlock.h
index 5b95cc33f..491cc72b0 100644
--- a/Eigen/src/SparseCore/SparseBlock.h
+++ b/Eigen/src/SparseCore/SparseBlock.h
@@ -50,11 +50,11 @@ public:
Index m_outer;
};
- inline BlockImpl(const XprType& xpr, int i)
+ inline BlockImpl(const XprType& xpr, Index i)
: m_matrix(xpr), m_outerStart(i), m_outerSize(OuterSize)
{}
- inline BlockImpl(const XprType& xpr, int startRow, int startCol, int blockRows, int blockCols)
+ inline BlockImpl(const XprType& xpr, Index startRow, Index startCol, Index blockRows, Index blockCols)
: m_matrix(xpr), m_outerStart(IsRowMajor ? startRow : startCol), m_outerSize(IsRowMajor ? blockRows : blockCols)
{}
@@ -65,7 +65,7 @@ public:
{
Index nnz = 0;
Index end = m_outerStart + m_outerSize.value();
- for(int j=m_outerStart; j<end; ++j)
+ for(Index j=m_outerStart; j<end; ++j)
for(typename XprType::InnerIterator it(m_matrix, j); it; ++it)
++nnz;
return nnz;
@@ -124,11 +124,11 @@ public:
Index m_outer;
};
- inline sparse_matrix_block_impl(const SparseMatrixType& xpr, int i)
+ inline sparse_matrix_block_impl(const SparseMatrixType& xpr, Index i)
: m_matrix(xpr), m_outerStart(i), m_outerSize(OuterSize)
{}
- inline sparse_matrix_block_impl(const SparseMatrixType& xpr, int startRow, int startCol, int blockRows, int blockCols)
+ inline sparse_matrix_block_impl(const SparseMatrixType& xpr, Index startRow, Index startCol, Index blockRows, Index blockCols)
: m_matrix(xpr), m_outerStart(IsRowMajor ? startRow : startCol), m_outerSize(IsRowMajor ? blockRows : blockCols)
{}
@@ -228,8 +228,8 @@ public:
Index nonZeros() const
{
if(m_matrix.isCompressed())
- return std::size_t(m_matrix.outerIndexPtr()[m_outerStart+m_outerSize.value()])
- - std::size_t(m_matrix.outerIndexPtr()[m_outerStart]);
+ return Index( std::size_t(m_matrix.outerIndexPtr()[m_outerStart+m_outerSize.value()])
+ - std::size_t(m_matrix.outerIndexPtr()[m_outerStart]));
else if(m_outerSize.value()==0)
return 0;
else
@@ -264,13 +264,14 @@ class BlockImpl<SparseMatrix<_Scalar, _Options, _Index>,BlockRows,BlockCols,true
: public internal::sparse_matrix_block_impl<SparseMatrix<_Scalar, _Options, _Index>,BlockRows,BlockCols>
{
public:
+ typedef _Index Index;
typedef SparseMatrix<_Scalar, _Options, _Index> SparseMatrixType;
typedef internal::sparse_matrix_block_impl<SparseMatrixType,BlockRows,BlockCols> Base;
- inline BlockImpl(SparseMatrixType& xpr, int i)
+ inline BlockImpl(SparseMatrixType& xpr, Index i)
: Base(xpr, i)
{}
- inline BlockImpl(SparseMatrixType& xpr, int startRow, int startCol, int blockRows, int blockCols)
+ inline BlockImpl(SparseMatrixType& xpr, Index startRow, Index startCol, Index blockRows, Index blockCols)
: Base(xpr, startRow, startCol, blockRows, blockCols)
{}
@@ -282,13 +283,14 @@ class BlockImpl<const SparseMatrix<_Scalar, _Options, _Index>,BlockRows,BlockCol
: public internal::sparse_matrix_block_impl<const SparseMatrix<_Scalar, _Options, _Index>,BlockRows,BlockCols>
{
public:
+ typedef _Index Index;
typedef const SparseMatrix<_Scalar, _Options, _Index> SparseMatrixType;
typedef internal::sparse_matrix_block_impl<SparseMatrixType,BlockRows,BlockCols> Base;
- inline BlockImpl(SparseMatrixType& xpr, int i)
+ inline BlockImpl(SparseMatrixType& xpr, Index i)
: Base(xpr, i)
{}
- inline BlockImpl(SparseMatrixType& xpr, int startRow, int startCol, int blockRows, int blockCols)
+ inline BlockImpl(SparseMatrixType& xpr, Index startRow, Index startCol, Index blockRows, Index blockCols)
: Base(xpr, startRow, startCol, blockRows, blockCols)
{}
@@ -362,7 +364,7 @@ public:
/** Column or Row constructor
*/
- inline BlockImpl(const XprType& xpr, int i)
+ inline BlockImpl(const XprType& xpr, Index i)
: m_matrix(xpr),
m_startRow( (BlockRows==1) && (BlockCols==XprType::ColsAtCompileTime) ? i : 0),
m_startCol( (BlockRows==XprType::RowsAtCompileTime) && (BlockCols==1) ? i : 0),
@@ -372,32 +374,32 @@ public:
/** Dynamic-size constructor
*/
- inline BlockImpl(const XprType& xpr, int startRow, int startCol, int blockRows, int blockCols)
+ inline BlockImpl(const XprType& xpr, Index startRow, Index startCol, Index blockRows, Index blockCols)
: m_matrix(xpr), m_startRow(startRow), m_startCol(startCol), m_blockRows(blockRows), m_blockCols(blockCols)
{}
- inline int rows() const { return m_blockRows.value(); }
- inline int cols() const { return m_blockCols.value(); }
+ inline Index rows() const { return m_blockRows.value(); }
+ inline Index cols() const { return m_blockCols.value(); }
- inline Scalar& coeffRef(int row, int col)
+ inline Scalar& coeffRef(Index row, Index col)
{
return m_matrix.const_cast_derived()
.coeffRef(row + m_startRow.value(), col + m_startCol.value());
}
- inline const Scalar coeff(int row, int col) const
+ inline const Scalar coeff(Index row, Index col) const
{
return m_matrix.coeff(row + m_startRow.value(), col + m_startCol.value());
}
- inline Scalar& coeffRef(int index)
+ inline Scalar& coeffRef(Index index)
{
return m_matrix.const_cast_derived()
.coeffRef(m_startRow.value() + (RowsAtCompileTime == 1 ? 0 : index),
m_startCol.value() + (RowsAtCompileTime == 1 ? index : 0));
}
- inline const Scalar coeff(int index) const
+ inline const Scalar coeff(Index index) const
{
return m_matrix
.coeff(m_startRow.value() + (RowsAtCompileTime == 1 ? 0 : index),
@@ -521,6 +523,7 @@ namespace internal {
while(m_outerPos<m_end)
{
m_outerPos++;
+ if(m_outerPos==m_end) break;
typename XprType::InnerIterator it(m_block.m_matrix, m_outerPos);
// search for the key m_innerIndex in the current outer-vector
while(it && it.index() < m_innerIndex) ++it;
diff --git a/Eigen/src/SparseCore/SparseCwiseBinaryOp.h b/Eigen/src/SparseCore/SparseCwiseBinaryOp.h
index ec86ca933..60fdd214a 100644
--- a/Eigen/src/SparseCore/SparseCwiseBinaryOp.h
+++ b/Eigen/src/SparseCore/SparseCwiseBinaryOp.h
@@ -69,7 +69,6 @@ class CwiseBinaryOpImpl<BinaryOp,Lhs,Rhs,Sparse>::InnerIterator
: public internal::sparse_cwise_binary_op_inner_iterator_selector<BinaryOp,Lhs,Rhs,typename CwiseBinaryOpImpl<BinaryOp,Lhs,Rhs,Sparse>::InnerIterator>
{
public:
- typedef typename Lhs::Index Index;
typedef internal::sparse_cwise_binary_op_inner_iterator_selector<
BinaryOp,Lhs,Rhs, InnerIterator> Base;
@@ -95,11 +94,11 @@ class sparse_cwise_binary_op_inner_iterator_selector<BinaryOp, Lhs, Rhs, Derived
{
typedef CwiseBinaryOp<BinaryOp, Lhs, Rhs> CwiseBinaryXpr;
typedef typename traits<CwiseBinaryXpr>::Scalar Scalar;
+ typedef typename traits<CwiseBinaryXpr>::Index Index;
typedef typename traits<CwiseBinaryXpr>::_LhsNested _LhsNested;
typedef typename traits<CwiseBinaryXpr>::_RhsNested _RhsNested;
typedef typename _LhsNested::InnerIterator LhsIterator;
typedef typename _RhsNested::InnerIterator RhsIterator;
- typedef typename Lhs::Index Index;
public:
@@ -161,11 +160,11 @@ class sparse_cwise_binary_op_inner_iterator_selector<scalar_product_op<T>, Lhs,
typedef scalar_product_op<T> BinaryFunc;
typedef CwiseBinaryOp<BinaryFunc, Lhs, Rhs> CwiseBinaryXpr;
typedef typename CwiseBinaryXpr::Scalar Scalar;
+ typedef typename CwiseBinaryXpr::Index Index;
typedef typename traits<CwiseBinaryXpr>::_LhsNested _LhsNested;
typedef typename _LhsNested::InnerIterator LhsIterator;
typedef typename traits<CwiseBinaryXpr>::_RhsNested _RhsNested;
typedef typename _RhsNested::InnerIterator RhsIterator;
- typedef typename Lhs::Index Index;
public:
EIGEN_STRONG_INLINE sparse_cwise_binary_op_inner_iterator_selector(const CwiseBinaryXpr& xpr, Index outer)
@@ -215,15 +214,15 @@ class sparse_cwise_binary_op_inner_iterator_selector<scalar_product_op<T>, Lhs,
typedef scalar_product_op<T> BinaryFunc;
typedef CwiseBinaryOp<BinaryFunc, Lhs, Rhs> CwiseBinaryXpr;
typedef typename CwiseBinaryXpr::Scalar Scalar;
+ typedef typename CwiseBinaryXpr::Index Index;
typedef typename traits<CwiseBinaryXpr>::_LhsNested _LhsNested;
typedef typename traits<CwiseBinaryXpr>::RhsNested RhsNested;
typedef typename _LhsNested::InnerIterator LhsIterator;
- typedef typename Lhs::Index Index;
enum { IsRowMajor = (int(Lhs::Flags)&RowMajorBit)==RowMajorBit };
public:
EIGEN_STRONG_INLINE sparse_cwise_binary_op_inner_iterator_selector(const CwiseBinaryXpr& xpr, Index outer)
- : m_rhs(xpr.rhs()), m_lhsIter(xpr.lhs(),outer), m_functor(xpr.functor()), m_outer(outer)
+ : m_rhs(xpr.rhs()), m_lhsIter(xpr.lhs(),typename _LhsNested::Index(outer)), m_functor(xpr.functor()), m_outer(outer)
{}
EIGEN_STRONG_INLINE Derived& operator++()
@@ -256,9 +255,9 @@ class sparse_cwise_binary_op_inner_iterator_selector<scalar_product_op<T>, Lhs,
typedef scalar_product_op<T> BinaryFunc;
typedef CwiseBinaryOp<BinaryFunc, Lhs, Rhs> CwiseBinaryXpr;
typedef typename CwiseBinaryXpr::Scalar Scalar;
+ typedef typename CwiseBinaryXpr::Index Index;
typedef typename traits<CwiseBinaryXpr>::_RhsNested _RhsNested;
typedef typename _RhsNested::InnerIterator RhsIterator;
- typedef typename Lhs::Index Index;
enum { IsRowMajor = (int(Rhs::Flags)&RowMajorBit)==RowMajorBit };
public:
diff --git a/Eigen/src/SparseCore/SparseDenseProduct.h b/Eigen/src/SparseCore/SparseDenseProduct.h
index 610833f3b..4a7813296 100644
--- a/Eigen/src/SparseCore/SparseDenseProduct.h
+++ b/Eigen/src/SparseCore/SparseDenseProduct.h
@@ -19,7 +19,10 @@ template<typename Lhs, typename Rhs, int InnerSize> struct SparseDenseProductRet
template<typename Lhs, typename Rhs> struct SparseDenseProductReturnType<Lhs,Rhs,1>
{
- typedef SparseDenseOuterProduct<Lhs,Rhs,false> Type;
+ typedef typename internal::conditional<
+ Lhs::IsRowMajor,
+ SparseDenseOuterProduct<Rhs,Lhs,true>,
+ SparseDenseOuterProduct<Lhs,Rhs,false> >::type Type;
};
template<typename Lhs, typename Rhs, int InnerSize> struct DenseSparseProductReturnType
@@ -29,7 +32,10 @@ template<typename Lhs, typename Rhs, int InnerSize> struct DenseSparseProductRet
template<typename Lhs, typename Rhs> struct DenseSparseProductReturnType<Lhs,Rhs,1>
{
- typedef SparseDenseOuterProduct<Rhs,Lhs,true> Type;
+ typedef typename internal::conditional<
+ Rhs::IsRowMajor,
+ SparseDenseOuterProduct<Rhs,Lhs,true>,
+ SparseDenseOuterProduct<Lhs,Rhs,false> >::type Type;
};
namespace internal {
@@ -96,8 +102,8 @@ class SparseDenseOuterProduct
EIGEN_STATIC_ASSERT(Tr,YOU_MADE_A_PROGRAMMING_MISTAKE);
}
- EIGEN_STRONG_INLINE Index rows() const { return Tr ? m_rhs.rows() : m_lhs.rows(); }
- EIGEN_STRONG_INLINE Index cols() const { return Tr ? m_lhs.cols() : m_rhs.cols(); }
+ EIGEN_STRONG_INLINE Index rows() const { return Tr ? Index(m_rhs.rows()) : m_lhs.rows(); }
+ EIGEN_STRONG_INLINE Index cols() const { return Tr ? m_lhs.cols() : Index(m_rhs.cols()); }
EIGEN_STRONG_INLINE const _LhsNested& lhs() const { return m_lhs; }
EIGEN_STRONG_INLINE const _RhsNested& rhs() const { return m_rhs; }
@@ -114,18 +120,33 @@ class SparseDenseOuterProduct<Lhs,Rhs,Transpose>::InnerIterator : public _LhsNes
typedef typename SparseDenseOuterProduct::Index Index;
public:
EIGEN_STRONG_INLINE InnerIterator(const SparseDenseOuterProduct& prod, Index outer)
- : Base(prod.lhs(), 0), m_outer(outer), m_factor(prod.rhs().coeff(outer))
- {
- }
+ : Base(prod.lhs(), 0), m_outer(outer), m_empty(false), m_factor(get(prod.rhs(), outer, typename internal::traits<Rhs>::StorageKind() ))
+ {}
inline Index outer() const { return m_outer; }
- inline Index row() const { return Transpose ? Base::row() : m_outer; }
- inline Index col() const { return Transpose ? m_outer : Base::row(); }
+ inline Index row() const { return Transpose ? m_outer : Base::index(); }
+ inline Index col() const { return Transpose ? Base::index() : m_outer; }
inline Scalar value() const { return Base::value() * m_factor; }
+ inline operator bool() const { return Base::operator bool() && !m_empty; }
protected:
+ Scalar get(const _RhsNested &rhs, Index outer, Dense = Dense()) const
+ {
+ return rhs.coeff(outer);
+ }
+
+ Scalar get(const _RhsNested &rhs, Index outer, Sparse = Sparse())
+ {
+ typename Traits::_RhsNested::InnerIterator it(rhs, outer);
+ if (it && it.index()==0 && it.value()!=Scalar(0))
+ return it.value();
+ m_empty = true;
+ return Scalar(0);
+ }
+
Index m_outer;
+ bool m_empty;
Scalar m_factor;
};
diff --git a/Eigen/src/SparseCore/SparseDiagonalProduct.h b/Eigen/src/SparseCore/SparseDiagonalProduct.h
index 1bb590e64..c056b4914 100644
--- a/Eigen/src/SparseCore/SparseDiagonalProduct.h
+++ b/Eigen/src/SparseCore/SparseDiagonalProduct.h
@@ -32,8 +32,10 @@ struct traits<SparseDiagonalProduct<Lhs, Rhs> >
typedef typename remove_all<Lhs>::type _Lhs;
typedef typename remove_all<Rhs>::type _Rhs;
typedef typename _Lhs::Scalar Scalar;
- typedef typename promote_index_type<typename traits<Lhs>::Index,
- typename traits<Rhs>::Index>::type Index;
+ // propagate the index type of the sparse matrix
+ typedef typename conditional< is_diagonal<_Lhs>::ret,
+ typename traits<Rhs>::Index,
+ typename traits<Lhs>::Index>::type Index;
typedef Sparse StorageKind;
typedef MatrixXpr XprKind;
enum {
@@ -90,8 +92,8 @@ class SparseDiagonalProduct
eigen_assert(lhs.cols() == rhs.rows() && "invalid sparse matrix * diagonal matrix product");
}
- EIGEN_STRONG_INLINE Index rows() const { return m_lhs.rows(); }
- EIGEN_STRONG_INLINE Index cols() const { return m_rhs.cols(); }
+ EIGEN_STRONG_INLINE Index rows() const { return Index(m_lhs.rows()); }
+ EIGEN_STRONG_INLINE Index cols() const { return Index(m_rhs.cols()); }
EIGEN_STRONG_INLINE const _LhsNested& lhs() const { return m_lhs; }
EIGEN_STRONG_INLINE const _RhsNested& rhs() const { return m_rhs; }
@@ -109,7 +111,7 @@ class sparse_diagonal_product_inner_iterator_selector
: public CwiseUnaryOp<scalar_multiple_op<typename Lhs::Scalar>,const Rhs>::InnerIterator
{
typedef typename CwiseUnaryOp<scalar_multiple_op<typename Lhs::Scalar>,const Rhs>::InnerIterator Base;
- typedef typename Lhs::Index Index;
+ typedef typename Rhs::Index Index;
public:
inline sparse_diagonal_product_inner_iterator_selector(
const SparseDiagonalProductType& expr, Index outer)
@@ -129,7 +131,7 @@ class sparse_diagonal_product_inner_iterator_selector
scalar_product_op<typename Lhs::Scalar>,
const typename Rhs::ConstInnerVectorReturnType,
const typename Lhs::DiagonalVectorType>::InnerIterator Base;
- typedef typename Lhs::Index Index;
+ typedef typename Rhs::Index Index;
Index m_outer;
public:
inline sparse_diagonal_product_inner_iterator_selector(
diff --git a/Eigen/src/SparseCore/SparseMatrix.h b/Eigen/src/SparseCore/SparseMatrix.h
index e0b7494c1..2ed2f3ebd 100644
--- a/Eigen/src/SparseCore/SparseMatrix.h
+++ b/Eigen/src/SparseCore/SparseMatrix.h
@@ -800,7 +800,9 @@ protected:
template<typename Other>
void initAssignment(const Other& other)
{
- resize(other.rows(), other.cols());
+ eigen_assert( other.rows() == typename Other::Index(Index(other.rows()))
+ && other.cols() == typename Other::Index(Index(other.cols())) );
+ resize(Index(other.rows()), Index(other.cols()));
if(m_innerNonZeros)
{
std::free(m_innerNonZeros);
@@ -940,7 +942,7 @@ void set_from_triplets(const InputIterator& begin, const InputIterator& end, Spa
enum { IsRowMajor = SparseMatrixType::IsRowMajor };
typedef typename SparseMatrixType::Scalar Scalar;
typedef typename SparseMatrixType::Index Index;
- SparseMatrix<Scalar,IsRowMajor?ColMajor:RowMajor> trMat(mat.rows(),mat.cols());
+ SparseMatrix<Scalar,IsRowMajor?ColMajor:RowMajor,Index> trMat(mat.rows(),mat.cols());
if(begin!=end)
{
@@ -1178,7 +1180,7 @@ EIGEN_DONT_INLINE typename SparseMatrix<_Scalar,_Options,_Index>::Scalar& Sparse
size_t p = m_outerIndex[outer+1];
++m_outerIndex[outer+1];
- float reallocRatio = 1;
+ double reallocRatio = 1;
if (m_data.allocatedSize()<=m_data.size())
{
// if there is no preallocated memory, let's reserve a minimum of 32 elements
@@ -1190,13 +1192,13 @@ EIGEN_DONT_INLINE typename SparseMatrix<_Scalar,_Options,_Index>::Scalar& Sparse
{
// we need to reallocate the data, to reduce multiple reallocations
// we use a smart resize algorithm based on the current filling ratio
- // in addition, we use float to avoid integers overflows
- float nnzEstimate = float(m_outerIndex[outer])*float(m_outerSize)/float(outer+1);
- reallocRatio = (nnzEstimate-float(m_data.size()))/float(m_data.size());
+ // in addition, we use double to avoid integers overflows
+ double nnzEstimate = double(m_outerIndex[outer])*double(m_outerSize)/double(outer+1);
+ reallocRatio = (nnzEstimate-double(m_data.size()))/double(m_data.size());
// furthermore we bound the realloc ratio to:
// 1) reduce multiple minor realloc when the matrix is almost filled
// 2) avoid to allocate too much memory when the matrix is almost empty
- reallocRatio = (std::min)((std::max)(reallocRatio,1.5f),8.f);
+ reallocRatio = (std::min)((std::max)(reallocRatio,1.5),8.);
}
}
m_data.resize(m_data.size()+1,reallocRatio);
diff --git a/Eigen/src/SparseCore/SparseMatrixBase.h b/Eigen/src/SparseCore/SparseMatrixBase.h
index bbcf7fb1c..1050cf3f1 100644
--- a/Eigen/src/SparseCore/SparseMatrixBase.h
+++ b/Eigen/src/SparseCore/SparseMatrixBase.h
@@ -202,20 +202,20 @@ template<typename Derived> class SparseMatrixBase : public EigenBase<Derived>
inline Derived& assign(const OtherDerived& other)
{
const bool transpose = (Flags & RowMajorBit) != (OtherDerived::Flags & RowMajorBit);
- const Index outerSize = (int(OtherDerived::Flags) & RowMajorBit) ? other.rows() : other.cols();
+ const Index outerSize = (int(OtherDerived::Flags) & RowMajorBit) ? Index(other.rows()) : Index(other.cols());
if ((!transpose) && other.isRValue())
{
// eval without temporary
- derived().resize(other.rows(), other.cols());
+ derived().resize(Index(other.rows()), Index(other.cols()));
derived().setZero();
derived().reserve((std::max)(this->rows(),this->cols())*2);
for (Index j=0; j<outerSize; ++j)
{
derived().startVec(j);
- for (typename OtherDerived::InnerIterator it(other, j); it; ++it)
+ for (typename OtherDerived::InnerIterator it(other, typename OtherDerived::Index(j)); it; ++it)
{
Scalar v = it.value();
- derived().insertBackByOuterInner(j,it.index()) = v;
+ derived().insertBackByOuterInner(j,Index(it.index())) = v;
}
}
derived().finalize();
@@ -237,19 +237,19 @@ template<typename Derived> class SparseMatrixBase : public EigenBase<Derived>
enum { Flip = (Flags & RowMajorBit) != (OtherDerived::Flags & RowMajorBit) };
- const Index outerSize = other.outerSize();
+ const Index outerSize = Index(other.outerSize());
//typedef typename internal::conditional<transpose, LinkedVectorMatrix<Scalar,Flags&RowMajorBit>, Derived>::type TempType;
// thanks to shallow copies, we always eval to a tempary
- Derived temp(other.rows(), other.cols());
+ Derived temp(Index(other.rows()), Index(other.cols()));
temp.reserve((std::max)(this->rows(),this->cols())*2);
for (Index j=0; j<outerSize; ++j)
{
temp.startVec(j);
- for (typename OtherDerived::InnerIterator it(other.derived(), j); it; ++it)
+ for (typename OtherDerived::InnerIterator it(other.derived(), typename OtherDerived::Index(j)); it; ++it)
{
Scalar v = it.value();
- temp.insertBackByOuterInner(Flip?it.index():j,Flip?j:it.index()) = v;
+ temp.insertBackByOuterInner(Flip?Index(it.index()):j,Flip?j:Index(it.index())) = v;
}
}
temp.finalize();
@@ -369,17 +369,6 @@ template<typename Derived> class SparseMatrixBase : public EigenBase<Derived>
template<typename OtherDerived>
Derived& operator*=(const SparseMatrixBase<OtherDerived>& other);
- #ifdef EIGEN2_SUPPORT
- // deprecated
- template<typename OtherDerived>
- typename internal::plain_matrix_type_column_major<OtherDerived>::type
- solveTriangular(const MatrixBase<OtherDerived>& other) const;
-
- // deprecated
- template<typename OtherDerived>
- void solveTriangularInPlace(MatrixBase<OtherDerived>& other) const;
- #endif // EIGEN2_SUPPORT
-
template<int Mode>
inline const SparseTriangularView<Derived, Mode> triangularView() const;
@@ -412,7 +401,7 @@ template<typename Derived> class SparseMatrixBase : public EigenBase<Derived>
{
dst.setZero();
for (Index j=0; j<outerSize(); ++j)
- for (typename Derived::InnerIterator i(derived(),j); i; ++i)
+ for (typename Derived::InnerIterator i(derived(),typename Derived::Index(j)); i; ++i)
dst.coeffRef(i.row(),i.col()) = i.value();
}
diff --git a/Eigen/src/SparseCore/SparseSelfAdjointView.h b/Eigen/src/SparseCore/SparseSelfAdjointView.h
index 0eda96bc4..56c922929 100644
--- a/Eigen/src/SparseCore/SparseSelfAdjointView.h
+++ b/Eigen/src/SparseCore/SparseSelfAdjointView.h
@@ -246,7 +246,7 @@ class SparseSelfAdjointTimeDenseProduct
|| ( (UpLo&Lower) && LhsIsRowMajor),
ProcessSecondHalf = !ProcessFirstHalf
};
- for (Index j=0; j<m_lhs.outerSize(); ++j)
+ for (typename _Lhs::Index j=0; j<m_lhs.outerSize(); ++j)
{
LhsInnerIterator i(m_lhs,j);
if (ProcessSecondHalf)
diff --git a/Eigen/src/SparseCore/SparseUtil.h b/Eigen/src/SparseCore/SparseUtil.h
index 05023858b..02c19d18f 100644
--- a/Eigen/src/SparseCore/SparseUtil.h
+++ b/Eigen/src/SparseCore/SparseUtil.h
@@ -84,8 +84,11 @@ template<typename Lhs, typename Rhs> class DenseTimeSparseProduct;
template<typename Lhs, typename Rhs, bool Transpose> class SparseDenseOuterProduct;
template<typename Lhs, typename Rhs> struct SparseSparseProductReturnType;
-template<typename Lhs, typename Rhs, int InnerSize = internal::traits<Lhs>::ColsAtCompileTime> struct DenseSparseProductReturnType;
-template<typename Lhs, typename Rhs, int InnerSize = internal::traits<Lhs>::ColsAtCompileTime> struct SparseDenseProductReturnType;
+template<typename Lhs, typename Rhs,
+ int InnerSize = EIGEN_SIZE_MIN_PREFER_FIXED(internal::traits<Lhs>::ColsAtCompileTime,internal::traits<Rhs>::RowsAtCompileTime)> struct DenseSparseProductReturnType;
+
+template<typename Lhs, typename Rhs,
+ int InnerSize = EIGEN_SIZE_MIN_PREFER_FIXED(internal::traits<Lhs>::ColsAtCompileTime,internal::traits<Rhs>::RowsAtCompileTime)> struct SparseDenseProductReturnType;
template<typename MatrixType,int UpLo> class SparseSymmetricPermutationProduct;
namespace internal {
diff --git a/Eigen/src/SparseCore/TriangularSolver.h b/Eigen/src/SparseCore/TriangularSolver.h
index cb8ad82b4..dd55522a7 100644
--- a/Eigen/src/SparseCore/TriangularSolver.h
+++ b/Eigen/src/SparseCore/TriangularSolver.h
@@ -28,15 +28,16 @@ template<typename Lhs, typename Rhs, int Mode>
struct sparse_solve_triangular_selector<Lhs,Rhs,Mode,Lower,RowMajor>
{
typedef typename Rhs::Scalar Scalar;
+ typedef typename Lhs::Index Index;
static void run(const Lhs& lhs, Rhs& other)
{
- for(int col=0 ; col<other.cols() ; ++col)
+ for(Index col=0 ; col<other.cols() ; ++col)
{
- for(int i=0; i<lhs.rows(); ++i)
+ for(Index i=0; i<lhs.rows(); ++i)
{
Scalar tmp = other.coeff(i,col);
Scalar lastVal(0);
- int lastIndex = 0;
+ Index lastIndex = 0;
for(typename Lhs::InnerIterator it(lhs, i); it; ++it)
{
lastVal = it.value();
@@ -62,11 +63,12 @@ template<typename Lhs, typename Rhs, int Mode>
struct sparse_solve_triangular_selector<Lhs,Rhs,Mode,Upper,RowMajor>
{
typedef typename Rhs::Scalar Scalar;
+ typedef typename Lhs::Index Index;
static void run(const Lhs& lhs, Rhs& other)
{
- for(int col=0 ; col<other.cols() ; ++col)
+ for(Index col=0 ; col<other.cols() ; ++col)
{
- for(int i=lhs.rows()-1 ; i>=0 ; --i)
+ for(Index i=lhs.rows()-1 ; i>=0 ; --i)
{
Scalar tmp = other.coeff(i,col);
Scalar l_ii = 0;
@@ -100,11 +102,12 @@ template<typename Lhs, typename Rhs, int Mode>
struct sparse_solve_triangular_selector<Lhs,Rhs,Mode,Lower,ColMajor>
{
typedef typename Rhs::Scalar Scalar;
+ typedef typename Lhs::Index Index;
static void run(const Lhs& lhs, Rhs& other)
{
- for(int col=0 ; col<other.cols() ; ++col)
+ for(Index col=0 ; col<other.cols() ; ++col)
{
- for(int i=0; i<lhs.cols(); ++i)
+ for(Index i=0; i<lhs.cols(); ++i)
{
Scalar& tmp = other.coeffRef(i,col);
if (tmp!=Scalar(0)) // optimization when other is actually sparse
@@ -132,11 +135,12 @@ template<typename Lhs, typename Rhs, int Mode>
struct sparse_solve_triangular_selector<Lhs,Rhs,Mode,Upper,ColMajor>
{
typedef typename Rhs::Scalar Scalar;
+ typedef typename Lhs::Index Index;
static void run(const Lhs& lhs, Rhs& other)
{
- for(int col=0 ; col<other.cols() ; ++col)
+ for(Index col=0 ; col<other.cols() ; ++col)
{
- for(int i=lhs.cols()-1; i>=0; --i)
+ for(Index i=lhs.cols()-1; i>=0; --i)
{
Scalar& tmp = other.coeffRef(i,col);
if (tmp!=Scalar(0)) // optimization when other is actually sparse
@@ -209,7 +213,7 @@ struct sparse_solve_triangular_sparse_selector<Lhs,Rhs,Mode,UpLo,ColMajor>
{
typedef typename Rhs::Scalar Scalar;
typedef typename promote_index_type<typename traits<Lhs>::Index,
- typename traits<Rhs>::Index>::type Index;
+ typename traits<Rhs>::Index>::type Index;
static void run(const Lhs& lhs, Rhs& other)
{
const bool IsLower = (UpLo==Lower);
@@ -219,7 +223,7 @@ struct sparse_solve_triangular_sparse_selector<Lhs,Rhs,Mode,UpLo,ColMajor>
Rhs res(other.rows(), other.cols());
res.reserve(other.nonZeros());
- for(int col=0 ; col<other.cols() ; ++col)
+ for(Index col=0 ; col<other.cols() ; ++col)
{
// FIXME estimate number of non zeros
tempVector.init(.99/*float(other.col(col).nonZeros())/float(other.rows())*/);
@@ -230,7 +234,7 @@ struct sparse_solve_triangular_sparse_selector<Lhs,Rhs,Mode,UpLo,ColMajor>
tempVector.coeffRef(rhsIt.index()) = rhsIt.value();
}
- for(int i=IsLower?0:lhs.cols()-1;
+ for(Index i=IsLower?0:lhs.cols()-1;
IsLower?i<lhs.cols():i>=0;
i+=IsLower?1:-1)
{
@@ -267,7 +271,7 @@ struct sparse_solve_triangular_sparse_selector<Lhs,Rhs,Mode,UpLo,ColMajor>
}
- int count = 0;
+ Index count = 0;
// FIXME compute a reference value to filter zeros
for (typename AmbiVector<Scalar,Index>::Iterator it(tempVector/*,1e-12*/); it; ++it)
{
@@ -305,30 +309,6 @@ void SparseTriangularView<ExpressionType,Mode>::solveInPlace(SparseMatrixBase<Ot
// other = otherCopy;
}
-#ifdef EIGEN2_SUPPORT
-
-// deprecated stuff:
-
-/** \deprecated */
-template<typename Derived>
-template<typename OtherDerived>
-void SparseMatrixBase<Derived>::solveTriangularInPlace(MatrixBase<OtherDerived>& other) const
-{
- this->template triangular<Flags&(Upper|Lower)>().solveInPlace(other);
-}
-
-/** \deprecated */
-template<typename Derived>
-template<typename OtherDerived>
-typename internal::plain_matrix_type_column_major<OtherDerived>::type
-SparseMatrixBase<Derived>::solveTriangular(const MatrixBase<OtherDerived>& other) const
-{
- typename internal::plain_matrix_type_column_major<OtherDerived>::type res(other);
- derived().solveTriangularInPlace(res);
- return res;
-}
-#endif // EIGEN2_SUPPORT
-
} // end namespace Eigen
#endif // EIGEN_SPARSETRIANGULARSOLVER_H
diff --git a/Eigen/src/SparseQR/SparseQR.h b/Eigen/src/SparseQR/SparseQR.h
index 267c48bc3..4c6553bf2 100644
--- a/Eigen/src/SparseQR/SparseQR.h
+++ b/Eigen/src/SparseQR/SparseQR.h
@@ -2,7 +2,7 @@
// for linear algebra.
//
// Copyright (C) 2012-2013 Desire Nuentsa <desire.nuentsa_wakam@inria.fr>
-// Copyright (C) 2012-2013 Gael Guennebaud <gael.guennebaud@inria.fr>
+// Copyright (C) 2012-2014 Gael Guennebaud <gael.guennebaud@inria.fr>
//
// 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
@@ -58,6 +58,7 @@ namespace internal {
* \tparam _OrderingType The fill-reducing ordering method. See the \link OrderingMethods_Module
* OrderingMethods \endlink module for the list of built-in and external ordering methods.
*
+ * \warning The input sparse matrix A must be in compressed mode (see SparseMatrix::makeCompressed()).
*
*/
template<typename _MatrixType, typename _OrderingType>
@@ -77,10 +78,23 @@ class SparseQR
SparseQR () : m_isInitialized(false), m_analysisIsok(false), m_lastError(""), m_useDefaultThreshold(true),m_isQSorted(false)
{ }
+ /** Construct a QR factorization of the matrix \a mat.
+ *
+ * \warning The matrix \a mat must be in compressed mode (see SparseMatrix::makeCompressed()).
+ *
+ * \sa compute()
+ */
SparseQR(const MatrixType& mat) : m_isInitialized(false), m_analysisIsok(false), m_lastError(""), m_useDefaultThreshold(true),m_isQSorted(false)
{
compute(mat);
}
+
+ /** Computes the QR factorization of the sparse matrix \a mat.
+ *
+ * \warning The matrix \a mat must be in compressed mode (see SparseMatrix::makeCompressed()).
+ *
+ * \sa analyzePattern(), factorize()
+ */
void compute(const MatrixType& mat)
{
analyzePattern(mat);
@@ -166,7 +180,7 @@ class SparseQR
y.bottomRows(y.rows()-rank).setZero();
// Apply the column permutation
- if (m_perm_c.size()) dest.topRows(cols()) = colsPermutation() * y.topRows(cols());
+ if (m_perm_c.size()) dest = colsPermutation() * y.topRows(cols());
else dest = y.topRows(cols());
m_info = Success;
@@ -256,6 +270,8 @@ class SparseQR
/** \brief Preprocessing step of a QR factorization
*
+ * \warning The matrix \a mat must be in compressed mode (see SparseMatrix::makeCompressed()).
+ *
* In this step, the fill-reducing permutation is computed and applied to the columns of A
* and the column elimination tree is computed as well. Only the sparsity pattern of \a mat is exploited.
*
@@ -264,11 +280,13 @@ class SparseQR
template <typename MatrixType, typename OrderingType>
void SparseQR<MatrixType,OrderingType>::analyzePattern(const MatrixType& mat)
{
+ eigen_assert(mat.isCompressed() && "SparseQR requires a sparse matrix in compressed mode. Call .makeCompressed() before passing it to SparseQR");
// Compute the column fill reducing ordering
OrderingType ord;
ord(mat, m_perm_c);
Index n = mat.cols();
Index m = mat.rows();
+ Index diagSize = (std::min)(m,n);
if (!m_perm_c.size())
{
@@ -280,13 +298,13 @@ void SparseQR<MatrixType,OrderingType>::analyzePattern(const MatrixType& mat)
m_outputPerm_c = m_perm_c.inverse();
internal::coletree(mat, m_etree, m_firstRowElt, m_outputPerm_c.indices().data());
- m_R.resize(n, n);
- m_Q.resize(m, n);
+ m_R.resize(m, n);
+ m_Q.resize(m, diagSize);
// Allocate space for nonzero elements : rough estimation
m_R.reserve(2*mat.nonZeros()); //FIXME Get a more accurate estimation through symbolic factorization with the etree
m_Q.reserve(2*mat.nonZeros());
- m_hcoeffs.resize(n);
+ m_hcoeffs.resize(diagSize);
m_analysisIsok = true;
}
@@ -306,11 +324,12 @@ void SparseQR<MatrixType,OrderingType>::factorize(const MatrixType& mat)
eigen_assert(m_analysisIsok && "analyzePattern() should be called before this step");
Index m = mat.rows();
Index n = mat.cols();
- IndexVector mark(m); mark.setConstant(-1); // Record the visited nodes
- IndexVector Ridx(n), Qidx(m); // Store temporarily the row indexes for the current column of R and Q
- Index nzcolR, nzcolQ; // Number of nonzero for the current column of R and Q
- ScalarVector tval(m); // The dense vector used to compute the current column
- bool found_diag;
+ Index diagSize = (std::min)(m,n);
+ IndexVector mark((std::max)(m,n)); mark.setConstant(-1); // Record the visited nodes
+ IndexVector Ridx(n), Qidx(m); // Store temporarily the row indexes for the current column of R and Q
+ Index nzcolR, nzcolQ; // Number of nonzero for the current column of R and Q
+ ScalarVector tval(m); // The dense vector used to compute the current column
+ RealScalar pivotThreshold = m_threshold;
m_pmat = mat;
m_pmat.uncompress(); // To have the innerNonZeroPtr allocated
@@ -322,7 +341,7 @@ void SparseQR<MatrixType,OrderingType>::factorize(const MatrixType& mat)
m_pmat.innerNonZeroPtr()[p] = mat.outerIndexPtr()[i+1] - mat.outerIndexPtr()[i];
}
- /* Compute the default threshold, see :
+ /* Compute the default threshold as in MatLab, see:
* Tim Davis, "Algorithm 915, SuiteSparseQR: Multifrontal Multithreaded Rank-Revealing
* Sparse QR Factorization, ACM Trans. on Math. Soft. 38(1), 2011, Page 8:3
*/
@@ -330,24 +349,24 @@ void SparseQR<MatrixType,OrderingType>::factorize(const MatrixType& mat)
{
RealScalar max2Norm = 0.0;
for (int j = 0; j < n; j++) max2Norm = (max)(max2Norm, m_pmat.col(j).norm());
- m_threshold = 20 * (m + n) * max2Norm * NumTraits<RealScalar>::epsilon();
+ pivotThreshold = 20 * (m + n) * max2Norm * NumTraits<RealScalar>::epsilon();
}
// Initialize the numerical permutation
m_pivotperm.setIdentity(n);
Index nonzeroCol = 0; // Record the number of valid pivots
+ m_Q.startVec(0);
// Left looking rank-revealing QR factorization: compute a column of R and Q at a time
- for (Index col = 0; col < (std::min)(n,m); ++col)
+ for (Index col = 0; col < n; ++col)
{
mark.setConstant(-1);
m_R.startVec(col);
- m_Q.startVec(col);
mark(nonzeroCol) = col;
Qidx(0) = nonzeroCol;
nzcolR = 0; nzcolQ = 1;
- found_diag = col>=m;
+ bool found_diag = nonzeroCol>=m;
tval.setZero();
// Symbolic factorization: find the nonzero locations of the column k of the factors R and Q, i.e.,
@@ -356,7 +375,7 @@ void SparseQR<MatrixType,OrderingType>::factorize(const MatrixType& mat)
// thus the trick with found_diag that permits to do one more iteration on the diagonal element if this one has not been found.
for (typename MatrixType::InnerIterator itp(m_pmat, col); itp || !found_diag; ++itp)
{
- Index curIdx = nonzeroCol ;
+ Index curIdx = nonzeroCol;
if(itp) curIdx = itp.row();
if(curIdx == nonzeroCol) found_diag = true;
@@ -398,7 +417,7 @@ void SparseQR<MatrixType,OrderingType>::factorize(const MatrixType& mat)
// Browse all the indexes of R(:,col) in reverse order
for (Index i = nzcolR-1; i >= 0; i--)
{
- Index curIdx = m_pivotperm.indices()(Ridx(i));
+ Index curIdx = Ridx(i);
// Apply the curIdx-th householder vector to the current column (temporarily stored into tval)
Scalar tdot(0);
@@ -427,34 +446,37 @@ void SparseQR<MatrixType,OrderingType>::factorize(const MatrixType& mat)
}
}
} // End update current column
-
- // Compute the Householder reflection that eliminate the current column
- // FIXME this step should call the Householder module.
- Scalar tau;
- RealScalar beta;
- Scalar c0 = nzcolQ ? tval(Qidx(0)) : Scalar(0);
- // First, the squared norm of Q((col+1):m, col)
- RealScalar sqrNorm = 0.;
- for (Index itq = 1; itq < nzcolQ; ++itq) sqrNorm += numext::abs2(tval(Qidx(itq)));
+ Scalar tau;
+ RealScalar beta = 0;
- if(sqrNorm == RealScalar(0) && numext::imag(c0) == RealScalar(0))
- {
- tau = RealScalar(0);
- beta = numext::real(c0);
- tval(Qidx(0)) = 1;
- }
- else
+ if(nonzeroCol < diagSize)
{
- using std::sqrt;
- beta = sqrt(numext::abs2(c0) + sqrNorm);
- if(numext::real(c0) >= RealScalar(0))
- beta = -beta;
- tval(Qidx(0)) = 1;
- for (Index itq = 1; itq < nzcolQ; ++itq)
- tval(Qidx(itq)) /= (c0 - beta);
- tau = numext::conj((beta-c0) / beta);
-
+ // Compute the Householder reflection that eliminate the current column
+ // FIXME this step should call the Householder module.
+ Scalar c0 = nzcolQ ? tval(Qidx(0)) : Scalar(0);
+
+ // First, the squared norm of Q((col+1):m, col)
+ RealScalar sqrNorm = 0.;
+ for (Index itq = 1; itq < nzcolQ; ++itq) sqrNorm += numext::abs2(tval(Qidx(itq)));
+ if(sqrNorm == RealScalar(0) && numext::imag(c0) == RealScalar(0))
+ {
+ tau = RealScalar(0);
+ beta = numext::real(c0);
+ tval(Qidx(0)) = 1;
+ }
+ else
+ {
+ using std::sqrt;
+ beta = sqrt(numext::abs2(c0) + sqrNorm);
+ if(numext::real(c0) >= RealScalar(0))
+ beta = -beta;
+ tval(Qidx(0)) = 1;
+ for (Index itq = 1; itq < nzcolQ; ++itq)
+ tval(Qidx(itq)) /= (c0 - beta);
+ tau = numext::conj((beta-c0) / beta);
+
+ }
}
// Insert values in R
@@ -468,24 +490,25 @@ void SparseQR<MatrixType,OrderingType>::factorize(const MatrixType& mat)
}
}
- if(abs(beta) >= m_threshold)
+ if(nonzeroCol < diagSize && abs(beta) >= pivotThreshold)
{
m_R.insertBackByOuterInner(col, nonzeroCol) = beta;
- nonzeroCol++;
// The householder coefficient
- m_hcoeffs(col) = tau;
+ m_hcoeffs(nonzeroCol) = tau;
// Record the householder reflections
for (Index itq = 0; itq < nzcolQ; ++itq)
{
Index iQ = Qidx(itq);
- m_Q.insertBackByOuterInnerUnordered(col,iQ) = tval(iQ);
+ m_Q.insertBackByOuterInnerUnordered(nonzeroCol,iQ) = tval(iQ);
tval(iQ) = Scalar(0.);
- }
+ }
+ nonzeroCol++;
+ if(nonzeroCol<diagSize)
+ m_Q.startVec(nonzeroCol);
}
else
{
// Zero pivot found: move implicitly this column to the end
- m_hcoeffs(col) = Scalar(0);
for (Index j = nonzeroCol; j < n-1; j++)
std::swap(m_pivotperm.indices()(j), m_pivotperm.indices()[j+1]);
@@ -494,6 +517,8 @@ void SparseQR<MatrixType,OrderingType>::factorize(const MatrixType& mat)
}
}
+ m_hcoeffs.tail(diagSize-nonzeroCol).setZero();
+
// Finalize the column pointers of the sparse matrices R and Q
m_Q.finalize();
m_Q.makeCompressed();
@@ -562,14 +587,16 @@ struct SparseQR_QProduct : ReturnByValue<SparseQR_QProduct<SparseQRType, Derived
template<typename DesType>
void evalTo(DesType& res) const
{
+ Index m = m_qr.rows();
Index n = m_qr.cols();
+ Index diagSize = (std::min)(m,n);
res = m_other;
if (m_transpose)
{
eigen_assert(m_qr.m_Q.rows() == m_other.rows() && "Non conforming object sizes");
//Compute res = Q' * other column by column
for(Index j = 0; j < res.cols(); j++){
- for (Index k = 0; k < n; k++)
+ for (Index k = 0; k < diagSize; k++)
{
Scalar tau = Scalar(0);
tau = m_qr.m_Q.col(k).dot(res.col(j));
@@ -582,10 +609,10 @@ struct SparseQR_QProduct : ReturnByValue<SparseQR_QProduct<SparseQRType, Derived
else
{
eigen_assert(m_qr.m_Q.rows() == m_other.rows() && "Non conforming object sizes");
- // Compute res = Q' * other column by column
+ // Compute res = Q * other column by column
for(Index j = 0; j < res.cols(); j++)
{
- for (Index k = n-1; k >=0; k--)
+ for (Index k = diagSize-1; k >=0; k--)
{
Scalar tau = Scalar(0);
tau = m_qr.m_Q.col(k).dot(res.col(j));
@@ -619,7 +646,7 @@ struct SparseQRMatrixQReturnType : public EigenBase<SparseQRMatrixQReturnType<Sp
return SparseQRMatrixQTransposeReturnType<SparseQRType>(m_qr);
}
inline Index rows() const { return m_qr.rows(); }
- inline Index cols() const { return m_qr.cols(); }
+ inline Index cols() const { return (std::min)(m_qr.rows(),m_qr.cols()); }
// To use for operations with the transpose of Q
SparseQRMatrixQTransposeReturnType<SparseQRType> transpose() const
{
diff --git a/Eigen/src/plugins/ArrayCwiseUnaryOps.h b/Eigen/src/plugins/ArrayCwiseUnaryOps.h
index aea3375ed..ce462e951 100644
--- a/Eigen/src/plugins/ArrayCwiseUnaryOps.h
+++ b/Eigen/src/plugins/ArrayCwiseUnaryOps.h
@@ -141,6 +141,18 @@ tan() const
return derived();
}
+/** \returns an expression of the coefficient-wise arc tan of *this.
+ *
+ * Example: \include Cwise_atan.cpp
+ * Output: \verbinclude Cwise_atan.out
+ *
+ * \sa cos(), sin(), tan()
+ */
+inline const CwiseUnaryOp<internal::scalar_atan_op<Scalar>, Derived>
+atan() const
+{
+ return derived();
+}
/** \returns an expression of the coefficient-wise power of *this to the given exponent.
*
diff --git a/bench/btl/cmake/FindACML.cmake b/bench/btl/cmake/FindACML.cmake
index f45ae1b0d..4989fa2f4 100644
--- a/bench/btl/cmake/FindACML.cmake
+++ b/bench/btl/cmake/FindACML.cmake
@@ -17,6 +17,7 @@ find_file(ACML_LIBRARIES
libacml_mp.so
PATHS
/usr/lib
+ /usr/lib64
$ENV{ACMLDIR}/lib
${LIB_INSTALL_DIR}
)
@@ -35,6 +36,7 @@ if(NOT ACML_LIBRARIES)
libacml.so libacml_mv.so
PATHS
/usr/lib
+ /usr/lib64
$ENV{ACMLDIR}/lib
${LIB_INSTALL_DIR}
)
diff --git a/bench/btl/cmake/FindATLAS.cmake b/bench/btl/cmake/FindATLAS.cmake
index 14b1dee09..4136a989d 100644
--- a/bench/btl/cmake/FindATLAS.cmake
+++ b/bench/btl/cmake/FindATLAS.cmake
@@ -3,18 +3,13 @@ if (ATLAS_LIBRARIES)
set(ATLAS_FIND_QUIETLY TRUE)
endif (ATLAS_LIBRARIES)
-find_file(ATLAS_LIB libatlas.so.3 PATHS /usr/lib $ENV{ATLASDIR} ${LIB_INSTALL_DIR})
+find_file(ATLAS_LIB libatlas.so.3 PATHS /usr/lib /usr/lib/atlas /usr/lib64 /usr/lib64/atlas $ENV{ATLASDIR} ${LIB_INSTALL_DIR})
find_library(ATLAS_LIB satlas PATHS $ENV{ATLASDIR} ${LIB_INSTALL_DIR})
-find_file(ATLAS_LAPACK liblapack_atlas.so.3 PATHS /usr/lib $ENV{ATLASDIR} ${LIB_INSTALL_DIR})
-find_library(ATLAS_LAPACK lapack_atlas PATHS $ENV{ATLASDIR} ${LIB_INSTALL_DIR})
+find_file(ATLAS_LAPACK NAMES liblapack_atlas.so.3 liblapack.so.3 PATHS /usr/lib /usr/lib/atlas /usr/lib64 /usr/lib64/atlas $ENV{ATLASDIR} ${LIB_INSTALL_DIR})
+find_library(ATLAS_LAPACK NAMES lapack_atlas lapack PATHS $ENV{ATLASDIR} ${LIB_INSTALL_DIR})
-if(NOT ATLAS_LAPACK)
- find_file(ATLAS_LAPACK liblapack.so.3 PATHS /usr/lib/atlas $ENV{ATLASDIR} ${LIB_INSTALL_DIR})
- find_library(ATLAS_LAPACK lapack PATHS $ENV{ATLASDIR} ${LIB_INSTALL_DIR})
-endif(NOT ATLAS_LAPACK)
-
-find_file(ATLAS_F77BLAS libf77blas.so.3 PATHS /usr/lib $ENV{ATLASDIR} ${LIB_INSTALL_DIR})
+find_file(ATLAS_F77BLAS libf77blas.so.3 PATHS /usr/lib /usr/lib/atlas /usr/lib64 /usr/lib64/atlas $ENV{ATLASDIR} ${LIB_INSTALL_DIR})
find_library(ATLAS_F77BLAS f77blas PATHS $ENV{ATLASDIR} ${LIB_INSTALL_DIR})
if(ATLAS_LIB AND ATLAS_CBLAS AND ATLAS_LAPACK AND ATLAS_F77BLAS)
diff --git a/bench/btl/cmake/FindCBLAS.cmake b/bench/btl/cmake/FindCBLAS.cmake
index 554f0291b..ce0f2f2b2 100644
--- a/bench/btl/cmake/FindCBLAS.cmake
+++ b/bench/btl/cmake/FindCBLAS.cmake
@@ -23,6 +23,7 @@ find_file(CBLAS_LIBRARIES
libcblas.so.3
PATHS
/usr/lib
+ /usr/lib64
$ENV{CBLASDIR}/lib
${LIB_INSTALL_DIR}
)
diff --git a/bench/btl/cmake/FindOPENBLAS.cmake b/bench/btl/cmake/FindOPENBLAS.cmake
index c76fc251c..2a0919436 100644
--- a/bench/btl/cmake/FindOPENBLAS.cmake
+++ b/bench/btl/cmake/FindOPENBLAS.cmake
@@ -3,7 +3,7 @@ if (OPENBLAS_LIBRARIES)
set(OPENBLAS_FIND_QUIETLY TRUE)
endif (OPENBLAS_LIBRARIES)
-find_file(OPENBLAS_LIBRARIES libopenblas.so PATHS /usr/lib $ENV{OPENBLASDIR} ${LIB_INSTALL_DIR})
+find_file(OPENBLAS_LIBRARIES NAMES libopenblas.so libopenblas.so.0 PATHS /usr/lib /usr/lib64 $ENV{OPENBLASDIR} ${LIB_INSTALL_DIR})
find_library(OPENBLAS_LIBRARIES openblas PATHS $ENV{OPENBLASDIR} ${LIB_INSTALL_DIR})
if(OPENBLAS_LIBRARIES AND CMAKE_COMPILER_IS_GNUCXX)
diff --git a/blas/level1_impl.h b/blas/level1_impl.h
index 98e4c0963..e623bd178 100644
--- a/blas/level1_impl.h
+++ b/blas/level1_impl.h
@@ -59,7 +59,7 @@ int EIGEN_CAT(EIGEN_CAT(i,SCALAR_SUFFIX),amax_)(int *n, RealScalar *px, int *inc
DenseIndex ret;
if(*incx==1) make_vector(x,*n).cwiseAbs().maxCoeff(&ret);
else make_vector(x,*n,std::abs(*incx)).cwiseAbs().maxCoeff(&ret);
- return ret+1;
+ return int(ret)+1;
}
int EIGEN_CAT(EIGEN_CAT(i,SCALAR_SUFFIX),amin_)(int *n, RealScalar *px, int *incx)
@@ -70,7 +70,7 @@ int EIGEN_CAT(EIGEN_CAT(i,SCALAR_SUFFIX),amin_)(int *n, RealScalar *px, int *inc
DenseIndex ret;
if(*incx==1) make_vector(x,*n).cwiseAbs().minCoeff(&ret);
else make_vector(x,*n,std::abs(*incx)).cwiseAbs().minCoeff(&ret);
- return ret+1;
+ return int(ret)+1;
}
int EIGEN_BLAS_FUNC(rotg)(RealScalar *pa, RealScalar *pb, RealScalar *pc, RealScalar *ps)
diff --git a/blas/level3_impl.h b/blas/level3_impl.h
index 07dbc22ff..a05872666 100644
--- a/blas/level3_impl.h
+++ b/blas/level3_impl.h
@@ -56,7 +56,7 @@ int EIGEN_BLAS_FUNC(gemm)(char *opa, char *opb, int *m, int *n, int *k, RealScal
else matrix(c, *m, *n, *ldc) *= beta;
}
- internal::gemm_blocking_space<ColMajor,Scalar,Scalar,Dynamic,Dynamic,Dynamic> blocking(*m,*n,*k);
+ internal::gemm_blocking_space<ColMajor,Scalar,Scalar,Dynamic,Dynamic,Dynamic> blocking(*m,*n,*k,true);
int code = OP(*opa) | (OP(*opb) << 2);
func[code](*m, *n, *k, a, *lda, b, *ldb, c, *ldc, alpha, blocking, 0);
diff --git a/cmake/Eigen3Config.cmake.in b/cmake/Eigen3Config.cmake.in
index 257c595ed..e50f6dbe0 100644
--- a/cmake/Eigen3Config.cmake.in
+++ b/cmake/Eigen3Config.cmake.in
@@ -3,26 +3,26 @@
# Eigen3Config.cmake(.in)
# Use the following variables to compile and link against Eigen:
-# EIGEN_FOUND - True if Eigen was found on your system
-# EIGEN_USE_FILE - The file making Eigen usable
-# EIGEN_DEFINITIONS - Definitions needed to build with Eigen
-# EIGEN_INCLUDE_DIR - Directory where signature_of_eigen3_matrix_library can be found
-# EIGEN_INCLUDE_DIRS - List of directories of Eigen and it's dependencies
-# EIGEN_ROOT_DIR - The base directory of Eigen
-# EIGEN_VERSION_STRING - A human-readable string containing the version
-# EIGEN_VERSION_MAJOR - The major version of Eigen
-# EIGEN_VERSION_MINOR - The minor version of Eigen
-# EIGEN_VERSION_PATCH - The patch version of Eigen
+# EIGEN3_FOUND - True if Eigen was found on your system
+# EIGEN3_USE_FILE - The file making Eigen usable
+# EIGEN3_DEFINITIONS - Definitions needed to build with Eigen
+# EIGEN3_INCLUDE_DIR - Directory where signature_of_eigen3_matrix_library can be found
+# EIGEN3_INCLUDE_DIRS - List of directories of Eigen and it's dependencies
+# EIGEN3_ROOT_DIR - The base directory of Eigen
+# EIGEN3_VERSION_STRING - A human-readable string containing the version
+# EIGEN3_VERSION_MAJOR - The major version of Eigen
+# EIGEN3_VERSION_MINOR - The minor version of Eigen
+# EIGEN3_VERSION_PATCH - The patch version of Eigen
-set ( EIGEN_FOUND 1 )
-set ( EIGEN_USE_FILE "@EIGEN_USE_FILE@" )
+set ( EIGEN3_FOUND 1 )
+set ( EIGEN3_USE_FILE "@EIGEN_USE_FILE@" )
-set ( EIGEN_DEFINITIONS "@EIGEN_DEFINITIONS@" )
-set ( EIGEN_INCLUDE_DIR "@EIGEN_INCLUDE_DIR@" )
-set ( EIGEN_INCLUDE_DIRS "@EIGEN_INCLUDE_DIRS@" )
-set ( EIGEN_ROOT_DIR "@EIGEN_ROOT_DIR@" )
+set ( EIGEN3_DEFINITIONS "@EIGEN_DEFINITIONS@" )
+set ( EIGEN3_INCLUDE_DIR "@EIGEN_INCLUDE_DIR@" )
+set ( EIGEN3_INCLUDE_DIRS "@EIGEN_INCLUDE_DIRS@" )
+set ( EIGEN3_ROOT_DIR "@EIGEN_ROOT_DIR@" )
-set ( EIGEN_VERSION_STRING "@EIGEN_VERSION_STRING@" )
-set ( EIGEN_VERSION_MAJOR "@EIGEN_VERSION_MAJOR@" )
-set ( EIGEN_VERSION_MINOR "@EIGEN_VERSION_MINOR@" )
-set ( EIGEN_VERSION_PATCH "@EIGEN_VERSION_PATCH@" )
+set ( EIGEN3_VERSION_STRING "@EIGEN_VERSION_STRING@" )
+set ( EIGEN3_VERSION_MAJOR "@EIGEN_VERSION_MAJOR@" )
+set ( EIGEN3_VERSION_MINOR "@EIGEN_VERSION_MINOR@" )
+set ( EIGEN3_VERSION_PATCH "@EIGEN_VERSION_PATCH@" )
diff --git a/cmake/FindCholmod.cmake b/cmake/FindCholmod.cmake
index 7b3046d45..23239c300 100644
--- a/cmake/FindCholmod.cmake
+++ b/cmake/FindCholmod.cmake
@@ -86,4 +86,4 @@ include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(CHOLMOD DEFAULT_MSG
CHOLMOD_INCLUDES CHOLMOD_LIBRARIES)
-mark_as_advanced(CHOLMOD_INCLUDES CHOLMOD_LIBRARIES AMD_LIBRARY COLAMD_LIBRARY SUITESPARSE_LIBRARY)
+mark_as_advanced(CHOLMOD_INCLUDES CHOLMOD_LIBRARIES AMD_LIBRARY COLAMD_LIBRARY SUITESPARSE_LIBRARY CAMD_LIBRARY CCOLAMD_LIBRARY CHOLMOD_METIS_LIBRARY)
diff --git a/cmake/FindFFTW.cmake b/cmake/FindFFTW.cmake
index a9e9925e7..6c4dc9ab4 100644
--- a/cmake/FindFFTW.cmake
+++ b/cmake/FindFFTW.cmake
@@ -115,5 +115,5 @@ include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(FFTW DEFAULT_MSG
FFTW_INCLUDES FFTW_LIBRARIES)
-mark_as_advanced(FFTW_INCLUDES FFTW_LIBRARIES)
+mark_as_advanced(FFTW_INCLUDES FFTW_LIBRARIES FFTW_LIB FFTWF_LIB FFTWL_LIB)
diff --git a/cmake/FindMetis.cmake b/cmake/FindMetis.cmake
index 627c3e9ae..e0040d320 100644
--- a/cmake/FindMetis.cmake
+++ b/cmake/FindMetis.cmake
@@ -10,16 +10,50 @@ find_path(METIS_INCLUDES
PATHS
$ENV{METISDIR}
${INCLUDE_INSTALL_DIR}
- PATH_SUFFIXES
+ PATH_SUFFIXES
+ .
metis
include
)
+macro(_metis_check_version)
+ file(READ "${METIS_INCLUDES}/metis.h" _metis_version_header)
+
+ string(REGEX MATCH "define[ \t]+METIS_VER_MAJOR[ \t]+([0-9]+)" _metis_major_version_match "${_metis_version_header}")
+ set(METIS_MAJOR_VERSION "${CMAKE_MATCH_1}")
+ string(REGEX MATCH "define[ \t]+METIS_VER_MINOR[ \t]+([0-9]+)" _metis_minor_version_match "${_metis_version_header}")
+ set(METIS_MINOR_VERSION "${CMAKE_MATCH_1}")
+ string(REGEX MATCH "define[ \t]+METIS_VER_SUBMINOR[ \t]+([0-9]+)" _metis_subminor_version_match "${_metis_version_header}")
+ set(METIS_SUBMINOR_VERSION "${CMAKE_MATCH_1}")
+ if(NOT METIS_MAJOR_VERSION)
+ message(WARNING "Could not determine Metis version. Assuming version 4.0.0")
+ set(METIS_VERSION 4.0.0)
+ else()
+ set(METIS_VERSION ${METIS_MAJOR_VERSION}.${METIS_MINOR_VERSION}.${METIS_SUBMINOR_VERSION})
+ endif()
+ if(${METIS_VERSION} VERSION_LESS ${Metis_FIND_VERSION})
+ set(METIS_VERSION_OK FALSE)
+ else()
+ set(METIS_VERSION_OK TRUE)
+ endif()
+
+ if(NOT METIS_VERSION_OK)
+ message(STATUS "Metis version ${METIS_VERSION} found in ${METIS_INCLUDES}, "
+ "but at least version ${Metis_FIND_VERSION} is required")
+ endif(NOT METIS_VERSION_OK)
+endmacro(_metis_check_version)
+
+ if(METIS_INCLUDES AND Metis_FIND_VERSION)
+ _metis_check_version()
+ else()
+ set(METIS_VERSION_OK TRUE)
+ endif()
+
find_library(METIS_LIBRARIES metis PATHS $ENV{METISDIR} ${LIB_INSTALL_DIR} PATH_SUFFIXES lib)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(METIS DEFAULT_MSG
- METIS_INCLUDES METIS_LIBRARIES)
+ METIS_INCLUDES METIS_LIBRARIES METIS_VERSION_OK)
mark_as_advanced(METIS_INCLUDES METIS_LIBRARIES)
diff --git a/doc/A05_PortingFrom2To3.dox b/doc/A05_PortingFrom2To3.dox
index d885b4f6d..47011aec0 100644
--- a/doc/A05_PortingFrom2To3.dox
+++ b/doc/A05_PortingFrom2To3.dox
@@ -9,11 +9,8 @@ and gives tips to help porting your application from Eigen2 to Eigen3.
\section CompatibilitySupport Eigen2 compatibility support
-In order to ease the switch from Eigen2 to Eigen3, Eigen3 features \subpage Eigen2SupportModes "Eigen2 support modes".
-
-The quick way to enable this is to define the \c EIGEN2_SUPPORT preprocessor token \b before including any Eigen header (typically it should be set in your project options).
-
-A more powerful, \em staged migration path is also provided, which may be useful to migrate larger projects from Eigen2 to Eigen3. This is explained in the \ref Eigen2SupportModes "Eigen 2 support modes" page.
+Up to version 3.2 %Eigen provides <a href="http://eigen.tuxfamily.org/dox/Eigen2SupportModes.html">Eigen2 support modes</a>. These are removed now, because they were barely used anymore and became hard to maintain after internal re-designs.
+You can still use them by first <a href="http://eigen.tuxfamily.org/dox/Eigen2ToEigen3.html">porting your code to Eigen 3.2</a>.
\section Using The USING_PART_OF_NAMESPACE_EIGEN macro
diff --git a/doc/A10_Eigen2SupportModes.dox b/doc/A10_Eigen2SupportModes.dox
deleted file mode 100644
index abfdb4683..000000000
--- a/doc/A10_Eigen2SupportModes.dox
+++ /dev/null
@@ -1,93 +0,0 @@
-namespace Eigen {
-
-/** \page Eigen2SupportModes Eigen 2 support modes
-
-This page documents the Eigen2 support modes, a powerful tool to help migrating your project from Eigen 2 to Eigen 3.
-Don't miss our page on \ref Eigen2ToEigen3 "API changes" between Eigen 2 and Eigen 3.
-
-\eigenAutoToc
-
-\section EIGEN2_SUPPORT_Macro The quick way: define EIGEN2_SUPPORT
-
-By defining EIGEN2_SUPPORT before including any Eigen 3 header, you get back a large part of the Eigen 2 API, while keeping the Eigen 3 API and ABI unchanged.
-
-This defaults to the \ref Stage30 "stage 30" described below.
-
-The rest of this page describes an optional, more powerful \em staged migration path.
-
-\section StagedMigrationPathOverview Overview of the staged migration path
-
-The primary reason why EIGEN2_SUPPORT alone may not be enough to migrate a large project from Eigen 2 to Eigen 3 is that some of the Eigen 2 API is inherently incompatible with the Eigen 3 API. This happens when the same identifier is used in Eigen 2 and in Eigen 3 with different meanings. To help migrate projects that rely on such API, we provide a staged migration path allowing to perform the migration \em incrementally.
-
-It goes as follows:
-\li Step 0: start with a project using Eigen 2.
-\li Step 1: build your project against Eigen 3 with \ref Stage10 "Eigen 2 support stage 10". This mode enables maximum compatibility with the Eigen 2 API, with just a few exceptions.
-\li Step 2: build your project against Eigen 3 with \ref Stage20 "Eigen 2 support stage 20". This mode forces you to add eigen2_ prefixes to the Eigen2 identifiers that conflict with Eigen 3 API.
-\li Step 3: build your project against Eigen 3 with \ref Stage30 "Eigen 2 support stage 30". This mode enables the full Eigen 3 API.
-\li Step 4: build your project against Eigen 3 with \ref Stage40 "Eigen 2 support stage 40". This mode enables the full Eigen 3 strictness on matters, such as const-correctness, where Eigen 2 was looser.
-\li Step 5: build your project against Eigen 3 without any Eigen 2 support mode.
-
-\section Stage10 Stage 10: define EIGEN2_SUPPORT_STAGE10_FULL_EIGEN2_API
-
-Enable this mode by defining the EIGEN2_SUPPORT_STAGE10_FULL_EIGEN2_API preprocessor macro before including any Eigen 3 header.
-
-This mode maximizes support for the Eigen 2 API. As a result, it does not offer the full Eigen 3 API. Also, it doesn't offer quite 100% of the Eigen 2 API.
-
-The part of the Eigen 3 API that is not present in this mode, is Eigen 3's Geometry module. Indeed, this mode completely replaces it by a copy of Eigen 2's Geometry module.
-
-The parts of the API that are still not 100% Eigen 2 compatible in this mode are:
-\li Dot products over complex numbers. Eigen 2's dot product was linear in the first variable. Eigen 3's dot product is linear in the second variable. In other words, the Eigen 2 code \code x.dot(y) \endcode is equivalent to the Eigen 3 code \code y.dot(x) \endcode In yet other words, dot products are complex-conjugated in Eigen 3 compared to Eigen 2. The switch to the new convention was commanded by common usage, especially with the notation \f$ x^Ty \f$ for dot products of column-vectors.
-\li The Sparse module.
-\li Certain fine details of linear algebraic decompositions. For example, LDLT decomposition is now pivoting in Eigen 3 whereas it wasn't in Eigen 2, so code that was relying on its underlying matrix structure will break.
-\li Usage of Eigen types in STL containers, \ref Eigen2ToEigen3 "as explained on this page".
-
-\section Stage20 Stage 20: define EIGEN2_SUPPORT_STAGE20_RESOLVE_API_CONFLICTS
-
-Enable this mode by defining the EIGEN2_SUPPORT_STAGE10_FULL_EIGEN2_API preprocessor macro before including any Eigen 3 header.
-
-This mode removes the Eigen 2 API that is directly conflicting with Eigen 3 API. Instead, these bits of Eigen 2 API remain available with eigen2_ prefixes. The main examples of such API are:
-\li the whole Geometry module. For example, replace \c Quaternion by \c eigen2_Quaternion, replace \c Transform3f by \c eigen2_Transform3f, etc.
-\li the lu() method to obtain a LU decomposition. Replace by eigen2_lu().
-
-There is also one more eigen2_-prefixed identifier that you should know about, even though its use is not checked at compile time by this mode: the dot() method. As was discussed above, over complex numbers, its meaning is different between Eigen 2 and Eigen 3. You can use eigen2_dot() to get the Eigen 2 behavior.
-
-\section Stage30 Stage 30: define EIGEN2_SUPPORT_STAGE30_FULL_EIGEN3_API
-
-Enable this mode by defining the EIGEN2_SUPPORT_STAGE30_FULL_EIGEN3_API preprocessor macro before including any Eigen 3 header. Also, this mode is what you get by default when you just define EIGEN2_SUPPORT.
-
-This mode gives you the full unaltered Eigen 3 API, while still keeping as much support as possible for the Eigen 2 API.
-
-The eigen2_-prefixed identifiers are still available, but at this stage you should now replace them by Eigen 3 identifiers. Have a look at our page on \ref Eigen2ToEigen3 "API changes" between Eigen 2 and Eigen 3.
-
-\section Stage40 Stage 40: define EIGEN2_SUPPORT_STAGE40_FULL_EIGEN3_STRICTNESS
-
-Enable this mode by defining the EIGEN2_SUPPORT_STAGE40_FULL_EIGEN3_STRICTNESS preprocessor macro before including any Eigen 3 header.
-
-This mode tightens the last bits of strictness, especially const-correctness, that had to be loosened to support what Eigen 2 allowed. For example, this code compiled in Eigen 2:
-\code
-const float array[4];
-x = Map<Vector4f>(array);
-\endcode
-That allowed to circumvent constness. This is no longer allowed in Eigen 3. If you have to map const data in Eigen 3, map it as a const-qualified type. However, rather than explictly constructing Map objects, we strongly encourage you to use the static Map methods instead, as they take care of all of this for you:
-\code
-const float array[4];
-x = Vector4f::Map(array);
-\endcode
-This lets Eigen do the right thing for you and works equally well in Eigen 2 and in Eigen 3.
-
-\section FinallyDropAllEigen2Support Finally drop all Eigen 2 support
-
-Stage 40 is the first where it's "comfortable" to stay for a little longer period, since it preserves 100% Eigen 3 compatibility. However, we still encourage you to complete your migration as quickly as possible. While we do run the Eigen 2 test suite against Eigen 3's stage 10 support mode, we can't guarantee the same level of support and quality assurance for Eigen 2 support as we do for Eigen 3 itself, especially not in the long term. \ref Eigen2ToEigen3 "This page" describes a large part of the changes that you may need to perform.
-
-\section ABICompatibility What about ABI compatibility?
-
-It goes as follows:
-\li Stage 10 already is ABI compatible with Eigen 3 for the basic (Matrix, Array, SparseMatrix...) types. However, since this stage uses a copy of Eigen 2's Geometry module instead of Eigen 3's own Geometry module, the ABI in the Geometry module is not Eigen 3 compatible.
-\li Stage 20 removes the Eigen 3-incompatible Eigen 2 Geometry module (it remains available with eigen2_ prefix). So at this stage, all the identifiers that exist in Eigen 3 have the Eigen 3 ABI (and API).
-\li Stage 30 introduces the remaining Eigen 3 identifiers. So at this stage, you have the full Eigen 3 ABI.
-\li Stage 40 is no different than Stage 30 in these matters.
-
-
-*/
-
-}
diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
index 8a493031c..1b8aaf9aa 100644
--- a/doc/CMakeLists.txt
+++ b/doc/CMakeLists.txt
@@ -10,12 +10,20 @@ if(CMAKE_COMPILER_IS_GNUCXX)
endif(CMAKE_SYSTEM_NAME MATCHES Linux)
endif(CMAKE_COMPILER_IS_GNUCXX)
+option(EIGEN_INTERNAL_DOCUMENTATION "Build internal documentation" OFF)
+
+
# Set some Doxygen flags
set(EIGEN_DOXY_PROJECT_NAME "Eigen")
set(EIGEN_DOXY_OUTPUT_DIRECTORY_SUFFIX "")
set(EIGEN_DOXY_INPUT "\"${Eigen_SOURCE_DIR}/Eigen\" \"${Eigen_SOURCE_DIR}/doc\"")
set(EIGEN_DOXY_HTML_COLORSTYLE_HUE "220")
set(EIGEN_DOXY_TAGFILES "")
+if(EIGEN_INTERNAL_DOCUMENTATION)
+ set(EIGEN_DOXY_INTERNAL "YES")
+else(EIGEN_INTERNAL_DOCUMENTATION)
+ set(EIGEN_DOXY_INTERNAL "NO")
+endif(EIGEN_INTERNAL_DOCUMENTATION)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in
diff --git a/doc/Doxyfile.in b/doc/Doxyfile.in
index 7bbf693a0..5d82add72 100644
--- a/doc/Doxyfile.in
+++ b/doc/Doxyfile.in
@@ -460,7 +460,7 @@ HIDE_IN_BODY_DOCS = NO
# to NO (the default) then the documentation will be excluded.
# Set it to YES to include the internal documentation.
-INTERNAL_DOCS = NO
+INTERNAL_DOCS = ${EIGEN_DOXY_INTERNAL}
# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
# file names in lower-case letters. If set to YES upper-case letters are also
@@ -474,13 +474,13 @@ CASE_SENSE_NAMES = YES
# will show members with their full class and namespace scopes in the
# documentation. If set to YES the scope will be hidden.
-HIDE_SCOPE_NAMES = YES
+HIDE_SCOPE_NAMES = NO
# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
# will put a list of the files that are included by a file in the documentation
# of that file.
-SHOW_INCLUDE_FILES = NO
+SHOW_INCLUDE_FILES = ${EIGEN_DOXY_INTERNAL}
# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen
# will list include files with double quotes in the documentation
@@ -546,7 +546,7 @@ STRICT_PROTO_MATCHING = NO
# disable (NO) the todo list. This list is created by putting \todo
# commands in the documentation.
-GENERATE_TODOLIST = NO
+GENERATE_TODOLIST = ${EIGEN_DOXY_INTERNAL}
# The GENERATE_TESTLIST tag can be used to enable (YES) or
# disable (NO) the test list. This list is created by putting \test
@@ -558,13 +558,13 @@ GENERATE_TESTLIST = NO
# disable (NO) the bug list. This list is created by putting \bug
# commands in the documentation.
-GENERATE_BUGLIST = NO
+GENERATE_BUGLIST = ${EIGEN_DOXY_INTERNAL}
# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or
# disable (NO) the deprecated list. This list is created by putting
# \deprecated commands in the documentation.
-GENERATE_DEPRECATEDLIST= NO
+GENERATE_DEPRECATEDLIST= ${EIGEN_DOXY_INTERNAL}
# The ENABLED_SECTIONS tag can be used to enable conditional
# documentation sections, marked by \if sectionname ... \endif.
@@ -1584,7 +1584,6 @@ PREDEFINED = EIGEN_EMPTY_STRUCT \
EIGEN_QT_SUPPORT \
EIGEN_STRONG_INLINE=inline \
EIGEN_DEVICE_FUNC= \
- "EIGEN2_SUPPORT_STAGE=99" \
"EIGEN_MAKE_CWISE_BINARY_OP(METHOD,FUNCTOR)=template<typename OtherDerived> const CwiseBinaryOp<FUNCTOR<Scalar>, const Derived, const OtherDerived> METHOD(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const;" \
"EIGEN_CWISE_PRODUCT_RETURN_TYPE(LHS,RHS)=CwiseBinaryOp<internal::scalar_product_op<typename LHS::Scalar, typename RHS::Scalar >, const LHS, const RHS>"
@@ -1601,8 +1600,7 @@ EXPAND_AS_DEFINED = EIGEN_MAKE_TYPEDEFS \
EIGEN_CWISE_BINOP_RETURN_TYPE \
EIGEN_CURRENT_STORAGE_BASE_CLASS \
EIGEN_MATHFUNC_IMPL \
- _EIGEN_GENERIC_PUBLIC_INTERFACE \
- EIGEN2_SUPPORT
+ _EIGEN_GENERIC_PUBLIC_INTERFACE
# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
# doxygen's preprocessor will remove all references to function-like macros
diff --git a/doc/Manual.dox b/doc/Manual.dox
index 0cbe792d5..43af857a5 100644
--- a/doc/Manual.dox
+++ b/doc/Manual.dox
@@ -159,4 +159,7 @@ namespace Eigen {
\ingroup Geometry_Reference */
/** \addtogroup Splines_Module
\ingroup Geometry_Reference */
+
+/** \internal \brief Namespace containing low-level routines from the %Eigen library. */
+namespace internal {}
}
diff --git a/doc/PreprocessorDirectives.dox b/doc/PreprocessorDirectives.dox
index 6e40f919f..4be2167ef 100644
--- a/doc/PreprocessorDirectives.dox
+++ b/doc/PreprocessorDirectives.dox
@@ -5,7 +5,7 @@ namespace Eigen {
You can control some aspects of %Eigen by defining the preprocessor tokens using \c \#define. These macros
should be defined before any %Eigen headers are included. Often they are best set in the project options.
-This page lists the preprocesor tokens recognised by %Eigen.
+This page lists the preprocessor tokens recognized by %Eigen.
\eigenAutoToc
@@ -18,20 +18,32 @@ one option, and other parts (or libraries that you use) are compiled with anothe
fail to link or exhibit subtle bugs. Nevertheless, these options can be useful for people who know what they
are doing.
- - \b EIGEN2_SUPPORT - if defined, enables the Eigen2 compatibility mode. This is meant to ease the transition
- of Eigen2 to Eigen3 (see \ref Eigen2ToEigen3). Not defined by default.
- - \b EIGEN2_SUPPORT_STAGEnn_xxx (for various values of nn and xxx) - staged migration path from Eigen2 to
- Eigen3; see \ref Eigen2SupportModes.
+ - \b EIGEN2_SUPPORT and \b EIGEN2_SUPPORT_STAGEnn_xxx are disabled starting from the 3.3 release.
+ Defining one of these will raise a compile-error. If you need to compile Eigen2 code,
+ <a href="http://eigen.tuxfamily.org/index.php?title=Eigen2">check this site</a>.
- \b EIGEN_DEFAULT_DENSE_INDEX_TYPE - the type for column and row indices in matrices, vectors and array
(DenseBase::Index). Set to \c std::ptrdiff_t by default.
- \b EIGEN_DEFAULT_IO_FORMAT - the IOFormat to use when printing a matrix if no %IOFormat is specified.
Defaults to the %IOFormat constructed by the default constructor IOFormat::IOFormat().
- \b EIGEN_INITIALIZE_MATRICES_BY_ZERO - if defined, all entries of newly constructed matrices and arrays are
initialized to zero, as are new entries in matrices and arrays after resizing. Not defined by default.
+ \warning The unary (resp. binary) constructor of \c 1x1 (resp. \c 2x1 or \c 1x2) fixed size matrices is
+ always interpreted as an initialization constructor where the argument(s) are the coefficient values
+ and not the sizes. For instance, \code Vector2d v(2,1); \endcode will create a vector with coeficients [2,1],
+ and \b not a \c 2x1 vector initialized with zeros (i.e., [0,0]). If such cases might occur, then it is
+ recommended to use the default constructor with a explicit call to resize:
+ \code
+ Matrix<?,SizeAtCompileTime,1> v;
+ v.resize(size);
+ Matrix<?,RowsAtCompileTime,ColsAtCompileTime> m;
+ m.resize(rows,cols);
+ \endcode
- \b EIGEN_INITIALIZE_MATRICES_BY_NAN - if defined, all entries of newly constructed matrices and arrays are
initialized to NaN, as are new entries in matrices and arrays after resizing. This option is especially
useful for debugging purpose, though a memory tool like <a href="http://valgrind.org/">valgrind</a> is
preferable. Not defined by default.
+ \warning See the documentation of \c EIGEN_INITIALIZE_MATRICES_BY_ZERO for a discussion on a limitations
+ of these macros when applied to \c 1x1, \c 1x2, and \c 2x1 fixed-size matrices.
- \b EIGEN_NO_AUTOMATIC_RESIZING - if defined, the matrices (or arrays) on both sides of an assignment
<tt>a = b</tt> have to be of the same size; otherwise, %Eigen automatically resizes \c a so that it is of
the correct size. Not defined by default.
@@ -55,13 +67,15 @@ run time. However, these assertions do cost time and can thus be turned off.
\section TopicPreprocessorDirectivesPerformance Alignment, vectorization and performance tweaking
- - \b EIGEN_MALLOC_ALREADY_ALIGNED - Can be set to 0 or 1 to tell whether default system malloc already
+ - \b EIGEN_MALLOC_ALREADY_ALIGNED - Can be set to 0 or 1 to tell whether default system \c malloc already
returns aligned buffers. In not defined, then this information is automatically deduced from the compiler
and system preprocessor tokens.
- \b EIGEN_DONT_ALIGN - disables alignment completely. %Eigen will not try to align its objects and does not
expect that any objects passed to it are aligned. This will turn off vectorization. Not defined by default.
- \b EIGEN_DONT_ALIGN_STATICALLY - disables alignment of arrays on the stack. Not defined by default, unless
\c EIGEN_DONT_ALIGN is defined.
+ - \b EIGEN_DONT_PARALLELIZE - if defined, this disables multi-threading. This is only relevant if you enabled OpenMP.
+ See \ref TopicMultiThreading for details.
- \b EIGEN_DONT_VECTORIZE - disables explicit vectorization when defined. Not defined by default, unless
alignment is disabled by %Eigen's platform test or the user defining \c EIGEN_DONT_ALIGN.
- \b EIGEN_FAST_MATH - enables some optimizations which might affect the accuracy of the result. This currently
diff --git a/doc/SparseLinearSystems.dox b/doc/SparseLinearSystems.dox
index c00be10d3..147b55376 100644
--- a/doc/SparseLinearSystems.dox
+++ b/doc/SparseLinearSystems.dox
@@ -102,7 +102,7 @@ x2 = solver.solve(b2);
The compute() method is equivalent to calling both analyzePattern() and factorize().
Finally, each solver provides some specific features, such as determinant, access to the factors, controls of the iterations, and so on.
-More details are availble in the documentations of the respective classes.
+More details are available in the documentations of the respective classes.
\section TheSparseCompute The Compute Step
In the compute() function, the matrix is generally factorized: LLT for self-adjoint matrices, LDLT for general hermitian matrices, LU for non hermitian matrices and QR for rectangular matrices. These are the results of using direct solvers. For this class of solvers precisely, the compute step is further subdivided into analyzePattern() and factorize().
@@ -140,7 +140,16 @@ x2 = solver.solve(b2);
For direct methods, the solution are computed at the machine precision. Sometimes, the solution need not be too accurate. In this case, the iterative methods are more suitable and the desired accuracy can be set before the solve step using \b setTolerance(). For all the available functions, please, refer to the documentation of the \link IterativeLinearSolvers_Module Iterative solvers module \endlink.
\section BenchmarkRoutine
-Most of the time, all you need is to know how much time it will take to qolve your system, and hopefully, what is the most suitable solver. In Eigen, we provide a benchmark routine that can be used for this purpose. It is very easy to use. In the build directory, navigate to bench/spbench and compile the routine by typing \b make \e spbenchsolver. Run it with --help option to get the list of all available options. Basically, the matrices to test should be in <a href="http://math.nist.gov/MatrixMarket/formats.html">MatrixMarket Coordinate format</a>, and the routine returns the statistics from all available solvers in Eigen.
+Most of the time, all you need is to know how much time it will take to solve your system, and hopefully, what is the most suitable solver. In Eigen, we provide a benchmark routine that can be used for this purpose. It is very easy to use. In the build directory, navigate to bench/spbench and compile the routine by typing \b make \e spbenchsolver. Run it with --help option to get the list of all available options. Basically, the matrices to test should be in <a href="http://math.nist.gov/MatrixMarket/formats.html">MatrixMarket Coordinate format</a>, and the routine returns the statistics from all available solvers in Eigen.
+
+To export your matrices and right-hand-side vectors in the matrix-market format, you can the the unsupported SparseExtra module:
+\code
+#include <unsupported/Eigen/SparseExtra>
+...
+Eigen::saveMarket(A, "filename.mtx");
+Eigen::saveMarket(A, "filename_SPD.mtx", Eigen::Symmetric); // if A is symmetric-positive-definite
+Eigen::saveMarketVector(B, "filename_b.mtx");
+\endcode
The following table gives an example of XML statistics from several Eigen built-in and external solvers.
<TABLE border="1">
diff --git a/doc/TopicLinearAlgebraDecompositions.dox b/doc/TopicLinearAlgebraDecompositions.dox
index 77f2c92ab..5bcff2c96 100644
--- a/doc/TopicLinearAlgebraDecompositions.dox
+++ b/doc/TopicLinearAlgebraDecompositions.dox
@@ -116,7 +116,7 @@ For an introduction on linear solvers and decompositions, check this \link Tutor
<td>JacobiSVD (two-sided)</td>
<td>-</td>
<td>Slow (but fast for small matrices)</td>
- <td>Excellent-Proven<sup><a href="#note3">3</a></sup></td>
+ <td>Proven<sup><a href="#note3">3</a></sup></td>
<td>Yes</td>
<td>Singular values/vectors, least squares</td>
<td>Yes (and does least squares)</td>
@@ -132,7 +132,7 @@ For an introduction on linear solvers and decompositions, check this \link Tutor
<td>Yes</td>
<td>Eigenvalues/vectors</td>
<td>-</td>
- <td>Good</td>
+ <td>Excellent</td>
<td><em>Closed forms for 2x2 and 3x3</em></td>
</tr>
diff --git a/doc/TutorialLinearAlgebra.dox b/doc/TutorialLinearAlgebra.dox
index e6c41fd70..cb92ceeae 100644
--- a/doc/TutorialLinearAlgebra.dox
+++ b/doc/TutorialLinearAlgebra.dox
@@ -40,8 +40,9 @@ depending on your matrix and the trade-off you want to make:
<tr>
<th>Decomposition</th>
<th>Method</th>
- <th>Requirements on the matrix</th>
- <th>Speed</th>
+ <th>Requirements<br/>on the matrix</th>
+ <th>Speed<br/> (small-to-medium)</th>
+ <th>Speed<br/> (large)</th>
<th>Accuracy</th>
</tr>
<tr>
@@ -49,6 +50,7 @@ depending on your matrix and the trade-off you want to make:
<td>partialPivLu()</td>
<td>Invertible</td>
<td>++</td>
+ <td>++</td>
<td>+</td>
</tr>
<tr class="alt">
@@ -56,6 +58,7 @@ depending on your matrix and the trade-off you want to make:
<td>fullPivLu()</td>
<td>None</td>
<td>-</td>
+ <td>- -</td>
<td>+++</td>
</tr>
<tr>
@@ -63,20 +66,23 @@ depending on your matrix and the trade-off you want to make:
<td>householderQr()</td>
<td>None</td>
<td>++</td>
+ <td>++</td>
<td>+</td>
</tr>
<tr class="alt">
<td>ColPivHouseholderQR</td>
<td>colPivHouseholderQr()</td>
<td>None</td>
- <td>+</td>
<td>++</td>
+ <td>-</td>
+ <td>+++</td>
</tr>
<tr>
<td>FullPivHouseholderQR</td>
<td>fullPivHouseholderQr()</td>
<td>None</td>
<td>-</td>
+ <td>- -</td>
<td>+++</td>
</tr>
<tr class="alt">
@@ -84,21 +90,31 @@ depending on your matrix and the trade-off you want to make:
<td>llt()</td>
<td>Positive definite</td>
<td>+++</td>
+ <td>+++</td>
<td>+</td>
</tr>
<tr>
<td>LDLT</td>
<td>ldlt()</td>
- <td>Positive or negative semidefinite</td>
+ <td>Positive or negative<br/> semidefinite</td>
<td>+++</td>
+ <td>+</td>
<td>++</td>
</tr>
+ <tr class="alt">
+ <td>JacobiSVD</td>
+ <td>jacobiSvd()</td>
+ <td>None</td>
+ <td>- -</td>
+ <td>- - -</td>
+ <td>+++</td>
+ </tr>
</table>
All of these decompositions offer a solve() method that works as in the above example.
For example, if your matrix is positive definite, the above table says that a very good
-choice is then the LDLT decomposition. Here's an example, also demonstrating that using a general
+choice is then the LLT or LDLT decomposition. Here's an example, also demonstrating that using a general
matrix (not a vector) as right hand side is possible.
<table class="example">
diff --git a/doc/examples/MatrixBase_cwise_const.cpp b/doc/examples/MatrixBase_cwise_const.cpp
deleted file mode 100644
index 23700e0b6..000000000
--- a/doc/examples/MatrixBase_cwise_const.cpp
+++ /dev/null
@@ -1,18 +0,0 @@
-#define EIGEN2_SUPPORT
-#include <Eigen/Core>
-#include <iostream>
-
-using namespace Eigen;
-using namespace std;
-
-int main()
-{
- Matrix3i m = Matrix3i::Random();
- cout << "Here is the matrix m:" << endl << m << endl;
- Matrix3i n = Matrix3i::Random();
- cout << "And here is the matrix n:" << endl << n << endl;
- cout << "The coefficient-wise product of m and n is:" << endl;
- cout << m.cwise() * n << endl;
- cout << "Taking the cube of the coefficients of m yields:" << endl;
- cout << m.cwise().pow(3) << endl;
-}
diff --git a/doc/snippets/Cwise_atan.cpp b/doc/snippets/Cwise_atan.cpp
new file mode 100644
index 000000000..446844726
--- /dev/null
+++ b/doc/snippets/Cwise_atan.cpp
@@ -0,0 +1,2 @@
+ArrayXd v = ArrayXd::LinSpaced(5,0,1);
+cout << v.atan() << endl;
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index c2d827051..47aefddb8 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -82,7 +82,7 @@ endif()
find_package(Pastix)
find_package(Scotch)
-find_package(Metis)
+find_package(Metis 5.0 REQUIRED)
if(PASTIX_FOUND)
add_definitions("-DEIGEN_PASTIX_SUPPORT")
include_directories(${PASTIX_INCLUDES})
@@ -157,9 +157,10 @@ ei_add_test(vectorization_logic)
ei_add_test(basicstuff)
ei_add_test(linearstructure)
ei_add_test(integer_types)
-ei_add_test(cwiseop)
ei_add_test(unalignedcount)
-ei_add_test(exceptions)
+if(NOT EIGEN_TEST_NO_EXCEPTIONS)
+ ei_add_test(exceptions)
+endif()
ei_add_test(redux)
ei_add_test(visitor)
ei_add_test(block)
@@ -239,7 +240,9 @@ ei_add_test(nesting_ops "${CMAKE_CXX_FLAGS_DEBUG}")
ei_add_test(zerosized)
ei_add_test(dontalign)
ei_add_test(evaluators)
-ei_add_test(sizeoverflow)
+if(NOT EIGEN_TEST_NO_EXCEPTIONS)
+ ei_add_test(sizeoverflow)
+endif()
ei_add_test(prec_inverse_4x4)
ei_add_test(vectorwiseop)
ei_add_test(special_numbers)
@@ -258,8 +261,6 @@ if(QT4_FOUND)
ei_add_test(qtvector "" "${QT_QTCORE_LIBRARY}")
endif(QT4_FOUND)
-ei_add_test(eigen2support)
-
if(UMFPACK_FOUND)
ei_add_test(umfpack_support "" "${UMFPACK_ALL_LIBS}")
endif()
@@ -302,8 +303,9 @@ ei_add_property(EIGEN_TESTING_SUMMARY "CXX_FLAGS: ${CMAKE_CXX_FLAGS}\n")
ei_add_property(EIGEN_TESTING_SUMMARY "Sparse lib flags: ${SPARSE_LIBS}\n")
option(EIGEN_TEST_EIGEN2 "Run whole Eigen2 test suite against EIGEN2_SUPPORT" OFF)
+mark_as_advanced(EIGEN_TEST_EIGEN2)
if(EIGEN_TEST_EIGEN2)
- add_subdirectory(eigen2)
+ message(WARNING "The Eigen2 test suite has been removed")
endif()
diff --git a/test/array.cpp b/test/array.cpp
index 5f49fc1ea..010fead2d 100644
--- a/test/array.cpp
+++ b/test/array.cpp
@@ -178,6 +178,7 @@ template<typename ArrayType> void array_real(const ArrayType& m)
VERIFY_IS_APPROX(m1.asin(), asin(m1));
VERIFY_IS_APPROX(m1.acos(), acos(m1));
VERIFY_IS_APPROX(m1.tan(), tan(m1));
+ VERIFY_IS_APPROX(m1.atan(), atan(m1));
VERIFY_IS_APPROX(cos(m1+RealScalar(3)*m2), cos((m1+RealScalar(3)*m2).eval()));
diff --git a/test/basicstuff.cpp b/test/basicstuff.cpp
index 8c0621ecd..3d7d74d4e 100644
--- a/test/basicstuff.cpp
+++ b/test/basicstuff.cpp
@@ -180,15 +180,64 @@ void casting()
template <typename Scalar>
void fixedSizeMatrixConstruction()
{
- const Scalar raw[3] = {1,2,3};
- Matrix<Scalar,3,1> m(raw);
- Array<Scalar,3,1> a(raw);
- VERIFY(m(0) == 1);
- VERIFY(m(1) == 2);
- VERIFY(m(2) == 3);
- VERIFY(a(0) == 1);
- VERIFY(a(1) == 2);
- VERIFY(a(2) == 3);
+ Scalar raw[4];
+ for(int k=0; k<4; ++k)
+ raw[k] = internal::random<Scalar>();
+
+ {
+ Matrix<Scalar,4,1> m(raw);
+ Array<Scalar,4,1> a(raw);
+ for(int k=0; k<4; ++k) VERIFY(m(k) == raw[k]);
+ for(int k=0; k<4; ++k) VERIFY(a(k) == raw[k]);
+ VERIFY_IS_EQUAL(m,(Matrix<Scalar,4,1>(raw[0],raw[1],raw[2],raw[3])));
+ VERIFY((a==(Array<Scalar,4,1>(raw[0],raw[1],raw[2],raw[3]))).all());
+ }
+ {
+ Matrix<Scalar,3,1> m(raw);
+ Array<Scalar,3,1> a(raw);
+ for(int k=0; k<3; ++k) VERIFY(m(k) == raw[k]);
+ for(int k=0; k<3; ++k) VERIFY(a(k) == raw[k]);
+ VERIFY_IS_EQUAL(m,(Matrix<Scalar,3,1>(raw[0],raw[1],raw[2])));
+ VERIFY((a==Array<Scalar,3,1>(raw[0],raw[1],raw[2])).all());
+ }
+ {
+ Matrix<Scalar,2,1> m(raw), m2( (DenseIndex(raw[0])), (DenseIndex(raw[1])) );
+ Array<Scalar,2,1> a(raw), a2( (DenseIndex(raw[0])), (DenseIndex(raw[1])) );
+ for(int k=0; k<2; ++k) VERIFY(m(k) == raw[k]);
+ for(int k=0; k<2; ++k) VERIFY(a(k) == raw[k]);
+ VERIFY_IS_EQUAL(m,(Matrix<Scalar,2,1>(raw[0],raw[1])));
+ VERIFY((a==Array<Scalar,2,1>(raw[0],raw[1])).all());
+ for(int k=0; k<2; ++k) VERIFY(m2(k) == DenseIndex(raw[k]));
+ for(int k=0; k<2; ++k) VERIFY(a2(k) == DenseIndex(raw[k]));
+ }
+ {
+ Matrix<Scalar,1,2> m(raw),
+ m2( (DenseIndex(raw[0])), (DenseIndex(raw[1])) ),
+ m3( (int(raw[0])), (int(raw[1])) ),
+ m4( (float(raw[0])), (float(raw[1])) );
+ Array<Scalar,1,2> a(raw), a2( (DenseIndex(raw[0])), (DenseIndex(raw[1])) );
+ for(int k=0; k<2; ++k) VERIFY(m(k) == raw[k]);
+ for(int k=0; k<2; ++k) VERIFY(a(k) == raw[k]);
+ VERIFY_IS_EQUAL(m,(Matrix<Scalar,1,2>(raw[0],raw[1])));
+ VERIFY((a==Array<Scalar,1,2>(raw[0],raw[1])).all());
+ for(int k=0; k<2; ++k) VERIFY(m2(k) == DenseIndex(raw[k]));
+ for(int k=0; k<2; ++k) VERIFY(a2(k) == DenseIndex(raw[k]));
+ for(int k=0; k<2; ++k) VERIFY(m3(k) == int(raw[k]));
+ for(int k=0; k<2; ++k) VERIFY(m4(k) == float(raw[k]));
+ }
+ {
+ Matrix<Scalar,1,1> m(raw), m1(raw[0]), m2( (DenseIndex(raw[0])) ), m3( (int(raw[0])) );
+ Array<Scalar,1,1> a(raw), a1(raw[0]), a2( (DenseIndex(raw[0])) );
+ VERIFY(m(0) == raw[0]);
+ VERIFY(a(0) == raw[0]);
+ VERIFY(m1(0) == raw[0]);
+ VERIFY(a1(0) == raw[0]);
+ VERIFY(m2(0) == DenseIndex(raw[0]));
+ VERIFY(a2(0) == DenseIndex(raw[0]));
+ VERIFY(m3(0) == int(raw[0]));
+ VERIFY_IS_EQUAL(m,(Matrix<Scalar,1,1>(raw[0])));
+ VERIFY((a==Array<Scalar,1,1>(raw[0])).all());
+ }
}
void test_basicstuff()
@@ -207,8 +256,11 @@ void test_basicstuff()
}
CALL_SUBTEST_1(fixedSizeMatrixConstruction<unsigned char>());
+ CALL_SUBTEST_1(fixedSizeMatrixConstruction<float>());
CALL_SUBTEST_1(fixedSizeMatrixConstruction<double>());
- CALL_SUBTEST_1(fixedSizeMatrixConstruction<double>());
+ CALL_SUBTEST_1(fixedSizeMatrixConstruction<int>());
+ CALL_SUBTEST_1(fixedSizeMatrixConstruction<long int>());
+ CALL_SUBTEST_1(fixedSizeMatrixConstruction<std::ptrdiff_t>());
CALL_SUBTEST_2(casting());
}
diff --git a/test/block.cpp b/test/block.cpp
index 9ed5d7bc5..269acd28e 100644
--- a/test/block.cpp
+++ b/test/block.cpp
@@ -141,11 +141,11 @@ template<typename MatrixType> void block(const MatrixType& m)
VERIFY_IS_EQUAL( (m1.transpose().block(c1,r1,c2-c1+1,r2-r1+1).col(0)) , (m1.row(r1).segment(c1,c2-c1+1)).transpose() );
// expressions without direct access
- VERIFY_IS_EQUAL( ((m1+m2).block(r1,c1,rows-r1,cols-c1).block(r2-r1,c2-c1,rows-r2,cols-c2)) , ((m1+m2).block(r2,c2,rows-r2,cols-c2)) );
- VERIFY_IS_EQUAL( ((m1+m2).block(r1,c1,r2-r1+1,c2-c1+1).row(0)) , ((m1+m2).row(r1).segment(c1,c2-c1+1)) );
- VERIFY_IS_EQUAL( ((m1+m2).block(r1,c1,r2-r1+1,c2-c1+1).col(0)) , ((m1+m2).col(c1).segment(r1,r2-r1+1)) );
- VERIFY_IS_EQUAL( ((m1+m2).block(r1,c1,r2-r1+1,c2-c1+1).transpose().col(0)) , ((m1+m2).row(r1).segment(c1,c2-c1+1)).transpose() );
- VERIFY_IS_EQUAL( ((m1+m2).transpose().block(c1,r1,c2-c1+1,r2-r1+1).col(0)) , ((m1+m2).row(r1).segment(c1,c2-c1+1)).transpose() );
+ VERIFY_IS_APPROX( ((m1+m2).block(r1,c1,rows-r1,cols-c1).block(r2-r1,c2-c1,rows-r2,cols-c2)) , ((m1+m2).block(r2,c2,rows-r2,cols-c2)) );
+ VERIFY_IS_APPROX( ((m1+m2).block(r1,c1,r2-r1+1,c2-c1+1).row(0)) , ((m1+m2).row(r1).segment(c1,c2-c1+1)) );
+ VERIFY_IS_APPROX( ((m1+m2).block(r1,c1,r2-r1+1,c2-c1+1).col(0)) , ((m1+m2).col(c1).segment(r1,r2-r1+1)) );
+ VERIFY_IS_APPROX( ((m1+m2).block(r1,c1,r2-r1+1,c2-c1+1).transpose().col(0)) , ((m1+m2).row(r1).segment(c1,c2-c1+1)).transpose() );
+ VERIFY_IS_APPROX( ((m1+m2).transpose().block(c1,r1,c2-c1+1,r2-r1+1).col(0)) , ((m1+m2).row(r1).segment(c1,c2-c1+1)).transpose() );
// evaluation into plain matrices from expressions with direct access (stress MapBase)
DynamicMatrixType dm;
diff --git a/test/cholesky.cpp b/test/cholesky.cpp
index 569318f83..a883192ab 100644
--- a/test/cholesky.cpp
+++ b/test/cholesky.cpp
@@ -68,6 +68,7 @@ template<typename MatrixType> void cholesky(const MatrixType& m)
Index cols = m.cols();
typedef typename MatrixType::Scalar Scalar;
+ typedef typename NumTraits<Scalar>::Real RealScalar;
typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime> SquareMatrixType;
typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, 1> VectorType;
@@ -180,7 +181,7 @@ template<typename MatrixType> void cholesky(const MatrixType& m)
if(rows>=3)
{
SquareMatrixType A = symm;
- int c = internal::random<int>(0,rows-2);
+ Index c = internal::random<Index>(0,rows-2);
A.bottomRightCorner(c,c).setZero();
// Make sure a solution exists:
vecX.setRandom();
@@ -195,7 +196,7 @@ template<typename MatrixType> void cholesky(const MatrixType& m)
// check non-full rank matrices
if(rows>=3)
{
- int r = internal::random<int>(1,rows-1);
+ Index r = internal::random<Index>(1,rows-1);
Matrix<Scalar,Dynamic,Dynamic> a = Matrix<Scalar,Dynamic,Dynamic>::Random(rows,r);
SquareMatrixType A = a * a.adjoint();
// Make sure a solution exists:
@@ -207,6 +208,25 @@ template<typename MatrixType> void cholesky(const MatrixType& m)
vecX = ldltlo.solve(vecB);
VERIFY_IS_APPROX(A * vecX, vecB);
}
+
+ // check matrices with a wide spectrum
+ if(rows>=3)
+ {
+ RealScalar s = (std::min)(16,std::numeric_limits<RealScalar>::max_exponent10/8);
+ Matrix<Scalar,Dynamic,Dynamic> a = Matrix<Scalar,Dynamic,Dynamic>::Random(rows,rows);
+ Matrix<RealScalar,Dynamic,1> d = Matrix<RealScalar,Dynamic,1>::Random(rows);
+ for(Index k=0; k<rows; ++k)
+ d(k) = d(k)*std::pow(RealScalar(10),internal::random<RealScalar>(-s,s));
+ SquareMatrixType A = a * d.asDiagonal() * a.adjoint();
+ // Make sure a solution exists:
+ vecX.setRandom();
+ vecB = A * vecX;
+ vecX.setZero();
+ ldltlo.compute(A);
+ VERIFY_IS_APPROX(A, ldltlo.reconstructedMatrix());
+ vecX = ldltlo.solve(vecB);
+ VERIFY_IS_APPROX(A * vecX, vecB);
+ }
}
// update/downdate
diff --git a/test/ctorleak.cpp b/test/ctorleak.cpp
new file mode 100644
index 000000000..145d91be4
--- /dev/null
+++ b/test/ctorleak.cpp
@@ -0,0 +1,51 @@
+#include "main.h"
+
+#include <exception> // std::exception
+
+struct Foo
+{
+ static unsigned object_count;
+ static unsigned object_limit;
+ int dummy;
+
+ Foo()
+ {
+#ifdef EIGEN_EXCEPTIONS
+ // TODO: Is this the correct way to handle this?
+ if (Foo::object_count > Foo::object_limit) { throw Foo::Fail(); }
+#endif
+ ++Foo::object_count;
+ }
+
+ ~Foo()
+ {
+ --Foo::object_count;
+ }
+
+ class Fail : public std::exception {};
+};
+
+unsigned Foo::object_count = 0;
+unsigned Foo::object_limit = 0;
+
+
+void test_ctorleak()
+{
+ typedef DenseIndex Index;
+ Foo::object_count = 0;
+ for(int i = 0; i < g_repeat; i++) {
+ Index rows = internal::random<Index>(2,EIGEN_TEST_MAX_SIZE), cols = internal::random<Index>(2,EIGEN_TEST_MAX_SIZE);
+ Foo::object_limit = internal::random(0, rows*cols - 2);
+#ifdef EIGEN_EXCEPTIONS
+ try
+ {
+#endif
+ Matrix<Foo, Dynamic, Dynamic> m(rows, cols);
+#ifdef EIGEN_EXCEPTIONS
+ VERIFY(false); // not reached if exceptions are enabled
+ }
+ catch (const Foo::Fail&) { /* ignore */ }
+#endif
+ }
+ VERIFY_IS_EQUAL(static_cast<unsigned>(0), Foo::object_count);
+}
diff --git a/test/cwiseop.cpp b/test/cwiseop.cpp
deleted file mode 100644
index 247fa2a09..000000000
--- a/test/cwiseop.cpp
+++ /dev/null
@@ -1,182 +0,0 @@
-// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra.
-//
-// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
-// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
-//
-// 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/.
-
-#define EIGEN2_SUPPORT
-#define EIGEN_NO_STATIC_ASSERT
-#include "main.h"
-#include <functional>
-
-#ifdef min
-#undef min
-#endif
-
-#ifdef max
-#undef max
-#endif
-
-using namespace std;
-
-template<typename Scalar> struct AddIfNull {
- const Scalar operator() (const Scalar a, const Scalar b) const {return a<=1e-3 ? b : a;}
- enum { Cost = NumTraits<Scalar>::AddCost };
-};
-
-template<typename MatrixType>
-typename Eigen::internal::enable_if<!NumTraits<typename MatrixType::Scalar>::IsInteger,typename MatrixType::Scalar>::type
-cwiseops_real_only(MatrixType& m1, MatrixType& m2, MatrixType& m3, MatrixType& mones)
-{
- typedef typename MatrixType::Scalar Scalar;
- typedef typename NumTraits<Scalar>::Real RealScalar;
-
- VERIFY_IS_APPROX(m1.cwise() / m2, m1.cwise() * (m2.cwise().inverse()));
- m3 = m1.cwise().abs().cwise().sqrt();
- VERIFY_IS_APPROX(m3.cwise().square(), m1.cwise().abs());
- VERIFY_IS_APPROX(m1.cwise().square().cwise().sqrt(), m1.cwise().abs());
- VERIFY_IS_APPROX(m1.cwise().abs().cwise().log().cwise().exp() , m1.cwise().abs());
-
- VERIFY_IS_APPROX(m1.cwise().pow(2), m1.cwise().square());
- m3 = (m1.cwise().abs().cwise()<=RealScalar(0.01)).select(mones,m1);
- VERIFY_IS_APPROX(m3.cwise().pow(-1), m3.cwise().inverse());
- m3 = m1.cwise().abs();
- VERIFY_IS_APPROX(m3.cwise().pow(RealScalar(0.5)), m3.cwise().sqrt());
-
-// VERIFY_IS_APPROX(m1.cwise().tan(), m1.cwise().sin().cwise() / m1.cwise().cos());
- VERIFY_IS_APPROX(mones, m1.cwise().sin().cwise().square() + m1.cwise().cos().cwise().square());
- m3 = m1;
- m3.cwise() /= m2;
- VERIFY_IS_APPROX(m3, m1.cwise() / m2);
-
- return Scalar(0);
-}
-
-template<typename MatrixType>
-typename Eigen::internal::enable_if<NumTraits<typename MatrixType::Scalar>::IsInteger,typename MatrixType::Scalar>::type
-cwiseops_real_only(MatrixType& , MatrixType& , MatrixType& , MatrixType& )
-{
- return 0;
-}
-
-template<typename MatrixType> void cwiseops(const MatrixType& m)
-{
- typedef typename MatrixType::Index Index;
- typedef typename MatrixType::Scalar Scalar;
- typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, 1> VectorType;
-
- Index rows = m.rows();
- Index cols = m.cols();
-
- MatrixType m1 = MatrixType::Random(rows, cols),
- m1bis = m1,
- m2 = MatrixType::Random(rows, cols),
- m3(rows, cols),
- m4(rows, cols),
- mzero = MatrixType::Zero(rows, cols),
- mones = MatrixType::Ones(rows, cols),
- identity = Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime>
- ::Identity(rows, rows);
- VectorType vzero = VectorType::Zero(rows),
- vones = VectorType::Ones(rows),
- v3(rows);
-
- Index r = internal::random<Index>(0, rows-1),
- c = internal::random<Index>(0, cols-1);
-
- Scalar s1 = internal::random<Scalar>();
-
- // test Zero, Ones, Constant, and the set* variants
- m3 = MatrixType::Constant(rows, cols, s1);
- for (int j=0; j<cols; ++j)
- for (int i=0; i<rows; ++i)
- {
- VERIFY_IS_APPROX(mzero(i,j), Scalar(0));
- VERIFY_IS_APPROX(mones(i,j), Scalar(1));
- VERIFY_IS_APPROX(m3(i,j), s1);
- }
- VERIFY(mzero.isZero());
- VERIFY(mones.isOnes());
- VERIFY(m3.isConstant(s1));
- VERIFY(identity.isIdentity());
- VERIFY_IS_APPROX(m4.setConstant(s1), m3);
- VERIFY_IS_APPROX(m4.setConstant(rows,cols,s1), m3);
- VERIFY_IS_APPROX(m4.setZero(), mzero);
- VERIFY_IS_APPROX(m4.setZero(rows,cols), mzero);
- VERIFY_IS_APPROX(m4.setOnes(), mones);
- VERIFY_IS_APPROX(m4.setOnes(rows,cols), mones);
- m4.fill(s1);
- VERIFY_IS_APPROX(m4, m3);
-
- VERIFY_IS_APPROX(v3.setConstant(rows, s1), VectorType::Constant(rows,s1));
- VERIFY_IS_APPROX(v3.setZero(rows), vzero);
- VERIFY_IS_APPROX(v3.setOnes(rows), vones);
-
- m2 = m2.template binaryExpr<AddIfNull<Scalar> >(mones);
-
- VERIFY_IS_APPROX(m1.cwise().pow(2), m1.cwise().abs2());
- VERIFY_IS_APPROX(m1.cwise().pow(2), m1.cwise().square());
- VERIFY_IS_APPROX(m1.cwise().pow(3), m1.cwise().cube());
-
- VERIFY_IS_APPROX(m1 + mones, m1.cwise()+Scalar(1));
- VERIFY_IS_APPROX(m1 - mones, m1.cwise()-Scalar(1));
- m3 = m1; m3.cwise() += 1;
- VERIFY_IS_APPROX(m1 + mones, m3);
- m3 = m1; m3.cwise() -= 1;
- VERIFY_IS_APPROX(m1 - mones, m3);
-
- VERIFY_IS_APPROX(m2, m2.cwise() * mones);
- VERIFY_IS_APPROX(m1.cwise() * m2, m2.cwise() * m1);
- m3 = m1;
- m3.cwise() *= m2;
- VERIFY_IS_APPROX(m3, m1.cwise() * m2);
-
- VERIFY_IS_APPROX(mones, m2.cwise()/m2);
-
- // check min
- VERIFY_IS_APPROX( m1.cwise().min(m2), m2.cwise().min(m1) );
- VERIFY_IS_APPROX( m1.cwise().min(m1+mones), m1 );
- VERIFY_IS_APPROX( m1.cwise().min(m1-mones), m1-mones );
-
- // check max
- VERIFY_IS_APPROX( m1.cwise().max(m2), m2.cwise().max(m1) );
- VERIFY_IS_APPROX( m1.cwise().max(m1-mones), m1 );
- VERIFY_IS_APPROX( m1.cwise().max(m1+mones), m1+mones );
-
- VERIFY( (m1.cwise() == m1).all() );
- VERIFY( (m1.cwise() != m2).any() );
- VERIFY(!(m1.cwise() == (m1+mones)).any() );
- if (rows*cols>1)
- {
- m3 = m1;
- m3(r,c) += 1;
- VERIFY( (m1.cwise() == m3).any() );
- VERIFY( !(m1.cwise() == m3).all() );
- }
- VERIFY( (m1.cwise().min(m2).cwise() <= m2).all() );
- VERIFY( (m1.cwise().max(m2).cwise() >= m2).all() );
- VERIFY( (m1.cwise().min(m2).cwise() < (m1+mones)).all() );
- VERIFY( (m1.cwise().max(m2).cwise() > (m1-mones)).all() );
-
- VERIFY( (m1.cwise()<m1.unaryExpr(bind2nd(plus<Scalar>(), Scalar(1)))).all() );
- VERIFY( !(m1.cwise()<m1bis.unaryExpr(bind2nd(minus<Scalar>(), Scalar(1)))).all() );
- VERIFY( !(m1.cwise()>m1bis.unaryExpr(bind2nd(plus<Scalar>(), Scalar(1)))).any() );
-
- cwiseops_real_only(m1, m2, m3, mones);
-}
-
-void test_cwiseop()
-{
- for(int i = 0; i < g_repeat ; i++) {
- CALL_SUBTEST_1( cwiseops(Matrix<float, 1, 1>()) );
- CALL_SUBTEST_2( cwiseops(Matrix4d()) );
- CALL_SUBTEST_3( cwiseops(MatrixXf(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) );
- CALL_SUBTEST_4( cwiseops(MatrixXf(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) );
- CALL_SUBTEST_5( cwiseops(MatrixXi(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) );
- CALL_SUBTEST_6( cwiseops(MatrixXd(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) );
- }
-}
diff --git a/test/dynalloc.cpp b/test/dynalloc.cpp
index c98cc80f0..1190eb9cd 100644
--- a/test/dynalloc.cpp
+++ b/test/dynalloc.cpp
@@ -55,7 +55,7 @@ void check_aligned_new()
void check_aligned_stack_alloc()
{
- for(int i = 1; i < 1000; i++)
+ for(int i = 1; i < 400; i++)
{
ei_declare_aligned_stack_constructed_variable(float,p,i,0);
VERIFY(size_t(p)%ALIGNMENT==0);
@@ -93,6 +93,32 @@ template<typename T> void check_dynaligned()
}
}
+template<typename T> void check_custom_new_delete()
+{
+ {
+ T* t = new T;
+ delete t;
+ }
+
+ {
+ std::size_t N = internal::random<std::size_t>(1,10);
+ T* t = new T[N];
+ delete[] t;
+ }
+
+#ifdef EIGEN_ALIGN
+ {
+ T* t = static_cast<T *>((T::operator new)(sizeof(T)));
+ (T::operator delete)(t, sizeof(T));
+ }
+
+ {
+ T* t = static_cast<T *>((T::operator new)(sizeof(T)));
+ (T::operator delete)(t);
+ }
+#endif
+}
+
void test_dynalloc()
{
// low level dynamic memory allocation
@@ -109,6 +135,11 @@ void test_dynalloc()
CALL_SUBTEST(check_dynaligned<Vector4d>() );
CALL_SUBTEST(check_dynaligned<Vector4i>() );
CALL_SUBTEST(check_dynaligned<Vector8f>() );
+
+ CALL_SUBTEST( check_custom_new_delete<Vector4f>() );
+ CALL_SUBTEST( check_custom_new_delete<Vector2f>() );
+ CALL_SUBTEST( check_custom_new_delete<Matrix4f>() );
+ CALL_SUBTEST( check_custom_new_delete<MatrixXi>() );
}
// check static allocation, who knows ?
diff --git a/test/eigen2/CMakeLists.txt b/test/eigen2/CMakeLists.txt
deleted file mode 100644
index 41a02f4ad..000000000
--- a/test/eigen2/CMakeLists.txt
+++ /dev/null
@@ -1,65 +0,0 @@
-add_custom_target(eigen2_buildtests)
-add_custom_target(eigen2_check COMMAND "ctest -R eigen2")
-add_dependencies(eigen2_check eigen2_buildtests)
-add_dependencies(buildtests eigen2_buildtests)
-
-add_definitions("-DEIGEN2_SUPPORT_STAGE10_FULL_EIGEN2_API")
-
-# Disable unused warnings for this module
-# As EIGEN2 support is deprecated, it is not really worth fixing them
-ei_add_cxx_compiler_flag("-Wno-unused-local-typedefs")
-ei_add_cxx_compiler_flag("-Wno-unused-but-set-variable")
-
-ei_add_test(eigen2_meta)
-ei_add_test(eigen2_sizeof)
-ei_add_test(eigen2_dynalloc)
-ei_add_test(eigen2_nomalloc)
-#ei_add_test(eigen2_first_aligned)
-ei_add_test(eigen2_mixingtypes)
-#ei_add_test(eigen2_packetmath)
-ei_add_test(eigen2_unalignedassert)
-#ei_add_test(eigen2_vectorization_logic)
-ei_add_test(eigen2_basicstuff)
-ei_add_test(eigen2_linearstructure)
-ei_add_test(eigen2_cwiseop)
-ei_add_test(eigen2_sum)
-ei_add_test(eigen2_product_small)
-ei_add_test(eigen2_product_large ${EI_OFLAG})
-ei_add_test(eigen2_adjoint)
-ei_add_test(eigen2_submatrices)
-ei_add_test(eigen2_miscmatrices)
-ei_add_test(eigen2_commainitializer)
-ei_add_test(eigen2_smallvectors)
-ei_add_test(eigen2_map)
-ei_add_test(eigen2_array)
-ei_add_test(eigen2_triangular)
-ei_add_test(eigen2_cholesky " " "${GSL_LIBRARIES}")
-ei_add_test(eigen2_lu ${EI_OFLAG})
-ei_add_test(eigen2_determinant ${EI_OFLAG})
-ei_add_test(eigen2_inverse)
-ei_add_test(eigen2_qr)
-ei_add_test(eigen2_eigensolver " " "${GSL_LIBRARIES}")
-ei_add_test(eigen2_svd)
-ei_add_test(eigen2_geometry)
-ei_add_test(eigen2_geometry_with_eigen2_prefix)
-ei_add_test(eigen2_hyperplane)
-ei_add_test(eigen2_parametrizedline)
-ei_add_test(eigen2_alignedbox)
-ei_add_test(eigen2_regression)
-ei_add_test(eigen2_stdvector)
-ei_add_test(eigen2_newstdvector)
-if(QT4_FOUND)
- ei_add_test(eigen2_qtvector " " "${QT_QTCORE_LIBRARY}")
-endif(QT4_FOUND)
-# no support for eigen2 sparse module
-# if(NOT EIGEN_DEFAULT_TO_ROW_MAJOR)
-# ei_add_test(eigen2_sparse_vector)
-# ei_add_test(eigen2_sparse_basic)
-# ei_add_test(eigen2_sparse_solvers " " "${SPARSE_LIBS}")
-# ei_add_test(eigen2_sparse_product)
-# endif()
-ei_add_test(eigen2_swap)
-ei_add_test(eigen2_visitor)
-ei_add_test(eigen2_bug_132)
-
-ei_add_test(eigen2_prec_inverse_4x4 ${EI_OFLAG})
diff --git a/test/eigen2/eigen2_adjoint.cpp b/test/eigen2/eigen2_adjoint.cpp
deleted file mode 100644
index 8ec9c9202..000000000
--- a/test/eigen2/eigen2_adjoint.cpp
+++ /dev/null
@@ -1,101 +0,0 @@
-// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra. Eigen itself is part of the KDE project.
-//
-// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
-//
-// 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"
-
-template<typename MatrixType> void adjoint(const MatrixType& m)
-{
- /* this test covers the following files:
- Transpose.h Conjugate.h Dot.h
- */
-
- typedef typename MatrixType::Scalar Scalar;
- typedef typename NumTraits<Scalar>::Real RealScalar;
- typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, 1> VectorType;
- typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime> SquareMatrixType;
- int rows = m.rows();
- int cols = m.cols();
-
- RealScalar largerEps = test_precision<RealScalar>();
- if (ei_is_same_type<RealScalar,float>::ret)
- largerEps = RealScalar(1e-3f);
-
- MatrixType m1 = MatrixType::Random(rows, cols),
- m2 = MatrixType::Random(rows, cols),
- m3(rows, cols),
- mzero = MatrixType::Zero(rows, cols),
- identity = SquareMatrixType::Identity(rows, rows),
- square = SquareMatrixType::Random(rows, rows);
- VectorType v1 = VectorType::Random(rows),
- v2 = VectorType::Random(rows),
- v3 = VectorType::Random(rows),
- vzero = VectorType::Zero(rows);
-
- Scalar s1 = ei_random<Scalar>(),
- s2 = ei_random<Scalar>();
-
- // check basic compatibility of adjoint, transpose, conjugate
- VERIFY_IS_APPROX(m1.transpose().conjugate().adjoint(), m1);
- VERIFY_IS_APPROX(m1.adjoint().conjugate().transpose(), m1);
-
- // check multiplicative behavior
- VERIFY_IS_APPROX((m1.adjoint() * m2).adjoint(), m2.adjoint() * m1);
- VERIFY_IS_APPROX((s1 * m1).adjoint(), ei_conj(s1) * m1.adjoint());
-
- // check basic properties of dot, norm, norm2
- typedef typename NumTraits<Scalar>::Real RealScalar;
- VERIFY(ei_isApprox((s1 * v1 + s2 * v2).eigen2_dot(v3), s1 * v1.eigen2_dot(v3) + s2 * v2.eigen2_dot(v3), largerEps));
- VERIFY(ei_isApprox(v3.eigen2_dot(s1 * v1 + s2 * v2), ei_conj(s1)*v3.eigen2_dot(v1)+ei_conj(s2)*v3.eigen2_dot(v2), largerEps));
- VERIFY_IS_APPROX(ei_conj(v1.eigen2_dot(v2)), v2.eigen2_dot(v1));
- VERIFY_IS_APPROX(ei_real(v1.eigen2_dot(v1)), v1.squaredNorm());
- if(NumTraits<Scalar>::HasFloatingPoint)
- VERIFY_IS_APPROX(v1.squaredNorm(), v1.norm() * v1.norm());
- VERIFY_IS_MUCH_SMALLER_THAN(ei_abs(vzero.eigen2_dot(v1)), static_cast<RealScalar>(1));
- if(NumTraits<Scalar>::HasFloatingPoint)
- VERIFY_IS_MUCH_SMALLER_THAN(vzero.norm(), static_cast<RealScalar>(1));
-
- // check compatibility of dot and adjoint
- VERIFY(ei_isApprox(v1.eigen2_dot(square * v2), (square.adjoint() * v1).eigen2_dot(v2), largerEps));
-
- // like in testBasicStuff, test operator() to check const-qualification
- int r = ei_random<int>(0, rows-1),
- c = ei_random<int>(0, cols-1);
- VERIFY_IS_APPROX(m1.conjugate()(r,c), ei_conj(m1(r,c)));
- VERIFY_IS_APPROX(m1.adjoint()(c,r), ei_conj(m1(r,c)));
-
- if(NumTraits<Scalar>::HasFloatingPoint)
- {
- // check that Random().normalized() works: tricky as the random xpr must be evaluated by
- // normalized() in order to produce a consistent result.
- VERIFY_IS_APPROX(VectorType::Random(rows).normalized().norm(), RealScalar(1));
- }
-
- // check inplace transpose
- m3 = m1;
- m3.transposeInPlace();
- VERIFY_IS_APPROX(m3,m1.transpose());
- m3.transposeInPlace();
- VERIFY_IS_APPROX(m3,m1);
-
-}
-
-void test_eigen2_adjoint()
-{
- for(int i = 0; i < g_repeat; i++) {
- CALL_SUBTEST_1( adjoint(Matrix<float, 1, 1>()) );
- CALL_SUBTEST_2( adjoint(Matrix3d()) );
- CALL_SUBTEST_3( adjoint(Matrix4f()) );
- CALL_SUBTEST_4( adjoint(MatrixXcf(4, 4)) );
- CALL_SUBTEST_5( adjoint(MatrixXi(8, 12)) );
- CALL_SUBTEST_6( adjoint(MatrixXf(21, 21)) );
- }
- // test a large matrix only once
- CALL_SUBTEST_7( adjoint(Matrix<float, 100, 100>()) );
-}
-
diff --git a/test/eigen2/eigen2_alignedbox.cpp b/test/eigen2/eigen2_alignedbox.cpp
deleted file mode 100644
index 35043b958..000000000
--- a/test/eigen2/eigen2_alignedbox.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-// 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 <g.gael@free.fr>
-//
-// 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 <Eigen/Geometry>
-#include <Eigen/LU>
-#include <Eigen/QR>
-
-template<typename BoxType> 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<Scalar>::Real RealScalar;
- typedef Matrix<Scalar, BoxType::AmbientDimAtCompileTime, 1> VectorType;
-
- VectorType p0 = VectorType::Random(dim);
- VectorType p1 = VectorType::Random(dim);
- RealScalar s1 = ei_random<RealScalar>(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<Scalar>::type OtherScalar;
- AlignedBox<OtherScalar,Dim> hp1f = b0.template cast<OtherScalar>();
- VERIFY_IS_APPROX(hp1f.template cast<Scalar>(),b0);
- AlignedBox<Scalar,Dim> hp1d = b0.template cast<Scalar>();
- VERIFY_IS_APPROX(hp1d.template cast<Scalar>(),b0);
-}
-
-void test_eigen2_alignedbox()
-{
- for(int i = 0; i < g_repeat; i++) {
- CALL_SUBTEST_1( alignedbox(AlignedBox<float,2>()) );
- CALL_SUBTEST_2( alignedbox(AlignedBox<float,3>()) );
- CALL_SUBTEST_3( alignedbox(AlignedBox<double,4>()) );
- }
-}
diff --git a/test/eigen2/eigen2_array.cpp b/test/eigen2/eigen2_array.cpp
deleted file mode 100644
index c1ff40ce7..000000000
--- a/test/eigen2/eigen2_array.cpp
+++ /dev/null
@@ -1,142 +0,0 @@
-// 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 <g.gael@free.fr>
-//
-// 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 <Eigen/Array>
-
-template<typename MatrixType> void array(const MatrixType& m)
-{
- /* this test covers the following files:
- Array.cpp
- */
-
- typedef typename MatrixType::Scalar Scalar;
- typedef typename NumTraits<Scalar>::Real RealScalar;
- typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, 1> VectorType;
-
- int rows = m.rows();
- int cols = m.cols();
-
- MatrixType m1 = MatrixType::Random(rows, cols),
- m2 = MatrixType::Random(rows, cols),
- m3(rows, cols);
-
- Scalar s1 = ei_random<Scalar>(),
- s2 = ei_random<Scalar>();
-
- // scalar addition
- VERIFY_IS_APPROX(m1.cwise() + s1, s1 + m1.cwise());
- VERIFY_IS_APPROX(m1.cwise() + s1, MatrixType::Constant(rows,cols,s1) + m1);
- VERIFY_IS_APPROX((m1*Scalar(2)).cwise() - s2, (m1+m1) - MatrixType::Constant(rows,cols,s2) );
- m3 = m1;
- m3.cwise() += s2;
- VERIFY_IS_APPROX(m3, m1.cwise() + s2);
- m3 = m1;
- m3.cwise() -= s1;
- VERIFY_IS_APPROX(m3, m1.cwise() - s1);
-
- // reductions
- VERIFY_IS_APPROX(m1.colwise().sum().sum(), m1.sum());
- VERIFY_IS_APPROX(m1.rowwise().sum().sum(), m1.sum());
- if (!ei_isApprox(m1.sum(), (m1+m2).sum()))
- VERIFY_IS_NOT_APPROX(((m1+m2).rowwise().sum()).sum(), m1.sum());
- VERIFY_IS_APPROX(m1.colwise().sum(), m1.colwise().redux(internal::scalar_sum_op<Scalar>()));
-}
-
-template<typename MatrixType> void comparisons(const MatrixType& m)
-{
- typedef typename MatrixType::Scalar Scalar;
- typedef typename NumTraits<Scalar>::Real RealScalar;
- typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, 1> VectorType;
-
- int rows = m.rows();
- int cols = m.cols();
-
- int r = ei_random<int>(0, rows-1),
- c = ei_random<int>(0, cols-1);
-
- MatrixType m1 = MatrixType::Random(rows, cols),
- m2 = MatrixType::Random(rows, cols),
- m3(rows, cols);
-
- VERIFY(((m1.cwise() + Scalar(1)).cwise() > m1).all());
- VERIFY(((m1.cwise() - Scalar(1)).cwise() < m1).all());
- if (rows*cols>1)
- {
- m3 = m1;
- m3(r,c) += 1;
- VERIFY(! (m1.cwise() < m3).all() );
- VERIFY(! (m1.cwise() > m3).all() );
- }
-
- // comparisons to scalar
- VERIFY( (m1.cwise() != (m1(r,c)+1) ).any() );
- VERIFY( (m1.cwise() > (m1(r,c)-1) ).any() );
- VERIFY( (m1.cwise() < (m1(r,c)+1) ).any() );
- VERIFY( (m1.cwise() == m1(r,c) ).any() );
-
- // test Select
- VERIFY_IS_APPROX( (m1.cwise()<m2).select(m1,m2), m1.cwise().min(m2) );
- VERIFY_IS_APPROX( (m1.cwise()>m2).select(m1,m2), m1.cwise().max(m2) );
- Scalar mid = (m1.cwise().abs().minCoeff() + m1.cwise().abs().maxCoeff())/Scalar(2);
- for (int j=0; j<cols; ++j)
- for (int i=0; i<rows; ++i)
- m3(i,j) = ei_abs(m1(i,j))<mid ? 0 : m1(i,j);
- VERIFY_IS_APPROX( (m1.cwise().abs().cwise()<MatrixType::Constant(rows,cols,mid))
- .select(MatrixType::Zero(rows,cols),m1), m3);
- // shorter versions:
- VERIFY_IS_APPROX( (m1.cwise().abs().cwise()<MatrixType::Constant(rows,cols,mid))
- .select(0,m1), m3);
- VERIFY_IS_APPROX( (m1.cwise().abs().cwise()>=MatrixType::Constant(rows,cols,mid))
- .select(m1,0), m3);
- // even shorter version:
- VERIFY_IS_APPROX( (m1.cwise().abs().cwise()<mid).select(0,m1), m3);
-
- // count
- VERIFY(((m1.cwise().abs().cwise()+1).cwise()>RealScalar(0.1)).count() == rows*cols);
- VERIFY_IS_APPROX(((m1.cwise().abs().cwise()+1).cwise()>RealScalar(0.1)).colwise().count().template cast<int>(), RowVectorXi::Constant(cols,rows));
- VERIFY_IS_APPROX(((m1.cwise().abs().cwise()+1).cwise()>RealScalar(0.1)).rowwise().count().template cast<int>(), VectorXi::Constant(rows, cols));
-}
-
-template<typename VectorType> void lpNorm(const VectorType& v)
-{
- VectorType u = VectorType::Random(v.size());
-
- VERIFY_IS_APPROX(u.template lpNorm<Infinity>(), u.cwise().abs().maxCoeff());
- VERIFY_IS_APPROX(u.template lpNorm<1>(), u.cwise().abs().sum());
- VERIFY_IS_APPROX(u.template lpNorm<2>(), ei_sqrt(u.cwise().abs().cwise().square().sum()));
- VERIFY_IS_APPROX(ei_pow(u.template lpNorm<5>(), typename VectorType::RealScalar(5)), u.cwise().abs().cwise().pow(5).sum());
-}
-
-void test_eigen2_array()
-{
- for(int i = 0; i < g_repeat; i++) {
- CALL_SUBTEST_1( array(Matrix<float, 1, 1>()) );
- CALL_SUBTEST_2( array(Matrix2f()) );
- CALL_SUBTEST_3( array(Matrix4d()) );
- CALL_SUBTEST_4( array(MatrixXcf(3, 3)) );
- CALL_SUBTEST_5( array(MatrixXf(8, 12)) );
- CALL_SUBTEST_6( array(MatrixXi(8, 12)) );
- }
- for(int i = 0; i < g_repeat; i++) {
- CALL_SUBTEST_1( comparisons(Matrix<float, 1, 1>()) );
- CALL_SUBTEST_2( comparisons(Matrix2f()) );
- CALL_SUBTEST_3( comparisons(Matrix4d()) );
- CALL_SUBTEST_5( comparisons(MatrixXf(8, 12)) );
- CALL_SUBTEST_6( comparisons(MatrixXi(8, 12)) );
- }
- for(int i = 0; i < g_repeat; i++) {
- CALL_SUBTEST_1( lpNorm(Matrix<float, 1, 1>()) );
- CALL_SUBTEST_2( lpNorm(Vector2f()) );
- CALL_SUBTEST_3( lpNorm(Vector3d()) );
- CALL_SUBTEST_4( lpNorm(Vector4f()) );
- CALL_SUBTEST_5( lpNorm(VectorXf(16)) );
- CALL_SUBTEST_7( lpNorm(VectorXcd(10)) );
- }
-}
diff --git a/test/eigen2/eigen2_basicstuff.cpp b/test/eigen2/eigen2_basicstuff.cpp
deleted file mode 100644
index 4fa16d5ae..000000000
--- a/test/eigen2/eigen2_basicstuff.cpp
+++ /dev/null
@@ -1,108 +0,0 @@
-// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra. Eigen itself is part of the KDE project.
-//
-// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
-//
-// 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"
-
-template<typename MatrixType> void basicStuff(const MatrixType& m)
-{
- typedef typename MatrixType::Scalar Scalar;
- typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, 1> VectorType;
-
- int rows = m.rows();
- int cols = m.cols();
-
- // this test relies a lot on Random.h, and there's not much more that we can do
- // to test it, hence I consider that we will have tested Random.h
- MatrixType m1 = MatrixType::Random(rows, cols),
- m2 = MatrixType::Random(rows, cols),
- m3(rows, cols),
- mzero = MatrixType::Zero(rows, cols),
- identity = Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime>
- ::Identity(rows, rows),
- square = Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime>::Random(rows, rows);
- VectorType v1 = VectorType::Random(rows),
- v2 = VectorType::Random(rows),
- vzero = VectorType::Zero(rows);
-
- Scalar x = ei_random<Scalar>();
-
- int r = ei_random<int>(0, rows-1),
- c = ei_random<int>(0, cols-1);
-
- m1.coeffRef(r,c) = x;
- VERIFY_IS_APPROX(x, m1.coeff(r,c));
- m1(r,c) = x;
- VERIFY_IS_APPROX(x, m1(r,c));
- v1.coeffRef(r) = x;
- VERIFY_IS_APPROX(x, v1.coeff(r));
- v1(r) = x;
- VERIFY_IS_APPROX(x, v1(r));
- v1[r] = x;
- VERIFY_IS_APPROX(x, v1[r]);
-
- VERIFY_IS_APPROX( v1, v1);
- VERIFY_IS_NOT_APPROX( v1, 2*v1);
- VERIFY_IS_MUCH_SMALLER_THAN( vzero, v1);
- if(NumTraits<Scalar>::HasFloatingPoint)
- VERIFY_IS_MUCH_SMALLER_THAN( vzero, v1.norm());
- VERIFY_IS_NOT_MUCH_SMALLER_THAN(v1, v1);
- VERIFY_IS_APPROX( vzero, v1-v1);
- VERIFY_IS_APPROX( m1, m1);
- VERIFY_IS_NOT_APPROX( m1, 2*m1);
- VERIFY_IS_MUCH_SMALLER_THAN( mzero, m1);
- VERIFY_IS_NOT_MUCH_SMALLER_THAN(m1, m1);
- VERIFY_IS_APPROX( mzero, m1-m1);
-
- // always test operator() on each read-only expression class,
- // in order to check const-qualifiers.
- // indeed, if an expression class (here Zero) is meant to be read-only,
- // hence has no _write() method, the corresponding MatrixBase method (here zero())
- // should return a const-qualified object so that it is the const-qualified
- // operator() that gets called, which in turn calls _read().
- VERIFY_IS_MUCH_SMALLER_THAN(MatrixType::Zero(rows,cols)(r,c), static_cast<Scalar>(1));
-
- // now test copying a row-vector into a (column-)vector and conversely.
- square.col(r) = square.row(r).eval();
- Matrix<Scalar, 1, MatrixType::RowsAtCompileTime> rv(rows);
- Matrix<Scalar, MatrixType::RowsAtCompileTime, 1> cv(rows);
- rv = square.row(r);
- cv = square.col(r);
- VERIFY_IS_APPROX(rv, cv.transpose());
-
- if(cols!=1 && rows!=1 && MatrixType::SizeAtCompileTime!=Dynamic)
- {
- VERIFY_RAISES_ASSERT(m1 = (m2.block(0,0, rows-1, cols-1)));
- }
-
- VERIFY_IS_APPROX(m3 = m1,m1);
- MatrixType m4;
- VERIFY_IS_APPROX(m4 = m1,m1);
-
- // test swap
- m3 = m1;
- m1.swap(m2);
- VERIFY_IS_APPROX(m3, m2);
- if(rows*cols>=3)
- {
- VERIFY_IS_NOT_APPROX(m3, m1);
- }
-}
-
-void test_eigen2_basicstuff()
-{
- for(int i = 0; i < g_repeat; i++) {
- CALL_SUBTEST_1( basicStuff(Matrix<float, 1, 1>()) );
- CALL_SUBTEST_2( basicStuff(Matrix4d()) );
- CALL_SUBTEST_3( basicStuff(MatrixXcf(3, 3)) );
- CALL_SUBTEST_4( basicStuff(MatrixXi(8, 12)) );
- CALL_SUBTEST_5( basicStuff(MatrixXcd(20, 20)) );
- CALL_SUBTEST_6( basicStuff(Matrix<float, 100, 100>()) );
- CALL_SUBTEST_7( basicStuff(Matrix<long double,Dynamic,Dynamic>(10,10)) );
- }
-}
diff --git a/test/eigen2/eigen2_bug_132.cpp b/test/eigen2/eigen2_bug_132.cpp
deleted file mode 100644
index 7fe3610ce..000000000
--- a/test/eigen2/eigen2_bug_132.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra. Eigen itself is part of the KDE project.
-//
-// Copyright (C) 2010 Benoit Jacob <jacob.benoit.1@gmail.com>
-//
-// 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"
-
-void test_eigen2_bug_132() {
- int size = 100;
- MatrixXd A(size, size);
- VectorXd b(size), c(size);
- {
- VectorXd y = A.transpose() * (b-c); // bug 132: infinite recursion in coeffRef
- VectorXd z = (b-c).transpose() * A; // bug 132: infinite recursion in coeffRef
- }
-
- // the following ones weren't failing, but let's include them for completeness:
- {
- VectorXd y = A * (b-c);
- VectorXd z = (b-c).transpose() * A.transpose();
- }
-}
diff --git a/test/eigen2/eigen2_cholesky.cpp b/test/eigen2/eigen2_cholesky.cpp
deleted file mode 100644
index 9c4b6f561..000000000
--- a/test/eigen2/eigen2_cholesky.cpp
+++ /dev/null
@@ -1,113 +0,0 @@
-// 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 <g.gael@free.fr>
-//
-// 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/.
-
-#define EIGEN_NO_ASSERTION_CHECKING
-#include "main.h"
-#include <Eigen/Cholesky>
-#include <Eigen/LU>
-
-#ifdef HAS_GSL
-#include "gsl_helper.h"
-#endif
-
-template<typename MatrixType> void cholesky(const MatrixType& m)
-{
- /* this test covers the following files:
- LLT.h LDLT.h
- */
- int rows = m.rows();
- int cols = m.cols();
-
- typedef typename MatrixType::Scalar Scalar;
- typedef typename NumTraits<Scalar>::Real RealScalar;
- typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime> SquareMatrixType;
- typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, 1> VectorType;
-
- MatrixType a0 = MatrixType::Random(rows,cols);
- VectorType vecB = VectorType::Random(rows), vecX(rows);
- MatrixType matB = MatrixType::Random(rows,cols), matX(rows,cols);
- SquareMatrixType symm = a0 * a0.adjoint();
- // let's make sure the matrix is not singular or near singular
- MatrixType a1 = MatrixType::Random(rows,cols);
- symm += a1 * a1.adjoint();
-
- #ifdef HAS_GSL
- if (ei_is_same_type<RealScalar,double>::ret)
- {
- typedef GslTraits<Scalar> Gsl;
- typename Gsl::Matrix gMatA=0, gSymm=0;
- typename Gsl::Vector gVecB=0, gVecX=0;
- convert<MatrixType>(symm, gSymm);
- convert<MatrixType>(symm, gMatA);
- convert<VectorType>(vecB, gVecB);
- convert<VectorType>(vecB, gVecX);
- Gsl::cholesky(gMatA);
- Gsl::cholesky_solve(gMatA, gVecB, gVecX);
- VectorType vecX(rows), _vecX, _vecB;
- convert(gVecX, _vecX);
- symm.llt().solve(vecB, &vecX);
- Gsl::prod(gSymm, gVecX, gVecB);
- convert(gVecB, _vecB);
- // test gsl itself !
- VERIFY_IS_APPROX(vecB, _vecB);
- VERIFY_IS_APPROX(vecX, _vecX);
-
- Gsl::free(gMatA);
- Gsl::free(gSymm);
- Gsl::free(gVecB);
- Gsl::free(gVecX);
- }
- #endif
-
- {
- LDLT<SquareMatrixType> ldlt(symm);
- VERIFY(ldlt.isPositiveDefinite());
- // in eigen3, LDLT is pivoting
- //VERIFY_IS_APPROX(symm, ldlt.matrixL() * ldlt.vectorD().asDiagonal() * ldlt.matrixL().adjoint());
- ldlt.solve(vecB, &vecX);
- VERIFY_IS_APPROX(symm * vecX, vecB);
- ldlt.solve(matB, &matX);
- VERIFY_IS_APPROX(symm * matX, matB);
- }
-
- {
- LLT<SquareMatrixType> chol(symm);
- VERIFY(chol.isPositiveDefinite());
- VERIFY_IS_APPROX(symm, chol.matrixL() * chol.matrixL().adjoint());
- chol.solve(vecB, &vecX);
- VERIFY_IS_APPROX(symm * vecX, vecB);
- chol.solve(matB, &matX);
- VERIFY_IS_APPROX(symm * matX, matB);
- }
-
-#if 0 // cholesky is not rank-revealing anyway
- // test isPositiveDefinite on non definite matrix
- if (rows>4)
- {
- SquareMatrixType symm = a0.block(0,0,rows,cols-4) * a0.block(0,0,rows,cols-4).adjoint();
- LLT<SquareMatrixType> chol(symm);
- VERIFY(!chol.isPositiveDefinite());
- LDLT<SquareMatrixType> cholnosqrt(symm);
- VERIFY(!cholnosqrt.isPositiveDefinite());
- }
-#endif
-}
-
-void test_eigen2_cholesky()
-{
- for(int i = 0; i < g_repeat; i++) {
- CALL_SUBTEST_1( cholesky(Matrix<double,1,1>()) );
- CALL_SUBTEST_2( cholesky(Matrix2d()) );
- CALL_SUBTEST_3( cholesky(Matrix3f()) );
- CALL_SUBTEST_4( cholesky(Matrix4d()) );
- CALL_SUBTEST_5( cholesky(MatrixXcd(7,7)) );
- CALL_SUBTEST_6( cholesky(MatrixXf(17,17)) );
- CALL_SUBTEST_7( cholesky(MatrixXd(33,33)) );
- }
-}
diff --git a/test/eigen2/eigen2_commainitializer.cpp b/test/eigen2/eigen2_commainitializer.cpp
deleted file mode 100644
index e0f901e0b..000000000
--- a/test/eigen2/eigen2_commainitializer.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-// 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 <g.gael@free.fr>
-//
-// 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"
-
-void test_eigen2_commainitializer()
-{
- Matrix3d m3;
- Matrix4d m4;
-
- VERIFY_RAISES_ASSERT( (m3 << 1, 2, 3, 4, 5, 6, 7, 8) );
-
- #ifndef _MSC_VER
- VERIFY_RAISES_ASSERT( (m3 << 1, 2, 3, 4, 5, 6, 7, 8, 9, 10) );
- #endif
-
- double data[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
- Matrix3d ref = Map<Matrix<double,3,3,RowMajor> >(data);
-
- m3 = Matrix3d::Random();
- m3 << 1, 2, 3, 4, 5, 6, 7, 8, 9;
- VERIFY_IS_APPROX(m3, ref );
-
- Vector3d vec[3];
- vec[0] << 1, 4, 7;
- vec[1] << 2, 5, 8;
- vec[2] << 3, 6, 9;
- m3 = Matrix3d::Random();
- m3 << vec[0], vec[1], vec[2];
- VERIFY_IS_APPROX(m3, ref);
-
- vec[0] << 1, 2, 3;
- vec[1] << 4, 5, 6;
- vec[2] << 7, 8, 9;
- m3 = Matrix3d::Random();
- m3 << vec[0].transpose(),
- 4, 5, 6,
- vec[2].transpose();
- VERIFY_IS_APPROX(m3, ref);
-}
diff --git a/test/eigen2/eigen2_cwiseop.cpp b/test/eigen2/eigen2_cwiseop.cpp
deleted file mode 100644
index 4391d19b4..000000000
--- a/test/eigen2/eigen2_cwiseop.cpp
+++ /dev/null
@@ -1,158 +0,0 @@
-// 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 <g.gael@free.fr>
-// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
-//
-// 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 <functional>
-#include <Eigen/Array>
-
-using namespace std;
-
-template<typename Scalar> struct AddIfNull {
- const Scalar operator() (const Scalar a, const Scalar b) const {return a<=1e-3 ? b : a;}
- enum { Cost = NumTraits<Scalar>::AddCost };
-};
-
-template<typename MatrixType> void cwiseops(const MatrixType& m)
-{
- typedef typename MatrixType::Scalar Scalar;
- typedef typename NumTraits<Scalar>::Real RealScalar;
- typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, 1> VectorType;
-
- int rows = m.rows();
- int cols = m.cols();
-
- MatrixType m1 = MatrixType::Random(rows, cols),
- m2 = MatrixType::Random(rows, cols),
- m3(rows, cols),
- m4(rows, cols),
- mzero = MatrixType::Zero(rows, cols),
- mones = MatrixType::Ones(rows, cols),
- identity = Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime>
- ::Identity(rows, rows),
- square = Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime>::Random(rows, rows);
- VectorType v1 = VectorType::Random(rows),
- v2 = VectorType::Random(rows),
- vzero = VectorType::Zero(rows),
- vones = VectorType::Ones(rows),
- v3(rows);
-
- int r = ei_random<int>(0, rows-1),
- c = ei_random<int>(0, cols-1);
-
- Scalar s1 = ei_random<Scalar>();
-
- // test Zero, Ones, Constant, and the set* variants
- m3 = MatrixType::Constant(rows, cols, s1);
- for (int j=0; j<cols; ++j)
- for (int i=0; i<rows; ++i)
- {
- VERIFY_IS_APPROX(mzero(i,j), Scalar(0));
- VERIFY_IS_APPROX(mones(i,j), Scalar(1));
- VERIFY_IS_APPROX(m3(i,j), s1);
- }
- VERIFY(mzero.isZero());
- VERIFY(mones.isOnes());
- VERIFY(m3.isConstant(s1));
- VERIFY(identity.isIdentity());
- VERIFY_IS_APPROX(m4.setConstant(s1), m3);
- VERIFY_IS_APPROX(m4.setConstant(rows,cols,s1), m3);
- VERIFY_IS_APPROX(m4.setZero(), mzero);
- VERIFY_IS_APPROX(m4.setZero(rows,cols), mzero);
- VERIFY_IS_APPROX(m4.setOnes(), mones);
- VERIFY_IS_APPROX(m4.setOnes(rows,cols), mones);
- m4.fill(s1);
- VERIFY_IS_APPROX(m4, m3);
-
- VERIFY_IS_APPROX(v3.setConstant(rows, s1), VectorType::Constant(rows,s1));
- VERIFY_IS_APPROX(v3.setZero(rows), vzero);
- VERIFY_IS_APPROX(v3.setOnes(rows), vones);
-
- m2 = m2.template binaryExpr<AddIfNull<Scalar> >(mones);
-
- VERIFY_IS_APPROX(m1.cwise().pow(2), m1.cwise().abs2());
- VERIFY_IS_APPROX(m1.cwise().pow(2), m1.cwise().square());
- VERIFY_IS_APPROX(m1.cwise().pow(3), m1.cwise().cube());
-
- VERIFY_IS_APPROX(m1 + mones, m1.cwise()+Scalar(1));
- VERIFY_IS_APPROX(m1 - mones, m1.cwise()-Scalar(1));
- m3 = m1; m3.cwise() += 1;
- VERIFY_IS_APPROX(m1 + mones, m3);
- m3 = m1; m3.cwise() -= 1;
- VERIFY_IS_APPROX(m1 - mones, m3);
-
- VERIFY_IS_APPROX(m2, m2.cwise() * mones);
- VERIFY_IS_APPROX(m1.cwise() * m2, m2.cwise() * m1);
- m3 = m1;
- m3.cwise() *= m2;
- VERIFY_IS_APPROX(m3, m1.cwise() * m2);
-
- VERIFY_IS_APPROX(mones, m2.cwise()/m2);
- if(NumTraits<Scalar>::HasFloatingPoint)
- {
- VERIFY_IS_APPROX(m1.cwise() / m2, m1.cwise() * (m2.cwise().inverse()));
- m3 = m1.cwise().abs().cwise().sqrt();
- VERIFY_IS_APPROX(m3.cwise().square(), m1.cwise().abs());
- VERIFY_IS_APPROX(m1.cwise().square().cwise().sqrt(), m1.cwise().abs());
- VERIFY_IS_APPROX(m1.cwise().abs().cwise().log().cwise().exp() , m1.cwise().abs());
-
- VERIFY_IS_APPROX(m1.cwise().pow(2), m1.cwise().square());
- m3 = (m1.cwise().abs().cwise()<=RealScalar(0.01)).select(mones,m1);
- VERIFY_IS_APPROX(m3.cwise().pow(-1), m3.cwise().inverse());
- m3 = m1.cwise().abs();
- VERIFY_IS_APPROX(m3.cwise().pow(RealScalar(0.5)), m3.cwise().sqrt());
-
-// VERIFY_IS_APPROX(m1.cwise().tan(), m1.cwise().sin().cwise() / m1.cwise().cos());
- VERIFY_IS_APPROX(mones, m1.cwise().sin().cwise().square() + m1.cwise().cos().cwise().square());
- m3 = m1;
- m3.cwise() /= m2;
- VERIFY_IS_APPROX(m3, m1.cwise() / m2);
- }
-
- // check min
- VERIFY_IS_APPROX( m1.cwise().min(m2), m2.cwise().min(m1) );
- VERIFY_IS_APPROX( m1.cwise().min(m1+mones), m1 );
- VERIFY_IS_APPROX( m1.cwise().min(m1-mones), m1-mones );
-
- // check max
- VERIFY_IS_APPROX( m1.cwise().max(m2), m2.cwise().max(m1) );
- VERIFY_IS_APPROX( m1.cwise().max(m1-mones), m1 );
- VERIFY_IS_APPROX( m1.cwise().max(m1+mones), m1+mones );
-
- VERIFY( (m1.cwise() == m1).all() );
- VERIFY( (m1.cwise() != m2).any() );
- VERIFY(!(m1.cwise() == (m1+mones)).any() );
- if (rows*cols>1)
- {
- m3 = m1;
- m3(r,c) += 1;
- VERIFY( (m1.cwise() == m3).any() );
- VERIFY( !(m1.cwise() == m3).all() );
- }
- VERIFY( (m1.cwise().min(m2).cwise() <= m2).all() );
- VERIFY( (m1.cwise().max(m2).cwise() >= m2).all() );
- VERIFY( (m1.cwise().min(m2).cwise() < (m1+mones)).all() );
- VERIFY( (m1.cwise().max(m2).cwise() > (m1-mones)).all() );
-
- VERIFY( (m1.cwise()<m1.unaryExpr(bind2nd(plus<Scalar>(), Scalar(1)))).all() );
- VERIFY( !(m1.cwise()<m1.unaryExpr(bind2nd(minus<Scalar>(), Scalar(1)))).all() );
- VERIFY( !(m1.cwise()>m1.unaryExpr(bind2nd(plus<Scalar>(), Scalar(1)))).any() );
-}
-
-void test_eigen2_cwiseop()
-{
- for(int i = 0; i < g_repeat ; i++) {
- CALL_SUBTEST_1( cwiseops(Matrix<float, 1, 1>()) );
- CALL_SUBTEST_2( cwiseops(Matrix4d()) );
- CALL_SUBTEST_3( cwiseops(MatrixXf(3, 3)) );
- CALL_SUBTEST_3( cwiseops(MatrixXf(22, 22)) );
- CALL_SUBTEST_4( cwiseops(MatrixXi(8, 12)) );
- CALL_SUBTEST_5( cwiseops(MatrixXd(20, 20)) );
- }
-}
diff --git a/test/eigen2/eigen2_determinant.cpp b/test/eigen2/eigen2_determinant.cpp
deleted file mode 100644
index c7b4ad053..000000000
--- a/test/eigen2/eigen2_determinant.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-// 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 Benoit Jacob <jacob.benoit.1@gmail.com>
-// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
-//
-// 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 <Eigen/LU>
-
-template<typename MatrixType> void determinant(const MatrixType& m)
-{
- /* this test covers the following files:
- Determinant.h
- */
- int size = m.rows();
-
- MatrixType m1(size, size), m2(size, size);
- m1.setRandom();
- m2.setRandom();
- typedef typename MatrixType::Scalar Scalar;
- Scalar x = ei_random<Scalar>();
- VERIFY_IS_APPROX(MatrixType::Identity(size, size).determinant(), Scalar(1));
- VERIFY_IS_APPROX((m1*m2).determinant(), m1.determinant() * m2.determinant());
- if(size==1) return;
- int i = ei_random<int>(0, size-1);
- int j;
- do {
- j = ei_random<int>(0, size-1);
- } while(j==i);
- m2 = m1;
- m2.row(i).swap(m2.row(j));
- VERIFY_IS_APPROX(m2.determinant(), -m1.determinant());
- m2 = m1;
- m2.col(i).swap(m2.col(j));
- VERIFY_IS_APPROX(m2.determinant(), -m1.determinant());
- VERIFY_IS_APPROX(m2.determinant(), m2.transpose().determinant());
- VERIFY_IS_APPROX(ei_conj(m2.determinant()), m2.adjoint().determinant());
- m2 = m1;
- m2.row(i) += x*m2.row(j);
- VERIFY_IS_APPROX(m2.determinant(), m1.determinant());
- m2 = m1;
- m2.row(i) *= x;
- VERIFY_IS_APPROX(m2.determinant(), m1.determinant() * x);
-}
-
-void test_eigen2_determinant()
-{
- for(int i = 0; i < g_repeat; i++) {
- CALL_SUBTEST_1( determinant(Matrix<float, 1, 1>()) );
- CALL_SUBTEST_2( determinant(Matrix<double, 2, 2>()) );
- CALL_SUBTEST_3( determinant(Matrix<double, 3, 3>()) );
- CALL_SUBTEST_4( determinant(Matrix<double, 4, 4>()) );
- CALL_SUBTEST_5( determinant(Matrix<std::complex<double>, 10, 10>()) );
- CALL_SUBTEST_6( determinant(MatrixXd(20, 20)) );
- }
- CALL_SUBTEST_6( determinant(MatrixXd(200, 200)) );
-}
diff --git a/test/eigen2/eigen2_dynalloc.cpp b/test/eigen2/eigen2_dynalloc.cpp
deleted file mode 100644
index 1891a9e33..000000000
--- a/test/eigen2/eigen2_dynalloc.cpp
+++ /dev/null
@@ -1,131 +0,0 @@
-// 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 <g.gael@free.fr>
-//
-// 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"
-
-#if EIGEN_ARCH_WANTS_ALIGNMENT
-#define ALIGNMENT 16
-#else
-#define ALIGNMENT 1
-#endif
-
-void check_handmade_aligned_malloc()
-{
- for(int i = 1; i < 1000; i++)
- {
- char *p = (char*)ei_handmade_aligned_malloc(i);
- VERIFY(std::size_t(p)%ALIGNMENT==0);
- // if the buffer is wrongly allocated this will give a bad write --> check with valgrind
- for(int j = 0; j < i; j++) p[j]=0;
- ei_handmade_aligned_free(p);
- }
-}
-
-void check_aligned_malloc()
-{
- for(int i = 1; i < 1000; i++)
- {
- char *p = (char*)ei_aligned_malloc(i);
- VERIFY(std::size_t(p)%ALIGNMENT==0);
- // if the buffer is wrongly allocated this will give a bad write --> check with valgrind
- for(int j = 0; j < i; j++) p[j]=0;
- ei_aligned_free(p);
- }
-}
-
-void check_aligned_new()
-{
- for(int i = 1; i < 1000; i++)
- {
- float *p = ei_aligned_new<float>(i);
- VERIFY(std::size_t(p)%ALIGNMENT==0);
- // if the buffer is wrongly allocated this will give a bad write --> check with valgrind
- for(int j = 0; j < i; j++) p[j]=0;
- ei_aligned_delete(p,i);
- }
-}
-
-void check_aligned_stack_alloc()
-{
- for(int i = 1; i < 1000; i++)
- {
- ei_declare_aligned_stack_constructed_variable(float, p, i, 0);
- VERIFY(std::size_t(p)%ALIGNMENT==0);
- // if the buffer is wrongly allocated this will give a bad write --> check with valgrind
- for(int j = 0; j < i; j++) p[j]=0;
- }
-}
-
-
-// test compilation with both a struct and a class...
-struct MyStruct
-{
- EIGEN_MAKE_ALIGNED_OPERATOR_NEW
- char dummychar;
- Vector4f avec;
-};
-
-class MyClassA
-{
- public:
- EIGEN_MAKE_ALIGNED_OPERATOR_NEW
- char dummychar;
- Vector4f avec;
-};
-
-template<typename T> void check_dynaligned()
-{
- T* obj = new T;
- VERIFY(std::size_t(obj)%ALIGNMENT==0);
- delete obj;
-}
-
-void test_eigen2_dynalloc()
-{
- // low level dynamic memory allocation
- CALL_SUBTEST(check_handmade_aligned_malloc());
- CALL_SUBTEST(check_aligned_malloc());
- CALL_SUBTEST(check_aligned_new());
- CALL_SUBTEST(check_aligned_stack_alloc());
-
- for (int i=0; i<g_repeat*100; ++i)
- {
- CALL_SUBTEST( check_dynaligned<Vector4f>() );
- CALL_SUBTEST( check_dynaligned<Vector2d>() );
- CALL_SUBTEST( check_dynaligned<Matrix4f>() );
- CALL_SUBTEST( check_dynaligned<Vector4d>() );
- CALL_SUBTEST( check_dynaligned<Vector4i>() );
- }
-
- // check static allocation, who knows ?
- {
- MyStruct foo0; VERIFY(std::size_t(foo0.avec.data())%ALIGNMENT==0);
- MyClassA fooA; VERIFY(std::size_t(fooA.avec.data())%ALIGNMENT==0);
- }
-
- // dynamic allocation, single object
- for (int i=0; i<g_repeat*100; ++i)
- {
- MyStruct *foo0 = new MyStruct(); VERIFY(std::size_t(foo0->avec.data())%ALIGNMENT==0);
- MyClassA *fooA = new MyClassA(); VERIFY(std::size_t(fooA->avec.data())%ALIGNMENT==0);
- delete foo0;
- delete fooA;
- }
-
- // dynamic allocation, array
- const int N = 10;
- for (int i=0; i<g_repeat*100; ++i)
- {
- MyStruct *foo0 = new MyStruct[N]; VERIFY(std::size_t(foo0->avec.data())%ALIGNMENT==0);
- MyClassA *fooA = new MyClassA[N]; VERIFY(std::size_t(fooA->avec.data())%ALIGNMENT==0);
- delete[] foo0;
- delete[] fooA;
- }
-
-}
diff --git a/test/eigen2/eigen2_eigensolver.cpp b/test/eigen2/eigen2_eigensolver.cpp
deleted file mode 100644
index 48b4ace43..000000000
--- a/test/eigen2/eigen2_eigensolver.cpp
+++ /dev/null
@@ -1,146 +0,0 @@
-// 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 <g.gael@free.fr>
-//
-// 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 <Eigen/QR>
-
-#ifdef HAS_GSL
-#include "gsl_helper.h"
-#endif
-
-template<typename MatrixType> void selfadjointeigensolver(const MatrixType& m)
-{
- /* this test covers the following files:
- EigenSolver.h, SelfAdjointEigenSolver.h (and indirectly: Tridiagonalization.h)
- */
- int rows = m.rows();
- int cols = m.cols();
-
- typedef typename MatrixType::Scalar Scalar;
- typedef typename NumTraits<Scalar>::Real RealScalar;
- typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, 1> VectorType;
- typedef Matrix<RealScalar, MatrixType::RowsAtCompileTime, 1> RealVectorType;
- typedef typename std::complex<typename NumTraits<typename MatrixType::Scalar>::Real> Complex;
-
- RealScalar largerEps = 10*test_precision<RealScalar>();
-
- MatrixType a = MatrixType::Random(rows,cols);
- MatrixType a1 = MatrixType::Random(rows,cols);
- MatrixType symmA = a.adjoint() * a + a1.adjoint() * a1;
-
- MatrixType b = MatrixType::Random(rows,cols);
- MatrixType b1 = MatrixType::Random(rows,cols);
- MatrixType symmB = b.adjoint() * b + b1.adjoint() * b1;
-
- SelfAdjointEigenSolver<MatrixType> eiSymm(symmA);
- // generalized eigen pb
- SelfAdjointEigenSolver<MatrixType> eiSymmGen(symmA, symmB);
-
- #ifdef HAS_GSL
- if (ei_is_same_type<RealScalar,double>::ret)
- {
- typedef GslTraits<Scalar> Gsl;
- typename Gsl::Matrix gEvec=0, gSymmA=0, gSymmB=0;
- typename GslTraits<RealScalar>::Vector gEval=0;
- RealVectorType _eval;
- MatrixType _evec;
- convert<MatrixType>(symmA, gSymmA);
- convert<MatrixType>(symmB, gSymmB);
- convert<MatrixType>(symmA, gEvec);
- gEval = GslTraits<RealScalar>::createVector(rows);
-
- Gsl::eigen_symm(gSymmA, gEval, gEvec);
- convert(gEval, _eval);
- convert(gEvec, _evec);
-
- // test gsl itself !
- VERIFY((symmA * _evec).isApprox(_evec * _eval.asDiagonal(), largerEps));
-
- // compare with eigen
- VERIFY_IS_APPROX(_eval, eiSymm.eigenvalues());
- VERIFY_IS_APPROX(_evec.cwise().abs(), eiSymm.eigenvectors().cwise().abs());
-
- // generalized pb
- Gsl::eigen_symm_gen(gSymmA, gSymmB, gEval, gEvec);
- convert(gEval, _eval);
- convert(gEvec, _evec);
- // test GSL itself:
- VERIFY((symmA * _evec).isApprox(symmB * (_evec * _eval.asDiagonal()), largerEps));
-
- // compare with eigen
- MatrixType normalized_eivec = eiSymmGen.eigenvectors()*eiSymmGen.eigenvectors().colwise().norm().asDiagonal().inverse();
- VERIFY_IS_APPROX(_eval, eiSymmGen.eigenvalues());
- VERIFY_IS_APPROX(_evec.cwiseAbs(), normalized_eivec.cwiseAbs());
-
- Gsl::free(gSymmA);
- Gsl::free(gSymmB);
- GslTraits<RealScalar>::free(gEval);
- Gsl::free(gEvec);
- }
- #endif
-
- VERIFY((symmA * eiSymm.eigenvectors()).isApprox(
- eiSymm.eigenvectors() * eiSymm.eigenvalues().asDiagonal(), largerEps));
-
- // generalized eigen problem Ax = lBx
- VERIFY((symmA * eiSymmGen.eigenvectors()).isApprox(
- symmB * (eiSymmGen.eigenvectors() * eiSymmGen.eigenvalues().asDiagonal()), largerEps));
-
- MatrixType sqrtSymmA = eiSymm.operatorSqrt();
- VERIFY_IS_APPROX(symmA, sqrtSymmA*sqrtSymmA);
- VERIFY_IS_APPROX(sqrtSymmA, symmA*eiSymm.operatorInverseSqrt());
-}
-
-template<typename MatrixType> void eigensolver(const MatrixType& m)
-{
- /* this test covers the following files:
- EigenSolver.h
- */
- int rows = m.rows();
- int cols = m.cols();
-
- typedef typename MatrixType::Scalar Scalar;
- typedef typename NumTraits<Scalar>::Real RealScalar;
- typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, 1> VectorType;
- typedef Matrix<RealScalar, MatrixType::RowsAtCompileTime, 1> RealVectorType;
- typedef typename std::complex<typename NumTraits<typename MatrixType::Scalar>::Real> Complex;
-
- // RealScalar largerEps = 10*test_precision<RealScalar>();
-
- MatrixType a = MatrixType::Random(rows,cols);
- MatrixType a1 = MatrixType::Random(rows,cols);
- MatrixType symmA = a.adjoint() * a + a1.adjoint() * a1;
-
- EigenSolver<MatrixType> ei0(symmA);
- VERIFY_IS_APPROX(symmA * ei0.pseudoEigenvectors(), ei0.pseudoEigenvectors() * ei0.pseudoEigenvalueMatrix());
- VERIFY_IS_APPROX((symmA.template cast<Complex>()) * (ei0.pseudoEigenvectors().template cast<Complex>()),
- (ei0.pseudoEigenvectors().template cast<Complex>()) * (ei0.eigenvalues().asDiagonal()));
-
- EigenSolver<MatrixType> ei1(a);
- VERIFY_IS_APPROX(a * ei1.pseudoEigenvectors(), ei1.pseudoEigenvectors() * ei1.pseudoEigenvalueMatrix());
- VERIFY_IS_APPROX(a.template cast<Complex>() * ei1.eigenvectors(),
- ei1.eigenvectors() * ei1.eigenvalues().asDiagonal());
-
-}
-
-void test_eigen2_eigensolver()
-{
- for(int i = 0; i < g_repeat; i++) {
- // very important to test a 3x3 matrix since we provide a special path for it
- CALL_SUBTEST_1( selfadjointeigensolver(Matrix3f()) );
- CALL_SUBTEST_2( selfadjointeigensolver(Matrix4d()) );
- CALL_SUBTEST_3( selfadjointeigensolver(MatrixXf(7,7)) );
- CALL_SUBTEST_4( selfadjointeigensolver(MatrixXcd(5,5)) );
- CALL_SUBTEST_5( selfadjointeigensolver(MatrixXd(19,19)) );
-
- CALL_SUBTEST_6( eigensolver(Matrix4f()) );
- CALL_SUBTEST_5( eigensolver(MatrixXd(17,17)) );
- }
-}
-
diff --git a/test/eigen2/eigen2_first_aligned.cpp b/test/eigen2/eigen2_first_aligned.cpp
deleted file mode 100644
index 51bb3cad1..000000000
--- a/test/eigen2/eigen2_first_aligned.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra.
-//
-// Copyright (C) 2009 Benoit Jacob <jacob.benoit.1@gmail.com>
-//
-// 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"
-
-template<typename Scalar>
-void test_eigen2_first_aligned_helper(Scalar *array, int size)
-{
- const int packet_size = sizeof(Scalar) * ei_packet_traits<Scalar>::size;
- VERIFY(((std::size_t(array) + sizeof(Scalar) * ei_alignmentOffset(array, size)) % packet_size) == 0);
-}
-
-template<typename Scalar>
-void test_eigen2_none_aligned_helper(Scalar *array, int size)
-{
- VERIFY(ei_packet_traits<Scalar>::size == 1 || ei_alignmentOffset(array, size) == size);
-}
-
-struct some_non_vectorizable_type { float x; };
-
-void test_eigen2_first_aligned()
-{
- EIGEN_ALIGN_128 float array_float[100];
- test_first_aligned_helper(array_float, 50);
- test_first_aligned_helper(array_float+1, 50);
- test_first_aligned_helper(array_float+2, 50);
- test_first_aligned_helper(array_float+3, 50);
- test_first_aligned_helper(array_float+4, 50);
- test_first_aligned_helper(array_float+5, 50);
-
- EIGEN_ALIGN_128 double array_double[100];
- test_first_aligned_helper(array_double, 50);
- test_first_aligned_helper(array_double+1, 50);
- test_first_aligned_helper(array_double+2, 50);
-
- double *array_double_plus_4_bytes = (double*)(std::size_t(array_double)+4);
- test_none_aligned_helper(array_double_plus_4_bytes, 50);
- test_none_aligned_helper(array_double_plus_4_bytes+1, 50);
-
- some_non_vectorizable_type array_nonvec[100];
- test_first_aligned_helper(array_nonvec, 100);
- test_none_aligned_helper(array_nonvec, 100);
-}
diff --git a/test/eigen2/eigen2_geometry.cpp b/test/eigen2/eigen2_geometry.cpp
deleted file mode 100644
index 70b4ab5f1..000000000
--- a/test/eigen2/eigen2_geometry.cpp
+++ /dev/null
@@ -1,431 +0,0 @@
-// 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 <g.gael@free.fr>
-//
-// 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 <Eigen/Geometry>
-#include <Eigen/LU>
-#include <Eigen/SVD>
-
-template<typename Scalar> void geometry(void)
-{
- /* this test covers the following files:
- Cross.h Quaternion.h, Transform.cpp
- */
-
- typedef Matrix<Scalar,2,2> Matrix2;
- typedef Matrix<Scalar,3,3> Matrix3;
- typedef Matrix<Scalar,4,4> Matrix4;
- typedef Matrix<Scalar,2,1> Vector2;
- typedef Matrix<Scalar,3,1> Vector3;
- typedef Matrix<Scalar,4,1> Vector4;
- typedef Quaternion<Scalar> Quaternionx;
- typedef AngleAxis<Scalar> AngleAxisx;
- typedef Transform<Scalar,2> Transform2;
- typedef Transform<Scalar,3> Transform3;
- typedef Scaling<Scalar,2> Scaling2;
- typedef Scaling<Scalar,3> Scaling3;
- typedef Translation<Scalar,2> Translation2;
- typedef Translation<Scalar,3> Translation3;
-
- Scalar largeEps = test_precision<Scalar>();
- if (ei_is_same_type<Scalar,float>::ret)
- largeEps = 1e-2f;
-
- Vector3 v0 = Vector3::Random(),
- v1 = Vector3::Random(),
- v2 = Vector3::Random();
- Vector2 u0 = Vector2::Random();
- Matrix3 matrot1;
-
- Scalar a = ei_random<Scalar>(-Scalar(M_PI), Scalar(M_PI));
-
- // cross product
- VERIFY_IS_MUCH_SMALLER_THAN(v1.cross(v2).eigen2_dot(v1), Scalar(1));
- Matrix3 m;
- m << v0.normalized(),
- (v0.cross(v1)).normalized(),
- (v0.cross(v1).cross(v0)).normalized();
- VERIFY(m.isUnitary());
-
- // Quaternion: Identity(), setIdentity();
- Quaternionx q1, q2;
- q2.setIdentity();
- VERIFY_IS_APPROX(Quaternionx(Quaternionx::Identity()).coeffs(), q2.coeffs());
- q1.coeffs().setRandom();
- VERIFY_IS_APPROX(q1.coeffs(), (q1*q2).coeffs());
-
- // unitOrthogonal
- VERIFY_IS_MUCH_SMALLER_THAN(u0.unitOrthogonal().eigen2_dot(u0), Scalar(1));
- VERIFY_IS_MUCH_SMALLER_THAN(v0.unitOrthogonal().eigen2_dot(v0), Scalar(1));
- VERIFY_IS_APPROX(u0.unitOrthogonal().norm(), Scalar(1));
- VERIFY_IS_APPROX(v0.unitOrthogonal().norm(), Scalar(1));
-
-
- VERIFY_IS_APPROX(v0, AngleAxisx(a, v0.normalized()) * v0);
- VERIFY_IS_APPROX(-v0, AngleAxisx(Scalar(M_PI), v0.unitOrthogonal()) * v0);
- VERIFY_IS_APPROX(ei_cos(a)*v0.squaredNorm(), v0.eigen2_dot(AngleAxisx(a, v0.unitOrthogonal()) * v0));
- m = AngleAxisx(a, v0.normalized()).toRotationMatrix().adjoint();
- VERIFY_IS_APPROX(Matrix3::Identity(), m * AngleAxisx(a, v0.normalized()));
- VERIFY_IS_APPROX(Matrix3::Identity(), AngleAxisx(a, v0.normalized()) * m);
-
- q1 = AngleAxisx(a, v0.normalized());
- q2 = AngleAxisx(a, v1.normalized());
-
- // angular distance
- Scalar refangle = ei_abs(AngleAxisx(q1.inverse()*q2).angle());
- if (refangle>Scalar(M_PI))
- refangle = Scalar(2)*Scalar(M_PI) - refangle;
-
- if((q1.coeffs()-q2.coeffs()).norm() > 10*largeEps)
- {
- VERIFY(ei_isApprox(q1.angularDistance(q2), refangle, largeEps));
- }
-
- // rotation matrix conversion
- VERIFY_IS_APPROX(q1 * v2, q1.toRotationMatrix() * v2);
- VERIFY_IS_APPROX(q1 * q2 * v2,
- q1.toRotationMatrix() * q2.toRotationMatrix() * v2);
-
- VERIFY( (q2*q1).isApprox(q1*q2, largeEps) || !(q2 * q1 * v2).isApprox(
- q1.toRotationMatrix() * q2.toRotationMatrix() * v2));
-
- q2 = q1.toRotationMatrix();
- VERIFY_IS_APPROX(q1*v1,q2*v1);
-
- matrot1 = AngleAxisx(Scalar(0.1), Vector3::UnitX())
- * AngleAxisx(Scalar(0.2), Vector3::UnitY())
- * AngleAxisx(Scalar(0.3), Vector3::UnitZ());
- VERIFY_IS_APPROX(matrot1 * v1,
- AngleAxisx(Scalar(0.1), Vector3(1,0,0)).toRotationMatrix()
- * (AngleAxisx(Scalar(0.2), Vector3(0,1,0)).toRotationMatrix()
- * (AngleAxisx(Scalar(0.3), Vector3(0,0,1)).toRotationMatrix() * v1)));
-
- // angle-axis conversion
- AngleAxisx aa = q1;
- VERIFY_IS_APPROX(q1 * v1, Quaternionx(aa) * v1);
- VERIFY_IS_NOT_APPROX(q1 * v1, Quaternionx(AngleAxisx(aa.angle()*2,aa.axis())) * v1);
-
- // from two vector creation
- VERIFY_IS_APPROX(v2.normalized(),(q2.setFromTwoVectors(v1,v2)*v1).normalized());
- VERIFY_IS_APPROX(v2.normalized(),(q2.setFromTwoVectors(v1,v2)*v1).normalized());
-
- // inverse and conjugate
- VERIFY_IS_APPROX(q1 * (q1.inverse() * v1), v1);
- VERIFY_IS_APPROX(q1 * (q1.conjugate() * v1), v1);
-
- // AngleAxis
- VERIFY_IS_APPROX(AngleAxisx(a,v1.normalized()).toRotationMatrix(),
- Quaternionx(AngleAxisx(a,v1.normalized())).toRotationMatrix());
-
- AngleAxisx aa1;
- m = q1.toRotationMatrix();
- aa1 = m;
- VERIFY_IS_APPROX(AngleAxisx(m).toRotationMatrix(),
- Quaternionx(m).toRotationMatrix());
-
- // Transform
- // TODO complete the tests !
- a = 0;
- while (ei_abs(a)<Scalar(0.1))
- a = ei_random<Scalar>(-Scalar(0.4)*Scalar(M_PI), Scalar(0.4)*Scalar(M_PI));
- q1 = AngleAxisx(a, v0.normalized());
- Transform3 t0, t1, t2;
- // first test setIdentity() and Identity()
- t0.setIdentity();
- VERIFY_IS_APPROX(t0.matrix(), Transform3::MatrixType::Identity());
- t0.matrix().setZero();
- t0 = Transform3::Identity();
- VERIFY_IS_APPROX(t0.matrix(), Transform3::MatrixType::Identity());
-
- t0.linear() = q1.toRotationMatrix();
- t1.setIdentity();
- t1.linear() = q1.toRotationMatrix();
-
- v0 << 50, 2, 1;//= ei_random_matrix<Vector3>().cwiseProduct(Vector3(10,2,0.5));
- t0.scale(v0);
- t1.prescale(v0);
-
- VERIFY_IS_APPROX( (t0 * Vector3(1,0,0)).norm(), v0.x());
- //VERIFY(!ei_isApprox((t1 * Vector3(1,0,0)).norm(), v0.x()));
-
- t0.setIdentity();
- t1.setIdentity();
- v1 << 1, 2, 3;
- t0.linear() = q1.toRotationMatrix();
- t0.pretranslate(v0);
- t0.scale(v1);
- t1.linear() = q1.conjugate().toRotationMatrix();
- t1.prescale(v1.cwise().inverse());
- t1.translate(-v0);
-
- VERIFY((t0.matrix() * t1.matrix()).isIdentity(test_precision<Scalar>()));
-
- t1.fromPositionOrientationScale(v0, q1, v1);
- VERIFY_IS_APPROX(t1.matrix(), t0.matrix());
- VERIFY_IS_APPROX(t1*v1, t0*v1);
-
- t0.setIdentity(); t0.scale(v0).rotate(q1.toRotationMatrix());
- t1.setIdentity(); t1.scale(v0).rotate(q1);
- VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
-
- t0.setIdentity(); t0.scale(v0).rotate(AngleAxisx(q1));
- VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
-
- VERIFY_IS_APPROX(t0.scale(a).matrix(), t1.scale(Vector3::Constant(a)).matrix());
- VERIFY_IS_APPROX(t0.prescale(a).matrix(), t1.prescale(Vector3::Constant(a)).matrix());
-
- // More transform constructors, operator=, operator*=
-
- Matrix3 mat3 = Matrix3::Random();
- Matrix4 mat4;
- mat4 << mat3 , Vector3::Zero() , Vector4::Zero().transpose();
- Transform3 tmat3(mat3), tmat4(mat4);
- tmat4.matrix()(3,3) = Scalar(1);
- VERIFY_IS_APPROX(tmat3.matrix(), tmat4.matrix());
-
- Scalar a3 = ei_random<Scalar>(-Scalar(M_PI), Scalar(M_PI));
- Vector3 v3 = Vector3::Random().normalized();
- AngleAxisx aa3(a3, v3);
- Transform3 t3(aa3);
- Transform3 t4;
- t4 = aa3;
- VERIFY_IS_APPROX(t3.matrix(), t4.matrix());
- t4.rotate(AngleAxisx(-a3,v3));
- VERIFY_IS_APPROX(t4.matrix(), Matrix4::Identity());
- t4 *= aa3;
- VERIFY_IS_APPROX(t3.matrix(), t4.matrix());
-
- v3 = Vector3::Random();
- Translation3 tv3(v3);
- Transform3 t5(tv3);
- t4 = tv3;
- VERIFY_IS_APPROX(t5.matrix(), t4.matrix());
- t4.translate(-v3);
- VERIFY_IS_APPROX(t4.matrix(), Matrix4::Identity());
- t4 *= tv3;
- VERIFY_IS_APPROX(t5.matrix(), t4.matrix());
-
- Scaling3 sv3(v3);
- Transform3 t6(sv3);
- t4 = sv3;
- VERIFY_IS_APPROX(t6.matrix(), t4.matrix());
- t4.scale(v3.cwise().inverse());
- VERIFY_IS_APPROX(t4.matrix(), Matrix4::Identity());
- t4 *= sv3;
- VERIFY_IS_APPROX(t6.matrix(), t4.matrix());
-
- // matrix * transform
- VERIFY_IS_APPROX(Transform3(t3.matrix()*t4).matrix(), Transform3(t3*t4).matrix());
-
- // chained Transform product
- VERIFY_IS_APPROX(((t3*t4)*t5).matrix(), (t3*(t4*t5)).matrix());
-
- // check that Transform product doesn't have aliasing problems
- t5 = t4;
- t5 = t5*t5;
- VERIFY_IS_APPROX(t5, t4*t4);
-
- // 2D transformation
- Transform2 t20, t21;
- Vector2 v20 = Vector2::Random();
- Vector2 v21 = Vector2::Random();
- for (int k=0; k<2; ++k)
- if (ei_abs(v21[k])<Scalar(1e-3)) v21[k] = Scalar(1e-3);
- t21.setIdentity();
- t21.linear() = Rotation2D<Scalar>(a).toRotationMatrix();
- VERIFY_IS_APPROX(t20.fromPositionOrientationScale(v20,a,v21).matrix(),
- t21.pretranslate(v20).scale(v21).matrix());
-
- t21.setIdentity();
- t21.linear() = Rotation2D<Scalar>(-a).toRotationMatrix();
- VERIFY( (t20.fromPositionOrientationScale(v20,a,v21)
- * (t21.prescale(v21.cwise().inverse()).translate(-v20))).matrix().isIdentity(test_precision<Scalar>()) );
-
- // Transform - new API
- // 3D
- t0.setIdentity();
- t0.rotate(q1).scale(v0).translate(v0);
- // mat * scaling and mat * translation
- t1 = (Matrix3(q1) * Scaling3(v0)) * Translation3(v0);
- VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
- // mat * transformation and scaling * translation
- t1 = Matrix3(q1) * (Scaling3(v0) * Translation3(v0));
- VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
-
- t0.setIdentity();
- t0.prerotate(q1).prescale(v0).pretranslate(v0);
- // translation * scaling and transformation * mat
- t1 = (Translation3(v0) * Scaling3(v0)) * Matrix3(q1);
- VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
- // scaling * mat and translation * mat
- t1 = Translation3(v0) * (Scaling3(v0) * Matrix3(q1));
- VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
-
- t0.setIdentity();
- t0.scale(v0).translate(v0).rotate(q1);
- // translation * mat and scaling * transformation
- t1 = Scaling3(v0) * (Translation3(v0) * Matrix3(q1));
- VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
- // transformation * scaling
- t0.scale(v0);
- t1 = t1 * Scaling3(v0);
- VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
- // transformation * translation
- t0.translate(v0);
- t1 = t1 * Translation3(v0);
- VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
- // translation * transformation
- t0.pretranslate(v0);
- t1 = Translation3(v0) * t1;
- VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
-
- // transform * quaternion
- t0.rotate(q1);
- t1 = t1 * q1;
- VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
-
- // translation * quaternion
- t0.translate(v1).rotate(q1);
- t1 = t1 * (Translation3(v1) * q1);
- VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
-
- // scaling * quaternion
- t0.scale(v1).rotate(q1);
- t1 = t1 * (Scaling3(v1) * q1);
- VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
-
- // quaternion * transform
- t0.prerotate(q1);
- t1 = q1 * t1;
- VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
-
- // quaternion * translation
- t0.rotate(q1).translate(v1);
- t1 = t1 * (q1 * Translation3(v1));
- VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
-
- // quaternion * scaling
- t0.rotate(q1).scale(v1);
- t1 = t1 * (q1 * Scaling3(v1));
- VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
-
- // translation * vector
- t0.setIdentity();
- t0.translate(v0);
- VERIFY_IS_APPROX(t0 * v1, Translation3(v0) * v1);
-
- // scaling * vector
- t0.setIdentity();
- t0.scale(v0);
- VERIFY_IS_APPROX(t0 * v1, Scaling3(v0) * v1);
-
- // test transform inversion
- t0.setIdentity();
- t0.translate(v0);
- t0.linear().setRandom();
- VERIFY_IS_APPROX(t0.inverse(Affine), t0.matrix().inverse());
- t0.setIdentity();
- t0.translate(v0).rotate(q1);
- VERIFY_IS_APPROX(t0.inverse(Isometry), t0.matrix().inverse());
-
- // test extract rotation and scaling
- t0.setIdentity();
- t0.translate(v0).rotate(q1).scale(v1);
- VERIFY_IS_APPROX(t0.rotation() * v1, Matrix3(q1) * v1);
-
- Matrix3 mat_rotation, mat_scaling;
- t0.setIdentity();
- t0.translate(v0).rotate(q1).scale(v1);
- t0.computeRotationScaling(&mat_rotation, &mat_scaling);
- VERIFY_IS_APPROX(t0.linear(), mat_rotation * mat_scaling);
- VERIFY_IS_APPROX(mat_rotation*mat_rotation.adjoint(), Matrix3::Identity());
- VERIFY_IS_APPROX(mat_rotation.determinant(), Scalar(1));
- t0.computeScalingRotation(&mat_scaling, &mat_rotation);
- VERIFY_IS_APPROX(t0.linear(), mat_scaling * mat_rotation);
- VERIFY_IS_APPROX(mat_rotation*mat_rotation.adjoint(), Matrix3::Identity());
- VERIFY_IS_APPROX(mat_rotation.determinant(), Scalar(1));
-
- // test casting
- Transform<float,3> t1f = t1.template cast<float>();
- VERIFY_IS_APPROX(t1f.template cast<Scalar>(),t1);
- Transform<double,3> t1d = t1.template cast<double>();
- VERIFY_IS_APPROX(t1d.template cast<Scalar>(),t1);
-
- Translation3 tr1(v0);
- Translation<float,3> tr1f = tr1.template cast<float>();
- VERIFY_IS_APPROX(tr1f.template cast<Scalar>(),tr1);
- Translation<double,3> tr1d = tr1.template cast<double>();
- VERIFY_IS_APPROX(tr1d.template cast<Scalar>(),tr1);
-
- Scaling3 sc1(v0);
- Scaling<float,3> sc1f = sc1.template cast<float>();
- VERIFY_IS_APPROX(sc1f.template cast<Scalar>(),sc1);
- Scaling<double,3> sc1d = sc1.template cast<double>();
- VERIFY_IS_APPROX(sc1d.template cast<Scalar>(),sc1);
-
- Quaternion<float> q1f = q1.template cast<float>();
- VERIFY_IS_APPROX(q1f.template cast<Scalar>(),q1);
- Quaternion<double> q1d = q1.template cast<double>();
- VERIFY_IS_APPROX(q1d.template cast<Scalar>(),q1);
-
- AngleAxis<float> aa1f = aa1.template cast<float>();
- VERIFY_IS_APPROX(aa1f.template cast<Scalar>(),aa1);
- AngleAxis<double> aa1d = aa1.template cast<double>();
- VERIFY_IS_APPROX(aa1d.template cast<Scalar>(),aa1);
-
- Rotation2D<Scalar> r2d1(ei_random<Scalar>());
- Rotation2D<float> r2d1f = r2d1.template cast<float>();
- VERIFY_IS_APPROX(r2d1f.template cast<Scalar>(),r2d1);
- Rotation2D<double> r2d1d = r2d1.template cast<double>();
- VERIFY_IS_APPROX(r2d1d.template cast<Scalar>(),r2d1);
-
- m = q1;
-// m.col(1) = Vector3(0,ei_random<Scalar>(),ei_random<Scalar>()).normalized();
-// m.col(0) = Vector3(-1,0,0).normalized();
-// m.col(2) = m.col(0).cross(m.col(1));
- #define VERIFY_EULER(I,J,K, X,Y,Z) { \
- Vector3 ea = m.eulerAngles(I,J,K); \
- Matrix3 m1 = Matrix3(AngleAxisx(ea[0], Vector3::Unit##X()) * AngleAxisx(ea[1], Vector3::Unit##Y()) * AngleAxisx(ea[2], Vector3::Unit##Z())); \
- VERIFY_IS_APPROX(m, Matrix3(AngleAxisx(ea[0], Vector3::Unit##X()) * AngleAxisx(ea[1], Vector3::Unit##Y()) * AngleAxisx(ea[2], Vector3::Unit##Z()))); \
- }
- VERIFY_EULER(0,1,2, X,Y,Z);
- VERIFY_EULER(0,1,0, X,Y,X);
- VERIFY_EULER(0,2,1, X,Z,Y);
- VERIFY_EULER(0,2,0, X,Z,X);
-
- VERIFY_EULER(1,2,0, Y,Z,X);
- VERIFY_EULER(1,2,1, Y,Z,Y);
- VERIFY_EULER(1,0,2, Y,X,Z);
- VERIFY_EULER(1,0,1, Y,X,Y);
-
- VERIFY_EULER(2,0,1, Z,X,Y);
- VERIFY_EULER(2,0,2, Z,X,Z);
- VERIFY_EULER(2,1,0, Z,Y,X);
- VERIFY_EULER(2,1,2, Z,Y,Z);
-
- // colwise/rowwise cross product
- mat3.setRandom();
- Vector3 vec3 = Vector3::Random();
- Matrix3 mcross;
- int i = ei_random<int>(0,2);
- mcross = mat3.colwise().cross(vec3);
- VERIFY_IS_APPROX(mcross.col(i), mat3.col(i).cross(vec3));
- mcross = mat3.rowwise().cross(vec3);
- VERIFY_IS_APPROX(mcross.row(i), mat3.row(i).cross(vec3));
-
-
-}
-
-void test_eigen2_geometry()
-{
- for(int i = 0; i < g_repeat; i++) {
- CALL_SUBTEST_1( geometry<float>() );
- CALL_SUBTEST_2( geometry<double>() );
- }
-}
diff --git a/test/eigen2/eigen2_geometry_with_eigen2_prefix.cpp b/test/eigen2/eigen2_geometry_with_eigen2_prefix.cpp
deleted file mode 100644
index f83b57249..000000000
--- a/test/eigen2/eigen2_geometry_with_eigen2_prefix.cpp
+++ /dev/null
@@ -1,434 +0,0 @@
-// 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 <g.gael@free.fr>
-//
-// 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/.
-
-#define EIGEN2_SUPPORT_STAGE15_RESOLVE_API_CONFLICTS_WARN
-
-#include "main.h"
-#include <Eigen/Geometry>
-#include <Eigen/LU>
-#include <Eigen/SVD>
-
-template<typename Scalar> void geometry(void)
-{
- /* this test covers the following files:
- Cross.h Quaternion.h, Transform.cpp
- */
-
- typedef Matrix<Scalar,2,2> Matrix2;
- typedef Matrix<Scalar,3,3> Matrix3;
- typedef Matrix<Scalar,4,4> Matrix4;
- typedef Matrix<Scalar,2,1> Vector2;
- typedef Matrix<Scalar,3,1> Vector3;
- typedef Matrix<Scalar,4,1> Vector4;
- typedef eigen2_Quaternion<Scalar> Quaternionx;
- typedef eigen2_AngleAxis<Scalar> AngleAxisx;
- typedef eigen2_Transform<Scalar,2> Transform2;
- typedef eigen2_Transform<Scalar,3> Transform3;
- typedef eigen2_Scaling<Scalar,2> Scaling2;
- typedef eigen2_Scaling<Scalar,3> Scaling3;
- typedef eigen2_Translation<Scalar,2> Translation2;
- typedef eigen2_Translation<Scalar,3> Translation3;
-
- Scalar largeEps = test_precision<Scalar>();
- if (ei_is_same_type<Scalar,float>::ret)
- largeEps = 1e-2f;
-
- Vector3 v0 = Vector3::Random(),
- v1 = Vector3::Random(),
- v2 = Vector3::Random();
- Vector2 u0 = Vector2::Random();
- Matrix3 matrot1;
-
- Scalar a = ei_random<Scalar>(-Scalar(M_PI), Scalar(M_PI));
-
- // cross product
- VERIFY_IS_MUCH_SMALLER_THAN(v1.cross(v2).eigen2_dot(v1), Scalar(1));
- Matrix3 m;
- m << v0.normalized(),
- (v0.cross(v1)).normalized(),
- (v0.cross(v1).cross(v0)).normalized();
- VERIFY(m.isUnitary());
-
- // Quaternion: Identity(), setIdentity();
- Quaternionx q1, q2;
- q2.setIdentity();
- VERIFY_IS_APPROX(Quaternionx(Quaternionx::Identity()).coeffs(), q2.coeffs());
- q1.coeffs().setRandom();
- VERIFY_IS_APPROX(q1.coeffs(), (q1*q2).coeffs());
-
- // unitOrthogonal
- VERIFY_IS_MUCH_SMALLER_THAN(u0.unitOrthogonal().eigen2_dot(u0), Scalar(1));
- VERIFY_IS_MUCH_SMALLER_THAN(v0.unitOrthogonal().eigen2_dot(v0), Scalar(1));
- VERIFY_IS_APPROX(u0.unitOrthogonal().norm(), Scalar(1));
- VERIFY_IS_APPROX(v0.unitOrthogonal().norm(), Scalar(1));
-
-
- VERIFY_IS_APPROX(v0, AngleAxisx(a, v0.normalized()) * v0);
- VERIFY_IS_APPROX(-v0, AngleAxisx(Scalar(M_PI), v0.unitOrthogonal()) * v0);
- VERIFY_IS_APPROX(ei_cos(a)*v0.squaredNorm(), v0.eigen2_dot(AngleAxisx(a, v0.unitOrthogonal()) * v0));
- m = AngleAxisx(a, v0.normalized()).toRotationMatrix().adjoint();
- VERIFY_IS_APPROX(Matrix3::Identity(), m * AngleAxisx(a, v0.normalized()));
- VERIFY_IS_APPROX(Matrix3::Identity(), AngleAxisx(a, v0.normalized()) * m);
-
- q1 = AngleAxisx(a, v0.normalized());
- q2 = AngleAxisx(a, v1.normalized());
-
- // angular distance
- Scalar refangle = ei_abs(AngleAxisx(q1.inverse()*q2).angle());
- if (refangle>Scalar(M_PI))
- refangle = Scalar(2)*Scalar(M_PI) - refangle;
-
- if((q1.coeffs()-q2.coeffs()).norm() > 10*largeEps)
- {
- VERIFY(ei_isApprox(q1.angularDistance(q2), refangle, largeEps));
- }
-
- // rotation matrix conversion
- VERIFY_IS_APPROX(q1 * v2, q1.toRotationMatrix() * v2);
- VERIFY_IS_APPROX(q1 * q2 * v2,
- q1.toRotationMatrix() * q2.toRotationMatrix() * v2);
-
- VERIFY( (q2*q1).isApprox(q1*q2, largeEps) || !(q2 * q1 * v2).isApprox(
- q1.toRotationMatrix() * q2.toRotationMatrix() * v2));
-
- q2 = q1.toRotationMatrix();
- VERIFY_IS_APPROX(q1*v1,q2*v1);
-
- matrot1 = AngleAxisx(Scalar(0.1), Vector3::UnitX())
- * AngleAxisx(Scalar(0.2), Vector3::UnitY())
- * AngleAxisx(Scalar(0.3), Vector3::UnitZ());
- VERIFY_IS_APPROX(matrot1 * v1,
- AngleAxisx(Scalar(0.1), Vector3(1,0,0)).toRotationMatrix()
- * (AngleAxisx(Scalar(0.2), Vector3(0,1,0)).toRotationMatrix()
- * (AngleAxisx(Scalar(0.3), Vector3(0,0,1)).toRotationMatrix() * v1)));
-
- // angle-axis conversion
- AngleAxisx aa = q1;
- VERIFY_IS_APPROX(q1 * v1, Quaternionx(aa) * v1);
- VERIFY_IS_NOT_APPROX(q1 * v1, Quaternionx(AngleAxisx(aa.angle()*2,aa.axis())) * v1);
-
- // from two vector creation
- VERIFY_IS_APPROX(v2.normalized(),(q2.setFromTwoVectors(v1,v2)*v1).normalized());
- VERIFY_IS_APPROX(v2.normalized(),(q2.setFromTwoVectors(v1,v2)*v1).normalized());
-
- // inverse and conjugate
- VERIFY_IS_APPROX(q1 * (q1.inverse() * v1), v1);
- VERIFY_IS_APPROX(q1 * (q1.conjugate() * v1), v1);
-
- // AngleAxis
- VERIFY_IS_APPROX(AngleAxisx(a,v1.normalized()).toRotationMatrix(),
- Quaternionx(AngleAxisx(a,v1.normalized())).toRotationMatrix());
-
- AngleAxisx aa1;
- m = q1.toRotationMatrix();
- aa1 = m;
- VERIFY_IS_APPROX(AngleAxisx(m).toRotationMatrix(),
- Quaternionx(m).toRotationMatrix());
-
- // Transform
- // TODO complete the tests !
- a = 0;
- while (ei_abs(a)<Scalar(0.1))
- a = ei_random<Scalar>(-Scalar(0.4)*Scalar(M_PI), Scalar(0.4)*Scalar(M_PI));
- q1 = AngleAxisx(a, v0.normalized());
- Transform3 t0, t1, t2;
- // first test setIdentity() and Identity()
- t0.setIdentity();
- VERIFY_IS_APPROX(t0.matrix(), Transform3::MatrixType::Identity());
- t0.matrix().setZero();
- t0 = Transform3::Identity();
- VERIFY_IS_APPROX(t0.matrix(), Transform3::MatrixType::Identity());
-
- t0.linear() = q1.toRotationMatrix();
- t1.setIdentity();
- t1.linear() = q1.toRotationMatrix();
-
- v0 << 50, 2, 1;//= ei_random_matrix<Vector3>().cwiseProduct(Vector3(10,2,0.5));
- t0.scale(v0);
- t1.prescale(v0);
-
- VERIFY_IS_APPROX( (t0 * Vector3(1,0,0)).norm(), v0.x());
- //VERIFY(!ei_isApprox((t1 * Vector3(1,0,0)).norm(), v0.x()));
-
- t0.setIdentity();
- t1.setIdentity();
- v1 << 1, 2, 3;
- t0.linear() = q1.toRotationMatrix();
- t0.pretranslate(v0);
- t0.scale(v1);
- t1.linear() = q1.conjugate().toRotationMatrix();
- t1.prescale(v1.cwise().inverse());
- t1.translate(-v0);
-
- VERIFY((t0.matrix() * t1.matrix()).isIdentity(test_precision<Scalar>()));
-
- t1.fromPositionOrientationScale(v0, q1, v1);
- VERIFY_IS_APPROX(t1.matrix(), t0.matrix());
- VERIFY_IS_APPROX(t1*v1, t0*v1);
-
- t0.setIdentity(); t0.scale(v0).rotate(q1.toRotationMatrix());
- t1.setIdentity(); t1.scale(v0).rotate(q1);
- VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
-
- t0.setIdentity(); t0.scale(v0).rotate(AngleAxisx(q1));
- VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
-
- VERIFY_IS_APPROX(t0.scale(a).matrix(), t1.scale(Vector3::Constant(a)).matrix());
- VERIFY_IS_APPROX(t0.prescale(a).matrix(), t1.prescale(Vector3::Constant(a)).matrix());
-
- // More transform constructors, operator=, operator*=
-
- Matrix3 mat3 = Matrix3::Random();
- Matrix4 mat4;
- mat4 << mat3 , Vector3::Zero() , Vector4::Zero().transpose();
- Transform3 tmat3(mat3), tmat4(mat4);
- tmat4.matrix()(3,3) = Scalar(1);
- VERIFY_IS_APPROX(tmat3.matrix(), tmat4.matrix());
-
- Scalar a3 = ei_random<Scalar>(-Scalar(M_PI), Scalar(M_PI));
- Vector3 v3 = Vector3::Random().normalized();
- AngleAxisx aa3(a3, v3);
- Transform3 t3(aa3);
- Transform3 t4;
- t4 = aa3;
- VERIFY_IS_APPROX(t3.matrix(), t4.matrix());
- t4.rotate(AngleAxisx(-a3,v3));
- VERIFY_IS_APPROX(t4.matrix(), Matrix4::Identity());
- t4 *= aa3;
- VERIFY_IS_APPROX(t3.matrix(), t4.matrix());
-
- v3 = Vector3::Random();
- Translation3 tv3(v3);
- Transform3 t5(tv3);
- t4 = tv3;
- VERIFY_IS_APPROX(t5.matrix(), t4.matrix());
- t4.translate(-v3);
- VERIFY_IS_APPROX(t4.matrix(), Matrix4::Identity());
- t4 *= tv3;
- VERIFY_IS_APPROX(t5.matrix(), t4.matrix());
-
- Scaling3 sv3(v3);
- Transform3 t6(sv3);
- t4 = sv3;
- VERIFY_IS_APPROX(t6.matrix(), t4.matrix());
- t4.scale(v3.cwise().inverse());
- VERIFY_IS_APPROX(t4.matrix(), Matrix4::Identity());
- t4 *= sv3;
- VERIFY_IS_APPROX(t6.matrix(), t4.matrix());
-
- // matrix * transform
- VERIFY_IS_APPROX(Transform3(t3.matrix()*t4).matrix(), Transform3(t3*t4).matrix());
-
- // chained Transform product
- VERIFY_IS_APPROX(((t3*t4)*t5).matrix(), (t3*(t4*t5)).matrix());
-
- // check that Transform product doesn't have aliasing problems
- t5 = t4;
- t5 = t5*t5;
- VERIFY_IS_APPROX(t5, t4*t4);
-
- // 2D transformation
- Transform2 t20, t21;
- Vector2 v20 = Vector2::Random();
- Vector2 v21 = Vector2::Random();
- for (int k=0; k<2; ++k)
- if (ei_abs(v21[k])<Scalar(1e-3)) v21[k] = Scalar(1e-3);
- t21.setIdentity();
- t21.linear() = Rotation2D<Scalar>(a).toRotationMatrix();
- VERIFY_IS_APPROX(t20.fromPositionOrientationScale(v20,a,v21).matrix(),
- t21.pretranslate(v20).scale(v21).matrix());
-
- t21.setIdentity();
- t21.linear() = Rotation2D<Scalar>(-a).toRotationMatrix();
- VERIFY( (t20.fromPositionOrientationScale(v20,a,v21)
- * (t21.prescale(v21.cwise().inverse()).translate(-v20))).matrix().isIdentity(test_precision<Scalar>()) );
-
- // Transform - new API
- // 3D
- t0.setIdentity();
- t0.rotate(q1).scale(v0).translate(v0);
- // mat * scaling and mat * translation
- t1 = (Matrix3(q1) * Scaling3(v0)) * Translation3(v0);
- VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
- // mat * transformation and scaling * translation
- t1 = Matrix3(q1) * (Scaling3(v0) * Translation3(v0));
- VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
-
- t0.setIdentity();
- t0.prerotate(q1).prescale(v0).pretranslate(v0);
- // translation * scaling and transformation * mat
- t1 = (Translation3(v0) * Scaling3(v0)) * Matrix3(q1);
- VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
- // scaling * mat and translation * mat
- t1 = Translation3(v0) * (Scaling3(v0) * Matrix3(q1));
- VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
-
- t0.setIdentity();
- t0.scale(v0).translate(v0).rotate(q1);
- // translation * mat and scaling * transformation
- t1 = Scaling3(v0) * (Translation3(v0) * Matrix3(q1));
- VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
- // transformation * scaling
- t0.scale(v0);
- t1 = t1 * Scaling3(v0);
- VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
- // transformation * translation
- t0.translate(v0);
- t1 = t1 * Translation3(v0);
- VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
- // translation * transformation
- t0.pretranslate(v0);
- t1 = Translation3(v0) * t1;
- VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
-
- // transform * quaternion
- t0.rotate(q1);
- t1 = t1 * q1;
- VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
-
- // translation * quaternion
- t0.translate(v1).rotate(q1);
- t1 = t1 * (Translation3(v1) * q1);
- VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
-
- // scaling * quaternion
- t0.scale(v1).rotate(q1);
- t1 = t1 * (Scaling3(v1) * q1);
- VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
-
- // quaternion * transform
- t0.prerotate(q1);
- t1 = q1 * t1;
- VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
-
- // quaternion * translation
- t0.rotate(q1).translate(v1);
- t1 = t1 * (q1 * Translation3(v1));
- VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
-
- // quaternion * scaling
- t0.rotate(q1).scale(v1);
- t1 = t1 * (q1 * Scaling3(v1));
- VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
-
- // translation * vector
- t0.setIdentity();
- t0.translate(v0);
- VERIFY_IS_APPROX(t0 * v1, Translation3(v0) * v1);
-
- // scaling * vector
- t0.setIdentity();
- t0.scale(v0);
- VERIFY_IS_APPROX(t0 * v1, Scaling3(v0) * v1);
-
- // test transform inversion
- t0.setIdentity();
- t0.translate(v0);
- t0.linear().setRandom();
- VERIFY_IS_APPROX(t0.inverse(Affine), t0.matrix().inverse());
- t0.setIdentity();
- t0.translate(v0).rotate(q1);
- VERIFY_IS_APPROX(t0.inverse(Isometry), t0.matrix().inverse());
-
- // test extract rotation and scaling
- t0.setIdentity();
- t0.translate(v0).rotate(q1).scale(v1);
- VERIFY_IS_APPROX(t0.rotation() * v1, Matrix3(q1) * v1);
-
- Matrix3 mat_rotation, mat_scaling;
- t0.setIdentity();
- t0.translate(v0).rotate(q1).scale(v1);
- t0.computeRotationScaling(&mat_rotation, &mat_scaling);
- VERIFY_IS_APPROX(t0.linear(), mat_rotation * mat_scaling);
- VERIFY_IS_APPROX(mat_rotation*mat_rotation.adjoint(), Matrix3::Identity());
- VERIFY_IS_APPROX(mat_rotation.determinant(), Scalar(1));
- t0.computeScalingRotation(&mat_scaling, &mat_rotation);
- VERIFY_IS_APPROX(t0.linear(), mat_scaling * mat_rotation);
- VERIFY_IS_APPROX(mat_rotation*mat_rotation.adjoint(), Matrix3::Identity());
- VERIFY_IS_APPROX(mat_rotation.determinant(), Scalar(1));
-
- // test casting
- eigen2_Transform<float,3> t1f = t1.template cast<float>();
- VERIFY_IS_APPROX(t1f.template cast<Scalar>(),t1);
- eigen2_Transform<double,3> t1d = t1.template cast<double>();
- VERIFY_IS_APPROX(t1d.template cast<Scalar>(),t1);
-
- Translation3 tr1(v0);
- eigen2_Translation<float,3> tr1f = tr1.template cast<float>();
- VERIFY_IS_APPROX(tr1f.template cast<Scalar>(),tr1);
- eigen2_Translation<double,3> tr1d = tr1.template cast<double>();
- VERIFY_IS_APPROX(tr1d.template cast<Scalar>(),tr1);
-
- Scaling3 sc1(v0);
- eigen2_Scaling<float,3> sc1f = sc1.template cast<float>();
- VERIFY_IS_APPROX(sc1f.template cast<Scalar>(),sc1);
- eigen2_Scaling<double,3> sc1d = sc1.template cast<double>();
- VERIFY_IS_APPROX(sc1d.template cast<Scalar>(),sc1);
-
- eigen2_Quaternion<float> q1f = q1.template cast<float>();
- VERIFY_IS_APPROX(q1f.template cast<Scalar>(),q1);
- eigen2_Quaternion<double> q1d = q1.template cast<double>();
- VERIFY_IS_APPROX(q1d.template cast<Scalar>(),q1);
-
- eigen2_AngleAxis<float> aa1f = aa1.template cast<float>();
- VERIFY_IS_APPROX(aa1f.template cast<Scalar>(),aa1);
- eigen2_AngleAxis<double> aa1d = aa1.template cast<double>();
- VERIFY_IS_APPROX(aa1d.template cast<Scalar>(),aa1);
-
- eigen2_Rotation2D<Scalar> r2d1(ei_random<Scalar>());
- eigen2_Rotation2D<float> r2d1f = r2d1.template cast<float>();
- VERIFY_IS_APPROX(r2d1f.template cast<Scalar>(),r2d1);
- eigen2_Rotation2D<double> r2d1d = r2d1.template cast<double>();
- VERIFY_IS_APPROX(r2d1d.template cast<Scalar>(),r2d1);
-
- m = q1;
-// m.col(1) = Vector3(0,ei_random<Scalar>(),ei_random<Scalar>()).normalized();
-// m.col(0) = Vector3(-1,0,0).normalized();
-// m.col(2) = m.col(0).cross(m.col(1));
- #define VERIFY_EULER(I,J,K, X,Y,Z) { \
- Vector3 ea = m.eulerAngles(I,J,K); \
- Matrix3 m1 = Matrix3(AngleAxisx(ea[0], Vector3::Unit##X()) * AngleAxisx(ea[1], Vector3::Unit##Y()) * AngleAxisx(ea[2], Vector3::Unit##Z())); \
- VERIFY_IS_APPROX(m, Matrix3(AngleAxisx(ea[0], Vector3::Unit##X()) * AngleAxisx(ea[1], Vector3::Unit##Y()) * AngleAxisx(ea[2], Vector3::Unit##Z()))); \
- }
- VERIFY_EULER(0,1,2, X,Y,Z);
- VERIFY_EULER(0,1,0, X,Y,X);
- VERIFY_EULER(0,2,1, X,Z,Y);
- VERIFY_EULER(0,2,0, X,Z,X);
-
- VERIFY_EULER(1,2,0, Y,Z,X);
- VERIFY_EULER(1,2,1, Y,Z,Y);
- VERIFY_EULER(1,0,2, Y,X,Z);
- VERIFY_EULER(1,0,1, Y,X,Y);
-
- VERIFY_EULER(2,0,1, Z,X,Y);
- VERIFY_EULER(2,0,2, Z,X,Z);
- VERIFY_EULER(2,1,0, Z,Y,X);
- VERIFY_EULER(2,1,2, Z,Y,Z);
-
- // colwise/rowwise cross product
- mat3.setRandom();
- Vector3 vec3 = Vector3::Random();
- Matrix3 mcross;
- int i = ei_random<int>(0,2);
- mcross = mat3.colwise().cross(vec3);
- VERIFY_IS_APPROX(mcross.col(i), mat3.col(i).cross(vec3));
- mcross = mat3.rowwise().cross(vec3);
- VERIFY_IS_APPROX(mcross.row(i), mat3.row(i).cross(vec3));
-
-
-}
-
-void test_eigen2_geometry_with_eigen2_prefix()
-{
- std::cout << "eigen2 support: " << EIGEN2_SUPPORT_STAGE << std::endl;
- for(int i = 0; i < g_repeat; i++) {
- CALL_SUBTEST_1( geometry<float>() );
- CALL_SUBTEST_2( geometry<double>() );
- }
-}
diff --git a/test/eigen2/eigen2_hyperplane.cpp b/test/eigen2/eigen2_hyperplane.cpp
deleted file mode 100644
index f3f85e14d..000000000
--- a/test/eigen2/eigen2_hyperplane.cpp
+++ /dev/null
@@ -1,126 +0,0 @@
-// 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 <g.gael@free.fr>
-// Copyright (C) 2008 Benoit Jacob <jacob.benoit.1@gmail.com>
-//
-// 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 <Eigen/Geometry>
-#include <Eigen/LU>
-#include <Eigen/QR>
-
-template<typename HyperplaneType> void hyperplane(const HyperplaneType& _plane)
-{
- /* this test covers the following files:
- Hyperplane.h
- */
-
- const int dim = _plane.dim();
- typedef typename HyperplaneType::Scalar Scalar;
- typedef typename NumTraits<Scalar>::Real RealScalar;
- typedef Matrix<Scalar, HyperplaneType::AmbientDimAtCompileTime, 1> VectorType;
- typedef Matrix<Scalar, HyperplaneType::AmbientDimAtCompileTime,
- HyperplaneType::AmbientDimAtCompileTime> MatrixType;
-
- VectorType p0 = VectorType::Random(dim);
- VectorType p1 = VectorType::Random(dim);
-
- VectorType n0 = VectorType::Random(dim).normalized();
- VectorType n1 = VectorType::Random(dim).normalized();
-
- HyperplaneType pl0(n0, p0);
- HyperplaneType pl1(n1, p1);
- HyperplaneType pl2 = pl1;
-
- Scalar s0 = ei_random<Scalar>();
- Scalar s1 = ei_random<Scalar>();
-
- VERIFY_IS_APPROX( n1.eigen2_dot(n1), Scalar(1) );
-
- VERIFY_IS_MUCH_SMALLER_THAN( pl0.absDistance(p0), Scalar(1) );
- VERIFY_IS_APPROX( pl1.signedDistance(p1 + n1 * s0), s0 );
- VERIFY_IS_MUCH_SMALLER_THAN( pl1.signedDistance(pl1.projection(p0)), Scalar(1) );
- VERIFY_IS_MUCH_SMALLER_THAN( pl1.absDistance(p1 + pl1.normal().unitOrthogonal() * s1), Scalar(1) );
-
- // transform
- if (!NumTraits<Scalar>::IsComplex)
- {
- MatrixType rot = MatrixType::Random(dim,dim).qr().matrixQ();
- Scaling<Scalar,HyperplaneType::AmbientDimAtCompileTime> scaling(VectorType::Random());
- Translation<Scalar,HyperplaneType::AmbientDimAtCompileTime> translation(VectorType::Random());
-
- pl2 = pl1;
- VERIFY_IS_MUCH_SMALLER_THAN( pl2.transform(rot).absDistance(rot * p1), Scalar(1) );
- pl2 = pl1;
- VERIFY_IS_MUCH_SMALLER_THAN( pl2.transform(rot,Isometry).absDistance(rot * p1), Scalar(1) );
- pl2 = pl1;
- VERIFY_IS_MUCH_SMALLER_THAN( pl2.transform(rot*scaling).absDistance((rot*scaling) * p1), Scalar(1) );
- pl2 = pl1;
- VERIFY_IS_MUCH_SMALLER_THAN( pl2.transform(rot*scaling*translation)
- .absDistance((rot*scaling*translation) * p1), Scalar(1) );
- pl2 = pl1;
- VERIFY_IS_MUCH_SMALLER_THAN( pl2.transform(rot*translation,Isometry)
- .absDistance((rot*translation) * p1), Scalar(1) );
- }
-
- // casting
- const int Dim = HyperplaneType::AmbientDimAtCompileTime;
- typedef typename GetDifferentType<Scalar>::type OtherScalar;
- Hyperplane<OtherScalar,Dim> hp1f = pl1.template cast<OtherScalar>();
- VERIFY_IS_APPROX(hp1f.template cast<Scalar>(),pl1);
- Hyperplane<Scalar,Dim> hp1d = pl1.template cast<Scalar>();
- VERIFY_IS_APPROX(hp1d.template cast<Scalar>(),pl1);
-}
-
-template<typename Scalar> void lines()
-{
- typedef Hyperplane<Scalar, 2> HLine;
- typedef ParametrizedLine<Scalar, 2> PLine;
- typedef Matrix<Scalar,2,1> Vector;
- typedef Matrix<Scalar,3,1> CoeffsType;
-
- for(int i = 0; i < 10; i++)
- {
- Vector center = Vector::Random();
- Vector u = Vector::Random();
- Vector v = Vector::Random();
- Scalar a = ei_random<Scalar>();
- while (ei_abs(a-1) < 1e-4) a = ei_random<Scalar>();
- while (u.norm() < 1e-4) u = Vector::Random();
- while (v.norm() < 1e-4) v = Vector::Random();
-
- HLine line_u = HLine::Through(center + u, center + a*u);
- HLine line_v = HLine::Through(center + v, center + a*v);
-
- // the line equations should be normalized so that a^2+b^2=1
- VERIFY_IS_APPROX(line_u.normal().norm(), Scalar(1));
- VERIFY_IS_APPROX(line_v.normal().norm(), Scalar(1));
-
- Vector result = line_u.intersection(line_v);
-
- // the lines should intersect at the point we called "center"
- VERIFY_IS_APPROX(result, center);
-
- // check conversions between two types of lines
- PLine pl(line_u); // gcc 3.3 will commit suicide if we don't name this variable
- CoeffsType converted_coeffs(HLine(pl).coeffs());
- converted_coeffs *= line_u.coeffs()(0)/converted_coeffs(0);
- VERIFY(line_u.coeffs().isApprox(converted_coeffs));
- }
-}
-
-void test_eigen2_hyperplane()
-{
- for(int i = 0; i < g_repeat; i++) {
- CALL_SUBTEST_1( hyperplane(Hyperplane<float,2>()) );
- CALL_SUBTEST_2( hyperplane(Hyperplane<float,3>()) );
- CALL_SUBTEST_3( hyperplane(Hyperplane<double,4>()) );
- CALL_SUBTEST_4( hyperplane(Hyperplane<std::complex<double>,5>()) );
- CALL_SUBTEST_5( lines<float>() );
- CALL_SUBTEST_6( lines<double>() );
- }
-}
diff --git a/test/eigen2/eigen2_inverse.cpp b/test/eigen2/eigen2_inverse.cpp
deleted file mode 100644
index 5de1dfefa..000000000
--- a/test/eigen2/eigen2_inverse.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-// 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 <g.gael@free.fr>
-// Copyright (C) 2008 Benoit Jacob <jacob.benoit.1@gmail.com>
-//
-// 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 <Eigen/LU>
-
-template<typename MatrixType> void inverse(const MatrixType& m)
-{
- /* this test covers the following files:
- Inverse.h
- */
- int rows = m.rows();
- int cols = m.cols();
-
- typedef typename MatrixType::Scalar Scalar;
- typedef typename NumTraits<Scalar>::Real RealScalar;
- typedef Matrix<Scalar, MatrixType::ColsAtCompileTime, 1> VectorType;
-
- MatrixType m1 = MatrixType::Random(rows, cols),
- m2(rows, cols),
- mzero = MatrixType::Zero(rows, cols),
- identity = MatrixType::Identity(rows, rows);
-
- while(ei_abs(m1.determinant()) < RealScalar(0.1) && rows <= 8)
- {
- m1 = MatrixType::Random(rows, cols);
- }
-
- m2 = m1.inverse();
- VERIFY_IS_APPROX(m1, m2.inverse() );
-
- m1.computeInverse(&m2);
- VERIFY_IS_APPROX(m1, m2.inverse() );
-
- VERIFY_IS_APPROX((Scalar(2)*m2).inverse(), m2.inverse()*Scalar(0.5));
-
- VERIFY_IS_APPROX(identity, m1.inverse() * m1 );
- VERIFY_IS_APPROX(identity, m1 * m1.inverse() );
-
- VERIFY_IS_APPROX(m1, m1.inverse().inverse() );
-
- // since for the general case we implement separately row-major and col-major, test that
- VERIFY_IS_APPROX(m1.transpose().inverse(), m1.inverse().transpose());
-}
-
-void test_eigen2_inverse()
-{
- for(int i = 0; i < g_repeat; i++) {
- CALL_SUBTEST_1( inverse(Matrix<double,1,1>()) );
- CALL_SUBTEST_2( inverse(Matrix2d()) );
- CALL_SUBTEST_3( inverse(Matrix3f()) );
- CALL_SUBTEST_4( inverse(Matrix4f()) );
- CALL_SUBTEST_5( inverse(MatrixXf(8,8)) );
- CALL_SUBTEST_6( inverse(MatrixXcd(7,7)) );
- }
-}
diff --git a/test/eigen2/eigen2_linearstructure.cpp b/test/eigen2/eigen2_linearstructure.cpp
deleted file mode 100644
index 22f02c396..000000000
--- a/test/eigen2/eigen2_linearstructure.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
-// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra. Eigen itself is part of the KDE project.
-//
-// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
-//
-// 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"
-
-template<typename MatrixType> void linearStructure(const MatrixType& m)
-{
- /* this test covers the following files:
- Sum.h Difference.h Opposite.h ScalarMultiple.h
- */
-
- typedef typename MatrixType::Scalar Scalar;
- typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, 1> VectorType;
-
- int rows = m.rows();
- int cols = m.cols();
-
- // this test relies a lot on Random.h, and there's not much more that we can do
- // to test it, hence I consider that we will have tested Random.h
- MatrixType m1 = MatrixType::Random(rows, cols),
- m2 = MatrixType::Random(rows, cols),
- m3(rows, cols),
- mzero = MatrixType::Zero(rows, cols);
-
- Scalar s1 = ei_random<Scalar>();
- while (ei_abs(s1)<1e-3) s1 = ei_random<Scalar>();
-
- int r = ei_random<int>(0, rows-1),
- c = ei_random<int>(0, cols-1);
-
- VERIFY_IS_APPROX(-(-m1), m1);
- VERIFY_IS_APPROX(m1+m1, 2*m1);
- VERIFY_IS_APPROX(m1+m2-m1, m2);
- VERIFY_IS_APPROX(-m2+m1+m2, m1);
- VERIFY_IS_APPROX(m1*s1, s1*m1);
- VERIFY_IS_APPROX((m1+m2)*s1, s1*m1+s1*m2);
- VERIFY_IS_APPROX((-m1+m2)*s1, -s1*m1+s1*m2);
- m3 = m2; m3 += m1;
- VERIFY_IS_APPROX(m3, m1+m2);
- m3 = m2; m3 -= m1;
- VERIFY_IS_APPROX(m3, m2-m1);
- m3 = m2; m3 *= s1;
- VERIFY_IS_APPROX(m3, s1*m2);
- if(NumTraits<Scalar>::HasFloatingPoint)
- {
- m3 = m2; m3 /= s1;
- VERIFY_IS_APPROX(m3, m2/s1);
- }
-
- // again, test operator() to check const-qualification
- VERIFY_IS_APPROX((-m1)(r,c), -(m1(r,c)));
- VERIFY_IS_APPROX((m1-m2)(r,c), (m1(r,c))-(m2(r,c)));
- VERIFY_IS_APPROX((m1+m2)(r,c), (m1(r,c))+(m2(r,c)));
- VERIFY_IS_APPROX((s1*m1)(r,c), s1*(m1(r,c)));
- VERIFY_IS_APPROX((m1*s1)(r,c), (m1(r,c))*s1);
- if(NumTraits<Scalar>::HasFloatingPoint)
- VERIFY_IS_APPROX((m1/s1)(r,c), (m1(r,c))/s1);
-
- // use .block to disable vectorization and compare to the vectorized version
- VERIFY_IS_APPROX(m1+m1.block(0,0,rows,cols), m1+m1);
- VERIFY_IS_APPROX(m1.cwise() * m1.block(0,0,rows,cols), m1.cwise() * m1);
- VERIFY_IS_APPROX(m1 - m1.block(0,0,rows,cols), m1 - m1);
- VERIFY_IS_APPROX(m1.block(0,0,rows,cols) * s1, m1 * s1);
-}
-
-void test_eigen2_linearstructure()
-{
- for(int i = 0; i < g_repeat; i++) {
- CALL_SUBTEST_1( linearStructure(Matrix<float, 1, 1>()) );
- CALL_SUBTEST_2( linearStructure(Matrix2f()) );
- CALL_SUBTEST_3( linearStructure(Vector3d()) );
- CALL_SUBTEST_4( linearStructure(Matrix4d()) );
- CALL_SUBTEST_5( linearStructure(MatrixXcf(3, 3)) );
- CALL_SUBTEST_6( linearStructure(MatrixXf(8, 12)) );
- CALL_SUBTEST_7( linearStructure(MatrixXi(8, 12)) );
- CALL_SUBTEST_8( linearStructure(MatrixXcd(20, 20)) );
- }
-}
diff --git a/test/eigen2/eigen2_lu.cpp b/test/eigen2/eigen2_lu.cpp
deleted file mode 100644
index e993b1c7c..000000000
--- a/test/eigen2/eigen2_lu.cpp
+++ /dev/null
@@ -1,122 +0,0 @@
-// 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 Benoit Jacob <jacob.benoit.1@gmail.com>
-//
-// 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 <Eigen/LU>
-
-template<typename Derived>
-void doSomeRankPreservingOperations(Eigen::MatrixBase<Derived>& m)
-{
- typedef typename Derived::RealScalar RealScalar;
- for(int a = 0; a < 3*(m.rows()+m.cols()); a++)
- {
- RealScalar d = Eigen::ei_random<RealScalar>(-1,1);
- int i = Eigen::ei_random<int>(0,m.rows()-1); // i is a random row number
- int j;
- do {
- j = Eigen::ei_random<int>(0,m.rows()-1);
- } while (i==j); // j is another one (must be different)
- m.row(i) += d * m.row(j);
-
- i = Eigen::ei_random<int>(0,m.cols()-1); // i is a random column number
- do {
- j = Eigen::ei_random<int>(0,m.cols()-1);
- } while (i==j); // j is another one (must be different)
- m.col(i) += d * m.col(j);
- }
-}
-
-template<typename MatrixType> void lu_non_invertible()
-{
- /* this test covers the following files:
- LU.h
- */
- // NOTE there seems to be a problem with too small sizes -- could easily lie in the doSomeRankPreservingOperations function
- int rows = ei_random<int>(20,200), cols = ei_random<int>(20,200), cols2 = ei_random<int>(20,200);
- int rank = ei_random<int>(1, std::min(rows, cols)-1);
-
- MatrixType m1(rows, cols), m2(cols, cols2), m3(rows, cols2), k(1,1);
- m1 = MatrixType::Random(rows,cols);
- if(rows <= cols)
- for(int i = rank; i < rows; i++) m1.row(i).setZero();
- else
- for(int i = rank; i < cols; i++) m1.col(i).setZero();
- doSomeRankPreservingOperations(m1);
-
- LU<MatrixType> lu(m1);
- typename LU<MatrixType>::KernelResultType m1kernel = lu.kernel();
- typename LU<MatrixType>::ImageResultType m1image = lu.image();
-
- VERIFY(rank == lu.rank());
- VERIFY(cols - lu.rank() == lu.dimensionOfKernel());
- VERIFY(!lu.isInjective());
- VERIFY(!lu.isInvertible());
- VERIFY(lu.isSurjective() == (lu.rank() == rows));
- VERIFY((m1 * m1kernel).isMuchSmallerThan(m1));
- VERIFY(m1image.lu().rank() == rank);
- MatrixType sidebyside(m1.rows(), m1.cols() + m1image.cols());
- sidebyside << m1, m1image;
- VERIFY(sidebyside.lu().rank() == rank);
- m2 = MatrixType::Random(cols,cols2);
- m3 = m1*m2;
- m2 = MatrixType::Random(cols,cols2);
- lu.solve(m3, &m2);
- VERIFY_IS_APPROX(m3, m1*m2);
- /* solve now always returns true
- m3 = MatrixType::Random(rows,cols2);
- VERIFY(!lu.solve(m3, &m2));
- */
-}
-
-template<typename MatrixType> void lu_invertible()
-{
- /* this test covers the following files:
- LU.h
- */
- typedef typename NumTraits<typename MatrixType::Scalar>::Real RealScalar;
- int size = ei_random<int>(10,200);
-
- MatrixType m1(size, size), m2(size, size), m3(size, size);
- m1 = MatrixType::Random(size,size);
-
- if (ei_is_same_type<RealScalar,float>::ret)
- {
- // let's build a matrix more stable to inverse
- MatrixType a = MatrixType::Random(size,size*2);
- m1 += a * a.adjoint();
- }
-
- LU<MatrixType> lu(m1);
- VERIFY(0 == lu.dimensionOfKernel());
- VERIFY(size == lu.rank());
- VERIFY(lu.isInjective());
- VERIFY(lu.isSurjective());
- VERIFY(lu.isInvertible());
- VERIFY(lu.image().lu().isInvertible());
- m3 = MatrixType::Random(size,size);
- lu.solve(m3, &m2);
- VERIFY_IS_APPROX(m3, m1*m2);
- VERIFY_IS_APPROX(m2, lu.inverse()*m3);
- m3 = MatrixType::Random(size,size);
- VERIFY(lu.solve(m3, &m2));
-}
-
-void test_eigen2_lu()
-{
- for(int i = 0; i < g_repeat; i++) {
- CALL_SUBTEST_1( lu_non_invertible<MatrixXf>() );
- CALL_SUBTEST_2( lu_non_invertible<MatrixXd>() );
- CALL_SUBTEST_3( lu_non_invertible<MatrixXcf>() );
- CALL_SUBTEST_4( lu_non_invertible<MatrixXcd>() );
- CALL_SUBTEST_1( lu_invertible<MatrixXf>() );
- CALL_SUBTEST_2( lu_invertible<MatrixXd>() );
- CALL_SUBTEST_3( lu_invertible<MatrixXcf>() );
- CALL_SUBTEST_4( lu_invertible<MatrixXcd>() );
- }
-}
diff --git a/test/eigen2/eigen2_map.cpp b/test/eigen2/eigen2_map.cpp
deleted file mode 100644
index 4a1c4e11a..000000000
--- a/test/eigen2/eigen2_map.cpp
+++ /dev/null
@@ -1,114 +0,0 @@
-// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra. Eigen itself is part of the KDE project.
-//
-// Copyright (C) 2007-2010 Benoit Jacob <jacob.benoit.1@gmail.com>
-//
-// 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"
-
-template<typename VectorType> void map_class_vector(const VectorType& m)
-{
- typedef typename VectorType::Scalar Scalar;
-
- int size = m.size();
-
- // test Map.h
- Scalar* array1 = ei_aligned_new<Scalar>(size);
- Scalar* array2 = ei_aligned_new<Scalar>(size);
- Scalar* array3 = new Scalar[size+1];
- Scalar* array3unaligned = std::size_t(array3)%16 == 0 ? array3+1 : array3;
-
- Map<VectorType, Aligned>(array1, size) = VectorType::Random(size);
- Map<VectorType>(array2, size) = Map<VectorType>(array1, size);
- Map<VectorType>(array3unaligned, size) = Map<VectorType>((const Scalar*)array1, size); // test non-const-correctness support in eigen2
- VectorType ma1 = Map<VectorType>(array1, size);
- VectorType ma2 = Map<VectorType, Aligned>(array2, size);
- VectorType ma3 = Map<VectorType>(array3unaligned, size);
- VERIFY_IS_APPROX(ma1, ma2);
- VERIFY_IS_APPROX(ma1, ma3);
-
- ei_aligned_delete(array1, size);
- ei_aligned_delete(array2, size);
- delete[] array3;
-}
-
-template<typename MatrixType> void map_class_matrix(const MatrixType& m)
-{
- typedef typename MatrixType::Scalar Scalar;
-
- int rows = m.rows(), cols = m.cols(), size = rows*cols;
-
- // test Map.h
- Scalar* array1 = ei_aligned_new<Scalar>(size);
- for(int i = 0; i < size; i++) array1[i] = Scalar(1);
- Scalar* array2 = ei_aligned_new<Scalar>(size);
- for(int i = 0; i < size; i++) array2[i] = Scalar(1);
- Scalar* array3 = new Scalar[size+1];
- for(int i = 0; i < size+1; i++) array3[i] = Scalar(1);
- Scalar* array3unaligned = std::size_t(array3)%16 == 0 ? array3+1 : array3;
- Map<MatrixType, Aligned>(array1, rows, cols) = MatrixType::Ones(rows,cols);
- Map<MatrixType>(array2, rows, cols) = Map<MatrixType>((const Scalar*)array1, rows, cols); // test non-const-correctness support in eigen2
- Map<MatrixType>(array3unaligned, rows, cols) = Map<MatrixType>(array1, rows, cols);
- MatrixType ma1 = Map<MatrixType>(array1, rows, cols);
- MatrixType ma2 = Map<MatrixType, Aligned>(array2, rows, cols);
- VERIFY_IS_APPROX(ma1, ma2);
- MatrixType ma3 = Map<MatrixType>(array3unaligned, rows, cols);
- VERIFY_IS_APPROX(ma1, ma3);
-
- ei_aligned_delete(array1, size);
- ei_aligned_delete(array2, size);
- delete[] array3;
-}
-
-template<typename VectorType> void map_static_methods(const VectorType& m)
-{
- typedef typename VectorType::Scalar Scalar;
-
- int size = m.size();
-
- // test Map.h
- Scalar* array1 = ei_aligned_new<Scalar>(size);
- Scalar* array2 = ei_aligned_new<Scalar>(size);
- Scalar* array3 = new Scalar[size+1];
- Scalar* array3unaligned = std::size_t(array3)%16 == 0 ? array3+1 : array3;
-
- VectorType::MapAligned(array1, size) = VectorType::Random(size);
- VectorType::Map(array2, size) = VectorType::Map(array1, size);
- VectorType::Map(array3unaligned, size) = VectorType::Map(array1, size);
- VectorType ma1 = VectorType::Map(array1, size);
- VectorType ma2 = VectorType::MapAligned(array2, size);
- VectorType ma3 = VectorType::Map(array3unaligned, size);
- VERIFY_IS_APPROX(ma1, ma2);
- VERIFY_IS_APPROX(ma1, ma3);
-
- ei_aligned_delete(array1, size);
- ei_aligned_delete(array2, size);
- delete[] array3;
-}
-
-
-void test_eigen2_map()
-{
- for(int i = 0; i < g_repeat; i++) {
- CALL_SUBTEST_1( map_class_vector(Matrix<float, 1, 1>()) );
- CALL_SUBTEST_2( map_class_vector(Vector4d()) );
- CALL_SUBTEST_3( map_class_vector(RowVector4f()) );
- CALL_SUBTEST_4( map_class_vector(VectorXcf(8)) );
- CALL_SUBTEST_5( map_class_vector(VectorXi(12)) );
-
- CALL_SUBTEST_1( map_class_matrix(Matrix<float, 1, 1>()) );
- CALL_SUBTEST_2( map_class_matrix(Matrix4d()) );
- CALL_SUBTEST_6( map_class_matrix(Matrix<float,3,5>()) );
- CALL_SUBTEST_4( map_class_matrix(MatrixXcf(ei_random<int>(1,10),ei_random<int>(1,10))) );
- CALL_SUBTEST_5( map_class_matrix(MatrixXi(ei_random<int>(1,10),ei_random<int>(1,10))) );
-
- CALL_SUBTEST_1( map_static_methods(Matrix<double, 1, 1>()) );
- CALL_SUBTEST_2( map_static_methods(Vector3f()) );
- CALL_SUBTEST_7( map_static_methods(RowVector3d()) );
- CALL_SUBTEST_4( map_static_methods(VectorXcd(8)) );
- CALL_SUBTEST_5( map_static_methods(VectorXf(12)) );
- }
-}
diff --git a/test/eigen2/eigen2_meta.cpp b/test/eigen2/eigen2_meta.cpp
deleted file mode 100644
index 1d01bd84d..000000000
--- a/test/eigen2/eigen2_meta.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-// 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 <g.gael@free.fr>
-//
-// 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"
-
-void test_eigen2_meta()
-{
- typedef float & FloatRef;
- typedef const float & ConstFloatRef;
-
- VERIFY((ei_meta_if<(3<4),ei_meta_true, ei_meta_false>::ret::ret));
- VERIFY(( ei_is_same_type<float,float>::ret));
- VERIFY((!ei_is_same_type<float,double>::ret));
- VERIFY((!ei_is_same_type<float,float&>::ret));
- VERIFY((!ei_is_same_type<float,const float&>::ret));
-
- VERIFY(( ei_is_same_type<float,ei_cleantype<const float&>::type >::ret));
- VERIFY(( ei_is_same_type<float,ei_cleantype<const float*>::type >::ret));
- VERIFY(( ei_is_same_type<float,ei_cleantype<const float*&>::type >::ret));
- VERIFY(( ei_is_same_type<float,ei_cleantype<float**>::type >::ret));
- VERIFY(( ei_is_same_type<float,ei_cleantype<float**&>::type >::ret));
- VERIFY(( ei_is_same_type<float,ei_cleantype<float* const *&>::type >::ret));
- VERIFY(( ei_is_same_type<float,ei_cleantype<float* const>::type >::ret));
-
- VERIFY(( ei_is_same_type<float*,ei_unconst<const float*>::type >::ret));
- VERIFY(( ei_is_same_type<float&,ei_unconst<const float&>::type >::ret));
- VERIFY(( ei_is_same_type<float&,ei_unconst<ConstFloatRef>::type >::ret));
-
- VERIFY(( ei_is_same_type<float&,ei_unconst<float&>::type >::ret));
- VERIFY(( ei_is_same_type<float,ei_unref<float&>::type >::ret));
- VERIFY(( ei_is_same_type<const float,ei_unref<const float&>::type >::ret));
- VERIFY(( ei_is_same_type<float,ei_unpointer<float*>::type >::ret));
- VERIFY(( ei_is_same_type<const float,ei_unpointer<const float*>::type >::ret));
- VERIFY(( ei_is_same_type<float,ei_unpointer<float* const >::type >::ret));
-
- VERIFY(ei_meta_sqrt<1>::ret == 1);
- #define VERIFY_META_SQRT(X) VERIFY(ei_meta_sqrt<X>::ret == int(ei_sqrt(double(X))))
- VERIFY_META_SQRT(2);
- VERIFY_META_SQRT(3);
- VERIFY_META_SQRT(4);
- VERIFY_META_SQRT(5);
- VERIFY_META_SQRT(6);
- VERIFY_META_SQRT(8);
- VERIFY_META_SQRT(9);
- VERIFY_META_SQRT(15);
- VERIFY_META_SQRT(16);
- VERIFY_META_SQRT(17);
- VERIFY_META_SQRT(255);
- VERIFY_META_SQRT(256);
- VERIFY_META_SQRT(257);
- VERIFY_META_SQRT(1023);
- VERIFY_META_SQRT(1024);
- VERIFY_META_SQRT(1025);
-}
diff --git a/test/eigen2/eigen2_miscmatrices.cpp b/test/eigen2/eigen2_miscmatrices.cpp
deleted file mode 100644
index 8bbb20cc8..000000000
--- a/test/eigen2/eigen2_miscmatrices.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra. Eigen itself is part of the KDE project.
-//
-// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
-//
-// 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"
-
-template<typename MatrixType> void miscMatrices(const MatrixType& m)
-{
- /* this test covers the following files:
- DiagonalMatrix.h Ones.h
- */
-
- typedef typename MatrixType::Scalar Scalar;
- typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, 1> VectorType;
- typedef Matrix<Scalar, 1, MatrixType::ColsAtCompileTime> RowVectorType;
- int rows = m.rows();
- int cols = m.cols();
-
- int r = ei_random<int>(0, rows-1), r2 = ei_random<int>(0, rows-1), c = ei_random<int>(0, cols-1);
- VERIFY_IS_APPROX(MatrixType::Ones(rows,cols)(r,c), static_cast<Scalar>(1));
- MatrixType m1 = MatrixType::Ones(rows,cols);
- VERIFY_IS_APPROX(m1(r,c), static_cast<Scalar>(1));
- VectorType v1 = VectorType::Random(rows);
- v1[0];
- Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime>
- square = v1.asDiagonal();
- if(r==r2) VERIFY_IS_APPROX(square(r,r2), v1[r]);
- else VERIFY_IS_MUCH_SMALLER_THAN(square(r,r2), static_cast<Scalar>(1));
- square = MatrixType::Zero(rows, rows);
- square.diagonal() = VectorType::Ones(rows);
- VERIFY_IS_APPROX(square, MatrixType::Identity(rows, rows));
-}
-
-void test_eigen2_miscmatrices()
-{
- for(int i = 0; i < g_repeat; i++) {
- CALL_SUBTEST_1( miscMatrices(Matrix<float, 1, 1>()) );
- CALL_SUBTEST_2( miscMatrices(Matrix4d()) );
- CALL_SUBTEST_3( miscMatrices(MatrixXcf(3, 3)) );
- CALL_SUBTEST_4( miscMatrices(MatrixXi(8, 12)) );
- CALL_SUBTEST_5( miscMatrices(MatrixXcd(20, 20)) );
- }
-}
diff --git a/test/eigen2/eigen2_mixingtypes.cpp b/test/eigen2/eigen2_mixingtypes.cpp
deleted file mode 100644
index fb5ac5dda..000000000
--- a/test/eigen2/eigen2_mixingtypes.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-// 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 <g.gael@free.fr>
-// Copyright (C) 2008 Benoit Jacob <jacob.benoit.1@gmail.com>
-//
-// 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/.
-
-#ifndef EIGEN_NO_STATIC_ASSERT
-#define EIGEN_NO_STATIC_ASSERT // turn static asserts into runtime asserts in order to check them
-#endif
-
-#ifndef EIGEN_DONT_VECTORIZE
-#define EIGEN_DONT_VECTORIZE // SSE intrinsics aren't designed to allow mixing types
-#endif
-
-#include "main.h"
-
-
-template<int SizeAtCompileType> void mixingtypes(int size = SizeAtCompileType)
-{
- typedef Matrix<float, SizeAtCompileType, SizeAtCompileType> Mat_f;
- typedef Matrix<double, SizeAtCompileType, SizeAtCompileType> Mat_d;
- typedef Matrix<std::complex<float>, SizeAtCompileType, SizeAtCompileType> Mat_cf;
- typedef Matrix<std::complex<double>, SizeAtCompileType, SizeAtCompileType> Mat_cd;
- typedef Matrix<float, SizeAtCompileType, 1> Vec_f;
- typedef Matrix<double, SizeAtCompileType, 1> Vec_d;
- typedef Matrix<std::complex<float>, SizeAtCompileType, 1> Vec_cf;
- typedef Matrix<std::complex<double>, SizeAtCompileType, 1> Vec_cd;
-
- Mat_f mf(size,size);
- Mat_d md(size,size);
- Mat_cf mcf(size,size);
- Mat_cd mcd(size,size);
- Vec_f vf(size,1);
- Vec_d vd(size,1);
- Vec_cf vcf(size,1);
- Vec_cd vcd(size,1);
-
- mf+mf;
- VERIFY_RAISES_ASSERT(mf+md);
- VERIFY_RAISES_ASSERT(mf+mcf);
- VERIFY_RAISES_ASSERT(vf=vd);
- VERIFY_RAISES_ASSERT(vf+=vd);
- VERIFY_RAISES_ASSERT(mcd=md);
-
- mf*mf;
- md*mcd;
- mcd*md;
- mf*vcf;
- mcf*vf;
- mcf *= mf;
- vcd = md*vcd;
- vcf = mcf*vf;
-#if 0
- // these are know generating hard build errors in eigen3
- VERIFY_RAISES_ASSERT(mf*md);
- VERIFY_RAISES_ASSERT(mcf*mcd);
- VERIFY_RAISES_ASSERT(mcf*vcd);
- VERIFY_RAISES_ASSERT(vcf = mf*vf);
-
- vf.eigen2_dot(vf);
- VERIFY_RAISES_ASSERT(vd.eigen2_dot(vf));
- VERIFY_RAISES_ASSERT(vcf.eigen2_dot(vf)); // yeah eventually we should allow this but i'm too lazy to make that change now in Dot.h
- // especially as that might be rewritten as cwise product .sum() which would make that automatic.
-#endif
-}
-
-void test_eigen2_mixingtypes()
-{
- // check that our operator new is indeed called:
- CALL_SUBTEST_1(mixingtypes<3>());
- CALL_SUBTEST_2(mixingtypes<4>());
- CALL_SUBTEST_3(mixingtypes<Dynamic>(20));
-}
diff --git a/test/eigen2/eigen2_newstdvector.cpp b/test/eigen2/eigen2_newstdvector.cpp
deleted file mode 100644
index 5f9009901..000000000
--- a/test/eigen2/eigen2_newstdvector.cpp
+++ /dev/null
@@ -1,149 +0,0 @@
-// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra.
-//
-// Copyright (C) 2008 Benoit Jacob <jacob.benoit.1@gmail.com>
-//
-// 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/.
-
-#define EIGEN_USE_NEW_STDVECTOR
-#include "main.h"
-#include <Eigen/StdVector>
-#include <Eigen/Geometry>
-
-template<typename MatrixType>
-void check_stdvector_matrix(const MatrixType& m)
-{
- int rows = m.rows();
- int cols = m.cols();
- MatrixType x = MatrixType::Random(rows,cols), y = MatrixType::Random(rows,cols);
- std::vector<MatrixType,Eigen::aligned_allocator<MatrixType> > v(10, MatrixType(rows,cols)), w(20, y);
- v[5] = x;
- w[6] = v[5];
- VERIFY_IS_APPROX(w[6], v[5]);
- v = w;
- for(int i = 0; i < 20; i++)
- {
- VERIFY_IS_APPROX(w[i], v[i]);
- }
-
- v.resize(21);
- v[20] = x;
- VERIFY_IS_APPROX(v[20], x);
- v.resize(22,y);
- VERIFY_IS_APPROX(v[21], y);
- v.push_back(x);
- VERIFY_IS_APPROX(v[22], x);
- VERIFY((std::size_t)&(v[22]) == (std::size_t)&(v[21]) + sizeof(MatrixType));
-
- // do a lot of push_back such that the vector gets internally resized
- // (with memory reallocation)
- MatrixType* ref = &w[0];
- for(int i=0; i<30 || ((ref==&w[0]) && i<300); ++i)
- v.push_back(w[i%w.size()]);
- for(unsigned int i=23; i<v.size(); ++i)
- {
- VERIFY(v[i]==w[(i-23)%w.size()]);
- }
-}
-
-template<typename TransformType>
-void check_stdvector_transform(const TransformType&)
-{
- typedef typename TransformType::MatrixType MatrixType;
- TransformType x(MatrixType::Random()), y(MatrixType::Random());
- std::vector<TransformType,Eigen::aligned_allocator<TransformType> > v(10), w(20, y);
- v[5] = x;
- w[6] = v[5];
- VERIFY_IS_APPROX(w[6], v[5]);
- v = w;
- for(int i = 0; i < 20; i++)
- {
- VERIFY_IS_APPROX(w[i], v[i]);
- }
-
- v.resize(21);
- v[20] = x;
- VERIFY_IS_APPROX(v[20], x);
- v.resize(22,y);
- VERIFY_IS_APPROX(v[21], y);
- v.push_back(x);
- VERIFY_IS_APPROX(v[22], x);
- VERIFY((std::size_t)&(v[22]) == (std::size_t)&(v[21]) + sizeof(TransformType));
-
- // do a lot of push_back such that the vector gets internally resized
- // (with memory reallocation)
- TransformType* ref = &w[0];
- for(int i=0; i<30 || ((ref==&w[0]) && i<300); ++i)
- v.push_back(w[i%w.size()]);
- for(unsigned int i=23; i<v.size(); ++i)
- {
- VERIFY(v[i].matrix()==w[(i-23)%w.size()].matrix());
- }
-}
-
-template<typename QuaternionType>
-void check_stdvector_quaternion(const QuaternionType&)
-{
- typedef typename QuaternionType::Coefficients Coefficients;
- QuaternionType x(Coefficients::Random()), y(Coefficients::Random());
- std::vector<QuaternionType,Eigen::aligned_allocator<QuaternionType> > v(10), w(20, y);
- v[5] = x;
- w[6] = v[5];
- VERIFY_IS_APPROX(w[6], v[5]);
- v = w;
- for(int i = 0; i < 20; i++)
- {
- VERIFY_IS_APPROX(w[i], v[i]);
- }
-
- v.resize(21);
- v[20] = x;
- VERIFY_IS_APPROX(v[20], x);
- v.resize(22,y);
- VERIFY_IS_APPROX(v[21], y);
- v.push_back(x);
- VERIFY_IS_APPROX(v[22], x);
- VERIFY((std::size_t)&(v[22]) == (std::size_t)&(v[21]) + sizeof(QuaternionType));
-
- // do a lot of push_back such that the vector gets internally resized
- // (with memory reallocation)
- QuaternionType* ref = &w[0];
- for(int i=0; i<30 || ((ref==&w[0]) && i<300); ++i)
- v.push_back(w[i%w.size()]);
- for(unsigned int i=23; i<v.size(); ++i)
- {
- VERIFY(v[i].coeffs()==w[(i-23)%w.size()].coeffs());
- }
-}
-
-void test_eigen2_newstdvector()
-{
- // some non vectorizable fixed sizes
- CALL_SUBTEST_1(check_stdvector_matrix(Vector2f()));
- CALL_SUBTEST_1(check_stdvector_matrix(Matrix3f()));
- CALL_SUBTEST_1(check_stdvector_matrix(Matrix3d()));
-
- // some vectorizable fixed sizes
- CALL_SUBTEST_2(check_stdvector_matrix(Matrix2f()));
- CALL_SUBTEST_2(check_stdvector_matrix(Vector4f()));
- CALL_SUBTEST_2(check_stdvector_matrix(Matrix4f()));
- CALL_SUBTEST_2(check_stdvector_matrix(Matrix4d()));
-
- // some dynamic sizes
- CALL_SUBTEST_3(check_stdvector_matrix(MatrixXd(1,1)));
- CALL_SUBTEST_3(check_stdvector_matrix(VectorXd(20)));
- CALL_SUBTEST_3(check_stdvector_matrix(RowVectorXf(20)));
- CALL_SUBTEST_3(check_stdvector_matrix(MatrixXcf(10,10)));
-
- // some Transform
- CALL_SUBTEST_4(check_stdvector_transform(Transform2f()));
- CALL_SUBTEST_4(check_stdvector_transform(Transform3f()));
- CALL_SUBTEST_4(check_stdvector_transform(Transform3d()));
- //CALL_SUBTEST(check_stdvector_transform(Transform4d()));
-
- // some Quaternion
- CALL_SUBTEST_5(check_stdvector_quaternion(Quaternionf()));
- CALL_SUBTEST_5(check_stdvector_quaternion(Quaterniond()));
-}
diff --git a/test/eigen2/eigen2_nomalloc.cpp b/test/eigen2/eigen2_nomalloc.cpp
deleted file mode 100644
index e234abe4b..000000000
--- a/test/eigen2/eigen2_nomalloc.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-// 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 <g.gael@free.fr>
-// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
-//
-// 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/.
-
-// this hack is needed to make this file compiles with -pedantic (gcc)
-#ifdef __GNUC__
-#define throw(X)
-#endif
-// discard stack allocation as that too bypasses malloc
-#define EIGEN_STACK_ALLOCATION_LIMIT 0
-// any heap allocation will raise an assert
-#define EIGEN_NO_MALLOC
-
-#include "main.h"
-
-template<typename MatrixType> void nomalloc(const MatrixType& m)
-{
- /* this test check no dynamic memory allocation are issued with fixed-size matrices
- */
-
- typedef typename MatrixType::Scalar Scalar;
- typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, 1> VectorType;
-
- int rows = m.rows();
- int cols = m.cols();
-
- MatrixType m1 = MatrixType::Random(rows, cols),
- m2 = MatrixType::Random(rows, cols),
- m3(rows, cols),
- mzero = MatrixType::Zero(rows, cols),
- identity = Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime>
- ::Identity(rows, rows),
- square = Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime>
- ::Random(rows, rows);
- VectorType v1 = VectorType::Random(rows),
- v2 = VectorType::Random(rows),
- vzero = VectorType::Zero(rows);
-
- Scalar s1 = ei_random<Scalar>();
-
- int r = ei_random<int>(0, rows-1),
- c = ei_random<int>(0, cols-1);
-
- VERIFY_IS_APPROX((m1+m2)*s1, s1*m1+s1*m2);
- VERIFY_IS_APPROX((m1+m2)(r,c), (m1(r,c))+(m2(r,c)));
- VERIFY_IS_APPROX(m1.cwise() * m1.block(0,0,rows,cols), m1.cwise() * m1);
- VERIFY_IS_APPROX((m1*m1.transpose())*m2, m1*(m1.transpose()*m2));
-}
-
-void test_eigen2_nomalloc()
-{
- // check that our operator new is indeed called:
- VERIFY_RAISES_ASSERT(MatrixXd dummy = MatrixXd::Random(3,3));
- CALL_SUBTEST_1( nomalloc(Matrix<float, 1, 1>()) );
- CALL_SUBTEST_2( nomalloc(Matrix4d()) );
- CALL_SUBTEST_3( nomalloc(Matrix<float,32,32>()) );
-}
diff --git a/test/eigen2/eigen2_packetmath.cpp b/test/eigen2/eigen2_packetmath.cpp
deleted file mode 100644
index b1f325fe7..000000000
--- a/test/eigen2/eigen2_packetmath.cpp
+++ /dev/null
@@ -1,132 +0,0 @@
-// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra. Eigen itself is part of the KDE project.
-//
-// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
-//
-// 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"
-
-// using namespace Eigen;
-
-template<typename Scalar> bool areApprox(const Scalar* a, const Scalar* b, int size)
-{
- for (int i=0; i<size; ++i)
- if (!ei_isApprox(a[i],b[i])) return false;
- return true;
-}
-
-#define CHECK_CWISE(REFOP, POP) { \
- for (int i=0; i<PacketSize; ++i) \
- ref[i] = REFOP(data1[i], data1[i+PacketSize]); \
- ei_pstore(data2, POP(ei_pload(data1), ei_pload(data1+PacketSize))); \
- VERIFY(areApprox(ref, data2, PacketSize) && #POP); \
-}
-
-#define REF_ADD(a,b) ((a)+(b))
-#define REF_SUB(a,b) ((a)-(b))
-#define REF_MUL(a,b) ((a)*(b))
-#define REF_DIV(a,b) ((a)/(b))
-
-namespace std {
-
-template<> const complex<float>& min(const complex<float>& a, const complex<float>& b)
-{ return a.real() < b.real() ? a : b; }
-
-template<> const complex<float>& max(const complex<float>& a, const complex<float>& b)
-{ return a.real() < b.real() ? b : a; }
-
-}
-
-template<typename Scalar> void packetmath()
-{
- typedef typename ei_packet_traits<Scalar>::type Packet;
- const int PacketSize = ei_packet_traits<Scalar>::size;
-
- const int size = PacketSize*4;
- EIGEN_ALIGN_128 Scalar data1[ei_packet_traits<Scalar>::size*4];
- EIGEN_ALIGN_128 Scalar data2[ei_packet_traits<Scalar>::size*4];
- EIGEN_ALIGN_128 Packet packets[PacketSize*2];
- EIGEN_ALIGN_128 Scalar ref[ei_packet_traits<Scalar>::size*4];
- for (int i=0; i<size; ++i)
- {
- data1[i] = ei_random<Scalar>();
- data2[i] = ei_random<Scalar>();
- }
-
- ei_pstore(data2, ei_pload(data1));
- VERIFY(areApprox(data1, data2, PacketSize) && "aligned load/store");
-
- for (int offset=0; offset<PacketSize; ++offset)
- {
- ei_pstore(data2, ei_ploadu(data1+offset));
- VERIFY(areApprox(data1+offset, data2, PacketSize) && "ei_ploadu");
- }
-
- for (int offset=0; offset<PacketSize; ++offset)
- {
- ei_pstoreu(data2+offset, ei_pload(data1));
- VERIFY(areApprox(data1, data2+offset, PacketSize) && "ei_pstoreu");
- }
-
- for (int offset=0; offset<PacketSize; ++offset)
- {
- packets[0] = ei_pload(data1);
- packets[1] = ei_pload(data1+PacketSize);
- if (offset==0) ei_palign<0>(packets[0], packets[1]);
- else if (offset==1) ei_palign<1>(packets[0], packets[1]);
- else if (offset==2) ei_palign<2>(packets[0], packets[1]);
- else if (offset==3) ei_palign<3>(packets[0], packets[1]);
- ei_pstore(data2, packets[0]);
-
- for (int i=0; i<PacketSize; ++i)
- ref[i] = data1[i+offset];
-
- typedef Matrix<Scalar, PacketSize, 1> Vector;
- VERIFY(areApprox(ref, data2, PacketSize) && "ei_palign");
- }
-
- CHECK_CWISE(REF_ADD, ei_padd);
- CHECK_CWISE(REF_SUB, ei_psub);
- CHECK_CWISE(REF_MUL, ei_pmul);
- #ifndef EIGEN_VECTORIZE_ALTIVEC
- if (!ei_is_same_type<Scalar,int>::ret)
- CHECK_CWISE(REF_DIV, ei_pdiv);
- #endif
- CHECK_CWISE(std::min, ei_pmin);
- CHECK_CWISE(std::max, ei_pmax);
-
- for (int i=0; i<PacketSize; ++i)
- ref[i] = data1[0];
- ei_pstore(data2, ei_pset1(data1[0]));
- VERIFY(areApprox(ref, data2, PacketSize) && "ei_pset1");
-
- VERIFY(ei_isApprox(data1[0], ei_pfirst(ei_pload(data1))) && "ei_pfirst");
-
- ref[0] = 0;
- for (int i=0; i<PacketSize; ++i)
- ref[0] += data1[i];
- VERIFY(ei_isApprox(ref[0], ei_predux(ei_pload(data1))) && "ei_predux");
-
- for (int j=0; j<PacketSize; ++j)
- {
- ref[j] = 0;
- for (int i=0; i<PacketSize; ++i)
- ref[j] += data1[i+j*PacketSize];
- packets[j] = ei_pload(data1+j*PacketSize);
- }
- ei_pstore(data2, ei_preduxp(packets));
- VERIFY(areApprox(ref, data2, PacketSize) && "ei_preduxp");
-}
-
-void test_eigen2_packetmath()
-{
- for(int i = 0; i < g_repeat; i++) {
- CALL_SUBTEST_1( packetmath<float>() );
- CALL_SUBTEST_2( packetmath<double>() );
- CALL_SUBTEST_3( packetmath<int>() );
- CALL_SUBTEST_4( packetmath<std::complex<float> >() );
- }
-}
diff --git a/test/eigen2/eigen2_parametrizedline.cpp b/test/eigen2/eigen2_parametrizedline.cpp
deleted file mode 100644
index 814728870..000000000
--- a/test/eigen2/eigen2_parametrizedline.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-// 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 <g.gael@free.fr>
-// Copyright (C) 2008 Benoit Jacob <jacob.benoit.1@gmail.com>
-//
-// 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 <Eigen/Geometry>
-#include <Eigen/LU>
-#include <Eigen/QR>
-
-template<typename LineType> void parametrizedline(const LineType& _line)
-{
- /* this test covers the following files:
- ParametrizedLine.h
- */
-
- const int dim = _line.dim();
- typedef typename LineType::Scalar Scalar;
- typedef typename NumTraits<Scalar>::Real RealScalar;
- typedef Matrix<Scalar, LineType::AmbientDimAtCompileTime, 1> VectorType;
- typedef Matrix<Scalar, LineType::AmbientDimAtCompileTime,
- LineType::AmbientDimAtCompileTime> MatrixType;
-
- VectorType p0 = VectorType::Random(dim);
- VectorType p1 = VectorType::Random(dim);
-
- VectorType d0 = VectorType::Random(dim).normalized();
-
- LineType l0(p0, d0);
-
- Scalar s0 = ei_random<Scalar>();
- Scalar s1 = ei_abs(ei_random<Scalar>());
-
- VERIFY_IS_MUCH_SMALLER_THAN( l0.distance(p0), RealScalar(1) );
- VERIFY_IS_MUCH_SMALLER_THAN( l0.distance(p0+s0*d0), RealScalar(1) );
- VERIFY_IS_APPROX( (l0.projection(p1)-p1).norm(), l0.distance(p1) );
- VERIFY_IS_MUCH_SMALLER_THAN( l0.distance(l0.projection(p1)), RealScalar(1) );
- VERIFY_IS_APPROX( Scalar(l0.distance((p0+s0*d0) + d0.unitOrthogonal() * s1)), s1 );
-
- // casting
- const int Dim = LineType::AmbientDimAtCompileTime;
- typedef typename GetDifferentType<Scalar>::type OtherScalar;
- ParametrizedLine<OtherScalar,Dim> hp1f = l0.template cast<OtherScalar>();
- VERIFY_IS_APPROX(hp1f.template cast<Scalar>(),l0);
- ParametrizedLine<Scalar,Dim> hp1d = l0.template cast<Scalar>();
- VERIFY_IS_APPROX(hp1d.template cast<Scalar>(),l0);
-}
-
-void test_eigen2_parametrizedline()
-{
- for(int i = 0; i < g_repeat; i++) {
- CALL_SUBTEST_1( parametrizedline(ParametrizedLine<float,2>()) );
- CALL_SUBTEST_2( parametrizedline(ParametrizedLine<float,3>()) );
- CALL_SUBTEST_3( parametrizedline(ParametrizedLine<double,4>()) );
- CALL_SUBTEST_4( parametrizedline(ParametrizedLine<std::complex<double>,5>()) );
- }
-}
diff --git a/test/eigen2/eigen2_prec_inverse_4x4.cpp b/test/eigen2/eigen2_prec_inverse_4x4.cpp
deleted file mode 100644
index 8bfa55694..000000000
--- a/test/eigen2/eigen2_prec_inverse_4x4.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
-// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra.
-//
-// Copyright (C) 2009 Benoit Jacob <jacob.benoit.1@gmail.com>
-//
-// 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 <Eigen/LU>
-#include <algorithm>
-
-template<typename T> std::string type_name() { return "other"; }
-template<> std::string type_name<float>() { return "float"; }
-template<> std::string type_name<double>() { return "double"; }
-template<> std::string type_name<int>() { return "int"; }
-template<> std::string type_name<std::complex<float> >() { return "complex<float>"; }
-template<> std::string type_name<std::complex<double> >() { return "complex<double>"; }
-template<> std::string type_name<std::complex<int> >() { return "complex<int>"; }
-
-#define EIGEN_DEBUG_VAR(x) std::cerr << #x << " = " << x << std::endl;
-
-template<typename T> inline typename NumTraits<T>::Real epsilon()
-{
- return std::numeric_limits<typename NumTraits<T>::Real>::epsilon();
-}
-
-template<typename MatrixType> void inverse_permutation_4x4()
-{
- typedef typename MatrixType::Scalar Scalar;
- typedef typename MatrixType::RealScalar RealScalar;
- Vector4i indices(0,1,2,3);
- for(int i = 0; i < 24; ++i)
- {
- MatrixType m = MatrixType::Zero();
- m(indices(0),0) = 1;
- m(indices(1),1) = 1;
- m(indices(2),2) = 1;
- m(indices(3),3) = 1;
- MatrixType inv = m.inverse();
- double error = double( (m*inv-MatrixType::Identity()).norm() / epsilon<Scalar>() );
- VERIFY(error == 0.0);
- std::next_permutation(indices.data(),indices.data()+4);
- }
-}
-
-template<typename MatrixType> void inverse_general_4x4(int repeat)
-{
- typedef typename MatrixType::Scalar Scalar;
- typedef typename MatrixType::RealScalar RealScalar;
- double error_sum = 0., error_max = 0.;
- for(int i = 0; i < repeat; ++i)
- {
- MatrixType m;
- RealScalar absdet;
- do {
- m = MatrixType::Random();
- absdet = ei_abs(m.determinant());
- } while(absdet < 10 * epsilon<Scalar>());
- MatrixType inv = m.inverse();
- double error = double( (m*inv-MatrixType::Identity()).norm() * absdet / epsilon<Scalar>() );
- error_sum += error;
- error_max = std::max(error_max, error);
- }
- std::cerr << "inverse_general_4x4, Scalar = " << type_name<Scalar>() << std::endl;
- double error_avg = error_sum / repeat;
- EIGEN_DEBUG_VAR(error_avg);
- EIGEN_DEBUG_VAR(error_max);
- VERIFY(error_avg < (NumTraits<Scalar>::IsComplex ? 8.0 : 1.25));
- VERIFY(error_max < (NumTraits<Scalar>::IsComplex ? 64.0 : 20.0));
-}
-
-void test_eigen2_prec_inverse_4x4()
-{
- CALL_SUBTEST_1((inverse_permutation_4x4<Matrix4f>()));
- CALL_SUBTEST_1(( inverse_general_4x4<Matrix4f>(200000 * g_repeat) ));
-
- CALL_SUBTEST_2((inverse_permutation_4x4<Matrix<double,4,4,RowMajor> >()));
- CALL_SUBTEST_2(( inverse_general_4x4<Matrix<double,4,4,RowMajor> >(200000 * g_repeat) ));
-
- CALL_SUBTEST_3((inverse_permutation_4x4<Matrix4cf>()));
- CALL_SUBTEST_3((inverse_general_4x4<Matrix4cf>(50000 * g_repeat)));
-}
diff --git a/test/eigen2/eigen2_product_large.cpp b/test/eigen2/eigen2_product_large.cpp
deleted file mode 100644
index 5149ef748..000000000
--- a/test/eigen2/eigen2_product_large.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra. Eigen itself is part of the KDE project.
-//
-// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
-//
-// 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 "product.h"
-
-void test_eigen2_product_large()
-{
- for(int i = 0; i < g_repeat; i++) {
- CALL_SUBTEST_1( product(MatrixXf(ei_random<int>(1,320), ei_random<int>(1,320))) );
- CALL_SUBTEST_2( product(MatrixXd(ei_random<int>(1,320), ei_random<int>(1,320))) );
- CALL_SUBTEST_3( product(MatrixXi(ei_random<int>(1,320), ei_random<int>(1,320))) );
- CALL_SUBTEST_4( product(MatrixXcf(ei_random<int>(1,50), ei_random<int>(1,50))) );
- CALL_SUBTEST_5( product(Matrix<float,Dynamic,Dynamic,RowMajor>(ei_random<int>(1,320), ei_random<int>(1,320))) );
- }
-
-#ifdef EIGEN_TEST_PART_6
- {
- // test a specific issue in DiagonalProduct
- int N = 1000000;
- VectorXf v = VectorXf::Ones(N);
- MatrixXf m = MatrixXf::Ones(N,3);
- m = (v+v).asDiagonal() * m;
- VERIFY_IS_APPROX(m, MatrixXf::Constant(N,3,2));
- }
-
- {
- // test deferred resizing in Matrix::operator=
- MatrixXf a = MatrixXf::Random(10,4), b = MatrixXf::Random(4,10), c = a;
- VERIFY_IS_APPROX((a = a * b), (c * b).eval());
- }
-
- {
- MatrixXf mat1(10,10); mat1.setRandom();
- MatrixXf mat2(32,10); mat2.setRandom();
- MatrixXf result = mat1.row(2)*mat2.transpose();
- VERIFY_IS_APPROX(result, (mat1.row(2)*mat2.transpose()).eval());
- }
-#endif
-}
diff --git a/test/eigen2/eigen2_product_small.cpp b/test/eigen2/eigen2_product_small.cpp
deleted file mode 100644
index 4cd8c102f..000000000
--- a/test/eigen2/eigen2_product_small.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra. Eigen itself is part of the KDE project.
-//
-// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
-//
-// 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/.
-
-#define EIGEN_NO_STATIC_ASSERT
-#include "product.h"
-
-void test_eigen2_product_small()
-{
- for(int i = 0; i < g_repeat; i++) {
- CALL_SUBTEST_1( product(Matrix<float, 3, 2>()) );
- CALL_SUBTEST_2( product(Matrix<int, 3, 5>()) );
- CALL_SUBTEST_3( product(Matrix3d()) );
- CALL_SUBTEST_4( product(Matrix4d()) );
- CALL_SUBTEST_5( product(Matrix4f()) );
- }
-}
diff --git a/test/eigen2/eigen2_qr.cpp b/test/eigen2/eigen2_qr.cpp
deleted file mode 100644
index 76977e4c1..000000000
--- a/test/eigen2/eigen2_qr.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-// 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 <g.gael@free.fr>
-//
-// 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 <Eigen/QR>
-
-template<typename MatrixType> void qr(const MatrixType& m)
-{
- /* this test covers the following files:
- QR.h
- */
- int rows = m.rows();
- int cols = m.cols();
-
- typedef typename MatrixType::Scalar Scalar;
- typedef Matrix<Scalar, MatrixType::ColsAtCompileTime, MatrixType::ColsAtCompileTime> SquareMatrixType;
- typedef Matrix<Scalar, MatrixType::ColsAtCompileTime, 1> VectorType;
-
- MatrixType a = MatrixType::Random(rows,cols);
- QR<MatrixType> qrOfA(a);
- VERIFY_IS_APPROX(a, qrOfA.matrixQ() * qrOfA.matrixR());
- VERIFY_IS_NOT_APPROX(a+MatrixType::Identity(rows, cols), qrOfA.matrixQ() * qrOfA.matrixR());
-
- #if 0 // eigenvalues module not yet ready
- SquareMatrixType b = a.adjoint() * a;
-
- // check tridiagonalization
- Tridiagonalization<SquareMatrixType> tridiag(b);
- VERIFY_IS_APPROX(b, tridiag.matrixQ() * tridiag.matrixT() * tridiag.matrixQ().adjoint());
-
- // check hessenberg decomposition
- HessenbergDecomposition<SquareMatrixType> hess(b);
- VERIFY_IS_APPROX(b, hess.matrixQ() * hess.matrixH() * hess.matrixQ().adjoint());
- VERIFY_IS_APPROX(tridiag.matrixT(), hess.matrixH());
- b = SquareMatrixType::Random(cols,cols);
- hess.compute(b);
- VERIFY_IS_APPROX(b, hess.matrixQ() * hess.matrixH() * hess.matrixQ().adjoint());
- #endif
-}
-
-void test_eigen2_qr()
-{
- for(int i = 0; i < 1; i++) {
- CALL_SUBTEST_1( qr(Matrix2f()) );
- CALL_SUBTEST_2( qr(Matrix4d()) );
- CALL_SUBTEST_3( qr(MatrixXf(12,8)) );
- CALL_SUBTEST_4( qr(MatrixXcd(5,5)) );
- CALL_SUBTEST_4( qr(MatrixXcd(7,3)) );
- }
-
-#ifdef EIGEN_TEST_PART_5
- // small isFullRank test
- {
- Matrix3d mat;
- mat << 1, 45, 1, 2, 2, 2, 1, 2, 3;
- VERIFY(mat.qr().isFullRank());
- mat << 1, 1, 1, 2, 2, 2, 1, 2, 3;
- //always returns true in eigen2support
- //VERIFY(!mat.qr().isFullRank());
- }
-
-#endif
-}
diff --git a/test/eigen2/eigen2_qtvector.cpp b/test/eigen2/eigen2_qtvector.cpp
deleted file mode 100644
index 6cfb58a26..000000000
--- a/test/eigen2/eigen2_qtvector.cpp
+++ /dev/null
@@ -1,158 +0,0 @@
-// 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 <g.gael@free.fr>
-// Copyright (C) 2008 Benoit Jacob <jacob.benoit.1@gmail.com>
-//
-// 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/.
-
-#define EIGEN_WORK_AROUND_QT_BUG_CALLING_WRONG_OPERATOR_NEW_FIXED_IN_QT_4_5
-
-#include "main.h"
-
-#include <Eigen/Geometry>
-#include <Eigen/QtAlignedMalloc>
-
-#include <QtCore/QVector>
-
-template<typename MatrixType>
-void check_qtvector_matrix(const MatrixType& m)
-{
- int rows = m.rows();
- int cols = m.cols();
- MatrixType x = MatrixType::Random(rows,cols), y = MatrixType::Random(rows,cols);
- QVector<MatrixType> v(10, MatrixType(rows,cols)), w(20, y);
- for(int i = 0; i < 20; i++)
- {
- VERIFY_IS_APPROX(w[i], y);
- }
- v[5] = x;
- w[6] = v[5];
- VERIFY_IS_APPROX(w[6], v[5]);
- v = w;
- for(int i = 0; i < 20; i++)
- {
- VERIFY_IS_APPROX(w[i], v[i]);
- }
-
- v.resize(21);
- v[20] = x;
- VERIFY_IS_APPROX(v[20], x);
- v.fill(y,22);
- VERIFY_IS_APPROX(v[21], y);
- v.push_back(x);
- VERIFY_IS_APPROX(v[22], x);
- VERIFY((size_t)&(v[22]) == (size_t)&(v[21]) + sizeof(MatrixType));
-
- // do a lot of push_back such that the vector gets internally resized
- // (with memory reallocation)
- MatrixType* ref = &w[0];
- for(int i=0; i<30 || ((ref==&w[0]) && i<300); ++i)
- v.push_back(w[i%w.size()]);
- for(int i=23; i<v.size(); ++i)
- {
- VERIFY(v[i]==w[(i-23)%w.size()]);
- }
-}
-
-template<typename TransformType>
-void check_qtvector_transform(const TransformType&)
-{
- typedef typename TransformType::MatrixType MatrixType;
- TransformType x(MatrixType::Random()), y(MatrixType::Random());
- QVector<TransformType> v(10), w(20, y);
- v[5] = x;
- w[6] = v[5];
- VERIFY_IS_APPROX(w[6], v[5]);
- v = w;
- for(int i = 0; i < 20; i++)
- {
- VERIFY_IS_APPROX(w[i], v[i]);
- }
-
- v.resize(21);
- v[20] = x;
- VERIFY_IS_APPROX(v[20], x);
- v.fill(y,22);
- VERIFY_IS_APPROX(v[21], y);
- v.push_back(x);
- VERIFY_IS_APPROX(v[22], x);
- VERIFY((size_t)&(v[22]) == (size_t)&(v[21]) + sizeof(TransformType));
-
- // do a lot of push_back such that the vector gets internally resized
- // (with memory reallocation)
- TransformType* ref = &w[0];
- for(int i=0; i<30 || ((ref==&w[0]) && i<300); ++i)
- v.push_back(w[i%w.size()]);
- for(unsigned int i=23; int(i)<v.size(); ++i)
- {
- VERIFY(v[i].matrix()==w[(i-23)%w.size()].matrix());
- }
-}
-
-template<typename QuaternionType>
-void check_qtvector_quaternion(const QuaternionType&)
-{
- typedef typename QuaternionType::Coefficients Coefficients;
- QuaternionType x(Coefficients::Random()), y(Coefficients::Random());
- QVector<QuaternionType> v(10), w(20, y);
- v[5] = x;
- w[6] = v[5];
- VERIFY_IS_APPROX(w[6], v[5]);
- v = w;
- for(int i = 0; i < 20; i++)
- {
- VERIFY_IS_APPROX(w[i], v[i]);
- }
-
- v.resize(21);
- v[20] = x;
- VERIFY_IS_APPROX(v[20], x);
- v.fill(y,22);
- VERIFY_IS_APPROX(v[21], y);
- v.push_back(x);
- VERIFY_IS_APPROX(v[22], x);
- VERIFY((size_t)&(v[22]) == (size_t)&(v[21]) + sizeof(QuaternionType));
-
- // do a lot of push_back such that the vector gets internally resized
- // (with memory reallocation)
- QuaternionType* ref = &w[0];
- for(int i=0; i<30 || ((ref==&w[0]) && i<300); ++i)
- v.push_back(w[i%w.size()]);
- for(unsigned int i=23; int(i)<v.size(); ++i)
- {
- VERIFY(v[i].coeffs()==w[(i-23)%w.size()].coeffs());
- }
-}
-
-void test_eigen2_qtvector()
-{
- // some non vectorizable fixed sizes
- CALL_SUBTEST_1(check_qtvector_matrix(Vector2f()));
- CALL_SUBTEST_1(check_qtvector_matrix(Matrix3f()));
- CALL_SUBTEST_1(check_qtvector_matrix(Matrix3d()));
-
- // some vectorizable fixed sizes
- CALL_SUBTEST_2(check_qtvector_matrix(Matrix2f()));
- CALL_SUBTEST_2(check_qtvector_matrix(Vector4f()));
- CALL_SUBTEST_2(check_qtvector_matrix(Matrix4f()));
- CALL_SUBTEST_2(check_qtvector_matrix(Matrix4d()));
-
- // some dynamic sizes
- CALL_SUBTEST_3(check_qtvector_matrix(MatrixXd(1,1)));
- CALL_SUBTEST_3(check_qtvector_matrix(VectorXd(20)));
- CALL_SUBTEST_3(check_qtvector_matrix(RowVectorXf(20)));
- CALL_SUBTEST_3(check_qtvector_matrix(MatrixXcf(10,10)));
-
- // some Transform
- CALL_SUBTEST_4(check_qtvector_transform(Transform2f()));
- CALL_SUBTEST_4(check_qtvector_transform(Transform3f()));
- CALL_SUBTEST_4(check_qtvector_transform(Transform3d()));
- //CALL_SUBTEST_4(check_qtvector_transform(Transform4d()));
-
- // some Quaternion
- CALL_SUBTEST_5(check_qtvector_quaternion(Quaternionf()));
- CALL_SUBTEST_5(check_qtvector_quaternion(Quaternionf()));
-}
diff --git a/test/eigen2/eigen2_regression.cpp b/test/eigen2/eigen2_regression.cpp
deleted file mode 100644
index c68b58da8..000000000
--- a/test/eigen2/eigen2_regression.cpp
+++ /dev/null
@@ -1,136 +0,0 @@
-// 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 Benoit Jacob <jacob.benoit.1@gmail.com>
-//
-// 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 <Eigen/LeastSquares>
-
-template<typename VectorType,
- typename HyperplaneType>
-void makeNoisyCohyperplanarPoints(int numPoints,
- VectorType **points,
- HyperplaneType *hyperplane,
- typename VectorType::Scalar noiseAmplitude)
-{
- typedef typename VectorType::Scalar Scalar;
- const int size = points[0]->size();
- // pick a random hyperplane, store the coefficients of its equation
- hyperplane->coeffs().resize(size + 1);
- for(int j = 0; j < size + 1; j++)
- {
- do {
- hyperplane->coeffs().coeffRef(j) = ei_random<Scalar>();
- } while(ei_abs(hyperplane->coeffs().coeff(j)) < 0.5);
- }
-
- // now pick numPoints random points on this hyperplane
- for(int i = 0; i < numPoints; i++)
- {
- VectorType& cur_point = *(points[i]);
- do
- {
- cur_point = VectorType::Random(size)/*.normalized()*/;
- // project cur_point onto the hyperplane
- Scalar x = - (hyperplane->coeffs().start(size).cwise()*cur_point).sum();
- cur_point *= hyperplane->coeffs().coeff(size) / x;
- } while( cur_point.norm() < 0.5
- || cur_point.norm() > 2.0 );
- }
-
- // add some noise to these points
- for(int i = 0; i < numPoints; i++ )
- *(points[i]) += noiseAmplitude * VectorType::Random(size);
-}
-
-template<typename VectorType>
-void check_linearRegression(int numPoints,
- VectorType **points,
- const VectorType& original,
- typename VectorType::Scalar tolerance)
-{
- int size = points[0]->size();
- assert(size==2);
- VectorType result(size);
- linearRegression(numPoints, points, &result, 1);
- typename VectorType::Scalar error = (result - original).norm() / original.norm();
- VERIFY(ei_abs(error) < ei_abs(tolerance));
-}
-
-template<typename VectorType,
- typename HyperplaneType>
-void check_fitHyperplane(int numPoints,
- VectorType **points,
- const HyperplaneType& original,
- typename VectorType::Scalar tolerance)
-{
- int size = points[0]->size();
- HyperplaneType result(size);
- fitHyperplane(numPoints, points, &result);
- result.coeffs() *= original.coeffs().coeff(size)/result.coeffs().coeff(size);
- typename VectorType::Scalar error = (result.coeffs() - original.coeffs()).norm() / original.coeffs().norm();
- std::cout << ei_abs(error) << " xxx " << ei_abs(tolerance) << std::endl;
- VERIFY(ei_abs(error) < ei_abs(tolerance));
-}
-
-void test_eigen2_regression()
-{
- for(int i = 0; i < g_repeat; i++)
- {
-#ifdef EIGEN_TEST_PART_1
- {
- Vector2f points2f [1000];
- Vector2f *points2f_ptrs [1000];
- for(int i = 0; i < 1000; i++) points2f_ptrs[i] = &(points2f[i]);
- Vector2f coeffs2f;
- Hyperplane<float,2> coeffs3f;
- makeNoisyCohyperplanarPoints(1000, points2f_ptrs, &coeffs3f, 0.01f);
- coeffs2f[0] = -coeffs3f.coeffs()[0]/coeffs3f.coeffs()[1];
- coeffs2f[1] = -coeffs3f.coeffs()[2]/coeffs3f.coeffs()[1];
- CALL_SUBTEST(check_linearRegression(10, points2f_ptrs, coeffs2f, 0.05f));
- CALL_SUBTEST(check_linearRegression(100, points2f_ptrs, coeffs2f, 0.01f));
- CALL_SUBTEST(check_linearRegression(1000, points2f_ptrs, coeffs2f, 0.002f));
- }
-#endif
-#ifdef EIGEN_TEST_PART_2
- {
- Vector2f points2f [1000];
- Vector2f *points2f_ptrs [1000];
- for(int i = 0; i < 1000; i++) points2f_ptrs[i] = &(points2f[i]);
- Hyperplane<float,2> coeffs3f;
- makeNoisyCohyperplanarPoints(1000, points2f_ptrs, &coeffs3f, 0.01f);
- CALL_SUBTEST(check_fitHyperplane(10, points2f_ptrs, coeffs3f, 0.05f));
- CALL_SUBTEST(check_fitHyperplane(100, points2f_ptrs, coeffs3f, 0.01f));
- CALL_SUBTEST(check_fitHyperplane(1000, points2f_ptrs, coeffs3f, 0.002f));
- }
-#endif
-#ifdef EIGEN_TEST_PART_3
- {
- Vector4d points4d [1000];
- Vector4d *points4d_ptrs [1000];
- for(int i = 0; i < 1000; i++) points4d_ptrs[i] = &(points4d[i]);
- Hyperplane<double,4> coeffs5d;
- makeNoisyCohyperplanarPoints(1000, points4d_ptrs, &coeffs5d, 0.01);
- CALL_SUBTEST(check_fitHyperplane(10, points4d_ptrs, coeffs5d, 0.05));
- CALL_SUBTEST(check_fitHyperplane(100, points4d_ptrs, coeffs5d, 0.01));
- CALL_SUBTEST(check_fitHyperplane(1000, points4d_ptrs, coeffs5d, 0.002));
- }
-#endif
-#ifdef EIGEN_TEST_PART_4
- {
- VectorXcd *points11cd_ptrs[1000];
- for(int i = 0; i < 1000; i++) points11cd_ptrs[i] = new VectorXcd(11);
- Hyperplane<std::complex<double>,Dynamic> *coeffs12cd = new Hyperplane<std::complex<double>,Dynamic>(11);
- makeNoisyCohyperplanarPoints(1000, points11cd_ptrs, coeffs12cd, 0.01);
- CALL_SUBTEST(check_fitHyperplane(100, points11cd_ptrs, *coeffs12cd, 0.025));
- CALL_SUBTEST(check_fitHyperplane(1000, points11cd_ptrs, *coeffs12cd, 0.006));
- delete coeffs12cd;
- for(int i = 0; i < 1000; i++) delete points11cd_ptrs[i];
- }
-#endif
- }
-}
diff --git a/test/eigen2/eigen2_sizeof.cpp b/test/eigen2/eigen2_sizeof.cpp
deleted file mode 100644
index ec1af5a06..000000000
--- a/test/eigen2/eigen2_sizeof.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-// 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 <g.gael@free.fr>
-//
-// 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"
-
-template<typename MatrixType> void verifySizeOf(const MatrixType&)
-{
- typedef typename MatrixType::Scalar Scalar;
- if (MatrixType::RowsAtCompileTime!=Dynamic && MatrixType::ColsAtCompileTime!=Dynamic)
- VERIFY(sizeof(MatrixType)==sizeof(Scalar)*MatrixType::SizeAtCompileTime);
- else
- VERIFY(sizeof(MatrixType)==sizeof(Scalar*) + 2 * sizeof(typename MatrixType::Index));
-}
-
-void test_eigen2_sizeof()
-{
- CALL_SUBTEST( verifySizeOf(Matrix<float, 1, 1>()) );
- 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>()) );
-}
diff --git a/test/eigen2/eigen2_smallvectors.cpp b/test/eigen2/eigen2_smallvectors.cpp
deleted file mode 100644
index 03962b17d..000000000
--- a/test/eigen2/eigen2_smallvectors.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra. Eigen itself is part of the KDE project.
-//
-// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
-//
-// 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"
-
-template<typename Scalar> void smallVectors()
-{
- typedef Matrix<Scalar, 1, 2> V2;
- typedef Matrix<Scalar, 3, 1> V3;
- typedef Matrix<Scalar, 1, 4> V4;
- Scalar x1 = ei_random<Scalar>(),
- x2 = ei_random<Scalar>(),
- x3 = ei_random<Scalar>(),
- x4 = ei_random<Scalar>();
- V2 v2(x1, x2);
- V3 v3(x1, x2, x3);
- V4 v4(x1, x2, x3, x4);
- VERIFY_IS_APPROX(x1, v2.x());
- VERIFY_IS_APPROX(x1, v3.x());
- VERIFY_IS_APPROX(x1, v4.x());
- VERIFY_IS_APPROX(x2, v2.y());
- VERIFY_IS_APPROX(x2, v3.y());
- VERIFY_IS_APPROX(x2, v4.y());
- VERIFY_IS_APPROX(x3, v3.z());
- VERIFY_IS_APPROX(x3, v4.z());
- VERIFY_IS_APPROX(x4, v4.w());
-}
-
-void test_eigen2_smallvectors()
-{
- for(int i = 0; i < g_repeat; i++) {
- CALL_SUBTEST( smallVectors<int>() );
- CALL_SUBTEST( smallVectors<float>() );
- CALL_SUBTEST( smallVectors<double>() );
- }
-}
diff --git a/test/eigen2/eigen2_sparse_basic.cpp b/test/eigen2/eigen2_sparse_basic.cpp
deleted file mode 100644
index 049077670..000000000
--- a/test/eigen2/eigen2_sparse_basic.cpp
+++ /dev/null
@@ -1,317 +0,0 @@
-// 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 Daniel Gomez Ferro <dgomezferro@gmail.com>
-//
-// 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 "sparse.h"
-
-template<typename SetterType,typename DenseType, typename Scalar, int Options>
-bool test_random_setter(SparseMatrix<Scalar,Options>& sm, const DenseType& ref, const std::vector<Vector2i>& nonzeroCoords)
-{
- typedef SparseMatrix<Scalar,Options> SparseType;
- {
- sm.setZero();
- SetterType w(sm);
- std::vector<Vector2i> remaining = nonzeroCoords;
- while(!remaining.empty())
- {
- int i = ei_random<int>(0,remaining.size()-1);
- w(remaining[i].x(),remaining[i].y()) = ref.coeff(remaining[i].x(),remaining[i].y());
- remaining[i] = remaining.back();
- remaining.pop_back();
- }
- }
- return sm.isApprox(ref);
-}
-
-template<typename SetterType,typename DenseType, typename T>
-bool test_random_setter(DynamicSparseMatrix<T>& sm, const DenseType& ref, const std::vector<Vector2i>& nonzeroCoords)
-{
- sm.setZero();
- std::vector<Vector2i> remaining = nonzeroCoords;
- while(!remaining.empty())
- {
- int i = ei_random<int>(0,remaining.size()-1);
- sm.coeffRef(remaining[i].x(),remaining[i].y()) = ref.coeff(remaining[i].x(),remaining[i].y());
- remaining[i] = remaining.back();
- remaining.pop_back();
- }
- return sm.isApprox(ref);
-}
-
-template<typename SparseMatrixType> void sparse_basic(const SparseMatrixType& ref)
-{
- const int rows = ref.rows();
- const int cols = ref.cols();
- typedef typename SparseMatrixType::Scalar Scalar;
- enum { Flags = SparseMatrixType::Flags };
-
- double density = std::max(8./(rows*cols), 0.01);
- typedef Matrix<Scalar,Dynamic,Dynamic> DenseMatrix;
- typedef Matrix<Scalar,Dynamic,1> DenseVector;
- Scalar eps = 1e-6;
-
- SparseMatrixType m(rows, cols);
- DenseMatrix refMat = DenseMatrix::Zero(rows, cols);
- DenseVector vec1 = DenseVector::Random(rows);
- Scalar s1 = ei_random<Scalar>();
-
- std::vector<Vector2i> zeroCoords;
- std::vector<Vector2i> nonzeroCoords;
- initSparse<Scalar>(density, refMat, m, 0, &zeroCoords, &nonzeroCoords);
-
- if (zeroCoords.size()==0 || nonzeroCoords.size()==0)
- return;
-
- // test coeff and coeffRef
- for (int i=0; i<(int)zeroCoords.size(); ++i)
- {
- VERIFY_IS_MUCH_SMALLER_THAN( m.coeff(zeroCoords[i].x(),zeroCoords[i].y()), eps );
- if(ei_is_same_type<SparseMatrixType,SparseMatrix<Scalar,Flags> >::ret)
- VERIFY_RAISES_ASSERT( m.coeffRef(zeroCoords[0].x(),zeroCoords[0].y()) = 5 );
- }
- VERIFY_IS_APPROX(m, refMat);
-
- m.coeffRef(nonzeroCoords[0].x(), nonzeroCoords[0].y()) = Scalar(5);
- refMat.coeffRef(nonzeroCoords[0].x(), nonzeroCoords[0].y()) = Scalar(5);
-
- VERIFY_IS_APPROX(m, refMat);
- /*
- // test InnerIterators and Block expressions
- for (int t=0; t<10; ++t)
- {
- int j = ei_random<int>(0,cols-1);
- int i = ei_random<int>(0,rows-1);
- int w = ei_random<int>(1,cols-j-1);
- int h = ei_random<int>(1,rows-i-1);
-
-// VERIFY_IS_APPROX(m.block(i,j,h,w), refMat.block(i,j,h,w));
- for(int c=0; c<w; c++)
- {
- VERIFY_IS_APPROX(m.block(i,j,h,w).col(c), refMat.block(i,j,h,w).col(c));
- for(int r=0; r<h; r++)
- {
-// VERIFY_IS_APPROX(m.block(i,j,h,w).col(c).coeff(r), refMat.block(i,j,h,w).col(c).coeff(r));
- }
- }
-// for(int r=0; r<h; r++)
-// {
-// VERIFY_IS_APPROX(m.block(i,j,h,w).row(r), refMat.block(i,j,h,w).row(r));
-// for(int c=0; c<w; c++)
-// {
-// VERIFY_IS_APPROX(m.block(i,j,h,w).row(r).coeff(c), refMat.block(i,j,h,w).row(r).coeff(c));
-// }
-// }
- }
-
- for(int c=0; c<cols; c++)
- {
- VERIFY_IS_APPROX(m.col(c) + m.col(c), (m + m).col(c));
- VERIFY_IS_APPROX(m.col(c) + m.col(c), refMat.col(c) + refMat.col(c));
- }
-
- for(int r=0; r<rows; r++)
- {
- VERIFY_IS_APPROX(m.row(r) + m.row(r), (m + m).row(r));
- VERIFY_IS_APPROX(m.row(r) + m.row(r), refMat.row(r) + refMat.row(r));
- }
- */
-
- // test SparseSetters
- // coherent setter
- // TODO extend the MatrixSetter
-// {
-// m.setZero();
-// VERIFY_IS_NOT_APPROX(m, refMat);
-// SparseSetter<SparseMatrixType, FullyCoherentAccessPattern> w(m);
-// for (int i=0; i<nonzeroCoords.size(); ++i)
-// {
-// w->coeffRef(nonzeroCoords[i].x(),nonzeroCoords[i].y()) = refMat.coeff(nonzeroCoords[i].x(),nonzeroCoords[i].y());
-// }
-// }
-// VERIFY_IS_APPROX(m, refMat);
-
- // random setter
-// {
-// m.setZero();
-// VERIFY_IS_NOT_APPROX(m, refMat);
-// SparseSetter<SparseMatrixType, RandomAccessPattern> w(m);
-// std::vector<Vector2i> remaining = nonzeroCoords;
-// while(!remaining.empty())
-// {
-// int i = ei_random<int>(0,remaining.size()-1);
-// w->coeffRef(remaining[i].x(),remaining[i].y()) = refMat.coeff(remaining[i].x(),remaining[i].y());
-// remaining[i] = remaining.back();
-// remaining.pop_back();
-// }
-// }
-// VERIFY_IS_APPROX(m, refMat);
-
- VERIFY(( test_random_setter<RandomSetter<SparseMatrixType, StdMapTraits> >(m,refMat,nonzeroCoords) ));
- #ifdef EIGEN_UNORDERED_MAP_SUPPORT
- VERIFY(( test_random_setter<RandomSetter<SparseMatrixType, StdUnorderedMapTraits> >(m,refMat,nonzeroCoords) ));
- #endif
- #ifdef _DENSE_HASH_MAP_H_
- VERIFY(( test_random_setter<RandomSetter<SparseMatrixType, GoogleDenseHashMapTraits> >(m,refMat,nonzeroCoords) ));
- #endif
- #ifdef _SPARSE_HASH_MAP_H_
- VERIFY(( test_random_setter<RandomSetter<SparseMatrixType, GoogleSparseHashMapTraits> >(m,refMat,nonzeroCoords) ));
- #endif
-
- // test fillrand
- {
- DenseMatrix m1(rows,cols);
- m1.setZero();
- SparseMatrixType m2(rows,cols);
- m2.startFill();
- for (int j=0; j<cols; ++j)
- {
- for (int k=0; k<rows/2; ++k)
- {
- int i = ei_random<int>(0,rows-1);
- if (m1.coeff(i,j)==Scalar(0))
- m2.fillrand(i,j) = m1(i,j) = ei_random<Scalar>();
- }
- }
- m2.endFill();
- VERIFY_IS_APPROX(m2,m1);
- }
-
- // test RandomSetter
- /*{
- SparseMatrixType m1(rows,cols), m2(rows,cols);
- DenseMatrix refM1 = DenseMatrix::Zero(rows, rows);
- initSparse<Scalar>(density, refM1, m1);
- {
- Eigen::RandomSetter<SparseMatrixType > setter(m2);
- for (int j=0; j<m1.outerSize(); ++j)
- for (typename SparseMatrixType::InnerIterator i(m1,j); i; ++i)
- setter(i.index(), j) = i.value();
- }
- VERIFY_IS_APPROX(m1, m2);
- }*/
-// std::cerr << m.transpose() << "\n\n" << refMat.transpose() << "\n\n";
-// VERIFY_IS_APPROX(m, refMat);
-
- // test basic computations
- {
- DenseMatrix refM1 = DenseMatrix::Zero(rows, rows);
- DenseMatrix refM2 = DenseMatrix::Zero(rows, rows);
- DenseMatrix refM3 = DenseMatrix::Zero(rows, rows);
- DenseMatrix refM4 = DenseMatrix::Zero(rows, rows);
- SparseMatrixType m1(rows, rows);
- SparseMatrixType m2(rows, rows);
- SparseMatrixType m3(rows, rows);
- SparseMatrixType m4(rows, rows);
- initSparse<Scalar>(density, refM1, m1);
- initSparse<Scalar>(density, refM2, m2);
- initSparse<Scalar>(density, refM3, m3);
- initSparse<Scalar>(density, refM4, m4);
-
- VERIFY_IS_APPROX(m1+m2, refM1+refM2);
- VERIFY_IS_APPROX(m1+m2+m3, refM1+refM2+refM3);
- VERIFY_IS_APPROX(m3.cwise()*(m1+m2), refM3.cwise()*(refM1+refM2));
- VERIFY_IS_APPROX(m1*s1-m2, refM1*s1-refM2);
-
- VERIFY_IS_APPROX(m1*=s1, refM1*=s1);
- VERIFY_IS_APPROX(m1/=s1, refM1/=s1);
-
- VERIFY_IS_APPROX(m1+=m2, refM1+=refM2);
- VERIFY_IS_APPROX(m1-=m2, refM1-=refM2);
-
- VERIFY_IS_APPROX(m1.col(0).eigen2_dot(refM2.row(0)), refM1.col(0).eigen2_dot(refM2.row(0)));
-
- refM4.setRandom();
- // sparse cwise* dense
- VERIFY_IS_APPROX(m3.cwise()*refM4, refM3.cwise()*refM4);
-// VERIFY_IS_APPROX(m3.cwise()/refM4, refM3.cwise()/refM4);
- }
-
- // test innerVector()
- {
- DenseMatrix refMat2 = DenseMatrix::Zero(rows, rows);
- SparseMatrixType m2(rows, rows);
- initSparse<Scalar>(density, refMat2, m2);
- int j0 = ei_random(0,rows-1);
- int j1 = ei_random(0,rows-1);
- VERIFY_IS_APPROX(m2.innerVector(j0), refMat2.col(j0));
- VERIFY_IS_APPROX(m2.innerVector(j0)+m2.innerVector(j1), refMat2.col(j0)+refMat2.col(j1));
- //m2.innerVector(j0) = 2*m2.innerVector(j1);
- //refMat2.col(j0) = 2*refMat2.col(j1);
- //VERIFY_IS_APPROX(m2, refMat2);
- }
-
- // test innerVectors()
- {
- DenseMatrix refMat2 = DenseMatrix::Zero(rows, rows);
- SparseMatrixType m2(rows, rows);
- initSparse<Scalar>(density, refMat2, m2);
- int j0 = ei_random(0,rows-2);
- int j1 = ei_random(0,rows-2);
- int n0 = ei_random<int>(1,rows-std::max(j0,j1));
- VERIFY_IS_APPROX(m2.innerVectors(j0,n0), refMat2.block(0,j0,rows,n0));
- VERIFY_IS_APPROX(m2.innerVectors(j0,n0)+m2.innerVectors(j1,n0),
- refMat2.block(0,j0,rows,n0)+refMat2.block(0,j1,rows,n0));
- //m2.innerVectors(j0,n0) = m2.innerVectors(j0,n0) + m2.innerVectors(j1,n0);
- //refMat2.block(0,j0,rows,n0) = refMat2.block(0,j0,rows,n0) + refMat2.block(0,j1,rows,n0);
- }
-
- // test transpose
- {
- DenseMatrix refMat2 = DenseMatrix::Zero(rows, rows);
- SparseMatrixType m2(rows, rows);
- initSparse<Scalar>(density, refMat2, m2);
- VERIFY_IS_APPROX(m2.transpose().eval(), refMat2.transpose().eval());
- VERIFY_IS_APPROX(m2.transpose(), refMat2.transpose());
- }
-
- // test prune
- {
- SparseMatrixType m2(rows, rows);
- DenseMatrix refM2(rows, rows);
- refM2.setZero();
- int countFalseNonZero = 0;
- int countTrueNonZero = 0;
- m2.startFill();
- for (int j=0; j<m2.outerSize(); ++j)
- for (int i=0; i<m2.innerSize(); ++i)
- {
- float x = ei_random<float>(0,1);
- if (x<0.1)
- {
- // do nothing
- }
- else if (x<0.5)
- {
- countFalseNonZero++;
- m2.fill(i,j) = Scalar(0);
- }
- else
- {
- countTrueNonZero++;
- m2.fill(i,j) = refM2(i,j) = Scalar(1);
- }
- }
- m2.endFill();
- VERIFY(countFalseNonZero+countTrueNonZero == m2.nonZeros());
- VERIFY_IS_APPROX(m2, refM2);
- m2.prune(1);
- VERIFY(countTrueNonZero==m2.nonZeros());
- VERIFY_IS_APPROX(m2, refM2);
- }
-}
-
-void test_eigen2_sparse_basic()
-{
- for(int i = 0; i < g_repeat; i++) {
- CALL_SUBTEST_1( sparse_basic(SparseMatrix<double>(8, 8)) );
- CALL_SUBTEST_2( sparse_basic(SparseMatrix<std::complex<double> >(16, 16)) );
- CALL_SUBTEST_1( sparse_basic(SparseMatrix<double>(33, 33)) );
-
- CALL_SUBTEST_3( sparse_basic(DynamicSparseMatrix<double>(8, 8)) );
- }
-}
diff --git a/test/eigen2/eigen2_sparse_product.cpp b/test/eigen2/eigen2_sparse_product.cpp
deleted file mode 100644
index d28e76dff..000000000
--- a/test/eigen2/eigen2_sparse_product.cpp
+++ /dev/null
@@ -1,115 +0,0 @@
-// 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 Daniel Gomez Ferro <dgomezferro@gmail.com>
-//
-// 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 "sparse.h"
-
-template<typename SparseMatrixType> void sparse_product(const SparseMatrixType& ref)
-{
- const int rows = ref.rows();
- const int cols = ref.cols();
- typedef typename SparseMatrixType::Scalar Scalar;
- enum { Flags = SparseMatrixType::Flags };
-
- double density = std::max(8./(rows*cols), 0.01);
- typedef Matrix<Scalar,Dynamic,Dynamic> DenseMatrix;
- typedef Matrix<Scalar,Dynamic,1> DenseVector;
-
- // test matrix-matrix product
- {
- DenseMatrix refMat2 = DenseMatrix::Zero(rows, rows);
- DenseMatrix refMat3 = DenseMatrix::Zero(rows, rows);
- DenseMatrix refMat4 = DenseMatrix::Zero(rows, rows);
- DenseMatrix dm4 = DenseMatrix::Zero(rows, rows);
- SparseMatrixType m2(rows, rows);
- SparseMatrixType m3(rows, rows);
- SparseMatrixType m4(rows, rows);
- initSparse<Scalar>(density, refMat2, m2);
- initSparse<Scalar>(density, refMat3, m3);
- initSparse<Scalar>(density, refMat4, m4);
- VERIFY_IS_APPROX(m4=m2*m3, refMat4=refMat2*refMat3);
- VERIFY_IS_APPROX(m4=m2.transpose()*m3, refMat4=refMat2.transpose()*refMat3);
- VERIFY_IS_APPROX(m4=m2.transpose()*m3.transpose(), refMat4=refMat2.transpose()*refMat3.transpose());
- VERIFY_IS_APPROX(m4=m2*m3.transpose(), refMat4=refMat2*refMat3.transpose());
-
- // sparse * dense
- VERIFY_IS_APPROX(dm4=m2*refMat3, refMat4=refMat2*refMat3);
- VERIFY_IS_APPROX(dm4=m2*refMat3.transpose(), refMat4=refMat2*refMat3.transpose());
- VERIFY_IS_APPROX(dm4=m2.transpose()*refMat3, refMat4=refMat2.transpose()*refMat3);
- VERIFY_IS_APPROX(dm4=m2.transpose()*refMat3.transpose(), refMat4=refMat2.transpose()*refMat3.transpose());
-
- // dense * sparse
- VERIFY_IS_APPROX(dm4=refMat2*m3, refMat4=refMat2*refMat3);
- VERIFY_IS_APPROX(dm4=refMat2*m3.transpose(), refMat4=refMat2*refMat3.transpose());
- VERIFY_IS_APPROX(dm4=refMat2.transpose()*m3, refMat4=refMat2.transpose()*refMat3);
- VERIFY_IS_APPROX(dm4=refMat2.transpose()*m3.transpose(), refMat4=refMat2.transpose()*refMat3.transpose());
-
- VERIFY_IS_APPROX(m3=m3*m3, refMat3=refMat3*refMat3);
- }
-
- // test matrix - diagonal product
- if(false) // it compiles, but the precision is terrible. probably doesn't matter in this branch....
- {
- DenseMatrix refM2 = DenseMatrix::Zero(rows, rows);
- DenseMatrix refM3 = DenseMatrix::Zero(rows, rows);
- DiagonalMatrix<DenseVector> d1(DenseVector::Random(rows));
- SparseMatrixType m2(rows, rows);
- SparseMatrixType m3(rows, rows);
- initSparse<Scalar>(density, refM2, m2);
- initSparse<Scalar>(density, refM3, m3);
- VERIFY_IS_APPROX(m3=m2*d1, refM3=refM2*d1);
- VERIFY_IS_APPROX(m3=m2.transpose()*d1, refM3=refM2.transpose()*d1);
- VERIFY_IS_APPROX(m3=d1*m2, refM3=d1*refM2);
- VERIFY_IS_APPROX(m3=d1*m2.transpose(), refM3=d1 * refM2.transpose());
- }
-
- // test self adjoint products
- {
- DenseMatrix b = DenseMatrix::Random(rows, rows);
- DenseMatrix x = DenseMatrix::Random(rows, rows);
- DenseMatrix refX = DenseMatrix::Random(rows, rows);
- DenseMatrix refUp = DenseMatrix::Zero(rows, rows);
- DenseMatrix refLo = DenseMatrix::Zero(rows, rows);
- DenseMatrix refS = DenseMatrix::Zero(rows, rows);
- SparseMatrixType mUp(rows, rows);
- SparseMatrixType mLo(rows, rows);
- SparseMatrixType mS(rows, rows);
- do {
- initSparse<Scalar>(density, refUp, mUp, ForceRealDiag|/*ForceNonZeroDiag|*/MakeUpperTriangular);
- } while (refUp.isZero());
- refLo = refUp.transpose().conjugate();
- mLo = mUp.transpose().conjugate();
- refS = refUp + refLo;
- refS.diagonal() *= 0.5;
- mS = mUp + mLo;
- for (int k=0; k<mS.outerSize(); ++k)
- for (typename SparseMatrixType::InnerIterator it(mS,k); it; ++it)
- if (it.index() == k)
- it.valueRef() *= 0.5;
-
- VERIFY_IS_APPROX(refS.adjoint(), refS);
- VERIFY_IS_APPROX(mS.transpose().conjugate(), mS);
- VERIFY_IS_APPROX(mS, refS);
- VERIFY_IS_APPROX(x=mS*b, refX=refS*b);
- VERIFY_IS_APPROX(x=mUp.template marked<UpperTriangular|SelfAdjoint>()*b, refX=refS*b);
- VERIFY_IS_APPROX(x=mLo.template marked<LowerTriangular|SelfAdjoint>()*b, refX=refS*b);
- VERIFY_IS_APPROX(x=mS.template marked<SelfAdjoint>()*b, refX=refS*b);
- }
-
-}
-
-void test_eigen2_sparse_product()
-{
- for(int i = 0; i < g_repeat; i++) {
- CALL_SUBTEST_1( sparse_product(SparseMatrix<double>(8, 8)) );
- CALL_SUBTEST_2( sparse_product(SparseMatrix<std::complex<double> >(16, 16)) );
- CALL_SUBTEST_1( sparse_product(SparseMatrix<double>(33, 33)) );
-
- CALL_SUBTEST_3( sparse_product(DynamicSparseMatrix<double>(8, 8)) );
- }
-}
diff --git a/test/eigen2/eigen2_sparse_solvers.cpp b/test/eigen2/eigen2_sparse_solvers.cpp
deleted file mode 100644
index 3aef27ab4..000000000
--- a/test/eigen2/eigen2_sparse_solvers.cpp
+++ /dev/null
@@ -1,200 +0,0 @@
-// 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 Daniel Gomez Ferro <dgomezferro@gmail.com>
-//
-// 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 "sparse.h"
-
-template<typename Scalar> void
-initSPD(double density,
- Matrix<Scalar,Dynamic,Dynamic>& refMat,
- SparseMatrix<Scalar>& sparseMat)
-{
- Matrix<Scalar,Dynamic,Dynamic> aux(refMat.rows(),refMat.cols());
- initSparse(density,refMat,sparseMat);
- refMat = refMat * refMat.adjoint();
- for (int k=0; k<2; ++k)
- {
- initSparse(density,aux,sparseMat,ForceNonZeroDiag);
- refMat += aux * aux.adjoint();
- }
- sparseMat.startFill();
- for (int j=0 ; j<sparseMat.cols(); ++j)
- for (int i=j ; i<sparseMat.rows(); ++i)
- if (refMat(i,j)!=Scalar(0))
- sparseMat.fill(i,j) = refMat(i,j);
- sparseMat.endFill();
-}
-
-template<typename Scalar> void sparse_solvers(int rows, int cols)
-{
- double density = std::max(8./(rows*cols), 0.01);
- typedef Matrix<Scalar,Dynamic,Dynamic> DenseMatrix;
- typedef Matrix<Scalar,Dynamic,1> DenseVector;
- // Scalar eps = 1e-6;
-
- DenseVector vec1 = DenseVector::Random(rows);
-
- std::vector<Vector2i> zeroCoords;
- std::vector<Vector2i> nonzeroCoords;
-
- // test triangular solver
- {
- DenseVector vec2 = vec1, vec3 = vec1;
- SparseMatrix<Scalar> m2(rows, cols);
- DenseMatrix refMat2 = DenseMatrix::Zero(rows, cols);
-
- // lower
- initSparse<Scalar>(density, refMat2, m2, ForceNonZeroDiag|MakeLowerTriangular, &zeroCoords, &nonzeroCoords);
- VERIFY_IS_APPROX(refMat2.template marked<LowerTriangular>().solveTriangular(vec2),
- m2.template marked<LowerTriangular>().solveTriangular(vec3));
-
- // lower - transpose
- initSparse<Scalar>(density, refMat2, m2, ForceNonZeroDiag|MakeLowerTriangular, &zeroCoords, &nonzeroCoords);
- VERIFY_IS_APPROX(refMat2.template marked<LowerTriangular>().transpose().solveTriangular(vec2),
- m2.template marked<LowerTriangular>().transpose().solveTriangular(vec3));
-
- // upper
- initSparse<Scalar>(density, refMat2, m2, ForceNonZeroDiag|MakeUpperTriangular, &zeroCoords, &nonzeroCoords);
- VERIFY_IS_APPROX(refMat2.template marked<UpperTriangular>().solveTriangular(vec2),
- m2.template marked<UpperTriangular>().solveTriangular(vec3));
-
- // upper - transpose
- initSparse<Scalar>(density, refMat2, m2, ForceNonZeroDiag|MakeUpperTriangular, &zeroCoords, &nonzeroCoords);
- VERIFY_IS_APPROX(refMat2.template marked<UpperTriangular>().transpose().solveTriangular(vec2),
- m2.template marked<UpperTriangular>().transpose().solveTriangular(vec3));
- }
-
- // test LLT
- {
- // TODO fix the issue with complex (see SparseLLT::solveInPlace)
- SparseMatrix<Scalar> m2(rows, cols);
- DenseMatrix refMat2(rows, cols);
-
- DenseVector b = DenseVector::Random(cols);
- DenseVector refX(cols), x(cols);
-
- initSPD(density, refMat2, m2);
-
- refMat2.llt().solve(b, &refX);
- typedef SparseMatrix<Scalar,LowerTriangular|SelfAdjoint> SparseSelfAdjointMatrix;
- if (!NumTraits<Scalar>::IsComplex)
- {
- x = b;
- SparseLLT<SparseSelfAdjointMatrix> (m2).solveInPlace(x);
- VERIFY(refX.isApprox(x,test_precision<Scalar>()) && "LLT: default");
- }
- #ifdef EIGEN_CHOLMOD_SUPPORT
- x = b;
- SparseLLT<SparseSelfAdjointMatrix,Cholmod>(m2).solveInPlace(x);
- VERIFY(refX.isApprox(x,test_precision<Scalar>()) && "LLT: cholmod");
- #endif
- if (!NumTraits<Scalar>::IsComplex)
- {
- #ifdef EIGEN_TAUCS_SUPPORT
- x = b;
- SparseLLT<SparseSelfAdjointMatrix,Taucs>(m2,IncompleteFactorization).solveInPlace(x);
- VERIFY(refX.isApprox(x,test_precision<Scalar>()) && "LLT: taucs (IncompleteFactorization)");
- x = b;
- SparseLLT<SparseSelfAdjointMatrix,Taucs>(m2,SupernodalMultifrontal).solveInPlace(x);
- VERIFY(refX.isApprox(x,test_precision<Scalar>()) && "LLT: taucs (SupernodalMultifrontal)");
- x = b;
- SparseLLT<SparseSelfAdjointMatrix,Taucs>(m2,SupernodalLeftLooking).solveInPlace(x);
- VERIFY(refX.isApprox(x,test_precision<Scalar>()) && "LLT: taucs (SupernodalLeftLooking)");
- #endif
- }
- }
-
- // test LDLT
- if (!NumTraits<Scalar>::IsComplex)
- {
- // TODO fix the issue with complex (see SparseLDLT::solveInPlace)
- SparseMatrix<Scalar> m2(rows, cols);
- DenseMatrix refMat2(rows, cols);
-
- DenseVector b = DenseVector::Random(cols);
- DenseVector refX(cols), x(cols);
-
- //initSPD(density, refMat2, m2);
- initSparse<Scalar>(density, refMat2, m2, ForceNonZeroDiag|MakeUpperTriangular, 0, 0);
- refMat2 += refMat2.adjoint();
- refMat2.diagonal() *= 0.5;
-
- refMat2.ldlt().solve(b, &refX);
- typedef SparseMatrix<Scalar,UpperTriangular|SelfAdjoint> SparseSelfAdjointMatrix;
- x = b;
- SparseLDLT<SparseSelfAdjointMatrix> ldlt(m2);
- if (ldlt.succeeded())
- ldlt.solveInPlace(x);
- VERIFY(refX.isApprox(x,test_precision<Scalar>()) && "LDLT: default");
- }
-
- // test LU
- {
- static int count = 0;
- SparseMatrix<Scalar> m2(rows, cols);
- DenseMatrix refMat2(rows, cols);
-
- DenseVector b = DenseVector::Random(cols);
- DenseVector refX(cols), x(cols);
-
- initSparse<Scalar>(density, refMat2, m2, ForceNonZeroDiag, &zeroCoords, &nonzeroCoords);
-
- LU<DenseMatrix> refLu(refMat2);
- refLu.solve(b, &refX);
- #if defined(EIGEN_SUPERLU_SUPPORT) || defined(EIGEN_UMFPACK_SUPPORT)
- Scalar refDet = refLu.determinant();
- #endif
- x.setZero();
- // // SparseLU<SparseMatrix<Scalar> > (m2).solve(b,&x);
- // // VERIFY(refX.isApprox(x,test_precision<Scalar>()) && "LU: default");
- #ifdef EIGEN_SUPERLU_SUPPORT
- {
- x.setZero();
- SparseLU<SparseMatrix<Scalar>,SuperLU> slu(m2);
- if (slu.succeeded())
- {
- if (slu.solve(b,&x)) {
- VERIFY(refX.isApprox(x,test_precision<Scalar>()) && "LU: SuperLU");
- }
- // std::cerr << refDet << " == " << slu.determinant() << "\n";
- if (count==0) {
- VERIFY_IS_APPROX(refDet,slu.determinant()); // FIXME det is not very stable for complex
- }
- }
- }
- #endif
- #ifdef EIGEN_UMFPACK_SUPPORT
- {
- // check solve
- x.setZero();
- SparseLU<SparseMatrix<Scalar>,UmfPack> slu(m2);
- if (slu.succeeded()) {
- if (slu.solve(b,&x)) {
- if (count==0) {
- VERIFY(refX.isApprox(x,test_precision<Scalar>()) && "LU: umfpack"); // FIXME solve is not very stable for complex
- }
- }
- VERIFY_IS_APPROX(refDet,slu.determinant());
- // TODO check the extracted data
- //std::cerr << slu.matrixL() << "\n";
- }
- }
- #endif
- count++;
- }
-
-}
-
-void test_eigen2_sparse_solvers()
-{
- for(int i = 0; i < g_repeat; i++) {
- CALL_SUBTEST_1( sparse_solvers<double>(8, 8) );
- CALL_SUBTEST_2( sparse_solvers<std::complex<double> >(16, 16) );
- CALL_SUBTEST_1( sparse_solvers<double>(101, 101) );
- }
-}
diff --git a/test/eigen2/eigen2_sparse_vector.cpp b/test/eigen2/eigen2_sparse_vector.cpp
deleted file mode 100644
index e6d2d77a1..000000000
--- a/test/eigen2/eigen2_sparse_vector.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
-// 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 Daniel Gomez Ferro <dgomezferro@gmail.com>
-//
-// 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 "sparse.h"
-
-template<typename Scalar> void sparse_vector(int rows, int cols)
-{
- double densityMat = std::max(8./(rows*cols), 0.01);
- double densityVec = std::max(8./float(rows), 0.1);
- typedef Matrix<Scalar,Dynamic,Dynamic> DenseMatrix;
- typedef Matrix<Scalar,Dynamic,1> DenseVector;
- typedef SparseVector<Scalar> SparseVectorType;
- typedef SparseMatrix<Scalar> SparseMatrixType;
- Scalar eps = 1e-6;
-
- SparseMatrixType m1(rows,cols);
- SparseVectorType v1(rows), v2(rows), v3(rows);
- DenseMatrix refM1 = DenseMatrix::Zero(rows, cols);
- DenseVector refV1 = DenseVector::Random(rows),
- refV2 = DenseVector::Random(rows),
- refV3 = DenseVector::Random(rows);
-
- std::vector<int> zerocoords, nonzerocoords;
- initSparse<Scalar>(densityVec, refV1, v1, &zerocoords, &nonzerocoords);
- initSparse<Scalar>(densityMat, refM1, m1);
-
- initSparse<Scalar>(densityVec, refV2, v2);
- initSparse<Scalar>(densityVec, refV3, v3);
-
- Scalar s1 = ei_random<Scalar>();
-
- // test coeff and coeffRef
- for (unsigned int i=0; i<zerocoords.size(); ++i)
- {
- VERIFY_IS_MUCH_SMALLER_THAN( v1.coeff(zerocoords[i]), eps );
- //VERIFY_RAISES_ASSERT( v1.coeffRef(zerocoords[i]) = 5 );
- }
- {
- VERIFY(int(nonzerocoords.size()) == v1.nonZeros());
- int j=0;
- for (typename SparseVectorType::InnerIterator it(v1); it; ++it,++j)
- {
- VERIFY(nonzerocoords[j]==it.index());
- VERIFY(it.value()==v1.coeff(it.index()));
- VERIFY(it.value()==refV1.coeff(it.index()));
- }
- }
- VERIFY_IS_APPROX(v1, refV1);
-
- v1.coeffRef(nonzerocoords[0]) = Scalar(5);
- refV1.coeffRef(nonzerocoords[0]) = Scalar(5);
- VERIFY_IS_APPROX(v1, refV1);
-
- VERIFY_IS_APPROX(v1+v2, refV1+refV2);
- VERIFY_IS_APPROX(v1+v2+v3, refV1+refV2+refV3);
-
- VERIFY_IS_APPROX(v1*s1-v2, refV1*s1-refV2);
-
- VERIFY_IS_APPROX(v1*=s1, refV1*=s1);
- VERIFY_IS_APPROX(v1/=s1, refV1/=s1);
-
- VERIFY_IS_APPROX(v1+=v2, refV1+=refV2);
- VERIFY_IS_APPROX(v1-=v2, refV1-=refV2);
-
- VERIFY_IS_APPROX(v1.eigen2_dot(v2), refV1.eigen2_dot(refV2));
- VERIFY_IS_APPROX(v1.eigen2_dot(refV2), refV1.eigen2_dot(refV2));
-
-}
-
-void test_eigen2_sparse_vector()
-{
- for(int i = 0; i < g_repeat; i++) {
- CALL_SUBTEST_1( sparse_vector<double>(8, 8) );
- CALL_SUBTEST_2( sparse_vector<std::complex<double> >(16, 16) );
- CALL_SUBTEST_1( sparse_vector<double>(299, 535) );
- }
-}
-
diff --git a/test/eigen2/eigen2_stdvector.cpp b/test/eigen2/eigen2_stdvector.cpp
deleted file mode 100644
index 6ab05c20a..000000000
--- a/test/eigen2/eigen2_stdvector.cpp
+++ /dev/null
@@ -1,148 +0,0 @@
-// 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 Benoit Jacob <jacob.benoit.1@gmail.com>
-//
-// 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 <Eigen/StdVector>
-#include "main.h"
-#include <Eigen/Geometry>
-
-template<typename MatrixType>
-void check_stdvector_matrix(const MatrixType& m)
-{
- int rows = m.rows();
- int cols = m.cols();
- MatrixType x = MatrixType::Random(rows,cols), y = MatrixType::Random(rows,cols);
- std::vector<MatrixType, aligned_allocator<MatrixType> > v(10, MatrixType(rows,cols)), w(20, y);
- v[5] = x;
- w[6] = v[5];
- VERIFY_IS_APPROX(w[6], v[5]);
- v = w;
- for(int i = 0; i < 20; i++)
- {
- VERIFY_IS_APPROX(w[i], v[i]);
- }
-
- v.resize(21);
- v[20] = x;
- VERIFY_IS_APPROX(v[20], x);
- v.resize(22,y);
- VERIFY_IS_APPROX(v[21], y);
- v.push_back(x);
- VERIFY_IS_APPROX(v[22], x);
- VERIFY((std::size_t)&(v[22]) == (std::size_t)&(v[21]) + sizeof(MatrixType));
-
- // do a lot of push_back such that the vector gets internally resized
- // (with memory reallocation)
- MatrixType* ref = &w[0];
- for(int i=0; i<30 || ((ref==&w[0]) && i<300); ++i)
- v.push_back(w[i%w.size()]);
- for(unsigned int i=23; i<v.size(); ++i)
- {
- VERIFY(v[i]==w[(i-23)%w.size()]);
- }
-}
-
-template<typename TransformType>
-void check_stdvector_transform(const TransformType&)
-{
- typedef typename TransformType::MatrixType MatrixType;
- TransformType x(MatrixType::Random()), y(MatrixType::Random());
- std::vector<TransformType, aligned_allocator<TransformType> > v(10), w(20, y);
- v[5] = x;
- w[6] = v[5];
- VERIFY_IS_APPROX(w[6], v[5]);
- v = w;
- for(int i = 0; i < 20; i++)
- {
- VERIFY_IS_APPROX(w[i], v[i]);
- }
-
- v.resize(21);
- v[20] = x;
- VERIFY_IS_APPROX(v[20], x);
- v.resize(22,y);
- VERIFY_IS_APPROX(v[21], y);
- v.push_back(x);
- VERIFY_IS_APPROX(v[22], x);
- VERIFY((std::size_t)&(v[22]) == (std::size_t)&(v[21]) + sizeof(TransformType));
-
- // do a lot of push_back such that the vector gets internally resized
- // (with memory reallocation)
- TransformType* ref = &w[0];
- for(int i=0; i<30 || ((ref==&w[0]) && i<300); ++i)
- v.push_back(w[i%w.size()]);
- for(unsigned int i=23; i<v.size(); ++i)
- {
- VERIFY(v[i].matrix()==w[(i-23)%w.size()].matrix());
- }
-}
-
-template<typename QuaternionType>
-void check_stdvector_quaternion(const QuaternionType&)
-{
- typedef typename QuaternionType::Coefficients Coefficients;
- QuaternionType x(Coefficients::Random()), y(Coefficients::Random());
- std::vector<QuaternionType, aligned_allocator<QuaternionType> > v(10), w(20, y);
- v[5] = x;
- w[6] = v[5];
- VERIFY_IS_APPROX(w[6], v[5]);
- v = w;
- for(int i = 0; i < 20; i++)
- {
- VERIFY_IS_APPROX(w[i], v[i]);
- }
-
- v.resize(21);
- v[20] = x;
- VERIFY_IS_APPROX(v[20], x);
- v.resize(22,y);
- VERIFY_IS_APPROX(v[21], y);
- v.push_back(x);
- VERIFY_IS_APPROX(v[22], x);
- VERIFY((std::size_t)&(v[22]) == (std::size_t)&(v[21]) + sizeof(QuaternionType));
-
- // do a lot of push_back such that the vector gets internally resized
- // (with memory reallocation)
- QuaternionType* ref = &w[0];
- for(int i=0; i<30 || ((ref==&w[0]) && i<300); ++i)
- v.push_back(w[i%w.size()]);
- for(unsigned int i=23; i<v.size(); ++i)
- {
- VERIFY(v[i].coeffs()==w[(i-23)%w.size()].coeffs());
- }
-}
-
-void test_eigen2_stdvector()
-{
- // some non vectorizable fixed sizes
- CALL_SUBTEST_1(check_stdvector_matrix(Vector2f()));
- CALL_SUBTEST_1(check_stdvector_matrix(Matrix3f()));
- CALL_SUBTEST_1(check_stdvector_matrix(Matrix3d()));
-
- // some vectorizable fixed sizes
- CALL_SUBTEST_2(check_stdvector_matrix(Matrix2f()));
- CALL_SUBTEST_2(check_stdvector_matrix(Vector4f()));
- CALL_SUBTEST_2(check_stdvector_matrix(Matrix4f()));
- CALL_SUBTEST_2(check_stdvector_matrix(Matrix4d()));
-
- // some dynamic sizes
- CALL_SUBTEST_3(check_stdvector_matrix(MatrixXd(1,1)));
- CALL_SUBTEST_3(check_stdvector_matrix(VectorXd(20)));
- CALL_SUBTEST_3(check_stdvector_matrix(RowVectorXf(20)));
- CALL_SUBTEST_3(check_stdvector_matrix(MatrixXcf(10,10)));
-
- // some Transform
- CALL_SUBTEST_4(check_stdvector_transform(Transform2f()));
- CALL_SUBTEST_4(check_stdvector_transform(Transform3f()));
- CALL_SUBTEST_4(check_stdvector_transform(Transform3d()));
- //CALL_SUBTEST_4(check_stdvector_transform(Transform4d()));
-
- // some Quaternion
- CALL_SUBTEST_5(check_stdvector_quaternion(Quaternionf()));
- CALL_SUBTEST_5(check_stdvector_quaternion(Quaternionf()));
-}
diff --git a/test/eigen2/eigen2_submatrices.cpp b/test/eigen2/eigen2_submatrices.cpp
deleted file mode 100644
index c5d3f243d..000000000
--- a/test/eigen2/eigen2_submatrices.cpp
+++ /dev/null
@@ -1,148 +0,0 @@
-// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra. Eigen itself is part of the KDE project.
-//
-// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
-//
-// 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"
-
-// check minor separately in order to avoid the possible creation of a zero-sized
-// array. Comes from a compilation error with gcc-3.4 or gcc-4 with -ansi -pedantic.
-// Another solution would be to declare the array like this: T m_data[Size==0?1:Size]; in ei_matrix_storage
-// but this is probably not bad to raise such an error at compile time...
-template<typename Scalar, int _Rows, int _Cols> struct CheckMinor
-{
- typedef Matrix<Scalar, _Rows, _Cols> MatrixType;
- CheckMinor(MatrixType& m1, int r1, int c1)
- {
- int rows = m1.rows();
- int cols = m1.cols();
-
- Matrix<Scalar, Dynamic, Dynamic> mi = m1.minor(0,0).eval();
- VERIFY_IS_APPROX(mi, m1.block(1,1,rows-1,cols-1));
- mi = m1.minor(r1,c1);
- VERIFY_IS_APPROX(mi.transpose(), m1.transpose().minor(c1,r1));
- //check operator(), both constant and non-constant, on minor()
- m1.minor(r1,c1)(0,0) = m1.minor(0,0)(0,0);
- }
-};
-
-template<typename Scalar> struct CheckMinor<Scalar,1,1>
-{
- typedef Matrix<Scalar, 1, 1> MatrixType;
- CheckMinor(MatrixType&, int, int) {}
-};
-
-template<typename MatrixType> void submatrices(const MatrixType& m)
-{
- /* this test covers the following files:
- Row.h Column.h Block.h Minor.h DiagonalCoeffs.h
- */
- typedef typename MatrixType::Scalar Scalar;
- typedef typename MatrixType::RealScalar RealScalar;
- typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, 1> VectorType;
- typedef Matrix<Scalar, 1, MatrixType::ColsAtCompileTime> RowVectorType;
- int rows = m.rows();
- int cols = m.cols();
-
- MatrixType m1 = MatrixType::Random(rows, cols),
- m2 = MatrixType::Random(rows, cols),
- m3(rows, cols),
- mzero = MatrixType::Zero(rows, cols),
- ones = MatrixType::Ones(rows, cols),
- identity = Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime>
- ::Identity(rows, rows),
- square = Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime>
- ::Random(rows, rows);
- VectorType v1 = VectorType::Random(rows),
- v2 = VectorType::Random(rows),
- v3 = VectorType::Random(rows),
- vzero = VectorType::Zero(rows);
-
- Scalar s1 = ei_random<Scalar>();
-
- int r1 = ei_random<int>(0,rows-1);
- int r2 = ei_random<int>(r1,rows-1);
- int c1 = ei_random<int>(0,cols-1);
- int c2 = ei_random<int>(c1,cols-1);
-
- //check row() and col()
- VERIFY_IS_APPROX(m1.col(c1).transpose(), m1.transpose().row(c1));
- VERIFY_IS_APPROX(square.row(r1).eigen2_dot(m1.col(c1)), (square.lazy() * m1.conjugate())(r1,c1));
- //check operator(), both constant and non-constant, on row() and col()
- m1.row(r1) += s1 * m1.row(r2);
- m1.col(c1) += s1 * m1.col(c2);
-
- //check block()
- Matrix<Scalar,Dynamic,Dynamic> b1(1,1); b1(0,0) = m1(r1,c1);
- RowVectorType br1(m1.block(r1,0,1,cols));
- VectorType bc1(m1.block(0,c1,rows,1));
- VERIFY_IS_APPROX(b1, m1.block(r1,c1,1,1));
- VERIFY_IS_APPROX(m1.row(r1), br1);
- VERIFY_IS_APPROX(m1.col(c1), bc1);
- //check operator(), both constant and non-constant, on block()
- m1.block(r1,c1,r2-r1+1,c2-c1+1) = s1 * m2.block(0, 0, r2-r1+1,c2-c1+1);
- m1.block(r1,c1,r2-r1+1,c2-c1+1)(r2-r1,c2-c1) = m2.block(0, 0, r2-r1+1,c2-c1+1)(0,0);
-
- //check minor()
- CheckMinor<Scalar, MatrixType::RowsAtCompileTime, MatrixType::ColsAtCompileTime> checkminor(m1,r1,c1);
-
- //check diagonal()
- VERIFY_IS_APPROX(m1.diagonal(), m1.transpose().diagonal());
- m2.diagonal() = 2 * m1.diagonal();
- m2.diagonal()[0] *= 3;
- VERIFY_IS_APPROX(m2.diagonal()[0], static_cast<Scalar>(6) * m1.diagonal()[0]);
-
- enum {
- BlockRows = EIGEN_SIZE_MIN_PREFER_FIXED(MatrixType::RowsAtCompileTime,2),
- BlockCols = EIGEN_SIZE_MIN_PREFER_FIXED(MatrixType::ColsAtCompileTime,5)
- };
- if (rows>=5 && cols>=8)
- {
- // test fixed block() as lvalue
- m1.template block<BlockRows,BlockCols>(1,1) *= s1;
- // test operator() on fixed block() both as constant and non-constant
- m1.template block<BlockRows,BlockCols>(1,1)(0, 3) = m1.template block<2,5>(1,1)(1,2);
- // check that fixed block() and block() agree
- Matrix<Scalar,Dynamic,Dynamic> b = m1.template block<BlockRows,BlockCols>(3,3);
- VERIFY_IS_APPROX(b, m1.block(3,3,BlockRows,BlockCols));
- }
-
- if (rows>2)
- {
- // test sub vectors
- VERIFY_IS_APPROX(v1.template start<2>(), v1.block(0,0,2,1));
- VERIFY_IS_APPROX(v1.template start<2>(), v1.start(2));
- VERIFY_IS_APPROX(v1.template start<2>(), v1.segment(0,2));
- VERIFY_IS_APPROX(v1.template start<2>(), v1.template segment<2>(0));
- int i = rows-2;
- VERIFY_IS_APPROX(v1.template end<2>(), v1.block(i,0,2,1));
- VERIFY_IS_APPROX(v1.template end<2>(), v1.end(2));
- VERIFY_IS_APPROX(v1.template end<2>(), v1.segment(i,2));
- VERIFY_IS_APPROX(v1.template end<2>(), v1.template segment<2>(i));
- i = ei_random(0,rows-2);
- VERIFY_IS_APPROX(v1.segment(i,2), v1.template segment<2>(i));
- }
-
- // stress some basic stuffs with block matrices
- VERIFY(ei_real(ones.col(c1).sum()) == RealScalar(rows));
- VERIFY(ei_real(ones.row(r1).sum()) == RealScalar(cols));
-
- VERIFY(ei_real(ones.col(c1).eigen2_dot(ones.col(c2))) == RealScalar(rows));
- VERIFY(ei_real(ones.row(r1).eigen2_dot(ones.row(r2))) == RealScalar(cols));
-}
-
-void test_eigen2_submatrices()
-{
- for(int i = 0; i < g_repeat; i++) {
- CALL_SUBTEST_1( submatrices(Matrix<float, 1, 1>()) );
- CALL_SUBTEST_2( submatrices(Matrix4d()) );
- CALL_SUBTEST_3( submatrices(MatrixXcf(3, 3)) );
- CALL_SUBTEST_4( submatrices(MatrixXi(8, 12)) );
- CALL_SUBTEST_5( submatrices(MatrixXcd(20, 20)) );
- CALL_SUBTEST_6( submatrices(MatrixXf(20, 20)) );
- }
-}
diff --git a/test/eigen2/eigen2_sum.cpp b/test/eigen2/eigen2_sum.cpp
deleted file mode 100644
index b47057caa..000000000
--- a/test/eigen2/eigen2_sum.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-// 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 Benoit Jacob <jacob.benoit.1@gmail.com>
-//
-// 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"
-
-template<typename MatrixType> void matrixSum(const MatrixType& m)
-{
- typedef typename MatrixType::Scalar Scalar;
-
- int rows = m.rows();
- int cols = m.cols();
-
- MatrixType m1 = MatrixType::Random(rows, cols);
-
- VERIFY_IS_MUCH_SMALLER_THAN(MatrixType::Zero(rows, cols).sum(), Scalar(1));
- VERIFY_IS_APPROX(MatrixType::Ones(rows, cols).sum(), Scalar(float(rows*cols))); // the float() here to shut up excessive MSVC warning about int->complex conversion being lossy
- Scalar x = Scalar(0);
- for(int i = 0; i < rows; i++) for(int j = 0; j < cols; j++) x += m1(i,j);
- VERIFY_IS_APPROX(m1.sum(), x);
-}
-
-template<typename VectorType> void vectorSum(const VectorType& w)
-{
- typedef typename VectorType::Scalar Scalar;
- int size = w.size();
-
- VectorType v = VectorType::Random(size);
- for(int i = 1; i < size; i++)
- {
- Scalar s = Scalar(0);
- for(int j = 0; j < i; j++) s += v[j];
- VERIFY_IS_APPROX(s, v.start(i).sum());
- }
-
- for(int i = 0; i < size-1; i++)
- {
- Scalar s = Scalar(0);
- for(int j = i; j < size; j++) s += v[j];
- VERIFY_IS_APPROX(s, v.end(size-i).sum());
- }
-
- for(int i = 0; i < size/2; i++)
- {
- Scalar s = Scalar(0);
- for(int j = i; j < size-i; j++) s += v[j];
- VERIFY_IS_APPROX(s, v.segment(i, size-2*i).sum());
- }
-}
-
-void test_eigen2_sum()
-{
- for(int i = 0; i < g_repeat; i++) {
- CALL_SUBTEST_1( matrixSum(Matrix<float, 1, 1>()) );
- CALL_SUBTEST_2( matrixSum(Matrix2f()) );
- CALL_SUBTEST_3( matrixSum(Matrix4d()) );
- CALL_SUBTEST_4( matrixSum(MatrixXcf(3, 3)) );
- CALL_SUBTEST_5( matrixSum(MatrixXf(8, 12)) );
- CALL_SUBTEST_6( matrixSum(MatrixXi(8, 12)) );
- }
- for(int i = 0; i < g_repeat; i++) {
- CALL_SUBTEST_5( vectorSum(VectorXf(5)) );
- CALL_SUBTEST_7( vectorSum(VectorXd(10)) );
- CALL_SUBTEST_5( vectorSum(VectorXf(33)) );
- }
-}
diff --git a/test/eigen2/eigen2_svd.cpp b/test/eigen2/eigen2_svd.cpp
deleted file mode 100644
index d4689a56f..000000000
--- a/test/eigen2/eigen2_svd.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-// 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 <g.gael@free.fr>
-//
-// 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 <Eigen/SVD>
-
-template<typename MatrixType> void svd(const MatrixType& m)
-{
- /* this test covers the following files:
- SVD.h
- */
- int rows = m.rows();
- int cols = m.cols();
-
- typedef typename MatrixType::Scalar Scalar;
- typedef typename NumTraits<Scalar>::Real RealScalar;
- MatrixType a = MatrixType::Random(rows,cols);
- Matrix<Scalar, MatrixType::RowsAtCompileTime, 1> b =
- Matrix<Scalar, MatrixType::RowsAtCompileTime, 1>::Random(rows,1);
- Matrix<Scalar, MatrixType::ColsAtCompileTime, 1> x(cols,1), x2(cols,1);
-
- RealScalar largerEps = test_precision<RealScalar>();
- if (ei_is_same_type<RealScalar,float>::ret)
- largerEps = 1e-3f;
-
- {
- SVD<MatrixType> svd(a);
- MatrixType sigma = MatrixType::Zero(rows,cols);
- MatrixType matU = MatrixType::Zero(rows,rows);
- sigma.block(0,0,cols,cols) = svd.singularValues().asDiagonal();
- matU.block(0,0,rows,cols) = svd.matrixU();
- VERIFY_IS_APPROX(a, matU * sigma * svd.matrixV().transpose());
- }
-
-
- if (rows==cols)
- {
- if (ei_is_same_type<RealScalar,float>::ret)
- {
- MatrixType a1 = MatrixType::Random(rows,cols);
- a += a * a.adjoint() + a1 * a1.adjoint();
- }
- SVD<MatrixType> svd(a);
- svd.solve(b, &x);
- VERIFY_IS_APPROX(a * x,b);
- }
-
-
- if(rows==cols)
- {
- SVD<MatrixType> svd(a);
- MatrixType unitary, positive;
- svd.computeUnitaryPositive(&unitary, &positive);
- VERIFY_IS_APPROX(unitary * unitary.adjoint(), MatrixType::Identity(unitary.rows(),unitary.rows()));
- VERIFY_IS_APPROX(positive, positive.adjoint());
- for(int i = 0; i < rows; i++) VERIFY(positive.diagonal()[i] >= 0); // cheap necessary (not sufficient) condition for positivity
- VERIFY_IS_APPROX(unitary*positive, a);
-
- svd.computePositiveUnitary(&positive, &unitary);
- VERIFY_IS_APPROX(unitary * unitary.adjoint(), MatrixType::Identity(unitary.rows(),unitary.rows()));
- VERIFY_IS_APPROX(positive, positive.adjoint());
- for(int i = 0; i < rows; i++) VERIFY(positive.diagonal()[i] >= 0); // cheap necessary (not sufficient) condition for positivity
- VERIFY_IS_APPROX(positive*unitary, a);
- }
-}
-
-void test_eigen2_svd()
-{
- for(int i = 0; i < g_repeat; i++) {
- CALL_SUBTEST_1( svd(Matrix3f()) );
- CALL_SUBTEST_2( svd(Matrix4d()) );
- CALL_SUBTEST_3( svd(MatrixXf(7,7)) );
- CALL_SUBTEST_4( svd(MatrixXd(14,7)) );
- // complex are not implemented yet
-// CALL_SUBTEST( svd(MatrixXcd(6,6)) );
-// CALL_SUBTEST( svd(MatrixXcf(3,3)) );
- SVD<MatrixXf> s;
- MatrixXf m = MatrixXf::Random(10,1);
- s.compute(m);
- }
-}
diff --git a/test/eigen2/eigen2_swap.cpp b/test/eigen2/eigen2_swap.cpp
deleted file mode 100644
index f3a8846d9..000000000
--- a/test/eigen2/eigen2_swap.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra.
-//
-// Copyright (C) 2009 Benoit Jacob <jacob.benoit.1@gmail.com>
-//
-// 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/.
-
-#define EIGEN_NO_STATIC_ASSERT
-#include "main.h"
-
-template<typename T>
-struct other_matrix_type
-{
- typedef int type;
-};
-
-template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
-struct other_matrix_type<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> >
-{
- typedef Matrix<_Scalar, _Rows, _Cols, _Options^RowMajor, _MaxRows, _MaxCols> type;
-};
-
-template<typename MatrixType> void swap(const MatrixType& m)
-{
- typedef typename other_matrix_type<MatrixType>::type OtherMatrixType;
- typedef typename MatrixType::Scalar Scalar;
-
- ei_assert((!ei_is_same_type<MatrixType,OtherMatrixType>::ret));
- int rows = m.rows();
- int cols = m.cols();
-
- // construct 3 matrix guaranteed to be distinct
- MatrixType m1 = MatrixType::Random(rows,cols);
- MatrixType m2 = MatrixType::Random(rows,cols) + Scalar(100) * MatrixType::Identity(rows,cols);
- OtherMatrixType m3 = OtherMatrixType::Random(rows,cols) + Scalar(200) * OtherMatrixType::Identity(rows,cols);
-
- MatrixType m1_copy = m1;
- MatrixType m2_copy = m2;
- OtherMatrixType m3_copy = m3;
-
- // test swapping 2 matrices of same type
- m1.swap(m2);
- VERIFY_IS_APPROX(m1,m2_copy);
- VERIFY_IS_APPROX(m2,m1_copy);
- m1 = m1_copy;
- m2 = m2_copy;
-
- // test swapping 2 matrices of different types
- m1.swap(m3);
- VERIFY_IS_APPROX(m1,m3_copy);
- VERIFY_IS_APPROX(m3,m1_copy);
- m1 = m1_copy;
- m3 = m3_copy;
-
- // test swapping matrix with expression
- m1.swap(m2.block(0,0,rows,cols));
- VERIFY_IS_APPROX(m1,m2_copy);
- VERIFY_IS_APPROX(m2,m1_copy);
- m1 = m1_copy;
- m2 = m2_copy;
-
- // test swapping two expressions of different types
- m1.transpose().swap(m3.transpose());
- VERIFY_IS_APPROX(m1,m3_copy);
- VERIFY_IS_APPROX(m3,m1_copy);
- m1 = m1_copy;
- m3 = m3_copy;
-
- // test assertion on mismatching size -- matrix case
- VERIFY_RAISES_ASSERT(m1.swap(m1.row(0)));
- // test assertion on mismatching size -- xpr case
- VERIFY_RAISES_ASSERT(m1.row(0).swap(m1));
-}
-
-void test_eigen2_swap()
-{
- CALL_SUBTEST_1( swap(Matrix3f()) ); // fixed size, no vectorization
- CALL_SUBTEST_1( swap(Matrix4d()) ); // fixed size, possible vectorization
- CALL_SUBTEST_1( swap(MatrixXd(3,3)) ); // dyn size, no vectorization
- CALL_SUBTEST_1( swap(MatrixXf(30,30)) ); // dyn size, possible vectorization
-}
diff --git a/test/eigen2/eigen2_triangular.cpp b/test/eigen2/eigen2_triangular.cpp
deleted file mode 100644
index 3748c7d71..000000000
--- a/test/eigen2/eigen2_triangular.cpp
+++ /dev/null
@@ -1,158 +0,0 @@
-// 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 <gael.guennebaud@gmail.com>
-//
-// 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"
-
-template<typename MatrixType> void triangular(const MatrixType& m)
-{
- typedef typename MatrixType::Scalar Scalar;
- typedef typename NumTraits<Scalar>::Real RealScalar;
- typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, 1> VectorType;
-
- RealScalar largerEps = 10*test_precision<RealScalar>();
-
- int rows = m.rows();
- int cols = m.cols();
-
- MatrixType m1 = MatrixType::Random(rows, cols),
- m2 = MatrixType::Random(rows, cols),
- m3(rows, cols),
- m4(rows, cols),
- r1(rows, cols),
- r2(rows, cols),
- mzero = MatrixType::Zero(rows, cols),
- mones = MatrixType::Ones(rows, cols),
- identity = Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime>
- ::Identity(rows, rows),
- square = Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime>
- ::Random(rows, rows);
- VectorType v1 = VectorType::Random(rows),
- v2 = VectorType::Random(rows),
- vzero = VectorType::Zero(rows);
-
- MatrixType m1up = m1.template part<Eigen::UpperTriangular>();
- MatrixType m2up = m2.template part<Eigen::UpperTriangular>();
-
- if (rows*cols>1)
- {
- VERIFY(m1up.isUpperTriangular());
- VERIFY(m2up.transpose().isLowerTriangular());
- VERIFY(!m2.isLowerTriangular());
- }
-
-// VERIFY_IS_APPROX(m1up.transpose() * m2, m1.upper().transpose().lower() * m2);
-
- // test overloaded operator+=
- r1.setZero();
- r2.setZero();
- r1.template part<Eigen::UpperTriangular>() += m1;
- r2 += m1up;
- VERIFY_IS_APPROX(r1,r2);
-
- // test overloaded operator=
- m1.setZero();
- m1.template part<Eigen::UpperTriangular>() = (m2.transpose() * m2).lazy();
- m3 = m2.transpose() * m2;
- VERIFY_IS_APPROX(m3.template part<Eigen::LowerTriangular>().transpose(), m1);
-
- // test overloaded operator=
- m1.setZero();
- m1.template part<Eigen::LowerTriangular>() = (m2.transpose() * m2).lazy();
- VERIFY_IS_APPROX(m3.template part<Eigen::LowerTriangular>(), m1);
-
- VERIFY_IS_APPROX(m3.template part<Diagonal>(), m3.diagonal().asDiagonal());
-
- m1 = MatrixType::Random(rows, cols);
- for (int i=0; i<rows; ++i)
- while (ei_abs2(m1(i,i))<1e-3) m1(i,i) = ei_random<Scalar>();
-
- Transpose<MatrixType> trm4(m4);
- // test back and forward subsitution
- m3 = m1.template part<Eigen::LowerTriangular>();
- VERIFY(m3.template marked<Eigen::LowerTriangular>().solveTriangular(m3).cwise().abs().isIdentity(test_precision<RealScalar>()));
- VERIFY(m3.transpose().template marked<Eigen::UpperTriangular>()
- .solveTriangular(m3.transpose()).cwise().abs().isIdentity(test_precision<RealScalar>()));
- // check M * inv(L) using in place API
- m4 = m3;
- m3.transpose().template marked<Eigen::UpperTriangular>().solveTriangularInPlace(trm4);
- VERIFY(m4.cwise().abs().isIdentity(test_precision<RealScalar>()));
-
- m3 = m1.template part<Eigen::UpperTriangular>();
- VERIFY(m3.template marked<Eigen::UpperTriangular>().solveTriangular(m3).cwise().abs().isIdentity(test_precision<RealScalar>()));
- VERIFY(m3.transpose().template marked<Eigen::LowerTriangular>()
- .solveTriangular(m3.transpose()).cwise().abs().isIdentity(test_precision<RealScalar>()));
- // check M * inv(U) using in place API
- m4 = m3;
- m3.transpose().template marked<Eigen::LowerTriangular>().solveTriangularInPlace(trm4);
- VERIFY(m4.cwise().abs().isIdentity(test_precision<RealScalar>()));
-
- m3 = m1.template part<Eigen::UpperTriangular>();
- VERIFY(m2.isApprox(m3 * (m3.template marked<Eigen::UpperTriangular>().solveTriangular(m2)), largerEps));
- m3 = m1.template part<Eigen::LowerTriangular>();
- VERIFY(m2.isApprox(m3 * (m3.template marked<Eigen::LowerTriangular>().solveTriangular(m2)), largerEps));
-
- VERIFY((m1.template part<Eigen::UpperTriangular>() * m2.template part<Eigen::UpperTriangular>()).isUpperTriangular());
-
- // test swap
- m1.setOnes();
- m2.setZero();
- m2.template part<Eigen::UpperTriangular>().swap(m1);
- m3.setZero();
- m3.template part<Eigen::UpperTriangular>().setOnes();
- VERIFY_IS_APPROX(m2,m3);
-
-}
-
-void selfadjoint()
-{
- Matrix2i m;
- m << 1, 2,
- 3, 4;
-
- Matrix2i m1 = Matrix2i::Zero();
- m1.part<SelfAdjoint>() = m;
- Matrix2i ref1;
- ref1 << 1, 2,
- 2, 4;
- VERIFY(m1 == ref1);
-
- Matrix2i m2 = Matrix2i::Zero();
- m2.part<SelfAdjoint>() = m.part<UpperTriangular>();
- Matrix2i ref2;
- ref2 << 1, 2,
- 2, 4;
- VERIFY(m2 == ref2);
-
- Matrix2i m3 = Matrix2i::Zero();
- m3.part<SelfAdjoint>() = m.part<LowerTriangular>();
- Matrix2i ref3;
- ref3 << 1, 0,
- 0, 4;
- VERIFY(m3 == ref3);
-
- // example inspired from bug 159
- int array[] = {1, 2, 3, 4};
- Matrix2i::Map(array).part<SelfAdjoint>() = Matrix2i::Random().part<LowerTriangular>();
-
- std::cout << "hello\n" << array << std::endl;
-}
-
-void test_eigen2_triangular()
-{
- CALL_SUBTEST_8( selfadjoint() );
- for(int i = 0; i < g_repeat ; i++) {
- CALL_SUBTEST_1( triangular(Matrix<float, 1, 1>()) );
- CALL_SUBTEST_2( triangular(Matrix<float, 2, 2>()) );
- CALL_SUBTEST_3( triangular(Matrix3d()) );
- CALL_SUBTEST_4( triangular(MatrixXcf(4, 4)) );
- CALL_SUBTEST_5( triangular(Matrix<std::complex<float>,8, 8>()) );
- CALL_SUBTEST_6( triangular(MatrixXd(17,17)) );
- CALL_SUBTEST_7( triangular(Matrix<float,Dynamic,Dynamic,RowMajor>(5, 5)) );
- }
-}
diff --git a/test/eigen2/eigen2_unalignedassert.cpp b/test/eigen2/eigen2_unalignedassert.cpp
deleted file mode 100644
index d10b6f538..000000000
--- a/test/eigen2/eigen2_unalignedassert.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-// 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 Benoit Jacob <jacob.benoit.1@gmail.com>
-//
-// 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"
-
-struct Good1
-{
- MatrixXd m; // good: m will allocate its own array, taking care of alignment.
- Good1() : m(20,20) {}
-};
-
-struct Good2
-{
- Matrix3d m; // good: m's size isn't a multiple of 16 bytes, so m doesn't have to be aligned
-};
-
-struct Good3
-{
- Vector2f m; // good: same reason
-};
-
-struct Bad4
-{
- Vector2d m; // bad: sizeof(m)%16==0 so alignment is required
-};
-
-struct Bad5
-{
- Matrix<float, 2, 6> m; // bad: same reason
-};
-
-struct Bad6
-{
- Matrix<double, 3, 4> m; // bad: same reason
-};
-
-struct Good7
-{
- EIGEN_MAKE_ALIGNED_OPERATOR_NEW
- Vector2d m;
- float f; // make the struct have sizeof%16!=0 to make it a little more tricky when we allow an array of 2 such objects
-};
-
-struct Good8
-{
- EIGEN_MAKE_ALIGNED_OPERATOR_NEW
- float f; // try the f at first -- the EIGEN_ALIGN_128 attribute of m should make that still work
- Matrix4f m;
-};
-
-struct Good9
-{
- Matrix<float,2,2,DontAlign> m; // good: no alignment requested
- float f;
-};
-
-template<bool Align> struct Depends
-{
- EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(Align)
- Vector2d m;
- float f;
-};
-
-template<typename T>
-void check_unalignedassert_good()
-{
- T *x, *y;
- x = new T;
- delete x;
- y = new T[2];
- delete[] y;
-}
-
-#if EIGEN_ARCH_WANTS_ALIGNMENT
-template<typename T>
-void check_unalignedassert_bad()
-{
- float buf[sizeof(T)+16];
- float *unaligned = buf;
- while((reinterpret_cast<std::size_t>(unaligned)&0xf)==0) ++unaligned; // make sure unaligned is really unaligned
- T *x = ::new(static_cast<void*>(unaligned)) T;
- x->~T();
-}
-#endif
-
-void unalignedassert()
-{
- check_unalignedassert_good<Good1>();
- check_unalignedassert_good<Good2>();
- check_unalignedassert_good<Good3>();
-#if EIGEN_ARCH_WANTS_ALIGNMENT
- VERIFY_RAISES_ASSERT(check_unalignedassert_bad<Bad4>());
- VERIFY_RAISES_ASSERT(check_unalignedassert_bad<Bad5>());
- VERIFY_RAISES_ASSERT(check_unalignedassert_bad<Bad6>());
-#endif
-
- check_unalignedassert_good<Good7>();
- check_unalignedassert_good<Good8>();
- check_unalignedassert_good<Good9>();
- check_unalignedassert_good<Depends<true> >();
-
-#if EIGEN_ARCH_WANTS_ALIGNMENT
- VERIFY_RAISES_ASSERT(check_unalignedassert_bad<Depends<false> >());
-#endif
-}
-
-void test_eigen2_unalignedassert()
-{
- CALL_SUBTEST(unalignedassert());
-}
diff --git a/test/eigen2/eigen2_visitor.cpp b/test/eigen2/eigen2_visitor.cpp
deleted file mode 100644
index 4781991de..000000000
--- a/test/eigen2/eigen2_visitor.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra.
-//
-// Copyright (C) 2008 Benoit Jacob <jacob.benoit.1@gmail.com>
-//
-// 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"
-
-template<typename MatrixType> void matrixVisitor(const MatrixType& p)
-{
- typedef typename MatrixType::Scalar Scalar;
-
- int rows = p.rows();
- int cols = p.cols();
-
- // construct a random matrix where all coefficients are different
- MatrixType m;
- m = MatrixType::Random(rows, cols);
- for(int i = 0; i < m.size(); i++)
- for(int i2 = 0; i2 < i; i2++)
- while(m(i) == m(i2)) // yes, ==
- m(i) = ei_random<Scalar>();
-
- Scalar minc = Scalar(1000), maxc = Scalar(-1000);
- int minrow=0,mincol=0,maxrow=0,maxcol=0;
- for(int j = 0; j < cols; j++)
- for(int i = 0; i < rows; i++)
- {
- if(m(i,j) < minc)
- {
- minc = m(i,j);
- minrow = i;
- mincol = j;
- }
- if(m(i,j) > maxc)
- {
- maxc = m(i,j);
- maxrow = i;
- maxcol = j;
- }
- }
- int eigen_minrow, eigen_mincol, eigen_maxrow, eigen_maxcol;
- Scalar eigen_minc, eigen_maxc;
- eigen_minc = m.minCoeff(&eigen_minrow,&eigen_mincol);
- eigen_maxc = m.maxCoeff(&eigen_maxrow,&eigen_maxcol);
- VERIFY(minrow == eigen_minrow);
- VERIFY(maxrow == eigen_maxrow);
- VERIFY(mincol == eigen_mincol);
- VERIFY(maxcol == eigen_maxcol);
- VERIFY_IS_APPROX(minc, eigen_minc);
- VERIFY_IS_APPROX(maxc, eigen_maxc);
- VERIFY_IS_APPROX(minc, m.minCoeff());
- VERIFY_IS_APPROX(maxc, m.maxCoeff());
-}
-
-template<typename VectorType> void vectorVisitor(const VectorType& w)
-{
- typedef typename VectorType::Scalar Scalar;
-
- int size = w.size();
-
- // construct a random vector where all coefficients are different
- VectorType v;
- v = VectorType::Random(size);
- for(int i = 0; i < size; i++)
- for(int i2 = 0; i2 < i; i2++)
- while(v(i) == v(i2)) // yes, ==
- v(i) = ei_random<Scalar>();
-
- Scalar minc = Scalar(1000), maxc = Scalar(-1000);
- int minidx=0,maxidx=0;
- for(int i = 0; i < size; i++)
- {
- if(v(i) < minc)
- {
- minc = v(i);
- minidx = i;
- }
- if(v(i) > maxc)
- {
- maxc = v(i);
- maxidx = i;
- }
- }
- int eigen_minidx, eigen_maxidx;
- Scalar eigen_minc, eigen_maxc;
- eigen_minc = v.minCoeff(&eigen_minidx);
- eigen_maxc = v.maxCoeff(&eigen_maxidx);
- VERIFY(minidx == eigen_minidx);
- VERIFY(maxidx == eigen_maxidx);
- VERIFY_IS_APPROX(minc, eigen_minc);
- VERIFY_IS_APPROX(maxc, eigen_maxc);
- VERIFY_IS_APPROX(minc, v.minCoeff());
- VERIFY_IS_APPROX(maxc, v.maxCoeff());
-}
-
-void test_eigen2_visitor()
-{
- for(int i = 0; i < g_repeat; i++) {
- CALL_SUBTEST_1( matrixVisitor(Matrix<float, 1, 1>()) );
- CALL_SUBTEST_2( matrixVisitor(Matrix2f()) );
- CALL_SUBTEST_3( matrixVisitor(Matrix4d()) );
- CALL_SUBTEST_4( matrixVisitor(MatrixXd(8, 12)) );
- CALL_SUBTEST_5( matrixVisitor(Matrix<double,Dynamic,Dynamic,RowMajor>(20, 20)) );
- CALL_SUBTEST_6( matrixVisitor(MatrixXi(8, 12)) );
- }
- for(int i = 0; i < g_repeat; i++) {
- CALL_SUBTEST_7( vectorVisitor(Vector4f()) );
- CALL_SUBTEST_4( vectorVisitor(VectorXd(10)) );
- CALL_SUBTEST_4( vectorVisitor(RowVectorXd(10)) );
- CALL_SUBTEST_8( vectorVisitor(VectorXf(33)) );
- }
-}
diff --git a/test/eigen2/gsl_helper.h b/test/eigen2/gsl_helper.h
deleted file mode 100644
index d1d854533..000000000
--- a/test/eigen2/gsl_helper.h
+++ /dev/null
@@ -1,175 +0,0 @@
-// 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 <g.gael@free.fr>
-//
-// 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/.
-
-#ifndef EIGEN_GSL_HELPER
-#define EIGEN_GSL_HELPER
-
-#include <Eigen/Core>
-
-#include <gsl/gsl_blas.h>
-#include <gsl/gsl_multifit.h>
-#include <gsl/gsl_eigen.h>
-#include <gsl/gsl_linalg.h>
-#include <gsl/gsl_complex.h>
-#include <gsl/gsl_complex_math.h>
-
-namespace Eigen {
-
-template<typename Scalar, bool IsComplex = NumTraits<Scalar>::IsComplex> struct GslTraits
-{
- typedef gsl_matrix* Matrix;
- typedef gsl_vector* Vector;
- static Matrix createMatrix(int rows, int cols) { return gsl_matrix_alloc(rows,cols); }
- static Vector createVector(int size) { return gsl_vector_alloc(size); }
- static void free(Matrix& m) { gsl_matrix_free(m); m=0; }
- static void free(Vector& m) { gsl_vector_free(m); m=0; }
- static void prod(const Matrix& m, const Vector& v, Vector& x) { gsl_blas_dgemv(CblasNoTrans,1,m,v,0,x); }
- static void cholesky(Matrix& m) { gsl_linalg_cholesky_decomp(m); }
- static void cholesky_solve(const Matrix& m, const Vector& b, Vector& x) { gsl_linalg_cholesky_solve(m,b,x); }
- static void eigen_symm(const Matrix& m, Vector& eval, Matrix& evec)
- {
- gsl_eigen_symmv_workspace * w = gsl_eigen_symmv_alloc(m->size1);
- Matrix a = createMatrix(m->size1, m->size2);
- gsl_matrix_memcpy(a, m);
- gsl_eigen_symmv(a,eval,evec,w);
- gsl_eigen_symmv_sort(eval, evec, GSL_EIGEN_SORT_VAL_ASC);
- gsl_eigen_symmv_free(w);
- free(a);
- }
- static void eigen_symm_gen(const Matrix& m, const Matrix& _b, Vector& eval, Matrix& evec)
- {
- gsl_eigen_gensymmv_workspace * w = gsl_eigen_gensymmv_alloc(m->size1);
- Matrix a = createMatrix(m->size1, m->size2);
- Matrix b = createMatrix(_b->size1, _b->size2);
- gsl_matrix_memcpy(a, m);
- gsl_matrix_memcpy(b, _b);
- gsl_eigen_gensymmv(a,b,eval,evec,w);
- gsl_eigen_symmv_sort(eval, evec, GSL_EIGEN_SORT_VAL_ASC);
- gsl_eigen_gensymmv_free(w);
- free(a);
- }
-};
-
-template<typename Scalar> struct GslTraits<Scalar,true>
-{
- typedef gsl_matrix_complex* Matrix;
- typedef gsl_vector_complex* Vector;
- static Matrix createMatrix(int rows, int cols) { return gsl_matrix_complex_alloc(rows,cols); }
- static Vector createVector(int size) { return gsl_vector_complex_alloc(size); }
- static void free(Matrix& m) { gsl_matrix_complex_free(m); m=0; }
- static void free(Vector& m) { gsl_vector_complex_free(m); m=0; }
- static void cholesky(Matrix& m) { gsl_linalg_complex_cholesky_decomp(m); }
- static void cholesky_solve(const Matrix& m, const Vector& b, Vector& x) { gsl_linalg_complex_cholesky_solve(m,b,x); }
- static void prod(const Matrix& m, const Vector& v, Vector& x)
- { gsl_blas_zgemv(CblasNoTrans,gsl_complex_rect(1,0),m,v,gsl_complex_rect(0,0),x); }
- static void eigen_symm(const Matrix& m, gsl_vector* &eval, Matrix& evec)
- {
- gsl_eigen_hermv_workspace * w = gsl_eigen_hermv_alloc(m->size1);
- Matrix a = createMatrix(m->size1, m->size2);
- gsl_matrix_complex_memcpy(a, m);
- gsl_eigen_hermv(a,eval,evec,w);
- gsl_eigen_hermv_sort(eval, evec, GSL_EIGEN_SORT_VAL_ASC);
- gsl_eigen_hermv_free(w);
- free(a);
- }
- static void eigen_symm_gen(const Matrix& m, const Matrix& _b, gsl_vector* &eval, Matrix& evec)
- {
- gsl_eigen_genhermv_workspace * w = gsl_eigen_genhermv_alloc(m->size1);
- Matrix a = createMatrix(m->size1, m->size2);
- Matrix b = createMatrix(_b->size1, _b->size2);
- gsl_matrix_complex_memcpy(a, m);
- gsl_matrix_complex_memcpy(b, _b);
- gsl_eigen_genhermv(a,b,eval,evec,w);
- gsl_eigen_hermv_sort(eval, evec, GSL_EIGEN_SORT_VAL_ASC);
- gsl_eigen_genhermv_free(w);
- free(a);
- }
-};
-
-template<typename MatrixType>
-void convert(const MatrixType& m, gsl_matrix* &res)
-{
-// if (res)
-// gsl_matrix_free(res);
- res = gsl_matrix_alloc(m.rows(), m.cols());
- for (int i=0 ; i<m.rows() ; ++i)
- for (int j=0 ; j<m.cols(); ++j)
- gsl_matrix_set(res, i, j, m(i,j));
-}
-
-template<typename MatrixType>
-void convert(const gsl_matrix* m, MatrixType& res)
-{
- res.resize(int(m->size1), int(m->size2));
- for (int i=0 ; i<res.rows() ; ++i)
- for (int j=0 ; j<res.cols(); ++j)
- res(i,j) = gsl_matrix_get(m,i,j);
-}
-
-template<typename VectorType>
-void convert(const VectorType& m, gsl_vector* &res)
-{
- if (res) gsl_vector_free(res);
- res = gsl_vector_alloc(m.size());
- for (int i=0 ; i<m.size() ; ++i)
- gsl_vector_set(res, i, m[i]);
-}
-
-template<typename VectorType>
-void convert(const gsl_vector* m, VectorType& res)
-{
- res.resize (m->size);
- for (int i=0 ; i<res.rows() ; ++i)
- res[i] = gsl_vector_get(m, i);
-}
-
-template<typename MatrixType>
-void convert(const MatrixType& m, gsl_matrix_complex* &res)
-{
- res = gsl_matrix_complex_alloc(m.rows(), m.cols());
- for (int i=0 ; i<m.rows() ; ++i)
- for (int j=0 ; j<m.cols(); ++j)
- {
- gsl_matrix_complex_set(res, i, j,
- gsl_complex_rect(m(i,j).real(), m(i,j).imag()));
- }
-}
-
-template<typename MatrixType>
-void convert(const gsl_matrix_complex* m, MatrixType& res)
-{
- res.resize(int(m->size1), int(m->size2));
- for (int i=0 ; i<res.rows() ; ++i)
- for (int j=0 ; j<res.cols(); ++j)
- res(i,j) = typename MatrixType::Scalar(
- GSL_REAL(gsl_matrix_complex_get(m,i,j)),
- GSL_IMAG(gsl_matrix_complex_get(m,i,j)));
-}
-
-template<typename VectorType>
-void convert(const VectorType& m, gsl_vector_complex* &res)
-{
- res = gsl_vector_complex_alloc(m.size());
- for (int i=0 ; i<m.size() ; ++i)
- gsl_vector_complex_set(res, i, gsl_complex_rect(m[i].real(), m[i].imag()));
-}
-
-template<typename VectorType>
-void convert(const gsl_vector_complex* m, VectorType& res)
-{
- res.resize(m->size);
- for (int i=0 ; i<res.rows() ; ++i)
- res[i] = typename VectorType::Scalar(
- GSL_REAL(gsl_vector_complex_get(m, i)),
- GSL_IMAG(gsl_vector_complex_get(m, i)));
-}
-
-}
-
-#endif // EIGEN_GSL_HELPER
diff --git a/test/eigen2/main.h b/test/eigen2/main.h
deleted file mode 100644
index ad2ba1994..000000000
--- a/test/eigen2/main.h
+++ /dev/null
@@ -1,399 +0,0 @@
-// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra. Eigen itself is part of the KDE project.
-//
-// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
-// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
-//
-// 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 <cstdlib>
-#include <ctime>
-#include <iostream>
-#include <string>
-#include <vector>
-
-#ifndef EIGEN_TEST_FUNC
-#error EIGEN_TEST_FUNC must be defined
-#endif
-
-#define DEFAULT_REPEAT 10
-
-namespace Eigen
-{
- static std::vector<std::string> g_test_stack;
- static int g_repeat;
-}
-
-#define EI_PP_MAKE_STRING2(S) #S
-#define EI_PP_MAKE_STRING(S) EI_PP_MAKE_STRING2(S)
-
-#define EI_PP_CAT2(a,b) a ## b
-#define EI_PP_CAT(a,b) EI_PP_CAT2(a,b)
-
-#ifndef EIGEN_NO_ASSERTION_CHECKING
-
- namespace Eigen
- {
- static const bool should_raise_an_assert = false;
-
- // Used to avoid to raise two exceptions at a time in which
- // case the exception is not properly caught.
- // This may happen when a second exceptions is raise in a destructor.
- static bool no_more_assert = false;
-
- struct eigen_assert_exception
- {
- eigen_assert_exception(void) {}
- ~eigen_assert_exception() { Eigen::no_more_assert = false; }
- };
- }
-
- // If EIGEN_DEBUG_ASSERTS is defined and if no assertion is raised while
- // one should have been, then the list of excecuted assertions is printed out.
- //
- // EIGEN_DEBUG_ASSERTS is not enabled by default as it
- // significantly increases the compilation time
- // and might even introduce side effects that would hide
- // some memory errors.
- #ifdef EIGEN_DEBUG_ASSERTS
-
- namespace Eigen
- {
- static bool ei_push_assert = false;
- static std::vector<std::string> eigen_assert_list;
- }
-
- #define eigen_assert(a) \
- if( (!(a)) && (!no_more_assert) ) \
- { \
- Eigen::no_more_assert = true; \
- throw Eigen::eigen_assert_exception(); \
- } \
- else if (Eigen::ei_push_assert) \
- { \
- eigen_assert_list.push_back(std::string(EI_PP_MAKE_STRING(__FILE__)" ("EI_PP_MAKE_STRING(__LINE__)") : "#a) ); \
- }
-
- #define VERIFY_RAISES_ASSERT(a) \
- { \
- Eigen::no_more_assert = false; \
- try { \
- Eigen::eigen_assert_list.clear(); \
- Eigen::ei_push_assert = true; \
- a; \
- Eigen::ei_push_assert = false; \
- std::cerr << "One of the following asserts should have been raised:\n"; \
- for (uint ai=0 ; ai<eigen_assert_list.size() ; ++ai) \
- std::cerr << " " << eigen_assert_list[ai] << "\n"; \
- VERIFY(Eigen::should_raise_an_assert && # a); \
- } catch (Eigen::eigen_assert_exception e) { \
- Eigen::ei_push_assert = false; VERIFY(true); \
- } \
- }
-
- #else // EIGEN_DEBUG_ASSERTS
-
- #undef eigen_assert
-
- // see bug 89. The copy_bool here is working around a bug in gcc <= 4.3
- #define eigen_assert(a) \
- if( (!Eigen::internal::copy_bool(a)) && (!no_more_assert) ) \
- { \
- Eigen::no_more_assert = true; \
- throw Eigen::eigen_assert_exception(); \
- }
-
- #define VERIFY_RAISES_ASSERT(a) { \
- Eigen::no_more_assert = false; \
- try { a; VERIFY(Eigen::should_raise_an_assert && # a); } \
- catch (Eigen::eigen_assert_exception e) { VERIFY(true); } \
- }
-
- #endif // EIGEN_DEBUG_ASSERTS
-
- #define EIGEN_USE_CUSTOM_ASSERT
-
-#else // EIGEN_NO_ASSERTION_CHECKING
-
- #define VERIFY_RAISES_ASSERT(a) {}
-
-#endif // EIGEN_NO_ASSERTION_CHECKING
-
-
-#define EIGEN_INTERNAL_DEBUGGING
-#define EIGEN_NICE_RANDOM
-#include <Eigen/Array>
-
-
-#define VERIFY(a) do { if (!(a)) { \
- std::cerr << "Test " << g_test_stack.back() << " failed in "EI_PP_MAKE_STRING(__FILE__) << " (" << EI_PP_MAKE_STRING(__LINE__) << ")" \
- << std::endl << " " << EI_PP_MAKE_STRING(a) << std::endl << std::endl; \
- abort(); \
- } } while (0)
-
-#define VERIFY_IS_APPROX(a, b) VERIFY(test_ei_isApprox(a, b))
-#define VERIFY_IS_NOT_APPROX(a, b) VERIFY(!test_ei_isApprox(a, b))
-#define VERIFY_IS_MUCH_SMALLER_THAN(a, b) VERIFY(test_ei_isMuchSmallerThan(a, b))
-#define VERIFY_IS_NOT_MUCH_SMALLER_THAN(a, b) VERIFY(!test_ei_isMuchSmallerThan(a, b))
-#define VERIFY_IS_APPROX_OR_LESS_THAN(a, b) VERIFY(test_ei_isApproxOrLessThan(a, b))
-#define VERIFY_IS_NOT_APPROX_OR_LESS_THAN(a, b) VERIFY(!test_ei_isApproxOrLessThan(a, b))
-
-#define CALL_SUBTEST(FUNC) do { \
- g_test_stack.push_back(EI_PP_MAKE_STRING(FUNC)); \
- FUNC; \
- g_test_stack.pop_back(); \
- } while (0)
-
-namespace Eigen {
-
-template<typename T> inline typename NumTraits<T>::Real test_precision();
-template<> inline int test_precision<int>() { return 0; }
-template<> inline float test_precision<float>() { return 1e-3f; }
-template<> inline double test_precision<double>() { return 1e-6; }
-template<> inline float test_precision<std::complex<float> >() { return test_precision<float>(); }
-template<> inline double test_precision<std::complex<double> >() { return test_precision<double>(); }
-template<> inline long double test_precision<long double>() { return 1e-6; }
-
-inline bool test_ei_isApprox(const int& a, const int& b)
-{ return ei_isApprox(a, b, test_precision<int>()); }
-inline bool test_ei_isMuchSmallerThan(const int& a, const int& b)
-{ return ei_isMuchSmallerThan(a, b, test_precision<int>()); }
-inline bool test_ei_isApproxOrLessThan(const int& a, const int& b)
-{ return ei_isApproxOrLessThan(a, b, test_precision<int>()); }
-
-inline bool test_ei_isApprox(const float& a, const float& b)
-{ return ei_isApprox(a, b, test_precision<float>()); }
-inline bool test_ei_isMuchSmallerThan(const float& a, const float& b)
-{ return ei_isMuchSmallerThan(a, b, test_precision<float>()); }
-inline bool test_ei_isApproxOrLessThan(const float& a, const float& b)
-{ return ei_isApproxOrLessThan(a, b, test_precision<float>()); }
-
-inline bool test_ei_isApprox(const double& a, const double& b)
-{ return ei_isApprox(a, b, test_precision<double>()); }
-inline bool test_ei_isMuchSmallerThan(const double& a, const double& b)
-{ return ei_isMuchSmallerThan(a, b, test_precision<double>()); }
-inline bool test_ei_isApproxOrLessThan(const double& a, const double& b)
-{ return ei_isApproxOrLessThan(a, b, test_precision<double>()); }
-
-inline bool test_ei_isApprox(const std::complex<float>& a, const std::complex<float>& b)
-{ return ei_isApprox(a, b, test_precision<std::complex<float> >()); }
-inline bool test_ei_isMuchSmallerThan(const std::complex<float>& a, const std::complex<float>& b)
-{ return ei_isMuchSmallerThan(a, b, test_precision<std::complex<float> >()); }
-
-inline bool test_ei_isApprox(const std::complex<double>& a, const std::complex<double>& b)
-{ return ei_isApprox(a, b, test_precision<std::complex<double> >()); }
-inline bool test_ei_isMuchSmallerThan(const std::complex<double>& a, const std::complex<double>& b)
-{ return ei_isMuchSmallerThan(a, b, test_precision<std::complex<double> >()); }
-
-inline bool test_ei_isApprox(const long double& a, const long double& b)
-{ return ei_isApprox(a, b, test_precision<long double>()); }
-inline bool test_ei_isMuchSmallerThan(const long double& a, const long double& b)
-{ return ei_isMuchSmallerThan(a, b, test_precision<long double>()); }
-inline bool test_ei_isApproxOrLessThan(const long double& a, const long double& b)
-{ return ei_isApproxOrLessThan(a, b, test_precision<long double>()); }
-
-template<typename Type1, typename Type2>
-inline bool test_ei_isApprox(const Type1& a, const Type2& b)
-{
- return a.isApprox(b, test_precision<typename Type1::Scalar>());
-}
-
-template<typename Derived1, typename Derived2>
-inline bool test_ei_isMuchSmallerThan(const MatrixBase<Derived1>& m1,
- const MatrixBase<Derived2>& m2)
-{
- return m1.isMuchSmallerThan(m2, test_precision<typename ei_traits<Derived1>::Scalar>());
-}
-
-template<typename Derived>
-inline bool test_ei_isMuchSmallerThan(const MatrixBase<Derived>& m,
- const typename NumTraits<typename ei_traits<Derived>::Scalar>::Real& s)
-{
- return m.isMuchSmallerThan(s, test_precision<typename ei_traits<Derived>::Scalar>());
-}
-
-} // end namespace Eigen
-
-template<typename T> struct GetDifferentType;
-
-template<> struct GetDifferentType<float> { typedef double type; };
-template<> struct GetDifferentType<double> { typedef float type; };
-template<typename T> struct GetDifferentType<std::complex<T> >
-{ typedef std::complex<typename GetDifferentType<T>::type> type; };
-
-// forward declaration of the main test function
-void EI_PP_CAT(test_,EIGEN_TEST_FUNC)();
-
-using namespace Eigen;
-
-#ifdef EIGEN_TEST_PART_1
-#define CALL_SUBTEST_1(FUNC) CALL_SUBTEST(FUNC)
-#else
-#define CALL_SUBTEST_1(FUNC)
-#endif
-
-#ifdef EIGEN_TEST_PART_2
-#define CALL_SUBTEST_2(FUNC) CALL_SUBTEST(FUNC)
-#else
-#define CALL_SUBTEST_2(FUNC)
-#endif
-
-#ifdef EIGEN_TEST_PART_3
-#define CALL_SUBTEST_3(FUNC) CALL_SUBTEST(FUNC)
-#else
-#define CALL_SUBTEST_3(FUNC)
-#endif
-
-#ifdef EIGEN_TEST_PART_4
-#define CALL_SUBTEST_4(FUNC) CALL_SUBTEST(FUNC)
-#else
-#define CALL_SUBTEST_4(FUNC)
-#endif
-
-#ifdef EIGEN_TEST_PART_5
-#define CALL_SUBTEST_5(FUNC) CALL_SUBTEST(FUNC)
-#else
-#define CALL_SUBTEST_5(FUNC)
-#endif
-
-#ifdef EIGEN_TEST_PART_6
-#define CALL_SUBTEST_6(FUNC) CALL_SUBTEST(FUNC)
-#else
-#define CALL_SUBTEST_6(FUNC)
-#endif
-
-#ifdef EIGEN_TEST_PART_7
-#define CALL_SUBTEST_7(FUNC) CALL_SUBTEST(FUNC)
-#else
-#define CALL_SUBTEST_7(FUNC)
-#endif
-
-#ifdef EIGEN_TEST_PART_8
-#define CALL_SUBTEST_8(FUNC) CALL_SUBTEST(FUNC)
-#else
-#define CALL_SUBTEST_8(FUNC)
-#endif
-
-#ifdef EIGEN_TEST_PART_9
-#define CALL_SUBTEST_9(FUNC) CALL_SUBTEST(FUNC)
-#else
-#define CALL_SUBTEST_9(FUNC)
-#endif
-
-#ifdef EIGEN_TEST_PART_10
-#define CALL_SUBTEST_10(FUNC) CALL_SUBTEST(FUNC)
-#else
-#define CALL_SUBTEST_10(FUNC)
-#endif
-
-#ifdef EIGEN_TEST_PART_11
-#define CALL_SUBTEST_11(FUNC) CALL_SUBTEST(FUNC)
-#else
-#define CALL_SUBTEST_11(FUNC)
-#endif
-
-#ifdef EIGEN_TEST_PART_12
-#define CALL_SUBTEST_12(FUNC) CALL_SUBTEST(FUNC)
-#else
-#define CALL_SUBTEST_12(FUNC)
-#endif
-
-#ifdef EIGEN_TEST_PART_13
-#define CALL_SUBTEST_13(FUNC) CALL_SUBTEST(FUNC)
-#else
-#define CALL_SUBTEST_13(FUNC)
-#endif
-
-#ifdef EIGEN_TEST_PART_14
-#define CALL_SUBTEST_14(FUNC) CALL_SUBTEST(FUNC)
-#else
-#define CALL_SUBTEST_14(FUNC)
-#endif
-
-#ifdef EIGEN_TEST_PART_15
-#define CALL_SUBTEST_15(FUNC) CALL_SUBTEST(FUNC)
-#else
-#define CALL_SUBTEST_15(FUNC)
-#endif
-
-#ifdef EIGEN_TEST_PART_16
-#define CALL_SUBTEST_16(FUNC) CALL_SUBTEST(FUNC)
-#else
-#define CALL_SUBTEST_16(FUNC)
-#endif
-
-
-
-int main(int argc, char *argv[])
-{
- bool has_set_repeat = false;
- bool has_set_seed = false;
- bool need_help = false;
- unsigned int seed = 0;
- int repeat = DEFAULT_REPEAT;
-
- for(int i = 1; i < argc; i++)
- {
- if(argv[i][0] == 'r')
- {
- if(has_set_repeat)
- {
- std::cout << "Argument " << argv[i] << " conflicting with a former argument" << std::endl;
- return 1;
- }
- repeat = std::atoi(argv[i]+1);
- has_set_repeat = true;
- if(repeat <= 0)
- {
- std::cout << "Invalid \'repeat\' value " << argv[i]+1 << std::endl;
- return 1;
- }
- }
- else if(argv[i][0] == 's')
- {
- if(has_set_seed)
- {
- std::cout << "Argument " << argv[i] << " conflicting with a former argument" << std::endl;
- return 1;
- }
- seed = int(std::strtoul(argv[i]+1, 0, 10));
- has_set_seed = true;
- bool ok = seed!=0;
- if(!ok)
- {
- std::cout << "Invalid \'seed\' value " << argv[i]+1 << std::endl;
- return 1;
- }
- }
- else
- {
- need_help = true;
- }
- }
-
- if(need_help)
- {
- std::cout << "This test application takes the following optional arguments:" << std::endl;
- std::cout << " rN Repeat each test N times (default: " << DEFAULT_REPEAT << ")" << std::endl;
- std::cout << " sN Use N as seed for random numbers (default: based on current time)" << std::endl;
- return 1;
- }
-
- if(!has_set_seed) seed = (unsigned int) std::time(NULL);
- if(!has_set_repeat) repeat = DEFAULT_REPEAT;
-
- std::cout << "Initializing random number generator with seed " << seed << std::endl;
- std::srand(seed);
- std::cout << "Repeating each test " << repeat << " times" << std::endl;
-
- Eigen::g_repeat = repeat;
- Eigen::g_test_stack.push_back(EI_PP_MAKE_STRING(EIGEN_TEST_FUNC));
-
- EI_PP_CAT(test_,EIGEN_TEST_FUNC)();
- return 0;
-}
-
-
-
diff --git a/test/eigen2/product.h b/test/eigen2/product.h
deleted file mode 100644
index 2c9604d9a..000000000
--- a/test/eigen2/product.h
+++ /dev/null
@@ -1,132 +0,0 @@
-// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra. Eigen itself is part of the KDE project.
-//
-// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
-//
-// 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 <Eigen/Array>
-#include <Eigen/QR>
-
-template<typename Derived1, typename Derived2>
-bool areNotApprox(const MatrixBase<Derived1>& m1, const MatrixBase<Derived2>& m2, typename Derived1::RealScalar epsilon = precision<typename Derived1::RealScalar>())
-{
- return !((m1-m2).cwise().abs2().maxCoeff() < epsilon * epsilon
- * std::max(m1.cwise().abs2().maxCoeff(), m2.cwise().abs2().maxCoeff()));
-}
-
-template<typename MatrixType> void product(const MatrixType& m)
-{
- /* this test covers the following files:
- Identity.h Product.h
- */
-
- typedef typename MatrixType::Scalar Scalar;
- typedef typename NumTraits<Scalar>::FloatingPoint FloatingPoint;
- typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, 1> RowVectorType;
- typedef Matrix<Scalar, MatrixType::ColsAtCompileTime, 1> ColVectorType;
- typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime> RowSquareMatrixType;
- typedef Matrix<Scalar, MatrixType::ColsAtCompileTime, MatrixType::ColsAtCompileTime> ColSquareMatrixType;
- typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::ColsAtCompileTime,
- MatrixType::Options^RowMajor> OtherMajorMatrixType;
-
- int rows = m.rows();
- int cols = m.cols();
-
- // this test relies a lot on Random.h, and there's not much more that we can do
- // to test it, hence I consider that we will have tested Random.h
- MatrixType m1 = MatrixType::Random(rows, cols),
- m2 = MatrixType::Random(rows, cols),
- m3(rows, cols),
- mzero = MatrixType::Zero(rows, cols);
- RowSquareMatrixType
- identity = RowSquareMatrixType::Identity(rows, rows),
- square = RowSquareMatrixType::Random(rows, rows),
- res = RowSquareMatrixType::Random(rows, rows);
- ColSquareMatrixType
- square2 = ColSquareMatrixType::Random(cols, cols),
- res2 = ColSquareMatrixType::Random(cols, cols);
- RowVectorType v1 = RowVectorType::Random(rows),
- v2 = RowVectorType::Random(rows),
- vzero = RowVectorType::Zero(rows);
- ColVectorType vc2 = ColVectorType::Random(cols), vcres(cols);
- OtherMajorMatrixType tm1 = m1;
-
- Scalar s1 = ei_random<Scalar>();
-
- int r = ei_random<int>(0, rows-1),
- c = ei_random<int>(0, cols-1);
-
- // begin testing Product.h: only associativity for now
- // (we use Transpose.h but this doesn't count as a test for it)
-
- VERIFY_IS_APPROX((m1*m1.transpose())*m2, m1*(m1.transpose()*m2));
- m3 = m1;
- m3 *= m1.transpose() * m2;
- VERIFY_IS_APPROX(m3, m1 * (m1.transpose()*m2));
- VERIFY_IS_APPROX(m3, m1.lazy() * (m1.transpose()*m2));
-
- // continue testing Product.h: distributivity
- VERIFY_IS_APPROX(square*(m1 + m2), square*m1+square*m2);
- VERIFY_IS_APPROX(square*(m1 - m2), square*m1-square*m2);
-
- // continue testing Product.h: compatibility with ScalarMultiple.h
- VERIFY_IS_APPROX(s1*(square*m1), (s1*square)*m1);
- VERIFY_IS_APPROX(s1*(square*m1), square*(m1*s1));
-
- // again, test operator() to check const-qualification
- s1 += (square.lazy() * m1)(r,c);
-
- // test Product.h together with Identity.h
- VERIFY_IS_APPROX(v1, identity*v1);
- VERIFY_IS_APPROX(v1.transpose(), v1.transpose() * identity);
- // again, test operator() to check const-qualification
- VERIFY_IS_APPROX(MatrixType::Identity(rows, cols)(r,c), static_cast<Scalar>(r==c));
-
- if (rows!=cols)
- VERIFY_RAISES_ASSERT(m3 = m1*m1);
-
- // test the previous tests were not screwed up because operator* returns 0
- // (we use the more accurate default epsilon)
- if (NumTraits<Scalar>::HasFloatingPoint && std::min(rows,cols)>1)
- {
- VERIFY(areNotApprox(m1.transpose()*m2,m2.transpose()*m1));
- }
-
- // test optimized operator+= path
- res = square;
- res += (m1 * m2.transpose()).lazy();
- VERIFY_IS_APPROX(res, square + m1 * m2.transpose());
- if (NumTraits<Scalar>::HasFloatingPoint && std::min(rows,cols)>1)
- {
- VERIFY(areNotApprox(res,square + m2 * m1.transpose()));
- }
- vcres = vc2;
- vcres += (m1.transpose() * v1).lazy();
- VERIFY_IS_APPROX(vcres, vc2 + m1.transpose() * v1);
- tm1 = m1;
- VERIFY_IS_APPROX(tm1.transpose() * v1, m1.transpose() * v1);
- VERIFY_IS_APPROX(v1.transpose() * tm1, v1.transpose() * m1);
-
- // test submatrix and matrix/vector product
- for (int i=0; i<rows; ++i)
- res.row(i) = m1.row(i) * m2.transpose();
- VERIFY_IS_APPROX(res, m1 * m2.transpose());
- // the other way round:
- for (int i=0; i<rows; ++i)
- res.col(i) = m1 * m2.transpose().col(i);
- VERIFY_IS_APPROX(res, m1 * m2.transpose());
-
- res2 = square2;
- res2 += (m1.transpose() * m2).lazy();
- VERIFY_IS_APPROX(res2, square2 + m1.transpose() * m2);
-
- if (NumTraits<Scalar>::HasFloatingPoint && std::min(rows,cols)>1)
- {
- VERIFY(areNotApprox(res2,square2 + m2.transpose() * m1));
- }
-}
-
diff --git a/test/eigen2/sparse.h b/test/eigen2/sparse.h
deleted file mode 100644
index e12f89990..000000000
--- a/test/eigen2/sparse.h
+++ /dev/null
@@ -1,154 +0,0 @@
-// 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 Daniel Gomez Ferro <dgomezferro@gmail.com>
-//
-// 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/.
-
-#ifndef EIGEN_TESTSPARSE_H
-
-#include "main.h"
-
-#if EIGEN_GNUC_AT_LEAST(4,0) && !defined __ICC
-#include <tr1/unordered_map>
-#define EIGEN_UNORDERED_MAP_SUPPORT
-namespace std {
- using std::tr1::unordered_map;
-}
-#endif
-
-#ifdef EIGEN_GOOGLEHASH_SUPPORT
- #include <google/sparse_hash_map>
-#endif
-
-#include <Eigen/Cholesky>
-#include <Eigen/LU>
-#include <Eigen/Sparse>
-
-enum {
- ForceNonZeroDiag = 1,
- MakeLowerTriangular = 2,
- MakeUpperTriangular = 4,
- ForceRealDiag = 8
-};
-
-/* Initializes both a sparse and dense matrix with same random values,
- * and a ratio of \a density non zero entries.
- * \param flags is a union of ForceNonZeroDiag, MakeLowerTriangular and MakeUpperTriangular
- * allowing to control the shape of the matrix.
- * \param zeroCoords and nonzeroCoords allows to get the coordinate lists of the non zero,
- * and zero coefficients respectively.
- */
-template<typename Scalar> void
-initSparse(double density,
- Matrix<Scalar,Dynamic,Dynamic>& refMat,
- SparseMatrix<Scalar>& sparseMat,
- int flags = 0,
- std::vector<Vector2i>* zeroCoords = 0,
- std::vector<Vector2i>* nonzeroCoords = 0)
-{
- sparseMat.startFill(int(refMat.rows()*refMat.cols()*density));
- for(int j=0; j<refMat.cols(); j++)
- {
- for(int i=0; i<refMat.rows(); i++)
- {
- Scalar v = (ei_random<double>(0,1) < density) ? ei_random<Scalar>() : Scalar(0);
- if ((flags&ForceNonZeroDiag) && (i==j))
- {
- v = ei_random<Scalar>()*Scalar(3.);
- v = v*v + Scalar(5.);
- }
- if ((flags & MakeLowerTriangular) && j>i)
- v = Scalar(0);
- else if ((flags & MakeUpperTriangular) && j<i)
- v = Scalar(0);
-
- if ((flags&ForceRealDiag) && (i==j))
- v = ei_real(v);
-
- if (v!=Scalar(0))
- {
- sparseMat.fill(i,j) = v;
- if (nonzeroCoords)
- nonzeroCoords->push_back(Vector2i(i,j));
- }
- else if (zeroCoords)
- {
- zeroCoords->push_back(Vector2i(i,j));
- }
- refMat(i,j) = v;
- }
- }
- sparseMat.endFill();
-}
-
-template<typename Scalar> void
-initSparse(double density,
- Matrix<Scalar,Dynamic,Dynamic>& refMat,
- DynamicSparseMatrix<Scalar>& sparseMat,
- int flags = 0,
- std::vector<Vector2i>* zeroCoords = 0,
- std::vector<Vector2i>* nonzeroCoords = 0)
-{
- sparseMat.startFill(int(refMat.rows()*refMat.cols()*density));
- for(int j=0; j<refMat.cols(); j++)
- {
- for(int i=0; i<refMat.rows(); i++)
- {
- Scalar v = (ei_random<double>(0,1) < density) ? ei_random<Scalar>() : Scalar(0);
- if ((flags&ForceNonZeroDiag) && (i==j))
- {
- v = ei_random<Scalar>()*Scalar(3.);
- v = v*v + Scalar(5.);
- }
- if ((flags & MakeLowerTriangular) && j>i)
- v = Scalar(0);
- else if ((flags & MakeUpperTriangular) && j<i)
- v = Scalar(0);
-
- if ((flags&ForceRealDiag) && (i==j))
- v = ei_real(v);
-
- if (v!=Scalar(0))
- {
- sparseMat.fill(i,j) = v;
- if (nonzeroCoords)
- nonzeroCoords->push_back(Vector2i(i,j));
- }
- else if (zeroCoords)
- {
- zeroCoords->push_back(Vector2i(i,j));
- }
- refMat(i,j) = v;
- }
- }
- sparseMat.endFill();
-}
-
-template<typename Scalar> void
-initSparse(double density,
- Matrix<Scalar,Dynamic,1>& refVec,
- SparseVector<Scalar>& sparseVec,
- std::vector<int>* zeroCoords = 0,
- std::vector<int>* nonzeroCoords = 0)
-{
- sparseVec.reserve(int(refVec.size()*density));
- sparseVec.setZero();
- for(int i=0; i<refVec.size(); i++)
- {
- Scalar v = (ei_random<double>(0,1) < density) ? ei_random<Scalar>() : Scalar(0);
- if (v!=Scalar(0))
- {
- sparseVec.fill(i) = v;
- if (nonzeroCoords)
- nonzeroCoords->push_back(i);
- }
- else if (zeroCoords)
- zeroCoords->push_back(i);
- refVec[i] = v;
- }
-}
-
-#endif // EIGEN_TESTSPARSE_H
diff --git a/test/jacobisvd.cpp b/test/jacobisvd.cpp
index d441a6eca..36721b496 100644
--- a/test/jacobisvd.cpp
+++ b/test/jacobisvd.cpp
@@ -67,6 +67,7 @@ template<typename MatrixType, int QRPreconditioner>
void jacobisvd_solve(const MatrixType& m, unsigned int computationOptions)
{
typedef typename MatrixType::Scalar Scalar;
+ typedef typename MatrixType::RealScalar RealScalar;
typedef typename MatrixType::Index Index;
Index rows = m.rows();
Index cols = m.cols();
@@ -81,9 +82,37 @@ void jacobisvd_solve(const MatrixType& m, unsigned int computationOptions)
RhsType rhs = RhsType::Random(rows, internal::random<Index>(1, cols));
JacobiSVD<MatrixType, QRPreconditioner> svd(m, computationOptions);
+
+ if(internal::is_same<RealScalar,double>::value) svd.setThreshold(1e-8);
+ else if(internal::is_same<RealScalar,float>::value) svd.setThreshold(1e-4);
+
SolutionType x = svd.solve(rhs);
+
+ RealScalar residual = (m*x-rhs).norm();
+ // Check that there is no significantly better solution in the neighborhood of x
+ if(!test_isMuchSmallerThan(residual,rhs.norm()))
+ {
+ // If the residual is very small, then we have an exact solution, so we are already good.
+ for(int k=0;k<x.rows();++k)
+ {
+ SolutionType y(x);
+ y.row(k).array() += 2*NumTraits<RealScalar>::epsilon();
+ RealScalar residual_y = (m*y-rhs).norm();
+ VERIFY( test_isApprox(residual_y,residual) || residual < residual_y );
+
+ y.row(k) = x.row(k).array() - 2*NumTraits<RealScalar>::epsilon();
+ residual_y = (m*y-rhs).norm();
+ VERIFY( test_isApprox(residual_y,residual) || residual < residual_y );
+ }
+ }
+
// evaluate normal equation which works also for least-squares solutions
- VERIFY_IS_APPROX(m.adjoint()*m*x,m.adjoint()*rhs);
+ if(internal::is_same<RealScalar,double>::value)
+ {
+ // This test is not stable with single precision.
+ // This is probably because squaring m signicantly affects the precision.
+ VERIFY_IS_APPROX(m.adjoint()*m*x,m.adjoint()*rhs);
+ }
// check minimal norm solutions
{
@@ -139,10 +168,9 @@ void jacobisvd_test_all_computation_options(const MatrixType& m)
if (QRPreconditioner == NoQRPreconditioner && m.rows() != m.cols())
return;
JacobiSVD<MatrixType, QRPreconditioner> fullSvd(m, ComputeFullU|ComputeFullV);
-
- jacobisvd_check_full(m, fullSvd);
- jacobisvd_solve<MatrixType, QRPreconditioner>(m, ComputeFullU | ComputeFullV);
-
+ CALL_SUBTEST(( jacobisvd_check_full(m, fullSvd) ));
+ CALL_SUBTEST(( jacobisvd_solve<MatrixType, QRPreconditioner>(m, ComputeFullU | ComputeFullV) ));
+
#if defined __INTEL_COMPILER
// remark #111: statement is unreachable
#pragma warning disable 111
@@ -150,20 +178,20 @@ void jacobisvd_test_all_computation_options(const MatrixType& m)
if(QRPreconditioner == FullPivHouseholderQRPreconditioner)
return;
- jacobisvd_compare_to_full(m, ComputeFullU, fullSvd);
- jacobisvd_compare_to_full(m, ComputeFullV, fullSvd);
- jacobisvd_compare_to_full(m, 0, fullSvd);
+ CALL_SUBTEST(( jacobisvd_compare_to_full(m, ComputeFullU, fullSvd) ));
+ CALL_SUBTEST(( jacobisvd_compare_to_full(m, ComputeFullV, fullSvd) ));
+ CALL_SUBTEST(( jacobisvd_compare_to_full(m, 0, fullSvd) ));
if (MatrixType::ColsAtCompileTime == Dynamic) {
// thin U/V are only available with dynamic number of columns
- jacobisvd_compare_to_full(m, ComputeFullU|ComputeThinV, fullSvd);
- jacobisvd_compare_to_full(m, ComputeThinV, fullSvd);
- jacobisvd_compare_to_full(m, ComputeThinU|ComputeFullV, fullSvd);
- jacobisvd_compare_to_full(m, ComputeThinU , fullSvd);
- jacobisvd_compare_to_full(m, ComputeThinU|ComputeThinV, fullSvd);
- jacobisvd_solve<MatrixType, QRPreconditioner>(m, ComputeFullU | ComputeThinV);
- jacobisvd_solve<MatrixType, QRPreconditioner>(m, ComputeThinU | ComputeFullV);
- jacobisvd_solve<MatrixType, QRPreconditioner>(m, ComputeThinU | ComputeThinV);
+ CALL_SUBTEST(( jacobisvd_compare_to_full(m, ComputeFullU|ComputeThinV, fullSvd) ));
+ CALL_SUBTEST(( jacobisvd_compare_to_full(m, ComputeThinV, fullSvd) ));
+ CALL_SUBTEST(( jacobisvd_compare_to_full(m, ComputeThinU|ComputeFullV, fullSvd) ));
+ CALL_SUBTEST(( jacobisvd_compare_to_full(m, ComputeThinU , fullSvd) ));
+ CALL_SUBTEST(( jacobisvd_compare_to_full(m, ComputeThinU|ComputeThinV, fullSvd) ));
+ CALL_SUBTEST(( jacobisvd_solve<MatrixType, QRPreconditioner>(m, ComputeFullU | ComputeThinV) ));
+ CALL_SUBTEST(( jacobisvd_solve<MatrixType, QRPreconditioner>(m, ComputeThinU | ComputeFullV) ));
+ CALL_SUBTEST(( jacobisvd_solve<MatrixType, QRPreconditioner>(m, ComputeThinU | ComputeThinV) ));
// test reconstruction
typedef typename MatrixType::Index Index;
@@ -176,12 +204,29 @@ void jacobisvd_test_all_computation_options(const MatrixType& m)
template<typename MatrixType>
void jacobisvd(const MatrixType& a = MatrixType(), bool pickrandom = true)
{
- MatrixType m = pickrandom ? MatrixType::Random(a.rows(), a.cols()) : a;
+ MatrixType m = a;
+ if(pickrandom)
+ {
+ typedef typename MatrixType::Scalar Scalar;
+ typedef typename MatrixType::RealScalar RealScalar;
+ typedef typename MatrixType::Index Index;
+ Index diagSize = (std::min)(a.rows(), a.cols());
+ RealScalar s = std::numeric_limits<RealScalar>::max_exponent10/4;
+ s = internal::random<RealScalar>(1,s);
+ Matrix<RealScalar,Dynamic,1> d = Matrix<RealScalar,Dynamic,1>::Random(diagSize);
+ for(Index k=0; k<diagSize; ++k)
+ d(k) = d(k)*std::pow(RealScalar(10),internal::random<RealScalar>(-s,s));
+ m = Matrix<Scalar,Dynamic,Dynamic>::Random(a.rows(),diagSize) * d.asDiagonal() * Matrix<Scalar,Dynamic,Dynamic>::Random(diagSize,a.cols());
+ // cancel some coeffs
+ Index n = internal::random<Index>(0,m.size()-1);
+ for(Index i=0; i<n; ++i)
+ m(internal::random<Index>(0,m.rows()-1), internal::random<Index>(0,m.cols()-1)) = Scalar(0);
+ }
- jacobisvd_test_all_computation_options<MatrixType, FullPivHouseholderQRPreconditioner>(m);
- jacobisvd_test_all_computation_options<MatrixType, ColPivHouseholderQRPreconditioner>(m);
- jacobisvd_test_all_computation_options<MatrixType, HouseholderQRPreconditioner>(m);
- jacobisvd_test_all_computation_options<MatrixType, NoQRPreconditioner>(m);
+ CALL_SUBTEST(( jacobisvd_test_all_computation_options<MatrixType, FullPivHouseholderQRPreconditioner>(m) ));
+ CALL_SUBTEST(( jacobisvd_test_all_computation_options<MatrixType, ColPivHouseholderQRPreconditioner>(m) ));
+ CALL_SUBTEST(( jacobisvd_test_all_computation_options<MatrixType, HouseholderQRPreconditioner>(m) ));
+ CALL_SUBTEST(( jacobisvd_test_all_computation_options<MatrixType, NoQRPreconditioner>(m) ));
}
template<typename MatrixType> void jacobisvd_verify_assert(const MatrixType& m)
@@ -384,6 +429,7 @@ void test_jacobisvd()
TEST_SET_BUT_UNUSED_VARIABLE(r)
TEST_SET_BUT_UNUSED_VARIABLE(c)
+ CALL_SUBTEST_10(( jacobisvd<MatrixXd>(MatrixXd(r,c)) ));
CALL_SUBTEST_7(( jacobisvd<MatrixXf>(MatrixXf(r,c)) ));
CALL_SUBTEST_8(( jacobisvd<MatrixXcd>(MatrixXcd(r,c)) ));
(void) r;
diff --git a/test/main.h b/test/main.h
index 3ccc2ae88..3295dcb71 100644
--- a/test/main.h
+++ b/test/main.h
@@ -117,13 +117,14 @@ namespace Eigen
if(report_on_cerr_on_assert_failure) \
std::cerr << #a << " " __FILE__ << "(" << __LINE__ << ")\n"; \
Eigen::no_more_assert = true; \
- throw Eigen::eigen_assert_exception(); \
+ EIGEN_THROW_X(Eigen::eigen_assert_exception()); \
} \
else if (Eigen::internal::push_assert) \
{ \
eigen_assert_list.push_back(std::string(EI_PP_MAKE_STRING(__FILE__) " (" EI_PP_MAKE_STRING(__LINE__) ") : " #a) ); \
}
+ #ifdef EIGEN_EXCEPTIONS
#define VERIFY_RAISES_ASSERT(a) \
{ \
Eigen::no_more_assert = false; \
@@ -142,6 +143,7 @@ namespace Eigen
Eigen::report_on_cerr_on_assert_failure = true; \
Eigen::internal::push_assert = false; \
}
+ #endif //EIGEN_EXCEPTIONS
#elif !defined(__CUDACC__) // EIGEN_DEBUG_ASSERTS
// see bug 89. The copy_bool here is working around a bug in gcc <= 4.3
@@ -152,9 +154,10 @@ namespace Eigen
if(report_on_cerr_on_assert_failure) \
eigen_plain_assert(a); \
else \
- throw Eigen::eigen_assert_exception(); \
+ EIGEN_THROW_X(Eigen::eigen_assert_exception()); \
}
- #define VERIFY_RAISES_ASSERT(a) { \
+ #ifdef EIGEN_EXCEPTIONS
+ #define VERIFY_RAISES_ASSERT(a) { \
Eigen::no_more_assert = false; \
Eigen::report_on_cerr_on_assert_failure = false; \
try { \
@@ -164,9 +167,14 @@ namespace Eigen
catch (Eigen::eigen_assert_exception&) { VERIFY(true); } \
Eigen::report_on_cerr_on_assert_failure = true; \
}
-
+ #endif //EIGEN_EXCEPTIONS
#endif // EIGEN_DEBUG_ASSERTS
+#ifndef VERIFY_RAISES_ASSERT
+ #define VERIFY_RAISES_ASSERT(a) \
+ std::cout << "Can't VERIFY_RAISES_ASSERT( " #a " ) with exceptions disabled";
+#endif
+
#if !defined(__CUDACC__)
#define EIGEN_USE_CUSTOM_ASSERT
#endif
diff --git a/test/mapstaticmethods.cpp b/test/mapstaticmethods.cpp
index 5b512bde4..06272d106 100644
--- a/test/mapstaticmethods.cpp
+++ b/test/mapstaticmethods.cpp
@@ -69,7 +69,8 @@ struct mapstaticmethods_impl<PlainObjectType, true, false>
{
static void run(const PlainObjectType& m)
{
- int rows = m.rows(), cols = m.cols();
+ typedef typename PlainObjectType::Index Index;
+ Index rows = m.rows(), cols = m.cols();
int i = internal::random<int>(2,5), j = internal::random<int>(2,5);
@@ -115,7 +116,8 @@ struct mapstaticmethods_impl<PlainObjectType, true, true>
{
static void run(const PlainObjectType& v)
{
- int size = v.size();
+ typedef typename PlainObjectType::Index Index;
+ Index size = v.size();
int i = internal::random<int>(2,5);
diff --git a/test/meta.cpp b/test/meta.cpp
index 3302c5887..b8dea68e8 100644
--- a/test/meta.cpp
+++ b/test/meta.cpp
@@ -9,6 +9,12 @@
#include "main.h"
+template<typename From, typename To>
+bool check_is_convertible(const From&, const To&)
+{
+ return internal::is_convertible<From,To>::value;
+}
+
void test_meta()
{
VERIFY((internal::conditional<(3<4),internal::true_type, internal::false_type>::type::value));
@@ -52,6 +58,24 @@ void test_meta()
VERIFY(( internal::is_same<const float,internal::remove_pointer<const float*>::type >::value));
VERIFY(( internal::is_same<float,internal::remove_pointer<float* const >::type >::value));
+ VERIFY(( internal::is_convertible<float,double>::value ));
+ VERIFY(( internal::is_convertible<int,double>::value ));
+ VERIFY(( internal::is_convertible<double,int>::value ));
+ VERIFY((!internal::is_convertible<std::complex<double>,double>::value ));
+ VERIFY(( internal::is_convertible<Array33f,Matrix3f>::value ));
+// VERIFY((!internal::is_convertible<Matrix3f,Matrix3d>::value )); //does not work because the conversion is prevented by a static assertion
+ VERIFY((!internal::is_convertible<Array33f,int>::value ));
+ VERIFY((!internal::is_convertible<MatrixXf,float>::value ));
+ {
+ float f;
+ MatrixXf A, B;
+ VectorXf a, b;
+ VERIFY(( check_is_convertible(a.dot(b), f) ));
+ VERIFY(( check_is_convertible(a.transpose()*b, f) ));
+ VERIFY((!check_is_convertible(A*B, f) ));
+ VERIFY(( check_is_convertible(A*B, A) ));
+ }
+
VERIFY(internal::meta_sqrt<1>::ret == 1);
#define VERIFY_META_SQRT(X) VERIFY(internal::meta_sqrt<X>::ret == int(std::sqrt(double(X))))
VERIFY_META_SQRT(2);
diff --git a/test/packetmath.cpp b/test/packetmath.cpp
index f4bb544e5..af9be89ca 100644
--- a/test/packetmath.cpp
+++ b/test/packetmath.cpp
@@ -424,14 +424,17 @@ template<typename Scalar> void packetmath_scatter_gather() {
for (int i=0; i<PacketSize; ++i) {
data1[i] = internal::random<Scalar>()/RealScalar(PacketSize);
}
- EIGEN_ALIGN_DEFAULT Scalar buffer[PacketSize*11];
- memset(buffer, 0, 11*sizeof(Packet));
+
+ int stride = internal::random<int>(1,20);
+
+ EIGEN_ALIGN_DEFAULT Scalar buffer[PacketSize*20];
+ memset(buffer, 0, 20*sizeof(Packet));
Packet packet = internal::pload<Packet>(data1);
- internal::pscatter<Scalar, Packet>(buffer, packet, 11);
+ internal::pscatter<Scalar, Packet>(buffer, packet, stride);
- for (int i = 0; i < PacketSize*11; ++i) {
- if ((i%11) == 0) {
- VERIFY(isApproxAbs(buffer[i], data1[i/11], refvalue) && "pscatter");
+ for (int i = 0; i < PacketSize*20; ++i) {
+ if ((i%stride) == 0 && i<stride*PacketSize) {
+ VERIFY(isApproxAbs(buffer[i], data1[i/stride], refvalue) && "pscatter");
} else {
VERIFY(isApproxAbs(buffer[i], Scalar(0), refvalue) && "pscatter");
}
diff --git a/test/product_large.cpp b/test/product_large.cpp
index 03d7bd8ed..11531aa1d 100644
--- a/test/product_large.cpp
+++ b/test/product_large.cpp
@@ -61,4 +61,13 @@ void test_product_large()
VERIFY_IS_APPROX(r2, (mat1.row(2)*mat2).eval());
}
#endif
+
+ // Regression test for bug 714:
+#ifdef EIGEN_HAS_OPENMP
+ std::cout << "Testing omp_set_dynamic(1)\n";
+ omp_set_dynamic(1);
+ for(int i = 0; i < g_repeat; i++) {
+ CALL_SUBTEST_6( product(Matrix<float,Dynamic,Dynamic>(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) );
+ }
+#endif
}
diff --git a/test/product_notemporary.cpp b/test/product_notemporary.cpp
index 258d238e2..3a9df618b 100644
--- a/test/product_notemporary.cpp
+++ b/test/product_notemporary.cpp
@@ -7,13 +7,12 @@
// 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/.
-static int nb_temporaries;
+static long int nb_temporaries;
-inline void on_temporary_creation(int size) {
+inline void on_temporary_creation(long int size) {
// here's a great place to set a breakpoint when debugging failures in this test!
if(size!=0) nb_temporaries++;
}
-
#define EIGEN_DENSE_STORAGE_CTOR_PLUGIN { on_temporary_creation(size); }
diff --git a/test/product_trsolve.cpp b/test/product_trsolve.cpp
index 69892b3a8..4b97fa9d6 100644
--- a/test/product_trsolve.cpp
+++ b/test/product_trsolve.cpp
@@ -84,10 +84,18 @@ void test_product_trsolve()
CALL_SUBTEST_4((trsolve<std::complex<double>,Dynamic,Dynamic>(internal::random<int>(1,EIGEN_TEST_MAX_SIZE/2),internal::random<int>(1,EIGEN_TEST_MAX_SIZE/2))));
// vectors
- CALL_SUBTEST_1((trsolve<float,Dynamic,1>(internal::random<int>(1,EIGEN_TEST_MAX_SIZE))));
- CALL_SUBTEST_5((trsolve<std::complex<double>,Dynamic,1>(internal::random<int>(1,EIGEN_TEST_MAX_SIZE))));
- CALL_SUBTEST_6((trsolve<float,1,1>()));
- CALL_SUBTEST_7((trsolve<float,1,2>()));
- CALL_SUBTEST_8((trsolve<std::complex<float>,4,1>()));
+ CALL_SUBTEST_5((trsolve<float,Dynamic,1>(internal::random<int>(1,EIGEN_TEST_MAX_SIZE))));
+ CALL_SUBTEST_6((trsolve<double,Dynamic,1>(internal::random<int>(1,EIGEN_TEST_MAX_SIZE))));
+ CALL_SUBTEST_7((trsolve<std::complex<float>,Dynamic,1>(internal::random<int>(1,EIGEN_TEST_MAX_SIZE))));
+ CALL_SUBTEST_8((trsolve<std::complex<double>,Dynamic,1>(internal::random<int>(1,EIGEN_TEST_MAX_SIZE))));
+
+ // meta-unrollers
+ CALL_SUBTEST_9((trsolve<float,4,1>()));
+ CALL_SUBTEST_10((trsolve<double,4,1>()));
+ CALL_SUBTEST_11((trsolve<std::complex<float>,4,1>()));
+ CALL_SUBTEST_12((trsolve<float,1,1>()));
+ CALL_SUBTEST_13((trsolve<float,1,2>()));
+ CALL_SUBTEST_14((trsolve<float,3,1>()));
+
}
}
diff --git a/test/ref.cpp b/test/ref.cpp
index 19e81549c..d91e3b54c 100644
--- a/test/ref.cpp
+++ b/test/ref.cpp
@@ -12,13 +12,12 @@
#undef EIGEN_DEFAULT_TO_ROW_MAJOR
#endif
-static int nb_temporaries;
+static long int nb_temporaries;
-inline void on_temporary_creation(int) {
+inline void on_temporary_creation(long int) {
// here's a great place to set a breakpoint when debugging failures in this test!
nb_temporaries++;
}
-
#define EIGEN_DENSE_STORAGE_CTOR_PLUGIN { on_temporary_creation(size); }
diff --git a/test/simplicial_cholesky.cpp b/test/simplicial_cholesky.cpp
index e93a52e9c..786468421 100644
--- a/test/simplicial_cholesky.cpp
+++ b/test/simplicial_cholesky.cpp
@@ -11,26 +11,31 @@
template<typename T> void test_simplicial_cholesky_T()
{
- SimplicialCholesky<SparseMatrix<T>, Lower> chol_colmajor_lower;
- SimplicialCholesky<SparseMatrix<T>, Upper> chol_colmajor_upper;
- SimplicialLLT<SparseMatrix<T>, Lower> llt_colmajor_lower;
- SimplicialLDLT<SparseMatrix<T>, Upper> llt_colmajor_upper;
- SimplicialLDLT<SparseMatrix<T>, Lower> ldlt_colmajor_lower;
- SimplicialLDLT<SparseMatrix<T>, Upper> ldlt_colmajor_upper;
+ SimplicialCholesky<SparseMatrix<T>, Lower> chol_colmajor_lower_amd;
+ SimplicialCholesky<SparseMatrix<T>, Upper> chol_colmajor_upper_amd;
+ SimplicialLLT<SparseMatrix<T>, Lower> llt_colmajor_lower_amd;
+ SimplicialLLT<SparseMatrix<T>, Upper> llt_colmajor_upper_amd;
+ SimplicialLDLT<SparseMatrix<T>, Lower> ldlt_colmajor_lower_amd;
+ SimplicialLDLT<SparseMatrix<T>, Upper> ldlt_colmajor_upper_amd;
+ SimplicialLDLT<SparseMatrix<T>, Lower, NaturalOrdering<int> > ldlt_colmajor_lower_nat;
+ SimplicialLDLT<SparseMatrix<T>, Upper, NaturalOrdering<int> > ldlt_colmajor_upper_nat;
- check_sparse_spd_solving(chol_colmajor_lower);
- check_sparse_spd_solving(chol_colmajor_upper);
- check_sparse_spd_solving(llt_colmajor_lower);
- check_sparse_spd_solving(llt_colmajor_upper);
- check_sparse_spd_solving(ldlt_colmajor_lower);
- check_sparse_spd_solving(ldlt_colmajor_upper);
+ check_sparse_spd_solving(chol_colmajor_lower_amd);
+ check_sparse_spd_solving(chol_colmajor_upper_amd);
+ check_sparse_spd_solving(llt_colmajor_lower_amd);
+ check_sparse_spd_solving(llt_colmajor_upper_amd);
+ check_sparse_spd_solving(ldlt_colmajor_lower_amd);
+ check_sparse_spd_solving(ldlt_colmajor_upper_amd);
- check_sparse_spd_determinant(chol_colmajor_lower);
- check_sparse_spd_determinant(chol_colmajor_upper);
- check_sparse_spd_determinant(llt_colmajor_lower);
- check_sparse_spd_determinant(llt_colmajor_upper);
- check_sparse_spd_determinant(ldlt_colmajor_lower);
- check_sparse_spd_determinant(ldlt_colmajor_upper);
+ check_sparse_spd_determinant(chol_colmajor_lower_amd);
+ check_sparse_spd_determinant(chol_colmajor_upper_amd);
+ check_sparse_spd_determinant(llt_colmajor_lower_amd);
+ check_sparse_spd_determinant(llt_colmajor_upper_amd);
+ check_sparse_spd_determinant(ldlt_colmajor_lower_amd);
+ check_sparse_spd_determinant(ldlt_colmajor_upper_amd);
+
+ check_sparse_spd_solving(ldlt_colmajor_lower_nat);
+ check_sparse_spd_solving(ldlt_colmajor_upper_nat);
}
void test_simplicial_cholesky()
diff --git a/test/sparse.h b/test/sparse.h
index e19a76316..81ab9e873 100644
--- a/test/sparse.h
+++ b/test/sparse.h
@@ -71,7 +71,7 @@ initSparse(double density,
//sparseMat.startVec(j);
for(Index i=0; i<sparseMat.innerSize(); i++)
{
- int ai(i), aj(j);
+ Index ai(i), aj(j);
if(IsRowMajor)
std::swap(ai,aj);
Scalar v = (internal::random<double>(0,1) < density) ? internal::random<Scalar>() : Scalar(0);
@@ -163,7 +163,7 @@ initSparse(double density,
{
sparseVec.reserve(int(refVec.size()*density));
sparseVec.setZero();
- for(Index i=0; i<refVec.size(); i++)
+ for(int i=0; i<refVec.size(); i++)
{
Scalar v = (internal::random<double>(0,1) < density) ? internal::random<Scalar>() : Scalar(0);
if (v!=Scalar(0))
diff --git a/test/sparse_basic.cpp b/test/sparse_basic.cpp
index 6c620f037..4c9b9111e 100644
--- a/test/sparse_basic.cpp
+++ b/test/sparse_basic.cpp
@@ -147,7 +147,7 @@ template<typename SparseMatrixType> void sparse_basic(const SparseMatrixType& re
DenseMatrix m1(rows,cols);
m1.setZero();
SparseMatrixType m2(rows,cols);
- VectorXi r(VectorXi::Constant(m2.outerSize(), ((mode%2)==0) ? m2.innerSize() : std::max<int>(1,m2.innerSize()/8)));
+ VectorXi r(VectorXi::Constant(m2.outerSize(), ((mode%2)==0) ? int(m2.innerSize()) : std::max<int>(1,int(m2.innerSize())/8)));
m2.reserve(r);
for (int k=0; k<rows*cols; ++k)
{
@@ -181,7 +181,7 @@ template<typename SparseMatrixType> void sparse_basic(const SparseMatrixType& re
VERIFY_IS_APPROX(m2.innerVector(j0)+m2.innerVector(j1), refMat2.col(j0)+refMat2.col(j1));
SparseMatrixType m3(rows,rows);
- m3.reserve(VectorXi::Constant(rows,rows/2));
+ m3.reserve(VectorXi::Constant(rows,int(rows/2)));
for(Index j=0; j<rows; ++j)
for(Index k=0; k<j; ++k)
m3.insertByOuterInner(j,k) = k+1;
@@ -384,11 +384,11 @@ template<typename SparseMatrixType> void sparse_basic(const SparseMatrixType& re
{
typedef Triplet<Scalar,Index> TripletType;
std::vector<TripletType> triplets;
- int ntriplets = rows*cols;
+ Index ntriplets = rows*cols;
triplets.reserve(ntriplets);
DenseMatrix refMat(rows,cols);
refMat.setZero();
- for(int i=0;i<ntriplets;++i)
+ for(Index i=0;i<ntriplets;++i)
{
Index r = internal::random<Index>(0,rows-1);
Index c = internal::random<Index>(0,cols-1);
diff --git a/test/sparse_product.cpp b/test/sparse_product.cpp
index a2ea9d5b7..0f52164c8 100644
--- a/test/sparse_product.cpp
+++ b/test/sparse_product.cpp
@@ -9,32 +9,6 @@
#include "sparse.h"
-template<typename SparseMatrixType, typename DenseMatrix, bool IsRowMajor=SparseMatrixType::IsRowMajor> struct test_outer;
-
-template<typename SparseMatrixType, typename DenseMatrix> struct test_outer<SparseMatrixType,DenseMatrix,false> {
- static void run(SparseMatrixType& m2, SparseMatrixType& m4, DenseMatrix& refMat2, DenseMatrix& refMat4) {
- typedef typename SparseMatrixType::Index Index;
- Index c = internal::random<Index>(0,m2.cols()-1);
- Index c1 = internal::random<Index>(0,m2.cols()-1);
- VERIFY_IS_APPROX(m4=m2.col(c)*refMat2.col(c1).transpose(), refMat4=refMat2.col(c)*refMat2.col(c1).transpose());
- VERIFY_IS_APPROX(m4=refMat2.col(c1)*m2.col(c).transpose(), refMat4=refMat2.col(c1)*refMat2.col(c).transpose());
- }
-};
-
-template<typename SparseMatrixType, typename DenseMatrix> struct test_outer<SparseMatrixType,DenseMatrix,true> {
- static void run(SparseMatrixType& m2, SparseMatrixType& m4, DenseMatrix& refMat2, DenseMatrix& refMat4) {
- typedef typename SparseMatrixType::Index Index;
- Index r = internal::random<Index>(0,m2.rows()-1);
- Index c1 = internal::random<Index>(0,m2.cols()-1);
- VERIFY_IS_APPROX(m4=m2.row(r).transpose()*refMat2.col(c1).transpose(), refMat4=refMat2.row(r).transpose()*refMat2.col(c1).transpose());
- VERIFY_IS_APPROX(m4=refMat2.col(c1)*m2.row(r), refMat4=refMat2.col(c1)*refMat2.row(r));
- }
-};
-
-// (m2,m4,refMat2,refMat4,dv1);
-// VERIFY_IS_APPROX(m4=m2.innerVector(c)*dv1.transpose(), refMat4=refMat2.colVector(c)*dv1.transpose());
-// VERIFY_IS_APPROX(m4=dv1*mcm.col(c).transpose(), refMat4=dv1*refMat2.col(c).transpose());
-
template<typename SparseMatrixType> void sparse_product()
{
typedef typename SparseMatrixType::Index Index;
@@ -119,7 +93,45 @@ template<typename SparseMatrixType> void sparse_product()
VERIFY_IS_APPROX(dm4=refMat2t.transpose()*m3t.transpose(), refMat4=refMat2t.transpose()*refMat3t.transpose());
// sparse * dense and dense * sparse outer product
- test_outer<SparseMatrixType,DenseMatrix>::run(m2,m4,refMat2,refMat4);
+ {
+ Index c = internal::random<Index>(0,depth-1);
+ Index r = internal::random<Index>(0,rows-1);
+ Index c1 = internal::random<Index>(0,cols-1);
+ Index r1 = internal::random<Index>(0,depth-1);
+ DenseMatrix dm5 = DenseMatrix::Random(depth, cols);
+
+ VERIFY_IS_APPROX( m4=m2.col(c)*dm5.col(c1).transpose(), refMat4=refMat2.col(c)*dm5.col(c1).transpose());
+ VERIFY_IS_EQUAL(m4.nonZeros(), (refMat4.array()!=0).count());
+ VERIFY_IS_APPROX( m4=m2.middleCols(c,1)*dm5.col(c1).transpose(), refMat4=refMat2.col(c)*dm5.col(c1).transpose());
+ VERIFY_IS_EQUAL(m4.nonZeros(), (refMat4.array()!=0).count());
+ VERIFY_IS_APPROX(dm4=m2.col(c)*dm5.col(c1).transpose(), refMat4=refMat2.col(c)*dm5.col(c1).transpose());
+
+ VERIFY_IS_APPROX(m4=dm5.col(c1)*m2.col(c).transpose(), refMat4=dm5.col(c1)*refMat2.col(c).transpose());
+ VERIFY_IS_EQUAL(m4.nonZeros(), (refMat4.array()!=0).count());
+ VERIFY_IS_APPROX(m4=dm5.col(c1)*m2.middleCols(c,1).transpose(), refMat4=dm5.col(c1)*refMat2.col(c).transpose());
+ VERIFY_IS_EQUAL(m4.nonZeros(), (refMat4.array()!=0).count());
+ VERIFY_IS_APPROX(dm4=dm5.col(c1)*m2.col(c).transpose(), refMat4=dm5.col(c1)*refMat2.col(c).transpose());
+
+ VERIFY_IS_APPROX( m4=dm5.row(r1).transpose()*m2.col(c).transpose(), refMat4=dm5.row(r1).transpose()*refMat2.col(c).transpose());
+ VERIFY_IS_EQUAL(m4.nonZeros(), (refMat4.array()!=0).count());
+ VERIFY_IS_APPROX(dm4=dm5.row(r1).transpose()*m2.col(c).transpose(), refMat4=dm5.row(r1).transpose()*refMat2.col(c).transpose());
+
+ VERIFY_IS_APPROX( m4=m2.row(r).transpose()*dm5.col(c1).transpose(), refMat4=refMat2.row(r).transpose()*dm5.col(c1).transpose());
+ VERIFY_IS_EQUAL(m4.nonZeros(), (refMat4.array()!=0).count());
+ VERIFY_IS_APPROX( m4=m2.middleRows(r,1).transpose()*dm5.col(c1).transpose(), refMat4=refMat2.row(r).transpose()*dm5.col(c1).transpose());
+ VERIFY_IS_EQUAL(m4.nonZeros(), (refMat4.array()!=0).count());
+ VERIFY_IS_APPROX(dm4=m2.row(r).transpose()*dm5.col(c1).transpose(), refMat4=refMat2.row(r).transpose()*dm5.col(c1).transpose());
+
+ VERIFY_IS_APPROX( m4=dm5.col(c1)*m2.row(r), refMat4=dm5.col(c1)*refMat2.row(r));
+ VERIFY_IS_EQUAL(m4.nonZeros(), (refMat4.array()!=0).count());
+ VERIFY_IS_APPROX( m4=dm5.col(c1)*m2.middleRows(r,1), refMat4=dm5.col(c1)*refMat2.row(r));
+ VERIFY_IS_EQUAL(m4.nonZeros(), (refMat4.array()!=0).count());
+ VERIFY_IS_APPROX(dm4=dm5.col(c1)*m2.row(r), refMat4=dm5.col(c1)*refMat2.row(r));
+
+ VERIFY_IS_APPROX( m4=dm5.row(r1).transpose()*m2.row(r), refMat4=dm5.row(r1).transpose()*refMat2.row(r));
+ VERIFY_IS_EQUAL(m4.nonZeros(), (refMat4.array()!=0).count());
+ VERIFY_IS_APPROX(dm4=dm5.row(r1).transpose()*m2.row(r), refMat4=dm5.row(r1).transpose()*refMat2.row(r));
+ }
VERIFY_IS_APPROX(m6=m6*m6, refMat6=refMat6*refMat6);
diff --git a/test/sparseqr.cpp b/test/sparseqr.cpp
index 6edba30b2..1fe4a98ee 100644
--- a/test/sparseqr.cpp
+++ b/test/sparseqr.cpp
@@ -2,24 +2,24 @@
// for linear algebra.
//
// Copyright (C) 2012 Desire Nuentsa Wakam <desire.nuentsa_wakam@inria.fr>
+// Copyright (C) 2014 Gael Guennebaud <gael.guennebaud@inria.fr>
//
// 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
#include "sparse.h"
#include <Eigen/SparseQR>
-
template<typename MatrixType,typename DenseMat>
-int generate_sparse_rectangular_problem(MatrixType& A, DenseMat& dA, int maxRows = 300, int maxCols = 300)
+int generate_sparse_rectangular_problem(MatrixType& A, DenseMat& dA, int maxRows = 300, int maxCols = 150)
{
eigen_assert(maxRows >= maxCols);
typedef typename MatrixType::Scalar Scalar;
int rows = internal::random<int>(1,maxRows);
- int cols = internal::random<int>(1,rows);
+ int cols = internal::random<int>(1,maxCols);
double density = (std::max)(8./(rows*cols), 0.01);
- A.resize(rows,rows);
- dA.resize(rows,rows);
+ A.resize(rows,cols);
+ dA.resize(rows,cols);
initSparse<Scalar>(density, dA, A,ForceNonZeroDiag);
A.makeCompressed();
int nop = internal::random<int>(0, internal::random<double>(0,1) > 0.5 ? cols/2 : 0);
@@ -31,6 +31,13 @@ int generate_sparse_rectangular_problem(MatrixType& A, DenseMat& dA, int maxRows
A.col(j0) = s * A.col(j1);
dA.col(j0) = s * dA.col(j1);
}
+
+// if(rows<cols) {
+// A.conservativeResize(cols,cols);
+// dA.conservativeResize(cols,cols);
+// dA.bottomRows(cols-rows).setZero();
+// }
+
return rows;
}
@@ -42,11 +49,10 @@ template<typename Scalar> void test_sparseqr_scalar()
MatrixType A;
DenseMat dA;
DenseVector refX,x,b;
- SparseQR<MatrixType, AMDOrdering<int> > solver;
+ SparseQR<MatrixType, COLAMDOrdering<int> > solver;
generate_sparse_rectangular_problem(A,dA);
- int n = A.cols();
- b = DenseVector::Random(n);
+ b = dA * DenseVector::Random(A.cols());
solver.compute(A);
if (solver.info() != Success)
{
@@ -60,17 +66,19 @@ template<typename Scalar> void test_sparseqr_scalar()
std::cerr << "sparse QR factorization failed\n";
exit(0);
return;
- }
+ }
+
+ VERIFY_IS_APPROX(A * x, b);
+
//Compare with a dense QR solver
ColPivHouseholderQR<DenseMat> dqr(dA);
refX = dqr.solve(b);
VERIFY_IS_EQUAL(dqr.rank(), solver.rank());
-
- if(solver.rank()<A.cols())
- VERIFY((dA * refX - b).norm() * 2 > (A * x - b).norm() );
- else
+ if(solver.rank()==A.cols()) // full rank
VERIFY_IS_APPROX(x, refX);
+// else
+// VERIFY((dA * refX - b).norm() * 2 > (A * x - b).norm() );
// Compute explicitly the matrix Q
MatrixType Q, QtQ, idM;
@@ -88,3 +96,4 @@ void test_sparseqr()
CALL_SUBTEST_2(test_sparseqr_scalar<std::complex<double> >());
}
}
+
diff --git a/test/triangular.cpp b/test/triangular.cpp
index 54320390b..936c2aef3 100644
--- a/test/triangular.cpp
+++ b/test/triangular.cpp
@@ -113,6 +113,13 @@ template<typename MatrixType> void triangular_square(const MatrixType& m)
m3.setZero();
m3.template triangularView<Upper>().setOnes();
VERIFY_IS_APPROX(m2,m3);
+
+ m1.setRandom();
+ m3 = m1.template triangularView<Upper>();
+ Matrix<Scalar, MatrixType::ColsAtCompileTime, Dynamic> m5(cols, internal::random<int>(1,20)); m5.setRandom();
+ Matrix<Scalar, Dynamic, MatrixType::RowsAtCompileTime> m6(internal::random<int>(1,20), rows); m6.setRandom();
+ VERIFY_IS_APPROX(m1.template triangularView<Upper>() * m5, m3*m5);
+ VERIFY_IS_APPROX(m6*m1.template triangularView<Upper>(), m6*m3);
}
diff --git a/test/vectorization_logic.cpp b/test/vectorization_logic.cpp
index 09b46660b..b069f0771 100644
--- a/test/vectorization_logic.cpp
+++ b/test/vectorization_logic.cpp
@@ -77,8 +77,9 @@ bool test_redux(const Xpr&, int traversal, int unrolling)
template<typename Scalar, bool Enable = internal::packet_traits<Scalar>::Vectorizable> struct vectorization_logic
{
+ typedef internal::packet_traits<Scalar> PacketTraits;
enum {
- PacketSize = internal::packet_traits<Scalar>::size
+ PacketSize = PacketTraits::size
};
static void run()
{
@@ -151,7 +152,7 @@ template<typename Scalar, bool Enable = internal::packet_traits<Scalar>::Vectori
LinearTraversal,CompleteUnrolling));
VERIFY(test_assign(Matrix3(),Matrix3().cwiseQuotient(Matrix3()),
- LinearVectorizedTraversal,CompleteUnrolling));
+ PacketTraits::HasDiv ? LinearVectorizedTraversal : LinearTraversal,CompleteUnrolling));
VERIFY(test_assign(Matrix<Scalar,17,17>(),Matrix<Scalar,17,17>()+Matrix<Scalar,17,17>(),
LinearTraversal,NoUnrolling));
@@ -209,6 +210,7 @@ void test_vectorization_logic()
#ifdef EIGEN_VECTORIZE
+ CALL_SUBTEST( vectorization_logic<int>::run() );
CALL_SUBTEST( vectorization_logic<float>::run() );
CALL_SUBTEST( vectorization_logic<double>::run() );
CALL_SUBTEST( vectorization_logic<std::complex<float> >::run() );
diff --git a/unsupported/Eigen/CXX11/Core b/unsupported/Eigen/CXX11/Core
index bba3d578d..f6c3b49bb 100644
--- a/unsupported/Eigen/CXX11/Core
+++ b/unsupported/Eigen/CXX11/Core
@@ -34,6 +34,7 @@
#if __cplusplus <= 199711L
#include "src/Core/util/EmulateCXX11Meta.h"
#else
+#include <array>
#include "src/Core/util/CXX11Workarounds.h"
#include "src/Core/util/CXX11Meta.h"
#endif
diff --git a/unsupported/Eigen/MPRealSupport b/unsupported/Eigen/MPRealSupport
index d4b03647d..632de3854 100644
--- a/unsupported/Eigen/MPRealSupport
+++ b/unsupported/Eigen/MPRealSupport
@@ -27,6 +27,8 @@ namespace Eigen {
* via the <a href="http://www.holoborodko.com/pavel/mpfr">MPFR C++</a>
* library which itself is built upon <a href="http://www.mpfr.org/">MPFR</a>/<a href="http://gmplib.org/">GMP</a>.
*
+ * \warning MPFR C++ is licensed under the GPL.
+ *
* You can find a copy of MPFR C++ that is known to be compatible in the unsupported/test/mpreal folder.
*
* Here is an example:
@@ -86,9 +88,9 @@ int main()
inline static Real epsilon (const Real& x) { return mpfr::machine_epsilon(x); }
inline static Real dummy_precision()
- {
- unsigned int weak_prec = ((mpfr::mpreal::get_default_prec()-1) * 90) / 100;
- return mpfr::machine_epsilon(weak_prec);
+ {
+ mpfr_prec_t weak_prec = ((mpfr::mpreal::get_default_prec()-1) * 90) / 100;
+ return mpfr::machine_epsilon(weak_prec);
}
};
@@ -139,64 +141,53 @@ int main()
public:
typedef mpfr::mpreal ResScalar;
enum {
- nr = 2, // must be 2 for proper packing...
+ nr = 1,
mr = 1,
- WorkSpaceFactor = nr,
LhsProgress = 1,
RhsProgress = 1
};
};
- template<typename Index, int mr, int nr, bool ConjugateLhs, bool ConjugateRhs>
- struct gebp_kernel<mpfr::mpreal,mpfr::mpreal,Index,mr,nr,ConjugateLhs,ConjugateRhs>
+ template<typename Index, bool ConjugateLhs, bool ConjugateRhs>
+ struct gebp_kernel<mpfr::mpreal,mpfr::mpreal,Index,1,1,ConjugateLhs,ConjugateRhs>
{
typedef mpfr::mpreal mpreal;
EIGEN_DONT_INLINE
void operator()(mpreal* res, Index resStride, const mpreal* blockA, const mpreal* blockB, Index rows, Index depth, Index cols, mpreal alpha,
- Index strideA=-1, Index strideB=-1, Index offsetA=0, Index offsetB=0, mpreal* /*unpackedB*/ = 0)
+ Index strideA=-1, Index strideB=-1, Index offsetA=0, Index offsetB=0)
{
- mpreal acc1, acc2, tmp;
+ if(rows==0 || cols==0 || depth==0)
+ return;
+
+ mpreal acc1(0,mpfr_get_prec(blockA[0].mpfr_srcptr())),
+ tmp (0,mpfr_get_prec(blockA[0].mpfr_srcptr()));
if(strideA==-1) strideA = depth;
if(strideB==-1) strideB = depth;
- for(Index j=0; j<cols; j+=nr)
+ for(Index i=0; i<rows; ++i)
{
- Index actual_nr = (std::min<Index>)(nr,cols-j);
- mpreal *C1 = res + j*resStride;
- mpreal *C2 = res + (j+1)*resStride;
- for(Index i=0; i<rows; i++)
+ for(Index j=0; j<cols; ++j)
{
- mpreal *B = const_cast<mpreal*>(blockB) + j*strideB + offsetB*actual_nr;
- mpreal *A = const_cast<mpreal*>(blockA) + i*strideA + offsetA;
+ mpreal *C1 = res + j*resStride;
+
+ const mpreal *A = blockA + i*strideA + offsetA;
+ const mpreal *B = blockB + j*strideB + offsetB;
+
acc1 = 0;
- acc2 = 0;
for(Index k=0; k<depth; k++)
{
- mpfr_mul(tmp.mpfr_ptr(), A[k].mpfr_ptr(), B[0].mpfr_ptr(), mpreal::get_default_rnd());
+ mpfr_mul(tmp.mpfr_ptr(), A[k].mpfr_srcptr(), B[k].mpfr_srcptr(), mpreal::get_default_rnd());
mpfr_add(acc1.mpfr_ptr(), acc1.mpfr_ptr(), tmp.mpfr_ptr(), mpreal::get_default_rnd());
-
- if(actual_nr==2) {
- mpfr_mul(tmp.mpfr_ptr(), A[k].mpfr_ptr(), B[1].mpfr_ptr(), mpreal::get_default_rnd());
- mpfr_add(acc2.mpfr_ptr(), acc2.mpfr_ptr(), tmp.mpfr_ptr(), mpreal::get_default_rnd());
- }
-
- B+=actual_nr;
}
- mpfr_mul(acc1.mpfr_ptr(), acc1.mpfr_ptr(), alpha.mpfr_ptr(), mpreal::get_default_rnd());
- mpfr_add(C1[i].mpfr_ptr(), C1[i].mpfr_ptr(), acc1.mpfr_ptr(), mpreal::get_default_rnd());
-
- if(actual_nr==2) {
- mpfr_mul(acc2.mpfr_ptr(), acc2.mpfr_ptr(), alpha.mpfr_ptr(), mpreal::get_default_rnd());
- mpfr_add(C2[i].mpfr_ptr(), C2[i].mpfr_ptr(), acc2.mpfr_ptr(), mpreal::get_default_rnd());
- }
+ mpfr_mul(acc1.mpfr_ptr(), acc1.mpfr_srcptr(), alpha.mpfr_srcptr(), mpreal::get_default_rnd());
+ mpfr_add(C1[i].mpfr_ptr(), C1[i].mpfr_srcptr(), acc1.mpfr_srcptr(), mpreal::get_default_rnd());
}
}
}
};
-
} // end namespace internal
}
diff --git a/unsupported/Eigen/SVD b/unsupported/Eigen/SVD
index 7cc059280..900a8aa60 100644
--- a/unsupported/Eigen/SVD
+++ b/unsupported/Eigen/SVD
@@ -29,10 +29,6 @@
#include "../../Eigen/src/SVD/JacobiSVD_MKL.h"
#endif
-#ifdef EIGEN2_SUPPORT
-#include "../../Eigen/src/Eigen2Support/SVD.h"
-#endif
-
#include "../../Eigen/src/Core/util/ReenableStupidWarnings.h"
#endif // EIGEN_SVD_MODULE_H
diff --git a/unsupported/Eigen/src/IterativeSolvers/GMRES.h b/unsupported/Eigen/src/IterativeSolvers/GMRES.h
index 073367506..c8c84069e 100644
--- a/unsupported/Eigen/src/IterativeSolvers/GMRES.h
+++ b/unsupported/Eigen/src/IterativeSolvers/GMRES.h
@@ -2,7 +2,7 @@
// for linear algebra.
//
// Copyright (C) 2011 Gael Guennebaud <gael.guennebaud@inria.fr>
-// Copyright (C) 2012 Kolja Brix <brix@igpm.rwth-aaachen.de>
+// Copyright (C) 2012, 2014 Kolja Brix <brix@igpm.rwth-aaachen.de>
//
// 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
@@ -72,16 +72,20 @@ bool gmres(const MatrixType & mat, const Rhs & rhs, Dest & x, const Precondition
VectorType p0 = rhs - mat*x;
VectorType r0 = precond.solve(p0);
-// RealScalar r0_sqnorm = r0.squaredNorm();
+
+ // is initial guess already good enough?
+ if(abs(r0.norm()) < tol) {
+ return true;
+ }
VectorType w = VectorType::Zero(restart + 1);
- FMatrixType H = FMatrixType::Zero(m, restart + 1);
+ FMatrixType H = FMatrixType::Zero(m, restart + 1); // Hessenberg matrix
VectorType tau = VectorType::Zero(restart + 1);
std::vector < JacobiRotation < Scalar > > G(restart);
// generate first Householder vector
- VectorType e;
+ VectorType e(m-1);
RealScalar beta;
r0.makeHouseholder(e, tau.coeffRef(0), beta);
w(0)=(Scalar) beta;
diff --git a/unsupported/Eigen/src/IterativeSolvers/Scaling.h b/unsupported/Eigen/src/IterativeSolvers/Scaling.h
index 4fd439202..d113e6e90 100644
--- a/unsupported/Eigen/src/IterativeSolvers/Scaling.h
+++ b/unsupported/Eigen/src/IterativeSolvers/Scaling.h
@@ -9,6 +9,9 @@
#ifndef EIGEN_ITERSCALING_H
#define EIGEN_ITERSCALING_H
+
+namespace Eigen {
+
/**
* \ingroup IterativeSolvers_Module
* \brief iterative scaling algorithm to equilibrate rows and column norms in matrices
@@ -41,8 +44,6 @@
*
* \sa \ref IncompleteLUT
*/
-namespace Eigen {
-using std::abs;
template<typename _MatrixType>
class IterScaling
{
@@ -71,6 +72,7 @@ class IterScaling
*/
void compute (const MatrixType& mat)
{
+ using std::abs;
int m = mat.rows();
int n = mat.cols();
eigen_assert((m>0 && m == n) && "Please give a non - empty matrix");
diff --git a/unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h b/unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h
index 05df5a102..160120d03 100644
--- a/unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h
+++ b/unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h
@@ -176,8 +176,8 @@ void matrix_exp_pade17(const MatrixType &A, MatrixType &U, MatrixType &V)
const MatrixType A4 = A2 * A2;
const MatrixType A6 = A4 * A2;
const MatrixType A8 = A4 * A4;
- V = b[17] * m_tmp1 + b[15] * A6 + b[13] * A4 + b[11] * A2; // used for temporary storage
- matrixType tmp = A8 * V;
+ V = b[17] * A8 + b[15] * A6 + b[13] * A4 + b[11] * A2; // used for temporary storage
+ MatrixType tmp = A8 * V;
tmp += b[9] * A8 + b[7] * A6 + b[5] * A4 + b[3] * A2
+ b[1] * MatrixType::Identity(A.rows(), A.cols());
U.noalias() = A * tmp;
diff --git a/unsupported/Eigen/src/SparseExtra/MarketIO.h b/unsupported/Eigen/src/SparseExtra/MarketIO.h
index 1c40d3f7c..25ff4228d 100644
--- a/unsupported/Eigen/src/SparseExtra/MarketIO.h
+++ b/unsupported/Eigen/src/SparseExtra/MarketIO.h
@@ -133,6 +133,7 @@ template<typename SparseMatrixType>
bool loadMarket(SparseMatrixType& mat, const std::string& filename)
{
typedef typename SparseMatrixType::Scalar Scalar;
+ typedef typename SparseMatrixType::Index Index;
std::ifstream input(filename.c_str(),std::ios::in);
if(!input)
return false;
@@ -142,11 +143,11 @@ bool loadMarket(SparseMatrixType& mat, const std::string& filename)
bool readsizes = false;
- typedef Triplet<Scalar,int> T;
+ typedef Triplet<Scalar,Index> T;
std::vector<T> elements;
- int M(-1), N(-1), NNZ(-1);
- int count = 0;
+ Index M(-1), N(-1), NNZ(-1);
+ Index count = 0;
while(input.getline(buffer, maxBuffersize))
{
// skip comments
@@ -169,7 +170,7 @@ bool loadMarket(SparseMatrixType& mat, const std::string& filename)
}
else
{
- int i(-1), j(-1);
+ Index i(-1), j(-1);
Scalar value;
if( internal::GetMarketLine(line, M, N, i, j, value) )
{
diff --git a/unsupported/Eigen/src/Splines/Spline.h b/unsupported/Eigen/src/Splines/Spline.h
index 1b47992d6..c46f728bc 100644
--- a/unsupported/Eigen/src/Splines/Spline.h
+++ b/unsupported/Eigen/src/Splines/Spline.h
@@ -44,9 +44,15 @@ namespace Eigen
/** \brief The data type used to store knot vectors. */
typedef typename SplineTraits<Spline>::KnotVectorType KnotVectorType;
+
+ /** \brief The data type used to store parameter vectors. */
+ typedef typename SplineTraits<Spline>::ParameterVectorType ParameterVectorType;
/** \brief The data type used to store non-zero basis functions. */
typedef typename SplineTraits<Spline>::BasisVectorType BasisVectorType;
+
+ /** \brief The data type used to store the values of the basis function derivatives. */
+ typedef typename SplineTraits<Spline>::BasisDerivativeType BasisDerivativeType;
/** \brief The data type representing the spline's control points. */
typedef typename SplineTraits<Spline>::ControlPointVectorType ControlPointVectorType;
@@ -203,10 +209,25 @@ namespace Eigen
**/
static BasisVectorType BasisFunctions(Scalar u, DenseIndex degree, const KnotVectorType& knots);
+ /**
+ * \copydoc Spline::basisFunctionDerivatives
+ * \param degree The degree of the underlying spline
+ * \param knots The underlying spline's knot vector.
+ **/
+ static BasisDerivativeType BasisFunctionDerivatives(
+ const Scalar u, const DenseIndex order, const DenseIndex degree, const KnotVectorType& knots);
private:
KnotVectorType m_knots; /*!< Knot vector. */
ControlPointVectorType m_ctrls; /*!< Control points. */
+
+ template <typename DerivativeType>
+ static void BasisFunctionDerivativesImpl(
+ const typename Spline<_Scalar, _Dim, _Degree>::Scalar u,
+ const DenseIndex order,
+ const DenseIndex p,
+ const typename Spline<_Scalar, _Dim, _Degree>::KnotVectorType& U,
+ DerivativeType& N_);
};
template <typename _Scalar, int _Dim, int _Degree>
@@ -345,20 +366,24 @@ namespace Eigen
}
/* --------------------------------------------------------------------------------------------- */
-
- template <typename SplineType, typename DerivativeType>
- void basisFunctionDerivativesImpl(const SplineType& spline, typename SplineType::Scalar u, DenseIndex order, DerivativeType& N_)
+
+
+ template <typename _Scalar, int _Dim, int _Degree>
+ template <typename DerivativeType>
+ void Spline<_Scalar, _Dim, _Degree>::BasisFunctionDerivativesImpl(
+ const typename Spline<_Scalar, _Dim, _Degree>::Scalar u,
+ const DenseIndex order,
+ const DenseIndex p,
+ const typename Spline<_Scalar, _Dim, _Degree>::KnotVectorType& U,
+ DerivativeType& N_)
{
+ typedef Spline<_Scalar, _Dim, _Degree> SplineType;
enum { Order = SplineTraits<SplineType>::OrderAtCompileTime };
typedef typename SplineTraits<SplineType>::Scalar Scalar;
typedef typename SplineTraits<SplineType>::BasisVectorType BasisVectorType;
- typedef typename SplineTraits<SplineType>::KnotVectorType KnotVectorType;
-
- const KnotVectorType& U = spline.knots();
-
- const DenseIndex p = spline.degree();
- const DenseIndex span = spline.span(u);
+
+ const DenseIndex span = SplineType::Span(u, p, U);
const DenseIndex n = (std::min)(p, order);
@@ -455,8 +480,8 @@ namespace Eigen
typename SplineTraits< Spline<_Scalar, _Dim, _Degree> >::BasisDerivativeType
Spline<_Scalar, _Dim, _Degree>::basisFunctionDerivatives(Scalar u, DenseIndex order) const
{
- typename SplineTraits< Spline >::BasisDerivativeType der;
- basisFunctionDerivativesImpl(*this, u, order, der);
+ typename SplineTraits<Spline<_Scalar, _Dim, _Degree> >::BasisDerivativeType der;
+ BasisFunctionDerivativesImpl(u, order, degree(), knots(), der);
return der;
}
@@ -465,8 +490,21 @@ namespace Eigen
typename SplineTraits< Spline<_Scalar, _Dim, _Degree>, DerivativeOrder >::BasisDerivativeType
Spline<_Scalar, _Dim, _Degree>::basisFunctionDerivatives(Scalar u, DenseIndex order) const
{
- typename SplineTraits< Spline, DerivativeOrder >::BasisDerivativeType der;
- basisFunctionDerivativesImpl(*this, u, order, der);
+ typename SplineTraits< Spline<_Scalar, _Dim, _Degree>, DerivativeOrder >::BasisDerivativeType der;
+ BasisFunctionDerivativesImpl(u, order, degree(), knots(), der);
+ return der;
+ }
+
+ template <typename _Scalar, int _Dim, int _Degree>
+ typename SplineTraits<Spline<_Scalar, _Dim, _Degree> >::BasisDerivativeType
+ Spline<_Scalar, _Dim, _Degree>::BasisFunctionDerivatives(
+ const typename Spline<_Scalar, _Dim, _Degree>::Scalar u,
+ const DenseIndex order,
+ const DenseIndex degree,
+ const typename Spline<_Scalar, _Dim, _Degree>::KnotVectorType& knots)
+ {
+ typename SplineTraits<Spline>::BasisDerivativeType der;
+ BasisFunctionDerivativesImpl(u, order, degree, knots, der);
return der;
}
}
diff --git a/unsupported/Eigen/src/Splines/SplineFitting.h b/unsupported/Eigen/src/Splines/SplineFitting.h
index 0265d532c..d3c245fa9 100644
--- a/unsupported/Eigen/src/Splines/SplineFitting.h
+++ b/unsupported/Eigen/src/Splines/SplineFitting.h
@@ -10,10 +10,14 @@
#ifndef EIGEN_SPLINE_FITTING_H
#define EIGEN_SPLINE_FITTING_H
+#include <algorithm>
+#include <functional>
#include <numeric>
+#include <vector>
#include "SplineFwd.h"
+#include <Eigen/LU>
#include <Eigen/QR>
namespace Eigen
@@ -50,6 +54,129 @@ namespace Eigen
}
/**
+ * \brief Computes knot averages when derivative constraints are present.
+ * Note that this is a technical interpretation of the referenced article
+ * since the algorithm contained therein is incorrect as written.
+ * \ingroup Splines_Module
+ *
+ * \param[in] parameters The parameters at which the interpolation B-Spline
+ * will intersect the given interpolation points. The parameters
+ * are assumed to be a non-decreasing sequence.
+ * \param[in] degree The degree of the interpolating B-Spline. This must be
+ * greater than zero.
+ * \param[in] derivativeIndices The indices corresponding to parameters at
+ * which there are derivative constraints. The indices are assumed
+ * to be a non-decreasing sequence.
+ * \param[out] knots The calculated knot vector. These will be returned as a
+ * non-decreasing sequence
+ *
+ * \sa Les A. Piegl, Khairan Rajab, Volha Smarodzinana. 2008.
+ * Curve interpolation with directional constraints for engineering design.
+ * Engineering with Computers
+ **/
+ template <typename KnotVectorType, typename ParameterVectorType, typename IndexArray>
+ void KnotAveragingWithDerivatives(const ParameterVectorType& parameters,
+ const unsigned int degree,
+ const IndexArray& derivativeIndices,
+ KnotVectorType& knots)
+ {
+ typedef typename ParameterVectorType::Scalar Scalar;
+
+ DenseIndex numParameters = parameters.size();
+ DenseIndex numDerivatives = derivativeIndices.size();
+
+ if (numDerivatives < 1)
+ {
+ KnotAveraging(parameters, degree, knots);
+ return;
+ }
+
+ DenseIndex startIndex;
+ DenseIndex endIndex;
+
+ DenseIndex numInternalDerivatives = numDerivatives;
+
+ if (derivativeIndices[0] == 0)
+ {
+ startIndex = 0;
+ --numInternalDerivatives;
+ }
+ else
+ {
+ startIndex = 1;
+ }
+ if (derivativeIndices[numDerivatives - 1] == numParameters - 1)
+ {
+ endIndex = numParameters - degree;
+ --numInternalDerivatives;
+ }
+ else
+ {
+ endIndex = numParameters - degree - 1;
+ }
+
+ // There are (endIndex - startIndex + 1) knots obtained from the averaging
+ // and 2 for the first and last parameters.
+ DenseIndex numAverageKnots = endIndex - startIndex + 3;
+ KnotVectorType averageKnots(numAverageKnots);
+ averageKnots[0] = parameters[0];
+
+ int newKnotIndex = 0;
+ for (DenseIndex i = startIndex; i <= endIndex; ++i)
+ averageKnots[++newKnotIndex] = parameters.segment(i, degree).mean();
+ averageKnots[++newKnotIndex] = parameters[numParameters - 1];
+
+ newKnotIndex = -1;
+
+ ParameterVectorType temporaryParameters(numParameters + 1);
+ KnotVectorType derivativeKnots(numInternalDerivatives);
+ for (unsigned int i = 0; i < numAverageKnots - 1; ++i)
+ {
+ temporaryParameters[0] = averageKnots[i];
+ ParameterVectorType parameterIndices(numParameters);
+ int temporaryParameterIndex = 1;
+ for (int j = 0; j < numParameters; ++j)
+ {
+ Scalar parameter = parameters[j];
+ if (parameter >= averageKnots[i] && parameter < averageKnots[i + 1])
+ {
+ parameterIndices[temporaryParameterIndex] = j;
+ temporaryParameters[temporaryParameterIndex++] = parameter;
+ }
+ }
+ temporaryParameters[temporaryParameterIndex] = averageKnots[i + 1];
+
+ for (int j = 0; j <= temporaryParameterIndex - 2; ++j)
+ {
+ for (DenseIndex k = 0; k < derivativeIndices.size(); ++k)
+ {
+ if (parameterIndices[j + 1] == derivativeIndices[k]
+ && parameterIndices[j + 1] != 0
+ && parameterIndices[j + 1] != numParameters - 1)
+ {
+ derivativeKnots[++newKnotIndex] = temporaryParameters.segment(j, 3).mean();
+ break;
+ }
+ }
+ }
+ }
+
+ KnotVectorType temporaryKnots(averageKnots.size() + derivativeKnots.size());
+
+ std::merge(averageKnots.data(), averageKnots.data() + averageKnots.size(),
+ derivativeKnots.data(), derivativeKnots.data() + derivativeKnots.size(),
+ temporaryKnots.data());
+
+ // Number of control points (one for each point and derivative) plus spline order.
+ DenseIndex numKnots = numParameters + numDerivatives + degree + 1;
+ knots.resize(numKnots);
+
+ knots.head(degree).fill(temporaryKnots[0]);
+ knots.tail(degree).fill(temporaryKnots.template tail<1>()[0]);
+ knots.segment(degree, temporaryKnots.size()) = temporaryKnots;
+ }
+
+ /**
* \brief Computes chord length parameters which are required for spline interpolation.
* \ingroup Splines_Module
*
@@ -86,6 +213,7 @@ namespace Eigen
struct SplineFitting
{
typedef typename SplineType::KnotVectorType KnotVectorType;
+ typedef typename SplineType::ParameterVectorType ParameterVectorType;
/**
* \brief Fits an interpolating Spline to the given data points.
@@ -109,6 +237,52 @@ namespace Eigen
**/
template <typename PointArrayType>
static SplineType Interpolate(const PointArrayType& pts, DenseIndex degree, const KnotVectorType& knot_parameters);
+
+ /**
+ * \brief Fits an interpolating spline to the given data points and
+ * derivatives.
+ *
+ * \param points The points for which an interpolating spline will be computed.
+ * \param derivatives The desired derivatives of the interpolating spline at interpolation
+ * points.
+ * \param derivativeIndices An array indicating which point each derivative belongs to. This
+ * must be the same size as @a derivatives.
+ * \param degree The degree of the interpolating spline.
+ *
+ * \returns A spline interpolating @a points with @a derivatives at those points.
+ *
+ * \sa Les A. Piegl, Khairan Rajab, Volha Smarodzinana. 2008.
+ * Curve interpolation with directional constraints for engineering design.
+ * Engineering with Computers
+ **/
+ template <typename PointArrayType, typename IndexArray>
+ static SplineType InterpolateWithDerivatives(const PointArrayType& points,
+ const PointArrayType& derivatives,
+ const IndexArray& derivativeIndices,
+ const unsigned int degree);
+
+ /**
+ * \brief Fits an interpolating spline to the given data points and derivatives.
+ *
+ * \param points The points for which an interpolating spline will be computed.
+ * \param derivatives The desired derivatives of the interpolating spline at interpolation points.
+ * \param derivativeIndices An array indicating which point each derivative belongs to. This
+ * must be the same size as @a derivatives.
+ * \param degree The degree of the interpolating spline.
+ * \param parameters The parameters corresponding to the interpolation points.
+ *
+ * \returns A spline interpolating @a points with @a derivatives at those points.
+ *
+ * \sa Les A. Piegl, Khairan Rajab, Volha Smarodzinana. 2008.
+ * Curve interpolation with directional constraints for engineering design.
+ * Engineering with Computers
+ */
+ template <typename PointArrayType, typename IndexArray>
+ static SplineType InterpolateWithDerivatives(const PointArrayType& points,
+ const PointArrayType& derivatives,
+ const IndexArray& derivativeIndices,
+ const unsigned int degree,
+ const ParameterVectorType& parameters);
};
template <typename SplineType>
@@ -151,6 +325,106 @@ namespace Eigen
ChordLengths(pts, chord_lengths);
return Interpolate(pts, degree, chord_lengths);
}
+
+ template <typename SplineType>
+ template <typename PointArrayType, typename IndexArray>
+ SplineType
+ SplineFitting<SplineType>::InterpolateWithDerivatives(const PointArrayType& points,
+ const PointArrayType& derivatives,
+ const IndexArray& derivativeIndices,
+ const unsigned int degree,
+ const ParameterVectorType& parameters)
+ {
+ typedef typename SplineType::KnotVectorType::Scalar Scalar;
+ typedef typename SplineType::ControlPointVectorType ControlPointVectorType;
+
+ typedef Matrix<Scalar, Dynamic, Dynamic> MatrixType;
+
+ const DenseIndex n = points.cols() + derivatives.cols();
+
+ KnotVectorType knots;
+
+ KnotAveragingWithDerivatives(parameters, degree, derivativeIndices, knots);
+
+ // fill matrix
+ MatrixType A = MatrixType::Zero(n, n);
+
+ // Use these dimensions for quicker populating, then transpose for solving.
+ MatrixType b(points.rows(), n);
+
+ DenseIndex startRow;
+ DenseIndex derivativeStart;
+
+ // End derivatives.
+ if (derivativeIndices[0] == 0)
+ {
+ A.template block<1, 2>(1, 0) << -1, 1;
+
+ Scalar y = (knots(degree + 1) - knots(0)) / degree;
+ b.col(1) = y*derivatives.col(0);
+
+ startRow = 2;
+ derivativeStart = 1;
+ }
+ else
+ {
+ startRow = 1;
+ derivativeStart = 0;
+ }
+ if (derivativeIndices[derivatives.cols() - 1] == points.cols() - 1)
+ {
+ A.template block<1, 2>(n - 2, n - 2) << -1, 1;
+
+ Scalar y = (knots(knots.size() - 1) - knots(knots.size() - (degree + 2))) / degree;
+ b.col(b.cols() - 2) = y*derivatives.col(derivatives.cols() - 1);
+ }
+
+ DenseIndex row = startRow;
+ DenseIndex derivativeIndex = derivativeStart;
+ for (DenseIndex i = 1; i < parameters.size() - 1; ++i)
+ {
+ const DenseIndex span = SplineType::Span(parameters[i], degree, knots);
+
+ if (derivativeIndices[derivativeIndex] == i)
+ {
+ A.block(row, span - degree, 2, degree + 1)
+ = SplineType::BasisFunctionDerivatives(parameters[i], 1, degree, knots);
+
+ b.col(row++) = points.col(i);
+ b.col(row++) = derivatives.col(derivativeIndex++);
+ }
+ else
+ {
+ A.row(row++).segment(span - degree, degree + 1)
+ = SplineType::BasisFunctions(parameters[i], degree, knots);
+ }
+ }
+ b.col(0) = points.col(0);
+ b.col(b.cols() - 1) = points.col(points.cols() - 1);
+ A(0,0) = 1;
+ A(n - 1, n - 1) = 1;
+
+ // Solve
+ FullPivLU<MatrixType> lu(A);
+ ControlPointVectorType controlPoints = lu.solve(MatrixType(b.transpose())).transpose();
+
+ SplineType spline(knots, controlPoints);
+
+ return spline;
+ }
+
+ template <typename SplineType>
+ template <typename PointArrayType, typename IndexArray>
+ SplineType
+ SplineFitting<SplineType>::InterpolateWithDerivatives(const PointArrayType& points,
+ const PointArrayType& derivatives,
+ const IndexArray& derivativeIndices,
+ const unsigned int degree)
+ {
+ ParameterVectorType parameters;
+ ChordLengths(points, parameters);
+ return InterpolateWithDerivatives(points, derivatives, derivativeIndices, degree, parameters);
+ }
}
#endif // EIGEN_SPLINE_FITTING_H
diff --git a/unsupported/Eigen/src/Splines/SplineFwd.h b/unsupported/Eigen/src/Splines/SplineFwd.h
index 9ea23a9a1..0a95fbf3e 100644
--- a/unsupported/Eigen/src/Splines/SplineFwd.h
+++ b/unsupported/Eigen/src/Splines/SplineFwd.h
@@ -48,6 +48,9 @@ namespace Eigen
/** \brief The data type used to store knot vectors. */
typedef Array<Scalar,1,Dynamic> KnotVectorType;
+
+ /** \brief The data type used to store parameter vectors. */
+ typedef Array<Scalar,1,Dynamic> ParameterVectorType;
/** \brief The data type representing the spline's control points. */
typedef Array<Scalar,Dimension,Dynamic> ControlPointVectorType;
diff --git a/unsupported/doc/Overview.dox b/unsupported/doc/Overview.dox
index d048377df..45464a545 100644
--- a/unsupported/doc/Overview.dox
+++ b/unsupported/doc/Overview.dox
@@ -1,14 +1,15 @@
+/// \brief Namespace containing all symbols from the %Eigen library.
namespace Eigen {
-/** \mainpage Eigen's unsupported modules
+/** \mainpage %Eigen's unsupported modules
-This is the API documentation for Eigen's unsupported modules.
+This is the API documentation for %Eigen's unsupported modules.
These modules are contributions from various users. They are provided "as is", without any support.
Click on the \e Modules tab at the top of this page to get a list of all unsupported modules.
-Don't miss the <a href="..//index.html">official Eigen documentation</a>.
+Don't miss the <a href="../index.html">official Eigen documentation</a>.
*/
@@ -18,8 +19,10 @@ Don't miss the <a href="..//index.html">official Eigen documentation</a>.
The unsupported modules are contributions from various users. They are
provided "as is", without any support. Nevertheless, some of them are
-subject to be included in Eigen in the future.
+subject to be included in %Eigen in the future.
*/
+/// \internal \brief Namespace containing low-level routines from the %Eigen library.
+namespace internal {}
}
diff --git a/unsupported/test/CMakeLists.txt b/unsupported/test/CMakeLists.txt
index 7458128fb..406564673 100644
--- a/unsupported/test/CMakeLists.txt
+++ b/unsupported/test/CMakeLists.txt
@@ -100,7 +100,7 @@ if(EIGEN_TEST_CXX11)
ei_add_test(cxx11_meta "-std=c++0x")
ei_add_test(cxx11_tensor_simple "-std=c++0x")
ei_add_test(cxx11_tensor_symmetry "-std=c++0x")
- ei_add_test(cxx11_tensor_assign "-std=c++0x")
+# ei_add_test(cxx11_tensor_assign "-std=c++0x")
ei_add_test(cxx11_tensor_comparisons "-std=c++0x")
ei_add_test(cxx11_tensor_contraction "-std=c++0x")
ei_add_test(cxx11_tensor_convolution "-std=c++0x")
@@ -108,7 +108,7 @@ if(EIGEN_TEST_CXX11)
# ei_add_test(cxx11_tensor_fixed_size "-std=c++0x")
ei_add_test(cxx11_tensor_lvalue "-std=c++0x")
ei_add_test(cxx11_tensor_map "-std=c++0x")
- ei_add_test(cxx11_tensor_morphing "-std=c++0x")
+# ei_add_test(cxx11_tensor_morphing "-std=c++0x")
# ei_add_test(cxx11_tensor_device "-std=c++0x")
# ei_add_test(cxx11_tensor_fixed_size "-std=c++0x")
# ei_add_test(cxx11_tensor_thread_pool "-std=c++0x")
diff --git a/unsupported/test/mpreal/mpreal.h b/unsupported/test/mpreal/mpreal.h
index 70d37ab71..dddda7dd9 100644
--- a/unsupported/test/mpreal/mpreal.h
+++ b/unsupported/test/mpreal/mpreal.h
@@ -1,59 +1,47 @@
/*
- Multi-precision floating point number class for C++.
+ MPFR C++: Multi-precision floating point number class for C++.
Based on MPFR library: http://mpfr.org
Project homepage: http://www.holoborodko.com/pavel/mpfr
Contact e-mail: pavel@holoborodko.com
- Copyright (c) 2008-2013 Pavel Holoborodko
+ Copyright (c) 2008-2014 Pavel Holoborodko
Contributors:
Dmitriy Gubanov, Konstantin Holoborodko, Brian Gladman,
Helmut Jarausch, Fokko Beekhof, Ulrich Mutze, Heinz van Saanen,
Pere Constans, Peter van Hoof, Gael Guennebaud, Tsai Chia Cheng,
- Alexei Zubanov, Jauhien Piatlicki, Victor Berger, John Westwood.
+ Alexei Zubanov, Jauhien Piatlicki, Victor Berger, John Westwood,
+ Petr Aleksandrov, Orion Poplawski, Charles Karney.
- ****************************************************************************
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
+ Licensing:
+ (A) MPFR C++ is under GNU General Public License ("GPL").
+
+ (B) Non-free licenses may also be purchased from the author, for users who
+ do not want their programs protected by the GPL.
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ The non-free licenses are for users that wish to use MPFR C++ in
+ their products but are unwilling to release their software
+ under the GPL (which would require them to release source code
+ and allow free redistribution).
- ****************************************************************************
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
+ Such users can purchase an unlimited-use license from the author.
+ Contact us for more details.
- 3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- SUCH DAMAGE.
+ GNU General Public License ("GPL") copyright permissions statement:
+ **************************************************************************
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __MPREAL_H__
@@ -71,6 +59,15 @@
// Options
#define MPREAL_HAVE_INT64_SUPPORT // Enable int64_t support if possible. Available only for MSVC 2010 & GCC.
#define MPREAL_HAVE_MSVC_DEBUGVIEW // Enable Debugger Visualizer for "Debug" builds in MSVC.
+#define MPREAL_HAVE_DYNAMIC_STD_NUMERIC_LIMITS // Enable extended std::numeric_limits<mpfr::mpreal> specialization.
+ // Meaning that "digits", "round_style" and similar members are defined as functions, not constants.
+ // See std::numeric_limits<mpfr::mpreal> at the end of the file for more information.
+
+// Library version
+#define MPREAL_VERSION_MAJOR 3
+#define MPREAL_VERSION_MINOR 5
+#define MPREAL_VERSION_PATCHLEVEL 9
+#define MPREAL_VERSION_STRING "3.5.9"
// Detect compiler using signatures from http://predef.sourceforge.net/
#if defined(__GNUC__) && defined(__INTEL_COMPILER)
@@ -83,17 +80,29 @@
#define IsInf(x) std::isinf(x) // GNU C/C++ (and/or other compilers), just hope for C99 conformance
#endif
-// Detect support for r-value references (move semantic). Borrowed from Eigen.
// A Clang feature extension to determine compiler features.
-// We use it to determine 'cxx_rvalue_references'
#ifndef __has_feature
-# define __has_feature(x) 0
+ #define __has_feature(x) 0
#endif
+// Detect support for r-value references (move semantic). Borrowed from Eigen.
#if (__has_feature(cxx_rvalue_references) || \
- defined(__GXX_EXPERIMENTAL_CXX0X__) || \
- (defined(_MSC_VER) && _MSC_VER >= 1600))
-#define MPREAL_HAVE_MOVE_SUPPORT
+ defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L || \
+ (defined(_MSC_VER) && _MSC_VER >= 1600))
+
+ #define MPREAL_HAVE_MOVE_SUPPORT
+
+ // Use fields in mpfr_t structure to check if it was initialized / set dummy initialization
+ #define mpfr_is_initialized(x) (0 != (x)->_mpfr_d)
+ #define mpfr_set_uninitialized(x) ((x)->_mpfr_d = 0 )
+#endif
+
+// Detect support for explicit converters.
+#if (__has_feature(cxx_explicit_conversions) || \
+ defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L || \
+ (defined(_MSC_VER) && _MSC_VER >= 1800))
+
+ #define MPREAL_HAVE_EXPLICIT_CONVERTERS
#endif
// Detect available 64-bit capabilities
@@ -112,7 +121,7 @@
#endif
#elif defined (__GNUC__) && defined(__linux__)
- #if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || defined(__ia64) || defined(__itanium__) || defined(_M_IA64)
+ #if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || defined(__ia64) || defined(__itanium__) || defined(_M_IA64) || defined (__PPC64__)
#undef MPREAL_HAVE_INT64_SUPPORT // Remove all shaman dances for x64 builds since
#undef MPFR_USE_INTMAX_T // GCC already supports x64 as of "long int" is 64-bit integer, nothing left to do
#else
@@ -175,7 +184,7 @@ public:
mpreal(const int u, mp_prec_t prec = mpreal::get_default_prec(), mp_rnd_t mode = mpreal::get_default_rnd());
// Construct mpreal from mpfr_t structure.
- // shared = true allows to avoid deep copy, so that mpreal and 'u' shared same data & pointers.
+ // shared = true allows to avoid deep copy, so that mpreal and 'u' share the same data & pointers.
mpreal(const mpfr_t u, bool shared = false);
#if defined (MPREAL_HAVE_INT64_SUPPORT)
@@ -315,14 +324,34 @@ public:
friend bool operator == (const mpreal& a, const double b);
// Type Conversion operators
+ bool toBool (mp_rnd_t mode = GMP_RNDZ) const;
long toLong (mp_rnd_t mode = GMP_RNDZ) const;
unsigned long toULong (mp_rnd_t mode = GMP_RNDZ) const;
+ float toFloat (mp_rnd_t mode = GMP_RNDN) const;
double toDouble (mp_rnd_t mode = GMP_RNDN) const;
long double toLDouble (mp_rnd_t mode = GMP_RNDN) const;
+#if defined (MPREAL_HAVE_EXPLICIT_CONVERTERS)
+ explicit operator bool () const { return toBool(); }
+ explicit operator int () const { return toLong(); }
+ explicit operator long () const { return toLong(); }
+ explicit operator long long () const { return toLong(); }
+ explicit operator unsigned () const { return toULong(); }
+ explicit operator unsigned long () const { return toULong(); }
+ explicit operator unsigned long long () const { return toULong(); }
+ explicit operator float () const { return toFloat(); }
+ explicit operator double () const { return toDouble(); }
+ explicit operator long double () const { return toLDouble(); }
+#endif
+
#if defined (MPREAL_HAVE_INT64_SUPPORT)
int64_t toInt64 (mp_rnd_t mode = GMP_RNDZ) const;
uint64_t toUInt64 (mp_rnd_t mode = GMP_RNDZ) const;
+
+ #if defined (MPREAL_HAVE_EXPLICIT_CONVERTERS)
+ explicit operator int64_t () const { return toInt64(); }
+ explicit operator uint64_t () const { return toUInt64(); }
+ #endif
#endif
// Get raw pointers so that mpreal can be directly used in raw mpfr_* functions
@@ -331,122 +360,124 @@ public:
::mpfr_srcptr mpfr_srcptr() const;
// Convert mpreal to string with n significant digits in base b
- // n = 0 -> convert with the maximum available digits
- std::string toString(int n = 0, int b = 10, mp_rnd_t mode = mpreal::get_default_rnd()) const;
+ // n = -1 -> convert with the maximum available digits
+ std::string toString(int n = -1, int b = 10, mp_rnd_t mode = mpreal::get_default_rnd()) const;
#if (MPFR_VERSION >= MPFR_VERSION_NUM(2,4,0))
- std::string toString(const std::string& format) const;
+ std::string toString(const std::string& format) const;
#endif
+ std::ostream& output(std::ostream& os) const;
+
// Math Functions
- friend const mpreal sqr (const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal sqrt(const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal sqrt(const unsigned long int v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal cbrt(const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal root(const mpreal& v, unsigned long int k, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal pow (const mpreal& a, const mpreal& b, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal pow (const mpreal& a, const mpz_t b, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal pow (const mpreal& a, const unsigned long int b, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal pow (const mpreal& a, const long int b, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal pow (const unsigned long int a, const mpreal& b, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal pow (const unsigned long int a, const unsigned long int b, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal fabs(const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
-
- friend const mpreal abs(const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal dim(const mpreal& a, const mpreal& b, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend inline const mpreal mul_2ui(const mpreal& v, unsigned long int k, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend inline const mpreal mul_2si(const mpreal& v, long int k, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend inline const mpreal div_2ui(const mpreal& v, unsigned long int k, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend inline const mpreal div_2si(const mpreal& v, long int k, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
+ friend const mpreal sqr (const mpreal& v, mp_rnd_t rnd_mode);
+ friend const mpreal sqrt(const mpreal& v, mp_rnd_t rnd_mode);
+ friend const mpreal sqrt(const unsigned long int v, mp_rnd_t rnd_mode);
+ friend const mpreal cbrt(const mpreal& v, mp_rnd_t rnd_mode);
+ friend const mpreal root(const mpreal& v, unsigned long int k, mp_rnd_t rnd_mode);
+ friend const mpreal pow (const mpreal& a, const mpreal& b, mp_rnd_t rnd_mode);
+ friend const mpreal pow (const mpreal& a, const mpz_t b, mp_rnd_t rnd_mode);
+ friend const mpreal pow (const mpreal& a, const unsigned long int b, mp_rnd_t rnd_mode);
+ friend const mpreal pow (const mpreal& a, const long int b, mp_rnd_t rnd_mode);
+ friend const mpreal pow (const unsigned long int a, const mpreal& b, mp_rnd_t rnd_mode);
+ friend const mpreal pow (const unsigned long int a, const unsigned long int b, mp_rnd_t rnd_mode);
+ friend const mpreal fabs(const mpreal& v, mp_rnd_t rnd_mode);
+
+ friend const mpreal abs(const mpreal& v, mp_rnd_t rnd_mode);
+ friend const mpreal dim(const mpreal& a, const mpreal& b, mp_rnd_t rnd_mode);
+ friend inline const mpreal mul_2ui(const mpreal& v, unsigned long int k, mp_rnd_t rnd_mode);
+ friend inline const mpreal mul_2si(const mpreal& v, long int k, mp_rnd_t rnd_mode);
+ friend inline const mpreal div_2ui(const mpreal& v, unsigned long int k, mp_rnd_t rnd_mode);
+ friend inline const mpreal div_2si(const mpreal& v, long int k, mp_rnd_t rnd_mode);
friend int cmpabs(const mpreal& a,const mpreal& b);
- friend const mpreal log (const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal log2 (const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal log10(const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal exp (const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal exp2 (const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal exp10(const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal log1p(const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal expm1(const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
-
- friend const mpreal cos(const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal sin(const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal tan(const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal sec(const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal csc(const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal cot(const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend int sin_cos(mpreal& s, mpreal& c, const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
-
- friend const mpreal acos (const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal asin (const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal atan (const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal atan2 (const mpreal& y, const mpreal& x, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal acot (const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal asec (const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal acsc (const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
-
- friend const mpreal cosh (const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal sinh (const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal tanh (const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal sech (const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal csch (const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal coth (const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal acosh (const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal asinh (const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal atanh (const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal acoth (const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal asech (const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal acsch (const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
-
- friend const mpreal hypot (const mpreal& x, const mpreal& y, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
-
- friend const mpreal fac_ui (unsigned long int v, mp_prec_t prec = mpreal::get_default_prec(), mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal eint (const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
-
- friend const mpreal gamma (const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal lngamma (const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal lgamma (const mpreal& v, int *signp = 0, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal zeta (const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal erf (const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal erfc (const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal besselj0 (const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal besselj1 (const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal besseljn (long n, const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal bessely0 (const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal bessely1 (const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal besselyn (long n, const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal fma (const mpreal& v1, const mpreal& v2, const mpreal& v3, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal fms (const mpreal& v1, const mpreal& v2, const mpreal& v3, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal agm (const mpreal& v1, const mpreal& v2, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal sum (const mpreal tab[], unsigned long int n, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
+ friend const mpreal log (const mpreal& v, mp_rnd_t rnd_mode);
+ friend const mpreal log2 (const mpreal& v, mp_rnd_t rnd_mode);
+ friend const mpreal log10(const mpreal& v, mp_rnd_t rnd_mode);
+ friend const mpreal exp (const mpreal& v, mp_rnd_t rnd_mode);
+ friend const mpreal exp2 (const mpreal& v, mp_rnd_t rnd_mode);
+ friend const mpreal exp10(const mpreal& v, mp_rnd_t rnd_mode);
+ friend const mpreal log1p(const mpreal& v, mp_rnd_t rnd_mode);
+ friend const mpreal expm1(const mpreal& v, mp_rnd_t rnd_mode);
+
+ friend const mpreal cos(const mpreal& v, mp_rnd_t rnd_mode);
+ friend const mpreal sin(const mpreal& v, mp_rnd_t rnd_mode);
+ friend const mpreal tan(const mpreal& v, mp_rnd_t rnd_mode);
+ friend const mpreal sec(const mpreal& v, mp_rnd_t rnd_mode);
+ friend const mpreal csc(const mpreal& v, mp_rnd_t rnd_mode);
+ friend const mpreal cot(const mpreal& v, mp_rnd_t rnd_mode);
+ friend int sin_cos(mpreal& s, mpreal& c, const mpreal& v, mp_rnd_t rnd_mode);
+
+ friend const mpreal acos (const mpreal& v, mp_rnd_t rnd_mode);
+ friend const mpreal asin (const mpreal& v, mp_rnd_t rnd_mode);
+ friend const mpreal atan (const mpreal& v, mp_rnd_t rnd_mode);
+ friend const mpreal atan2 (const mpreal& y, const mpreal& x, mp_rnd_t rnd_mode);
+ friend const mpreal acot (const mpreal& v, mp_rnd_t rnd_mode);
+ friend const mpreal asec (const mpreal& v, mp_rnd_t rnd_mode);
+ friend const mpreal acsc (const mpreal& v, mp_rnd_t rnd_mode);
+
+ friend const mpreal cosh (const mpreal& v, mp_rnd_t rnd_mode);
+ friend const mpreal sinh (const mpreal& v, mp_rnd_t rnd_mode);
+ friend const mpreal tanh (const mpreal& v, mp_rnd_t rnd_mode);
+ friend const mpreal sech (const mpreal& v, mp_rnd_t rnd_mode);
+ friend const mpreal csch (const mpreal& v, mp_rnd_t rnd_mode);
+ friend const mpreal coth (const mpreal& v, mp_rnd_t rnd_mode);
+ friend const mpreal acosh (const mpreal& v, mp_rnd_t rnd_mode);
+ friend const mpreal asinh (const mpreal& v, mp_rnd_t rnd_mode);
+ friend const mpreal atanh (const mpreal& v, mp_rnd_t rnd_mode);
+ friend const mpreal acoth (const mpreal& v, mp_rnd_t rnd_mode);
+ friend const mpreal asech (const mpreal& v, mp_rnd_t rnd_mode);
+ friend const mpreal acsch (const mpreal& v, mp_rnd_t rnd_mode);
+
+ friend const mpreal hypot (const mpreal& x, const mpreal& y, mp_rnd_t rnd_mode);
+
+ friend const mpreal fac_ui (unsigned long int v, mp_prec_t prec, mp_rnd_t rnd_mode);
+ friend const mpreal eint (const mpreal& v, mp_rnd_t rnd_mode);
+
+ friend const mpreal gamma (const mpreal& v, mp_rnd_t rnd_mode);
+ friend const mpreal lngamma (const mpreal& v, mp_rnd_t rnd_mode);
+ friend const mpreal lgamma (const mpreal& v, int *signp, mp_rnd_t rnd_mode);
+ friend const mpreal zeta (const mpreal& v, mp_rnd_t rnd_mode);
+ friend const mpreal erf (const mpreal& v, mp_rnd_t rnd_mode);
+ friend const mpreal erfc (const mpreal& v, mp_rnd_t rnd_mode);
+ friend const mpreal besselj0 (const mpreal& v, mp_rnd_t rnd_mode);
+ friend const mpreal besselj1 (const mpreal& v, mp_rnd_t rnd_mode);
+ friend const mpreal besseljn (long n, const mpreal& v, mp_rnd_t rnd_mode);
+ friend const mpreal bessely0 (const mpreal& v, mp_rnd_t rnd_mode);
+ friend const mpreal bessely1 (const mpreal& v, mp_rnd_t rnd_mode);
+ friend const mpreal besselyn (long n, const mpreal& v, mp_rnd_t rnd_mode);
+ friend const mpreal fma (const mpreal& v1, const mpreal& v2, const mpreal& v3, mp_rnd_t rnd_mode);
+ friend const mpreal fms (const mpreal& v1, const mpreal& v2, const mpreal& v3, mp_rnd_t rnd_mode);
+ friend const mpreal agm (const mpreal& v1, const mpreal& v2, mp_rnd_t rnd_mode);
+ friend const mpreal sum (const mpreal tab[], unsigned long int n, mp_rnd_t rnd_mode);
friend int sgn(const mpreal& v); // returns -1 or +1
// MPFR 2.4.0 Specifics
#if (MPFR_VERSION >= MPFR_VERSION_NUM(2,4,0))
- friend int sinh_cosh (mpreal& s, mpreal& c, const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal li2 (const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal fmod (const mpreal& x, const mpreal& y, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal rec_sqrt (const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
+ friend int sinh_cosh (mpreal& s, mpreal& c, const mpreal& v, mp_rnd_t rnd_mode);
+ friend const mpreal li2 (const mpreal& v, mp_rnd_t rnd_mode);
+ friend const mpreal fmod (const mpreal& x, const mpreal& y, mp_rnd_t rnd_mode);
+ friend const mpreal rec_sqrt (const mpreal& v, mp_rnd_t rnd_mode);
// MATLAB's semantic equivalents
- friend const mpreal rem (const mpreal& x, const mpreal& y, mp_rnd_t rnd_mode = mpreal::get_default_rnd()); // Remainder after division
- friend const mpreal mod (const mpreal& x, const mpreal& y, mp_rnd_t rnd_mode = mpreal::get_default_rnd()); // Modulus after division
+ friend const mpreal rem (const mpreal& x, const mpreal& y, mp_rnd_t rnd_mode); // Remainder after division
+ friend const mpreal mod (const mpreal& x, const mpreal& y, mp_rnd_t rnd_mode); // Modulus after division
#endif
// MPFR 3.0.0 Specifics
#if (MPFR_VERSION >= MPFR_VERSION_NUM(3,0,0))
- friend const mpreal digamma (const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal ai (const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal urandom (gmp_randstate_t& state, mp_rnd_t rnd_mode = mpreal::get_default_rnd()); // use gmp_randinit_default() to init state, gmp_randclear() to clear
- friend const mpreal grandom (gmp_randstate_t& state, mp_rnd_t rnd_mode = mpreal::get_default_rnd()); // use gmp_randinit_default() to init state, gmp_randclear() to clear
- friend const mpreal grandom (unsigned int seed = 0);
+ friend const mpreal digamma (const mpreal& v, mp_rnd_t rnd_mode);
+ friend const mpreal ai (const mpreal& v, mp_rnd_t rnd_mode);
+ friend const mpreal urandom (gmp_randstate_t& state, mp_rnd_t rnd_mode); // use gmp_randinit_default() to init state, gmp_randclear() to clear
+ friend const mpreal grandom (gmp_randstate_t& state, mp_rnd_t rnd_mode); // use gmp_randinit_default() to init state, gmp_randclear() to clear
+ friend const mpreal grandom (unsigned int seed);
#endif
// Uniformly distributed random number generation in [0,1] using
// Mersenne-Twister algorithm by default.
// Use parameter to setup seed, e.g.: random((unsigned)time(NULL))
// Check urandom() for more precise control.
- friend const mpreal random(unsigned int seed = 0);
+ friend const mpreal random(unsigned int seed);
// Exponent and mantissa manipulation
friend const mpreal frexp(const mpreal& v, mp_exp_t* exp);
@@ -458,31 +489,31 @@ public:
// Constants
// don't forget to call mpfr_free_cache() for every thread where you are using const-functions
- friend const mpreal const_log2 (mp_prec_t prec = mpreal::get_default_prec(), mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal const_pi (mp_prec_t prec = mpreal::get_default_prec(), mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal const_euler (mp_prec_t prec = mpreal::get_default_prec(), mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal const_catalan (mp_prec_t prec = mpreal::get_default_prec(), mp_rnd_t rnd_mode = mpreal::get_default_rnd());
+ friend const mpreal const_log2 (mp_prec_t prec, mp_rnd_t rnd_mode);
+ friend const mpreal const_pi (mp_prec_t prec, mp_rnd_t rnd_mode);
+ friend const mpreal const_euler (mp_prec_t prec, mp_rnd_t rnd_mode);
+ friend const mpreal const_catalan (mp_prec_t prec, mp_rnd_t rnd_mode);
// returns +inf iff sign>=0 otherwise -inf
- friend const mpreal const_infinity(int sign = 1, mp_prec_t prec = mpreal::get_default_prec(), mp_rnd_t rnd_mode = mpreal::get_default_rnd());
+ friend const mpreal const_infinity(int sign, mp_prec_t prec);
// Output/ Input
friend std::ostream& operator<<(std::ostream& os, const mpreal& v);
friend std::istream& operator>>(std::istream& is, mpreal& v);
// Integer Related Functions
- friend const mpreal rint (const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
+ friend const mpreal rint (const mpreal& v, mp_rnd_t rnd_mode);
friend const mpreal ceil (const mpreal& v);
friend const mpreal floor(const mpreal& v);
friend const mpreal round(const mpreal& v);
friend const mpreal trunc(const mpreal& v);
- friend const mpreal rint_ceil (const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal rint_floor (const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal rint_round (const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal rint_trunc (const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal frac (const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal remainder ( const mpreal& x, const mpreal& y, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal remquo (long* q, const mpreal& x, const mpreal& y, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
+ friend const mpreal rint_ceil (const mpreal& v, mp_rnd_t rnd_mode);
+ friend const mpreal rint_floor (const mpreal& v, mp_rnd_t rnd_mode);
+ friend const mpreal rint_round (const mpreal& v, mp_rnd_t rnd_mode);
+ friend const mpreal rint_trunc (const mpreal& v, mp_rnd_t rnd_mode);
+ friend const mpreal frac (const mpreal& v, mp_rnd_t rnd_mode);
+ friend const mpreal remainder ( const mpreal& x, const mpreal& y, mp_rnd_t rnd_mode);
+ friend const mpreal remquo (long* q, const mpreal& x, const mpreal& y, mp_rnd_t rnd_mode);
// Miscellaneous Functions
friend const mpreal nexttoward (const mpreal& x, const mpreal& y);
@@ -549,8 +580,8 @@ public:
// Efficient swapping of two mpreal values - needed for std algorithms
friend void swap(mpreal& x, mpreal& y);
- friend const mpreal fmax(const mpreal& x, const mpreal& y, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
- friend const mpreal fmin(const mpreal& x, const mpreal& y, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
+ friend const mpreal fmax(const mpreal& x, const mpreal& y, mp_rnd_t rnd_mode);
+ friend const mpreal fmin(const mpreal& x, const mpreal& y, mp_rnd_t rnd_mode);
private:
// Human friendly Debug Preview in Visual Studio.
@@ -579,16 +610,16 @@ public:
// Default constructor: creates mp number and initializes it to 0.
inline mpreal::mpreal()
{
- mpfr_init2(mp,mpreal::get_default_prec());
- mpfr_set_ui(mp,0,mpreal::get_default_rnd());
+ mpfr_init2 (mpfr_ptr(), mpreal::get_default_prec());
+ mpfr_set_ui(mpfr_ptr(), 0, mpreal::get_default_rnd());
MPREAL_MSVC_DEBUGVIEW_CODE;
}
inline mpreal::mpreal(const mpreal& u)
{
- mpfr_init2(mp,mpfr_get_prec(u.mp));
- mpfr_set(mp,u.mp,mpreal::get_default_rnd());
+ mpfr_init2(mpfr_ptr(),mpfr_get_prec(u.mpfr_srcptr()));
+ mpfr_set (mpfr_ptr(),u.mpfr_srcptr(),mpreal::get_default_rnd());
MPREAL_MSVC_DEBUGVIEW_CODE;
}
@@ -596,8 +627,7 @@ inline mpreal::mpreal(const mpreal& u)
#ifdef MPREAL_HAVE_MOVE_SUPPORT
inline mpreal::mpreal(mpreal&& other)
{
- mpfr_ptr()->_mpfr_d = 0; // make sure "other" holds no pinter to actual data
-
+ mpfr_set_uninitialized(mpfr_ptr()); // make sure "other" holds no pinter to actual data
mpfr_swap(mpfr_ptr(), other.mpfr_ptr());
MPREAL_MSVC_DEBUGVIEW_CODE;
@@ -616,12 +646,12 @@ inline mpreal::mpreal(const mpfr_t u, bool shared)
{
if(shared)
{
- std::memcpy(mp, u, sizeof(mpfr_t));
+ std::memcpy(mpfr_ptr(), u, sizeof(mpfr_t));
}
else
{
- mpfr_init2(mp, mpfr_get_prec(u));
- mpfr_set (mp, u, mpreal::get_default_rnd());
+ mpfr_init2(mpfr_ptr(), mpfr_get_prec(u));
+ mpfr_set (mpfr_ptr(), u, mpreal::get_default_rnd());
}
MPREAL_MSVC_DEBUGVIEW_CODE;
@@ -629,40 +659,40 @@ inline mpreal::mpreal(const mpfr_t u, bool shared)
inline mpreal::mpreal(const mpf_t u)
{
- mpfr_init2(mp,(mp_prec_t) mpf_get_prec(u)); // (gmp: mp_bitcnt_t) unsigned long -> long (mpfr: mp_prec_t)
- mpfr_set_f(mp,u,mpreal::get_default_rnd());
+ mpfr_init2(mpfr_ptr(),(mp_prec_t) mpf_get_prec(u)); // (gmp: mp_bitcnt_t) unsigned long -> long (mpfr: mp_prec_t)
+ mpfr_set_f(mpfr_ptr(),u,mpreal::get_default_rnd());
MPREAL_MSVC_DEBUGVIEW_CODE;
}
inline mpreal::mpreal(const mpz_t u, mp_prec_t prec, mp_rnd_t mode)
{
- mpfr_init2(mp,prec);
- mpfr_set_z(mp,u,mode);
+ mpfr_init2(mpfr_ptr(), prec);
+ mpfr_set_z(mpfr_ptr(), u, mode);
MPREAL_MSVC_DEBUGVIEW_CODE;
}
inline mpreal::mpreal(const mpq_t u, mp_prec_t prec, mp_rnd_t mode)
{
- mpfr_init2(mp,prec);
- mpfr_set_q(mp,u,mode);
+ mpfr_init2(mpfr_ptr(), prec);
+ mpfr_set_q(mpfr_ptr(), u, mode);
MPREAL_MSVC_DEBUGVIEW_CODE;
}
inline mpreal::mpreal(const double u, mp_prec_t prec, mp_rnd_t mode)
{
- mpfr_init2(mp, prec);
+ mpfr_init2(mpfr_ptr(), prec);
#if (MPREAL_DOUBLE_BITS_OVERFLOW > -1)
- if(fits_in_bits(u, MPREAL_DOUBLE_BITS_OVERFLOW))
- {
- mpfr_set_d(mp, u, mode);
- }else
- throw conversion_overflow();
+ if(fits_in_bits(u, MPREAL_DOUBLE_BITS_OVERFLOW))
+ {
+ mpfr_set_d(mpfr_ptr(), u, mode);
+ }else
+ throw conversion_overflow();
#else
- mpfr_set_d(mp, u, mode);
+ mpfr_set_d(mpfr_ptr(), u, mode);
#endif
MPREAL_MSVC_DEBUGVIEW_CODE;
@@ -670,40 +700,40 @@ inline mpreal::mpreal(const double u, mp_prec_t prec, mp_rnd_t mode)
inline mpreal::mpreal(const long double u, mp_prec_t prec, mp_rnd_t mode)
{
- mpfr_init2(mp,prec);
- mpfr_set_ld(mp,u,mode);
+ mpfr_init2 (mpfr_ptr(), prec);
+ mpfr_set_ld(mpfr_ptr(), u, mode);
MPREAL_MSVC_DEBUGVIEW_CODE;
}
inline mpreal::mpreal(const unsigned long int u, mp_prec_t prec, mp_rnd_t mode)
{
- mpfr_init2(mp,prec);
- mpfr_set_ui(mp,u,mode);
+ mpfr_init2 (mpfr_ptr(), prec);
+ mpfr_set_ui(mpfr_ptr(), u, mode);
MPREAL_MSVC_DEBUGVIEW_CODE;
}
inline mpreal::mpreal(const unsigned int u, mp_prec_t prec, mp_rnd_t mode)
{
- mpfr_init2(mp,prec);
- mpfr_set_ui(mp,u,mode);
+ mpfr_init2 (mpfr_ptr(), prec);
+ mpfr_set_ui(mpfr_ptr(), u, mode);
MPREAL_MSVC_DEBUGVIEW_CODE;
}
inline mpreal::mpreal(const long int u, mp_prec_t prec, mp_rnd_t mode)
{
- mpfr_init2(mp,prec);
- mpfr_set_si(mp,u,mode);
+ mpfr_init2 (mpfr_ptr(), prec);
+ mpfr_set_si(mpfr_ptr(), u, mode);
MPREAL_MSVC_DEBUGVIEW_CODE;
}
inline mpreal::mpreal(const int u, mp_prec_t prec, mp_rnd_t mode)
{
- mpfr_init2(mp,prec);
- mpfr_set_si(mp,u,mode);
+ mpfr_init2 (mpfr_ptr(), prec);
+ mpfr_set_si(mpfr_ptr(), u, mode);
MPREAL_MSVC_DEBUGVIEW_CODE;
}
@@ -711,16 +741,16 @@ inline mpreal::mpreal(const int u, mp_prec_t prec, mp_rnd_t mode)
#if defined (MPREAL_HAVE_INT64_SUPPORT)
inline mpreal::mpreal(const uint64_t u, mp_prec_t prec, mp_rnd_t mode)
{
- mpfr_init2(mp,prec);
- mpfr_set_uj(mp, u, mode);
+ mpfr_init2 (mpfr_ptr(), prec);
+ mpfr_set_uj(mpfr_ptr(), u, mode);
MPREAL_MSVC_DEBUGVIEW_CODE;
}
inline mpreal::mpreal(const int64_t u, mp_prec_t prec, mp_rnd_t mode)
{
- mpfr_init2(mp,prec);
- mpfr_set_sj(mp, u, mode);
+ mpfr_init2 (mpfr_ptr(), prec);
+ mpfr_set_sj(mpfr_ptr(), u, mode);
MPREAL_MSVC_DEBUGVIEW_CODE;
}
@@ -728,24 +758,26 @@ inline mpreal::mpreal(const int64_t u, mp_prec_t prec, mp_rnd_t mode)
inline mpreal::mpreal(const char* s, mp_prec_t prec, int base, mp_rnd_t mode)
{
- mpfr_init2(mp, prec);
- mpfr_set_str(mp, s, base, mode);
+ mpfr_init2 (mpfr_ptr(), prec);
+ mpfr_set_str(mpfr_ptr(), s, base, mode);
MPREAL_MSVC_DEBUGVIEW_CODE;
}
inline mpreal::mpreal(const std::string& s, mp_prec_t prec, int base, mp_rnd_t mode)
{
- mpfr_init2(mp, prec);
- mpfr_set_str(mp, s.c_str(), base, mode);
+ mpfr_init2 (mpfr_ptr(), prec);
+ mpfr_set_str(mpfr_ptr(), s.c_str(), base, mode);
MPREAL_MSVC_DEBUGVIEW_CODE;
}
inline void mpreal::clear(::mpfr_ptr x)
{
- // Use undocumented field in mpfr_t structure to check if it was initialized
- if(0 != x->_mpfr_d) mpfr_clear(x);
+#ifdef MPREAL_HAVE_MOVE_SUPPORT
+ if(mpfr_is_initialized(x))
+#endif
+ mpfr_clear(x);
}
inline mpreal::~mpreal()
@@ -821,6 +853,9 @@ const mpreal sqrt(const int v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
const mpreal sqrt(const long double v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
const mpreal sqrt(const double v, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
+// abs
+inline const mpreal abs(const mpreal& x, mp_rnd_t r = mpreal::get_default_rnd());
+
//////////////////////////////////////////////////////////////////////////
// pow
const mpreal pow(const mpreal& a, const unsigned int b, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
@@ -873,6 +908,11 @@ const mpreal pow(const double a, const unsigned int b, mp_rnd_t rnd_mode = mprea
const mpreal pow(const double a, const long int b, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
const mpreal pow(const double a, const int b, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
+inline const mpreal mul_2ui(const mpreal& v, unsigned long int k, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
+inline const mpreal mul_2si(const mpreal& v, long int k, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
+inline const mpreal div_2ui(const mpreal& v, unsigned long int k, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
+inline const mpreal div_2si(const mpreal& v, long int k, mp_rnd_t rnd_mode = mpreal::get_default_rnd());
+
//////////////////////////////////////////////////////////////////////////
// Estimate machine epsilon for the given precision
// Returns smallest eps such that 1.0 + eps != 1.0
@@ -920,15 +960,15 @@ inline mpreal& mpreal::operator=(const mpreal& v)
{
if (this != &v)
{
- mp_prec_t tp = mpfr_get_prec(mp);
- mp_prec_t vp = mpfr_get_prec(v.mp);
+ mp_prec_t tp = mpfr_get_prec( mpfr_srcptr());
+ mp_prec_t vp = mpfr_get_prec(v.mpfr_srcptr());
- if(tp != vp){
- clear(mpfr_ptr());
- mpfr_init2(mpfr_ptr(), vp);
- }
+ if(tp != vp){
+ clear(mpfr_ptr());
+ mpfr_init2(mpfr_ptr(), vp);
+ }
- mpfr_set(mp, v.mp, mpreal::get_default_rnd());
+ mpfr_set(mpfr_ptr(), v.mpfr_srcptr(), mpreal::get_default_rnd());
MPREAL_MSVC_DEBUGVIEW_CODE;
}
@@ -937,7 +977,7 @@ inline mpreal& mpreal::operator=(const mpreal& v)
inline mpreal& mpreal::operator=(const mpf_t v)
{
- mpfr_set_f(mp, v, mpreal::get_default_rnd());
+ mpfr_set_f(mpfr_ptr(), v, mpreal::get_default_rnd());
MPREAL_MSVC_DEBUGVIEW_CODE;
return *this;
@@ -945,7 +985,7 @@ inline mpreal& mpreal::operator=(const mpf_t v)
inline mpreal& mpreal::operator=(const mpz_t v)
{
- mpfr_set_z(mp, v, mpreal::get_default_rnd());
+ mpfr_set_z(mpfr_ptr(), v, mpreal::get_default_rnd());
MPREAL_MSVC_DEBUGVIEW_CODE;
return *this;
@@ -953,7 +993,7 @@ inline mpreal& mpreal::operator=(const mpz_t v)
inline mpreal& mpreal::operator=(const mpq_t v)
{
- mpfr_set_q(mp, v, mpreal::get_default_rnd());
+ mpfr_set_q(mpfr_ptr(), v, mpreal::get_default_rnd());
MPREAL_MSVC_DEBUGVIEW_CODE;
return *this;
@@ -961,7 +1001,7 @@ inline mpreal& mpreal::operator=(const mpq_t v)
inline mpreal& mpreal::operator=(const long double v)
{
- mpfr_set_ld(mp, v, mpreal::get_default_rnd());
+ mpfr_set_ld(mpfr_ptr(), v, mpreal::get_default_rnd());
MPREAL_MSVC_DEBUGVIEW_CODE;
return *this;
@@ -970,22 +1010,22 @@ inline mpreal& mpreal::operator=(const long double v)
inline mpreal& mpreal::operator=(const double v)
{
#if (MPREAL_DOUBLE_BITS_OVERFLOW > -1)
- if(fits_in_bits(v, MPREAL_DOUBLE_BITS_OVERFLOW))
- {
- mpfr_set_d(mp,v,mpreal::get_default_rnd());
- }else
- throw conversion_overflow();
+ if(fits_in_bits(v, MPREAL_DOUBLE_BITS_OVERFLOW))
+ {
+ mpfr_set_d(mpfr_ptr(),v,mpreal::get_default_rnd());
+ }else
+ throw conversion_overflow();
#else
- mpfr_set_d(mp,v,mpreal::get_default_rnd());
+ mpfr_set_d(mpfr_ptr(),v,mpreal::get_default_rnd());
#endif
- MPREAL_MSVC_DEBUGVIEW_CODE;
+ MPREAL_MSVC_DEBUGVIEW_CODE;
return *this;
}
inline mpreal& mpreal::operator=(const unsigned long int v)
{
- mpfr_set_ui(mp, v, mpreal::get_default_rnd());
+ mpfr_set_ui(mpfr_ptr(), v, mpreal::get_default_rnd());
MPREAL_MSVC_DEBUGVIEW_CODE;
return *this;
@@ -993,7 +1033,7 @@ inline mpreal& mpreal::operator=(const unsigned long int v)
inline mpreal& mpreal::operator=(const unsigned int v)
{
- mpfr_set_ui(mp, v, mpreal::get_default_rnd());
+ mpfr_set_ui(mpfr_ptr(), v, mpreal::get_default_rnd());
MPREAL_MSVC_DEBUGVIEW_CODE;
return *this;
@@ -1001,7 +1041,7 @@ inline mpreal& mpreal::operator=(const unsigned int v)
inline mpreal& mpreal::operator=(const long int v)
{
- mpfr_set_si(mp, v, mpreal::get_default_rnd());
+ mpfr_set_si(mpfr_ptr(), v, mpreal::get_default_rnd());
MPREAL_MSVC_DEBUGVIEW_CODE;
return *this;
@@ -1009,7 +1049,7 @@ inline mpreal& mpreal::operator=(const long int v)
inline mpreal& mpreal::operator=(const int v)
{
- mpfr_set_si(mp, v, mpreal::get_default_rnd());
+ mpfr_set_si(mpfr_ptr(), v, mpreal::get_default_rnd());
MPREAL_MSVC_DEBUGVIEW_CODE;
return *this;
@@ -1026,11 +1066,11 @@ inline mpreal& mpreal::operator=(const char* s)
mpfr_t t;
- mpfr_init2(t, mpfr_get_prec(mp));
+ mpfr_init2(t, mpfr_get_prec(mpfr_srcptr()));
if(0 == mpfr_set_str(t, s, 10, mpreal::get_default_rnd()))
{
- mpfr_set(mp, t, mpreal::get_default_rnd());
+ mpfr_set(mpfr_ptr(), t, mpreal::get_default_rnd());
MPREAL_MSVC_DEBUGVIEW_CODE;
}
@@ -1049,11 +1089,11 @@ inline mpreal& mpreal::operator=(const std::string& s)
mpfr_t t;
- mpfr_init2(t, mpfr_get_prec(mp));
+ mpfr_init2(t, mpfr_get_prec(mpfr_srcptr()));
if(0 == mpfr_set_str(t, s.c_str(), 10, mpreal::get_default_rnd()))
{
- mpfr_set(mp, t, mpreal::get_default_rnd());
+ mpfr_set(mpfr_ptr(), t, mpreal::get_default_rnd());
MPREAL_MSVC_DEBUGVIEW_CODE;
}
@@ -1066,7 +1106,7 @@ inline mpreal& mpreal::operator=(const std::string& s)
// + Addition
inline mpreal& mpreal::operator+=(const mpreal& v)
{
- mpfr_add(mp,mp,v.mp,mpreal::get_default_rnd());
+ mpfr_add(mpfr_ptr(), mpfr_srcptr(), v.mpfr_srcptr(), mpreal::get_default_rnd());
MPREAL_MSVC_DEBUGVIEW_CODE;
return *this;
}
@@ -1080,14 +1120,14 @@ inline mpreal& mpreal::operator+=(const mpf_t u)
inline mpreal& mpreal::operator+=(const mpz_t u)
{
- mpfr_add_z(mp,mp,u,mpreal::get_default_rnd());
+ mpfr_add_z(mpfr_ptr(),mpfr_srcptr(),u,mpreal::get_default_rnd());
MPREAL_MSVC_DEBUGVIEW_CODE;
return *this;
}
inline mpreal& mpreal::operator+=(const mpq_t u)
{
- mpfr_add_q(mp,mp,u,mpreal::get_default_rnd());
+ mpfr_add_q(mpfr_ptr(),mpfr_srcptr(),u,mpreal::get_default_rnd());
MPREAL_MSVC_DEBUGVIEW_CODE;
return *this;
}
@@ -1102,7 +1142,7 @@ inline mpreal& mpreal::operator+= (const long double u)
inline mpreal& mpreal::operator+= (const double u)
{
#if (MPFR_VERSION >= MPFR_VERSION_NUM(2,4,0))
- mpfr_add_d(mp,mp,u,mpreal::get_default_rnd());
+ mpfr_add_d(mpfr_ptr(),mpfr_srcptr(),u,mpreal::get_default_rnd());
#else
*this += mpreal(u);
#endif
@@ -1113,28 +1153,28 @@ inline mpreal& mpreal::operator+= (const double u)
inline mpreal& mpreal::operator+=(const unsigned long int u)
{
- mpfr_add_ui(mp,mp,u,mpreal::get_default_rnd());
+ mpfr_add_ui(mpfr_ptr(),mpfr_srcptr(),u,mpreal::get_default_rnd());
MPREAL_MSVC_DEBUGVIEW_CODE;
return *this;
}
inline mpreal& mpreal::operator+=(const unsigned int u)
{
- mpfr_add_ui(mp,mp,u,mpreal::get_default_rnd());
+ mpfr_add_ui(mpfr_ptr(),mpfr_srcptr(),u,mpreal::get_default_rnd());
MPREAL_MSVC_DEBUGVIEW_CODE;
return *this;
}
inline mpreal& mpreal::operator+=(const long int u)
{
- mpfr_add_si(mp,mp,u,mpreal::get_default_rnd());
+ mpfr_add_si(mpfr_ptr(),mpfr_srcptr(),u,mpreal::get_default_rnd());
MPREAL_MSVC_DEBUGVIEW_CODE;
return *this;
}
inline mpreal& mpreal::operator+=(const int u)
{
- mpfr_add_si(mp,mp,u,mpreal::get_default_rnd());
+ mpfr_add_si(mpfr_ptr(),mpfr_srcptr(),u,mpreal::get_default_rnd());
MPREAL_MSVC_DEBUGVIEW_CODE;
return *this;
}
@@ -1154,9 +1194,9 @@ inline const mpreal mpreal::operator+()const { return mpreal(*this); }
inline const mpreal operator+(const mpreal& a, const mpreal& b)
{
- mpreal c(0, (std::max)(mpfr_get_prec(a.mpfr_ptr()), mpfr_get_prec(b.mpfr_ptr())));
- mpfr_add(c.mpfr_ptr(), a.mpfr_srcptr(), b.mpfr_srcptr(), mpreal::get_default_rnd());
- return c;
+ mpreal c(0, (std::max)(mpfr_get_prec(a.mpfr_ptr()), mpfr_get_prec(b.mpfr_ptr())));
+ mpfr_add(c.mpfr_ptr(), a.mpfr_srcptr(), b.mpfr_srcptr(), mpreal::get_default_rnd());
+ return c;
}
inline mpreal& mpreal::operator++()
@@ -1187,21 +1227,21 @@ inline const mpreal mpreal::operator-- (int)
// - Subtraction
inline mpreal& mpreal::operator-=(const mpreal& v)
{
- mpfr_sub(mp,mp,v.mp,mpreal::get_default_rnd());
+ mpfr_sub(mpfr_ptr(),mpfr_srcptr(),v.mpfr_srcptr(),mpreal::get_default_rnd());
MPREAL_MSVC_DEBUGVIEW_CODE;
return *this;
}
inline mpreal& mpreal::operator-=(const mpz_t v)
{
- mpfr_sub_z(mp,mp,v,mpreal::get_default_rnd());
+ mpfr_sub_z(mpfr_ptr(),mpfr_srcptr(),v,mpreal::get_default_rnd());
MPREAL_MSVC_DEBUGVIEW_CODE;
return *this;
}
inline mpreal& mpreal::operator-=(const mpq_t v)
{
- mpfr_sub_q(mp,mp,v,mpreal::get_default_rnd());
+ mpfr_sub_q(mpfr_ptr(),mpfr_srcptr(),v,mpreal::get_default_rnd());
MPREAL_MSVC_DEBUGVIEW_CODE;
return *this;
}
@@ -1216,7 +1256,7 @@ inline mpreal& mpreal::operator-=(const long double v)
inline mpreal& mpreal::operator-=(const double v)
{
#if (MPFR_VERSION >= MPFR_VERSION_NUM(2,4,0))
- mpfr_sub_d(mp,mp,v,mpreal::get_default_rnd());
+ mpfr_sub_d(mpfr_ptr(),mpfr_srcptr(),v,mpreal::get_default_rnd());
#else
*this -= mpreal(v);
#endif
@@ -1227,28 +1267,28 @@ inline mpreal& mpreal::operator-=(const double v)
inline mpreal& mpreal::operator-=(const unsigned long int v)
{
- mpfr_sub_ui(mp,mp,v,mpreal::get_default_rnd());
+ mpfr_sub_ui(mpfr_ptr(),mpfr_srcptr(),v,mpreal::get_default_rnd());
MPREAL_MSVC_DEBUGVIEW_CODE;
return *this;
}
inline mpreal& mpreal::operator-=(const unsigned int v)
{
- mpfr_sub_ui(mp,mp,v,mpreal::get_default_rnd());
+ mpfr_sub_ui(mpfr_ptr(),mpfr_srcptr(),v,mpreal::get_default_rnd());
MPREAL_MSVC_DEBUGVIEW_CODE;
return *this;
}
inline mpreal& mpreal::operator-=(const long int v)
{
- mpfr_sub_si(mp,mp,v,mpreal::get_default_rnd());
+ mpfr_sub_si(mpfr_ptr(),mpfr_srcptr(),v,mpreal::get_default_rnd());
MPREAL_MSVC_DEBUGVIEW_CODE;
return *this;
}
inline mpreal& mpreal::operator-=(const int v)
{
- mpfr_sub_si(mp,mp,v,mpreal::get_default_rnd());
+ mpfr_sub_si(mpfr_ptr(),mpfr_srcptr(),v,mpreal::get_default_rnd());
MPREAL_MSVC_DEBUGVIEW_CODE;
return *this;
}
@@ -1256,15 +1296,15 @@ inline mpreal& mpreal::operator-=(const int v)
inline const mpreal mpreal::operator-()const
{
mpreal u(*this);
- mpfr_neg(u.mp,u.mp,mpreal::get_default_rnd());
+ mpfr_neg(u.mpfr_ptr(),u.mpfr_srcptr(),mpreal::get_default_rnd());
return u;
}
inline const mpreal operator-(const mpreal& a, const mpreal& b)
{
- mpreal c(0, (std::max)(mpfr_get_prec(a.mpfr_ptr()), mpfr_get_prec(b.mpfr_ptr())));
- mpfr_sub(c.mpfr_ptr(), a.mpfr_srcptr(), b.mpfr_srcptr(), mpreal::get_default_rnd());
- return c;
+ mpreal c(0, (std::max)(mpfr_get_prec(a.mpfr_ptr()), mpfr_get_prec(b.mpfr_ptr())));
+ mpfr_sub(c.mpfr_ptr(), a.mpfr_srcptr(), b.mpfr_srcptr(), mpreal::get_default_rnd());
+ return c;
}
inline const mpreal operator-(const double b, const mpreal& a)
@@ -1312,21 +1352,21 @@ inline const mpreal operator-(const int b, const mpreal& a)
// * Multiplication
inline mpreal& mpreal::operator*= (const mpreal& v)
{
- mpfr_mul(mp,mp,v.mp,mpreal::get_default_rnd());
+ mpfr_mul(mpfr_ptr(),mpfr_srcptr(),v.mpfr_srcptr(),mpreal::get_default_rnd());
MPREAL_MSVC_DEBUGVIEW_CODE;
return *this;
}
inline mpreal& mpreal::operator*=(const mpz_t v)
{
- mpfr_mul_z(mp,mp,v,mpreal::get_default_rnd());
+ mpfr_mul_z(mpfr_ptr(),mpfr_srcptr(),v,mpreal::get_default_rnd());
MPREAL_MSVC_DEBUGVIEW_CODE;
return *this;
}
inline mpreal& mpreal::operator*=(const mpq_t v)
{
- mpfr_mul_q(mp,mp,v,mpreal::get_default_rnd());
+ mpfr_mul_q(mpfr_ptr(),mpfr_srcptr(),v,mpreal::get_default_rnd());
MPREAL_MSVC_DEBUGVIEW_CODE;
return *this;
}
@@ -1341,7 +1381,7 @@ inline mpreal& mpreal::operator*=(const long double v)
inline mpreal& mpreal::operator*=(const double v)
{
#if (MPFR_VERSION >= MPFR_VERSION_NUM(2,4,0))
- mpfr_mul_d(mp,mp,v,mpreal::get_default_rnd());
+ mpfr_mul_d(mpfr_ptr(),mpfr_srcptr(),v,mpreal::get_default_rnd());
#else
*this *= mpreal(v);
#endif
@@ -1351,58 +1391,58 @@ inline mpreal& mpreal::operator*=(const double v)
inline mpreal& mpreal::operator*=(const unsigned long int v)
{
- mpfr_mul_ui(mp,mp,v,mpreal::get_default_rnd());
+ mpfr_mul_ui(mpfr_ptr(),mpfr_srcptr(),v,mpreal::get_default_rnd());
MPREAL_MSVC_DEBUGVIEW_CODE;
return *this;
}
inline mpreal& mpreal::operator*=(const unsigned int v)
{
- mpfr_mul_ui(mp,mp,v,mpreal::get_default_rnd());
+ mpfr_mul_ui(mpfr_ptr(),mpfr_srcptr(),v,mpreal::get_default_rnd());
MPREAL_MSVC_DEBUGVIEW_CODE;
return *this;
}
inline mpreal& mpreal::operator*=(const long int v)
{
- mpfr_mul_si(mp,mp,v,mpreal::get_default_rnd());
+ mpfr_mul_si(mpfr_ptr(),mpfr_srcptr(),v,mpreal::get_default_rnd());
MPREAL_MSVC_DEBUGVIEW_CODE;
return *this;
}
inline mpreal& mpreal::operator*=(const int v)
{
- mpfr_mul_si(mp,mp,v,mpreal::get_default_rnd());
+ mpfr_mul_si(mpfr_ptr(),mpfr_srcptr(),v,mpreal::get_default_rnd());
MPREAL_MSVC_DEBUGVIEW_CODE;
return *this;
}
inline const mpreal operator*(const mpreal& a, const mpreal& b)
{
- mpreal c(0, (std::max)(mpfr_get_prec(a.mpfr_ptr()), mpfr_get_prec(b.mpfr_ptr())));
- mpfr_mul(c.mpfr_ptr(), a.mpfr_srcptr(), b.mpfr_srcptr(), mpreal::get_default_rnd());
- return c;
+ mpreal c(0, (std::max)(mpfr_get_prec(a.mpfr_ptr()), mpfr_get_prec(b.mpfr_ptr())));
+ mpfr_mul(c.mpfr_ptr(), a.mpfr_srcptr(), b.mpfr_srcptr(), mpreal::get_default_rnd());
+ return c;
}
//////////////////////////////////////////////////////////////////////////
// / Division
inline mpreal& mpreal::operator/=(const mpreal& v)
{
- mpfr_div(mp,mp,v.mp,mpreal::get_default_rnd());
+ mpfr_div(mpfr_ptr(),mpfr_srcptr(),v.mpfr_srcptr(),mpreal::get_default_rnd());
MPREAL_MSVC_DEBUGVIEW_CODE;
return *this;
}
inline mpreal& mpreal::operator/=(const mpz_t v)
{
- mpfr_div_z(mp,mp,v,mpreal::get_default_rnd());
+ mpfr_div_z(mpfr_ptr(),mpfr_srcptr(),v,mpreal::get_default_rnd());
MPREAL_MSVC_DEBUGVIEW_CODE;
return *this;
}
inline mpreal& mpreal::operator/=(const mpq_t v)
{
- mpfr_div_q(mp,mp,v,mpreal::get_default_rnd());
+ mpfr_div_q(mpfr_ptr(),mpfr_srcptr(),v,mpreal::get_default_rnd());
MPREAL_MSVC_DEBUGVIEW_CODE;
return *this;
}
@@ -1417,7 +1457,7 @@ inline mpreal& mpreal::operator/=(const long double v)
inline mpreal& mpreal::operator/=(const double v)
{
#if (MPFR_VERSION >= MPFR_VERSION_NUM(2,4,0))
- mpfr_div_d(mp,mp,v,mpreal::get_default_rnd());
+ mpfr_div_d(mpfr_ptr(),mpfr_srcptr(),v,mpreal::get_default_rnd());
#else
*this /= mpreal(v);
#endif
@@ -1427,72 +1467,72 @@ inline mpreal& mpreal::operator/=(const double v)
inline mpreal& mpreal::operator/=(const unsigned long int v)
{
- mpfr_div_ui(mp,mp,v,mpreal::get_default_rnd());
+ mpfr_div_ui(mpfr_ptr(),mpfr_srcptr(),v,mpreal::get_default_rnd());
MPREAL_MSVC_DEBUGVIEW_CODE;
return *this;
}
inline mpreal& mpreal::operator/=(const unsigned int v)
{
- mpfr_div_ui(mp,mp,v,mpreal::get_default_rnd());
+ mpfr_div_ui(mpfr_ptr(),mpfr_srcptr(),v,mpreal::get_default_rnd());
MPREAL_MSVC_DEBUGVIEW_CODE;
return *this;
}
inline mpreal& mpreal::operator/=(const long int v)
{
- mpfr_div_si(mp,mp,v,mpreal::get_default_rnd());
+ mpfr_div_si(mpfr_ptr(),mpfr_srcptr(),v,mpreal::get_default_rnd());
MPREAL_MSVC_DEBUGVIEW_CODE;
return *this;
}
inline mpreal& mpreal::operator/=(const int v)
{
- mpfr_div_si(mp,mp,v,mpreal::get_default_rnd());
+ mpfr_div_si(mpfr_ptr(),mpfr_srcptr(),v,mpreal::get_default_rnd());
MPREAL_MSVC_DEBUGVIEW_CODE;
return *this;
}
inline const mpreal operator/(const mpreal& a, const mpreal& b)
{
- mpreal c(0, (std::max)(mpfr_get_prec(a.mpfr_ptr()), mpfr_get_prec(b.mpfr_ptr())));
- mpfr_div(c.mpfr_ptr(), a.mpfr_srcptr(), b.mpfr_srcptr(), mpreal::get_default_rnd());
- return c;
+ mpreal c(0, (std::max)(mpfr_get_prec(a.mpfr_srcptr()), mpfr_get_prec(b.mpfr_srcptr())));
+ mpfr_div(c.mpfr_ptr(), a.mpfr_srcptr(), b.mpfr_srcptr(), mpreal::get_default_rnd());
+ return c;
}
inline const mpreal operator/(const unsigned long int b, const mpreal& a)
{
- mpreal x(0, mpfr_get_prec(a.mpfr_ptr()));
+ mpreal x(0, mpfr_get_prec(a.mpfr_srcptr()));
mpfr_ui_div(x.mpfr_ptr(), b, a.mpfr_srcptr(), mpreal::get_default_rnd());
return x;
}
inline const mpreal operator/(const unsigned int b, const mpreal& a)
{
- mpreal x(0, mpfr_get_prec(a.mpfr_ptr()));
+ mpreal x(0, mpfr_get_prec(a.mpfr_srcptr()));
mpfr_ui_div(x.mpfr_ptr(), b, a.mpfr_srcptr(), mpreal::get_default_rnd());
return x;
}
inline const mpreal operator/(const long int b, const mpreal& a)
{
- mpreal x(0, mpfr_get_prec(a.mpfr_ptr()));
- mpfr_si_div(x.mpfr_ptr(), b, a.mpfr_srcptr(),mpreal::get_default_rnd());
+ mpreal x(0, mpfr_get_prec(a.mpfr_srcptr()));
+ mpfr_si_div(x.mpfr_ptr(), b, a.mpfr_srcptr(), mpreal::get_default_rnd());
return x;
}
inline const mpreal operator/(const int b, const mpreal& a)
{
- mpreal x(0, mpfr_get_prec(a.mpfr_ptr()));
- mpfr_si_div(x.mpfr_ptr(), b, a.mpfr_srcptr(),mpreal::get_default_rnd());
+ mpreal x(0, mpfr_get_prec(a.mpfr_srcptr()));
+ mpfr_si_div(x.mpfr_ptr(), b, a.mpfr_srcptr(), mpreal::get_default_rnd());
return x;
}
inline const mpreal operator/(const double b, const mpreal& a)
{
#if (MPFR_VERSION >= MPFR_VERSION_NUM(2,4,0))
- mpreal x(0, mpfr_get_prec(a.mpfr_ptr()));
- mpfr_d_div(x.mpfr_ptr(), b, a.mpfr_srcptr(),mpreal::get_default_rnd());
+ mpreal x(0, mpfr_get_prec(a.mpfr_srcptr()));
+ mpfr_d_div(x.mpfr_ptr(), b, a.mpfr_srcptr(), mpreal::get_default_rnd());
return x;
#else
mpreal x(0, mpfr_get_prec(a.mpfr_ptr()));
@@ -1505,56 +1545,56 @@ inline const mpreal operator/(const double b, const mpreal& a)
// Shifts operators - Multiplication/Division by power of 2
inline mpreal& mpreal::operator<<=(const unsigned long int u)
{
- mpfr_mul_2ui(mp,mp,u,mpreal::get_default_rnd());
+ mpfr_mul_2ui(mpfr_ptr(),mpfr_srcptr(),u,mpreal::get_default_rnd());
MPREAL_MSVC_DEBUGVIEW_CODE;
return *this;
}
inline mpreal& mpreal::operator<<=(const unsigned int u)
{
- mpfr_mul_2ui(mp,mp,static_cast<unsigned long int>(u),mpreal::get_default_rnd());
+ mpfr_mul_2ui(mpfr_ptr(),mpfr_srcptr(),static_cast<unsigned long int>(u),mpreal::get_default_rnd());
MPREAL_MSVC_DEBUGVIEW_CODE;
return *this;
}
inline mpreal& mpreal::operator<<=(const long int u)
{
- mpfr_mul_2si(mp,mp,u,mpreal::get_default_rnd());
+ mpfr_mul_2si(mpfr_ptr(),mpfr_srcptr(),u,mpreal::get_default_rnd());
MPREAL_MSVC_DEBUGVIEW_CODE;
return *this;
}
inline mpreal& mpreal::operator<<=(const int u)
{
- mpfr_mul_2si(mp,mp,static_cast<long int>(u),mpreal::get_default_rnd());
+ mpfr_mul_2si(mpfr_ptr(),mpfr_srcptr(),static_cast<long int>(u),mpreal::get_default_rnd());
MPREAL_MSVC_DEBUGVIEW_CODE;
return *this;
}
inline mpreal& mpreal::operator>>=(const unsigned long int u)
{
- mpfr_div_2ui(mp,mp,u,mpreal::get_default_rnd());
+ mpfr_div_2ui(mpfr_ptr(),mpfr_srcptr(),u,mpreal::get_default_rnd());
MPREAL_MSVC_DEBUGVIEW_CODE;
return *this;
}
inline mpreal& mpreal::operator>>=(const unsigned int u)
{
- mpfr_div_2ui(mp,mp,static_cast<unsigned long int>(u),mpreal::get_default_rnd());
+ mpfr_div_2ui(mpfr_ptr(),mpfr_srcptr(),static_cast<unsigned long int>(u),mpreal::get_default_rnd());
MPREAL_MSVC_DEBUGVIEW_CODE;
return *this;
}
inline mpreal& mpreal::operator>>=(const long int u)
{
- mpfr_div_2si(mp,mp,u,mpreal::get_default_rnd());
+ mpfr_div_2si(mpfr_ptr(),mpfr_srcptr(),u,mpreal::get_default_rnd());
MPREAL_MSVC_DEBUGVIEW_CODE;
return *this;
}
inline mpreal& mpreal::operator>>=(const int u)
{
- mpfr_div_2si(mp,mp,static_cast<long int>(u),mpreal::get_default_rnd());
+ mpfr_div_2si(mpfr_ptr(),mpfr_srcptr(),static_cast<long int>(u),mpreal::get_default_rnd());
MPREAL_MSVC_DEBUGVIEW_CODE;
return *this;
}
@@ -1603,7 +1643,7 @@ inline const mpreal operator>>(const mpreal& v, const int k)
inline const mpreal mul_2ui(const mpreal& v, unsigned long int k, mp_rnd_t rnd_mode)
{
mpreal x(v);
- mpfr_mul_2ui(x.mp,v.mp,k,rnd_mode);
+ mpfr_mul_2ui(x.mpfr_ptr(),v.mpfr_srcptr(),k,rnd_mode);
return x;
}
@@ -1611,61 +1651,63 @@ inline const mpreal mul_2ui(const mpreal& v, unsigned long int k, mp_rnd_t rnd_m
inline const mpreal mul_2si(const mpreal& v, long int k, mp_rnd_t rnd_mode)
{
mpreal x(v);
- mpfr_mul_2si(x.mp,v.mp,k,rnd_mode);
+ mpfr_mul_2si(x.mpfr_ptr(),v.mpfr_srcptr(),k,rnd_mode);
return x;
}
inline const mpreal div_2ui(const mpreal& v, unsigned long int k, mp_rnd_t rnd_mode)
{
mpreal x(v);
- mpfr_div_2ui(x.mp,v.mp,k,rnd_mode);
+ mpfr_div_2ui(x.mpfr_ptr(),v.mpfr_srcptr(),k,rnd_mode);
return x;
}
inline const mpreal div_2si(const mpreal& v, long int k, mp_rnd_t rnd_mode)
{
mpreal x(v);
- mpfr_div_2si(x.mp,v.mp,k,rnd_mode);
+ mpfr_div_2si(x.mpfr_ptr(),v.mpfr_srcptr(),k,rnd_mode);
return x;
}
//////////////////////////////////////////////////////////////////////////
//Boolean operators
-inline bool operator > (const mpreal& a, const mpreal& b){ return (mpfr_greater_p(a.mp,b.mp) !=0); }
-inline bool operator >= (const mpreal& a, const mpreal& b){ return (mpfr_greaterequal_p(a.mp,b.mp) !=0); }
-inline bool operator < (const mpreal& a, const mpreal& b){ return (mpfr_less_p(a.mp,b.mp) !=0); }
-inline bool operator <= (const mpreal& a, const mpreal& b){ return (mpfr_lessequal_p(a.mp,b.mp) !=0); }
-inline bool operator == (const mpreal& a, const mpreal& b){ return (mpfr_equal_p(a.mp,b.mp) !=0); }
-inline bool operator != (const mpreal& a, const mpreal& b){ return (mpfr_lessgreater_p(a.mp,b.mp) !=0); }
-
-inline bool operator == (const mpreal& a, const unsigned long int b ){ return (mpfr_cmp_ui(a.mp,b) == 0); }
-inline bool operator == (const mpreal& a, const unsigned int b ){ return (mpfr_cmp_ui(a.mp,b) == 0); }
-inline bool operator == (const mpreal& a, const long int b ){ return (mpfr_cmp_si(a.mp,b) == 0); }
-inline bool operator == (const mpreal& a, const int b ){ return (mpfr_cmp_si(a.mp,b) == 0); }
-inline bool operator == (const mpreal& a, const long double b ){ return (mpfr_cmp_ld(a.mp,b) == 0); }
-inline bool operator == (const mpreal& a, const double b ){ return (mpfr_cmp_d(a.mp,b) == 0); }
-
-
-inline bool isnan (const mpreal& v){ return (mpfr_nan_p(v.mp) != 0); }
-inline bool isinf (const mpreal& v){ return (mpfr_inf_p(v.mp) != 0); }
-inline bool isfinite (const mpreal& v){ return (mpfr_number_p(v.mp) != 0); }
-inline bool iszero (const mpreal& v){ return (mpfr_zero_p(v.mp) != 0); }
-inline bool isint (const mpreal& v){ return (mpfr_integer_p(v.mp) != 0); }
+inline bool operator > (const mpreal& a, const mpreal& b){ return (mpfr_greater_p (a.mpfr_srcptr(),b.mpfr_srcptr()) !=0 ); }
+inline bool operator >= (const mpreal& a, const mpreal& b){ return (mpfr_greaterequal_p (a.mpfr_srcptr(),b.mpfr_srcptr()) !=0 ); }
+inline bool operator < (const mpreal& a, const mpreal& b){ return (mpfr_less_p (a.mpfr_srcptr(),b.mpfr_srcptr()) !=0 ); }
+inline bool operator <= (const mpreal& a, const mpreal& b){ return (mpfr_lessequal_p (a.mpfr_srcptr(),b.mpfr_srcptr()) !=0 ); }
+inline bool operator == (const mpreal& a, const mpreal& b){ return (mpfr_equal_p (a.mpfr_srcptr(),b.mpfr_srcptr()) !=0 ); }
+inline bool operator != (const mpreal& a, const mpreal& b){ return (mpfr_lessgreater_p (a.mpfr_srcptr(),b.mpfr_srcptr()) !=0 ); }
+
+inline bool operator == (const mpreal& a, const unsigned long int b ){ return (mpfr_cmp_ui(a.mpfr_srcptr(),b) == 0 ); }
+inline bool operator == (const mpreal& a, const unsigned int b ){ return (mpfr_cmp_ui(a.mpfr_srcptr(),b) == 0 ); }
+inline bool operator == (const mpreal& a, const long int b ){ return (mpfr_cmp_si(a.mpfr_srcptr(),b) == 0 ); }
+inline bool operator == (const mpreal& a, const int b ){ return (mpfr_cmp_si(a.mpfr_srcptr(),b) == 0 ); }
+inline bool operator == (const mpreal& a, const long double b ){ return (mpfr_cmp_ld(a.mpfr_srcptr(),b) == 0 ); }
+inline bool operator == (const mpreal& a, const double b ){ return (mpfr_cmp_d (a.mpfr_srcptr(),b) == 0 ); }
+
+
+inline bool isnan (const mpreal& op){ return (mpfr_nan_p (op.mpfr_srcptr()) != 0 ); }
+inline bool isinf (const mpreal& op){ return (mpfr_inf_p (op.mpfr_srcptr()) != 0 ); }
+inline bool isfinite (const mpreal& op){ return (mpfr_number_p (op.mpfr_srcptr()) != 0 ); }
+inline bool iszero (const mpreal& op){ return (mpfr_zero_p (op.mpfr_srcptr()) != 0 ); }
+inline bool isint (const mpreal& op){ return (mpfr_integer_p(op.mpfr_srcptr()) != 0 ); }
#if (MPFR_VERSION >= MPFR_VERSION_NUM(3,0,0))
-inline bool isregular(const mpreal& v){ return (mpfr_regular_p(v.mp));}
+inline bool isregular(const mpreal& op){ return (mpfr_regular_p(op.mpfr_srcptr()));}
#endif
//////////////////////////////////////////////////////////////////////////
// Type Converters
-inline long mpreal::toLong (mp_rnd_t mode) const { return mpfr_get_si(mp, mode); }
-inline unsigned long mpreal::toULong (mp_rnd_t mode) const { return mpfr_get_ui(mp, mode); }
-inline double mpreal::toDouble (mp_rnd_t mode) const { return mpfr_get_d (mp, mode); }
-inline long double mpreal::toLDouble(mp_rnd_t mode) const { return mpfr_get_ld(mp, mode); }
+inline bool mpreal::toBool (mp_rnd_t /*mode*/) const { return mpfr_zero_p (mpfr_srcptr()) == 0; }
+inline long mpreal::toLong (mp_rnd_t mode) const { return mpfr_get_si (mpfr_srcptr(), mode); }
+inline unsigned long mpreal::toULong (mp_rnd_t mode) const { return mpfr_get_ui (mpfr_srcptr(), mode); }
+inline float mpreal::toFloat (mp_rnd_t mode) const { return mpfr_get_flt(mpfr_srcptr(), mode); }
+inline double mpreal::toDouble (mp_rnd_t mode) const { return mpfr_get_d (mpfr_srcptr(), mode); }
+inline long double mpreal::toLDouble(mp_rnd_t mode) const { return mpfr_get_ld (mpfr_srcptr(), mode); }
#if defined (MPREAL_HAVE_INT64_SUPPORT)
-inline int64_t mpreal::toInt64 (mp_rnd_t mode) const{ return mpfr_get_sj(mp, mode); }
-inline uint64_t mpreal::toUInt64(mp_rnd_t mode) const{ return mpfr_get_uj(mp, mode); }
+inline int64_t mpreal::toInt64 (mp_rnd_t mode) const{ return mpfr_get_sj(mpfr_srcptr(), mode); }
+inline uint64_t mpreal::toUInt64(mp_rnd_t mode) const{ return mpfr_get_uj(mpfr_srcptr(), mode); }
#endif
inline ::mpfr_ptr mpreal::mpfr_ptr() { return mp; }
@@ -1689,7 +1731,7 @@ inline std::string mpreal::toString(const std::string& format) const
if( !format.empty() )
{
- if(!(mpfr_asprintf(&s,format.c_str(),mp) < 0))
+ if(!(mpfr_asprintf(&s, format.c_str(), mpfr_srcptr()) < 0))
{
out = std::string(s);
@@ -1704,20 +1746,19 @@ inline std::string mpreal::toString(const std::string& format) const
inline std::string mpreal::toString(int n, int b, mp_rnd_t mode) const
{
+ // TODO: Add extended format specification (f, e, rounding mode) as it done in output operator
(void)b;
(void)mode;
#if (MPFR_VERSION >= MPFR_VERSION_NUM(2,4,0))
- // Use MPFR native function for output
- char format[128];
- int digits;
+ std::ostringstream format;
- digits = n > 0 ? n : bits2digits(mpfr_get_prec(mp));
-
- sprintf(format,"%%.%dRNg",digits); // Default format
+ int digits = (n >= 0) ? n : bits2digits(mpfr_get_prec(mpfr_srcptr()));
+
+ format << "%." << digits << "RNg";
- return toString(std::string(format));
+ return toString(format.str());
#else
@@ -1735,8 +1776,8 @@ inline std::string mpreal::toString(int n, int b, mp_rnd_t mode) const
if(mpfr_zero_p(mp)) return "0";
if(mpfr_nan_p(mp)) return "NaN";
- s = mpfr_get_str(NULL,&exp,b,0,mp,mode);
- ns = mpfr_get_str(NULL,&exp,b,n,mp,mode);
+ s = mpfr_get_str(NULL, &exp, b, 0, mp, mode);
+ ns = mpfr_get_str(NULL, &exp, b, (std::max)(0,n), mp, mode);
if(s!=NULL && ns!=NULL)
{
@@ -1821,17 +1862,43 @@ inline std::string mpreal::toString(int n, int b, mp_rnd_t mode) const
//////////////////////////////////////////////////////////////////////////
// I/O
+inline std::ostream& mpreal::output(std::ostream& os) const
+{
+ std::ostringstream format;
+ const std::ios::fmtflags flags = os.flags();
+
+ format << ((flags & std::ios::showpos) ? "%+" : "%");
+ if (os.precision() >= 0)
+ format << '.' << os.precision() << "R*"
+ << ((flags & std::ios::floatfield) == std::ios::fixed ? 'f' :
+ (flags & std::ios::floatfield) == std::ios::scientific ? 'e' :
+ 'g');
+ else
+ format << "R*e";
+
+ char *s = NULL;
+ if(!(mpfr_asprintf(&s, format.str().c_str(),
+ mpfr::mpreal::get_default_rnd(),
+ mpfr_srcptr())
+ < 0))
+ {
+ os << std::string(s);
+ mpfr_free_str(s);
+ }
+ return os;
+}
+
inline std::ostream& operator<<(std::ostream& os, const mpreal& v)
{
- return os<<v.toString(static_cast<int>(os.precision()));
+ return v.output(os);
}
inline std::istream& operator>>(std::istream &is, mpreal& v)
{
- // ToDo, use cout::hexfloat and other flags to setup base
+ // TODO: use cout::hexfloat and other flags to setup base
std::string tmp;
is >> tmp;
- mpfr_set_str(v.mp, tmp.c_str(), 10, mpreal::get_default_rnd());
+ mpfr_set_str(v.mpfr_ptr(), tmp.c_str(), 10, mpreal::get_default_rnd());
return is;
}
@@ -1844,53 +1911,53 @@ inline mp_prec_t digits2bits(int d)
{
const double LOG2_10 = 3.3219280948873624;
- return (mp_prec_t) std::ceil( d * LOG2_10 );
+ return mp_prec_t(std::ceil( d * LOG2_10 ));
}
inline int bits2digits(mp_prec_t b)
{
const double LOG10_2 = 0.30102999566398119;
- return (int) std::floor( b * LOG10_2 );
+ return int(std::floor( b * LOG10_2 ));
}
//////////////////////////////////////////////////////////////////////////
// Set/Get number properties
-inline int sgn(const mpreal& v)
+inline int sgn(const mpreal& op)
{
- int r = mpfr_signbit(v.mp);
- return (r>0?-1:1);
+ int r = mpfr_signbit(op.mpfr_srcptr());
+ return (r > 0? -1 : 1);
}
inline mpreal& mpreal::setSign(int sign, mp_rnd_t RoundingMode)
{
- mpfr_setsign(mp,mp,(sign < 0 ? 1 : 0),RoundingMode);
+ mpfr_setsign(mpfr_ptr(), mpfr_srcptr(), (sign < 0 ? 1 : 0), RoundingMode);
MPREAL_MSVC_DEBUGVIEW_CODE;
return *this;
}
inline int mpreal::getPrecision() const
{
- return mpfr_get_prec(mp);
+ return int(mpfr_get_prec(mpfr_srcptr()));
}
inline mpreal& mpreal::setPrecision(int Precision, mp_rnd_t RoundingMode)
{
- mpfr_prec_round(mp, Precision, RoundingMode);
+ mpfr_prec_round(mpfr_ptr(), Precision, RoundingMode);
MPREAL_MSVC_DEBUGVIEW_CODE;
return *this;
}
inline mpreal& mpreal::setInf(int sign)
{
- mpfr_set_inf(mp,sign);
+ mpfr_set_inf(mpfr_ptr(), sign);
MPREAL_MSVC_DEBUGVIEW_CODE;
return *this;
}
inline mpreal& mpreal::setNan()
{
- mpfr_set_nan(mp);
+ mpfr_set_nan(mpfr_ptr());
MPREAL_MSVC_DEBUGVIEW_CODE;
return *this;
}
@@ -1899,9 +1966,9 @@ inline mpreal& mpreal::setZero(int sign)
{
#if (MPFR_VERSION >= MPFR_VERSION_NUM(3,0,0))
- mpfr_set_zero(mp, sign);
+ mpfr_set_zero(mpfr_ptr(), sign);
#else
- mpfr_set_si(mp, 0, (mpfr_get_default_rounding_mode)());
+ mpfr_set_si(mpfr_ptr(), 0, (mpfr_get_default_rounding_mode)());
setSign(sign);
#endif
@@ -1911,23 +1978,23 @@ inline mpreal& mpreal::setZero(int sign)
inline mp_prec_t mpreal::get_prec() const
{
- return mpfr_get_prec(mp);
+ return mpfr_get_prec(mpfr_srcptr());
}
inline void mpreal::set_prec(mp_prec_t prec, mp_rnd_t rnd_mode)
{
- mpfr_prec_round(mp,prec,rnd_mode);
+ mpfr_prec_round(mpfr_ptr(),prec,rnd_mode);
MPREAL_MSVC_DEBUGVIEW_CODE;
}
inline mp_exp_t mpreal::get_exp ()
{
- return mpfr_get_exp(mp);
+ return mpfr_get_exp(mpfr_srcptr());
}
inline int mpreal::set_exp (mp_exp_t e)
{
- int x = mpfr_set_exp(mp, e);
+ int x = mpfr_set_exp(mpfr_ptr(), e);
MPREAL_MSVC_DEBUGVIEW_CODE;
return x;
}
@@ -1945,7 +2012,7 @@ inline const mpreal ldexp(const mpreal& v, mp_exp_t exp)
mpreal x(v);
// rounding is not important since we just increasing the exponent
- mpfr_mul_2si(x.mp,x.mp,exp,mpreal::get_default_rnd());
+ mpfr_mul_2si(x.mpfr_ptr(), x.mpfr_srcptr(), exp, mpreal::get_default_rnd());
return x;
}
@@ -1960,9 +2027,9 @@ inline mpreal machine_epsilon(const mpreal& x)
/* the smallest eps such that x + eps != x */
if( x < 0)
{
- return nextabove(-x)+x;
+ return nextabove(-x) + x;
}else{
- return nextabove(x)-x;
+ return nextabove( x) - x;
}
}
@@ -1997,22 +2064,22 @@ inline bool isEqualFuzzy(const mpreal& a, const mpreal& b)
inline const mpreal modf(const mpreal& v, mpreal& n)
{
- mpreal frac(v);
+ mpreal f(v);
// rounding is not important since we are using the same number
- mpfr_frac(frac.mp,frac.mp,mpreal::get_default_rnd());
- mpfr_trunc(n.mp,v.mp);
- return frac;
+ mpfr_frac (f.mpfr_ptr(),f.mpfr_srcptr(),mpreal::get_default_rnd());
+ mpfr_trunc(n.mpfr_ptr(),v.mpfr_srcptr());
+ return f;
}
inline int mpreal::check_range (int t, mp_rnd_t rnd_mode)
{
- return mpfr_check_range(mp,t,rnd_mode);
+ return mpfr_check_range(mpfr_ptr(),t,rnd_mode);
}
inline int mpreal::subnormalize (int t,mp_rnd_t rnd_mode)
{
- int r = mpfr_subnormalize(mp,t,rnd_mode);
+ int r = mpfr_subnormalize(mpfr_ptr(),t,rnd_mode);
MPREAL_MSVC_DEBUGVIEW_CODE;
return r;
}
@@ -2065,8 +2132,11 @@ inline mp_exp_t mpreal::get_emax_max (void)
mpfr_##f(y.mpfr_ptr(), x.mpfr_srcptr(), r); \
return y;
-inline const mpreal sqr (const mpreal& x, mp_rnd_t r) { MPREAL_UNARY_MATH_FUNCTION_BODY(sqr ); }
-inline const mpreal sqrt (const mpreal& x, mp_rnd_t r) { MPREAL_UNARY_MATH_FUNCTION_BODY(sqrt); }
+inline const mpreal sqr (const mpreal& x, mp_rnd_t r = mpreal::get_default_rnd())
+{ MPREAL_UNARY_MATH_FUNCTION_BODY(sqr ); }
+
+inline const mpreal sqrt (const mpreal& x, mp_rnd_t r = mpreal::get_default_rnd())
+{ MPREAL_UNARY_MATH_FUNCTION_BODY(sqrt); }
inline const mpreal sqrt(const unsigned long int x, mp_rnd_t r)
{
@@ -2092,14 +2162,14 @@ inline const mpreal sqrt(const int v, mp_rnd_t rnd_mode)
else return mpreal().setNan(); // NaN
}
-inline const mpreal root(const mpreal& x, unsigned long int k, mp_rnd_t r)
+inline const mpreal root(const mpreal& x, unsigned long int k, mp_rnd_t r = mpreal::get_default_rnd())
{
mpreal y(0, mpfr_get_prec(x.mpfr_srcptr()));
mpfr_root(y.mpfr_ptr(), x.mpfr_srcptr(), k, r);
return y;
}
-inline const mpreal dim(const mpreal& a, const mpreal& b, mp_rnd_t r)
+inline const mpreal dim(const mpreal& a, const mpreal& b, mp_rnd_t r = mpreal::get_default_rnd())
{
mpreal y(0, mpfr_get_prec(a.mpfr_srcptr()));
mpfr_dim(y.mpfr_ptr(), a.mpfr_srcptr(), b.mpfr_srcptr(), r);
@@ -2111,7 +2181,7 @@ inline int cmpabs(const mpreal& a,const mpreal& b)
return mpfr_cmpabs(a.mpfr_ptr(), b.mpfr_srcptr());
}
-inline int sin_cos(mpreal& s, mpreal& c, const mpreal& v, mp_rnd_t rnd_mode)
+inline int sin_cos(mpreal& s, mpreal& c, const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd())
{
return mpfr_sin_cos(s.mpfr_ptr(), c.mpfr_ptr(), v.mpfr_srcptr(), rnd_mode);
}
@@ -2119,84 +2189,85 @@ inline int sin_cos(mpreal& s, mpreal& c, const mpreal& v, mp_rnd_t rnd_mode)
inline const mpreal sqrt (const long double v, mp_rnd_t rnd_mode) { return sqrt(mpreal(v),rnd_mode); }
inline const mpreal sqrt (const double v, mp_rnd_t rnd_mode) { return sqrt(mpreal(v),rnd_mode); }
-inline const mpreal cbrt (const mpreal& x, mp_rnd_t r) { MPREAL_UNARY_MATH_FUNCTION_BODY(cbrt ); }
-inline const mpreal fabs (const mpreal& x, mp_rnd_t r) { MPREAL_UNARY_MATH_FUNCTION_BODY(abs ); }
-inline const mpreal abs (const mpreal& x, mp_rnd_t r) { MPREAL_UNARY_MATH_FUNCTION_BODY(abs ); }
-inline const mpreal log (const mpreal& x, mp_rnd_t r) { MPREAL_UNARY_MATH_FUNCTION_BODY(log ); }
-inline const mpreal log2 (const mpreal& x, mp_rnd_t r) { MPREAL_UNARY_MATH_FUNCTION_BODY(log2 ); }
-inline const mpreal log10 (const mpreal& x, mp_rnd_t r) { MPREAL_UNARY_MATH_FUNCTION_BODY(log10); }
-inline const mpreal exp (const mpreal& x, mp_rnd_t r) { MPREAL_UNARY_MATH_FUNCTION_BODY(exp ); }
-inline const mpreal exp2 (const mpreal& x, mp_rnd_t r) { MPREAL_UNARY_MATH_FUNCTION_BODY(exp2 ); }
-inline const mpreal exp10 (const mpreal& x, mp_rnd_t r) { MPREAL_UNARY_MATH_FUNCTION_BODY(exp10); }
-inline const mpreal cos (const mpreal& x, mp_rnd_t r) { MPREAL_UNARY_MATH_FUNCTION_BODY(cos ); }
-inline const mpreal sin (const mpreal& x, mp_rnd_t r) { MPREAL_UNARY_MATH_FUNCTION_BODY(sin ); }
-inline const mpreal tan (const mpreal& x, mp_rnd_t r) { MPREAL_UNARY_MATH_FUNCTION_BODY(tan ); }
-inline const mpreal sec (const mpreal& x, mp_rnd_t r) { MPREAL_UNARY_MATH_FUNCTION_BODY(sec ); }
-inline const mpreal csc (const mpreal& x, mp_rnd_t r) { MPREAL_UNARY_MATH_FUNCTION_BODY(csc ); }
-inline const mpreal cot (const mpreal& x, mp_rnd_t r) { MPREAL_UNARY_MATH_FUNCTION_BODY(cot ); }
-inline const mpreal acos (const mpreal& x, mp_rnd_t r) { MPREAL_UNARY_MATH_FUNCTION_BODY(acos ); }
-inline const mpreal asin (const mpreal& x, mp_rnd_t r) { MPREAL_UNARY_MATH_FUNCTION_BODY(asin ); }
-inline const mpreal atan (const mpreal& x, mp_rnd_t r) { MPREAL_UNARY_MATH_FUNCTION_BODY(atan ); }
-
-inline const mpreal acot (const mpreal& v, mp_rnd_t r) { return atan (1/v, r); }
-inline const mpreal asec (const mpreal& v, mp_rnd_t r) { return acos (1/v, r); }
-inline const mpreal acsc (const mpreal& v, mp_rnd_t r) { return asin (1/v, r); }
-inline const mpreal acoth (const mpreal& v, mp_rnd_t r) { return atanh(1/v, r); }
-inline const mpreal asech (const mpreal& v, mp_rnd_t r) { return acosh(1/v, r); }
-inline const mpreal acsch (const mpreal& v, mp_rnd_t r) { return asinh(1/v, r); }
-
-inline const mpreal cosh (const mpreal& x, mp_rnd_t r) { MPREAL_UNARY_MATH_FUNCTION_BODY(cosh ); }
-inline const mpreal sinh (const mpreal& x, mp_rnd_t r) { MPREAL_UNARY_MATH_FUNCTION_BODY(sinh ); }
-inline const mpreal tanh (const mpreal& x, mp_rnd_t r) { MPREAL_UNARY_MATH_FUNCTION_BODY(tanh ); }
-inline const mpreal sech (const mpreal& x, mp_rnd_t r) { MPREAL_UNARY_MATH_FUNCTION_BODY(sech ); }
-inline const mpreal csch (const mpreal& x, mp_rnd_t r) { MPREAL_UNARY_MATH_FUNCTION_BODY(csch ); }
-inline const mpreal coth (const mpreal& x, mp_rnd_t r) { MPREAL_UNARY_MATH_FUNCTION_BODY(coth ); }
-inline const mpreal acosh (const mpreal& x, mp_rnd_t r) { MPREAL_UNARY_MATH_FUNCTION_BODY(acosh); }
-inline const mpreal asinh (const mpreal& x, mp_rnd_t r) { MPREAL_UNARY_MATH_FUNCTION_BODY(asinh); }
-inline const mpreal atanh (const mpreal& x, mp_rnd_t r) { MPREAL_UNARY_MATH_FUNCTION_BODY(atanh); }
-
-inline const mpreal log1p (const mpreal& x, mp_rnd_t r) { MPREAL_UNARY_MATH_FUNCTION_BODY(log1p ); }
-inline const mpreal expm1 (const mpreal& x, mp_rnd_t r) { MPREAL_UNARY_MATH_FUNCTION_BODY(expm1 ); }
-inline const mpreal eint (const mpreal& x, mp_rnd_t r) { MPREAL_UNARY_MATH_FUNCTION_BODY(eint ); }
-inline const mpreal gamma (const mpreal& x, mp_rnd_t r) { MPREAL_UNARY_MATH_FUNCTION_BODY(gamma ); }
-inline const mpreal lngamma (const mpreal& x, mp_rnd_t r) { MPREAL_UNARY_MATH_FUNCTION_BODY(lngamma); }
-inline const mpreal zeta (const mpreal& x, mp_rnd_t r) { MPREAL_UNARY_MATH_FUNCTION_BODY(zeta ); }
-inline const mpreal erf (const mpreal& x, mp_rnd_t r) { MPREAL_UNARY_MATH_FUNCTION_BODY(erf ); }
-inline const mpreal erfc (const mpreal& x, mp_rnd_t r) { MPREAL_UNARY_MATH_FUNCTION_BODY(erfc ); }
-inline const mpreal besselj0(const mpreal& x, mp_rnd_t r) { MPREAL_UNARY_MATH_FUNCTION_BODY(j0 ); }
-inline const mpreal besselj1(const mpreal& x, mp_rnd_t r) { MPREAL_UNARY_MATH_FUNCTION_BODY(j1 ); }
-inline const mpreal bessely0(const mpreal& x, mp_rnd_t r) { MPREAL_UNARY_MATH_FUNCTION_BODY(y0 ); }
-inline const mpreal bessely1(const mpreal& x, mp_rnd_t r) { MPREAL_UNARY_MATH_FUNCTION_BODY(y1 ); }
-
-inline const mpreal atan2 (const mpreal& y, const mpreal& x, mp_rnd_t rnd_mode)
+inline const mpreal cbrt (const mpreal& x, mp_rnd_t r = mpreal::get_default_rnd()) { MPREAL_UNARY_MATH_FUNCTION_BODY(cbrt ); }
+inline const mpreal fabs (const mpreal& x, mp_rnd_t r = mpreal::get_default_rnd()) { MPREAL_UNARY_MATH_FUNCTION_BODY(abs ); }
+inline const mpreal abs (const mpreal& x, mp_rnd_t r) { MPREAL_UNARY_MATH_FUNCTION_BODY(abs ); }
+inline const mpreal log (const mpreal& x, mp_rnd_t r = mpreal::get_default_rnd()) { MPREAL_UNARY_MATH_FUNCTION_BODY(log ); }
+inline const mpreal log2 (const mpreal& x, mp_rnd_t r = mpreal::get_default_rnd()) { MPREAL_UNARY_MATH_FUNCTION_BODY(log2 ); }
+inline const mpreal log10 (const mpreal& x, mp_rnd_t r = mpreal::get_default_rnd()) { MPREAL_UNARY_MATH_FUNCTION_BODY(log10); }
+inline const mpreal exp (const mpreal& x, mp_rnd_t r = mpreal::get_default_rnd()) { MPREAL_UNARY_MATH_FUNCTION_BODY(exp ); }
+inline const mpreal exp2 (const mpreal& x, mp_rnd_t r = mpreal::get_default_rnd()) { MPREAL_UNARY_MATH_FUNCTION_BODY(exp2 ); }
+inline const mpreal exp10 (const mpreal& x, mp_rnd_t r = mpreal::get_default_rnd()) { MPREAL_UNARY_MATH_FUNCTION_BODY(exp10); }
+inline const mpreal cos (const mpreal& x, mp_rnd_t r = mpreal::get_default_rnd()) { MPREAL_UNARY_MATH_FUNCTION_BODY(cos ); }
+inline const mpreal sin (const mpreal& x, mp_rnd_t r = mpreal::get_default_rnd()) { MPREAL_UNARY_MATH_FUNCTION_BODY(sin ); }
+inline const mpreal tan (const mpreal& x, mp_rnd_t r = mpreal::get_default_rnd()) { MPREAL_UNARY_MATH_FUNCTION_BODY(tan ); }
+inline const mpreal sec (const mpreal& x, mp_rnd_t r = mpreal::get_default_rnd()) { MPREAL_UNARY_MATH_FUNCTION_BODY(sec ); }
+inline const mpreal csc (const mpreal& x, mp_rnd_t r = mpreal::get_default_rnd()) { MPREAL_UNARY_MATH_FUNCTION_BODY(csc ); }
+inline const mpreal cot (const mpreal& x, mp_rnd_t r = mpreal::get_default_rnd()) { MPREAL_UNARY_MATH_FUNCTION_BODY(cot ); }
+inline const mpreal acos (const mpreal& x, mp_rnd_t r = mpreal::get_default_rnd()) { MPREAL_UNARY_MATH_FUNCTION_BODY(acos ); }
+inline const mpreal asin (const mpreal& x, mp_rnd_t r = mpreal::get_default_rnd()) { MPREAL_UNARY_MATH_FUNCTION_BODY(asin ); }
+inline const mpreal atan (const mpreal& x, mp_rnd_t r = mpreal::get_default_rnd()) { MPREAL_UNARY_MATH_FUNCTION_BODY(atan ); }
+
+inline const mpreal acot (const mpreal& v, mp_rnd_t r = mpreal::get_default_rnd()) { return atan (1/v, r); }
+inline const mpreal asec (const mpreal& v, mp_rnd_t r = mpreal::get_default_rnd()) { return acos (1/v, r); }
+inline const mpreal acsc (const mpreal& v, mp_rnd_t r = mpreal::get_default_rnd()) { return asin (1/v, r); }
+inline const mpreal acoth (const mpreal& v, mp_rnd_t r = mpreal::get_default_rnd()) { return atanh(1/v, r); }
+inline const mpreal asech (const mpreal& v, mp_rnd_t r = mpreal::get_default_rnd()) { return acosh(1/v, r); }
+inline const mpreal acsch (const mpreal& v, mp_rnd_t r = mpreal::get_default_rnd()) { return asinh(1/v, r); }
+
+inline const mpreal cosh (const mpreal& x, mp_rnd_t r = mpreal::get_default_rnd()) { MPREAL_UNARY_MATH_FUNCTION_BODY(cosh ); }
+inline const mpreal sinh (const mpreal& x, mp_rnd_t r = mpreal::get_default_rnd()) { MPREAL_UNARY_MATH_FUNCTION_BODY(sinh ); }
+inline const mpreal tanh (const mpreal& x, mp_rnd_t r = mpreal::get_default_rnd()) { MPREAL_UNARY_MATH_FUNCTION_BODY(tanh ); }
+inline const mpreal sech (const mpreal& x, mp_rnd_t r = mpreal::get_default_rnd()) { MPREAL_UNARY_MATH_FUNCTION_BODY(sech ); }
+inline const mpreal csch (const mpreal& x, mp_rnd_t r = mpreal::get_default_rnd()) { MPREAL_UNARY_MATH_FUNCTION_BODY(csch ); }
+inline const mpreal coth (const mpreal& x, mp_rnd_t r = mpreal::get_default_rnd()) { MPREAL_UNARY_MATH_FUNCTION_BODY(coth ); }
+inline const mpreal acosh (const mpreal& x, mp_rnd_t r = mpreal::get_default_rnd()) { MPREAL_UNARY_MATH_FUNCTION_BODY(acosh); }
+inline const mpreal asinh (const mpreal& x, mp_rnd_t r = mpreal::get_default_rnd()) { MPREAL_UNARY_MATH_FUNCTION_BODY(asinh); }
+inline const mpreal atanh (const mpreal& x, mp_rnd_t r = mpreal::get_default_rnd()) { MPREAL_UNARY_MATH_FUNCTION_BODY(atanh); }
+
+inline const mpreal log1p (const mpreal& x, mp_rnd_t r = mpreal::get_default_rnd()) { MPREAL_UNARY_MATH_FUNCTION_BODY(log1p ); }
+inline const mpreal expm1 (const mpreal& x, mp_rnd_t r = mpreal::get_default_rnd()) { MPREAL_UNARY_MATH_FUNCTION_BODY(expm1 ); }
+inline const mpreal eint (const mpreal& x, mp_rnd_t r = mpreal::get_default_rnd()) { MPREAL_UNARY_MATH_FUNCTION_BODY(eint ); }
+inline const mpreal gamma (const mpreal& x, mp_rnd_t r = mpreal::get_default_rnd()) { MPREAL_UNARY_MATH_FUNCTION_BODY(gamma ); }
+inline const mpreal lngamma (const mpreal& x, mp_rnd_t r = mpreal::get_default_rnd()) { MPREAL_UNARY_MATH_FUNCTION_BODY(lngamma); }
+inline const mpreal zeta (const mpreal& x, mp_rnd_t r = mpreal::get_default_rnd()) { MPREAL_UNARY_MATH_FUNCTION_BODY(zeta ); }
+inline const mpreal erf (const mpreal& x, mp_rnd_t r = mpreal::get_default_rnd()) { MPREAL_UNARY_MATH_FUNCTION_BODY(erf ); }
+inline const mpreal erfc (const mpreal& x, mp_rnd_t r = mpreal::get_default_rnd()) { MPREAL_UNARY_MATH_FUNCTION_BODY(erfc ); }
+inline const mpreal besselj0(const mpreal& x, mp_rnd_t r = mpreal::get_default_rnd()) { MPREAL_UNARY_MATH_FUNCTION_BODY(j0 ); }
+inline const mpreal besselj1(const mpreal& x, mp_rnd_t r = mpreal::get_default_rnd()) { MPREAL_UNARY_MATH_FUNCTION_BODY(j1 ); }
+inline const mpreal bessely0(const mpreal& x, mp_rnd_t r = mpreal::get_default_rnd()) { MPREAL_UNARY_MATH_FUNCTION_BODY(y0 ); }
+inline const mpreal bessely1(const mpreal& x, mp_rnd_t r = mpreal::get_default_rnd()) { MPREAL_UNARY_MATH_FUNCTION_BODY(y1 ); }
+
+inline const mpreal atan2 (const mpreal& y, const mpreal& x, mp_rnd_t rnd_mode = mpreal::get_default_rnd())
{
mpreal a(0,(std::max)(y.getPrecision(), x.getPrecision()));
mpfr_atan2(a.mpfr_ptr(), y.mpfr_srcptr(), x.mpfr_srcptr(), rnd_mode);
return a;
}
-inline const mpreal hypot (const mpreal& x, const mpreal& y, mp_rnd_t rnd_mode)
+inline const mpreal hypot (const mpreal& x, const mpreal& y, mp_rnd_t rnd_mode = mpreal::get_default_rnd())
{
mpreal a(0,(std::max)(y.getPrecision(), x.getPrecision()));
mpfr_hypot(a.mpfr_ptr(), x.mpfr_srcptr(), y.mpfr_srcptr(), rnd_mode);
return a;
}
-inline const mpreal remainder (const mpreal& x, const mpreal& y, mp_rnd_t rnd_mode)
+inline const mpreal remainder (const mpreal& x, const mpreal& y, mp_rnd_t rnd_mode = mpreal::get_default_rnd())
{
mpreal a(0,(std::max)(y.getPrecision(), x.getPrecision()));
mpfr_remainder(a.mpfr_ptr(), x.mpfr_srcptr(), y.mpfr_srcptr(), rnd_mode);
return a;
}
-inline const mpreal remquo (long* q, const mpreal& x, const mpreal& y, mp_rnd_t rnd_mode)
+inline const mpreal remquo (long* q, const mpreal& x, const mpreal& y, mp_rnd_t rnd_mode = mpreal::get_default_rnd())
{
mpreal a(0,(std::max)(y.getPrecision(), x.getPrecision()));
mpfr_remquo(a.mpfr_ptr(),q, x.mpfr_srcptr(), y.mpfr_srcptr(), rnd_mode);
return a;
}
-inline const mpreal fac_ui (unsigned long int v, mp_prec_t prec, mp_rnd_t rnd_mode)
+inline const mpreal fac_ui (unsigned long int v, mp_prec_t prec = mpreal::get_default_prec(),
+ mp_rnd_t rnd_mode = mpreal::get_default_rnd())
{
mpreal x(0, prec);
mpfr_fac_ui(x.mpfr_ptr(),v,rnd_mode);
@@ -2204,33 +2275,33 @@ inline const mpreal fac_ui (unsigned long int v, mp_prec_t prec, mp_rnd_t rnd_mo
}
-inline const mpreal lgamma (const mpreal& v, int *signp, mp_rnd_t rnd_mode)
+inline const mpreal lgamma (const mpreal& v, int *signp = 0, mp_rnd_t rnd_mode = mpreal::get_default_rnd())
{
mpreal x(v);
int tsignp;
- if(signp) mpfr_lgamma(x.mp, signp,v.mp,rnd_mode);
- else mpfr_lgamma(x.mp,&tsignp,v.mp,rnd_mode);
+ if(signp) mpfr_lgamma(x.mpfr_ptr(), signp,v.mpfr_srcptr(),rnd_mode);
+ else mpfr_lgamma(x.mpfr_ptr(),&tsignp,v.mpfr_srcptr(),rnd_mode);
return x;
}
-inline const mpreal besseljn (long n, const mpreal& x, mp_rnd_t r)
+inline const mpreal besseljn (long n, const mpreal& x, mp_rnd_t r = mpreal::get_default_rnd())
{
- mpreal y(0, mpfr_get_prec(x.mpfr_srcptr()));
+ mpreal y(0, x.getPrecision());
mpfr_jn(y.mpfr_ptr(), n, x.mpfr_srcptr(), r);
return y;
}
-inline const mpreal besselyn (long n, const mpreal& x, mp_rnd_t r)
+inline const mpreal besselyn (long n, const mpreal& x, mp_rnd_t r = mpreal::get_default_rnd())
{
- mpreal y(0, mpfr_get_prec(x.mpfr_srcptr()));
+ mpreal y(0, x.getPrecision());
mpfr_yn(y.mpfr_ptr(), n, x.mpfr_srcptr(), r);
return y;
}
-inline const mpreal fma (const mpreal& v1, const mpreal& v2, const mpreal& v3, mp_rnd_t rnd_mode)
+inline const mpreal fma (const mpreal& v1, const mpreal& v2, const mpreal& v3, mp_rnd_t rnd_mode = mpreal::get_default_rnd())
{
mpreal a;
mp_prec_t p1, p2, p3;
@@ -2245,7 +2316,7 @@ inline const mpreal fma (const mpreal& v1, const mpreal& v2, const mpreal& v3, m
return a;
}
-inline const mpreal fms (const mpreal& v1, const mpreal& v2, const mpreal& v3, mp_rnd_t rnd_mode)
+inline const mpreal fms (const mpreal& v1, const mpreal& v2, const mpreal& v3, mp_rnd_t rnd_mode = mpreal::get_default_rnd())
{
mpreal a;
mp_prec_t p1, p2, p3;
@@ -2260,7 +2331,7 @@ inline const mpreal fms (const mpreal& v1, const mpreal& v2, const mpreal& v3, m
return a;
}
-inline const mpreal agm (const mpreal& v1, const mpreal& v2, mp_rnd_t rnd_mode)
+inline const mpreal agm (const mpreal& v1, const mpreal& v2, mp_rnd_t rnd_mode = mpreal::get_default_rnd())
{
mpreal a;
mp_prec_t p1, p2;
@@ -2275,7 +2346,7 @@ inline const mpreal agm (const mpreal& v1, const mpreal& v2, mp_rnd_t rnd_mode)
return a;
}
-inline const mpreal sum (const mpreal tab[], unsigned long int n, mp_rnd_t rnd_mode)
+inline const mpreal sum (const mpreal tab[], unsigned long int n, mp_rnd_t rnd_mode = mpreal::get_default_rnd())
{
mpreal x;
mpfr_ptr* t;
@@ -2292,23 +2363,23 @@ inline const mpreal sum (const mpreal tab[], unsigned long int n, mp_rnd_t rnd_m
// MPFR 2.4.0 Specifics
#if (MPFR_VERSION >= MPFR_VERSION_NUM(2,4,0))
-inline int sinh_cosh(mpreal& s, mpreal& c, const mpreal& v, mp_rnd_t rnd_mode)
+inline int sinh_cosh(mpreal& s, mpreal& c, const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd())
{
return mpfr_sinh_cosh(s.mp,c.mp,v.mp,rnd_mode);
}
-inline const mpreal li2 (const mpreal& x, mp_rnd_t r)
+inline const mpreal li2 (const mpreal& x, mp_rnd_t r = mpreal::get_default_rnd())
{
MPREAL_UNARY_MATH_FUNCTION_BODY(li2);
}
-inline const mpreal rem (const mpreal& x, const mpreal& y, mp_rnd_t rnd_mode)
+inline const mpreal rem (const mpreal& x, const mpreal& y, mp_rnd_t rnd_mode = mpreal::get_default_rnd())
{
/* R = rem(X,Y) if Y != 0, returns X - n * Y where n = trunc(X/Y). */
return fmod(x, y, rnd_mode);
}
-inline const mpreal mod (const mpreal& x, const mpreal& y, mp_rnd_t rnd_mode)
+inline const mpreal mod (const mpreal& x, const mpreal& y, mp_rnd_t rnd_mode = mpreal::get_default_rnd())
{
(void)rnd_mode;
@@ -2333,7 +2404,7 @@ inline const mpreal mod (const mpreal& x, const mpreal& y, mp_rnd_t rnd_mode)
return m;
}
-inline const mpreal fmod (const mpreal& x, const mpreal& y, mp_rnd_t rnd_mode)
+inline const mpreal fmod (const mpreal& x, const mpreal& y, mp_rnd_t rnd_mode = mpreal::get_default_rnd())
{
mpreal a;
mp_prec_t yp, xp;
@@ -2348,7 +2419,7 @@ inline const mpreal fmod (const mpreal& x, const mpreal& y, mp_rnd_t rnd_mode)
return a;
}
-inline const mpreal rec_sqrt(const mpreal& v, mp_rnd_t rnd_mode)
+inline const mpreal rec_sqrt(const mpreal& v, mp_rnd_t rnd_mode = mpreal::get_default_rnd())
{
mpreal x(v);
mpfr_rec_sqrt(x.mp,v.mp,rnd_mode);
@@ -2359,41 +2430,41 @@ inline const mpreal rec_sqrt(const mpreal& v, mp_rnd_t rnd_mode)
//////////////////////////////////////////////////////////////////////////
// MPFR 3.0.0 Specifics
#if (MPFR_VERSION >= MPFR_VERSION_NUM(3,0,0))
-inline const mpreal digamma (const mpreal& x, mp_rnd_t r) { MPREAL_UNARY_MATH_FUNCTION_BODY(digamma); }
-inline const mpreal ai (const mpreal& x, mp_rnd_t r) { MPREAL_UNARY_MATH_FUNCTION_BODY(ai); }
+inline const mpreal digamma (const mpreal& x, mp_rnd_t r = mpreal::get_default_rnd()) { MPREAL_UNARY_MATH_FUNCTION_BODY(digamma); }
+inline const mpreal ai (const mpreal& x, mp_rnd_t r = mpreal::get_default_rnd()) { MPREAL_UNARY_MATH_FUNCTION_BODY(ai); }
#endif // MPFR 3.0.0 Specifics
//////////////////////////////////////////////////////////////////////////
// Constants
-inline const mpreal const_log2 (mp_prec_t p, mp_rnd_t r)
+inline const mpreal const_log2 (mp_prec_t p = mpreal::get_default_prec(), mp_rnd_t r = mpreal::get_default_rnd())
{
mpreal x(0, p);
mpfr_const_log2(x.mpfr_ptr(), r);
return x;
}
-inline const mpreal const_pi (mp_prec_t p, mp_rnd_t r)
+inline const mpreal const_pi (mp_prec_t p = mpreal::get_default_prec(), mp_rnd_t r = mpreal::get_default_rnd())
{
mpreal x(0, p);
mpfr_const_pi(x.mpfr_ptr(), r);
return x;
}
-inline const mpreal const_euler (mp_prec_t p, mp_rnd_t r)
+inline const mpreal const_euler (mp_prec_t p = mpreal::get_default_prec(), mp_rnd_t r = mpreal::get_default_rnd())
{
mpreal x(0, p);
mpfr_const_euler(x.mpfr_ptr(), r);
return x;
}
-inline const mpreal const_catalan (mp_prec_t p, mp_rnd_t r)
+inline const mpreal const_catalan (mp_prec_t p = mpreal::get_default_prec(), mp_rnd_t r = mpreal::get_default_rnd())
{
mpreal x(0, p);
mpfr_const_catalan(x.mpfr_ptr(), r);
return x;
}
-inline const mpreal const_infinity (int sign, mp_prec_t p, mp_rnd_t /*r*/)
+inline const mpreal const_infinity (int sign = 1, mp_prec_t p = mpreal::get_default_prec())
{
mpreal x(0, p);
mpfr_set_inf(x.mpfr_ptr(), sign);
@@ -2430,12 +2501,12 @@ inline const mpreal trunc(const mpreal& v)
return x;
}
-inline const mpreal rint (const mpreal& x, mp_rnd_t r) { MPREAL_UNARY_MATH_FUNCTION_BODY(rint ); }
-inline const mpreal rint_ceil (const mpreal& x, mp_rnd_t r) { MPREAL_UNARY_MATH_FUNCTION_BODY(rint_ceil ); }
-inline const mpreal rint_floor (const mpreal& x, mp_rnd_t r) { MPREAL_UNARY_MATH_FUNCTION_BODY(rint_floor); }
-inline const mpreal rint_round (const mpreal& x, mp_rnd_t r) { MPREAL_UNARY_MATH_FUNCTION_BODY(rint_round); }
-inline const mpreal rint_trunc (const mpreal& x, mp_rnd_t r) { MPREAL_UNARY_MATH_FUNCTION_BODY(rint_trunc); }
-inline const mpreal frac (const mpreal& x, mp_rnd_t r) { MPREAL_UNARY_MATH_FUNCTION_BODY(frac ); }
+inline const mpreal rint (const mpreal& x, mp_rnd_t r = mpreal::get_default_rnd()) { MPREAL_UNARY_MATH_FUNCTION_BODY(rint ); }
+inline const mpreal rint_ceil (const mpreal& x, mp_rnd_t r = mpreal::get_default_rnd()) { MPREAL_UNARY_MATH_FUNCTION_BODY(rint_ceil ); }
+inline const mpreal rint_floor (const mpreal& x, mp_rnd_t r = mpreal::get_default_rnd()) { MPREAL_UNARY_MATH_FUNCTION_BODY(rint_floor); }
+inline const mpreal rint_round (const mpreal& x, mp_rnd_t r = mpreal::get_default_rnd()) { MPREAL_UNARY_MATH_FUNCTION_BODY(rint_round); }
+inline const mpreal rint_trunc (const mpreal& x, mp_rnd_t r = mpreal::get_default_rnd()) { MPREAL_UNARY_MATH_FUNCTION_BODY(rint_trunc); }
+inline const mpreal frac (const mpreal& x, mp_rnd_t r = mpreal::get_default_rnd()) { MPREAL_UNARY_MATH_FUNCTION_BODY(frac ); }
//////////////////////////////////////////////////////////////////////////
// Miscellaneous Functions
@@ -2443,14 +2514,14 @@ inline void swap (mpreal& a, mpreal& b) { mpfr_swap(a.mp,b
inline const mpreal (max)(const mpreal& x, const mpreal& y){ return (x>y?x:y); }
inline const mpreal (min)(const mpreal& x, const mpreal& y){ return (x<y?x:y); }
-inline const mpreal fmax(const mpreal& x, const mpreal& y, mp_rnd_t rnd_mode)
+inline const mpreal fmax(const mpreal& x, const mpreal& y, mp_rnd_t rnd_mode = mpreal::get_default_rnd())
{
mpreal a;
mpfr_max(a.mp,x.mp,y.mp,rnd_mode);
return a;
}
-inline const mpreal fmin(const mpreal& x, const mpreal& y, mp_rnd_t rnd_mode)
+inline const mpreal fmin(const mpreal& x, const mpreal& y, mp_rnd_t rnd_mode = mpreal::get_default_rnd())
{
mpreal a;
mpfr_min(a.mp,x.mp,y.mp,rnd_mode);
@@ -2485,16 +2556,16 @@ inline const mpreal urandomb (gmp_randstate_t& state)
return x;
}
-#if (MPFR_VERSION >= MPFR_VERSION_NUM(3,0,0))
+#if (MPFR_VERSION >= MPFR_VERSION_NUM(3,1,0))
// use gmp_randinit_default() to init state, gmp_randclear() to clear
-inline const mpreal urandom (gmp_randstate_t& state, mp_rnd_t rnd_mode)
+inline const mpreal urandom (gmp_randstate_t& state, mp_rnd_t rnd_mode = mpreal::get_default_rnd())
{
mpreal x;
mpfr_urandom(x.mp,state,rnd_mode);
return x;
}
-inline const mpreal grandom (gmp_randstate_t& state, mp_rnd_t rnd_mode)
+inline const mpreal grandom (gmp_randstate_t& state, mp_rnd_t rnd_mode = mpreal::get_default_rnd())
{
mpreal x;
mpfr_grandom(x.mp, NULL, state, rnd_mode);
@@ -2516,7 +2587,7 @@ inline const mpreal random2 (mp_size_t size, mp_exp_t exp)
// a = random(seed); <- initialization & first random number generation
// a = random(); <- next random numbers generation
// seed != 0
-inline const mpreal random(unsigned int seed)
+inline const mpreal random(unsigned int seed = 0)
{
#if (MPFR_VERSION >= MPFR_VERSION_NUM(3,0,0))
@@ -2541,7 +2612,7 @@ inline const mpreal random(unsigned int seed)
}
#if (MPFR_VERSION >= MPFR_VERSION_NUM(3,0,0))
-inline const mpreal grandom(unsigned int seed)
+inline const mpreal grandom(unsigned int seed = 0)
{
static gmp_randstate_t state;
static bool isFirstTime = true;
@@ -2578,21 +2649,21 @@ inline bool mpreal::fits_in_bits(double x, int n)
return IsInf(x) || (std::modf ( std::ldexp ( std::frexp ( x, &i ), n ), &t ) == 0.0);
}
-inline const mpreal pow(const mpreal& a, const mpreal& b, mp_rnd_t rnd_mode)
+inline const mpreal pow(const mpreal& a, const mpreal& b, mp_rnd_t rnd_mode = mpreal::get_default_rnd())
{
mpreal x(a);
mpfr_pow(x.mp,x.mp,b.mp,rnd_mode);
return x;
}
-inline const mpreal pow(const mpreal& a, const mpz_t b, mp_rnd_t rnd_mode)
+inline const mpreal pow(const mpreal& a, const mpz_t b, mp_rnd_t rnd_mode = mpreal::get_default_rnd())
{
mpreal x(a);
mpfr_pow_z(x.mp,x.mp,b,rnd_mode);
return x;
}
-inline const mpreal pow(const mpreal& a, const unsigned long int b, mp_rnd_t rnd_mode)
+inline const mpreal pow(const mpreal& a, const unsigned long int b, mp_rnd_t rnd_mode = mpreal::get_default_rnd())
{
mpreal x(a);
mpfr_pow_ui(x.mp,x.mp,b,rnd_mode);
@@ -2604,7 +2675,7 @@ inline const mpreal pow(const mpreal& a, const unsigned int b, mp_rnd_t rnd_mode
return pow(a,static_cast<unsigned long int>(b),rnd_mode);
}
-inline const mpreal pow(const mpreal& a, const long int b, mp_rnd_t rnd_mode)
+inline const mpreal pow(const mpreal& a, const long int b, mp_rnd_t rnd_mode = mpreal::get_default_rnd())
{
mpreal x(a);
mpfr_pow_si(x.mp,x.mp,b,rnd_mode);
@@ -2626,7 +2697,7 @@ inline const mpreal pow(const mpreal& a, const double b, mp_rnd_t rnd_mode)
return pow(a,mpreal(b),rnd_mode);
}
-inline const mpreal pow(const unsigned long int a, const mpreal& b, mp_rnd_t rnd_mode)
+inline const mpreal pow(const unsigned long int a, const mpreal& b, mp_rnd_t rnd_mode = mpreal::get_default_rnd())
{
mpreal x(a);
mpfr_ui_pow(x.mp,a,b.mp,rnd_mode);
@@ -2641,13 +2712,13 @@ inline const mpreal pow(const unsigned int a, const mpreal& b, mp_rnd_t rnd_mode
inline const mpreal pow(const long int a, const mpreal& b, mp_rnd_t rnd_mode)
{
if (a>=0) return pow(static_cast<unsigned long int>(a),b,rnd_mode);
- else return pow(mpreal(a),b,rnd_mode);
+ else return pow(mpreal(a),b,rnd_mode);
}
inline const mpreal pow(const int a, const mpreal& b, mp_rnd_t rnd_mode)
{
if (a>=0) return pow(static_cast<unsigned long int>(a),b,rnd_mode);
- else return pow(mpreal(a),b,rnd_mode);
+ else return pow(mpreal(a),b,rnd_mode);
}
inline const mpreal pow(const long double a, const mpreal& b, mp_rnd_t rnd_mode)
@@ -2676,13 +2747,13 @@ inline const mpreal pow(const unsigned long int a, const unsigned int b, mp_rnd_
inline const mpreal pow(const unsigned long int a, const long int b, mp_rnd_t rnd_mode)
{
if(b>0) return pow(a,static_cast<unsigned long int>(b),rnd_mode); //mpfr_ui_pow_ui
- else return pow(a,mpreal(b),rnd_mode); //mpfr_ui_pow
+ else return pow(a,mpreal(b),rnd_mode); //mpfr_ui_pow
}
inline const mpreal pow(const unsigned long int a, const int b, mp_rnd_t rnd_mode)
{
if(b>0) return pow(a,static_cast<unsigned long int>(b),rnd_mode); //mpfr_ui_pow_ui
- else return pow(a,mpreal(b),rnd_mode); //mpfr_ui_pow
+ else return pow(a,mpreal(b),rnd_mode); //mpfr_ui_pow
}
inline const mpreal pow(const unsigned long int a, const long double b, mp_rnd_t rnd_mode)
@@ -2879,7 +2950,7 @@ inline const mpreal pow(const double a, const int b, mp_rnd_t rnd_mode)
// Non-throwing swap C++ idiom: http://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Non-throwing_swap
namespace std
{
- // only allowed to extend namespace std with specializations
+ // we are allowed to extend namespace std with specializations only
template <>
inline void swap(mpfr::mpreal& x, mpfr::mpreal& y)
{
@@ -2907,20 +2978,6 @@ namespace std
static const bool tinyness_before = true;
static const float_denorm_style has_denorm = denorm_absent;
-
- inline static float_round_style round_style()
- {
- mp_rnd_t r = mpfr::mpreal::get_default_rnd();
-
- switch (r)
- {
- case GMP_RNDN: return round_to_nearest;
- case GMP_RNDZ: return round_toward_zero;
- case GMP_RNDU: return round_toward_infinity;
- case GMP_RNDD: return round_toward_neg_infinity;
- default: return round_indeterminate;
- }
- }
inline static mpfr::mpreal (min) (mp_prec_t precision = mpfr::mpreal::get_default_prec()) { return mpfr::minval(precision); }
inline static mpfr::mpreal (max) (mp_prec_t precision = mpfr::mpreal::get_default_prec()) { return mpfr::maxval(precision); }
@@ -2928,7 +2985,7 @@ namespace std
// Returns smallest eps such that 1 + eps != 1 (classic machine epsilon)
inline static mpfr::mpreal epsilon(mp_prec_t precision = mpfr::mpreal::get_default_prec()) { return mpfr::machine_epsilon(precision); }
-
+
// Returns smallest eps such that x + eps != x (relative machine epsilon)
inline static mpfr::mpreal epsilon(const mpfr::mpreal& x) { return mpfr::machine_epsilon(x); }
@@ -2951,10 +3008,30 @@ namespace std
MPREAL_PERMISSIVE_EXPR static const int min_exponent10 = (int) (MPFR_EMIN_DEFAULT * 0.3010299956639811);
MPREAL_PERMISSIVE_EXPR static const int max_exponent10 = (int) (MPFR_EMAX_DEFAULT * 0.3010299956639811);
- // Should be constant according to standard, but 'digits' depends on precision in MPFR
+#ifdef MPREAL_HAVE_DYNAMIC_STD_NUMERIC_LIMITS
+
+ // Following members should be constant according to standard, but they can be variable in MPFR
+ // So we define them as functions here.
+ //
+ // This is preferable way for std::numeric_limits<mpfr::mpreal> specialization.
+ // But it is incompatible with standard std::numeric_limits and might not work with other libraries, e.g. boost.
+ // See below for compatible implementation.
+ inline static float_round_style round_style()
+ {
+ mp_rnd_t r = mpfr::mpreal::get_default_rnd();
+
+ switch (r)
+ {
+ case GMP_RNDN: return round_to_nearest;
+ case GMP_RNDZ: return round_toward_zero;
+ case GMP_RNDU: return round_toward_infinity;
+ case GMP_RNDD: return round_toward_neg_infinity;
+ default: return round_indeterminate;
+ }
+ }
- inline static int digits() { return mpfr::mpreal::get_default_prec(); }
- inline static int digits(const mpfr::mpreal& x) { return x.getPrecision(); }
+ inline static int digits() { return int(mpfr::mpreal::get_default_prec()); }
+ inline static int digits(const mpfr::mpreal& x) { return x.getPrecision(); }
inline static int digits10(mp_prec_t precision = mpfr::mpreal::get_default_prec())
{
@@ -2970,6 +3047,25 @@ namespace std
{
return digits10(precision);
}
+#else
+ // Digits and round_style are NOT constants when it comes to mpreal.
+ // If possible, please use functions digits() and round_style() defined above.
+ //
+ // These (default) values are preserved for compatibility with existing libraries, e.g. boost.
+ // Change them accordingly to your application.
+ //
+ // For example, if you use 256 bits of precision uniformly in your program, then:
+ // digits = 256
+ // digits10 = 77
+ // max_digits10 = 78
+ //
+ // Approximate formula for decimal digits is: digits10 = floor(log10(2) * digits). See bits2digits() for more details.
+
+ static const std::float_round_style round_style = round_to_nearest;
+ static const int digits = 53;
+ static const int digits10 = 15;
+ static const int max_digits10 = 16;
+#endif
};
}
diff --git a/unsupported/test/mpreal_support.cpp b/unsupported/test/mpreal_support.cpp
index bc00382be..1aa9e786a 100644
--- a/unsupported/test/mpreal_support.cpp
+++ b/unsupported/test/mpreal_support.cpp
@@ -32,12 +32,11 @@ void test_mpreal_support()
VERIFY_IS_APPROX(A.array().abs2().sqrt(), A.array().abs());
VERIFY_IS_APPROX(A.array().sin(), sin(A.array()));
VERIFY_IS_APPROX(A.array().cos(), cos(A.array()));
-
// Cholesky
X = S.selfadjointView<Lower>().llt().solve(B);
VERIFY_IS_APPROX((S.selfadjointView<Lower>()*X).eval(),B);
-
+
// partial LU
X = A.lu().solve(B);
VERIFY_IS_APPROX((A*X).eval(),B);
diff --git a/unsupported/test/splines.cpp b/unsupported/test/splines.cpp
index a7eb3e0c4..97665af96 100644
--- a/unsupported/test/splines.cpp
+++ b/unsupported/test/splines.cpp
@@ -13,23 +13,23 @@
namespace Eigen {
-// lets do some explicit instantiations and thus
-// force the compilation of all spline functions...
-template class Spline<double, 2, Dynamic>;
-template class Spline<double, 3, Dynamic>;
+ // lets do some explicit instantiations and thus
+ // force the compilation of all spline functions...
+ template class Spline<double, 2, Dynamic>;
+ template class Spline<double, 3, Dynamic>;
-template class Spline<double, 2, 2>;
-template class Spline<double, 2, 3>;
-template class Spline<double, 2, 4>;
-template class Spline<double, 2, 5>;
+ template class Spline<double, 2, 2>;
+ template class Spline<double, 2, 3>;
+ template class Spline<double, 2, 4>;
+ template class Spline<double, 2, 5>;
-template class Spline<float, 2, Dynamic>;
-template class Spline<float, 3, Dynamic>;
+ template class Spline<float, 2, Dynamic>;
+ template class Spline<float, 3, Dynamic>;
-template class Spline<float, 3, 2>;
-template class Spline<float, 3, 3>;
-template class Spline<float, 3, 4>;
-template class Spline<float, 3, 5>;
+ template class Spline<float, 3, 2>;
+ template class Spline<float, 3, 3>;
+ template class Spline<float, 3, 4>;
+ template class Spline<float, 3, 5>;
}
@@ -234,11 +234,48 @@ void check_global_interpolation2d()
}
}
+void check_global_interpolation_with_derivatives2d()
+{
+ typedef Spline2d::PointType PointType;
+ typedef Spline2d::KnotVectorType KnotVectorType;
+
+ const unsigned int numPoints = 100;
+ const unsigned int dimension = 2;
+ const unsigned int degree = 3;
+
+ ArrayXXd points = ArrayXXd::Random(dimension, numPoints);
+
+ KnotVectorType knots;
+ Eigen::ChordLengths(points, knots);
+
+ ArrayXXd derivatives = ArrayXXd::Random(dimension, numPoints);
+ VectorXd derivativeIndices(numPoints);
+
+ for (Eigen::DenseIndex i = 0; i < numPoints; ++i)
+ derivativeIndices(i) = static_cast<double>(i);
+
+ const Spline2d spline = SplineFitting<Spline2d>::InterpolateWithDerivatives(
+ points, derivatives, derivativeIndices, degree);
+
+ for (Eigen::DenseIndex i = 0; i < points.cols(); ++i)
+ {
+ PointType point = spline(knots(i));
+ PointType referencePoint = points.col(i);
+ VERIFY_IS_APPROX(point, referencePoint);
+ PointType derivative = spline.derivatives(knots(i), 1).col(1);
+ PointType referenceDerivative = derivatives.col(i);
+ VERIFY_IS_APPROX(derivative, referenceDerivative);
+ }
+}
void test_splines()
{
- CALL_SUBTEST( eval_spline3d() );
- CALL_SUBTEST( eval_spline3d_onbrks() );
- CALL_SUBTEST( eval_closed_spline2d() );
- CALL_SUBTEST( check_global_interpolation2d() );
+ for (int i = 0; i < g_repeat; ++i)
+ {
+ CALL_SUBTEST( eval_spline3d() );
+ CALL_SUBTEST( eval_spline3d_onbrks() );
+ CALL_SUBTEST( eval_closed_spline2d() );
+ CALL_SUBTEST( check_global_interpolation2d() );
+ CALL_SUBTEST( check_global_interpolation_with_derivatives2d() );
+ }
}