tomoto 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +123 -0
- data/ext/tomoto/ext.cpp +245 -0
- data/ext/tomoto/extconf.rb +28 -0
- data/lib/tomoto.rb +12 -0
- data/lib/tomoto/ct.rb +11 -0
- data/lib/tomoto/hdp.rb +11 -0
- data/lib/tomoto/lda.rb +67 -0
- data/lib/tomoto/version.rb +3 -0
- data/vendor/EigenRand/EigenRand/Core.h +1139 -0
- data/vendor/EigenRand/EigenRand/Dists/Basic.h +111 -0
- data/vendor/EigenRand/EigenRand/Dists/Discrete.h +877 -0
- data/vendor/EigenRand/EigenRand/Dists/GammaPoisson.h +108 -0
- data/vendor/EigenRand/EigenRand/Dists/NormalExp.h +626 -0
- data/vendor/EigenRand/EigenRand/EigenRand +19 -0
- data/vendor/EigenRand/EigenRand/Macro.h +24 -0
- data/vendor/EigenRand/EigenRand/MorePacketMath.h +978 -0
- data/vendor/EigenRand/EigenRand/PacketFilter.h +286 -0
- data/vendor/EigenRand/EigenRand/PacketRandomEngine.h +624 -0
- data/vendor/EigenRand/EigenRand/RandUtils.h +413 -0
- data/vendor/EigenRand/EigenRand/doc.h +220 -0
- data/vendor/EigenRand/LICENSE +21 -0
- data/vendor/EigenRand/README.md +288 -0
- data/vendor/eigen/COPYING.BSD +26 -0
- data/vendor/eigen/COPYING.GPL +674 -0
- data/vendor/eigen/COPYING.LGPL +502 -0
- data/vendor/eigen/COPYING.MINPACK +52 -0
- data/vendor/eigen/COPYING.MPL2 +373 -0
- data/vendor/eigen/COPYING.README +18 -0
- data/vendor/eigen/Eigen/CMakeLists.txt +19 -0
- data/vendor/eigen/Eigen/Cholesky +46 -0
- data/vendor/eigen/Eigen/CholmodSupport +48 -0
- data/vendor/eigen/Eigen/Core +537 -0
- data/vendor/eigen/Eigen/Dense +7 -0
- data/vendor/eigen/Eigen/Eigen +2 -0
- data/vendor/eigen/Eigen/Eigenvalues +61 -0
- data/vendor/eigen/Eigen/Geometry +62 -0
- data/vendor/eigen/Eigen/Householder +30 -0
- data/vendor/eigen/Eigen/IterativeLinearSolvers +48 -0
- data/vendor/eigen/Eigen/Jacobi +33 -0
- data/vendor/eigen/Eigen/LU +50 -0
- data/vendor/eigen/Eigen/MetisSupport +35 -0
- data/vendor/eigen/Eigen/OrderingMethods +73 -0
- data/vendor/eigen/Eigen/PaStiXSupport +48 -0
- data/vendor/eigen/Eigen/PardisoSupport +35 -0
- data/vendor/eigen/Eigen/QR +51 -0
- data/vendor/eigen/Eigen/QtAlignedMalloc +40 -0
- data/vendor/eigen/Eigen/SPQRSupport +34 -0
- data/vendor/eigen/Eigen/SVD +51 -0
- data/vendor/eigen/Eigen/Sparse +36 -0
- data/vendor/eigen/Eigen/SparseCholesky +45 -0
- data/vendor/eigen/Eigen/SparseCore +69 -0
- data/vendor/eigen/Eigen/SparseLU +46 -0
- data/vendor/eigen/Eigen/SparseQR +37 -0
- data/vendor/eigen/Eigen/StdDeque +27 -0
- data/vendor/eigen/Eigen/StdList +26 -0
- data/vendor/eigen/Eigen/StdVector +27 -0
- data/vendor/eigen/Eigen/SuperLUSupport +64 -0
- data/vendor/eigen/Eigen/UmfPackSupport +40 -0
- data/vendor/eigen/Eigen/src/Cholesky/LDLT.h +673 -0
- data/vendor/eigen/Eigen/src/Cholesky/LLT.h +542 -0
- data/vendor/eigen/Eigen/src/Cholesky/LLT_LAPACKE.h +99 -0
- data/vendor/eigen/Eigen/src/CholmodSupport/CholmodSupport.h +639 -0
- data/vendor/eigen/Eigen/src/Core/Array.h +329 -0
- data/vendor/eigen/Eigen/src/Core/ArrayBase.h +226 -0
- data/vendor/eigen/Eigen/src/Core/ArrayWrapper.h +209 -0
- data/vendor/eigen/Eigen/src/Core/Assign.h +90 -0
- data/vendor/eigen/Eigen/src/Core/AssignEvaluator.h +935 -0
- data/vendor/eigen/Eigen/src/Core/Assign_MKL.h +178 -0
- data/vendor/eigen/Eigen/src/Core/BandMatrix.h +353 -0
- data/vendor/eigen/Eigen/src/Core/Block.h +452 -0
- data/vendor/eigen/Eigen/src/Core/BooleanRedux.h +164 -0
- data/vendor/eigen/Eigen/src/Core/CommaInitializer.h +160 -0
- data/vendor/eigen/Eigen/src/Core/ConditionEstimator.h +175 -0
- data/vendor/eigen/Eigen/src/Core/CoreEvaluators.h +1688 -0
- data/vendor/eigen/Eigen/src/Core/CoreIterators.h +127 -0
- data/vendor/eigen/Eigen/src/Core/CwiseBinaryOp.h +184 -0
- data/vendor/eigen/Eigen/src/Core/CwiseNullaryOp.h +866 -0
- data/vendor/eigen/Eigen/src/Core/CwiseTernaryOp.h +197 -0
- data/vendor/eigen/Eigen/src/Core/CwiseUnaryOp.h +103 -0
- data/vendor/eigen/Eigen/src/Core/CwiseUnaryView.h +128 -0
- data/vendor/eigen/Eigen/src/Core/DenseBase.h +611 -0
- data/vendor/eigen/Eigen/src/Core/DenseCoeffsBase.h +681 -0
- data/vendor/eigen/Eigen/src/Core/DenseStorage.h +570 -0
- data/vendor/eigen/Eigen/src/Core/Diagonal.h +260 -0
- data/vendor/eigen/Eigen/src/Core/DiagonalMatrix.h +343 -0
- data/vendor/eigen/Eigen/src/Core/DiagonalProduct.h +28 -0
- data/vendor/eigen/Eigen/src/Core/Dot.h +318 -0
- data/vendor/eigen/Eigen/src/Core/EigenBase.h +159 -0
- data/vendor/eigen/Eigen/src/Core/ForceAlignedAccess.h +146 -0
- data/vendor/eigen/Eigen/src/Core/Fuzzy.h +155 -0
- data/vendor/eigen/Eigen/src/Core/GeneralProduct.h +455 -0
- data/vendor/eigen/Eigen/src/Core/GenericPacketMath.h +593 -0
- data/vendor/eigen/Eigen/src/Core/GlobalFunctions.h +187 -0
- data/vendor/eigen/Eigen/src/Core/IO.h +225 -0
- data/vendor/eigen/Eigen/src/Core/Inverse.h +118 -0
- data/vendor/eigen/Eigen/src/Core/Map.h +171 -0
- data/vendor/eigen/Eigen/src/Core/MapBase.h +303 -0
- data/vendor/eigen/Eigen/src/Core/MathFunctions.h +1415 -0
- data/vendor/eigen/Eigen/src/Core/MathFunctionsImpl.h +101 -0
- data/vendor/eigen/Eigen/src/Core/Matrix.h +459 -0
- data/vendor/eigen/Eigen/src/Core/MatrixBase.h +529 -0
- data/vendor/eigen/Eigen/src/Core/NestByValue.h +110 -0
- data/vendor/eigen/Eigen/src/Core/NoAlias.h +108 -0
- data/vendor/eigen/Eigen/src/Core/NumTraits.h +248 -0
- data/vendor/eigen/Eigen/src/Core/PermutationMatrix.h +633 -0
- data/vendor/eigen/Eigen/src/Core/PlainObjectBase.h +1035 -0
- data/vendor/eigen/Eigen/src/Core/Product.h +186 -0
- data/vendor/eigen/Eigen/src/Core/ProductEvaluators.h +1112 -0
- data/vendor/eigen/Eigen/src/Core/Random.h +182 -0
- data/vendor/eigen/Eigen/src/Core/Redux.h +505 -0
- data/vendor/eigen/Eigen/src/Core/Ref.h +283 -0
- data/vendor/eigen/Eigen/src/Core/Replicate.h +142 -0
- data/vendor/eigen/Eigen/src/Core/ReturnByValue.h +117 -0
- data/vendor/eigen/Eigen/src/Core/Reverse.h +211 -0
- data/vendor/eigen/Eigen/src/Core/Select.h +162 -0
- data/vendor/eigen/Eigen/src/Core/SelfAdjointView.h +352 -0
- data/vendor/eigen/Eigen/src/Core/SelfCwiseBinaryOp.h +47 -0
- data/vendor/eigen/Eigen/src/Core/Solve.h +188 -0
- data/vendor/eigen/Eigen/src/Core/SolveTriangular.h +235 -0
- data/vendor/eigen/Eigen/src/Core/SolverBase.h +130 -0
- data/vendor/eigen/Eigen/src/Core/StableNorm.h +221 -0
- data/vendor/eigen/Eigen/src/Core/Stride.h +111 -0
- data/vendor/eigen/Eigen/src/Core/Swap.h +67 -0
- data/vendor/eigen/Eigen/src/Core/Transpose.h +403 -0
- data/vendor/eigen/Eigen/src/Core/Transpositions.h +407 -0
- data/vendor/eigen/Eigen/src/Core/TriangularMatrix.h +983 -0
- data/vendor/eigen/Eigen/src/Core/VectorBlock.h +96 -0
- data/vendor/eigen/Eigen/src/Core/VectorwiseOp.h +695 -0
- data/vendor/eigen/Eigen/src/Core/Visitor.h +273 -0
- data/vendor/eigen/Eigen/src/Core/arch/AVX/Complex.h +451 -0
- data/vendor/eigen/Eigen/src/Core/arch/AVX/MathFunctions.h +439 -0
- data/vendor/eigen/Eigen/src/Core/arch/AVX/PacketMath.h +637 -0
- data/vendor/eigen/Eigen/src/Core/arch/AVX/TypeCasting.h +51 -0
- data/vendor/eigen/Eigen/src/Core/arch/AVX512/MathFunctions.h +391 -0
- data/vendor/eigen/Eigen/src/Core/arch/AVX512/PacketMath.h +1316 -0
- data/vendor/eigen/Eigen/src/Core/arch/AltiVec/Complex.h +430 -0
- data/vendor/eigen/Eigen/src/Core/arch/AltiVec/MathFunctions.h +322 -0
- data/vendor/eigen/Eigen/src/Core/arch/AltiVec/PacketMath.h +1061 -0
- data/vendor/eigen/Eigen/src/Core/arch/CUDA/Complex.h +103 -0
- data/vendor/eigen/Eigen/src/Core/arch/CUDA/Half.h +674 -0
- data/vendor/eigen/Eigen/src/Core/arch/CUDA/MathFunctions.h +91 -0
- data/vendor/eigen/Eigen/src/Core/arch/CUDA/PacketMath.h +333 -0
- data/vendor/eigen/Eigen/src/Core/arch/CUDA/PacketMathHalf.h +1124 -0
- data/vendor/eigen/Eigen/src/Core/arch/CUDA/TypeCasting.h +212 -0
- data/vendor/eigen/Eigen/src/Core/arch/Default/ConjHelper.h +29 -0
- data/vendor/eigen/Eigen/src/Core/arch/Default/Settings.h +49 -0
- data/vendor/eigen/Eigen/src/Core/arch/NEON/Complex.h +490 -0
- data/vendor/eigen/Eigen/src/Core/arch/NEON/MathFunctions.h +91 -0
- data/vendor/eigen/Eigen/src/Core/arch/NEON/PacketMath.h +760 -0
- data/vendor/eigen/Eigen/src/Core/arch/SSE/Complex.h +471 -0
- data/vendor/eigen/Eigen/src/Core/arch/SSE/MathFunctions.h +562 -0
- data/vendor/eigen/Eigen/src/Core/arch/SSE/PacketMath.h +895 -0
- data/vendor/eigen/Eigen/src/Core/arch/SSE/TypeCasting.h +77 -0
- data/vendor/eigen/Eigen/src/Core/arch/ZVector/Complex.h +397 -0
- data/vendor/eigen/Eigen/src/Core/arch/ZVector/MathFunctions.h +137 -0
- data/vendor/eigen/Eigen/src/Core/arch/ZVector/PacketMath.h +945 -0
- data/vendor/eigen/Eigen/src/Core/functors/AssignmentFunctors.h +168 -0
- data/vendor/eigen/Eigen/src/Core/functors/BinaryFunctors.h +475 -0
- data/vendor/eigen/Eigen/src/Core/functors/NullaryFunctors.h +188 -0
- data/vendor/eigen/Eigen/src/Core/functors/StlFunctors.h +136 -0
- data/vendor/eigen/Eigen/src/Core/functors/TernaryFunctors.h +25 -0
- data/vendor/eigen/Eigen/src/Core/functors/UnaryFunctors.h +792 -0
- data/vendor/eigen/Eigen/src/Core/products/GeneralBlockPanelKernel.h +2156 -0
- data/vendor/eigen/Eigen/src/Core/products/GeneralMatrixMatrix.h +492 -0
- data/vendor/eigen/Eigen/src/Core/products/GeneralMatrixMatrixTriangular.h +311 -0
- data/vendor/eigen/Eigen/src/Core/products/GeneralMatrixMatrixTriangular_BLAS.h +145 -0
- data/vendor/eigen/Eigen/src/Core/products/GeneralMatrixMatrix_BLAS.h +122 -0
- data/vendor/eigen/Eigen/src/Core/products/GeneralMatrixVector.h +619 -0
- data/vendor/eigen/Eigen/src/Core/products/GeneralMatrixVector_BLAS.h +136 -0
- data/vendor/eigen/Eigen/src/Core/products/Parallelizer.h +163 -0
- data/vendor/eigen/Eigen/src/Core/products/SelfadjointMatrixMatrix.h +521 -0
- data/vendor/eigen/Eigen/src/Core/products/SelfadjointMatrixMatrix_BLAS.h +287 -0
- data/vendor/eigen/Eigen/src/Core/products/SelfadjointMatrixVector.h +260 -0
- data/vendor/eigen/Eigen/src/Core/products/SelfadjointMatrixVector_BLAS.h +118 -0
- data/vendor/eigen/Eigen/src/Core/products/SelfadjointProduct.h +133 -0
- data/vendor/eigen/Eigen/src/Core/products/SelfadjointRank2Update.h +93 -0
- data/vendor/eigen/Eigen/src/Core/products/TriangularMatrixMatrix.h +466 -0
- data/vendor/eigen/Eigen/src/Core/products/TriangularMatrixMatrix_BLAS.h +315 -0
- data/vendor/eigen/Eigen/src/Core/products/TriangularMatrixVector.h +350 -0
- data/vendor/eigen/Eigen/src/Core/products/TriangularMatrixVector_BLAS.h +255 -0
- data/vendor/eigen/Eigen/src/Core/products/TriangularSolverMatrix.h +335 -0
- data/vendor/eigen/Eigen/src/Core/products/TriangularSolverMatrix_BLAS.h +163 -0
- data/vendor/eigen/Eigen/src/Core/products/TriangularSolverVector.h +145 -0
- data/vendor/eigen/Eigen/src/Core/util/BlasUtil.h +398 -0
- data/vendor/eigen/Eigen/src/Core/util/Constants.h +547 -0
- data/vendor/eigen/Eigen/src/Core/util/DisableStupidWarnings.h +83 -0
- data/vendor/eigen/Eigen/src/Core/util/ForwardDeclarations.h +302 -0
- data/vendor/eigen/Eigen/src/Core/util/MKL_support.h +130 -0
- data/vendor/eigen/Eigen/src/Core/util/Macros.h +1001 -0
- data/vendor/eigen/Eigen/src/Core/util/Memory.h +993 -0
- data/vendor/eigen/Eigen/src/Core/util/Meta.h +534 -0
- data/vendor/eigen/Eigen/src/Core/util/NonMPL2.h +3 -0
- data/vendor/eigen/Eigen/src/Core/util/ReenableStupidWarnings.h +27 -0
- data/vendor/eigen/Eigen/src/Core/util/StaticAssert.h +218 -0
- data/vendor/eigen/Eigen/src/Core/util/XprHelper.h +821 -0
- data/vendor/eigen/Eigen/src/Eigenvalues/ComplexEigenSolver.h +346 -0
- data/vendor/eigen/Eigen/src/Eigenvalues/ComplexSchur.h +459 -0
- data/vendor/eigen/Eigen/src/Eigenvalues/ComplexSchur_LAPACKE.h +91 -0
- data/vendor/eigen/Eigen/src/Eigenvalues/EigenSolver.h +622 -0
- data/vendor/eigen/Eigen/src/Eigenvalues/GeneralizedEigenSolver.h +418 -0
- data/vendor/eigen/Eigen/src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h +226 -0
- data/vendor/eigen/Eigen/src/Eigenvalues/HessenbergDecomposition.h +374 -0
- data/vendor/eigen/Eigen/src/Eigenvalues/MatrixBaseEigenvalues.h +158 -0
- data/vendor/eigen/Eigen/src/Eigenvalues/RealQZ.h +654 -0
- data/vendor/eigen/Eigen/src/Eigenvalues/RealSchur.h +546 -0
- data/vendor/eigen/Eigen/src/Eigenvalues/RealSchur_LAPACKE.h +77 -0
- data/vendor/eigen/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h +870 -0
- data/vendor/eigen/Eigen/src/Eigenvalues/SelfAdjointEigenSolver_LAPACKE.h +87 -0
- data/vendor/eigen/Eigen/src/Eigenvalues/Tridiagonalization.h +556 -0
- data/vendor/eigen/Eigen/src/Geometry/AlignedBox.h +392 -0
- data/vendor/eigen/Eigen/src/Geometry/AngleAxis.h +247 -0
- data/vendor/eigen/Eigen/src/Geometry/EulerAngles.h +114 -0
- data/vendor/eigen/Eigen/src/Geometry/Homogeneous.h +497 -0
- data/vendor/eigen/Eigen/src/Geometry/Hyperplane.h +282 -0
- data/vendor/eigen/Eigen/src/Geometry/OrthoMethods.h +234 -0
- data/vendor/eigen/Eigen/src/Geometry/ParametrizedLine.h +195 -0
- data/vendor/eigen/Eigen/src/Geometry/Quaternion.h +814 -0
- data/vendor/eigen/Eigen/src/Geometry/Rotation2D.h +199 -0
- data/vendor/eigen/Eigen/src/Geometry/RotationBase.h +206 -0
- data/vendor/eigen/Eigen/src/Geometry/Scaling.h +170 -0
- data/vendor/eigen/Eigen/src/Geometry/Transform.h +1542 -0
- data/vendor/eigen/Eigen/src/Geometry/Translation.h +208 -0
- data/vendor/eigen/Eigen/src/Geometry/Umeyama.h +166 -0
- data/vendor/eigen/Eigen/src/Geometry/arch/Geometry_SSE.h +161 -0
- data/vendor/eigen/Eigen/src/Householder/BlockHouseholder.h +103 -0
- data/vendor/eigen/Eigen/src/Householder/Householder.h +172 -0
- data/vendor/eigen/Eigen/src/Householder/HouseholderSequence.h +470 -0
- data/vendor/eigen/Eigen/src/IterativeLinearSolvers/BasicPreconditioners.h +226 -0
- data/vendor/eigen/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h +228 -0
- data/vendor/eigen/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h +246 -0
- data/vendor/eigen/Eigen/src/IterativeLinearSolvers/IncompleteCholesky.h +400 -0
- data/vendor/eigen/Eigen/src/IterativeLinearSolvers/IncompleteLUT.h +462 -0
- data/vendor/eigen/Eigen/src/IterativeLinearSolvers/IterativeSolverBase.h +394 -0
- data/vendor/eigen/Eigen/src/IterativeLinearSolvers/LeastSquareConjugateGradient.h +216 -0
- data/vendor/eigen/Eigen/src/IterativeLinearSolvers/SolveWithGuess.h +115 -0
- data/vendor/eigen/Eigen/src/Jacobi/Jacobi.h +462 -0
- data/vendor/eigen/Eigen/src/LU/Determinant.h +101 -0
- data/vendor/eigen/Eigen/src/LU/FullPivLU.h +891 -0
- data/vendor/eigen/Eigen/src/LU/InverseImpl.h +415 -0
- data/vendor/eigen/Eigen/src/LU/PartialPivLU.h +611 -0
- data/vendor/eigen/Eigen/src/LU/PartialPivLU_LAPACKE.h +83 -0
- data/vendor/eigen/Eigen/src/LU/arch/Inverse_SSE.h +338 -0
- data/vendor/eigen/Eigen/src/MetisSupport/MetisSupport.h +137 -0
- data/vendor/eigen/Eigen/src/OrderingMethods/Amd.h +445 -0
- data/vendor/eigen/Eigen/src/OrderingMethods/Eigen_Colamd.h +1843 -0
- data/vendor/eigen/Eigen/src/OrderingMethods/Ordering.h +157 -0
- data/vendor/eigen/Eigen/src/PaStiXSupport/PaStiXSupport.h +678 -0
- data/vendor/eigen/Eigen/src/PardisoSupport/PardisoSupport.h +543 -0
- data/vendor/eigen/Eigen/src/QR/ColPivHouseholderQR.h +653 -0
- data/vendor/eigen/Eigen/src/QR/ColPivHouseholderQR_LAPACKE.h +97 -0
- data/vendor/eigen/Eigen/src/QR/CompleteOrthogonalDecomposition.h +562 -0
- data/vendor/eigen/Eigen/src/QR/FullPivHouseholderQR.h +676 -0
- data/vendor/eigen/Eigen/src/QR/HouseholderQR.h +409 -0
- data/vendor/eigen/Eigen/src/QR/HouseholderQR_LAPACKE.h +68 -0
- data/vendor/eigen/Eigen/src/SPQRSupport/SuiteSparseQRSupport.h +313 -0
- data/vendor/eigen/Eigen/src/SVD/BDCSVD.h +1246 -0
- data/vendor/eigen/Eigen/src/SVD/JacobiSVD.h +804 -0
- data/vendor/eigen/Eigen/src/SVD/JacobiSVD_LAPACKE.h +91 -0
- data/vendor/eigen/Eigen/src/SVD/SVDBase.h +315 -0
- data/vendor/eigen/Eigen/src/SVD/UpperBidiagonalization.h +414 -0
- data/vendor/eigen/Eigen/src/SparseCholesky/SimplicialCholesky.h +689 -0
- data/vendor/eigen/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h +199 -0
- data/vendor/eigen/Eigen/src/SparseCore/AmbiVector.h +377 -0
- data/vendor/eigen/Eigen/src/SparseCore/CompressedStorage.h +258 -0
- data/vendor/eigen/Eigen/src/SparseCore/ConservativeSparseSparseProduct.h +352 -0
- data/vendor/eigen/Eigen/src/SparseCore/MappedSparseMatrix.h +67 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseAssign.h +216 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseBlock.h +603 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseColEtree.h +206 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseCompressedBase.h +341 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseCwiseBinaryOp.h +726 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseCwiseUnaryOp.h +148 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseDenseProduct.h +320 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseDiagonalProduct.h +138 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseDot.h +98 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseFuzzy.h +29 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseMap.h +305 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseMatrix.h +1403 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseMatrixBase.h +405 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparsePermutation.h +178 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseProduct.h +169 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseRedux.h +49 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseRef.h +397 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseSelfAdjointView.h +656 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseSolverBase.h +124 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseSparseProductWithPruning.h +198 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseTranspose.h +92 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseTriangularView.h +189 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseUtil.h +178 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseVector.h +478 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseView.h +253 -0
- data/vendor/eigen/Eigen/src/SparseCore/TriangularSolver.h +315 -0
- data/vendor/eigen/Eigen/src/SparseLU/SparseLU.h +773 -0
- data/vendor/eigen/Eigen/src/SparseLU/SparseLUImpl.h +66 -0
- data/vendor/eigen/Eigen/src/SparseLU/SparseLU_Memory.h +226 -0
- data/vendor/eigen/Eigen/src/SparseLU/SparseLU_Structs.h +110 -0
- data/vendor/eigen/Eigen/src/SparseLU/SparseLU_SupernodalMatrix.h +301 -0
- data/vendor/eigen/Eigen/src/SparseLU/SparseLU_Utils.h +80 -0
- data/vendor/eigen/Eigen/src/SparseLU/SparseLU_column_bmod.h +181 -0
- data/vendor/eigen/Eigen/src/SparseLU/SparseLU_column_dfs.h +179 -0
- data/vendor/eigen/Eigen/src/SparseLU/SparseLU_copy_to_ucol.h +107 -0
- data/vendor/eigen/Eigen/src/SparseLU/SparseLU_gemm_kernel.h +280 -0
- data/vendor/eigen/Eigen/src/SparseLU/SparseLU_heap_relax_snode.h +126 -0
- data/vendor/eigen/Eigen/src/SparseLU/SparseLU_kernel_bmod.h +130 -0
- data/vendor/eigen/Eigen/src/SparseLU/SparseLU_panel_bmod.h +223 -0
- data/vendor/eigen/Eigen/src/SparseLU/SparseLU_panel_dfs.h +258 -0
- data/vendor/eigen/Eigen/src/SparseLU/SparseLU_pivotL.h +137 -0
- data/vendor/eigen/Eigen/src/SparseLU/SparseLU_pruneL.h +136 -0
- data/vendor/eigen/Eigen/src/SparseLU/SparseLU_relax_snode.h +83 -0
- data/vendor/eigen/Eigen/src/SparseQR/SparseQR.h +745 -0
- data/vendor/eigen/Eigen/src/StlSupport/StdDeque.h +126 -0
- data/vendor/eigen/Eigen/src/StlSupport/StdList.h +106 -0
- data/vendor/eigen/Eigen/src/StlSupport/StdVector.h +131 -0
- data/vendor/eigen/Eigen/src/StlSupport/details.h +84 -0
- data/vendor/eigen/Eigen/src/SuperLUSupport/SuperLUSupport.h +1027 -0
- data/vendor/eigen/Eigen/src/UmfPackSupport/UmfPackSupport.h +506 -0
- data/vendor/eigen/Eigen/src/misc/Image.h +82 -0
- data/vendor/eigen/Eigen/src/misc/Kernel.h +79 -0
- data/vendor/eigen/Eigen/src/misc/RealSvd2x2.h +55 -0
- data/vendor/eigen/Eigen/src/misc/blas.h +440 -0
- data/vendor/eigen/Eigen/src/misc/lapack.h +152 -0
- data/vendor/eigen/Eigen/src/misc/lapacke.h +16291 -0
- data/vendor/eigen/Eigen/src/misc/lapacke_mangling.h +17 -0
- data/vendor/eigen/Eigen/src/plugins/ArrayCwiseBinaryOps.h +332 -0
- data/vendor/eigen/Eigen/src/plugins/ArrayCwiseUnaryOps.h +552 -0
- data/vendor/eigen/Eigen/src/plugins/BlockMethods.h +1058 -0
- data/vendor/eigen/Eigen/src/plugins/CommonCwiseBinaryOps.h +115 -0
- data/vendor/eigen/Eigen/src/plugins/CommonCwiseUnaryOps.h +163 -0
- data/vendor/eigen/Eigen/src/plugins/MatrixCwiseBinaryOps.h +152 -0
- data/vendor/eigen/Eigen/src/plugins/MatrixCwiseUnaryOps.h +85 -0
- data/vendor/eigen/README.md +3 -0
- data/vendor/eigen/bench/README.txt +55 -0
- data/vendor/eigen/bench/btl/COPYING +340 -0
- data/vendor/eigen/bench/btl/README +154 -0
- data/vendor/eigen/bench/tensors/README +21 -0
- data/vendor/eigen/blas/README.txt +6 -0
- data/vendor/eigen/demos/mandelbrot/README +10 -0
- data/vendor/eigen/demos/mix_eigen_and_c/README +9 -0
- data/vendor/eigen/demos/opengl/README +13 -0
- data/vendor/eigen/unsupported/Eigen/CXX11/src/Tensor/README.md +1760 -0
- data/vendor/eigen/unsupported/README.txt +50 -0
- data/vendor/tomotopy/LICENSE +21 -0
- data/vendor/tomotopy/README.kr.rst +375 -0
- data/vendor/tomotopy/README.rst +382 -0
- data/vendor/tomotopy/src/Labeling/FoRelevance.cpp +362 -0
- data/vendor/tomotopy/src/Labeling/FoRelevance.h +88 -0
- data/vendor/tomotopy/src/Labeling/Labeler.h +50 -0
- data/vendor/tomotopy/src/TopicModel/CT.h +37 -0
- data/vendor/tomotopy/src/TopicModel/CTModel.cpp +13 -0
- data/vendor/tomotopy/src/TopicModel/CTModel.hpp +293 -0
- data/vendor/tomotopy/src/TopicModel/DMR.h +51 -0
- data/vendor/tomotopy/src/TopicModel/DMRModel.cpp +13 -0
- data/vendor/tomotopy/src/TopicModel/DMRModel.hpp +374 -0
- data/vendor/tomotopy/src/TopicModel/DT.h +65 -0
- data/vendor/tomotopy/src/TopicModel/DTM.h +22 -0
- data/vendor/tomotopy/src/TopicModel/DTModel.cpp +15 -0
- data/vendor/tomotopy/src/TopicModel/DTModel.hpp +572 -0
- data/vendor/tomotopy/src/TopicModel/GDMR.h +37 -0
- data/vendor/tomotopy/src/TopicModel/GDMRModel.cpp +14 -0
- data/vendor/tomotopy/src/TopicModel/GDMRModel.hpp +485 -0
- data/vendor/tomotopy/src/TopicModel/HDP.h +74 -0
- data/vendor/tomotopy/src/TopicModel/HDPModel.cpp +13 -0
- data/vendor/tomotopy/src/TopicModel/HDPModel.hpp +592 -0
- data/vendor/tomotopy/src/TopicModel/HLDA.h +40 -0
- data/vendor/tomotopy/src/TopicModel/HLDAModel.cpp +13 -0
- data/vendor/tomotopy/src/TopicModel/HLDAModel.hpp +681 -0
- data/vendor/tomotopy/src/TopicModel/HPA.h +27 -0
- data/vendor/tomotopy/src/TopicModel/HPAModel.cpp +21 -0
- data/vendor/tomotopy/src/TopicModel/HPAModel.hpp +588 -0
- data/vendor/tomotopy/src/TopicModel/LDA.h +144 -0
- data/vendor/tomotopy/src/TopicModel/LDACVB0Model.hpp +442 -0
- data/vendor/tomotopy/src/TopicModel/LDAModel.cpp +13 -0
- data/vendor/tomotopy/src/TopicModel/LDAModel.hpp +1058 -0
- data/vendor/tomotopy/src/TopicModel/LLDA.h +45 -0
- data/vendor/tomotopy/src/TopicModel/LLDAModel.cpp +13 -0
- data/vendor/tomotopy/src/TopicModel/LLDAModel.hpp +203 -0
- data/vendor/tomotopy/src/TopicModel/MGLDA.h +63 -0
- data/vendor/tomotopy/src/TopicModel/MGLDAModel.cpp +17 -0
- data/vendor/tomotopy/src/TopicModel/MGLDAModel.hpp +558 -0
- data/vendor/tomotopy/src/TopicModel/PA.h +43 -0
- data/vendor/tomotopy/src/TopicModel/PAModel.cpp +13 -0
- data/vendor/tomotopy/src/TopicModel/PAModel.hpp +467 -0
- data/vendor/tomotopy/src/TopicModel/PLDA.h +17 -0
- data/vendor/tomotopy/src/TopicModel/PLDAModel.cpp +13 -0
- data/vendor/tomotopy/src/TopicModel/PLDAModel.hpp +214 -0
- data/vendor/tomotopy/src/TopicModel/SLDA.h +54 -0
- data/vendor/tomotopy/src/TopicModel/SLDAModel.cpp +17 -0
- data/vendor/tomotopy/src/TopicModel/SLDAModel.hpp +456 -0
- data/vendor/tomotopy/src/TopicModel/TopicModel.hpp +692 -0
- data/vendor/tomotopy/src/Utils/AliasMethod.hpp +169 -0
- data/vendor/tomotopy/src/Utils/Dictionary.h +80 -0
- data/vendor/tomotopy/src/Utils/EigenAddonOps.hpp +181 -0
- data/vendor/tomotopy/src/Utils/LBFGS.h +202 -0
- data/vendor/tomotopy/src/Utils/LBFGS/LineSearchBacktracking.h +120 -0
- data/vendor/tomotopy/src/Utils/LBFGS/LineSearchBracketing.h +122 -0
- data/vendor/tomotopy/src/Utils/LBFGS/Param.h +213 -0
- data/vendor/tomotopy/src/Utils/LUT.hpp +82 -0
- data/vendor/tomotopy/src/Utils/MultiNormalDistribution.hpp +69 -0
- data/vendor/tomotopy/src/Utils/PolyaGamma.hpp +200 -0
- data/vendor/tomotopy/src/Utils/PolyaGammaHybrid.hpp +672 -0
- data/vendor/tomotopy/src/Utils/ThreadPool.hpp +150 -0
- data/vendor/tomotopy/src/Utils/Trie.hpp +220 -0
- data/vendor/tomotopy/src/Utils/TruncMultiNormal.hpp +94 -0
- data/vendor/tomotopy/src/Utils/Utils.hpp +337 -0
- data/vendor/tomotopy/src/Utils/avx_gamma.h +46 -0
- data/vendor/tomotopy/src/Utils/avx_mathfun.h +736 -0
- data/vendor/tomotopy/src/Utils/exception.h +28 -0
- data/vendor/tomotopy/src/Utils/math.h +281 -0
- data/vendor/tomotopy/src/Utils/rtnorm.hpp +2690 -0
- data/vendor/tomotopy/src/Utils/sample.hpp +192 -0
- data/vendor/tomotopy/src/Utils/serializer.hpp +695 -0
- data/vendor/tomotopy/src/Utils/slp.hpp +131 -0
- data/vendor/tomotopy/src/Utils/sse_gamma.h +48 -0
- data/vendor/tomotopy/src/Utils/sse_mathfun.h +710 -0
- data/vendor/tomotopy/src/Utils/text.hpp +49 -0
- data/vendor/tomotopy/src/Utils/tvector.hpp +543 -0
- metadata +531 -0
@@ -0,0 +1,346 @@
|
|
1
|
+
// This file is part of Eigen, a lightweight C++ template library
|
2
|
+
// for linear algebra.
|
3
|
+
//
|
4
|
+
// Copyright (C) 2009 Claire Maurice
|
5
|
+
// Copyright (C) 2009 Gael Guennebaud <gael.guennebaud@inria.fr>
|
6
|
+
// Copyright (C) 2010,2012 Jitse Niesen <jitse@maths.leeds.ac.uk>
|
7
|
+
//
|
8
|
+
// This Source Code Form is subject to the terms of the Mozilla
|
9
|
+
// Public License v. 2.0. If a copy of the MPL was not distributed
|
10
|
+
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
11
|
+
|
12
|
+
#ifndef EIGEN_COMPLEX_EIGEN_SOLVER_H
|
13
|
+
#define EIGEN_COMPLEX_EIGEN_SOLVER_H
|
14
|
+
|
15
|
+
#include "./ComplexSchur.h"
|
16
|
+
|
17
|
+
namespace Eigen {
|
18
|
+
|
19
|
+
/** \eigenvalues_module \ingroup Eigenvalues_Module
|
20
|
+
*
|
21
|
+
*
|
22
|
+
* \class ComplexEigenSolver
|
23
|
+
*
|
24
|
+
* \brief Computes eigenvalues and eigenvectors of general complex matrices
|
25
|
+
*
|
26
|
+
* \tparam _MatrixType the type of the matrix of which we are
|
27
|
+
* computing the eigendecomposition; this is expected to be an
|
28
|
+
* instantiation of the Matrix class template.
|
29
|
+
*
|
30
|
+
* The eigenvalues and eigenvectors of a matrix \f$ A \f$ are scalars
|
31
|
+
* \f$ \lambda \f$ and vectors \f$ v \f$ such that \f$ Av = \lambda v
|
32
|
+
* \f$. If \f$ D \f$ is a diagonal matrix with the eigenvalues on
|
33
|
+
* the diagonal, and \f$ V \f$ is a matrix with the eigenvectors as
|
34
|
+
* its columns, then \f$ A V = V D \f$. The matrix \f$ V \f$ is
|
35
|
+
* almost always invertible, in which case we have \f$ A = V D V^{-1}
|
36
|
+
* \f$. This is called the eigendecomposition.
|
37
|
+
*
|
38
|
+
* The main function in this class is compute(), which computes the
|
39
|
+
* eigenvalues and eigenvectors of a given function. The
|
40
|
+
* documentation for that function contains an example showing the
|
41
|
+
* main features of the class.
|
42
|
+
*
|
43
|
+
* \sa class EigenSolver, class SelfAdjointEigenSolver
|
44
|
+
*/
|
45
|
+
template<typename _MatrixType> class ComplexEigenSolver
|
46
|
+
{
|
47
|
+
public:
|
48
|
+
|
49
|
+
/** \brief Synonym for the template parameter \p _MatrixType. */
|
50
|
+
typedef _MatrixType MatrixType;
|
51
|
+
|
52
|
+
enum {
|
53
|
+
RowsAtCompileTime = MatrixType::RowsAtCompileTime,
|
54
|
+
ColsAtCompileTime = MatrixType::ColsAtCompileTime,
|
55
|
+
Options = MatrixType::Options,
|
56
|
+
MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
|
57
|
+
MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
|
58
|
+
};
|
59
|
+
|
60
|
+
/** \brief Scalar type for matrices of type #MatrixType. */
|
61
|
+
typedef typename MatrixType::Scalar Scalar;
|
62
|
+
typedef typename NumTraits<Scalar>::Real RealScalar;
|
63
|
+
typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3
|
64
|
+
|
65
|
+
/** \brief Complex scalar type for #MatrixType.
|
66
|
+
*
|
67
|
+
* This is \c std::complex<Scalar> if #Scalar is real (e.g.,
|
68
|
+
* \c float or \c double) and just \c Scalar if #Scalar is
|
69
|
+
* complex.
|
70
|
+
*/
|
71
|
+
typedef std::complex<RealScalar> ComplexScalar;
|
72
|
+
|
73
|
+
/** \brief Type for vector of eigenvalues as returned by eigenvalues().
|
74
|
+
*
|
75
|
+
* This is a column vector with entries of type #ComplexScalar.
|
76
|
+
* The length of the vector is the size of #MatrixType.
|
77
|
+
*/
|
78
|
+
typedef Matrix<ComplexScalar, ColsAtCompileTime, 1, Options&(~RowMajor), MaxColsAtCompileTime, 1> EigenvalueType;
|
79
|
+
|
80
|
+
/** \brief Type for matrix of eigenvectors as returned by eigenvectors().
|
81
|
+
*
|
82
|
+
* This is a square matrix with entries of type #ComplexScalar.
|
83
|
+
* The size is the same as the size of #MatrixType.
|
84
|
+
*/
|
85
|
+
typedef Matrix<ComplexScalar, RowsAtCompileTime, ColsAtCompileTime, Options, MaxRowsAtCompileTime, MaxColsAtCompileTime> EigenvectorType;
|
86
|
+
|
87
|
+
/** \brief Default constructor.
|
88
|
+
*
|
89
|
+
* The default constructor is useful in cases in which the user intends to
|
90
|
+
* perform decompositions via compute().
|
91
|
+
*/
|
92
|
+
ComplexEigenSolver()
|
93
|
+
: m_eivec(),
|
94
|
+
m_eivalues(),
|
95
|
+
m_schur(),
|
96
|
+
m_isInitialized(false),
|
97
|
+
m_eigenvectorsOk(false),
|
98
|
+
m_matX()
|
99
|
+
{}
|
100
|
+
|
101
|
+
/** \brief Default Constructor with memory preallocation
|
102
|
+
*
|
103
|
+
* Like the default constructor but with preallocation of the internal data
|
104
|
+
* according to the specified problem \a size.
|
105
|
+
* \sa ComplexEigenSolver()
|
106
|
+
*/
|
107
|
+
explicit ComplexEigenSolver(Index size)
|
108
|
+
: m_eivec(size, size),
|
109
|
+
m_eivalues(size),
|
110
|
+
m_schur(size),
|
111
|
+
m_isInitialized(false),
|
112
|
+
m_eigenvectorsOk(false),
|
113
|
+
m_matX(size, size)
|
114
|
+
{}
|
115
|
+
|
116
|
+
/** \brief Constructor; computes eigendecomposition of given matrix.
|
117
|
+
*
|
118
|
+
* \param[in] matrix Square matrix whose eigendecomposition is to be computed.
|
119
|
+
* \param[in] computeEigenvectors If true, both the eigenvectors and the
|
120
|
+
* eigenvalues are computed; if false, only the eigenvalues are
|
121
|
+
* computed.
|
122
|
+
*
|
123
|
+
* This constructor calls compute() to compute the eigendecomposition.
|
124
|
+
*/
|
125
|
+
template<typename InputType>
|
126
|
+
explicit ComplexEigenSolver(const EigenBase<InputType>& matrix, bool computeEigenvectors = true)
|
127
|
+
: m_eivec(matrix.rows(),matrix.cols()),
|
128
|
+
m_eivalues(matrix.cols()),
|
129
|
+
m_schur(matrix.rows()),
|
130
|
+
m_isInitialized(false),
|
131
|
+
m_eigenvectorsOk(false),
|
132
|
+
m_matX(matrix.rows(),matrix.cols())
|
133
|
+
{
|
134
|
+
compute(matrix.derived(), computeEigenvectors);
|
135
|
+
}
|
136
|
+
|
137
|
+
/** \brief Returns the eigenvectors of given matrix.
|
138
|
+
*
|
139
|
+
* \returns A const reference to the matrix whose columns are the eigenvectors.
|
140
|
+
*
|
141
|
+
* \pre Either the constructor
|
142
|
+
* ComplexEigenSolver(const MatrixType& matrix, bool) or the member
|
143
|
+
* function compute(const MatrixType& matrix, bool) has been called before
|
144
|
+
* to compute the eigendecomposition of a matrix, and
|
145
|
+
* \p computeEigenvectors was set to true (the default).
|
146
|
+
*
|
147
|
+
* This function returns a matrix whose columns are the eigenvectors. Column
|
148
|
+
* \f$ k \f$ is an eigenvector corresponding to eigenvalue number \f$ k
|
149
|
+
* \f$ as returned by eigenvalues(). The eigenvectors are normalized to
|
150
|
+
* have (Euclidean) norm equal to one. The matrix returned by this
|
151
|
+
* function is the matrix \f$ V \f$ in the eigendecomposition \f$ A = V D
|
152
|
+
* V^{-1} \f$, if it exists.
|
153
|
+
*
|
154
|
+
* Example: \include ComplexEigenSolver_eigenvectors.cpp
|
155
|
+
* Output: \verbinclude ComplexEigenSolver_eigenvectors.out
|
156
|
+
*/
|
157
|
+
const EigenvectorType& eigenvectors() const
|
158
|
+
{
|
159
|
+
eigen_assert(m_isInitialized && "ComplexEigenSolver is not initialized.");
|
160
|
+
eigen_assert(m_eigenvectorsOk && "The eigenvectors have not been computed together with the eigenvalues.");
|
161
|
+
return m_eivec;
|
162
|
+
}
|
163
|
+
|
164
|
+
/** \brief Returns the eigenvalues of given matrix.
|
165
|
+
*
|
166
|
+
* \returns A const reference to the column vector containing the eigenvalues.
|
167
|
+
*
|
168
|
+
* \pre Either the constructor
|
169
|
+
* ComplexEigenSolver(const MatrixType& matrix, bool) or the member
|
170
|
+
* function compute(const MatrixType& matrix, bool) has been called before
|
171
|
+
* to compute the eigendecomposition of a matrix.
|
172
|
+
*
|
173
|
+
* This function returns a column vector containing the
|
174
|
+
* eigenvalues. Eigenvalues are repeated according to their
|
175
|
+
* algebraic multiplicity, so there are as many eigenvalues as
|
176
|
+
* rows in the matrix. The eigenvalues are not sorted in any particular
|
177
|
+
* order.
|
178
|
+
*
|
179
|
+
* Example: \include ComplexEigenSolver_eigenvalues.cpp
|
180
|
+
* Output: \verbinclude ComplexEigenSolver_eigenvalues.out
|
181
|
+
*/
|
182
|
+
const EigenvalueType& eigenvalues() const
|
183
|
+
{
|
184
|
+
eigen_assert(m_isInitialized && "ComplexEigenSolver is not initialized.");
|
185
|
+
return m_eivalues;
|
186
|
+
}
|
187
|
+
|
188
|
+
/** \brief Computes eigendecomposition of given matrix.
|
189
|
+
*
|
190
|
+
* \param[in] matrix Square matrix whose eigendecomposition is to be computed.
|
191
|
+
* \param[in] computeEigenvectors If true, both the eigenvectors and the
|
192
|
+
* eigenvalues are computed; if false, only the eigenvalues are
|
193
|
+
* computed.
|
194
|
+
* \returns Reference to \c *this
|
195
|
+
*
|
196
|
+
* This function computes the eigenvalues of the complex matrix \p matrix.
|
197
|
+
* The eigenvalues() function can be used to retrieve them. If
|
198
|
+
* \p computeEigenvectors is true, then the eigenvectors are also computed
|
199
|
+
* and can be retrieved by calling eigenvectors().
|
200
|
+
*
|
201
|
+
* The matrix is first reduced to Schur form using the
|
202
|
+
* ComplexSchur class. The Schur decomposition is then used to
|
203
|
+
* compute the eigenvalues and eigenvectors.
|
204
|
+
*
|
205
|
+
* The cost of the computation is dominated by the cost of the
|
206
|
+
* Schur decomposition, which is \f$ O(n^3) \f$ where \f$ n \f$
|
207
|
+
* is the size of the matrix.
|
208
|
+
*
|
209
|
+
* Example: \include ComplexEigenSolver_compute.cpp
|
210
|
+
* Output: \verbinclude ComplexEigenSolver_compute.out
|
211
|
+
*/
|
212
|
+
template<typename InputType>
|
213
|
+
ComplexEigenSolver& compute(const EigenBase<InputType>& matrix, bool computeEigenvectors = true);
|
214
|
+
|
215
|
+
/** \brief Reports whether previous computation was successful.
|
216
|
+
*
|
217
|
+
* \returns \c Success if computation was succesful, \c NoConvergence otherwise.
|
218
|
+
*/
|
219
|
+
ComputationInfo info() const
|
220
|
+
{
|
221
|
+
eigen_assert(m_isInitialized && "ComplexEigenSolver is not initialized.");
|
222
|
+
return m_schur.info();
|
223
|
+
}
|
224
|
+
|
225
|
+
/** \brief Sets the maximum number of iterations allowed. */
|
226
|
+
ComplexEigenSolver& setMaxIterations(Index maxIters)
|
227
|
+
{
|
228
|
+
m_schur.setMaxIterations(maxIters);
|
229
|
+
return *this;
|
230
|
+
}
|
231
|
+
|
232
|
+
/** \brief Returns the maximum number of iterations. */
|
233
|
+
Index getMaxIterations()
|
234
|
+
{
|
235
|
+
return m_schur.getMaxIterations();
|
236
|
+
}
|
237
|
+
|
238
|
+
protected:
|
239
|
+
|
240
|
+
static void check_template_parameters()
|
241
|
+
{
|
242
|
+
EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar);
|
243
|
+
}
|
244
|
+
|
245
|
+
EigenvectorType m_eivec;
|
246
|
+
EigenvalueType m_eivalues;
|
247
|
+
ComplexSchur<MatrixType> m_schur;
|
248
|
+
bool m_isInitialized;
|
249
|
+
bool m_eigenvectorsOk;
|
250
|
+
EigenvectorType m_matX;
|
251
|
+
|
252
|
+
private:
|
253
|
+
void doComputeEigenvectors(RealScalar matrixnorm);
|
254
|
+
void sortEigenvalues(bool computeEigenvectors);
|
255
|
+
};
|
256
|
+
|
257
|
+
|
258
|
+
template<typename MatrixType>
|
259
|
+
template<typename InputType>
|
260
|
+
ComplexEigenSolver<MatrixType>&
|
261
|
+
ComplexEigenSolver<MatrixType>::compute(const EigenBase<InputType>& matrix, bool computeEigenvectors)
|
262
|
+
{
|
263
|
+
check_template_parameters();
|
264
|
+
|
265
|
+
// this code is inspired from Jampack
|
266
|
+
eigen_assert(matrix.cols() == matrix.rows());
|
267
|
+
|
268
|
+
// Do a complex Schur decomposition, A = U T U^*
|
269
|
+
// The eigenvalues are on the diagonal of T.
|
270
|
+
m_schur.compute(matrix.derived(), computeEigenvectors);
|
271
|
+
|
272
|
+
if(m_schur.info() == Success)
|
273
|
+
{
|
274
|
+
m_eivalues = m_schur.matrixT().diagonal();
|
275
|
+
if(computeEigenvectors)
|
276
|
+
doComputeEigenvectors(m_schur.matrixT().norm());
|
277
|
+
sortEigenvalues(computeEigenvectors);
|
278
|
+
}
|
279
|
+
|
280
|
+
m_isInitialized = true;
|
281
|
+
m_eigenvectorsOk = computeEigenvectors;
|
282
|
+
return *this;
|
283
|
+
}
|
284
|
+
|
285
|
+
|
286
|
+
template<typename MatrixType>
|
287
|
+
void ComplexEigenSolver<MatrixType>::doComputeEigenvectors(RealScalar matrixnorm)
|
288
|
+
{
|
289
|
+
const Index n = m_eivalues.size();
|
290
|
+
|
291
|
+
matrixnorm = numext::maxi(matrixnorm,(std::numeric_limits<RealScalar>::min)());
|
292
|
+
|
293
|
+
// Compute X such that T = X D X^(-1), where D is the diagonal of T.
|
294
|
+
// The matrix X is unit triangular.
|
295
|
+
m_matX = EigenvectorType::Zero(n, n);
|
296
|
+
for(Index k=n-1 ; k>=0 ; k--)
|
297
|
+
{
|
298
|
+
m_matX.coeffRef(k,k) = ComplexScalar(1.0,0.0);
|
299
|
+
// Compute X(i,k) using the (i,k) entry of the equation X T = D X
|
300
|
+
for(Index i=k-1 ; i>=0 ; i--)
|
301
|
+
{
|
302
|
+
m_matX.coeffRef(i,k) = -m_schur.matrixT().coeff(i,k);
|
303
|
+
if(k-i-1>0)
|
304
|
+
m_matX.coeffRef(i,k) -= (m_schur.matrixT().row(i).segment(i+1,k-i-1) * m_matX.col(k).segment(i+1,k-i-1)).value();
|
305
|
+
ComplexScalar z = m_schur.matrixT().coeff(i,i) - m_schur.matrixT().coeff(k,k);
|
306
|
+
if(z==ComplexScalar(0))
|
307
|
+
{
|
308
|
+
// If the i-th and k-th eigenvalue are equal, then z equals 0.
|
309
|
+
// Use a small value instead, to prevent division by zero.
|
310
|
+
numext::real_ref(z) = NumTraits<RealScalar>::epsilon() * matrixnorm;
|
311
|
+
}
|
312
|
+
m_matX.coeffRef(i,k) = m_matX.coeff(i,k) / z;
|
313
|
+
}
|
314
|
+
}
|
315
|
+
|
316
|
+
// Compute V as V = U X; now A = U T U^* = U X D X^(-1) U^* = V D V^(-1)
|
317
|
+
m_eivec.noalias() = m_schur.matrixU() * m_matX;
|
318
|
+
// .. and normalize the eigenvectors
|
319
|
+
for(Index k=0 ; k<n ; k++)
|
320
|
+
{
|
321
|
+
m_eivec.col(k).normalize();
|
322
|
+
}
|
323
|
+
}
|
324
|
+
|
325
|
+
|
326
|
+
template<typename MatrixType>
|
327
|
+
void ComplexEigenSolver<MatrixType>::sortEigenvalues(bool computeEigenvectors)
|
328
|
+
{
|
329
|
+
const Index n = m_eivalues.size();
|
330
|
+
for (Index i=0; i<n; i++)
|
331
|
+
{
|
332
|
+
Index k;
|
333
|
+
m_eivalues.cwiseAbs().tail(n-i).minCoeff(&k);
|
334
|
+
if (k != 0)
|
335
|
+
{
|
336
|
+
k += i;
|
337
|
+
std::swap(m_eivalues[k],m_eivalues[i]);
|
338
|
+
if(computeEigenvectors)
|
339
|
+
m_eivec.col(i).swap(m_eivec.col(k));
|
340
|
+
}
|
341
|
+
}
|
342
|
+
}
|
343
|
+
|
344
|
+
} // end namespace Eigen
|
345
|
+
|
346
|
+
#endif // EIGEN_COMPLEX_EIGEN_SOLVER_H
|
@@ -0,0 +1,459 @@
|
|
1
|
+
// This file is part of Eigen, a lightweight C++ template library
|
2
|
+
// for linear algebra.
|
3
|
+
//
|
4
|
+
// Copyright (C) 2009 Claire Maurice
|
5
|
+
// Copyright (C) 2009 Gael Guennebaud <gael.guennebaud@inria.fr>
|
6
|
+
// Copyright (C) 2010,2012 Jitse Niesen <jitse@maths.leeds.ac.uk>
|
7
|
+
//
|
8
|
+
// This Source Code Form is subject to the terms of the Mozilla
|
9
|
+
// Public License v. 2.0. If a copy of the MPL was not distributed
|
10
|
+
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
11
|
+
|
12
|
+
#ifndef EIGEN_COMPLEX_SCHUR_H
|
13
|
+
#define EIGEN_COMPLEX_SCHUR_H
|
14
|
+
|
15
|
+
#include "./HessenbergDecomposition.h"
|
16
|
+
|
17
|
+
namespace Eigen {
|
18
|
+
|
19
|
+
namespace internal {
|
20
|
+
template<typename MatrixType, bool IsComplex> struct complex_schur_reduce_to_hessenberg;
|
21
|
+
}
|
22
|
+
|
23
|
+
/** \eigenvalues_module \ingroup Eigenvalues_Module
|
24
|
+
*
|
25
|
+
*
|
26
|
+
* \class ComplexSchur
|
27
|
+
*
|
28
|
+
* \brief Performs a complex Schur decomposition of a real or complex square matrix
|
29
|
+
*
|
30
|
+
* \tparam _MatrixType the type of the matrix of which we are
|
31
|
+
* computing the Schur decomposition; this is expected to be an
|
32
|
+
* instantiation of the Matrix class template.
|
33
|
+
*
|
34
|
+
* Given a real or complex square matrix A, this class computes the
|
35
|
+
* Schur decomposition: \f$ A = U T U^*\f$ where U is a unitary
|
36
|
+
* complex matrix, and T is a complex upper triangular matrix. The
|
37
|
+
* diagonal of the matrix T corresponds to the eigenvalues of the
|
38
|
+
* matrix A.
|
39
|
+
*
|
40
|
+
* Call the function compute() to compute the Schur decomposition of
|
41
|
+
* a given matrix. Alternatively, you can use the
|
42
|
+
* ComplexSchur(const MatrixType&, bool) constructor which computes
|
43
|
+
* the Schur decomposition at construction time. Once the
|
44
|
+
* decomposition is computed, you can use the matrixU() and matrixT()
|
45
|
+
* functions to retrieve the matrices U and V in the decomposition.
|
46
|
+
*
|
47
|
+
* \note This code is inspired from Jampack
|
48
|
+
*
|
49
|
+
* \sa class RealSchur, class EigenSolver, class ComplexEigenSolver
|
50
|
+
*/
|
51
|
+
template<typename _MatrixType> class ComplexSchur
|
52
|
+
{
|
53
|
+
public:
|
54
|
+
typedef _MatrixType MatrixType;
|
55
|
+
enum {
|
56
|
+
RowsAtCompileTime = MatrixType::RowsAtCompileTime,
|
57
|
+
ColsAtCompileTime = MatrixType::ColsAtCompileTime,
|
58
|
+
Options = MatrixType::Options,
|
59
|
+
MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
|
60
|
+
MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
|
61
|
+
};
|
62
|
+
|
63
|
+
/** \brief Scalar type for matrices of type \p _MatrixType. */
|
64
|
+
typedef typename MatrixType::Scalar Scalar;
|
65
|
+
typedef typename NumTraits<Scalar>::Real RealScalar;
|
66
|
+
typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3
|
67
|
+
|
68
|
+
/** \brief Complex scalar type for \p _MatrixType.
|
69
|
+
*
|
70
|
+
* This is \c std::complex<Scalar> if #Scalar is real (e.g.,
|
71
|
+
* \c float or \c double) and just \c Scalar if #Scalar is
|
72
|
+
* complex.
|
73
|
+
*/
|
74
|
+
typedef std::complex<RealScalar> ComplexScalar;
|
75
|
+
|
76
|
+
/** \brief Type for the matrices in the Schur decomposition.
|
77
|
+
*
|
78
|
+
* This is a square matrix with entries of type #ComplexScalar.
|
79
|
+
* The size is the same as the size of \p _MatrixType.
|
80
|
+
*/
|
81
|
+
typedef Matrix<ComplexScalar, RowsAtCompileTime, ColsAtCompileTime, Options, MaxRowsAtCompileTime, MaxColsAtCompileTime> ComplexMatrixType;
|
82
|
+
|
83
|
+
/** \brief Default constructor.
|
84
|
+
*
|
85
|
+
* \param [in] size Positive integer, size of the matrix whose Schur decomposition will be computed.
|
86
|
+
*
|
87
|
+
* The default constructor is useful in cases in which the user
|
88
|
+
* intends to perform decompositions via compute(). The \p size
|
89
|
+
* parameter is only used as a hint. It is not an error to give a
|
90
|
+
* wrong \p size, but it may impair performance.
|
91
|
+
*
|
92
|
+
* \sa compute() for an example.
|
93
|
+
*/
|
94
|
+
explicit ComplexSchur(Index size = RowsAtCompileTime==Dynamic ? 1 : RowsAtCompileTime)
|
95
|
+
: m_matT(size,size),
|
96
|
+
m_matU(size,size),
|
97
|
+
m_hess(size),
|
98
|
+
m_isInitialized(false),
|
99
|
+
m_matUisUptodate(false),
|
100
|
+
m_maxIters(-1)
|
101
|
+
{}
|
102
|
+
|
103
|
+
/** \brief Constructor; computes Schur decomposition of given matrix.
|
104
|
+
*
|
105
|
+
* \param[in] matrix Square matrix whose Schur decomposition is to be computed.
|
106
|
+
* \param[in] computeU If true, both T and U are computed; if false, only T is computed.
|
107
|
+
*
|
108
|
+
* This constructor calls compute() to compute the Schur decomposition.
|
109
|
+
*
|
110
|
+
* \sa matrixT() and matrixU() for examples.
|
111
|
+
*/
|
112
|
+
template<typename InputType>
|
113
|
+
explicit ComplexSchur(const EigenBase<InputType>& matrix, bool computeU = true)
|
114
|
+
: m_matT(matrix.rows(),matrix.cols()),
|
115
|
+
m_matU(matrix.rows(),matrix.cols()),
|
116
|
+
m_hess(matrix.rows()),
|
117
|
+
m_isInitialized(false),
|
118
|
+
m_matUisUptodate(false),
|
119
|
+
m_maxIters(-1)
|
120
|
+
{
|
121
|
+
compute(matrix.derived(), computeU);
|
122
|
+
}
|
123
|
+
|
124
|
+
/** \brief Returns the unitary matrix in the Schur decomposition.
|
125
|
+
*
|
126
|
+
* \returns A const reference to the matrix U.
|
127
|
+
*
|
128
|
+
* It is assumed that either the constructor
|
129
|
+
* ComplexSchur(const MatrixType& matrix, bool computeU) or the
|
130
|
+
* member function compute(const MatrixType& matrix, bool computeU)
|
131
|
+
* has been called before to compute the Schur decomposition of a
|
132
|
+
* matrix, and that \p computeU was set to true (the default
|
133
|
+
* value).
|
134
|
+
*
|
135
|
+
* Example: \include ComplexSchur_matrixU.cpp
|
136
|
+
* Output: \verbinclude ComplexSchur_matrixU.out
|
137
|
+
*/
|
138
|
+
const ComplexMatrixType& matrixU() const
|
139
|
+
{
|
140
|
+
eigen_assert(m_isInitialized && "ComplexSchur is not initialized.");
|
141
|
+
eigen_assert(m_matUisUptodate && "The matrix U has not been computed during the ComplexSchur decomposition.");
|
142
|
+
return m_matU;
|
143
|
+
}
|
144
|
+
|
145
|
+
/** \brief Returns the triangular matrix in the Schur decomposition.
|
146
|
+
*
|
147
|
+
* \returns A const reference to the matrix T.
|
148
|
+
*
|
149
|
+
* It is assumed that either the constructor
|
150
|
+
* ComplexSchur(const MatrixType& matrix, bool computeU) or the
|
151
|
+
* member function compute(const MatrixType& matrix, bool computeU)
|
152
|
+
* has been called before to compute the Schur decomposition of a
|
153
|
+
* matrix.
|
154
|
+
*
|
155
|
+
* Note that this function returns a plain square matrix. If you want to reference
|
156
|
+
* only the upper triangular part, use:
|
157
|
+
* \code schur.matrixT().triangularView<Upper>() \endcode
|
158
|
+
*
|
159
|
+
* Example: \include ComplexSchur_matrixT.cpp
|
160
|
+
* Output: \verbinclude ComplexSchur_matrixT.out
|
161
|
+
*/
|
162
|
+
const ComplexMatrixType& matrixT() const
|
163
|
+
{
|
164
|
+
eigen_assert(m_isInitialized && "ComplexSchur is not initialized.");
|
165
|
+
return m_matT;
|
166
|
+
}
|
167
|
+
|
168
|
+
/** \brief Computes Schur decomposition of given matrix.
|
169
|
+
*
|
170
|
+
* \param[in] matrix Square matrix whose Schur decomposition is to be computed.
|
171
|
+
* \param[in] computeU If true, both T and U are computed; if false, only T is computed.
|
172
|
+
|
173
|
+
* \returns Reference to \c *this
|
174
|
+
*
|
175
|
+
* The Schur decomposition is computed by first reducing the
|
176
|
+
* matrix to Hessenberg form using the class
|
177
|
+
* HessenbergDecomposition. The Hessenberg matrix is then reduced
|
178
|
+
* to triangular form by performing QR iterations with a single
|
179
|
+
* shift. The cost of computing the Schur decomposition depends
|
180
|
+
* on the number of iterations; as a rough guide, it may be taken
|
181
|
+
* on the number of iterations; as a rough guide, it may be taken
|
182
|
+
* to be \f$25n^3\f$ complex flops, or \f$10n^3\f$ complex flops
|
183
|
+
* if \a computeU is false.
|
184
|
+
*
|
185
|
+
* Example: \include ComplexSchur_compute.cpp
|
186
|
+
* Output: \verbinclude ComplexSchur_compute.out
|
187
|
+
*
|
188
|
+
* \sa compute(const MatrixType&, bool, Index)
|
189
|
+
*/
|
190
|
+
template<typename InputType>
|
191
|
+
ComplexSchur& compute(const EigenBase<InputType>& matrix, bool computeU = true);
|
192
|
+
|
193
|
+
/** \brief Compute Schur decomposition from a given Hessenberg matrix
|
194
|
+
* \param[in] matrixH Matrix in Hessenberg form H
|
195
|
+
* \param[in] matrixQ orthogonal matrix Q that transform a matrix A to H : A = Q H Q^T
|
196
|
+
* \param computeU Computes the matriX U of the Schur vectors
|
197
|
+
* \return Reference to \c *this
|
198
|
+
*
|
199
|
+
* This routine assumes that the matrix is already reduced in Hessenberg form matrixH
|
200
|
+
* using either the class HessenbergDecomposition or another mean.
|
201
|
+
* It computes the upper quasi-triangular matrix T of the Schur decomposition of H
|
202
|
+
* When computeU is true, this routine computes the matrix U such that
|
203
|
+
* A = U T U^T = (QZ) T (QZ)^T = Q H Q^T where A is the initial matrix
|
204
|
+
*
|
205
|
+
* NOTE Q is referenced if computeU is true; so, if the initial orthogonal matrix
|
206
|
+
* is not available, the user should give an identity matrix (Q.setIdentity())
|
207
|
+
*
|
208
|
+
* \sa compute(const MatrixType&, bool)
|
209
|
+
*/
|
210
|
+
template<typename HessMatrixType, typename OrthMatrixType>
|
211
|
+
ComplexSchur& computeFromHessenberg(const HessMatrixType& matrixH, const OrthMatrixType& matrixQ, bool computeU=true);
|
212
|
+
|
213
|
+
/** \brief Reports whether previous computation was successful.
|
214
|
+
*
|
215
|
+
* \returns \c Success if computation was succesful, \c NoConvergence otherwise.
|
216
|
+
*/
|
217
|
+
ComputationInfo info() const
|
218
|
+
{
|
219
|
+
eigen_assert(m_isInitialized && "ComplexSchur is not initialized.");
|
220
|
+
return m_info;
|
221
|
+
}
|
222
|
+
|
223
|
+
/** \brief Sets the maximum number of iterations allowed.
|
224
|
+
*
|
225
|
+
* If not specified by the user, the maximum number of iterations is m_maxIterationsPerRow times the size
|
226
|
+
* of the matrix.
|
227
|
+
*/
|
228
|
+
ComplexSchur& setMaxIterations(Index maxIters)
|
229
|
+
{
|
230
|
+
m_maxIters = maxIters;
|
231
|
+
return *this;
|
232
|
+
}
|
233
|
+
|
234
|
+
/** \brief Returns the maximum number of iterations. */
|
235
|
+
Index getMaxIterations()
|
236
|
+
{
|
237
|
+
return m_maxIters;
|
238
|
+
}
|
239
|
+
|
240
|
+
/** \brief Maximum number of iterations per row.
|
241
|
+
*
|
242
|
+
* If not otherwise specified, the maximum number of iterations is this number times the size of the
|
243
|
+
* matrix. It is currently set to 30.
|
244
|
+
*/
|
245
|
+
static const int m_maxIterationsPerRow = 30;
|
246
|
+
|
247
|
+
protected:
|
248
|
+
ComplexMatrixType m_matT, m_matU;
|
249
|
+
HessenbergDecomposition<MatrixType> m_hess;
|
250
|
+
ComputationInfo m_info;
|
251
|
+
bool m_isInitialized;
|
252
|
+
bool m_matUisUptodate;
|
253
|
+
Index m_maxIters;
|
254
|
+
|
255
|
+
private:
|
256
|
+
bool subdiagonalEntryIsNeglegible(Index i);
|
257
|
+
ComplexScalar computeShift(Index iu, Index iter);
|
258
|
+
void reduceToTriangularForm(bool computeU);
|
259
|
+
friend struct internal::complex_schur_reduce_to_hessenberg<MatrixType, NumTraits<Scalar>::IsComplex>;
|
260
|
+
};
|
261
|
+
|
262
|
+
/** If m_matT(i+1,i) is neglegible in floating point arithmetic
|
263
|
+
* compared to m_matT(i,i) and m_matT(j,j), then set it to zero and
|
264
|
+
* return true, else return false. */
|
265
|
+
template<typename MatrixType>
|
266
|
+
inline bool ComplexSchur<MatrixType>::subdiagonalEntryIsNeglegible(Index i)
|
267
|
+
{
|
268
|
+
RealScalar d = numext::norm1(m_matT.coeff(i,i)) + numext::norm1(m_matT.coeff(i+1,i+1));
|
269
|
+
RealScalar sd = numext::norm1(m_matT.coeff(i+1,i));
|
270
|
+
if (internal::isMuchSmallerThan(sd, d, NumTraits<RealScalar>::epsilon()))
|
271
|
+
{
|
272
|
+
m_matT.coeffRef(i+1,i) = ComplexScalar(0);
|
273
|
+
return true;
|
274
|
+
}
|
275
|
+
return false;
|
276
|
+
}
|
277
|
+
|
278
|
+
|
279
|
+
/** Compute the shift in the current QR iteration. */
|
280
|
+
template<typename MatrixType>
|
281
|
+
typename ComplexSchur<MatrixType>::ComplexScalar ComplexSchur<MatrixType>::computeShift(Index iu, Index iter)
|
282
|
+
{
|
283
|
+
using std::abs;
|
284
|
+
if (iter == 10 || iter == 20)
|
285
|
+
{
|
286
|
+
// exceptional shift, taken from http://www.netlib.org/eispack/comqr.f
|
287
|
+
return abs(numext::real(m_matT.coeff(iu,iu-1))) + abs(numext::real(m_matT.coeff(iu-1,iu-2)));
|
288
|
+
}
|
289
|
+
|
290
|
+
// compute the shift as one of the eigenvalues of t, the 2x2
|
291
|
+
// diagonal block on the bottom of the active submatrix
|
292
|
+
Matrix<ComplexScalar,2,2> t = m_matT.template block<2,2>(iu-1,iu-1);
|
293
|
+
RealScalar normt = t.cwiseAbs().sum();
|
294
|
+
t /= normt; // the normalization by sf is to avoid under/overflow
|
295
|
+
|
296
|
+
ComplexScalar b = t.coeff(0,1) * t.coeff(1,0);
|
297
|
+
ComplexScalar c = t.coeff(0,0) - t.coeff(1,1);
|
298
|
+
ComplexScalar disc = sqrt(c*c + RealScalar(4)*b);
|
299
|
+
ComplexScalar det = t.coeff(0,0) * t.coeff(1,1) - b;
|
300
|
+
ComplexScalar trace = t.coeff(0,0) + t.coeff(1,1);
|
301
|
+
ComplexScalar eival1 = (trace + disc) / RealScalar(2);
|
302
|
+
ComplexScalar eival2 = (trace - disc) / RealScalar(2);
|
303
|
+
|
304
|
+
if(numext::norm1(eival1) > numext::norm1(eival2))
|
305
|
+
eival2 = det / eival1;
|
306
|
+
else
|
307
|
+
eival1 = det / eival2;
|
308
|
+
|
309
|
+
// choose the eigenvalue closest to the bottom entry of the diagonal
|
310
|
+
if(numext::norm1(eival1-t.coeff(1,1)) < numext::norm1(eival2-t.coeff(1,1)))
|
311
|
+
return normt * eival1;
|
312
|
+
else
|
313
|
+
return normt * eival2;
|
314
|
+
}
|
315
|
+
|
316
|
+
|
317
|
+
template<typename MatrixType>
|
318
|
+
template<typename InputType>
|
319
|
+
ComplexSchur<MatrixType>& ComplexSchur<MatrixType>::compute(const EigenBase<InputType>& matrix, bool computeU)
|
320
|
+
{
|
321
|
+
m_matUisUptodate = false;
|
322
|
+
eigen_assert(matrix.cols() == matrix.rows());
|
323
|
+
|
324
|
+
if(matrix.cols() == 1)
|
325
|
+
{
|
326
|
+
m_matT = matrix.derived().template cast<ComplexScalar>();
|
327
|
+
if(computeU) m_matU = ComplexMatrixType::Identity(1,1);
|
328
|
+
m_info = Success;
|
329
|
+
m_isInitialized = true;
|
330
|
+
m_matUisUptodate = computeU;
|
331
|
+
return *this;
|
332
|
+
}
|
333
|
+
|
334
|
+
internal::complex_schur_reduce_to_hessenberg<MatrixType, NumTraits<Scalar>::IsComplex>::run(*this, matrix.derived(), computeU);
|
335
|
+
computeFromHessenberg(m_matT, m_matU, computeU);
|
336
|
+
return *this;
|
337
|
+
}
|
338
|
+
|
339
|
+
template<typename MatrixType>
|
340
|
+
template<typename HessMatrixType, typename OrthMatrixType>
|
341
|
+
ComplexSchur<MatrixType>& ComplexSchur<MatrixType>::computeFromHessenberg(const HessMatrixType& matrixH, const OrthMatrixType& matrixQ, bool computeU)
|
342
|
+
{
|
343
|
+
m_matT = matrixH;
|
344
|
+
if(computeU)
|
345
|
+
m_matU = matrixQ;
|
346
|
+
reduceToTriangularForm(computeU);
|
347
|
+
return *this;
|
348
|
+
}
|
349
|
+
namespace internal {
|
350
|
+
|
351
|
+
/* Reduce given matrix to Hessenberg form */
|
352
|
+
template<typename MatrixType, bool IsComplex>
|
353
|
+
struct complex_schur_reduce_to_hessenberg
|
354
|
+
{
|
355
|
+
// this is the implementation for the case IsComplex = true
|
356
|
+
static void run(ComplexSchur<MatrixType>& _this, const MatrixType& matrix, bool computeU)
|
357
|
+
{
|
358
|
+
_this.m_hess.compute(matrix);
|
359
|
+
_this.m_matT = _this.m_hess.matrixH();
|
360
|
+
if(computeU) _this.m_matU = _this.m_hess.matrixQ();
|
361
|
+
}
|
362
|
+
};
|
363
|
+
|
364
|
+
template<typename MatrixType>
|
365
|
+
struct complex_schur_reduce_to_hessenberg<MatrixType, false>
|
366
|
+
{
|
367
|
+
static void run(ComplexSchur<MatrixType>& _this, const MatrixType& matrix, bool computeU)
|
368
|
+
{
|
369
|
+
typedef typename ComplexSchur<MatrixType>::ComplexScalar ComplexScalar;
|
370
|
+
|
371
|
+
// Note: m_hess is over RealScalar; m_matT and m_matU is over ComplexScalar
|
372
|
+
_this.m_hess.compute(matrix);
|
373
|
+
_this.m_matT = _this.m_hess.matrixH().template cast<ComplexScalar>();
|
374
|
+
if(computeU)
|
375
|
+
{
|
376
|
+
// This may cause an allocation which seems to be avoidable
|
377
|
+
MatrixType Q = _this.m_hess.matrixQ();
|
378
|
+
_this.m_matU = Q.template cast<ComplexScalar>();
|
379
|
+
}
|
380
|
+
}
|
381
|
+
};
|
382
|
+
|
383
|
+
} // end namespace internal
|
384
|
+
|
385
|
+
// Reduce the Hessenberg matrix m_matT to triangular form by QR iteration.
|
386
|
+
template<typename MatrixType>
|
387
|
+
void ComplexSchur<MatrixType>::reduceToTriangularForm(bool computeU)
|
388
|
+
{
|
389
|
+
Index maxIters = m_maxIters;
|
390
|
+
if (maxIters == -1)
|
391
|
+
maxIters = m_maxIterationsPerRow * m_matT.rows();
|
392
|
+
|
393
|
+
// The matrix m_matT is divided in three parts.
|
394
|
+
// Rows 0,...,il-1 are decoupled from the rest because m_matT(il,il-1) is zero.
|
395
|
+
// Rows il,...,iu is the part we are working on (the active submatrix).
|
396
|
+
// Rows iu+1,...,end are already brought in triangular form.
|
397
|
+
Index iu = m_matT.cols() - 1;
|
398
|
+
Index il;
|
399
|
+
Index iter = 0; // number of iterations we are working on the (iu,iu) element
|
400
|
+
Index totalIter = 0; // number of iterations for whole matrix
|
401
|
+
|
402
|
+
while(true)
|
403
|
+
{
|
404
|
+
// find iu, the bottom row of the active submatrix
|
405
|
+
while(iu > 0)
|
406
|
+
{
|
407
|
+
if(!subdiagonalEntryIsNeglegible(iu-1)) break;
|
408
|
+
iter = 0;
|
409
|
+
--iu;
|
410
|
+
}
|
411
|
+
|
412
|
+
// if iu is zero then we are done; the whole matrix is triangularized
|
413
|
+
if(iu==0) break;
|
414
|
+
|
415
|
+
// if we spent too many iterations, we give up
|
416
|
+
iter++;
|
417
|
+
totalIter++;
|
418
|
+
if(totalIter > maxIters) break;
|
419
|
+
|
420
|
+
// find il, the top row of the active submatrix
|
421
|
+
il = iu-1;
|
422
|
+
while(il > 0 && !subdiagonalEntryIsNeglegible(il-1))
|
423
|
+
{
|
424
|
+
--il;
|
425
|
+
}
|
426
|
+
|
427
|
+
/* perform the QR step using Givens rotations. The first rotation
|
428
|
+
creates a bulge; the (il+2,il) element becomes nonzero. This
|
429
|
+
bulge is chased down to the bottom of the active submatrix. */
|
430
|
+
|
431
|
+
ComplexScalar shift = computeShift(iu, iter);
|
432
|
+
JacobiRotation<ComplexScalar> rot;
|
433
|
+
rot.makeGivens(m_matT.coeff(il,il) - shift, m_matT.coeff(il+1,il));
|
434
|
+
m_matT.rightCols(m_matT.cols()-il).applyOnTheLeft(il, il+1, rot.adjoint());
|
435
|
+
m_matT.topRows((std::min)(il+2,iu)+1).applyOnTheRight(il, il+1, rot);
|
436
|
+
if(computeU) m_matU.applyOnTheRight(il, il+1, rot);
|
437
|
+
|
438
|
+
for(Index i=il+1 ; i<iu ; i++)
|
439
|
+
{
|
440
|
+
rot.makeGivens(m_matT.coeffRef(i,i-1), m_matT.coeffRef(i+1,i-1), &m_matT.coeffRef(i,i-1));
|
441
|
+
m_matT.coeffRef(i+1,i-1) = ComplexScalar(0);
|
442
|
+
m_matT.rightCols(m_matT.cols()-i).applyOnTheLeft(i, i+1, rot.adjoint());
|
443
|
+
m_matT.topRows((std::min)(i+2,iu)+1).applyOnTheRight(i, i+1, rot);
|
444
|
+
if(computeU) m_matU.applyOnTheRight(i, i+1, rot);
|
445
|
+
}
|
446
|
+
}
|
447
|
+
|
448
|
+
if(totalIter <= maxIters)
|
449
|
+
m_info = Success;
|
450
|
+
else
|
451
|
+
m_info = NoConvergence;
|
452
|
+
|
453
|
+
m_isInitialized = true;
|
454
|
+
m_matUisUptodate = computeU;
|
455
|
+
}
|
456
|
+
|
457
|
+
} // end namespace Eigen
|
458
|
+
|
459
|
+
#endif // EIGEN_COMPLEX_SCHUR_H
|