@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
@@ -13,411 +13,415 @@
13
13
 
14
14
  #include "./Tridiagonalization.h"
15
15
 
16
- namespace Eigen {
16
+ // IWYU pragma: private
17
+ #include "./InternalHeaderCheck.h"
17
18
 
18
- template<typename _MatrixType>
19
+ namespace Eigen {
20
+
21
+ template <typename MatrixType_>
19
22
  class GeneralizedSelfAdjointEigenSolver;
20
23
 
21
24
  namespace internal {
22
- template<typename SolverType,int Size,bool IsComplex> struct direct_selfadjoint_eigenvalues;
23
- template<typename MatrixType, typename DiagType, typename SubDiagType>
24
- ComputationInfo computeFromTridiagonal_impl(DiagType& diag, SubDiagType& subdiag, const Index maxIterations, bool computeEigenvectors, MatrixType& eivec);
25
- }
25
+ template <typename SolverType, int Size, bool IsComplex>
26
+ struct direct_selfadjoint_eigenvalues;
27
+
28
+ template <typename MatrixType, typename DiagType, typename SubDiagType>
29
+ EIGEN_DEVICE_FUNC ComputationInfo computeFromTridiagonal_impl(DiagType& diag, SubDiagType& subdiag,
30
+ const Index maxIterations, bool computeEigenvectors,
31
+ MatrixType& eivec);
32
+ } // namespace internal
26
33
 
27
34
  /** \eigenvalues_module \ingroup Eigenvalues_Module
28
- *
29
- *
30
- * \class SelfAdjointEigenSolver
31
- *
32
- * \brief Computes eigenvalues and eigenvectors of selfadjoint matrices
33
- *
34
- * \tparam _MatrixType the type of the matrix of which we are computing the
35
- * eigendecomposition; this is expected to be an instantiation of the Matrix
36
- * class template.
37
- *
38
- * A matrix \f$ A \f$ is selfadjoint if it equals its adjoint. For real
39
- * matrices, this means that the matrix is symmetric: it equals its
40
- * transpose. This class computes the eigenvalues and eigenvectors of a
41
- * selfadjoint matrix. These are the scalars \f$ \lambda \f$ and vectors
42
- * \f$ v \f$ such that \f$ Av = \lambda v \f$. The eigenvalues of a
43
- * selfadjoint matrix are always real. If \f$ D \f$ is a diagonal matrix with
44
- * the eigenvalues on the diagonal, and \f$ V \f$ is a matrix with the
45
- * eigenvectors as its columns, then \f$ A = V D V^{-1} \f$ (for selfadjoint
46
- * matrices, the matrix \f$ V \f$ is always invertible). This is called the
47
- * eigendecomposition.
48
- *
49
- * The algorithm exploits the fact that the matrix is selfadjoint, making it
50
- * faster and more accurate than the general purpose eigenvalue algorithms
51
- * implemented in EigenSolver and ComplexEigenSolver.
52
- *
53
- * Only the \b lower \b triangular \b part of the input matrix is referenced.
54
- *
55
- * Call the function compute() to compute the eigenvalues and eigenvectors of
56
- * a given matrix. Alternatively, you can use the
57
- * SelfAdjointEigenSolver(const MatrixType&, int) constructor which computes
58
- * the eigenvalues and eigenvectors at construction time. Once the eigenvalue
59
- * and eigenvectors are computed, they can be retrieved with the eigenvalues()
60
- * and eigenvectors() functions.
61
- *
62
- * The documentation for SelfAdjointEigenSolver(const MatrixType&, int)
63
- * contains an example of the typical use of this class.
64
- *
65
- * To solve the \em generalized eigenvalue problem \f$ Av = \lambda Bv \f$ and
66
- * the likes, see the class GeneralizedSelfAdjointEigenSolver.
67
- *
68
- * \sa MatrixBase::eigenvalues(), class EigenSolver, class ComplexEigenSolver
69
- */
70
- template<typename _MatrixType> class SelfAdjointEigenSolver
71
- {
72
- public:
73
-
74
- typedef _MatrixType MatrixType;
75
- enum {
76
- Size = MatrixType::RowsAtCompileTime,
77
- ColsAtCompileTime = MatrixType::ColsAtCompileTime,
78
- Options = MatrixType::Options,
79
- MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
80
- };
81
-
82
- /** \brief Scalar type for matrices of type \p _MatrixType. */
83
- typedef typename MatrixType::Scalar Scalar;
84
- typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3
85
-
86
- typedef Matrix<Scalar,Size,Size,ColMajor,MaxColsAtCompileTime,MaxColsAtCompileTime> EigenvectorsType;
87
-
88
- /** \brief Real scalar type for \p _MatrixType.
89
- *
90
- * This is just \c Scalar if #Scalar is real (e.g., \c float or
91
- * \c double), and the type of the real part of \c Scalar if #Scalar is
92
- * complex.
93
- */
94
- typedef typename NumTraits<Scalar>::Real RealScalar;
95
-
96
- friend struct internal::direct_selfadjoint_eigenvalues<SelfAdjointEigenSolver,Size,NumTraits<Scalar>::IsComplex>;
97
-
98
- /** \brief Type for vector of eigenvalues as returned by eigenvalues().
99
- *
100
- * This is a column vector with entries of type #RealScalar.
101
- * The length of the vector is the size of \p _MatrixType.
102
- */
103
- typedef typename internal::plain_col_type<MatrixType, RealScalar>::type RealVectorType;
104
- typedef Tridiagonalization<MatrixType> TridiagonalizationType;
105
- typedef typename TridiagonalizationType::SubDiagonalType SubDiagonalType;
106
-
107
- /** \brief Default constructor for fixed-size matrices.
108
- *
109
- * The default constructor is useful in cases in which the user intends to
110
- * perform decompositions via compute(). This constructor
111
- * can only be used if \p _MatrixType is a fixed-size matrix; use
112
- * SelfAdjointEigenSolver(Index) for dynamic-size matrices.
113
- *
114
- * Example: \include SelfAdjointEigenSolver_SelfAdjointEigenSolver.cpp
115
- * Output: \verbinclude SelfAdjointEigenSolver_SelfAdjointEigenSolver.out
116
- */
117
- EIGEN_DEVICE_FUNC
118
- SelfAdjointEigenSolver()
119
- : m_eivec(),
120
- m_eivalues(),
121
- m_subdiag(),
122
- m_isInitialized(false)
123
- { }
124
-
125
- /** \brief Constructor, pre-allocates memory for dynamic-size matrices.
126
- *
127
- * \param [in] size Positive integer, size of the matrix whose
128
- * eigenvalues and eigenvectors will be computed.
129
- *
130
- * This constructor is useful for dynamic-size matrices, when the user
131
- * intends to perform decompositions via compute(). The \p size
132
- * parameter is only used as a hint. It is not an error to give a wrong
133
- * \p size, but it may impair performance.
134
- *
135
- * \sa compute() for an example
136
- */
137
- EIGEN_DEVICE_FUNC
138
- explicit SelfAdjointEigenSolver(Index size)
139
- : m_eivec(size, size),
140
- m_eivalues(size),
141
- m_subdiag(size > 1 ? size - 1 : 1),
142
- m_isInitialized(false)
143
- {}
144
-
145
- /** \brief Constructor; computes eigendecomposition of given matrix.
146
- *
147
- * \param[in] matrix Selfadjoint matrix whose eigendecomposition is to
148
- * be computed. Only the lower triangular part of the matrix is referenced.
149
- * \param[in] options Can be #ComputeEigenvectors (default) or #EigenvaluesOnly.
150
- *
151
- * This constructor calls compute(const MatrixType&, int) to compute the
152
- * eigenvalues of the matrix \p matrix. The eigenvectors are computed if
153
- * \p options equals #ComputeEigenvectors.
154
- *
155
- * Example: \include SelfAdjointEigenSolver_SelfAdjointEigenSolver_MatrixType.cpp
156
- * Output: \verbinclude SelfAdjointEigenSolver_SelfAdjointEigenSolver_MatrixType.out
157
- *
158
- * \sa compute(const MatrixType&, int)
159
- */
160
- template<typename InputType>
161
- EIGEN_DEVICE_FUNC
162
- explicit SelfAdjointEigenSolver(const EigenBase<InputType>& matrix, int options = ComputeEigenvectors)
35
+ *
36
+ *
37
+ * \class SelfAdjointEigenSolver
38
+ *
39
+ * \brief Computes eigenvalues and eigenvectors of selfadjoint matrices
40
+ *
41
+ * \tparam MatrixType_ the type of the matrix of which we are computing the
42
+ * eigendecomposition; this is expected to be an instantiation of the Matrix
43
+ * class template.
44
+ *
45
+ * A matrix \f$ A \f$ is selfadjoint if it equals its adjoint. For real
46
+ * matrices, this means that the matrix is symmetric: it equals its
47
+ * transpose. This class computes the eigenvalues and eigenvectors of a
48
+ * selfadjoint matrix. These are the scalars \f$ \lambda \f$ and vectors
49
+ * \f$ v \f$ such that \f$ Av = \lambda v \f$. The eigenvalues of a
50
+ * selfadjoint matrix are always real. If \f$ D \f$ is a diagonal matrix with
51
+ * the eigenvalues on the diagonal, and \f$ V \f$ is a matrix with the
52
+ * eigenvectors as its columns, then \f$ A = V D V^{-1} \f$. This is called the
53
+ * eigendecomposition.
54
+ *
55
+ * For a selfadjoint matrix, \f$ V \f$ is unitary, meaning its inverse is equal
56
+ * to its adjoint, \f$ V^{-1} = V^{\dagger} \f$. If \f$ A \f$ is real, then
57
+ * \f$ V \f$ is also real and therefore orthogonal, meaning its inverse is
58
+ * equal to its transpose, \f$ V^{-1} = V^T \f$.
59
+ *
60
+ * The algorithm exploits the fact that the matrix is selfadjoint, making it
61
+ * faster and more accurate than the general purpose eigenvalue algorithms
62
+ * implemented in EigenSolver and ComplexEigenSolver.
63
+ *
64
+ * Only the \b lower \b triangular \b part of the input matrix is referenced.
65
+ *
66
+ * Call the function compute() to compute the eigenvalues and eigenvectors of
67
+ * a given matrix. Alternatively, you can use the
68
+ * SelfAdjointEigenSolver(const MatrixType&, int) constructor which computes
69
+ * the eigenvalues and eigenvectors at construction time. Once the eigenvalue
70
+ * and eigenvectors are computed, they can be retrieved with the eigenvalues()
71
+ * and eigenvectors() functions.
72
+ *
73
+ * The documentation for SelfAdjointEigenSolver(const MatrixType&, int)
74
+ * contains an example of the typical use of this class.
75
+ *
76
+ * To solve the \em generalized eigenvalue problem \f$ Av = \lambda Bv \f$ and
77
+ * the likes, see the class GeneralizedSelfAdjointEigenSolver.
78
+ *
79
+ * \sa MatrixBase::eigenvalues(), class EigenSolver, class ComplexEigenSolver
80
+ */
81
+ template <typename MatrixType_>
82
+ class SelfAdjointEigenSolver {
83
+ public:
84
+ typedef MatrixType_ MatrixType;
85
+ enum {
86
+ Size = MatrixType::RowsAtCompileTime,
87
+ ColsAtCompileTime = MatrixType::ColsAtCompileTime,
88
+ Options = internal::traits<MatrixType>::Options,
89
+ MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
90
+ };
91
+
92
+ /** \brief Scalar type for matrices of type \p MatrixType_. */
93
+ typedef typename MatrixType::Scalar Scalar;
94
+ typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3
95
+
96
+ typedef Matrix<Scalar, Size, Size, ColMajor, MaxColsAtCompileTime, MaxColsAtCompileTime> EigenvectorsType;
97
+
98
+ /** \brief Real scalar type for \p MatrixType_.
99
+ *
100
+ * This is just \c Scalar if #Scalar is real (e.g., \c float or
101
+ * \c double), and the type of the real part of \c Scalar if #Scalar is
102
+ * complex.
103
+ */
104
+ typedef typename NumTraits<Scalar>::Real RealScalar;
105
+
106
+ friend struct internal::direct_selfadjoint_eigenvalues<SelfAdjointEigenSolver, Size, NumTraits<Scalar>::IsComplex>;
107
+
108
+ /** \brief Type for vector of eigenvalues as returned by eigenvalues().
109
+ *
110
+ * This is a column vector with entries of type #RealScalar.
111
+ * The length of the vector is the size of \p MatrixType_.
112
+ */
113
+ typedef typename internal::plain_col_type<MatrixType, Scalar>::type VectorType;
114
+ typedef typename internal::plain_col_type<MatrixType, RealScalar>::type RealVectorType;
115
+ typedef Tridiagonalization<MatrixType> TridiagonalizationType;
116
+ typedef typename TridiagonalizationType::SubDiagonalType SubDiagonalType;
117
+
118
+ /** \brief Default constructor for fixed-size matrices.
119
+ *
120
+ * The default constructor is useful in cases in which the user intends to
121
+ * perform decompositions via compute(). This constructor
122
+ * can only be used if \p MatrixType_ is a fixed-size matrix; use
123
+ * SelfAdjointEigenSolver(Index) for dynamic-size matrices.
124
+ *
125
+ * Example: \include SelfAdjointEigenSolver_SelfAdjointEigenSolver.cpp
126
+ * Output: \verbinclude SelfAdjointEigenSolver_SelfAdjointEigenSolver.out
127
+ */
128
+ EIGEN_DEVICE_FUNC SelfAdjointEigenSolver()
129
+ : m_eivec(),
130
+ m_workspace(),
131
+ m_eivalues(),
132
+ m_subdiag(),
133
+ m_hcoeffs(),
134
+ m_info(InvalidInput),
135
+ m_isInitialized(false),
136
+ m_eigenvectorsOk(false) {}
137
+
138
+ /** \brief Constructor, pre-allocates memory for dynamic-size matrices.
139
+ *
140
+ * \param [in] size Positive integer, size of the matrix whose
141
+ * eigenvalues and eigenvectors will be computed.
142
+ *
143
+ * This constructor is useful for dynamic-size matrices, when the user
144
+ * intends to perform decompositions via compute(). The \p size
145
+ * parameter is only used as a hint. It is not an error to give a wrong
146
+ * \p size, but it may impair performance.
147
+ *
148
+ * \sa compute() for an example
149
+ */
150
+ EIGEN_DEVICE_FUNC explicit SelfAdjointEigenSolver(Index size)
151
+ : m_eivec(size, size),
152
+ m_workspace(size),
153
+ m_eivalues(size),
154
+ m_subdiag(size > 1 ? size - 1 : 1),
155
+ m_hcoeffs(size > 1 ? size - 1 : 1),
156
+ m_isInitialized(false),
157
+ m_eigenvectorsOk(false) {}
158
+
159
+ /** \brief Constructor; computes eigendecomposition of given matrix.
160
+ *
161
+ * \param[in] matrix Selfadjoint matrix whose eigendecomposition is to
162
+ * be computed. Only the lower triangular part of the matrix is referenced.
163
+ * \param[in] options Can be #ComputeEigenvectors (default) or #EigenvaluesOnly.
164
+ *
165
+ * This constructor calls compute(const MatrixType&, int) to compute the
166
+ * eigenvalues of the matrix \p matrix. The eigenvectors are computed if
167
+ * \p options equals #ComputeEigenvectors.
168
+ *
169
+ * Example: \include SelfAdjointEigenSolver_SelfAdjointEigenSolver_MatrixType.cpp
170
+ * Output: \verbinclude SelfAdjointEigenSolver_SelfAdjointEigenSolver_MatrixType.out
171
+ *
172
+ * \sa compute(const MatrixType&, int)
173
+ */
174
+ template <typename InputType>
175
+ EIGEN_DEVICE_FUNC explicit SelfAdjointEigenSolver(const EigenBase<InputType>& matrix,
176
+ int options = ComputeEigenvectors)
163
177
  : m_eivec(matrix.rows(), matrix.cols()),
178
+ m_workspace(matrix.cols()),
164
179
  m_eivalues(matrix.cols()),
165
180
  m_subdiag(matrix.rows() > 1 ? matrix.rows() - 1 : 1),
166
- m_isInitialized(false)
167
- {
168
- compute(matrix.derived(), options);
169
- }
181
+ m_hcoeffs(matrix.cols() > 1 ? matrix.cols() - 1 : 1),
182
+ m_isInitialized(false),
183
+ m_eigenvectorsOk(false) {
184
+ compute(matrix.derived(), options);
185
+ }
170
186
 
171
- /** \brief Computes eigendecomposition of given matrix.
172
- *
173
- * \param[in] matrix Selfadjoint matrix whose eigendecomposition is to
174
- * be computed. Only the lower triangular part of the matrix is referenced.
175
- * \param[in] options Can be #ComputeEigenvectors (default) or #EigenvaluesOnly.
176
- * \returns Reference to \c *this
177
- *
178
- * This function computes the eigenvalues of \p matrix. The eigenvalues()
179
- * function can be used to retrieve them. If \p options equals #ComputeEigenvectors,
180
- * then the eigenvectors are also computed and can be retrieved by
181
- * calling eigenvectors().
182
- *
183
- * This implementation uses a symmetric QR algorithm. The matrix is first
184
- * reduced to tridiagonal form using the Tridiagonalization class. The
185
- * tridiagonal matrix is then brought to diagonal form with implicit
186
- * symmetric QR steps with Wilkinson shift. Details can be found in
187
- * Section 8.3 of Golub \& Van Loan, <i>%Matrix Computations</i>.
188
- *
189
- * The cost of the computation is about \f$ 9n^3 \f$ if the eigenvectors
190
- * are required and \f$ 4n^3/3 \f$ if they are not required.
191
- *
192
- * This method reuses the memory in the SelfAdjointEigenSolver object that
193
- * was allocated when the object was constructed, if the size of the
194
- * matrix does not change.
195
- *
196
- * Example: \include SelfAdjointEigenSolver_compute_MatrixType.cpp
197
- * Output: \verbinclude SelfAdjointEigenSolver_compute_MatrixType.out
198
- *
199
- * \sa SelfAdjointEigenSolver(const MatrixType&, int)
200
- */
201
- template<typename InputType>
202
- EIGEN_DEVICE_FUNC
203
- SelfAdjointEigenSolver& compute(const EigenBase<InputType>& matrix, int options = ComputeEigenvectors);
204
-
205
- /** \brief Computes eigendecomposition of given matrix using a closed-form algorithm
206
- *
207
- * This is a variant of compute(const MatrixType&, int options) which
208
- * directly solves the underlying polynomial equation.
209
- *
210
- * Currently only 2x2 and 3x3 matrices for which the sizes are known at compile time are supported (e.g., Matrix3d).
211
- *
212
- * This method is usually significantly faster than the QR iterative algorithm
213
- * but it might also be less accurate. It is also worth noting that
214
- * for 3x3 matrices it involves trigonometric operations which are
215
- * not necessarily available for all scalar types.
216
- *
217
- * For the 3x3 case, we observed the following worst case relative error regarding the eigenvalues:
218
- * - double: 1e-8
219
- * - float: 1e-3
220
- *
221
- * \sa compute(const MatrixType&, int options)
222
- */
223
- EIGEN_DEVICE_FUNC
224
- SelfAdjointEigenSolver& computeDirect(const MatrixType& matrix, int options = ComputeEigenvectors);
225
-
226
- /**
227
- *\brief Computes the eigen decomposition from a tridiagonal symmetric matrix
228
- *
229
- * \param[in] diag The vector containing the diagonal of the matrix.
230
- * \param[in] subdiag The subdiagonal of the matrix.
231
- * \param[in] options Can be #ComputeEigenvectors (default) or #EigenvaluesOnly.
232
- * \returns Reference to \c *this
233
- *
234
- * This function assumes that the matrix has been reduced to tridiagonal form.
235
- *
236
- * \sa compute(const MatrixType&, int) for more information
237
- */
238
- SelfAdjointEigenSolver& computeFromTridiagonal(const RealVectorType& diag, const SubDiagonalType& subdiag , int options=ComputeEigenvectors);
239
-
240
- /** \brief Returns the eigenvectors of given matrix.
241
- *
242
- * \returns A const reference to the matrix whose columns are the eigenvectors.
243
- *
244
- * \pre The eigenvectors have been computed before.
245
- *
246
- * Column \f$ k \f$ of the returned matrix is an eigenvector corresponding
247
- * to eigenvalue number \f$ k \f$ as returned by eigenvalues(). The
248
- * eigenvectors are normalized to have (Euclidean) norm equal to one. If
249
- * this object was used to solve the eigenproblem for the selfadjoint
250
- * matrix \f$ A \f$, then the matrix returned by this function is the
251
- * matrix \f$ V \f$ in the eigendecomposition \f$ A = V D V^{-1} \f$.
252
- *
253
- * Example: \include SelfAdjointEigenSolver_eigenvectors.cpp
254
- * Output: \verbinclude SelfAdjointEigenSolver_eigenvectors.out
255
- *
256
- * \sa eigenvalues()
257
- */
258
- EIGEN_DEVICE_FUNC
259
- const EigenvectorsType& eigenvectors() const
260
- {
261
- eigen_assert(m_isInitialized && "SelfAdjointEigenSolver is not initialized.");
262
- eigen_assert(m_eigenvectorsOk && "The eigenvectors have not been computed together with the eigenvalues.");
263
- return m_eivec;
264
- }
187
+ /** \brief Computes eigendecomposition of given matrix.
188
+ *
189
+ * \param[in] matrix Selfadjoint matrix whose eigendecomposition is to
190
+ * be computed. Only the lower triangular part of the matrix is referenced.
191
+ * \param[in] options Can be #ComputeEigenvectors (default) or #EigenvaluesOnly.
192
+ * \returns Reference to \c *this
193
+ *
194
+ * This function computes the eigenvalues of \p matrix. The eigenvalues()
195
+ * function can be used to retrieve them. If \p options equals #ComputeEigenvectors,
196
+ * then the eigenvectors are also computed and can be retrieved by
197
+ * calling eigenvectors().
198
+ *
199
+ * This implementation uses a symmetric QR algorithm. The matrix is first
200
+ * reduced to tridiagonal form using the Tridiagonalization class. The
201
+ * tridiagonal matrix is then brought to diagonal form with implicit
202
+ * symmetric QR steps with Wilkinson shift. Details can be found in
203
+ * Section 8.3 of Golub \& Van Loan, <i>%Matrix Computations</i>.
204
+ *
205
+ * The cost of the computation is about \f$ 9n^3 \f$ if the eigenvectors
206
+ * are required and \f$ 4n^3/3 \f$ if they are not required.
207
+ *
208
+ * This method reuses the memory in the SelfAdjointEigenSolver object that
209
+ * was allocated when the object was constructed, if the size of the
210
+ * matrix does not change.
211
+ *
212
+ * Example: \include SelfAdjointEigenSolver_compute_MatrixType.cpp
213
+ * Output: \verbinclude SelfAdjointEigenSolver_compute_MatrixType.out
214
+ *
215
+ * \sa SelfAdjointEigenSolver(const MatrixType&, int)
216
+ */
217
+ template <typename InputType>
218
+ EIGEN_DEVICE_FUNC SelfAdjointEigenSolver& compute(const EigenBase<InputType>& matrix,
219
+ int options = ComputeEigenvectors);
220
+
221
+ /** \brief Computes eigendecomposition of given matrix using a closed-form algorithm
222
+ *
223
+ * This is a variant of compute(const MatrixType&, int options) which
224
+ * directly solves the underlying polynomial equation.
225
+ *
226
+ * Currently only 2x2 and 3x3 matrices for which the sizes are known at compile time are supported (e.g., Matrix3d).
227
+ *
228
+ * This method is usually significantly faster than the QR iterative algorithm
229
+ * but it might also be less accurate. It is also worth noting that
230
+ * for 3x3 matrices it involves trigonometric operations which are
231
+ * not necessarily available for all scalar types.
232
+ *
233
+ * For the 3x3 case, we observed the following worst case relative error regarding the eigenvalues:
234
+ * - double: 1e-8
235
+ * - float: 1e-3
236
+ *
237
+ * \sa compute(const MatrixType&, int options)
238
+ */
239
+ EIGEN_DEVICE_FUNC SelfAdjointEigenSolver& computeDirect(const MatrixType& matrix, int options = ComputeEigenvectors);
240
+
241
+ /**
242
+ *\brief Computes the eigen decomposition from a tridiagonal symmetric matrix
243
+ *
244
+ * \param[in] diag The vector containing the diagonal of the matrix.
245
+ * \param[in] subdiag The subdiagonal of the matrix.
246
+ * \param[in] options Can be #ComputeEigenvectors (default) or #EigenvaluesOnly.
247
+ * \returns Reference to \c *this
248
+ *
249
+ * This function assumes that the matrix has been reduced to tridiagonal form.
250
+ *
251
+ * \sa compute(const MatrixType&, int) for more information
252
+ */
253
+ SelfAdjointEigenSolver& computeFromTridiagonal(const RealVectorType& diag, const SubDiagonalType& subdiag,
254
+ int options = ComputeEigenvectors);
255
+
256
+ /** \brief Returns the eigenvectors of given matrix.
257
+ *
258
+ * \returns A const reference to the matrix whose columns are the eigenvectors.
259
+ *
260
+ * \pre The eigenvectors have been computed before.
261
+ *
262
+ * Column \f$ k \f$ of the returned matrix is an eigenvector corresponding
263
+ * to eigenvalue number \f$ k \f$ as returned by eigenvalues(). The
264
+ * eigenvectors are normalized to have (Euclidean) norm equal to one. If
265
+ * this object was used to solve the eigenproblem for the selfadjoint
266
+ * matrix \f$ A \f$, then the matrix returned by this function is the
267
+ * matrix \f$ V \f$ in the eigendecomposition \f$ A = V D V^{-1} \f$.
268
+ *
269
+ * For a selfadjoint matrix, \f$ V \f$ is unitary, meaning its inverse is equal
270
+ * to its adjoint, \f$ V^{-1} = V^{\dagger} \f$. If \f$ A \f$ is real, then
271
+ * \f$ V \f$ is also real and therefore orthogonal, meaning its inverse is
272
+ * equal to its transpose, \f$ V^{-1} = V^T \f$.
273
+ *
274
+ * Example: \include SelfAdjointEigenSolver_eigenvectors.cpp
275
+ * Output: \verbinclude SelfAdjointEigenSolver_eigenvectors.out
276
+ *
277
+ * \sa eigenvalues()
278
+ */
279
+ EIGEN_DEVICE_FUNC const EigenvectorsType& eigenvectors() const {
280
+ eigen_assert(m_isInitialized && "SelfAdjointEigenSolver is not initialized.");
281
+ eigen_assert(m_eigenvectorsOk && "The eigenvectors have not been computed together with the eigenvalues.");
282
+ return m_eivec;
283
+ }
265
284
 
266
- /** \brief Returns the eigenvalues of given matrix.
267
- *
268
- * \returns A const reference to the column vector containing the eigenvalues.
269
- *
270
- * \pre The eigenvalues have been computed before.
271
- *
272
- * The eigenvalues are repeated according to their algebraic multiplicity,
273
- * so there are as many eigenvalues as rows in the matrix. The eigenvalues
274
- * are sorted in increasing order.
275
- *
276
- * Example: \include SelfAdjointEigenSolver_eigenvalues.cpp
277
- * Output: \verbinclude SelfAdjointEigenSolver_eigenvalues.out
278
- *
279
- * \sa eigenvectors(), MatrixBase::eigenvalues()
280
- */
281
- EIGEN_DEVICE_FUNC
282
- const RealVectorType& eigenvalues() const
283
- {
284
- eigen_assert(m_isInitialized && "SelfAdjointEigenSolver is not initialized.");
285
- return m_eivalues;
286
- }
285
+ /** \brief Returns the eigenvalues of given matrix.
286
+ *
287
+ * \returns A const reference to the column vector containing the eigenvalues.
288
+ *
289
+ * \pre The eigenvalues have been computed before.
290
+ *
291
+ * The eigenvalues are repeated according to their algebraic multiplicity,
292
+ * so there are as many eigenvalues as rows in the matrix. The eigenvalues
293
+ * are sorted in increasing order.
294
+ *
295
+ * Example: \include SelfAdjointEigenSolver_eigenvalues.cpp
296
+ * Output: \verbinclude SelfAdjointEigenSolver_eigenvalues.out
297
+ *
298
+ * \sa eigenvectors(), MatrixBase::eigenvalues()
299
+ */
300
+ EIGEN_DEVICE_FUNC const RealVectorType& eigenvalues() const {
301
+ eigen_assert(m_isInitialized && "SelfAdjointEigenSolver is not initialized.");
302
+ return m_eivalues;
303
+ }
287
304
 
288
- /** \brief Computes the positive-definite square root of the matrix.
289
- *
290
- * \returns the positive-definite square root of the matrix
291
- *
292
- * \pre The eigenvalues and eigenvectors of a positive-definite matrix
293
- * have been computed before.
294
- *
295
- * The square root of a positive-definite matrix \f$ A \f$ is the
296
- * positive-definite matrix whose square equals \f$ A \f$. This function
297
- * uses the eigendecomposition \f$ A = V D V^{-1} \f$ to compute the
298
- * square root as \f$ A^{1/2} = V D^{1/2} V^{-1} \f$.
299
- *
300
- * Example: \include SelfAdjointEigenSolver_operatorSqrt.cpp
301
- * Output: \verbinclude SelfAdjointEigenSolver_operatorSqrt.out
302
- *
303
- * \sa operatorInverseSqrt(), <a href="unsupported/group__MatrixFunctions__Module.html">MatrixFunctions Module</a>
304
- */
305
- EIGEN_DEVICE_FUNC
306
- MatrixType operatorSqrt() const
307
- {
308
- eigen_assert(m_isInitialized && "SelfAdjointEigenSolver is not initialized.");
309
- eigen_assert(m_eigenvectorsOk && "The eigenvectors have not been computed together with the eigenvalues.");
310
- return m_eivec * m_eivalues.cwiseSqrt().asDiagonal() * m_eivec.adjoint();
311
- }
305
+ /** \brief Computes the positive-definite square root of the matrix.
306
+ *
307
+ * \returns the positive-definite square root of the matrix
308
+ *
309
+ * \pre The eigenvalues and eigenvectors of a positive-definite matrix
310
+ * have been computed before.
311
+ *
312
+ * The square root of a positive-definite matrix \f$ A \f$ is the
313
+ * positive-definite matrix whose square equals \f$ A \f$. This function
314
+ * uses the eigendecomposition \f$ A = V D V^{-1} \f$ to compute the
315
+ * square root as \f$ A^{1/2} = V D^{1/2} V^{-1} \f$.
316
+ *
317
+ * Example: \include SelfAdjointEigenSolver_operatorSqrt.cpp
318
+ * Output: \verbinclude SelfAdjointEigenSolver_operatorSqrt.out
319
+ *
320
+ * \sa operatorInverseSqrt(), <a href="unsupported/group__MatrixFunctions__Module.html">MatrixFunctions Module</a>
321
+ */
322
+ EIGEN_DEVICE_FUNC MatrixType operatorSqrt() const {
323
+ eigen_assert(m_isInitialized && "SelfAdjointEigenSolver is not initialized.");
324
+ eigen_assert(m_eigenvectorsOk && "The eigenvectors have not been computed together with the eigenvalues.");
325
+ return m_eivec * m_eivalues.cwiseSqrt().asDiagonal() * m_eivec.adjoint();
326
+ }
312
327
 
313
- /** \brief Computes the inverse square root of the matrix.
314
- *
315
- * \returns the inverse positive-definite square root of the matrix
316
- *
317
- * \pre The eigenvalues and eigenvectors of a positive-definite matrix
318
- * have been computed before.
319
- *
320
- * This function uses the eigendecomposition \f$ A = V D V^{-1} \f$ to
321
- * compute the inverse square root as \f$ V D^{-1/2} V^{-1} \f$. This is
322
- * cheaper than first computing the square root with operatorSqrt() and
323
- * then its inverse with MatrixBase::inverse().
324
- *
325
- * Example: \include SelfAdjointEigenSolver_operatorInverseSqrt.cpp
326
- * Output: \verbinclude SelfAdjointEigenSolver_operatorInverseSqrt.out
327
- *
328
- * \sa operatorSqrt(), MatrixBase::inverse(), <a href="unsupported/group__MatrixFunctions__Module.html">MatrixFunctions Module</a>
329
- */
330
- EIGEN_DEVICE_FUNC
331
- MatrixType operatorInverseSqrt() const
332
- {
333
- eigen_assert(m_isInitialized && "SelfAdjointEigenSolver is not initialized.");
334
- eigen_assert(m_eigenvectorsOk && "The eigenvectors have not been computed together with the eigenvalues.");
335
- return m_eivec * m_eivalues.cwiseInverse().cwiseSqrt().asDiagonal() * m_eivec.adjoint();
336
- }
328
+ /** \brief Computes the inverse square root of the matrix.
329
+ *
330
+ * \returns the inverse positive-definite square root of the matrix
331
+ *
332
+ * \pre The eigenvalues and eigenvectors of a positive-definite matrix
333
+ * have been computed before.
334
+ *
335
+ * This function uses the eigendecomposition \f$ A = V D V^{-1} \f$ to
336
+ * compute the inverse square root as \f$ V D^{-1/2} V^{-1} \f$. This is
337
+ * cheaper than first computing the square root with operatorSqrt() and
338
+ * then its inverse with MatrixBase::inverse().
339
+ *
340
+ * Example: \include SelfAdjointEigenSolver_operatorInverseSqrt.cpp
341
+ * Output: \verbinclude SelfAdjointEigenSolver_operatorInverseSqrt.out
342
+ *
343
+ * \sa operatorSqrt(), MatrixBase::inverse(), <a
344
+ * href="unsupported/group__MatrixFunctions__Module.html">MatrixFunctions Module</a>
345
+ */
346
+ EIGEN_DEVICE_FUNC MatrixType operatorInverseSqrt() const {
347
+ eigen_assert(m_isInitialized && "SelfAdjointEigenSolver is not initialized.");
348
+ eigen_assert(m_eigenvectorsOk && "The eigenvectors have not been computed together with the eigenvalues.");
349
+ return m_eivec * m_eivalues.cwiseInverse().cwiseSqrt().asDiagonal() * m_eivec.adjoint();
350
+ }
337
351
 
338
- /** \brief Reports whether previous computation was successful.
339
- *
340
- * \returns \c Success if computation was succesful, \c NoConvergence otherwise.
341
- */
342
- EIGEN_DEVICE_FUNC
343
- ComputationInfo info() const
344
- {
345
- eigen_assert(m_isInitialized && "SelfAdjointEigenSolver is not initialized.");
346
- return m_info;
347
- }
352
+ /** \brief Reports whether previous computation was successful.
353
+ *
354
+ * \returns \c Success if computation was successful, \c NoConvergence otherwise.
355
+ */
356
+ EIGEN_DEVICE_FUNC ComputationInfo info() const {
357
+ eigen_assert(m_isInitialized && "SelfAdjointEigenSolver is not initialized.");
358
+ return m_info;
359
+ }
348
360
 
349
- /** \brief Maximum number of iterations.
350
- *
351
- * The algorithm terminates if it does not converge within m_maxIterations * n iterations, where n
352
- * denotes the size of the matrix. This value is currently set to 30 (copied from LAPACK).
353
- */
354
- static const int m_maxIterations = 30;
355
-
356
- protected:
357
- static void check_template_parameters()
358
- {
359
- EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar);
360
- }
361
-
362
- EigenvectorsType m_eivec;
363
- RealVectorType m_eivalues;
364
- typename TridiagonalizationType::SubDiagonalType m_subdiag;
365
- ComputationInfo m_info;
366
- bool m_isInitialized;
367
- bool m_eigenvectorsOk;
361
+ /** \brief Maximum number of iterations.
362
+ *
363
+ * The algorithm terminates if it does not converge within m_maxIterations * n iterations, where n
364
+ * denotes the size of the matrix. This value is currently set to 30 (copied from LAPACK).
365
+ */
366
+ static const int m_maxIterations = 30;
367
+
368
+ protected:
369
+ EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar)
370
+
371
+ EigenvectorsType m_eivec;
372
+ VectorType m_workspace;
373
+ RealVectorType m_eivalues;
374
+ typename TridiagonalizationType::SubDiagonalType m_subdiag;
375
+ typename TridiagonalizationType::CoeffVectorType m_hcoeffs;
376
+ ComputationInfo m_info;
377
+ bool m_isInitialized;
378
+ bool m_eigenvectorsOk;
368
379
  };
369
380
 
370
381
  namespace internal {
371
382
  /** \internal
372
- *
373
- * \eigenvalues_module \ingroup Eigenvalues_Module
374
- *
375
- * Performs a QR step on a tridiagonal symmetric matrix represented as a
376
- * pair of two vectors \a diag and \a subdiag.
377
- *
378
- * \param diag the diagonal part of the input selfadjoint tridiagonal matrix
379
- * \param subdiag the sub-diagonal part of the input selfadjoint tridiagonal matrix
380
- * \param start starting index of the submatrix to work on
381
- * \param end last+1 index of the submatrix to work on
382
- * \param matrixQ pointer to the column-major matrix holding the eigenvectors, can be 0
383
- * \param n size of the input matrix
384
- *
385
- * For compilation efficiency reasons, this procedure does not use eigen expression
386
- * for its arguments.
387
- *
388
- * Implemented from Golub's "Matrix Computations", algorithm 8.3.2:
389
- * "implicit symmetric QR step with Wilkinson shift"
390
- */
391
- template<int StorageOrder,typename RealScalar, typename Scalar, typename Index>
392
- EIGEN_DEVICE_FUNC
393
- static void tridiagonal_qr_step(RealScalar* diag, RealScalar* subdiag, Index start, Index end, Scalar* matrixQ, Index n);
394
- }
395
-
396
- template<typename MatrixType>
397
- template<typename InputType>
398
- EIGEN_DEVICE_FUNC
399
- SelfAdjointEigenSolver<MatrixType>& SelfAdjointEigenSolver<MatrixType>
400
- ::compute(const EigenBase<InputType>& a_matrix, int options)
401
- {
402
- check_template_parameters();
403
-
404
- const InputType &matrix(a_matrix.derived());
405
-
406
- using std::abs;
383
+ *
384
+ * \eigenvalues_module \ingroup Eigenvalues_Module
385
+ *
386
+ * Performs a QR step on a tridiagonal symmetric matrix represented as a
387
+ * pair of two vectors \a diag and \a subdiag.
388
+ *
389
+ * \param diag the diagonal part of the input selfadjoint tridiagonal matrix
390
+ * \param subdiag the sub-diagonal part of the input selfadjoint tridiagonal matrix
391
+ * \param start starting index of the submatrix to work on
392
+ * \param end last+1 index of the submatrix to work on
393
+ * \param matrixQ pointer to the column-major matrix holding the eigenvectors, can be 0
394
+ * \param n size of the input matrix
395
+ *
396
+ * For compilation efficiency reasons, this procedure does not use eigen expression
397
+ * for its arguments.
398
+ *
399
+ * Implemented from Golub's "Matrix Computations", algorithm 8.3.2:
400
+ * "implicit symmetric QR step with Wilkinson shift"
401
+ */
402
+ template <int StorageOrder, typename RealScalar, typename Scalar, typename Index>
403
+ EIGEN_DEVICE_FUNC static void tridiagonal_qr_step(RealScalar* diag, RealScalar* subdiag, Index start, Index end,
404
+ Scalar* matrixQ, Index n);
405
+ } // namespace internal
406
+
407
+ template <typename MatrixType>
408
+ template <typename InputType>
409
+ EIGEN_DEVICE_FUNC SelfAdjointEigenSolver<MatrixType>& SelfAdjointEigenSolver<MatrixType>::compute(
410
+ const EigenBase<InputType>& a_matrix, int options) {
411
+ const InputType& matrix(a_matrix.derived());
412
+
413
+ EIGEN_USING_STD(abs);
407
414
  eigen_assert(matrix.cols() == matrix.rows());
408
- eigen_assert((options&~(EigVecMask|GenEigMask))==0
409
- && (options&EigVecMask)!=EigVecMask
410
- && "invalid option parameter");
411
- bool computeEigenvectors = (options&ComputeEigenvectors)==ComputeEigenvectors;
415
+ eigen_assert((options & ~(EigVecMask | GenEigMask)) == 0 && (options & EigVecMask) != EigVecMask &&
416
+ "invalid option parameter");
417
+ bool computeEigenvectors = (options & ComputeEigenvectors) == ComputeEigenvectors;
412
418
  Index n = matrix.cols();
413
- m_eivalues.resize(n,1);
419
+ m_eivalues.resize(n, 1);
414
420
 
415
- if(n==1)
416
- {
421
+ if (n == 1) {
417
422
  m_eivec = matrix;
418
- m_eivalues.coeffRef(0,0) = numext::real(m_eivec.coeff(0,0));
419
- if(computeEigenvectors)
420
- m_eivec.setOnes(n,n);
423
+ m_eivalues.coeffRef(0, 0) = numext::real(m_eivec.coeff(0, 0));
424
+ if (computeEigenvectors) m_eivec.setOnes(n, n);
421
425
  m_info = Success;
422
426
  m_isInitialized = true;
423
427
  m_eigenvectorsOk = computeEigenvectors;
@@ -431,13 +435,14 @@ SelfAdjointEigenSolver<MatrixType>& SelfAdjointEigenSolver<MatrixType>
431
435
  // map the matrix coefficients to [-1:1] to avoid over- and underflow.
432
436
  mat = matrix.template triangularView<Lower>();
433
437
  RealScalar scale = mat.cwiseAbs().maxCoeff();
434
- if(scale==RealScalar(0)) scale = RealScalar(1);
438
+ if (numext::is_exactly_zero(scale)) scale = RealScalar(1);
435
439
  mat.template triangularView<Lower>() /= scale;
436
- m_subdiag.resize(n-1);
437
- internal::tridiagonalization_inplace(mat, diag, m_subdiag, computeEigenvectors);
440
+ m_subdiag.resize(n - 1);
441
+ m_hcoeffs.resize(n - 1);
442
+ internal::tridiagonalization_inplace(mat, diag, m_subdiag, m_hcoeffs, m_workspace, computeEigenvectors);
438
443
 
439
444
  m_info = internal::computeFromTridiagonal_impl(diag, m_subdiag, m_maxIterations, computeEigenvectors, m_eivec);
440
-
445
+
441
446
  // scale back the eigen values
442
447
  m_eivalues *= scale;
443
448
 
@@ -446,17 +451,15 @@ SelfAdjointEigenSolver<MatrixType>& SelfAdjointEigenSolver<MatrixType>
446
451
  return *this;
447
452
  }
448
453
 
449
- template<typename MatrixType>
450
- SelfAdjointEigenSolver<MatrixType>& SelfAdjointEigenSolver<MatrixType>
451
- ::computeFromTridiagonal(const RealVectorType& diag, const SubDiagonalType& subdiag , int options)
452
- {
453
- //TODO : Add an option to scale the values beforehand
454
- bool computeEigenvectors = (options&ComputeEigenvectors)==ComputeEigenvectors;
454
+ template <typename MatrixType>
455
+ SelfAdjointEigenSolver<MatrixType>& SelfAdjointEigenSolver<MatrixType>::computeFromTridiagonal(
456
+ const RealVectorType& diag, const SubDiagonalType& subdiag, int options) {
457
+ // TODO : Add an option to scale the values beforehand
458
+ bool computeEigenvectors = (options & ComputeEigenvectors) == ComputeEigenvectors;
455
459
 
456
460
  m_eivalues = diag;
457
461
  m_subdiag = subdiag;
458
- if (computeEigenvectors)
459
- {
462
+ if (computeEigenvectors) {
460
463
  m_eivec.setIdentity(diag.size(), diag.size());
461
464
  }
462
465
  m_info = internal::computeFromTridiagonal_impl(m_eivalues, m_subdiag, m_maxIterations, computeEigenvectors, m_eivec);
@@ -468,56 +471,60 @@ SelfAdjointEigenSolver<MatrixType>& SelfAdjointEigenSolver<MatrixType>
468
471
 
469
472
  namespace internal {
470
473
  /**
471
- * \internal
472
- * \brief Compute the eigendecomposition from a tridiagonal matrix
473
- *
474
- * \param[in,out] diag : On input, the diagonal of the matrix, on output the eigenvalues
475
- * \param[in,out] subdiag : The subdiagonal part of the matrix (entries are modified during the decomposition)
476
- * \param[in] maxIterations : the maximum number of iterations
477
- * \param[in] computeEigenvectors : whether the eigenvectors have to be computed or not
478
- * \param[out] eivec : The matrix to store the eigenvectors if computeEigenvectors==true. Must be allocated on input.
479
- * \returns \c Success or \c NoConvergence
480
- */
481
- template<typename MatrixType, typename DiagType, typename SubDiagType>
482
- ComputationInfo computeFromTridiagonal_impl(DiagType& diag, SubDiagType& subdiag, const Index maxIterations, bool computeEigenvectors, MatrixType& eivec)
483
- {
484
- using std::abs;
485
-
474
+ * \internal
475
+ * \brief Compute the eigendecomposition from a tridiagonal matrix
476
+ *
477
+ * \param[in,out] diag : On input, the diagonal of the matrix, on output the eigenvalues
478
+ * \param[in,out] subdiag : The subdiagonal part of the matrix (entries are modified during the decomposition)
479
+ * \param[in] maxIterations : the maximum number of iterations
480
+ * \param[in] computeEigenvectors : whether the eigenvectors have to be computed or not
481
+ * \param[out] eivec : The matrix to store the eigenvectors if computeEigenvectors==true. Must be allocated on input.
482
+ * \returns \c Success or \c NoConvergence
483
+ */
484
+ template <typename MatrixType, typename DiagType, typename SubDiagType>
485
+ EIGEN_DEVICE_FUNC ComputationInfo computeFromTridiagonal_impl(DiagType& diag, SubDiagType& subdiag,
486
+ const Index maxIterations, bool computeEigenvectors,
487
+ MatrixType& eivec) {
486
488
  ComputationInfo info;
487
489
  typedef typename MatrixType::Scalar Scalar;
488
490
 
489
491
  Index n = diag.size();
490
- Index end = n-1;
492
+ Index end = n - 1;
491
493
  Index start = 0;
492
- Index iter = 0; // total number of iterations
493
-
494
+ Index iter = 0; // total number of iterations
495
+
494
496
  typedef typename DiagType::RealScalar RealScalar;
495
497
  const RealScalar considerAsZero = (std::numeric_limits<RealScalar>::min)();
496
- const RealScalar precision = RealScalar(2)*NumTraits<RealScalar>::epsilon();
497
-
498
- while (end>0)
499
- {
500
- for (Index i = start; i<end; ++i)
501
- if (internal::isMuchSmallerThan(abs(subdiag[i]),(abs(diag[i])+abs(diag[i+1])),precision) || abs(subdiag[i]) <= considerAsZero)
502
- subdiag[i] = 0;
503
-
504
- // find the largest unreduced block
505
- while (end>0 && subdiag[end-1]==RealScalar(0))
506
- {
498
+ const RealScalar precision_inv = RealScalar(1) / NumTraits<RealScalar>::epsilon();
499
+ while (end > 0) {
500
+ for (Index i = start; i < end; ++i) {
501
+ if (numext::abs(subdiag[i]) < considerAsZero) {
502
+ subdiag[i] = RealScalar(0);
503
+ } else {
504
+ // abs(subdiag[i]) <= epsilon * sqrt(abs(diag[i]) + abs(diag[i+1]))
505
+ // Scaled to prevent underflows.
506
+ const RealScalar scaled_subdiag = precision_inv * subdiag[i];
507
+ if (scaled_subdiag * scaled_subdiag <= (numext::abs(diag[i]) + numext::abs(diag[i + 1]))) {
508
+ subdiag[i] = RealScalar(0);
509
+ }
510
+ }
511
+ }
512
+
513
+ // find the largest unreduced block at the end of the matrix.
514
+ while (end > 0 && numext::is_exactly_zero(subdiag[end - 1])) {
507
515
  end--;
508
516
  }
509
- if (end<=0)
510
- break;
517
+ if (end <= 0) break;
511
518
 
512
519
  // if we spent too many iterations, we give up
513
520
  iter++;
514
- if(iter > maxIterations * n) break;
521
+ if (iter > maxIterations * n) break;
515
522
 
516
523
  start = end - 1;
517
- while (start>0 && subdiag[start-1]!=0)
518
- start--;
524
+ while (start > 0 && !numext::is_exactly_zero(subdiag[start - 1])) start--;
519
525
 
520
- internal::tridiagonal_qr_step<MatrixType::Flags&RowMajorBit ? RowMajor : ColMajor>(diag.data(), subdiag.data(), start, end, computeEigenvectors ? eivec.data() : (Scalar*)0, n);
526
+ internal::tridiagonal_qr_step<MatrixType::Flags & RowMajorBit ? RowMajor : ColMajor>(
527
+ diag.data(), subdiag.data(), start, end, computeEigenvectors ? eivec.data() : (Scalar*)0, n);
521
528
  }
522
529
  if (iter <= maxIterations * n)
523
530
  info = Success;
@@ -527,86 +534,80 @@ ComputationInfo computeFromTridiagonal_impl(DiagType& diag, SubDiagType& subdiag
527
534
  // Sort eigenvalues and corresponding vectors.
528
535
  // TODO make the sort optional ?
529
536
  // TODO use a better sort algorithm !!
530
- if (info == Success)
531
- {
532
- for (Index i = 0; i < n-1; ++i)
533
- {
537
+ if (info == Success) {
538
+ for (Index i = 0; i < n - 1; ++i) {
534
539
  Index k;
535
- diag.segment(i,n-i).minCoeff(&k);
536
- if (k > 0)
537
- {
538
- std::swap(diag[i], diag[k+i]);
539
- if(computeEigenvectors)
540
- eivec.col(i).swap(eivec.col(k+i));
540
+ diag.segment(i, n - i).minCoeff(&k);
541
+ if (k > 0) {
542
+ numext::swap(diag[i], diag[k + i]);
543
+ if (computeEigenvectors) eivec.col(i).swap(eivec.col(k + i));
541
544
  }
542
545
  }
543
546
  }
544
547
  return info;
545
548
  }
546
-
547
- template<typename SolverType,int Size,bool IsComplex> struct direct_selfadjoint_eigenvalues
548
- {
549
- EIGEN_DEVICE_FUNC
550
- static inline void run(SolverType& eig, const typename SolverType::MatrixType& A, int options)
551
- { eig.compute(A,options); }
549
+
550
+ template <typename SolverType, int Size, bool IsComplex>
551
+ struct direct_selfadjoint_eigenvalues {
552
+ EIGEN_DEVICE_FUNC static inline void run(SolverType& eig, const typename SolverType::MatrixType& A, int options) {
553
+ eig.compute(A, options);
554
+ }
552
555
  };
553
556
 
554
- template<typename SolverType> struct direct_selfadjoint_eigenvalues<SolverType,3,false>
555
- {
557
+ template <typename SolverType>
558
+ struct direct_selfadjoint_eigenvalues<SolverType, 3, false> {
556
559
  typedef typename SolverType::MatrixType MatrixType;
557
560
  typedef typename SolverType::RealVectorType VectorType;
558
561
  typedef typename SolverType::Scalar Scalar;
559
562
  typedef typename SolverType::EigenvectorsType EigenvectorsType;
560
-
561
563
 
562
564
  /** \internal
563
565
  * Computes the roots of the characteristic polynomial of \a m.
564
566
  * For numerical stability m.trace() should be near zero and to avoid over- or underflow m should be normalized.
565
567
  */
566
- EIGEN_DEVICE_FUNC
567
- static inline void computeRoots(const MatrixType& m, VectorType& roots)
568
- {
569
- EIGEN_USING_STD_MATH(sqrt)
570
- EIGEN_USING_STD_MATH(atan2)
571
- EIGEN_USING_STD_MATH(cos)
572
- EIGEN_USING_STD_MATH(sin)
573
- const Scalar s_inv3 = Scalar(1)/Scalar(3);
568
+ EIGEN_DEVICE_FUNC static inline void computeRoots(const MatrixType& m, VectorType& roots) {
569
+ EIGEN_USING_STD(sqrt)
570
+ EIGEN_USING_STD(atan2)
571
+ EIGEN_USING_STD(cos)
572
+ EIGEN_USING_STD(sin)
573
+ const Scalar s_inv3 = Scalar(1) / Scalar(3);
574
574
  const Scalar s_sqrt3 = sqrt(Scalar(3));
575
575
 
576
576
  // The characteristic equation is x^3 - c2*x^2 + c1*x - c0 = 0. The
577
577
  // eigenvalues are the roots to this equation, all guaranteed to be
578
578
  // real-valued, because the matrix is symmetric.
579
- Scalar c0 = m(0,0)*m(1,1)*m(2,2) + Scalar(2)*m(1,0)*m(2,0)*m(2,1) - m(0,0)*m(2,1)*m(2,1) - m(1,1)*m(2,0)*m(2,0) - m(2,2)*m(1,0)*m(1,0);
580
- Scalar c1 = m(0,0)*m(1,1) - m(1,0)*m(1,0) + m(0,0)*m(2,2) - m(2,0)*m(2,0) + m(1,1)*m(2,2) - m(2,1)*m(2,1);
581
- Scalar c2 = m(0,0) + m(1,1) + m(2,2);
579
+ Scalar c0 = m(0, 0) * m(1, 1) * m(2, 2) + Scalar(2) * m(1, 0) * m(2, 0) * m(2, 1) - m(0, 0) * m(2, 1) * m(2, 1) -
580
+ m(1, 1) * m(2, 0) * m(2, 0) - m(2, 2) * m(1, 0) * m(1, 0);
581
+ Scalar c1 = m(0, 0) * m(1, 1) - m(1, 0) * m(1, 0) + m(0, 0) * m(2, 2) - m(2, 0) * m(2, 0) + m(1, 1) * m(2, 2) -
582
+ m(2, 1) * m(2, 1);
583
+ Scalar c2 = m(0, 0) + m(1, 1) + m(2, 2);
582
584
 
583
585
  // Construct the parameters used in classifying the roots of the equation
584
586
  // and in solving the equation for the roots in closed form.
585
- Scalar c2_over_3 = c2*s_inv3;
586
- Scalar a_over_3 = (c2*c2_over_3 - c1)*s_inv3;
587
+ Scalar c2_over_3 = c2 * s_inv3;
588
+ Scalar a_over_3 = (c2 * c2_over_3 - c1) * s_inv3;
587
589
  a_over_3 = numext::maxi(a_over_3, Scalar(0));
588
590
 
589
- Scalar half_b = Scalar(0.5)*(c0 + c2_over_3*(Scalar(2)*c2_over_3*c2_over_3 - c1));
591
+ Scalar half_b = Scalar(0.5) * (c0 + c2_over_3 * (Scalar(2) * c2_over_3 * c2_over_3 - c1));
590
592
 
591
- Scalar q = a_over_3*a_over_3*a_over_3 - half_b*half_b;
593
+ Scalar q = a_over_3 * a_over_3 * a_over_3 - half_b * half_b;
592
594
  q = numext::maxi(q, Scalar(0));
593
595
 
594
596
  // Compute the eigenvalues by solving for the roots of the polynomial.
595
597
  Scalar rho = sqrt(a_over_3);
596
- Scalar theta = atan2(sqrt(q),half_b)*s_inv3; // since sqrt(q) > 0, atan2 is in [0, pi] and theta is in [0, pi/3]
598
+ Scalar theta = atan2(sqrt(q), half_b) * s_inv3; // since sqrt(q) > 0, atan2 is in [0, pi] and theta is in [0, pi/3]
597
599
  Scalar cos_theta = cos(theta);
598
600
  Scalar sin_theta = sin(theta);
599
601
  // roots are already sorted, since cos is monotonically decreasing on [0, pi]
600
- roots(0) = c2_over_3 - rho*(cos_theta + s_sqrt3*sin_theta); // == 2*rho*cos(theta+2pi/3)
601
- roots(1) = c2_over_3 - rho*(cos_theta - s_sqrt3*sin_theta); // == 2*rho*cos(theta+ pi/3)
602
- roots(2) = c2_over_3 + Scalar(2)*rho*cos_theta;
602
+ roots(0) = c2_over_3 - rho * (cos_theta + s_sqrt3 * sin_theta); // == 2*rho*cos(theta+2pi/3)
603
+ roots(1) = c2_over_3 - rho * (cos_theta - s_sqrt3 * sin_theta); // == 2*rho*cos(theta+ pi/3)
604
+ roots(2) = c2_over_3 + Scalar(2) * rho * cos_theta;
603
605
  }
604
606
 
605
- EIGEN_DEVICE_FUNC
606
- static inline bool extract_kernel(MatrixType& mat, Ref<VectorType> res, Ref<VectorType> representative)
607
- {
608
- EIGEN_USING_STD_MATH(sqrt)
609
- EIGEN_USING_STD_MATH(abs)
607
+ EIGEN_DEVICE_FUNC static inline bool extract_kernel(MatrixType& mat, Ref<VectorType> res,
608
+ Ref<VectorType> representative) {
609
+ EIGEN_USING_STD(abs);
610
+ EIGEN_USING_STD(sqrt);
610
611
  Index i0;
611
612
  // Find non-zero column i0 (by construction, there must exist a non zero coefficient on the diagonal):
612
613
  mat.diagonal().cwiseAbs().maxCoeff(&i0);
@@ -615,47 +616,43 @@ template<typename SolverType> struct direct_selfadjoint_eigenvalues<SolverType,3
615
616
  representative = mat.col(i0);
616
617
  Scalar n0, n1;
617
618
  VectorType c0, c1;
618
- n0 = (c0 = representative.cross(mat.col((i0+1)%3))).squaredNorm();
619
- n1 = (c1 = representative.cross(mat.col((i0+2)%3))).squaredNorm();
620
- if(n0>n1) res = c0/sqrt(n0);
621
- else res = c1/sqrt(n1);
619
+ n0 = (c0 = representative.cross(mat.col((i0 + 1) % 3))).squaredNorm();
620
+ n1 = (c1 = representative.cross(mat.col((i0 + 2) % 3))).squaredNorm();
621
+ if (n0 > n1)
622
+ res = c0 / sqrt(n0);
623
+ else
624
+ res = c1 / sqrt(n1);
622
625
 
623
626
  return true;
624
627
  }
625
628
 
626
- EIGEN_DEVICE_FUNC
627
- static inline void run(SolverType& solver, const MatrixType& mat, int options)
628
- {
629
+ EIGEN_DEVICE_FUNC static inline void run(SolverType& solver, const MatrixType& mat, int options) {
629
630
  eigen_assert(mat.cols() == 3 && mat.cols() == mat.rows());
630
- eigen_assert((options&~(EigVecMask|GenEigMask))==0
631
- && (options&EigVecMask)!=EigVecMask
632
- && "invalid option parameter");
633
- bool computeEigenvectors = (options&ComputeEigenvectors)==ComputeEigenvectors;
634
-
631
+ eigen_assert((options & ~(EigVecMask | GenEigMask)) == 0 && (options & EigVecMask) != EigVecMask &&
632
+ "invalid option parameter");
633
+ bool computeEigenvectors = (options & ComputeEigenvectors) == ComputeEigenvectors;
634
+
635
635
  EigenvectorsType& eivecs = solver.m_eivec;
636
636
  VectorType& eivals = solver.m_eivalues;
637
-
637
+
638
638
  // Shift the matrix to the mean eigenvalue and map the matrix coefficients to [-1:1] to avoid over- and underflow.
639
639
  Scalar shift = mat.trace() / Scalar(3);
640
- // TODO Avoid this copy. Currently it is necessary to suppress bogus values when determining maxCoeff and for computing the eigenvectors later
640
+ // TODO Avoid this copy. Currently it is necessary to suppress bogus values when determining maxCoeff and for
641
+ // computing the eigenvectors later
641
642
  MatrixType scaledMat = mat.template selfadjointView<Lower>();
642
643
  scaledMat.diagonal().array() -= shift;
643
644
  Scalar scale = scaledMat.cwiseAbs().maxCoeff();
644
- if(scale > 0) scaledMat /= scale; // TODO for scale==0 we could save the remaining operations
645
+ if (scale > 0) scaledMat /= scale; // TODO for scale==0 we could save the remaining operations
645
646
 
646
647
  // compute the eigenvalues
647
- computeRoots(scaledMat,eivals);
648
+ computeRoots(scaledMat, eivals);
648
649
 
649
650
  // compute the eigenvectors
650
- if(computeEigenvectors)
651
- {
652
- if((eivals(2)-eivals(0))<=Eigen::NumTraits<Scalar>::epsilon())
653
- {
651
+ if (computeEigenvectors) {
652
+ if ((eivals(2) - eivals(0)) <= Eigen::NumTraits<Scalar>::epsilon()) {
654
653
  // All three eigenvalues are numerically the same
655
654
  eivecs.setIdentity();
656
- }
657
- else
658
- {
655
+ } else {
659
656
  MatrixType tmp;
660
657
  tmp = scaledMat;
661
658
 
@@ -663,31 +660,27 @@ template<typename SolverType> struct direct_selfadjoint_eigenvalues<SolverType,3
663
660
  Scalar d0 = eivals(2) - eivals(1);
664
661
  Scalar d1 = eivals(1) - eivals(0);
665
662
  Index k(0), l(2);
666
- if(d0 > d1)
667
- {
668
- numext::swap(k,l);
663
+ if (d0 > d1) {
664
+ numext::swap(k, l);
669
665
  d0 = d1;
670
666
  }
671
667
 
672
668
  // Compute the eigenvector of index k
673
669
  {
674
- tmp.diagonal().array () -= eivals(k);
670
+ tmp.diagonal().array() -= eivals(k);
675
671
  // By construction, 'tmp' is of rank 2, and its kernel corresponds to the respective eigenvector.
676
672
  extract_kernel(tmp, eivecs.col(k), eivecs.col(l));
677
673
  }
678
674
 
679
675
  // Compute eigenvector of index l
680
- if(d0<=2*Eigen::NumTraits<Scalar>::epsilon()*d1)
681
- {
676
+ if (d0 <= 2 * Eigen::NumTraits<Scalar>::epsilon() * d1) {
682
677
  // If d0 is too small, then the two other eigenvalues are numerically the same,
683
678
  // and thus we only have to ortho-normalize the near orthogonal vector we saved above.
684
- eivecs.col(l) -= eivecs.col(k).dot(eivecs.col(l))*eivecs.col(l);
679
+ eivecs.col(l) -= eivecs.col(k).dot(eivecs.col(l)) * eivecs.col(l);
685
680
  eivecs.col(l).normalize();
686
- }
687
- else
688
- {
681
+ } else {
689
682
  tmp = scaledMat;
690
- tmp.diagonal().array () -= eivals(l);
683
+ tmp.diagonal().array() -= eivals(l);
691
684
 
692
685
  VectorType dummy;
693
686
  extract_kernel(tmp, eivecs.col(l), dummy);
@@ -701,7 +694,7 @@ template<typename SolverType> struct direct_selfadjoint_eigenvalues<SolverType,3
701
694
  // Rescale back to the original size.
702
695
  eivals *= scale;
703
696
  eivals.array() += shift;
704
-
697
+
705
698
  solver.m_info = Success;
706
699
  solver.m_isInitialized = true;
707
700
  solver.m_eigenvectorsOk = computeEigenvectors;
@@ -709,73 +702,59 @@ template<typename SolverType> struct direct_selfadjoint_eigenvalues<SolverType,3
709
702
  };
710
703
 
711
704
  // 2x2 direct eigenvalues decomposition, code from Hauke Heibel
712
- template<typename SolverType>
713
- struct direct_selfadjoint_eigenvalues<SolverType,2,false>
714
- {
705
+ template <typename SolverType>
706
+ struct direct_selfadjoint_eigenvalues<SolverType, 2, false> {
715
707
  typedef typename SolverType::MatrixType MatrixType;
716
708
  typedef typename SolverType::RealVectorType VectorType;
717
709
  typedef typename SolverType::Scalar Scalar;
718
710
  typedef typename SolverType::EigenvectorsType EigenvectorsType;
719
-
720
- EIGEN_DEVICE_FUNC
721
- static inline void computeRoots(const MatrixType& m, VectorType& roots)
722
- {
723
- using std::sqrt;
724
- const Scalar t0 = Scalar(0.5) * sqrt( numext::abs2(m(0,0)-m(1,1)) + Scalar(4)*numext::abs2(m(1,0)));
725
- const Scalar t1 = Scalar(0.5) * (m(0,0) + m(1,1));
711
+
712
+ EIGEN_DEVICE_FUNC static inline void computeRoots(const MatrixType& m, VectorType& roots) {
713
+ EIGEN_USING_STD(sqrt);
714
+ const Scalar t0 = Scalar(0.5) * sqrt(numext::abs2(m(0, 0) - m(1, 1)) + Scalar(4) * numext::abs2(m(1, 0)));
715
+ const Scalar t1 = Scalar(0.5) * (m(0, 0) + m(1, 1));
726
716
  roots(0) = t1 - t0;
727
717
  roots(1) = t1 + t0;
728
718
  }
729
-
730
- EIGEN_DEVICE_FUNC
731
- static inline void run(SolverType& solver, const MatrixType& mat, int options)
732
- {
733
- EIGEN_USING_STD_MATH(sqrt);
734
- EIGEN_USING_STD_MATH(abs);
735
-
719
+
720
+ EIGEN_DEVICE_FUNC static inline void run(SolverType& solver, const MatrixType& mat, int options) {
721
+ EIGEN_USING_STD(sqrt);
722
+ EIGEN_USING_STD(abs);
723
+
736
724
  eigen_assert(mat.cols() == 2 && mat.cols() == mat.rows());
737
- eigen_assert((options&~(EigVecMask|GenEigMask))==0
738
- && (options&EigVecMask)!=EigVecMask
739
- && "invalid option parameter");
740
- bool computeEigenvectors = (options&ComputeEigenvectors)==ComputeEigenvectors;
741
-
725
+ eigen_assert((options & ~(EigVecMask | GenEigMask)) == 0 && (options & EigVecMask) != EigVecMask &&
726
+ "invalid option parameter");
727
+ bool computeEigenvectors = (options & ComputeEigenvectors) == ComputeEigenvectors;
728
+
742
729
  EigenvectorsType& eivecs = solver.m_eivec;
743
730
  VectorType& eivals = solver.m_eivalues;
744
-
731
+
745
732
  // Shift the matrix to the mean eigenvalue and map the matrix coefficients to [-1:1] to avoid over- and underflow.
746
733
  Scalar shift = mat.trace() / Scalar(2);
747
734
  MatrixType scaledMat = mat;
748
- scaledMat.coeffRef(0,1) = mat.coeff(1,0);
735
+ scaledMat.coeffRef(0, 1) = mat.coeff(1, 0);
749
736
  scaledMat.diagonal().array() -= shift;
750
737
  Scalar scale = scaledMat.cwiseAbs().maxCoeff();
751
- if(scale > Scalar(0))
752
- scaledMat /= scale;
738
+ if (scale > Scalar(0)) scaledMat /= scale;
753
739
 
754
740
  // Compute the eigenvalues
755
- computeRoots(scaledMat,eivals);
741
+ computeRoots(scaledMat, eivals);
756
742
 
757
743
  // compute the eigen vectors
758
- if(computeEigenvectors)
759
- {
760
- if((eivals(1)-eivals(0))<=abs(eivals(1))*Eigen::NumTraits<Scalar>::epsilon())
761
- {
744
+ if (computeEigenvectors) {
745
+ if ((eivals(1) - eivals(0)) <= abs(eivals(1)) * Eigen::NumTraits<Scalar>::epsilon()) {
762
746
  eivecs.setIdentity();
763
- }
764
- else
765
- {
766
- scaledMat.diagonal().array () -= eivals(1);
767
- Scalar a2 = numext::abs2(scaledMat(0,0));
768
- Scalar c2 = numext::abs2(scaledMat(1,1));
769
- Scalar b2 = numext::abs2(scaledMat(1,0));
770
- if(a2>c2)
771
- {
772
- eivecs.col(1) << -scaledMat(1,0), scaledMat(0,0);
773
- eivecs.col(1) /= sqrt(a2+b2);
774
- }
775
- else
776
- {
777
- eivecs.col(1) << -scaledMat(1,1), scaledMat(1,0);
778
- eivecs.col(1) /= sqrt(c2+b2);
747
+ } else {
748
+ scaledMat.diagonal().array() -= eivals(1);
749
+ Scalar a2 = numext::abs2(scaledMat(0, 0));
750
+ Scalar c2 = numext::abs2(scaledMat(1, 1));
751
+ Scalar b2 = numext::abs2(scaledMat(1, 0));
752
+ if (a2 > c2) {
753
+ eivecs.col(1) << -scaledMat(1, 0), scaledMat(0, 0);
754
+ eivecs.col(1) /= sqrt(a2 + b2);
755
+ } else {
756
+ eivecs.col(1) << -scaledMat(1, 1), scaledMat(1, 0);
757
+ eivecs.col(1) /= sqrt(c2 + b2);
779
758
  }
780
759
 
781
760
  eivecs.col(0) << eivecs.col(1).unitOrthogonal();
@@ -792,80 +771,80 @@ struct direct_selfadjoint_eigenvalues<SolverType,2,false>
792
771
  }
793
772
  };
794
773
 
795
- }
774
+ } // namespace internal
796
775
 
797
- template<typename MatrixType>
798
- EIGEN_DEVICE_FUNC
799
- SelfAdjointEigenSolver<MatrixType>& SelfAdjointEigenSolver<MatrixType>
800
- ::computeDirect(const MatrixType& matrix, int options)
801
- {
802
- internal::direct_selfadjoint_eigenvalues<SelfAdjointEigenSolver,Size,NumTraits<Scalar>::IsComplex>::run(*this,matrix,options);
776
+ template <typename MatrixType>
777
+ EIGEN_DEVICE_FUNC SelfAdjointEigenSolver<MatrixType>& SelfAdjointEigenSolver<MatrixType>::computeDirect(
778
+ const MatrixType& matrix, int options) {
779
+ internal::direct_selfadjoint_eigenvalues<SelfAdjointEigenSolver, Size, NumTraits<Scalar>::IsComplex>::run(
780
+ *this, matrix, options);
803
781
  return *this;
804
782
  }
805
783
 
806
784
  namespace internal {
807
- template<int StorageOrder,typename RealScalar, typename Scalar, typename Index>
808
- EIGEN_DEVICE_FUNC
809
- static void tridiagonal_qr_step(RealScalar* diag, RealScalar* subdiag, Index start, Index end, Scalar* matrixQ, Index n)
810
- {
811
- using std::abs;
812
- RealScalar td = (diag[end-1] - diag[end])*RealScalar(0.5);
813
- RealScalar e = subdiag[end-1];
785
+
786
+ // Francis implicit QR step.
787
+ template <int StorageOrder, typename RealScalar, typename Scalar, typename Index>
788
+ EIGEN_DEVICE_FUNC static void tridiagonal_qr_step(RealScalar* diag, RealScalar* subdiag, Index start, Index end,
789
+ Scalar* matrixQ, Index n) {
790
+ // Wilkinson Shift.
791
+ RealScalar td = (diag[end - 1] - diag[end]) * RealScalar(0.5);
792
+ RealScalar e = subdiag[end - 1];
814
793
  // Note that thanks to scaling, e^2 or td^2 cannot overflow, however they can still
815
794
  // underflow thus leading to inf/NaN values when using the following commented code:
816
- // RealScalar e2 = numext::abs2(subdiag[end-1]);
817
- // RealScalar mu = diag[end] - e2 / (td + (td>0 ? 1 : -1) * sqrt(td*td + e2));
795
+ // RealScalar e2 = numext::abs2(subdiag[end-1]);
796
+ // RealScalar mu = diag[end] - e2 / (td + (td>0 ? 1 : -1) * sqrt(td*td + e2));
818
797
  // This explain the following, somewhat more complicated, version:
819
798
  RealScalar mu = diag[end];
820
- if(td==RealScalar(0))
821
- mu -= abs(e);
822
- else
823
- {
824
- RealScalar e2 = numext::abs2(subdiag[end-1]);
825
- RealScalar h = numext::hypot(td,e);
826
- if(e2==RealScalar(0)) mu -= (e / (td + (td>RealScalar(0) ? RealScalar(1) : RealScalar(-1)))) * (e / h);
827
- else mu -= e2 / (td + (td>RealScalar(0) ? h : -h));
799
+ if (numext::is_exactly_zero(td)) {
800
+ mu -= numext::abs(e);
801
+ } else if (!numext::is_exactly_zero(e)) {
802
+ const RealScalar e2 = numext::abs2(e);
803
+ const RealScalar h = numext::hypot(td, e);
804
+ if (numext::is_exactly_zero(e2)) {
805
+ mu -= e / ((td + (td > RealScalar(0) ? h : -h)) / e);
806
+ } else {
807
+ mu -= e2 / (td + (td > RealScalar(0) ? h : -h));
808
+ }
828
809
  }
829
-
810
+
830
811
  RealScalar x = diag[start] - mu;
831
812
  RealScalar z = subdiag[start];
832
- for (Index k = start; k < end; ++k)
833
- {
813
+ // If z ever becomes zero, the Givens rotation will be the identity and
814
+ // z will stay zero for all future iterations.
815
+ for (Index k = start; k < end && !numext::is_exactly_zero(z); ++k) {
834
816
  JacobiRotation<RealScalar> rot;
835
817
  rot.makeGivens(x, z);
836
818
 
837
819
  // do T = G' T G
838
820
  RealScalar sdk = rot.s() * diag[k] + rot.c() * subdiag[k];
839
- RealScalar dkp1 = rot.s() * subdiag[k] + rot.c() * diag[k+1];
821
+ RealScalar dkp1 = rot.s() * subdiag[k] + rot.c() * diag[k + 1];
840
822
 
841
- diag[k] = rot.c() * (rot.c() * diag[k] - rot.s() * subdiag[k]) - rot.s() * (rot.c() * subdiag[k] - rot.s() * diag[k+1]);
842
- diag[k+1] = rot.s() * sdk + rot.c() * dkp1;
823
+ diag[k] =
824
+ rot.c() * (rot.c() * diag[k] - rot.s() * subdiag[k]) - rot.s() * (rot.c() * subdiag[k] - rot.s() * diag[k + 1]);
825
+ diag[k + 1] = rot.s() * sdk + rot.c() * dkp1;
843
826
  subdiag[k] = rot.c() * sdk - rot.s() * dkp1;
844
-
845
827
 
846
- if (k > start)
847
- subdiag[k - 1] = rot.c() * subdiag[k-1] - rot.s() * z;
828
+ if (k > start) subdiag[k - 1] = rot.c() * subdiag[k - 1] - rot.s() * z;
848
829
 
830
+ // "Chasing the bulge" to return to triangular form.
849
831
  x = subdiag[k];
850
-
851
- if (k < end - 1)
852
- {
853
- z = -rot.s() * subdiag[k+1];
854
- subdiag[k + 1] = rot.c() * subdiag[k+1];
832
+ if (k < end - 1) {
833
+ z = -rot.s() * subdiag[k + 1];
834
+ subdiag[k + 1] = rot.c() * subdiag[k + 1];
855
835
  }
856
-
836
+
857
837
  // apply the givens rotation to the unit matrix Q = Q * G
858
- if (matrixQ)
859
- {
838
+ if (matrixQ) {
860
839
  // FIXME if StorageOrder == RowMajor this operation is not very efficient
861
- Map<Matrix<Scalar,Dynamic,Dynamic,StorageOrder> > q(matrixQ,n,n);
862
- q.applyOnTheRight(k,k+1,rot);
840
+ Map<Matrix<Scalar, Dynamic, Dynamic, StorageOrder> > q(matrixQ, n, n);
841
+ q.applyOnTheRight(k, k + 1, rot);
863
842
  }
864
843
  }
865
844
  }
866
845
 
867
- } // end namespace internal
846
+ } // end namespace internal
868
847
 
869
- } // end namespace Eigen
848
+ } // end namespace Eigen
870
849
 
871
- #endif // EIGEN_SELFADJOINTEIGENSOLVER_H
850
+ #endif // EIGEN_SELFADJOINTEIGENSOLVER_H