@smake/eigen 1.0.2 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/eigen/Eigen/AccelerateSupport +52 -0
- package/eigen/Eigen/Cholesky +18 -21
- package/eigen/Eigen/CholmodSupport +28 -28
- package/eigen/Eigen/Core +235 -326
- package/eigen/Eigen/Eigenvalues +16 -14
- package/eigen/Eigen/Geometry +21 -24
- package/eigen/Eigen/Householder +9 -8
- package/eigen/Eigen/IterativeLinearSolvers +8 -4
- package/eigen/Eigen/Jacobi +14 -14
- package/eigen/Eigen/KLUSupport +43 -0
- package/eigen/Eigen/LU +16 -20
- package/eigen/Eigen/MetisSupport +12 -12
- package/eigen/Eigen/OrderingMethods +54 -54
- package/eigen/Eigen/PaStiXSupport +23 -20
- package/eigen/Eigen/PardisoSupport +17 -14
- package/eigen/Eigen/QR +18 -21
- package/eigen/Eigen/QtAlignedMalloc +5 -13
- package/eigen/Eigen/SPQRSupport +21 -14
- package/eigen/Eigen/SVD +23 -18
- package/eigen/Eigen/Sparse +1 -4
- package/eigen/Eigen/SparseCholesky +18 -23
- package/eigen/Eigen/SparseCore +18 -17
- package/eigen/Eigen/SparseLU +12 -8
- package/eigen/Eigen/SparseQR +16 -14
- package/eigen/Eigen/StdDeque +5 -2
- package/eigen/Eigen/StdList +5 -2
- package/eigen/Eigen/StdVector +5 -2
- package/eigen/Eigen/SuperLUSupport +30 -24
- package/eigen/Eigen/ThreadPool +80 -0
- package/eigen/Eigen/UmfPackSupport +19 -17
- package/eigen/Eigen/Version +14 -0
- package/eigen/Eigen/src/AccelerateSupport/AccelerateSupport.h +423 -0
- package/eigen/Eigen/src/AccelerateSupport/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/Cholesky/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/Cholesky/LDLT.h +377 -401
- package/eigen/Eigen/src/Cholesky/LLT.h +332 -360
- package/eigen/Eigen/src/Cholesky/LLT_LAPACKE.h +81 -56
- package/eigen/Eigen/src/CholmodSupport/CholmodSupport.h +620 -521
- package/eigen/Eigen/src/CholmodSupport/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/Core/ArithmeticSequence.h +239 -0
- package/eigen/Eigen/src/Core/Array.h +341 -294
- package/eigen/Eigen/src/Core/ArrayBase.h +190 -203
- package/eigen/Eigen/src/Core/ArrayWrapper.h +127 -171
- package/eigen/Eigen/src/Core/Assign.h +30 -40
- package/eigen/Eigen/src/Core/AssignEvaluator.h +711 -589
- package/eigen/Eigen/src/Core/Assign_MKL.h +130 -125
- package/eigen/Eigen/src/Core/BandMatrix.h +268 -283
- package/eigen/Eigen/src/Core/Block.h +375 -398
- package/eigen/Eigen/src/Core/CommaInitializer.h +86 -97
- package/eigen/Eigen/src/Core/ConditionEstimator.h +51 -53
- package/eigen/Eigen/src/Core/CoreEvaluators.h +1356 -1026
- package/eigen/Eigen/src/Core/CoreIterators.h +73 -59
- package/eigen/Eigen/src/Core/CwiseBinaryOp.h +114 -132
- package/eigen/Eigen/src/Core/CwiseNullaryOp.h +726 -617
- package/eigen/Eigen/src/Core/CwiseTernaryOp.h +77 -103
- package/eigen/Eigen/src/Core/CwiseUnaryOp.h +56 -68
- package/eigen/Eigen/src/Core/CwiseUnaryView.h +132 -95
- package/eigen/Eigen/src/Core/DenseBase.h +632 -571
- package/eigen/Eigen/src/Core/DenseCoeffsBase.h +511 -624
- package/eigen/Eigen/src/Core/DenseStorage.h +512 -509
- package/eigen/Eigen/src/Core/DeviceWrapper.h +153 -0
- package/eigen/Eigen/src/Core/Diagonal.h +169 -210
- package/eigen/Eigen/src/Core/DiagonalMatrix.h +351 -274
- package/eigen/Eigen/src/Core/DiagonalProduct.h +12 -10
- package/eigen/Eigen/src/Core/Dot.h +172 -222
- package/eigen/Eigen/src/Core/EigenBase.h +75 -85
- package/eigen/Eigen/src/Core/Fill.h +138 -0
- package/eigen/Eigen/src/Core/FindCoeff.h +464 -0
- package/eigen/Eigen/src/Core/ForceAlignedAccess.h +90 -109
- package/eigen/Eigen/src/Core/Fuzzy.h +82 -105
- package/eigen/Eigen/src/Core/GeneralProduct.h +327 -263
- package/eigen/Eigen/src/Core/GenericPacketMath.h +1472 -360
- package/eigen/Eigen/src/Core/GlobalFunctions.h +194 -151
- package/eigen/Eigen/src/Core/IO.h +147 -139
- package/eigen/Eigen/src/Core/IndexedView.h +321 -0
- package/eigen/Eigen/src/Core/InnerProduct.h +260 -0
- package/eigen/Eigen/src/Core/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/Core/Inverse.h +56 -66
- package/eigen/Eigen/src/Core/Map.h +124 -142
- package/eigen/Eigen/src/Core/MapBase.h +256 -281
- package/eigen/Eigen/src/Core/MathFunctions.h +1620 -938
- package/eigen/Eigen/src/Core/MathFunctionsImpl.h +233 -71
- package/eigen/Eigen/src/Core/Matrix.h +491 -416
- package/eigen/Eigen/src/Core/MatrixBase.h +468 -453
- package/eigen/Eigen/src/Core/NestByValue.h +66 -85
- package/eigen/Eigen/src/Core/NoAlias.h +79 -85
- package/eigen/Eigen/src/Core/NumTraits.h +235 -148
- package/eigen/Eigen/src/Core/PartialReduxEvaluator.h +253 -0
- package/eigen/Eigen/src/Core/PermutationMatrix.h +461 -511
- package/eigen/Eigen/src/Core/PlainObjectBase.h +871 -894
- package/eigen/Eigen/src/Core/Product.h +260 -139
- package/eigen/Eigen/src/Core/ProductEvaluators.h +863 -714
- package/eigen/Eigen/src/Core/Random.h +161 -136
- package/eigen/Eigen/src/Core/RandomImpl.h +262 -0
- package/eigen/Eigen/src/Core/RealView.h +250 -0
- package/eigen/Eigen/src/Core/Redux.h +366 -336
- package/eigen/Eigen/src/Core/Ref.h +308 -209
- package/eigen/Eigen/src/Core/Replicate.h +94 -106
- package/eigen/Eigen/src/Core/Reshaped.h +398 -0
- package/eigen/Eigen/src/Core/ReturnByValue.h +49 -55
- package/eigen/Eigen/src/Core/Reverse.h +136 -145
- package/eigen/Eigen/src/Core/Select.h +70 -140
- package/eigen/Eigen/src/Core/SelfAdjointView.h +262 -285
- package/eigen/Eigen/src/Core/SelfCwiseBinaryOp.h +23 -20
- package/eigen/Eigen/src/Core/SkewSymmetricMatrix3.h +382 -0
- package/eigen/Eigen/src/Core/Solve.h +97 -111
- package/eigen/Eigen/src/Core/SolveTriangular.h +131 -129
- package/eigen/Eigen/src/Core/SolverBase.h +138 -101
- package/eigen/Eigen/src/Core/StableNorm.h +156 -160
- package/eigen/Eigen/src/Core/StlIterators.h +619 -0
- package/eigen/Eigen/src/Core/Stride.h +91 -88
- package/eigen/Eigen/src/Core/Swap.h +70 -38
- package/eigen/Eigen/src/Core/Transpose.h +295 -273
- package/eigen/Eigen/src/Core/Transpositions.h +272 -317
- package/eigen/Eigen/src/Core/TriangularMatrix.h +670 -755
- package/eigen/Eigen/src/Core/VectorBlock.h +59 -72
- package/eigen/Eigen/src/Core/VectorwiseOp.h +668 -630
- package/eigen/Eigen/src/Core/Visitor.h +480 -216
- package/eigen/Eigen/src/Core/arch/AVX/Complex.h +407 -293
- package/eigen/Eigen/src/Core/arch/AVX/MathFunctions.h +79 -388
- package/eigen/Eigen/src/Core/arch/AVX/PacketMath.h +2935 -491
- package/eigen/Eigen/src/Core/arch/AVX/Reductions.h +353 -0
- package/eigen/Eigen/src/Core/arch/AVX/TypeCasting.h +279 -22
- package/eigen/Eigen/src/Core/arch/AVX512/Complex.h +472 -0
- package/eigen/Eigen/src/Core/arch/AVX512/GemmKernel.h +1245 -0
- package/eigen/Eigen/src/Core/arch/AVX512/MathFunctions.h +85 -333
- package/eigen/Eigen/src/Core/arch/AVX512/MathFunctionsFP16.h +75 -0
- package/eigen/Eigen/src/Core/arch/AVX512/PacketMath.h +2490 -649
- package/eigen/Eigen/src/Core/arch/AVX512/PacketMathFP16.h +1413 -0
- package/eigen/Eigen/src/Core/arch/AVX512/Reductions.h +297 -0
- package/eigen/Eigen/src/Core/arch/AVX512/TrsmKernel.h +1167 -0
- package/eigen/Eigen/src/Core/arch/AVX512/TrsmUnrolls.inc +1219 -0
- package/eigen/Eigen/src/Core/arch/AVX512/TypeCasting.h +277 -0
- package/eigen/Eigen/src/Core/arch/AVX512/TypeCastingFP16.h +130 -0
- package/eigen/Eigen/src/Core/arch/AltiVec/Complex.h +521 -298
- package/eigen/Eigen/src/Core/arch/AltiVec/MathFunctions.h +39 -280
- package/eigen/Eigen/src/Core/arch/AltiVec/MatrixProduct.h +3686 -0
- package/eigen/Eigen/src/Core/arch/AltiVec/MatrixProductCommon.h +205 -0
- package/eigen/Eigen/src/Core/arch/AltiVec/MatrixProductMMA.h +901 -0
- package/eigen/Eigen/src/Core/arch/AltiVec/MatrixProductMMAbfloat16.h +742 -0
- package/eigen/Eigen/src/Core/arch/AltiVec/MatrixVectorProduct.inc +2818 -0
- package/eigen/Eigen/src/Core/arch/AltiVec/PacketMath.h +3391 -723
- package/eigen/Eigen/src/Core/arch/AltiVec/TypeCasting.h +153 -0
- package/eigen/Eigen/src/Core/arch/Default/BFloat16.h +866 -0
- package/eigen/Eigen/src/Core/arch/Default/ConjHelper.h +113 -14
- package/eigen/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h +2634 -0
- package/eigen/Eigen/src/Core/arch/Default/GenericPacketMathFunctionsFwd.h +227 -0
- package/eigen/Eigen/src/Core/arch/Default/Half.h +1091 -0
- package/eigen/Eigen/src/Core/arch/Default/Settings.h +11 -13
- package/eigen/Eigen/src/Core/arch/GPU/Complex.h +244 -0
- package/eigen/Eigen/src/Core/arch/GPU/MathFunctions.h +104 -0
- package/eigen/Eigen/src/Core/arch/GPU/PacketMath.h +1712 -0
- package/eigen/Eigen/src/Core/arch/GPU/Tuple.h +268 -0
- package/eigen/Eigen/src/Core/arch/GPU/TypeCasting.h +77 -0
- package/eigen/Eigen/src/Core/arch/HIP/hcc/math_constants.h +23 -0
- package/eigen/Eigen/src/Core/arch/HVX/PacketMath.h +1088 -0
- package/eigen/Eigen/src/Core/arch/LSX/Complex.h +520 -0
- package/eigen/Eigen/src/Core/arch/LSX/GeneralBlockPanelKernel.h +23 -0
- package/eigen/Eigen/src/Core/arch/LSX/MathFunctions.h +43 -0
- package/eigen/Eigen/src/Core/arch/LSX/PacketMath.h +2866 -0
- package/eigen/Eigen/src/Core/arch/LSX/TypeCasting.h +526 -0
- package/eigen/Eigen/src/Core/arch/MSA/Complex.h +620 -0
- package/eigen/Eigen/src/Core/arch/MSA/MathFunctions.h +379 -0
- package/eigen/Eigen/src/Core/arch/MSA/PacketMath.h +1237 -0
- package/eigen/Eigen/src/Core/arch/NEON/Complex.h +531 -289
- package/eigen/Eigen/src/Core/arch/NEON/GeneralBlockPanelKernel.h +243 -0
- package/eigen/Eigen/src/Core/arch/NEON/MathFunctions.h +50 -73
- package/eigen/Eigen/src/Core/arch/NEON/PacketMath.h +5915 -579
- package/eigen/Eigen/src/Core/arch/NEON/TypeCasting.h +1642 -0
- package/eigen/Eigen/src/Core/arch/NEON/UnaryFunctors.h +57 -0
- package/eigen/Eigen/src/Core/arch/SSE/Complex.h +366 -334
- package/eigen/Eigen/src/Core/arch/SSE/MathFunctions.h +40 -514
- package/eigen/Eigen/src/Core/arch/SSE/PacketMath.h +2164 -675
- package/eigen/Eigen/src/Core/arch/SSE/Reductions.h +324 -0
- package/eigen/Eigen/src/Core/arch/SSE/TypeCasting.h +188 -35
- package/eigen/Eigen/src/Core/arch/SVE/MathFunctions.h +48 -0
- package/eigen/Eigen/src/Core/arch/SVE/PacketMath.h +674 -0
- package/eigen/Eigen/src/Core/arch/SVE/TypeCasting.h +52 -0
- package/eigen/Eigen/src/Core/arch/SYCL/InteropHeaders.h +227 -0
- package/eigen/Eigen/src/Core/arch/SYCL/MathFunctions.h +303 -0
- package/eigen/Eigen/src/Core/arch/SYCL/PacketMath.h +576 -0
- package/eigen/Eigen/src/Core/arch/SYCL/TypeCasting.h +83 -0
- package/eigen/Eigen/src/Core/arch/ZVector/Complex.h +434 -261
- package/eigen/Eigen/src/Core/arch/ZVector/MathFunctions.h +160 -53
- package/eigen/Eigen/src/Core/arch/ZVector/PacketMath.h +1073 -605
- package/eigen/Eigen/src/Core/functors/AssignmentFunctors.h +123 -117
- package/eigen/Eigen/src/Core/functors/BinaryFunctors.h +594 -322
- package/eigen/Eigen/src/Core/functors/NullaryFunctors.h +204 -118
- package/eigen/Eigen/src/Core/functors/StlFunctors.h +110 -97
- package/eigen/Eigen/src/Core/functors/TernaryFunctors.h +34 -7
- package/eigen/Eigen/src/Core/functors/UnaryFunctors.h +1158 -530
- package/eigen/Eigen/src/Core/products/GeneralBlockPanelKernel.h +2329 -1333
- package/eigen/Eigen/src/Core/products/GeneralMatrixMatrix.h +328 -364
- package/eigen/Eigen/src/Core/products/GeneralMatrixMatrixTriangular.h +191 -178
- package/eigen/Eigen/src/Core/products/GeneralMatrixMatrixTriangular_BLAS.h +85 -82
- package/eigen/Eigen/src/Core/products/GeneralMatrixMatrix_BLAS.h +154 -73
- package/eigen/Eigen/src/Core/products/GeneralMatrixVector.h +396 -542
- package/eigen/Eigen/src/Core/products/GeneralMatrixVector_BLAS.h +80 -77
- package/eigen/Eigen/src/Core/products/Parallelizer.h +208 -92
- package/eigen/Eigen/src/Core/products/SelfadjointMatrixMatrix.h +331 -375
- package/eigen/Eigen/src/Core/products/SelfadjointMatrixMatrix_BLAS.h +206 -224
- package/eigen/Eigen/src/Core/products/SelfadjointMatrixVector.h +139 -146
- package/eigen/Eigen/src/Core/products/SelfadjointMatrixVector_BLAS.h +58 -61
- package/eigen/Eigen/src/Core/products/SelfadjointProduct.h +71 -71
- package/eigen/Eigen/src/Core/products/SelfadjointRank2Update.h +48 -46
- package/eigen/Eigen/src/Core/products/TriangularMatrixMatrix.h +294 -369
- package/eigen/Eigen/src/Core/products/TriangularMatrixMatrix_BLAS.h +246 -238
- package/eigen/Eigen/src/Core/products/TriangularMatrixVector.h +244 -247
- package/eigen/Eigen/src/Core/products/TriangularMatrixVector_BLAS.h +212 -192
- package/eigen/Eigen/src/Core/products/TriangularSolverMatrix.h +328 -275
- package/eigen/Eigen/src/Core/products/TriangularSolverMatrix_BLAS.h +108 -109
- package/eigen/Eigen/src/Core/products/TriangularSolverVector.h +70 -93
- package/eigen/Eigen/src/Core/util/Assert.h +158 -0
- package/eigen/Eigen/src/Core/util/BlasUtil.h +413 -290
- package/eigen/Eigen/src/Core/util/ConfigureVectorization.h +543 -0
- package/eigen/Eigen/src/Core/util/Constants.h +314 -263
- package/eigen/Eigen/src/Core/util/DisableStupidWarnings.h +130 -78
- package/eigen/Eigen/src/Core/util/EmulateArray.h +270 -0
- package/eigen/Eigen/src/Core/util/ForwardDeclarations.h +450 -224
- package/eigen/Eigen/src/Core/util/GpuHipCudaDefines.inc +101 -0
- package/eigen/Eigen/src/Core/util/GpuHipCudaUndefines.inc +45 -0
- package/eigen/Eigen/src/Core/util/IndexedViewHelper.h +487 -0
- package/eigen/Eigen/src/Core/util/IntegralConstant.h +279 -0
- package/eigen/Eigen/src/Core/util/MKL_support.h +39 -30
- package/eigen/Eigen/src/Core/util/Macros.h +939 -646
- package/eigen/Eigen/src/Core/util/MaxSizeVector.h +139 -0
- package/eigen/Eigen/src/Core/util/Memory.h +1042 -650
- package/eigen/Eigen/src/Core/util/Meta.h +618 -426
- package/eigen/Eigen/src/Core/util/MoreMeta.h +638 -0
- package/eigen/Eigen/src/Core/util/ReenableStupidWarnings.h +32 -19
- package/eigen/Eigen/src/Core/util/ReshapedHelper.h +51 -0
- package/eigen/Eigen/src/Core/util/Serializer.h +209 -0
- package/eigen/Eigen/src/Core/util/StaticAssert.h +51 -164
- package/eigen/Eigen/src/Core/util/SymbolicIndex.h +445 -0
- package/eigen/Eigen/src/Core/util/XprHelper.h +793 -538
- package/eigen/Eigen/src/Eigenvalues/ComplexEigenSolver.h +246 -277
- package/eigen/Eigen/src/Eigenvalues/ComplexSchur.h +299 -319
- package/eigen/Eigen/src/Eigenvalues/ComplexSchur_LAPACKE.h +52 -48
- package/eigen/Eigen/src/Eigenvalues/EigenSolver.h +413 -456
- package/eigen/Eigen/src/Eigenvalues/GeneralizedEigenSolver.h +309 -325
- package/eigen/Eigen/src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h +157 -171
- package/eigen/Eigen/src/Eigenvalues/HessenbergDecomposition.h +292 -310
- package/eigen/Eigen/src/Eigenvalues/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/Eigenvalues/MatrixBaseEigenvalues.h +91 -107
- package/eigen/Eigen/src/Eigenvalues/RealQZ.h +539 -606
- package/eigen/Eigen/src/Eigenvalues/RealSchur.h +348 -382
- package/eigen/Eigen/src/Eigenvalues/RealSchur_LAPACKE.h +41 -35
- package/eigen/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h +579 -600
- package/eigen/Eigen/src/Eigenvalues/SelfAdjointEigenSolver_LAPACKE.h +47 -44
- package/eigen/Eigen/src/Eigenvalues/Tridiagonalization.h +434 -461
- package/eigen/Eigen/src/Geometry/AlignedBox.h +307 -214
- package/eigen/Eigen/src/Geometry/AngleAxis.h +135 -137
- package/eigen/Eigen/src/Geometry/EulerAngles.h +163 -74
- package/eigen/Eigen/src/Geometry/Homogeneous.h +289 -333
- package/eigen/Eigen/src/Geometry/Hyperplane.h +152 -161
- package/eigen/Eigen/src/Geometry/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/Geometry/OrthoMethods.h +168 -145
- package/eigen/Eigen/src/Geometry/ParametrizedLine.h +141 -104
- package/eigen/Eigen/src/Geometry/Quaternion.h +595 -497
- package/eigen/Eigen/src/Geometry/Rotation2D.h +110 -108
- package/eigen/Eigen/src/Geometry/RotationBase.h +148 -145
- package/eigen/Eigen/src/Geometry/Scaling.h +115 -90
- package/eigen/Eigen/src/Geometry/Transform.h +896 -953
- package/eigen/Eigen/src/Geometry/Translation.h +100 -98
- package/eigen/Eigen/src/Geometry/Umeyama.h +79 -84
- package/eigen/Eigen/src/Geometry/arch/Geometry_SIMD.h +154 -0
- package/eigen/Eigen/src/Householder/BlockHouseholder.h +54 -42
- package/eigen/Eigen/src/Householder/Householder.h +104 -122
- package/eigen/Eigen/src/Householder/HouseholderSequence.h +416 -382
- package/eigen/Eigen/src/Householder/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/IterativeLinearSolvers/BasicPreconditioners.h +153 -166
- package/eigen/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h +127 -138
- package/eigen/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h +95 -124
- package/eigen/Eigen/src/IterativeLinearSolvers/IncompleteCholesky.h +269 -267
- package/eigen/Eigen/src/IterativeLinearSolvers/IncompleteLUT.h +246 -259
- package/eigen/Eigen/src/IterativeLinearSolvers/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/IterativeLinearSolvers/IterativeSolverBase.h +218 -217
- package/eigen/Eigen/src/IterativeLinearSolvers/LeastSquareConjugateGradient.h +80 -103
- package/eigen/Eigen/src/IterativeLinearSolvers/SolveWithGuess.h +59 -63
- package/eigen/Eigen/src/Jacobi/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/Jacobi/Jacobi.h +256 -291
- package/eigen/Eigen/src/KLUSupport/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/KLUSupport/KLUSupport.h +339 -0
- package/eigen/Eigen/src/LU/Determinant.h +60 -63
- package/eigen/Eigen/src/LU/FullPivLU.h +561 -626
- package/eigen/Eigen/src/LU/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/LU/InverseImpl.h +213 -275
- package/eigen/Eigen/src/LU/PartialPivLU.h +407 -435
- package/eigen/Eigen/src/LU/PartialPivLU_LAPACKE.h +54 -40
- package/eigen/Eigen/src/LU/arch/InverseSize4.h +353 -0
- package/eigen/Eigen/src/MetisSupport/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/MetisSupport/MetisSupport.h +81 -93
- package/eigen/Eigen/src/OrderingMethods/Amd.h +250 -282
- package/eigen/Eigen/src/OrderingMethods/Eigen_Colamd.h +950 -1103
- package/eigen/Eigen/src/OrderingMethods/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/OrderingMethods/Ordering.h +111 -122
- package/eigen/Eigen/src/PaStiXSupport/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/PaStiXSupport/PaStiXSupport.h +524 -570
- package/eigen/Eigen/src/PardisoSupport/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/PardisoSupport/PardisoSupport.h +385 -429
- package/eigen/Eigen/src/QR/ColPivHouseholderQR.h +494 -473
- package/eigen/Eigen/src/QR/ColPivHouseholderQR_LAPACKE.h +120 -56
- package/eigen/Eigen/src/QR/CompleteOrthogonalDecomposition.h +223 -137
- package/eigen/Eigen/src/QR/FullPivHouseholderQR.h +517 -460
- package/eigen/Eigen/src/QR/HouseholderQR.h +412 -278
- package/eigen/Eigen/src/QR/HouseholderQR_LAPACKE.h +32 -23
- package/eigen/Eigen/src/QR/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/SPQRSupport/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/SPQRSupport/SuiteSparseQRSupport.h +263 -261
- package/eigen/Eigen/src/SVD/BDCSVD.h +872 -679
- package/eigen/Eigen/src/SVD/BDCSVD_LAPACKE.h +174 -0
- package/eigen/Eigen/src/SVD/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/SVD/JacobiSVD.h +585 -543
- package/eigen/Eigen/src/SVD/JacobiSVD_LAPACKE.h +85 -49
- package/eigen/Eigen/src/SVD/SVDBase.h +281 -160
- package/eigen/Eigen/src/SVD/UpperBidiagonalization.h +202 -237
- package/eigen/Eigen/src/SparseCholesky/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/SparseCholesky/SimplicialCholesky.h +769 -590
- package/eigen/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h +318 -129
- package/eigen/Eigen/src/SparseCore/AmbiVector.h +202 -251
- package/eigen/Eigen/src/SparseCore/CompressedStorage.h +184 -236
- package/eigen/Eigen/src/SparseCore/ConservativeSparseSparseProduct.h +140 -184
- package/eigen/Eigen/src/SparseCore/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/SparseCore/SparseAssign.h +174 -111
- package/eigen/Eigen/src/SparseCore/SparseBlock.h +408 -477
- package/eigen/Eigen/src/SparseCore/SparseColEtree.h +100 -112
- package/eigen/Eigen/src/SparseCore/SparseCompressedBase.h +531 -280
- package/eigen/Eigen/src/SparseCore/SparseCwiseBinaryOp.h +559 -347
- package/eigen/Eigen/src/SparseCore/SparseCwiseUnaryOp.h +100 -108
- package/eigen/Eigen/src/SparseCore/SparseDenseProduct.h +185 -191
- package/eigen/Eigen/src/SparseCore/SparseDiagonalProduct.h +71 -71
- package/eigen/Eigen/src/SparseCore/SparseDot.h +49 -47
- package/eigen/Eigen/src/SparseCore/SparseFuzzy.h +13 -11
- package/eigen/Eigen/src/SparseCore/SparseMap.h +243 -253
- package/eigen/Eigen/src/SparseCore/SparseMatrix.h +1614 -1142
- package/eigen/Eigen/src/SparseCore/SparseMatrixBase.h +403 -357
- package/eigen/Eigen/src/SparseCore/SparsePermutation.h +186 -115
- package/eigen/Eigen/src/SparseCore/SparseProduct.h +100 -91
- package/eigen/Eigen/src/SparseCore/SparseRedux.h +22 -24
- package/eigen/Eigen/src/SparseCore/SparseRef.h +268 -295
- package/eigen/Eigen/src/SparseCore/SparseSelfAdjointView.h +371 -414
- package/eigen/Eigen/src/SparseCore/SparseSolverBase.h +78 -87
- package/eigen/Eigen/src/SparseCore/SparseSparseProductWithPruning.h +81 -95
- package/eigen/Eigen/src/SparseCore/SparseTranspose.h +62 -71
- package/eigen/Eigen/src/SparseCore/SparseTriangularView.h +132 -144
- package/eigen/Eigen/src/SparseCore/SparseUtil.h +146 -115
- package/eigen/Eigen/src/SparseCore/SparseVector.h +426 -372
- package/eigen/Eigen/src/SparseCore/SparseView.h +164 -193
- package/eigen/Eigen/src/SparseCore/TriangularSolver.h +129 -170
- package/eigen/Eigen/src/SparseLU/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/SparseLU/SparseLU.h +814 -618
- package/eigen/Eigen/src/SparseLU/SparseLUImpl.h +61 -48
- package/eigen/Eigen/src/SparseLU/SparseLU_Memory.h +102 -118
- package/eigen/Eigen/src/SparseLU/SparseLU_Structs.h +38 -35
- package/eigen/Eigen/src/SparseLU/SparseLU_SupernodalMatrix.h +273 -255
- package/eigen/Eigen/src/SparseLU/SparseLU_Utils.h +44 -49
- package/eigen/Eigen/src/SparseLU/SparseLU_column_bmod.h +104 -108
- package/eigen/Eigen/src/SparseLU/SparseLU_column_dfs.h +90 -101
- package/eigen/Eigen/src/SparseLU/SparseLU_copy_to_ucol.h +57 -58
- package/eigen/Eigen/src/SparseLU/SparseLU_heap_relax_snode.h +43 -55
- package/eigen/Eigen/src/SparseLU/SparseLU_kernel_bmod.h +74 -71
- package/eigen/Eigen/src/SparseLU/SparseLU_panel_bmod.h +125 -133
- package/eigen/Eigen/src/SparseLU/SparseLU_panel_dfs.h +136 -159
- package/eigen/Eigen/src/SparseLU/SparseLU_pivotL.h +51 -52
- package/eigen/Eigen/src/SparseLU/SparseLU_pruneL.h +67 -73
- package/eigen/Eigen/src/SparseLU/SparseLU_relax_snode.h +24 -26
- package/eigen/Eigen/src/SparseQR/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/SparseQR/SparseQR.h +451 -490
- package/eigen/Eigen/src/StlSupport/StdDeque.h +28 -105
- package/eigen/Eigen/src/StlSupport/StdList.h +28 -84
- package/eigen/Eigen/src/StlSupport/StdVector.h +28 -108
- package/eigen/Eigen/src/StlSupport/details.h +48 -50
- package/eigen/Eigen/src/SuperLUSupport/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/SuperLUSupport/SuperLUSupport.h +634 -732
- package/eigen/Eigen/src/ThreadPool/Barrier.h +70 -0
- package/eigen/Eigen/src/ThreadPool/CoreThreadPoolDevice.h +336 -0
- package/eigen/Eigen/src/ThreadPool/EventCount.h +241 -0
- package/eigen/Eigen/src/ThreadPool/ForkJoin.h +140 -0
- package/eigen/Eigen/src/ThreadPool/InternalHeaderCheck.h +4 -0
- package/eigen/Eigen/src/ThreadPool/NonBlockingThreadPool.h +587 -0
- package/eigen/Eigen/src/ThreadPool/RunQueue.h +230 -0
- package/eigen/Eigen/src/ThreadPool/ThreadCancel.h +21 -0
- package/eigen/Eigen/src/ThreadPool/ThreadEnvironment.h +43 -0
- package/eigen/Eigen/src/ThreadPool/ThreadLocal.h +289 -0
- package/eigen/Eigen/src/ThreadPool/ThreadPoolInterface.h +50 -0
- package/eigen/Eigen/src/ThreadPool/ThreadYield.h +16 -0
- package/eigen/Eigen/src/UmfPackSupport/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/UmfPackSupport/UmfPackSupport.h +480 -380
- package/eigen/Eigen/src/misc/Image.h +41 -43
- package/eigen/Eigen/src/misc/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/misc/Kernel.h +39 -41
- package/eigen/Eigen/src/misc/RealSvd2x2.h +19 -21
- package/eigen/Eigen/src/misc/blas.h +83 -426
- package/eigen/Eigen/src/misc/lapacke.h +9976 -16182
- package/eigen/Eigen/src/misc/lapacke_helpers.h +163 -0
- package/eigen/Eigen/src/misc/lapacke_mangling.h +4 -5
- package/eigen/Eigen/src/plugins/ArrayCwiseBinaryOps.inc +344 -0
- package/eigen/Eigen/src/plugins/ArrayCwiseUnaryOps.inc +544 -0
- package/eigen/Eigen/src/plugins/BlockMethods.inc +1370 -0
- package/eigen/Eigen/src/plugins/CommonCwiseBinaryOps.inc +116 -0
- package/eigen/Eigen/src/plugins/CommonCwiseUnaryOps.inc +167 -0
- package/eigen/Eigen/src/plugins/IndexedViewMethods.inc +192 -0
- package/eigen/Eigen/src/plugins/InternalHeaderCheck.inc +3 -0
- package/eigen/Eigen/src/plugins/MatrixCwiseBinaryOps.inc +331 -0
- package/eigen/Eigen/src/plugins/MatrixCwiseUnaryOps.inc +118 -0
- package/eigen/Eigen/src/plugins/ReshapedMethods.inc +133 -0
- package/lib/LibEigen.d.ts +4 -0
- package/lib/LibEigen.js +14 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +7 -3
- package/package.json +2 -10
- package/eigen/Eigen/CMakeLists.txt +0 -19
- package/eigen/Eigen/src/Core/BooleanRedux.h +0 -164
- package/eigen/Eigen/src/Core/arch/CUDA/Complex.h +0 -103
- package/eigen/Eigen/src/Core/arch/CUDA/Half.h +0 -675
- package/eigen/Eigen/src/Core/arch/CUDA/MathFunctions.h +0 -91
- package/eigen/Eigen/src/Core/arch/CUDA/PacketMath.h +0 -333
- package/eigen/Eigen/src/Core/arch/CUDA/PacketMathHalf.h +0 -1124
- package/eigen/Eigen/src/Core/arch/CUDA/TypeCasting.h +0 -212
- package/eigen/Eigen/src/Core/util/NonMPL2.h +0 -3
- package/eigen/Eigen/src/Geometry/arch/Geometry_SSE.h +0 -161
- package/eigen/Eigen/src/LU/arch/Inverse_SSE.h +0 -338
- package/eigen/Eigen/src/SparseCore/MappedSparseMatrix.h +0 -67
- package/eigen/Eigen/src/SparseLU/SparseLU_gemm_kernel.h +0 -280
- package/eigen/Eigen/src/misc/lapack.h +0 -152
- package/eigen/Eigen/src/plugins/ArrayCwiseBinaryOps.h +0 -332
- package/eigen/Eigen/src/plugins/ArrayCwiseUnaryOps.h +0 -552
- package/eigen/Eigen/src/plugins/BlockMethods.h +0 -1058
- package/eigen/Eigen/src/plugins/CommonCwiseBinaryOps.h +0 -115
- package/eigen/Eigen/src/plugins/CommonCwiseUnaryOps.h +0 -163
- package/eigen/Eigen/src/plugins/MatrixCwiseBinaryOps.h +0 -152
- package/eigen/Eigen/src/plugins/MatrixCwiseUnaryOps.h +0 -85
- package/lib/eigen.d.ts +0 -2
- package/lib/eigen.js +0 -15
|
@@ -13,411 +13,415 @@
|
|
|
13
13
|
|
|
14
14
|
#include "./Tridiagonalization.h"
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
// IWYU pragma: private
|
|
17
|
+
#include "./InternalHeaderCheck.h"
|
|
17
18
|
|
|
18
|
-
|
|
19
|
+
namespace Eigen {
|
|
20
|
+
|
|
21
|
+
template <typename MatrixType_>
|
|
19
22
|
class GeneralizedSelfAdjointEigenSolver;
|
|
20
23
|
|
|
21
24
|
namespace internal {
|
|
22
|
-
template<typename SolverType,int Size,bool IsComplex>
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
template <typename SolverType, int Size, bool IsComplex>
|
|
26
|
+
struct direct_selfadjoint_eigenvalues;
|
|
27
|
+
|
|
28
|
+
template <typename MatrixType, typename DiagType, typename SubDiagType>
|
|
29
|
+
EIGEN_DEVICE_FUNC ComputationInfo computeFromTridiagonal_impl(DiagType& diag, SubDiagType& subdiag,
|
|
30
|
+
const Index maxIterations, bool computeEigenvectors,
|
|
31
|
+
MatrixType& eivec);
|
|
32
|
+
} // namespace internal
|
|
26
33
|
|
|
27
34
|
/** \eigenvalues_module \ingroup Eigenvalues_Module
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
35
|
+
*
|
|
36
|
+
*
|
|
37
|
+
* \class SelfAdjointEigenSolver
|
|
38
|
+
*
|
|
39
|
+
* \brief Computes eigenvalues and eigenvectors of selfadjoint matrices
|
|
40
|
+
*
|
|
41
|
+
* \tparam MatrixType_ the type of the matrix of which we are computing the
|
|
42
|
+
* eigendecomposition; this is expected to be an instantiation of the Matrix
|
|
43
|
+
* class template.
|
|
44
|
+
*
|
|
45
|
+
* A matrix \f$ A \f$ is selfadjoint if it equals its adjoint. For real
|
|
46
|
+
* matrices, this means that the matrix is symmetric: it equals its
|
|
47
|
+
* transpose. This class computes the eigenvalues and eigenvectors of a
|
|
48
|
+
* selfadjoint matrix. These are the scalars \f$ \lambda \f$ and vectors
|
|
49
|
+
* \f$ v \f$ such that \f$ Av = \lambda v \f$. The eigenvalues of a
|
|
50
|
+
* selfadjoint matrix are always real. If \f$ D \f$ is a diagonal matrix with
|
|
51
|
+
* the eigenvalues on the diagonal, and \f$ V \f$ is a matrix with the
|
|
52
|
+
* eigenvectors as its columns, then \f$ A = V D V^{-1} \f$. This is called the
|
|
53
|
+
* eigendecomposition.
|
|
54
|
+
*
|
|
55
|
+
* For a selfadjoint matrix, \f$ V \f$ is unitary, meaning its inverse is equal
|
|
56
|
+
* to its adjoint, \f$ V^{-1} = V^{\dagger} \f$. If \f$ A \f$ is real, then
|
|
57
|
+
* \f$ V \f$ is also real and therefore orthogonal, meaning its inverse is
|
|
58
|
+
* equal to its transpose, \f$ V^{-1} = V^T \f$.
|
|
59
|
+
*
|
|
60
|
+
* The algorithm exploits the fact that the matrix is selfadjoint, making it
|
|
61
|
+
* faster and more accurate than the general purpose eigenvalue algorithms
|
|
62
|
+
* implemented in EigenSolver and ComplexEigenSolver.
|
|
63
|
+
*
|
|
64
|
+
* Only the \b lower \b triangular \b part of the input matrix is referenced.
|
|
65
|
+
*
|
|
66
|
+
* Call the function compute() to compute the eigenvalues and eigenvectors of
|
|
67
|
+
* a given matrix. Alternatively, you can use the
|
|
68
|
+
* SelfAdjointEigenSolver(const MatrixType&, int) constructor which computes
|
|
69
|
+
* the eigenvalues and eigenvectors at construction time. Once the eigenvalue
|
|
70
|
+
* and eigenvectors are computed, they can be retrieved with the eigenvalues()
|
|
71
|
+
* and eigenvectors() functions.
|
|
72
|
+
*
|
|
73
|
+
* The documentation for SelfAdjointEigenSolver(const MatrixType&, int)
|
|
74
|
+
* contains an example of the typical use of this class.
|
|
75
|
+
*
|
|
76
|
+
* To solve the \em generalized eigenvalue problem \f$ Av = \lambda Bv \f$ and
|
|
77
|
+
* the likes, see the class GeneralizedSelfAdjointEigenSolver.
|
|
78
|
+
*
|
|
79
|
+
* \sa MatrixBase::eigenvalues(), class EigenSolver, class ComplexEigenSolver
|
|
80
|
+
*/
|
|
81
|
+
template <typename MatrixType_>
|
|
82
|
+
class SelfAdjointEigenSolver {
|
|
83
|
+
public:
|
|
84
|
+
typedef MatrixType_ MatrixType;
|
|
85
|
+
enum {
|
|
86
|
+
Size = MatrixType::RowsAtCompileTime,
|
|
87
|
+
ColsAtCompileTime = MatrixType::ColsAtCompileTime,
|
|
88
|
+
Options = internal::traits<MatrixType>::Options,
|
|
89
|
+
MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
/** \brief Scalar type for matrices of type \p MatrixType_. */
|
|
93
|
+
typedef typename MatrixType::Scalar Scalar;
|
|
94
|
+
typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3
|
|
95
|
+
|
|
96
|
+
typedef Matrix<Scalar, Size, Size, ColMajor, MaxColsAtCompileTime, MaxColsAtCompileTime> EigenvectorsType;
|
|
97
|
+
|
|
98
|
+
/** \brief Real scalar type for \p MatrixType_.
|
|
99
|
+
*
|
|
100
|
+
* This is just \c Scalar if #Scalar is real (e.g., \c float or
|
|
101
|
+
* \c double), and the type of the real part of \c Scalar if #Scalar is
|
|
102
|
+
* complex.
|
|
103
|
+
*/
|
|
104
|
+
typedef typename NumTraits<Scalar>::Real RealScalar;
|
|
105
|
+
|
|
106
|
+
friend struct internal::direct_selfadjoint_eigenvalues<SelfAdjointEigenSolver, Size, NumTraits<Scalar>::IsComplex>;
|
|
107
|
+
|
|
108
|
+
/** \brief Type for vector of eigenvalues as returned by eigenvalues().
|
|
109
|
+
*
|
|
110
|
+
* This is a column vector with entries of type #RealScalar.
|
|
111
|
+
* The length of the vector is the size of \p MatrixType_.
|
|
112
|
+
*/
|
|
113
|
+
typedef typename internal::plain_col_type<MatrixType, Scalar>::type VectorType;
|
|
114
|
+
typedef typename internal::plain_col_type<MatrixType, RealScalar>::type RealVectorType;
|
|
115
|
+
typedef Tridiagonalization<MatrixType> TridiagonalizationType;
|
|
116
|
+
typedef typename TridiagonalizationType::SubDiagonalType SubDiagonalType;
|
|
117
|
+
|
|
118
|
+
/** \brief Default constructor for fixed-size matrices.
|
|
119
|
+
*
|
|
120
|
+
* The default constructor is useful in cases in which the user intends to
|
|
121
|
+
* perform decompositions via compute(). This constructor
|
|
122
|
+
* can only be used if \p MatrixType_ is a fixed-size matrix; use
|
|
123
|
+
* SelfAdjointEigenSolver(Index) for dynamic-size matrices.
|
|
124
|
+
*
|
|
125
|
+
* Example: \include SelfAdjointEigenSolver_SelfAdjointEigenSolver.cpp
|
|
126
|
+
* Output: \verbinclude SelfAdjointEigenSolver_SelfAdjointEigenSolver.out
|
|
127
|
+
*/
|
|
128
|
+
EIGEN_DEVICE_FUNC SelfAdjointEigenSolver()
|
|
129
|
+
: m_eivec(),
|
|
130
|
+
m_workspace(),
|
|
131
|
+
m_eivalues(),
|
|
132
|
+
m_subdiag(),
|
|
133
|
+
m_hcoeffs(),
|
|
134
|
+
m_info(InvalidInput),
|
|
135
|
+
m_isInitialized(false),
|
|
136
|
+
m_eigenvectorsOk(false) {}
|
|
137
|
+
|
|
138
|
+
/** \brief Constructor, pre-allocates memory for dynamic-size matrices.
|
|
139
|
+
*
|
|
140
|
+
* \param [in] size Positive integer, size of the matrix whose
|
|
141
|
+
* eigenvalues and eigenvectors will be computed.
|
|
142
|
+
*
|
|
143
|
+
* This constructor is useful for dynamic-size matrices, when the user
|
|
144
|
+
* intends to perform decompositions via compute(). The \p size
|
|
145
|
+
* parameter is only used as a hint. It is not an error to give a wrong
|
|
146
|
+
* \p size, but it may impair performance.
|
|
147
|
+
*
|
|
148
|
+
* \sa compute() for an example
|
|
149
|
+
*/
|
|
150
|
+
EIGEN_DEVICE_FUNC explicit SelfAdjointEigenSolver(Index size)
|
|
151
|
+
: m_eivec(size, size),
|
|
152
|
+
m_workspace(size),
|
|
153
|
+
m_eivalues(size),
|
|
154
|
+
m_subdiag(size > 1 ? size - 1 : 1),
|
|
155
|
+
m_hcoeffs(size > 1 ? size - 1 : 1),
|
|
156
|
+
m_isInitialized(false),
|
|
157
|
+
m_eigenvectorsOk(false) {}
|
|
158
|
+
|
|
159
|
+
/** \brief Constructor; computes eigendecomposition of given matrix.
|
|
160
|
+
*
|
|
161
|
+
* \param[in] matrix Selfadjoint matrix whose eigendecomposition is to
|
|
162
|
+
* be computed. Only the lower triangular part of the matrix is referenced.
|
|
163
|
+
* \param[in] options Can be #ComputeEigenvectors (default) or #EigenvaluesOnly.
|
|
164
|
+
*
|
|
165
|
+
* This constructor calls compute(const MatrixType&, int) to compute the
|
|
166
|
+
* eigenvalues of the matrix \p matrix. The eigenvectors are computed if
|
|
167
|
+
* \p options equals #ComputeEigenvectors.
|
|
168
|
+
*
|
|
169
|
+
* Example: \include SelfAdjointEigenSolver_SelfAdjointEigenSolver_MatrixType.cpp
|
|
170
|
+
* Output: \verbinclude SelfAdjointEigenSolver_SelfAdjointEigenSolver_MatrixType.out
|
|
171
|
+
*
|
|
172
|
+
* \sa compute(const MatrixType&, int)
|
|
173
|
+
*/
|
|
174
|
+
template <typename InputType>
|
|
175
|
+
EIGEN_DEVICE_FUNC explicit SelfAdjointEigenSolver(const EigenBase<InputType>& matrix,
|
|
176
|
+
int options = ComputeEigenvectors)
|
|
163
177
|
: m_eivec(matrix.rows(), matrix.cols()),
|
|
178
|
+
m_workspace(matrix.cols()),
|
|
164
179
|
m_eivalues(matrix.cols()),
|
|
165
180
|
m_subdiag(matrix.rows() > 1 ? matrix.rows() - 1 : 1),
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
181
|
+
m_hcoeffs(matrix.cols() > 1 ? matrix.cols() - 1 : 1),
|
|
182
|
+
m_isInitialized(false),
|
|
183
|
+
m_eigenvectorsOk(false) {
|
|
184
|
+
compute(matrix.derived(), options);
|
|
185
|
+
}
|
|
170
186
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
187
|
+
/** \brief Computes eigendecomposition of given matrix.
|
|
188
|
+
*
|
|
189
|
+
* \param[in] matrix Selfadjoint matrix whose eigendecomposition is to
|
|
190
|
+
* be computed. Only the lower triangular part of the matrix is referenced.
|
|
191
|
+
* \param[in] options Can be #ComputeEigenvectors (default) or #EigenvaluesOnly.
|
|
192
|
+
* \returns Reference to \c *this
|
|
193
|
+
*
|
|
194
|
+
* This function computes the eigenvalues of \p matrix. The eigenvalues()
|
|
195
|
+
* function can be used to retrieve them. If \p options equals #ComputeEigenvectors,
|
|
196
|
+
* then the eigenvectors are also computed and can be retrieved by
|
|
197
|
+
* calling eigenvectors().
|
|
198
|
+
*
|
|
199
|
+
* This implementation uses a symmetric QR algorithm. The matrix is first
|
|
200
|
+
* reduced to tridiagonal form using the Tridiagonalization class. The
|
|
201
|
+
* tridiagonal matrix is then brought to diagonal form with implicit
|
|
202
|
+
* symmetric QR steps with Wilkinson shift. Details can be found in
|
|
203
|
+
* Section 8.3 of Golub \& Van Loan, <i>%Matrix Computations</i>.
|
|
204
|
+
*
|
|
205
|
+
* The cost of the computation is about \f$ 9n^3 \f$ if the eigenvectors
|
|
206
|
+
* are required and \f$ 4n^3/3 \f$ if they are not required.
|
|
207
|
+
*
|
|
208
|
+
* This method reuses the memory in the SelfAdjointEigenSolver object that
|
|
209
|
+
* was allocated when the object was constructed, if the size of the
|
|
210
|
+
* matrix does not change.
|
|
211
|
+
*
|
|
212
|
+
* Example: \include SelfAdjointEigenSolver_compute_MatrixType.cpp
|
|
213
|
+
* Output: \verbinclude SelfAdjointEigenSolver_compute_MatrixType.out
|
|
214
|
+
*
|
|
215
|
+
* \sa SelfAdjointEigenSolver(const MatrixType&, int)
|
|
216
|
+
*/
|
|
217
|
+
template <typename InputType>
|
|
218
|
+
EIGEN_DEVICE_FUNC SelfAdjointEigenSolver& compute(const EigenBase<InputType>& matrix,
|
|
219
|
+
int options = ComputeEigenvectors);
|
|
220
|
+
|
|
221
|
+
/** \brief Computes eigendecomposition of given matrix using a closed-form algorithm
|
|
222
|
+
*
|
|
223
|
+
* This is a variant of compute(const MatrixType&, int options) which
|
|
224
|
+
* directly solves the underlying polynomial equation.
|
|
225
|
+
*
|
|
226
|
+
* Currently only 2x2 and 3x3 matrices for which the sizes are known at compile time are supported (e.g., Matrix3d).
|
|
227
|
+
*
|
|
228
|
+
* This method is usually significantly faster than the QR iterative algorithm
|
|
229
|
+
* but it might also be less accurate. It is also worth noting that
|
|
230
|
+
* for 3x3 matrices it involves trigonometric operations which are
|
|
231
|
+
* not necessarily available for all scalar types.
|
|
232
|
+
*
|
|
233
|
+
* For the 3x3 case, we observed the following worst case relative error regarding the eigenvalues:
|
|
234
|
+
* - double: 1e-8
|
|
235
|
+
* - float: 1e-3
|
|
236
|
+
*
|
|
237
|
+
* \sa compute(const MatrixType&, int options)
|
|
238
|
+
*/
|
|
239
|
+
EIGEN_DEVICE_FUNC SelfAdjointEigenSolver& computeDirect(const MatrixType& matrix, int options = ComputeEigenvectors);
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
*\brief Computes the eigen decomposition from a tridiagonal symmetric matrix
|
|
243
|
+
*
|
|
244
|
+
* \param[in] diag The vector containing the diagonal of the matrix.
|
|
245
|
+
* \param[in] subdiag The subdiagonal of the matrix.
|
|
246
|
+
* \param[in] options Can be #ComputeEigenvectors (default) or #EigenvaluesOnly.
|
|
247
|
+
* \returns Reference to \c *this
|
|
248
|
+
*
|
|
249
|
+
* This function assumes that the matrix has been reduced to tridiagonal form.
|
|
250
|
+
*
|
|
251
|
+
* \sa compute(const MatrixType&, int) for more information
|
|
252
|
+
*/
|
|
253
|
+
SelfAdjointEigenSolver& computeFromTridiagonal(const RealVectorType& diag, const SubDiagonalType& subdiag,
|
|
254
|
+
int options = ComputeEigenvectors);
|
|
255
|
+
|
|
256
|
+
/** \brief Returns the eigenvectors of given matrix.
|
|
257
|
+
*
|
|
258
|
+
* \returns A const reference to the matrix whose columns are the eigenvectors.
|
|
259
|
+
*
|
|
260
|
+
* \pre The eigenvectors have been computed before.
|
|
261
|
+
*
|
|
262
|
+
* Column \f$ k \f$ of the returned matrix is an eigenvector corresponding
|
|
263
|
+
* to eigenvalue number \f$ k \f$ as returned by eigenvalues(). The
|
|
264
|
+
* eigenvectors are normalized to have (Euclidean) norm equal to one. If
|
|
265
|
+
* this object was used to solve the eigenproblem for the selfadjoint
|
|
266
|
+
* matrix \f$ A \f$, then the matrix returned by this function is the
|
|
267
|
+
* matrix \f$ V \f$ in the eigendecomposition \f$ A = V D V^{-1} \f$.
|
|
268
|
+
*
|
|
269
|
+
* For a selfadjoint matrix, \f$ V \f$ is unitary, meaning its inverse is equal
|
|
270
|
+
* to its adjoint, \f$ V^{-1} = V^{\dagger} \f$. If \f$ A \f$ is real, then
|
|
271
|
+
* \f$ V \f$ is also real and therefore orthogonal, meaning its inverse is
|
|
272
|
+
* equal to its transpose, \f$ V^{-1} = V^T \f$.
|
|
273
|
+
*
|
|
274
|
+
* Example: \include SelfAdjointEigenSolver_eigenvectors.cpp
|
|
275
|
+
* Output: \verbinclude SelfAdjointEigenSolver_eigenvectors.out
|
|
276
|
+
*
|
|
277
|
+
* \sa eigenvalues()
|
|
278
|
+
*/
|
|
279
|
+
EIGEN_DEVICE_FUNC const EigenvectorsType& eigenvectors() const {
|
|
280
|
+
eigen_assert(m_isInitialized && "SelfAdjointEigenSolver is not initialized.");
|
|
281
|
+
eigen_assert(m_eigenvectorsOk && "The eigenvectors have not been computed together with the eigenvalues.");
|
|
282
|
+
return m_eivec;
|
|
283
|
+
}
|
|
265
284
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
return m_eivalues;
|
|
286
|
-
}
|
|
285
|
+
/** \brief Returns the eigenvalues of given matrix.
|
|
286
|
+
*
|
|
287
|
+
* \returns A const reference to the column vector containing the eigenvalues.
|
|
288
|
+
*
|
|
289
|
+
* \pre The eigenvalues have been computed before.
|
|
290
|
+
*
|
|
291
|
+
* The eigenvalues are repeated according to their algebraic multiplicity,
|
|
292
|
+
* so there are as many eigenvalues as rows in the matrix. The eigenvalues
|
|
293
|
+
* are sorted in increasing order.
|
|
294
|
+
*
|
|
295
|
+
* Example: \include SelfAdjointEigenSolver_eigenvalues.cpp
|
|
296
|
+
* Output: \verbinclude SelfAdjointEigenSolver_eigenvalues.out
|
|
297
|
+
*
|
|
298
|
+
* \sa eigenvectors(), MatrixBase::eigenvalues()
|
|
299
|
+
*/
|
|
300
|
+
EIGEN_DEVICE_FUNC const RealVectorType& eigenvalues() const {
|
|
301
|
+
eigen_assert(m_isInitialized && "SelfAdjointEigenSolver is not initialized.");
|
|
302
|
+
return m_eivalues;
|
|
303
|
+
}
|
|
287
304
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
return m_eivec * m_eivalues.cwiseSqrt().asDiagonal() * m_eivec.adjoint();
|
|
311
|
-
}
|
|
305
|
+
/** \brief Computes the positive-definite square root of the matrix.
|
|
306
|
+
*
|
|
307
|
+
* \returns the positive-definite square root of the matrix
|
|
308
|
+
*
|
|
309
|
+
* \pre The eigenvalues and eigenvectors of a positive-definite matrix
|
|
310
|
+
* have been computed before.
|
|
311
|
+
*
|
|
312
|
+
* The square root of a positive-definite matrix \f$ A \f$ is the
|
|
313
|
+
* positive-definite matrix whose square equals \f$ A \f$. This function
|
|
314
|
+
* uses the eigendecomposition \f$ A = V D V^{-1} \f$ to compute the
|
|
315
|
+
* square root as \f$ A^{1/2} = V D^{1/2} V^{-1} \f$.
|
|
316
|
+
*
|
|
317
|
+
* Example: \include SelfAdjointEigenSolver_operatorSqrt.cpp
|
|
318
|
+
* Output: \verbinclude SelfAdjointEigenSolver_operatorSqrt.out
|
|
319
|
+
*
|
|
320
|
+
* \sa operatorInverseSqrt(), <a href="unsupported/group__MatrixFunctions__Module.html">MatrixFunctions Module</a>
|
|
321
|
+
*/
|
|
322
|
+
EIGEN_DEVICE_FUNC MatrixType operatorSqrt() const {
|
|
323
|
+
eigen_assert(m_isInitialized && "SelfAdjointEigenSolver is not initialized.");
|
|
324
|
+
eigen_assert(m_eigenvectorsOk && "The eigenvectors have not been computed together with the eigenvalues.");
|
|
325
|
+
return m_eivec * m_eivalues.cwiseSqrt().asDiagonal() * m_eivec.adjoint();
|
|
326
|
+
}
|
|
312
327
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
}
|
|
328
|
+
/** \brief Computes the inverse square root of the matrix.
|
|
329
|
+
*
|
|
330
|
+
* \returns the inverse positive-definite square root of the matrix
|
|
331
|
+
*
|
|
332
|
+
* \pre The eigenvalues and eigenvectors of a positive-definite matrix
|
|
333
|
+
* have been computed before.
|
|
334
|
+
*
|
|
335
|
+
* This function uses the eigendecomposition \f$ A = V D V^{-1} \f$ to
|
|
336
|
+
* compute the inverse square root as \f$ V D^{-1/2} V^{-1} \f$. This is
|
|
337
|
+
* cheaper than first computing the square root with operatorSqrt() and
|
|
338
|
+
* then its inverse with MatrixBase::inverse().
|
|
339
|
+
*
|
|
340
|
+
* Example: \include SelfAdjointEigenSolver_operatorInverseSqrt.cpp
|
|
341
|
+
* Output: \verbinclude SelfAdjointEigenSolver_operatorInverseSqrt.out
|
|
342
|
+
*
|
|
343
|
+
* \sa operatorSqrt(), MatrixBase::inverse(), <a
|
|
344
|
+
* href="unsupported/group__MatrixFunctions__Module.html">MatrixFunctions Module</a>
|
|
345
|
+
*/
|
|
346
|
+
EIGEN_DEVICE_FUNC MatrixType operatorInverseSqrt() const {
|
|
347
|
+
eigen_assert(m_isInitialized && "SelfAdjointEigenSolver is not initialized.");
|
|
348
|
+
eigen_assert(m_eigenvectorsOk && "The eigenvectors have not been computed together with the eigenvalues.");
|
|
349
|
+
return m_eivec * m_eivalues.cwiseInverse().cwiseSqrt().asDiagonal() * m_eivec.adjoint();
|
|
350
|
+
}
|
|
337
351
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
return m_info;
|
|
347
|
-
}
|
|
352
|
+
/** \brief Reports whether previous computation was successful.
|
|
353
|
+
*
|
|
354
|
+
* \returns \c Success if computation was successful, \c NoConvergence otherwise.
|
|
355
|
+
*/
|
|
356
|
+
EIGEN_DEVICE_FUNC ComputationInfo info() const {
|
|
357
|
+
eigen_assert(m_isInitialized && "SelfAdjointEigenSolver is not initialized.");
|
|
358
|
+
return m_info;
|
|
359
|
+
}
|
|
348
360
|
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
bool m_eigenvectorsOk;
|
|
361
|
+
/** \brief Maximum number of iterations.
|
|
362
|
+
*
|
|
363
|
+
* The algorithm terminates if it does not converge within m_maxIterations * n iterations, where n
|
|
364
|
+
* denotes the size of the matrix. This value is currently set to 30 (copied from LAPACK).
|
|
365
|
+
*/
|
|
366
|
+
static const int m_maxIterations = 30;
|
|
367
|
+
|
|
368
|
+
protected:
|
|
369
|
+
EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar)
|
|
370
|
+
|
|
371
|
+
EigenvectorsType m_eivec;
|
|
372
|
+
VectorType m_workspace;
|
|
373
|
+
RealVectorType m_eivalues;
|
|
374
|
+
typename TridiagonalizationType::SubDiagonalType m_subdiag;
|
|
375
|
+
typename TridiagonalizationType::CoeffVectorType m_hcoeffs;
|
|
376
|
+
ComputationInfo m_info;
|
|
377
|
+
bool m_isInitialized;
|
|
378
|
+
bool m_eigenvectorsOk;
|
|
368
379
|
};
|
|
369
380
|
|
|
370
381
|
namespace internal {
|
|
371
382
|
/** \internal
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
template<int StorageOrder,typename RealScalar, typename Scalar, typename Index>
|
|
392
|
-
EIGEN_DEVICE_FUNC
|
|
393
|
-
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
template<typename MatrixType>
|
|
397
|
-
template<typename InputType>
|
|
398
|
-
EIGEN_DEVICE_FUNC
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
const InputType &matrix(a_matrix.derived());
|
|
405
|
-
|
|
406
|
-
using std::abs;
|
|
383
|
+
*
|
|
384
|
+
* \eigenvalues_module \ingroup Eigenvalues_Module
|
|
385
|
+
*
|
|
386
|
+
* Performs a QR step on a tridiagonal symmetric matrix represented as a
|
|
387
|
+
* pair of two vectors \a diag and \a subdiag.
|
|
388
|
+
*
|
|
389
|
+
* \param diag the diagonal part of the input selfadjoint tridiagonal matrix
|
|
390
|
+
* \param subdiag the sub-diagonal part of the input selfadjoint tridiagonal matrix
|
|
391
|
+
* \param start starting index of the submatrix to work on
|
|
392
|
+
* \param end last+1 index of the submatrix to work on
|
|
393
|
+
* \param matrixQ pointer to the column-major matrix holding the eigenvectors, can be 0
|
|
394
|
+
* \param n size of the input matrix
|
|
395
|
+
*
|
|
396
|
+
* For compilation efficiency reasons, this procedure does not use eigen expression
|
|
397
|
+
* for its arguments.
|
|
398
|
+
*
|
|
399
|
+
* Implemented from Golub's "Matrix Computations", algorithm 8.3.2:
|
|
400
|
+
* "implicit symmetric QR step with Wilkinson shift"
|
|
401
|
+
*/
|
|
402
|
+
template <int StorageOrder, typename RealScalar, typename Scalar, typename Index>
|
|
403
|
+
EIGEN_DEVICE_FUNC static void tridiagonal_qr_step(RealScalar* diag, RealScalar* subdiag, Index start, Index end,
|
|
404
|
+
Scalar* matrixQ, Index n);
|
|
405
|
+
} // namespace internal
|
|
406
|
+
|
|
407
|
+
template <typename MatrixType>
|
|
408
|
+
template <typename InputType>
|
|
409
|
+
EIGEN_DEVICE_FUNC SelfAdjointEigenSolver<MatrixType>& SelfAdjointEigenSolver<MatrixType>::compute(
|
|
410
|
+
const EigenBase<InputType>& a_matrix, int options) {
|
|
411
|
+
const InputType& matrix(a_matrix.derived());
|
|
412
|
+
|
|
413
|
+
EIGEN_USING_STD(abs);
|
|
407
414
|
eigen_assert(matrix.cols() == matrix.rows());
|
|
408
|
-
eigen_assert((options
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
bool computeEigenvectors = (options&ComputeEigenvectors)==ComputeEigenvectors;
|
|
415
|
+
eigen_assert((options & ~(EigVecMask | GenEigMask)) == 0 && (options & EigVecMask) != EigVecMask &&
|
|
416
|
+
"invalid option parameter");
|
|
417
|
+
bool computeEigenvectors = (options & ComputeEigenvectors) == ComputeEigenvectors;
|
|
412
418
|
Index n = matrix.cols();
|
|
413
|
-
m_eivalues.resize(n,1);
|
|
419
|
+
m_eivalues.resize(n, 1);
|
|
414
420
|
|
|
415
|
-
if(n==1)
|
|
416
|
-
{
|
|
421
|
+
if (n == 1) {
|
|
417
422
|
m_eivec = matrix;
|
|
418
|
-
m_eivalues.coeffRef(0,0) = numext::real(m_eivec.coeff(0,0));
|
|
419
|
-
if(computeEigenvectors)
|
|
420
|
-
m_eivec.setOnes(n,n);
|
|
423
|
+
m_eivalues.coeffRef(0, 0) = numext::real(m_eivec.coeff(0, 0));
|
|
424
|
+
if (computeEigenvectors) m_eivec.setOnes(n, n);
|
|
421
425
|
m_info = Success;
|
|
422
426
|
m_isInitialized = true;
|
|
423
427
|
m_eigenvectorsOk = computeEigenvectors;
|
|
@@ -431,13 +435,14 @@ SelfAdjointEigenSolver<MatrixType>& SelfAdjointEigenSolver<MatrixType>
|
|
|
431
435
|
// map the matrix coefficients to [-1:1] to avoid over- and underflow.
|
|
432
436
|
mat = matrix.template triangularView<Lower>();
|
|
433
437
|
RealScalar scale = mat.cwiseAbs().maxCoeff();
|
|
434
|
-
if(scale
|
|
438
|
+
if (numext::is_exactly_zero(scale)) scale = RealScalar(1);
|
|
435
439
|
mat.template triangularView<Lower>() /= scale;
|
|
436
|
-
m_subdiag.resize(n-1);
|
|
437
|
-
|
|
440
|
+
m_subdiag.resize(n - 1);
|
|
441
|
+
m_hcoeffs.resize(n - 1);
|
|
442
|
+
internal::tridiagonalization_inplace(mat, diag, m_subdiag, m_hcoeffs, m_workspace, computeEigenvectors);
|
|
438
443
|
|
|
439
444
|
m_info = internal::computeFromTridiagonal_impl(diag, m_subdiag, m_maxIterations, computeEigenvectors, m_eivec);
|
|
440
|
-
|
|
445
|
+
|
|
441
446
|
// scale back the eigen values
|
|
442
447
|
m_eivalues *= scale;
|
|
443
448
|
|
|
@@ -446,17 +451,15 @@ SelfAdjointEigenSolver<MatrixType>& SelfAdjointEigenSolver<MatrixType>
|
|
|
446
451
|
return *this;
|
|
447
452
|
}
|
|
448
453
|
|
|
449
|
-
template<typename MatrixType>
|
|
450
|
-
SelfAdjointEigenSolver<MatrixType>& SelfAdjointEigenSolver<MatrixType
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
bool computeEigenvectors = (options&ComputeEigenvectors)==ComputeEigenvectors;
|
|
454
|
+
template <typename MatrixType>
|
|
455
|
+
SelfAdjointEigenSolver<MatrixType>& SelfAdjointEigenSolver<MatrixType>::computeFromTridiagonal(
|
|
456
|
+
const RealVectorType& diag, const SubDiagonalType& subdiag, int options) {
|
|
457
|
+
// TODO : Add an option to scale the values beforehand
|
|
458
|
+
bool computeEigenvectors = (options & ComputeEigenvectors) == ComputeEigenvectors;
|
|
455
459
|
|
|
456
460
|
m_eivalues = diag;
|
|
457
461
|
m_subdiag = subdiag;
|
|
458
|
-
if (computeEigenvectors)
|
|
459
|
-
{
|
|
462
|
+
if (computeEigenvectors) {
|
|
460
463
|
m_eivec.setIdentity(diag.size(), diag.size());
|
|
461
464
|
}
|
|
462
465
|
m_info = internal::computeFromTridiagonal_impl(m_eivalues, m_subdiag, m_maxIterations, computeEigenvectors, m_eivec);
|
|
@@ -468,56 +471,60 @@ SelfAdjointEigenSolver<MatrixType>& SelfAdjointEigenSolver<MatrixType>
|
|
|
468
471
|
|
|
469
472
|
namespace internal {
|
|
470
473
|
/**
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
template<typename MatrixType, typename DiagType, typename SubDiagType>
|
|
482
|
-
ComputationInfo computeFromTridiagonal_impl(DiagType& diag, SubDiagType& subdiag,
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
474
|
+
* \internal
|
|
475
|
+
* \brief Compute the eigendecomposition from a tridiagonal matrix
|
|
476
|
+
*
|
|
477
|
+
* \param[in,out] diag : On input, the diagonal of the matrix, on output the eigenvalues
|
|
478
|
+
* \param[in,out] subdiag : The subdiagonal part of the matrix (entries are modified during the decomposition)
|
|
479
|
+
* \param[in] maxIterations : the maximum number of iterations
|
|
480
|
+
* \param[in] computeEigenvectors : whether the eigenvectors have to be computed or not
|
|
481
|
+
* \param[out] eivec : The matrix to store the eigenvectors if computeEigenvectors==true. Must be allocated on input.
|
|
482
|
+
* \returns \c Success or \c NoConvergence
|
|
483
|
+
*/
|
|
484
|
+
template <typename MatrixType, typename DiagType, typename SubDiagType>
|
|
485
|
+
EIGEN_DEVICE_FUNC ComputationInfo computeFromTridiagonal_impl(DiagType& diag, SubDiagType& subdiag,
|
|
486
|
+
const Index maxIterations, bool computeEigenvectors,
|
|
487
|
+
MatrixType& eivec) {
|
|
486
488
|
ComputationInfo info;
|
|
487
489
|
typedef typename MatrixType::Scalar Scalar;
|
|
488
490
|
|
|
489
491
|
Index n = diag.size();
|
|
490
|
-
Index end = n-1;
|
|
492
|
+
Index end = n - 1;
|
|
491
493
|
Index start = 0;
|
|
492
|
-
Index iter = 0;
|
|
493
|
-
|
|
494
|
+
Index iter = 0; // total number of iterations
|
|
495
|
+
|
|
494
496
|
typedef typename DiagType::RealScalar RealScalar;
|
|
495
497
|
const RealScalar considerAsZero = (std::numeric_limits<RealScalar>::min)();
|
|
496
|
-
const RealScalar
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
subdiag[i]
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
498
|
+
const RealScalar precision_inv = RealScalar(1) / NumTraits<RealScalar>::epsilon();
|
|
499
|
+
while (end > 0) {
|
|
500
|
+
for (Index i = start; i < end; ++i) {
|
|
501
|
+
if (numext::abs(subdiag[i]) < considerAsZero) {
|
|
502
|
+
subdiag[i] = RealScalar(0);
|
|
503
|
+
} else {
|
|
504
|
+
// abs(subdiag[i]) <= epsilon * sqrt(abs(diag[i]) + abs(diag[i+1]))
|
|
505
|
+
// Scaled to prevent underflows.
|
|
506
|
+
const RealScalar scaled_subdiag = precision_inv * subdiag[i];
|
|
507
|
+
if (scaled_subdiag * scaled_subdiag <= (numext::abs(diag[i]) + numext::abs(diag[i + 1]))) {
|
|
508
|
+
subdiag[i] = RealScalar(0);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
// find the largest unreduced block at the end of the matrix.
|
|
514
|
+
while (end > 0 && numext::is_exactly_zero(subdiag[end - 1])) {
|
|
507
515
|
end--;
|
|
508
516
|
}
|
|
509
|
-
if (end<=0)
|
|
510
|
-
break;
|
|
517
|
+
if (end <= 0) break;
|
|
511
518
|
|
|
512
519
|
// if we spent too many iterations, we give up
|
|
513
520
|
iter++;
|
|
514
|
-
if(iter > maxIterations * n) break;
|
|
521
|
+
if (iter > maxIterations * n) break;
|
|
515
522
|
|
|
516
523
|
start = end - 1;
|
|
517
|
-
while (start>0 && subdiag[start-1]
|
|
518
|
-
start--;
|
|
524
|
+
while (start > 0 && !numext::is_exactly_zero(subdiag[start - 1])) start--;
|
|
519
525
|
|
|
520
|
-
internal::tridiagonal_qr_step<MatrixType::Flags&RowMajorBit ? RowMajor : ColMajor>(
|
|
526
|
+
internal::tridiagonal_qr_step<MatrixType::Flags & RowMajorBit ? RowMajor : ColMajor>(
|
|
527
|
+
diag.data(), subdiag.data(), start, end, computeEigenvectors ? eivec.data() : (Scalar*)0, n);
|
|
521
528
|
}
|
|
522
529
|
if (iter <= maxIterations * n)
|
|
523
530
|
info = Success;
|
|
@@ -527,86 +534,80 @@ ComputationInfo computeFromTridiagonal_impl(DiagType& diag, SubDiagType& subdiag
|
|
|
527
534
|
// Sort eigenvalues and corresponding vectors.
|
|
528
535
|
// TODO make the sort optional ?
|
|
529
536
|
// TODO use a better sort algorithm !!
|
|
530
|
-
if (info == Success)
|
|
531
|
-
|
|
532
|
-
for (Index i = 0; i < n-1; ++i)
|
|
533
|
-
{
|
|
537
|
+
if (info == Success) {
|
|
538
|
+
for (Index i = 0; i < n - 1; ++i) {
|
|
534
539
|
Index k;
|
|
535
|
-
diag.segment(i,n-i).minCoeff(&k);
|
|
536
|
-
if (k > 0)
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
if(computeEigenvectors)
|
|
540
|
-
eivec.col(i).swap(eivec.col(k+i));
|
|
540
|
+
diag.segment(i, n - i).minCoeff(&k);
|
|
541
|
+
if (k > 0) {
|
|
542
|
+
numext::swap(diag[i], diag[k + i]);
|
|
543
|
+
if (computeEigenvectors) eivec.col(i).swap(eivec.col(k + i));
|
|
541
544
|
}
|
|
542
545
|
}
|
|
543
546
|
}
|
|
544
547
|
return info;
|
|
545
548
|
}
|
|
546
|
-
|
|
547
|
-
template<typename SolverType,int Size,bool IsComplex>
|
|
548
|
-
{
|
|
549
|
-
EIGEN_DEVICE_FUNC
|
|
550
|
-
|
|
551
|
-
|
|
549
|
+
|
|
550
|
+
template <typename SolverType, int Size, bool IsComplex>
|
|
551
|
+
struct direct_selfadjoint_eigenvalues {
|
|
552
|
+
EIGEN_DEVICE_FUNC static inline void run(SolverType& eig, const typename SolverType::MatrixType& A, int options) {
|
|
553
|
+
eig.compute(A, options);
|
|
554
|
+
}
|
|
552
555
|
};
|
|
553
556
|
|
|
554
|
-
template<typename SolverType>
|
|
555
|
-
{
|
|
557
|
+
template <typename SolverType>
|
|
558
|
+
struct direct_selfadjoint_eigenvalues<SolverType, 3, false> {
|
|
556
559
|
typedef typename SolverType::MatrixType MatrixType;
|
|
557
560
|
typedef typename SolverType::RealVectorType VectorType;
|
|
558
561
|
typedef typename SolverType::Scalar Scalar;
|
|
559
562
|
typedef typename SolverType::EigenvectorsType EigenvectorsType;
|
|
560
|
-
|
|
561
563
|
|
|
562
564
|
/** \internal
|
|
563
565
|
* Computes the roots of the characteristic polynomial of \a m.
|
|
564
566
|
* For numerical stability m.trace() should be near zero and to avoid over- or underflow m should be normalized.
|
|
565
567
|
*/
|
|
566
|
-
EIGEN_DEVICE_FUNC
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
EIGEN_USING_STD_MATH(sin)
|
|
573
|
-
const Scalar s_inv3 = Scalar(1)/Scalar(3);
|
|
568
|
+
EIGEN_DEVICE_FUNC static inline void computeRoots(const MatrixType& m, VectorType& roots) {
|
|
569
|
+
EIGEN_USING_STD(sqrt)
|
|
570
|
+
EIGEN_USING_STD(atan2)
|
|
571
|
+
EIGEN_USING_STD(cos)
|
|
572
|
+
EIGEN_USING_STD(sin)
|
|
573
|
+
const Scalar s_inv3 = Scalar(1) / Scalar(3);
|
|
574
574
|
const Scalar s_sqrt3 = sqrt(Scalar(3));
|
|
575
575
|
|
|
576
576
|
// The characteristic equation is x^3 - c2*x^2 + c1*x - c0 = 0. The
|
|
577
577
|
// eigenvalues are the roots to this equation, all guaranteed to be
|
|
578
578
|
// real-valued, because the matrix is symmetric.
|
|
579
|
-
Scalar c0 = m(0,0)*m(1,1)*m(2,2) + Scalar(2)*m(1,0)*m(2,0)*m(2,1) - m(0,0)*m(2,1)*m(2,
|
|
580
|
-
|
|
581
|
-
Scalar
|
|
579
|
+
Scalar c0 = m(0, 0) * m(1, 1) * m(2, 2) + Scalar(2) * m(1, 0) * m(2, 0) * m(2, 1) - m(0, 0) * m(2, 1) * m(2, 1) -
|
|
580
|
+
m(1, 1) * m(2, 0) * m(2, 0) - m(2, 2) * m(1, 0) * m(1, 0);
|
|
581
|
+
Scalar c1 = m(0, 0) * m(1, 1) - m(1, 0) * m(1, 0) + m(0, 0) * m(2, 2) - m(2, 0) * m(2, 0) + m(1, 1) * m(2, 2) -
|
|
582
|
+
m(2, 1) * m(2, 1);
|
|
583
|
+
Scalar c2 = m(0, 0) + m(1, 1) + m(2, 2);
|
|
582
584
|
|
|
583
585
|
// Construct the parameters used in classifying the roots of the equation
|
|
584
586
|
// and in solving the equation for the roots in closed form.
|
|
585
|
-
Scalar c2_over_3 = c2*s_inv3;
|
|
586
|
-
Scalar a_over_3 = (c2*c2_over_3 - c1)*s_inv3;
|
|
587
|
+
Scalar c2_over_3 = c2 * s_inv3;
|
|
588
|
+
Scalar a_over_3 = (c2 * c2_over_3 - c1) * s_inv3;
|
|
587
589
|
a_over_3 = numext::maxi(a_over_3, Scalar(0));
|
|
588
590
|
|
|
589
|
-
Scalar half_b = Scalar(0.5)*(c0 + c2_over_3*(Scalar(2)*c2_over_3*c2_over_3 - c1));
|
|
591
|
+
Scalar half_b = Scalar(0.5) * (c0 + c2_over_3 * (Scalar(2) * c2_over_3 * c2_over_3 - c1));
|
|
590
592
|
|
|
591
|
-
Scalar q = a_over_3*a_over_3*a_over_3 - half_b*half_b;
|
|
593
|
+
Scalar q = a_over_3 * a_over_3 * a_over_3 - half_b * half_b;
|
|
592
594
|
q = numext::maxi(q, Scalar(0));
|
|
593
595
|
|
|
594
596
|
// Compute the eigenvalues by solving for the roots of the polynomial.
|
|
595
597
|
Scalar rho = sqrt(a_over_3);
|
|
596
|
-
Scalar theta = atan2(sqrt(q),half_b)*s_inv3; // since sqrt(q) > 0, atan2 is in [0, pi] and theta is in [0, pi/3]
|
|
598
|
+
Scalar theta = atan2(sqrt(q), half_b) * s_inv3; // since sqrt(q) > 0, atan2 is in [0, pi] and theta is in [0, pi/3]
|
|
597
599
|
Scalar cos_theta = cos(theta);
|
|
598
600
|
Scalar sin_theta = sin(theta);
|
|
599
601
|
// roots are already sorted, since cos is monotonically decreasing on [0, pi]
|
|
600
|
-
roots(0) = c2_over_3 - rho*(cos_theta + s_sqrt3*sin_theta);
|
|
601
|
-
roots(1) = c2_over_3 - rho*(cos_theta - s_sqrt3*sin_theta);
|
|
602
|
-
roots(2) = c2_over_3 + Scalar(2)*rho*cos_theta;
|
|
602
|
+
roots(0) = c2_over_3 - rho * (cos_theta + s_sqrt3 * sin_theta); // == 2*rho*cos(theta+2pi/3)
|
|
603
|
+
roots(1) = c2_over_3 - rho * (cos_theta - s_sqrt3 * sin_theta); // == 2*rho*cos(theta+ pi/3)
|
|
604
|
+
roots(2) = c2_over_3 + Scalar(2) * rho * cos_theta;
|
|
603
605
|
}
|
|
604
606
|
|
|
605
|
-
EIGEN_DEVICE_FUNC
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
EIGEN_USING_STD_MATH(abs)
|
|
607
|
+
EIGEN_DEVICE_FUNC static inline bool extract_kernel(MatrixType& mat, Ref<VectorType> res,
|
|
608
|
+
Ref<VectorType> representative) {
|
|
609
|
+
EIGEN_USING_STD(abs);
|
|
610
|
+
EIGEN_USING_STD(sqrt);
|
|
610
611
|
Index i0;
|
|
611
612
|
// Find non-zero column i0 (by construction, there must exist a non zero coefficient on the diagonal):
|
|
612
613
|
mat.diagonal().cwiseAbs().maxCoeff(&i0);
|
|
@@ -615,47 +616,43 @@ template<typename SolverType> struct direct_selfadjoint_eigenvalues<SolverType,3
|
|
|
615
616
|
representative = mat.col(i0);
|
|
616
617
|
Scalar n0, n1;
|
|
617
618
|
VectorType c0, c1;
|
|
618
|
-
n0 = (c0 = representative.cross(mat.col((i0+1)%3))).squaredNorm();
|
|
619
|
-
n1 = (c1 = representative.cross(mat.col((i0+2)%3))).squaredNorm();
|
|
620
|
-
if(n0>n1)
|
|
621
|
-
|
|
619
|
+
n0 = (c0 = representative.cross(mat.col((i0 + 1) % 3))).squaredNorm();
|
|
620
|
+
n1 = (c1 = representative.cross(mat.col((i0 + 2) % 3))).squaredNorm();
|
|
621
|
+
if (n0 > n1)
|
|
622
|
+
res = c0 / sqrt(n0);
|
|
623
|
+
else
|
|
624
|
+
res = c1 / sqrt(n1);
|
|
622
625
|
|
|
623
626
|
return true;
|
|
624
627
|
}
|
|
625
628
|
|
|
626
|
-
EIGEN_DEVICE_FUNC
|
|
627
|
-
static inline void run(SolverType& solver, const MatrixType& mat, int options)
|
|
628
|
-
{
|
|
629
|
+
EIGEN_DEVICE_FUNC static inline void run(SolverType& solver, const MatrixType& mat, int options) {
|
|
629
630
|
eigen_assert(mat.cols() == 3 && mat.cols() == mat.rows());
|
|
630
|
-
eigen_assert((options
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
631
|
+
eigen_assert((options & ~(EigVecMask | GenEigMask)) == 0 && (options & EigVecMask) != EigVecMask &&
|
|
632
|
+
"invalid option parameter");
|
|
633
|
+
bool computeEigenvectors = (options & ComputeEigenvectors) == ComputeEigenvectors;
|
|
634
|
+
|
|
635
635
|
EigenvectorsType& eivecs = solver.m_eivec;
|
|
636
636
|
VectorType& eivals = solver.m_eivalues;
|
|
637
|
-
|
|
637
|
+
|
|
638
638
|
// Shift the matrix to the mean eigenvalue and map the matrix coefficients to [-1:1] to avoid over- and underflow.
|
|
639
639
|
Scalar shift = mat.trace() / Scalar(3);
|
|
640
|
-
// TODO Avoid this copy. Currently it is necessary to suppress bogus values when determining maxCoeff and for
|
|
640
|
+
// TODO Avoid this copy. Currently it is necessary to suppress bogus values when determining maxCoeff and for
|
|
641
|
+
// computing the eigenvectors later
|
|
641
642
|
MatrixType scaledMat = mat.template selfadjointView<Lower>();
|
|
642
643
|
scaledMat.diagonal().array() -= shift;
|
|
643
644
|
Scalar scale = scaledMat.cwiseAbs().maxCoeff();
|
|
644
|
-
if(scale > 0) scaledMat /= scale;
|
|
645
|
+
if (scale > 0) scaledMat /= scale; // TODO for scale==0 we could save the remaining operations
|
|
645
646
|
|
|
646
647
|
// compute the eigenvalues
|
|
647
|
-
computeRoots(scaledMat,eivals);
|
|
648
|
+
computeRoots(scaledMat, eivals);
|
|
648
649
|
|
|
649
650
|
// compute the eigenvectors
|
|
650
|
-
if(computeEigenvectors)
|
|
651
|
-
|
|
652
|
-
if((eivals(2)-eivals(0))<=Eigen::NumTraits<Scalar>::epsilon())
|
|
653
|
-
{
|
|
651
|
+
if (computeEigenvectors) {
|
|
652
|
+
if ((eivals(2) - eivals(0)) <= Eigen::NumTraits<Scalar>::epsilon()) {
|
|
654
653
|
// All three eigenvalues are numerically the same
|
|
655
654
|
eivecs.setIdentity();
|
|
656
|
-
}
|
|
657
|
-
else
|
|
658
|
-
{
|
|
655
|
+
} else {
|
|
659
656
|
MatrixType tmp;
|
|
660
657
|
tmp = scaledMat;
|
|
661
658
|
|
|
@@ -663,31 +660,27 @@ template<typename SolverType> struct direct_selfadjoint_eigenvalues<SolverType,3
|
|
|
663
660
|
Scalar d0 = eivals(2) - eivals(1);
|
|
664
661
|
Scalar d1 = eivals(1) - eivals(0);
|
|
665
662
|
Index k(0), l(2);
|
|
666
|
-
if(d0 > d1)
|
|
667
|
-
|
|
668
|
-
numext::swap(k,l);
|
|
663
|
+
if (d0 > d1) {
|
|
664
|
+
numext::swap(k, l);
|
|
669
665
|
d0 = d1;
|
|
670
666
|
}
|
|
671
667
|
|
|
672
668
|
// Compute the eigenvector of index k
|
|
673
669
|
{
|
|
674
|
-
tmp.diagonal().array
|
|
670
|
+
tmp.diagonal().array() -= eivals(k);
|
|
675
671
|
// By construction, 'tmp' is of rank 2, and its kernel corresponds to the respective eigenvector.
|
|
676
672
|
extract_kernel(tmp, eivecs.col(k), eivecs.col(l));
|
|
677
673
|
}
|
|
678
674
|
|
|
679
675
|
// Compute eigenvector of index l
|
|
680
|
-
if(d0<=2*Eigen::NumTraits<Scalar>::epsilon()*d1)
|
|
681
|
-
{
|
|
676
|
+
if (d0 <= 2 * Eigen::NumTraits<Scalar>::epsilon() * d1) {
|
|
682
677
|
// If d0 is too small, then the two other eigenvalues are numerically the same,
|
|
683
678
|
// and thus we only have to ortho-normalize the near orthogonal vector we saved above.
|
|
684
|
-
eivecs.col(l) -= eivecs.col(k).dot(eivecs.col(l))*eivecs.col(l);
|
|
679
|
+
eivecs.col(l) -= eivecs.col(k).dot(eivecs.col(l)) * eivecs.col(l);
|
|
685
680
|
eivecs.col(l).normalize();
|
|
686
|
-
}
|
|
687
|
-
else
|
|
688
|
-
{
|
|
681
|
+
} else {
|
|
689
682
|
tmp = scaledMat;
|
|
690
|
-
tmp.diagonal().array
|
|
683
|
+
tmp.diagonal().array() -= eivals(l);
|
|
691
684
|
|
|
692
685
|
VectorType dummy;
|
|
693
686
|
extract_kernel(tmp, eivecs.col(l), dummy);
|
|
@@ -701,7 +694,7 @@ template<typename SolverType> struct direct_selfadjoint_eigenvalues<SolverType,3
|
|
|
701
694
|
// Rescale back to the original size.
|
|
702
695
|
eivals *= scale;
|
|
703
696
|
eivals.array() += shift;
|
|
704
|
-
|
|
697
|
+
|
|
705
698
|
solver.m_info = Success;
|
|
706
699
|
solver.m_isInitialized = true;
|
|
707
700
|
solver.m_eigenvectorsOk = computeEigenvectors;
|
|
@@ -709,73 +702,59 @@ template<typename SolverType> struct direct_selfadjoint_eigenvalues<SolverType,3
|
|
|
709
702
|
};
|
|
710
703
|
|
|
711
704
|
// 2x2 direct eigenvalues decomposition, code from Hauke Heibel
|
|
712
|
-
template<typename SolverType>
|
|
713
|
-
struct direct_selfadjoint_eigenvalues<SolverType,2,false>
|
|
714
|
-
{
|
|
705
|
+
template <typename SolverType>
|
|
706
|
+
struct direct_selfadjoint_eigenvalues<SolverType, 2, false> {
|
|
715
707
|
typedef typename SolverType::MatrixType MatrixType;
|
|
716
708
|
typedef typename SolverType::RealVectorType VectorType;
|
|
717
709
|
typedef typename SolverType::Scalar Scalar;
|
|
718
710
|
typedef typename SolverType::EigenvectorsType EigenvectorsType;
|
|
719
|
-
|
|
720
|
-
EIGEN_DEVICE_FUNC
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
const Scalar t0 = Scalar(0.5) * sqrt( numext::abs2(m(0,0)-m(1,1)) + Scalar(4)*numext::abs2(m(1,0)));
|
|
725
|
-
const Scalar t1 = Scalar(0.5) * (m(0,0) + m(1,1));
|
|
711
|
+
|
|
712
|
+
EIGEN_DEVICE_FUNC static inline void computeRoots(const MatrixType& m, VectorType& roots) {
|
|
713
|
+
EIGEN_USING_STD(sqrt);
|
|
714
|
+
const Scalar t0 = Scalar(0.5) * sqrt(numext::abs2(m(0, 0) - m(1, 1)) + Scalar(4) * numext::abs2(m(1, 0)));
|
|
715
|
+
const Scalar t1 = Scalar(0.5) * (m(0, 0) + m(1, 1));
|
|
726
716
|
roots(0) = t1 - t0;
|
|
727
717
|
roots(1) = t1 + t0;
|
|
728
718
|
}
|
|
729
|
-
|
|
730
|
-
EIGEN_DEVICE_FUNC
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
EIGEN_USING_STD_MATH(abs);
|
|
735
|
-
|
|
719
|
+
|
|
720
|
+
EIGEN_DEVICE_FUNC static inline void run(SolverType& solver, const MatrixType& mat, int options) {
|
|
721
|
+
EIGEN_USING_STD(sqrt);
|
|
722
|
+
EIGEN_USING_STD(abs);
|
|
723
|
+
|
|
736
724
|
eigen_assert(mat.cols() == 2 && mat.cols() == mat.rows());
|
|
737
|
-
eigen_assert((options
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
725
|
+
eigen_assert((options & ~(EigVecMask | GenEigMask)) == 0 && (options & EigVecMask) != EigVecMask &&
|
|
726
|
+
"invalid option parameter");
|
|
727
|
+
bool computeEigenvectors = (options & ComputeEigenvectors) == ComputeEigenvectors;
|
|
728
|
+
|
|
742
729
|
EigenvectorsType& eivecs = solver.m_eivec;
|
|
743
730
|
VectorType& eivals = solver.m_eivalues;
|
|
744
|
-
|
|
731
|
+
|
|
745
732
|
// Shift the matrix to the mean eigenvalue and map the matrix coefficients to [-1:1] to avoid over- and underflow.
|
|
746
733
|
Scalar shift = mat.trace() / Scalar(2);
|
|
747
734
|
MatrixType scaledMat = mat;
|
|
748
|
-
scaledMat.coeffRef(0,1) = mat.coeff(1,0);
|
|
735
|
+
scaledMat.coeffRef(0, 1) = mat.coeff(1, 0);
|
|
749
736
|
scaledMat.diagonal().array() -= shift;
|
|
750
737
|
Scalar scale = scaledMat.cwiseAbs().maxCoeff();
|
|
751
|
-
if(scale > Scalar(0))
|
|
752
|
-
scaledMat /= scale;
|
|
738
|
+
if (scale > Scalar(0)) scaledMat /= scale;
|
|
753
739
|
|
|
754
740
|
// Compute the eigenvalues
|
|
755
|
-
computeRoots(scaledMat,eivals);
|
|
741
|
+
computeRoots(scaledMat, eivals);
|
|
756
742
|
|
|
757
743
|
// compute the eigen vectors
|
|
758
|
-
if(computeEigenvectors)
|
|
759
|
-
|
|
760
|
-
if((eivals(1)-eivals(0))<=abs(eivals(1))*Eigen::NumTraits<Scalar>::epsilon())
|
|
761
|
-
{
|
|
744
|
+
if (computeEigenvectors) {
|
|
745
|
+
if ((eivals(1) - eivals(0)) <= abs(eivals(1)) * Eigen::NumTraits<Scalar>::epsilon()) {
|
|
762
746
|
eivecs.setIdentity();
|
|
763
|
-
}
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
Scalar
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
{
|
|
772
|
-
eivecs.col(1) << -scaledMat(1,
|
|
773
|
-
eivecs.col(1) /= sqrt(
|
|
774
|
-
}
|
|
775
|
-
else
|
|
776
|
-
{
|
|
777
|
-
eivecs.col(1) << -scaledMat(1,1), scaledMat(1,0);
|
|
778
|
-
eivecs.col(1) /= sqrt(c2+b2);
|
|
747
|
+
} else {
|
|
748
|
+
scaledMat.diagonal().array() -= eivals(1);
|
|
749
|
+
Scalar a2 = numext::abs2(scaledMat(0, 0));
|
|
750
|
+
Scalar c2 = numext::abs2(scaledMat(1, 1));
|
|
751
|
+
Scalar b2 = numext::abs2(scaledMat(1, 0));
|
|
752
|
+
if (a2 > c2) {
|
|
753
|
+
eivecs.col(1) << -scaledMat(1, 0), scaledMat(0, 0);
|
|
754
|
+
eivecs.col(1) /= sqrt(a2 + b2);
|
|
755
|
+
} else {
|
|
756
|
+
eivecs.col(1) << -scaledMat(1, 1), scaledMat(1, 0);
|
|
757
|
+
eivecs.col(1) /= sqrt(c2 + b2);
|
|
779
758
|
}
|
|
780
759
|
|
|
781
760
|
eivecs.col(0) << eivecs.col(1).unitOrthogonal();
|
|
@@ -792,80 +771,80 @@ struct direct_selfadjoint_eigenvalues<SolverType,2,false>
|
|
|
792
771
|
}
|
|
793
772
|
};
|
|
794
773
|
|
|
795
|
-
}
|
|
774
|
+
} // namespace internal
|
|
796
775
|
|
|
797
|
-
template<typename MatrixType>
|
|
798
|
-
EIGEN_DEVICE_FUNC
|
|
799
|
-
|
|
800
|
-
::
|
|
801
|
-
|
|
802
|
-
internal::direct_selfadjoint_eigenvalues<SelfAdjointEigenSolver,Size,NumTraits<Scalar>::IsComplex>::run(*this,matrix,options);
|
|
776
|
+
template <typename MatrixType>
|
|
777
|
+
EIGEN_DEVICE_FUNC SelfAdjointEigenSolver<MatrixType>& SelfAdjointEigenSolver<MatrixType>::computeDirect(
|
|
778
|
+
const MatrixType& matrix, int options) {
|
|
779
|
+
internal::direct_selfadjoint_eigenvalues<SelfAdjointEigenSolver, Size, NumTraits<Scalar>::IsComplex>::run(
|
|
780
|
+
*this, matrix, options);
|
|
803
781
|
return *this;
|
|
804
782
|
}
|
|
805
783
|
|
|
806
784
|
namespace internal {
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
RealScalar
|
|
785
|
+
|
|
786
|
+
// Francis implicit QR step.
|
|
787
|
+
template <int StorageOrder, typename RealScalar, typename Scalar, typename Index>
|
|
788
|
+
EIGEN_DEVICE_FUNC static void tridiagonal_qr_step(RealScalar* diag, RealScalar* subdiag, Index start, Index end,
|
|
789
|
+
Scalar* matrixQ, Index n) {
|
|
790
|
+
// Wilkinson Shift.
|
|
791
|
+
RealScalar td = (diag[end - 1] - diag[end]) * RealScalar(0.5);
|
|
792
|
+
RealScalar e = subdiag[end - 1];
|
|
814
793
|
// Note that thanks to scaling, e^2 or td^2 cannot overflow, however they can still
|
|
815
794
|
// underflow thus leading to inf/NaN values when using the following commented code:
|
|
816
|
-
// RealScalar e2 = numext::abs2(subdiag[end-1]);
|
|
817
|
-
// RealScalar mu = diag[end] - e2 / (td + (td>0 ? 1 : -1) * sqrt(td*td + e2));
|
|
795
|
+
// RealScalar e2 = numext::abs2(subdiag[end-1]);
|
|
796
|
+
// RealScalar mu = diag[end] - e2 / (td + (td>0 ? 1 : -1) * sqrt(td*td + e2));
|
|
818
797
|
// This explain the following, somewhat more complicated, version:
|
|
819
798
|
RealScalar mu = diag[end];
|
|
820
|
-
if(td
|
|
821
|
-
mu -= abs(e);
|
|
822
|
-
else
|
|
823
|
-
|
|
824
|
-
RealScalar
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
else
|
|
799
|
+
if (numext::is_exactly_zero(td)) {
|
|
800
|
+
mu -= numext::abs(e);
|
|
801
|
+
} else if (!numext::is_exactly_zero(e)) {
|
|
802
|
+
const RealScalar e2 = numext::abs2(e);
|
|
803
|
+
const RealScalar h = numext::hypot(td, e);
|
|
804
|
+
if (numext::is_exactly_zero(e2)) {
|
|
805
|
+
mu -= e / ((td + (td > RealScalar(0) ? h : -h)) / e);
|
|
806
|
+
} else {
|
|
807
|
+
mu -= e2 / (td + (td > RealScalar(0) ? h : -h));
|
|
808
|
+
}
|
|
828
809
|
}
|
|
829
|
-
|
|
810
|
+
|
|
830
811
|
RealScalar x = diag[start] - mu;
|
|
831
812
|
RealScalar z = subdiag[start];
|
|
832
|
-
|
|
833
|
-
|
|
813
|
+
// If z ever becomes zero, the Givens rotation will be the identity and
|
|
814
|
+
// z will stay zero for all future iterations.
|
|
815
|
+
for (Index k = start; k < end && !numext::is_exactly_zero(z); ++k) {
|
|
834
816
|
JacobiRotation<RealScalar> rot;
|
|
835
817
|
rot.makeGivens(x, z);
|
|
836
818
|
|
|
837
819
|
// do T = G' T G
|
|
838
820
|
RealScalar sdk = rot.s() * diag[k] + rot.c() * subdiag[k];
|
|
839
|
-
RealScalar dkp1 = rot.s() * subdiag[k] + rot.c() * diag[k+1];
|
|
821
|
+
RealScalar dkp1 = rot.s() * subdiag[k] + rot.c() * diag[k + 1];
|
|
840
822
|
|
|
841
|
-
diag[k] =
|
|
842
|
-
|
|
823
|
+
diag[k] =
|
|
824
|
+
rot.c() * (rot.c() * diag[k] - rot.s() * subdiag[k]) - rot.s() * (rot.c() * subdiag[k] - rot.s() * diag[k + 1]);
|
|
825
|
+
diag[k + 1] = rot.s() * sdk + rot.c() * dkp1;
|
|
843
826
|
subdiag[k] = rot.c() * sdk - rot.s() * dkp1;
|
|
844
|
-
|
|
845
827
|
|
|
846
|
-
if (k > start)
|
|
847
|
-
subdiag[k - 1] = rot.c() * subdiag[k-1] - rot.s() * z;
|
|
828
|
+
if (k > start) subdiag[k - 1] = rot.c() * subdiag[k - 1] - rot.s() * z;
|
|
848
829
|
|
|
830
|
+
// "Chasing the bulge" to return to triangular form.
|
|
849
831
|
x = subdiag[k];
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
z = -rot.s() * subdiag[k+1];
|
|
854
|
-
subdiag[k + 1] = rot.c() * subdiag[k+1];
|
|
832
|
+
if (k < end - 1) {
|
|
833
|
+
z = -rot.s() * subdiag[k + 1];
|
|
834
|
+
subdiag[k + 1] = rot.c() * subdiag[k + 1];
|
|
855
835
|
}
|
|
856
|
-
|
|
836
|
+
|
|
857
837
|
// apply the givens rotation to the unit matrix Q = Q * G
|
|
858
|
-
if (matrixQ)
|
|
859
|
-
{
|
|
838
|
+
if (matrixQ) {
|
|
860
839
|
// FIXME if StorageOrder == RowMajor this operation is not very efficient
|
|
861
|
-
Map<Matrix<Scalar,Dynamic,Dynamic,StorageOrder> > q(matrixQ,n,n);
|
|
862
|
-
q.applyOnTheRight(k,k+1,rot);
|
|
840
|
+
Map<Matrix<Scalar, Dynamic, Dynamic, StorageOrder> > q(matrixQ, n, n);
|
|
841
|
+
q.applyOnTheRight(k, k + 1, rot);
|
|
863
842
|
}
|
|
864
843
|
}
|
|
865
844
|
}
|
|
866
845
|
|
|
867
|
-
}
|
|
846
|
+
} // end namespace internal
|
|
868
847
|
|
|
869
|
-
}
|
|
848
|
+
} // end namespace Eigen
|
|
870
849
|
|
|
871
|
-
#endif
|
|
850
|
+
#endif // EIGEN_SELFADJOINTEIGENSOLVER_H
|