@smake/eigen 1.1.0 → 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 -20
- package/eigen/Eigen/CholmodSupport +28 -28
- package/eigen/Eigen/Core +187 -120
- package/eigen/Eigen/Eigenvalues +16 -13
- package/eigen/Eigen/Geometry +18 -18
- package/eigen/Eigen/Householder +9 -7
- package/eigen/Eigen/IterativeLinearSolvers +8 -4
- package/eigen/Eigen/Jacobi +14 -13
- package/eigen/Eigen/KLUSupport +23 -21
- package/eigen/Eigen/LU +15 -16
- package/eigen/Eigen/MetisSupport +12 -12
- package/eigen/Eigen/OrderingMethods +54 -51
- package/eigen/Eigen/PaStiXSupport +23 -21
- package/eigen/Eigen/PardisoSupport +17 -14
- package/eigen/Eigen/QR +18 -20
- package/eigen/Eigen/QtAlignedMalloc +5 -12
- package/eigen/Eigen/SPQRSupport +21 -14
- package/eigen/Eigen/SVD +23 -17
- package/eigen/Eigen/Sparse +1 -2
- package/eigen/Eigen/SparseCholesky +18 -15
- package/eigen/Eigen/SparseCore +18 -17
- package/eigen/Eigen/SparseLU +9 -9
- 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 +366 -405
- package/eigen/Eigen/src/Cholesky/LLT.h +323 -367
- package/eigen/Eigen/src/Cholesky/LLT_LAPACKE.h +81 -56
- package/eigen/Eigen/src/CholmodSupport/CholmodSupport.h +585 -529
- package/eigen/Eigen/src/CholmodSupport/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/Core/ArithmeticSequence.h +143 -317
- package/eigen/Eigen/src/Core/Array.h +329 -370
- package/eigen/Eigen/src/Core/ArrayBase.h +190 -203
- package/eigen/Eigen/src/Core/ArrayWrapper.h +126 -170
- package/eigen/Eigen/src/Core/Assign.h +30 -40
- package/eigen/Eigen/src/Core/AssignEvaluator.h +651 -604
- package/eigen/Eigen/src/Core/Assign_MKL.h +125 -120
- package/eigen/Eigen/src/Core/BandMatrix.h +267 -282
- package/eigen/Eigen/src/Core/Block.h +371 -390
- package/eigen/Eigen/src/Core/CommaInitializer.h +85 -100
- package/eigen/Eigen/src/Core/ConditionEstimator.h +51 -53
- package/eigen/Eigen/src/Core/CoreEvaluators.h +1214 -937
- package/eigen/Eigen/src/Core/CoreIterators.h +72 -63
- package/eigen/Eigen/src/Core/CwiseBinaryOp.h +112 -129
- package/eigen/Eigen/src/Core/CwiseNullaryOp.h +676 -702
- package/eigen/Eigen/src/Core/CwiseTernaryOp.h +77 -103
- package/eigen/Eigen/src/Core/CwiseUnaryOp.h +55 -67
- package/eigen/Eigen/src/Core/CwiseUnaryView.h +127 -92
- package/eigen/Eigen/src/Core/DenseBase.h +630 -658
- package/eigen/Eigen/src/Core/DenseCoeffsBase.h +511 -628
- package/eigen/Eigen/src/Core/DenseStorage.h +511 -590
- package/eigen/Eigen/src/Core/DeviceWrapper.h +153 -0
- package/eigen/Eigen/src/Core/Diagonal.h +168 -207
- package/eigen/Eigen/src/Core/DiagonalMatrix.h +346 -317
- package/eigen/Eigen/src/Core/DiagonalProduct.h +12 -10
- package/eigen/Eigen/src/Core/Dot.h +167 -217
- package/eigen/Eigen/src/Core/EigenBase.h +74 -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 -113
- package/eigen/Eigen/src/Core/Fuzzy.h +82 -105
- package/eigen/Eigen/src/Core/GeneralProduct.h +315 -261
- package/eigen/Eigen/src/Core/GenericPacketMath.h +1182 -520
- package/eigen/Eigen/src/Core/GlobalFunctions.h +193 -157
- package/eigen/Eigen/src/Core/IO.h +131 -156
- package/eigen/Eigen/src/Core/IndexedView.h +209 -125
- 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 +50 -59
- package/eigen/Eigen/src/Core/Map.h +123 -141
- package/eigen/Eigen/src/Core/MapBase.h +255 -282
- package/eigen/Eigen/src/Core/MathFunctions.h +1247 -1201
- package/eigen/Eigen/src/Core/MathFunctionsImpl.h +162 -99
- package/eigen/Eigen/src/Core/Matrix.h +463 -494
- package/eigen/Eigen/src/Core/MatrixBase.h +468 -470
- package/eigen/Eigen/src/Core/NestByValue.h +58 -52
- package/eigen/Eigen/src/Core/NoAlias.h +79 -86
- package/eigen/Eigen/src/Core/NumTraits.h +206 -206
- package/eigen/Eigen/src/Core/PartialReduxEvaluator.h +163 -142
- package/eigen/Eigen/src/Core/PermutationMatrix.h +461 -511
- package/eigen/Eigen/src/Core/PlainObjectBase.h +858 -972
- package/eigen/Eigen/src/Core/Product.h +246 -130
- package/eigen/Eigen/src/Core/ProductEvaluators.h +779 -671
- package/eigen/Eigen/src/Core/Random.h +153 -164
- 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 +334 -314
- package/eigen/Eigen/src/Core/Ref.h +259 -257
- package/eigen/Eigen/src/Core/Replicate.h +92 -104
- package/eigen/Eigen/src/Core/Reshaped.h +215 -271
- package/eigen/Eigen/src/Core/ReturnByValue.h +47 -55
- package/eigen/Eigen/src/Core/Reverse.h +133 -148
- package/eigen/Eigen/src/Core/Select.h +68 -140
- package/eigen/Eigen/src/Core/SelfAdjointView.h +254 -290
- 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 +88 -102
- package/eigen/Eigen/src/Core/SolveTriangular.h +126 -124
- package/eigen/Eigen/src/Core/SolverBase.h +132 -133
- package/eigen/Eigen/src/Core/StableNorm.h +113 -147
- package/eigen/Eigen/src/Core/StlIterators.h +404 -248
- package/eigen/Eigen/src/Core/Stride.h +90 -92
- package/eigen/Eigen/src/Core/Swap.h +70 -39
- package/eigen/Eigen/src/Core/Transpose.h +258 -295
- package/eigen/Eigen/src/Core/Transpositions.h +270 -333
- package/eigen/Eigen/src/Core/TriangularMatrix.h +642 -743
- package/eigen/Eigen/src/Core/VectorBlock.h +59 -72
- package/eigen/Eigen/src/Core/VectorwiseOp.h +653 -704
- package/eigen/Eigen/src/Core/Visitor.h +464 -308
- package/eigen/Eigen/src/Core/arch/AVX/Complex.h +380 -187
- package/eigen/Eigen/src/Core/arch/AVX/MathFunctions.h +65 -163
- package/eigen/Eigen/src/Core/arch/AVX/PacketMath.h +2145 -638
- package/eigen/Eigen/src/Core/arch/AVX/Reductions.h +353 -0
- package/eigen/Eigen/src/Core/arch/AVX/TypeCasting.h +253 -60
- package/eigen/Eigen/src/Core/arch/AVX512/Complex.h +278 -228
- package/eigen/Eigen/src/Core/arch/AVX512/GemmKernel.h +1245 -0
- package/eigen/Eigen/src/Core/arch/AVX512/MathFunctions.h +48 -269
- package/eigen/Eigen/src/Core/arch/AVX512/MathFunctionsFP16.h +75 -0
- package/eigen/Eigen/src/Core/arch/AVX512/PacketMath.h +1597 -754
- 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 +229 -41
- package/eigen/Eigen/src/Core/arch/AVX512/TypeCastingFP16.h +130 -0
- package/eigen/Eigen/src/Core/arch/AltiVec/Complex.h +420 -184
- package/eigen/Eigen/src/Core/arch/AltiVec/MathFunctions.h +40 -49
- package/eigen/Eigen/src/Core/arch/AltiVec/MatrixProduct.h +2962 -2213
- package/eigen/Eigen/src/Core/arch/AltiVec/MatrixProductCommon.h +196 -212
- package/eigen/Eigen/src/Core/arch/AltiVec/MatrixProductMMA.h +713 -441
- 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 +2380 -1362
- package/eigen/Eigen/src/Core/arch/AltiVec/TypeCasting.h +153 -0
- package/eigen/Eigen/src/Core/arch/Default/BFloat16.h +390 -224
- package/eigen/Eigen/src/Core/arch/Default/ConjHelper.h +78 -67
- package/eigen/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h +1784 -799
- package/eigen/Eigen/src/Core/arch/Default/GenericPacketMathFunctionsFwd.h +167 -50
- package/eigen/Eigen/src/Core/arch/Default/Half.h +528 -379
- package/eigen/Eigen/src/Core/arch/Default/Settings.h +10 -12
- package/eigen/Eigen/src/Core/arch/GPU/Complex.h +244 -0
- package/eigen/Eigen/src/Core/arch/GPU/MathFunctions.h +41 -40
- package/eigen/Eigen/src/Core/arch/GPU/PacketMath.h +550 -523
- package/eigen/Eigen/src/Core/arch/GPU/Tuple.h +268 -0
- package/eigen/Eigen/src/Core/arch/GPU/TypeCasting.h +27 -30
- package/eigen/Eigen/src/Core/arch/HIP/hcc/math_constants.h +8 -8
- 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 +54 -82
- package/eigen/Eigen/src/Core/arch/MSA/MathFunctions.h +84 -92
- package/eigen/Eigen/src/Core/arch/MSA/PacketMath.h +51 -47
- package/eigen/Eigen/src/Core/arch/NEON/Complex.h +454 -306
- package/eigen/Eigen/src/Core/arch/NEON/GeneralBlockPanelKernel.h +175 -115
- package/eigen/Eigen/src/Core/arch/NEON/MathFunctions.h +23 -30
- package/eigen/Eigen/src/Core/arch/NEON/PacketMath.h +4366 -2857
- package/eigen/Eigen/src/Core/arch/NEON/TypeCasting.h +616 -393
- package/eigen/Eigen/src/Core/arch/NEON/UnaryFunctors.h +57 -0
- package/eigen/Eigen/src/Core/arch/SSE/Complex.h +350 -198
- package/eigen/Eigen/src/Core/arch/SSE/MathFunctions.h +38 -149
- package/eigen/Eigen/src/Core/arch/SSE/PacketMath.h +1791 -912
- package/eigen/Eigen/src/Core/arch/SSE/Reductions.h +324 -0
- package/eigen/Eigen/src/Core/arch/SSE/TypeCasting.h +128 -40
- package/eigen/Eigen/src/Core/arch/SVE/MathFunctions.h +10 -6
- package/eigen/Eigen/src/Core/arch/SVE/PacketMath.h +156 -234
- package/eigen/Eigen/src/Core/arch/SVE/TypeCasting.h +6 -3
- package/eigen/Eigen/src/Core/arch/SYCL/InteropHeaders.h +27 -32
- package/eigen/Eigen/src/Core/arch/SYCL/MathFunctions.h +119 -117
- package/eigen/Eigen/src/Core/arch/SYCL/PacketMath.h +325 -419
- package/eigen/Eigen/src/Core/arch/SYCL/TypeCasting.h +15 -17
- package/eigen/Eigen/src/Core/arch/ZVector/Complex.h +325 -181
- package/eigen/Eigen/src/Core/arch/ZVector/MathFunctions.h +94 -83
- package/eigen/Eigen/src/Core/arch/ZVector/PacketMath.h +811 -458
- package/eigen/Eigen/src/Core/functors/AssignmentFunctors.h +121 -124
- package/eigen/Eigen/src/Core/functors/BinaryFunctors.h +576 -370
- package/eigen/Eigen/src/Core/functors/NullaryFunctors.h +194 -109
- package/eigen/Eigen/src/Core/functors/StlFunctors.h +95 -112
- package/eigen/Eigen/src/Core/functors/TernaryFunctors.h +34 -7
- package/eigen/Eigen/src/Core/functors/UnaryFunctors.h +1038 -749
- package/eigen/Eigen/src/Core/products/GeneralBlockPanelKernel.h +1883 -1375
- package/eigen/Eigen/src/Core/products/GeneralMatrixMatrix.h +312 -370
- package/eigen/Eigen/src/Core/products/GeneralMatrixMatrixTriangular.h +189 -176
- package/eigen/Eigen/src/Core/products/GeneralMatrixMatrixTriangular_BLAS.h +84 -81
- package/eigen/Eigen/src/Core/products/GeneralMatrixMatrix_BLAS.h +154 -73
- package/eigen/Eigen/src/Core/products/GeneralMatrixVector.h +292 -337
- package/eigen/Eigen/src/Core/products/GeneralMatrixVector_BLAS.h +80 -77
- package/eigen/Eigen/src/Core/products/Parallelizer.h +207 -105
- package/eigen/Eigen/src/Core/products/SelfadjointMatrixMatrix.h +327 -388
- package/eigen/Eigen/src/Core/products/SelfadjointMatrixMatrix_BLAS.h +206 -224
- package/eigen/Eigen/src/Core/products/SelfadjointMatrixVector.h +138 -147
- 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 -47
- 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 -277
- package/eigen/Eigen/src/Core/products/TriangularSolverMatrix_BLAS.h +108 -109
- package/eigen/Eigen/src/Core/products/TriangularSolverVector.h +68 -94
- package/eigen/Eigen/src/Core/util/Assert.h +158 -0
- package/eigen/Eigen/src/Core/util/BlasUtil.h +342 -303
- package/eigen/Eigen/src/Core/util/ConfigureVectorization.h +348 -317
- package/eigen/Eigen/src/Core/util/Constants.h +297 -262
- package/eigen/Eigen/src/Core/util/DisableStupidWarnings.h +130 -90
- package/eigen/Eigen/src/Core/util/EmulateArray.h +270 -0
- package/eigen/Eigen/src/Core/util/ForwardDeclarations.h +449 -247
- 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 +417 -116
- package/eigen/Eigen/src/Core/util/IntegralConstant.h +211 -204
- package/eigen/Eigen/src/Core/util/MKL_support.h +39 -37
- package/eigen/Eigen/src/Core/util/Macros.h +655 -773
- package/eigen/Eigen/src/Core/util/MaxSizeVector.h +139 -0
- package/eigen/Eigen/src/Core/util/Memory.h +970 -748
- package/eigen/Eigen/src/Core/util/Meta.h +581 -633
- 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 +17 -17
- package/eigen/Eigen/src/Core/util/Serializer.h +209 -0
- package/eigen/Eigen/src/Core/util/StaticAssert.h +50 -166
- package/eigen/Eigen/src/Core/util/SymbolicIndex.h +377 -225
- package/eigen/Eigen/src/Core/util/XprHelper.h +784 -547
- 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 +89 -105
- package/eigen/Eigen/src/Eigenvalues/RealQZ.h +537 -607
- package/eigen/Eigen/src/Eigenvalues/RealSchur.h +342 -381
- package/eigen/Eigen/src/Eigenvalues/RealSchur_LAPACKE.h +41 -35
- package/eigen/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h +541 -595
- package/eigen/Eigen/src/Eigenvalues/SelfAdjointEigenSolver_LAPACKE.h +47 -44
- package/eigen/Eigen/src/Eigenvalues/Tridiagonalization.h +430 -462
- package/eigen/Eigen/src/Geometry/AlignedBox.h +226 -227
- package/eigen/Eigen/src/Geometry/AngleAxis.h +131 -133
- package/eigen/Eigen/src/Geometry/EulerAngles.h +163 -74
- package/eigen/Eigen/src/Geometry/Homogeneous.h +285 -333
- package/eigen/Eigen/src/Geometry/Hyperplane.h +151 -160
- package/eigen/Eigen/src/Geometry/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/Geometry/OrthoMethods.h +168 -146
- package/eigen/Eigen/src/Geometry/ParametrizedLine.h +127 -127
- package/eigen/Eigen/src/Geometry/Quaternion.h +566 -506
- package/eigen/Eigen/src/Geometry/Rotation2D.h +107 -105
- package/eigen/Eigen/src/Geometry/RotationBase.h +148 -145
- package/eigen/Eigen/src/Geometry/Scaling.h +113 -106
- package/eigen/Eigen/src/Geometry/Transform.h +858 -936
- package/eigen/Eigen/src/Geometry/Translation.h +94 -92
- package/eigen/Eigen/src/Geometry/Umeyama.h +79 -84
- package/eigen/Eigen/src/Geometry/arch/Geometry_SIMD.h +90 -104
- package/eigen/Eigen/src/Householder/BlockHouseholder.h +51 -46
- package/eigen/Eigen/src/Householder/Householder.h +102 -124
- package/eigen/Eigen/src/Householder/HouseholderSequence.h +412 -453
- package/eigen/Eigen/src/Householder/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/IterativeLinearSolvers/BasicPreconditioners.h +149 -162
- package/eigen/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h +124 -119
- package/eigen/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h +92 -104
- package/eigen/Eigen/src/IterativeLinearSolvers/IncompleteCholesky.h +251 -243
- package/eigen/Eigen/src/IterativeLinearSolvers/IncompleteLUT.h +224 -228
- package/eigen/Eigen/src/IterativeLinearSolvers/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/IterativeLinearSolvers/IterativeSolverBase.h +178 -227
- package/eigen/Eigen/src/IterativeLinearSolvers/LeastSquareConjugateGradient.h +79 -84
- package/eigen/Eigen/src/IterativeLinearSolvers/SolveWithGuess.h +54 -60
- package/eigen/Eigen/src/Jacobi/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/Jacobi/Jacobi.h +252 -308
- package/eigen/Eigen/src/KLUSupport/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/KLUSupport/KLUSupport.h +208 -227
- package/eigen/Eigen/src/LU/Determinant.h +50 -69
- package/eigen/Eigen/src/LU/FullPivLU.h +545 -596
- package/eigen/Eigen/src/LU/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/LU/InverseImpl.h +206 -285
- package/eigen/Eigen/src/LU/PartialPivLU.h +390 -428
- package/eigen/Eigen/src/LU/PartialPivLU_LAPACKE.h +54 -40
- package/eigen/Eigen/src/LU/arch/InverseSize4.h +72 -70
- 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 +243 -265
- package/eigen/Eigen/src/OrderingMethods/Eigen_Colamd.h +831 -1004
- package/eigen/Eigen/src/OrderingMethods/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/OrderingMethods/Ordering.h +112 -119
- 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 -430
- package/eigen/Eigen/src/QR/ColPivHouseholderQR.h +479 -479
- package/eigen/Eigen/src/QR/ColPivHouseholderQR_LAPACKE.h +120 -56
- package/eigen/Eigen/src/QR/CompleteOrthogonalDecomposition.h +166 -153
- package/eigen/Eigen/src/QR/FullPivHouseholderQR.h +495 -475
- package/eigen/Eigen/src/QR/HouseholderQR.h +394 -285
- 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 +244 -264
- package/eigen/Eigen/src/SVD/BDCSVD.h +817 -713
- 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 +577 -543
- package/eigen/Eigen/src/SVD/JacobiSVD_LAPACKE.h +85 -49
- package/eigen/Eigen/src/SVD/SVDBase.h +242 -182
- package/eigen/Eigen/src/SVD/UpperBidiagonalization.h +200 -235
- package/eigen/Eigen/src/SparseCholesky/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/SparseCholesky/SimplicialCholesky.h +765 -594
- package/eigen/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h +308 -94
- package/eigen/Eigen/src/SparseCore/AmbiVector.h +202 -251
- package/eigen/Eigen/src/SparseCore/CompressedStorage.h +184 -252
- package/eigen/Eigen/src/SparseCore/ConservativeSparseSparseProduct.h +134 -178
- package/eigen/Eigen/src/SparseCore/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/SparseCore/SparseAssign.h +149 -140
- package/eigen/Eigen/src/SparseCore/SparseBlock.h +403 -440
- package/eigen/Eigen/src/SparseCore/SparseColEtree.h +100 -112
- package/eigen/Eigen/src/SparseCore/SparseCompressedBase.h +525 -303
- package/eigen/Eigen/src/SparseCore/SparseCwiseBinaryOp.h +555 -339
- package/eigen/Eigen/src/SparseCore/SparseCwiseUnaryOp.h +100 -108
- package/eigen/Eigen/src/SparseCore/SparseDenseProduct.h +169 -197
- 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 +1603 -1245
- package/eigen/Eigen/src/SparseCore/SparseMatrixBase.h +403 -350
- package/eigen/Eigen/src/SparseCore/SparsePermutation.h +186 -115
- package/eigen/Eigen/src/SparseCore/SparseProduct.h +94 -97
- 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 +370 -416
- 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 +138 -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 +756 -710
- 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 +245 -301
- 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 +89 -100
- 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 +124 -132
- 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 +450 -502
- package/eigen/Eigen/src/StlSupport/StdDeque.h +28 -93
- 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 -730
- 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 +428 -464
- 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 +9972 -16179
- 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.h → BlockMethods.inc} +434 -506
- package/eigen/Eigen/src/plugins/CommonCwiseBinaryOps.inc +116 -0
- package/eigen/Eigen/src/plugins/{CommonCwiseUnaryOps.h → CommonCwiseUnaryOps.inc} +58 -68
- 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/package.json +1 -1
- package/eigen/COPYING.APACHE +0 -203
- package/eigen/COPYING.BSD +0 -26
- package/eigen/COPYING.GPL +0 -674
- package/eigen/COPYING.LGPL +0 -502
- package/eigen/COPYING.MINPACK +0 -51
- package/eigen/COPYING.MPL2 +0 -373
- package/eigen/COPYING.README +0 -18
- package/eigen/Eigen/src/Core/BooleanRedux.h +0 -162
- package/eigen/Eigen/src/Core/arch/CUDA/Complex.h +0 -258
- package/eigen/Eigen/src/Core/arch/Default/TypeCasting.h +0 -120
- package/eigen/Eigen/src/Core/arch/SYCL/SyclMemoryModel.h +0 -694
- package/eigen/Eigen/src/Core/util/NonMPL2.h +0 -3
- 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 -358
- package/eigen/Eigen/src/plugins/ArrayCwiseUnaryOps.h +0 -696
- package/eigen/Eigen/src/plugins/CommonCwiseBinaryOps.h +0 -115
- package/eigen/Eigen/src/plugins/IndexedViewMethods.h +0 -262
- package/eigen/Eigen/src/plugins/MatrixCwiseBinaryOps.h +0 -152
- package/eigen/Eigen/src/plugins/MatrixCwiseUnaryOps.h +0 -95
- package/eigen/Eigen/src/plugins/ReshapedMethods.h +0 -149
- package/eigen/README.md +0 -5
|
@@ -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
|
-
|
|
111
|
+
MatrixOptions = traits<MatrixType>::Options
|
|
116
112
|
};
|
|
117
113
|
|
|
118
|
-
typedef typename internal::make_proper_matrix_type<
|
|
119
|
-
|
|
120
|
-
|
|
114
|
+
typedef typename internal::make_proper_matrix_type<Scalar, ColsAtCompileTime, RowsAtCompileTime, MatrixOptions,
|
|
115
|
+
MaxColsAtCompileTime, MaxRowsAtCompileTime>::type
|
|
116
|
+
TransposeTypeWithSameStorageOrder;
|
|
121
117
|
|
|
122
|
-
void allocate(const
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
m_qr.~QRType();
|
|
127
|
-
::new (&m_qr) QRType(svd.cols(), svd.rows());
|
|
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
|
-
|
|
205
|
+
MatrixOptions = internal::traits<MatrixType>::Options,
|
|
206
|
+
WorkspaceSize = internal::traits<SVDType>::MatrixVColsAtCompileTime,
|
|
207
|
+
MaxWorkspaceSize = internal::traits<SVDType>::MatrixVMaxColsAtCompileTime
|
|
206
208
|
};
|
|
207
209
|
|
|
208
|
-
typedef
|
|
209
|
-
Scalar, ColsAtCompileTime, RowsAtCompileTime, Options, MaxColsAtCompileTime, MaxRowsAtCompileTime
|
|
210
|
-
>::type TransposeTypeWithSameStorageOrder;
|
|
210
|
+
typedef Matrix<Scalar, WorkspaceSize, 1, ColMajor, MaxWorkspaceSize, 1> WorkspaceType;
|
|
211
211
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
212
|
+
typedef typename internal::make_proper_matrix_type<Scalar, ColsAtCompileTime, RowsAtCompileTime, MatrixOptions,
|
|
213
|
+
MaxColsAtCompileTime, MaxRowsAtCompileTime>::type
|
|
214
|
+
TransposeTypeWithSameStorageOrder;
|
|
215
|
+
|
|
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());
|
|
218
220
|
}
|
|
219
|
-
if (svd.m_computeFullV)
|
|
220
|
-
|
|
221
|
-
|
|
221
|
+
if (svd.m_computeFullV)
|
|
222
|
+
m_workspace.resize(svd.cols());
|
|
223
|
+
else if (svd.m_computeThinV)
|
|
224
|
+
m_workspace.resize(svd.rows());
|
|
222
225
|
}
|
|
223
|
-
|
|
224
|
-
bool run(
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
if(svd.
|
|
233
|
-
else if(svd.m_computeThinV)
|
|
234
|
-
{
|
|
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) {
|
|
235
236
|
svd.m_matrixV.setIdentity(matrix.cols(), matrix.rows());
|
|
236
237
|
m_qr.householderQ().applyThisOnTheLeft(svd.m_matrixV, m_workspace);
|
|
237
238
|
}
|
|
238
|
-
if(svd.computeU()) svd.m_matrixU = m_qr.colsPermutation();
|
|
239
|
+
if (svd.computeU()) svd.m_matrixU = m_qr.colsPermutation();
|
|
239
240
|
return true;
|
|
240
|
-
}
|
|
241
|
-
|
|
241
|
+
} else
|
|
242
|
+
return false;
|
|
242
243
|
}
|
|
243
244
|
|
|
244
|
-
private:
|
|
245
|
+
private:
|
|
245
246
|
typedef ColPivHouseholderQR<TransposeTypeWithSameStorageOrder> QRType;
|
|
246
247
|
QRType m_qr;
|
|
247
|
-
|
|
248
|
-
typename internal::plain_row_type<MatrixType>::type m_workspace;
|
|
248
|
+
WorkspaceType m_workspace;
|
|
249
249
|
};
|
|
250
250
|
|
|
251
251
|
/*** preconditioner using HouseholderQR ***/
|
|
252
252
|
|
|
253
|
-
template<typename MatrixType>
|
|
254
|
-
class qr_preconditioner_impl<MatrixType, HouseholderQRPreconditioner, PreconditionIfMoreRowsThanCols, true>
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
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());
|
|
263
270
|
}
|
|
264
|
-
if (svd.m_computeFullU)
|
|
265
|
-
|
|
271
|
+
if (svd.m_computeFullU)
|
|
272
|
+
m_workspace.resize(svd.rows());
|
|
273
|
+
else if (svd.m_computeThinU)
|
|
274
|
+
m_workspace.resize(svd.cols());
|
|
266
275
|
}
|
|
267
|
-
|
|
268
|
-
bool run(
|
|
269
|
-
|
|
270
|
-
if(matrix.rows() > matrix.cols())
|
|
271
|
-
{
|
|
276
|
+
template <typename Xpr>
|
|
277
|
+
bool run(SVDType& svd, const Xpr& matrix) {
|
|
278
|
+
if (matrix.rows() > matrix.cols()) {
|
|
272
279
|
m_qr.compute(matrix);
|
|
273
|
-
svd.m_workMatrix = m_qr.matrixQR().block(0,0,matrix.cols(),matrix.cols()).template triangularView<Upper>();
|
|
274
|
-
if(svd.m_computeFullU)
|
|
275
|
-
|
|
276
|
-
{
|
|
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) {
|
|
277
284
|
svd.m_matrixU.setIdentity(matrix.rows(), matrix.cols());
|
|
278
285
|
m_qr.householderQ().applyThisOnTheLeft(svd.m_matrixU, m_workspace);
|
|
279
286
|
}
|
|
280
|
-
if(svd.computeV()) svd.m_matrixV.setIdentity(matrix.cols(), matrix.cols());
|
|
287
|
+
if (svd.computeV()) svd.m_matrixV.setIdentity(matrix.cols(), matrix.cols());
|
|
281
288
|
return true;
|
|
282
289
|
}
|
|
283
290
|
return false;
|
|
284
291
|
}
|
|
285
|
-
|
|
292
|
+
|
|
293
|
+
private:
|
|
286
294
|
typedef HouseholderQR<MatrixType> QRType;
|
|
287
295
|
QRType m_qr;
|
|
288
|
-
|
|
296
|
+
WorkspaceType m_workspace;
|
|
289
297
|
};
|
|
290
298
|
|
|
291
|
-
template<typename MatrixType>
|
|
292
|
-
class qr_preconditioner_impl<MatrixType, HouseholderQRPreconditioner, PreconditionIfMoreColsThanRows, true>
|
|
293
|
-
|
|
294
|
-
public:
|
|
299
|
+
template <typename MatrixType, int Options>
|
|
300
|
+
class qr_preconditioner_impl<MatrixType, Options, HouseholderQRPreconditioner, PreconditionIfMoreColsThanRows, true> {
|
|
301
|
+
public:
|
|
295
302
|
typedef typename MatrixType::Scalar Scalar;
|
|
296
|
-
|
|
297
|
-
|
|
303
|
+
typedef JacobiSVD<MatrixType, Options> SVDType;
|
|
304
|
+
|
|
305
|
+
enum {
|
|
298
306
|
RowsAtCompileTime = MatrixType::RowsAtCompileTime,
|
|
299
307
|
ColsAtCompileTime = MatrixType::ColsAtCompileTime,
|
|
300
308
|
MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
|
|
301
309
|
MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime,
|
|
302
|
-
|
|
310
|
+
MatrixOptions = internal::traits<MatrixType>::Options,
|
|
311
|
+
WorkspaceSize = internal::traits<SVDType>::MatrixVColsAtCompileTime,
|
|
312
|
+
MaxWorkspaceSize = internal::traits<SVDType>::MatrixVMaxColsAtCompileTime
|
|
303
313
|
};
|
|
304
314
|
|
|
305
|
-
typedef
|
|
306
|
-
|
|
307
|
-
|
|
315
|
+
typedef Matrix<Scalar, WorkspaceSize, 1, ColMajor, MaxWorkspaceSize, 1> WorkspaceType;
|
|
316
|
+
|
|
317
|
+
typedef typename internal::make_proper_matrix_type<Scalar, ColsAtCompileTime, RowsAtCompileTime, MatrixOptions,
|
|
318
|
+
MaxColsAtCompileTime, MaxRowsAtCompileTime>::type
|
|
319
|
+
TransposeTypeWithSameStorageOrder;
|
|
308
320
|
|
|
309
|
-
void allocate(const
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
m_qr.~QRType();
|
|
314
|
-
::new (&m_qr) QRType(svd.cols(), svd.rows());
|
|
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,326 +359,356 @@ 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
|
-
{
|
|
430
|
-
typedef _MatrixType MatrixType;
|
|
427
|
+
template <typename MatrixType_, int Options>
|
|
428
|
+
struct traits<JacobiSVD<MatrixType_, Options> > : svd_traits<MatrixType_, Options> {
|
|
429
|
+
typedef MatrixType_ MatrixType;
|
|
431
430
|
};
|
|
432
431
|
|
|
433
|
-
}
|
|
432
|
+
} // end namespace internal
|
|
434
433
|
|
|
435
434
|
/** \ingroup SVD_Module
|
|
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
|
-
|
|
519
|
-
* The default constructor is useful in cases in which the user intends to
|
|
520
|
-
* perform decompositions via JacobiSVD::compute(const MatrixType&).
|
|
521
|
-
*/
|
|
522
|
-
JacobiSVD()
|
|
523
|
-
{}
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
/** \brief Default Constructor with memory preallocation
|
|
527
|
-
*
|
|
528
|
-
* Like the default constructor but with preallocation of the internal data
|
|
529
|
-
* according to the specified problem size.
|
|
530
|
-
* \sa JacobiSVD()
|
|
531
|
-
*/
|
|
532
|
-
JacobiSVD(Index rows, Index cols, unsigned int computationOptions = 0)
|
|
533
|
-
{
|
|
534
|
-
allocate(rows, cols, computationOptions);
|
|
535
|
-
}
|
|
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
|
+
};
|
|
536
518
|
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
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
|
+
}
|
|
551
563
|
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
*/
|
|
562
|
-
JacobiSVD& compute(const MatrixType& matrix, unsigned int computationOptions);
|
|
563
|
-
|
|
564
|
-
/** \brief Method performing the decomposition of given matrix using current options.
|
|
565
|
-
*
|
|
566
|
-
* \param matrix the matrix to decompose
|
|
567
|
-
*
|
|
568
|
-
* This method uses the current \a computationOptions, as already passed to the constructor or to compute(const MatrixType&, unsigned int).
|
|
569
|
-
*/
|
|
570
|
-
JacobiSVD& compute(const MatrixType& matrix)
|
|
571
|
-
{
|
|
572
|
-
return compute(matrix, m_computationOptions);
|
|
573
|
-
}
|
|
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
|
+
}
|
|
574
573
|
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
using Base::rank;
|
|
580
|
-
|
|
581
|
-
private:
|
|
582
|
-
void allocate(Index rows, Index cols, unsigned int computationOptions);
|
|
583
|
-
|
|
584
|
-
protected:
|
|
585
|
-
using Base::m_matrixU;
|
|
586
|
-
using Base::m_matrixV;
|
|
587
|
-
using Base::m_singularValues;
|
|
588
|
-
using Base::m_info;
|
|
589
|
-
using Base::m_isInitialized;
|
|
590
|
-
using Base::m_isAllocated;
|
|
591
|
-
using Base::m_usePrescribedThreshold;
|
|
592
|
-
using Base::m_computeFullU;
|
|
593
|
-
using Base::m_computeThinU;
|
|
594
|
-
using Base::m_computeFullV;
|
|
595
|
-
using Base::m_computeThinV;
|
|
596
|
-
using Base::m_computationOptions;
|
|
597
|
-
using Base::m_nonzeroSingularValues;
|
|
598
|
-
using Base::m_rows;
|
|
599
|
-
using Base::m_cols;
|
|
600
|
-
using Base::m_diagSize;
|
|
601
|
-
using Base::m_prescribedThreshold;
|
|
602
|
-
WorkMatrixType m_workMatrix;
|
|
603
|
-
|
|
604
|
-
template<typename __MatrixType, int _QRPreconditioner, bool _IsComplex>
|
|
605
|
-
friend struct internal::svd_precondition_2x2_block_to_be_real;
|
|
606
|
-
template<typename __MatrixType, int _QRPreconditioner, int _Case, bool _DoAnything>
|
|
607
|
-
friend struct internal::qr_preconditioner_impl;
|
|
608
|
-
|
|
609
|
-
internal::qr_preconditioner_impl<MatrixType, QRPreconditioner, internal::PreconditionIfMoreColsThanRows> m_qr_precond_morecols;
|
|
610
|
-
internal::qr_preconditioner_impl<MatrixType, QRPreconditioner, internal::PreconditionIfMoreRowsThanCols> m_qr_precond_morerows;
|
|
611
|
-
MatrixType m_scaledMatrix;
|
|
612
|
-
};
|
|
574
|
+
template <typename Derived>
|
|
575
|
+
explicit JacobiSVD(const TriangularBase<Derived>& matrix) {
|
|
576
|
+
compute_impl(matrix, internal::get_computation_options(Options));
|
|
577
|
+
}
|
|
613
578
|
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
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);
|
|
625
597
|
}
|
|
626
598
|
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
m_computeFullV = (computationOptions & ComputeFullV) != 0;
|
|
636
|
-
m_computeThinV = (computationOptions & ComputeThinV) != 0;
|
|
637
|
-
eigen_assert(!(m_computeFullU && m_computeThinU) && "JacobiSVD: you can't ask for both full and thin U");
|
|
638
|
-
eigen_assert(!(m_computeFullV && m_computeThinV) && "JacobiSVD: you can't ask for both full and thin V");
|
|
639
|
-
eigen_assert(EIGEN_IMPLIES(m_computeThinU || m_computeThinV, MatrixType::ColsAtCompileTime==Dynamic) &&
|
|
640
|
-
"JacobiSVD: thin U and V are only available when your matrix has a dynamic number of columns.");
|
|
641
|
-
if (QRPreconditioner == FullPivHouseholderQRPreconditioner)
|
|
642
|
-
{
|
|
643
|
-
eigen_assert(!(m_computeThinU || m_computeThinV) &&
|
|
644
|
-
"JacobiSVD: can't compute thin U or thin V with the FullPivHouseholderQR preconditioner. "
|
|
645
|
-
"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);
|
|
646
607
|
}
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
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);
|
|
662
696
|
}
|
|
663
697
|
|
|
664
|
-
template<typename MatrixType, int
|
|
665
|
-
|
|
666
|
-
JacobiSVD<MatrixType,
|
|
667
|
-
{
|
|
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
|
+
|
|
668
706
|
using std::abs;
|
|
707
|
+
|
|
669
708
|
allocate(matrix.rows(), matrix.cols(), computationOptions);
|
|
670
709
|
|
|
671
|
-
// currently we stop when we reach precision 2*epsilon as the last bit of precision can require an unreasonable number
|
|
672
|
-
// 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
|
|
673
712
|
const RealScalar precision = RealScalar(2) * NumTraits<Scalar>::epsilon();
|
|
674
713
|
|
|
675
714
|
// limit for denormal numbers to be considered zero in order to avoid infinite loops (see bug 286)
|
|
@@ -680,112 +719,101 @@ JacobiSVD<MatrixType, QRPreconditioner>::compute(const MatrixType& matrix, unsig
|
|
|
680
719
|
if (!(numext::isfinite)(scale)) {
|
|
681
720
|
m_isInitialized = true;
|
|
682
721
|
m_info = InvalidInput;
|
|
722
|
+
m_nonzeroSingularValues = 0;
|
|
683
723
|
return *this;
|
|
684
724
|
}
|
|
685
|
-
if(scale
|
|
686
|
-
|
|
725
|
+
if (numext::is_exactly_zero(scale)) scale = RealScalar(1);
|
|
726
|
+
|
|
687
727
|
/*** step 1. The R-SVD step: we use a QR decomposition to reduce to the case of a square matrix */
|
|
688
728
|
|
|
689
|
-
if(
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
if(
|
|
699
|
-
if(m_computeThinU) m_matrixU.setIdentity(m_rows,m_diagSize);
|
|
700
|
-
if(m_computeFullV) m_matrixV.setIdentity(m_cols,m_cols);
|
|
701
|
-
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());
|
|
702
739
|
}
|
|
703
740
|
|
|
704
741
|
/*** step 2. The main Jacobi SVD iteration. ***/
|
|
705
742
|
RealScalar maxDiagEntry = m_workMatrix.cwiseAbs().diagonal().maxCoeff();
|
|
706
743
|
|
|
707
744
|
bool finished = false;
|
|
708
|
-
while(!finished)
|
|
709
|
-
{
|
|
745
|
+
while (!finished) {
|
|
710
746
|
finished = true;
|
|
711
747
|
|
|
712
748
|
// do a sweep: for all index pairs (p,q), perform SVD of the corresponding 2x2 sub-matrix
|
|
713
749
|
|
|
714
|
-
for(Index p = 1; p <
|
|
715
|
-
|
|
716
|
-
for(Index q = 0; q < p; ++q)
|
|
717
|
-
{
|
|
750
|
+
for (Index p = 1; p < diagSize(); ++p) {
|
|
751
|
+
for (Index q = 0; q < p; ++q) {
|
|
718
752
|
// if this 2x2 sub-matrix is not diagonal already...
|
|
719
753
|
// notice that this comparison will evaluate to false if any NaN is involved, ensuring that NaN's don't
|
|
720
754
|
// keep us iterating forever. Similarly, small denormal numbers are considered zero.
|
|
721
755
|
RealScalar threshold = numext::maxi<RealScalar>(considerAsZero, precision * maxDiagEntry);
|
|
722
|
-
if(abs(m_workMatrix.coeff(p,q))>threshold || abs(m_workMatrix.coeff(q,p)) > threshold)
|
|
723
|
-
{
|
|
756
|
+
if (abs(m_workMatrix.coeff(p, q)) > threshold || abs(m_workMatrix.coeff(q, p)) > threshold) {
|
|
724
757
|
finished = false;
|
|
725
758
|
// perform SVD decomposition of 2x2 sub-matrix corresponding to indices p,q to make it diagonal
|
|
726
759
|
// the complex to real operation returns true if the updated 2x2 block is not already diagonal
|
|
727
|
-
if(internal::svd_precondition_2x2_block_to_be_real<MatrixType,
|
|
728
|
-
|
|
760
|
+
if (internal::svd_precondition_2x2_block_to_be_real<MatrixType, Options>::run(m_workMatrix, *this, p, q,
|
|
761
|
+
maxDiagEntry)) {
|
|
729
762
|
JacobiRotation<RealScalar> j_left, j_right;
|
|
730
763
|
internal::real_2x2_jacobi_svd(m_workMatrix, p, q, &j_left, &j_right);
|
|
731
764
|
|
|
732
765
|
// accumulate resulting Jacobi rotations
|
|
733
|
-
m_workMatrix.applyOnTheLeft(p,q,j_left);
|
|
734
|
-
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());
|
|
735
768
|
|
|
736
|
-
m_workMatrix.applyOnTheRight(p,q,j_right);
|
|
737
|
-
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);
|
|
738
771
|
|
|
739
772
|
// keep track of the largest diagonal coefficient
|
|
740
|
-
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))));
|
|
741
775
|
}
|
|
742
776
|
}
|
|
743
777
|
}
|
|
744
778
|
}
|
|
745
779
|
}
|
|
746
780
|
|
|
747
|
-
/*** 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
|
+
* ***/
|
|
748
783
|
|
|
749
|
-
for(Index i = 0; i <
|
|
750
|
-
{
|
|
784
|
+
for (Index i = 0; i < diagSize(); ++i) {
|
|
751
785
|
// For a complex matrix, some diagonal coefficients might note have been
|
|
752
786
|
// treated by svd_precondition_2x2_block_to_be_real, and the imaginary part
|
|
753
787
|
// of some diagonal entry might not be null.
|
|
754
|
-
if(NumTraits<Scalar>::IsComplex && abs(numext::imag(m_workMatrix.coeff(i,i)))>considerAsZero)
|
|
755
|
-
|
|
756
|
-
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));
|
|
757
790
|
m_singularValues.coeffRef(i) = abs(a);
|
|
758
|
-
if(computeU()) m_matrixU.col(i) *= m_workMatrix.coeff(i,i)/a;
|
|
759
|
-
}
|
|
760
|
-
else
|
|
761
|
-
{
|
|
791
|
+
if (computeU()) m_matrixU.col(i) *= m_workMatrix.coeff(i, i) / a;
|
|
792
|
+
} else {
|
|
762
793
|
// m_workMatrix.coeff(i,i) is already real, no difficulty:
|
|
763
|
-
RealScalar a = numext::real(m_workMatrix.coeff(i,i));
|
|
794
|
+
RealScalar a = numext::real(m_workMatrix.coeff(i, i));
|
|
764
795
|
m_singularValues.coeffRef(i) = abs(a);
|
|
765
|
-
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);
|
|
766
797
|
}
|
|
767
798
|
}
|
|
768
|
-
|
|
799
|
+
|
|
769
800
|
m_singularValues *= scale;
|
|
770
801
|
|
|
771
802
|
/*** step 4. Sort singular values in descending order and compute the number of nonzero singular values ***/
|
|
772
803
|
|
|
773
|
-
m_nonzeroSingularValues =
|
|
774
|
-
for(Index i = 0; i <
|
|
775
|
-
{
|
|
804
|
+
m_nonzeroSingularValues = diagSize();
|
|
805
|
+
for (Index i = 0; i < diagSize(); i++) {
|
|
776
806
|
Index pos;
|
|
777
|
-
RealScalar maxRemainingSingularValue = m_singularValues.tail(
|
|
778
|
-
if(maxRemainingSingularValue
|
|
779
|
-
{
|
|
807
|
+
RealScalar maxRemainingSingularValue = m_singularValues.tail(diagSize() - i).maxCoeff(&pos);
|
|
808
|
+
if (numext::is_exactly_zero(maxRemainingSingularValue)) {
|
|
780
809
|
m_nonzeroSingularValues = i;
|
|
781
810
|
break;
|
|
782
811
|
}
|
|
783
|
-
if(pos)
|
|
784
|
-
{
|
|
812
|
+
if (pos) {
|
|
785
813
|
pos += i;
|
|
786
814
|
std::swap(m_singularValues.coeffRef(i), m_singularValues.coeffRef(pos));
|
|
787
|
-
if(computeU()) m_matrixU.col(pos).swap(m_matrixU.col(i));
|
|
788
|
-
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));
|
|
789
817
|
}
|
|
790
818
|
}
|
|
791
819
|
|
|
@@ -794,19 +822,25 @@ JacobiSVD<MatrixType, QRPreconditioner>::compute(const MatrixType& matrix, unsig
|
|
|
794
822
|
}
|
|
795
823
|
|
|
796
824
|
/** \svd_module
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
template<typename Derived>
|
|
804
|
-
|
|
805
|
-
MatrixBase<Derived>::jacobiSvd(
|
|
806
|
-
|
|
807
|
-
|
|
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);
|
|
808
842
|
}
|
|
809
843
|
|
|
810
|
-
}
|
|
844
|
+
} // end namespace Eigen
|
|
811
845
|
|
|
812
|
-
#endif
|
|
846
|
+
#endif // EIGEN_JACOBISVD_H
|