@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.
Files changed (435) hide show
  1. package/README.md +1 -1
  2. package/eigen/Eigen/AccelerateSupport +52 -0
  3. package/eigen/Eigen/Cholesky +18 -21
  4. package/eigen/Eigen/CholmodSupport +28 -28
  5. package/eigen/Eigen/Core +235 -326
  6. package/eigen/Eigen/Eigenvalues +16 -14
  7. package/eigen/Eigen/Geometry +21 -24
  8. package/eigen/Eigen/Householder +9 -8
  9. package/eigen/Eigen/IterativeLinearSolvers +8 -4
  10. package/eigen/Eigen/Jacobi +14 -14
  11. package/eigen/Eigen/KLUSupport +43 -0
  12. package/eigen/Eigen/LU +16 -20
  13. package/eigen/Eigen/MetisSupport +12 -12
  14. package/eigen/Eigen/OrderingMethods +54 -54
  15. package/eigen/Eigen/PaStiXSupport +23 -20
  16. package/eigen/Eigen/PardisoSupport +17 -14
  17. package/eigen/Eigen/QR +18 -21
  18. package/eigen/Eigen/QtAlignedMalloc +5 -13
  19. package/eigen/Eigen/SPQRSupport +21 -14
  20. package/eigen/Eigen/SVD +23 -18
  21. package/eigen/Eigen/Sparse +1 -4
  22. package/eigen/Eigen/SparseCholesky +18 -23
  23. package/eigen/Eigen/SparseCore +18 -17
  24. package/eigen/Eigen/SparseLU +12 -8
  25. package/eigen/Eigen/SparseQR +16 -14
  26. package/eigen/Eigen/StdDeque +5 -2
  27. package/eigen/Eigen/StdList +5 -2
  28. package/eigen/Eigen/StdVector +5 -2
  29. package/eigen/Eigen/SuperLUSupport +30 -24
  30. package/eigen/Eigen/ThreadPool +80 -0
  31. package/eigen/Eigen/UmfPackSupport +19 -17
  32. package/eigen/Eigen/Version +14 -0
  33. package/eigen/Eigen/src/AccelerateSupport/AccelerateSupport.h +423 -0
  34. package/eigen/Eigen/src/AccelerateSupport/InternalHeaderCheck.h +3 -0
  35. package/eigen/Eigen/src/Cholesky/InternalHeaderCheck.h +3 -0
  36. package/eigen/Eigen/src/Cholesky/LDLT.h +377 -401
  37. package/eigen/Eigen/src/Cholesky/LLT.h +332 -360
  38. package/eigen/Eigen/src/Cholesky/LLT_LAPACKE.h +81 -56
  39. package/eigen/Eigen/src/CholmodSupport/CholmodSupport.h +620 -521
  40. package/eigen/Eigen/src/CholmodSupport/InternalHeaderCheck.h +3 -0
  41. package/eigen/Eigen/src/Core/ArithmeticSequence.h +239 -0
  42. package/eigen/Eigen/src/Core/Array.h +341 -294
  43. package/eigen/Eigen/src/Core/ArrayBase.h +190 -203
  44. package/eigen/Eigen/src/Core/ArrayWrapper.h +127 -171
  45. package/eigen/Eigen/src/Core/Assign.h +30 -40
  46. package/eigen/Eigen/src/Core/AssignEvaluator.h +711 -589
  47. package/eigen/Eigen/src/Core/Assign_MKL.h +130 -125
  48. package/eigen/Eigen/src/Core/BandMatrix.h +268 -283
  49. package/eigen/Eigen/src/Core/Block.h +375 -398
  50. package/eigen/Eigen/src/Core/CommaInitializer.h +86 -97
  51. package/eigen/Eigen/src/Core/ConditionEstimator.h +51 -53
  52. package/eigen/Eigen/src/Core/CoreEvaluators.h +1356 -1026
  53. package/eigen/Eigen/src/Core/CoreIterators.h +73 -59
  54. package/eigen/Eigen/src/Core/CwiseBinaryOp.h +114 -132
  55. package/eigen/Eigen/src/Core/CwiseNullaryOp.h +726 -617
  56. package/eigen/Eigen/src/Core/CwiseTernaryOp.h +77 -103
  57. package/eigen/Eigen/src/Core/CwiseUnaryOp.h +56 -68
  58. package/eigen/Eigen/src/Core/CwiseUnaryView.h +132 -95
  59. package/eigen/Eigen/src/Core/DenseBase.h +632 -571
  60. package/eigen/Eigen/src/Core/DenseCoeffsBase.h +511 -624
  61. package/eigen/Eigen/src/Core/DenseStorage.h +512 -509
  62. package/eigen/Eigen/src/Core/DeviceWrapper.h +153 -0
  63. package/eigen/Eigen/src/Core/Diagonal.h +169 -210
  64. package/eigen/Eigen/src/Core/DiagonalMatrix.h +351 -274
  65. package/eigen/Eigen/src/Core/DiagonalProduct.h +12 -10
  66. package/eigen/Eigen/src/Core/Dot.h +172 -222
  67. package/eigen/Eigen/src/Core/EigenBase.h +75 -85
  68. package/eigen/Eigen/src/Core/Fill.h +138 -0
  69. package/eigen/Eigen/src/Core/FindCoeff.h +464 -0
  70. package/eigen/Eigen/src/Core/ForceAlignedAccess.h +90 -109
  71. package/eigen/Eigen/src/Core/Fuzzy.h +82 -105
  72. package/eigen/Eigen/src/Core/GeneralProduct.h +327 -263
  73. package/eigen/Eigen/src/Core/GenericPacketMath.h +1472 -360
  74. package/eigen/Eigen/src/Core/GlobalFunctions.h +194 -151
  75. package/eigen/Eigen/src/Core/IO.h +147 -139
  76. package/eigen/Eigen/src/Core/IndexedView.h +321 -0
  77. package/eigen/Eigen/src/Core/InnerProduct.h +260 -0
  78. package/eigen/Eigen/src/Core/InternalHeaderCheck.h +3 -0
  79. package/eigen/Eigen/src/Core/Inverse.h +56 -66
  80. package/eigen/Eigen/src/Core/Map.h +124 -142
  81. package/eigen/Eigen/src/Core/MapBase.h +256 -281
  82. package/eigen/Eigen/src/Core/MathFunctions.h +1620 -938
  83. package/eigen/Eigen/src/Core/MathFunctionsImpl.h +233 -71
  84. package/eigen/Eigen/src/Core/Matrix.h +491 -416
  85. package/eigen/Eigen/src/Core/MatrixBase.h +468 -453
  86. package/eigen/Eigen/src/Core/NestByValue.h +66 -85
  87. package/eigen/Eigen/src/Core/NoAlias.h +79 -85
  88. package/eigen/Eigen/src/Core/NumTraits.h +235 -148
  89. package/eigen/Eigen/src/Core/PartialReduxEvaluator.h +253 -0
  90. package/eigen/Eigen/src/Core/PermutationMatrix.h +461 -511
  91. package/eigen/Eigen/src/Core/PlainObjectBase.h +871 -894
  92. package/eigen/Eigen/src/Core/Product.h +260 -139
  93. package/eigen/Eigen/src/Core/ProductEvaluators.h +863 -714
  94. package/eigen/Eigen/src/Core/Random.h +161 -136
  95. package/eigen/Eigen/src/Core/RandomImpl.h +262 -0
  96. package/eigen/Eigen/src/Core/RealView.h +250 -0
  97. package/eigen/Eigen/src/Core/Redux.h +366 -336
  98. package/eigen/Eigen/src/Core/Ref.h +308 -209
  99. package/eigen/Eigen/src/Core/Replicate.h +94 -106
  100. package/eigen/Eigen/src/Core/Reshaped.h +398 -0
  101. package/eigen/Eigen/src/Core/ReturnByValue.h +49 -55
  102. package/eigen/Eigen/src/Core/Reverse.h +136 -145
  103. package/eigen/Eigen/src/Core/Select.h +70 -140
  104. package/eigen/Eigen/src/Core/SelfAdjointView.h +262 -285
  105. package/eigen/Eigen/src/Core/SelfCwiseBinaryOp.h +23 -20
  106. package/eigen/Eigen/src/Core/SkewSymmetricMatrix3.h +382 -0
  107. package/eigen/Eigen/src/Core/Solve.h +97 -111
  108. package/eigen/Eigen/src/Core/SolveTriangular.h +131 -129
  109. package/eigen/Eigen/src/Core/SolverBase.h +138 -101
  110. package/eigen/Eigen/src/Core/StableNorm.h +156 -160
  111. package/eigen/Eigen/src/Core/StlIterators.h +619 -0
  112. package/eigen/Eigen/src/Core/Stride.h +91 -88
  113. package/eigen/Eigen/src/Core/Swap.h +70 -38
  114. package/eigen/Eigen/src/Core/Transpose.h +295 -273
  115. package/eigen/Eigen/src/Core/Transpositions.h +272 -317
  116. package/eigen/Eigen/src/Core/TriangularMatrix.h +670 -755
  117. package/eigen/Eigen/src/Core/VectorBlock.h +59 -72
  118. package/eigen/Eigen/src/Core/VectorwiseOp.h +668 -630
  119. package/eigen/Eigen/src/Core/Visitor.h +480 -216
  120. package/eigen/Eigen/src/Core/arch/AVX/Complex.h +407 -293
  121. package/eigen/Eigen/src/Core/arch/AVX/MathFunctions.h +79 -388
  122. package/eigen/Eigen/src/Core/arch/AVX/PacketMath.h +2935 -491
  123. package/eigen/Eigen/src/Core/arch/AVX/Reductions.h +353 -0
  124. package/eigen/Eigen/src/Core/arch/AVX/TypeCasting.h +279 -22
  125. package/eigen/Eigen/src/Core/arch/AVX512/Complex.h +472 -0
  126. package/eigen/Eigen/src/Core/arch/AVX512/GemmKernel.h +1245 -0
  127. package/eigen/Eigen/src/Core/arch/AVX512/MathFunctions.h +85 -333
  128. package/eigen/Eigen/src/Core/arch/AVX512/MathFunctionsFP16.h +75 -0
  129. package/eigen/Eigen/src/Core/arch/AVX512/PacketMath.h +2490 -649
  130. package/eigen/Eigen/src/Core/arch/AVX512/PacketMathFP16.h +1413 -0
  131. package/eigen/Eigen/src/Core/arch/AVX512/Reductions.h +297 -0
  132. package/eigen/Eigen/src/Core/arch/AVX512/TrsmKernel.h +1167 -0
  133. package/eigen/Eigen/src/Core/arch/AVX512/TrsmUnrolls.inc +1219 -0
  134. package/eigen/Eigen/src/Core/arch/AVX512/TypeCasting.h +277 -0
  135. package/eigen/Eigen/src/Core/arch/AVX512/TypeCastingFP16.h +130 -0
  136. package/eigen/Eigen/src/Core/arch/AltiVec/Complex.h +521 -298
  137. package/eigen/Eigen/src/Core/arch/AltiVec/MathFunctions.h +39 -280
  138. package/eigen/Eigen/src/Core/arch/AltiVec/MatrixProduct.h +3686 -0
  139. package/eigen/Eigen/src/Core/arch/AltiVec/MatrixProductCommon.h +205 -0
  140. package/eigen/Eigen/src/Core/arch/AltiVec/MatrixProductMMA.h +901 -0
  141. package/eigen/Eigen/src/Core/arch/AltiVec/MatrixProductMMAbfloat16.h +742 -0
  142. package/eigen/Eigen/src/Core/arch/AltiVec/MatrixVectorProduct.inc +2818 -0
  143. package/eigen/Eigen/src/Core/arch/AltiVec/PacketMath.h +3391 -723
  144. package/eigen/Eigen/src/Core/arch/AltiVec/TypeCasting.h +153 -0
  145. package/eigen/Eigen/src/Core/arch/Default/BFloat16.h +866 -0
  146. package/eigen/Eigen/src/Core/arch/Default/ConjHelper.h +113 -14
  147. package/eigen/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h +2634 -0
  148. package/eigen/Eigen/src/Core/arch/Default/GenericPacketMathFunctionsFwd.h +227 -0
  149. package/eigen/Eigen/src/Core/arch/Default/Half.h +1091 -0
  150. package/eigen/Eigen/src/Core/arch/Default/Settings.h +11 -13
  151. package/eigen/Eigen/src/Core/arch/GPU/Complex.h +244 -0
  152. package/eigen/Eigen/src/Core/arch/GPU/MathFunctions.h +104 -0
  153. package/eigen/Eigen/src/Core/arch/GPU/PacketMath.h +1712 -0
  154. package/eigen/Eigen/src/Core/arch/GPU/Tuple.h +268 -0
  155. package/eigen/Eigen/src/Core/arch/GPU/TypeCasting.h +77 -0
  156. package/eigen/Eigen/src/Core/arch/HIP/hcc/math_constants.h +23 -0
  157. package/eigen/Eigen/src/Core/arch/HVX/PacketMath.h +1088 -0
  158. package/eigen/Eigen/src/Core/arch/LSX/Complex.h +520 -0
  159. package/eigen/Eigen/src/Core/arch/LSX/GeneralBlockPanelKernel.h +23 -0
  160. package/eigen/Eigen/src/Core/arch/LSX/MathFunctions.h +43 -0
  161. package/eigen/Eigen/src/Core/arch/LSX/PacketMath.h +2866 -0
  162. package/eigen/Eigen/src/Core/arch/LSX/TypeCasting.h +526 -0
  163. package/eigen/Eigen/src/Core/arch/MSA/Complex.h +620 -0
  164. package/eigen/Eigen/src/Core/arch/MSA/MathFunctions.h +379 -0
  165. package/eigen/Eigen/src/Core/arch/MSA/PacketMath.h +1237 -0
  166. package/eigen/Eigen/src/Core/arch/NEON/Complex.h +531 -289
  167. package/eigen/Eigen/src/Core/arch/NEON/GeneralBlockPanelKernel.h +243 -0
  168. package/eigen/Eigen/src/Core/arch/NEON/MathFunctions.h +50 -73
  169. package/eigen/Eigen/src/Core/arch/NEON/PacketMath.h +5915 -579
  170. package/eigen/Eigen/src/Core/arch/NEON/TypeCasting.h +1642 -0
  171. package/eigen/Eigen/src/Core/arch/NEON/UnaryFunctors.h +57 -0
  172. package/eigen/Eigen/src/Core/arch/SSE/Complex.h +366 -334
  173. package/eigen/Eigen/src/Core/arch/SSE/MathFunctions.h +40 -514
  174. package/eigen/Eigen/src/Core/arch/SSE/PacketMath.h +2164 -675
  175. package/eigen/Eigen/src/Core/arch/SSE/Reductions.h +324 -0
  176. package/eigen/Eigen/src/Core/arch/SSE/TypeCasting.h +188 -35
  177. package/eigen/Eigen/src/Core/arch/SVE/MathFunctions.h +48 -0
  178. package/eigen/Eigen/src/Core/arch/SVE/PacketMath.h +674 -0
  179. package/eigen/Eigen/src/Core/arch/SVE/TypeCasting.h +52 -0
  180. package/eigen/Eigen/src/Core/arch/SYCL/InteropHeaders.h +227 -0
  181. package/eigen/Eigen/src/Core/arch/SYCL/MathFunctions.h +303 -0
  182. package/eigen/Eigen/src/Core/arch/SYCL/PacketMath.h +576 -0
  183. package/eigen/Eigen/src/Core/arch/SYCL/TypeCasting.h +83 -0
  184. package/eigen/Eigen/src/Core/arch/ZVector/Complex.h +434 -261
  185. package/eigen/Eigen/src/Core/arch/ZVector/MathFunctions.h +160 -53
  186. package/eigen/Eigen/src/Core/arch/ZVector/PacketMath.h +1073 -605
  187. package/eigen/Eigen/src/Core/functors/AssignmentFunctors.h +123 -117
  188. package/eigen/Eigen/src/Core/functors/BinaryFunctors.h +594 -322
  189. package/eigen/Eigen/src/Core/functors/NullaryFunctors.h +204 -118
  190. package/eigen/Eigen/src/Core/functors/StlFunctors.h +110 -97
  191. package/eigen/Eigen/src/Core/functors/TernaryFunctors.h +34 -7
  192. package/eigen/Eigen/src/Core/functors/UnaryFunctors.h +1158 -530
  193. package/eigen/Eigen/src/Core/products/GeneralBlockPanelKernel.h +2329 -1333
  194. package/eigen/Eigen/src/Core/products/GeneralMatrixMatrix.h +328 -364
  195. package/eigen/Eigen/src/Core/products/GeneralMatrixMatrixTriangular.h +191 -178
  196. package/eigen/Eigen/src/Core/products/GeneralMatrixMatrixTriangular_BLAS.h +85 -82
  197. package/eigen/Eigen/src/Core/products/GeneralMatrixMatrix_BLAS.h +154 -73
  198. package/eigen/Eigen/src/Core/products/GeneralMatrixVector.h +396 -542
  199. package/eigen/Eigen/src/Core/products/GeneralMatrixVector_BLAS.h +80 -77
  200. package/eigen/Eigen/src/Core/products/Parallelizer.h +208 -92
  201. package/eigen/Eigen/src/Core/products/SelfadjointMatrixMatrix.h +331 -375
  202. package/eigen/Eigen/src/Core/products/SelfadjointMatrixMatrix_BLAS.h +206 -224
  203. package/eigen/Eigen/src/Core/products/SelfadjointMatrixVector.h +139 -146
  204. package/eigen/Eigen/src/Core/products/SelfadjointMatrixVector_BLAS.h +58 -61
  205. package/eigen/Eigen/src/Core/products/SelfadjointProduct.h +71 -71
  206. package/eigen/Eigen/src/Core/products/SelfadjointRank2Update.h +48 -46
  207. package/eigen/Eigen/src/Core/products/TriangularMatrixMatrix.h +294 -369
  208. package/eigen/Eigen/src/Core/products/TriangularMatrixMatrix_BLAS.h +246 -238
  209. package/eigen/Eigen/src/Core/products/TriangularMatrixVector.h +244 -247
  210. package/eigen/Eigen/src/Core/products/TriangularMatrixVector_BLAS.h +212 -192
  211. package/eigen/Eigen/src/Core/products/TriangularSolverMatrix.h +328 -275
  212. package/eigen/Eigen/src/Core/products/TriangularSolverMatrix_BLAS.h +108 -109
  213. package/eigen/Eigen/src/Core/products/TriangularSolverVector.h +70 -93
  214. package/eigen/Eigen/src/Core/util/Assert.h +158 -0
  215. package/eigen/Eigen/src/Core/util/BlasUtil.h +413 -290
  216. package/eigen/Eigen/src/Core/util/ConfigureVectorization.h +543 -0
  217. package/eigen/Eigen/src/Core/util/Constants.h +314 -263
  218. package/eigen/Eigen/src/Core/util/DisableStupidWarnings.h +130 -78
  219. package/eigen/Eigen/src/Core/util/EmulateArray.h +270 -0
  220. package/eigen/Eigen/src/Core/util/ForwardDeclarations.h +450 -224
  221. package/eigen/Eigen/src/Core/util/GpuHipCudaDefines.inc +101 -0
  222. package/eigen/Eigen/src/Core/util/GpuHipCudaUndefines.inc +45 -0
  223. package/eigen/Eigen/src/Core/util/IndexedViewHelper.h +487 -0
  224. package/eigen/Eigen/src/Core/util/IntegralConstant.h +279 -0
  225. package/eigen/Eigen/src/Core/util/MKL_support.h +39 -30
  226. package/eigen/Eigen/src/Core/util/Macros.h +939 -646
  227. package/eigen/Eigen/src/Core/util/MaxSizeVector.h +139 -0
  228. package/eigen/Eigen/src/Core/util/Memory.h +1042 -650
  229. package/eigen/Eigen/src/Core/util/Meta.h +618 -426
  230. package/eigen/Eigen/src/Core/util/MoreMeta.h +638 -0
  231. package/eigen/Eigen/src/Core/util/ReenableStupidWarnings.h +32 -19
  232. package/eigen/Eigen/src/Core/util/ReshapedHelper.h +51 -0
  233. package/eigen/Eigen/src/Core/util/Serializer.h +209 -0
  234. package/eigen/Eigen/src/Core/util/StaticAssert.h +51 -164
  235. package/eigen/Eigen/src/Core/util/SymbolicIndex.h +445 -0
  236. package/eigen/Eigen/src/Core/util/XprHelper.h +793 -538
  237. package/eigen/Eigen/src/Eigenvalues/ComplexEigenSolver.h +246 -277
  238. package/eigen/Eigen/src/Eigenvalues/ComplexSchur.h +299 -319
  239. package/eigen/Eigen/src/Eigenvalues/ComplexSchur_LAPACKE.h +52 -48
  240. package/eigen/Eigen/src/Eigenvalues/EigenSolver.h +413 -456
  241. package/eigen/Eigen/src/Eigenvalues/GeneralizedEigenSolver.h +309 -325
  242. package/eigen/Eigen/src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h +157 -171
  243. package/eigen/Eigen/src/Eigenvalues/HessenbergDecomposition.h +292 -310
  244. package/eigen/Eigen/src/Eigenvalues/InternalHeaderCheck.h +3 -0
  245. package/eigen/Eigen/src/Eigenvalues/MatrixBaseEigenvalues.h +91 -107
  246. package/eigen/Eigen/src/Eigenvalues/RealQZ.h +539 -606
  247. package/eigen/Eigen/src/Eigenvalues/RealSchur.h +348 -382
  248. package/eigen/Eigen/src/Eigenvalues/RealSchur_LAPACKE.h +41 -35
  249. package/eigen/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h +579 -600
  250. package/eigen/Eigen/src/Eigenvalues/SelfAdjointEigenSolver_LAPACKE.h +47 -44
  251. package/eigen/Eigen/src/Eigenvalues/Tridiagonalization.h +434 -461
  252. package/eigen/Eigen/src/Geometry/AlignedBox.h +307 -214
  253. package/eigen/Eigen/src/Geometry/AngleAxis.h +135 -137
  254. package/eigen/Eigen/src/Geometry/EulerAngles.h +163 -74
  255. package/eigen/Eigen/src/Geometry/Homogeneous.h +289 -333
  256. package/eigen/Eigen/src/Geometry/Hyperplane.h +152 -161
  257. package/eigen/Eigen/src/Geometry/InternalHeaderCheck.h +3 -0
  258. package/eigen/Eigen/src/Geometry/OrthoMethods.h +168 -145
  259. package/eigen/Eigen/src/Geometry/ParametrizedLine.h +141 -104
  260. package/eigen/Eigen/src/Geometry/Quaternion.h +595 -497
  261. package/eigen/Eigen/src/Geometry/Rotation2D.h +110 -108
  262. package/eigen/Eigen/src/Geometry/RotationBase.h +148 -145
  263. package/eigen/Eigen/src/Geometry/Scaling.h +115 -90
  264. package/eigen/Eigen/src/Geometry/Transform.h +896 -953
  265. package/eigen/Eigen/src/Geometry/Translation.h +100 -98
  266. package/eigen/Eigen/src/Geometry/Umeyama.h +79 -84
  267. package/eigen/Eigen/src/Geometry/arch/Geometry_SIMD.h +154 -0
  268. package/eigen/Eigen/src/Householder/BlockHouseholder.h +54 -42
  269. package/eigen/Eigen/src/Householder/Householder.h +104 -122
  270. package/eigen/Eigen/src/Householder/HouseholderSequence.h +416 -382
  271. package/eigen/Eigen/src/Householder/InternalHeaderCheck.h +3 -0
  272. package/eigen/Eigen/src/IterativeLinearSolvers/BasicPreconditioners.h +153 -166
  273. package/eigen/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h +127 -138
  274. package/eigen/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h +95 -124
  275. package/eigen/Eigen/src/IterativeLinearSolvers/IncompleteCholesky.h +269 -267
  276. package/eigen/Eigen/src/IterativeLinearSolvers/IncompleteLUT.h +246 -259
  277. package/eigen/Eigen/src/IterativeLinearSolvers/InternalHeaderCheck.h +3 -0
  278. package/eigen/Eigen/src/IterativeLinearSolvers/IterativeSolverBase.h +218 -217
  279. package/eigen/Eigen/src/IterativeLinearSolvers/LeastSquareConjugateGradient.h +80 -103
  280. package/eigen/Eigen/src/IterativeLinearSolvers/SolveWithGuess.h +59 -63
  281. package/eigen/Eigen/src/Jacobi/InternalHeaderCheck.h +3 -0
  282. package/eigen/Eigen/src/Jacobi/Jacobi.h +256 -291
  283. package/eigen/Eigen/src/KLUSupport/InternalHeaderCheck.h +3 -0
  284. package/eigen/Eigen/src/KLUSupport/KLUSupport.h +339 -0
  285. package/eigen/Eigen/src/LU/Determinant.h +60 -63
  286. package/eigen/Eigen/src/LU/FullPivLU.h +561 -626
  287. package/eigen/Eigen/src/LU/InternalHeaderCheck.h +3 -0
  288. package/eigen/Eigen/src/LU/InverseImpl.h +213 -275
  289. package/eigen/Eigen/src/LU/PartialPivLU.h +407 -435
  290. package/eigen/Eigen/src/LU/PartialPivLU_LAPACKE.h +54 -40
  291. package/eigen/Eigen/src/LU/arch/InverseSize4.h +353 -0
  292. package/eigen/Eigen/src/MetisSupport/InternalHeaderCheck.h +3 -0
  293. package/eigen/Eigen/src/MetisSupport/MetisSupport.h +81 -93
  294. package/eigen/Eigen/src/OrderingMethods/Amd.h +250 -282
  295. package/eigen/Eigen/src/OrderingMethods/Eigen_Colamd.h +950 -1103
  296. package/eigen/Eigen/src/OrderingMethods/InternalHeaderCheck.h +3 -0
  297. package/eigen/Eigen/src/OrderingMethods/Ordering.h +111 -122
  298. package/eigen/Eigen/src/PaStiXSupport/InternalHeaderCheck.h +3 -0
  299. package/eigen/Eigen/src/PaStiXSupport/PaStiXSupport.h +524 -570
  300. package/eigen/Eigen/src/PardisoSupport/InternalHeaderCheck.h +3 -0
  301. package/eigen/Eigen/src/PardisoSupport/PardisoSupport.h +385 -429
  302. package/eigen/Eigen/src/QR/ColPivHouseholderQR.h +494 -473
  303. package/eigen/Eigen/src/QR/ColPivHouseholderQR_LAPACKE.h +120 -56
  304. package/eigen/Eigen/src/QR/CompleteOrthogonalDecomposition.h +223 -137
  305. package/eigen/Eigen/src/QR/FullPivHouseholderQR.h +517 -460
  306. package/eigen/Eigen/src/QR/HouseholderQR.h +412 -278
  307. package/eigen/Eigen/src/QR/HouseholderQR_LAPACKE.h +32 -23
  308. package/eigen/Eigen/src/QR/InternalHeaderCheck.h +3 -0
  309. package/eigen/Eigen/src/SPQRSupport/InternalHeaderCheck.h +3 -0
  310. package/eigen/Eigen/src/SPQRSupport/SuiteSparseQRSupport.h +263 -261
  311. package/eigen/Eigen/src/SVD/BDCSVD.h +872 -679
  312. package/eigen/Eigen/src/SVD/BDCSVD_LAPACKE.h +174 -0
  313. package/eigen/Eigen/src/SVD/InternalHeaderCheck.h +3 -0
  314. package/eigen/Eigen/src/SVD/JacobiSVD.h +585 -543
  315. package/eigen/Eigen/src/SVD/JacobiSVD_LAPACKE.h +85 -49
  316. package/eigen/Eigen/src/SVD/SVDBase.h +281 -160
  317. package/eigen/Eigen/src/SVD/UpperBidiagonalization.h +202 -237
  318. package/eigen/Eigen/src/SparseCholesky/InternalHeaderCheck.h +3 -0
  319. package/eigen/Eigen/src/SparseCholesky/SimplicialCholesky.h +769 -590
  320. package/eigen/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h +318 -129
  321. package/eigen/Eigen/src/SparseCore/AmbiVector.h +202 -251
  322. package/eigen/Eigen/src/SparseCore/CompressedStorage.h +184 -236
  323. package/eigen/Eigen/src/SparseCore/ConservativeSparseSparseProduct.h +140 -184
  324. package/eigen/Eigen/src/SparseCore/InternalHeaderCheck.h +3 -0
  325. package/eigen/Eigen/src/SparseCore/SparseAssign.h +174 -111
  326. package/eigen/Eigen/src/SparseCore/SparseBlock.h +408 -477
  327. package/eigen/Eigen/src/SparseCore/SparseColEtree.h +100 -112
  328. package/eigen/Eigen/src/SparseCore/SparseCompressedBase.h +531 -280
  329. package/eigen/Eigen/src/SparseCore/SparseCwiseBinaryOp.h +559 -347
  330. package/eigen/Eigen/src/SparseCore/SparseCwiseUnaryOp.h +100 -108
  331. package/eigen/Eigen/src/SparseCore/SparseDenseProduct.h +185 -191
  332. package/eigen/Eigen/src/SparseCore/SparseDiagonalProduct.h +71 -71
  333. package/eigen/Eigen/src/SparseCore/SparseDot.h +49 -47
  334. package/eigen/Eigen/src/SparseCore/SparseFuzzy.h +13 -11
  335. package/eigen/Eigen/src/SparseCore/SparseMap.h +243 -253
  336. package/eigen/Eigen/src/SparseCore/SparseMatrix.h +1614 -1142
  337. package/eigen/Eigen/src/SparseCore/SparseMatrixBase.h +403 -357
  338. package/eigen/Eigen/src/SparseCore/SparsePermutation.h +186 -115
  339. package/eigen/Eigen/src/SparseCore/SparseProduct.h +100 -91
  340. package/eigen/Eigen/src/SparseCore/SparseRedux.h +22 -24
  341. package/eigen/Eigen/src/SparseCore/SparseRef.h +268 -295
  342. package/eigen/Eigen/src/SparseCore/SparseSelfAdjointView.h +371 -414
  343. package/eigen/Eigen/src/SparseCore/SparseSolverBase.h +78 -87
  344. package/eigen/Eigen/src/SparseCore/SparseSparseProductWithPruning.h +81 -95
  345. package/eigen/Eigen/src/SparseCore/SparseTranspose.h +62 -71
  346. package/eigen/Eigen/src/SparseCore/SparseTriangularView.h +132 -144
  347. package/eigen/Eigen/src/SparseCore/SparseUtil.h +146 -115
  348. package/eigen/Eigen/src/SparseCore/SparseVector.h +426 -372
  349. package/eigen/Eigen/src/SparseCore/SparseView.h +164 -193
  350. package/eigen/Eigen/src/SparseCore/TriangularSolver.h +129 -170
  351. package/eigen/Eigen/src/SparseLU/InternalHeaderCheck.h +3 -0
  352. package/eigen/Eigen/src/SparseLU/SparseLU.h +814 -618
  353. package/eigen/Eigen/src/SparseLU/SparseLUImpl.h +61 -48
  354. package/eigen/Eigen/src/SparseLU/SparseLU_Memory.h +102 -118
  355. package/eigen/Eigen/src/SparseLU/SparseLU_Structs.h +38 -35
  356. package/eigen/Eigen/src/SparseLU/SparseLU_SupernodalMatrix.h +273 -255
  357. package/eigen/Eigen/src/SparseLU/SparseLU_Utils.h +44 -49
  358. package/eigen/Eigen/src/SparseLU/SparseLU_column_bmod.h +104 -108
  359. package/eigen/Eigen/src/SparseLU/SparseLU_column_dfs.h +90 -101
  360. package/eigen/Eigen/src/SparseLU/SparseLU_copy_to_ucol.h +57 -58
  361. package/eigen/Eigen/src/SparseLU/SparseLU_heap_relax_snode.h +43 -55
  362. package/eigen/Eigen/src/SparseLU/SparseLU_kernel_bmod.h +74 -71
  363. package/eigen/Eigen/src/SparseLU/SparseLU_panel_bmod.h +125 -133
  364. package/eigen/Eigen/src/SparseLU/SparseLU_panel_dfs.h +136 -159
  365. package/eigen/Eigen/src/SparseLU/SparseLU_pivotL.h +51 -52
  366. package/eigen/Eigen/src/SparseLU/SparseLU_pruneL.h +67 -73
  367. package/eigen/Eigen/src/SparseLU/SparseLU_relax_snode.h +24 -26
  368. package/eigen/Eigen/src/SparseQR/InternalHeaderCheck.h +3 -0
  369. package/eigen/Eigen/src/SparseQR/SparseQR.h +451 -490
  370. package/eigen/Eigen/src/StlSupport/StdDeque.h +28 -105
  371. package/eigen/Eigen/src/StlSupport/StdList.h +28 -84
  372. package/eigen/Eigen/src/StlSupport/StdVector.h +28 -108
  373. package/eigen/Eigen/src/StlSupport/details.h +48 -50
  374. package/eigen/Eigen/src/SuperLUSupport/InternalHeaderCheck.h +3 -0
  375. package/eigen/Eigen/src/SuperLUSupport/SuperLUSupport.h +634 -732
  376. package/eigen/Eigen/src/ThreadPool/Barrier.h +70 -0
  377. package/eigen/Eigen/src/ThreadPool/CoreThreadPoolDevice.h +336 -0
  378. package/eigen/Eigen/src/ThreadPool/EventCount.h +241 -0
  379. package/eigen/Eigen/src/ThreadPool/ForkJoin.h +140 -0
  380. package/eigen/Eigen/src/ThreadPool/InternalHeaderCheck.h +4 -0
  381. package/eigen/Eigen/src/ThreadPool/NonBlockingThreadPool.h +587 -0
  382. package/eigen/Eigen/src/ThreadPool/RunQueue.h +230 -0
  383. package/eigen/Eigen/src/ThreadPool/ThreadCancel.h +21 -0
  384. package/eigen/Eigen/src/ThreadPool/ThreadEnvironment.h +43 -0
  385. package/eigen/Eigen/src/ThreadPool/ThreadLocal.h +289 -0
  386. package/eigen/Eigen/src/ThreadPool/ThreadPoolInterface.h +50 -0
  387. package/eigen/Eigen/src/ThreadPool/ThreadYield.h +16 -0
  388. package/eigen/Eigen/src/UmfPackSupport/InternalHeaderCheck.h +3 -0
  389. package/eigen/Eigen/src/UmfPackSupport/UmfPackSupport.h +480 -380
  390. package/eigen/Eigen/src/misc/Image.h +41 -43
  391. package/eigen/Eigen/src/misc/InternalHeaderCheck.h +3 -0
  392. package/eigen/Eigen/src/misc/Kernel.h +39 -41
  393. package/eigen/Eigen/src/misc/RealSvd2x2.h +19 -21
  394. package/eigen/Eigen/src/misc/blas.h +83 -426
  395. package/eigen/Eigen/src/misc/lapacke.h +9976 -16182
  396. package/eigen/Eigen/src/misc/lapacke_helpers.h +163 -0
  397. package/eigen/Eigen/src/misc/lapacke_mangling.h +4 -5
  398. package/eigen/Eigen/src/plugins/ArrayCwiseBinaryOps.inc +344 -0
  399. package/eigen/Eigen/src/plugins/ArrayCwiseUnaryOps.inc +544 -0
  400. package/eigen/Eigen/src/plugins/BlockMethods.inc +1370 -0
  401. package/eigen/Eigen/src/plugins/CommonCwiseBinaryOps.inc +116 -0
  402. package/eigen/Eigen/src/plugins/CommonCwiseUnaryOps.inc +167 -0
  403. package/eigen/Eigen/src/plugins/IndexedViewMethods.inc +192 -0
  404. package/eigen/Eigen/src/plugins/InternalHeaderCheck.inc +3 -0
  405. package/eigen/Eigen/src/plugins/MatrixCwiseBinaryOps.inc +331 -0
  406. package/eigen/Eigen/src/plugins/MatrixCwiseUnaryOps.inc +118 -0
  407. package/eigen/Eigen/src/plugins/ReshapedMethods.inc +133 -0
  408. package/lib/LibEigen.d.ts +4 -0
  409. package/lib/LibEigen.js +14 -0
  410. package/lib/index.d.ts +1 -1
  411. package/lib/index.js +7 -3
  412. package/package.json +2 -10
  413. package/eigen/Eigen/CMakeLists.txt +0 -19
  414. package/eigen/Eigen/src/Core/BooleanRedux.h +0 -164
  415. package/eigen/Eigen/src/Core/arch/CUDA/Complex.h +0 -103
  416. package/eigen/Eigen/src/Core/arch/CUDA/Half.h +0 -675
  417. package/eigen/Eigen/src/Core/arch/CUDA/MathFunctions.h +0 -91
  418. package/eigen/Eigen/src/Core/arch/CUDA/PacketMath.h +0 -333
  419. package/eigen/Eigen/src/Core/arch/CUDA/PacketMathHalf.h +0 -1124
  420. package/eigen/Eigen/src/Core/arch/CUDA/TypeCasting.h +0 -212
  421. package/eigen/Eigen/src/Core/util/NonMPL2.h +0 -3
  422. package/eigen/Eigen/src/Geometry/arch/Geometry_SSE.h +0 -161
  423. package/eigen/Eigen/src/LU/arch/Inverse_SSE.h +0 -338
  424. package/eigen/Eigen/src/SparseCore/MappedSparseMatrix.h +0 -67
  425. package/eigen/Eigen/src/SparseLU/SparseLU_gemm_kernel.h +0 -280
  426. package/eigen/Eigen/src/misc/lapack.h +0 -152
  427. package/eigen/Eigen/src/plugins/ArrayCwiseBinaryOps.h +0 -332
  428. package/eigen/Eigen/src/plugins/ArrayCwiseUnaryOps.h +0 -552
  429. package/eigen/Eigen/src/plugins/BlockMethods.h +0 -1058
  430. package/eigen/Eigen/src/plugins/CommonCwiseBinaryOps.h +0 -115
  431. package/eigen/Eigen/src/plugins/CommonCwiseUnaryOps.h +0 -163
  432. package/eigen/Eigen/src/plugins/MatrixCwiseBinaryOps.h +0 -152
  433. package/eigen/Eigen/src/plugins/MatrixCwiseUnaryOps.h +0 -85
  434. package/lib/eigen.d.ts +0 -2
  435. 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
- namespace Eigen {
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 QRPreconditioner,
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
- enum { a = MatrixType::RowsAtCompileTime != Dynamic &&
36
- MatrixType::ColsAtCompileTime != Dynamic &&
37
- MatrixType::ColsAtCompileTime <= MatrixType::RowsAtCompileTime,
38
- b = MatrixType::RowsAtCompileTime != Dynamic &&
39
- MatrixType::ColsAtCompileTime != Dynamic &&
40
- MatrixType::RowsAtCompileTime <= MatrixType::ColsAtCompileTime,
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
- bool DoAnything = qr_preconditioner_should_do_anything<MatrixType, QRPreconditioner, Case>::ret
49
- > struct qr_preconditioner_impl {};
50
-
51
- template<typename MatrixType, int QRPreconditioner, int Case>
52
- class qr_preconditioner_impl<MatrixType, QRPreconditioner, Case, false>
53
- {
54
- public:
55
- void allocate(const JacobiSVD<MatrixType, QRPreconditioner>&) {}
56
- bool run(JacobiSVD<MatrixType, QRPreconditioner>&, const 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, true>
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
- enum
70
- {
71
- RowsAtCompileTime = MatrixType::RowsAtCompileTime,
72
- MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime
73
- };
74
- typedef Matrix<Scalar, 1, RowsAtCompileTime, RowMajor, 1, MaxRowsAtCompileTime> WorkspaceType;
75
-
76
- void allocate(const JacobiSVD<MatrixType, FullPivHouseholderQRPreconditioner>& svd)
77
- {
78
- if (svd.rows() != m_qr.rows() || svd.cols() != m_qr.cols())
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(JacobiSVD<MatrixType, FullPivHouseholderQRPreconditioner>& svd, const MatrixType& matrix)
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
- private:
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, true>
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
- enum
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
- TrOptions = RowsAtCompileTime==1 ? (MatrixType::Options & ~(RowMajor))
116
- : ColsAtCompileTime==1 ? (MatrixType::Options | RowMajor)
117
- : MatrixType::Options
111
+ MatrixOptions = traits<MatrixType>::Options
118
112
  };
119
- typedef Matrix<Scalar, ColsAtCompileTime, RowsAtCompileTime, TrOptions, MaxColsAtCompileTime, MaxRowsAtCompileTime>
120
- TransposeTypeWithSameStorageOrder;
121
-
122
- void allocate(const JacobiSVD<MatrixType, FullPivHouseholderQRPreconditioner>& svd)
123
- {
124
- if (svd.cols() != m_qr.rows() || svd.rows() != m_qr.cols())
125
- {
126
- m_qr.~QRType();
127
- ::new (&m_qr) QRType(svd.cols(), svd.rows());
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(JacobiSVD<MatrixType, FullPivHouseholderQRPreconditioner>& svd, const MatrixType& matrix)
134
- {
135
- if(matrix.cols() > matrix.rows())
136
- {
137
- m_adjoint = matrix.adjoint();
138
- m_qr.compute(m_adjoint);
139
- svd.m_workMatrix = m_qr.matrixQR().block(0,0,matrix.rows(),matrix.rows()).template triangularView<Upper>().adjoint();
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
- else return false;
134
+ } else
135
+ return false;
145
136
  }
146
- private:
137
+
138
+ private:
147
139
  typedef FullPivHouseholderQR<TransposeTypeWithSameStorageOrder> QRType;
148
140
  QRType m_qr;
149
- TransposeTypeWithSameStorageOrder m_adjoint;
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, true>
157
- {
158
- public:
159
- void allocate(const JacobiSVD<MatrixType, ColPivHouseholderQRPreconditioner>& svd)
160
- {
161
- if (svd.rows() != m_qr.rows() || svd.cols() != m_qr.cols())
162
- {
163
- m_qr.~QRType();
164
- ::new (&m_qr) QRType(svd.rows(), svd.cols());
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) m_workspace.resize(svd.rows());
167
- else if (svd.m_computeThinU) m_workspace.resize(svd.cols());
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(JacobiSVD<MatrixType, ColPivHouseholderQRPreconditioner>& svd, const MatrixType& matrix)
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) m_qr.householderQ().evalTo(svd.m_matrixU, m_workspace);
177
- else if(svd.m_computeThinU)
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
- typename internal::plain_col_type<MatrixType>::type m_workspace;
190
+ WorkspaceType m_workspace;
192
191
  };
193
192
 
194
- template<typename MatrixType>
195
- class qr_preconditioner_impl<MatrixType, ColPivHouseholderQRPreconditioner, PreconditionIfMoreColsThanRows, true>
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
- enum
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
- TrOptions = RowsAtCompileTime==1 ? (MatrixType::Options & ~(RowMajor))
206
- : ColsAtCompileTime==1 ? (MatrixType::Options | RowMajor)
207
- : MatrixType::Options
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, ColsAtCompileTime, RowsAtCompileTime, TrOptions, MaxColsAtCompileTime, MaxRowsAtCompileTime>
211
- TransposeTypeWithSameStorageOrder;
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 JacobiSVD<MatrixType, ColPivHouseholderQRPreconditioner>& svd)
214
- {
215
- if (svd.cols() != m_qr.rows() || svd.rows() != m_qr.cols())
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) m_workspace.resize(svd.cols());
221
- else if (svd.m_computeThinV) m_workspace.resize(svd.rows());
222
- m_adjoint.resize(svd.cols(), svd.rows());
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(JacobiSVD<MatrixType, ColPivHouseholderQRPreconditioner>& svd, const MatrixType& matrix)
226
- {
227
- if(matrix.cols() > matrix.rows())
228
- {
229
- m_adjoint = matrix.adjoint();
230
- m_qr.compute(m_adjoint);
231
-
232
- svd.m_workMatrix = m_qr.matrixQR().block(0,0,matrix.rows(),matrix.rows()).template triangularView<Upper>().adjoint();
233
- if(svd.m_computeFullV) m_qr.householderQ().evalTo(svd.m_matrixV, m_workspace);
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
- else return false;
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
- TransposeTypeWithSameStorageOrder m_adjoint;
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
- public:
258
- void allocate(const JacobiSVD<MatrixType, HouseholderQRPreconditioner>& svd)
259
- {
260
- if (svd.rows() != m_qr.rows() || svd.cols() != m_qr.cols())
261
- {
262
- m_qr.~QRType();
263
- ::new (&m_qr) QRType(svd.rows(), svd.cols());
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) m_workspace.resize(svd.rows());
266
- else if (svd.m_computeThinU) m_workspace.resize(svd.cols());
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(JacobiSVD<MatrixType, HouseholderQRPreconditioner>& svd, const MatrixType& matrix)
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) m_qr.householderQ().evalTo(svd.m_matrixU, m_workspace);
276
- else if(svd.m_computeThinU)
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
- private:
292
+
293
+ private:
287
294
  typedef HouseholderQR<MatrixType> QRType;
288
295
  QRType m_qr;
289
- typename internal::plain_col_type<MatrixType>::type m_workspace;
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
- enum
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
- Options = MatrixType::Options
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, ColsAtCompileTime, RowsAtCompileTime, Options, MaxColsAtCompileTime, MaxRowsAtCompileTime>
307
- TransposeTypeWithSameStorageOrder;
315
+ typedef Matrix<Scalar, WorkspaceSize, 1, ColMajor, MaxWorkspaceSize, 1> WorkspaceType;
308
316
 
309
- void allocate(const JacobiSVD<MatrixType, HouseholderQRPreconditioner>& svd)
310
- {
311
- if (svd.cols() != m_qr.rows() || svd.rows() != m_qr.cols())
312
- {
313
- m_qr.~QRType();
314
- ::new (&m_qr) QRType(svd.cols(), svd.rows());
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) m_workspace.resize(svd.cols());
317
- else if (svd.m_computeThinV) m_workspace.resize(svd.rows());
318
- m_adjoint.resize(svd.cols(), svd.rows());
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
- bool run(JacobiSVD<MatrixType, HouseholderQRPreconditioner>& svd, const MatrixType& matrix)
322
- {
323
- if(matrix.cols() > matrix.rows())
324
- {
325
- m_adjoint = matrix.adjoint();
326
- m_qr.compute(m_adjoint);
327
-
328
- svd.m_workMatrix = m_qr.matrixQR().block(0,0,matrix.rows(),matrix.rows()).template triangularView<Upper>().adjoint();
329
- if(svd.m_computeFullV) m_qr.householderQ().evalTo(svd.m_matrixV, m_workspace);
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
- else return false;
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
- TransposeTypeWithSameStorageOrder m_adjoint;
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 QRPreconditioner>
354
- struct svd_precondition_2x2_block_to_be_real<MatrixType, QRPreconditioner, false>
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 QRPreconditioner>
362
- struct svd_precondition_2x2_block_to_be_real<MatrixType, QRPreconditioner, true>
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==0)
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
- // work_matrix.coeff(p,q) can be zero if work_matrix.coeff(q,p) is not zero but small enough to underflow when computing n
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
- else
399
- {
400
- rot.c() = conj(work_matrix.coeff(p,p)) / n;
401
- rot.s() = work_matrix.coeff(q,p) / n;
402
- work_matrix.applyOnTheLeft(p,q,rot);
403
- if(svd.computeU()) svd.m_matrixU.applyOnTheRight(p,q,rot.adjoint());
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>(maxDiagEntry,numext::maxi<RealScalar>(abs(work_matrix.coeff(p,p)), abs(work_matrix.coeff(q,q))));
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 _MatrixType, int QRPreconditioner>
427
- struct traits<JacobiSVD<_MatrixType,QRPreconditioner> >
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
- } // end namespace internal
432
+ } // end namespace internal
433
433
 
434
434
  /** \ingroup SVD_Module
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 QRPreconditioner this optional parameter allows to specify the type of QR decomposition that will be used internally
443
- * for the R-SVD step for non-square matrices. See discussion of possible values below.
444
- *
445
- * SVD decomposition consists in decomposing any n-by-p matrix \a A as a product
446
- * \f[ A = U S V^* \f]
447
- * 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 outside of its main diagonal;
448
- * the diagonal entries of S are known as the \em singular \em values of \a A and the columns of \a U and \a V are known as the left
449
- * and right \em singular \em vectors of \a A respectively.
450
- *
451
- * Singular values are always sorted in decreasing order.
452
- *
453
- * This JacobiSVD decomposition computes only the singular values by default. If you want \a U or \a V, you need to ask for them explicitly.
454
- *
455
- * 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 matrix, letting \a m be the
456
- * smaller value among \a n and \a p, there are only \a m singular vectors; the remaining columns of \a U and \a V do not correspond to actual
457
- * singular vectors. Asking for \em thin \a U or \a V means asking for only their \a m first columns to be formed. So \a U is then a n-by-m matrix,
458
- * and \a V is then a p-by-m matrix. Notice that thin \a U and \a V are all you need for (least squares) solving.
459
- *
460
- * Here's an example demonstrating basic usage:
461
- * \include JacobiSVD_basic.cpp
462
- * Output: \verbinclude JacobiSVD_basic.out
463
- *
464
- * This JacobiSVD class is a two-sided Jacobi R-SVD decomposition, ensuring optimal reliability and accuracy. The downside is that it's slower than
465
- * bidiagonalizing SVD algorithms for large square matrices; however its complexity is still \f$ O(n^2p) \f$ where \a n is the smaller dimension and
466
- * \a p is the greater dimension, meaning that it is still of the same order of complexity as the faster bidiagonalizing R-SVD algorithms.
467
- * In particular, like any R-SVD, it takes advantage of non-squareness in that its complexity is only linear in the greater dimension.
468
- *
469
- * If the input matrix has inf or nan coefficients, the result of the computation is undefined, but the computation is guaranteed to
470
- * terminate in finite (and reasonable) time.
471
- *
472
- * The possible values for QRPreconditioner are:
473
- * \li ColPivHouseholderQRPreconditioner is the default. In practice it's very safe. It uses column-pivoting QR.
474
- * \li FullPivHouseholderQRPreconditioner, is the safest and slowest. It uses full-pivoting QR.
475
- * Contrary to other QRs, it doesn't allow computing thin unitaries.
476
- * \li HouseholderQRPreconditioner is the fastest, and less safe and accurate than the pivoting variants. It uses non-pivoting QR.
477
- * This is very similar in safety and accuracy to the bidiagonalization process used by bidiagonalizing SVD algorithms (since bidiagonalization
478
- * is inherently non-pivoting). However the resulting SVD is still more reliable than bidiagonalizing SVDs because the Jacobi-based iterarive
479
- * process is more reliable than the optimized bidiagonal SVD iterations.
480
- * \li NoQRPreconditioner allows not to use a QR preconditioner at all. This is useful if you know that you will only be computing
481
- * JacobiSVD decompositions of square matrices. Non-square matrices require a QR preconditioner. Using this option will result in
482
- * faster compilation and smaller executable code. It won't significantly speed up computation, since JacobiSVD is always checking
483
- * if QR preconditioning is needed before applying it anyway.
484
- *
485
- * \sa MatrixBase::jacobiSvd()
486
- */
487
- template<typename _MatrixType, int QRPreconditioner> class JacobiSVD
488
- : public SVDBase<JacobiSVD<_MatrixType,QRPreconditioner> >
489
- {
490
- typedef SVDBase<JacobiSVD> Base;
491
- public:
492
-
493
- typedef _MatrixType MatrixType;
494
- typedef typename MatrixType::Scalar Scalar;
495
- typedef typename NumTraits<typename MatrixType::Scalar>::Real RealScalar;
496
- enum {
497
- RowsAtCompileTime = MatrixType::RowsAtCompileTime,
498
- ColsAtCompileTime = MatrixType::ColsAtCompileTime,
499
- DiagSizeAtCompileTime = EIGEN_SIZE_MIN_PREFER_DYNAMIC(RowsAtCompileTime,ColsAtCompileTime),
500
- MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
501
- MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime,
502
- MaxDiagSizeAtCompileTime = EIGEN_SIZE_MIN_PREFER_FIXED(MaxRowsAtCompileTime,MaxColsAtCompileTime),
503
- MatrixOptions = MatrixType::Options
504
- };
505
-
506
- typedef typename Base::MatrixUType MatrixUType;
507
- typedef typename Base::MatrixVType MatrixVType;
508
- typedef typename Base::SingularValuesType SingularValuesType;
509
-
510
- typedef typename internal::plain_row_type<MatrixType>::type RowType;
511
- typedef typename internal::plain_col_type<MatrixType>::type ColType;
512
- typedef Matrix<Scalar, DiagSizeAtCompileTime, DiagSizeAtCompileTime,
513
- MatrixOptions, MaxDiagSizeAtCompileTime, MaxDiagSizeAtCompileTime>
514
- WorkMatrixType;
515
-
516
- /** \brief Default Constructor.
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
- /** \brief Constructor performing the decomposition of given matrix.
537
- *
538
- * \param matrix the matrix to decompose
539
- * \param computationOptions optional parameter allowing to specify if you want full or thin U or V unitaries to be computed.
540
- * By default, none is computed. This is a bit-field, the possible bits are #ComputeFullU, #ComputeThinU,
541
- * #ComputeFullV, #ComputeThinV.
542
- *
543
- * Thin unitaries are only available if your matrix type has a Dynamic number of columns (for example MatrixXf). They also are not
544
- * available with the (non-default) FullPivHouseholderQR preconditioner.
545
- */
546
- explicit JacobiSVD(const MatrixType& matrix, unsigned int computationOptions = 0)
547
- {
548
- compute(matrix, computationOptions);
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
- /** \brief Method performing the decomposition of given matrix using custom options.
552
- *
553
- * \param matrix the matrix to decompose
554
- * \param computationOptions optional parameter allowing to specify if you want full or thin U or V unitaries to be computed.
555
- * By default, none is computed. This is a bit-field, the possible bits are #ComputeFullU, #ComputeThinU,
556
- * #ComputeFullV, #ComputeThinV.
557
- *
558
- * Thin unitaries are only available if your matrix type has a Dynamic number of columns (for example MatrixXf). They also are not
559
- * available with the (non-default) FullPivHouseholderQR preconditioner.
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
- using Base::computeU;
575
- using Base::computeV;
576
- using Base::rows;
577
- using Base::cols;
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
- template<typename MatrixType, int QRPreconditioner>
613
- void JacobiSVD<MatrixType, QRPreconditioner>::allocate(Index rows, Index cols, unsigned int computationOptions)
614
- {
615
- eigen_assert(rows >= 0 && cols >= 0);
616
-
617
- if (m_isAllocated &&
618
- rows == m_rows &&
619
- cols == m_cols &&
620
- computationOptions == m_computationOptions)
621
- {
622
- return;
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
- m_rows = rows;
626
- m_cols = cols;
627
- m_isInitialized = false;
628
- m_isAllocated = true;
629
- m_computationOptions = computationOptions;
630
- m_computeFullU = (computationOptions & ComputeFullU) != 0;
631
- m_computeThinU = (computationOptions & ComputeThinU) != 0;
632
- m_computeFullV = (computationOptions & ComputeFullV) != 0;
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
- m_diagSize = (std::min)(m_rows, m_cols);
645
- m_singularValues.resize(m_diagSize);
646
- if(RowsAtCompileTime==Dynamic)
647
- m_matrixU.resize(m_rows, m_computeFullU ? m_rows
648
- : m_computeThinU ? m_diagSize
649
- : 0);
650
- if(ColsAtCompileTime==Dynamic)
651
- m_matrixV.resize(m_cols, m_computeFullV ? m_cols
652
- : m_computeThinV ? m_diagSize
653
- : 0);
654
- m_workMatrix.resize(m_diagSize, m_diagSize);
655
-
656
- if(m_cols>m_rows) m_qr_precond_morecols.allocate(*this);
657
- if(m_rows>m_cols) m_qr_precond_morerows.allocate(*this);
658
- if(m_rows!=m_cols) m_scaledMatrix.resize(rows,cols);
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 QRPreconditioner>
662
- JacobiSVD<MatrixType, QRPreconditioner>&
663
- JacobiSVD<MatrixType, QRPreconditioner>::compute(const MatrixType& matrix, unsigned int computationOptions)
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 of iterations,
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(scale==RealScalar(0)) scale = RealScalar(1);
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(m_rows!=m_cols)
682
- {
683
- m_scaledMatrix = matrix / scale;
684
- m_qr_precond_morecols.run(*this, m_scaledMatrix);
685
- m_qr_precond_morerows.run(*this, m_scaledMatrix);
686
- }
687
- else
688
- {
689
- m_workMatrix = matrix.block(0,0,m_diagSize,m_diagSize) / scale;
690
- if(m_computeFullU) m_matrixU.setIdentity(m_rows,m_rows);
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 < m_diagSize; ++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, QRPreconditioner>::run(m_workMatrix, *this, p, q, maxDiagEntry))
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>(maxDiagEntry,numext::maxi<RealScalar>(abs(m_workMatrix.coeff(p,p)), abs(m_workMatrix.coeff(q,q))));
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 < m_diagSize; ++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 = m_diagSize;
766
- for(Index i = 0; i < m_diagSize; i++)
767
- {
804
+ m_nonzeroSingularValues = diagSize();
805
+ for (Index i = 0; i < diagSize(); i++) {
768
806
  Index pos;
769
- RealScalar maxRemainingSingularValue = m_singularValues.tail(m_diagSize-i).maxCoeff(&pos);
770
- if(maxRemainingSingularValue == RealScalar(0))
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
- * \return the singular value decomposition of \c *this computed by two-sided
791
- * Jacobi transformations.
792
- *
793
- * \sa class JacobiSVD
794
- */
795
- template<typename Derived>
796
- JacobiSVD<typename MatrixBase<Derived>::PlainObject>
797
- MatrixBase<Derived>::jacobiSvd(unsigned int computationOptions) const
798
- {
799
- return JacobiSVD<PlainObject>(*this, computationOptions);
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
- } // end namespace Eigen
844
+ } // end namespace Eigen
803
845
 
804
- #endif // EIGEN_JACOBISVD_H
846
+ #endif // EIGEN_JACOBISVD_H