@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
|
@@ -11,13 +11,16 @@
|
|
|
11
11
|
#ifndef EIGEN_JACOBISVD_H
|
|
12
12
|
#define EIGEN_JACOBISVD_H
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
// IWYU pragma: private
|
|
15
|
+
#include "./InternalHeaderCheck.h"
|
|
16
|
+
|
|
17
|
+
namespace Eigen {
|
|
15
18
|
|
|
16
19
|
namespace internal {
|
|
20
|
+
|
|
17
21
|
// forward declaration (needed by ICC)
|
|
18
22
|
// the empty body is required by MSVC
|
|
19
|
-
template<typename MatrixType, int
|
|
20
|
-
bool IsComplex = NumTraits<typename MatrixType::Scalar>::IsComplex>
|
|
23
|
+
template <typename MatrixType, int Options, bool IsComplex = NumTraits<typename MatrixType::Scalar>::IsComplex>
|
|
21
24
|
struct svd_precondition_2x2_block_to_be_real {};
|
|
22
25
|
|
|
23
26
|
/*** QR preconditioners (R-SVD)
|
|
@@ -29,320 +32,326 @@ struct svd_precondition_2x2_block_to_be_real {};
|
|
|
29
32
|
|
|
30
33
|
enum { PreconditionIfMoreColsThanRows, PreconditionIfMoreRowsThanCols };
|
|
31
34
|
|
|
32
|
-
template<typename MatrixType, int QRPreconditioner, int Case>
|
|
33
|
-
struct qr_preconditioner_should_do_anything
|
|
34
|
-
{
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
ret = !( (QRPreconditioner == NoQRPreconditioner) ||
|
|
42
|
-
(Case == PreconditionIfMoreColsThanRows && bool(a)) ||
|
|
43
|
-
(Case == PreconditionIfMoreRowsThanCols && bool(b)) )
|
|
35
|
+
template <typename MatrixType, int QRPreconditioner, int Case>
|
|
36
|
+
struct qr_preconditioner_should_do_anything {
|
|
37
|
+
enum {
|
|
38
|
+
a = MatrixType::RowsAtCompileTime != Dynamic && MatrixType::ColsAtCompileTime != Dynamic &&
|
|
39
|
+
MatrixType::ColsAtCompileTime <= MatrixType::RowsAtCompileTime,
|
|
40
|
+
b = MatrixType::RowsAtCompileTime != Dynamic && MatrixType::ColsAtCompileTime != Dynamic &&
|
|
41
|
+
MatrixType::RowsAtCompileTime <= MatrixType::ColsAtCompileTime,
|
|
42
|
+
ret = !((QRPreconditioner == NoQRPreconditioner) || (Case == PreconditionIfMoreColsThanRows && bool(a)) ||
|
|
43
|
+
(Case == PreconditionIfMoreRowsThanCols && bool(b)))
|
|
44
44
|
};
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
-
template<typename MatrixType, int QRPreconditioner, int Case,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
template<typename MatrixType, int QRPreconditioner, int Case>
|
|
52
|
-
class qr_preconditioner_impl<MatrixType, QRPreconditioner, Case, false>
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
bool run(JacobiSVD<MatrixType,
|
|
57
|
-
{
|
|
47
|
+
template <typename MatrixType, int Options, int QRPreconditioner, int Case,
|
|
48
|
+
bool DoAnything = qr_preconditioner_should_do_anything<MatrixType, QRPreconditioner, Case>::ret>
|
|
49
|
+
struct qr_preconditioner_impl {};
|
|
50
|
+
|
|
51
|
+
template <typename MatrixType, int Options, int QRPreconditioner, int Case>
|
|
52
|
+
class qr_preconditioner_impl<MatrixType, Options, QRPreconditioner, Case, false> {
|
|
53
|
+
public:
|
|
54
|
+
void allocate(const JacobiSVD<MatrixType, Options>&) {}
|
|
55
|
+
template <typename Xpr>
|
|
56
|
+
bool run(JacobiSVD<MatrixType, Options>&, const Xpr&) {
|
|
58
57
|
return false;
|
|
59
58
|
}
|
|
60
59
|
};
|
|
61
60
|
|
|
62
61
|
/*** preconditioner using FullPivHouseholderQR ***/
|
|
63
62
|
|
|
64
|
-
template<typename MatrixType>
|
|
65
|
-
class qr_preconditioner_impl<MatrixType, FullPivHouseholderQRPreconditioner, PreconditionIfMoreRowsThanCols,
|
|
66
|
-
{
|
|
67
|
-
public:
|
|
63
|
+
template <typename MatrixType, int Options>
|
|
64
|
+
class qr_preconditioner_impl<MatrixType, Options, FullPivHouseholderQRPreconditioner, PreconditionIfMoreRowsThanCols,
|
|
65
|
+
true> {
|
|
66
|
+
public:
|
|
68
67
|
typedef typename MatrixType::Scalar Scalar;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
{
|
|
80
|
-
m_qr.~QRType();
|
|
81
|
-
::new (&m_qr) QRType(svd.rows(), svd.cols());
|
|
68
|
+
typedef JacobiSVD<MatrixType, Options> SVDType;
|
|
69
|
+
|
|
70
|
+
enum { WorkspaceSize = MatrixType::RowsAtCompileTime, MaxWorkspaceSize = MatrixType::MaxRowsAtCompileTime };
|
|
71
|
+
|
|
72
|
+
typedef Matrix<Scalar, 1, WorkspaceSize, RowMajor, 1, MaxWorkspaceSize> WorkspaceType;
|
|
73
|
+
|
|
74
|
+
void allocate(const SVDType& svd) {
|
|
75
|
+
if (svd.rows() != m_qr.rows() || svd.cols() != m_qr.cols()) {
|
|
76
|
+
internal::destroy_at(&m_qr);
|
|
77
|
+
internal::construct_at(&m_qr, svd.rows(), svd.cols());
|
|
82
78
|
}
|
|
83
79
|
if (svd.m_computeFullU) m_workspace.resize(svd.rows());
|
|
84
80
|
}
|
|
85
|
-
|
|
86
|
-
bool run(
|
|
87
|
-
|
|
88
|
-
if(matrix.rows() > matrix.cols())
|
|
89
|
-
{
|
|
81
|
+
template <typename Xpr>
|
|
82
|
+
bool run(SVDType& svd, const Xpr& matrix) {
|
|
83
|
+
if (matrix.rows() > matrix.cols()) {
|
|
90
84
|
m_qr.compute(matrix);
|
|
91
|
-
svd.m_workMatrix = m_qr.matrixQR().block(0,0,matrix.cols(),matrix.cols()).template triangularView<Upper>();
|
|
92
|
-
if(svd.m_computeFullU) m_qr.matrixQ().evalTo(svd.m_matrixU, m_workspace);
|
|
93
|
-
if(svd.computeV()) svd.m_matrixV = m_qr.colsPermutation();
|
|
85
|
+
svd.m_workMatrix = m_qr.matrixQR().block(0, 0, matrix.cols(), matrix.cols()).template triangularView<Upper>();
|
|
86
|
+
if (svd.m_computeFullU) m_qr.matrixQ().evalTo(svd.m_matrixU, m_workspace);
|
|
87
|
+
if (svd.computeV()) svd.m_matrixV = m_qr.colsPermutation();
|
|
94
88
|
return true;
|
|
95
89
|
}
|
|
96
90
|
return false;
|
|
97
91
|
}
|
|
98
|
-
|
|
92
|
+
|
|
93
|
+
private:
|
|
99
94
|
typedef FullPivHouseholderQR<MatrixType> QRType;
|
|
100
95
|
QRType m_qr;
|
|
101
96
|
WorkspaceType m_workspace;
|
|
102
97
|
};
|
|
103
98
|
|
|
104
|
-
template<typename MatrixType>
|
|
105
|
-
class qr_preconditioner_impl<MatrixType, FullPivHouseholderQRPreconditioner, PreconditionIfMoreColsThanRows,
|
|
106
|
-
{
|
|
107
|
-
public:
|
|
99
|
+
template <typename MatrixType, int Options>
|
|
100
|
+
class qr_preconditioner_impl<MatrixType, Options, FullPivHouseholderQRPreconditioner, PreconditionIfMoreColsThanRows,
|
|
101
|
+
true> {
|
|
102
|
+
public:
|
|
108
103
|
typedef typename MatrixType::Scalar Scalar;
|
|
109
|
-
|
|
110
|
-
|
|
104
|
+
typedef JacobiSVD<MatrixType, Options> SVDType;
|
|
105
|
+
|
|
106
|
+
enum {
|
|
111
107
|
RowsAtCompileTime = MatrixType::RowsAtCompileTime,
|
|
112
108
|
ColsAtCompileTime = MatrixType::ColsAtCompileTime,
|
|
113
109
|
MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
|
|
114
110
|
MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime,
|
|
115
|
-
|
|
116
|
-
: ColsAtCompileTime==1 ? (MatrixType::Options | RowMajor)
|
|
117
|
-
: MatrixType::Options
|
|
111
|
+
MatrixOptions = traits<MatrixType>::Options
|
|
118
112
|
};
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
{
|
|
126
|
-
m_qr
|
|
127
|
-
::
|
|
113
|
+
|
|
114
|
+
typedef typename internal::make_proper_matrix_type<Scalar, ColsAtCompileTime, RowsAtCompileTime, MatrixOptions,
|
|
115
|
+
MaxColsAtCompileTime, MaxRowsAtCompileTime>::type
|
|
116
|
+
TransposeTypeWithSameStorageOrder;
|
|
117
|
+
|
|
118
|
+
void allocate(const SVDType& svd) {
|
|
119
|
+
if (svd.cols() != m_qr.rows() || svd.rows() != m_qr.cols()) {
|
|
120
|
+
internal::destroy_at(&m_qr);
|
|
121
|
+
internal::construct_at(&m_qr, svd.cols(), svd.rows());
|
|
128
122
|
}
|
|
129
|
-
m_adjoint.resize(svd.cols(), svd.rows());
|
|
130
123
|
if (svd.m_computeFullV) m_workspace.resize(svd.cols());
|
|
131
124
|
}
|
|
132
|
-
|
|
133
|
-
bool run(
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
m_qr.
|
|
139
|
-
|
|
140
|
-
if(svd.m_computeFullV) m_qr.matrixQ().evalTo(svd.m_matrixV, m_workspace);
|
|
141
|
-
if(svd.computeU()) svd.m_matrixU = m_qr.colsPermutation();
|
|
125
|
+
template <typename Xpr>
|
|
126
|
+
bool run(SVDType& svd, const Xpr& matrix) {
|
|
127
|
+
if (matrix.cols() > matrix.rows()) {
|
|
128
|
+
m_qr.compute(matrix.adjoint());
|
|
129
|
+
svd.m_workMatrix =
|
|
130
|
+
m_qr.matrixQR().block(0, 0, matrix.rows(), matrix.rows()).template triangularView<Upper>().adjoint();
|
|
131
|
+
if (svd.m_computeFullV) m_qr.matrixQ().evalTo(svd.m_matrixV, m_workspace);
|
|
132
|
+
if (svd.computeU()) svd.m_matrixU = m_qr.colsPermutation();
|
|
142
133
|
return true;
|
|
143
|
-
}
|
|
144
|
-
|
|
134
|
+
} else
|
|
135
|
+
return false;
|
|
145
136
|
}
|
|
146
|
-
|
|
137
|
+
|
|
138
|
+
private:
|
|
147
139
|
typedef FullPivHouseholderQR<TransposeTypeWithSameStorageOrder> QRType;
|
|
148
140
|
QRType m_qr;
|
|
149
|
-
|
|
150
|
-
typename internal::plain_row_type<MatrixType>::type m_workspace;
|
|
141
|
+
typename plain_row_type<MatrixType>::type m_workspace;
|
|
151
142
|
};
|
|
152
143
|
|
|
153
144
|
/*** preconditioner using ColPivHouseholderQR ***/
|
|
154
145
|
|
|
155
|
-
template<typename MatrixType>
|
|
156
|
-
class qr_preconditioner_impl<MatrixType, ColPivHouseholderQRPreconditioner, PreconditionIfMoreRowsThanCols,
|
|
157
|
-
{
|
|
158
|
-
public:
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
146
|
+
template <typename MatrixType, int Options>
|
|
147
|
+
class qr_preconditioner_impl<MatrixType, Options, ColPivHouseholderQRPreconditioner, PreconditionIfMoreRowsThanCols,
|
|
148
|
+
true> {
|
|
149
|
+
public:
|
|
150
|
+
typedef typename MatrixType::Scalar Scalar;
|
|
151
|
+
typedef JacobiSVD<MatrixType, Options> SVDType;
|
|
152
|
+
|
|
153
|
+
enum {
|
|
154
|
+
WorkspaceSize = internal::traits<SVDType>::MatrixUColsAtCompileTime,
|
|
155
|
+
MaxWorkspaceSize = internal::traits<SVDType>::MatrixUMaxColsAtCompileTime
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
typedef Matrix<Scalar, 1, WorkspaceSize, RowMajor, 1, MaxWorkspaceSize> WorkspaceType;
|
|
159
|
+
|
|
160
|
+
void allocate(const SVDType& svd) {
|
|
161
|
+
if (svd.rows() != m_qr.rows() || svd.cols() != m_qr.cols()) {
|
|
162
|
+
internal::destroy_at(&m_qr);
|
|
163
|
+
internal::construct_at(&m_qr, svd.rows(), svd.cols());
|
|
165
164
|
}
|
|
166
|
-
if (svd.m_computeFullU)
|
|
167
|
-
|
|
165
|
+
if (svd.m_computeFullU)
|
|
166
|
+
m_workspace.resize(svd.rows());
|
|
167
|
+
else if (svd.m_computeThinU)
|
|
168
|
+
m_workspace.resize(svd.cols());
|
|
168
169
|
}
|
|
169
|
-
|
|
170
|
-
bool run(
|
|
171
|
-
|
|
172
|
-
if(matrix.rows() > matrix.cols())
|
|
173
|
-
{
|
|
170
|
+
template <typename Xpr>
|
|
171
|
+
bool run(SVDType& svd, const Xpr& matrix) {
|
|
172
|
+
if (matrix.rows() > matrix.cols()) {
|
|
174
173
|
m_qr.compute(matrix);
|
|
175
|
-
svd.m_workMatrix = m_qr.matrixQR().block(0,0,matrix.cols(),matrix.cols()).template triangularView<Upper>();
|
|
176
|
-
if(svd.m_computeFullU)
|
|
177
|
-
|
|
178
|
-
{
|
|
174
|
+
svd.m_workMatrix = m_qr.matrixQR().block(0, 0, matrix.cols(), matrix.cols()).template triangularView<Upper>();
|
|
175
|
+
if (svd.m_computeFullU)
|
|
176
|
+
m_qr.householderQ().evalTo(svd.m_matrixU, m_workspace);
|
|
177
|
+
else if (svd.m_computeThinU) {
|
|
179
178
|
svd.m_matrixU.setIdentity(matrix.rows(), matrix.cols());
|
|
180
179
|
m_qr.householderQ().applyThisOnTheLeft(svd.m_matrixU, m_workspace);
|
|
181
180
|
}
|
|
182
|
-
if(svd.computeV()) svd.m_matrixV = m_qr.colsPermutation();
|
|
181
|
+
if (svd.computeV()) svd.m_matrixV = m_qr.colsPermutation();
|
|
183
182
|
return true;
|
|
184
183
|
}
|
|
185
184
|
return false;
|
|
186
185
|
}
|
|
187
186
|
|
|
188
|
-
private:
|
|
187
|
+
private:
|
|
189
188
|
typedef ColPivHouseholderQR<MatrixType> QRType;
|
|
190
189
|
QRType m_qr;
|
|
191
|
-
|
|
190
|
+
WorkspaceType m_workspace;
|
|
192
191
|
};
|
|
193
192
|
|
|
194
|
-
template<typename MatrixType>
|
|
195
|
-
class qr_preconditioner_impl<MatrixType, ColPivHouseholderQRPreconditioner, PreconditionIfMoreColsThanRows,
|
|
196
|
-
{
|
|
197
|
-
public:
|
|
193
|
+
template <typename MatrixType, int Options>
|
|
194
|
+
class qr_preconditioner_impl<MatrixType, Options, ColPivHouseholderQRPreconditioner, PreconditionIfMoreColsThanRows,
|
|
195
|
+
true> {
|
|
196
|
+
public:
|
|
198
197
|
typedef typename MatrixType::Scalar Scalar;
|
|
199
|
-
|
|
200
|
-
|
|
198
|
+
typedef JacobiSVD<MatrixType, Options> SVDType;
|
|
199
|
+
|
|
200
|
+
enum {
|
|
201
201
|
RowsAtCompileTime = MatrixType::RowsAtCompileTime,
|
|
202
202
|
ColsAtCompileTime = MatrixType::ColsAtCompileTime,
|
|
203
203
|
MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
|
|
204
204
|
MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime,
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
205
|
+
MatrixOptions = internal::traits<MatrixType>::Options,
|
|
206
|
+
WorkspaceSize = internal::traits<SVDType>::MatrixVColsAtCompileTime,
|
|
207
|
+
MaxWorkspaceSize = internal::traits<SVDType>::MatrixVMaxColsAtCompileTime
|
|
208
208
|
};
|
|
209
209
|
|
|
210
|
-
typedef Matrix<Scalar,
|
|
211
|
-
|
|
210
|
+
typedef Matrix<Scalar, WorkspaceSize, 1, ColMajor, MaxWorkspaceSize, 1> WorkspaceType;
|
|
211
|
+
|
|
212
|
+
typedef typename internal::make_proper_matrix_type<Scalar, ColsAtCompileTime, RowsAtCompileTime, MatrixOptions,
|
|
213
|
+
MaxColsAtCompileTime, MaxRowsAtCompileTime>::type
|
|
214
|
+
TransposeTypeWithSameStorageOrder;
|
|
212
215
|
|
|
213
|
-
void allocate(const
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
m_qr.~QRType();
|
|
218
|
-
::new (&m_qr) QRType(svd.cols(), svd.rows());
|
|
216
|
+
void allocate(const SVDType& svd) {
|
|
217
|
+
if (svd.cols() != m_qr.rows() || svd.rows() != m_qr.cols()) {
|
|
218
|
+
internal::destroy_at(&m_qr);
|
|
219
|
+
internal::construct_at(&m_qr, svd.cols(), svd.rows());
|
|
219
220
|
}
|
|
220
|
-
if (svd.m_computeFullV)
|
|
221
|
-
|
|
222
|
-
|
|
221
|
+
if (svd.m_computeFullV)
|
|
222
|
+
m_workspace.resize(svd.cols());
|
|
223
|
+
else if (svd.m_computeThinV)
|
|
224
|
+
m_workspace.resize(svd.rows());
|
|
223
225
|
}
|
|
224
|
-
|
|
225
|
-
bool run(
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
if(svd.
|
|
234
|
-
else if(svd.m_computeThinV)
|
|
235
|
-
{
|
|
226
|
+
template <typename Xpr>
|
|
227
|
+
bool run(SVDType& svd, const Xpr& matrix) {
|
|
228
|
+
if (matrix.cols() > matrix.rows()) {
|
|
229
|
+
m_qr.compute(matrix.adjoint());
|
|
230
|
+
|
|
231
|
+
svd.m_workMatrix =
|
|
232
|
+
m_qr.matrixQR().block(0, 0, matrix.rows(), matrix.rows()).template triangularView<Upper>().adjoint();
|
|
233
|
+
if (svd.m_computeFullV)
|
|
234
|
+
m_qr.householderQ().evalTo(svd.m_matrixV, m_workspace);
|
|
235
|
+
else if (svd.m_computeThinV) {
|
|
236
236
|
svd.m_matrixV.setIdentity(matrix.cols(), matrix.rows());
|
|
237
237
|
m_qr.householderQ().applyThisOnTheLeft(svd.m_matrixV, m_workspace);
|
|
238
238
|
}
|
|
239
|
-
if(svd.computeU()) svd.m_matrixU = m_qr.colsPermutation();
|
|
239
|
+
if (svd.computeU()) svd.m_matrixU = m_qr.colsPermutation();
|
|
240
240
|
return true;
|
|
241
|
-
}
|
|
242
|
-
|
|
241
|
+
} else
|
|
242
|
+
return false;
|
|
243
243
|
}
|
|
244
244
|
|
|
245
|
-
private:
|
|
245
|
+
private:
|
|
246
246
|
typedef ColPivHouseholderQR<TransposeTypeWithSameStorageOrder> QRType;
|
|
247
247
|
QRType m_qr;
|
|
248
|
-
|
|
249
|
-
typename internal::plain_row_type<MatrixType>::type m_workspace;
|
|
248
|
+
WorkspaceType m_workspace;
|
|
250
249
|
};
|
|
251
250
|
|
|
252
251
|
/*** preconditioner using HouseholderQR ***/
|
|
253
252
|
|
|
254
|
-
template<typename MatrixType>
|
|
255
|
-
class qr_preconditioner_impl<MatrixType, HouseholderQRPreconditioner, PreconditionIfMoreRowsThanCols, true>
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
253
|
+
template <typename MatrixType, int Options>
|
|
254
|
+
class qr_preconditioner_impl<MatrixType, Options, HouseholderQRPreconditioner, PreconditionIfMoreRowsThanCols, true> {
|
|
255
|
+
public:
|
|
256
|
+
typedef typename MatrixType::Scalar Scalar;
|
|
257
|
+
typedef JacobiSVD<MatrixType, Options> SVDType;
|
|
258
|
+
|
|
259
|
+
enum {
|
|
260
|
+
WorkspaceSize = internal::traits<SVDType>::MatrixUColsAtCompileTime,
|
|
261
|
+
MaxWorkspaceSize = internal::traits<SVDType>::MatrixUMaxColsAtCompileTime
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
typedef Matrix<Scalar, 1, WorkspaceSize, RowMajor, 1, MaxWorkspaceSize> WorkspaceType;
|
|
265
|
+
|
|
266
|
+
void allocate(const SVDType& svd) {
|
|
267
|
+
if (svd.rows() != m_qr.rows() || svd.cols() != m_qr.cols()) {
|
|
268
|
+
internal::destroy_at(&m_qr);
|
|
269
|
+
internal::construct_at(&m_qr, svd.rows(), svd.cols());
|
|
264
270
|
}
|
|
265
|
-
if (svd.m_computeFullU)
|
|
266
|
-
|
|
271
|
+
if (svd.m_computeFullU)
|
|
272
|
+
m_workspace.resize(svd.rows());
|
|
273
|
+
else if (svd.m_computeThinU)
|
|
274
|
+
m_workspace.resize(svd.cols());
|
|
267
275
|
}
|
|
268
|
-
|
|
269
|
-
bool run(
|
|
270
|
-
|
|
271
|
-
if(matrix.rows() > matrix.cols())
|
|
272
|
-
{
|
|
276
|
+
template <typename Xpr>
|
|
277
|
+
bool run(SVDType& svd, const Xpr& matrix) {
|
|
278
|
+
if (matrix.rows() > matrix.cols()) {
|
|
273
279
|
m_qr.compute(matrix);
|
|
274
|
-
svd.m_workMatrix = m_qr.matrixQR().block(0,0,matrix.cols(),matrix.cols()).template triangularView<Upper>();
|
|
275
|
-
if(svd.m_computeFullU)
|
|
276
|
-
|
|
277
|
-
{
|
|
280
|
+
svd.m_workMatrix = m_qr.matrixQR().block(0, 0, matrix.cols(), matrix.cols()).template triangularView<Upper>();
|
|
281
|
+
if (svd.m_computeFullU)
|
|
282
|
+
m_qr.householderQ().evalTo(svd.m_matrixU, m_workspace);
|
|
283
|
+
else if (svd.m_computeThinU) {
|
|
278
284
|
svd.m_matrixU.setIdentity(matrix.rows(), matrix.cols());
|
|
279
285
|
m_qr.householderQ().applyThisOnTheLeft(svd.m_matrixU, m_workspace);
|
|
280
286
|
}
|
|
281
|
-
if(svd.computeV()) svd.m_matrixV.setIdentity(matrix.cols(), matrix.cols());
|
|
287
|
+
if (svd.computeV()) svd.m_matrixV.setIdentity(matrix.cols(), matrix.cols());
|
|
282
288
|
return true;
|
|
283
289
|
}
|
|
284
290
|
return false;
|
|
285
291
|
}
|
|
286
|
-
|
|
292
|
+
|
|
293
|
+
private:
|
|
287
294
|
typedef HouseholderQR<MatrixType> QRType;
|
|
288
295
|
QRType m_qr;
|
|
289
|
-
|
|
296
|
+
WorkspaceType m_workspace;
|
|
290
297
|
};
|
|
291
298
|
|
|
292
|
-
template<typename MatrixType>
|
|
293
|
-
class qr_preconditioner_impl<MatrixType, HouseholderQRPreconditioner, PreconditionIfMoreColsThanRows, true>
|
|
294
|
-
|
|
295
|
-
public:
|
|
299
|
+
template <typename MatrixType, int Options>
|
|
300
|
+
class qr_preconditioner_impl<MatrixType, Options, HouseholderQRPreconditioner, PreconditionIfMoreColsThanRows, true> {
|
|
301
|
+
public:
|
|
296
302
|
typedef typename MatrixType::Scalar Scalar;
|
|
297
|
-
|
|
298
|
-
|
|
303
|
+
typedef JacobiSVD<MatrixType, Options> SVDType;
|
|
304
|
+
|
|
305
|
+
enum {
|
|
299
306
|
RowsAtCompileTime = MatrixType::RowsAtCompileTime,
|
|
300
307
|
ColsAtCompileTime = MatrixType::ColsAtCompileTime,
|
|
301
308
|
MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
|
|
302
309
|
MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime,
|
|
303
|
-
|
|
310
|
+
MatrixOptions = internal::traits<MatrixType>::Options,
|
|
311
|
+
WorkspaceSize = internal::traits<SVDType>::MatrixVColsAtCompileTime,
|
|
312
|
+
MaxWorkspaceSize = internal::traits<SVDType>::MatrixVMaxColsAtCompileTime
|
|
304
313
|
};
|
|
305
314
|
|
|
306
|
-
typedef Matrix<Scalar,
|
|
307
|
-
TransposeTypeWithSameStorageOrder;
|
|
315
|
+
typedef Matrix<Scalar, WorkspaceSize, 1, ColMajor, MaxWorkspaceSize, 1> WorkspaceType;
|
|
308
316
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
317
|
+
typedef typename internal::make_proper_matrix_type<Scalar, ColsAtCompileTime, RowsAtCompileTime, MatrixOptions,
|
|
318
|
+
MaxColsAtCompileTime, MaxRowsAtCompileTime>::type
|
|
319
|
+
TransposeTypeWithSameStorageOrder;
|
|
320
|
+
|
|
321
|
+
void allocate(const SVDType& svd) {
|
|
322
|
+
if (svd.cols() != m_qr.rows() || svd.rows() != m_qr.cols()) {
|
|
323
|
+
internal::destroy_at(&m_qr);
|
|
324
|
+
internal::construct_at(&m_qr, svd.cols(), svd.rows());
|
|
315
325
|
}
|
|
316
|
-
if (svd.m_computeFullV)
|
|
317
|
-
|
|
318
|
-
|
|
326
|
+
if (svd.m_computeFullV)
|
|
327
|
+
m_workspace.resize(svd.cols());
|
|
328
|
+
else if (svd.m_computeThinV)
|
|
329
|
+
m_workspace.resize(svd.rows());
|
|
319
330
|
}
|
|
320
331
|
|
|
321
|
-
|
|
322
|
-
{
|
|
323
|
-
if(matrix.cols() > matrix.rows())
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
else if(svd.m_computeThinV)
|
|
331
|
-
{
|
|
332
|
+
template <typename Xpr>
|
|
333
|
+
bool run(SVDType& svd, const Xpr& matrix) {
|
|
334
|
+
if (matrix.cols() > matrix.rows()) {
|
|
335
|
+
m_qr.compute(matrix.adjoint());
|
|
336
|
+
|
|
337
|
+
svd.m_workMatrix =
|
|
338
|
+
m_qr.matrixQR().block(0, 0, matrix.rows(), matrix.rows()).template triangularView<Upper>().adjoint();
|
|
339
|
+
if (svd.m_computeFullV)
|
|
340
|
+
m_qr.householderQ().evalTo(svd.m_matrixV, m_workspace);
|
|
341
|
+
else if (svd.m_computeThinV) {
|
|
332
342
|
svd.m_matrixV.setIdentity(matrix.cols(), matrix.rows());
|
|
333
343
|
m_qr.householderQ().applyThisOnTheLeft(svd.m_matrixV, m_workspace);
|
|
334
344
|
}
|
|
335
|
-
if(svd.computeU()) svd.m_matrixU.setIdentity(matrix.rows(), matrix.rows());
|
|
345
|
+
if (svd.computeU()) svd.m_matrixU.setIdentity(matrix.rows(), matrix.rows());
|
|
336
346
|
return true;
|
|
337
|
-
}
|
|
338
|
-
|
|
347
|
+
} else
|
|
348
|
+
return false;
|
|
339
349
|
}
|
|
340
350
|
|
|
341
|
-
private:
|
|
351
|
+
private:
|
|
342
352
|
typedef HouseholderQR<TransposeTypeWithSameStorageOrder> QRType;
|
|
343
353
|
QRType m_qr;
|
|
344
|
-
|
|
345
|
-
typename internal::plain_row_type<MatrixType>::type m_workspace;
|
|
354
|
+
WorkspaceType m_workspace;
|
|
346
355
|
};
|
|
347
356
|
|
|
348
357
|
/*** 2x2 SVD implementation
|
|
@@ -350,434 +359,461 @@ private:
|
|
|
350
359
|
*** JacobiSVD consists in performing a series of 2x2 SVD subproblems
|
|
351
360
|
***/
|
|
352
361
|
|
|
353
|
-
template<typename MatrixType, int
|
|
354
|
-
struct svd_precondition_2x2_block_to_be_real<MatrixType,
|
|
355
|
-
|
|
356
|
-
typedef JacobiSVD<MatrixType, QRPreconditioner> SVD;
|
|
362
|
+
template <typename MatrixType, int Options>
|
|
363
|
+
struct svd_precondition_2x2_block_to_be_real<MatrixType, Options, false> {
|
|
364
|
+
typedef JacobiSVD<MatrixType, Options> SVD;
|
|
357
365
|
typedef typename MatrixType::RealScalar RealScalar;
|
|
358
366
|
static bool run(typename SVD::WorkMatrixType&, SVD&, Index, Index, RealScalar&) { return true; }
|
|
359
367
|
};
|
|
360
368
|
|
|
361
|
-
template<typename MatrixType, int
|
|
362
|
-
struct svd_precondition_2x2_block_to_be_real<MatrixType,
|
|
363
|
-
|
|
364
|
-
typedef JacobiSVD<MatrixType, QRPreconditioner> SVD;
|
|
369
|
+
template <typename MatrixType, int Options>
|
|
370
|
+
struct svd_precondition_2x2_block_to_be_real<MatrixType, Options, true> {
|
|
371
|
+
typedef JacobiSVD<MatrixType, Options> SVD;
|
|
365
372
|
typedef typename MatrixType::Scalar Scalar;
|
|
366
373
|
typedef typename MatrixType::RealScalar RealScalar;
|
|
367
|
-
static bool run(typename SVD::WorkMatrixType& work_matrix, SVD& svd, Index p, Index q, RealScalar& maxDiagEntry)
|
|
368
|
-
{
|
|
369
|
-
using std::sqrt;
|
|
374
|
+
static bool run(typename SVD::WorkMatrixType& work_matrix, SVD& svd, Index p, Index q, RealScalar& maxDiagEntry) {
|
|
370
375
|
using std::abs;
|
|
376
|
+
using std::sqrt;
|
|
371
377
|
Scalar z;
|
|
372
378
|
JacobiRotation<Scalar> rot;
|
|
373
|
-
RealScalar n = sqrt(numext::abs2(work_matrix.coeff(p,p)) + numext::abs2(work_matrix.coeff(q,p)));
|
|
379
|
+
RealScalar n = sqrt(numext::abs2(work_matrix.coeff(p, p)) + numext::abs2(work_matrix.coeff(q, p)));
|
|
374
380
|
|
|
375
381
|
const RealScalar considerAsZero = (std::numeric_limits<RealScalar>::min)();
|
|
376
382
|
const RealScalar precision = NumTraits<Scalar>::epsilon();
|
|
377
383
|
|
|
378
|
-
if(n
|
|
379
|
-
{
|
|
384
|
+
if (numext::is_exactly_zero(n)) {
|
|
380
385
|
// make sure first column is zero
|
|
381
|
-
work_matrix.coeffRef(p,p) = work_matrix.coeffRef(q,p) = Scalar(0);
|
|
386
|
+
work_matrix.coeffRef(p, p) = work_matrix.coeffRef(q, p) = Scalar(0);
|
|
382
387
|
|
|
383
|
-
if(abs(numext::imag(work_matrix.coeff(p,q)))>considerAsZero)
|
|
384
|
-
|
|
385
|
-
//
|
|
386
|
-
z = abs(work_matrix.coeff(p,q)) / work_matrix.coeff(p,q);
|
|
388
|
+
if (abs(numext::imag(work_matrix.coeff(p, q))) > considerAsZero) {
|
|
389
|
+
// work_matrix.coeff(p,q) can be zero if work_matrix.coeff(q,p) is not zero but small enough to underflow when
|
|
390
|
+
// computing n
|
|
391
|
+
z = abs(work_matrix.coeff(p, q)) / work_matrix.coeff(p, q);
|
|
387
392
|
work_matrix.row(p) *= z;
|
|
388
|
-
if(svd.computeU()) svd.m_matrixU.col(p) *= conj(z);
|
|
393
|
+
if (svd.computeU()) svd.m_matrixU.col(p) *= conj(z);
|
|
389
394
|
}
|
|
390
|
-
if(abs(numext::imag(work_matrix.coeff(q,q)))>considerAsZero)
|
|
391
|
-
|
|
392
|
-
z = abs(work_matrix.coeff(q,q)) / work_matrix.coeff(q,q);
|
|
395
|
+
if (abs(numext::imag(work_matrix.coeff(q, q))) > considerAsZero) {
|
|
396
|
+
z = abs(work_matrix.coeff(q, q)) / work_matrix.coeff(q, q);
|
|
393
397
|
work_matrix.row(q) *= z;
|
|
394
|
-
if(svd.computeU()) svd.m_matrixU.col(q) *= conj(z);
|
|
398
|
+
if (svd.computeU()) svd.m_matrixU.col(q) *= conj(z);
|
|
395
399
|
}
|
|
396
400
|
// otherwise the second row is already zero, so we have nothing to do.
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
work_matrix.
|
|
403
|
-
|
|
404
|
-
if(abs(numext::imag(work_matrix.coeff(p,q)))>considerAsZero)
|
|
405
|
-
{
|
|
406
|
-
z = abs(work_matrix.coeff(p,q)) / work_matrix.coeff(p,q);
|
|
401
|
+
} else {
|
|
402
|
+
rot.c() = conj(work_matrix.coeff(p, p)) / n;
|
|
403
|
+
rot.s() = work_matrix.coeff(q, p) / n;
|
|
404
|
+
work_matrix.applyOnTheLeft(p, q, rot);
|
|
405
|
+
if (svd.computeU()) svd.m_matrixU.applyOnTheRight(p, q, rot.adjoint());
|
|
406
|
+
if (abs(numext::imag(work_matrix.coeff(p, q))) > considerAsZero) {
|
|
407
|
+
z = abs(work_matrix.coeff(p, q)) / work_matrix.coeff(p, q);
|
|
407
408
|
work_matrix.col(q) *= z;
|
|
408
|
-
if(svd.computeV()) svd.m_matrixV.col(q) *= z;
|
|
409
|
+
if (svd.computeV()) svd.m_matrixV.col(q) *= z;
|
|
409
410
|
}
|
|
410
|
-
if(abs(numext::imag(work_matrix.coeff(q,q)))>considerAsZero)
|
|
411
|
-
|
|
412
|
-
z = abs(work_matrix.coeff(q,q)) / work_matrix.coeff(q,q);
|
|
411
|
+
if (abs(numext::imag(work_matrix.coeff(q, q))) > considerAsZero) {
|
|
412
|
+
z = abs(work_matrix.coeff(q, q)) / work_matrix.coeff(q, q);
|
|
413
413
|
work_matrix.row(q) *= z;
|
|
414
|
-
if(svd.computeU()) svd.m_matrixU.col(q) *= conj(z);
|
|
414
|
+
if (svd.computeU()) svd.m_matrixU.col(q) *= conj(z);
|
|
415
415
|
}
|
|
416
416
|
}
|
|
417
417
|
|
|
418
418
|
// update largest diagonal entry
|
|
419
|
-
maxDiagEntry = numext::maxi<RealScalar>(
|
|
419
|
+
maxDiagEntry = numext::maxi<RealScalar>(
|
|
420
|
+
maxDiagEntry, numext::maxi<RealScalar>(abs(work_matrix.coeff(p, p)), abs(work_matrix.coeff(q, q))));
|
|
420
421
|
// and check whether the 2x2 block is already diagonal
|
|
421
422
|
RealScalar threshold = numext::maxi<RealScalar>(considerAsZero, precision * maxDiagEntry);
|
|
422
|
-
return abs(work_matrix.coeff(p,q))>threshold || abs(work_matrix.coeff(q,p)) > threshold;
|
|
423
|
+
return abs(work_matrix.coeff(p, q)) > threshold || abs(work_matrix.coeff(q, p)) > threshold;
|
|
423
424
|
}
|
|
424
425
|
};
|
|
425
426
|
|
|
426
|
-
template<typename
|
|
427
|
-
struct traits<JacobiSVD<
|
|
428
|
-
|
|
429
|
-
typedef _MatrixType MatrixType;
|
|
427
|
+
template <typename MatrixType_, int Options>
|
|
428
|
+
struct traits<JacobiSVD<MatrixType_, Options> > : svd_traits<MatrixType_, Options> {
|
|
429
|
+
typedef MatrixType_ MatrixType;
|
|
430
430
|
};
|
|
431
431
|
|
|
432
|
-
}
|
|
432
|
+
} // end namespace internal
|
|
433
433
|
|
|
434
434
|
/** \ingroup SVD_Module
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
* The default constructor is useful in cases in which the user intends to
|
|
519
|
-
* perform decompositions via JacobiSVD::compute(const MatrixType&).
|
|
520
|
-
*/
|
|
521
|
-
JacobiSVD()
|
|
522
|
-
{}
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
/** \brief Default Constructor with memory preallocation
|
|
526
|
-
*
|
|
527
|
-
* Like the default constructor but with preallocation of the internal data
|
|
528
|
-
* according to the specified problem size.
|
|
529
|
-
* \sa JacobiSVD()
|
|
530
|
-
*/
|
|
531
|
-
JacobiSVD(Index rows, Index cols, unsigned int computationOptions = 0)
|
|
532
|
-
{
|
|
533
|
-
allocate(rows, cols, computationOptions);
|
|
534
|
-
}
|
|
435
|
+
*
|
|
436
|
+
*
|
|
437
|
+
* \class JacobiSVD
|
|
438
|
+
*
|
|
439
|
+
* \brief Two-sided Jacobi SVD decomposition of a rectangular matrix
|
|
440
|
+
*
|
|
441
|
+
* \tparam MatrixType_ the type of the matrix of which we are computing the SVD decomposition
|
|
442
|
+
* \tparam Options this optional parameter allows one to specify the type of QR decomposition that will be used
|
|
443
|
+
* internally for the R-SVD step for non-square matrices. Additionally, it allows one to specify whether to compute thin
|
|
444
|
+
* or full unitaries \a U and \a V. See discussion of possible values below.
|
|
445
|
+
*
|
|
446
|
+
* SVD decomposition consists in decomposing any n-by-p matrix \a A as a product
|
|
447
|
+
* \f[ A = U S V^* \f]
|
|
448
|
+
* where \a U is a n-by-n unitary, \a V is a p-by-p unitary, and \a S is a n-by-p real positive matrix which is zero
|
|
449
|
+
* outside of its main diagonal; the diagonal entries of S are known as the \em singular \em values of \a A and the
|
|
450
|
+
* columns of \a U and \a V are known as the left and right \em singular \em vectors of \a A respectively.
|
|
451
|
+
*
|
|
452
|
+
* Singular values are always sorted in decreasing order.
|
|
453
|
+
*
|
|
454
|
+
* This JacobiSVD decomposition computes only the singular values by default. If you want \a U or \a V, you need to ask
|
|
455
|
+
* for them explicitly.
|
|
456
|
+
*
|
|
457
|
+
* You can ask for only \em thin \a U or \a V to be computed, meaning the following. In case of a rectangular n-by-p
|
|
458
|
+
* matrix, letting \a m be the smaller value among \a n and \a p, there are only \a m singular vectors; the remaining
|
|
459
|
+
* columns of \a U and \a V do not correspond to actual singular vectors. Asking for \em thin \a U or \a V means asking
|
|
460
|
+
* for only their \a m first columns to be formed. So \a U is then a n-by-m matrix, and \a V is then a p-by-m matrix.
|
|
461
|
+
* Notice that thin \a U and \a V are all you need for (least squares) solving.
|
|
462
|
+
*
|
|
463
|
+
* Here's an example demonstrating basic usage:
|
|
464
|
+
* \include JacobiSVD_basic.cpp
|
|
465
|
+
* Output: \verbinclude JacobiSVD_basic.out
|
|
466
|
+
*
|
|
467
|
+
* This JacobiSVD class is a two-sided Jacobi R-SVD decomposition, ensuring optimal reliability and accuracy. The
|
|
468
|
+
* downside is that it's slower than bidiagonalizing SVD algorithms for large square matrices; however its complexity is
|
|
469
|
+
* still \f$ O(n^2p) \f$ where \a n is the smaller dimension and \a p is the greater dimension, meaning that it is still
|
|
470
|
+
* of the same order of complexity as the faster bidiagonalizing R-SVD algorithms. In particular, like any R-SVD, it
|
|
471
|
+
* takes advantage of non-squareness in that its complexity is only linear in the greater dimension.
|
|
472
|
+
*
|
|
473
|
+
* If the input matrix has inf or nan coefficients, the result of the computation is undefined, but the computation is
|
|
474
|
+
* guaranteed to terminate in finite (and reasonable) time.
|
|
475
|
+
*
|
|
476
|
+
* The possible QR preconditioners that can be set with Options template parameter are:
|
|
477
|
+
* \li ColPivHouseholderQRPreconditioner is the default. In practice it's very safe. It uses column-pivoting QR.
|
|
478
|
+
* \li FullPivHouseholderQRPreconditioner, is the safest and slowest. It uses full-pivoting QR.
|
|
479
|
+
* Contrary to other QRs, it doesn't allow computing thin unitaries.
|
|
480
|
+
* \li HouseholderQRPreconditioner is the fastest, and less safe and accurate than the pivoting variants. It uses
|
|
481
|
+
* non-pivoting QR. This is very similar in safety and accuracy to the bidiagonalization process used by bidiagonalizing
|
|
482
|
+
* SVD algorithms (since bidiagonalization is inherently non-pivoting). However the resulting SVD is still more reliable
|
|
483
|
+
* than bidiagonalizing SVDs because the Jacobi-based iterarive process is more reliable than the optimized bidiagonal
|
|
484
|
+
* SVD iterations. \li NoQRPreconditioner allows not to use a QR preconditioner at all. This is useful if you know that
|
|
485
|
+
* you will only be computing JacobiSVD decompositions of square matrices. Non-square matrices require a QR
|
|
486
|
+
* preconditioner. Using this option will result in faster compilation and smaller executable code. It won't
|
|
487
|
+
* significantly speed up computation, since JacobiSVD is always checking if QR preconditioning is needed before
|
|
488
|
+
* applying it anyway.
|
|
489
|
+
*
|
|
490
|
+
* One may also use the Options template parameter to specify how the unitaries should be computed. The options are
|
|
491
|
+
* #ComputeThinU, #ComputeThinV, #ComputeFullU, #ComputeFullV. It is not possible to request both the thin and full
|
|
492
|
+
* versions of a unitary. By default, unitaries will not be computed.
|
|
493
|
+
*
|
|
494
|
+
* You can set the QRPreconditioner and unitary options together: JacobiSVD<MatrixType,
|
|
495
|
+
* ColPivHouseholderQRPreconditioner | ComputeThinU | ComputeFullV>
|
|
496
|
+
*
|
|
497
|
+
* \sa MatrixBase::jacobiSvd()
|
|
498
|
+
*/
|
|
499
|
+
template <typename MatrixType_, int Options_>
|
|
500
|
+
class JacobiSVD : public SVDBase<JacobiSVD<MatrixType_, Options_> > {
|
|
501
|
+
typedef SVDBase<JacobiSVD> Base;
|
|
502
|
+
|
|
503
|
+
public:
|
|
504
|
+
typedef MatrixType_ MatrixType;
|
|
505
|
+
typedef typename Base::Scalar Scalar;
|
|
506
|
+
typedef typename Base::RealScalar RealScalar;
|
|
507
|
+
enum : int {
|
|
508
|
+
Options = Options_,
|
|
509
|
+
QRPreconditioner = internal::get_qr_preconditioner(Options),
|
|
510
|
+
RowsAtCompileTime = Base::RowsAtCompileTime,
|
|
511
|
+
ColsAtCompileTime = Base::ColsAtCompileTime,
|
|
512
|
+
DiagSizeAtCompileTime = Base::DiagSizeAtCompileTime,
|
|
513
|
+
MaxRowsAtCompileTime = Base::MaxRowsAtCompileTime,
|
|
514
|
+
MaxColsAtCompileTime = Base::MaxColsAtCompileTime,
|
|
515
|
+
MaxDiagSizeAtCompileTime = Base::MaxDiagSizeAtCompileTime,
|
|
516
|
+
MatrixOptions = Base::MatrixOptions
|
|
517
|
+
};
|
|
535
518
|
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
519
|
+
typedef typename Base::MatrixUType MatrixUType;
|
|
520
|
+
typedef typename Base::MatrixVType MatrixVType;
|
|
521
|
+
typedef typename Base::SingularValuesType SingularValuesType;
|
|
522
|
+
typedef Matrix<Scalar, DiagSizeAtCompileTime, DiagSizeAtCompileTime, MatrixOptions, MaxDiagSizeAtCompileTime,
|
|
523
|
+
MaxDiagSizeAtCompileTime>
|
|
524
|
+
WorkMatrixType;
|
|
525
|
+
|
|
526
|
+
/** \brief Default Constructor.
|
|
527
|
+
*
|
|
528
|
+
* The default constructor is useful in cases in which the user intends to
|
|
529
|
+
* perform decompositions via JacobiSVD::compute(const MatrixType&).
|
|
530
|
+
*/
|
|
531
|
+
JacobiSVD() {}
|
|
532
|
+
|
|
533
|
+
/** \brief Default Constructor with memory preallocation
|
|
534
|
+
*
|
|
535
|
+
* Like the default constructor but with preallocation of the internal data
|
|
536
|
+
* according to the specified problem size and \a Options template parameter.
|
|
537
|
+
*
|
|
538
|
+
* \sa JacobiSVD()
|
|
539
|
+
*/
|
|
540
|
+
JacobiSVD(Index rows, Index cols) { allocate(rows, cols, internal::get_computation_options(Options)); }
|
|
541
|
+
|
|
542
|
+
/** \brief Default Constructor with memory preallocation
|
|
543
|
+
*
|
|
544
|
+
* Like the default constructor but with preallocation of the internal data
|
|
545
|
+
* according to the specified problem size.
|
|
546
|
+
*
|
|
547
|
+
* One \b cannot request unitaries using both the \a Options template parameter
|
|
548
|
+
* and the constructor. If possible, prefer using the \a Options template parameter.
|
|
549
|
+
*
|
|
550
|
+
* \param rows number of rows for the input matrix
|
|
551
|
+
* \param cols number of columns for the input matrix
|
|
552
|
+
* \param computationOptions specify whether to compute Thin/Full unitaries U/V
|
|
553
|
+
* \sa JacobiSVD()
|
|
554
|
+
*
|
|
555
|
+
* \deprecated Will be removed in the next major Eigen version. Options should
|
|
556
|
+
* be specified in the \a Options template parameter.
|
|
557
|
+
*/
|
|
558
|
+
EIGEN_DEPRECATED_WITH_REASON("Options should be specified using the class template parameter.")
|
|
559
|
+
JacobiSVD(Index rows, Index cols, unsigned int computationOptions) {
|
|
560
|
+
internal::check_svd_options_assertions<MatrixType, Options>(computationOptions, rows, cols);
|
|
561
|
+
allocate(rows, cols, computationOptions);
|
|
562
|
+
}
|
|
550
563
|
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
*/
|
|
561
|
-
JacobiSVD& compute(const MatrixType& matrix, unsigned int computationOptions);
|
|
562
|
-
|
|
563
|
-
/** \brief Method performing the decomposition of given matrix using current options.
|
|
564
|
-
*
|
|
565
|
-
* \param matrix the matrix to decompose
|
|
566
|
-
*
|
|
567
|
-
* This method uses the current \a computationOptions, as already passed to the constructor or to compute(const MatrixType&, unsigned int).
|
|
568
|
-
*/
|
|
569
|
-
JacobiSVD& compute(const MatrixType& matrix)
|
|
570
|
-
{
|
|
571
|
-
return compute(matrix, m_computationOptions);
|
|
572
|
-
}
|
|
564
|
+
/** \brief Constructor performing the decomposition of given matrix, using the custom options specified
|
|
565
|
+
* with the \a Options template parameter.
|
|
566
|
+
*
|
|
567
|
+
* \param matrix the matrix to decompose
|
|
568
|
+
*/
|
|
569
|
+
template <typename Derived>
|
|
570
|
+
explicit JacobiSVD(const MatrixBase<Derived>& matrix) {
|
|
571
|
+
compute_impl(matrix, internal::get_computation_options(Options));
|
|
572
|
+
}
|
|
573
573
|
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
using Base::rank;
|
|
579
|
-
|
|
580
|
-
private:
|
|
581
|
-
void allocate(Index rows, Index cols, unsigned int computationOptions);
|
|
582
|
-
|
|
583
|
-
protected:
|
|
584
|
-
using Base::m_matrixU;
|
|
585
|
-
using Base::m_matrixV;
|
|
586
|
-
using Base::m_singularValues;
|
|
587
|
-
using Base::m_isInitialized;
|
|
588
|
-
using Base::m_isAllocated;
|
|
589
|
-
using Base::m_usePrescribedThreshold;
|
|
590
|
-
using Base::m_computeFullU;
|
|
591
|
-
using Base::m_computeThinU;
|
|
592
|
-
using Base::m_computeFullV;
|
|
593
|
-
using Base::m_computeThinV;
|
|
594
|
-
using Base::m_computationOptions;
|
|
595
|
-
using Base::m_nonzeroSingularValues;
|
|
596
|
-
using Base::m_rows;
|
|
597
|
-
using Base::m_cols;
|
|
598
|
-
using Base::m_diagSize;
|
|
599
|
-
using Base::m_prescribedThreshold;
|
|
600
|
-
WorkMatrixType m_workMatrix;
|
|
601
|
-
|
|
602
|
-
template<typename __MatrixType, int _QRPreconditioner, bool _IsComplex>
|
|
603
|
-
friend struct internal::svd_precondition_2x2_block_to_be_real;
|
|
604
|
-
template<typename __MatrixType, int _QRPreconditioner, int _Case, bool _DoAnything>
|
|
605
|
-
friend struct internal::qr_preconditioner_impl;
|
|
606
|
-
|
|
607
|
-
internal::qr_preconditioner_impl<MatrixType, QRPreconditioner, internal::PreconditionIfMoreColsThanRows> m_qr_precond_morecols;
|
|
608
|
-
internal::qr_preconditioner_impl<MatrixType, QRPreconditioner, internal::PreconditionIfMoreRowsThanCols> m_qr_precond_morerows;
|
|
609
|
-
MatrixType m_scaledMatrix;
|
|
610
|
-
};
|
|
574
|
+
template <typename Derived>
|
|
575
|
+
explicit JacobiSVD(const TriangularBase<Derived>& matrix) {
|
|
576
|
+
compute_impl(matrix, internal::get_computation_options(Options));
|
|
577
|
+
}
|
|
611
578
|
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
579
|
+
/** \brief Constructor performing the decomposition of given matrix using specified options
|
|
580
|
+
* for computing unitaries.
|
|
581
|
+
*
|
|
582
|
+
* One \b cannot request unitiaries using both the \a Options template parameter
|
|
583
|
+
* and the constructor. If possible, prefer using the \a Options template parameter.
|
|
584
|
+
*
|
|
585
|
+
* \param matrix the matrix to decompose
|
|
586
|
+
* \param computationOptions specify whether to compute Thin/Full unitaries U/V
|
|
587
|
+
*
|
|
588
|
+
* \deprecated Will be removed in the next major Eigen version. Options should
|
|
589
|
+
* be specified in the \a Options template parameter.
|
|
590
|
+
*/
|
|
591
|
+
// EIGEN_DEPRECATED // TODO(cantonios): re-enable after fixing a few 3p libraries that error on deprecation warnings.
|
|
592
|
+
template <typename Derived>
|
|
593
|
+
JacobiSVD(const MatrixBase<Derived>& matrix, unsigned int computationOptions) {
|
|
594
|
+
internal::check_svd_options_assertions<MatrixBase<Derived>, Options>(computationOptions, matrix.rows(),
|
|
595
|
+
matrix.cols());
|
|
596
|
+
compute_impl(matrix, computationOptions);
|
|
623
597
|
}
|
|
624
598
|
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
m_computeThinV = (computationOptions & ComputeThinV) != 0;
|
|
634
|
-
eigen_assert(!(m_computeFullU && m_computeThinU) && "JacobiSVD: you can't ask for both full and thin U");
|
|
635
|
-
eigen_assert(!(m_computeFullV && m_computeThinV) && "JacobiSVD: you can't ask for both full and thin V");
|
|
636
|
-
eigen_assert(EIGEN_IMPLIES(m_computeThinU || m_computeThinV, MatrixType::ColsAtCompileTime==Dynamic) &&
|
|
637
|
-
"JacobiSVD: thin U and V are only available when your matrix has a dynamic number of columns.");
|
|
638
|
-
if (QRPreconditioner == FullPivHouseholderQRPreconditioner)
|
|
639
|
-
{
|
|
640
|
-
eigen_assert(!(m_computeThinU || m_computeThinV) &&
|
|
641
|
-
"JacobiSVD: can't compute thin U or thin V with the FullPivHouseholderQR preconditioner. "
|
|
642
|
-
"Use the ColPivHouseholderQR preconditioner instead.");
|
|
599
|
+
/** \brief Method performing the decomposition of given matrix. Computes Thin/Full unitaries U/V if specified
|
|
600
|
+
* using the \a Options template parameter or the class constructor.
|
|
601
|
+
*
|
|
602
|
+
* \param matrix the matrix to decompose
|
|
603
|
+
*/
|
|
604
|
+
template <typename Derived>
|
|
605
|
+
JacobiSVD& compute(const MatrixBase<Derived>& matrix) {
|
|
606
|
+
return compute_impl(matrix, m_computationOptions);
|
|
643
607
|
}
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
608
|
+
|
|
609
|
+
template <typename Derived>
|
|
610
|
+
JacobiSVD& compute(const TriangularBase<Derived>& matrix) {
|
|
611
|
+
return compute_impl(matrix, m_computationOptions);
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
/** \brief Method performing the decomposition of given matrix, as specified by
|
|
615
|
+
* the `computationOptions` parameter.
|
|
616
|
+
*
|
|
617
|
+
* \param matrix the matrix to decompose
|
|
618
|
+
* \param computationOptions specify whether to compute Thin/Full unitaries U/V
|
|
619
|
+
*
|
|
620
|
+
* \deprecated Will be removed in the next major Eigen version. Options should
|
|
621
|
+
* be specified in the \a Options template parameter.
|
|
622
|
+
*/
|
|
623
|
+
template <typename Derived>
|
|
624
|
+
EIGEN_DEPRECATED_WITH_REASON("Options should be specified using the class template parameter.")
|
|
625
|
+
JacobiSVD& compute(const MatrixBase<Derived>& matrix, unsigned int computationOptions) {
|
|
626
|
+
internal::check_svd_options_assertions<MatrixBase<Derived>, Options>(m_computationOptions, matrix.rows(),
|
|
627
|
+
matrix.cols());
|
|
628
|
+
return compute_impl(matrix, computationOptions);
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
using Base::cols;
|
|
632
|
+
using Base::computeU;
|
|
633
|
+
using Base::computeV;
|
|
634
|
+
using Base::diagSize;
|
|
635
|
+
using Base::rank;
|
|
636
|
+
using Base::rows;
|
|
637
|
+
|
|
638
|
+
void allocate(Index rows_, Index cols_, unsigned int computationOptions) {
|
|
639
|
+
if (Base::allocate(rows_, cols_, computationOptions)) return;
|
|
640
|
+
eigen_assert(!(ShouldComputeThinU && int(QRPreconditioner) == int(FullPivHouseholderQRPreconditioner)) &&
|
|
641
|
+
!(ShouldComputeThinU && int(QRPreconditioner) == int(FullPivHouseholderQRPreconditioner)) &&
|
|
642
|
+
"JacobiSVD: can't compute thin U or thin V with the FullPivHouseholderQR preconditioner. "
|
|
643
|
+
"Use the ColPivHouseholderQR preconditioner instead.");
|
|
644
|
+
|
|
645
|
+
m_workMatrix.resize(diagSize(), diagSize());
|
|
646
|
+
if (cols() > rows()) m_qr_precond_morecols.allocate(*this);
|
|
647
|
+
if (rows() > cols()) m_qr_precond_morerows.allocate(*this);
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
private:
|
|
651
|
+
template <typename Derived>
|
|
652
|
+
JacobiSVD& compute_impl(const TriangularBase<Derived>& matrix, unsigned int computationOptions);
|
|
653
|
+
template <typename Derived>
|
|
654
|
+
JacobiSVD& compute_impl(const MatrixBase<Derived>& matrix, unsigned int computationOptions);
|
|
655
|
+
|
|
656
|
+
protected:
|
|
657
|
+
using Base::m_computationOptions;
|
|
658
|
+
using Base::m_computeFullU;
|
|
659
|
+
using Base::m_computeFullV;
|
|
660
|
+
using Base::m_computeThinU;
|
|
661
|
+
using Base::m_computeThinV;
|
|
662
|
+
using Base::m_info;
|
|
663
|
+
using Base::m_isAllocated;
|
|
664
|
+
using Base::m_isInitialized;
|
|
665
|
+
using Base::m_matrixU;
|
|
666
|
+
using Base::m_matrixV;
|
|
667
|
+
using Base::m_nonzeroSingularValues;
|
|
668
|
+
using Base::m_prescribedThreshold;
|
|
669
|
+
using Base::m_singularValues;
|
|
670
|
+
using Base::m_usePrescribedThreshold;
|
|
671
|
+
using Base::ShouldComputeThinU;
|
|
672
|
+
using Base::ShouldComputeThinV;
|
|
673
|
+
|
|
674
|
+
EIGEN_STATIC_ASSERT(!(ShouldComputeThinU && int(QRPreconditioner) == int(FullPivHouseholderQRPreconditioner)) &&
|
|
675
|
+
!(ShouldComputeThinU && int(QRPreconditioner) == int(FullPivHouseholderQRPreconditioner)),
|
|
676
|
+
"JacobiSVD: can't compute thin U or thin V with the FullPivHouseholderQR preconditioner. "
|
|
677
|
+
"Use the ColPivHouseholderQR preconditioner instead.")
|
|
678
|
+
|
|
679
|
+
template <typename MatrixType__, int Options__, bool IsComplex_>
|
|
680
|
+
friend struct internal::svd_precondition_2x2_block_to_be_real;
|
|
681
|
+
template <typename MatrixType__, int Options__, int QRPreconditioner_, int Case_, bool DoAnything_>
|
|
682
|
+
friend struct internal::qr_preconditioner_impl;
|
|
683
|
+
|
|
684
|
+
internal::qr_preconditioner_impl<MatrixType, Options, QRPreconditioner, internal::PreconditionIfMoreColsThanRows>
|
|
685
|
+
m_qr_precond_morecols;
|
|
686
|
+
internal::qr_preconditioner_impl<MatrixType, Options, QRPreconditioner, internal::PreconditionIfMoreRowsThanCols>
|
|
687
|
+
m_qr_precond_morerows;
|
|
688
|
+
WorkMatrixType m_workMatrix;
|
|
689
|
+
};
|
|
690
|
+
|
|
691
|
+
template <typename MatrixType, int Options>
|
|
692
|
+
template <typename Derived>
|
|
693
|
+
JacobiSVD<MatrixType, Options>& JacobiSVD<MatrixType, Options>::compute_impl(const TriangularBase<Derived>& matrix,
|
|
694
|
+
unsigned int computationOptions) {
|
|
695
|
+
return compute_impl(matrix.toDenseMatrix(), computationOptions);
|
|
659
696
|
}
|
|
660
697
|
|
|
661
|
-
template<typename MatrixType, int
|
|
662
|
-
|
|
663
|
-
JacobiSVD<MatrixType,
|
|
664
|
-
{
|
|
698
|
+
template <typename MatrixType, int Options>
|
|
699
|
+
template <typename Derived>
|
|
700
|
+
JacobiSVD<MatrixType, Options>& JacobiSVD<MatrixType, Options>::compute_impl(const MatrixBase<Derived>& matrix,
|
|
701
|
+
unsigned int computationOptions) {
|
|
702
|
+
EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Derived, MatrixType);
|
|
703
|
+
EIGEN_STATIC_ASSERT((std::is_same<typename Derived::Scalar, typename MatrixType::Scalar>::value),
|
|
704
|
+
Input matrix must have the same Scalar type as the BDCSVD object.);
|
|
705
|
+
|
|
665
706
|
using std::abs;
|
|
707
|
+
|
|
666
708
|
allocate(matrix.rows(), matrix.cols(), computationOptions);
|
|
667
709
|
|
|
668
|
-
// currently we stop when we reach precision 2*epsilon as the last bit of precision can require an unreasonable number
|
|
669
|
-
// only worsening the precision of U and V as we accumulate more rotations
|
|
710
|
+
// currently we stop when we reach precision 2*epsilon as the last bit of precision can require an unreasonable number
|
|
711
|
+
// of iterations, only worsening the precision of U and V as we accumulate more rotations
|
|
670
712
|
const RealScalar precision = RealScalar(2) * NumTraits<Scalar>::epsilon();
|
|
671
713
|
|
|
672
714
|
// limit for denormal numbers to be considered zero in order to avoid infinite loops (see bug 286)
|
|
673
715
|
const RealScalar considerAsZero = (std::numeric_limits<RealScalar>::min)();
|
|
674
716
|
|
|
675
717
|
// Scaling factor to reduce over/under-flows
|
|
676
|
-
RealScalar scale = matrix.cwiseAbs().maxCoeff();
|
|
677
|
-
if(
|
|
678
|
-
|
|
718
|
+
RealScalar scale = matrix.cwiseAbs().template maxCoeff<PropagateNaN>();
|
|
719
|
+
if (!(numext::isfinite)(scale)) {
|
|
720
|
+
m_isInitialized = true;
|
|
721
|
+
m_info = InvalidInput;
|
|
722
|
+
m_nonzeroSingularValues = 0;
|
|
723
|
+
return *this;
|
|
724
|
+
}
|
|
725
|
+
if (numext::is_exactly_zero(scale)) scale = RealScalar(1);
|
|
726
|
+
|
|
679
727
|
/*** step 1. The R-SVD step: we use a QR decomposition to reduce to the case of a square matrix */
|
|
680
728
|
|
|
681
|
-
if(
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
if(
|
|
691
|
-
if(m_computeThinU) m_matrixU.setIdentity(m_rows,m_diagSize);
|
|
692
|
-
if(m_computeFullV) m_matrixV.setIdentity(m_cols,m_cols);
|
|
693
|
-
if(m_computeThinV) m_matrixV.setIdentity(m_cols, m_diagSize);
|
|
729
|
+
if (rows() != cols()) {
|
|
730
|
+
m_qr_precond_morecols.run(*this, matrix / scale);
|
|
731
|
+
m_qr_precond_morerows.run(*this, matrix / scale);
|
|
732
|
+
} else {
|
|
733
|
+
m_workMatrix =
|
|
734
|
+
matrix.template topLeftCorner<DiagSizeAtCompileTime, DiagSizeAtCompileTime>(diagSize(), diagSize()) / scale;
|
|
735
|
+
if (m_computeFullU) m_matrixU.setIdentity(rows(), rows());
|
|
736
|
+
if (m_computeThinU) m_matrixU.setIdentity(rows(), diagSize());
|
|
737
|
+
if (m_computeFullV) m_matrixV.setIdentity(cols(), cols());
|
|
738
|
+
if (m_computeThinV) m_matrixV.setIdentity(cols(), diagSize());
|
|
694
739
|
}
|
|
695
740
|
|
|
696
741
|
/*** step 2. The main Jacobi SVD iteration. ***/
|
|
697
742
|
RealScalar maxDiagEntry = m_workMatrix.cwiseAbs().diagonal().maxCoeff();
|
|
698
743
|
|
|
699
744
|
bool finished = false;
|
|
700
|
-
while(!finished)
|
|
701
|
-
{
|
|
745
|
+
while (!finished) {
|
|
702
746
|
finished = true;
|
|
703
747
|
|
|
704
748
|
// do a sweep: for all index pairs (p,q), perform SVD of the corresponding 2x2 sub-matrix
|
|
705
749
|
|
|
706
|
-
for(Index p = 1; p <
|
|
707
|
-
|
|
708
|
-
for(Index q = 0; q < p; ++q)
|
|
709
|
-
{
|
|
750
|
+
for (Index p = 1; p < diagSize(); ++p) {
|
|
751
|
+
for (Index q = 0; q < p; ++q) {
|
|
710
752
|
// if this 2x2 sub-matrix is not diagonal already...
|
|
711
753
|
// notice that this comparison will evaluate to false if any NaN is involved, ensuring that NaN's don't
|
|
712
754
|
// keep us iterating forever. Similarly, small denormal numbers are considered zero.
|
|
713
755
|
RealScalar threshold = numext::maxi<RealScalar>(considerAsZero, precision * maxDiagEntry);
|
|
714
|
-
if(abs(m_workMatrix.coeff(p,q))>threshold || abs(m_workMatrix.coeff(q,p)) > threshold)
|
|
715
|
-
{
|
|
756
|
+
if (abs(m_workMatrix.coeff(p, q)) > threshold || abs(m_workMatrix.coeff(q, p)) > threshold) {
|
|
716
757
|
finished = false;
|
|
717
758
|
// perform SVD decomposition of 2x2 sub-matrix corresponding to indices p,q to make it diagonal
|
|
718
759
|
// the complex to real operation returns true if the updated 2x2 block is not already diagonal
|
|
719
|
-
if(internal::svd_precondition_2x2_block_to_be_real<MatrixType,
|
|
720
|
-
|
|
760
|
+
if (internal::svd_precondition_2x2_block_to_be_real<MatrixType, Options>::run(m_workMatrix, *this, p, q,
|
|
761
|
+
maxDiagEntry)) {
|
|
721
762
|
JacobiRotation<RealScalar> j_left, j_right;
|
|
722
763
|
internal::real_2x2_jacobi_svd(m_workMatrix, p, q, &j_left, &j_right);
|
|
723
764
|
|
|
724
765
|
// accumulate resulting Jacobi rotations
|
|
725
|
-
m_workMatrix.applyOnTheLeft(p,q,j_left);
|
|
726
|
-
if(computeU()) m_matrixU.applyOnTheRight(p,q,j_left.transpose());
|
|
766
|
+
m_workMatrix.applyOnTheLeft(p, q, j_left);
|
|
767
|
+
if (computeU()) m_matrixU.applyOnTheRight(p, q, j_left.transpose());
|
|
727
768
|
|
|
728
|
-
m_workMatrix.applyOnTheRight(p,q,j_right);
|
|
729
|
-
if(computeV()) m_matrixV.applyOnTheRight(p,q,j_right);
|
|
769
|
+
m_workMatrix.applyOnTheRight(p, q, j_right);
|
|
770
|
+
if (computeV()) m_matrixV.applyOnTheRight(p, q, j_right);
|
|
730
771
|
|
|
731
772
|
// keep track of the largest diagonal coefficient
|
|
732
|
-
maxDiagEntry = numext::maxi<RealScalar>(
|
|
773
|
+
maxDiagEntry = numext::maxi<RealScalar>(
|
|
774
|
+
maxDiagEntry, numext::maxi<RealScalar>(abs(m_workMatrix.coeff(p, p)), abs(m_workMatrix.coeff(q, q))));
|
|
733
775
|
}
|
|
734
776
|
}
|
|
735
777
|
}
|
|
736
778
|
}
|
|
737
779
|
}
|
|
738
780
|
|
|
739
|
-
/*** step 3. The work matrix is now diagonal, so ensure it's positive so its diagonal entries are the singular values
|
|
781
|
+
/*** step 3. The work matrix is now diagonal, so ensure it's positive so its diagonal entries are the singular values
|
|
782
|
+
* ***/
|
|
740
783
|
|
|
741
|
-
for(Index i = 0; i <
|
|
742
|
-
{
|
|
784
|
+
for (Index i = 0; i < diagSize(); ++i) {
|
|
743
785
|
// For a complex matrix, some diagonal coefficients might note have been
|
|
744
786
|
// treated by svd_precondition_2x2_block_to_be_real, and the imaginary part
|
|
745
787
|
// of some diagonal entry might not be null.
|
|
746
|
-
if(NumTraits<Scalar>::IsComplex && abs(numext::imag(m_workMatrix.coeff(i,i)))>considerAsZero)
|
|
747
|
-
|
|
748
|
-
RealScalar a = abs(m_workMatrix.coeff(i,i));
|
|
788
|
+
if (NumTraits<Scalar>::IsComplex && abs(numext::imag(m_workMatrix.coeff(i, i))) > considerAsZero) {
|
|
789
|
+
RealScalar a = abs(m_workMatrix.coeff(i, i));
|
|
749
790
|
m_singularValues.coeffRef(i) = abs(a);
|
|
750
|
-
if(computeU()) m_matrixU.col(i) *= m_workMatrix.coeff(i,i)/a;
|
|
751
|
-
}
|
|
752
|
-
else
|
|
753
|
-
{
|
|
791
|
+
if (computeU()) m_matrixU.col(i) *= m_workMatrix.coeff(i, i) / a;
|
|
792
|
+
} else {
|
|
754
793
|
// m_workMatrix.coeff(i,i) is already real, no difficulty:
|
|
755
|
-
RealScalar a = numext::real(m_workMatrix.coeff(i,i));
|
|
794
|
+
RealScalar a = numext::real(m_workMatrix.coeff(i, i));
|
|
756
795
|
m_singularValues.coeffRef(i) = abs(a);
|
|
757
|
-
if(computeU() && (a<RealScalar(0))) m_matrixU.col(i) = -m_matrixU.col(i);
|
|
796
|
+
if (computeU() && (a < RealScalar(0))) m_matrixU.col(i) = -m_matrixU.col(i);
|
|
758
797
|
}
|
|
759
798
|
}
|
|
760
|
-
|
|
799
|
+
|
|
761
800
|
m_singularValues *= scale;
|
|
762
801
|
|
|
763
802
|
/*** step 4. Sort singular values in descending order and compute the number of nonzero singular values ***/
|
|
764
803
|
|
|
765
|
-
m_nonzeroSingularValues =
|
|
766
|
-
for(Index i = 0; i <
|
|
767
|
-
{
|
|
804
|
+
m_nonzeroSingularValues = diagSize();
|
|
805
|
+
for (Index i = 0; i < diagSize(); i++) {
|
|
768
806
|
Index pos;
|
|
769
|
-
RealScalar maxRemainingSingularValue = m_singularValues.tail(
|
|
770
|
-
if(maxRemainingSingularValue
|
|
771
|
-
{
|
|
807
|
+
RealScalar maxRemainingSingularValue = m_singularValues.tail(diagSize() - i).maxCoeff(&pos);
|
|
808
|
+
if (numext::is_exactly_zero(maxRemainingSingularValue)) {
|
|
772
809
|
m_nonzeroSingularValues = i;
|
|
773
810
|
break;
|
|
774
811
|
}
|
|
775
|
-
if(pos)
|
|
776
|
-
{
|
|
812
|
+
if (pos) {
|
|
777
813
|
pos += i;
|
|
778
814
|
std::swap(m_singularValues.coeffRef(i), m_singularValues.coeffRef(pos));
|
|
779
|
-
if(computeU()) m_matrixU.col(pos).swap(m_matrixU.col(i));
|
|
780
|
-
if(computeV()) m_matrixV.col(pos).swap(m_matrixV.col(i));
|
|
815
|
+
if (computeU()) m_matrixU.col(pos).swap(m_matrixU.col(i));
|
|
816
|
+
if (computeV()) m_matrixV.col(pos).swap(m_matrixV.col(i));
|
|
781
817
|
}
|
|
782
818
|
}
|
|
783
819
|
|
|
@@ -786,19 +822,25 @@ JacobiSVD<MatrixType, QRPreconditioner>::compute(const MatrixType& matrix, unsig
|
|
|
786
822
|
}
|
|
787
823
|
|
|
788
824
|
/** \svd_module
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
template<typename Derived>
|
|
796
|
-
|
|
797
|
-
MatrixBase<Derived>::jacobiSvd(
|
|
798
|
-
|
|
799
|
-
|
|
825
|
+
*
|
|
826
|
+
* \return the singular value decomposition of \c *this computed by two-sided
|
|
827
|
+
* Jacobi transformations.
|
|
828
|
+
*
|
|
829
|
+
* \sa class JacobiSVD
|
|
830
|
+
*/
|
|
831
|
+
template <typename Derived>
|
|
832
|
+
template <int Options>
|
|
833
|
+
JacobiSVD<typename MatrixBase<Derived>::PlainObject, Options> MatrixBase<Derived>::jacobiSvd() const {
|
|
834
|
+
return JacobiSVD<PlainObject, Options>(*this);
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
template <typename Derived>
|
|
838
|
+
template <int Options>
|
|
839
|
+
JacobiSVD<typename MatrixBase<Derived>::PlainObject, Options> MatrixBase<Derived>::jacobiSvd(
|
|
840
|
+
unsigned int computationOptions) const {
|
|
841
|
+
return JacobiSVD<PlainObject, Options>(*this, computationOptions);
|
|
800
842
|
}
|
|
801
843
|
|
|
802
|
-
}
|
|
844
|
+
} // end namespace Eigen
|
|
803
845
|
|
|
804
|
-
#endif
|
|
846
|
+
#endif // EIGEN_JACOBISVD_H
|