From 2f6a73db9618b5f4da39852520c89356811e5319 Mon Sep 17 00:00:00 2001 From: PBerger Date: Mon, 19 Nov 2012 02:31:13 +0100 Subject: [PATCH] Fix for last update to Eigen: Delete old files. --- resources/3rdparty/eigen/Eigen/MetisSupport | 26 - resources/3rdparty/eigen/Eigen/SparseLU | 17 - .../eigen/Eigen/src/Core/AssignEvaluator.h | 755 ------- .../eigen/Eigen/src/Core/CoreEvaluators.h | 1299 ------------ .../eigen/Eigen/src/Core/ProductEvaluators.h | 411 ---- resources/3rdparty/eigen/Eigen/src/Core/Ref.h | 254 --- .../src/Eigenvalues/GeneralizedEigenSolver.h | 339 --- .../eigen/Eigen/src/Eigenvalues/RealQZ.h | 618 ------ .../Eigen/src/MetisSupport/CMakeLists.txt | 6 - .../Eigen/src/MetisSupport/MetisSupport.h | 138 -- .../Eigen/src/OrderingMethods/Eigen_Colamd.h | 1849 ----------------- .../Eigen/src/OrderingMethods/Ordering.h | 158 -- .../eigen/Eigen/src/SparseLU/CMakeLists.txt | 6 - .../eigen/Eigen/src/SparseLU/SparseLU.h | 630 ------ .../eigen/Eigen/src/SparseLU/SparseLUBase.h | 74 - .../Eigen/src/SparseLU/SparseLU_Coletree.h | 180 -- .../Eigen/src/SparseLU/SparseLU_Matrix.h | 313 --- .../Eigen/src/SparseLU/SparseLU_Memory.h | 204 -- .../Eigen/src/SparseLU/SparseLU_Structs.h | 103 - .../eigen/Eigen/src/SparseLU/SparseLU_Utils.h | 75 - .../Eigen/src/SparseLU/SparseLU_column_bmod.h | 162 -- .../Eigen/src/SparseLU/SparseLU_column_dfs.h | 164 -- .../src/SparseLU/SparseLU_copy_to_ucol.h | 100 - .../src/SparseLU/SparseLU_heap_relax_snode.h | 119 -- .../Eigen/src/SparseLU/SparseLU_kernel_bmod.h | 109 - .../Eigen/src/SparseLU/SparseLU_panel_bmod.h | 204 -- .../Eigen/src/SparseLU/SparseLU_panel_dfs.h | 247 --- .../Eigen/src/SparseLU/SparseLU_pivotL.h | 125 -- .../Eigen/src/SparseLU/SparseLU_pruneL.h | 129 -- .../Eigen/src/SparseLU/SparseLU_relax_snode.h | 73 - .../Eigen/src/SparseLU/SparseLU_snode_bmod.h | 72 - .../Eigen/src/SparseLU/SparseLU_snode_dfs.h | 95 - .../eigen/bench/spbench/sp_solver.cpp | 125 -- .../3rdparty/eigen/bench/spbench/spbench.dtd | 31 - .../eigen/bench/spbench/spbenchstyle.h | 94 - .../eigen/bench/spbench/test_sparseLU.cpp | 93 - .../3rdparty/eigen/blas/GeneralRank1Update.h | 44 - .../eigen/blas/PackedSelfadjointProduct.h | 54 - .../eigen/blas/PackedTriangularMatrixVector.h | 79 - .../eigen/blas/PackedTriangularSolverVector.h | 88 - resources/3rdparty/eigen/blas/Rank2Update.h | 57 - .../eigen/doc/I17_SparseLinearSystems.dox | 110 - .../doc/snippets/GeneralizedEigenSolver.cpp | 7 - .../snippets/HouseholderQR_householderQ.cpp | 7 - .../eigen/doc/snippets/RealQZ_compute.cpp | 17 - .../test/eigensolver_generalized_real.cpp | 63 - resources/3rdparty/eigen/test/evaluators.cpp | 321 --- resources/3rdparty/eigen/test/real_qz.cpp | 69 - resources/3rdparty/eigen/test/sparselu.cpp | 43 - .../src/IterativeSolvers/IncompleteCholesky.h | 221 -- .../Eigen/src/MatrixFunctions/MatrixPower.h | 386 ---- .../src/MatrixFunctions/MatrixPowerBase.h | 359 ---- .../unsupported/doc/examples/MatrixPower.cpp | 16 - .../doc/examples/MatrixPower_optimal.cpp | 17 - .../eigen/unsupported/test/matrix_functions.h | 47 - .../eigen/unsupported/test/matrix_power.cpp | 136 -- 56 files changed, 11538 deletions(-) delete mode 100644 resources/3rdparty/eigen/Eigen/MetisSupport delete mode 100644 resources/3rdparty/eigen/Eigen/SparseLU delete mode 100644 resources/3rdparty/eigen/Eigen/src/Core/AssignEvaluator.h delete mode 100644 resources/3rdparty/eigen/Eigen/src/Core/CoreEvaluators.h delete mode 100644 resources/3rdparty/eigen/Eigen/src/Core/ProductEvaluators.h delete mode 100644 resources/3rdparty/eigen/Eigen/src/Core/Ref.h delete mode 100644 resources/3rdparty/eigen/Eigen/src/Eigenvalues/GeneralizedEigenSolver.h delete mode 100644 resources/3rdparty/eigen/Eigen/src/Eigenvalues/RealQZ.h delete mode 100644 resources/3rdparty/eigen/Eigen/src/MetisSupport/CMakeLists.txt delete mode 100644 resources/3rdparty/eigen/Eigen/src/MetisSupport/MetisSupport.h delete mode 100644 resources/3rdparty/eigen/Eigen/src/OrderingMethods/Eigen_Colamd.h delete mode 100644 resources/3rdparty/eigen/Eigen/src/OrderingMethods/Ordering.h delete mode 100644 resources/3rdparty/eigen/Eigen/src/SparseLU/CMakeLists.txt delete mode 100644 resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU.h delete mode 100644 resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLUBase.h delete mode 100644 resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_Coletree.h delete mode 100644 resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_Matrix.h delete mode 100644 resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_Memory.h delete mode 100644 resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_Structs.h delete mode 100644 resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_Utils.h delete mode 100644 resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_column_bmod.h delete mode 100644 resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_column_dfs.h delete mode 100644 resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_copy_to_ucol.h delete mode 100644 resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_heap_relax_snode.h delete mode 100644 resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_kernel_bmod.h delete mode 100644 resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_panel_bmod.h delete mode 100644 resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_panel_dfs.h delete mode 100644 resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_pivotL.h delete mode 100644 resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_pruneL.h delete mode 100644 resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_relax_snode.h delete mode 100644 resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_snode_bmod.h delete mode 100644 resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_snode_dfs.h delete mode 100644 resources/3rdparty/eigen/bench/spbench/sp_solver.cpp delete mode 100644 resources/3rdparty/eigen/bench/spbench/spbench.dtd delete mode 100644 resources/3rdparty/eigen/bench/spbench/spbenchstyle.h delete mode 100644 resources/3rdparty/eigen/bench/spbench/test_sparseLU.cpp delete mode 100644 resources/3rdparty/eigen/blas/GeneralRank1Update.h delete mode 100644 resources/3rdparty/eigen/blas/PackedSelfadjointProduct.h delete mode 100644 resources/3rdparty/eigen/blas/PackedTriangularMatrixVector.h delete mode 100644 resources/3rdparty/eigen/blas/PackedTriangularSolverVector.h delete mode 100644 resources/3rdparty/eigen/blas/Rank2Update.h delete mode 100644 resources/3rdparty/eigen/doc/I17_SparseLinearSystems.dox delete mode 100644 resources/3rdparty/eigen/doc/snippets/GeneralizedEigenSolver.cpp delete mode 100644 resources/3rdparty/eigen/doc/snippets/HouseholderQR_householderQ.cpp delete mode 100644 resources/3rdparty/eigen/doc/snippets/RealQZ_compute.cpp delete mode 100644 resources/3rdparty/eigen/test/eigensolver_generalized_real.cpp delete mode 100644 resources/3rdparty/eigen/test/evaluators.cpp delete mode 100644 resources/3rdparty/eigen/test/real_qz.cpp delete mode 100644 resources/3rdparty/eigen/test/sparselu.cpp delete mode 100644 resources/3rdparty/eigen/unsupported/Eigen/src/IterativeSolvers/IncompleteCholesky.h delete mode 100644 resources/3rdparty/eigen/unsupported/Eigen/src/MatrixFunctions/MatrixPower.h delete mode 100644 resources/3rdparty/eigen/unsupported/Eigen/src/MatrixFunctions/MatrixPowerBase.h delete mode 100644 resources/3rdparty/eigen/unsupported/doc/examples/MatrixPower.cpp delete mode 100644 resources/3rdparty/eigen/unsupported/doc/examples/MatrixPower_optimal.cpp delete mode 100644 resources/3rdparty/eigen/unsupported/test/matrix_functions.h delete mode 100644 resources/3rdparty/eigen/unsupported/test/matrix_power.cpp diff --git a/resources/3rdparty/eigen/Eigen/MetisSupport b/resources/3rdparty/eigen/Eigen/MetisSupport deleted file mode 100644 index a44086ad9..000000000 --- a/resources/3rdparty/eigen/Eigen/MetisSupport +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef EIGEN_METISSUPPORT_MODULE_H -#define EIGEN_METISSUPPORT_MODULE_H - -#include "SparseCore" - -#include "src/Core/util/DisableStupidWarnings.h" - -extern "C" { -#include -} - - -/** \ingroup Support_modules - * \defgroup MetisSupport_Module MetisSupport module - * - * \code - * #include - * \endcode - */ - - -#include "src/MetisSupport/MetisSupport.h" - -#include "src/Core/util/ReenableStupidWarnings.h" - -#endif // EIGEN_METISSUPPORT_MODULE_H diff --git a/resources/3rdparty/eigen/Eigen/SparseLU b/resources/3rdparty/eigen/Eigen/SparseLU deleted file mode 100644 index 452bc9f83..000000000 --- a/resources/3rdparty/eigen/Eigen/SparseLU +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef EIGEN_SPARSELU_MODULE_H -#define EIGEN_SPARSELU_MODULE_H - -#include "SparseCore" - - -/** \ingroup Sparse_modules - * \defgroup SparseLU_Module SparseLU module - * - */ - -// Ordering interface -#include "OrderingMethods" - -#include "src/SparseLU/SparseLU.h" - -#endif // EIGEN_SPARSELU_MODULE_H diff --git a/resources/3rdparty/eigen/Eigen/src/Core/AssignEvaluator.h b/resources/3rdparty/eigen/Eigen/src/Core/AssignEvaluator.h deleted file mode 100644 index 5e134c83a..000000000 --- a/resources/3rdparty/eigen/Eigen/src/Core/AssignEvaluator.h +++ /dev/null @@ -1,755 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2011 Benoit Jacob -// Copyright (C) 2011 Gael Guennebaud -// Copyright (C) 2011-2012 Jitse Niesen -// -// 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_ASSIGN_EVALUATOR_H -#define EIGEN_ASSIGN_EVALUATOR_H - -namespace Eigen { - -// This implementation is based on Assign.h - -namespace internal { - -/*************************************************************************** -* Part 1 : the logic deciding a strategy for traversal and unrolling * -***************************************************************************/ - -// copy_using_evaluator_traits is based on assign_traits - -template -struct copy_using_evaluator_traits -{ -public: - enum { - DstIsAligned = Derived::Flags & AlignedBit, - DstHasDirectAccess = Derived::Flags & DirectAccessBit, - SrcIsAligned = OtherDerived::Flags & AlignedBit, - JointAlignment = bool(DstIsAligned) && bool(SrcIsAligned) ? Aligned : Unaligned, - SrcEvalBeforeAssign = (evaluator_traits::HasEvalTo == 1) - }; - -private: - enum { - InnerSize = int(Derived::IsVectorAtCompileTime) ? int(Derived::SizeAtCompileTime) - : int(Derived::Flags)&RowMajorBit ? int(Derived::ColsAtCompileTime) - : int(Derived::RowsAtCompileTime), - InnerMaxSize = int(Derived::IsVectorAtCompileTime) ? int(Derived::MaxSizeAtCompileTime) - : int(Derived::Flags)&RowMajorBit ? int(Derived::MaxColsAtCompileTime) - : int(Derived::MaxRowsAtCompileTime), - MaxSizeAtCompileTime = Derived::SizeAtCompileTime, - PacketSize = packet_traits::size - }; - - enum { - StorageOrdersAgree = (int(Derived::IsRowMajor) == int(OtherDerived::IsRowMajor)), - MightVectorize = StorageOrdersAgree - && (int(Derived::Flags) & int(OtherDerived::Flags) & ActualPacketAccessBit), - MayInnerVectorize = MightVectorize && int(InnerSize)!=Dynamic && int(InnerSize)%int(PacketSize)==0 - && int(DstIsAligned) && int(SrcIsAligned), - MayLinearize = StorageOrdersAgree && (int(Derived::Flags) & int(OtherDerived::Flags) & LinearAccessBit), - MayLinearVectorize = MightVectorize && MayLinearize && DstHasDirectAccess - && (DstIsAligned || MaxSizeAtCompileTime == Dynamic), - /* If the destination isn't aligned, we have to do runtime checks and we don't unroll, - so it's only good for large enough sizes. */ - MaySliceVectorize = MightVectorize && DstHasDirectAccess - && (int(InnerMaxSize)==Dynamic || int(InnerMaxSize)>=3*PacketSize) - /* slice vectorization can be slow, so we only want it if the slices are big, which is - indicated by InnerMaxSize rather than InnerSize, think of the case of a dynamic block - in a fixed-size matrix */ - }; - -public: - enum { - Traversal = int(SrcEvalBeforeAssign) ? int(AllAtOnceTraversal) - : int(MayInnerVectorize) ? int(InnerVectorizedTraversal) - : int(MayLinearVectorize) ? int(LinearVectorizedTraversal) - : int(MaySliceVectorize) ? int(SliceVectorizedTraversal) - : int(MayLinearize) ? int(LinearTraversal) - : int(DefaultTraversal), - Vectorized = int(Traversal) == InnerVectorizedTraversal - || int(Traversal) == LinearVectorizedTraversal - || int(Traversal) == SliceVectorizedTraversal - }; - -private: - enum { - UnrollingLimit = EIGEN_UNROLLING_LIMIT * (Vectorized ? int(PacketSize) : 1), - MayUnrollCompletely = int(Derived::SizeAtCompileTime) != Dynamic - && int(OtherDerived::CoeffReadCost) != Dynamic - && int(Derived::SizeAtCompileTime) * int(OtherDerived::CoeffReadCost) <= int(UnrollingLimit), - MayUnrollInner = int(InnerSize) != Dynamic - && int(OtherDerived::CoeffReadCost) != Dynamic - && int(InnerSize) * int(OtherDerived::CoeffReadCost) <= int(UnrollingLimit) - }; - -public: - enum { - Unrolling = (int(Traversal) == int(InnerVectorizedTraversal) || int(Traversal) == int(DefaultTraversal)) - ? ( - int(MayUnrollCompletely) ? int(CompleteUnrolling) - : int(MayUnrollInner) ? int(InnerUnrolling) - : int(NoUnrolling) - ) - : int(Traversal) == int(LinearVectorizedTraversal) - ? ( bool(MayUnrollCompletely) && bool(DstIsAligned) ? int(CompleteUnrolling) - : int(NoUnrolling) ) - : int(Traversal) == int(LinearTraversal) - ? ( bool(MayUnrollCompletely) ? int(CompleteUnrolling) - : int(NoUnrolling) ) - : int(NoUnrolling) - }; - -#ifdef EIGEN_DEBUG_ASSIGN - static void debug() - { - EIGEN_DEBUG_VAR(DstIsAligned) - EIGEN_DEBUG_VAR(SrcIsAligned) - EIGEN_DEBUG_VAR(JointAlignment) - EIGEN_DEBUG_VAR(InnerSize) - EIGEN_DEBUG_VAR(InnerMaxSize) - EIGEN_DEBUG_VAR(PacketSize) - EIGEN_DEBUG_VAR(StorageOrdersAgree) - EIGEN_DEBUG_VAR(MightVectorize) - EIGEN_DEBUG_VAR(MayLinearize) - EIGEN_DEBUG_VAR(MayInnerVectorize) - EIGEN_DEBUG_VAR(MayLinearVectorize) - EIGEN_DEBUG_VAR(MaySliceVectorize) - EIGEN_DEBUG_VAR(Traversal) - EIGEN_DEBUG_VAR(UnrollingLimit) - EIGEN_DEBUG_VAR(MayUnrollCompletely) - EIGEN_DEBUG_VAR(MayUnrollInner) - EIGEN_DEBUG_VAR(Unrolling) - } -#endif -}; - -/*************************************************************************** -* Part 2 : meta-unrollers -***************************************************************************/ - -/************************ -*** Default traversal *** -************************/ - -template -struct copy_using_evaluator_DefaultTraversal_CompleteUnrolling -{ - typedef typename DstEvaluatorType::XprType DstXprType; - - enum { - outer = Index / DstXprType::InnerSizeAtCompileTime, - inner = Index % DstXprType::InnerSizeAtCompileTime - }; - - EIGEN_STRONG_INLINE static void run(DstEvaluatorType &dstEvaluator, - SrcEvaluatorType &srcEvaluator) - { - dstEvaluator.copyCoeffByOuterInner(outer, inner, srcEvaluator); - copy_using_evaluator_DefaultTraversal_CompleteUnrolling - - ::run(dstEvaluator, srcEvaluator); - } -}; - -template -struct copy_using_evaluator_DefaultTraversal_CompleteUnrolling -{ - EIGEN_STRONG_INLINE static void run(DstEvaluatorType&, SrcEvaluatorType&) { } -}; - -template -struct copy_using_evaluator_DefaultTraversal_InnerUnrolling -{ - EIGEN_STRONG_INLINE static void run(DstEvaluatorType &dstEvaluator, - SrcEvaluatorType &srcEvaluator, - int outer) - { - dstEvaluator.copyCoeffByOuterInner(outer, Index, srcEvaluator); - copy_using_evaluator_DefaultTraversal_InnerUnrolling - - ::run(dstEvaluator, srcEvaluator, outer); - } -}; - -template -struct copy_using_evaluator_DefaultTraversal_InnerUnrolling -{ - EIGEN_STRONG_INLINE static void run(DstEvaluatorType&, SrcEvaluatorType&, int) { } -}; - -/*********************** -*** Linear traversal *** -***********************/ - -template -struct copy_using_evaluator_LinearTraversal_CompleteUnrolling -{ - EIGEN_STRONG_INLINE static void run(DstEvaluatorType &dstEvaluator, - SrcEvaluatorType &srcEvaluator) - { - dstEvaluator.copyCoeff(Index, srcEvaluator); - copy_using_evaluator_LinearTraversal_CompleteUnrolling - - ::run(dstEvaluator, srcEvaluator); - } -}; - -template -struct copy_using_evaluator_LinearTraversal_CompleteUnrolling -{ - EIGEN_STRONG_INLINE static void run(DstEvaluatorType&, SrcEvaluatorType&) { } -}; - -/************************** -*** Inner vectorization *** -**************************/ - -template -struct copy_using_evaluator_innervec_CompleteUnrolling -{ - typedef typename DstEvaluatorType::XprType DstXprType; - typedef typename SrcEvaluatorType::XprType SrcXprType; - - enum { - outer = Index / DstXprType::InnerSizeAtCompileTime, - inner = Index % DstXprType::InnerSizeAtCompileTime, - JointAlignment = copy_using_evaluator_traits::JointAlignment - }; - - EIGEN_STRONG_INLINE static void run(DstEvaluatorType &dstEvaluator, - SrcEvaluatorType &srcEvaluator) - { - dstEvaluator.template copyPacketByOuterInner(outer, inner, srcEvaluator); - enum { NextIndex = Index + packet_traits::size }; - copy_using_evaluator_innervec_CompleteUnrolling - - ::run(dstEvaluator, srcEvaluator); - } -}; - -template -struct copy_using_evaluator_innervec_CompleteUnrolling -{ - EIGEN_STRONG_INLINE static void run(DstEvaluatorType&, SrcEvaluatorType&) { } -}; - -template -struct copy_using_evaluator_innervec_InnerUnrolling -{ - EIGEN_STRONG_INLINE static void run(DstEvaluatorType &dstEvaluator, - SrcEvaluatorType &srcEvaluator, - int outer) - { - dstEvaluator.template copyPacketByOuterInner(outer, Index, srcEvaluator); - typedef typename DstEvaluatorType::XprType DstXprType; - enum { NextIndex = Index + packet_traits::size }; - copy_using_evaluator_innervec_InnerUnrolling - - ::run(dstEvaluator, srcEvaluator, outer); - } -}; - -template -struct copy_using_evaluator_innervec_InnerUnrolling -{ - EIGEN_STRONG_INLINE static void run(DstEvaluatorType&, SrcEvaluatorType&, int) { } -}; - -/*************************************************************************** -* Part 3 : implementation of all cases -***************************************************************************/ - -// copy_using_evaluator_impl is based on assign_impl - -template::Traversal, - int Unrolling = copy_using_evaluator_traits::Unrolling> -struct copy_using_evaluator_impl; - -/************************ -*** Default traversal *** -************************/ - -template -struct copy_using_evaluator_impl -{ - static void run(DstXprType& dst, const SrcXprType& src) - { - typedef typename evaluator::type DstEvaluatorType; - typedef typename evaluator::type SrcEvaluatorType; - typedef typename DstXprType::Index Index; - - DstEvaluatorType dstEvaluator(dst); - SrcEvaluatorType srcEvaluator(src); - - for(Index outer = 0; outer < dst.outerSize(); ++outer) { - for(Index inner = 0; inner < dst.innerSize(); ++inner) { - dstEvaluator.copyCoeffByOuterInner(outer, inner, srcEvaluator); - } - } - } -}; - -template -struct copy_using_evaluator_impl -{ - EIGEN_STRONG_INLINE static void run(DstXprType &dst, const SrcXprType &src) - { - typedef typename evaluator::type DstEvaluatorType; - typedef typename evaluator::type SrcEvaluatorType; - - DstEvaluatorType dstEvaluator(dst); - SrcEvaluatorType srcEvaluator(src); - - copy_using_evaluator_DefaultTraversal_CompleteUnrolling - - ::run(dstEvaluator, srcEvaluator); - } -}; - -template -struct copy_using_evaluator_impl -{ - typedef typename DstXprType::Index Index; - EIGEN_STRONG_INLINE static void run(DstXprType &dst, const SrcXprType &src) - { - typedef typename evaluator::type DstEvaluatorType; - typedef typename evaluator::type SrcEvaluatorType; - - DstEvaluatorType dstEvaluator(dst); - SrcEvaluatorType srcEvaluator(src); - - const Index outerSize = dst.outerSize(); - for(Index outer = 0; outer < outerSize; ++outer) - copy_using_evaluator_DefaultTraversal_InnerUnrolling - - ::run(dstEvaluator, srcEvaluator, outer); - } -}; - -/*************************** -*** Linear vectorization *** -***************************/ - -template -struct unaligned_copy_using_evaluator_impl -{ - // if IsAligned = true, then do nothing - template - static EIGEN_STRONG_INLINE void run(const SrcEvaluatorType&, DstEvaluatorType&, - typename SrcEvaluatorType::Index, typename SrcEvaluatorType::Index) {} -}; - -template <> -struct unaligned_copy_using_evaluator_impl -{ - // MSVC must not inline this functions. If it does, it fails to optimize the - // packet access path. -#ifdef _MSC_VER - template - static EIGEN_DONT_INLINE void run(DstEvaluatorType &dstEvaluator, - const SrcEvaluatorType &srcEvaluator, - typename DstEvaluatorType::Index start, - typename DstEvaluatorType::Index end) -#else - template - static EIGEN_STRONG_INLINE void run(DstEvaluatorType &dstEvaluator, - const SrcEvaluatorType &srcEvaluator, - typename DstEvaluatorType::Index start, - typename DstEvaluatorType::Index end) -#endif - { - for (typename DstEvaluatorType::Index index = start; index < end; ++index) - dstEvaluator.copyCoeff(index, srcEvaluator); - } -}; - -template -struct copy_using_evaluator_impl -{ - EIGEN_STRONG_INLINE static void run(DstXprType &dst, const SrcXprType &src) - { - typedef typename evaluator::type DstEvaluatorType; - typedef typename evaluator::type SrcEvaluatorType; - typedef typename DstXprType::Index Index; - - DstEvaluatorType dstEvaluator(dst); - SrcEvaluatorType srcEvaluator(src); - - const Index size = dst.size(); - typedef packet_traits PacketTraits; - enum { - packetSize = PacketTraits::size, - dstIsAligned = int(copy_using_evaluator_traits::DstIsAligned), - dstAlignment = PacketTraits::AlignedOnScalar ? Aligned : dstIsAligned, - srcAlignment = copy_using_evaluator_traits::JointAlignment - }; - const Index alignedStart = dstIsAligned ? 0 : first_aligned(&dstEvaluator.coeffRef(0), size); - const Index alignedEnd = alignedStart + ((size-alignedStart)/packetSize)*packetSize; - - unaligned_copy_using_evaluator_impl::run(dstEvaluator, srcEvaluator, 0, alignedStart); - - for(Index index = alignedStart; index < alignedEnd; index += packetSize) - { - dstEvaluator.template copyPacket(index, srcEvaluator); - } - - unaligned_copy_using_evaluator_impl<>::run(dstEvaluator, srcEvaluator, alignedEnd, size); - } -}; - -template -struct copy_using_evaluator_impl -{ - typedef typename DstXprType::Index Index; - EIGEN_STRONG_INLINE static void run(DstXprType &dst, const SrcXprType &src) - { - typedef typename evaluator::type DstEvaluatorType; - typedef typename evaluator::type SrcEvaluatorType; - - DstEvaluatorType dstEvaluator(dst); - SrcEvaluatorType srcEvaluator(src); - - enum { size = DstXprType::SizeAtCompileTime, - packetSize = packet_traits::size, - alignedSize = (size/packetSize)*packetSize }; - - copy_using_evaluator_innervec_CompleteUnrolling - - ::run(dstEvaluator, srcEvaluator); - copy_using_evaluator_DefaultTraversal_CompleteUnrolling - - ::run(dstEvaluator, srcEvaluator); - } -}; - -/************************** -*** Inner vectorization *** -**************************/ - -template -struct copy_using_evaluator_impl -{ - inline static void run(DstXprType &dst, const SrcXprType &src) - { - typedef typename evaluator::type DstEvaluatorType; - typedef typename evaluator::type SrcEvaluatorType; - typedef typename DstXprType::Index Index; - - DstEvaluatorType dstEvaluator(dst); - SrcEvaluatorType srcEvaluator(src); - - const Index innerSize = dst.innerSize(); - const Index outerSize = dst.outerSize(); - const Index packetSize = packet_traits::size; - for(Index outer = 0; outer < outerSize; ++outer) - for(Index inner = 0; inner < innerSize; inner+=packetSize) { - dstEvaluator.template copyPacketByOuterInner(outer, inner, srcEvaluator); - } - } -}; - -template -struct copy_using_evaluator_impl -{ - EIGEN_STRONG_INLINE static void run(DstXprType &dst, const SrcXprType &src) - { - typedef typename evaluator::type DstEvaluatorType; - typedef typename evaluator::type SrcEvaluatorType; - - DstEvaluatorType dstEvaluator(dst); - SrcEvaluatorType srcEvaluator(src); - - copy_using_evaluator_innervec_CompleteUnrolling - - ::run(dstEvaluator, srcEvaluator); - } -}; - -template -struct copy_using_evaluator_impl -{ - typedef typename DstXprType::Index Index; - EIGEN_STRONG_INLINE static void run(DstXprType &dst, const SrcXprType &src) - { - typedef typename evaluator::type DstEvaluatorType; - typedef typename evaluator::type SrcEvaluatorType; - - DstEvaluatorType dstEvaluator(dst); - SrcEvaluatorType srcEvaluator(src); - - const Index outerSize = dst.outerSize(); - for(Index outer = 0; outer < outerSize; ++outer) - copy_using_evaluator_innervec_InnerUnrolling - - ::run(dstEvaluator, srcEvaluator, outer); - } -}; - -/*********************** -*** Linear traversal *** -***********************/ - -template -struct copy_using_evaluator_impl -{ - inline static void run(DstXprType &dst, const SrcXprType &src) - { - typedef typename evaluator::type DstEvaluatorType; - typedef typename evaluator::type SrcEvaluatorType; - typedef typename DstXprType::Index Index; - - DstEvaluatorType dstEvaluator(dst); - SrcEvaluatorType srcEvaluator(src); - - const Index size = dst.size(); - for(Index i = 0; i < size; ++i) - dstEvaluator.copyCoeff(i, srcEvaluator); - } -}; - -template -struct copy_using_evaluator_impl -{ - EIGEN_STRONG_INLINE static void run(DstXprType &dst, const SrcXprType &src) - { - typedef typename evaluator::type DstEvaluatorType; - typedef typename evaluator::type SrcEvaluatorType; - - DstEvaluatorType dstEvaluator(dst); - SrcEvaluatorType srcEvaluator(src); - - copy_using_evaluator_LinearTraversal_CompleteUnrolling - - ::run(dstEvaluator, srcEvaluator); - } -}; - -/************************** -*** Slice vectorization *** -***************************/ - -template -struct copy_using_evaluator_impl -{ - inline static void run(DstXprType &dst, const SrcXprType &src) - { - typedef typename evaluator::type DstEvaluatorType; - typedef typename evaluator::type SrcEvaluatorType; - typedef typename DstXprType::Index Index; - - DstEvaluatorType dstEvaluator(dst); - SrcEvaluatorType srcEvaluator(src); - - typedef packet_traits PacketTraits; - enum { - packetSize = PacketTraits::size, - alignable = PacketTraits::AlignedOnScalar, - dstAlignment = alignable ? Aligned : int(copy_using_evaluator_traits::DstIsAligned) - }; - const Index packetAlignedMask = packetSize - 1; - const Index innerSize = dst.innerSize(); - const Index outerSize = dst.outerSize(); - const Index alignedStep = alignable ? (packetSize - dst.outerStride() % packetSize) & packetAlignedMask : 0; - Index alignedStart = ((!alignable) || copy_using_evaluator_traits::DstIsAligned) ? 0 - : first_aligned(&dstEvaluator.coeffRef(0,0), innerSize); - - for(Index outer = 0; outer < outerSize; ++outer) - { - const Index alignedEnd = alignedStart + ((innerSize-alignedStart) & ~packetAlignedMask); - // do the non-vectorizable part of the assignment - for(Index inner = 0; inner(outer, inner, srcEvaluator); - } - - // do the non-vectorizable part of the assignment - for(Index inner = alignedEnd; inner((alignedStart+alignedStep)%packetSize, innerSize); - } - } -}; - -/**************************** -*** All-at-once traversal *** -****************************/ - -template -struct copy_using_evaluator_impl -{ - inline static void run(DstXprType &dst, const SrcXprType &src) - { - typedef typename evaluator::type DstEvaluatorType; - typedef typename evaluator::type SrcEvaluatorType; - typedef typename DstXprType::Index Index; - - DstEvaluatorType dstEvaluator(dst); - SrcEvaluatorType srcEvaluator(src); - - // Evaluate rhs in temporary to prevent aliasing problems in a = a * a; - // TODO: Do not pass the xpr object to evalTo() - srcEvaluator.evalTo(dstEvaluator, dst); - } -}; - -/*************************************************************************** -* Part 4 : Entry points -***************************************************************************/ - -// Based on DenseBase::LazyAssign() - -template class StorageBase, typename SrcXprType> -EIGEN_STRONG_INLINE -const DstXprType& copy_using_evaluator(const NoAlias& dst, - const EigenBase& src) -{ - return noalias_copy_using_evaluator(dst.expression(), src.derived()); -} - -template::AssumeAliasing> -struct AddEvalIfAssumingAliasing; - -template -struct AddEvalIfAssumingAliasing -{ - static const XprType& run(const XprType& xpr) - { - return xpr; - } -}; - -template -struct AddEvalIfAssumingAliasing -{ - static const EvalToTemp run(const XprType& xpr) - { - return EvalToTemp(xpr); - } -}; - -template -EIGEN_STRONG_INLINE -const DstXprType& copy_using_evaluator(const EigenBase& dst, const EigenBase& src) -{ - return noalias_copy_using_evaluator(dst.const_cast_derived(), - AddEvalIfAssumingAliasing::run(src.derived())); -} - -template -EIGEN_STRONG_INLINE -const DstXprType& noalias_copy_using_evaluator(const PlainObjectBase& dst, const EigenBase& src) -{ -#ifdef EIGEN_DEBUG_ASSIGN - internal::copy_using_evaluator_traits::debug(); -#endif -#ifdef EIGEN_NO_AUTOMATIC_RESIZING - eigen_assert((dst.size()==0 || (IsVectorAtCompileTime ? (dst.size() == src.size()) - : (dst.rows() == src.rows() && dst.cols() == src.cols()))) - && "Size mismatch. Automatic resizing is disabled because EIGEN_NO_AUTOMATIC_RESIZING is defined"); -#else - dst.const_cast_derived().resizeLike(src.derived()); -#endif - return copy_using_evaluator_without_resizing(dst.const_cast_derived(), src.derived()); -} - -template -EIGEN_STRONG_INLINE -const DstXprType& noalias_copy_using_evaluator(const EigenBase& dst, const EigenBase& src) -{ - return copy_using_evaluator_without_resizing(dst.const_cast_derived(), src.derived()); -} - -template -const DstXprType& copy_using_evaluator_without_resizing(const DstXprType& dst, const SrcXprType& src) -{ -#ifdef EIGEN_DEBUG_ASSIGN - internal::copy_using_evaluator_traits::debug(); -#endif - eigen_assert(dst.rows() == src.rows() && dst.cols() == src.cols()); - copy_using_evaluator_impl::run(const_cast(dst), src); - return dst; -} - -// Based on DenseBase::swap() -// TODO: Chech whether we need to do something special for swapping two -// Arrays or Matrices. - -template -void swap_using_evaluator(const DstXprType& dst, const SrcXprType& src) -{ - copy_using_evaluator(SwapWrapper(const_cast(dst)), src); -} - -// Based on MatrixBase::operator+= (in CwiseBinaryOp.h) -template -void add_assign_using_evaluator(const MatrixBase& dst, const MatrixBase& src) -{ - typedef typename DstXprType::Scalar Scalar; - SelfCwiseBinaryOp, DstXprType, SrcXprType> tmp(dst.const_cast_derived()); - copy_using_evaluator(tmp, src.derived()); -} - -// Based on ArrayBase::operator+= -template -void add_assign_using_evaluator(const ArrayBase& dst, const ArrayBase& src) -{ - typedef typename DstXprType::Scalar Scalar; - SelfCwiseBinaryOp, DstXprType, SrcXprType> tmp(dst.const_cast_derived()); - copy_using_evaluator(tmp, src.derived()); -} - -// TODO: Add add_assign_using_evaluator for EigenBase ? - -template -void subtract_assign_using_evaluator(const MatrixBase& dst, const MatrixBase& src) -{ - typedef typename DstXprType::Scalar Scalar; - SelfCwiseBinaryOp, DstXprType, SrcXprType> tmp(dst.const_cast_derived()); - copy_using_evaluator(tmp, src.derived()); -} - -template -void subtract_assign_using_evaluator(const ArrayBase& dst, const ArrayBase& src) -{ - typedef typename DstXprType::Scalar Scalar; - SelfCwiseBinaryOp, DstXprType, SrcXprType> tmp(dst.const_cast_derived()); - copy_using_evaluator(tmp, src.derived()); -} - -template -void multiply_assign_using_evaluator(const ArrayBase& dst, const ArrayBase& src) -{ - typedef typename DstXprType::Scalar Scalar; - SelfCwiseBinaryOp, DstXprType, SrcXprType> tmp(dst.const_cast_derived()); - copy_using_evaluator(tmp, src.derived()); -} - -template -void divide_assign_using_evaluator(const ArrayBase& dst, const ArrayBase& src) -{ - typedef typename DstXprType::Scalar Scalar; - SelfCwiseBinaryOp, DstXprType, SrcXprType> tmp(dst.const_cast_derived()); - copy_using_evaluator(tmp, src.derived()); -} - - -} // namespace internal - -} // end namespace Eigen - -#endif // EIGEN_ASSIGN_EVALUATOR_H diff --git a/resources/3rdparty/eigen/Eigen/src/Core/CoreEvaluators.h b/resources/3rdparty/eigen/Eigen/src/Core/CoreEvaluators.h deleted file mode 100644 index cca01251c..000000000 --- a/resources/3rdparty/eigen/Eigen/src/Core/CoreEvaluators.h +++ /dev/null @@ -1,1299 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2011 Benoit Jacob -// Copyright (C) 2011 Gael Guennebaud -// Copyright (C) 2011-2012 Jitse Niesen -// -// 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_COREEVALUATORS_H -#define EIGEN_COREEVALUATORS_H - -namespace Eigen { - -namespace internal { - -// evaluator_traits contains traits for evaluator_impl - -template -struct evaluator_traits -{ - // 1 if evaluator_impl::evalTo() exists - // 0 if evaluator_impl allows coefficient-based access - static const int HasEvalTo = 0; - - // 1 if assignment A = B assumes aliasing when B is of type T and thus B needs to be evaluated into a - // temporary; 0 if not. - static const int AssumeAliasing = 0; -}; - -// expression class for evaluating nested expression to a temporary - -template -class EvalToTemp; - -// evaluator::type is type of evaluator for T -// evaluator::nestedType is type of evaluator if T is nested inside another evaluator - -template -struct evaluator_impl -{ }; - -template::HasEvalTo> -struct evaluator_nested_type; - -template -struct evaluator_nested_type -{ - typedef evaluator_impl type; -}; - -template -struct evaluator_nested_type -{ - typedef evaluator_impl > type; -}; - -template -struct evaluator -{ - typedef evaluator_impl type; - typedef typename evaluator_nested_type::type nestedType; -}; - -// TODO: Think about const-correctness - -template -struct evaluator - : evaluator -{ }; - -// ---------- base class for all writable evaluators ---------- - -template -struct evaluator_impl_base -{ - typedef typename ExpressionType::Index Index; - - template - void copyCoeff(Index row, Index col, const OtherEvaluatorType& other) - { - derived().coeffRef(row, col) = other.coeff(row, col); - } - - template - void copyCoeffByOuterInner(Index outer, Index inner, const OtherEvaluatorType& other) - { - Index row = rowIndexByOuterInner(outer, inner); - Index col = colIndexByOuterInner(outer, inner); - derived().copyCoeff(row, col, other); - } - - template - void copyCoeff(Index index, const OtherEvaluatorType& other) - { - derived().coeffRef(index) = other.coeff(index); - } - - template - void copyPacket(Index row, Index col, const OtherEvaluatorType& other) - { - derived().template writePacket(row, col, - other.template packet(row, col)); - } - - template - void copyPacketByOuterInner(Index outer, Index inner, const OtherEvaluatorType& other) - { - Index row = rowIndexByOuterInner(outer, inner); - Index col = colIndexByOuterInner(outer, inner); - derived().template copyPacket(row, col, other); - } - - template - void copyPacket(Index index, const OtherEvaluatorType& other) - { - derived().template writePacket(index, - other.template packet(index)); - } - - Index rowIndexByOuterInner(Index outer, Index inner) const - { - return int(ExpressionType::RowsAtCompileTime) == 1 ? 0 - : int(ExpressionType::ColsAtCompileTime) == 1 ? inner - : int(ExpressionType::Flags)&RowMajorBit ? outer - : inner; - } - - Index colIndexByOuterInner(Index outer, Index inner) const - { - return int(ExpressionType::ColsAtCompileTime) == 1 ? 0 - : int(ExpressionType::RowsAtCompileTime) == 1 ? inner - : int(ExpressionType::Flags)&RowMajorBit ? inner - : outer; - } - - evaluator_impl& derived() - { - return *static_cast*>(this); - } -}; - -// -------------------- Matrix and Array -------------------- -// -// evaluator_impl is a common base class for the -// Matrix and Array evaluators. - -template -struct evaluator_impl > - : evaluator_impl_base -{ - typedef PlainObjectBase PlainObjectType; - - enum { - IsRowMajor = PlainObjectType::IsRowMajor, - IsVectorAtCompileTime = PlainObjectType::IsVectorAtCompileTime, - RowsAtCompileTime = PlainObjectType::RowsAtCompileTime, - ColsAtCompileTime = PlainObjectType::ColsAtCompileTime - }; - - evaluator_impl(const PlainObjectType& m) - : m_data(m.data()), m_outerStride(IsVectorAtCompileTime ? 0 : m.outerStride()) - { } - - typedef typename PlainObjectType::Index Index; - typedef typename PlainObjectType::Scalar Scalar; - typedef typename PlainObjectType::CoeffReturnType CoeffReturnType; - typedef typename PlainObjectType::PacketScalar PacketScalar; - typedef typename PlainObjectType::PacketReturnType PacketReturnType; - - CoeffReturnType coeff(Index row, Index col) const - { - if (IsRowMajor) - return m_data[row * m_outerStride.value() + col]; - else - return m_data[row + col * m_outerStride.value()]; - } - - CoeffReturnType coeff(Index index) const - { - return m_data[index]; - } - - Scalar& coeffRef(Index row, Index col) - { - if (IsRowMajor) - return const_cast(m_data)[row * m_outerStride.value() + col]; - else - return const_cast(m_data)[row + col * m_outerStride.value()]; - } - - Scalar& coeffRef(Index index) - { - return const_cast(m_data)[index]; - } - - template - PacketReturnType packet(Index row, Index col) const - { - if (IsRowMajor) - return ploadt(m_data + row * m_outerStride.value() + col); - else - return ploadt(m_data + row + col * m_outerStride.value()); - } - - template - PacketReturnType packet(Index index) const - { - return ploadt(m_data + index); - } - - template - void writePacket(Index row, Index col, const PacketScalar& x) - { - if (IsRowMajor) - return pstoret - (const_cast(m_data) + row * m_outerStride.value() + col, x); - else - return pstoret - (const_cast(m_data) + row + col * m_outerStride.value(), x); - } - - template - void writePacket(Index index, const PacketScalar& x) - { - return pstoret(const_cast(m_data) + index, x); - } - -protected: - const Scalar *m_data; - - // We do not need to know the outer stride for vectors - variable_if_dynamic m_outerStride; -}; - -template -struct evaluator_impl > - : evaluator_impl > > -{ - typedef Matrix XprType; - - evaluator_impl(const XprType& m) - : evaluator_impl >(m) - { } -}; - -template -struct evaluator_impl > - : evaluator_impl > > -{ - typedef Array XprType; - - evaluator_impl(const XprType& m) - : evaluator_impl >(m) - { } -}; - -// -------------------- EvalToTemp -------------------- - -template -struct traits > - : public traits -{ }; - -template -class EvalToTemp - : public dense_xpr_base >::type -{ - public: - - typedef typename dense_xpr_base::type Base; - EIGEN_GENERIC_PUBLIC_INTERFACE(EvalToTemp) - - EvalToTemp(const ArgType& arg) - : m_arg(arg) - { } - - const ArgType& arg() const - { - return m_arg; - } - - Index rows() const - { - return m_arg.rows(); - } - - Index cols() const - { - return m_arg.cols(); - } - - private: - const ArgType& m_arg; -}; - -template -struct evaluator_impl > -{ - typedef EvalToTemp XprType; - typedef typename ArgType::PlainObject PlainObject; - - evaluator_impl(const XprType& xpr) - : m_result(xpr.rows(), xpr.cols()), m_resultImpl(m_result) - { - copy_using_evaluator_without_resizing(m_result, xpr.arg()); - } - - // This constructor is used when nesting an EvalTo evaluator in another evaluator - evaluator_impl(const ArgType& arg) - : m_result(arg.rows(), arg.cols()), m_resultImpl(m_result) - { - copy_using_evaluator_without_resizing(m_result, arg); - } - - typedef typename PlainObject::Index Index; - typedef typename PlainObject::Scalar Scalar; - typedef typename PlainObject::CoeffReturnType CoeffReturnType; - typedef typename PlainObject::PacketScalar PacketScalar; - typedef typename PlainObject::PacketReturnType PacketReturnType; - - // All other functions are forwarded to m_resultImpl - - CoeffReturnType coeff(Index row, Index col) const - { - return m_resultImpl.coeff(row, col); - } - - CoeffReturnType coeff(Index index) const - { - return m_resultImpl.coeff(index); - } - - Scalar& coeffRef(Index row, Index col) - { - return m_resultImpl.coeffRef(row, col); - } - - Scalar& coeffRef(Index index) - { - return m_resultImpl.coeffRef(index); - } - - template - PacketReturnType packet(Index row, Index col) const - { - return m_resultImpl.packet(row, col); - } - - template - PacketReturnType packet(Index index) const - { - return m_resultImpl.packet(index); - } - - template - void writePacket(Index row, Index col, const PacketScalar& x) - { - m_resultImpl.writePacket(row, col, x); - } - - template - void writePacket(Index index, const PacketScalar& x) - { - m_resultImpl.writePacket(index, x); - } - -protected: - PlainObject m_result; - typename evaluator::nestedType m_resultImpl; -}; - -// -------------------- Transpose -------------------- - -template -struct evaluator_impl > - : evaluator_impl_base > -{ - typedef Transpose XprType; - - evaluator_impl(const XprType& t) : m_argImpl(t.nestedExpression()) {} - - typedef typename XprType::Index Index; - typedef typename XprType::Scalar Scalar; - typedef typename XprType::CoeffReturnType CoeffReturnType; - typedef typename XprType::PacketScalar PacketScalar; - typedef typename XprType::PacketReturnType PacketReturnType; - - CoeffReturnType coeff(Index row, Index col) const - { - return m_argImpl.coeff(col, row); - } - - CoeffReturnType coeff(Index index) const - { - return m_argImpl.coeff(index); - } - - Scalar& coeffRef(Index row, Index col) - { - return m_argImpl.coeffRef(col, row); - } - - typename XprType::Scalar& coeffRef(Index index) - { - return m_argImpl.coeffRef(index); - } - - template - PacketReturnType packet(Index row, Index col) const - { - return m_argImpl.template packet(col, row); - } - - template - PacketReturnType packet(Index index) const - { - return m_argImpl.template packet(index); - } - - template - void writePacket(Index row, Index col, const PacketScalar& x) - { - m_argImpl.template writePacket(col, row, x); - } - - template - void writePacket(Index index, const PacketScalar& x) - { - m_argImpl.template writePacket(index, x); - } - -protected: - typename evaluator::nestedType m_argImpl; -}; - -// -------------------- CwiseNullaryOp -------------------- - -template -struct evaluator_impl > -{ - typedef CwiseNullaryOp XprType; - - evaluator_impl(const XprType& n) - : m_functor(n.functor()) - { } - - typedef typename XprType::Index Index; - typedef typename XprType::CoeffReturnType CoeffReturnType; - typedef typename XprType::PacketScalar PacketScalar; - - CoeffReturnType coeff(Index row, Index col) const - { - return m_functor(row, col); - } - - CoeffReturnType coeff(Index index) const - { - return m_functor(index); - } - - template - PacketScalar packet(Index row, Index col) const - { - return m_functor.packetOp(row, col); - } - - template - PacketScalar packet(Index index) const - { - return m_functor.packetOp(index); - } - -protected: - const NullaryOp m_functor; -}; - -// -------------------- CwiseUnaryOp -------------------- - -template -struct evaluator_impl > -{ - typedef CwiseUnaryOp XprType; - - evaluator_impl(const XprType& op) - : m_functor(op.functor()), - m_argImpl(op.nestedExpression()) - { } - - typedef typename XprType::Index Index; - typedef typename XprType::CoeffReturnType CoeffReturnType; - typedef typename XprType::PacketScalar PacketScalar; - - CoeffReturnType coeff(Index row, Index col) const - { - return m_functor(m_argImpl.coeff(row, col)); - } - - CoeffReturnType coeff(Index index) const - { - return m_functor(m_argImpl.coeff(index)); - } - - template - PacketScalar packet(Index row, Index col) const - { - return m_functor.packetOp(m_argImpl.template packet(row, col)); - } - - template - PacketScalar packet(Index index) const - { - return m_functor.packetOp(m_argImpl.template packet(index)); - } - -protected: - const UnaryOp m_functor; - typename evaluator::nestedType m_argImpl; -}; - -// -------------------- CwiseBinaryOp -------------------- - -template -struct evaluator_impl > -{ - typedef CwiseBinaryOp XprType; - - evaluator_impl(const XprType& xpr) - : m_functor(xpr.functor()), - m_lhsImpl(xpr.lhs()), - m_rhsImpl(xpr.rhs()) - { } - - typedef typename XprType::Index Index; - typedef typename XprType::CoeffReturnType CoeffReturnType; - typedef typename XprType::PacketScalar PacketScalar; - - CoeffReturnType coeff(Index row, Index col) const - { - return m_functor(m_lhsImpl.coeff(row, col), m_rhsImpl.coeff(row, col)); - } - - CoeffReturnType coeff(Index index) const - { - return m_functor(m_lhsImpl.coeff(index), m_rhsImpl.coeff(index)); - } - - template - PacketScalar packet(Index row, Index col) const - { - return m_functor.packetOp(m_lhsImpl.template packet(row, col), - m_rhsImpl.template packet(row, col)); - } - - template - PacketScalar packet(Index index) const - { - return m_functor.packetOp(m_lhsImpl.template packet(index), - m_rhsImpl.template packet(index)); - } - -protected: - const BinaryOp m_functor; - typename evaluator::nestedType m_lhsImpl; - typename evaluator::nestedType m_rhsImpl; -}; - -// -------------------- CwiseUnaryView -------------------- - -template -struct evaluator_impl > - : evaluator_impl_base > -{ - typedef CwiseUnaryView XprType; - - evaluator_impl(const XprType& op) - : m_unaryOp(op.functor()), - m_argImpl(op.nestedExpression()) - { } - - typedef typename XprType::Index Index; - typedef typename XprType::Scalar Scalar; - typedef typename XprType::CoeffReturnType CoeffReturnType; - - CoeffReturnType coeff(Index row, Index col) const - { - return m_unaryOp(m_argImpl.coeff(row, col)); - } - - CoeffReturnType coeff(Index index) const - { - return m_unaryOp(m_argImpl.coeff(index)); - } - - Scalar& coeffRef(Index row, Index col) - { - return m_unaryOp(m_argImpl.coeffRef(row, col)); - } - - Scalar& coeffRef(Index index) - { - return m_unaryOp(m_argImpl.coeffRef(index)); - } - -protected: - const UnaryOp m_unaryOp; - typename evaluator::nestedType m_argImpl; -}; - -// -------------------- Map -------------------- - -template -struct evaluator_impl > - : evaluator_impl_base -{ - typedef MapBase MapType; - typedef Derived XprType; - - typedef typename XprType::PointerType PointerType; - typedef typename XprType::Index Index; - typedef typename XprType::Scalar Scalar; - typedef typename XprType::CoeffReturnType CoeffReturnType; - typedef typename XprType::PacketScalar PacketScalar; - typedef typename XprType::PacketReturnType PacketReturnType; - - evaluator_impl(const XprType& map) - : m_data(const_cast(map.data())), - m_rowStride(map.rowStride()), - m_colStride(map.colStride()) - { } - - enum { - RowsAtCompileTime = XprType::RowsAtCompileTime - }; - - CoeffReturnType coeff(Index row, Index col) const - { - return m_data[col * m_colStride + row * m_rowStride]; - } - - CoeffReturnType coeff(Index index) const - { - return coeff(RowsAtCompileTime == 1 ? 0 : index, - RowsAtCompileTime == 1 ? index : 0); - } - - Scalar& coeffRef(Index row, Index col) - { - return m_data[col * m_colStride + row * m_rowStride]; - } - - Scalar& coeffRef(Index index) - { - return coeffRef(RowsAtCompileTime == 1 ? 0 : index, - RowsAtCompileTime == 1 ? index : 0); - } - - template - PacketReturnType packet(Index row, Index col) const - { - PointerType ptr = m_data + row * m_rowStride + col * m_colStride; - return internal::ploadt(ptr); - } - - template - PacketReturnType packet(Index index) const - { - return packet(RowsAtCompileTime == 1 ? 0 : index, - RowsAtCompileTime == 1 ? index : 0); - } - - template - void writePacket(Index row, Index col, const PacketScalar& x) - { - PointerType ptr = m_data + row * m_rowStride + col * m_colStride; - return internal::pstoret(ptr, x); - } - - template - void writePacket(Index index, const PacketScalar& x) - { - return writePacket(RowsAtCompileTime == 1 ? 0 : index, - RowsAtCompileTime == 1 ? index : 0, - x); - } - -protected: - PointerType m_data; - int m_rowStride; - int m_colStride; -}; - -template -struct evaluator_impl > - : public evaluator_impl > > -{ - typedef Map XprType; - - evaluator_impl(const XprType& map) - : evaluator_impl >(map) - { } -}; - -// -------------------- Block -------------------- - -template -struct evaluator_impl > - : evaluator_impl_base > -{ - typedef Block XprType; - - evaluator_impl(const XprType& block) - : m_argImpl(block.nestedExpression()), - m_startRow(block.startRow()), - m_startCol(block.startCol()) - { } - - typedef typename XprType::Index Index; - typedef typename XprType::Scalar Scalar; - typedef typename XprType::CoeffReturnType CoeffReturnType; - typedef typename XprType::PacketScalar PacketScalar; - typedef typename XprType::PacketReturnType PacketReturnType; - - enum { - RowsAtCompileTime = XprType::RowsAtCompileTime - }; - - CoeffReturnType coeff(Index row, Index col) const - { - return m_argImpl.coeff(m_startRow.value() + row, m_startCol.value() + col); - } - - CoeffReturnType coeff(Index index) const - { - return coeff(RowsAtCompileTime == 1 ? 0 : index, - RowsAtCompileTime == 1 ? index : 0); - } - - Scalar& coeffRef(Index row, Index col) - { - return m_argImpl.coeffRef(m_startRow.value() + row, m_startCol.value() + col); - } - - Scalar& coeffRef(Index index) - { - return coeffRef(RowsAtCompileTime == 1 ? 0 : index, - RowsAtCompileTime == 1 ? index : 0); - } - - template - PacketReturnType packet(Index row, Index col) const - { - return m_argImpl.template packet(m_startRow.value() + row, m_startCol.value() + col); - } - - template - PacketReturnType packet(Index index) const - { - return packet(RowsAtCompileTime == 1 ? 0 : index, - RowsAtCompileTime == 1 ? index : 0); - } - - template - void writePacket(Index row, Index col, const PacketScalar& x) - { - return m_argImpl.template writePacket(m_startRow.value() + row, m_startCol.value() + col, x); - } - - template - void writePacket(Index index, const PacketScalar& x) - { - return writePacket(RowsAtCompileTime == 1 ? 0 : index, - RowsAtCompileTime == 1 ? index : 0, - x); - } - -protected: - typename evaluator::nestedType m_argImpl; - const variable_if_dynamic m_startRow; - const variable_if_dynamic m_startCol; -}; - -// TODO: This evaluator does not actually use the child evaluator; -// all action is via the data() as returned by the Block expression. - -template -struct evaluator_impl > - : evaluator_impl > > -{ - typedef Block XprType; - - evaluator_impl(const XprType& block) - : evaluator_impl >(block) - { } -}; - - -// -------------------- Select -------------------- - -template -struct evaluator_impl > -{ - typedef Select XprType; - - evaluator_impl(const XprType& select) - : m_conditionImpl(select.conditionMatrix()), - m_thenImpl(select.thenMatrix()), - m_elseImpl(select.elseMatrix()) - { } - - typedef typename XprType::Index Index; - typedef typename XprType::CoeffReturnType CoeffReturnType; - - CoeffReturnType coeff(Index row, Index col) const - { - if (m_conditionImpl.coeff(row, col)) - return m_thenImpl.coeff(row, col); - else - return m_elseImpl.coeff(row, col); - } - - CoeffReturnType coeff(Index index) const - { - if (m_conditionImpl.coeff(index)) - return m_thenImpl.coeff(index); - else - return m_elseImpl.coeff(index); - } - -protected: - typename evaluator::nestedType m_conditionImpl; - typename evaluator::nestedType m_thenImpl; - typename evaluator::nestedType m_elseImpl; -}; - - -// -------------------- Replicate -------------------- - -template -struct evaluator_impl > -{ - typedef Replicate XprType; - - evaluator_impl(const XprType& replicate) - : m_argImpl(replicate.nestedExpression()), - m_rows(replicate.nestedExpression().rows()), - m_cols(replicate.nestedExpression().cols()) - { } - - typedef typename XprType::Index Index; - typedef typename XprType::CoeffReturnType CoeffReturnType; - typedef typename XprType::PacketReturnType PacketReturnType; - - CoeffReturnType coeff(Index row, Index col) const - { - // try to avoid using modulo; this is a pure optimization strategy - const Index actual_row = internal::traits::RowsAtCompileTime==1 ? 0 - : RowFactor==1 ? row - : row % m_rows.value(); - const Index actual_col = internal::traits::ColsAtCompileTime==1 ? 0 - : ColFactor==1 ? col - : col % m_cols.value(); - - return m_argImpl.coeff(actual_row, actual_col); - } - - template - PacketReturnType packet(Index row, Index col) const - { - const Index actual_row = internal::traits::RowsAtCompileTime==1 ? 0 - : RowFactor==1 ? row - : row % m_rows.value(); - const Index actual_col = internal::traits::ColsAtCompileTime==1 ? 0 - : ColFactor==1 ? col - : col % m_cols.value(); - - return m_argImpl.template packet(actual_row, actual_col); - } - -protected: - typename evaluator::nestedType m_argImpl; - const variable_if_dynamic m_rows; - const variable_if_dynamic m_cols; -}; - - -// -------------------- PartialReduxExpr -------------------- -// -// This is a wrapper around the expression object. -// TODO: Find out how to write a proper evaluator without duplicating -// the row() and col() member functions. - -template< typename ArgType, typename MemberOp, int Direction> -struct evaluator_impl > -{ - typedef PartialReduxExpr XprType; - - evaluator_impl(const XprType expr) - : m_expr(expr) - { } - - typedef typename XprType::Index Index; - typedef typename XprType::CoeffReturnType CoeffReturnType; - - CoeffReturnType coeff(Index row, Index col) const - { - return m_expr.coeff(row, col); - } - - CoeffReturnType coeff(Index index) const - { - return m_expr.coeff(index); - } - -protected: - const XprType m_expr; -}; - - -// -------------------- MatrixWrapper and ArrayWrapper -------------------- -// -// evaluator_impl_wrapper_base is a common base class for the -// MatrixWrapper and ArrayWrapper evaluators. - -template -struct evaluator_impl_wrapper_base - : evaluator_impl_base -{ - typedef typename remove_all::type ArgType; - - evaluator_impl_wrapper_base(const ArgType& arg) : m_argImpl(arg) {} - - typedef typename ArgType::Index Index; - typedef typename ArgType::Scalar Scalar; - typedef typename ArgType::CoeffReturnType CoeffReturnType; - typedef typename ArgType::PacketScalar PacketScalar; - typedef typename ArgType::PacketReturnType PacketReturnType; - - CoeffReturnType coeff(Index row, Index col) const - { - return m_argImpl.coeff(row, col); - } - - CoeffReturnType coeff(Index index) const - { - return m_argImpl.coeff(index); - } - - Scalar& coeffRef(Index row, Index col) - { - return m_argImpl.coeffRef(row, col); - } - - Scalar& coeffRef(Index index) - { - return m_argImpl.coeffRef(index); - } - - template - PacketReturnType packet(Index row, Index col) const - { - return m_argImpl.template packet(row, col); - } - - template - PacketReturnType packet(Index index) const - { - return m_argImpl.template packet(index); - } - - template - void writePacket(Index row, Index col, const PacketScalar& x) - { - m_argImpl.template writePacket(row, col, x); - } - - template - void writePacket(Index index, const PacketScalar& x) - { - m_argImpl.template writePacket(index, x); - } - -protected: - typename evaluator::nestedType m_argImpl; -}; - -template -struct evaluator_impl > - : evaluator_impl_wrapper_base > -{ - typedef MatrixWrapper XprType; - - evaluator_impl(const XprType& wrapper) - : evaluator_impl_wrapper_base >(wrapper.nestedExpression()) - { } -}; - -template -struct evaluator_impl > - : evaluator_impl_wrapper_base > -{ - typedef ArrayWrapper XprType; - - evaluator_impl(const XprType& wrapper) - : evaluator_impl_wrapper_base >(wrapper.nestedExpression()) - { } -}; - - -// -------------------- Reverse -------------------- - -// defined in Reverse.h: -template struct reverse_packet_cond; - -template -struct evaluator_impl > - : evaluator_impl_base > -{ - typedef Reverse XprType; - typedef typename XprType::Index Index; - typedef typename XprType::Scalar Scalar; - typedef typename XprType::CoeffReturnType CoeffReturnType; - typedef typename XprType::PacketScalar PacketScalar; - typedef typename XprType::PacketReturnType PacketReturnType; - - enum { - PacketSize = internal::packet_traits::size, - IsRowMajor = XprType::IsRowMajor, - IsColMajor = !IsRowMajor, - ReverseRow = (Direction == Vertical) || (Direction == BothDirections), - ReverseCol = (Direction == Horizontal) || (Direction == BothDirections), - OffsetRow = ReverseRow && IsColMajor ? PacketSize : 1, - OffsetCol = ReverseCol && IsRowMajor ? PacketSize : 1, - ReversePacket = (Direction == BothDirections) - || ((Direction == Vertical) && IsColMajor) - || ((Direction == Horizontal) && IsRowMajor) - }; - typedef internal::reverse_packet_cond reverse_packet; - - evaluator_impl(const XprType& reverse) - : m_argImpl(reverse.nestedExpression()), - m_rows(ReverseRow ? reverse.nestedExpression().rows() : 0), - m_cols(ReverseCol ? reverse.nestedExpression().cols() : 0) - { } - - CoeffReturnType coeff(Index row, Index col) const - { - return m_argImpl.coeff(ReverseRow ? m_rows.value() - row - 1 : row, - ReverseCol ? m_cols.value() - col - 1 : col); - } - - CoeffReturnType coeff(Index index) const - { - return m_argImpl.coeff(m_rows.value() * m_cols.value() - index - 1); - } - - Scalar& coeffRef(Index row, Index col) - { - return m_argImpl.coeffRef(ReverseRow ? m_rows.value() - row - 1 : row, - ReverseCol ? m_cols.value() - col - 1 : col); - } - - Scalar& coeffRef(Index index) - { - return m_argImpl.coeffRef(m_rows.value() * m_cols.value() - index - 1); - } - - template - PacketScalar packet(Index row, Index col) const - { - return reverse_packet::run(m_argImpl.template packet( - ReverseRow ? m_rows.value() - row - OffsetRow : row, - ReverseCol ? m_cols.value() - col - OffsetCol : col)); - } - - template - PacketScalar packet(Index index) const - { - return preverse(m_argImpl.template packet(m_rows.value() * m_cols.value() - index - PacketSize)); - } - - template - void writePacket(Index row, Index col, const PacketScalar& x) - { - m_argImpl.template writePacket( - ReverseRow ? m_rows.value() - row - OffsetRow : row, - ReverseCol ? m_cols.value() - col - OffsetCol : col, - reverse_packet::run(x)); - } - - template - void writePacket(Index index, const PacketScalar& x) - { - m_argImpl.template writePacket - (m_rows.value() * m_cols.value() - index - PacketSize, preverse(x)); - } - -protected: - typename evaluator::nestedType m_argImpl; - - // If we do not reverse rows, then we do not need to know the number of rows; same for columns - const variable_if_dynamic m_rows; - const variable_if_dynamic m_cols; -}; - - -// -------------------- Diagonal -------------------- - -template -struct evaluator_impl > - : evaluator_impl_base > -{ - typedef Diagonal XprType; - - evaluator_impl(const XprType& diagonal) - : m_argImpl(diagonal.nestedExpression()), - m_index(diagonal.index()) - { } - - typedef typename XprType::Index Index; - typedef typename XprType::Scalar Scalar; - typedef typename XprType::CoeffReturnType CoeffReturnType; - - CoeffReturnType coeff(Index row, Index) const - { - return m_argImpl.coeff(row + rowOffset(), row + colOffset()); - } - - CoeffReturnType coeff(Index index) const - { - return m_argImpl.coeff(index + rowOffset(), index + colOffset()); - } - - Scalar& coeffRef(Index row, Index) - { - return m_argImpl.coeffRef(row + rowOffset(), row + colOffset()); - } - - Scalar& coeffRef(Index index) - { - return m_argImpl.coeffRef(index + rowOffset(), index + colOffset()); - } - -protected: - typename evaluator::nestedType m_argImpl; - const internal::variable_if_dynamicindex m_index; - -private: - EIGEN_STRONG_INLINE Index rowOffset() const { return m_index.value() > 0 ? 0 : -m_index.value(); } - EIGEN_STRONG_INLINE Index colOffset() const { return m_index.value() > 0 ? m_index.value() : 0; } -}; - - -// ---------- SwapWrapper ---------- - -template -struct evaluator_impl > - : evaluator_impl_base > -{ - typedef SwapWrapper XprType; - - evaluator_impl(const XprType& swapWrapper) - : m_argImpl(swapWrapper.expression()) - { } - - typedef typename XprType::Index Index; - typedef typename XprType::Scalar Scalar; - typedef typename XprType::Packet Packet; - - // This function and the next one are needed by assign to correctly align loads/stores - // TODO make Assign use .data() - Scalar& coeffRef(Index row, Index col) - { - return m_argImpl.coeffRef(row, col); - } - - inline Scalar& coeffRef(Index index) - { - return m_argImpl.coeffRef(index); - } - - template - void copyCoeff(Index row, Index col, const OtherEvaluatorType& other) - { - OtherEvaluatorType& nonconst_other = const_cast(other); - Scalar tmp = m_argImpl.coeff(row, col); - m_argImpl.coeffRef(row, col) = nonconst_other.coeff(row, col); - nonconst_other.coeffRef(row, col) = tmp; - } - - template - void copyCoeff(Index index, const OtherEvaluatorType& other) - { - OtherEvaluatorType& nonconst_other = const_cast(other); - Scalar tmp = m_argImpl.coeff(index); - m_argImpl.coeffRef(index) = nonconst_other.coeff(index); - nonconst_other.coeffRef(index) = tmp; - } - - template - void copyPacket(Index row, Index col, const OtherEvaluatorType& other) - { - OtherEvaluatorType& nonconst_other = const_cast(other); - Packet tmp = m_argImpl.template packet(row, col); - m_argImpl.template writePacket - (row, col, nonconst_other.template packet(row, col)); - nonconst_other.template writePacket(row, col, tmp); - } - - template - void copyPacket(Index index, const OtherEvaluatorType& other) - { - OtherEvaluatorType& nonconst_other = const_cast(other); - Packet tmp = m_argImpl.template packet(index); - m_argImpl.template writePacket - (index, nonconst_other.template packet(index)); - nonconst_other.template writePacket(index, tmp); - } - -protected: - typename evaluator::nestedType m_argImpl; -}; - - -// ---------- SelfCwiseBinaryOp ---------- - -template -struct evaluator_impl > - : evaluator_impl_base > -{ - typedef SelfCwiseBinaryOp XprType; - - evaluator_impl(const XprType& selfCwiseBinaryOp) - : m_argImpl(selfCwiseBinaryOp.expression()), - m_functor(selfCwiseBinaryOp.functor()) - { } - - typedef typename XprType::Index Index; - typedef typename XprType::Scalar Scalar; - typedef typename XprType::Packet Packet; - - // This function and the next one are needed by assign to correctly align loads/stores - // TODO make Assign use .data() - Scalar& coeffRef(Index row, Index col) - { - return m_argImpl.coeffRef(row, col); - } - - inline Scalar& coeffRef(Index index) - { - return m_argImpl.coeffRef(index); - } - - template - void copyCoeff(Index row, Index col, const OtherEvaluatorType& other) - { - Scalar& tmp = m_argImpl.coeffRef(row, col); - tmp = m_functor(tmp, other.coeff(row, col)); - } - - template - void copyCoeff(Index index, const OtherEvaluatorType& other) - { - Scalar& tmp = m_argImpl.coeffRef(index); - tmp = m_functor(tmp, other.coeff(index)); - } - - template - void copyPacket(Index row, Index col, const OtherEvaluatorType& other) - { - const Packet res = m_functor.packetOp(m_argImpl.template packet(row, col), - other.template packet(row, col)); - m_argImpl.template writePacket(row, col, res); - } - - template - void copyPacket(Index index, const OtherEvaluatorType& other) - { - const Packet res = m_functor.packetOp(m_argImpl.template packet(index), - other.template packet(index)); - m_argImpl.template writePacket(index, res); - } - -protected: - typename evaluator::nestedType m_argImpl; - const BinaryOp m_functor; -}; - - -} // namespace internal - -} // end namespace Eigen - -#endif // EIGEN_COREEVALUATORS_H diff --git a/resources/3rdparty/eigen/Eigen/src/Core/ProductEvaluators.h b/resources/3rdparty/eigen/Eigen/src/Core/ProductEvaluators.h deleted file mode 100644 index 0c0570e44..000000000 --- a/resources/3rdparty/eigen/Eigen/src/Core/ProductEvaluators.h +++ /dev/null @@ -1,411 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2006-2008 Benoit Jacob -// Copyright (C) 2008-2010 Gael Guennebaud -// Copyright (C) 2011 Jitse Niesen -// -// 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_PRODUCTEVALUATORS_H -#define EIGEN_PRODUCTEVALUATORS_H - -namespace Eigen { - -namespace internal { - -// We can evaluate the product either all at once, like GeneralProduct and its evalTo() function, or -// traverse the matrix coefficient by coefficient, like CoeffBasedProduct. Use the existing logic -// in ProductReturnType to decide. - -template -struct product_evaluator_dispatcher; - -template -struct evaluator_impl > - : product_evaluator_dispatcher, typename ProductReturnType::Type> -{ - typedef Product XprType; - typedef product_evaluator_dispatcher::Type> Base; - - evaluator_impl(const XprType& xpr) : Base(xpr) - { } -}; - -template -struct product_evaluator_traits_dispatcher; - -template -struct evaluator_traits > - : product_evaluator_traits_dispatcher, typename ProductReturnType::Type> -{ - static const int AssumeAliasing = 1; -}; - -// Case 1: Evaluate all at once -// -// We can view the GeneralProduct class as a part of the product evaluator. -// Four sub-cases: InnerProduct, OuterProduct, GemmProduct and GemvProduct. -// InnerProduct is special because GeneralProduct does not have an evalTo() method in this case. - -template -struct product_evaluator_traits_dispatcher, GeneralProduct > -{ - static const int HasEvalTo = 0; -}; - -template -struct product_evaluator_dispatcher, GeneralProduct > - : public evaluator::PlainObject>::type -{ - typedef Product XprType; - typedef typename XprType::PlainObject PlainObject; - typedef typename evaluator::type evaluator_base; - - // TODO: Computation is too early (?) - product_evaluator_dispatcher(const XprType& xpr) : evaluator_base(m_result) - { - m_result.coeffRef(0,0) = (xpr.lhs().transpose().cwiseProduct(xpr.rhs())).sum(); - } - -protected: - PlainObject m_result; -}; - -// For the other three subcases, simply call the evalTo() method of GeneralProduct -// TODO: GeneralProduct should take evaluators, not expression objects. - -template -struct product_evaluator_traits_dispatcher, GeneralProduct > -{ - static const int HasEvalTo = 1; -}; - -template -struct product_evaluator_dispatcher, GeneralProduct > -{ - typedef Product XprType; - typedef typename XprType::PlainObject PlainObject; - typedef typename evaluator::type evaluator_base; - - product_evaluator_dispatcher(const XprType& xpr) : m_xpr(xpr) - { } - - template - void evalTo(DstEvaluatorType /* not used */, DstXprType& dst) - { - dst.resize(m_xpr.rows(), m_xpr.cols()); - GeneralProduct(m_xpr.lhs(), m_xpr.rhs()).evalTo(dst); - } - -protected: - const XprType& m_xpr; -}; - -// Case 2: Evaluate coeff by coeff -// -// This is mostly taken from CoeffBasedProduct.h -// The main difference is that we add an extra argument to the etor_product_*_impl::run() function -// for the inner dimension of the product, because evaluator object do not know their size. - -template -struct etor_product_coeff_impl; - -template -struct etor_product_packet_impl; - -template -struct product_evaluator_traits_dispatcher, CoeffBasedProduct > -{ - static const int HasEvalTo = 0; -}; - -template -struct product_evaluator_dispatcher, CoeffBasedProduct > - : evaluator_impl_base > -{ - typedef Product XprType; - typedef CoeffBasedProduct CoeffBasedProductType; - - product_evaluator_dispatcher(const XprType& xpr) - : m_lhsImpl(xpr.lhs()), - m_rhsImpl(xpr.rhs()), - m_innerDim(xpr.lhs().cols()) - { } - - typedef typename XprType::Index Index; - typedef typename XprType::Scalar Scalar; - typedef typename XprType::CoeffReturnType CoeffReturnType; - typedef typename XprType::PacketScalar PacketScalar; - typedef typename XprType::PacketReturnType PacketReturnType; - - // Everything below here is taken from CoeffBasedProduct.h - - enum { - RowsAtCompileTime = traits::RowsAtCompileTime, - PacketSize = packet_traits::size, - InnerSize = traits::InnerSize, - CoeffReadCost = traits::CoeffReadCost, - Unroll = CoeffReadCost != Dynamic && CoeffReadCost <= EIGEN_UNROLLING_LIMIT, - CanVectorizeInner = traits::CanVectorizeInner - }; - - typedef typename evaluator::type LhsEtorType; - typedef typename evaluator::type RhsEtorType; - typedef etor_product_coeff_impl CoeffImpl; - - const CoeffReturnType coeff(Index row, Index col) const - { - Scalar res; - CoeffImpl::run(row, col, m_lhsImpl, m_rhsImpl, m_innerDim, res); - return res; - } - - /* Allow index-based non-packet access. It is impossible though to allow index-based packed access, - * which is why we don't set the LinearAccessBit. - */ - const CoeffReturnType coeff(Index index) const - { - Scalar res; - const Index row = RowsAtCompileTime == 1 ? 0 : index; - const Index col = RowsAtCompileTime == 1 ? index : 0; - CoeffImpl::run(row, col, m_lhsImpl, m_rhsImpl, m_innerDim, res); - return res; - } - - template - const PacketReturnType packet(Index row, Index col) const - { - PacketScalar res; - typedef etor_product_packet_impl PacketImpl; - PacketImpl::run(row, col, m_lhsImpl, m_rhsImpl, m_innerDim, res); - return res; - } - -protected: - typename evaluator::type m_lhsImpl; - typename evaluator::type m_rhsImpl; - - // TODO: Get rid of m_innerDim if known at compile time - Index m_innerDim; -}; - -/*************************************************************************** -* Normal product .coeff() implementation (with meta-unrolling) -***************************************************************************/ - -/************************************** -*** Scalar path - no vectorization *** -**************************************/ - -template -struct etor_product_coeff_impl -{ - typedef typename Lhs::Index Index; - EIGEN_STRONG_INLINE static void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, Index innerDim, RetScalar &res) - { - etor_product_coeff_impl::run(row, col, lhs, rhs, innerDim, res); - res += lhs.coeff(row, UnrollingIndex) * rhs.coeff(UnrollingIndex, col); - } -}; - -template -struct etor_product_coeff_impl -{ - typedef typename Lhs::Index Index; - EIGEN_STRONG_INLINE static void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, Index /*innerDim*/, RetScalar &res) - { - res = lhs.coeff(row, 0) * rhs.coeff(0, col); - } -}; - -template -struct etor_product_coeff_impl -{ - typedef typename Lhs::Index Index; - EIGEN_STRONG_INLINE static void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, Index innerDim, RetScalar& res) - { - eigen_assert(innerDim>0 && "you are using a non initialized matrix"); - res = lhs.coeff(row, 0) * rhs.coeff(0, col); - for(Index i = 1; i < innerDim; ++i) - res += lhs.coeff(row, i) * rhs.coeff(i, col); - } -}; - -/******************************************* -*** Scalar path with inner vectorization *** -*******************************************/ - -template -struct etor_product_coeff_vectorized_unroller -{ - typedef typename Lhs::Index Index; - enum { PacketSize = packet_traits::size }; - EIGEN_STRONG_INLINE static void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, Index innerDim, typename Lhs::PacketScalar &pres) - { - etor_product_coeff_vectorized_unroller::run(row, col, lhs, rhs, innerDim, pres); - pres = padd(pres, pmul( lhs.template packet(row, UnrollingIndex) , rhs.template packet(UnrollingIndex, col) )); - } -}; - -template -struct etor_product_coeff_vectorized_unroller<0, Lhs, Rhs, Packet> -{ - typedef typename Lhs::Index Index; - EIGEN_STRONG_INLINE static void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, Index /*innerDim*/, typename Lhs::PacketScalar &pres) - { - pres = pmul(lhs.template packet(row, 0) , rhs.template packet(0, col)); - } -}; - -template -struct etor_product_coeff_impl -{ - typedef typename Lhs::PacketScalar Packet; - typedef typename Lhs::Index Index; - enum { PacketSize = packet_traits::size }; - EIGEN_STRONG_INLINE static void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, Index innerDim, RetScalar &res) - { - Packet pres; - etor_product_coeff_vectorized_unroller::run(row, col, lhs, rhs, innerDim, pres); - etor_product_coeff_impl::run(row, col, lhs, rhs, innerDim, res); - res = predux(pres); - } -}; - -template -struct etor_product_coeff_vectorized_dyn_selector -{ - typedef typename Lhs::Index Index; - EIGEN_STRONG_INLINE static void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, Index /*innerDim*/, typename Lhs::Scalar &res) - { - res = lhs.row(row).transpose().cwiseProduct(rhs.col(col)).sum(); - } -}; - -// NOTE the 3 following specializations are because taking .col(0) on a vector is a bit slower -// NOTE maybe they are now useless since we have a specialization for Block -template -struct etor_product_coeff_vectorized_dyn_selector -{ - typedef typename Lhs::Index Index; - EIGEN_STRONG_INLINE static void run(Index /*row*/, Index col, const Lhs& lhs, const Rhs& rhs, Index /*innerDim*/, typename Lhs::Scalar &res) - { - res = lhs.transpose().cwiseProduct(rhs.col(col)).sum(); - } -}; - -template -struct etor_product_coeff_vectorized_dyn_selector -{ - typedef typename Lhs::Index Index; - EIGEN_STRONG_INLINE static void run(Index row, Index /*col*/, const Lhs& lhs, const Rhs& rhs, Index /*innerDim*/, typename Lhs::Scalar &res) - { - res = lhs.row(row).transpose().cwiseProduct(rhs).sum(); - } -}; - -template -struct etor_product_coeff_vectorized_dyn_selector -{ - typedef typename Lhs::Index Index; - EIGEN_STRONG_INLINE static void run(Index /*row*/, Index /*col*/, const Lhs& lhs, const Rhs& rhs, Index /*innerDim*/, typename Lhs::Scalar &res) - { - res = lhs.transpose().cwiseProduct(rhs).sum(); - } -}; - -template -struct etor_product_coeff_impl -{ - typedef typename Lhs::Index Index; - EIGEN_STRONG_INLINE static void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, Index innerDim, typename Lhs::Scalar &res) - { - etor_product_coeff_vectorized_dyn_selector::run(row, col, lhs, rhs, innerDim, res); - } -}; - -/******************* -*** Packet path *** -*******************/ - -template -struct etor_product_packet_impl -{ - typedef typename Lhs::Index Index; - EIGEN_STRONG_INLINE static void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, Index innerDim, Packet &res) - { - etor_product_packet_impl::run(row, col, lhs, rhs, innerDim, res); - res = pmadd(pset1(lhs.coeff(row, UnrollingIndex)), rhs.template packet(UnrollingIndex, col), res); - } -}; - -template -struct etor_product_packet_impl -{ - typedef typename Lhs::Index Index; - EIGEN_STRONG_INLINE static void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, Index innerDim, Packet &res) - { - etor_product_packet_impl::run(row, col, lhs, rhs, innerDim, res); - res = pmadd(lhs.template packet(row, UnrollingIndex), pset1(rhs.coeff(UnrollingIndex, col)), res); - } -}; - -template -struct etor_product_packet_impl -{ - typedef typename Lhs::Index Index; - EIGEN_STRONG_INLINE static void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, Index /*innerDim*/, Packet &res) - { - res = pmul(pset1(lhs.coeff(row, 0)),rhs.template packet(0, col)); - } -}; - -template -struct etor_product_packet_impl -{ - typedef typename Lhs::Index Index; - EIGEN_STRONG_INLINE static void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, Index /*innerDim*/, Packet &res) - { - res = pmul(lhs.template packet(row, 0), pset1(rhs.coeff(0, col))); - } -}; - -template -struct etor_product_packet_impl -{ - typedef typename Lhs::Index Index; - EIGEN_STRONG_INLINE static void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, Index innerDim, Packet& res) - { - eigen_assert(innerDim>0 && "you are using a non initialized matrix"); - res = pmul(pset1(lhs.coeff(row, 0)),rhs.template packet(0, col)); - for(Index i = 1; i < innerDim; ++i) - res = pmadd(pset1(lhs.coeff(row, i)), rhs.template packet(i, col), res); - } -}; - -template -struct etor_product_packet_impl -{ - typedef typename Lhs::Index Index; - EIGEN_STRONG_INLINE static void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, Index innerDim, Packet& res) - { - eigen_assert(innerDim>0 && "you are using a non initialized matrix"); - res = pmul(lhs.template packet(row, 0), pset1(rhs.coeff(0, col))); - for(Index i = 1; i < innerDim; ++i) - res = pmadd(lhs.template packet(row, i), pset1(rhs.coeff(i, col)), res); - } -}; - -} // end namespace internal - -} // end namespace Eigen - -#endif // EIGEN_PRODUCT_EVALUATORS_H diff --git a/resources/3rdparty/eigen/Eigen/src/Core/Ref.h b/resources/3rdparty/eigen/Eigen/src/Core/Ref.h deleted file mode 100644 index e106bd59f..000000000 --- a/resources/3rdparty/eigen/Eigen/src/Core/Ref.h +++ /dev/null @@ -1,254 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2012 Gael Guennebaud -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef EIGEN_REF_H -#define EIGEN_REF_H - -namespace Eigen { - -template class RefBase; -template,OuterStride<> >::type > class Ref; - -/** \class Ref - * \ingroup Core_Module - * - * \brief A matrix or vector expression mapping an existing expressions - * - * \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). - * 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. - * A Ref<> object can represent either a const expression or a l-value: - * \code - * // in-out argument: - * void foo1(Ref x); - * - * // read-only const argument: - * void foo2(const Ref& 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. - * By default, a Ref can reference any dense vector expression of float having a contiguous memory layout. - * Likewise, a Ref 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), - * 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. - * Here are some examples: - * \code - * MatrixXf A; - * VectorXf a; - * foo1(a.head()); // OK - * foo1(A.col()); // OK - * foo1(A.row()); // compilation error because here innerstride!=1 - * foo2(A.row()); // The row is copied into a contiguous temporary - * foo2(2*a); // The expression is evaluated into a temporary - * 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. - * Here is an example accepting an innerstride!=1: - * \code - * // in-out argument: - * void foo3(Ref > 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 - * template function, e.g.: - * \code - * // in the .h: - * void foo(const Ref& A); - * void foo(const Ref >& A); - * - * // in the .cpp: - * template void foo_impl(const TypeOfA& A) { - * ... // crazy code goes here - * } - * void foo(const Ref& A) { foo_impl(A); } - * void foo(const Ref >& A) { foo_impl(A); } - * \endcode - * - * - * \sa PlainObjectBase::Map(), \ref TopicStorageOrders - */ - -namespace internal { - -template -struct traits > - : public traits > -{ - typedef _PlainObjectType PlainObjectType; - typedef _StrideType StrideType; - enum { - Options = _Options - }; - - template struct match { - enum { - HasDirectAccess = internal::has_direct_access::ret, - StorageOrderMatch = PlainObjectType::IsVectorAtCompileTime || ((PlainObjectType::Flags&RowMajorBit)==(Derived::Flags&RowMajorBit)), - InnerStrideMatch = int(StrideType::InnerStrideAtCompileTime)==int(Dynamic) - || int(StrideType::InnerStrideAtCompileTime)==int(Derived::InnerStrideAtCompileTime) - || (int(StrideType::InnerStrideAtCompileTime)==0 && int(Derived::InnerStrideAtCompileTime)==1), - OuterStrideMatch = Derived::IsVectorAtCompileTime - || int(StrideType::OuterStrideAtCompileTime)==int(Dynamic) || int(StrideType::OuterStrideAtCompileTime)==int(Derived::OuterStrideAtCompileTime), - AlignmentMatch = (_Options!=Aligned) || ((PlainObjectType::Flags&AlignedBit)==0) || ((traits::Flags&AlignedBit)==AlignedBit), - MatchAtCompileTime = HasDirectAccess && StorageOrderMatch && InnerStrideMatch && OuterStrideMatch && AlignmentMatch - }; - typedef typename internal::conditional::type type; - }; - -}; - -template -struct traits > : public traits {}; - -} - -template class RefBase - : public MapBase -{ - typedef typename internal::traits::PlainObjectType PlainObjectType; - typedef typename internal::traits::StrideType StrideType; - -public: - - typedef MapBase Base; - EIGEN_DENSE_PUBLIC_INTERFACE(RefBase) - - inline Index innerStride() const - { - return StrideType::InnerStrideAtCompileTime != 0 ? m_stride.inner() : 1; - } - - inline Index outerStride() const - { - return StrideType::OuterStrideAtCompileTime != 0 ? m_stride.outer() - : IsVectorAtCompileTime ? this->size() - : int(Flags)&RowMajorBit ? this->cols() - : this->rows(); - } - - RefBase() - : Base(0,RowsAtCompileTime==Dynamic?0:RowsAtCompileTime,ColsAtCompileTime==Dynamic?0:ColsAtCompileTime), - // Stride<> does not allow default ctor for Dynamic strides, so let' initialize it with dummy values: - m_stride(StrideType::OuterStrideAtCompileTime==Dynamic?0:StrideType::OuterStrideAtCompileTime, - StrideType::InnerStrideAtCompileTime==Dynamic?0:StrideType::InnerStrideAtCompileTime) - {} - -protected: - - typedef Stride StrideBase; - - template - void construct(Expression& expr) - { - if(PlainObjectType::RowsAtCompileTime==1) - { - eigen_assert(expr.rows()==1 || expr.cols()==1); - ::new (static_cast(this)) Base(expr.data(), 1, expr.size()); - } - else if(PlainObjectType::ColsAtCompileTime==1) - { - eigen_assert(expr.rows()==1 || expr.cols()==1); - ::new (static_cast(this)) Base(expr.data(), expr.size(), 1); - } - else - ::new (static_cast(this)) Base(expr.data(), expr.rows(), expr.cols()); - ::new (&m_stride) StrideBase(StrideType::OuterStrideAtCompileTime==0?0:expr.outerStride(), - StrideType::InnerStrideAtCompileTime==0?0:expr.innerStride()); - } - - StrideBase m_stride; -}; - - -template class Ref - : public RefBase > -{ - typedef internal::traits Traits; - public: - - typedef RefBase Base; - EIGEN_DENSE_PUBLIC_INTERFACE(Ref) - - - #ifndef EIGEN_PARSED_BY_DOXYGEN - template - inline Ref(PlainObjectBase& expr, - typename internal::enable_if::MatchAtCompileTime),Derived>::type* = 0) - { - Base::construct(expr); - } - template - inline Ref(const DenseBase& expr, - typename internal::enable_if::value&&bool(Traits::template match::MatchAtCompileTime)),Derived>::type* = 0, - int = Derived::ThisConstantIsPrivateInPlainObjectBase) - #else - template - inline Ref(DenseBase& expr) - #endif - { - Base::construct(expr.const_cast_derived()); - } - - EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Ref) - -}; - -// this is the const ref version -template class Ref - : public RefBase > -{ - typedef internal::traits Traits; - public: - - typedef RefBase Base; - EIGEN_DENSE_PUBLIC_INTERFACE(Ref) - - template - inline Ref(const DenseBase& expr) - { -// std::cout << match_helper::HasDirectAccess << "," << match_helper::OuterStrideMatch << "," << match_helper::InnerStrideMatch << "\n"; -// std::cout << int(StrideType::OuterStrideAtCompileTime) << " - " << int(Derived::OuterStrideAtCompileTime) << "\n"; -// std::cout << int(StrideType::InnerStrideAtCompileTime) << " - " << int(Derived::InnerStrideAtCompileTime) << "\n"; - construct(expr.derived(), typename Traits::template match::type()); - } - - protected: - - template - void construct(const Expression& expr,internal::true_type) - { - Base::construct(expr); - } - - template - void construct(const Expression& expr, internal::false_type) - { -// std::cout << "Ref: copy\n"; - m_object = expr; - Base::construct(m_object); - } - - protected: - PlainObjectType m_object; -}; - -} // end namespace Eigen - -#endif // EIGEN_REF_H diff --git a/resources/3rdparty/eigen/Eigen/src/Eigenvalues/GeneralizedEigenSolver.h b/resources/3rdparty/eigen/Eigen/src/Eigenvalues/GeneralizedEigenSolver.h deleted file mode 100644 index 0075880fe..000000000 --- a/resources/3rdparty/eigen/Eigen/src/Eigenvalues/GeneralizedEigenSolver.h +++ /dev/null @@ -1,339 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2012 Gael Guennebaud -// Copyright (C) 2010,2012 Jitse Niesen -// -// 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_GENERALIZEDEIGENSOLVER_H -#define EIGEN_GENERALIZEDEIGENSOLVER_H - -#include "./RealQZ.h" - -namespace Eigen { - -/** \eigenvalues_module \ingroup Eigenvalues_Module - * - * - * \class GeneralizedEigenSolver - * - * \brief Computes the generalized eigenvalues and eigenvectors of a pair of general matrices - * - * \tparam _MatrixType the type of the matrices of which we are computing the - * eigen-decomposition; this is expected to be an instantiation of the Matrix - * class template. Currently, only real matrices are supported. - * - * The generalized eigenvalues and eigenvectors of a matrix pair \f$ A \f$ and \f$ B \f$ are scalars - * \f$ \lambda \f$ and vectors \f$ v \f$ such that \f$ Av = \lambda Bv \f$. If - * \f$ D \f$ is a diagonal matrix with the eigenvalues on the diagonal, and - * \f$ V \f$ is a matrix with the eigenvectors as its columns, then \f$ A V = - * B V D \f$. The matrix \f$ V \f$ is almost always invertible, in which case we - * have \f$ A = B V D V^{-1} \f$. This is called the generalized eigen-decomposition. - * - * The generalized eigenvalues and eigenvectors of a matrix pair may be complex, even when the - * matrices are real. Moreover, the generalized eigenvalue might be infinite if the matrix B is - * singular. To workaround this difficulty, the eigenvalues are provided as a pair of complex \f$ \alpha \f$ - * and real \f$ \beta \f$ such that: \f$ \lambda_i = \alpha_i / \beta_i \f$. If \f$ \beta_i \f$ is (nearly) zero, - * then one can consider the well defined left eigenvalue \f$ \mu = \beta_i / \alpha_i\f$ such that: - * \f$ \mu_i A v_i = B v_i \f$, or even \f$ \mu_i u_i^T A = u_i^T B \f$ where \f$ u_i \f$ is - * called the left eigenvector. - * - * Call the function compute() to compute the generalized eigenvalues and eigenvectors of - * a given matrix pair. Alternatively, you can use the - * GeneralizedEigenSolver(const MatrixType&, const MatrixType&, bool) constructor which computes the - * eigenvalues and eigenvectors at construction time. Once the eigenvalue and - * eigenvectors are computed, they can be retrieved with the eigenvalues() and - * eigenvectors() functions. - * - * Here is an usage example of this class: - * Example: \include GeneralizedEigenSolver.cpp - * Output: \verbinclude GeneralizedEigenSolver.out - * - * \sa MatrixBase::eigenvalues(), class ComplexEigenSolver, class SelfAdjointEigenSolver - */ -template class GeneralizedEigenSolver -{ - public: - - /** \brief Synonym for the template parameter \p _MatrixType. */ - typedef _MatrixType MatrixType; - - enum { - RowsAtCompileTime = MatrixType::RowsAtCompileTime, - ColsAtCompileTime = MatrixType::ColsAtCompileTime, - Options = MatrixType::Options, - MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime, - MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime - }; - - /** \brief Scalar type for matrices of type #MatrixType. */ - typedef typename MatrixType::Scalar Scalar; - typedef typename NumTraits::Real RealScalar; - typedef typename MatrixType::Index Index; - - /** \brief Complex scalar type for #MatrixType. - * - * This is \c std::complex if #Scalar is real (e.g., - * \c float or \c double) and just \c Scalar if #Scalar is - * complex. - */ - typedef std::complex ComplexScalar; - - /** \brief Type for vector of real scalar values eigenvalues as returned by betas(). - * - * This is a column vector with entries of type #Scalar. - * The length of the vector is the size of #MatrixType. - */ - typedef Matrix VectorType; - - /** \brief Type for vector of complex scalar values eigenvalues as returned by betas(). - * - * This is a column vector with entries of type #ComplexScalar. - * The length of the vector is the size of #MatrixType. - */ - typedef Matrix ComplexVectorType; - - /** \brief Expression type for the eigenvalues as returned by eigenvalues(). - */ - typedef CwiseBinaryOp,ComplexVectorType,VectorType> EigenvalueType; - - /** \brief Type for matrix of eigenvectors as returned by eigenvectors(). - * - * This is a square matrix with entries of type #ComplexScalar. - * The size is the same as the size of #MatrixType. - */ - typedef Matrix EigenvectorsType; - - /** \brief Default constructor. - * - * The default constructor is useful in cases in which the user intends to - * perform decompositions via EigenSolver::compute(const MatrixType&, bool). - * - * \sa compute() for an example. - */ - GeneralizedEigenSolver() : m_eivec(), m_alphas(), m_betas(), m_isInitialized(false), m_realQZ(), m_matS(), m_tmp() {} - - /** \brief Default constructor with memory preallocation - * - * Like the default constructor but with preallocation of the internal data - * according to the specified problem \a size. - * \sa GeneralizedEigenSolver() - */ - GeneralizedEigenSolver(Index size) - : m_eivec(size, size), - m_alphas(size), - m_betas(size), - m_isInitialized(false), - m_eigenvectorsOk(false), - m_realQZ(size), - m_matS(size, size), - m_tmp(size) - {} - - /** \brief Constructor; computes the generalized eigendecomposition of given matrix pair. - * - * \param[in] A Square matrix whose eigendecomposition is to be computed. - * \param[in] B Square matrix whose eigendecomposition is to be computed. - * \param[in] computeEigenvectors If true, both the eigenvectors and the - * eigenvalues are computed; if false, only the eigenvalues are computed. - * - * This constructor calls compute() to compute the generalized eigenvalues - * and eigenvectors. - * - * \sa compute() - */ - GeneralizedEigenSolver(const MatrixType& A, const MatrixType& B, bool computeEigenvectors = true) - : m_eivec(A.rows(), A.cols()), - m_alphas(A.cols()), - m_betas(A.cols()), - m_isInitialized(false), - m_eigenvectorsOk(false), - m_realQZ(A.cols()), - m_matS(A.rows(), A.cols()), - m_tmp(A.cols()) - { - compute(A, B, computeEigenvectors); - } - - /* \brief Returns the computed generalized eigenvectors. - * - * \returns %Matrix whose columns are the (possibly complex) eigenvectors. - * - * \pre Either the constructor - * GeneralizedEigenSolver(const MatrixType&,const MatrixType&, bool) or the member function - * compute(const MatrixType&, const MatrixType& bool) has been called before, and - * \p computeEigenvectors was set to true (the default). - * - * Column \f$ k \f$ of the returned matrix is an eigenvector corresponding - * to eigenvalue number \f$ k \f$ as returned by eigenvalues(). The - * eigenvectors are normalized to have (Euclidean) norm equal to one. The - * matrix returned by this function is the matrix \f$ V \f$ in the - * generalized eigendecomposition \f$ A = B V D V^{-1} \f$, if it exists. - * - * \sa eigenvalues() - */ -// EigenvectorsType eigenvectors() const; - - /** \brief Returns an expression of the computed generalized eigenvalues. - * - * \returns An expression of the column vector containing the eigenvalues. - * - * It is a shortcut for \code this->alphas().cwiseQuotient(this->betas()); \endcode - * Not that betas might contain zeros. It is therefore not recommended to use this function, - * but rather directly deal with the alphas and betas vectors. - * - * \pre Either the constructor - * GeneralizedEigenSolver(const MatrixType&,const MatrixType&,bool) or the member function - * compute(const MatrixType&,const MatrixType&,bool) has been called before. - * - * The eigenvalues are repeated according to their algebraic multiplicity, - * so there are as many eigenvalues as rows in the matrix. The eigenvalues - * are not sorted in any particular order. - * - * \sa alphas(), betas(), eigenvectors() - */ - EigenvalueType eigenvalues() const - { - eigen_assert(m_isInitialized && "GeneralizedEigenSolver is not initialized."); - return EigenvalueType(m_alphas,m_betas); - } - - /** \returns A const reference to the vectors containing the alpha values - * - * This vector permits to reconstruct the j-th eigenvalues as alphas(i)/betas(j). - * - * \sa betas(), eigenvalues() */ - ComplexVectorType alphas() const - { - eigen_assert(m_isInitialized && "GeneralizedEigenSolver is not initialized."); - return m_alphas; - } - - /** \returns A const reference to the vectors containing the beta values - * - * This vector permits to reconstruct the j-th eigenvalues as alphas(i)/betas(j). - * - * \sa alphas(), eigenvalues() */ - VectorType betas() const - { - eigen_assert(m_isInitialized && "GeneralizedEigenSolver is not initialized."); - return m_betas; - } - - /** \brief Computes generalized eigendecomposition of given matrix. - * - * \param[in] A Square matrix whose eigendecomposition is to be computed. - * \param[in] B Square matrix whose eigendecomposition is to be computed. - * \param[in] computeEigenvectors If true, both the eigenvectors and the - * eigenvalues are computed; if false, only the eigenvalues are - * computed. - * \returns Reference to \c *this - * - * This function computes the eigenvalues of the real matrix \p matrix. - * The eigenvalues() function can be used to retrieve them. If - * \p computeEigenvectors is true, then the eigenvectors are also computed - * and can be retrieved by calling eigenvectors(). - * - * The matrix is first reduced to real generalized Schur form using the RealQZ - * class. The generalized Schur decomposition is then used to compute the eigenvalues - * and eigenvectors. - * - * The cost of the computation is dominated by the cost of the - * generalized Schur decomposition. - * - * This method reuses of the allocated data in the GeneralizedEigenSolver object. - */ - GeneralizedEigenSolver& compute(const MatrixType& A, const MatrixType& B, bool computeEigenvectors = true); - - ComputationInfo info() const - { - eigen_assert(m_isInitialized && "EigenSolver is not initialized."); - return m_realQZ.info(); - } - - /** Sets the maximal number of iterations allowed. - */ - GeneralizedEigenSolver& setMaxIterations(Index maxIters) - { - m_realQZ.setMaxIterations(maxIters); - return *this; - } - - protected: - MatrixType m_eivec; - ComplexVectorType m_alphas; - VectorType m_betas; - bool m_isInitialized; - bool m_eigenvectorsOk; - RealQZ m_realQZ; - MatrixType m_matS; - - typedef Matrix ColumnVectorType; - ColumnVectorType m_tmp; -}; - -//template -//typename GeneralizedEigenSolver::EigenvectorsType GeneralizedEigenSolver::eigenvectors() const -//{ -// eigen_assert(m_isInitialized && "EigenSolver is not initialized."); -// eigen_assert(m_eigenvectorsOk && "The eigenvectors have not been computed together with the eigenvalues."); -// Index n = m_eivec.cols(); -// EigenvectorsType matV(n,n); -// // TODO -// return matV; -//} - -template -GeneralizedEigenSolver& -GeneralizedEigenSolver::compute(const MatrixType& A, const MatrixType& B, bool computeEigenvectors) -{ - eigen_assert(A.cols() == A.rows() && B.cols() == A.rows() && B.cols() == B.rows()); - - // Reduce to generalized real Schur form: - // A = Q S Z and B = Q T Z - m_realQZ.compute(A, B, computeEigenvectors); - - if (m_realQZ.info() == Success) - { - m_matS = m_realQZ.matrixS(); - if (computeEigenvectors) - m_eivec = m_realQZ.matrixZ().transpose(); - - // Compute eigenvalues from matS - m_alphas.resize(A.cols()); - m_betas.resize(A.cols()); - Index i = 0; - while (i < A.cols()) - { - if (i == A.cols() - 1 || m_matS.coeff(i+1, i) == Scalar(0)) - { - m_alphas.coeffRef(i) = m_matS.coeff(i, i); - m_betas.coeffRef(i) = m_realQZ.matrixT().coeff(i,i); - ++i; - } - else - { - Scalar p = Scalar(0.5) * (m_matS.coeff(i, i) - m_matS.coeff(i+1, i+1)); - Scalar z = internal::sqrt(internal::abs(p * p + m_matS.coeff(i+1, i) * m_matS.coeff(i, i+1))); - m_alphas.coeffRef(i) = ComplexScalar(m_matS.coeff(i+1, i+1) + p, z); - m_alphas.coeffRef(i+1) = ComplexScalar(m_matS.coeff(i+1, i+1) + p, -z); - - m_betas.coeffRef(i) = m_realQZ.matrixT().coeff(i,i); - m_betas.coeffRef(i+1) = m_realQZ.matrixT().coeff(i,i); - i += 2; - } - } - } - - m_isInitialized = true; - m_eigenvectorsOk = false;//computeEigenvectors; - - return *this; -} - -} // end namespace Eigen - -#endif // EIGEN_GENERALIZEDEIGENSOLVER_H diff --git a/resources/3rdparty/eigen/Eigen/src/Eigenvalues/RealQZ.h b/resources/3rdparty/eigen/Eigen/src/Eigenvalues/RealQZ.h deleted file mode 100644 index fd6efdd56..000000000 --- a/resources/3rdparty/eigen/Eigen/src/Eigenvalues/RealQZ.h +++ /dev/null @@ -1,618 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2012 Alexey Korepanov -// -// 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_REAL_QZ_H -#define EIGEN_REAL_QZ_H - -namespace Eigen { - - /** \eigenvalues_module \ingroup Eigenvalues_Module - * - * - * \class RealQZ - * - * \brief Performs a real QZ decomposition of a pair of square matrices - * - * \tparam _MatrixType the type of the matrix of which we are computing the - * real QZ decomposition; this is expected to be an instantiation of the - * Matrix class template. - * - * Given a real square matrices A and B, this class computes the real QZ - * decomposition: \f$ A = Q S Z \f$, \f$ B = Q T Z \f$ where Q and Z are - * real orthogonal matrixes, T is upper-triangular matrix, and S is upper - * quasi-triangular matrix. An orthogonal matrix is a matrix whose - * inverse is equal to its transpose, \f$ U^{-1} = U^T \f$. A quasi-triangular - * matrix is a block-triangular matrix whose diagonal consists of 1-by-1 - * blocks and 2-by-2 blocks where further reduction is impossible due to - * complex eigenvalues. - * - * The eigenvalues of the pencil \f$ A - z B \f$ can be obtained from - * 1x1 and 2x2 blocks on the diagonals of S and T. - * - * Call the function compute() to compute the real QZ decomposition of a - * given pair of matrices. Alternatively, you can use the - * RealQZ(const MatrixType& B, const MatrixType& B, bool computeQZ) - * constructor which computes the real QZ decomposition at construction - * time. Once the decomposition is computed, you can use the matrixS(), - * matrixT(), matrixQ() and matrixZ() functions to retrieve the matrices - * S, T, Q and Z in the decomposition. If computeQZ==false, some time - * is saved by not computing matrices Q and Z. - * - * Example: \include RealQZ_compute.cpp - * Output: \include RealQZ_compute.out - * - * \note The implementation is based on the algorithm in "Matrix Computations" - * by Gene H. Golub and Charles F. Van Loan, and a paper "An algorithm for - * generalized eigenvalue problems" by C.B.Moler and G.W.Stewart. - * - * \sa class RealSchur, class ComplexSchur, class EigenSolver, class ComplexEigenSolver - */ - - template class RealQZ - { - public: - typedef _MatrixType MatrixType; - enum { - RowsAtCompileTime = MatrixType::RowsAtCompileTime, - ColsAtCompileTime = MatrixType::ColsAtCompileTime, - Options = MatrixType::Options, - MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime, - MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime - }; - typedef typename MatrixType::Scalar Scalar; - typedef std::complex::Real> ComplexScalar; - typedef typename MatrixType::Index Index; - - typedef Matrix EigenvalueType; - typedef Matrix ColumnVectorType; - - /** \brief Default constructor. - * - * \param [in] size Positive integer, size of the matrix whose QZ decomposition will be computed. - * - * The default constructor is useful in cases in which the user intends to - * perform decompositions via compute(). The \p size parameter is only - * used as a hint. It is not an error to give a wrong \p size, but it may - * impair performance. - * - * \sa compute() for an example. - */ - RealQZ(Index size = RowsAtCompileTime==Dynamic ? 1 : RowsAtCompileTime) : - m_S(size, size), - m_T(size, size), - m_Q(size, size), - m_Z(size, size), - m_workspace(size*2), - m_maxIters(400), - m_isInitialized(false) - { } - - /** \brief Constructor; computes real QZ decomposition of given matrices - * - * \param[in] A Matrix A. - * \param[in] B Matrix B. - * \param[in] computeQZ If false, A and Z are not computed. - * - * This constructor calls compute() to compute the QZ decomposition. - */ - RealQZ(const MatrixType& A, const MatrixType& B, bool computeQZ = true) : - m_S(A.rows(),A.cols()), - m_T(A.rows(),A.cols()), - m_Q(A.rows(),A.cols()), - m_Z(A.rows(),A.cols()), - m_workspace(A.rows()*2), - m_maxIters(400), - m_isInitialized(false) { - compute(A, B, computeQZ); - } - - /** \brief Returns matrix Q in the QZ decomposition. - * - * \returns A const reference to the matrix Q. - */ - const MatrixType& matrixQ() const { - eigen_assert(m_isInitialized && "RealQZ is not initialized."); - eigen_assert(m_computeQZ && "The matrices Q and Z have not been computed during the QZ decomposition."); - return m_Q; - } - - /** \brief Returns matrix Z in the QZ decomposition. - * - * \returns A const reference to the matrix Z. - */ - const MatrixType& matrixZ() const { - eigen_assert(m_isInitialized && "RealQZ is not initialized."); - eigen_assert(m_computeQZ && "The matrices Q and Z have not been computed during the QZ decomposition."); - return m_Z; - } - - /** \brief Returns matrix S in the QZ decomposition. - * - * \returns A const reference to the matrix S. - */ - const MatrixType& matrixS() const { - eigen_assert(m_isInitialized && "RealQZ is not initialized."); - return m_S; - } - - /** \brief Returns matrix S in the QZ decomposition. - * - * \returns A const reference to the matrix S. - */ - const MatrixType& matrixT() const { - eigen_assert(m_isInitialized && "RealQZ is not initialized."); - return m_T; - } - - /** \brief Computes QZ decomposition of given matrix. - * - * \param[in] A Matrix A. - * \param[in] B Matrix B. - * \param[in] computeQZ If false, A and Z are not computed. - * \returns Reference to \c *this - */ - RealQZ& compute(const MatrixType& A, const MatrixType& B, bool computeQZ = true); - - /** \brief Reports whether previous computation was successful. - * - * \returns \c Success if computation was succesful, \c NoConvergence otherwise. - */ - ComputationInfo info() const - { - eigen_assert(m_isInitialized && "RealQZ is not initialized."); - return m_info; - } - - /** \brief Returns number of performed QR-like iterations. - */ - Index iterations() const - { - eigen_assert(m_isInitialized && "RealQZ is not initialized."); - return m_global_iter; - } - - /** Sets the maximal number of iterations allowed to converge to one eigenvalue - * or decouple the problem. - */ - RealQZ& setMaxIterations(Index maxIters) - { - m_maxIters = maxIters; - return *this; - } - - private: - - MatrixType m_S, m_T, m_Q, m_Z; - Matrix m_workspace; - ComputationInfo m_info; - Index m_maxIters; - bool m_isInitialized; - bool m_computeQZ; - Scalar m_normOfT, m_normOfS; - Index m_global_iter; - - typedef Matrix Vector3s; - typedef Matrix Vector2s; - typedef Matrix Matrix2s; - typedef JacobiRotation JRs; - - void hessenbergTriangular(); - void computeNorms(); - Index findSmallSubdiagEntry(Index iu); - Index findSmallDiagEntry(Index f, Index l); - void splitOffTwoRows(Index i); - void pushDownZero(Index z, Index f, Index l); - void step(Index f, Index l, Index iter); - - }; // RealQZ - - /** \internal Reduces S and T to upper Hessenberg - triangular form */ - template - void RealQZ::hessenbergTriangular() - { - - const Index dim = m_S.cols(); - - // perform QR decomposition of T, overwrite T with R, save Q - HouseholderQR qrT(m_T); - m_T = qrT.matrixQR(); - m_T.template triangularView().setZero(); - m_Q = qrT.householderQ(); - // overwrite S with Q* S - m_S.applyOnTheLeft(m_Q.adjoint()); - // init Z as Identity - if (m_computeQZ) - m_Z = MatrixType::Identity(dim,dim); - // reduce S to upper Hessenberg with Givens rotations - for (Index j=0; j<=dim-3; j++) { - for (Index i=dim-1; i>=j+2; i--) { - JRs G; - // kill S(i,j) - if(m_S.coeff(i,j) != 0) - { - G.makeGivens(m_S.coeff(i-1,j), m_S.coeff(i,j), &m_S.coeffRef(i-1, j)); - m_S.coeffRef(i,j) = Scalar(0.0); - m_S.rightCols(dim-j-1).applyOnTheLeft(i-1,i,G.adjoint()); - m_T.rightCols(dim-i+1).applyOnTheLeft(i-1,i,G.adjoint()); - } - // update Q - if (m_computeQZ) - m_Q.applyOnTheRight(i-1,i,G); - // kill T(i,i-1) - if(m_T.coeff(i,i-1)!=Scalar(0)) - { - G.makeGivens(m_T.coeff(i,i), m_T.coeff(i,i-1), &m_T.coeffRef(i,i)); - m_T.coeffRef(i,i-1) = Scalar(0.0); - m_S.applyOnTheRight(i,i-1,G); - m_T.topRows(i).applyOnTheRight(i,i-1,G); - } - // update Z - if (m_computeQZ) - m_Z.applyOnTheLeft(i,i-1,G.adjoint()); - } - } - } - - /** \internal Computes vector L1 norms of S and T when in Hessenberg-Triangular form already */ - template - inline void RealQZ::computeNorms() - { - const Index size = m_S.cols(); - m_normOfS = Scalar(0.0); - m_normOfT = Scalar(0.0); - for (Index j = 0; j < size; ++j) - { - m_normOfS += m_S.col(j).segment(0, (std::min)(size,j+2)).cwiseAbs().sum(); - m_normOfT += m_T.row(j).segment(j, size - j).cwiseAbs().sum(); - } - } - - - /** \internal Look for single small sub-diagonal element S(res, res-1) and return res (or 0) */ - template - inline typename MatrixType::Index RealQZ::findSmallSubdiagEntry(Index iu) - { - Index res = iu; - while (res > 0) - { - Scalar s = internal::abs(m_S.coeff(res-1,res-1)) + internal::abs(m_S.coeff(res,res)); - if (s == Scalar(0.0)) - s = m_normOfS; - if (internal::abs(m_S.coeff(res,res-1)) < NumTraits::epsilon() * s) - break; - res--; - } - return res; - } - - /** \internal Look for single small diagonal element T(res, res) for res between f and l, and return res (or f-1) */ - template - inline typename MatrixType::Index RealQZ::findSmallDiagEntry(Index f, Index l) - { - Index res = l; - while (res >= f) { - if (internal::abs(m_T.coeff(res,res)) <= NumTraits::epsilon() * m_normOfT) - break; - res--; - } - return res; - } - - /** \internal decouple 2x2 diagonal block in rows i, i+1 if eigenvalues are real */ - template - inline void RealQZ::splitOffTwoRows(Index i) - { - const Index dim=m_S.cols(); - if (internal::abs(m_S.coeff(i+1,i)==Scalar(0))) - return; - Index z = findSmallDiagEntry(i,i+1); - if (z==i-1) - { - // block of (S T^{-1}) - Matrix2s STi = m_T.template block<2,2>(i,i).template triangularView(). - template solve(m_S.template block<2,2>(i,i)); - Scalar p = Scalar(0.5)*(STi(0,0)-STi(1,1)); - Scalar q = p*p + STi(1,0)*STi(0,1); - if (q>=0) { - Scalar z = internal::sqrt(q); - // one QR-like iteration for ABi - lambda I - // is enough - when we know exact eigenvalue in advance, - // convergence is immediate - JRs G; - if (p>=0) - G.makeGivens(p + z, STi(1,0)); - else - G.makeGivens(p - z, STi(1,0)); - m_S.rightCols(dim-i).applyOnTheLeft(i,i+1,G.adjoint()); - m_T.rightCols(dim-i).applyOnTheLeft(i,i+1,G.adjoint()); - // update Q - if (m_computeQZ) - m_Q.applyOnTheRight(i,i+1,G); - - G.makeGivens(m_T.coeff(i+1,i+1), m_T.coeff(i+1,i)); - m_S.topRows(i+2).applyOnTheRight(i+1,i,G); - m_T.topRows(i+2).applyOnTheRight(i+1,i,G); - // update Z - if (m_computeQZ) - m_Z.applyOnTheLeft(i+1,i,G.adjoint()); - - m_S.coeffRef(i+1,i) = Scalar(0.0); - m_T.coeffRef(i+1,i) = Scalar(0.0); - } - } - else - { - pushDownZero(z,i,i+1); - } - } - - /** \internal use zero in T(z,z) to zero S(l,l-1), working in block f..l */ - template - inline void RealQZ::pushDownZero(Index z, Index f, Index l) - { - JRs G; - const Index dim = m_S.cols(); - for (Index zz=z; zzf ? (zz-1) : zz; - G.makeGivens(m_T.coeff(zz, zz+1), m_T.coeff(zz+1, zz+1)); - m_S.rightCols(dim-firstColS).applyOnTheLeft(zz,zz+1,G.adjoint()); - m_T.rightCols(dim-zz).applyOnTheLeft(zz,zz+1,G.adjoint()); - m_T.coeffRef(zz+1,zz+1) = Scalar(0.0); - // update Q - if (m_computeQZ) - m_Q.applyOnTheRight(zz,zz+1,G); - // kill S(zz+1, zz-1) - if (zz>f) - { - G.makeGivens(m_S.coeff(zz+1, zz), m_S.coeff(zz+1,zz-1)); - m_S.topRows(zz+2).applyOnTheRight(zz, zz-1,G); - m_T.topRows(zz+1).applyOnTheRight(zz, zz-1,G); - m_S.coeffRef(zz+1,zz-1) = Scalar(0.0); - // update Z - if (m_computeQZ) - m_Z.applyOnTheLeft(zz,zz-1,G.adjoint()); - } - } - // finally kill S(l,l-1) - G.makeGivens(m_S.coeff(l,l), m_S.coeff(l,l-1)); - m_S.applyOnTheRight(l,l-1,G); - m_T.applyOnTheRight(l,l-1,G); - m_S.coeffRef(l,l-1)=Scalar(0.0); - // update Z - if (m_computeQZ) - m_Z.applyOnTheLeft(l,l-1,G.adjoint()); - } - - /** \internal QR-like iterative step for block f..l */ - template - inline void RealQZ::step(Index f, Index l, Index iter) { - const Index dim = m_S.cols(); - - // x, y, z - Scalar x, y, z; - if (iter==10) - { - // Wilkinson ad hoc shift - const Scalar - a11=m_S.coeff(f+0,f+0), a12=m_S.coeff(f+0,f+1), - a21=m_S.coeff(f+1,f+0), a22=m_S.coeff(f+1,f+1), a32=m_S.coeff(f+2,f+1), - b12=m_T.coeff(f+0,f+1), - b11i=Scalar(1.0)/m_T.coeff(f+0,f+0), - b22i=Scalar(1.0)/m_T.coeff(f+1,f+1), - a87=m_S.coeff(l-1,l-2), - a98=m_S.coeff(l-0,l-1), - b77i=Scalar(1.0)/m_T.coeff(l-2,l-2), - b88i=Scalar(1.0)/m_T.coeff(l-1,l-1); - Scalar ss = internal::abs(a87*b77i) + internal::abs(a98*b88i), - lpl = Scalar(1.5)*ss, - ll = ss*ss; - x = ll + a11*a11*b11i*b11i - lpl*a11*b11i + a12*a21*b11i*b22i - - a11*a21*b12*b11i*b11i*b22i; - y = a11*a21*b11i*b11i - lpl*a21*b11i + a21*a22*b11i*b22i - - a21*a21*b12*b11i*b11i*b22i; - z = a21*a32*b11i*b22i; - } - else if (iter==16) - { - // another exceptional shift - x = m_S.coeff(f,f)/m_T.coeff(f,f)-m_S.coeff(l,l)/m_T.coeff(l,l) + m_S.coeff(l,l-1)*m_T.coeff(l-1,l) / - (m_T.coeff(l-1,l-1)*m_T.coeff(l,l)); - y = m_S.coeff(f+1,f)/m_T.coeff(f,f); - z = 0; - } - else if (iter>23 && !(iter%8)) - { - // extremely exceptional shift - x = internal::random(-1.0,1.0); - y = internal::random(-1.0,1.0); - z = internal::random(-1.0,1.0); - } - else - { - // Compute the shifts: (x,y,z,0...) = (AB^-1 - l1 I) (AB^-1 - l2 I) e1 - // where l1 and l2 are the eigenvalues of the 2x2 matrix C = U V^-1 where - // U and V are 2x2 bottom right sub matrices of A and B. Thus: - // = AB^-1AB^-1 + l1 l2 I - (l1+l2)(AB^-1) - // = AB^-1AB^-1 + det(M) - tr(M)(AB^-1) - // Since we are only interested in having x, y, z with a correct ratio, we have: - const Scalar - a11 = m_S.coeff(f,f), a12 = m_S.coeff(f,f+1), - a21 = m_S.coeff(f+1,f), a22 = m_S.coeff(f+1,f+1), - a32 = m_S.coeff(f+2,f+1), - - a88 = m_S.coeff(l-1,l-1), a89 = m_S.coeff(l-1,l), - a98 = m_S.coeff(l,l-1), a99 = m_S.coeff(l,l), - - b11 = m_T.coeff(f,f), b12 = m_T.coeff(f,f+1), - b22 = m_T.coeff(f+1,f+1), - - b88 = m_T.coeff(l-1,l-1), b89 = m_T.coeff(l-1,l), - b99 = m_T.coeff(l,l); - - x = ( (a88/b88 - a11/b11)*(a99/b99 - a11/b11) - (a89/b99)*(a98/b88) + (a98/b88)*(b89/b99)*(a11/b11) ) * (b11/a21) - + a12/b22 - (a11/b11)*(b12/b22); - y = (a22/b22-a11/b11) - (a21/b11)*(b12/b22) - (a88/b88-a11/b11) - (a99/b99-a11/b11) + (a98/b88)*(b89/b99); - z = a32/b22; - } - - JRs G; - - for (Index k=f; k<=l-2; k++) - { - // variables for Householder reflections - Vector2s essential2; - Scalar tau, beta; - - Vector3s hr(x,y,z); - - // Q_k to annihilate S(k+1,k-1) and S(k+2,k-1) - hr.makeHouseholderInPlace(tau, beta); - essential2 = hr.template bottomRows<2>(); - Index fc=(std::max)(k-1,Index(0)); // first col to update - m_S.template middleRows<3>(k).rightCols(dim-fc).applyHouseholderOnTheLeft(essential2, tau, m_workspace.data()); - m_T.template middleRows<3>(k).rightCols(dim-fc).applyHouseholderOnTheLeft(essential2, tau, m_workspace.data()); - if (m_computeQZ) - m_Q.template middleCols<3>(k).applyHouseholderOnTheRight(essential2, tau, m_workspace.data()); - if (k>f) - m_S.coeffRef(k+2,k-1) = m_S.coeffRef(k+1,k-1) = Scalar(0.0); - - // Z_{k1} to annihilate T(k+2,k+1) and T(k+2,k) - hr << m_T.coeff(k+2,k+2),m_T.coeff(k+2,k),m_T.coeff(k+2,k+1); - hr.makeHouseholderInPlace(tau, beta); - essential2 = hr.template bottomRows<2>(); - { - Index lr = (std::min)(k+4,dim); // last row to update - Map > tmp(m_workspace.data(),lr); - // S - tmp = m_S.template middleCols<2>(k).topRows(lr) * essential2; - tmp += m_S.col(k+2).head(lr); - m_S.col(k+2).head(lr) -= tau*tmp; - m_S.template middleCols<2>(k).topRows(lr) -= (tau*tmp) * essential2.adjoint(); - // T - tmp = m_T.template middleCols<2>(k).topRows(lr) * essential2; - tmp += m_T.col(k+2).head(lr); - m_T.col(k+2).head(lr) -= tau*tmp; - m_T.template middleCols<2>(k).topRows(lr) -= (tau*tmp) * essential2.adjoint(); - } - if (m_computeQZ) - { - // Z - Map > tmp(m_workspace.data(),dim); - tmp = essential2.adjoint()*(m_Z.template middleRows<2>(k)); - tmp += m_Z.row(k+2); - m_Z.row(k+2) -= tau*tmp; - m_Z.template middleRows<2>(k) -= essential2 * (tau*tmp); - } - m_T.coeffRef(k+2,k) = m_T.coeffRef(k+2,k+1) = Scalar(0.0); - - // Z_{k2} to annihilate T(k+1,k) - G.makeGivens(m_T.coeff(k+1,k+1), m_T.coeff(k+1,k)); - m_S.applyOnTheRight(k+1,k,G); - m_T.applyOnTheRight(k+1,k,G); - // update Z - if (m_computeQZ) - m_Z.applyOnTheLeft(k+1,k,G.adjoint()); - m_T.coeffRef(k+1,k) = Scalar(0.0); - - // update x,y,z - x = m_S.coeff(k+1,k); - y = m_S.coeff(k+2,k); - if (k < l-2) - z = m_S.coeff(k+3,k); - } // loop over k - - // Q_{n-1} to annihilate y = S(l,l-2) - G.makeGivens(x,y); - m_S.applyOnTheLeft(l-1,l,G.adjoint()); - m_T.applyOnTheLeft(l-1,l,G.adjoint()); - if (m_computeQZ) - m_Q.applyOnTheRight(l-1,l,G); - m_S.coeffRef(l,l-2) = Scalar(0.0); - - // Z_{n-1} to annihilate T(l,l-1) - G.makeGivens(m_T.coeff(l,l),m_T.coeff(l,l-1)); - m_S.applyOnTheRight(l,l-1,G); - m_T.applyOnTheRight(l,l-1,G); - if (m_computeQZ) - m_Z.applyOnTheLeft(l,l-1,G.adjoint()); - m_T.coeffRef(l,l-1) = Scalar(0.0); - } - - - template - RealQZ& RealQZ::compute(const MatrixType& A_in, const MatrixType& B_in, bool computeQZ) - { - - const Index dim = A_in.cols(); - - assert (A_in.rows()==dim && A_in.cols()==dim - && B_in.rows()==dim && B_in.cols()==dim - && "Need square matrices of the same dimension"); - - m_isInitialized = true; - m_computeQZ = computeQZ; - m_S = A_in; m_T = B_in; - m_workspace.resize(dim*2); - m_global_iter = 0; - - // entrance point: hessenberg triangular decomposition - hessenbergTriangular(); - // compute L1 vector norms of T, S into m_normOfS, m_normOfT - computeNorms(); - - Index l = dim-1, - f, - local_iter = 0; - - while (l>0 && local_iter0) m_S.coeffRef(f,f-1) = Scalar(0.0); - if (f == l) // One root found - { - l--; - local_iter = 0; - } - else if (f == l-1) // Two roots found - { - splitOffTwoRows(f); - l -= 2; - local_iter = 0; - } - else // No convergence yet - { - // if there's zero on diagonal of T, we can isolate an eigenvalue with Givens rotations - Index z = findSmallDiagEntry(f,l); - if (z>=f) - { - // zero found - pushDownZero(z,f,l); - } - else - { - // We are sure now that S.block(f,f, l-f+1,l-f+1) is underuced upper-Hessenberg - // and T.block(f,f, l-f+1,l-f+1) is invertible uper-triangular, which allows to - // apply a QR-like iteration to rows and columns f..l. - step(f,l, local_iter); - local_iter++; - m_global_iter++; - } - } - } - // check if we converged before reaching iterations limit - m_info = (local_iter -// -// 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 METIS_SUPPORT_H -#define METIS_SUPPORT_H - -namespace Eigen { -/** - * Get the fill-reducing ordering from the METIS package - * - * If A is the original matrix and Ap is the permuted matrix, - * the fill-reducing permutation is defined as follows : - * Row (column) i of A is the matperm(i) row (column) of Ap. - * WARNING: As computed by METIS, this corresponds to the vector iperm (instead of perm) - */ -template -class MetisOrdering -{ -public: - typedef PermutationMatrix PermutationType; - typedef Matrix IndexVector; - - template - void get_symmetrized_graph(const MatrixType& A) - { - Index m = A.cols(); - - // Get the transpose of the input matrix - MatrixType At = A.transpose(); - // Get the number of nonzeros elements in each row/col of At+A - Index TotNz = 0; - IndexVector visited(m); - visited.setConstant(-1); - for (int j = 0; j < m; j++) - { - // Compute the union structure of of A(j,:) and At(j,:) - visited(j) = j; // Do not include the diagonal element - // Get the nonzeros in row/column j of A - for (typename MatrixType::InnerIterator it(A, j); it; ++it) - { - Index idx = it.index(); // Get the row index (for column major) or column index (for row major) - if (visited(idx) != j ) - { - visited(idx) = j; - ++TotNz; - } - } - //Get the nonzeros in row/column j of At - for (typename MatrixType::InnerIterator it(At, j); it; ++it) - { - Index idx = it.index(); - if(visited(idx) != j) - { - visited(idx) = j; - ++TotNz; - } - } - } - // Reserve place for A + At - m_indexPtr.resize(m+1); - m_innerIndices.resize(TotNz); - - // Now compute the real adjacency list of each column/row - visited.setConstant(-1); - Index CurNz = 0; - for (int j = 0; j < m; j++) - { - m_indexPtr(j) = CurNz; - - visited(j) = j; // Do not include the diagonal element - // Add the pattern of row/column j of A to A+At - for (typename MatrixType::InnerIterator it(A,j); it; ++it) - { - Index idx = it.index(); // Get the row index (for column major) or column index (for row major) - if (visited(idx) != j ) - { - visited(idx) = j; - m_innerIndices(CurNz) = idx; - CurNz++; - } - } - //Add the pattern of row/column j of At to A+At - for (typename MatrixType::InnerIterator it(At, j); it; ++it) - { - Index idx = it.index(); - if(visited(idx) != j) - { - visited(idx) = j; - m_innerIndices(CurNz) = idx; - ++CurNz; - } - } - } - m_indexPtr(m) = CurNz; - } - - template - void operator() (const MatrixType& A, PermutationType& matperm) - { - Index m = A.cols(); - IndexVector perm(m),iperm(m); - // First, symmetrize the matrix graph. - get_symmetrized_graph(A); - int output_error; - - // Call the fill-reducing routine from METIS - output_error = METIS_NodeND(&m, m_indexPtr.data(), m_innerIndices.data(), NULL, NULL, perm.data(), iperm.data()); - - if(output_error != METIS_OK) - { - //FIXME The ordering interface should define a class of possible errors - std::cerr << "ERROR WHILE CALLING THE METIS PACKAGE \n"; - return; - } - - // Get the fill-reducing permutation - //NOTE: If Ap is the permuted matrix then perm and iperm vectors are defined as follows - // Row (column) i of Ap is the perm(i) row(column) of A, and row (column) i of A is the iperm(i) row(column) of Ap - - // To be consistent with the use of the permutation in SparseLU module, we thus keep the iperm vector - matperm.resize(m); - for (int j = 0; j < m; j++) - matperm.indices()(j) = iperm(j); - - } - - protected: - IndexVector m_indexPtr; // Pointer to the adjacenccy list of each row/column - IndexVector m_innerIndices; // Adjacency list -}; - -}// end namespace eigen -#endif \ No newline at end of file diff --git a/resources/3rdparty/eigen/Eigen/src/OrderingMethods/Eigen_Colamd.h b/resources/3rdparty/eigen/Eigen/src/OrderingMethods/Eigen_Colamd.h deleted file mode 100644 index 6dc1f280d..000000000 --- a/resources/3rdparty/eigen/Eigen/src/OrderingMethods/Eigen_Colamd.h +++ /dev/null @@ -1,1849 +0,0 @@ -// // This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2012 Desire Nuentsa Wakam -// -// 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 file is modified from the colamd/symamd library. The copyright is below - -// The authors of the code itself are Stefan I. Larimore and Timothy A. -// Davis (davis@cise.ufl.edu), University of Florida. The algorithm was -// developed in collaboration with John Gilbert, Xerox PARC, and Esmond -// Ng, Oak Ridge National Laboratory. -// -// Date: -// -// September 8, 2003. Version 2.3. -// -// Acknowledgements: -// -// This work was supported by the National Science Foundation, under -// grants DMS-9504974 and DMS-9803599. -// -// Notice: -// -// Copyright (c) 1998-2003 by the University of Florida. -// All Rights Reserved. -// -// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY -// EXPRESSED OR IMPLIED. ANY USE IS AT YOUR OWN RISK. -// -// Permission is hereby granted to use, copy, modify, and/or distribute -// this program, provided that the Copyright, this License, and the -// Availability of the original version is retained on all copies and made -// accessible to the end-user of any code or package that includes COLAMD -// or any modified version of COLAMD. -// -// Availability: -// -// The colamd/symamd library is available at -// -// http://www.cise.ufl.edu/research/sparse/colamd/ - -// This is the http://www.cise.ufl.edu/research/sparse/colamd/colamd.h -// file. It is required by the colamd.c, colamdmex.c, and symamdmex.c -// files, and by any C code that calls the routines whose prototypes are -// listed below, or that uses the colamd/symamd definitions listed below. - -#ifndef EIGEN_COLAMD_H -#define EIGEN_COLAMD_H -namespace internal { -/* Ensure that debugging is turned off: */ -#ifndef COLAMD_NDEBUG -#define COLAMD_NDEBUG -#endif /* NDEBUG */ -/* ========================================================================== */ -/* === Knob and statistics definitions ====================================== */ -/* ========================================================================== */ - -/* size of the knobs [ ] array. Only knobs [0..1] are currently used. */ -#define COLAMD_KNOBS 20 - -/* number of output statistics. Only stats [0..6] are currently used. */ -#define COLAMD_STATS 20 - -/* knobs [0] and stats [0]: dense row knob and output statistic. */ -#define COLAMD_DENSE_ROW 0 - -/* knobs [1] and stats [1]: dense column knob and output statistic. */ -#define COLAMD_DENSE_COL 1 - -/* stats [2]: memory defragmentation count output statistic */ -#define COLAMD_DEFRAG_COUNT 2 - -/* stats [3]: colamd status: zero OK, > 0 warning or notice, < 0 error */ -#define COLAMD_STATUS 3 - -/* stats [4..6]: error info, or info on jumbled columns */ -#define COLAMD_INFO1 4 -#define COLAMD_INFO2 5 -#define COLAMD_INFO3 6 - -/* error codes returned in stats [3]: */ -#define COLAMD_OK (0) -#define COLAMD_OK_BUT_JUMBLED (1) -#define COLAMD_ERROR_A_not_present (-1) -#define COLAMD_ERROR_p_not_present (-2) -#define COLAMD_ERROR_nrow_negative (-3) -#define COLAMD_ERROR_ncol_negative (-4) -#define COLAMD_ERROR_nnz_negative (-5) -#define COLAMD_ERROR_p0_nonzero (-6) -#define COLAMD_ERROR_A_too_small (-7) -#define COLAMD_ERROR_col_length_negative (-8) -#define COLAMD_ERROR_row_index_out_of_bounds (-9) -#define COLAMD_ERROR_out_of_memory (-10) -#define COLAMD_ERROR_internal_error (-999) - -/* ========================================================================== */ -/* === Definitions ========================================================== */ -/* ========================================================================== */ - -#define COLAMD_MAX(a,b) (((a) > (b)) ? (a) : (b)) -#define COLAMD_MIN(a,b) (((a) < (b)) ? (a) : (b)) - -#define ONES_COMPLEMENT(r) (-(r)-1) - -/* -------------------------------------------------------------------------- */ - -#define COLAMD_EMPTY (-1) - -/* Row and column status */ -#define ALIVE (0) -#define DEAD (-1) - -/* Column status */ -#define DEAD_PRINCIPAL (-1) -#define DEAD_NON_PRINCIPAL (-2) - -/* Macros for row and column status update and checking. */ -#define ROW_IS_DEAD(r) ROW_IS_MARKED_DEAD (Row[r].shared2.mark) -#define ROW_IS_MARKED_DEAD(row_mark) (row_mark < ALIVE) -#define ROW_IS_ALIVE(r) (Row [r].shared2.mark >= ALIVE) -#define COL_IS_DEAD(c) (Col [c].start < ALIVE) -#define COL_IS_ALIVE(c) (Col [c].start >= ALIVE) -#define COL_IS_DEAD_PRINCIPAL(c) (Col [c].start == DEAD_PRINCIPAL) -#define KILL_ROW(r) { Row [r].shared2.mark = DEAD ; } -#define KILL_PRINCIPAL_COL(c) { Col [c].start = DEAD_PRINCIPAL ; } -#define KILL_NON_PRINCIPAL_COL(c) { Col [c].start = DEAD_NON_PRINCIPAL ; } - -/* ========================================================================== */ -/* === Colamd reporting mechanism =========================================== */ -/* ========================================================================== */ - - // == Row and Column structures == -typedef struct colamd_col_struct -{ - int start ; /* index for A of first row in this column, or DEAD */ - /* if column is dead */ - int length ; /* number of rows in this column */ - union - { - int thickness ; /* number of original columns represented by this */ - /* col, if the column is alive */ - int parent ; /* parent in parent tree super-column structure, if */ - /* the column is dead */ - } shared1 ; - union - { - int score ; /* the score used to maintain heap, if col is alive */ - int order ; /* pivot ordering of this column, if col is dead */ - } shared2 ; - union - { - int headhash ; /* head of a hash bucket, if col is at the head of */ - /* a degree list */ - int hash ; /* hash value, if col is not in a degree list */ - int prev ; /* previous column in degree list, if col is in a */ - /* degree list (but not at the head of a degree list) */ - } shared3 ; - union - { - int degree_next ; /* next column, if col is in a degree list */ - int hash_next ; /* next column, if col is in a hash list */ - } shared4 ; - -} colamd_col ; - -typedef struct Colamd_Row_struct -{ - int start ; /* index for A of first col in this row */ - int length ; /* number of principal columns in this row */ - union - { - int degree ; /* number of principal & non-principal columns in row */ - int p ; /* used as a row pointer in init_rows_cols () */ - } shared1 ; - union - { - int mark ; /* for computing set differences and marking dead rows*/ - int first_column ;/* first column in row (used in garbage collection) */ - } shared2 ; - -} Colamd_Row ; - -/* ========================================================================== */ -/* === Colamd recommended memory size ======================================= */ -/* ========================================================================== */ - -/* - The recommended length Alen of the array A passed to colamd is given by - the COLAMD_RECOMMENDED (nnz, n_row, n_col) macro. It returns -1 if any - argument is negative. 2*nnz space is required for the row and column - indices of the matrix. colamd_c (n_col) + colamd_r (n_row) space is - required for the Col and Row arrays, respectively, which are internal to - colamd. An additional n_col space is the minimal amount of "elbow room", - and nnz/5 more space is recommended for run time efficiency. - - This macro is not needed when using symamd. - - Explicit typecast to int added Sept. 23, 2002, COLAMD version 2.2, to avoid - gcc -pedantic warning messages. -*/ - -inline int colamd_c(int n_col) -{ return int( ((n_col) + 1) * sizeof (colamd_col) / sizeof (int) ) ; } - -inline int colamd_r(int n_row) -{ return int(((n_row) + 1) * sizeof (Colamd_Row) / sizeof (int)); } - - // Various routines -inline int colamd_recommended (int nnz, int n_row, int n_col) ; - -static inline void colamd_set_defaults (double knobs [COLAMD_KNOBS]) ; - -static bool colamd (int n_row, int n_col, int Alen, int A [], int p [], double knobs[COLAMD_KNOBS], int stats [COLAMD_STATS]) ; - -static int init_rows_cols (int n_row, int n_col, Colamd_Row Row [], colamd_col col [], int A [], int p [], int stats[COLAMD_STATS] ); - -static void init_scoring (int n_row, int n_col, Colamd_Row Row [], colamd_col Col [], int A [], int head [], double knobs[COLAMD_KNOBS], int *p_n_row2, int *p_n_col2, int *p_max_deg); - -static int find_ordering (int n_row, int n_col, int Alen, Colamd_Row Row [], colamd_col Col [], int A [], int head [], int n_col2, int max_deg, int pfree); - -static void order_children (int n_col, colamd_col Col [], int p []); - -static void detect_super_cols ( - colamd_col Col [], - int A [], - int head [], - int row_start, - int row_length ) ; - -static int garbage_collection (int n_row, int n_col, Colamd_Row Row [], colamd_col Col [], int A [], int *pfree) ; - -static inline int clear_mark (int n_row, Colamd_Row Row [] ) ; - -/* === No debugging ========================================================= */ - -#define COLAMD_DEBUG0(params) ; -#define COLAMD_DEBUG1(params) ; -#define COLAMD_DEBUG2(params) ; -#define COLAMD_DEBUG3(params) ; -#define COLAMD_DEBUG4(params) ; - -#define COLAMD_ASSERT(expression) ((void) 0) - - -/** - * \brief Returns the recommended value of Alen - * - * Returns recommended value of Alen for use by colamd. - * Returns -1 if any input argument is negative. - * The use of this routine or macro is optional. - * Note that the macro uses its arguments more than once, - * so be careful for side effects, if you pass expressions as arguments to COLAMD_RECOMMENDED. - * - * \param nnz nonzeros in A - * \param n_row number of rows in A - * \param n_col number of columns in A - * \return recommended value of Alen for use by colamd - */ -inline int colamd_recommended ( int nnz, int n_row, int n_col) -{ - if ((nnz) < 0 || (n_row) < 0 || (n_col) < 0) - return (-1); - else - return (2 * (nnz) + colamd_c (n_col) + colamd_r (n_row) + (n_col) + ((nnz) / 5)); -} - -/** - * \brief set default parameters The use of this routine is optional. - * - * Colamd: rows with more than (knobs [COLAMD_DENSE_ROW] * n_col) - * entries are removed prior to ordering. Columns with more than - * (knobs [COLAMD_DENSE_COL] * n_row) entries are removed prior to - * ordering, and placed last in the output column ordering. - * - * COLAMD_DENSE_ROW and COLAMD_DENSE_COL are defined as 0 and 1, - * respectively, in colamd.h. Default values of these two knobs - * are both 0.5. Currently, only knobs [0] and knobs [1] are - * used, but future versions may use more knobs. If so, they will - * be properly set to their defaults by the future version of - * colamd_set_defaults, so that the code that calls colamd will - * not need to change, assuming that you either use - * colamd_set_defaults, or pass a (double *) NULL pointer as the - * knobs array to colamd or symamd. - * - * \param knobs parameter settings for colamd - */ -static inline void colamd_set_defaults(double knobs[COLAMD_KNOBS]) -{ - /* === Local variables ================================================== */ - - int i ; - - if (!knobs) - { - return ; /* no knobs to initialize */ - } - for (i = 0 ; i < COLAMD_KNOBS ; i++) - { - knobs [i] = 0 ; - } - knobs [COLAMD_DENSE_ROW] = 0.5 ; /* ignore rows over 50% dense */ - knobs [COLAMD_DENSE_COL] = 0.5 ; /* ignore columns over 50% dense */ -} - -/** - * \brief Computes a column ordering using the column approximate minimum degree ordering - * - * Computes a column ordering (Q) of A such that P(AQ)=LU or - * (AQ)'AQ=LL' have less fill-in and require fewer floating point - * operations than factorizing the unpermuted matrix A or A'A, - * respectively. - * - * - * \param n_row number of rows in A - * \param n_col number of columns in A - * \param Alen, size of the array A - * \param A row indices of the matrix, of size ALen - * \param p column pointers of A, of size n_col+1 - * \param knobs parameter settings for colamd - * \param stats colamd output statistics and error codes - */ -static bool colamd(int n_row, int n_col, int Alen, int *A, int *p, double knobs[COLAMD_KNOBS], int stats[COLAMD_STATS]) -{ - /* === Local variables ================================================== */ - - int i ; /* loop index */ - int nnz ; /* nonzeros in A */ - int Row_size ; /* size of Row [], in integers */ - int Col_size ; /* size of Col [], in integers */ - int need ; /* minimum required length of A */ - Colamd_Row *Row ; /* pointer into A of Row [0..n_row] array */ - colamd_col *Col ; /* pointer into A of Col [0..n_col] array */ - int n_col2 ; /* number of non-dense, non-empty columns */ - int n_row2 ; /* number of non-dense, non-empty rows */ - int ngarbage ; /* number of garbage collections performed */ - int max_deg ; /* maximum row degree */ - double default_knobs [COLAMD_KNOBS] ; /* default knobs array */ - - - /* === Check the input arguments ======================================== */ - - if (!stats) - { - COLAMD_DEBUG0 (("colamd: stats not present\n")) ; - return (false) ; - } - for (i = 0 ; i < COLAMD_STATS ; i++) - { - stats [i] = 0 ; - } - stats [COLAMD_STATUS] = COLAMD_OK ; - stats [COLAMD_INFO1] = -1 ; - stats [COLAMD_INFO2] = -1 ; - - if (!A) /* A is not present */ - { - stats [COLAMD_STATUS] = COLAMD_ERROR_A_not_present ; - COLAMD_DEBUG0 (("colamd: A not present\n")) ; - return (false) ; - } - - if (!p) /* p is not present */ - { - stats [COLAMD_STATUS] = COLAMD_ERROR_p_not_present ; - COLAMD_DEBUG0 (("colamd: p not present\n")) ; - return (false) ; - } - - if (n_row < 0) /* n_row must be >= 0 */ - { - stats [COLAMD_STATUS] = COLAMD_ERROR_nrow_negative ; - stats [COLAMD_INFO1] = n_row ; - COLAMD_DEBUG0 (("colamd: nrow negative %d\n", n_row)) ; - return (false) ; - } - - if (n_col < 0) /* n_col must be >= 0 */ - { - stats [COLAMD_STATUS] = COLAMD_ERROR_ncol_negative ; - stats [COLAMD_INFO1] = n_col ; - COLAMD_DEBUG0 (("colamd: ncol negative %d\n", n_col)) ; - return (false) ; - } - - nnz = p [n_col] ; - if (nnz < 0) /* nnz must be >= 0 */ - { - stats [COLAMD_STATUS] = COLAMD_ERROR_nnz_negative ; - stats [COLAMD_INFO1] = nnz ; - COLAMD_DEBUG0 (("colamd: number of entries negative %d\n", nnz)) ; - return (false) ; - } - - if (p [0] != 0) - { - stats [COLAMD_STATUS] = COLAMD_ERROR_p0_nonzero ; - stats [COLAMD_INFO1] = p [0] ; - COLAMD_DEBUG0 (("colamd: p[0] not zero %d\n", p [0])) ; - return (false) ; - } - - /* === If no knobs, set default knobs =================================== */ - - if (!knobs) - { - colamd_set_defaults (default_knobs) ; - knobs = default_knobs ; - } - - /* === Allocate the Row and Col arrays from array A ===================== */ - - Col_size = colamd_c (n_col) ; - Row_size = colamd_r (n_row) ; - need = 2*nnz + n_col + Col_size + Row_size ; - - if (need > Alen) - { - /* not enough space in array A to perform the ordering */ - stats [COLAMD_STATUS] = COLAMD_ERROR_A_too_small ; - stats [COLAMD_INFO1] = need ; - stats [COLAMD_INFO2] = Alen ; - COLAMD_DEBUG0 (("colamd: Need Alen >= %d, given only Alen = %d\n", need,Alen)); - return (false) ; - } - - Alen -= Col_size + Row_size ; - Col = (colamd_col *) &A [Alen] ; - Row = (Colamd_Row *) &A [Alen + Col_size] ; - - /* === Construct the row and column data structures ===================== */ - - if (!init_rows_cols (n_row, n_col, Row, Col, A, p, stats)) - { - /* input matrix is invalid */ - COLAMD_DEBUG0 (("colamd: Matrix invalid\n")) ; - return (false) ; - } - - /* === Initialize scores, kill dense rows/columns ======================= */ - - init_scoring (n_row, n_col, Row, Col, A, p, knobs, - &n_row2, &n_col2, &max_deg) ; - - /* === Order the supercolumns =========================================== */ - - ngarbage = find_ordering (n_row, n_col, Alen, Row, Col, A, p, - n_col2, max_deg, 2*nnz) ; - - /* === Order the non-principal columns ================================== */ - - order_children (n_col, Col, p) ; - - /* === Return statistics in stats ======================================= */ - - stats [COLAMD_DENSE_ROW] = n_row - n_row2 ; - stats [COLAMD_DENSE_COL] = n_col - n_col2 ; - stats [COLAMD_DEFRAG_COUNT] = ngarbage ; - COLAMD_DEBUG0 (("colamd: done.\n")) ; - return (true) ; -} - -/* ========================================================================== */ -/* === NON-USER-CALLABLE ROUTINES: ========================================== */ -/* ========================================================================== */ - -/* There are no user-callable routines beyond this point in the file */ - - -/* ========================================================================== */ -/* === init_rows_cols ======================================================= */ -/* ========================================================================== */ - -/* - Takes the column form of the matrix in A and creates the row form of the - matrix. Also, row and column attributes are stored in the Col and Row - structs. If the columns are un-sorted or contain duplicate row indices, - this routine will also sort and remove duplicate row indices from the - column form of the matrix. Returns false if the matrix is invalid, - true otherwise. Not user-callable. -*/ - - static int init_rows_cols /* returns true if OK, or false otherwise */ -( - /* === Parameters ======================================================= */ - - int n_row, /* number of rows of A */ - int n_col, /* number of columns of A */ - Colamd_Row Row [], /* of size n_row+1 */ - colamd_col Col [], /* of size n_col+1 */ - int A [], /* row indices of A, of size Alen */ - int p [], /* pointers to columns in A, of size n_col+1 */ - int stats [COLAMD_STATS] /* colamd statistics */ -) -{ - /* === Local variables ================================================== */ - - int col ; /* a column index */ - int row ; /* a row index */ - int *cp ; /* a column pointer */ - int *cp_end ; /* a pointer to the end of a column */ - int *rp ; /* a row pointer */ - int *rp_end ; /* a pointer to the end of a row */ - int last_row ; /* previous row */ - - /* === Initialize columns, and check column pointers ==================== */ - - for (col = 0 ; col < n_col ; col++) - { - Col [col].start = p [col] ; - Col [col].length = p [col+1] - p [col] ; - - if (Col [col].length < 0) - { - /* column pointers must be non-decreasing */ - stats [COLAMD_STATUS] = COLAMD_ERROR_col_length_negative ; - stats [COLAMD_INFO1] = col ; - stats [COLAMD_INFO2] = Col [col].length ; - COLAMD_DEBUG0 (("colamd: col %d length %d < 0\n", col, Col [col].length)) ; - return (false) ; - } - - Col [col].shared1.thickness = 1 ; - Col [col].shared2.score = 0 ; - Col [col].shared3.prev = COLAMD_EMPTY ; - Col [col].shared4.degree_next = COLAMD_EMPTY ; - } - - /* p [0..n_col] no longer needed, used as "head" in subsequent routines */ - - /* === Scan columns, compute row degrees, and check row indices ========= */ - - stats [COLAMD_INFO3] = 0 ; /* number of duplicate or unsorted row indices*/ - - for (row = 0 ; row < n_row ; row++) - { - Row [row].length = 0 ; - Row [row].shared2.mark = -1 ; - } - - for (col = 0 ; col < n_col ; col++) - { - last_row = -1 ; - - cp = &A [p [col]] ; - cp_end = &A [p [col+1]] ; - - while (cp < cp_end) - { - row = *cp++ ; - - /* make sure row indices within range */ - if (row < 0 || row >= n_row) - { - stats [COLAMD_STATUS] = COLAMD_ERROR_row_index_out_of_bounds ; - stats [COLAMD_INFO1] = col ; - stats [COLAMD_INFO2] = row ; - stats [COLAMD_INFO3] = n_row ; - COLAMD_DEBUG0 (("colamd: row %d col %d out of bounds\n", row, col)) ; - return (false) ; - } - - if (row <= last_row || Row [row].shared2.mark == col) - { - /* row index are unsorted or repeated (or both), thus col */ - /* is jumbled. This is a notice, not an error condition. */ - stats [COLAMD_STATUS] = COLAMD_OK_BUT_JUMBLED ; - stats [COLAMD_INFO1] = col ; - stats [COLAMD_INFO2] = row ; - (stats [COLAMD_INFO3]) ++ ; - COLAMD_DEBUG1 (("colamd: row %d col %d unsorted/duplicate\n",row,col)); - } - - if (Row [row].shared2.mark != col) - { - Row [row].length++ ; - } - else - { - /* this is a repeated entry in the column, */ - /* it will be removed */ - Col [col].length-- ; - } - - /* mark the row as having been seen in this column */ - Row [row].shared2.mark = col ; - - last_row = row ; - } - } - - /* === Compute row pointers ============================================= */ - - /* row form of the matrix starts directly after the column */ - /* form of matrix in A */ - Row [0].start = p [n_col] ; - Row [0].shared1.p = Row [0].start ; - Row [0].shared2.mark = -1 ; - for (row = 1 ; row < n_row ; row++) - { - Row [row].start = Row [row-1].start + Row [row-1].length ; - Row [row].shared1.p = Row [row].start ; - Row [row].shared2.mark = -1 ; - } - - /* === Create row form ================================================== */ - - if (stats [COLAMD_STATUS] == COLAMD_OK_BUT_JUMBLED) - { - /* if cols jumbled, watch for repeated row indices */ - for (col = 0 ; col < n_col ; col++) - { - cp = &A [p [col]] ; - cp_end = &A [p [col+1]] ; - while (cp < cp_end) - { - row = *cp++ ; - if (Row [row].shared2.mark != col) - { - A [(Row [row].shared1.p)++] = col ; - Row [row].shared2.mark = col ; - } - } - } - } - else - { - /* if cols not jumbled, we don't need the mark (this is faster) */ - for (col = 0 ; col < n_col ; col++) - { - cp = &A [p [col]] ; - cp_end = &A [p [col+1]] ; - while (cp < cp_end) - { - A [(Row [*cp++].shared1.p)++] = col ; - } - } - } - - /* === Clear the row marks and set row degrees ========================== */ - - for (row = 0 ; row < n_row ; row++) - { - Row [row].shared2.mark = 0 ; - Row [row].shared1.degree = Row [row].length ; - } - - /* === See if we need to re-create columns ============================== */ - - if (stats [COLAMD_STATUS] == COLAMD_OK_BUT_JUMBLED) - { - COLAMD_DEBUG0 (("colamd: reconstructing column form, matrix jumbled\n")) ; - - - /* === Compute col pointers ========================================= */ - - /* col form of the matrix starts at A [0]. */ - /* Note, we may have a gap between the col form and the row */ - /* form if there were duplicate entries, if so, it will be */ - /* removed upon the first garbage collection */ - Col [0].start = 0 ; - p [0] = Col [0].start ; - for (col = 1 ; col < n_col ; col++) - { - /* note that the lengths here are for pruned columns, i.e. */ - /* no duplicate row indices will exist for these columns */ - Col [col].start = Col [col-1].start + Col [col-1].length ; - p [col] = Col [col].start ; - } - - /* === Re-create col form =========================================== */ - - for (row = 0 ; row < n_row ; row++) - { - rp = &A [Row [row].start] ; - rp_end = rp + Row [row].length ; - while (rp < rp_end) - { - A [(p [*rp++])++] = row ; - } - } - } - - /* === Done. Matrix is not (or no longer) jumbled ====================== */ - - return (true) ; -} - - -/* ========================================================================== */ -/* === init_scoring ========================================================= */ -/* ========================================================================== */ - -/* - Kills dense or empty columns and rows, calculates an initial score for - each column, and places all columns in the degree lists. Not user-callable. -*/ - -static void init_scoring -( - /* === Parameters ======================================================= */ - - int n_row, /* number of rows of A */ - int n_col, /* number of columns of A */ - Colamd_Row Row [], /* of size n_row+1 */ - colamd_col Col [], /* of size n_col+1 */ - int A [], /* column form and row form of A */ - int head [], /* of size n_col+1 */ - double knobs [COLAMD_KNOBS],/* parameters */ - int *p_n_row2, /* number of non-dense, non-empty rows */ - int *p_n_col2, /* number of non-dense, non-empty columns */ - int *p_max_deg /* maximum row degree */ -) -{ - /* === Local variables ================================================== */ - - int c ; /* a column index */ - int r, row ; /* a row index */ - int *cp ; /* a column pointer */ - int deg ; /* degree of a row or column */ - int *cp_end ; /* a pointer to the end of a column */ - int *new_cp ; /* new column pointer */ - int col_length ; /* length of pruned column */ - int score ; /* current column score */ - int n_col2 ; /* number of non-dense, non-empty columns */ - int n_row2 ; /* number of non-dense, non-empty rows */ - int dense_row_count ; /* remove rows with more entries than this */ - int dense_col_count ; /* remove cols with more entries than this */ - int min_score ; /* smallest column score */ - int max_deg ; /* maximum row degree */ - int next_col ; /* Used to add to degree list.*/ - - - /* === Extract knobs ==================================================== */ - - dense_row_count = COLAMD_MAX (0, COLAMD_MIN (knobs [COLAMD_DENSE_ROW] * n_col, n_col)) ; - dense_col_count = COLAMD_MAX (0, COLAMD_MIN (knobs [COLAMD_DENSE_COL] * n_row, n_row)) ; - COLAMD_DEBUG1 (("colamd: densecount: %d %d\n", dense_row_count, dense_col_count)) ; - max_deg = 0 ; - n_col2 = n_col ; - n_row2 = n_row ; - - /* === Kill empty columns =============================================== */ - - /* Put the empty columns at the end in their natural order, so that LU */ - /* factorization can proceed as far as possible. */ - for (c = n_col-1 ; c >= 0 ; c--) - { - deg = Col [c].length ; - if (deg == 0) - { - /* this is a empty column, kill and order it last */ - Col [c].shared2.order = --n_col2 ; - KILL_PRINCIPAL_COL (c) ; - } - } - COLAMD_DEBUG1 (("colamd: null columns killed: %d\n", n_col - n_col2)) ; - - /* === Kill dense columns =============================================== */ - - /* Put the dense columns at the end, in their natural order */ - for (c = n_col-1 ; c >= 0 ; c--) - { - /* skip any dead columns */ - if (COL_IS_DEAD (c)) - { - continue ; - } - deg = Col [c].length ; - if (deg > dense_col_count) - { - /* this is a dense column, kill and order it last */ - Col [c].shared2.order = --n_col2 ; - /* decrement the row degrees */ - cp = &A [Col [c].start] ; - cp_end = cp + Col [c].length ; - while (cp < cp_end) - { - Row [*cp++].shared1.degree-- ; - } - KILL_PRINCIPAL_COL (c) ; - } - } - COLAMD_DEBUG1 (("colamd: Dense and null columns killed: %d\n", n_col - n_col2)) ; - - /* === Kill dense and empty rows ======================================== */ - - for (r = 0 ; r < n_row ; r++) - { - deg = Row [r].shared1.degree ; - COLAMD_ASSERT (deg >= 0 && deg <= n_col) ; - if (deg > dense_row_count || deg == 0) - { - /* kill a dense or empty row */ - KILL_ROW (r) ; - --n_row2 ; - } - else - { - /* keep track of max degree of remaining rows */ - max_deg = COLAMD_MAX (max_deg, deg) ; - } - } - COLAMD_DEBUG1 (("colamd: Dense and null rows killed: %d\n", n_row - n_row2)) ; - - /* === Compute initial column scores ==================================== */ - - /* At this point the row degrees are accurate. They reflect the number */ - /* of "live" (non-dense) columns in each row. No empty rows exist. */ - /* Some "live" columns may contain only dead rows, however. These are */ - /* pruned in the code below. */ - - /* now find the initial matlab score for each column */ - for (c = n_col-1 ; c >= 0 ; c--) - { - /* skip dead column */ - if (COL_IS_DEAD (c)) - { - continue ; - } - score = 0 ; - cp = &A [Col [c].start] ; - new_cp = cp ; - cp_end = cp + Col [c].length ; - while (cp < cp_end) - { - /* get a row */ - row = *cp++ ; - /* skip if dead */ - if (ROW_IS_DEAD (row)) - { - continue ; - } - /* compact the column */ - *new_cp++ = row ; - /* add row's external degree */ - score += Row [row].shared1.degree - 1 ; - /* guard against integer overflow */ - score = COLAMD_MIN (score, n_col) ; - } - /* determine pruned column length */ - col_length = (int) (new_cp - &A [Col [c].start]) ; - if (col_length == 0) - { - /* a newly-made null column (all rows in this col are "dense" */ - /* and have already been killed) */ - COLAMD_DEBUG2 (("Newly null killed: %d\n", c)) ; - Col [c].shared2.order = --n_col2 ; - KILL_PRINCIPAL_COL (c) ; - } - else - { - /* set column length and set score */ - COLAMD_ASSERT (score >= 0) ; - COLAMD_ASSERT (score <= n_col) ; - Col [c].length = col_length ; - Col [c].shared2.score = score ; - } - } - COLAMD_DEBUG1 (("colamd: Dense, null, and newly-null columns killed: %d\n", - n_col-n_col2)) ; - - /* At this point, all empty rows and columns are dead. All live columns */ - /* are "clean" (containing no dead rows) and simplicial (no supercolumns */ - /* yet). Rows may contain dead columns, but all live rows contain at */ - /* least one live column. */ - - /* === Initialize degree lists ========================================== */ - - - /* clear the hash buckets */ - for (c = 0 ; c <= n_col ; c++) - { - head [c] = COLAMD_EMPTY ; - } - min_score = n_col ; - /* place in reverse order, so low column indices are at the front */ - /* of the lists. This is to encourage natural tie-breaking */ - for (c = n_col-1 ; c >= 0 ; c--) - { - /* only add principal columns to degree lists */ - if (COL_IS_ALIVE (c)) - { - COLAMD_DEBUG4 (("place %d score %d minscore %d ncol %d\n", - c, Col [c].shared2.score, min_score, n_col)) ; - - /* === Add columns score to DList =============================== */ - - score = Col [c].shared2.score ; - - COLAMD_ASSERT (min_score >= 0) ; - COLAMD_ASSERT (min_score <= n_col) ; - COLAMD_ASSERT (score >= 0) ; - COLAMD_ASSERT (score <= n_col) ; - COLAMD_ASSERT (head [score] >= COLAMD_EMPTY) ; - - /* now add this column to dList at proper score location */ - next_col = head [score] ; - Col [c].shared3.prev = COLAMD_EMPTY ; - Col [c].shared4.degree_next = next_col ; - - /* if there already was a column with the same score, set its */ - /* previous pointer to this new column */ - if (next_col != COLAMD_EMPTY) - { - Col [next_col].shared3.prev = c ; - } - head [score] = c ; - - /* see if this score is less than current min */ - min_score = COLAMD_MIN (min_score, score) ; - - - } - } - - - /* === Return number of remaining columns, and max row degree =========== */ - - *p_n_col2 = n_col2 ; - *p_n_row2 = n_row2 ; - *p_max_deg = max_deg ; -} - - -/* ========================================================================== */ -/* === find_ordering ======================================================== */ -/* ========================================================================== */ - -/* - Order the principal columns of the supercolumn form of the matrix - (no supercolumns on input). Uses a minimum approximate column minimum - degree ordering method. Not user-callable. -*/ - -static int find_ordering /* return the number of garbage collections */ -( - /* === Parameters ======================================================= */ - - int n_row, /* number of rows of A */ - int n_col, /* number of columns of A */ - int Alen, /* size of A, 2*nnz + n_col or larger */ - Colamd_Row Row [], /* of size n_row+1 */ - colamd_col Col [], /* of size n_col+1 */ - int A [], /* column form and row form of A */ - int head [], /* of size n_col+1 */ - int n_col2, /* Remaining columns to order */ - int max_deg, /* Maximum row degree */ - int pfree /* index of first free slot (2*nnz on entry) */ -) -{ - /* === Local variables ================================================== */ - - int k ; /* current pivot ordering step */ - int pivot_col ; /* current pivot column */ - int *cp ; /* a column pointer */ - int *rp ; /* a row pointer */ - int pivot_row ; /* current pivot row */ - int *new_cp ; /* modified column pointer */ - int *new_rp ; /* modified row pointer */ - int pivot_row_start ; /* pointer to start of pivot row */ - int pivot_row_degree ; /* number of columns in pivot row */ - int pivot_row_length ; /* number of supercolumns in pivot row */ - int pivot_col_score ; /* score of pivot column */ - int needed_memory ; /* free space needed for pivot row */ - int *cp_end ; /* pointer to the end of a column */ - int *rp_end ; /* pointer to the end of a row */ - int row ; /* a row index */ - int col ; /* a column index */ - int max_score ; /* maximum possible score */ - int cur_score ; /* score of current column */ - unsigned int hash ; /* hash value for supernode detection */ - int head_column ; /* head of hash bucket */ - int first_col ; /* first column in hash bucket */ - int tag_mark ; /* marker value for mark array */ - int row_mark ; /* Row [row].shared2.mark */ - int set_difference ; /* set difference size of row with pivot row */ - int min_score ; /* smallest column score */ - int col_thickness ; /* "thickness" (no. of columns in a supercol) */ - int max_mark ; /* maximum value of tag_mark */ - int pivot_col_thickness ; /* number of columns represented by pivot col */ - int prev_col ; /* Used by Dlist operations. */ - int next_col ; /* Used by Dlist operations. */ - int ngarbage ; /* number of garbage collections performed */ - - - /* === Initialization and clear mark ==================================== */ - - max_mark = INT_MAX - n_col ; /* INT_MAX defined in */ - tag_mark = clear_mark (n_row, Row) ; - min_score = 0 ; - ngarbage = 0 ; - COLAMD_DEBUG1 (("colamd: Ordering, n_col2=%d\n", n_col2)) ; - - /* === Order the columns ================================================ */ - - for (k = 0 ; k < n_col2 ; /* 'k' is incremented below */) - { - - /* === Select pivot column, and order it ============================ */ - - /* make sure degree list isn't empty */ - COLAMD_ASSERT (min_score >= 0) ; - COLAMD_ASSERT (min_score <= n_col) ; - COLAMD_ASSERT (head [min_score] >= COLAMD_EMPTY) ; - - /* get pivot column from head of minimum degree list */ - while (head [min_score] == COLAMD_EMPTY && min_score < n_col) - { - min_score++ ; - } - pivot_col = head [min_score] ; - COLAMD_ASSERT (pivot_col >= 0 && pivot_col <= n_col) ; - next_col = Col [pivot_col].shared4.degree_next ; - head [min_score] = next_col ; - if (next_col != COLAMD_EMPTY) - { - Col [next_col].shared3.prev = COLAMD_EMPTY ; - } - - COLAMD_ASSERT (COL_IS_ALIVE (pivot_col)) ; - COLAMD_DEBUG3 (("Pivot col: %d\n", pivot_col)) ; - - /* remember score for defrag check */ - pivot_col_score = Col [pivot_col].shared2.score ; - - /* the pivot column is the kth column in the pivot order */ - Col [pivot_col].shared2.order = k ; - - /* increment order count by column thickness */ - pivot_col_thickness = Col [pivot_col].shared1.thickness ; - k += pivot_col_thickness ; - COLAMD_ASSERT (pivot_col_thickness > 0) ; - - /* === Garbage_collection, if necessary ============================= */ - - needed_memory = COLAMD_MIN (pivot_col_score, n_col - k) ; - if (pfree + needed_memory >= Alen) - { - pfree = garbage_collection (n_row, n_col, Row, Col, A, &A [pfree]) ; - ngarbage++ ; - /* after garbage collection we will have enough */ - COLAMD_ASSERT (pfree + needed_memory < Alen) ; - /* garbage collection has wiped out the Row[].shared2.mark array */ - tag_mark = clear_mark (n_row, Row) ; - - } - - /* === Compute pivot row pattern ==================================== */ - - /* get starting location for this new merged row */ - pivot_row_start = pfree ; - - /* initialize new row counts to zero */ - pivot_row_degree = 0 ; - - /* tag pivot column as having been visited so it isn't included */ - /* in merged pivot row */ - Col [pivot_col].shared1.thickness = -pivot_col_thickness ; - - /* pivot row is the union of all rows in the pivot column pattern */ - cp = &A [Col [pivot_col].start] ; - cp_end = cp + Col [pivot_col].length ; - while (cp < cp_end) - { - /* get a row */ - row = *cp++ ; - COLAMD_DEBUG4 (("Pivot col pattern %d %d\n", ROW_IS_ALIVE (row), row)) ; - /* skip if row is dead */ - if (ROW_IS_DEAD (row)) - { - continue ; - } - rp = &A [Row [row].start] ; - rp_end = rp + Row [row].length ; - while (rp < rp_end) - { - /* get a column */ - col = *rp++ ; - /* add the column, if alive and untagged */ - col_thickness = Col [col].shared1.thickness ; - if (col_thickness > 0 && COL_IS_ALIVE (col)) - { - /* tag column in pivot row */ - Col [col].shared1.thickness = -col_thickness ; - COLAMD_ASSERT (pfree < Alen) ; - /* place column in pivot row */ - A [pfree++] = col ; - pivot_row_degree += col_thickness ; - } - } - } - - /* clear tag on pivot column */ - Col [pivot_col].shared1.thickness = pivot_col_thickness ; - max_deg = COLAMD_MAX (max_deg, pivot_row_degree) ; - - - /* === Kill all rows used to construct pivot row ==================== */ - - /* also kill pivot row, temporarily */ - cp = &A [Col [pivot_col].start] ; - cp_end = cp + Col [pivot_col].length ; - while (cp < cp_end) - { - /* may be killing an already dead row */ - row = *cp++ ; - COLAMD_DEBUG3 (("Kill row in pivot col: %d\n", row)) ; - KILL_ROW (row) ; - } - - /* === Select a row index to use as the new pivot row =============== */ - - pivot_row_length = pfree - pivot_row_start ; - if (pivot_row_length > 0) - { - /* pick the "pivot" row arbitrarily (first row in col) */ - pivot_row = A [Col [pivot_col].start] ; - COLAMD_DEBUG3 (("Pivotal row is %d\n", pivot_row)) ; - } - else - { - /* there is no pivot row, since it is of zero length */ - pivot_row = COLAMD_EMPTY ; - COLAMD_ASSERT (pivot_row_length == 0) ; - } - COLAMD_ASSERT (Col [pivot_col].length > 0 || pivot_row_length == 0) ; - - /* === Approximate degree computation =============================== */ - - /* Here begins the computation of the approximate degree. The column */ - /* score is the sum of the pivot row "length", plus the size of the */ - /* set differences of each row in the column minus the pattern of the */ - /* pivot row itself. The column ("thickness") itself is also */ - /* excluded from the column score (we thus use an approximate */ - /* external degree). */ - - /* The time taken by the following code (compute set differences, and */ - /* add them up) is proportional to the size of the data structure */ - /* being scanned - that is, the sum of the sizes of each column in */ - /* the pivot row. Thus, the amortized time to compute a column score */ - /* is proportional to the size of that column (where size, in this */ - /* context, is the column "length", or the number of row indices */ - /* in that column). The number of row indices in a column is */ - /* monotonically non-decreasing, from the length of the original */ - /* column on input to colamd. */ - - /* === Compute set differences ====================================== */ - - COLAMD_DEBUG3 (("** Computing set differences phase. **\n")) ; - - /* pivot row is currently dead - it will be revived later. */ - - COLAMD_DEBUG3 (("Pivot row: ")) ; - /* for each column in pivot row */ - rp = &A [pivot_row_start] ; - rp_end = rp + pivot_row_length ; - while (rp < rp_end) - { - col = *rp++ ; - COLAMD_ASSERT (COL_IS_ALIVE (col) && col != pivot_col) ; - COLAMD_DEBUG3 (("Col: %d\n", col)) ; - - /* clear tags used to construct pivot row pattern */ - col_thickness = -Col [col].shared1.thickness ; - COLAMD_ASSERT (col_thickness > 0) ; - Col [col].shared1.thickness = col_thickness ; - - /* === Remove column from degree list =========================== */ - - cur_score = Col [col].shared2.score ; - prev_col = Col [col].shared3.prev ; - next_col = Col [col].shared4.degree_next ; - COLAMD_ASSERT (cur_score >= 0) ; - COLAMD_ASSERT (cur_score <= n_col) ; - COLAMD_ASSERT (cur_score >= COLAMD_EMPTY) ; - if (prev_col == COLAMD_EMPTY) - { - head [cur_score] = next_col ; - } - else - { - Col [prev_col].shared4.degree_next = next_col ; - } - if (next_col != COLAMD_EMPTY) - { - Col [next_col].shared3.prev = prev_col ; - } - - /* === Scan the column ========================================== */ - - cp = &A [Col [col].start] ; - cp_end = cp + Col [col].length ; - while (cp < cp_end) - { - /* get a row */ - row = *cp++ ; - row_mark = Row [row].shared2.mark ; - /* skip if dead */ - if (ROW_IS_MARKED_DEAD (row_mark)) - { - continue ; - } - COLAMD_ASSERT (row != pivot_row) ; - set_difference = row_mark - tag_mark ; - /* check if the row has been seen yet */ - if (set_difference < 0) - { - COLAMD_ASSERT (Row [row].shared1.degree <= max_deg) ; - set_difference = Row [row].shared1.degree ; - } - /* subtract column thickness from this row's set difference */ - set_difference -= col_thickness ; - COLAMD_ASSERT (set_difference >= 0) ; - /* absorb this row if the set difference becomes zero */ - if (set_difference == 0) - { - COLAMD_DEBUG3 (("aggressive absorption. Row: %d\n", row)) ; - KILL_ROW (row) ; - } - else - { - /* save the new mark */ - Row [row].shared2.mark = set_difference + tag_mark ; - } - } - } - - - /* === Add up set differences for each column ======================= */ - - COLAMD_DEBUG3 (("** Adding set differences phase. **\n")) ; - - /* for each column in pivot row */ - rp = &A [pivot_row_start] ; - rp_end = rp + pivot_row_length ; - while (rp < rp_end) - { - /* get a column */ - col = *rp++ ; - COLAMD_ASSERT (COL_IS_ALIVE (col) && col != pivot_col) ; - hash = 0 ; - cur_score = 0 ; - cp = &A [Col [col].start] ; - /* compact the column */ - new_cp = cp ; - cp_end = cp + Col [col].length ; - - COLAMD_DEBUG4 (("Adding set diffs for Col: %d.\n", col)) ; - - while (cp < cp_end) - { - /* get a row */ - row = *cp++ ; - COLAMD_ASSERT(row >= 0 && row < n_row) ; - row_mark = Row [row].shared2.mark ; - /* skip if dead */ - if (ROW_IS_MARKED_DEAD (row_mark)) - { - continue ; - } - COLAMD_ASSERT (row_mark > tag_mark) ; - /* compact the column */ - *new_cp++ = row ; - /* compute hash function */ - hash += row ; - /* add set difference */ - cur_score += row_mark - tag_mark ; - /* integer overflow... */ - cur_score = COLAMD_MIN (cur_score, n_col) ; - } - - /* recompute the column's length */ - Col [col].length = (int) (new_cp - &A [Col [col].start]) ; - - /* === Further mass elimination ================================= */ - - if (Col [col].length == 0) - { - COLAMD_DEBUG4 (("further mass elimination. Col: %d\n", col)) ; - /* nothing left but the pivot row in this column */ - KILL_PRINCIPAL_COL (col) ; - pivot_row_degree -= Col [col].shared1.thickness ; - COLAMD_ASSERT (pivot_row_degree >= 0) ; - /* order it */ - Col [col].shared2.order = k ; - /* increment order count by column thickness */ - k += Col [col].shared1.thickness ; - } - else - { - /* === Prepare for supercolumn detection ==================== */ - - COLAMD_DEBUG4 (("Preparing supercol detection for Col: %d.\n", col)) ; - - /* save score so far */ - Col [col].shared2.score = cur_score ; - - /* add column to hash table, for supercolumn detection */ - hash %= n_col + 1 ; - - COLAMD_DEBUG4 ((" Hash = %d, n_col = %d.\n", hash, n_col)) ; - COLAMD_ASSERT (hash <= n_col) ; - - head_column = head [hash] ; - if (head_column > COLAMD_EMPTY) - { - /* degree list "hash" is non-empty, use prev (shared3) of */ - /* first column in degree list as head of hash bucket */ - first_col = Col [head_column].shared3.headhash ; - Col [head_column].shared3.headhash = col ; - } - else - { - /* degree list "hash" is empty, use head as hash bucket */ - first_col = - (head_column + 2) ; - head [hash] = - (col + 2) ; - } - Col [col].shared4.hash_next = first_col ; - - /* save hash function in Col [col].shared3.hash */ - Col [col].shared3.hash = (int) hash ; - COLAMD_ASSERT (COL_IS_ALIVE (col)) ; - } - } - - /* The approximate external column degree is now computed. */ - - /* === Supercolumn detection ======================================== */ - - COLAMD_DEBUG3 (("** Supercolumn detection phase. **\n")) ; - - detect_super_cols ( - - Col, A, head, pivot_row_start, pivot_row_length) ; - - /* === Kill the pivotal column ====================================== */ - - KILL_PRINCIPAL_COL (pivot_col) ; - - /* === Clear mark =================================================== */ - - tag_mark += (max_deg + 1) ; - if (tag_mark >= max_mark) - { - COLAMD_DEBUG2 (("clearing tag_mark\n")) ; - tag_mark = clear_mark (n_row, Row) ; - } - - /* === Finalize the new pivot row, and column scores ================ */ - - COLAMD_DEBUG3 (("** Finalize scores phase. **\n")) ; - - /* for each column in pivot row */ - rp = &A [pivot_row_start] ; - /* compact the pivot row */ - new_rp = rp ; - rp_end = rp + pivot_row_length ; - while (rp < rp_end) - { - col = *rp++ ; - /* skip dead columns */ - if (COL_IS_DEAD (col)) - { - continue ; - } - *new_rp++ = col ; - /* add new pivot row to column */ - A [Col [col].start + (Col [col].length++)] = pivot_row ; - - /* retrieve score so far and add on pivot row's degree. */ - /* (we wait until here for this in case the pivot */ - /* row's degree was reduced due to mass elimination). */ - cur_score = Col [col].shared2.score + pivot_row_degree ; - - /* calculate the max possible score as the number of */ - /* external columns minus the 'k' value minus the */ - /* columns thickness */ - max_score = n_col - k - Col [col].shared1.thickness ; - - /* make the score the external degree of the union-of-rows */ - cur_score -= Col [col].shared1.thickness ; - - /* make sure score is less or equal than the max score */ - cur_score = COLAMD_MIN (cur_score, max_score) ; - COLAMD_ASSERT (cur_score >= 0) ; - - /* store updated score */ - Col [col].shared2.score = cur_score ; - - /* === Place column back in degree list ========================= */ - - COLAMD_ASSERT (min_score >= 0) ; - COLAMD_ASSERT (min_score <= n_col) ; - COLAMD_ASSERT (cur_score >= 0) ; - COLAMD_ASSERT (cur_score <= n_col) ; - COLAMD_ASSERT (head [cur_score] >= COLAMD_EMPTY) ; - next_col = head [cur_score] ; - Col [col].shared4.degree_next = next_col ; - Col [col].shared3.prev = COLAMD_EMPTY ; - if (next_col != COLAMD_EMPTY) - { - Col [next_col].shared3.prev = col ; - } - head [cur_score] = col ; - - /* see if this score is less than current min */ - min_score = COLAMD_MIN (min_score, cur_score) ; - - } - - /* === Resurrect the new pivot row ================================== */ - - if (pivot_row_degree > 0) - { - /* update pivot row length to reflect any cols that were killed */ - /* during super-col detection and mass elimination */ - Row [pivot_row].start = pivot_row_start ; - Row [pivot_row].length = (int) (new_rp - &A[pivot_row_start]) ; - Row [pivot_row].shared1.degree = pivot_row_degree ; - Row [pivot_row].shared2.mark = 0 ; - /* pivot row is no longer dead */ - } - } - - /* === All principal columns have now been ordered ====================== */ - - return (ngarbage) ; -} - - -/* ========================================================================== */ -/* === order_children ======================================================= */ -/* ========================================================================== */ - -/* - The find_ordering routine has ordered all of the principal columns (the - representatives of the supercolumns). The non-principal columns have not - yet been ordered. This routine orders those columns by walking up the - parent tree (a column is a child of the column which absorbed it). The - final permutation vector is then placed in p [0 ... n_col-1], with p [0] - being the first column, and p [n_col-1] being the last. It doesn't look - like it at first glance, but be assured that this routine takes time linear - in the number of columns. Although not immediately obvious, the time - taken by this routine is O (n_col), that is, linear in the number of - columns. Not user-callable. -*/ - -static inline void order_children -( - /* === Parameters ======================================================= */ - - int n_col, /* number of columns of A */ - colamd_col Col [], /* of size n_col+1 */ - int p [] /* p [0 ... n_col-1] is the column permutation*/ -) -{ - /* === Local variables ================================================== */ - - int i ; /* loop counter for all columns */ - int c ; /* column index */ - int parent ; /* index of column's parent */ - int order ; /* column's order */ - - /* === Order each non-principal column ================================== */ - - for (i = 0 ; i < n_col ; i++) - { - /* find an un-ordered non-principal column */ - COLAMD_ASSERT (COL_IS_DEAD (i)) ; - if (!COL_IS_DEAD_PRINCIPAL (i) && Col [i].shared2.order == COLAMD_EMPTY) - { - parent = i ; - /* once found, find its principal parent */ - do - { - parent = Col [parent].shared1.parent ; - } while (!COL_IS_DEAD_PRINCIPAL (parent)) ; - - /* now, order all un-ordered non-principal columns along path */ - /* to this parent. collapse tree at the same time */ - c = i ; - /* get order of parent */ - order = Col [parent].shared2.order ; - - do - { - COLAMD_ASSERT (Col [c].shared2.order == COLAMD_EMPTY) ; - - /* order this column */ - Col [c].shared2.order = order++ ; - /* collaps tree */ - Col [c].shared1.parent = parent ; - - /* get immediate parent of this column */ - c = Col [c].shared1.parent ; - - /* continue until we hit an ordered column. There are */ - /* guarranteed not to be anymore unordered columns */ - /* above an ordered column */ - } while (Col [c].shared2.order == COLAMD_EMPTY) ; - - /* re-order the super_col parent to largest order for this group */ - Col [parent].shared2.order = order ; - } - } - - /* === Generate the permutation ========================================= */ - - for (c = 0 ; c < n_col ; c++) - { - p [Col [c].shared2.order] = c ; - } -} - - -/* ========================================================================== */ -/* === detect_super_cols ==================================================== */ -/* ========================================================================== */ - -/* - Detects supercolumns by finding matches between columns in the hash buckets. - Check amongst columns in the set A [row_start ... row_start + row_length-1]. - The columns under consideration are currently *not* in the degree lists, - and have already been placed in the hash buckets. - - The hash bucket for columns whose hash function is equal to h is stored - as follows: - - if head [h] is >= 0, then head [h] contains a degree list, so: - - head [h] is the first column in degree bucket h. - Col [head [h]].headhash gives the first column in hash bucket h. - - otherwise, the degree list is empty, and: - - -(head [h] + 2) is the first column in hash bucket h. - - For a column c in a hash bucket, Col [c].shared3.prev is NOT a "previous - column" pointer. Col [c].shared3.hash is used instead as the hash number - for that column. The value of Col [c].shared4.hash_next is the next column - in the same hash bucket. - - Assuming no, or "few" hash collisions, the time taken by this routine is - linear in the sum of the sizes (lengths) of each column whose score has - just been computed in the approximate degree computation. - Not user-callable. -*/ - -static void detect_super_cols -( - /* === Parameters ======================================================= */ - - colamd_col Col [], /* of size n_col+1 */ - int A [], /* row indices of A */ - int head [], /* head of degree lists and hash buckets */ - int row_start, /* pointer to set of columns to check */ - int row_length /* number of columns to check */ -) -{ - /* === Local variables ================================================== */ - - int hash ; /* hash value for a column */ - int *rp ; /* pointer to a row */ - int c ; /* a column index */ - int super_c ; /* column index of the column to absorb into */ - int *cp1 ; /* column pointer for column super_c */ - int *cp2 ; /* column pointer for column c */ - int length ; /* length of column super_c */ - int prev_c ; /* column preceding c in hash bucket */ - int i ; /* loop counter */ - int *rp_end ; /* pointer to the end of the row */ - int col ; /* a column index in the row to check */ - int head_column ; /* first column in hash bucket or degree list */ - int first_col ; /* first column in hash bucket */ - - /* === Consider each column in the row ================================== */ - - rp = &A [row_start] ; - rp_end = rp + row_length ; - while (rp < rp_end) - { - col = *rp++ ; - if (COL_IS_DEAD (col)) - { - continue ; - } - - /* get hash number for this column */ - hash = Col [col].shared3.hash ; - COLAMD_ASSERT (hash <= n_col) ; - - /* === Get the first column in this hash bucket ===================== */ - - head_column = head [hash] ; - if (head_column > COLAMD_EMPTY) - { - first_col = Col [head_column].shared3.headhash ; - } - else - { - first_col = - (head_column + 2) ; - } - - /* === Consider each column in the hash bucket ====================== */ - - for (super_c = first_col ; super_c != COLAMD_EMPTY ; - super_c = Col [super_c].shared4.hash_next) - { - COLAMD_ASSERT (COL_IS_ALIVE (super_c)) ; - COLAMD_ASSERT (Col [super_c].shared3.hash == hash) ; - length = Col [super_c].length ; - - /* prev_c is the column preceding column c in the hash bucket */ - prev_c = super_c ; - - /* === Compare super_c with all columns after it ================ */ - - for (c = Col [super_c].shared4.hash_next ; - c != COLAMD_EMPTY ; c = Col [c].shared4.hash_next) - { - COLAMD_ASSERT (c != super_c) ; - COLAMD_ASSERT (COL_IS_ALIVE (c)) ; - COLAMD_ASSERT (Col [c].shared3.hash == hash) ; - - /* not identical if lengths or scores are different */ - if (Col [c].length != length || - Col [c].shared2.score != Col [super_c].shared2.score) - { - prev_c = c ; - continue ; - } - - /* compare the two columns */ - cp1 = &A [Col [super_c].start] ; - cp2 = &A [Col [c].start] ; - - for (i = 0 ; i < length ; i++) - { - /* the columns are "clean" (no dead rows) */ - COLAMD_ASSERT (ROW_IS_ALIVE (*cp1)) ; - COLAMD_ASSERT (ROW_IS_ALIVE (*cp2)) ; - /* row indices will same order for both supercols, */ - /* no gather scatter nessasary */ - if (*cp1++ != *cp2++) - { - break ; - } - } - - /* the two columns are different if the for-loop "broke" */ - if (i != length) - { - prev_c = c ; - continue ; - } - - /* === Got it! two columns are identical =================== */ - - COLAMD_ASSERT (Col [c].shared2.score == Col [super_c].shared2.score) ; - - Col [super_c].shared1.thickness += Col [c].shared1.thickness ; - Col [c].shared1.parent = super_c ; - KILL_NON_PRINCIPAL_COL (c) ; - /* order c later, in order_children() */ - Col [c].shared2.order = COLAMD_EMPTY ; - /* remove c from hash bucket */ - Col [prev_c].shared4.hash_next = Col [c].shared4.hash_next ; - } - } - - /* === Empty this hash bucket ======================================= */ - - if (head_column > COLAMD_EMPTY) - { - /* corresponding degree list "hash" is not empty */ - Col [head_column].shared3.headhash = COLAMD_EMPTY ; - } - else - { - /* corresponding degree list "hash" is empty */ - head [hash] = COLAMD_EMPTY ; - } - } -} - - -/* ========================================================================== */ -/* === garbage_collection =================================================== */ -/* ========================================================================== */ - -/* - Defragments and compacts columns and rows in the workspace A. Used when - all avaliable memory has been used while performing row merging. Returns - the index of the first free position in A, after garbage collection. The - time taken by this routine is linear is the size of the array A, which is - itself linear in the number of nonzeros in the input matrix. - Not user-callable. -*/ - -static int garbage_collection /* returns the new value of pfree */ -( - /* === Parameters ======================================================= */ - - int n_row, /* number of rows */ - int n_col, /* number of columns */ - Colamd_Row Row [], /* row info */ - colamd_col Col [], /* column info */ - int A [], /* A [0 ... Alen-1] holds the matrix */ - int *pfree /* &A [0] ... pfree is in use */ -) -{ - /* === Local variables ================================================== */ - - int *psrc ; /* source pointer */ - int *pdest ; /* destination pointer */ - int j ; /* counter */ - int r ; /* a row index */ - int c ; /* a column index */ - int length ; /* length of a row or column */ - - /* === Defragment the columns =========================================== */ - - pdest = &A[0] ; - for (c = 0 ; c < n_col ; c++) - { - if (COL_IS_ALIVE (c)) - { - psrc = &A [Col [c].start] ; - - /* move and compact the column */ - COLAMD_ASSERT (pdest <= psrc) ; - Col [c].start = (int) (pdest - &A [0]) ; - length = Col [c].length ; - for (j = 0 ; j < length ; j++) - { - r = *psrc++ ; - if (ROW_IS_ALIVE (r)) - { - *pdest++ = r ; - } - } - Col [c].length = (int) (pdest - &A [Col [c].start]) ; - } - } - - /* === Prepare to defragment the rows =================================== */ - - for (r = 0 ; r < n_row ; r++) - { - if (ROW_IS_ALIVE (r)) - { - if (Row [r].length == 0) - { - /* this row is of zero length. cannot compact it, so kill it */ - COLAMD_DEBUG3 (("Defrag row kill\n")) ; - KILL_ROW (r) ; - } - else - { - /* save first column index in Row [r].shared2.first_column */ - psrc = &A [Row [r].start] ; - Row [r].shared2.first_column = *psrc ; - COLAMD_ASSERT (ROW_IS_ALIVE (r)) ; - /* flag the start of the row with the one's complement of row */ - *psrc = ONES_COMPLEMENT (r) ; - - } - } - } - - /* === Defragment the rows ============================================== */ - - psrc = pdest ; - while (psrc < pfree) - { - /* find a negative number ... the start of a row */ - if (*psrc++ < 0) - { - psrc-- ; - /* get the row index */ - r = ONES_COMPLEMENT (*psrc) ; - COLAMD_ASSERT (r >= 0 && r < n_row) ; - /* restore first column index */ - *psrc = Row [r].shared2.first_column ; - COLAMD_ASSERT (ROW_IS_ALIVE (r)) ; - - /* move and compact the row */ - COLAMD_ASSERT (pdest <= psrc) ; - Row [r].start = (int) (pdest - &A [0]) ; - length = Row [r].length ; - for (j = 0 ; j < length ; j++) - { - c = *psrc++ ; - if (COL_IS_ALIVE (c)) - { - *pdest++ = c ; - } - } - Row [r].length = (int) (pdest - &A [Row [r].start]) ; - - } - } - /* ensure we found all the rows */ - COLAMD_ASSERT (debug_rows == 0) ; - - /* === Return the new value of pfree ==================================== */ - - return ((int) (pdest - &A [0])) ; -} - - -/* ========================================================================== */ -/* === clear_mark =========================================================== */ -/* ========================================================================== */ - -/* - Clears the Row [].shared2.mark array, and returns the new tag_mark. - Return value is the new tag_mark. Not user-callable. -*/ - -static inline int clear_mark /* return the new value for tag_mark */ -( - /* === Parameters ======================================================= */ - - int n_row, /* number of rows in A */ - Colamd_Row Row [] /* Row [0 ... n_row-1].shared2.mark is set to zero */ -) -{ - /* === Local variables ================================================== */ - - int r ; - - for (r = 0 ; r < n_row ; r++) - { - if (ROW_IS_ALIVE (r)) - { - Row [r].shared2.mark = 0 ; - } - } - return (1) ; -} - - -} // namespace internal -#endif diff --git a/resources/3rdparty/eigen/Eigen/src/OrderingMethods/Ordering.h b/resources/3rdparty/eigen/Eigen/src/OrderingMethods/Ordering.h deleted file mode 100644 index f5757b319..000000000 --- a/resources/3rdparty/eigen/Eigen/src/OrderingMethods/Ordering.h +++ /dev/null @@ -1,158 +0,0 @@ - -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2012 Désiré Nuentsa-Wakam -// -// Eigen 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 3 of the License, or (at your option) any later version. -// -// Alternatively, 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 2 of -// the License, or (at your option) any later version. -// -// Eigen 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 or the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License and a copy of the GNU General Public License along with -// Eigen. If not, see . - -#ifndef EIGEN_ORDERING_H -#define EIGEN_ORDERING_H - -#include "Amd.h" -namespace Eigen { - -#include "Eigen_Colamd.h" - -namespace internal { - - /** - * Get the symmetric pattern A^T+A from the input matrix A. - * FIXME: The values should not be considered here - */ - template - void ordering_helper_at_plus_a(const MatrixType& mat, MatrixType& symmat) - { - MatrixType C; - C = mat.transpose(); // NOTE: Could be costly - for (int i = 0; i < C.rows(); i++) - { - for (typename MatrixType::InnerIterator it(C, i); it; ++it) - it.valueRef() = 0.0; - } - symmat = C + mat; - } - -} - -/** - * Get the approximate minimum degree ordering - * If the matrix is not structurally symmetric, an ordering of A^T+A is computed - * \tparam Index The type of indices of the matrix - */ -template -class AMDOrdering -{ - public: - typedef PermutationMatrix PermutationType; - - /** Compute the permutation vector from a sparse matrix - * This routine is much faster if the input matrix is column-major - */ - template - void operator()(const MatrixType& mat, PermutationType& perm) - { - // Compute the symmetric pattern - SparseMatrix symm; - internal::ordering_helper_at_plus_a(mat,symm); - - // Call the AMD routine - //m_mat.prune(keep_diag()); - internal::minimum_degree_ordering(symm, perm); - } - - /** Compute the permutation with a selfadjoint matrix */ - template - void operator()(const SparseSelfAdjointView& mat, PermutationType& perm) - { - SparseMatrix C = mat; - - // Call the AMD routine - // m_mat.prune(keep_diag()); //Remove the diagonal elements - internal::minimum_degree_ordering(C, perm); - } -}; - -/** - * Get the natural ordering - * - *NOTE Returns an empty permutation matrix - * \tparam Index The type of indices of the matrix - */ -template -class NaturalOrdering -{ - public: - typedef PermutationMatrix PermutationType; - - /** Compute the permutation vector from a column-major sparse matrix */ - template - void operator()(const MatrixType& mat, PermutationType& perm) - { - perm.resize(0); - } - -}; - -/** - * Get the column approximate minimum degree ordering - * The matrix should be in column-major format - */ -template -class COLAMDOrdering; -#include "Eigen_Colamd.h" - -template -class COLAMDOrdering -{ - public: - typedef PermutationMatrix PermutationType; - typedef Matrix IndexVector; - /** Compute the permutation vector form a sparse matrix */ - template - void operator() (const MatrixType& mat, PermutationType& perm) - { - int m = mat.rows(); - int n = mat.cols(); - int nnz = mat.nonZeros(); - // Get the recommended value of Alen to be used by colamd - int Alen = internal::colamd_recommended(nnz, m, n); - // Set the default parameters - double knobs [COLAMD_KNOBS]; - int stats [COLAMD_STATS]; - internal::colamd_set_defaults(knobs); - - int info; - IndexVector p(n+1), A(Alen); - for(int i=0; i <= n; i++) p(i) = mat.outerIndexPtr()[i]; - for(int 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); - eigen_assert( info && "COLAMD failed " ); - - perm.resize(n); - for (int i = 0; i < n; i++) perm.indices()(p(i)) = i; - - } - -}; - -} // end namespace Eigen -#endif \ No newline at end of file diff --git a/resources/3rdparty/eigen/Eigen/src/SparseLU/CMakeLists.txt b/resources/3rdparty/eigen/Eigen/src/SparseLU/CMakeLists.txt deleted file mode 100644 index 69729ee89..000000000 --- a/resources/3rdparty/eigen/Eigen/src/SparseLU/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -FILE(GLOB Eigen_SparseLU_SRCS "*.h") - -INSTALL(FILES - ${Eigen_SparseLU_SRCS} - DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/SparseLU COMPONENT Devel - ) diff --git a/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU.h b/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU.h deleted file mode 100644 index 9ea121ce5..000000000 --- a/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU.h +++ /dev/null @@ -1,630 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2012 Désiré Nuentsa-Wakam -// -// 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_SPARSE_LU_H -#define EIGEN_SPARSE_LU_H - -namespace Eigen { - - -// Data structure needed by all routines -#include "SparseLU_Structs.h" -#include "SparseLU_Matrix.h" - -// Base structure containing all the factorization routines -#include "SparseLUBase.h" -/** - * \ingroup SparseLU_Module - * \brief Sparse supernodal LU factorization for general matrices - * - * This class implements the supernodal LU factorization for general matrices. - * It uses the main techniques from the sequential SuperLU package - * (http://crd-legacy.lbl.gov/~xiaoye/SuperLU/). It handles transparently real - * and complex arithmetics with single and double precision, depending on the - * scalar type of your input matrix. - * The code has been optimized to provide BLAS-3 operations during supernode-panel updates. - * It benefits directly from the built-in high-performant Eigen BLAS routines. - * Moreover, when the size of a supernode is very small, the BLAS calls are avoided to - * enable a better optimization from the compiler. For best performance, - * you should compile it with NDEBUG flag to avoid the numerous bounds checking on vectors. - * - * An important parameter of this class is the ordering method. It is used to reorder the columns - * (and eventually the rows) of the matrix to reduce the number of new elements that are created during - * numerical factorization. The cheapest method available is COLAMD. - * See \link Ordering_Modules the Ordering module \endlink for the list of - * built-in and external ordering methods. - * - * Simple example with key steps - * \code - * VectorXd x(n), b(n); - * SparseMatrix A; - * SparseLU, COLAMDOrdering > solver; - * // fill A and b; - * // Compute the ordering permutation vector from the structural pattern of A - * solver.analyzePattern(A); - * // Compute the numerical factorization - * solver.factorize(A); - * //Use the factors to solve the linear system - * x = solver.solve(b); - * \endcode - * - * \WARNING The input matrix A should be in a \b compressed and \b column-major form. - * Otherwise an expensive copy will be made. You can call the inexpensive makeCompressed() to get a compressed matrix. - * - * \NOTE Unlike the initial SuperLU implementation, there is no step to equilibrate the matrix. - * For badly scaled matrices, this step can be useful to reduce the pivoting during factorization. - * If this is the case for your matrices, you can try the basic scaling method at - * "unsupported/Eigen/src/IterativeSolvers/Scaling.h" - * - * \tparam _MatrixType The type of the sparse matrix. It must be a column-major SparseMatrix<> - * \tparam _OrderingType The ordering method to use, either AMD, COLAMD or METIS - * - * - * \sa \ref TutorialSparseDirectSolvers - * \sa \ref Ordering_Modules - */ -template -class SparseLU -{ - public: - typedef _MatrixType MatrixType; - typedef _OrderingType OrderingType; - typedef typename MatrixType::Scalar Scalar; - typedef typename MatrixType::RealScalar RealScalar; - typedef typename MatrixType::Index Index; - typedef SparseMatrix NCMatrix; - typedef SuperNodalMatrix SCMatrix; - typedef Matrix ScalarVector; - typedef Matrix IndexVector; - typedef PermutationMatrix PermutationType; - - public: - SparseLU():m_isInitialized(true),m_Ustore(0,0,0,0,0,0),m_symmetricmode(false),m_diagpivotthresh(1.0) - { - initperfvalues(); - } - SparseLU(const MatrixType& matrix):m_isInitialized(true),m_Ustore(0,0,0,0,0,0),m_symmetricmode(false),m_diagpivotthresh(1.0) - { - initperfvalues(); - compute(matrix); - } - - ~SparseLU() - { - // Free all explicit dynamic pointers - } - - void analyzePattern (const MatrixType& matrix); - void factorize (const MatrixType& matrix); - void simplicialfactorize(const MatrixType& matrix); - - /** - * Compute the symbolic and numeric factorization of the input sparse matrix. - * The input matrix should be in column-major storage. - */ - void compute (const MatrixType& matrix) - { - // Analyze - analyzePattern(matrix); - //Factorize - factorize(matrix); - } - - inline Index rows() const { return m_mat.rows(); } - inline Index cols() const { return m_mat.cols(); } - /** Indicate that the pattern of the input matrix is symmetric */ - void isSymmetric(bool sym) - { - m_symmetricmode = sym; - } - - /** Set the threshold used for a diagonal entry to be an acceptable pivot. */ - void diagPivotThresh(RealScalar thresh) - { - m_diagpivotthresh = thresh; - } - - /** Return the number of nonzero elements in the L factor */ - int nnzL() - { - if (m_factorizationIsOk) - return m_nnzL; - else - { - std::cerr<<"Numerical factorization should be done before\n"; - return 0; - } - } - /** Return the number of nonzero elements in the U factor */ - int nnzU() - { - if (m_factorizationIsOk) - return m_nnzU; - else - { - std::cerr<<"Numerical factorization should be done before\n"; - return 0; - } - } - /** \returns the solution X of \f$ A X = B \f$ using the current decomposition of A. - * - * \sa compute() - */ - template - inline const internal::solve_retval solve(const MatrixBase& B) const - { - eigen_assert(m_factorizationIsOk && "SparseLU is not initialized."); - eigen_assert(rows()==B.rows() - && "SparseLU::solve(): invalid number of rows of the right hand side matrix B"); - return internal::solve_retval(*this, B.derived()); - } - - - /** \brief Reports whether previous computation was successful. - * - * \returns \c Success if computation was succesful, - * \c NumericalIssue if the PaStiX reports a problem - * \c InvalidInput if the input matrix is invalid - * - * \sa iparm() - */ - ComputationInfo info() const - { - eigen_assert(m_isInitialized && "Decomposition is not initialized."); - return m_info; - } - - template - bool _solve(const MatrixBase &B, MatrixBase &_X) const - { - Dest& X(_X.derived()); - eigen_assert(m_factorizationIsOk && "The matrix should be factorized first"); - EIGEN_STATIC_ASSERT((Dest::Flags&RowMajorBit)==0, - THIS_METHOD_IS_ONLY_FOR_COLUMN_MAJOR_MATRICES); - - - int nrhs = B.cols(); - Index n = B.rows(); - - // Permute the right hand side to form X = Pr*B - // on return, X is overwritten by the computed solution - X.resize(n,nrhs); - for(int j = 0; j < nrhs; ++j) - X.col(j) = m_perm_r * B.col(j); - - //Forward substitution with L - m_Lstore.solveInPlace(X); - - // Backward solve with U - for (int k = m_Lstore.nsuper(); k >= 0; k--) - { - Index fsupc = m_Lstore.supToCol()[k]; - Index istart = m_Lstore.rowIndexPtr()[fsupc]; - Index nsupr = m_Lstore.rowIndexPtr()[fsupc+1] - istart; - Index nsupc = m_Lstore.supToCol()[k+1] - fsupc; - Index luptr = m_Lstore.colIndexPtr()[fsupc]; - - if (nsupc == 1) - { - for (int j = 0; j < nrhs; j++) - { - X(fsupc, j) /= m_Lstore.valuePtr()[luptr]; - } - } - else - { - Map, 0, OuterStride<> > A( &(m_Lstore.valuePtr()[luptr]), nsupc, nsupc, OuterStride<>(nsupr) ); - Map< Matrix, 0, OuterStride<> > U (&(X(fsupc,0)), nsupc, nrhs, OuterStride<>(n) ); - U = A.template triangularView().solve(U); - } - - for (int j = 0; j < nrhs; ++j) - { - for (int jcol = fsupc; jcol < fsupc + nsupc; jcol++) - { - typename MappedSparseMatrix::InnerIterator it(m_Ustore, jcol); - for ( ; it; ++it) - { - Index irow = it.index(); - X(irow, j) -= X(jcol, j) * it.value(); - } - } - } - } // End For U-solve - - // Permute back the solution - for (int j = 0; j < nrhs; ++j) - X.col(j) = m_perm_c.inverse() * X.col(j); - - return true; - } - - protected: - // Functions - void initperfvalues() - { - m_perfv.panel_size = 12; - m_perfv.relax = 1; - m_perfv.maxsuper = 100; - m_perfv.rowblk = 200; - m_perfv.colblk = 60; - m_perfv.fillfactor = 20; - } - - // Variables - mutable ComputationInfo m_info; - bool m_isInitialized; - bool m_factorizationIsOk; - bool m_analysisIsOk; - NCMatrix m_mat; // The input (permuted ) matrix - SCMatrix m_Lstore; // The lower triangular matrix (supernodal) - MappedSparseMatrix m_Ustore; // The upper triangular matrix - PermutationType m_perm_c; // Column permutation - PermutationType m_perm_r ; // Row permutation - IndexVector m_etree; // Column elimination tree - - LU_GlobalLU_t m_glu; - - // SuperLU/SparseLU options - bool m_symmetricmode; - - // values for performance - LU_perfvalues m_perfv; - RealScalar m_diagpivotthresh; // Specifies the threshold used for a diagonal entry to be an acceptable pivot - int m_nnzL, m_nnzU; // Nonzeros in L and U factors - - private: - // Copy constructor - SparseLU (SparseLU& ) {} - -}; // End class SparseLU - - -// Functions needed by the anaysis phase -/** - * Compute the column permutation to minimize the fill-in - * - * - Apply this permutation to the input matrix - - * - * - Compute the column elimination tree on the permuted matrix - * - * - Postorder the elimination tree and the column permutation - * - */ -template -void SparseLU::analyzePattern(const MatrixType& mat) -{ - - //TODO It is possible as in SuperLU to compute row and columns scaling vectors to equilibrate the matrix mat. - - OrderingType ord; - ord(mat,m_perm_c); - - // Apply the permutation to the column of the input matrix -// m_mat = mat * m_perm_c.inverse(); //FIXME It should be less expensive here to permute only the structural pattern of the matrix - - //First copy the whole input matrix. - m_mat = mat; - m_mat.uncompress(); //NOTE: The effect of this command is only to create the InnerNonzeros pointers. FIXME : This vector is filled but not subsequently used. - //Then, permute only the column pointers - for (int i = 0; i < mat.cols(); i++) - { - m_mat.outerIndexPtr()[m_perm_c.indices()(i)] = mat.outerIndexPtr()[i]; - m_mat.innerNonZeroPtr()[m_perm_c.indices()(i)] = mat.outerIndexPtr()[i+1] - mat.outerIndexPtr()[i]; - } - - // Compute the column elimination tree of the permuted matrix - /*if (m_etree.size() == 0) */m_etree.resize(m_mat.cols()); - - SparseLUBase::LU_sp_coletree(m_mat, m_etree); - - // In symmetric mode, do not do postorder here - if (!m_symmetricmode) { - IndexVector post, iwork; - // Post order etree - SparseLUBase::LU_TreePostorder(m_mat.cols(), m_etree, post); - - - // Renumber etree in postorder - int m = m_mat.cols(); - iwork.resize(m+1); - for (int i = 0; i < m; ++i) iwork(post(i)) = post(m_etree(i)); - m_etree = iwork; - - // Postmultiply A*Pc by post, i.e reorder the matrix according to the postorder of the etree - PermutationType post_perm(m); //FIXME Use directly a constructor with post - for (int i = 0; i < m; i++) - post_perm.indices()(i) = post(i); - - // Combine the two permutations : postorder the permutation for future use - m_perm_c = post_perm * m_perm_c; - - } // end postordering - - m_analysisIsOk = true; -} - -// Functions needed by the numerical factorization phase - - -/** - * - Numerical factorization - * - Interleaved with the symbolic factorization - * On exit, info is - * - * = 0: successful factorization - * - * > 0: if info = i, and i is - * - * <= A->ncol: U(i,i) is exactly zero. The factorization has - * been completed, but the factor U is exactly singular, - * and division by zero will occur if it is used to solve a - * system of equations. - * - * > A->ncol: number of bytes allocated when memory allocation - * failure occurred, plus A->ncol. If lwork = -1, it is - * the estimated amount of space needed, plus A->ncol. - */ -template -void SparseLU::factorize(const MatrixType& matrix) -{ - - eigen_assert(m_analysisIsOk && "analyzePattern() should be called first"); - eigen_assert((matrix.rows() == matrix.cols()) && "Only for squared matrices"); - - typedef typename IndexVector::Scalar Index; - - - // Apply the column permutation computed in analyzepattern() - // m_mat = matrix * m_perm_c.inverse(); - m_mat = matrix; - m_mat.uncompress(); //NOTE: The effect of this command is only to create the InnerNonzeros pointers. - //Then, permute only the column pointers - for (int i = 0; i < matrix.cols(); i++) - { - m_mat.outerIndexPtr()[m_perm_c.indices()(i)] = matrix.outerIndexPtr()[i]; - m_mat.innerNonZeroPtr()[m_perm_c.indices()(i)] = matrix.outerIndexPtr()[i+1] - matrix.outerIndexPtr()[i]; - } - - int m = m_mat.rows(); - int n = m_mat.cols(); - int nnz = m_mat.nonZeros(); - int maxpanel = m_perfv.panel_size * m; - // Allocate working storage common to the factor routines - int lwork = 0; - int info = SparseLUBase::LUMemInit(m, n, nnz, lwork, m_perfv.fillfactor, m_perfv.panel_size, m_glu); - if (info) - { - std::cerr << "UNABLE TO ALLOCATE WORKING MEMORY\n\n" ; - m_factorizationIsOk = false; - return ; - } - - // Set up pointers for integer working arrays - IndexVector segrep(m); segrep.setZero(); - IndexVector parent(m); parent.setZero(); - IndexVector xplore(m); xplore.setZero(); - IndexVector repfnz(maxpanel); - IndexVector panel_lsub(maxpanel); - IndexVector xprune(n); xprune.setZero(); - IndexVector marker(m*LU_NO_MARKER); marker.setZero(); - - repfnz.setConstant(-1); - panel_lsub.setConstant(-1); - - // Set up pointers for scalar working arrays - ScalarVector dense; - dense.setZero(maxpanel); - ScalarVector tempv; - tempv.setZero(LU_NUM_TEMPV(m, m_perfv.panel_size, m_perfv.maxsuper, m_perfv.rowblk) ); - - // Compute the inverse of perm_c - PermutationType iperm_c(m_perm_c.inverse()); - - // Identify initial relaxed snodes - IndexVector relax_end(n); - if ( m_symmetricmode == true ) - SparseLUBase::LU_heap_relax_snode(n, m_etree, m_perfv.relax, marker, relax_end); - else - SparseLUBase::LU_relax_snode(n, m_etree, m_perfv.relax, marker, relax_end); - - - m_perm_r.resize(m); - m_perm_r.indices().setConstant(-1); - marker.setConstant(-1); - - m_glu.supno(0) = IND_EMPTY; m_glu.xsup.setConstant(0); - m_glu.xsup(0) = m_glu.xlsub(0) = m_glu.xusub(0) = m_glu.xlusup(0) = Index(0); - - // Work on one 'panel' at a time. A panel is one of the following : - // (a) a relaxed supernode at the bottom of the etree, or - // (b) panel_size contiguous columns, defined by the user - int jcol,kcol; - IndexVector panel_histo(n); - Index nextu, nextlu, jsupno, fsupc, new_next; - Index pivrow; // Pivotal row number in the original row matrix - int nseg1; // Number of segments in U-column above panel row jcol - int nseg; // Number of segments in each U-column - int irep, icol; - int i, k, jj; - for (jcol = 0; jcol < n; ) - { - if (relax_end(jcol) != IND_EMPTY) - { // Starting a relaxed node from jcol - kcol = relax_end(jcol); // End index of the relaxed snode - - // Factorize the relaxed supernode(jcol:kcol) - // First, determine the union of the row structure of the snode - info = SparseLUBase::LU_snode_dfs(jcol, kcol, m_mat, xprune, marker, m_glu); - if ( info ) - { - std::cerr << "MEMORY ALLOCATION FAILED IN SNODE_DFS() \n"; - m_info = NumericalIssue; - m_factorizationIsOk = false; - return; - } - nextu = m_glu.xusub(jcol); //starting location of column jcol in ucol - nextlu = m_glu.xlusup(jcol); //Starting location of column jcol in lusup (rectangular supernodes) - jsupno = m_glu.supno(jcol); // Supernode number which column jcol belongs to - fsupc = m_glu.xsup(jsupno); //First column number of the current supernode - new_next = nextlu + (m_glu.xlsub(fsupc+1)-m_glu.xlsub(fsupc)) * (kcol - jcol + 1); - int mem; - while (new_next > m_glu.nzlumax ) - { - mem = SparseLUBase::LUMemXpand(m_glu.lusup, m_glu.nzlumax, nextlu, LUSUP, m_glu.num_expansions); - if (mem) - { - std::cerr << "MEMORY ALLOCATION FAILED FOR L FACTOR \n"; - m_factorizationIsOk = false; - return; - } - } - - // Now, left-looking factorize each column within the snode - for (icol = jcol; icol<=kcol; icol++){ - m_glu.xusub(icol+1) = nextu; - // Scatter into SPA dense(*) - for (typename MatrixType::InnerIterator it(m_mat, icol); it; ++it) - dense(it.row()) = it.value(); - - // Numeric update within the snode - SparseLUBase::LU_snode_bmod(icol, fsupc, dense, m_glu); - - // Eliminate the current column - info = SparseLUBase::LU_pivotL(icol, m_diagpivotthresh, m_perm_r.indices(), iperm_c.indices(), pivrow, m_glu); - if ( info ) - { - m_info = NumericalIssue; - std::cerr<< "THE MATRIX IS STRUCTURALLY SINGULAR ... ZERO COLUMN AT " << info <::LU_panel_dfs(m, panel_size, jcol, m_mat, m_perm_r.indices(), nseg1, dense, panel_lsub, segrep, repfnz, xprune, marker, parent, xplore, m_glu); - - // Numeric sup-panel updates in topological order - SparseLUBase::LU_panel_bmod(m, panel_size, jcol, nseg1, dense, tempv, segrep, repfnz, m_perfv, m_glu); - - // Sparse LU within the panel, and below the panel diagonal - for ( jj = jcol; jj< jcol + panel_size; jj++) - { - k = (jj - jcol) * m; // Column index for w-wide arrays - - nseg = nseg1; // begin after all the panel segments - //Depth-first-search for the current column - VectorBlock panel_lsubk(panel_lsub, k, m); - VectorBlock repfnz_k(repfnz, k, m); - info = SparseLUBase::LU_column_dfs(m, jj, m_perm_r.indices(), m_perfv.maxsuper, nseg, panel_lsubk, segrep, repfnz_k, xprune, marker, parent, xplore, m_glu); - if ( info ) - { - std::cerr << "UNABLE TO EXPAND MEMORY IN COLUMN_DFS() \n"; - m_info = NumericalIssue; - m_factorizationIsOk = false; - return; - } - // Numeric updates to this column - VectorBlock dense_k(dense, k, m); - VectorBlock segrep_k(segrep, nseg1, m-nseg1); - info = SparseLUBase::LU_column_bmod(jj, (nseg - nseg1), dense_k, tempv, segrep_k, repfnz_k, jcol, m_glu); - if ( info ) - { - std::cerr << "UNABLE TO EXPAND MEMORY IN COLUMN_BMOD() \n"; - m_info = NumericalIssue; - m_factorizationIsOk = false; - return; - } - - // Copy the U-segments to ucol(*) - info = SparseLUBase::LU_copy_to_ucol(jj, nseg, segrep, repfnz_k ,m_perm_r.indices(), dense_k, m_glu); - if ( info ) - { - std::cerr << "UNABLE TO EXPAND MEMORY IN COPY_TO_UCOL() \n"; - m_info = NumericalIssue; - m_factorizationIsOk = false; - return; - } - - // Form the L-segment - info = SparseLUBase::LU_pivotL(jj, m_diagpivotthresh, m_perm_r.indices(), iperm_c.indices(), pivrow, m_glu); - if ( info ) - { - std::cerr<< "THE MATRIX IS STRUCTURALLY SINGULAR ... ZERO COLUMN AT " << info <::LU_pruneL(jj, m_perm_r.indices(), pivrow, nseg, segrep, repfnz_k, xprune, m_glu); - - // Reset repfnz for this column - for (i = 0; i < nseg; i++) - { - irep = segrep(i); - repfnz_k(irep) = IND_EMPTY; - } - } // end SparseLU within the panel - jcol += panel_size; // Move to the next panel - } // end else - } // end for -- end elimination - - // Count the number of nonzeros in factors - SparseLUBase::LU_countnz(n, m_nnzL, m_nnzU, m_glu); - // Apply permutation to the L subscripts - SparseLUBase::LU_fixupL(n, m_perm_r.indices(), m_glu); - - // Create supernode matrix L - m_Lstore.setInfos(m, n, m_glu.lusup, m_glu.xlusup, m_glu.lsub, m_glu.xlsub, m_glu.supno, m_glu.xsup); - // Create the column major upper sparse matrix U; - new (&m_Ustore) MappedSparseMatrix ( m, n, m_nnzU, m_glu.xusub.data(), m_glu.usub.data(), m_glu.ucol.data() ); - - m_info = Success; - m_factorizationIsOk = true; -} - -// #include "SparseLU_simplicialfactorize.h" -namespace internal { - -template -struct solve_retval, Rhs> - : solve_retval_base, Rhs> -{ - typedef SparseLU<_MatrixType,Derived> Dec; - EIGEN_MAKE_SOLVE_HELPERS(Dec,Rhs) - - template void evalTo(Dest& dst) const - { - dec()._solve(rhs(),dst); - } -}; - -} // end namespace internal - -} // End namespace Eigen -#endif diff --git a/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLUBase.h b/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLUBase.h deleted file mode 100644 index c00bc0532..000000000 --- a/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLUBase.h +++ /dev/null @@ -1,74 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2012 Désiré Nuentsa-Wakam -// -// 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 SPARSELUBASE_H -#define SPARSELUBASE_H -/** - * Base class for sparseLU - */ -template -struct SparseLUBase -{ - typedef Matrix ScalarVector; - typedef Matrix IndexVector; - typedef typename ScalarVector::RealScalar RealScalar; - typedef VectorBlock > BlockScalarVector; - typedef VectorBlock > BlockIndexVector; -// typedef Ref > BlockScalarVector; -// typedef Ref > BlockIndexVector; - typedef LU_GlobalLU_t GlobalLU_t; - typedef SparseMatrix MatrixType; - - static int etree_find (int i, IndexVector& pp); - static int LU_sp_coletree(const MatrixType& mat, IndexVector& parent); - static void LU_nr_etdfs (int n, IndexVector& parent, IndexVector& first_kid, IndexVector& next_kid, IndexVector& post, int postnum); - static void LU_TreePostorder(int n, IndexVector& parent, IndexVector& post); - template - static int expand(VectorType& vec, int& length, int nbElts, int keep_prev, int& num_expansions); - static int LUMemInit(int m, int n, int annz, int lwork, int fillratio, int panel_size, GlobalLU_t& glu); - template - static int LUMemXpand(VectorType& vec, int& maxlen, int nbElts, LU_MemType memtype, int& num_expansions); - static void LU_heap_relax_snode (const int n, IndexVector& et, const int relax_columns, IndexVector& descendants, IndexVector& relax_end); - static void LU_relax_snode (const int n, IndexVector& et, const int relax_columns, IndexVector& descendants, IndexVector& relax_end); - static int LU_snode_dfs(const int jcol, const int kcol,const MatrixType& mat, IndexVector& xprune, IndexVector& marker, LU_GlobalLU_t& glu); - static int LU_snode_bmod (const int jcol, const int fsupc, ScalarVector& dense, GlobalLU_t& glu); - static int LU_pivotL(const int jcol, const RealScalar diagpivotthresh, IndexVector& perm_r, IndexVector& iperm_c, int& pivrow, GlobalLU_t& glu); - template - static void LU_dfs_kernel(const int jj, IndexVector& perm_r, - int& nseg, IndexVector& panel_lsub, IndexVector& segrep, - Ref repfnz_col, IndexVector& xprune, Ref marker, IndexVector& parent, - IndexVector& xplore, GlobalLU_t& glu, int& nextl_col, int krow, Traits& traits); - static void LU_panel_dfs(const int m, const int w, const int jcol, MatrixType& A, IndexVector& perm_r, int& nseg, ScalarVector& dense, IndexVector& panel_lsub, IndexVector& segrep, IndexVector& repfnz, IndexVector& xprune, IndexVector& marker, IndexVector& parent, IndexVector& xplore, GlobalLU_t& glu); - - static void LU_panel_bmod(const int m, const int w, const int jcol, const int nseg, ScalarVector& dense, ScalarVector& tempv, IndexVector& segrep, IndexVector& repfnz, LU_perfvalues& perfv, GlobalLU_t& glu); - static int LU_column_dfs(const int m, const int jcol, IndexVector& perm_r, int maxsuper, int& nseg, BlockIndexVector& lsub_col, IndexVector& segrep, BlockIndexVector& repfnz, IndexVector& xprune, IndexVector& marker, IndexVector& parent, IndexVector& xplore, GlobalLU_t& glu); - static int LU_column_bmod(const int jcol, const int nseg, BlockScalarVector& dense, ScalarVector& tempv, BlockIndexVector& segrep, BlockIndexVector& repfnz, int fpanelc, GlobalLU_t& glu); - static int LU_copy_to_ucol(const int jcol, const int nseg, IndexVector& segrep, BlockIndexVector& repfnz ,IndexVector& perm_r, BlockScalarVector& dense, GlobalLU_t& glu); - static void LU_pruneL(const int jcol, const IndexVector& perm_r, const int pivrow, const int nseg, const IndexVector& segrep, BlockIndexVector& repfnz, IndexVector& xprune, GlobalLU_t& glu); - static void LU_countnz(const int n, int& nnzL, int& nnzU, GlobalLU_t& glu); - static void LU_fixupL(const int n, const IndexVector& perm_r, GlobalLU_t& glu); - -}; - -#include "SparseLU_Coletree.h" -#include "SparseLU_Memory.h" -#include "SparseLU_heap_relax_snode.h" -#include "SparseLU_relax_snode.h" -#include "SparseLU_snode_dfs.h" -#include "SparseLU_snode_bmod.h" -#include "SparseLU_pivotL.h" -#include "SparseLU_panel_dfs.h" -#include "SparseLU_kernel_bmod.h" -#include "SparseLU_panel_bmod.h" -#include "SparseLU_column_dfs.h" -#include "SparseLU_column_bmod.h" -#include "SparseLU_copy_to_ucol.h" -#include "SparseLU_pruneL.h" -#include "SparseLU_Utils.h" - -#endif diff --git a/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_Coletree.h b/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_Coletree.h deleted file mode 100644 index d3bc36ea4..000000000 --- a/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_Coletree.h +++ /dev/null @@ -1,180 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2012 Désiré Nuentsa-Wakam -// -// 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/. - - -/* - - * NOTE: This file is the modified version of sp_coletree.c file in SuperLU - - * -- SuperLU routine (version 3.1) -- - * Univ. of California Berkeley, Xerox Palo Alto Research Center, - * and Lawrence Berkeley National Lab. - * August 1, 2008 - * - * Copyright (c) 1994 by Xerox Corporation. All rights reserved. - * - * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY - * EXPRESSED OR IMPLIED. ANY USE IS AT YOUR OWN RISK. - * - * Permission is hereby granted to use or copy this program for any - * purpose, provided the above notices are retained on all copies. - * Permission to modify the code and to distribute modified code is - * granted, provided the above notices are retained, and a notice that - * the code was modified is included with the above copyright notice. - */ -#ifndef SPARSELU_COLETREE_H -#define SPARSELU_COLETREE_H -/** Find the root of the tree/set containing the vertex i : Use Path halving */ -template< typename Scalar,typename Index> -int SparseLUBase::etree_find (int i, IndexVector& pp) -{ - int p = pp(i); // Parent - int gp = pp(p); // Grand parent - while (gp != p) - { - pp(i) = gp; // Parent pointer on find path is changed to former grand parent - i = gp; - p = pp(i); - gp = pp(p); - } - return p; -} - -/** Compute the column elimination tree of a sparse matrix - * NOTE : The matrix is supposed to be in column-major format. - * - */ -template -int SparseLUBase::LU_sp_coletree(const MatrixType& mat, IndexVector& parent) -{ - int nc = mat.cols(); // Number of columns - int nr = mat.rows(); // Number of rows - - IndexVector root(nc); // root of subtree of etree - root.setZero(); - IndexVector pp(nc); // disjoint sets - pp.setZero(); // Initialize disjoint sets - IndexVector firstcol(nr); // First nonzero column in each row - - //Compute first nonzero column in each row - int row,col; - firstcol.setConstant(nc); //for (row = 0; row < nr; firstcol(row++) = nc); - for (col = 0; col < nc; col++) - { - for (typename MatrixType::InnerIterator it(mat, col); it; ++it) - { // Is it necessary to browse the whole matrix, the lower part should do the job ?? - row = it.row(); - firstcol(row) = (std::min)(firstcol(row), col); - } - } - /* Compute etree by Liu's algorithm for symmetric matrices, - except use (firstcol[r],c) in place of an edge (r,c) of A. - Thus each row clique in A'*A is replaced by a star - centered at its first vertex, which has the same fill. */ - int rset, cset, rroot; - for (col = 0; col < nc; col++) - { - pp(col) = col; - cset = col; - root(cset) = col; - parent(col) = nc; - for (typename MatrixType::InnerIterator it(mat, col); it; ++it) - { // A sequence of interleaved find and union is performed - row = firstcol(it.row()); - if (row >= col) continue; - rset = etree_find(row, pp); // Find the name of the set containing row - rroot = root(rset); - if (rroot != col) - { - parent(rroot) = col; - pp(cset) = rset; - cset = rset; - root(cset) = col; - } - } - } - return 0; -} - -/** - * Depth-first search from vertex n. No recursion. - * This routine was contributed by Cédric Doucet, CEDRAT Group, Meylan, France. -*/ -template -void SparseLUBase::LU_nr_etdfs (int n, IndexVector& parent, IndexVector& first_kid, IndexVector& next_kid, IndexVector& post, int postnum) -{ - int current = n, first, next; - while (postnum != n) - { - // No kid for the current node - first = first_kid(current); - - // no kid for the current node - if (first == -1) - { - // Numbering this node because it has no kid - post(current) = postnum++; - - // looking for the next kid - next = next_kid(current); - while (next == -1) - { - // No more kids : back to the parent node - current = parent(current); - // numbering the parent node - post(current) = postnum++; - - // Get the next kid - next = next_kid(current); - } - // stopping criterion - if (postnum == n+1) return; - - // Updating current node - current = next; - } - else - { - current = first; - } - } -} - - -/** - * Post order a tree - * \param parent Input tree - * \param post postordered tree - */ -template -void SparseLUBase::LU_TreePostorder(int n, IndexVector& parent, IndexVector& post) -{ - IndexVector first_kid, next_kid; // Linked list of children - int postnum; - // Allocate storage for working arrays and results - first_kid.resize(n+1); - next_kid.setZero(n+1); - post.setZero(n+1); - - // Set up structure describing children - int v, dad; - first_kid.setConstant(-1); - for (v = n-1; v >= 0; v--) - { - dad = parent(v); - next_kid(v) = first_kid(dad); - first_kid(dad) = v; - } - - // Depth-first search from dummy root vertex #n - postnum = 0; - LU_nr_etdfs(n, parent, first_kid, next_kid, post, postnum); -} - -#endif \ No newline at end of file diff --git a/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_Matrix.h b/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_Matrix.h deleted file mode 100644 index 31aeee64d..000000000 --- a/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_Matrix.h +++ /dev/null @@ -1,313 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2012 Désiré Nuentsa-Wakam -// Copyright (C) 2012 Gael Guennebaud -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef EIGEN_SPARSELU_MATRIX_H -#define EIGEN_SPARSELU_MATRIX_H - -/** \ingroup SparseLU_Module - * \brief a class to manipulate the L supernodal factor from the SparseLU factorization - * - * This class contain the data to easily store - * and manipulate the supernodes during the factorization and solution phase of Sparse LU. - * Only the lower triangular matrix has supernodes. - * - * NOTE : This class corresponds to the SCformat structure in SuperLU - * - */ -/* TO DO - * InnerIterator as for sparsematrix - * SuperInnerIterator to iterate through all supernodes - * Function for triangular solve - */ -template -class SuperNodalMatrix -{ - public: - typedef _Scalar Scalar; - typedef _Index Index; - typedef Matrix IndexVector; - typedef Matrix ScalarVector; - public: - SuperNodalMatrix() - { - - } - SuperNodalMatrix(int m, int n, ScalarVector& nzval, IndexVector& nzval_colptr, IndexVector& rowind, - IndexVector& rowind_colptr, IndexVector& col_to_sup, IndexVector& sup_to_col ) - { - setInfos(m, n, nzval, nzval_colptr, rowind, rowind_colptr, col_to_sup, sup_to_col); - } - - ~SuperNodalMatrix() - { - - } - /** - * Set appropriate pointers for the lower triangular supernodal matrix - * These infos are available at the end of the numerical factorization - * FIXME This class will be modified such that it can be use in the course - * of the factorization. - */ - void setInfos(int m, int n, ScalarVector& nzval, IndexVector& nzval_colptr, IndexVector& rowind, - IndexVector& rowind_colptr, IndexVector& col_to_sup, IndexVector& sup_to_col ) - { - m_row = m; - m_col = n; - m_nzval = nzval.data(); - m_nzval_colptr = nzval_colptr.data(); - m_rowind = rowind.data(); - m_rowind_colptr = rowind_colptr.data(); - m_nsuper = col_to_sup(n); - m_col_to_sup = col_to_sup.data(); - m_sup_to_col = sup_to_col.data(); - - } - - /** - * Number of rows - */ - int rows() - { - return m_row; - } - - /** - * Number of columns - */ - int cols() - { - return m_col; - } - - /** - * Return the array of nonzero values packed by column - * - * The size is nnz - */ - Scalar* valuePtr() - { - return m_nzval; - } - - const Scalar* valuePtr() const - { - return m_nzval; - } - /** - * Return the pointers to the beginning of each column in \ref valuePtr() - */ - Index* colIndexPtr() - { - return m_nzval_colptr; - } - - const Index* colIndexPtr() const - { - return m_nzval_colptr; - } - - /** - * Return the array of compressed row indices of all supernodes - */ - Index* rowIndex() - { - return m_rowind; - } - - const Index* rowIndex() const - { - return m_rowind; - } - - /** - * Return the location in \em rowvaluePtr() which starts each column - */ - Index* rowIndexPtr() - { - return m_rowind_colptr; - } - - const Index* rowIndexPtr() const - { - return m_rowind_colptr; - } - - /** - * Return the array of column-to-supernode mapping - */ - Index* colToSup() - { - return m_col_to_sup; - } - - const Index* colToSup() const - { - return m_col_to_sup; - } - /** - * Return the array of supernode-to-column mapping - */ - Index* supToCol() - { - return m_sup_to_col; - } - - const Index* supToCol() const - { - return m_sup_to_col; - } - - /** - * Return the number of supernodes - */ - int nsuper() const - { - return m_nsuper; - } - - class InnerIterator; - template - void solveInPlace( MatrixBase&X) const; - - - - - protected: - Index m_row; // Number of rows - Index m_col; // Number of columns - Index m_nsuper; // Number of supernodes - Scalar* m_nzval; //array of nonzero values packed by column - Index* m_nzval_colptr; //nzval_colptr[j] Stores the location in nzval[] which starts column j - Index* m_rowind; // Array of compressed row indices of rectangular supernodes - Index* m_rowind_colptr; //rowind_colptr[j] stores the location in rowind[] which starts column j - Index* m_col_to_sup; // col_to_sup[j] is the supernode number to which column j belongs - Index* m_sup_to_col; //sup_to_col[s] points to the starting column of the s-th supernode - - private : -}; - -/** - * \brief InnerIterator class to iterate over nonzero values of the current column in the supernode - * - */ -template -class SuperNodalMatrix::InnerIterator -{ - public: - InnerIterator(const SuperNodalMatrix& mat, Index outer) - : m_matrix(mat), - m_outer(outer), - m_idval(mat.colIndexPtr()[outer]), - m_startval(m_idval), - m_endval(mat.colIndexPtr()[outer+1]), - m_idrow(mat.rowIndexPtr()[outer]), - m_startidrow(m_idrow), - m_endidrow(mat.rowIndexPtr()[outer+1]) - {} - inline InnerIterator& operator++() - { - m_idval++; - m_idrow++; - return *this; - } - inline Scalar value() const { return m_matrix.valuePtr()[m_idval]; } - - inline Scalar& valueRef() { return const_cast(m_matrix.valuePtr()[m_idval]); } - - inline Index index() const { return m_matrix.rowIndex()[m_idrow]; } - inline Index row() const { return index(); } - inline Index col() const { return m_outer; } - - inline Index supIndex() const { return m_matrix.colToSup()[m_outer]; } - - inline operator bool() const - { - return ( (m_idval < m_endval) && (m_idval > m_startval) && - (m_idrow < m_endidrow) && (m_idrow > m_startidrow) ); - } - - protected: - const SuperNodalMatrix& m_matrix; // Supernodal lower triangular matrix - const Index m_outer; // Current column - Index m_idval; //Index to browse the values in the current column - const Index m_startval; // Start of the column value - const Index m_endval; // End of the column value - Index m_idrow; //Index to browse the row indices - const Index m_startidrow; // Start of the row indices of the current column value - const Index m_endidrow; // End of the row indices of the current column value -}; - -/** - * \brief Solve with the supernode triangular matrix - * - */ -template -template -void SuperNodalMatrix::solveInPlace( MatrixBase&X) const -{ - Index n = X.rows(); - int nrhs = X.cols(); - const Scalar * Lval = valuePtr(); // Nonzero values - Matrix work(n, nrhs); // working vector - work.setZero(); - for (int k = 0; k <= nsuper(); k ++) - { - Index fsupc = supToCol()[k]; // First column of the current supernode - Index istart = rowIndexPtr()[fsupc]; // Pointer index to the subscript of the current column - Index nsupr = rowIndexPtr()[fsupc+1] - istart; // Number of rows in the current supernode - Index nsupc = supToCol()[k+1] - fsupc; // Number of columns in the current supernode - Index nrow = nsupr - nsupc; // Number of rows in the non-diagonal part of the supernode - Index irow; //Current index row - - if (nsupc == 1 ) - { - for (int j = 0; j < nrhs; j++) - { - InnerIterator it(*this, fsupc); - ++it; // Skip the diagonal element - for (; it; ++it) - { - irow = it.row(); - X(irow, j) -= X(fsupc, j) * it.value(); - } - } - } - else - { - // The supernode has more than one column - Index luptr = colIndexPtr()[fsupc]; - - // Triangular solve - Map, 0, OuterStride<> > A( &(Lval[luptr]), nsupc, nsupc, OuterStride<>(nsupr) ); - Map< Matrix, 0, OuterStride<> > U (&(X(fsupc,0)), nsupc, nrhs, OuterStride<>(n) ); - U = A.template triangularView().solve(U); - - // Matrix-vector product - new (&A) Map, 0, OuterStride<> > ( &(Lval[luptr+nsupc]), nrow, nsupc, OuterStride<>(nsupr) ); - work.block(0, 0, nrow, nrhs) = A * U; - - //Begin Scatter - for (int j = 0; j < nrhs; j++) - { - Index iptr = istart + nsupc; - for (int i = 0; i < nrow; i++) - { - irow = rowIndex()[iptr]; - X(irow, j) -= work(i, j); // Scatter operation - work(i, j) = Scalar(0); - iptr++; - } - } - } - } -} - - -#endif \ No newline at end of file diff --git a/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_Memory.h b/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_Memory.h deleted file mode 100644 index 7b9f01355..000000000 --- a/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_Memory.h +++ /dev/null @@ -1,204 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2012 Désiré Nuentsa-Wakam -// -// 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/. - -/* - - * NOTE: This file is the modified version of [s,d,c,z]memory.c files in SuperLU - - * -- SuperLU routine (version 3.1) -- - * Univ. of California Berkeley, Xerox Palo Alto Research Center, - * and Lawrence Berkeley National Lab. - * August 1, 2008 - * - * Copyright (c) 1994 by Xerox Corporation. All rights reserved. - * - * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY - * EXPRESSED OR IMPLIED. ANY USE IS AT YOUR OWN RISK. - * - * Permission is hereby granted to use or copy this program for any - * purpose, provided the above notices are retained on all copies. - * Permission to modify the code and to distribute modified code is - * granted, provided the above notices are retained, and a notice that - * the code was modified is included with the above copyright notice. - */ - -#ifndef EIGEN_SPARSELU_MEMORY -#define EIGEN_SPARSELU_MEMORY - -#define LU_NO_MARKER 3 -#define LU_NUM_TEMPV(m,w,t,b) ((std::max)(m, (t+b)*w) ) -#define IND_EMPTY (-1) - -#define LU_Reduce(alpha) ((alpha + 1) / 2) // i.e (alpha-1)/2 + 1 -#define LU_GluIntArray(n) (5* (n) + 5) -#define LU_TempSpace(m, w) ( (2*w + 4 + LU_NO_MARKER) * m * sizeof(Index) \ - + (w + 1) * m * sizeof(Scalar) ) - - -/** - * Expand the existing storage to accomodate more fill-ins - * \param vec Valid pointer to the vector to allocate or expand - * \param [in,out]length At input, contain the current length of the vector that is to be increased. At output, length of the newly allocated vector - * \param [in]nbElts Current number of elements in the factors - * \param keep_prev 1: use length and do not expand the vector; 0: compute new_len and expand - * \param [in,out]num_expansions Number of times the memory has been expanded - */ -template -template -int SparseLUBase::expand(VectorType& vec, int& length, int nbElts, int keep_prev, int& num_expansions) -{ - - float alpha = 1.5; // Ratio of the memory increase - int new_len; // New size of the allocated memory - - if(num_expansions == 0 || keep_prev) - new_len = length ; // First time allocate requested - else - new_len = alpha * length ; - - VectorType old_vec; // Temporary vector to hold the previous values - if (nbElts > 0 ) - old_vec = vec.segment(0,nbElts); - - //Allocate or expand the current vector - try - { - vec.resize(new_len); - } - catch(std::bad_alloc& ) - { - if ( !num_expansions ) - { - // First time to allocate from LUMemInit() - throw; // Pass the exception to LUMemInit() which has a try... catch block - } - if (keep_prev) - { - // In this case, the memory length should not not be reduced - return new_len; - } - else - { - // Reduce the size and increase again - int tries = 0; // Number of attempts - do - { - alpha = LU_Reduce(alpha); - new_len = alpha * length ; - try - { - vec.resize(new_len); - } - catch(std::bad_alloc& ) - { - tries += 1; - if ( tries > 10) return new_len; - } - } while (!vec.size()); - } - } - //Copy the previous values to the newly allocated space - if (nbElts > 0) - vec.segment(0, nbElts) = old_vec; - - - length = new_len; - if(num_expansions) ++num_expansions; - return 0; -} - -/** - * \brief Allocate various working space for the numerical factorization phase. - * \param m number of rows of the input matrix - * \param n number of columns - * \param annz number of initial nonzeros in the matrix - * \param lwork if lwork=-1, this routine returns an estimated size of the required memory - * \param glu persistent data to facilitate multiple factors : will be deleted later ?? - * \return an estimated size of the required memory if lwork = -1; otherwise, return the size of actually allocated memory when allocation failed, and 0 on success - * NOTE Unlike SuperLU, this routine does not support successive factorization with the same pattern and the same row permutation - */ -template -int SparseLUBase::LUMemInit(int m, int n, int annz, int lwork, int fillratio, int panel_size, GlobalLU_t& glu) -{ - int& num_expansions = glu.num_expansions; //No memory expansions so far - num_expansions = 0; - glu.nzumax = glu.nzlumax = (std::max)(fillratio * annz, m*n); // estimated number of nonzeros in U - glu.nzlmax = (std::max)(1., fillratio/4.) * annz; // estimated nnz in L factor - - // Return the estimated size to the user if necessary - if (lwork == IND_EMPTY) - { - int estimated_size; - estimated_size = LU_GluIntArray(n) * sizeof(Index) + LU_TempSpace(m, panel_size) - + (glu.nzlmax + glu.nzumax) * sizeof(Index) + (glu.nzlumax+glu.nzumax) * sizeof(Scalar) + n; - return estimated_size; - } - - // Setup the required space - - // First allocate Integer pointers for L\U factors - glu.xsup.resize(n+1); - glu.supno.resize(n+1); - glu.xlsub.resize(n+1); - glu.xlusup.resize(n+1); - glu.xusub.resize(n+1); - - // Reserve memory for L/U factors - do - { - try - { - expand(glu.lusup, glu.nzlumax, 0, 0, num_expansions); - expand(glu.ucol,glu.nzumax, 0, 0, num_expansions); - expand(glu.lsub,glu.nzlmax, 0, 0, num_expansions); - expand(glu.usub,glu.nzumax, 0, 1, num_expansions); - } - catch(std::bad_alloc& ) - { - //Reduce the estimated size and retry - glu.nzlumax /= 2; - glu.nzumax /= 2; - glu.nzlmax /= 2; - if (glu.nzlumax < annz ) return glu.nzlumax; - } - - } while (!glu.lusup.size() || !glu.ucol.size() || !glu.lsub.size() || !glu.usub.size()); - - - - ++num_expansions; - return 0; - -} // end LuMemInit - -/** - * \brief Expand the existing storage - * \param vec vector to expand - * \param [in,out]maxlen On input, previous size of vec (Number of elements to copy ). on output, new size - * \param nbElts current number of elements in the vector. - * \param glu Global data structure - * \return 0 on success, > 0 size of the memory allocated so far - */ -template -template -int SparseLUBase::LUMemXpand(VectorType& vec, int& maxlen, int nbElts, LU_MemType memtype, int& num_expansions) -{ - int failed_size; - if (memtype == USUB) - failed_size = expand(vec, maxlen, nbElts, 1, num_expansions); - else - failed_size = expand(vec, maxlen, nbElts, 0, num_expansions); - - if (failed_size) - return failed_size; - - return 0 ; - -} -#endif \ No newline at end of file diff --git a/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_Structs.h b/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_Structs.h deleted file mode 100644 index 7b3aa250c..000000000 --- a/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_Structs.h +++ /dev/null @@ -1,103 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2012 Désiré Nuentsa-Wakam -// -// 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/. - -/* - * NOTE: This file comes from a partly modified version of files slu_[s,d,c,z]defs.h - * -- SuperLU routine (version 4.1) -- - * Univ. of California Berkeley, Xerox Palo Alto Research Center, - * and Lawrence Berkeley National Lab. - * November, 2010 - * - * Global data structures used in LU factorization - - * - * nsuper: #supernodes = nsuper + 1, numbered [0, nsuper]. - * (xsup,supno): supno[i] is the supernode no to which i belongs; - * xsup(s) points to the beginning of the s-th supernode. - * e.g. supno 0 1 2 2 3 3 3 4 4 4 4 4 (n=12) - * xsup 0 1 2 4 7 12 - * Note: dfs will be performed on supernode rep. relative to the new - * row pivoting ordering - * - * (xlsub,lsub): lsub[*] contains the compressed subscript of - * rectangular supernodes; xlsub[j] points to the starting - * location of the j-th column in lsub[*]. Note that xlsub - * is indexed by column. - * Storage: original row subscripts - * - * During the course of sparse LU factorization, we also use - * (xlsub,lsub) for the purpose of symmetric pruning. For each - * supernode {s,s+1,...,t=s+r} with first column s and last - * column t, the subscript set - * lsub[j], j=xlsub[s], .., xlsub[s+1]-1 - * is the structure of column s (i.e. structure of this supernode). - * It is used for the storage of numerical values. - * Furthermore, - * lsub[j], j=xlsub[t], .., xlsub[t+1]-1 - * is the structure of the last column t of this supernode. - * It is for the purpose of symmetric pruning. Therefore, the - * structural subscripts can be rearranged without making physical - * interchanges among the numerical values. - * - * However, if the supernode has only one column, then we - * only keep one set of subscripts. For any subscript interchange - * performed, similar interchange must be done on the numerical - * values. - * - * The last column structures (for pruning) will be removed - * after the numercial LU factorization phase. - * - * (xlusup,lusup): lusup[*] contains the numerical values of the - * rectangular supernodes; xlusup[j] points to the starting - * location of the j-th column in storage vector lusup[*] - * Note: xlusup is indexed by column. - * Each rectangular supernode is stored by column-major - * scheme, consistent with Fortran 2-dim array storage. - * - * (xusub,ucol,usub): ucol[*] stores the numerical values of - * U-columns outside the rectangular supernodes. The row - * subscript of nonzero ucol[k] is stored in usub[k]. - * xusub[i] points to the starting location of column i in ucol. - * Storage: new row subscripts; that is subscripts of PA. - */ -#ifndef EIGEN_LU_STRUCTS -#define EIGEN_LU_STRUCTS -typedef enum {LUSUP, UCOL, LSUB, USUB, LLVL, ULVL} LU_MemType; - - -template -struct LU_GlobalLU_t { - typedef typename IndexVector::Scalar Index; - IndexVector xsup; //First supernode column ... xsup(s) points to the beginning of the s-th supernode - IndexVector supno; // Supernode number corresponding to this column (column to supernode mapping) - ScalarVector lusup; // nonzero values of L ordered by columns - IndexVector lsub; // Compressed row indices of L rectangular supernodes. - IndexVector xlusup; // pointers to the beginning of each column in lusup - IndexVector xlsub; // pointers to the beginning of each column in lsub - Index nzlmax; // Current max size of lsub - Index nzlumax; // Current max size of lusup - ScalarVector ucol; // nonzero values of U ordered by columns - IndexVector usub; // row indices of U columns in ucol - IndexVector xusub; // Pointers to the beginning of each column of U in ucol - Index nzumax; // Current max size of ucol - Index n; // Number of columns in the matrix - int num_expansions; -}; - -// Values to set for performance -struct LU_perfvalues { - int panel_size; // a panel consists of at most consecutive columns - int relax; // To control degree of relaxing supernodes. If the number of nodes (columns) - // in a subtree of the elimination tree is less than relax, this subtree is considered - // as one supernode regardless of the row structures of those columns - int maxsuper; // The maximum size for a supernode in complete LU - int rowblk; // The minimum row dimension for 2-D blocking to be used; - int colblk; // The minimum column dimension for 2-D blocking to be used; - int fillfactor; // The estimated fills factors for L and U, compared with A -}; -#endif \ No newline at end of file diff --git a/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_Utils.h b/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_Utils.h deleted file mode 100644 index b13930dbb..000000000 --- a/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_Utils.h +++ /dev/null @@ -1,75 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2012 Désiré Nuentsa-Wakam -// -// 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_SPARSELU_UTILS_H -#define EIGEN_SPARSELU_UTILS_H - - -/** - * \brief Count Nonzero elements in the factors - */ -template -void SparseLUBase::LU_countnz(const int n, int& nnzL, int& nnzU, GlobalLU_t& glu) -{ - nnzL = 0; - nnzU = (glu.xusub)(n); - int nsuper = (glu.supno)(n); - int jlen; - int i, j, fsupc; - if (n <= 0 ) return; - // For each supernode - for (i = 0; i <= nsuper; i++) - { - fsupc = glu.xsup(i); - jlen = glu.xlsub(fsupc+1) - glu.xlsub(fsupc); - - for (j = fsupc; j < glu.xsup(i+1); j++) - { - nnzL += jlen; - nnzU += j - fsupc + 1; - jlen--; - } - } - -} -/** - * \brief Fix up the data storage lsub for L-subscripts. - * - * It removes the subscripts sets for structural pruning, - * and applies permutation to the remaining subscripts - * - */ -template -void SparseLUBase::LU_fixupL(const int n, const IndexVector& perm_r, GlobalLU_t& glu) -{ - int fsupc, i, j, k, jstart; - - int nextl = 0; - int nsuper = (glu.supno)(n); - - // For each supernode - for (i = 0; i <= nsuper; i++) - { - fsupc = glu.xsup(i); - jstart = glu.xlsub(fsupc); - glu.xlsub(fsupc) = nextl; - for (j = jstart; j < glu.xlsub(fsupc + 1); j++) - { - glu.lsub(nextl) = perm_r(glu.lsub(j)); // Now indexed into P*A - nextl++; - } - for (k = fsupc+1; k < glu.xsup(i+1); k++) - glu.xlsub(k) = nextl; // other columns in supernode i - } - - glu.xlsub(n) = nextl; -} - -#endif diff --git a/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_column_bmod.h b/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_column_bmod.h deleted file mode 100644 index 94f18fb73..000000000 --- a/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_column_bmod.h +++ /dev/null @@ -1,162 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2012 Désiré Nuentsa-Wakam -// Copyright (C) 2012 Gael Guennebaud -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -/* - - * NOTE: This file is the modified version of xcolumn_bmod.c file in SuperLU - - * -- SuperLU routine (version 3.0) -- - * Univ. of California Berkeley, Xerox Palo Alto Research Center, - * and Lawrence Berkeley National Lab. - * October 15, 2003 - * - * Copyright (c) 1994 by Xerox Corporation. All rights reserved. - * - * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY - * EXPRESSED OR IMPLIED. ANY USE IS AT YOUR OWN RISK. - * - * Permission is hereby granted to use or copy this program for any - * purpose, provided the above notices are retained on all copies. - * Permission to modify the code and to distribute modified code is - * granted, provided the above notices are retained, and a notice that - * the code was modified is included with the above copyright notice. - */ -#ifndef SPARSELU_COLUMN_BMOD_H -#define SPARSELU_COLUMN_BMOD_H - -/** - * \brief Performs numeric block updates (sup-col) in topological order - * - * \param jcol current column to update - * \param nseg Number of segments in the U part - * \param dense Store the full representation of the column - * \param tempv working array - * \param segrep segment representative ... - * \param repfnz ??? First nonzero column in each row ??? ... - * \param fpanelc First column in the current panel - * \param glu Global LU data. - * \return 0 - successful return - * > 0 - number of bytes allocated when run out of space - * - */ -template -int SparseLUBase::LU_column_bmod(const int jcol, const int nseg, BlockScalarVector& dense, ScalarVector& tempv, BlockIndexVector& segrep, BlockIndexVector& repfnz, int fpanelc, GlobalLU_t& glu) -{ - int jsupno, k, ksub, krep, ksupno; - int lptr, nrow, isub, irow, nextlu, new_next, ufirst; - int fsupc, nsupc, nsupr, luptr, kfnz, no_zeros; - /* krep = representative of current k-th supernode - * fsupc = first supernodal column - * nsupc = number of columns in a supernode - * nsupr = number of rows in a supernode - * luptr = location of supernodal LU-block in storage - * kfnz = first nonz in the k-th supernodal segment - * no_zeros = no lf leading zeros in a supernodal U-segment - */ - - jsupno = glu.supno(jcol); - // For each nonzero supernode segment of U[*,j] in topological order - k = nseg - 1; - int d_fsupc; // distance between the first column of the current panel and the - // first column of the current snode - int fst_col; // First column within small LU update - int segsize; - for (ksub = 0; ksub < nseg; ksub++) - { - krep = segrep(k); k--; - ksupno = glu.supno(krep); - if (jsupno != ksupno ) - { - // outside the rectangular supernode - fsupc = glu.xsup(ksupno); - fst_col = (std::max)(fsupc, fpanelc); - - // Distance from the current supernode to the current panel; - // d_fsupc = 0 if fsupc > fpanelc - d_fsupc = fst_col - fsupc; - - luptr = glu.xlusup(fst_col) + d_fsupc; - lptr = glu.xlsub(fsupc) + d_fsupc; - - kfnz = repfnz(krep); - kfnz = (std::max)(kfnz, fpanelc); - - segsize = krep - kfnz + 1; - nsupc = krep - fst_col + 1; - nsupr = glu.xlsub(fsupc+1) - glu.xlsub(fsupc); - nrow = nsupr - d_fsupc - nsupc; - - // Perform a triangular solver and block update, - // then scatter the result of sup-col update to dense - no_zeros = kfnz - fst_col; - if(segsize==1) - LU_kernel_bmod<1>::run(segsize, dense, tempv, glu.lusup, luptr, nsupr, nrow, glu.lsub, lptr, no_zeros); - else - LU_kernel_bmod::run(segsize, dense, tempv, glu.lusup, luptr, nsupr, nrow, glu.lsub, lptr, no_zeros); - } // end if jsupno - } // end for each segment - - // Process the supernodal portion of L\U[*,j] - nextlu = glu.xlusup(jcol); - fsupc = glu.xsup(jsupno); - - // copy the SPA dense into L\U[*,j] - int mem; - new_next = nextlu + glu.xlsub(fsupc + 1) - glu.xlsub(fsupc); - while (new_next > glu.nzlumax ) - { - mem = LUMemXpand(glu.lusup, glu.nzlumax, nextlu, LUSUP, glu.num_expansions); - if (mem) return mem; - } - - for (isub = glu.xlsub(fsupc); isub < glu.xlsub(fsupc+1); isub++) - { - irow = glu.lsub(isub); - glu.lusup(nextlu) = dense(irow); - dense(irow) = Scalar(0.0); - ++nextlu; - } - - glu.xlusup(jcol + 1) = nextlu; // close L\U(*,jcol); - - /* For more updates within the panel (also within the current supernode), - * should start from the first column of the panel, or the first column - * of the supernode, whichever is bigger. There are two cases: - * 1) fsupc < fpanelc, then fst_col <-- fpanelc - * 2) fsupc >= fpanelc, then fst_col <-- fsupc - */ - fst_col = (std::max)(fsupc, fpanelc); - - if (fst_col < jcol) - { - // Distance between the current supernode and the current panel - // d_fsupc = 0 if fsupc >= fpanelc - d_fsupc = fst_col - fsupc; - - lptr = glu.xlsub(fsupc) + d_fsupc; - luptr = glu.xlusup(fst_col) + d_fsupc; - nsupr = glu.xlsub(fsupc+1) - glu.xlsub(fsupc); // leading dimension - nsupc = jcol - fst_col; // excluding jcol - nrow = nsupr - d_fsupc - nsupc; - - // points to the beginning of jcol in snode L\U(jsupno) - ufirst = glu.xlusup(jcol) + d_fsupc; - Map, 0, OuterStride<> > A( &(glu.lusup.data()[luptr]), nsupc, nsupc, OuterStride<>(nsupr) ); - VectorBlock u(glu.lusup, ufirst, nsupc); - u = A.template triangularView().solve(u); - - new (&A) Map, 0, OuterStride<> > ( &(glu.lusup.data()[luptr+nsupc]), nrow, nsupc, OuterStride<>(nsupr) ); - VectorBlock l(glu.lusup, ufirst+nsupc, nrow); - l.noalias() -= A * u; - - } // End if fst_col - return 0; -} -#endif \ No newline at end of file diff --git a/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_column_dfs.h b/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_column_dfs.h deleted file mode 100644 index fa8dcf18d..000000000 --- a/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_column_dfs.h +++ /dev/null @@ -1,164 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2012 Désiré Nuentsa-Wakam -// -// 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/. - -/* - - * NOTE: This file is the modified version of [s,d,c,z]column_dfs.c file in SuperLU - - * -- SuperLU routine (version 2.0) -- - * Univ. of California Berkeley, Xerox Palo Alto Research Center, - * and Lawrence Berkeley National Lab. - * November 15, 1997 - * - * Copyright (c) 1994 by Xerox Corporation. All rights reserved. - * - * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY - * EXPRESSED OR IMPLIED. ANY USE IS AT YOUR OWN RISK. - * - * Permission is hereby granted to use or copy this program for any - * purpose, provided the above notices are retained on all copies. - * Permission to modify the code and to distribute modified code is - * granted, provided the above notices are retained, and a notice that - * the code was modified is included with the above copyright notice. - */ -#ifndef SPARSELU_COLUMN_DFS_H -#define SPARSELU_COLUMN_DFS_H -/** - * \brief Performs a symbolic factorization on column jcol and decide the supernode boundary - * - * A supernode representative is the last column of a supernode. - * The nonzeros in U[*,j] are segments that end at supernodes representatives. - * The routine returns a list of the supernodal representatives - * in topological order of the dfs that generates them. - * The location of the first nonzero in each supernodal segment - * (supernodal entry location) is also returned. - * - * \param m number of rows in the matrix - * \param jcol Current column - * \param perm_r Row permutation - * \param maxsuper Maximum number of column allowed in a supernode - * \param [in,out] nseg Number of segments in current U[*,j] - new segments appended - * \param lsub_col defines the rhs vector to start the dfs - * \param [in,out] segrep Segment representatives - new segments appended - * \param repfnz First nonzero location in each row - * \param xprune - * \param marker marker[i] == jj, if i was visited during dfs of current column jj; - * \param parent - * \param xplore working array - * \param glu global LU data - * \return 0 success - * > 0 number of bytes allocated when run out of space - * - */ -template -struct LU_column_dfs_traits -{ - typedef typename IndexVector::Scalar Index; - typedef typename ScalarVector::Scalar Scalar; - LU_column_dfs_traits(Index jcol, Index& jsuper, LU_GlobalLU_t& glu) - : m_jcol(jcol), m_jsuper_ref(jsuper), m_glu(glu) - {} - bool update_segrep(Index /*krep*/, Index /*jj*/) - { - return true; - } - void mem_expand(IndexVector& lsub, int& nextl, int chmark) - { - if (nextl >= m_glu.nzlmax) - SparseLUBase::LUMemXpand(lsub, m_glu.nzlmax, nextl, LSUB, m_glu.num_expansions); - if (chmark != (m_jcol-1)) m_jsuper_ref = IND_EMPTY; - } - enum { ExpandMem = true }; - - int m_jcol; - int& m_jsuper_ref; - LU_GlobalLU_t& m_glu; -}; - -template -int SparseLUBase::LU_column_dfs(const int m, const int jcol, IndexVector& perm_r, int maxsuper, int& nseg, BlockIndexVector& lsub_col, IndexVector& segrep, BlockIndexVector& repfnz, IndexVector& xprune, IndexVector& marker, IndexVector& parent, IndexVector& xplore, GlobalLU_t& glu) -{ - - int jsuper = glu.supno(jcol); - int nextl = glu.xlsub(jcol); - VectorBlock marker2(marker, 2*m, m); - - - LU_column_dfs_traits traits(jcol, jsuper, glu); - - // For each nonzero in A(*,jcol) do dfs - for (int k = 0; lsub_col[k] != IND_EMPTY; k++) - { - int krow = lsub_col(k); - lsub_col(k) = IND_EMPTY; - int kmark = marker2(krow); - - // krow was visited before, go to the next nonz; - if (kmark == jcol) continue; - - LU_dfs_kernel(jcol, perm_r, nseg, glu.lsub, segrep, repfnz, xprune, marker2, parent, - xplore, glu, nextl, krow, traits); - } // for each nonzero ... - - int fsupc, jptr, jm1ptr, ito, ifrom, istop; - int nsuper = glu.supno(jcol); - int jcolp1 = jcol + 1; - int jcolm1 = jcol - 1; - - // check to see if j belongs in the same supernode as j-1 - if ( jcol == 0 ) - { // Do nothing for column 0 - nsuper = glu.supno(0) = 0 ; - } - else - { - fsupc = glu.xsup(nsuper); - jptr = glu.xlsub(jcol); // Not yet compressed - jm1ptr = glu.xlsub(jcolm1); - - // Use supernodes of type T2 : see SuperLU paper - if ( (nextl-jptr != jptr-jm1ptr-1) ) jsuper = IND_EMPTY; - - // Make sure the number of columns in a supernode doesn't - // exceed threshold - if ( (jcol - fsupc) >= maxsuper) jsuper = IND_EMPTY; - - /* If jcol starts a new supernode, reclaim storage space in - * glu.lsub from previous supernode. Note we only store - * the subscript set of the first and last columns of - * a supernode. (first for num values, last for pruning) - */ - if (jsuper == IND_EMPTY) - { // starts a new supernode - if ( (fsupc < jcolm1-1) ) - { // >= 3 columns in nsuper - ito = glu.xlsub(fsupc+1); - glu.xlsub(jcolm1) = ito; - istop = ito + jptr - jm1ptr; - xprune(jcolm1) = istop; // intialize xprune(jcol-1) - glu.xlsub(jcol) = istop; - - for (ifrom = jm1ptr; ifrom < nextl; ++ifrom, ++ito) - glu.lsub(ito) = glu.lsub(ifrom); - nextl = ito; // = istop + length(jcol) - } - nsuper++; - glu.supno(jcol) = nsuper; - } // if a new supernode - } // end else: jcol > 0 - - // Tidy up the pointers before exit - glu.xsup(nsuper+1) = jcolp1; - glu.supno(jcolp1) = nsuper; - xprune(jcol) = nextl; // Intialize upper bound for pruning - glu.xlsub(jcolp1) = nextl; - - return 0; -} -#endif \ No newline at end of file diff --git a/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_copy_to_ucol.h b/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_copy_to_ucol.h deleted file mode 100644 index d3227469d..000000000 --- a/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_copy_to_ucol.h +++ /dev/null @@ -1,100 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2012 Désiré Nuentsa-Wakam -// -// 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/. -/* - - * NOTE: This file is the modified version of [s,d,c,z]copy_to_ucol.c file in SuperLU - - * -- SuperLU routine (version 2.0) -- - * Univ. of California Berkeley, Xerox Palo Alto Research Center, - * and Lawrence Berkeley National Lab. - * November 15, 1997 - * - * Copyright (c) 1994 by Xerox Corporation. All rights reserved. - * - * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY - * EXPRESSED OR IMPLIED. ANY USE IS AT YOUR OWN RISK. - * - * Permission is hereby granted to use or copy this program for any - * purpose, provided the above notices are retained on all copies. - * Permission to modify the code and to distribute modified code is - * granted, provided the above notices are retained, and a notice that - * the code was modified is included with the above copyright notice. - */ -#ifndef SPARSELU_COPY_TO_UCOL_H -#define SPARSELU_COPY_TO_UCOL_H - -/** - * \brief Performs numeric block updates (sup-col) in topological order - * - * \param jcol current column to update - * \param nseg Number of segments in the U part - * \param segrep segment representative ... - * \param repfnz First nonzero column in each row ... - * \param perm_r Row permutation - * \param dense Store the full representation of the column - * \param glu Global LU data. - * \return 0 - successful return - * > 0 - number of bytes allocated when run out of space - * - */ -template -int SparseLUBase::LU_copy_to_ucol(const int jcol, const int nseg, IndexVector& segrep, BlockIndexVector& repfnz ,IndexVector& perm_r, BlockScalarVector& dense, GlobalLU_t& glu) -{ - Index ksub, krep, ksupno; - - Index jsupno = glu.supno(jcol); - - // For each nonzero supernode segment of U[*,j] in topological order - int k = nseg - 1, i; - Index nextu = glu.xusub(jcol); - Index kfnz, isub, segsize; - Index new_next,irow; - Index fsupc, mem; - for (ksub = 0; ksub < nseg; ksub++) - { - krep = segrep(k); k--; - ksupno = glu.supno(krep); - if (jsupno != ksupno ) // should go into ucol(); - { - kfnz = repfnz(krep); - if (kfnz != IND_EMPTY) - { // Nonzero U-segment - fsupc = glu.xsup(ksupno); - isub = glu.xlsub(fsupc) + kfnz - fsupc; - segsize = krep - kfnz + 1; - new_next = nextu + segsize; - while (new_next > glu.nzumax) - { - mem = LUMemXpand(glu.ucol, glu.nzumax, nextu, UCOL, glu.num_expansions); - if (mem) return mem; - mem = LUMemXpand(glu.usub, glu.nzumax, nextu, USUB, glu.num_expansions); - if (mem) return mem; - - } - - for (i = 0; i < segsize; i++) - { - irow = glu.lsub(isub); - glu.usub(nextu) = perm_r(irow); // Unlike the L part, the U part is stored in its final order - glu.ucol(nextu) = dense(irow); - dense(irow) = Scalar(0.0); - nextu++; - isub++; - } - - } // end nonzero U-segment - - } // end if jsupno - - } // end for each segment - glu.xusub(jcol + 1) = nextu; // close U(*,jcol) - return 0; -} - -#endif \ No newline at end of file diff --git a/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_heap_relax_snode.h b/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_heap_relax_snode.h deleted file mode 100644 index 69e1d4da9..000000000 --- a/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_heap_relax_snode.h +++ /dev/null @@ -1,119 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2012 Désiré Nuentsa-Wakam -// -// 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 file is a modified version of heap_relax_snode.c file in SuperLU - * -- SuperLU routine (version 3.0) -- - * Univ. of California Berkeley, Xerox Palo Alto Research Center, - * and Lawrence Berkeley National Lab. - * October 15, 2003 - * - * Copyright (c) 1994 by Xerox Corporation. All rights reserved. - * - * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY - * EXPRESSED OR IMPLIED. ANY USE IS AT YOUR OWN RISK. - * - * Permission is hereby granted to use or copy this program for any - * purpose, provided the above notices are retained on all copies. - * Permission to modify the code and to distribute modified code is - * granted, provided the above notices are retained, and a notice that - * the code was modified is included with the above copyright notice. - */ - -#ifndef SPARSELU_HEAP_RELAX_SNODE_H -#define SPARSELU_HEAP_RELAX_SNODE_H -#include "SparseLU_Coletree.h" -/** - * \brief Identify the initial relaxed supernodes - * - * This routine applied to a symmetric elimination tree. - * It assumes that the matrix has been reordered according to the postorder of the etree - * \param et elimination tree - * \param relax_columns Maximum number of columns allowed in a relaxed snode - * \param descendants Number of descendants of each node in the etree - * \param relax_end last column in a supernode - */ -template -void SparseLUBase::LU_heap_relax_snode (const int n, IndexVector& et, const int relax_columns, IndexVector& descendants, IndexVector& relax_end) -{ - - // The etree may not be postordered, but its heap ordered - IndexVector post; - LU_TreePostorder(n, et, post); // Post order etree - IndexVector inv_post(n+1); - int i; - for (i = 0; i < n+1; ++i) inv_post(post(i)) = i; // inv_post = post.inverse()??? - - // Renumber etree in postorder - IndexVector iwork(n); - IndexVector et_save(n+1); - for (i = 0; i < n; ++i) - { - iwork(post(i)) = post(et(i)); - } - et_save = et; // Save the original etree - et = iwork; - - // compute the number of descendants of each node in the etree - relax_end.setConstant(IND_EMPTY); - int j, parent; - descendants.setZero(); - for (j = 0; j < n; j++) - { - parent = et(j); - if (parent != n) // not the dummy root - descendants(parent) += descendants(j) + 1; - } - // Identify the relaxed supernodes by postorder traversal of the etree - int snode_start; // beginning of a snode - int k; - int nsuper_et_post = 0; // Number of relaxed snodes in postordered etree - int nsuper_et = 0; // Number of relaxed snodes in the original etree - int l; - for (j = 0; j < n; ) - { - parent = et(j); - snode_start = j; - while ( parent != n && descendants(parent) < relax_columns ) - { - j = parent; - parent = et(j); - } - // Found a supernode in postordered etree, j is the last column - ++nsuper_et_post; - k = n; - for (i = snode_start; i <= j; ++i) - k = (std::min)(k, inv_post(i)); - l = inv_post(j); - if ( (l - k) == (j - snode_start) ) // Same number of columns in the snode - { - // This is also a supernode in the original etree - relax_end(k) = l; // Record last column - ++nsuper_et; - } - else - { - for (i = snode_start; i <= j; ++i) - { - l = inv_post(i); - if (descendants(i) == 0) - { - relax_end(l) = l; - ++nsuper_et; - } - } - } - j++; - // Search for a new leaf - while (descendants(j) != 0 && j < n) j++; - } // End postorder traversal of the etree - - // Recover the original etree - et = et_save; -} -#endif diff --git a/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_kernel_bmod.h b/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_kernel_bmod.h deleted file mode 100644 index b15ff9c50..000000000 --- a/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_kernel_bmod.h +++ /dev/null @@ -1,109 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2012 Désiré Nuentsa-Wakam -// Copyright (C) 2012 Gael Guennebaud -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef SPARSELU_KERNEL_BMOD_H -#define SPARSELU_KERNEL_BMOD_H - -/** - * \brief Performs numeric block updates from a given supernode to a single column - * - * \param segsize Size of the segment (and blocks ) to use for updates - * \param [in,out]dense Packed values of the original matrix - * \param tempv temporary vector to use for updates - * \param lusup array containing the supernodes - * \param nsupr Number of rows in the supernode - * \param nrow Number of rows in the rectangular part of the supernode - * \param lsub compressed row subscripts of supernodes - * \param lptr pointer to the first column of the current supernode in lsub - * \param no_zeros Number of nonzeros elements before the diagonal part of the supernode - * \return 0 on success - */ -template struct LU_kernel_bmod -{ - template - EIGEN_DONT_INLINE static void run(const int segsize, BlockScalarVector& dense, ScalarVector& tempv, ScalarVector& lusup, int& luptr, const int nsupr, const int nrow, IndexVector& lsub, const int lptr, const int no_zeros) - { - typedef typename ScalarVector::Scalar Scalar; - // First, copy U[*,j] segment from dense(*) to tempv(*) - // The result of triangular solve is in tempv[*]; - // The result of matric-vector update is in dense[*] - int isub = lptr + no_zeros; - int i, irow; - for (i = 0; i < ((SegSizeAtCompileTime==Dynamic)?segsize:SegSizeAtCompileTime); i++) - { - irow = lsub(isub); - tempv(i) = dense(irow); - ++isub; - } - // Dense triangular solve -- start effective triangle - luptr += nsupr * no_zeros + no_zeros; - // Form Eigen matrix and vector - Map, 0, OuterStride<> > A( &(lusup.data()[luptr]), segsize, segsize, OuterStride<>(nsupr) ); - Map > u(tempv.data(), segsize); - - u = A.template triangularView().solve(u); - - // Dense matrix-vector product y <-- B*x - luptr += segsize; - Map, 0, OuterStride<> > B( &(lusup.data()[luptr]), nrow, segsize, OuterStride<>(nsupr) ); - Map > l(tempv.data()+segsize, nrow); - if(SegSizeAtCompileTime==2) - l = u(0) * B.col(0) + u(1) * B.col(1); - else if(SegSizeAtCompileTime==3) - l = u(0) * B.col(0) + u(1) * B.col(1) + u(2) * B.col(2); - else - l.noalias() = B * u; - - // Scatter tempv[] into SPA dense[] as a temporary storage - isub = lptr + no_zeros; - for (i = 0; i < ((SegSizeAtCompileTime==Dynamic)?segsize:SegSizeAtCompileTime); i++) - { - irow = lsub(isub++); - dense(irow) = tempv(i); - } - - // Scatter l into SPA dense[] - for (i = 0; i < nrow; i++) - { - irow = lsub(isub++); - dense(irow) -= l(i); - } - } -}; - -template <> struct LU_kernel_bmod<1> -{ - template - EIGEN_DONT_INLINE static void run(const int /*segsize*/, BlockScalarVector& dense, ScalarVector& /*tempv*/, ScalarVector& lusup, int& luptr, const int nsupr, const int nrow, IndexVector& lsub, const int lptr, const int no_zeros) - { - typedef typename ScalarVector::Scalar Scalar; - Scalar f = dense(lsub(lptr + no_zeros)); - luptr += nsupr * no_zeros + no_zeros + 1; - const Scalar* a(lusup.data() + luptr); - const typename IndexVector::Scalar* irow(lsub.data()+lptr + no_zeros + 1); - int i = 0; - for (; i+1 < nrow; i+=2) - { - int i0 = *(irow++); - int i1 = *(irow++); - Scalar a0 = *(a++); - Scalar a1 = *(a++); - Scalar d0 = dense.coeff(i0); - Scalar d1 = dense.coeff(i1); - d0 -= f*a0; - d1 -= f*a1; - dense.coeffRef(i0) = d0; - dense.coeffRef(i1) = d1; - } - if(i -// Copyright (C) 2012 Gael Guennebaud -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -/* - - * NOTE: This file is the modified version of [s,d,c,z]panel_bmod.c file in SuperLU - - * -- SuperLU routine (version 3.0) -- - * Univ. of California Berkeley, Xerox Palo Alto Research Center, - * and Lawrence Berkeley National Lab. - * October 15, 2003 - * - * Copyright (c) 1994 by Xerox Corporation. All rights reserved. - * - * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY - * EXPRESSED OR IMPLIED. ANY USE IS AT YOUR OWN RISK. - * - * Permission is hereby granted to use or copy this program for any - * purpose, provided the above notices are retained on all copies. - * Permission to modify the code and to distribute modified code is - * granted, provided the above notices are retained, and a notice that - * the code was modified is included with the above copyright notice. - */ -#ifndef SPARSELU_PANEL_BMOD_H -#define SPARSELU_PANEL_BMOD_H -/** - * \brief Performs numeric block updates (sup-panel) in topological order. - * - * Before entering this routine, the original nonzeros in the panel - * were already copied i nto the spa[m,w] - * - * \param m number of rows in the matrix - * \param w Panel size - * \param jcol Starting column of the panel - * \param nseg Number of segments in the U part - * \param dense Store the full representation of the panel - * \param tempv working array - * \param segrep segment representative... first row in the segment - * \param repfnz First nonzero rows - * \param glu Global LU data. - * - * - */ -template -void SparseLUBase::LU_panel_bmod(const int m, const int w, const int jcol, const int nseg, ScalarVector& dense, ScalarVector& tempv, IndexVector& segrep, IndexVector& repfnz, LU_perfvalues& perfv, GlobalLU_t& glu) -{ - - int ksub,jj,nextl_col; - int fsupc, nsupc, nsupr, nrow; - int krep, kfnz; - int lptr; // points to the row subscripts of a supernode - int luptr; // ... - int segsize,no_zeros ; - // For each nonz supernode segment of U[*,j] in topological order - int k = nseg - 1; - for (ksub = 0; ksub < nseg; ksub++) - { // For each updating supernode - - /* krep = representative of current k-th supernode - * fsupc = first supernodal column - * nsupc = number of columns in a supernode - * nsupr = number of rows in a supernode - */ - krep = segrep(k); k--; - fsupc = glu.xsup(glu.supno(krep)); - nsupc = krep - fsupc + 1; - nsupr = glu.xlsub(fsupc+1) - glu.xlsub(fsupc); - nrow = nsupr - nsupc; - lptr = glu.xlsub(fsupc); - - // loop over the panel columns to detect the actual number of columns and rows - int u_rows = 0; - int u_cols = 0; - for (jj = jcol; jj < jcol + w; jj++) - { - nextl_col = (jj-jcol) * m; - VectorBlock repfnz_col(repfnz, nextl_col, m); // First nonzero column index for each row - - kfnz = repfnz_col(krep); - if ( kfnz == IND_EMPTY ) - continue; // skip any zero segment - - segsize = krep - kfnz + 1; - u_cols++; - u_rows = (std::max)(segsize,u_rows); - } - - // if the blocks are large enough, use level 3 - // TODO find better heuristics! - if( nsupc >= perfv.colblk && nrow > perfv.rowblk && u_cols>perfv.relax) - { - Map > U(tempv.data(), u_rows, u_cols); - - // gather U - int u_col = 0; - for (jj = jcol; jj < jcol + w; jj++) - { - nextl_col = (jj-jcol) * m; - VectorBlock repfnz_col(repfnz, nextl_col, m); // First nonzero column index for each row - VectorBlock dense_col(dense, nextl_col, m); // Scatter/gather entire matrix column from/to here - - kfnz = repfnz_col(krep); - if ( kfnz == IND_EMPTY ) - continue; // skip any zero segment - - segsize = krep - kfnz + 1; - luptr = glu.xlusup(fsupc); - no_zeros = kfnz - fsupc; - - int isub = lptr + no_zeros; - int off = u_rows-segsize; - for (int i = 0; i < off; i++) U(i,u_col) = 0; - for (int i = 0; i < segsize; i++) - { - int irow = glu.lsub(isub); - U(i+off,u_col) = dense_col(irow); - ++isub; - } - u_col++; - } - // solve U = A^-1 U - luptr = glu.xlusup(fsupc); - no_zeros = (krep - u_rows + 1) - fsupc; - luptr += nsupr * no_zeros + no_zeros; - Map, 0, OuterStride<> > A(glu.lusup.data()+luptr, u_rows, u_rows, OuterStride<>(nsupr) ); - U = A.template triangularView().solve(U); - - // update - luptr += u_rows; - Map, 0, OuterStride<> > B(glu.lusup.data()+luptr, nrow, u_rows, OuterStride<>(nsupr) ); - assert(tempv.size()>w*u_rows + nrow*w); - Map > L(tempv.data()+w*u_rows, nrow, u_cols); - L.noalias() = B * U; - - // scatter U and L - u_col = 0; - for (jj = jcol; jj < jcol + w; jj++) - { - nextl_col = (jj-jcol) * m; - VectorBlock repfnz_col(repfnz, nextl_col, m); // First nonzero column index for each row - VectorBlock dense_col(dense, nextl_col, m); // Scatter/gather entire matrix column from/to here - - kfnz = repfnz_col(krep); - if ( kfnz == IND_EMPTY ) - continue; // skip any zero segment - - segsize = krep - kfnz + 1; - no_zeros = kfnz - fsupc; - int isub = lptr + no_zeros; - - int off = u_rows-segsize; - for (int i = 0; i < segsize; i++) - { - int irow = glu.lsub(isub++); - dense_col(irow) = U.coeff(i+off,u_col); - U.coeffRef(i+off,u_col) = 0; - } - - // Scatter l into SPA dense[] - for (int i = 0; i < nrow; i++) - { - int irow = glu.lsub(isub++); - dense_col(irow) -= L.coeff(i,u_col); - L.coeffRef(i,u_col) = 0; - } - u_col++; - } - } - else // level 2 only - { - // Sequence through each column in the panel - for (jj = jcol; jj < jcol + w; jj++) - { - nextl_col = (jj-jcol) * m; - VectorBlock repfnz_col(repfnz, nextl_col, m); // First nonzero column index for each row - VectorBlock dense_col(dense, nextl_col, m); // Scatter/gather entire matrix column from/to here - - kfnz = repfnz_col(krep); - if ( kfnz == IND_EMPTY ) - continue; // skip any zero segment - - segsize = krep - kfnz + 1; - luptr = glu.xlusup(fsupc); - - // Perform a trianglar solve and block update, - // then scatter the result of sup-col update to dense[] - no_zeros = kfnz - fsupc; - if(segsize==1) LU_kernel_bmod<1>::run(segsize, dense_col, tempv, glu.lusup, luptr, nsupr, nrow, glu.lsub, lptr, no_zeros); - else if(segsize==2) LU_kernel_bmod<2>::run(segsize, dense_col, tempv, glu.lusup, luptr, nsupr, nrow, glu.lsub, lptr, no_zeros); - else if(segsize==3) LU_kernel_bmod<3>::run(segsize, dense_col, tempv, glu.lusup, luptr, nsupr, nrow, glu.lsub, lptr, no_zeros); - else LU_kernel_bmod::run(segsize, dense_col, tempv, glu.lusup, luptr, nsupr, nrow, glu.lsub, lptr, no_zeros); - } // End for each column in the panel - } - - } // End for each updating supernode -} -#endif diff --git a/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_panel_dfs.h b/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_panel_dfs.h deleted file mode 100644 index 5d3025388..000000000 --- a/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_panel_dfs.h +++ /dev/null @@ -1,247 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2012 Désiré Nuentsa-Wakam -// -// 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/. - -/* - - * NOTE: This file is the modified version of [s,d,c,z]panel_dfs.c file in SuperLU - - * -- SuperLU routine (version 2.0) -- - * Univ. of California Berkeley, Xerox Palo Alto Research Center, - * and Lawrence Berkeley National Lab. - * November 15, 1997 - * - * Copyright (c) 1994 by Xerox Corporation. All rights reserved. - * - * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY - * EXPRESSED OR IMPLIED. ANY USE IS AT YOUR OWN RISK. - * - * Permission is hereby granted to use or copy this program for any - * purpose, provided the above notices are retained on all copies. - * Permission to modify the code and to distribute modified code is - * granted, provided the above notices are retained, and a notice that - * the code was modified is included with the above copyright notice. - */ -#ifndef SPARSELU_PANEL_DFS_H -#define SPARSELU_PANEL_DFS_H -template -template -void SparseLUBase::LU_dfs_kernel(const int jj, IndexVector& perm_r, - int& nseg, IndexVector& panel_lsub, IndexVector& segrep, - Ref repfnz_col, IndexVector& xprune, Ref marker, IndexVector& parent, - IndexVector& xplore, GlobalLU_t& glu, - int& nextl_col, int krow, Traits& traits - ) -{ - - int kmark = marker(krow); - - // For each unmarked krow of jj - marker(krow) = jj; - int kperm = perm_r(krow); - if (kperm == IND_EMPTY ) { - // krow is in L : place it in structure of L(*, jj) - panel_lsub(nextl_col++) = krow; // krow is indexed into A - - traits.mem_expand(panel_lsub, nextl_col, kmark); - } - else - { - // krow is in U : if its supernode-representative krep - // has been explored, update repfnz(*) - // krep = supernode representative of the current row - int krep = glu.xsup(glu.supno(kperm)+1) - 1; - // First nonzero element in the current column: - int myfnz = repfnz_col(krep); - - if (myfnz != IND_EMPTY ) - { - // Representative visited before - if (myfnz > kperm ) repfnz_col(krep) = kperm; - - } - else - { - // Otherwise, perform dfs starting at krep - int oldrep = IND_EMPTY; - parent(krep) = oldrep; - repfnz_col(krep) = kperm; - int xdfs = glu.xlsub(krep); - int maxdfs = xprune(krep); - - int kpar; - do - { - // For each unmarked kchild of krep - while (xdfs < maxdfs) - { - int kchild = glu.lsub(xdfs); - xdfs++; - int chmark = marker(kchild); - - if (chmark != jj ) - { - marker(kchild) = jj; - int chperm = perm_r(kchild); - - if (chperm == IND_EMPTY) - { - // case kchild is in L: place it in L(*, j) - panel_lsub(nextl_col++) = kchild; - traits.mem_expand(panel_lsub, nextl_col, chmark); - } - else - { - // case kchild is in U : - // chrep = its supernode-rep. If its rep has been explored, - // update its repfnz(*) - int chrep = glu.xsup(glu.supno(chperm)+1) - 1; - myfnz = repfnz_col(chrep); - - if (myfnz != IND_EMPTY) - { // Visited before - if (myfnz > chperm) - repfnz_col(chrep) = chperm; - } - else - { // Cont. dfs at snode-rep of kchild - xplore(krep) = xdfs; - oldrep = krep; - krep = chrep; // Go deeper down G(L) - parent(krep) = oldrep; - repfnz_col(krep) = chperm; - xdfs = glu.xlsub(krep); - maxdfs = xprune(krep); - - } // end if myfnz != -1 - } // end if chperm == -1 - - } // end if chmark !=jj - } // end while xdfs < maxdfs - - // krow has no more unexplored nbrs : - // Place snode-rep krep in postorder DFS, if this - // segment is seen for the first time. (Note that - // "repfnz(krep)" may change later.) - // Baktrack dfs to its parent - if(traits.update_segrep(krep,jj)) - //if (marker1(krep) < jcol ) - { - segrep(nseg) = krep; - ++nseg; - //marker1(krep) = jj; - } - - kpar = parent(krep); // Pop recursion, mimic recursion - if (kpar == IND_EMPTY) - break; // dfs done - krep = kpar; - xdfs = xplore(krep); - maxdfs = xprune(krep); - - } while (kpar != IND_EMPTY); // Do until empty stack - - } // end if (myfnz = -1) - - } // end if (kperm == -1) -} - -/** - * \brief Performs a symbolic factorization on a panel of columns [jcol, jcol+w) - * - * A supernode representative is the last column of a supernode. - * The nonzeros in U[*,j] are segments that end at supernodes representatives - * - * The routine returns a list of the supernodal representatives - * in topological order of the dfs that generates them. This list is - * a superset of the topological order of each individual column within - * the panel. - * The location of the first nonzero in each supernodal segment - * (supernodal entry location) is also returned. Each column has - * a separate list for this purpose. - * - * Two markers arrays are used for dfs : - * marker[i] == jj, if i was visited during dfs of current column jj; - * marker1[i] >= jcol, if i was visited by earlier columns in this panel; - * - * \param [in]m number of rows in the matrix - * \param [in]w Panel size - * \param [in]jcol Starting column of the panel - * \param [in]A Input matrix in column-major storage - * \param [in]perm_r Row permutation - * \param [out]nseg Number of U segments - * \param [out]dense Accumulate the column vectors of the panel - * \param [out]panel_lsub Subscripts of the row in the panel - * \param [out]segrep Segment representative i.e first nonzero row of each segment - * \param [out]repfnz First nonzero location in each row - * \param [out]xprune - * \param [out]marker - * - * - */ - -template -struct LU_panel_dfs_traits -{ - typedef typename IndexVector::Scalar Index; - LU_panel_dfs_traits(Index jcol, Index* marker) - : m_jcol(jcol), m_marker(marker) - {} - bool update_segrep(Index krep, Index jj) - { - if(m_marker[krep] -void SparseLUBase::LU_panel_dfs(const int m, const int w, const int jcol, MatrixType& A, IndexVector& perm_r, int& nseg, ScalarVector& dense, IndexVector& panel_lsub, IndexVector& segrep, IndexVector& repfnz, IndexVector& xprune, IndexVector& marker, IndexVector& parent, IndexVector& xplore, GlobalLU_t& glu) -{ - int nextl_col; // Next available position in panel_lsub[*,jj] - - // Initialize pointers - VectorBlock marker1(marker, m, m); - nseg = 0; - - LU_panel_dfs_traits traits(jcol, marker1.data()); - - // For each column in the panel - for (int jj = jcol; jj < jcol + w; jj++) - { - nextl_col = (jj - jcol) * m; - - VectorBlock repfnz_col(repfnz, nextl_col, m); // First nonzero location in each row - VectorBlock dense_col(dense,nextl_col, m); // Accumulate a column vector here - - - // For each nnz in A[*, jj] do depth first search - for (typename MatrixType::InnerIterator it(A, jj); it; ++it) - { - int krow = it.row(); - dense_col(krow) = it.value(); - - int kmark = marker(krow); - if (kmark == jj) - continue; // krow visited before, go to the next nonzero - - LU_dfs_kernel(jj, perm_r, nseg, panel_lsub, segrep, repfnz_col, xprune, marker, parent, - xplore, glu, nextl_col, krow, traits); - }// end for nonzeros in column jj - - } // end for column jj - -} -#endif \ No newline at end of file diff --git a/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_pivotL.h b/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_pivotL.h deleted file mode 100644 index c4a9f1c74..000000000 --- a/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_pivotL.h +++ /dev/null @@ -1,125 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2012 Désiré Nuentsa-Wakam -// -// 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/. - -/* - - * NOTE: This file is the modified version of xpivotL.c file in SuperLU - - * -- SuperLU routine (version 3.0) -- - * Univ. of California Berkeley, Xerox Palo Alto Research Center, - * and Lawrence Berkeley National Lab. - * October 15, 2003 - * - * Copyright (c) 1994 by Xerox Corporation. All rights reserved. - * - * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY - * EXPRESSED OR IMPLIED. ANY USE IS AT YOUR OWN RISK. - * - * Permission is hereby granted to use or copy this program for any - * purpose, provided the above notices are retained on all copies. - * Permission to modify the code and to distribute modified code is - * granted, provided the above notices are retained, and a notice that - * the code was modified is included with the above copyright notice. - */ -#ifndef SPARSELU_PIVOTL_H -#define SPARSELU_PIVOTL_H -/** - * \brief Performs the numerical pivotin on the current column of L, and the CDIV operation. - * - * Pivot policy : - * (1) Compute thresh = u * max_(i>=j) abs(A_ij); - * (2) IF user specifies pivot row k and abs(A_kj) >= thresh THEN - * pivot row = k; - * ELSE IF abs(A_jj) >= thresh THEN - * pivot row = j; - * ELSE - * pivot row = m; - * - * Note: If you absolutely want to use a given pivot order, then set u=0.0. - * - * \param jcol The current column of L - * \param u diagonal pivoting threshold - * \param [in,out]perm_r Row permutation (threshold pivoting) - * \param [in] iperm_c column permutation - used to finf diagonal of Pc*A*Pc' - * \param [out]pivrow The pivot row - * \param glu Global LU data - * \return 0 if success, i > 0 if U(i,i) is exactly zero - * - */ -template -int SparseLUBase::LU_pivotL(const int jcol, const RealScalar diagpivotthresh, IndexVector& perm_r, IndexVector& iperm_c, int& pivrow, GlobalLU_t& glu) -{ - - Index fsupc = (glu.xsup)((glu.supno)(jcol)); // First column in the supernode containing the column jcol - Index nsupc = jcol - fsupc; // Number of columns in the supernode portion, excluding jcol; nsupc >=0 - Index lptr = glu.xlsub(fsupc); // pointer to the starting location of the row subscripts for this supernode portion - Index nsupr = glu.xlsub(fsupc+1) - lptr; // Number of rows in the supernode - Scalar* lu_sup_ptr = &(glu.lusup.data()[glu.xlusup(fsupc)]); // Start of the current supernode - Scalar* lu_col_ptr = &(glu.lusup.data()[glu.xlusup(jcol)]); // Start of jcol in the supernode - Index* lsub_ptr = &(glu.lsub.data()[lptr]); // Start of row indices of the supernode - - // Determine the largest abs numerical value for partial pivoting - Index diagind = iperm_c(jcol); // diagonal index - RealScalar pivmax = 0.0; - Index pivptr = nsupc; - Index diag = IND_EMPTY; - RealScalar rtemp; - Index isub, icol, itemp, k; - for (isub = nsupc; isub < nsupr; ++isub) { - rtemp = std::abs(lu_col_ptr[isub]); - if (rtemp > pivmax) { - pivmax = rtemp; - pivptr = isub; - } - if (lsub_ptr[isub] == diagind) diag = isub; - } - - // Test for singularity - if ( pivmax == 0.0 ) { - pivrow = lsub_ptr[pivptr]; - perm_r(pivrow) = jcol; - return (jcol+1); - } - - RealScalar thresh = diagpivotthresh * pivmax; - - // Choose appropriate pivotal element - - { - // Test if the diagonal element can be used as a pivot (given the threshold value) - if (diag >= 0 ) - { - // Diagonal element exists - rtemp = std::abs(lu_col_ptr[diag]); - if (rtemp != 0.0 && rtemp >= thresh) pivptr = diag; - } - pivrow = lsub_ptr[pivptr]; - } - - // Record pivot row - perm_r(pivrow) = jcol; - // Interchange row subscripts - if (pivptr != nsupc ) - { - std::swap( lsub_ptr[pivptr], lsub_ptr[nsupc] ); - // Interchange numerical values as well, for the two rows in the whole snode - // such that L is indexed the same way as A - for (icol = 0; icol <= nsupc; icol++) - { - itemp = pivptr + icol * nsupr; - std::swap(lu_sup_ptr[itemp], lu_sup_ptr[nsupc + icol * nsupr]); - } - } - // cdiv operations - Scalar temp = Scalar(1.0) / lu_col_ptr[nsupc]; - for (k = nsupc+1; k < nsupr; k++) - lu_col_ptr[k] *= temp; - return 0; -} -#endif \ No newline at end of file diff --git a/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_pruneL.h b/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_pruneL.h deleted file mode 100644 index d8c58e039..000000000 --- a/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_pruneL.h +++ /dev/null @@ -1,129 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2012 Désiré Nuentsa-Wakam -// -// 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/. - -/* - - * NOTE: This file is the modified version of [s,d,c,z]pruneL.c file in SuperLU - - * -- SuperLU routine (version 2.0) -- - * Univ. of California Berkeley, Xerox Palo Alto Research Center, - * and Lawrence Berkeley National Lab. - * November 15, 1997 - * - * Copyright (c) 1994 by Xerox Corporation. All rights reserved. - * - * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY - * EXPRESSED OR IMPLIED. ANY USE IS AT YOUR OWN RISK. - * - * Permission is hereby granted to use or copy this program for any - * purpose, provided the above notices are retained on all copies. - * Permission to modify the code and to distribute modified code is - * granted, provided the above notices are retained, and a notice that - * the code was modified is included with the above copyright notice. - */ -#ifndef SPARSELU_PRUNEL_H -#define SPARSELU_PRUNEL_H - -/** - * \brief Prunes the L-structure. - * - * It prunes the L-structure of supernodes whose L-structure contains the current pivot row "pivrow" - * - * - * \param jcol The current column of L - * \param [in]perm_r Row permutation - * \param [out]pivrow The pivot row - * \param nseg Number of segments - * \param segrep - * \param repfnz - * \param [out]xprune - * \param glu Global LU data - * - */ -template -void SparseLUBase::LU_pruneL(const int jcol, const IndexVector& perm_r, const int pivrow, const int nseg, const IndexVector& segrep, BlockIndexVector& repfnz, IndexVector& xprune, GlobalLU_t& glu) -{ - // For each supernode-rep irep in U(*,j] - int jsupno = glu.supno(jcol); - int i,irep,irep1; - bool movnum, do_prune = false; - Index kmin, kmax, minloc, maxloc,krow; - for (i = 0; i < nseg; i++) - { - irep = segrep(i); - irep1 = irep + 1; - do_prune = false; - - // Don't prune with a zero U-segment - if (repfnz(irep) == IND_EMPTY) continue; - - // If a snode overlaps with the next panel, then the U-segment - // is fragmented into two parts -- irep and irep1. We should let - // pruning occur at the rep-column in irep1s snode. - if (glu.supno(irep) == glu.supno(irep1) ) continue; // don't prune - - // If it has not been pruned & it has a nonz in row L(pivrow,i) - if (glu.supno(irep) != jsupno ) - { - if ( xprune (irep) >= glu.xlsub(irep1) ) - { - kmin = glu.xlsub(irep); - kmax = glu.xlsub(irep1) - 1; - for (krow = kmin; krow <= kmax; krow++) - { - if (glu.lsub(krow) == pivrow) - { - do_prune = true; - break; - } - } - } - - if (do_prune) - { - // do a quicksort-type partition - // movnum=true means that the num values have to be exchanged - movnum = false; - if (irep == glu.xsup(glu.supno(irep)) ) // Snode of size 1 - movnum = true; - - while (kmin <= kmax) - { - if (perm_r(glu.lsub(kmax)) == IND_EMPTY) - kmax--; - else if ( perm_r(glu.lsub(kmin)) != IND_EMPTY) - kmin++; - else - { - // kmin below pivrow (not yet pivoted), and kmax - // above pivrow: interchange the two suscripts - std::swap(glu.lsub(kmin), glu.lsub(kmax)); - - // If the supernode has only one column, then we - // only keep one set of subscripts. For any subscript - // intercnahge performed, similar interchange must be - // done on the numerical values. - if (movnum) - { - minloc = glu.xlusup(irep) + ( kmin - glu.xlsub(irep) ); - maxloc = glu.xlusup(irep) + ( kmax - glu.xlsub(irep) ); - std::swap(glu.lusup(minloc), glu.lusup(maxloc)); - } - kmin++; - kmax--; - } - } // end while - - xprune(irep) = kmin; //Pruning - } // end if do_prune - } // end pruning - } // End for each U-segment -} - -#endif \ No newline at end of file diff --git a/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_relax_snode.h b/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_relax_snode.h deleted file mode 100644 index 8db8619c1..000000000 --- a/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_relax_snode.h +++ /dev/null @@ -1,73 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2012 Désiré Nuentsa-Wakam -// -// 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 file is a modified version of heap_relax_snode.c file in SuperLU - * -- SuperLU routine (version 3.0) -- - * Univ. of California Berkeley, Xerox Palo Alto Research Center, - * and Lawrence Berkeley National Lab. - * October 15, 2003 - * - * Copyright (c) 1994 by Xerox Corporation. All rights reserved. - * - * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY - * EXPRESSED OR IMPLIED. ANY USE IS AT YOUR OWN RISK. - * - * Permission is hereby granted to use or copy this program for any - * purpose, provided the above notices are retained on all copies. - * Permission to modify the code and to distribute modified code is - * granted, provided the above notices are retained, and a notice that - * the code was modified is included with the above copyright notice. - */ - -#ifndef SPARSELU_RELAX_SNODE_H -#define SPARSELU_RELAX_SNODE_H -/** - * \brief Identify the initial relaxed supernodes - * - * This routine is applied to a column elimination tree. - * It assumes that the matrix has been reordered according to the postorder of the etree - * \param et elimination tree - * \param relax_columns Maximum number of columns allowed in a relaxed snode - * \param descendants Number of descendants of each node in the etree - * \param relax_end last column in a supernode - */ -template -void SparseLUBase::LU_relax_snode (const int n, IndexVector& et, const int relax_columns, IndexVector& descendants, IndexVector& relax_end) -{ - - // compute the number of descendants of each node in the etree - int j, parent; - relax_end.setConstant(IND_EMPTY); - descendants.setZero(); - for (j = 0; j < n; j++) - { - parent = et(j); - if (parent != n) // not the dummy root - descendants(parent) += descendants(j) + 1; - } - // Identify the relaxed supernodes by postorder traversal of the etree - int snode_start; // beginning of a snode - for (j = 0; j < n; ) - { - parent = et(j); - snode_start = j; - while ( parent != n && descendants(parent) < relax_columns ) - { - j = parent; - parent = et(j); - } - // Found a supernode in postordered etree, j is the last column - relax_end(snode_start) = j; // Record last column - j++; - // Search for a new leaf - while (descendants(j) != 0 && j < n) j++; - } // End postorder traversal of the etree - -} -#endif diff --git a/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_snode_bmod.h b/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_snode_bmod.h deleted file mode 100644 index beea71e31..000000000 --- a/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_snode_bmod.h +++ /dev/null @@ -1,72 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2012 Désiré Nuentsa-Wakam -// -// 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/. - -/* - - * NOTE: This file is the modified version of [s,d,c,z]snode_bmod.c file in SuperLU - - * -- SuperLU routine (version 3.0) -- - * Univ. of California Berkeley, Xerox Palo Alto Research Center, - * and Lawrence Berkeley National Lab. - * October 15, 2003 - * - * Copyright (c) 1994 by Xerox Corporation. All rights reserved. - * - * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY - * EXPRESSED OR IMPLIED. ANY USE IS AT YOUR OWN RISK. - * - * Permission is hereby granted to use or copy this program for any - * purpose, provided the above notices are retained on all copies. - * Permission to modify the code and to distribute modified code is - * granted, provided the above notices are retained, and a notice that - * the code was modified is included with the above copyright notice. - */ -#ifndef SPARSELU_SNODE_BMOD_H -#define SPARSELU_SNODE_BMOD_H -template -int SparseLUBase::LU_snode_bmod (const int jcol, const int fsupc, ScalarVector& dense, GlobalLU_t& glu) -{ - /* lsub : Compressed row subscripts of ( rectangular supernodes ) - * xlsub : xlsub[j] is the starting location of the j-th column in lsub(*) - * lusup : Numerical values of the rectangular supernodes - * xlusup[j] is the starting location of the j-th column in lusup(*) - */ - int nextlu = glu.xlusup(jcol); // Starting location of the next column to add - int irow, isub; - // Process the supernodal portion of L\U[*,jcol] - for (isub = glu.xlsub(fsupc); isub < glu.xlsub(fsupc+1); isub++) - { - irow = glu.lsub(isub); - glu.lusup(nextlu) = dense(irow); - dense(irow) = 0; - ++nextlu; - } - glu.xlusup(jcol + 1) = nextlu; // Initialize xlusup for next column ( jcol+1 ) - - if (fsupc < jcol ){ - int luptr = glu.xlusup(fsupc); // points to the first column of the supernode - int nsupr = glu.xlsub(fsupc + 1) -glu.xlsub(fsupc); //Number of rows in the supernode - int nsupc = jcol - fsupc; // Number of columns in the supernodal portion of L\U[*,jcol] - int ufirst = glu.xlusup(jcol); // points to the beginning of column jcol in supernode L\U(jsupno) - - int nrow = nsupr - nsupc; // Number of rows in the off-diagonal blocks - - // Solve the triangular system for U(fsupc:jcol, jcol) with L(fspuc:jcol, fsupc:jcol) - Map,0,OuterStride<> > A( &(glu.lusup.data()[luptr]), nsupc, nsupc, OuterStride<>(nsupr) ); - VectorBlock u(glu.lusup, ufirst, nsupc); - u = A.template triangularView().solve(u); // Call the Eigen dense triangular solve interface - - // Update the trailing part of the column jcol U(jcol:jcol+nrow, jcol) using L(jcol:jcol+nrow, fsupc:jcol) and U(fsupc:jcol) - new (&A) Map,0,OuterStride<> > ( &(glu.lusup.data()[luptr+nsupc]), nrow, nsupc, OuterStride<>(nsupr) ); - VectorBlock l(glu.lusup, ufirst+nsupc, nrow); - l.noalias() -= A * u; - } - return 0; -} -#endif \ No newline at end of file diff --git a/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_snode_dfs.h b/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_snode_dfs.h deleted file mode 100644 index 199436cd7..000000000 --- a/resources/3rdparty/eigen/Eigen/src/SparseLU/SparseLU_snode_dfs.h +++ /dev/null @@ -1,95 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2012 Désiré Nuentsa-Wakam -// -// 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/. - -/* - - * NOTE: This file is the modified version of [s,d,c,z]snode_dfs.c file in SuperLU - - * -- SuperLU routine (version 2.0) -- - * Univ. of California Berkeley, Xerox Palo Alto Research Center, - * and Lawrence Berkeley National Lab. - * November 15, 1997 - * - * Copyright (c) 1994 by Xerox Corporation. All rights reserved. - * - * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY - * EXPRESSED OR IMPLIED. ANY USE IS AT YOUR OWN RISK. - * - * Permission is hereby granted to use or copy this program for any - * purpose, provided the above notices are retained on all copies. - * Permission to modify the code and to distribute modified code is - * granted, provided the above notices are retained, and a notice that - * the code was modified is included with the above copyright notice. - */ -#ifndef SPARSELU_SNODE_DFS_H -#define SPARSELU_SNODE_DFS_H - /** - * \brief Determine the union of the row structures of those columns within the relaxed snode. - * NOTE: The relaxed snodes are leaves of the supernodal etree, therefore, - * the portion outside the rectangular supernode must be zero. - * - * \param jcol start of the supernode - * \param kcol end of the supernode - * \param asub Row indices - * \param colptr Pointer to the beginning of each column - * \param xprune (out) The pruned tree ?? - * \param marker (in/out) working vector - * \return 0 on success, > 0 size of the memory when memory allocation failed - */ -template -int SparseLUBase::LU_snode_dfs(const int jcol, const int kcol,const MatrixType& mat, IndexVector& xprune, IndexVector& marker, GlobalLU_t& glu) -{ - int mem; - Index nsuper = ++glu.supno(jcol); // Next available supernode number - int nextl = glu.xlsub(jcol); //Index of the starting location of the jcol-th column in lsub - int krow,kmark; - for (int i = jcol; i <=kcol; i++) - { - // For each nonzero in A(*,i) - for (typename MatrixType::InnerIterator it(mat, i); it; ++it) - { - krow = it.row(); - kmark = marker(krow); - if ( kmark != kcol ) - { - // First time to visit krow - marker(krow) = kcol; - glu.lsub(nextl++) = krow; - if( nextl >= glu.nzlmax ) - { - mem = LUMemXpand(glu.lsub, glu.nzlmax, nextl, LSUB, glu.num_expansions); - if (mem) return mem; // Memory expansion failed... Return the memory allocated so far - } - } - } - glu.supno(i) = nsuper; - } - - // If supernode > 1, then make a copy of the subscripts for pruning - if (jcol < kcol) - { - Index new_next = nextl + (nextl - glu.xlsub(jcol)); - while (new_next > glu.nzlmax) - { - mem = LUMemXpand(glu.lsub, glu.nzlmax, nextl, LSUB, glu.num_expansions); - if (mem) return mem; // Memory expansion failed... Return the memory allocated so far - } - Index ifrom, ito = nextl; - for (ifrom = glu.xlsub(jcol); ifrom < nextl;) - glu.lsub(ito++) = glu.lsub(ifrom++); - for (int i = jcol+1; i <=kcol; i++) glu.xlsub(i) = nextl; - nextl = ito; - } - glu.xsup(nsuper+1) = kcol + 1; // Start of next available supernode - glu.supno(kcol+1) = nsuper; - xprune(kcol) = nextl; - glu.xlsub(kcol+1) = nextl; - return 0; -} -#endif \ No newline at end of file diff --git a/resources/3rdparty/eigen/bench/spbench/sp_solver.cpp b/resources/3rdparty/eigen/bench/spbench/sp_solver.cpp deleted file mode 100644 index a1f4bac8a..000000000 --- a/resources/3rdparty/eigen/bench/spbench/sp_solver.cpp +++ /dev/null @@ -1,125 +0,0 @@ -// Small bench routine for Eigen available in Eigen -// (C) Desire NUENTSA WAKAM, INRIA - -#include -#include -#include -#include -#include -#include -#include -#include -//#include -#include -// #include -#include -#include -using namespace std; -using namespace Eigen; - -int main(int argc, char **args) -{ - SparseMatrix A; - typedef SparseMatrix::Index Index; - typedef Matrix DenseMatrix; - typedef Matrix DenseRhs; - VectorXd b, x, tmp; - BenchTimer timer,totaltime; - //SparseLU > solver; -// SuperLU > solver; - ConjugateGradient, Lower,IncompleteCholesky > solver; - ifstream matrix_file; - string line; - int n; - // Set parameters -// solver.iparm(IPARM_THREAD_NBR) = 4; - /* Fill the matrix with sparse matrix stored in Matrix-Market coordinate column-oriented format */ - if (argc < 2) assert(false && "please, give the matrix market file "); - - timer.start(); - totaltime.start(); - loadMarket(A, args[1]); - cout << "End charging matrix " << endl; - bool iscomplex=false, isvector=false; - int sym; - getMarketHeader(args[1], sym, iscomplex, isvector); - if (iscomplex) { cout<< " Not for complex matrices \n"; return -1; } - if (isvector) { cout << "The provided file is not a matrix file\n"; return -1;} - if (sym != 0) { // symmetric matrices, only the lower part is stored - SparseMatrix temp; - temp = A; - A = temp.selfadjointView(); - } - timer.stop(); - - n = A.cols(); - // ====== TESTS FOR SPARSE TUTORIAL ====== -// cout<< "OuterSize " << A.outerSize() << " inner " << A.innerSize() << endl; -// SparseMatrix mat1(A); -// SparseMatrix mat2; -// cout << " norm of A " << mat1.norm() << endl; ; -// PermutationMatrix perm(n); -// perm.resize(n,1); -// perm.indices().setLinSpaced(n, 0, n-1); -// mat2 = perm * mat1; -// mat.subrows(); -// mat2.resize(n,n); -// mat2.reserve(10); -// mat2.setConstant(); -// std::cout<< "NORM " << mat1.squaredNorm()<< endl; - - cout<< "Time to load the matrix " << timer.value() < 2) - loadMarketVector(b, args[2]); - else - { - b.resize(n); - tmp.resize(n); -// tmp.setRandom(); - for (int i = 0; i < n; i++) tmp(i) = i; - b = A * tmp ; - } -// Scaling > scal; -// scal.computeRef(A); -// b = scal.LeftScaling().cwiseProduct(b); - - /* Compute the factorization */ - cout<< "Starting the factorization "<< endl; - timer.reset(); - timer.start(); - cout<< "Size of Input Matrix "<< b.size()<<"\n\n"; - cout<< "Rows and columns "<< A.rows() <<" " < - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/resources/3rdparty/eigen/bench/spbench/spbenchstyle.h b/resources/3rdparty/eigen/bench/spbench/spbenchstyle.h deleted file mode 100644 index 17a05ce71..000000000 --- a/resources/3rdparty/eigen/bench/spbench/spbenchstyle.h +++ /dev/null @@ -1,94 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2012 Désiré Nuentsa-Wakam -// -// 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 SPBENCHSTYLE_H -#define SPBENCHSTYLE_H - -void printBenchStyle(std::ofstream& out) -{ - out << "\n \ - \n \ - \n \ - \n \ - \n \ - \n \ - \n \ - "; - out<<"\n \ - \n \ - \n \ - \n \ - \n \ - \n \ - \n \ - "; - - out<<" \n \ - \n \ - \n \ - \n \ - \n \ - \n \ - \n \ - \n \ - \n \ - \n \ - \n \ - \n \ - "; - out<<" \n \ - \n \ - \n \ - \n \ - \n \ - \n \ - \n \ - \n \ - \n \ - \n \ - \n \ - \n \ - \n \ - \n \ - \n \ - \n \ - \n \ - \n \ - \n \ - \n \ - "; - out<<" \n \ - \n \ - \n \ - \n \ - \n \ - \n \ - \n \ - \n \ -
Matrix N NNZ Sym SPD \n \ - \n \ - \n \ - \n \ - \n \ -
Compute Time
Solve Time
Total Time
Error \n \ - \n \ - (\n \ - \n \ - )\n \ -
\n \ - \n \ - \n \ -
\n \ -
\n\n"; - -} -#endif \ No newline at end of file diff --git a/resources/3rdparty/eigen/bench/spbench/test_sparseLU.cpp b/resources/3rdparty/eigen/bench/spbench/test_sparseLU.cpp deleted file mode 100644 index f8ecbe69b..000000000 --- a/resources/3rdparty/eigen/bench/spbench/test_sparseLU.cpp +++ /dev/null @@ -1,93 +0,0 @@ -// Small bench routine for Eigen available in Eigen -// (C) Desire NUENTSA WAKAM, INRIA - -#include -#include -#include -#include -#include -#include -#ifdef EIGEN_METIS_SUPPORT -#include -#endif - -using namespace std; -using namespace Eigen; - -int main(int argc, char **args) -{ -// typedef complex scalar; - typedef double scalar; - SparseMatrix A; - typedef SparseMatrix::Index Index; - typedef Matrix DenseMatrix; - typedef Matrix DenseRhs; - Matrix b, x, tmp; -// SparseLU, AMDOrdering > solver; -// #ifdef EIGEN_METIS_SUPPORT -// SparseLU, MetisOrdering > solver; -// std::cout<< "ORDERING : METIS\n"; -// #else - SparseLU, COLAMDOrdering > solver; - std::cout<< "ORDERING : COLAMD\n"; -// #endif - - ifstream matrix_file; - string line; - int n; - BenchTimer timer; - - // Set parameters - /* Fill the matrix with sparse matrix stored in Matrix-Market coordinate column-oriented format */ - if (argc < 2) assert(false && "please, give the matrix market file "); - loadMarket(A, args[1]); - cout << "End charging matrix " << endl; - bool iscomplex=false, isvector=false; - int sym; - getMarketHeader(args[1], sym, iscomplex, isvector); -// if (iscomplex) { cout<< " Not for complex matrices \n"; return -1; } - if (isvector) { cout << "The provided file is not a matrix file\n"; return -1;} - if (sym != 0) { // symmetric matrices, only the lower part is stored - SparseMatrix temp; - temp = A; - A = temp.selfadjointView(); - } - n = A.cols(); - /* Fill the right hand side */ - - if (argc > 2) - loadMarketVector(b, args[2]); - else - { - b.resize(n); - tmp.resize(n); -// tmp.setRandom(); - for (int i = 0; i < n; i++) tmp(i) = i; - b = A * tmp ; - } - - /* Compute the factorization */ -// solver.isSymmetric(true); - timer.start(); -// solver.compute(A); - solver.analyzePattern(A); - timer.stop(); - cout << "Time to analyze " << timer.value() << std::endl; - timer.reset(); - timer.start(); - solver.factorize(A); - timer.stop(); - cout << "Factorize Time " << timer.value() << std::endl; - timer.reset(); - timer.start(); - x = solver.solve(b); - timer.stop(); - cout << "solve time " << timer.value() << std::endl; - /* Check the accuracy */ - Matrix tmp2 = b - A*x; - scalar tempNorm = tmp2.norm()/b.norm(); - cout << "Relative norm of the computed solution : " << tempNorm <<"\n"; - cout << "Number of nonzeros in the factor : " << solver.nnzL() + solver.nnzU() << std::endl; - - return 0; -} \ No newline at end of file diff --git a/resources/3rdparty/eigen/blas/GeneralRank1Update.h b/resources/3rdparty/eigen/blas/GeneralRank1Update.h deleted file mode 100644 index 07d388c88..000000000 --- a/resources/3rdparty/eigen/blas/GeneralRank1Update.h +++ /dev/null @@ -1,44 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2012 Chen-Pang He -// -// 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_GENERAL_RANK1UPDATE_H -#define EIGEN_GENERAL_RANK1UPDATE_H - -namespace internal { - -/* Optimized matrix += alpha * uv' */ -template -struct general_rank1_update; - -template -struct general_rank1_update -{ - static void run(Index rows, Index cols, Scalar* mat, Index stride, const Scalar* u, const Scalar* v, Scalar alpha) - { - typedef Map > OtherMap; - typedef typename conj_expr_if::type ConjRhsType; - conj_if cj; - - for (Index i=0; i >(mat+stride*i,rows) += alpha * cj(v[i]) * ConjRhsType(OtherMap(u,rows)); - } -}; - -template -struct general_rank1_update -{ - static void run(Index rows, Index cols, Scalar* mat, Index stride, const Scalar* u, const Scalar* v, Scalar alpha) - { - general_rank1_update::run(rows,cols,mat,stride,u,v,alpha); - } -}; - -} // end namespace internal - -#endif // EIGEN_GENERAL_RANK1UPDATE_H diff --git a/resources/3rdparty/eigen/blas/PackedSelfadjointProduct.h b/resources/3rdparty/eigen/blas/PackedSelfadjointProduct.h deleted file mode 100644 index f7c9b9341..000000000 --- a/resources/3rdparty/eigen/blas/PackedSelfadjointProduct.h +++ /dev/null @@ -1,54 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2012 Chen-Pang He -// -// 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_SELFADJOINT_PACKED_PRODUCT_H -#define EIGEN_SELFADJOINT_PACKED_PRODUCT_H - -namespace internal { - -/* Optimized matrix += alpha * uv' - * The matrix is in packed form. - */ -template -struct selfadjoint_packed_rank1_update; - -template -struct selfadjoint_packed_rank1_update -{ - typedef typename NumTraits::Real RealScalar; - static void run(Index size, Scalar* mat, const Scalar* vec, RealScalar alpha) - { - typedef Map > OtherMap; - typedef typename conj_expr_if::type ConjRhsType; - conj_if cj; - - for (Index i=0; i >(mat, UpLo==Lower ? size-i : (i+1)) - += alpha * cj(vec[i]) * ConjRhsType(OtherMap(vec+(UpLo==Lower ? i : 0), UpLo==Lower ? size-i : (i+1))); - //FIXME This should be handled outside. - mat[UpLo==Lower ? 0 : i] = real(mat[UpLo==Lower ? 0 : i]); - mat += UpLo==Lower ? size-i : (i+1); - } - } -}; - -template -struct selfadjoint_packed_rank1_update -{ - typedef typename NumTraits::Real RealScalar; - static void run(Index size, Scalar* mat, const Scalar* vec, RealScalar alpha) - { - selfadjoint_packed_rank1_update::run(size,mat,vec,alpha); - } -}; - -} // end namespace internal - -#endif // EIGEN_SELFADJOINT_PACKED_PRODUCT_H diff --git a/resources/3rdparty/eigen/blas/PackedTriangularMatrixVector.h b/resources/3rdparty/eigen/blas/PackedTriangularMatrixVector.h deleted file mode 100644 index e9886d56f..000000000 --- a/resources/3rdparty/eigen/blas/PackedTriangularMatrixVector.h +++ /dev/null @@ -1,79 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2012 Chen-Pang He -// -// 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_PACKED_TRIANGULAR_MATRIX_VECTOR_H -#define EIGEN_PACKED_TRIANGULAR_MATRIX_VECTOR_H - -namespace internal { - -template -struct packed_triangular_matrix_vector_product; - -template -struct packed_triangular_matrix_vector_product -{ - typedef typename scalar_product_traits::ReturnType ResScalar; - enum { - IsLower = (Mode & Lower) ==Lower, - HasUnitDiag = (Mode & UnitDiag)==UnitDiag, - HasZeroDiag = (Mode & ZeroDiag)==ZeroDiag - }; - static void run(Index size, const LhsScalar* lhs, const RhsScalar* rhs, ResScalar* res, ResScalar alpha) - { - internal::conj_if cj; - typedef Map > LhsMap; - typedef typename conj_expr_if::type ConjLhsType; - typedef Map > ResMap; - - for (Index i=0; i0)) - ResMap(res+(IsLower ? s+i : 0),r) += alpha * cj(rhs[i]) * ConjLhsType(LhsMap(lhs+s,r)); - if (HasUnitDiag) - res[i] += alpha * cj(rhs[i]); - lhs += IsLower ? size-i: i+1; - } - }; -}; - -template -struct packed_triangular_matrix_vector_product -{ - typedef typename scalar_product_traits::ReturnType ResScalar; - enum { - IsLower = (Mode & Lower) ==Lower, - HasUnitDiag = (Mode & UnitDiag)==UnitDiag, - HasZeroDiag = (Mode & ZeroDiag)==ZeroDiag - }; - static void run(Index size, const LhsScalar* lhs, const RhsScalar* rhs, ResScalar* res, ResScalar alpha) - { - internal::conj_if cj; - typedef Map > LhsMap; - typedef typename conj_expr_if::type ConjLhsType; - typedef Map > RhsMap; - typedef typename conj_expr_if::type ConjRhsType; - - for (Index i=0; i0)) - res[i] += alpha * (ConjLhsType(LhsMap(lhs+s,r)).cwiseProduct(ConjRhsType(RhsMap(rhs+(IsLower ? 0 : s+i),r)))).sum(); - if (HasUnitDiag) - res[i] += alpha * cj(rhs[i]); - lhs += IsLower ? i+1 : size-i; - } - }; -}; - -} // end namespace internal - -#endif // EIGEN_PACKED_TRIANGULAR_MATRIX_VECTOR_H diff --git a/resources/3rdparty/eigen/blas/PackedTriangularSolverVector.h b/resources/3rdparty/eigen/blas/PackedTriangularSolverVector.h deleted file mode 100644 index 5c0bb4bd6..000000000 --- a/resources/3rdparty/eigen/blas/PackedTriangularSolverVector.h +++ /dev/null @@ -1,88 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2012 Chen-Pang He -// -// 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_PACKED_TRIANGULAR_SOLVER_VECTOR_H -#define EIGEN_PACKED_TRIANGULAR_SOLVER_VECTOR_H - -namespace internal { - -template -struct packed_triangular_solve_vector; - -// forward and backward substitution, row-major, rhs is a vector -template -struct packed_triangular_solve_vector -{ - enum { - IsLower = (Mode&Lower)==Lower - }; - static void run(Index size, const LhsScalar* lhs, RhsScalar* rhs) - { - internal::conj_if cj; - typedef Map > LhsMap; - typedef typename conj_expr_if::type ConjLhsType; - - lhs += IsLower ? 0 : (size*(size+1)>>1)-1; - for(Index pi=0; pi0) - rhs[i] -= (ConjLhsType(LhsMap(lhs+s,pi)) - .cwiseProduct(Map >(rhs+(IsLower ? 0 : i+1),pi))).sum(); - if (!(Mode & UnitDiag)) - rhs[i] /= cj(lhs[IsLower ? i : 0]); - IsLower ? lhs += pi+1 : lhs -= pi+2; - } - } -}; - -// forward and backward substitution, column-major, rhs is a vector -template -struct packed_triangular_solve_vector -{ - enum { - IsLower = (Mode&Lower)==Lower - }; - static void run(Index size, const LhsScalar* lhs, RhsScalar* rhs) - { - internal::conj_if cj; - typedef Map > LhsMap; - typedef typename conj_expr_if::type ConjLhsType; - - lhs += IsLower ? 0 : size*(size-1)>>1; - for(Index pi=0; pi0) - Map >(rhs+(IsLower? i+1 : 0),r) -= - rhs[i] * ConjLhsType(LhsMap(lhs+(IsLower? 1 : 0),r)); - IsLower ? lhs += size-pi : lhs -= r; - } - } -}; - -template -struct packed_triangular_solve_vector -{ - static void run(Index size, const LhsScalar* lhs, RhsScalar* rhs) - { - packed_triangular_solve_vector::run(size, lhs, rhs); - } -}; - -} // end namespace internal - -#endif // EIGEN_PACKED_TRIANGULAR_SOLVER_VECTOR_H diff --git a/resources/3rdparty/eigen/blas/Rank2Update.h b/resources/3rdparty/eigen/blas/Rank2Update.h deleted file mode 100644 index 8e1a676ee..000000000 --- a/resources/3rdparty/eigen/blas/Rank2Update.h +++ /dev/null @@ -1,57 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2012 Chen-Pang He -// -// 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_RANK2UPDATE_H -#define EIGEN_RANK2UPDATE_H - -namespace internal { - -/* Optimized selfadjoint matrix += alpha * uv' + conj(alpha)*vu' - * This is the low-level version of SelfadjointRank2Update.h - */ -template -struct rank2_update_selector -{ - static void run(Index size, Scalar* mat, Index stride, const Scalar* u, const Scalar* v, Scalar alpha) - { - typedef Map > OtherMap; - for (Index i=0; i >(mat+stride*i+(UpLo==Lower ? i : 0), UpLo==Lower ? size-i : (i+1)) += - conj(alpha) * conj(u[i]) * OtherMap(v+(UpLo==Lower ? i : 0), UpLo==Lower ? size-i : (i+1)) - + alpha * conj(v[i]) * OtherMap(u+(UpLo==Lower ? i : 0), UpLo==Lower ? size-i : (i+1)); - } - } -}; - -/* Optimized selfadjoint matrix += alpha * uv' + conj(alpha)*vu' - * The matrix is in packed form. - */ -template -struct packed_rank2_update_selector -{ - static void run(Index size, Scalar* mat, const Scalar* u, const Scalar* v, Scalar alpha) - { - typedef Map > OtherMap; - Index offset = 0; - for (Index i=0; i >(mat+offset, UpLo==Lower ? size-i : (i+1)) += - conj(alpha) * conj(u[i]) * OtherMap(v+(UpLo==Lower ? i : 0), UpLo==Lower ? size-i : (i+1)) - + alpha * conj(v[i]) * OtherMap(u+(UpLo==Lower ? i : 0), UpLo==Lower ? size-i : (i+1)); - //FIXME This should be handled outside. - mat[offset+(UpLo==Lower ? 0 : i)] = real(mat[offset+(UpLo==Lower ? 0 : i)]); - offset += UpLo==Lower ? size-i : (i+1); - } - } -}; - -} // end namespace internal - -#endif // EIGEN_RANK2UPDATE_H diff --git a/resources/3rdparty/eigen/doc/I17_SparseLinearSystems.dox b/resources/3rdparty/eigen/doc/I17_SparseLinearSystems.dox deleted file mode 100644 index cc8987d8a..000000000 --- a/resources/3rdparty/eigen/doc/I17_SparseLinearSystems.dox +++ /dev/null @@ -1,110 +0,0 @@ -namespace Eigen { -/** \page TopicSparseSystems Solving Sparse Linear Systems -In Eigen, there are several methods available to solve linear systems when the coefficient matrix is sparse. Because of the special representation of this class of matrices, special care should be taken in order to get a good performance. See \ref TutorialSparse for a detailed introduction about sparse matrices in Eigen. In this page, we briefly present the main steps that are common to all the linear solvers in Eigen together with the main concepts behind them. Depending on the properties of the matrix, the desired accuracy, the end-user is able to tune these steps in order to improve the performance of its code. However, an impatient user does not need to know deeply what's hiding behind these steps: the last section presents a benchmark routine that can be easily used to get an insight on the performance of all the available solvers. - -\b Table \b of \b contents \n - - \ref TheSparseCompute - - \ref TheSparseSolve - - \ref BenchmarkRoutine - - As summarized in \ref TutorialSparseDirectSolvers, there are many built-in solvers in Eigen as well as interface to external solvers libraries. All these solvers follow the same calling sequence. The basic steps are as follows : -\code -#include -// ... -SparseMatrix A; -// fill A -VectorXd b, x; -// fill b -// solve Ax = b -SolverClassName > solver; -solver.compute(A); -if(solver.info()!=Succeeded) { - // decomposition failed - return; -} -x = solver.solve(b); -if(solver.info()!=Succeeded) { - // solving failed - return; -} -\endcode - -\section TheSparseCompute The Compute Step -In the compute() function, the matrix is generally factorized: LLT for self-adjoint matrices, LDLT for general hermitian matrices and LU for non hermitian 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(). - -The goal of analyzePattern() is to reorder the nonzero elements of the matrix, such that the factorization step creates less fill-in. This step exploits only the structure of the matrix. Hence, the results of this step can be used for other linear systems where the matrix has the same structure. Note however that sometimes, some external solvers (like SuperLU) require that the values of the matrix are set in this step, for instance to equilibrate the rows and columns of the matrix. In this situation, the results of this step can note be used with other matrices. - -Eigen provides a limited set of methods to reorder the matrix in this step, either built-in (COLAMD, AMD) or external (METIS). These methods are set in template parameter list of the solver : -\code -DirectSolverClassName, OrderingMethod > solver; -\endcode - -See \link Ordering_Modules the Ordering module \endlink for the list of available methods and the associated options. - -In factorize(), the factors of the coefficient matrix are computed. This step should be called each time the values of the matrix change. However, the structural pattern of the matrix should not change between multiple calls. - -For iterative solvers, the compute step is used to eventually setup a preconditioner. Remember that, basically, the goal of the preconditioner is to speedup the convergence of an iterative method by solving a modified linear system where the coefficient matrix has more clustered eigenvalues. For real problems, an iterative solver should always be used with a preconditioner. In Eigen, a preconditioner is selected by simply adding it as a template parameter to the iterative solver object. -\code -IterativeSolverClassName, PreconditionerName > solver; -\endcode -The member function preconditioner() returns a read-write reference to the preconditioner - to directly interact with it. - -For instance, with the ILUT preconditioner, the incomplete factors L and U are computed in this step. -See \link Sparse_modules the Sparse module \endlink for the list of available preconditioners in Eigen. -\section TheSparseSolve The Solve step -The solve() function computes the solution of the linear systems with one or many right hand sides. -\code -X = solver.solve(B); -\endcode -Here, B can be a vector or a matrix where the columns form the different right hand sides. The solve() function can be called several times as well, for instance When all the right hand sides are not available at once. -\code -x1 = solver.solve(b1); -// Get the second right hand side b2 -x2 = solver.solve(b2); -// ... -\endcode -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 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. First, it should be activated at the configuration step with the flag TEST_REAL_CASES. Then, in bench/spbench, you can compile the routine by typing \b make \e spbenchsolver. You can then run it with --help option to get the list of all available options. Basically, the matrices to test should be in \link http://math.nist.gov/MatrixMarket/formats.html MatrixMarket Coordinate format \endlink, and the routine returns the statistics from all available solvers in Eigen. - -The following table gives an example of XHTML statistics from several Eigen built-in and external solvers. - - -
Matrix N NNZ UMFPACK SUPERLU PASTIX LU BiCGSTAB BiCGSTAB+ILUT GMRES+ILUT LDLT CHOLMOD LDLT PASTIX LDLT LLT CHOLMOD SP LLT CHOLMOD LLT PASTIX LLT CG
vector_graphics 12855 72069 Compute Time 0.02545490.02156770.07018270.0001533880.01401070.01537090.01016010.009305020.0649689 -
Solve Time 0.003378350.0009518260.004843730.03748860.00464450.008477540.0005418130.0002936960.00485376 -
Total Time 0.02883330.02251950.07502650.0376420.01865520.02384840.01070190.009598710.0698227 -
Error(Iter) 1.299e-16 2.04207e-16 4.83393e-15 3.94856e-11 (80) 1.03861e-12 (3) 5.81088e-14 (6) 1.97578e-16 1.83927e-16 4.24115e-15 -
poisson_SPD 19788 308232 Compute Time 0.4250261.823780.6173670.0004789211.340011.334710.7964190.8575730.4730070.8148260.1847190.8615550.4705590.000458188 -
Solve Time 0.02800530.01944020.02687470.2494370.05484440.09269910.008502040.00531710.02589320.008746030.005781550.005303610.02489420.239093 -
Total Time 0.4530311.843220.6442410.2499161.394861.427410.8049210.8628910.49890.8235720.1905010.8668590.4954530.239551 -
Error(Iter) 4.67146e-16 1.068e-15 1.3397e-15 6.29233e-11 (201) 3.68527e-11 (6) 3.3168e-15 (16) 1.86376e-15 1.31518e-16 1.42593e-15 3.45361e-15 3.14575e-16 2.21723e-15 7.21058e-16 9.06435e-12 (261) -
sherman2 1080 23094 Compute Time 0.006317540.0150520.0247514 -0.02144250.0217988 -
Solve Time 0.0004784240.0003379980.0010291 -0.002431520.00246152 -
Total Time 0.006795970.015390.0257805 -0.0238740.0242603 -
Error(Iter) 1.83099e-15 8.19351e-15 2.625e-14 1.3678e+69 (1080) 4.1911e-12 (7) 5.0299e-13 (12) -
bcsstk01_SPD 48 400 Compute Time 0.0001690790.000107890.0005725381.425e-069.1612e-058.3985e-055.6489e-057.0913e-050.0004682515.7389e-058.0212e-055.8394e-050.0004630171.333e-06 -
Solve Time 1.2288e-051.1124e-050.0002863878.5896e-051.6381e-051.6984e-053.095e-064.115e-060.0003254383.504e-067.369e-063.454e-060.0002940956.0516e-05 -
Total Time 0.0001813670.0001190140.0008589258.7321e-050.0001079930.0001009695.9584e-057.5028e-050.0007936896.0893e-058.7581e-056.1848e-050.0007571126.1849e-05 -
Error(Iter) 1.03474e-16 2.23046e-16 2.01273e-16 4.87455e-07 (48) 1.03553e-16 (2) 3.55965e-16 (2) 2.48189e-16 1.88808e-16 1.97976e-16 2.37248e-16 1.82701e-16 2.71474e-16 2.11322e-16 3.547e-09 (48) -
sherman1 1000 3750 Compute Time 0.002288050.002092310.005282689.846e-060.001635220.001621550.0007892590.0008044950.00438269 -
Solve Time 0.0002137889.7983e-050.0009388310.006298350.0003617640.000787944.3989e-052.5331e-050.000917166 -
Total Time 0.002501840.002190290.006221510.00630820.001996980.002409490.0008332480.0008298260.00529986 -
Error(Iter) 1.16839e-16 2.25968e-16 2.59116e-16 3.76779e-11 (248) 4.13343e-11 (4) 2.22347e-14 (10) 2.05861e-16 1.83555e-16 1.02917e-15 -
young1c 841 4089 Compute Time 0.002358430.002172280.005680751.2735e-050.002648660.00258236 -
Solve Time 0.0003295990.0001686340.000801180.05347380.001871930.00450211 -
Total Time 0.002688030.002340910.006481930.05348650.004520590.00708447 -
Error(Iter) 1.27029e-16 2.81321e-16 5.0492e-15 8.0507e-11 (706) 3.00447e-12 (8) 1.46532e-12 (16) -
mhd1280b 1280 22778 Compute Time 0.002348980.002070790.005709182.5976e-050.003025630.002980360.001445250.0009199220.00426444 -
Solve Time 0.001033920.0002119110.001050.01104320.0006282870.003920890.0001383036.2446e-050.00097564 -
Total Time 0.00338290.00228270.006759180.01106920.003653920.006901240.001583550.0009823680.00524008 -
Error(Iter) 1.32953e-16 3.08646e-16 6.734e-16 8.83132e-11 (40) 1.51153e-16 (1) 6.08556e-16 (8) 1.89264e-16 1.97477e-16 6.68126e-09 -
crashbasis 160000 1750416 Compute Time 3.20195.789215.75730.003835153.10063.09921 -
Solve Time 0.2619150.1062250.4021411.490890.248880.443673 -
Total Time 3.463815.8954216.15941.494733.349483.54288 -
Error(Iter) 1.76348e-16 4.58395e-16 1.67982e-14 8.64144e-11 (61) 8.5996e-12 (2) 6.04042e-14 (5) - -
-*/ -} \ No newline at end of file diff --git a/resources/3rdparty/eigen/doc/snippets/GeneralizedEigenSolver.cpp b/resources/3rdparty/eigen/doc/snippets/GeneralizedEigenSolver.cpp deleted file mode 100644 index 2acda45fa..000000000 --- a/resources/3rdparty/eigen/doc/snippets/GeneralizedEigenSolver.cpp +++ /dev/null @@ -1,7 +0,0 @@ -GeneralizedEigenSolver ges; -MatrixXf A = MatrixXf::Random(4,4); -MatrixXf B = MatrixXf::Random(4,4); -ges.compute(A, B); -cout << "The (complex) numerators of the generalzied eigenvalues are: " << ges.alphas().transpose() << endl; -cout << "The (real) denominatore of the generalzied eigenvalues are: " << ges.betas().transpose() << endl; -cout << "The (complex) generalzied eigenvalues are (alphas./beta): " << ges.eigenvalues().transpose() << endl; diff --git a/resources/3rdparty/eigen/doc/snippets/HouseholderQR_householderQ.cpp b/resources/3rdparty/eigen/doc/snippets/HouseholderQR_householderQ.cpp deleted file mode 100644 index e859ce55b..000000000 --- a/resources/3rdparty/eigen/doc/snippets/HouseholderQR_householderQ.cpp +++ /dev/null @@ -1,7 +0,0 @@ -MatrixXf A(MatrixXf::Random(5,3)), thinQ(MatrixXf::Identity(5,3)), Q; -A.setRandom(); -HouseholderQR qr(A); -Q = qr.householderQ(); -thinQ = qr.householderQ() * thinQ; -std::cout << "The complete unitary matrix Q is:\n" << Q << "\n\n"; -std::cout << "The thin matrix Q is:\n" << thinQ << "\n\n"; diff --git a/resources/3rdparty/eigen/doc/snippets/RealQZ_compute.cpp b/resources/3rdparty/eigen/doc/snippets/RealQZ_compute.cpp deleted file mode 100644 index a18da42e8..000000000 --- a/resources/3rdparty/eigen/doc/snippets/RealQZ_compute.cpp +++ /dev/null @@ -1,17 +0,0 @@ -MatrixXf A = MatrixXf::Random(4,4); -MatrixXf B = MatrixXf::Random(4,4); -RealQZ qz(4); // preallocate space for 4x4 matrices -qz.compute(A,B); // A = Q S Z, B = Q T Z - -// print original matrices and result of decomposition -cout << "A:\n" << A << "\n" << "B:\n" << B << "\n"; -cout << "S:\n" << qz.matrixS() << "\n" << "T:\n" << qz.matrixT() << "\n"; -cout << "Q:\n" << qz.matrixQ() << "\n" << "Z:\n" << qz.matrixZ() << "\n"; - -// verify precision -cout << "\nErrors:" - << "\n|A-QSZ|: " << (A-qz.matrixQ()*qz.matrixS()*qz.matrixZ()).norm() - << ", |B-QTZ|: " << (B-qz.matrixQ()*qz.matrixT()*qz.matrixZ()).norm() - << "\n|QQ* - I|: " << (qz.matrixQ()*qz.matrixQ().adjoint() - MatrixXf::Identity(4,4)).norm() - << ", |ZZ* - I|: " << (qz.matrixZ()*qz.matrixZ().adjoint() - MatrixXf::Identity(4,4)).norm() - << "\n"; diff --git a/resources/3rdparty/eigen/test/eigensolver_generalized_real.cpp b/resources/3rdparty/eigen/test/eigensolver_generalized_real.cpp deleted file mode 100644 index e3edbb772..000000000 --- a/resources/3rdparty/eigen/test/eigensolver_generalized_real.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2012 Gael Guennebaud -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#include "main.h" -#include -#include - -template void generalized_eigensolver_real(const MatrixType& m) -{ - typedef typename MatrixType::Index Index; - /* this test covers the following files: - GeneralizedEigenSolver.h - */ - Index rows = m.rows(); - Index cols = m.cols(); - - typedef typename MatrixType::Scalar Scalar; - typedef typename NumTraits::Real RealScalar; - typedef Matrix VectorType; - typedef Matrix RealVectorType; - typedef typename std::complex::Real> Complex; - - MatrixType a = MatrixType::Random(rows,cols); - MatrixType b = MatrixType::Random(rows,cols); - MatrixType a1 = MatrixType::Random(rows,cols); - MatrixType b1 = MatrixType::Random(rows,cols); - MatrixType spdA = a.adjoint() * a + a1.adjoint() * a1; - MatrixType spdB = b.adjoint() * b + b1.adjoint() * b1; - - // lets compare to GeneralizedSelfAdjointEigenSolver - GeneralizedSelfAdjointEigenSolver symmEig(spdA, spdB); - GeneralizedEigenSolver eig(spdA, spdB); - - VERIFY_IS_EQUAL(eig.eigenvalues().imag().cwiseAbs().maxCoeff(), 0); - - VectorType realEigenvalues = eig.eigenvalues().real(); - std::sort(realEigenvalues.data(), realEigenvalues.data()+realEigenvalues.size()); - VERIFY_IS_APPROX(realEigenvalues, symmEig.eigenvalues()); -} - -void test_eigensolver_generalized_real() -{ - int s; - for(int i = 0; i < g_repeat; i++) { - CALL_SUBTEST_1( generalized_eigensolver_real(Matrix4f()) ); - s = internal::random(1,EIGEN_TEST_MAX_SIZE/4); - CALL_SUBTEST_2( generalized_eigensolver_real(MatrixXd(s,s)) ); - - // some trivial but implementation-wise tricky cases - CALL_SUBTEST_2( generalized_eigensolver_real(MatrixXd(1,1)) ); - CALL_SUBTEST_2( generalized_eigensolver_real(MatrixXd(2,2)) ); - CALL_SUBTEST_3( generalized_eigensolver_real(Matrix()) ); - CALL_SUBTEST_4( generalized_eigensolver_real(Matrix2d()) ); - } - - EIGEN_UNUSED_VARIABLE(s) -} diff --git a/resources/3rdparty/eigen/test/evaluators.cpp b/resources/3rdparty/eigen/test/evaluators.cpp deleted file mode 100644 index 3081d7858..000000000 --- a/resources/3rdparty/eigen/test/evaluators.cpp +++ /dev/null @@ -1,321 +0,0 @@ -#define EIGEN_ENABLE_EVALUATORS -#include "main.h" - -using internal::copy_using_evaluator; -using namespace std; - -#define VERIFY_IS_APPROX_EVALUATOR(DEST,EXPR) VERIFY_IS_APPROX(copy_using_evaluator(DEST,(EXPR)), (EXPR).eval()); -#define VERIFY_IS_APPROX_EVALUATOR2(DEST,EXPR,REF) VERIFY_IS_APPROX(copy_using_evaluator(DEST,(EXPR)), (REF).eval()); - -void test_evaluators() -{ - // Testing Matrix evaluator and Transpose - Vector2d v = Vector2d::Random(); - const Vector2d v_const(v); - Vector2d v2; - RowVector2d w; - - VERIFY_IS_APPROX_EVALUATOR(v2, v); - VERIFY_IS_APPROX_EVALUATOR(v2, v_const); - - // Testing Transpose - VERIFY_IS_APPROX_EVALUATOR(w, v.transpose()); // Transpose as rvalue - VERIFY_IS_APPROX_EVALUATOR(w, v_const.transpose()); - - copy_using_evaluator(w.transpose(), v); // Transpose as lvalue - VERIFY_IS_APPROX(w,v.transpose().eval()); - - copy_using_evaluator(w.transpose(), v_const); - VERIFY_IS_APPROX(w,v_const.transpose().eval()); - - // Testing Array evaluator - ArrayXXf a(2,3); - ArrayXXf b(3,2); - a << 1,2,3, 4,5,6; - const ArrayXXf a_const(a); - - VERIFY_IS_APPROX_EVALUATOR(b, a.transpose()); - - VERIFY_IS_APPROX_EVALUATOR(b, a_const.transpose()); - - // Testing CwiseNullaryOp evaluator - copy_using_evaluator(w, RowVector2d::Random()); - VERIFY((w.array() >= -1).all() && (w.array() <= 1).all()); // not easy to test ... - - VERIFY_IS_APPROX_EVALUATOR(w, RowVector2d::Zero()); - - VERIFY_IS_APPROX_EVALUATOR(w, RowVector2d::Constant(3)); - - // mix CwiseNullaryOp and transpose - VERIFY_IS_APPROX_EVALUATOR(w, Vector2d::Zero().transpose()); - - { - // test product expressions - int s = internal::random(1,100); - MatrixXf a(s,s), b(s,s), c(s,s), d(s,s); - a.setRandom(); - b.setRandom(); - c.setRandom(); - d.setRandom(); - VERIFY_IS_APPROX_EVALUATOR(d, (a + b)); - VERIFY_IS_APPROX_EVALUATOR(d, (a + b).transpose()); - VERIFY_IS_APPROX_EVALUATOR2(d, prod(a,b), a*b); - VERIFY_IS_APPROX_EVALUATOR2(d.noalias(), prod(a,b), a*b); - VERIFY_IS_APPROX_EVALUATOR2(d, prod(a,b) + c, a*b + c); - VERIFY_IS_APPROX_EVALUATOR2(d, s * prod(a,b), s * a*b); - VERIFY_IS_APPROX_EVALUATOR2(d, prod(a,b).transpose(), (a*b).transpose()); - VERIFY_IS_APPROX_EVALUATOR2(d, prod(a,b) + prod(b,c), a*b + b*c); - - // check that prod works even with aliasing present - c = a*a; - copy_using_evaluator(a, prod(a,a)); - VERIFY_IS_APPROX(a,c); - } - - { - // test product with all possible sizes - int s = internal::random(1,100); - Matrix m11, res11; m11.setRandom(1,1); - Matrix m14, res14; m14.setRandom(1,4); - Matrix m1X, res1X; m1X.setRandom(1,s); - Matrix m41, res41; m41.setRandom(4,1); - Matrix m44, res44; m44.setRandom(4,4); - Matrix m4X, res4X; m4X.setRandom(4,s); - Matrix mX1, resX1; mX1.setRandom(s,1); - Matrix mX4, resX4; mX4.setRandom(s,4); - Matrix mXX, resXX; mXX.setRandom(s,s); - - VERIFY_IS_APPROX_EVALUATOR2(res11, prod(m11,m11), m11*m11); - VERIFY_IS_APPROX_EVALUATOR2(res11, prod(m14,m41), m14*m41); - VERIFY_IS_APPROX_EVALUATOR2(res11, prod(m1X,mX1), m1X*mX1); - VERIFY_IS_APPROX_EVALUATOR2(res14, prod(m11,m14), m11*m14); - VERIFY_IS_APPROX_EVALUATOR2(res14, prod(m14,m44), m14*m44); - VERIFY_IS_APPROX_EVALUATOR2(res14, prod(m1X,mX4), m1X*mX4); - VERIFY_IS_APPROX_EVALUATOR2(res1X, prod(m11,m1X), m11*m1X); - VERIFY_IS_APPROX_EVALUATOR2(res1X, prod(m14,m4X), m14*m4X); - VERIFY_IS_APPROX_EVALUATOR2(res1X, prod(m1X,mXX), m1X*mXX); - VERIFY_IS_APPROX_EVALUATOR2(res41, prod(m41,m11), m41*m11); - VERIFY_IS_APPROX_EVALUATOR2(res41, prod(m44,m41), m44*m41); - VERIFY_IS_APPROX_EVALUATOR2(res41, prod(m4X,mX1), m4X*mX1); - VERIFY_IS_APPROX_EVALUATOR2(res44, prod(m41,m14), m41*m14); - VERIFY_IS_APPROX_EVALUATOR2(res44, prod(m44,m44), m44*m44); - VERIFY_IS_APPROX_EVALUATOR2(res44, prod(m4X,mX4), m4X*mX4); - VERIFY_IS_APPROX_EVALUATOR2(res4X, prod(m41,m1X), m41*m1X); - VERIFY_IS_APPROX_EVALUATOR2(res4X, prod(m44,m4X), m44*m4X); - VERIFY_IS_APPROX_EVALUATOR2(res4X, prod(m4X,mXX), m4X*mXX); - VERIFY_IS_APPROX_EVALUATOR2(resX1, prod(mX1,m11), mX1*m11); - VERIFY_IS_APPROX_EVALUATOR2(resX1, prod(mX4,m41), mX4*m41); - VERIFY_IS_APPROX_EVALUATOR2(resX1, prod(mXX,mX1), mXX*mX1); - VERIFY_IS_APPROX_EVALUATOR2(resX4, prod(mX1,m14), mX1*m14); - VERIFY_IS_APPROX_EVALUATOR2(resX4, prod(mX4,m44), mX4*m44); - VERIFY_IS_APPROX_EVALUATOR2(resX4, prod(mXX,mX4), mXX*mX4); - VERIFY_IS_APPROX_EVALUATOR2(resXX, prod(mX1,m1X), mX1*m1X); - VERIFY_IS_APPROX_EVALUATOR2(resXX, prod(mX4,m4X), mX4*m4X); - VERIFY_IS_APPROX_EVALUATOR2(resXX, prod(mXX,mXX), mXX*mXX); - } - - // this does not work because Random is eval-before-nested: - // copy_using_evaluator(w, Vector2d::Random().transpose()); - - // test CwiseUnaryOp - VERIFY_IS_APPROX_EVALUATOR(v2, 3 * v); - VERIFY_IS_APPROX_EVALUATOR(w, (3 * v).transpose()); - VERIFY_IS_APPROX_EVALUATOR(b, (a + 3).transpose()); - VERIFY_IS_APPROX_EVALUATOR(b, (2 * a_const + 3).transpose()); - - // test CwiseBinaryOp - VERIFY_IS_APPROX_EVALUATOR(v2, v + Vector2d::Ones()); - VERIFY_IS_APPROX_EVALUATOR(w, (v + Vector2d::Ones()).transpose().cwiseProduct(RowVector2d::Constant(3))); - - // dynamic matrices and arrays - MatrixXd mat1(6,6), mat2(6,6); - VERIFY_IS_APPROX_EVALUATOR(mat1, MatrixXd::Identity(6,6)); - VERIFY_IS_APPROX_EVALUATOR(mat2, mat1); - copy_using_evaluator(mat2.transpose(), mat1); - VERIFY_IS_APPROX(mat2.transpose(), mat1); - - ArrayXXd arr1(6,6), arr2(6,6); - VERIFY_IS_APPROX_EVALUATOR(arr1, ArrayXXd::Constant(6,6, 3.0)); - VERIFY_IS_APPROX_EVALUATOR(arr2, arr1); - - // test automatic resizing - mat2.resize(3,3); - VERIFY_IS_APPROX_EVALUATOR(mat2, mat1); - arr2.resize(9,9); - VERIFY_IS_APPROX_EVALUATOR(arr2, arr1); - - // test direct traversal - Matrix3f m3; - Array33f a3; - VERIFY_IS_APPROX_EVALUATOR(m3, Matrix3f::Identity()); // matrix, nullary - // TODO: find a way to test direct traversal with array - VERIFY_IS_APPROX_EVALUATOR(m3.transpose(), Matrix3f::Identity().transpose()); // transpose - VERIFY_IS_APPROX_EVALUATOR(m3, 2 * Matrix3f::Identity()); // unary - VERIFY_IS_APPROX_EVALUATOR(m3, Matrix3f::Identity() + Matrix3f::Zero()); // binary - VERIFY_IS_APPROX_EVALUATOR(m3.block(0,0,2,2), Matrix3f::Identity().block(1,1,2,2)); // block - - // test linear traversal - VERIFY_IS_APPROX_EVALUATOR(m3, Matrix3f::Zero()); // matrix, nullary - VERIFY_IS_APPROX_EVALUATOR(a3, Array33f::Zero()); // array - VERIFY_IS_APPROX_EVALUATOR(m3.transpose(), Matrix3f::Zero().transpose()); // transpose - VERIFY_IS_APPROX_EVALUATOR(m3, 2 * Matrix3f::Zero()); // unary - VERIFY_IS_APPROX_EVALUATOR(m3, Matrix3f::Zero() + m3); // binary - - // test inner vectorization - Matrix4f m4, m4src = Matrix4f::Random(); - Array44f a4, a4src = Matrix4f::Random(); - VERIFY_IS_APPROX_EVALUATOR(m4, m4src); // matrix - VERIFY_IS_APPROX_EVALUATOR(a4, a4src); // array - VERIFY_IS_APPROX_EVALUATOR(m4.transpose(), m4src.transpose()); // transpose - // TODO: find out why Matrix4f::Zero() does not allow inner vectorization - VERIFY_IS_APPROX_EVALUATOR(m4, 2 * m4src); // unary - VERIFY_IS_APPROX_EVALUATOR(m4, m4src + m4src); // binary - - // test linear vectorization - MatrixXf mX(6,6), mXsrc = MatrixXf::Random(6,6); - ArrayXXf aX(6,6), aXsrc = ArrayXXf::Random(6,6); - VERIFY_IS_APPROX_EVALUATOR(mX, mXsrc); // matrix - VERIFY_IS_APPROX_EVALUATOR(aX, aXsrc); // array - VERIFY_IS_APPROX_EVALUATOR(mX.transpose(), mXsrc.transpose()); // transpose - VERIFY_IS_APPROX_EVALUATOR(mX, MatrixXf::Zero(6,6)); // nullary - VERIFY_IS_APPROX_EVALUATOR(mX, 2 * mXsrc); // unary - VERIFY_IS_APPROX_EVALUATOR(mX, mXsrc + mXsrc); // binary - - // test blocks and slice vectorization - VERIFY_IS_APPROX_EVALUATOR(m4, (mXsrc.block<4,4>(1,0))); - VERIFY_IS_APPROX_EVALUATOR(aX, ArrayXXf::Constant(10, 10, 3.0).block(2, 3, 6, 6)); - - Matrix4f m4ref = m4; - copy_using_evaluator(m4.block(1, 1, 2, 3), m3.bottomRows(2)); - m4ref.block(1, 1, 2, 3) = m3.bottomRows(2); - VERIFY_IS_APPROX(m4, m4ref); - - mX.setIdentity(20,20); - MatrixXf mXref = MatrixXf::Identity(20,20); - mXsrc = MatrixXf::Random(9,12); - copy_using_evaluator(mX.block(4, 4, 9, 12), mXsrc); - mXref.block(4, 4, 9, 12) = mXsrc; - VERIFY_IS_APPROX(mX, mXref); - - // test Map - const float raw[3] = {1,2,3}; - float buffer[3] = {0,0,0}; - Vector3f v3; - Array3f a3f; - VERIFY_IS_APPROX_EVALUATOR(v3, Map(raw)); - VERIFY_IS_APPROX_EVALUATOR(a3f, Map(raw)); - Vector3f::Map(buffer) = 2*v3; - VERIFY(buffer[0] == 2); - VERIFY(buffer[1] == 4); - VERIFY(buffer[2] == 6); - - // test CwiseUnaryView - mat1.setRandom(); - mat2.setIdentity(); - MatrixXcd matXcd(6,6), matXcd_ref(6,6); - copy_using_evaluator(matXcd.real(), mat1); - copy_using_evaluator(matXcd.imag(), mat2); - matXcd_ref.real() = mat1; - matXcd_ref.imag() = mat2; - VERIFY_IS_APPROX(matXcd, matXcd_ref); - - // test Select - VERIFY_IS_APPROX_EVALUATOR(aX, (aXsrc > 0).select(aXsrc, -aXsrc)); - - // test Replicate - mXsrc = MatrixXf::Random(6, 6); - VectorXf vX = VectorXf::Random(6); - mX.resize(6, 6); - VERIFY_IS_APPROX_EVALUATOR(mX, mXsrc.colwise() + vX); - matXcd.resize(12, 12); - VERIFY_IS_APPROX_EVALUATOR(matXcd, matXcd_ref.replicate(2,2)); - VERIFY_IS_APPROX_EVALUATOR(matXcd, (matXcd_ref.replicate<2,2>())); - - // test partial reductions - VectorXd vec1(6); - VERIFY_IS_APPROX_EVALUATOR(vec1, mat1.rowwise().sum()); - VERIFY_IS_APPROX_EVALUATOR(vec1, mat1.colwise().sum().transpose()); - - // test MatrixWrapper and ArrayWrapper - mat1.setRandom(6,6); - arr1.setRandom(6,6); - VERIFY_IS_APPROX_EVALUATOR(mat2, arr1.matrix()); - VERIFY_IS_APPROX_EVALUATOR(arr2, mat1.array()); - VERIFY_IS_APPROX_EVALUATOR(mat2, (arr1 + 2).matrix()); - VERIFY_IS_APPROX_EVALUATOR(arr2, mat1.array() + 2); - mat2.array() = arr1 * arr1; - VERIFY_IS_APPROX(mat2, (arr1 * arr1).matrix()); - arr2.matrix() = MatrixXd::Identity(6,6); - VERIFY_IS_APPROX(arr2, MatrixXd::Identity(6,6).array()); - - // test Reverse - VERIFY_IS_APPROX_EVALUATOR(arr2, arr1.reverse()); - VERIFY_IS_APPROX_EVALUATOR(arr2, arr1.colwise().reverse()); - VERIFY_IS_APPROX_EVALUATOR(arr2, arr1.rowwise().reverse()); - arr2.reverse() = arr1; - VERIFY_IS_APPROX(arr2, arr1.reverse()); - mat2.array() = mat1.array().reverse(); - VERIFY_IS_APPROX(mat2.array(), mat1.array().reverse()); - - // test Diagonal - VERIFY_IS_APPROX_EVALUATOR(vec1, mat1.diagonal()); - vec1.resize(5); - VERIFY_IS_APPROX_EVALUATOR(vec1, mat1.diagonal(1)); - VERIFY_IS_APPROX_EVALUATOR(vec1, mat1.diagonal<-1>()); - vec1.setRandom(); - - mat2 = mat1; - copy_using_evaluator(mat1.diagonal(1), vec1); - mat2.diagonal(1) = vec1; - VERIFY_IS_APPROX(mat1, mat2); - - copy_using_evaluator(mat1.diagonal<-1>(), mat1.diagonal(1)); - mat2.diagonal<-1>() = mat2.diagonal(1); - VERIFY_IS_APPROX(mat1, mat2); - - { - // test swapping - MatrixXd mat1, mat2, mat1ref, mat2ref; - mat1ref = mat1 = MatrixXd::Random(6, 6); - mat2ref = mat2 = 2 * mat1 + MatrixXd::Identity(6, 6); - swap_using_evaluator(mat1, mat2); - mat1ref.swap(mat2ref); - VERIFY_IS_APPROX(mat1, mat1ref); - VERIFY_IS_APPROX(mat2, mat2ref); - - swap_using_evaluator(mat1.block(0, 0, 3, 3), mat2.block(3, 3, 3, 3)); - mat1ref.block(0, 0, 3, 3).swap(mat2ref.block(3, 3, 3, 3)); - VERIFY_IS_APPROX(mat1, mat1ref); - VERIFY_IS_APPROX(mat2, mat2ref); - - swap_using_evaluator(mat1.row(2), mat2.col(3).transpose()); - mat1.row(2).swap(mat2.col(3).transpose()); - VERIFY_IS_APPROX(mat1, mat1ref); - VERIFY_IS_APPROX(mat2, mat2ref); - } - - { - // test compound assignment - const Matrix4d mat_const = Matrix4d::Random(); - Matrix4d mat, mat_ref; - mat = mat_ref = Matrix4d::Identity(); - add_assign_using_evaluator(mat, mat_const); - mat_ref += mat_const; - VERIFY_IS_APPROX(mat, mat_ref); - - subtract_assign_using_evaluator(mat.row(1), 2*mat.row(2)); - mat_ref.row(1) -= 2*mat_ref.row(2); - VERIFY_IS_APPROX(mat, mat_ref); - - const ArrayXXf arr_const = ArrayXXf::Random(5,3); - ArrayXXf arr, arr_ref; - arr = arr_ref = ArrayXXf::Constant(5, 3, 0.5); - multiply_assign_using_evaluator(arr, arr_const); - arr_ref *= arr_const; - VERIFY_IS_APPROX(arr, arr_ref); - - divide_assign_using_evaluator(arr.row(1), arr.row(2) + 1); - arr_ref.row(1) /= (arr_ref.row(2) + 1); - VERIFY_IS_APPROX(arr, arr_ref); - } -} diff --git a/resources/3rdparty/eigen/test/real_qz.cpp b/resources/3rdparty/eigen/test/real_qz.cpp deleted file mode 100644 index 951cf5b31..000000000 --- a/resources/3rdparty/eigen/test/real_qz.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2012 Alexey Korepanov -// -// This Source Code Form is subject to the terms of the Mozilla -// Public License v. 2.0. If a copy of the MPL was not distributed -// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#include "main.h" -#include -#include - -template void real_qz(const MatrixType& m) -{ - /* this test covers the following files: - RealQZ.h - */ - - typedef typename MatrixType::Index Index; - typedef typename MatrixType::Scalar Scalar; - typedef typename NumTraits::Real RealScalar; - typedef Matrix VectorType; - typedef Matrix RealVectorType; - typedef typename std::complex::Real> Complex; - - Index dim = m.cols(); - - MatrixType A = MatrixType::Random(dim,dim), - B = MatrixType::Random(dim,dim); - - RealQZ qz(A,B); - - VERIFY_IS_EQUAL(qz.info(), Success); - // check for zeros - bool all_zeros = true; - for (Index i=0; i0 && internal::abs(qz.matrixS()(i,j))!=Scalar(0.0) && internal::abs(qz.matrixS()(i-1,j-1))!=Scalar(0.0)) - all_zeros = false; - } - VERIFY_IS_EQUAL(all_zeros, true); - VERIFY_IS_APPROX(qz.matrixQ()*qz.matrixS()*qz.matrixZ(), A); - VERIFY_IS_APPROX(qz.matrixQ()*qz.matrixT()*qz.matrixZ(), B); - VERIFY_IS_APPROX(qz.matrixQ()*qz.matrixQ().adjoint(), MatrixType::Identity(dim,dim)); - VERIFY_IS_APPROX(qz.matrixZ()*qz.matrixZ().adjoint(), MatrixType::Identity(dim,dim)); -} - -void test_real_qz() -{ - int s; - for(int i = 0; i < g_repeat; i++) { - CALL_SUBTEST_1( real_qz(Matrix4f()) ); - s = internal::random(1,EIGEN_TEST_MAX_SIZE/4); - CALL_SUBTEST_2( real_qz(MatrixXd(s,s)) ); - - // some trivial but implementation-wise tricky cases - CALL_SUBTEST_2( real_qz(MatrixXd(1,1)) ); - CALL_SUBTEST_2( real_qz(MatrixXd(2,2)) ); - CALL_SUBTEST_3( real_qz(Matrix()) ); - CALL_SUBTEST_4( real_qz(Matrix2d()) ); - } - - EIGEN_UNUSED_VARIABLE(s) -} diff --git a/resources/3rdparty/eigen/test/sparselu.cpp b/resources/3rdparty/eigen/test/sparselu.cpp deleted file mode 100644 index e960f9c93..000000000 --- a/resources/3rdparty/eigen/test/sparselu.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2012 Désiré Nuentsa-Wakam -// -// Eigen 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 3 of the License, or (at your option) any later version. -// -// Alternatively, 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 2 of -// the License, or (at your option) any later version. -// -// Eigen 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 or the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License and a copy of the GNU General Public License along with -// Eigen. If not, see . -#include "sparse_solver.h" -#include -#include - -template void test_sparselu_T() -{ - SparseLU, COLAMDOrdering > sparselu_colamd; - SparseLU, AMDOrdering > sparselu_amd; - - check_sparse_square_solving(sparselu_colamd); - check_sparse_square_solving(sparselu_amd); -} - -void test_sparselu() -{ - CALL_SUBTEST_1(test_sparselu_T()); - CALL_SUBTEST_2(test_sparselu_T()); - CALL_SUBTEST_3(test_sparselu_T >()); - CALL_SUBTEST_4(test_sparselu_T >()); -} \ No newline at end of file diff --git a/resources/3rdparty/eigen/unsupported/Eigen/src/IterativeSolvers/IncompleteCholesky.h b/resources/3rdparty/eigen/unsupported/Eigen/src/IterativeSolvers/IncompleteCholesky.h deleted file mode 100644 index 5bc41c0f8..000000000 --- a/resources/3rdparty/eigen/unsupported/Eigen/src/IterativeSolvers/IncompleteCholesky.h +++ /dev/null @@ -1,221 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2012 Désiré Nuentsa-Wakam -// -// 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_INCOMPLETE_CHOlESKY_H -#define EIGEN_INCOMPLETE_CHOlESKY_H -#include "Eigen/src/IterativeLinearSolvers/IncompleteLUT.h" -#include -#include - -namespace Eigen { -/** - * \brief Modified Incomplete Cholesky with dual threshold - * - * References : C-J. Lin and J. J. Moré, Incomplete Cholesky Factorizations with - * Limited memory, SIAM J. Sci. Comput. 21(1), pp. 24-45, 1999 - * - * \tparam _MatrixType The type of the sparse matrix. It should be a symmetric - * matrix. It is advised to give a row-oriented sparse matrix - * \tparam _UpLo The triangular part of the matrix to reference. - * \tparam _OrderingType - */ - -template > -class IncompleteCholesky : internal::noncopyable -{ - public: - typedef SparseMatrix MatrixType; - typedef _OrderingType OrderingType; - typedef typename MatrixType::RealScalar RealScalar; - typedef typename MatrixType::Index Index; - typedef PermutationMatrix PermutationType; - typedef Matrix VectorType; - typedef Matrix IndexType; - - public: - IncompleteCholesky() {} - IncompleteCholesky(const MatrixType& matrix) - { - compute(matrix); - } - - Index rows() const { return m_L.rows(); } - - Index cols() const { return m_L.cols(); } - - - /** \brief Reports whether previous computation was successful. - * - * \returns \c Success if computation was succesful, - * \c NumericalIssue if the matrix appears to be negative. - */ - ComputationInfo info() const - { - eigen_assert(m_isInitialized && "IncompleteLLT is not initialized."); - return m_info; - } - /** - * \brief Computes the fill reducing permutation vector. - */ - template - void analyzePattern(const MatrixType& mat) - { - OrderingType ord; - ord(mat, m_perm); - m_analysisIsOk = true; - } - - template - void factorize(const MatrixType& amat); - - template - void compute (const MatrixType& matrix) - { - analyzePattern(matrix); - factorize(matrix); - } - - template - void _solve(const Rhs& b, Dest& x) const - { - eigen_assert(m_factorizationIsOk && "factorize() should be called first"); - if (m_perm.rows() == b.rows()) - x = m_perm.inverse() * b; - else - x = b; - x = m_L.template triangularView().solve(x); - x = m_L.adjoint().template triangularView().solve(x); - if (m_perm.rows() == b.rows()) - x = m_perm * x; - } - template inline const internal::solve_retval - solve(const MatrixBase& b) const - { - eigen_assert(m_isInitialized && "IncompleteLLT is not initialized."); - eigen_assert(cols()==b.rows() - && "IncompleteLLT::solve(): invalid number of rows of the right hand side matrix b"); - return internal::solve_retval(*this, b.derived()); - } - protected: - SparseMatrix m_L; // The lower part stored in CSC - bool m_analysisIsOk; - bool m_factorizationIsOk; - bool m_isInitialized; - ComputationInfo m_info; - PermutationType m_perm; - -}; - -template -template -void IncompleteCholesky::factorize(const _MatrixType& mat) -{ - eigen_assert(m_analysisIsOk && "analyzePattern() should be called first"); - - // FIXME Stability: We should probably compute the scaling factors and the shifts that are needed to ensure a succesful LLT factorization and an efficient preconditioner. - - // Dropping strategies : Keep only the p largest elements per column, where p is the number of elements in the column of the original matrix. Other strategies will be added - - // Apply the fill-reducing permutation computed in analyzePattern() - if (m_perm.rows() == mat.rows() ) - m_L.template selfadjointView() = mat.template selfadjointView<_UpLo>().twistedBy(m_perm); - else - m_L.template selfadjointView() = mat.template selfadjointView<_UpLo>(); - - int n = mat.cols(); - - Scalar *vals = m_L.valuePtr(); //Values - Index *rowIdx = m_L.innerIndexPtr(); //Row indices - Index *colPtr = m_L.outerIndexPtr(); // Pointer to the beginning of each row - VectorType firstElt(n-1); // for each j, points to the next entry in vals that will be used in the factorization - // Initialize firstElt; - for (int j = 0; j < n-1; j++) firstElt(j) = colPtr[j]+1; - std::vector > listCol(n); // listCol(j) is a linked list of columns to update column j - VectorType curCol(n); // Store a nonzero values in each column - VectorType irow(n); // Row indices of nonzero elements in each column - // jki version of the Cholesky factorization - for (int j=0; j < n; j++) - { - //Left-looking factorize the column j - // First, load the jth column into curCol - Scalar diag = vals[colPtr[j]]; // Lower diagonal matrix with - curCol.setZero(); - irow.setLinSpaced(n,0,n-1); - for (int i = colPtr[j] + 1; i < colPtr[j+1]; i++) - { - curCol(rowIdx[i]) = vals[i]; - irow(rowIdx[i]) = rowIdx[i]; - } - - std::list::iterator k; - // Browse all previous columns that will update column j - for(k = listCol[j].begin(); k != listCol[j].end(); k++) - { - int jk = firstElt(*k); // First element to use in the column - Scalar a_jk = vals[jk]; - diag -= a_jk * a_jk; - jk += 1; - for (int i = jk; i < colPtr[*k]; i++) - { - curCol(rowIdx[i]) -= vals[i] * a_jk ; - } - firstElt(*k) = jk; - if (jk < colPtr[*k+1]) - { - // Add this column to the updating columns list for column *k+1 - listCol[rowIdx[jk]].push_back(*k); - } - } - - // Select the largest p elements - // p is the original number of elements in the column (without the diagonal) - int p = colPtr[j+1] - colPtr[j] - 2 ; - internal::QuickSplit(curCol, irow, p); - if(RealScalar(diag) <= 0) - { //FIXME We can use heuristics (Kershaw, 1978 or above reference ) to get a dynamic shift - m_info = NumericalIssue; - return; - } - RealScalar rdiag = internal::sqrt(RealScalar(diag)); - Scalar scal = Scalar(1)/rdiag; - vals[colPtr[j]] = rdiag; - // Insert the largest p elements in the matrix and scale them meanwhile - int cpt = 0; - for (int i = colPtr[j]+1; i < colPtr[j+1]; i++) - { - vals[i] = curCol(cpt) * scal; - rowIdx[i] = irow(cpt); - cpt ++; - } - } - m_factorizationIsOk = true; - m_isInitialized = true; - m_info = Success; -} - -namespace internal { - -template -struct solve_retval, Rhs> - : solve_retval_base, Rhs> -{ - typedef IncompleteCholesky<_MatrixType> Dec; - EIGEN_MAKE_SOLVE_HELPERS(Dec,Rhs) - - template void evalTo(Dest& dst) const - { - dec()._solve(rhs(),dst); - } -}; - -} // end namespace internal - -} // end namespace Eigen - -#endif \ No newline at end of file diff --git a/resources/3rdparty/eigen/unsupported/Eigen/src/MatrixFunctions/MatrixPower.h b/resources/3rdparty/eigen/unsupported/Eigen/src/MatrixFunctions/MatrixPower.h deleted file mode 100644 index bf8bc4424..000000000 --- a/resources/3rdparty/eigen/unsupported/Eigen/src/MatrixFunctions/MatrixPower.h +++ /dev/null @@ -1,386 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2012 Chen-Pang He -// -// 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_MATRIX_POWER -#define EIGEN_MATRIX_POWER - -namespace Eigen { - -template class MatrixPowerEvaluator; - -/** - * \ingroup MatrixFunctions_Module - * - * \brief Class for computing matrix powers. - * - * \tparam MatrixType type of the base, expected to be an instantiation - * of the Matrix class template. - * - * This class is capable of computing real/complex matrices raised to - * an arbitrary real power. Meanwhile, it saves the result of Schur - * decomposition if an non-integral power has even been calculated. - * Therefore, if you want to compute multiple (>= 2) matrix powers - * for the same matrix, using the class directly is more efficient than - * calling MatrixBase::pow(). - * - * Example: - * \include MatrixPower_optimal.cpp - * Output: \verbinclude MatrixPower_optimal.out - */ -template -class MatrixPower : public MatrixPowerBase,MatrixType> -{ - public: - EIGEN_MATRIX_POWER_PUBLIC_INTERFACE(MatrixPower) - - /** - * \brief Constructor. - * - * \param[in] A the base of the matrix power. - * - * \warning Construct with a matrix, not a matrix expression! - */ - explicit MatrixPower(const MatrixType& A) : Base(A,0) - { } - - /** - * \brief Return the expression \f$ A^p \f$. - * - * \param[in] p exponent, a real scalar. - */ - const MatrixPowerEvaluator operator()(RealScalar p) - { return MatrixPowerEvaluator(*this, p); } - - /** - * \brief Compute the matrix power. - * - * \param[in] p exponent, a real scalar. - * \param[out] res \f$ A^p \f$ where A is specified in the - * constructor. - */ - void compute(MatrixType& res, RealScalar p); - - /** - * \brief Compute the matrix power multiplied by another matrix. - * - * \param[in] b a matrix with the same rows as A. - * \param[in] p exponent, a real scalar. - * \param[out] res \f$ A^p b \f$, where A is specified in the - * constructor. - */ - template - void compute(const Derived& b, ResultType& res, RealScalar p); - - private: - EIGEN_MATRIX_POWER_PROTECTED_MEMBERS(MatrixPower) - - typedef Matrix, RowsAtCompileTime, ColsAtCompileTime, - Options,MaxRowsAtCompileTime,MaxColsAtCompileTime> ComplexMatrix; - ComplexMatrix m_T, m_U, m_fT; - - RealScalar modfAndInit(RealScalar, RealScalar*); - - template - void apply(const Derived&, ResultType&, bool&); - - template - void computeIntPower(ResultType&, RealScalar); - - template - void computeIntPower(const Derived&, ResultType&, RealScalar); - - template - void computeFracPower(ResultType&, RealScalar); -}; - -template -void MatrixPower::compute(MatrixType& res, RealScalar p) -{ - switch (m_A.cols()) { - case 0: - break; - case 1: - res(0,0) = std::pow(m_A.coeff(0,0), p); - break; - default: - RealScalar intpart, x = modfAndInit(p, &intpart); - res = m_Id; - computeIntPower(res, intpart); - computeFracPower(res, x); - } -} - -template -template -void MatrixPower::compute(const Derived& b, ResultType& res, RealScalar p) -{ - switch (m_A.cols()) { - case 0: - break; - case 1: - res = std::pow(m_A.coeff(0,0), p) * b; - break; - default: - RealScalar intpart, x = modfAndInit(p, &intpart); - computeIntPower(b, res, intpart); - computeFracPower(res, x); - } -} - -template -typename MatrixPower::Base::RealScalar MatrixPower::modfAndInit(RealScalar x, RealScalar* intpart) -{ - *intpart = std::floor(x); - RealScalar res = x - *intpart; - - if (!m_conditionNumber && res) { - const ComplexSchur schurOfA(m_A); - m_T = schurOfA.matrixT(); - m_U = schurOfA.matrixU(); - - const RealArray absTdiag = m_T.diagonal().array().abs(); - m_conditionNumber = absTdiag.maxCoeff() / absTdiag.minCoeff(); - } - - if (res>RealScalar(0.5) && res>(1-res)*std::pow(m_conditionNumber, res)) { - --res; - ++*intpart; - } - return res; -} - -template -template -void MatrixPower::apply(const Derived& b, ResultType& res, bool& init) -{ - if (init) - res = m_tmp1 * res; - else { - init = true; - res.noalias() = m_tmp1 * b; - } -} - -template -template -void MatrixPower::computeIntPower(ResultType& res, RealScalar p) -{ - RealScalar pp = std::abs(p); - - if (p<0) m_tmp1 = m_A.inverse(); - else m_tmp1 = m_A; - - while (pp >= 1) { - if (std::fmod(pp, 2) >= 1) - res = m_tmp1 * res; - m_tmp1 *= m_tmp1; - pp /= 2; - } -} - -template -template -void MatrixPower::computeIntPower(const Derived& b, ResultType& res, RealScalar p) -{ - if (b.cols() >= m_A.cols()) { - m_tmp2 = m_Id; - computeIntPower(m_tmp2, p); - res.noalias() = m_tmp2 * b; - } - else { - RealScalar pp = std::abs(p); - int squarings, applyings = internal::binary_powering_cost(pp, &squarings); - bool init = false; - - if (p==0) { - res = b; - return; - } - else if (p>0) { - m_tmp1 = m_A; - } - else if (m_A.cols() > 2 && b.cols()*(pp-applyings) <= m_A.cols()*squarings) { - PartialPivLU A(m_A); - res = A.solve(b); - for (--pp; pp >= 1; --pp) - res = A.solve(res); - return; - } - else { - m_tmp1 = m_A.inverse(); - } - - while (b.cols()*(pp-applyings) > m_A.cols()*squarings) { - if (std::fmod(pp, 2) >= 1) { - apply(b, res, init); - --applyings; - } - m_tmp1 *= m_tmp1; - --squarings; - pp /= 2; - } - for (; pp >= 1; --pp) - apply(b, res, init); - } -} - -template -template -void MatrixPower::computeFracPower(ResultType& res, RealScalar p) -{ - if (p) { - eigen_assert(m_conditionNumber); - MatrixPowerTriangularAtomic(m_T).compute(m_fT, p); - internal::recompose_complex_schur::IsComplex>::run(m_tmp1, m_fT, m_U); - res = m_tmp1 * res; - } -} - -template -class MatrixPowerMatrixProduct : public MatrixPowerProductBase,Lhs,Rhs> -{ - public: - EIGEN_MATRIX_POWER_PRODUCT_PUBLIC_INTERFACE(MatrixPowerMatrixProduct) - - MatrixPowerMatrixProduct(MatrixPower& pow, const Rhs& b, RealScalar p) : - m_pow(pow), - m_b(b), - m_p(p) - { } - - template - inline void evalTo(ResultType& res) const - { m_pow.compute(m_b, res, m_p); } - - Index rows() const { return m_pow.rows(); } - Index cols() const { return m_b.cols(); } - - private: - MatrixPower& m_pow; - const Rhs& m_b; - const RealScalar m_p; - MatrixPowerMatrixProduct& operator=(const MatrixPowerMatrixProduct&); -}; - -/** - * \ingroup MatrixFunctions_Module - * - * \brief Proxy for the matrix power of some matrix (expression). - * - * \tparam Derived type of the base, a matrix (expression). - * - * This class holds the arguments to the matrix power until it is - * assigned or evaluated for some other reason (so the argument - * should not be changed in the meantime). It is the return type of - * MatrixBase::pow() and related functions and most of the - * time this is the only way it is used. - */ -template -class MatrixPowerReturnValue : public ReturnByValue > -{ - public: - typedef typename Derived::PlainObject PlainObject; - typedef typename Derived::RealScalar RealScalar; - typedef typename Derived::Index Index; - - /** - * \brief Constructor. - * - * \param[in] A %Matrix (expression), the base of the matrix power. - * \param[in] p scalar, the exponent of the matrix power. - */ - MatrixPowerReturnValue(const Derived& A, RealScalar p) : m_A(A), m_p(p) - { } - - /** - * \brief Compute the matrix power. - * - * \param[out] result \f$ A^p \f$ where \p A and \p p are as in the - * constructor. - */ - template - inline void evalTo(ResultType& res) const - { MatrixPower(m_A.eval()).compute(res, m_p); } - - /** - * \brief Return the expression \f$ A^p b \f$. - * - * \p A and \p p are specified in the constructor. - * - * \param[in] b the matrix (expression) to be applied. - */ - template - const MatrixPowerMatrixProduct operator*(const MatrixBase& b) const - { - MatrixPower Apow(m_A.eval()); - return MatrixPowerMatrixProduct(Apow, b.derived(), m_p); - } - - Index rows() const { return m_A.rows(); } - Index cols() const { return m_A.cols(); } - - private: - const Derived& m_A; - const RealScalar m_p; - MatrixPowerReturnValue& operator=(const MatrixPowerReturnValue&); -}; - -template -class MatrixPowerEvaluator : public ReturnByValue > -{ - public: - typedef typename MatrixType::RealScalar RealScalar; - typedef typename MatrixType::Index Index; - - MatrixPowerEvaluator(MatrixPower& pow, RealScalar p) : m_pow(pow), m_p(p) - { } - - template - inline void evalTo(ResultType& res) const - { m_pow.compute(res, m_p); } - - template - const MatrixPowerMatrixProduct operator*(const MatrixBase& b) const - { return MatrixPowerMatrixProduct(m_pow, b.derived(), m_p); } - - Index rows() const { return m_pow.rows(); } - Index cols() const { return m_pow.cols(); } - - private: - MatrixPower& m_pow; - const RealScalar m_p; - MatrixPowerEvaluator& operator=(const MatrixPowerEvaluator&); -}; - -namespace internal { -template -struct nested > -{ typedef typename MatrixPowerMatrixProduct::PlainObject const& type; }; - -template -struct traits > -{ typedef typename Derived::PlainObject ReturnType; }; - -template -struct traits > -{ typedef MatrixType ReturnType; }; - -template -struct traits > -: traits,Lhs,Rhs> > -{ }; -} // namespace internal - -template -const MatrixPowerReturnValue MatrixBase::pow(RealScalar p) const -{ return MatrixPowerReturnValue(derived(), p); } - -} // namespace Eigen - -#endif // EIGEN_MATRIX_POWER diff --git a/resources/3rdparty/eigen/unsupported/Eigen/src/MatrixFunctions/MatrixPowerBase.h b/resources/3rdparty/eigen/unsupported/Eigen/src/MatrixFunctions/MatrixPowerBase.h deleted file mode 100644 index 9616659ca..000000000 --- a/resources/3rdparty/eigen/unsupported/Eigen/src/MatrixFunctions/MatrixPowerBase.h +++ /dev/null @@ -1,359 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2012 Chen-Pang He -// -// 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_MATRIX_POWER_BASE -#define EIGEN_MATRIX_POWER_BASE - -namespace Eigen { - -namespace internal { -template -struct recompose_complex_schur -{ - template - static inline void run(ResultType& res, const MatrixType& T, const MatrixType& U) - { res.noalias() = U * (T.template triangularView() * U.adjoint()); } -}; - -template<> -struct recompose_complex_schur<0> -{ - template - static inline void run(ResultType& res, const MatrixType& T, const MatrixType& U) - { res.noalias() = (U * (T.template triangularView() * U.adjoint())).real(); } -}; - -template::IsComplex> -struct matrix_power_unwinder -{ - static inline Scalar run(const Scalar& eival, const Scalar& eival0, int unwindingNumber) - { return internal::atanh2(eival-eival0, eival+eival0) + Scalar(0, M_PI*unwindingNumber); } -}; - -template -struct matrix_power_unwinder -{ - static inline Scalar run(Scalar eival, Scalar eival0, int) - { return internal::atanh2(eival-eival0, eival+eival0); } -}; - -template -inline int binary_powering_cost(T p, int* squarings) -{ - int applyings=0, tmp; - - frexp(p, squarings); - --*squarings; - - while (std::frexp(p, &tmp), tmp > 0) { - p -= std::ldexp(static_cast(0.5), tmp); - ++applyings; - } - return applyings; -} - -inline int matrix_power_get_pade_degree(float normIminusT) -{ - const float maxNormForPade[] = { 2.8064004e-1f /* degree = 3 */ , 4.3386528e-1f }; - int degree = 3; - for (; degree <= 4; ++degree) - if (normIminusT <= maxNormForPade[degree - 3]) - break; - return degree; -} - -inline int matrix_power_get_pade_degree(double normIminusT) -{ - const double maxNormForPade[] = { 1.884160592658218e-2 /* degree = 3 */ , 6.038881904059573e-2, 1.239917516308172e-1, - 1.999045567181744e-1, 2.789358995219730e-1 }; - int degree = 3; - for (; degree <= 7; ++degree) - if (normIminusT <= maxNormForPade[degree - 3]) - break; - return degree; -} - -inline int matrix_power_get_pade_degree(long double normIminusT) -{ -#if LDBL_MANT_DIG == 53 - const int maxPadeDegree = 7; - const double maxNormForPade[] = { 1.884160592658218e-2L /* degree = 3 */ , 6.038881904059573e-2L, 1.239917516308172e-1L, - 1.999045567181744e-1L, 2.789358995219730e-1L }; -#elif LDBL_MANT_DIG <= 64 - const int maxPadeDegree = 8; - const double maxNormForPade[] = { 6.3854693117491799460e-3L /* degree = 3 */ , 2.6394893435456973676e-2L, - 6.4216043030404063729e-2L, 1.1701165502926694307e-1L, 1.7904284231268670284e-1L, 2.4471944416607995472e-1L }; -#elif LDBL_MANT_DIG <= 106 - const int maxPadeDegree = 10; - const double maxNormForPade[] = { 1.0007161601787493236741409687186e-4L /* degree = 3 */ , - 1.0007161601787493236741409687186e-3L, 4.7069769360887572939882574746264e-3L, 1.3220386624169159689406653101695e-2L, - 2.8063482381631737920612944054906e-2L, 4.9625993951953473052385361085058e-2L, 7.7367040706027886224557538328171e-2L, - 1.1016843812851143391275867258512e-1L }; -#else - const int maxPadeDegree = 10; - const double maxNormForPade[] = { 5.524506147036624377378713555116378e-5L /* degree = 3 */ , - 6.640600568157479679823602193345995e-4L, 3.227716520106894279249709728084626e-3L, - 9.619593944683432960546978734646284e-3L, 2.134595382433742403911124458161147e-2L, - 3.908166513900489428442993794761185e-2L, 6.266780814639442865832535460550138e-2L, - 9.134603732914548552537150753385375e-2L }; -#endif - int degree = 3; - for (; degree <= maxPadeDegree; ++degree) - if (normIminusT <= maxNormForPade[degree - 3]) - break; - return degree; -} -} // namespace internal - -template -class MatrixPowerTriangularAtomic -{ - private: - enum { - RowsAtCompileTime = MatrixType::RowsAtCompileTime, - MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime - }; - typedef typename MatrixType::Scalar Scalar; - typedef typename MatrixType::RealScalar RealScalar; - typedef Array ArrayType; - - const MatrixType& m_T; - const MatrixType m_Id; - - void computePade(int degree, const MatrixType& IminusT, MatrixType& res, RealScalar p) const; - void compute2x2(MatrixType& res, RealScalar p) const; - void computeBig(MatrixType& res, RealScalar p) const; - - public: - explicit MatrixPowerTriangularAtomic(const MatrixType& T); - void compute(MatrixType& res, RealScalar p) const; -}; - -template -MatrixPowerTriangularAtomic::MatrixPowerTriangularAtomic(const MatrixType& T) : - m_T(T), - m_Id(MatrixType::Identity(T.rows(), T.cols())) -{ eigen_assert(T.rows() == T.cols()); } - -template -void MatrixPowerTriangularAtomic::compute(MatrixType& res, RealScalar p) const -{ - switch (m_T.rows()) { - case 0: - break; - case 1: - res(0,0) = std::pow(m_T(0,0), p); - break; - case 2: - compute2x2(res, p); - break; - default: - computeBig(res, p); - } -} - -template -void MatrixPowerTriangularAtomic::computePade(int degree, const MatrixType& IminusT, MatrixType& res, - RealScalar p) const -{ - int i = degree<<1; - res = (p-degree) / ((i-1)<<1) * IminusT; - for (--i; i; --i) { - res = (m_Id + res).template triangularView().solve((i==1 ? -p : i&1 ? (-p-(i>>1))/(i<<1) : - (p-(i>>1))/((i-1)<<1)) * IminusT).eval(); - } - res += m_Id; -} - -template -void MatrixPowerTriangularAtomic::compute2x2(MatrixType& res, RealScalar p) const -{ - using std::abs; - using std::pow; - - ArrayType logTdiag = m_T.diagonal().array().log(); - res.coeffRef(0,0) = pow(m_T.coeff(0,0), p); - - for (int i=1; i < m_T.cols(); ++i) { - res.coeffRef(i,i) = pow(m_T.coeff(i,i), p); - if (m_T.coeff(i-1,i-1) == m_T.coeff(i,i)) { - res.coeffRef(i-1,i) = p * pow(m_T.coeff(i-1,i), p-1); - } - else if (2*abs(m_T.coeff(i-1,i-1)) < abs(m_T.coeff(i,i)) || 2*abs(m_T.coeff(i,i)) < abs(m_T.coeff(i-1,i-1))) { - res.coeffRef(i-1,i) = m_T.coeff(i-1,i) * (res.coeff(i,i)-res.coeff(i-1,i-1)) / (m_T.coeff(i,i)-m_T.coeff(i-1,i-1)); - } - else { - int unwindingNumber = std::ceil((internal::imag(logTdiag[i]-logTdiag[i-1]) - M_PI) / (2*M_PI)); - Scalar w = internal::matrix_power_unwinder::run(m_T.coeff(i,i), m_T.coeff(i-1,i-1), unwindingNumber); - res.coeffRef(i-1,i) = m_T.coeff(i-1,i) * RealScalar(2) * std::exp(RealScalar(0.5)*p*(logTdiag[i]+logTdiag[i-1])) * - std::sinh(p * w) / (m_T.coeff(i,i) - m_T.coeff(i-1,i-1)); - } - } -} - -template -void MatrixPowerTriangularAtomic::computeBig(MatrixType& res, RealScalar p) const -{ - const int digits = std::numeric_limits::digits; - const RealScalar maxNormForPade = digits <= 24? 4.3386528e-1f: // sigle precision - digits <= 53? 2.789358995219730e-1: // double precision - digits <= 64? 2.4471944416607995472e-1L: // extended precision - digits <= 106? 1.1016843812851143391275867258512e-1L: // double-double - 9.134603732914548552537150753385375e-2L; // quadruple precision - MatrixType IminusT, sqrtT, T=m_T; - RealScalar normIminusT; - int degree, degree2, numberOfSquareRoots=0; - bool hasExtraSquareRoot=false; - - while (true) { - IminusT = MatrixType::Identity(m_T.rows(), m_T.cols()) - T; - normIminusT = IminusT.cwiseAbs().colwise().sum().maxCoeff(); - if (normIminusT < maxNormForPade) { - degree = internal::matrix_power_get_pade_degree(normIminusT); - degree2 = internal::matrix_power_get_pade_degree(normIminusT/2); - if (degree - degree2 <= 1 || hasExtraSquareRoot) - break; - hasExtraSquareRoot = true; - } - MatrixSquareRootTriangular(T).compute(sqrtT); - T = sqrtT; - ++numberOfSquareRoots; - } - computePade(degree, IminusT, res, p); - - for (; numberOfSquareRoots; --numberOfSquareRoots) { - compute2x2(res, std::ldexp(p,-numberOfSquareRoots)); - res *= res; - } - compute2x2(res, p); -} - -#define EIGEN_MATRIX_POWER_PUBLIC_INTERFACE(Derived) \ - typedef MatrixPowerBase Base; \ - using Base::RowsAtCompileTime; \ - using Base::ColsAtCompileTime; \ - using Base::Options; \ - using Base::MaxRowsAtCompileTime; \ - using Base::MaxColsAtCompileTime; \ - typedef typename Base::Scalar Scalar; \ - typedef typename Base::RealScalar RealScalar; \ - typedef typename Base::RealArray RealArray; - -#define EIGEN_MATRIX_POWER_PROTECTED_MEMBERS(Derived) \ - using Base::m_A; \ - using Base::m_Id; \ - using Base::m_tmp1; \ - using Base::m_tmp2; \ - using Base::m_conditionNumber; - -#define EIGEN_MATRIX_POWER_PRODUCT_PUBLIC_INTERFACE(Derived) \ - typedef MatrixPowerProductBase Base; \ - EIGEN_DENSE_PUBLIC_INTERFACE(Derived) - -namespace internal { -template -struct traits > -{ - typedef MatrixXpr XprKind; - typedef typename remove_all<_Lhs>::type Lhs; - typedef typename remove_all<_Rhs>::type Rhs; - typedef typename remove_all::type PlainObject; - typedef typename scalar_product_traits::ReturnType Scalar; - typedef typename promote_storage_type::StorageKind, - typename traits::StorageKind>::ret StorageKind; - typedef typename promote_index_type::Index, - typename traits::Index>::type Index; - - enum { - RowsAtCompileTime = traits::RowsAtCompileTime, - ColsAtCompileTime = traits::ColsAtCompileTime, - MaxRowsAtCompileTime = traits::MaxRowsAtCompileTime, - MaxColsAtCompileTime = traits::MaxColsAtCompileTime, - Flags = (MaxRowsAtCompileTime==1 ? RowMajorBit : 0) - | EvalBeforeNestingBit | EvalBeforeAssigningBit | NestByRefBit, - CoeffReadCost = 0 - }; -}; -} // namespace internal - -template -class MatrixPowerBase -{ - public: - enum { - RowsAtCompileTime = MatrixType::RowsAtCompileTime, - ColsAtCompileTime = MatrixType::ColsAtCompileTime, - Options = MatrixType::Options, - MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime, - MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime - }; - typedef typename MatrixType::Scalar Scalar; - typedef typename MatrixType::RealScalar RealScalar; - typedef typename MatrixType::Index Index; - - explicit MatrixPowerBase(const MatrixType& A, RealScalar cond); - - void compute(MatrixType& res, RealScalar p); - - template - void compute(const OtherDerived& b, ResultType& res, RealScalar p); - - Index rows() const { return m_A.rows(); } - Index cols() const { return m_A.cols(); } - - protected: - typedef Array RealArray; - - const MatrixType& m_A; - const MatrixType m_Id; - MatrixType m_tmp1, m_tmp2; - RealScalar m_conditionNumber; -}; - -template -MatrixPowerBase::MatrixPowerBase(const MatrixType& A, RealScalar cond) : - m_A(A), - m_Id(MatrixType::Identity(A.rows(),A.cols())), - m_conditionNumber(cond) -{ eigen_assert(A.rows() == A.cols()); } - -template -void MatrixPowerBase::compute(MatrixType& res, RealScalar p) -{ static_cast(this)->compute(res,p); } - -template -template -void MatrixPowerBase::compute(const OtherDerived& b, ResultType& res, RealScalar p) -{ static_cast(this)->compute(b,res,p); } - -template -class MatrixPowerProductBase : public MatrixBase -{ - public: - typedef MatrixBase Base; - EIGEN_DENSE_PUBLIC_INTERFACE(MatrixPowerProductBase) - - inline Index rows() const { return derived().rows(); } - inline Index cols() const { return derived().cols(); } - - template - inline void evalTo(ResultType& res) const { derived().evalTo(res); } -}; - -template -template -Derived& MatrixBase::lazyAssign(const MatrixPowerProductBase& other) -{ - other.derived().evalTo(derived()); - return derived(); -} - -} // namespace Eigen - -#endif // EIGEN_MATRIX_POWER diff --git a/resources/3rdparty/eigen/unsupported/doc/examples/MatrixPower.cpp b/resources/3rdparty/eigen/unsupported/doc/examples/MatrixPower.cpp deleted file mode 100644 index 222452476..000000000 --- a/resources/3rdparty/eigen/unsupported/doc/examples/MatrixPower.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include -#include - -using namespace Eigen; - -int main() -{ - const double pi = std::acos(-1.0); - Matrix3d A; - A << cos(1), -sin(1), 0, - sin(1), cos(1), 0, - 0 , 0 , 1; - std::cout << "The matrix A is:\n" << A << "\n\n" - "The matrix power A^(pi/4) is:\n" << A.pow(pi/4) << std::endl; - return 0; -} diff --git a/resources/3rdparty/eigen/unsupported/doc/examples/MatrixPower_optimal.cpp b/resources/3rdparty/eigen/unsupported/doc/examples/MatrixPower_optimal.cpp deleted file mode 100644 index 86470ba0a..000000000 --- a/resources/3rdparty/eigen/unsupported/doc/examples/MatrixPower_optimal.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include - -using namespace Eigen; - -int main() -{ - Matrix4cd A = Matrix4cd::Random(); - MatrixPower Apow(A); - - std::cout << "The matrix A is:\n" << A << "\n\n" - "A^3.1 is:\n" << Apow(3.1) << "\n\n" - "A^3.3 is:\n" << Apow(3.3) << "\n\n" - "A^3.7 is:\n" << Apow(3.7) << "\n\n" - "A^3.9 is:\n" << Apow(3.9) << std::endl; - return 0; -} diff --git a/resources/3rdparty/eigen/unsupported/test/matrix_functions.h b/resources/3rdparty/eigen/unsupported/test/matrix_functions.h deleted file mode 100644 index 5817caef6..000000000 --- a/resources/3rdparty/eigen/unsupported/test/matrix_functions.h +++ /dev/null @@ -1,47 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2009-2011 Jitse Niesen -// -// 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 - -template ::Scalar>::IsComplex> -struct generateTestMatrix; - -// for real matrices, make sure none of the eigenvalues are negative -template -struct generateTestMatrix -{ - static void run(MatrixType& result, typename MatrixType::Index size) - { - MatrixType mat = MatrixType::Random(size, size); - EigenSolver es(mat); - typename EigenSolver::EigenvalueType eivals = es.eigenvalues(); - for (typename MatrixType::Index i = 0; i < size; ++i) { - if (eivals(i).imag() == 0 && eivals(i).real() < 0) - eivals(i) = -eivals(i); - } - result = (es.eigenvectors() * eivals.asDiagonal() * es.eigenvectors().inverse()).real(); - } -}; - -// for complex matrices, any matrix is fine -template -struct generateTestMatrix -{ - static void run(MatrixType& result, typename MatrixType::Index size) - { - result = MatrixType::Random(size, size); - } -}; - -template -double relerr(const MatrixBase& A, const MatrixBase& B) -{ - return std::sqrt((A - B).cwiseAbs2().sum() / (std::min)(A.cwiseAbs2().sum(), B.cwiseAbs2().sum())); -} diff --git a/resources/3rdparty/eigen/unsupported/test/matrix_power.cpp b/resources/3rdparty/eigen/unsupported/test/matrix_power.cpp deleted file mode 100644 index 95c63c574..000000000 --- a/resources/3rdparty/eigen/unsupported/test/matrix_power.cpp +++ /dev/null @@ -1,136 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. -// -// Copyright (C) 2012 Chen-Pang He -// -// 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 "matrix_functions.h" - -template -void test2dRotation(double tol) -{ - Matrix A, B, C; - T angle, c, s; - - A << 0, 1, -1, 0; - MatrixPower > Apow(A); - - for (int i=0; i<=20; ++i) { - angle = pow(10, (i-10) / 5.); - c = std::cos(angle); - s = std::sin(angle); - B << c, s, -s, c; - - C = Apow(std::ldexp(angle,1) / M_PI); - std::cout << "test2dRotation: i = " << i << " error powerm = " << relerr(C,B) << '\n'; - VERIFY(C.isApprox(B, static_cast(tol))); - } -} - -template -void test2dHyperbolicRotation(double tol) -{ - Matrix,2,2> A, B, C; - T angle, ch = std::cosh((T)1); - std::complex ish(0, std::sinh((T)1)); - - A << ch, ish, -ish, ch; - MatrixPower,2,2> > Apow(A); - - for (int i=0; i<=20; ++i) { - angle = std::ldexp(static_cast(i-10), -1); - ch = std::cosh(angle); - ish = std::complex(0, std::sinh(angle)); - B << ch, ish, -ish, ch; - - C = Apow(angle); - std::cout << "test2dHyperbolicRotation: i = " << i << " error powerm = " << relerr(C,B) << '\n'; - VERIFY(C.isApprox(B, static_cast(tol))); - } -} - -template -void testExponentLaws(const MatrixType& m, double tol) -{ - typedef typename MatrixType::RealScalar RealScalar; - MatrixType m1, m2, m3, m4, m5; - RealScalar x, y; - - for (int i=0; i::run(m1, m.rows()); - MatrixPower mpow(m1); - - x = internal::random(); - y = internal::random(); - m2 = mpow(x); - m3 = mpow(y); - - m4 = mpow(x+y); - m5.noalias() = m2 * m3; - VERIFY(m4.isApprox(m5, static_cast(tol))); - - m4 = mpow(x*y); - m5 = m2.pow(y); - VERIFY(m4.isApprox(m5, static_cast(tol))); - - m4 = (std::abs(x) * m1).pow(y); - m5 = std::pow(std::abs(x), y) * m3; - VERIFY(m4.isApprox(m5, static_cast(tol))); - } -} - -template -void testProduct(const MatrixType& m, const VectorType& v, double tol) -{ - typedef typename MatrixType::RealScalar RealScalar; - MatrixType m1; - VectorType v1, v2, v3; - RealScalar p; - - for (int i=0; i::run(m1, m.rows()); - MatrixPower mpow(m1); - - v1 = VectorType::Random(v.rows(), v.cols()); - p = internal::random(); - - v2.noalias() = mpow(p) * v1; - v3.noalias() = mpow(p).eval() * v1; - std::cout << "testMatrixVectorProduct: error powerm = " << relerr(v2, v3) << '\n'; - VERIFY(v2.isApprox(v3, static_cast(tol))); - } -} - -template -void testMatrixVector(const MatrixType& m, const VectorType& v, double tol) -{ - testExponentLaws(m,tol); - testProduct(m,v,tol); -} - -void test_matrix_power() -{ - typedef Matrix Matrix3dRowMajor; - typedef Matrix MatrixXe; - typedef Matrix VectorXe; - - CALL_SUBTEST_2(test2dRotation(1e-13)); - CALL_SUBTEST_1(test2dRotation(2e-5)); // was 1e-5, relaxed for clang 2.8 / linux / x86-64 - CALL_SUBTEST_9(test2dRotation(1e-13)); - CALL_SUBTEST_2(test2dHyperbolicRotation(1e-14)); - CALL_SUBTEST_1(test2dHyperbolicRotation(1e-5)); - CALL_SUBTEST_9(test2dHyperbolicRotation(1e-14)); - - CALL_SUBTEST_2(testMatrixVector(Matrix2d(), Vector2d(), 1e-13)); - CALL_SUBTEST_7(testMatrixVector(Matrix3dRowMajor(), MatrixXd(3,5), 1e-13)); - CALL_SUBTEST_3(testMatrixVector(Matrix4cd(), Vector4cd(), 1e-13)); - CALL_SUBTEST_4(testMatrixVector(MatrixXd(8,8), VectorXd(8), 1e-13)); - CALL_SUBTEST_1(testMatrixVector(Matrix2f(), Vector2f(), 1e-4)); - CALL_SUBTEST_5(testMatrixVector(Matrix3cf(), Vector3cf(), 1e-4)); - CALL_SUBTEST_8(testMatrixVector(Matrix4f(), Vector4f(), 1e-4)); - CALL_SUBTEST_6(testMatrixVector(MatrixXf(8,8), VectorXf(8), 1e-4)); - CALL_SUBTEST_9(testMatrixVector(MatrixXe(7,7), VectorXe(7), 1e-13)); -}