@smake/eigen 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (431) hide show
  1. package/README.md +1 -1
  2. package/eigen/Eigen/AccelerateSupport +52 -0
  3. package/eigen/Eigen/Cholesky +18 -20
  4. package/eigen/Eigen/CholmodSupport +28 -28
  5. package/eigen/Eigen/Core +187 -120
  6. package/eigen/Eigen/Eigenvalues +16 -13
  7. package/eigen/Eigen/Geometry +18 -18
  8. package/eigen/Eigen/Householder +9 -7
  9. package/eigen/Eigen/IterativeLinearSolvers +8 -4
  10. package/eigen/Eigen/Jacobi +14 -13
  11. package/eigen/Eigen/KLUSupport +23 -21
  12. package/eigen/Eigen/LU +15 -16
  13. package/eigen/Eigen/MetisSupport +12 -12
  14. package/eigen/Eigen/OrderingMethods +54 -51
  15. package/eigen/Eigen/PaStiXSupport +23 -21
  16. package/eigen/Eigen/PardisoSupport +17 -14
  17. package/eigen/Eigen/QR +18 -20
  18. package/eigen/Eigen/QtAlignedMalloc +5 -12
  19. package/eigen/Eigen/SPQRSupport +21 -14
  20. package/eigen/Eigen/SVD +23 -17
  21. package/eigen/Eigen/Sparse +1 -2
  22. package/eigen/Eigen/SparseCholesky +18 -15
  23. package/eigen/Eigen/SparseCore +18 -17
  24. package/eigen/Eigen/SparseLU +9 -9
  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 +366 -405
  37. package/eigen/Eigen/src/Cholesky/LLT.h +323 -367
  38. package/eigen/Eigen/src/Cholesky/LLT_LAPACKE.h +81 -56
  39. package/eigen/Eigen/src/CholmodSupport/CholmodSupport.h +585 -529
  40. package/eigen/Eigen/src/CholmodSupport/InternalHeaderCheck.h +3 -0
  41. package/eigen/Eigen/src/Core/ArithmeticSequence.h +143 -317
  42. package/eigen/Eigen/src/Core/Array.h +329 -370
  43. package/eigen/Eigen/src/Core/ArrayBase.h +190 -203
  44. package/eigen/Eigen/src/Core/ArrayWrapper.h +126 -170
  45. package/eigen/Eigen/src/Core/Assign.h +30 -40
  46. package/eigen/Eigen/src/Core/AssignEvaluator.h +651 -604
  47. package/eigen/Eigen/src/Core/Assign_MKL.h +125 -120
  48. package/eigen/Eigen/src/Core/BandMatrix.h +267 -282
  49. package/eigen/Eigen/src/Core/Block.h +371 -390
  50. package/eigen/Eigen/src/Core/CommaInitializer.h +85 -100
  51. package/eigen/Eigen/src/Core/ConditionEstimator.h +51 -53
  52. package/eigen/Eigen/src/Core/CoreEvaluators.h +1214 -937
  53. package/eigen/Eigen/src/Core/CoreIterators.h +72 -63
  54. package/eigen/Eigen/src/Core/CwiseBinaryOp.h +112 -129
  55. package/eigen/Eigen/src/Core/CwiseNullaryOp.h +676 -702
  56. package/eigen/Eigen/src/Core/CwiseTernaryOp.h +77 -103
  57. package/eigen/Eigen/src/Core/CwiseUnaryOp.h +55 -67
  58. package/eigen/Eigen/src/Core/CwiseUnaryView.h +127 -92
  59. package/eigen/Eigen/src/Core/DenseBase.h +630 -658
  60. package/eigen/Eigen/src/Core/DenseCoeffsBase.h +511 -628
  61. package/eigen/Eigen/src/Core/DenseStorage.h +511 -590
  62. package/eigen/Eigen/src/Core/DeviceWrapper.h +153 -0
  63. package/eigen/Eigen/src/Core/Diagonal.h +168 -207
  64. package/eigen/Eigen/src/Core/DiagonalMatrix.h +346 -317
  65. package/eigen/Eigen/src/Core/DiagonalProduct.h +12 -10
  66. package/eigen/Eigen/src/Core/Dot.h +167 -217
  67. package/eigen/Eigen/src/Core/EigenBase.h +74 -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 -113
  71. package/eigen/Eigen/src/Core/Fuzzy.h +82 -105
  72. package/eigen/Eigen/src/Core/GeneralProduct.h +315 -261
  73. package/eigen/Eigen/src/Core/GenericPacketMath.h +1182 -520
  74. package/eigen/Eigen/src/Core/GlobalFunctions.h +193 -157
  75. package/eigen/Eigen/src/Core/IO.h +131 -156
  76. package/eigen/Eigen/src/Core/IndexedView.h +209 -125
  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 +50 -59
  80. package/eigen/Eigen/src/Core/Map.h +123 -141
  81. package/eigen/Eigen/src/Core/MapBase.h +255 -282
  82. package/eigen/Eigen/src/Core/MathFunctions.h +1247 -1201
  83. package/eigen/Eigen/src/Core/MathFunctionsImpl.h +162 -99
  84. package/eigen/Eigen/src/Core/Matrix.h +463 -494
  85. package/eigen/Eigen/src/Core/MatrixBase.h +468 -470
  86. package/eigen/Eigen/src/Core/NestByValue.h +58 -52
  87. package/eigen/Eigen/src/Core/NoAlias.h +79 -86
  88. package/eigen/Eigen/src/Core/NumTraits.h +206 -206
  89. package/eigen/Eigen/src/Core/PartialReduxEvaluator.h +163 -142
  90. package/eigen/Eigen/src/Core/PermutationMatrix.h +461 -511
  91. package/eigen/Eigen/src/Core/PlainObjectBase.h +858 -972
  92. package/eigen/Eigen/src/Core/Product.h +246 -130
  93. package/eigen/Eigen/src/Core/ProductEvaluators.h +779 -671
  94. package/eigen/Eigen/src/Core/Random.h +153 -164
  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 +334 -314
  98. package/eigen/Eigen/src/Core/Ref.h +259 -257
  99. package/eigen/Eigen/src/Core/Replicate.h +92 -104
  100. package/eigen/Eigen/src/Core/Reshaped.h +215 -271
  101. package/eigen/Eigen/src/Core/ReturnByValue.h +47 -55
  102. package/eigen/Eigen/src/Core/Reverse.h +133 -148
  103. package/eigen/Eigen/src/Core/Select.h +68 -140
  104. package/eigen/Eigen/src/Core/SelfAdjointView.h +254 -290
  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 +88 -102
  108. package/eigen/Eigen/src/Core/SolveTriangular.h +126 -124
  109. package/eigen/Eigen/src/Core/SolverBase.h +132 -133
  110. package/eigen/Eigen/src/Core/StableNorm.h +113 -147
  111. package/eigen/Eigen/src/Core/StlIterators.h +404 -248
  112. package/eigen/Eigen/src/Core/Stride.h +90 -92
  113. package/eigen/Eigen/src/Core/Swap.h +70 -39
  114. package/eigen/Eigen/src/Core/Transpose.h +258 -295
  115. package/eigen/Eigen/src/Core/Transpositions.h +270 -333
  116. package/eigen/Eigen/src/Core/TriangularMatrix.h +642 -743
  117. package/eigen/Eigen/src/Core/VectorBlock.h +59 -72
  118. package/eigen/Eigen/src/Core/VectorwiseOp.h +653 -704
  119. package/eigen/Eigen/src/Core/Visitor.h +464 -308
  120. package/eigen/Eigen/src/Core/arch/AVX/Complex.h +380 -187
  121. package/eigen/Eigen/src/Core/arch/AVX/MathFunctions.h +65 -163
  122. package/eigen/Eigen/src/Core/arch/AVX/PacketMath.h +2145 -638
  123. package/eigen/Eigen/src/Core/arch/AVX/Reductions.h +353 -0
  124. package/eigen/Eigen/src/Core/arch/AVX/TypeCasting.h +253 -60
  125. package/eigen/Eigen/src/Core/arch/AVX512/Complex.h +278 -228
  126. package/eigen/Eigen/src/Core/arch/AVX512/GemmKernel.h +1245 -0
  127. package/eigen/Eigen/src/Core/arch/AVX512/MathFunctions.h +48 -269
  128. package/eigen/Eigen/src/Core/arch/AVX512/MathFunctionsFP16.h +75 -0
  129. package/eigen/Eigen/src/Core/arch/AVX512/PacketMath.h +1597 -754
  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 +229 -41
  135. package/eigen/Eigen/src/Core/arch/AVX512/TypeCastingFP16.h +130 -0
  136. package/eigen/Eigen/src/Core/arch/AltiVec/Complex.h +420 -184
  137. package/eigen/Eigen/src/Core/arch/AltiVec/MathFunctions.h +40 -49
  138. package/eigen/Eigen/src/Core/arch/AltiVec/MatrixProduct.h +2962 -2213
  139. package/eigen/Eigen/src/Core/arch/AltiVec/MatrixProductCommon.h +196 -212
  140. package/eigen/Eigen/src/Core/arch/AltiVec/MatrixProductMMA.h +713 -441
  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 +2380 -1362
  144. package/eigen/Eigen/src/Core/arch/AltiVec/TypeCasting.h +153 -0
  145. package/eigen/Eigen/src/Core/arch/Default/BFloat16.h +390 -224
  146. package/eigen/Eigen/src/Core/arch/Default/ConjHelper.h +78 -67
  147. package/eigen/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h +1784 -799
  148. package/eigen/Eigen/src/Core/arch/Default/GenericPacketMathFunctionsFwd.h +167 -50
  149. package/eigen/Eigen/src/Core/arch/Default/Half.h +528 -379
  150. package/eigen/Eigen/src/Core/arch/Default/Settings.h +10 -12
  151. package/eigen/Eigen/src/Core/arch/GPU/Complex.h +244 -0
  152. package/eigen/Eigen/src/Core/arch/GPU/MathFunctions.h +41 -40
  153. package/eigen/Eigen/src/Core/arch/GPU/PacketMath.h +550 -523
  154. package/eigen/Eigen/src/Core/arch/GPU/Tuple.h +268 -0
  155. package/eigen/Eigen/src/Core/arch/GPU/TypeCasting.h +27 -30
  156. package/eigen/Eigen/src/Core/arch/HIP/hcc/math_constants.h +8 -8
  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 +54 -82
  164. package/eigen/Eigen/src/Core/arch/MSA/MathFunctions.h +84 -92
  165. package/eigen/Eigen/src/Core/arch/MSA/PacketMath.h +51 -47
  166. package/eigen/Eigen/src/Core/arch/NEON/Complex.h +454 -306
  167. package/eigen/Eigen/src/Core/arch/NEON/GeneralBlockPanelKernel.h +175 -115
  168. package/eigen/Eigen/src/Core/arch/NEON/MathFunctions.h +23 -30
  169. package/eigen/Eigen/src/Core/arch/NEON/PacketMath.h +4366 -2857
  170. package/eigen/Eigen/src/Core/arch/NEON/TypeCasting.h +616 -393
  171. package/eigen/Eigen/src/Core/arch/NEON/UnaryFunctors.h +57 -0
  172. package/eigen/Eigen/src/Core/arch/SSE/Complex.h +350 -198
  173. package/eigen/Eigen/src/Core/arch/SSE/MathFunctions.h +38 -149
  174. package/eigen/Eigen/src/Core/arch/SSE/PacketMath.h +1791 -912
  175. package/eigen/Eigen/src/Core/arch/SSE/Reductions.h +324 -0
  176. package/eigen/Eigen/src/Core/arch/SSE/TypeCasting.h +128 -40
  177. package/eigen/Eigen/src/Core/arch/SVE/MathFunctions.h +10 -6
  178. package/eigen/Eigen/src/Core/arch/SVE/PacketMath.h +156 -234
  179. package/eigen/Eigen/src/Core/arch/SVE/TypeCasting.h +6 -3
  180. package/eigen/Eigen/src/Core/arch/SYCL/InteropHeaders.h +27 -32
  181. package/eigen/Eigen/src/Core/arch/SYCL/MathFunctions.h +119 -117
  182. package/eigen/Eigen/src/Core/arch/SYCL/PacketMath.h +325 -419
  183. package/eigen/Eigen/src/Core/arch/SYCL/TypeCasting.h +15 -17
  184. package/eigen/Eigen/src/Core/arch/ZVector/Complex.h +325 -181
  185. package/eigen/Eigen/src/Core/arch/ZVector/MathFunctions.h +94 -83
  186. package/eigen/Eigen/src/Core/arch/ZVector/PacketMath.h +811 -458
  187. package/eigen/Eigen/src/Core/functors/AssignmentFunctors.h +121 -124
  188. package/eigen/Eigen/src/Core/functors/BinaryFunctors.h +576 -370
  189. package/eigen/Eigen/src/Core/functors/NullaryFunctors.h +194 -109
  190. package/eigen/Eigen/src/Core/functors/StlFunctors.h +95 -112
  191. package/eigen/Eigen/src/Core/functors/TernaryFunctors.h +34 -7
  192. package/eigen/Eigen/src/Core/functors/UnaryFunctors.h +1038 -749
  193. package/eigen/Eigen/src/Core/products/GeneralBlockPanelKernel.h +1883 -1375
  194. package/eigen/Eigen/src/Core/products/GeneralMatrixMatrix.h +312 -370
  195. package/eigen/Eigen/src/Core/products/GeneralMatrixMatrixTriangular.h +189 -176
  196. package/eigen/Eigen/src/Core/products/GeneralMatrixMatrixTriangular_BLAS.h +84 -81
  197. package/eigen/Eigen/src/Core/products/GeneralMatrixMatrix_BLAS.h +154 -73
  198. package/eigen/Eigen/src/Core/products/GeneralMatrixVector.h +292 -337
  199. package/eigen/Eigen/src/Core/products/GeneralMatrixVector_BLAS.h +80 -77
  200. package/eigen/Eigen/src/Core/products/Parallelizer.h +207 -105
  201. package/eigen/Eigen/src/Core/products/SelfadjointMatrixMatrix.h +327 -388
  202. package/eigen/Eigen/src/Core/products/SelfadjointMatrixMatrix_BLAS.h +206 -224
  203. package/eigen/Eigen/src/Core/products/SelfadjointMatrixVector.h +138 -147
  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 -47
  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 -277
  212. package/eigen/Eigen/src/Core/products/TriangularSolverMatrix_BLAS.h +108 -109
  213. package/eigen/Eigen/src/Core/products/TriangularSolverVector.h +68 -94
  214. package/eigen/Eigen/src/Core/util/Assert.h +158 -0
  215. package/eigen/Eigen/src/Core/util/BlasUtil.h +342 -303
  216. package/eigen/Eigen/src/Core/util/ConfigureVectorization.h +348 -317
  217. package/eigen/Eigen/src/Core/util/Constants.h +297 -262
  218. package/eigen/Eigen/src/Core/util/DisableStupidWarnings.h +130 -90
  219. package/eigen/Eigen/src/Core/util/EmulateArray.h +270 -0
  220. package/eigen/Eigen/src/Core/util/ForwardDeclarations.h +449 -247
  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 +417 -116
  224. package/eigen/Eigen/src/Core/util/IntegralConstant.h +211 -204
  225. package/eigen/Eigen/src/Core/util/MKL_support.h +39 -37
  226. package/eigen/Eigen/src/Core/util/Macros.h +655 -773
  227. package/eigen/Eigen/src/Core/util/MaxSizeVector.h +139 -0
  228. package/eigen/Eigen/src/Core/util/Memory.h +970 -748
  229. package/eigen/Eigen/src/Core/util/Meta.h +581 -633
  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 +17 -17
  233. package/eigen/Eigen/src/Core/util/Serializer.h +209 -0
  234. package/eigen/Eigen/src/Core/util/StaticAssert.h +50 -166
  235. package/eigen/Eigen/src/Core/util/SymbolicIndex.h +377 -225
  236. package/eigen/Eigen/src/Core/util/XprHelper.h +784 -547
  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 +89 -105
  246. package/eigen/Eigen/src/Eigenvalues/RealQZ.h +537 -607
  247. package/eigen/Eigen/src/Eigenvalues/RealSchur.h +342 -381
  248. package/eigen/Eigen/src/Eigenvalues/RealSchur_LAPACKE.h +41 -35
  249. package/eigen/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h +541 -595
  250. package/eigen/Eigen/src/Eigenvalues/SelfAdjointEigenSolver_LAPACKE.h +47 -44
  251. package/eigen/Eigen/src/Eigenvalues/Tridiagonalization.h +430 -462
  252. package/eigen/Eigen/src/Geometry/AlignedBox.h +226 -227
  253. package/eigen/Eigen/src/Geometry/AngleAxis.h +131 -133
  254. package/eigen/Eigen/src/Geometry/EulerAngles.h +163 -74
  255. package/eigen/Eigen/src/Geometry/Homogeneous.h +285 -333
  256. package/eigen/Eigen/src/Geometry/Hyperplane.h +151 -160
  257. package/eigen/Eigen/src/Geometry/InternalHeaderCheck.h +3 -0
  258. package/eigen/Eigen/src/Geometry/OrthoMethods.h +168 -146
  259. package/eigen/Eigen/src/Geometry/ParametrizedLine.h +127 -127
  260. package/eigen/Eigen/src/Geometry/Quaternion.h +566 -506
  261. package/eigen/Eigen/src/Geometry/Rotation2D.h +107 -105
  262. package/eigen/Eigen/src/Geometry/RotationBase.h +148 -145
  263. package/eigen/Eigen/src/Geometry/Scaling.h +113 -106
  264. package/eigen/Eigen/src/Geometry/Transform.h +858 -936
  265. package/eigen/Eigen/src/Geometry/Translation.h +94 -92
  266. package/eigen/Eigen/src/Geometry/Umeyama.h +79 -84
  267. package/eigen/Eigen/src/Geometry/arch/Geometry_SIMD.h +90 -104
  268. package/eigen/Eigen/src/Householder/BlockHouseholder.h +51 -46
  269. package/eigen/Eigen/src/Householder/Householder.h +102 -124
  270. package/eigen/Eigen/src/Householder/HouseholderSequence.h +412 -453
  271. package/eigen/Eigen/src/Householder/InternalHeaderCheck.h +3 -0
  272. package/eigen/Eigen/src/IterativeLinearSolvers/BasicPreconditioners.h +149 -162
  273. package/eigen/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h +124 -119
  274. package/eigen/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h +92 -104
  275. package/eigen/Eigen/src/IterativeLinearSolvers/IncompleteCholesky.h +251 -243
  276. package/eigen/Eigen/src/IterativeLinearSolvers/IncompleteLUT.h +224 -228
  277. package/eigen/Eigen/src/IterativeLinearSolvers/InternalHeaderCheck.h +3 -0
  278. package/eigen/Eigen/src/IterativeLinearSolvers/IterativeSolverBase.h +178 -227
  279. package/eigen/Eigen/src/IterativeLinearSolvers/LeastSquareConjugateGradient.h +79 -84
  280. package/eigen/Eigen/src/IterativeLinearSolvers/SolveWithGuess.h +54 -60
  281. package/eigen/Eigen/src/Jacobi/InternalHeaderCheck.h +3 -0
  282. package/eigen/Eigen/src/Jacobi/Jacobi.h +252 -308
  283. package/eigen/Eigen/src/KLUSupport/InternalHeaderCheck.h +3 -0
  284. package/eigen/Eigen/src/KLUSupport/KLUSupport.h +208 -227
  285. package/eigen/Eigen/src/LU/Determinant.h +50 -69
  286. package/eigen/Eigen/src/LU/FullPivLU.h +545 -596
  287. package/eigen/Eigen/src/LU/InternalHeaderCheck.h +3 -0
  288. package/eigen/Eigen/src/LU/InverseImpl.h +206 -285
  289. package/eigen/Eigen/src/LU/PartialPivLU.h +390 -428
  290. package/eigen/Eigen/src/LU/PartialPivLU_LAPACKE.h +54 -40
  291. package/eigen/Eigen/src/LU/arch/InverseSize4.h +72 -70
  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 +243 -265
  295. package/eigen/Eigen/src/OrderingMethods/Eigen_Colamd.h +831 -1004
  296. package/eigen/Eigen/src/OrderingMethods/InternalHeaderCheck.h +3 -0
  297. package/eigen/Eigen/src/OrderingMethods/Ordering.h +112 -119
  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 -430
  302. package/eigen/Eigen/src/QR/ColPivHouseholderQR.h +479 -479
  303. package/eigen/Eigen/src/QR/ColPivHouseholderQR_LAPACKE.h +120 -56
  304. package/eigen/Eigen/src/QR/CompleteOrthogonalDecomposition.h +166 -153
  305. package/eigen/Eigen/src/QR/FullPivHouseholderQR.h +495 -475
  306. package/eigen/Eigen/src/QR/HouseholderQR.h +394 -285
  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 +244 -264
  311. package/eigen/Eigen/src/SVD/BDCSVD.h +817 -713
  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 +577 -543
  315. package/eigen/Eigen/src/SVD/JacobiSVD_LAPACKE.h +85 -49
  316. package/eigen/Eigen/src/SVD/SVDBase.h +242 -182
  317. package/eigen/Eigen/src/SVD/UpperBidiagonalization.h +200 -235
  318. package/eigen/Eigen/src/SparseCholesky/InternalHeaderCheck.h +3 -0
  319. package/eigen/Eigen/src/SparseCholesky/SimplicialCholesky.h +765 -594
  320. package/eigen/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h +308 -94
  321. package/eigen/Eigen/src/SparseCore/AmbiVector.h +202 -251
  322. package/eigen/Eigen/src/SparseCore/CompressedStorage.h +184 -252
  323. package/eigen/Eigen/src/SparseCore/ConservativeSparseSparseProduct.h +134 -178
  324. package/eigen/Eigen/src/SparseCore/InternalHeaderCheck.h +3 -0
  325. package/eigen/Eigen/src/SparseCore/SparseAssign.h +149 -140
  326. package/eigen/Eigen/src/SparseCore/SparseBlock.h +403 -440
  327. package/eigen/Eigen/src/SparseCore/SparseColEtree.h +100 -112
  328. package/eigen/Eigen/src/SparseCore/SparseCompressedBase.h +525 -303
  329. package/eigen/Eigen/src/SparseCore/SparseCwiseBinaryOp.h +555 -339
  330. package/eigen/Eigen/src/SparseCore/SparseCwiseUnaryOp.h +100 -108
  331. package/eigen/Eigen/src/SparseCore/SparseDenseProduct.h +169 -197
  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 +1603 -1245
  337. package/eigen/Eigen/src/SparseCore/SparseMatrixBase.h +403 -350
  338. package/eigen/Eigen/src/SparseCore/SparsePermutation.h +186 -115
  339. package/eigen/Eigen/src/SparseCore/SparseProduct.h +94 -97
  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 +370 -416
  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 +138 -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 +756 -710
  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 +245 -301
  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 +89 -100
  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 +124 -132
  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 +450 -502
  370. package/eigen/Eigen/src/StlSupport/StdDeque.h +28 -93
  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 -730
  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 +428 -464
  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 +9972 -16179
  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.h → BlockMethods.inc} +434 -506
  401. package/eigen/Eigen/src/plugins/CommonCwiseBinaryOps.inc +116 -0
  402. package/eigen/Eigen/src/plugins/{CommonCwiseUnaryOps.h → CommonCwiseUnaryOps.inc} +58 -68
  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/package.json +1 -1
  409. package/eigen/COPYING.APACHE +0 -203
  410. package/eigen/COPYING.BSD +0 -26
  411. package/eigen/COPYING.GPL +0 -674
  412. package/eigen/COPYING.LGPL +0 -502
  413. package/eigen/COPYING.MINPACK +0 -51
  414. package/eigen/COPYING.MPL2 +0 -373
  415. package/eigen/COPYING.README +0 -18
  416. package/eigen/Eigen/src/Core/BooleanRedux.h +0 -162
  417. package/eigen/Eigen/src/Core/arch/CUDA/Complex.h +0 -258
  418. package/eigen/Eigen/src/Core/arch/Default/TypeCasting.h +0 -120
  419. package/eigen/Eigen/src/Core/arch/SYCL/SyclMemoryModel.h +0 -694
  420. package/eigen/Eigen/src/Core/util/NonMPL2.h +0 -3
  421. package/eigen/Eigen/src/SparseCore/MappedSparseMatrix.h +0 -67
  422. package/eigen/Eigen/src/SparseLU/SparseLU_gemm_kernel.h +0 -280
  423. package/eigen/Eigen/src/misc/lapack.h +0 -152
  424. package/eigen/Eigen/src/plugins/ArrayCwiseBinaryOps.h +0 -358
  425. package/eigen/Eigen/src/plugins/ArrayCwiseUnaryOps.h +0 -696
  426. package/eigen/Eigen/src/plugins/CommonCwiseBinaryOps.h +0 -115
  427. package/eigen/Eigen/src/plugins/IndexedViewMethods.h +0 -262
  428. package/eigen/Eigen/src/plugins/MatrixCwiseBinaryOps.h +0 -152
  429. package/eigen/Eigen/src/plugins/MatrixCwiseUnaryOps.h +0 -95
  430. package/eigen/Eigen/src/plugins/ReshapedMethods.h +0 -149
  431. package/eigen/README.md +0 -5
@@ -8,916 +8,962 @@
8
8
  // Public License v. 2.0. If a copy of the MPL was not distributed
9
9
  // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
10
10
 
11
-
12
11
  #ifndef EIGEN_SPARSE_LU_H
13
12
  #define EIGEN_SPARSE_LU_H
14
13
 
15
- namespace Eigen {
14
+ // IWYU pragma: private
15
+ #include "./InternalHeaderCheck.h"
16
16
 
17
- template <typename _MatrixType, typename _OrderingType = COLAMDOrdering<typename _MatrixType::StorageIndex> > class SparseLU;
18
- template <typename MappedSparseMatrixType> struct SparseLUMatrixLReturnType;
19
- template <typename MatrixLType, typename MatrixUType> struct SparseLUMatrixUReturnType;
17
+ namespace Eigen {
20
18
 
21
- template <bool Conjugate,class SparseLUType>
22
- class SparseLUTransposeView : public SparseSolverBase<SparseLUTransposeView<Conjugate,SparseLUType> >
23
- {
24
- protected:
25
- typedef SparseSolverBase<SparseLUTransposeView<Conjugate,SparseLUType> > APIBase;
19
+ template <typename MatrixType_, typename OrderingType_ = COLAMDOrdering<typename MatrixType_::StorageIndex>>
20
+ class SparseLU;
21
+ template <typename MappedSparseMatrixType>
22
+ struct SparseLUMatrixLReturnType;
23
+ template <typename MatrixLType, typename MatrixUType>
24
+ struct SparseLUMatrixUReturnType;
25
+
26
+ template <bool Conjugate, class SparseLUType>
27
+ class SparseLUTransposeView : public SparseSolverBase<SparseLUTransposeView<Conjugate, SparseLUType>> {
28
+ protected:
29
+ typedef SparseSolverBase<SparseLUTransposeView<Conjugate, SparseLUType>> APIBase;
26
30
  using APIBase::m_isInitialized;
27
- public:
31
+
32
+ public:
28
33
  typedef typename SparseLUType::Scalar Scalar;
29
34
  typedef typename SparseLUType::StorageIndex StorageIndex;
30
35
  typedef typename SparseLUType::MatrixType MatrixType;
31
36
  typedef typename SparseLUType::OrderingType OrderingType;
32
37
 
33
- enum {
34
- ColsAtCompileTime = MatrixType::ColsAtCompileTime,
35
- MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
36
- };
38
+ enum { ColsAtCompileTime = MatrixType::ColsAtCompileTime, MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime };
37
39
 
38
- SparseLUTransposeView() : m_sparseLU(NULL) {}
39
- SparseLUTransposeView(const SparseLUTransposeView& view) {
40
+ SparseLUTransposeView() : APIBase(), m_sparseLU(NULL) {}
41
+ SparseLUTransposeView(const SparseLUTransposeView& view) : APIBase() {
40
42
  this->m_sparseLU = view.m_sparseLU;
43
+ this->m_isInitialized = view.m_isInitialized;
41
44
  }
42
- void setIsInitialized(const bool isInitialized) {this->m_isInitialized = isInitialized;}
43
- void setSparseLU(SparseLUType* sparseLU) {m_sparseLU = sparseLU;}
45
+ void setIsInitialized(const bool isInitialized) { this->m_isInitialized = isInitialized; }
46
+ void setSparseLU(SparseLUType* sparseLU) { m_sparseLU = sparseLU; }
44
47
  using APIBase::_solve_impl;
45
- template<typename Rhs, typename Dest>
46
- bool _solve_impl(const MatrixBase<Rhs> &B, MatrixBase<Dest> &X_base) const
47
- {
48
+ template <typename Rhs, typename Dest>
49
+ bool _solve_impl(const MatrixBase<Rhs>& B, MatrixBase<Dest>& X_base) const {
48
50
  Dest& X(X_base.derived());
49
51
  eigen_assert(m_sparseLU->info() == Success && "The matrix should be factorized first");
50
- EIGEN_STATIC_ASSERT((Dest::Flags&RowMajorBit)==0,
51
- THIS_METHOD_IS_ONLY_FOR_COLUMN_MAJOR_MATRICES);
52
-
52
+ EIGEN_STATIC_ASSERT((Dest::Flags & RowMajorBit) == 0, THIS_METHOD_IS_ONLY_FOR_COLUMN_MAJOR_MATRICES);
53
53
 
54
54
  // this ugly const_cast_derived() helps to detect aliasing when applying the permutations
55
- for(Index j = 0; j < B.cols(); ++j){
55
+ for (Index j = 0; j < B.cols(); ++j) {
56
56
  X.col(j) = m_sparseLU->colsPermutation() * B.const_cast_derived().col(j);
57
57
  }
58
- //Forward substitution with transposed or adjoint of U
58
+ // Forward substitution with transposed or adjoint of U
59
59
  m_sparseLU->matrixU().template solveTransposedInPlace<Conjugate>(X);
60
60
 
61
- //Backward substitution with transposed or adjoint of L
61
+ // Backward substitution with transposed or adjoint of L
62
62
  m_sparseLU->matrixL().template solveTransposedInPlace<Conjugate>(X);
63
63
 
64
64
  // Permute back the solution
65
- for (Index j = 0; j < B.cols(); ++j)
66
- X.col(j) = m_sparseLU->rowsPermutation().transpose() * X.col(j);
65
+ for (Index j = 0; j < B.cols(); ++j) X.col(j) = m_sparseLU->rowsPermutation().transpose() * X.col(j);
67
66
  return true;
68
67
  }
69
68
  inline Index rows() const { return m_sparseLU->rows(); }
70
69
  inline Index cols() const { return m_sparseLU->cols(); }
71
70
 
72
- private:
73
- SparseLUType *m_sparseLU;
71
+ private:
72
+ SparseLUType* m_sparseLU;
74
73
  SparseLUTransposeView& operator=(const SparseLUTransposeView&);
75
74
  };
76
75
 
77
-
78
76
  /** \ingroup SparseLU_Module
79
- * \class SparseLU
80
- *
81
- * \brief Sparse supernodal LU factorization for general matrices
82
- *
83
- * This class implements the supernodal LU factorization for general matrices.
84
- * It uses the main techniques from the sequential SuperLU package
85
- * (http://crd-legacy.lbl.gov/~xiaoye/SuperLU/). It handles transparently real
86
- * and complex arithmetic with single and double precision, depending on the
87
- * scalar type of your input matrix.
88
- * The code has been optimized to provide BLAS-3 operations during supernode-panel updates.
89
- * It benefits directly from the built-in high-performant Eigen BLAS routines.
90
- * Moreover, when the size of a supernode is very small, the BLAS calls are avoided to
91
- * enable a better optimization from the compiler. For best performance,
92
- * you should compile it with NDEBUG flag to avoid the numerous bounds checking on vectors.
93
- *
94
- * An important parameter of this class is the ordering method. It is used to reorder the columns
95
- * (and eventually the rows) of the matrix to reduce the number of new elements that are created during
96
- * numerical factorization. The cheapest method available is COLAMD.
97
- * See \link OrderingMethods_Module the OrderingMethods module \endlink for the list of
98
- * built-in and external ordering methods.
99
- *
100
- * Simple example with key steps
101
- * \code
102
- * VectorXd x(n), b(n);
103
- * SparseMatrix<double> A;
104
- * SparseLU<SparseMatrix<double>, COLAMDOrdering<int> > solver;
105
- * // fill A and b;
106
- * // Compute the ordering permutation vector from the structural pattern of A
107
- * solver.analyzePattern(A);
108
- * // Compute the numerical factorization
109
- * solver.factorize(A);
110
- * //Use the factors to solve the linear system
111
- * x = solver.solve(b);
112
- * \endcode
113
- *
114
- * \warning The input matrix A should be in a \b compressed and \b column-major form.
115
- * Otherwise an expensive copy will be made. You can call the inexpensive makeCompressed() to get a compressed matrix.
116
- *
117
- * \note Unlike the initial SuperLU implementation, there is no step to equilibrate the matrix.
118
- * For badly scaled matrices, this step can be useful to reduce the pivoting during factorization.
119
- * If this is the case for your matrices, you can try the basic scaling method at
120
- * "unsupported/Eigen/src/IterativeSolvers/Scaling.h"
121
- *
122
- * \tparam _MatrixType The type of the sparse matrix. It must be a column-major SparseMatrix<>
123
- * \tparam _OrderingType The ordering method to use, either AMD, COLAMD or METIS. Default is COLMAD
124
- *
125
- * \implsparsesolverconcept
126
- *
127
- * \sa \ref TutorialSparseSolverConcept
128
- * \sa \ref OrderingMethods_Module
129
- */
130
- template <typename _MatrixType, typename _OrderingType>
131
- class SparseLU : public SparseSolverBase<SparseLU<_MatrixType,_OrderingType> >, public internal::SparseLUImpl<typename _MatrixType::Scalar, typename _MatrixType::StorageIndex>
132
- {
133
- protected:
134
- typedef SparseSolverBase<SparseLU<_MatrixType,_OrderingType> > APIBase;
135
- using APIBase::m_isInitialized;
136
- public:
137
- using APIBase::_solve_impl;
138
-
139
- typedef _MatrixType MatrixType;
140
- typedef _OrderingType OrderingType;
141
- typedef typename MatrixType::Scalar Scalar;
142
- typedef typename MatrixType::RealScalar RealScalar;
143
- typedef typename MatrixType::StorageIndex StorageIndex;
144
- typedef SparseMatrix<Scalar,ColMajor,StorageIndex> NCMatrix;
145
- typedef internal::MappedSuperNodalMatrix<Scalar, StorageIndex> SCMatrix;
146
- typedef Matrix<Scalar,Dynamic,1> ScalarVector;
147
- typedef Matrix<StorageIndex,Dynamic,1> IndexVector;
148
- typedef PermutationMatrix<Dynamic, Dynamic, StorageIndex> PermutationType;
149
- typedef internal::SparseLUImpl<Scalar, StorageIndex> Base;
150
-
151
- enum {
152
- ColsAtCompileTime = MatrixType::ColsAtCompileTime,
153
- MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
154
- };
155
-
156
- public:
157
-
158
- SparseLU():m_lastError(""),m_Ustore(0,0,0,0,0,0),m_symmetricmode(false),m_diagpivotthresh(1.0),m_detPermR(1)
159
- {
160
- initperfvalues();
161
- }
162
- explicit SparseLU(const MatrixType& matrix)
163
- : m_lastError(""),m_Ustore(0,0,0,0,0,0),m_symmetricmode(false),m_diagpivotthresh(1.0),m_detPermR(1)
164
- {
165
- initperfvalues();
166
- compute(matrix);
167
- }
168
-
169
- ~SparseLU()
170
- {
171
- // Free all explicit dynamic pointers
172
- }
173
-
174
- void analyzePattern (const MatrixType& matrix);
175
- void factorize (const MatrixType& matrix);
176
- void simplicialfactorize(const MatrixType& matrix);
177
-
178
- /**
179
- * Compute the symbolic and numeric factorization of the input sparse matrix.
180
- * The input matrix should be in column-major storage.
181
- */
182
- void compute (const MatrixType& matrix)
183
- {
184
- // Analyze
185
- analyzePattern(matrix);
186
- //Factorize
187
- factorize(matrix);
188
- }
189
-
190
- /** \returns an expression of the transposed of the factored matrix.
191
- *
192
- * A typical usage is to solve for the transposed problem A^T x = b:
193
- * \code
194
- * solver.compute(A);
195
- * x = solver.transpose().solve(b);
196
- * \endcode
197
- *
198
- * \sa adjoint(), solve()
199
- */
200
- const SparseLUTransposeView<false,SparseLU<_MatrixType,_OrderingType> > transpose()
201
- {
202
- SparseLUTransposeView<false, SparseLU<_MatrixType,_OrderingType> > transposeView;
203
- transposeView.setSparseLU(this);
204
- transposeView.setIsInitialized(this->m_isInitialized);
205
- return transposeView;
206
- }
77
+ * \class SparseLU
78
+ *
79
+ * \brief Sparse supernodal LU factorization for general matrices
80
+ *
81
+ * This class implements the supernodal LU factorization for general matrices.
82
+ * It uses the main techniques from the sequential SuperLU package
83
+ * (http://crd-legacy.lbl.gov/~xiaoye/SuperLU/). It handles transparently real
84
+ * and complex arithmetic with single and double precision, depending on the
85
+ * scalar type of your input matrix.
86
+ * The code has been optimized to provide BLAS-3 operations during supernode-panel updates.
87
+ * It benefits directly from the built-in high-performant Eigen BLAS routines.
88
+ * Moreover, when the size of a supernode is very small, the BLAS calls are avoided to
89
+ * enable a better optimization from the compiler. For best performance,
90
+ * you should compile it with NDEBUG flag to avoid the numerous bounds checking on vectors.
91
+ *
92
+ * An important parameter of this class is the ordering method. It is used to reorder the columns
93
+ * (and eventually the rows) of the matrix to reduce the number of new elements that are created during
94
+ * numerical factorization. The cheapest method available is COLAMD.
95
+ * See \link OrderingMethods_Module the OrderingMethods module \endlink for the list of
96
+ * built-in and external ordering methods.
97
+ *
98
+ * Simple example with key steps
99
+ * \code
100
+ * VectorXd x(n), b(n);
101
+ * SparseMatrix<double> A;
102
+ * SparseLU<SparseMatrix<double>, COLAMDOrdering<int> > solver;
103
+ * // Fill A and b.
104
+ * // Compute the ordering permutation vector from the structural pattern of A.
105
+ * solver.analyzePattern(A);
106
+ * // Compute the numerical factorization.
107
+ * solver.factorize(A);
108
+ * // Use the factors to solve the linear system.
109
+ * x = solver.solve(b);
110
+ * \endcode
111
+ *
112
+ * We can directly call compute() instead of analyzePattern() and factorize()
113
+ * \code
114
+ * VectorXd x(n), b(n);
115
+ * SparseMatrix<double> A;
116
+ * SparseLU<SparseMatrix<double>, COLAMDOrdering<int> > solver;
117
+ * // Fill A and b.
118
+ * solver.compute(A);
119
+ * // Use the factors to solve the linear system.
120
+ * x = solver.solve(b);
121
+ * \endcode
122
+ *
123
+ * Or give the matrix to the constructor SparseLU(const MatrixType& matrix)
124
+ * \code
125
+ * VectorXd x(n), b(n);
126
+ * SparseMatrix<double> A;
127
+ * // Fill A and b.
128
+ * SparseLU<SparseMatrix<double>, COLAMDOrdering<int> > solver(A);
129
+ * // Use the factors to solve the linear system.
130
+ * x = solver.solve(b);
131
+ * \endcode
132
+ *
133
+ * \warning The input matrix A should be in a \b compressed and \b column-major form.
134
+ * Otherwise an expensive copy will be made. You can call the inexpensive makeCompressed() to get a compressed matrix.
135
+ *
136
+ * \note Unlike the initial SuperLU implementation, there is no step to equilibrate the matrix.
137
+ * For badly scaled matrices, this step can be useful to reduce the pivoting during factorization.
138
+ * If this is the case for your matrices, you can try the basic scaling method at
139
+ * "unsupported/Eigen/src/IterativeSolvers/Scaling.h"
140
+ *
141
+ * \tparam MatrixType_ The type of the sparse matrix. It must be a column-major SparseMatrix<>
142
+ * \tparam OrderingType_ The ordering method to use, either AMD, COLAMD or METIS. Default is COLMAD
143
+ *
144
+ * \implsparsesolverconcept
145
+ *
146
+ * \sa \ref TutorialSparseSolverConcept
147
+ * \sa \ref OrderingMethods_Module
148
+ */
149
+ template <typename MatrixType_, typename OrderingType_>
150
+ class SparseLU : public SparseSolverBase<SparseLU<MatrixType_, OrderingType_>>,
151
+ public internal::SparseLUImpl<typename MatrixType_::Scalar, typename MatrixType_::StorageIndex> {
152
+ protected:
153
+ typedef SparseSolverBase<SparseLU<MatrixType_, OrderingType_>> APIBase;
154
+ using APIBase::m_isInitialized;
207
155
 
156
+ public:
157
+ using APIBase::_solve_impl;
208
158
 
209
- /** \returns an expression of the adjoint of the factored matrix
210
- *
211
- * A typical usage is to solve for the adjoint problem A' x = b:
212
- * \code
213
- * solver.compute(A);
214
- * x = solver.adjoint().solve(b);
215
- * \endcode
216
- *
217
- * For real scalar types, this function is equivalent to transpose().
218
- *
219
- * \sa transpose(), solve()
220
- */
221
- const SparseLUTransposeView<true, SparseLU<_MatrixType,_OrderingType> > adjoint()
222
- {
223
- SparseLUTransposeView<true, SparseLU<_MatrixType,_OrderingType> > adjointView;
224
- adjointView.setSparseLU(this);
225
- adjointView.setIsInitialized(this->m_isInitialized);
226
- return adjointView;
227
- }
228
-
229
- inline Index rows() const { return m_mat.rows(); }
230
- inline Index cols() const { return m_mat.cols(); }
231
- /** Indicate that the pattern of the input matrix is symmetric */
232
- void isSymmetric(bool sym)
233
- {
234
- m_symmetricmode = sym;
235
- }
236
-
237
- /** \returns an expression of the matrix L, internally stored as supernodes
238
- * The only operation available with this expression is the triangular solve
239
- * \code
240
- * y = b; matrixL().solveInPlace(y);
241
- * \endcode
242
- */
243
- SparseLUMatrixLReturnType<SCMatrix> matrixL() const
244
- {
245
- return SparseLUMatrixLReturnType<SCMatrix>(m_Lstore);
246
- }
247
- /** \returns an expression of the matrix U,
248
- * The only operation available with this expression is the triangular solve
249
- * \code
250
- * y = b; matrixU().solveInPlace(y);
251
- * \endcode
252
- */
253
- SparseLUMatrixUReturnType<SCMatrix,MappedSparseMatrix<Scalar,ColMajor,StorageIndex> > matrixU() const
254
- {
255
- return SparseLUMatrixUReturnType<SCMatrix, MappedSparseMatrix<Scalar,ColMajor,StorageIndex> >(m_Lstore, m_Ustore);
256
- }
159
+ typedef MatrixType_ MatrixType;
160
+ typedef OrderingType_ OrderingType;
161
+ typedef typename MatrixType::Scalar Scalar;
162
+ typedef typename MatrixType::RealScalar RealScalar;
163
+ typedef typename MatrixType::StorageIndex StorageIndex;
164
+ typedef SparseMatrix<Scalar, ColMajor, StorageIndex> NCMatrix;
165
+ typedef internal::MappedSuperNodalMatrix<Scalar, StorageIndex> SCMatrix;
166
+ typedef Matrix<Scalar, Dynamic, 1> ScalarVector;
167
+ typedef Matrix<StorageIndex, Dynamic, 1> IndexVector;
168
+ typedef PermutationMatrix<Dynamic, Dynamic, StorageIndex> PermutationType;
169
+ typedef internal::SparseLUImpl<Scalar, StorageIndex> Base;
170
+
171
+ enum { ColsAtCompileTime = MatrixType::ColsAtCompileTime, MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime };
172
+
173
+ public:
174
+ /** \brief Basic constructor of the solver.
175
+ *
176
+ * Construct a SparseLU. As no matrix is given as argument, compute() should be called afterward with a matrix.
177
+ */
178
+ SparseLU()
179
+ : m_lastError(""), m_Ustore(0, 0, 0, 0, 0, 0), m_symmetricmode(false), m_diagpivotthresh(1.0), m_detPermR(1) {
180
+ initperfvalues();
181
+ }
182
+ /** \brief Constructor of the solver already based on a specific matrix.
183
+ *
184
+ * Construct a SparseLU. compute() is already called with the given matrix.
185
+ */
186
+ explicit SparseLU(const MatrixType& matrix)
187
+ : m_lastError(""), m_Ustore(0, 0, 0, 0, 0, 0), m_symmetricmode(false), m_diagpivotthresh(1.0), m_detPermR(1) {
188
+ initperfvalues();
189
+ compute(matrix);
190
+ }
257
191
 
258
- /**
259
- * \returns a reference to the row matrix permutation \f$ P_r \f$ such that \f$P_r A P_c^T = L U\f$
260
- * \sa colsPermutation()
261
- */
262
- inline const PermutationType& rowsPermutation() const
263
- {
264
- return m_perm_r;
265
- }
266
- /**
267
- * \returns a reference to the column matrix permutation\f$ P_c^T \f$ such that \f$P_r A P_c^T = L U\f$
268
- * \sa rowsPermutation()
269
- */
270
- inline const PermutationType& colsPermutation() const
271
- {
272
- return m_perm_c;
273
- }
274
- /** Set the threshold used for a diagonal entry to be an acceptable pivot. */
275
- void setPivotThreshold(const RealScalar& thresh)
276
- {
277
- m_diagpivotthresh = thresh;
278
- }
192
+ ~SparseLU() {
193
+ // Free all explicit dynamic pointers
194
+ }
195
+
196
+ void analyzePattern(const MatrixType& matrix);
197
+ void factorize(const MatrixType& matrix);
198
+ void simplicialfactorize(const MatrixType& matrix);
199
+
200
+ /** \brief Analyze and factorize the matrix so the solver is ready to solve.
201
+ *
202
+ * Compute the symbolic and numeric factorization of the input sparse matrix.
203
+ * The input matrix should be in column-major storage, otherwise analyzePattern()
204
+ * will do a heavy copy.
205
+ *
206
+ * Call analyzePattern() followed by factorize()
207
+ *
208
+ * \sa analyzePattern(), factorize()
209
+ */
210
+ void compute(const MatrixType& matrix) {
211
+ // Analyze
212
+ analyzePattern(matrix);
213
+ // Factorize
214
+ factorize(matrix);
215
+ }
216
+
217
+ /** \brief Return a solver for the transposed matrix.
218
+ *
219
+ * \returns an expression of the transposed of the factored matrix.
220
+ *
221
+ * A typical usage is to solve for the transposed problem A^T x = b:
222
+ * \code
223
+ * solver.compute(A);
224
+ * x = solver.transpose().solve(b);
225
+ * \endcode
226
+ *
227
+ * \sa adjoint(), solve()
228
+ */
229
+ const SparseLUTransposeView<false, SparseLU<MatrixType_, OrderingType_>> transpose() {
230
+ SparseLUTransposeView<false, SparseLU<MatrixType_, OrderingType_>> transposeView;
231
+ transposeView.setSparseLU(this);
232
+ transposeView.setIsInitialized(this->m_isInitialized);
233
+ return transposeView;
234
+ }
235
+
236
+ /** \brief Return a solver for the adjointed matrix.
237
+ *
238
+ * \returns an expression of the adjoint of the factored matrix
239
+ *
240
+ * A typical usage is to solve for the adjoint problem A' x = b:
241
+ * \code
242
+ * solver.compute(A);
243
+ * x = solver.adjoint().solve(b);
244
+ * \endcode
245
+ *
246
+ * For real scalar types, this function is equivalent to transpose().
247
+ *
248
+ * \sa transpose(), solve()
249
+ */
250
+ const SparseLUTransposeView<true, SparseLU<MatrixType_, OrderingType_>> adjoint() {
251
+ SparseLUTransposeView<true, SparseLU<MatrixType_, OrderingType_>> adjointView;
252
+ adjointView.setSparseLU(this);
253
+ adjointView.setIsInitialized(this->m_isInitialized);
254
+ return adjointView;
255
+ }
256
+
257
+ /** \brief Give the number of rows.
258
+ */
259
+ inline Index rows() const { return m_mat.rows(); }
260
+ /** \brief Give the number of columns.
261
+ */
262
+ inline Index cols() const { return m_mat.cols(); }
263
+ /** \brief Let you set that the pattern of the input matrix is symmetric
264
+ */
265
+ void isSymmetric(bool sym) { m_symmetricmode = sym; }
266
+
267
+ /** \brief Give the matrixL
268
+ *
269
+ * \returns an expression of the matrix L, internally stored as supernodes
270
+ * The only operation available with this expression is the triangular solve
271
+ * \code
272
+ * y = b; matrixL().solveInPlace(y);
273
+ * \endcode
274
+ */
275
+ SparseLUMatrixLReturnType<SCMatrix> matrixL() const { return SparseLUMatrixLReturnType<SCMatrix>(m_Lstore); }
276
+ /** \brief Give the MatrixU
277
+ *
278
+ * \returns an expression of the matrix U,
279
+ * The only operation available with this expression is the triangular solve
280
+ * \code
281
+ * y = b; matrixU().solveInPlace(y);
282
+ * \endcode
283
+ */
284
+ SparseLUMatrixUReturnType<SCMatrix, Map<SparseMatrix<Scalar, ColMajor, StorageIndex>>> matrixU() const {
285
+ return SparseLUMatrixUReturnType<SCMatrix, Map<SparseMatrix<Scalar, ColMajor, StorageIndex>>>(m_Lstore, m_Ustore);
286
+ }
287
+
288
+ /** \brief Give the row matrix permutation.
289
+ *
290
+ * \returns a reference to the row matrix permutation \f$ P_r \f$ such that \f$P_r A P_c^T = L U\f$
291
+ * \sa colsPermutation()
292
+ */
293
+ inline const PermutationType& rowsPermutation() const { return m_perm_r; }
294
+ /** \brief Give the column matrix permutation.
295
+ *
296
+ * \returns a reference to the column matrix permutation\f$ P_c^T \f$ such that \f$P_r A P_c^T = L U\f$
297
+ * \sa rowsPermutation()
298
+ */
299
+ inline const PermutationType& colsPermutation() const { return m_perm_c; }
300
+ /** Set the threshold used for a diagonal entry to be an acceptable pivot. */
301
+ void setPivotThreshold(const RealScalar& thresh) { m_diagpivotthresh = thresh; }
279
302
 
280
303
  #ifdef EIGEN_PARSED_BY_DOXYGEN
281
- /** \returns the solution X of \f$ A X = B \f$ using the current decomposition of A.
282
- *
283
- * \warning the destination matrix X in X = this->solve(B) must be colmun-major.
284
- *
285
- * \sa compute()
286
- */
287
- template<typename Rhs>
288
- inline const Solve<SparseLU, Rhs> solve(const MatrixBase<Rhs>& B) const;
289
- #endif // EIGEN_PARSED_BY_DOXYGEN
290
-
291
- /** \brief Reports whether previous computation was successful.
292
- *
293
- * \returns \c Success if computation was successful,
294
- * \c NumericalIssue if the LU factorization reports a problem, zero diagonal for instance
295
- * \c InvalidInput if the input matrix is invalid
296
- *
297
- * \sa iparm()
298
- */
299
- ComputationInfo info() const
300
- {
301
- eigen_assert(m_isInitialized && "Decomposition is not initialized.");
302
- return m_info;
303
- }
304
-
305
- /**
306
- * \returns A string describing the type of error
307
- */
308
- std::string lastErrorMessage() const
309
- {
310
- return m_lastError;
311
- }
304
+ /** \brief Solve a system \f$ A X = B \f$
305
+ *
306
+ * \returns the solution X of \f$ A X = B \f$ using the current decomposition of A.
307
+ *
308
+ * \warning the destination matrix X in X = this->solve(B) must be colmun-major.
309
+ *
310
+ * \sa compute()
311
+ */
312
+ template <typename Rhs>
313
+ inline const Solve<SparseLU, Rhs> solve(const MatrixBase<Rhs>& B) const;
314
+ #endif // EIGEN_PARSED_BY_DOXYGEN
315
+
316
+ /** \brief Reports whether previous computation was successful.
317
+ *
318
+ * \returns \c Success if computation was successful,
319
+ * \c NumericalIssue if the LU factorization reports a problem, zero diagonal for instance
320
+ * \c InvalidInput if the input matrix is invalid
321
+ *
322
+ * You can get a readable error message with lastErrorMessage().
323
+ *
324
+ * \sa lastErrorMessage()
325
+ */
326
+ ComputationInfo info() const {
327
+ eigen_assert(m_isInitialized && "Decomposition is not initialized.");
328
+ return m_info;
329
+ }
312
330
 
313
- template<typename Rhs, typename Dest>
314
- bool _solve_impl(const MatrixBase<Rhs> &B, MatrixBase<Dest> &X_base) const
315
- {
316
- Dest& X(X_base.derived());
317
- eigen_assert(m_factorizationIsOk && "The matrix should be factorized first");
318
- EIGEN_STATIC_ASSERT((Dest::Flags&RowMajorBit)==0,
319
- THIS_METHOD_IS_ONLY_FOR_COLUMN_MAJOR_MATRICES);
320
-
321
- // Permute the right hand side to form X = Pr*B
322
- // on return, X is overwritten by the computed solution
323
- X.resize(B.rows(),B.cols());
324
-
325
- // this ugly const_cast_derived() helps to detect aliasing when applying the permutations
326
- for(Index j = 0; j < B.cols(); ++j)
327
- X.col(j) = rowsPermutation() * B.const_cast_derived().col(j);
328
-
329
- //Forward substitution with L
330
- this->matrixL().solveInPlace(X);
331
- this->matrixU().solveInPlace(X);
332
-
333
- // Permute back the solution
334
- for (Index j = 0; j < B.cols(); ++j)
335
- X.col(j) = colsPermutation().inverse() * X.col(j);
336
-
337
- return true;
338
- }
339
-
340
- /**
341
- * \returns the absolute value of the determinant of the matrix of which
342
- * *this is the QR decomposition.
343
- *
344
- * \warning a determinant can be very big or small, so for matrices
345
- * of large enough dimension, there is a risk of overflow/underflow.
346
- * One way to work around that is to use logAbsDeterminant() instead.
347
- *
348
- * \sa logAbsDeterminant(), signDeterminant()
349
- */
350
- Scalar absDeterminant()
351
- {
352
- using std::abs;
353
- eigen_assert(m_factorizationIsOk && "The matrix should be factorized first.");
354
- // Initialize with the determinant of the row matrix
355
- Scalar det = Scalar(1.);
356
- // Note that the diagonal blocks of U are stored in supernodes,
357
- // which are available in the L part :)
358
- for (Index j = 0; j < this->cols(); ++j)
359
- {
360
- for (typename SCMatrix::InnerIterator it(m_Lstore, j); it; ++it)
361
- {
362
- if(it.index() == j)
363
- {
364
- det *= abs(it.value());
365
- break;
366
- }
331
+ /** \brief Give a human readable error
332
+ *
333
+ * \returns A string describing the type of error
334
+ */
335
+ std::string lastErrorMessage() const { return m_lastError; }
336
+
337
+ template <typename Rhs, typename Dest>
338
+ bool _solve_impl(const MatrixBase<Rhs>& B, MatrixBase<Dest>& X_base) const {
339
+ Dest& X(X_base.derived());
340
+ eigen_assert(m_factorizationIsOk && "The matrix should be factorized first");
341
+ EIGEN_STATIC_ASSERT((Dest::Flags & RowMajorBit) == 0, THIS_METHOD_IS_ONLY_FOR_COLUMN_MAJOR_MATRICES);
342
+
343
+ // Permute the right hand side to form X = Pr*B
344
+ // on return, X is overwritten by the computed solution
345
+ X.resize(B.rows(), B.cols());
346
+
347
+ // this ugly const_cast_derived() helps to detect aliasing when applying the permutations
348
+ for (Index j = 0; j < B.cols(); ++j) X.col(j) = rowsPermutation() * B.const_cast_derived().col(j);
349
+
350
+ // Forward substitution with L
351
+ this->matrixL().solveInPlace(X);
352
+ this->matrixU().solveInPlace(X);
353
+
354
+ // Permute back the solution
355
+ for (Index j = 0; j < B.cols(); ++j) X.col(j) = colsPermutation().inverse() * X.col(j);
356
+
357
+ return true;
358
+ }
359
+
360
+ /** \brief Give the absolute value of the determinant.
361
+ *
362
+ * \returns the absolute value of the determinant of the matrix of which
363
+ * *this is the QR decomposition.
364
+ *
365
+ * \warning a determinant can be very big or small, so for matrices
366
+ * of large enough dimension, there is a risk of overflow/underflow.
367
+ * One way to work around that is to use logAbsDeterminant() instead.
368
+ *
369
+ * \sa logAbsDeterminant(), signDeterminant()
370
+ */
371
+ Scalar absDeterminant() {
372
+ using std::abs;
373
+ eigen_assert(m_factorizationIsOk && "The matrix should be factorized first.");
374
+ // Initialize with the determinant of the row matrix
375
+ Scalar det = Scalar(1.);
376
+ // Note that the diagonal blocks of U are stored in supernodes,
377
+ // which are available in the L part :)
378
+ for (Index j = 0; j < this->cols(); ++j) {
379
+ for (typename SCMatrix::InnerIterator it(m_Lstore, j); it; ++it) {
380
+ if (it.index() == j) {
381
+ det *= abs(it.value());
382
+ break;
367
383
  }
368
384
  }
369
- return det;
370
385
  }
386
+ return det;
387
+ }
371
388
 
372
- /** \returns the natural log of the absolute value of the determinant of the matrix
373
- * of which **this is the QR decomposition
374
- *
375
- * \note This method is useful to work around the risk of overflow/underflow that's
376
- * inherent to the determinant computation.
377
- *
378
- * \sa absDeterminant(), signDeterminant()
379
- */
380
- Scalar logAbsDeterminant() const
381
- {
382
- using std::log;
383
- using std::abs;
384
-
385
- eigen_assert(m_factorizationIsOk && "The matrix should be factorized first.");
386
- Scalar det = Scalar(0.);
387
- for (Index j = 0; j < this->cols(); ++j)
388
- {
389
- for (typename SCMatrix::InnerIterator it(m_Lstore, j); it; ++it)
390
- {
391
- if(it.row() < j) continue;
392
- if(it.row() == j)
393
- {
394
- det += log(abs(it.value()));
395
- break;
396
- }
389
+ /** \brief Give the natural log of the absolute determinant.
390
+ *
391
+ * \returns the natural log of the absolute value of the determinant of the matrix
392
+ * of which **this is the QR decomposition
393
+ *
394
+ * \note This method is useful to work around the risk of overflow/underflow that's
395
+ * inherent to the determinant computation.
396
+ *
397
+ * \sa absDeterminant(), signDeterminant()
398
+ */
399
+ Scalar logAbsDeterminant() const {
400
+ using std::abs;
401
+ using std::log;
402
+
403
+ eigen_assert(m_factorizationIsOk && "The matrix should be factorized first.");
404
+ Scalar det = Scalar(0.);
405
+ for (Index j = 0; j < this->cols(); ++j) {
406
+ for (typename SCMatrix::InnerIterator it(m_Lstore, j); it; ++it) {
407
+ if (it.row() < j) continue;
408
+ if (it.row() == j) {
409
+ det += log(abs(it.value()));
410
+ break;
397
411
  }
398
412
  }
399
- return det;
400
413
  }
414
+ return det;
415
+ }
401
416
 
402
- /** \returns A number representing the sign of the determinant
403
- *
404
- * \sa absDeterminant(), logAbsDeterminant()
405
- */
406
- Scalar signDeterminant()
407
- {
408
- eigen_assert(m_factorizationIsOk && "The matrix should be factorized first.");
409
- // Initialize with the determinant of the row matrix
410
- Index det = 1;
411
- // Note that the diagonal blocks of U are stored in supernodes,
412
- // which are available in the L part :)
413
- for (Index j = 0; j < this->cols(); ++j)
414
- {
415
- for (typename SCMatrix::InnerIterator it(m_Lstore, j); it; ++it)
416
- {
417
- if(it.index() == j)
418
- {
419
- if(it.value()<0)
420
- det = -det;
421
- else if(it.value()==0)
422
- return 0;
423
- break;
424
- }
417
+ /** \brief Give the sign of the determinant.
418
+ *
419
+ * \returns A number representing the sign of the determinant
420
+ *
421
+ * \sa absDeterminant(), logAbsDeterminant()
422
+ */
423
+ Scalar signDeterminant() {
424
+ eigen_assert(m_factorizationIsOk && "The matrix should be factorized first.");
425
+ // Initialize with the determinant of the row matrix
426
+ Index det = 1;
427
+ // Note that the diagonal blocks of U are stored in supernodes,
428
+ // which are available in the L part :)
429
+ for (Index j = 0; j < this->cols(); ++j) {
430
+ for (typename SCMatrix::InnerIterator it(m_Lstore, j); it; ++it) {
431
+ if (it.index() == j) {
432
+ if (it.value() < 0)
433
+ det = -det;
434
+ else if (it.value() == 0)
435
+ return 0;
436
+ break;
425
437
  }
426
438
  }
427
- return det * m_detPermR * m_detPermC;
428
439
  }
429
-
430
- /** \returns The determinant of the matrix.
431
- *
432
- * \sa absDeterminant(), logAbsDeterminant()
433
- */
434
- Scalar determinant()
435
- {
436
- eigen_assert(m_factorizationIsOk && "The matrix should be factorized first.");
437
- // Initialize with the determinant of the row matrix
438
- Scalar det = Scalar(1.);
439
- // Note that the diagonal blocks of U are stored in supernodes,
440
- // which are available in the L part :)
441
- for (Index j = 0; j < this->cols(); ++j)
442
- {
443
- for (typename SCMatrix::InnerIterator it(m_Lstore, j); it; ++it)
444
- {
445
- if(it.index() == j)
446
- {
447
- det *= it.value();
448
- break;
449
- }
440
+ return det * m_detPermR * m_detPermC;
441
+ }
442
+
443
+ /** \brief Give the determinant.
444
+ *
445
+ * \returns The determinant of the matrix.
446
+ *
447
+ * \sa absDeterminant(), logAbsDeterminant()
448
+ */
449
+ Scalar determinant() {
450
+ eigen_assert(m_factorizationIsOk && "The matrix should be factorized first.");
451
+ // Initialize with the determinant of the row matrix
452
+ Scalar det = Scalar(1.);
453
+ // Note that the diagonal blocks of U are stored in supernodes,
454
+ // which are available in the L part :)
455
+ for (Index j = 0; j < this->cols(); ++j) {
456
+ for (typename SCMatrix::InnerIterator it(m_Lstore, j); it; ++it) {
457
+ if (it.index() == j) {
458
+ det *= it.value();
459
+ break;
450
460
  }
451
461
  }
452
- return (m_detPermR * m_detPermC) > 0 ? det : -det;
453
462
  }
463
+ return (m_detPermR * m_detPermC) > 0 ? det : -det;
464
+ }
454
465
 
455
- Index nnzL() const { return m_nnzL; };
456
- Index nnzU() const { return m_nnzU; };
457
-
458
- protected:
459
- // Functions
460
- void initperfvalues()
461
- {
462
- m_perfv.panel_size = 16;
463
- m_perfv.relax = 1;
464
- m_perfv.maxsuper = 128;
465
- m_perfv.rowblk = 16;
466
- m_perfv.colblk = 8;
467
- m_perfv.fillfactor = 20;
468
- }
469
-
470
- // Variables
471
- mutable ComputationInfo m_info;
472
- bool m_factorizationIsOk;
473
- bool m_analysisIsOk;
474
- std::string m_lastError;
475
- NCMatrix m_mat; // The input (permuted ) matrix
476
- SCMatrix m_Lstore; // The lower triangular matrix (supernodal)
477
- MappedSparseMatrix<Scalar,ColMajor,StorageIndex> m_Ustore; // The upper triangular matrix
478
- PermutationType m_perm_c; // Column permutation
479
- PermutationType m_perm_r ; // Row permutation
480
- IndexVector m_etree; // Column elimination tree
481
-
482
- typename Base::GlobalLU_t m_glu;
483
-
484
- // SparseLU options
485
- bool m_symmetricmode;
486
- // values for performance
487
- internal::perfvalues m_perfv;
488
- RealScalar m_diagpivotthresh; // Specifies the threshold used for a diagonal entry to be an acceptable pivot
489
- Index m_nnzL, m_nnzU; // Nonzeros in L and U factors
490
- Index m_detPermR, m_detPermC; // Determinants of the permutation matrices
491
- private:
492
- // Disable copy constructor
493
- SparseLU (const SparseLU& );
494
- }; // End class SparseLU
495
-
466
+ /** \brief Give the number of non zero in matrix L.
467
+ */
468
+ Index nnzL() const { return m_nnzL; }
469
+ /** \brief Give the number of non zero in matrix U.
470
+ */
471
+ Index nnzU() const { return m_nnzU; }
472
+
473
+ protected:
474
+ // Functions
475
+ void initperfvalues() {
476
+ m_perfv.panel_size = 16;
477
+ m_perfv.relax = 1;
478
+ m_perfv.maxsuper = 128;
479
+ m_perfv.rowblk = 16;
480
+ m_perfv.colblk = 8;
481
+ m_perfv.fillfactor = 20;
482
+ }
496
483
 
484
+ // Variables
485
+ mutable ComputationInfo m_info;
486
+ bool m_factorizationIsOk;
487
+ bool m_analysisIsOk;
488
+ std::string m_lastError;
489
+ NCMatrix m_mat; // The input (permuted ) matrix
490
+ SCMatrix m_Lstore; // The lower triangular matrix (supernodal)
491
+ Map<SparseMatrix<Scalar, ColMajor, StorageIndex>> m_Ustore; // The upper triangular matrix
492
+ PermutationType m_perm_c; // Column permutation
493
+ PermutationType m_perm_r; // Row permutation
494
+ IndexVector m_etree; // Column elimination tree
495
+
496
+ typename Base::GlobalLU_t m_glu;
497
+
498
+ // SparseLU options
499
+ bool m_symmetricmode;
500
+ // values for performance
501
+ internal::perfvalues m_perfv;
502
+ RealScalar m_diagpivotthresh; // Specifies the threshold used for a diagonal entry to be an acceptable pivot
503
+ Index m_nnzL, m_nnzU; // Nonzeros in L and U factors
504
+ Index m_detPermR, m_detPermC; // Determinants of the permutation matrices
505
+ private:
506
+ // Disable copy constructor
507
+ SparseLU(const SparseLU&);
508
+ }; // End class SparseLU
497
509
 
498
510
  // Functions needed by the anaysis phase
499
- /**
500
- * Compute the column permutation to minimize the fill-in
501
- *
502
- * - Apply this permutation to the input matrix -
503
- *
504
- * - Compute the column elimination tree on the permuted matrix
505
- *
506
- * - Postorder the elimination tree and the column permutation
507
- *
508
- */
511
+ /** \brief Compute the column permutation.
512
+ *
513
+ * Compute the column permutation to minimize the fill-in
514
+ *
515
+ * - Apply this permutation to the input matrix -
516
+ *
517
+ * - Compute the column elimination tree on the permuted matrix
518
+ *
519
+ * - Postorder the elimination tree and the column permutation
520
+ *
521
+ * It is possible to call compute() instead of analyzePattern() + factorize().
522
+ *
523
+ * If the matrix is row-major this function will do an heavy copy.
524
+ *
525
+ * \sa factorize(), compute()
526
+ */
509
527
  template <typename MatrixType, typename OrderingType>
510
- void SparseLU<MatrixType, OrderingType>::analyzePattern(const MatrixType& mat)
511
- {
512
-
513
- //TODO It is possible as in SuperLU to compute row and columns scaling vectors to equilibrate the matrix mat.
514
-
515
- // Firstly, copy the whole input matrix.
528
+ void SparseLU<MatrixType, OrderingType>::analyzePattern(const MatrixType& mat) {
529
+ // TODO It is possible as in SuperLU to compute row and columns scaling vectors to equilibrate the matrix mat.
530
+
531
+ // Firstly, copy the whole input matrix.
516
532
  m_mat = mat;
517
-
533
+
518
534
  // Compute fill-in ordering
519
- OrderingType ord;
520
- ord(m_mat,m_perm_c);
521
-
535
+ OrderingType ord;
536
+ ord(m_mat, m_perm_c);
537
+
522
538
  // Apply the permutation to the column of the input matrix
523
- if (m_perm_c.size())
524
- {
525
- m_mat.uncompress(); //NOTE: The effect of this command is only to create the InnerNonzeros pointers. FIXME : This vector is filled but not subsequently used.
539
+ if (m_perm_c.size()) {
540
+ m_mat.uncompress(); // NOTE: The effect of this command is only to create the InnerNonzeros pointers. FIXME : This
541
+ // vector is filled but not subsequently used.
526
542
  // Then, permute only the column pointers
527
- ei_declare_aligned_stack_constructed_variable(StorageIndex,outerIndexPtr,mat.cols()+1,mat.isCompressed()?const_cast<StorageIndex*>(mat.outerIndexPtr()):0);
528
-
529
- // If the input matrix 'mat' is uncompressed, then the outer-indices do not match the ones of m_mat, and a copy is thus needed.
530
- if(!mat.isCompressed())
531
- IndexVector::Map(outerIndexPtr, mat.cols()+1) = IndexVector::Map(m_mat.outerIndexPtr(),mat.cols()+1);
532
-
543
+ ei_declare_aligned_stack_constructed_variable(
544
+ StorageIndex, outerIndexPtr, mat.cols() + 1,
545
+ mat.isCompressed() ? const_cast<StorageIndex*>(mat.outerIndexPtr()) : 0);
546
+
547
+ // If the input matrix 'mat' is uncompressed, then the outer-indices do not match the ones of m_mat, and a copy is
548
+ // thus needed.
549
+ if (!mat.isCompressed())
550
+ IndexVector::Map(outerIndexPtr, mat.cols() + 1) = IndexVector::Map(m_mat.outerIndexPtr(), mat.cols() + 1);
551
+
533
552
  // Apply the permutation and compute the nnz per column.
534
- for (Index i = 0; i < mat.cols(); i++)
535
- {
553
+ for (Index i = 0; i < mat.cols(); i++) {
536
554
  m_mat.outerIndexPtr()[m_perm_c.indices()(i)] = outerIndexPtr[i];
537
- m_mat.innerNonZeroPtr()[m_perm_c.indices()(i)] = outerIndexPtr[i+1] - outerIndexPtr[i];
555
+ m_mat.innerNonZeroPtr()[m_perm_c.indices()(i)] = outerIndexPtr[i + 1] - outerIndexPtr[i];
538
556
  }
539
557
  }
540
-
541
- // Compute the column elimination tree of the permuted matrix
558
+
559
+ // Compute the column elimination tree of the permuted matrix
542
560
  IndexVector firstRowElt;
543
- internal::coletree(m_mat, m_etree,firstRowElt);
544
-
561
+ internal::coletree(m_mat, m_etree, firstRowElt);
562
+
545
563
  // In symmetric mode, do not do postorder here
546
564
  if (!m_symmetricmode) {
547
- IndexVector post, iwork;
565
+ IndexVector post, iwork;
548
566
  // Post order etree
549
- internal::treePostorder(StorageIndex(m_mat.cols()), m_etree, post);
550
-
551
-
552
- // Renumber etree in postorder
553
- Index m = m_mat.cols();
554
- iwork.resize(m+1);
567
+ internal::treePostorder(StorageIndex(m_mat.cols()), m_etree, post);
568
+
569
+ // Renumber etree in postorder
570
+ Index m = m_mat.cols();
571
+ iwork.resize(m + 1);
555
572
  for (Index i = 0; i < m; ++i) iwork(post(i)) = post(m_etree(i));
556
573
  m_etree = iwork;
557
-
574
+
558
575
  // Postmultiply A*Pc by post, i.e reorder the matrix according to the postorder of the etree
559
- PermutationType post_perm(m);
560
- for (Index i = 0; i < m; i++)
561
- post_perm.indices()(i) = post(i);
562
-
576
+ PermutationType post_perm(m);
577
+ for (Index i = 0; i < m; i++) post_perm.indices()(i) = post(i);
578
+
563
579
  // Combine the two permutations : postorder the permutation for future use
564
- if(m_perm_c.size()) {
580
+ if (m_perm_c.size()) {
565
581
  m_perm_c = post_perm * m_perm_c;
566
582
  }
567
-
568
- } // end postordering
569
-
570
- m_analysisIsOk = true;
583
+
584
+ } // end postordering
585
+
586
+ m_analysisIsOk = true;
571
587
  }
572
588
 
573
589
  // Functions needed by the numerical factorization phase
574
590
 
575
-
576
- /**
577
- * - Numerical factorization
578
- * - Interleaved with the symbolic factorization
579
- * On exit, info is
580
- *
581
- * = 0: successful factorization
582
- *
583
- * > 0: if info = i, and i is
584
- *
585
- * <= A->ncol: U(i,i) is exactly zero. The factorization has
586
- * been completed, but the factor U is exactly singular,
587
- * and division by zero will occur if it is used to solve a
588
- * system of equations.
589
- *
590
- * > A->ncol: number of bytes allocated when memory allocation
591
- * failure occurred, plus A->ncol. If lwork = -1, it is
592
- * the estimated amount of space needed, plus A->ncol.
593
- */
591
+ /** \brief Factorize the matrix to get the solver ready.
592
+ *
593
+ * - Numerical factorization
594
+ * - Interleaved with the symbolic factorization
595
+ *
596
+ * To get error of this function you should check info(), you can get more info of
597
+ * errors with lastErrorMessage().
598
+ *
599
+ * In the past (before 2012 (git history is not older)), this function was returning an integer.
600
+ * This exit was 0 if successful factorization.
601
+ * > 0 if info = i, and i is been completed, but the factor U is exactly singular,
602
+ * and division by zero will occur if it is used to solve a system of equation.
603
+ * > A->ncol: number of bytes allocated when memory allocation failure occurred, plus A->ncol.
604
+ * If lwork = -1, it is the estimated amount of space needed, plus A->ncol.
605
+ *
606
+ * It seems that A was the name of the matrix in the past.
607
+ *
608
+ * \sa analyzePattern(), compute(), SparseLU(), info(), lastErrorMessage()
609
+ */
594
610
  template <typename MatrixType, typename OrderingType>
595
- void SparseLU<MatrixType, OrderingType>::factorize(const MatrixType& matrix)
596
- {
611
+ void SparseLU<MatrixType, OrderingType>::factorize(const MatrixType& matrix) {
597
612
  using internal::emptyIdxLU;
598
- eigen_assert(m_analysisIsOk && "analyzePattern() should be called first");
613
+ eigen_assert(m_analysisIsOk && "analyzePattern() should be called first");
599
614
  eigen_assert((matrix.rows() == matrix.cols()) && "Only for squared matrices");
600
-
615
+
601
616
  m_isInitialized = true;
602
-
617
+
603
618
  // Apply the column permutation computed in analyzepattern()
604
- // m_mat = matrix * m_perm_c.inverse();
619
+ // m_mat = matrix * m_perm_c.inverse();
605
620
  m_mat = matrix;
606
- if (m_perm_c.size())
607
- {
608
- m_mat.uncompress(); //NOTE: The effect of this command is only to create the InnerNonzeros pointers.
609
- //Then, permute only the column pointers
610
- const StorageIndex * outerIndexPtr;
611
- if (matrix.isCompressed()) outerIndexPtr = matrix.outerIndexPtr();
612
- else
613
- {
614
- StorageIndex* outerIndexPtr_t = new StorageIndex[matrix.cols()+1];
615
- for(Index i = 0; i <= matrix.cols(); i++) outerIndexPtr_t[i] = m_mat.outerIndexPtr()[i];
621
+ if (m_perm_c.size()) {
622
+ m_mat.uncompress(); // NOTE: The effect of this command is only to create the InnerNonzeros pointers.
623
+ // Then, permute only the column pointers
624
+ const StorageIndex* outerIndexPtr;
625
+ if (matrix.isCompressed())
626
+ outerIndexPtr = matrix.outerIndexPtr();
627
+ else {
628
+ StorageIndex* outerIndexPtr_t = new StorageIndex[matrix.cols() + 1];
629
+ for (Index i = 0; i <= matrix.cols(); i++) outerIndexPtr_t[i] = m_mat.outerIndexPtr()[i];
616
630
  outerIndexPtr = outerIndexPtr_t;
617
631
  }
618
- for (Index i = 0; i < matrix.cols(); i++)
619
- {
632
+ for (Index i = 0; i < matrix.cols(); i++) {
620
633
  m_mat.outerIndexPtr()[m_perm_c.indices()(i)] = outerIndexPtr[i];
621
- m_mat.innerNonZeroPtr()[m_perm_c.indices()(i)] = outerIndexPtr[i+1] - outerIndexPtr[i];
634
+ m_mat.innerNonZeroPtr()[m_perm_c.indices()(i)] = outerIndexPtr[i + 1] - outerIndexPtr[i];
622
635
  }
623
- if(!matrix.isCompressed()) delete[] outerIndexPtr;
624
- }
625
- else
626
- { //FIXME This should not be needed if the empty permutation is handled transparently
636
+ if (!matrix.isCompressed()) delete[] outerIndexPtr;
637
+ } else { // FIXME This should not be needed if the empty permutation is handled transparently
627
638
  m_perm_c.resize(matrix.cols());
628
- for(StorageIndex i = 0; i < matrix.cols(); ++i) m_perm_c.indices()(i) = i;
639
+ for (StorageIndex i = 0; i < matrix.cols(); ++i) m_perm_c.indices()(i) = i;
629
640
  }
630
-
641
+
631
642
  Index m = m_mat.rows();
632
643
  Index n = m_mat.cols();
633
644
  Index nnz = m_mat.nonZeros();
634
645
  Index maxpanel = m_perfv.panel_size * m;
635
646
  // Allocate working storage common to the factor routines
636
647
  Index lwork = 0;
637
- Index info = Base::memInit(m, n, nnz, lwork, m_perfv.fillfactor, m_perfv.panel_size, m_glu);
638
- if (info)
639
- {
640
- m_lastError = "UNABLE TO ALLOCATE WORKING MEMORY\n\n" ;
648
+ // Return the size of actually allocated memory when allocation failed,
649
+ // and 0 on success.
650
+ Index info = Base::memInit(m, n, nnz, lwork, m_perfv.fillfactor, m_perfv.panel_size, m_glu);
651
+ if (info) {
652
+ m_lastError = "UNABLE TO ALLOCATE WORKING MEMORY\n\n";
641
653
  m_factorizationIsOk = false;
642
- return ;
654
+ return;
643
655
  }
644
-
645
- // Set up pointers for integer working arrays
646
- IndexVector segrep(m); segrep.setZero();
647
- IndexVector parent(m); parent.setZero();
648
- IndexVector xplore(m); xplore.setZero();
656
+
657
+ // Set up pointers for integer working arrays
658
+ IndexVector segrep(m);
659
+ segrep.setZero();
660
+ IndexVector parent(m);
661
+ parent.setZero();
662
+ IndexVector xplore(m);
663
+ xplore.setZero();
649
664
  IndexVector repfnz(maxpanel);
650
665
  IndexVector panel_lsub(maxpanel);
651
- IndexVector xprune(n); xprune.setZero();
652
- IndexVector marker(m*internal::LUNoMarker); marker.setZero();
653
-
654
- repfnz.setConstant(-1);
666
+ IndexVector xprune(n);
667
+ xprune.setZero();
668
+ IndexVector marker(m * internal::LUNoMarker);
669
+ marker.setZero();
670
+
671
+ repfnz.setConstant(-1);
655
672
  panel_lsub.setConstant(-1);
656
-
657
- // Set up pointers for scalar working arrays
658
- ScalarVector dense;
673
+
674
+ // Set up pointers for scalar working arrays
675
+ ScalarVector dense;
659
676
  dense.setZero(maxpanel);
660
- ScalarVector tempv;
661
- tempv.setZero(internal::LUnumTempV(m, m_perfv.panel_size, m_perfv.maxsuper, /*m_perfv.rowblk*/m) );
662
-
677
+ ScalarVector tempv;
678
+ tempv.setZero(internal::LUnumTempV(m, m_perfv.panel_size, m_perfv.maxsuper, /*m_perfv.rowblk*/ m));
679
+
663
680
  // Compute the inverse of perm_c
664
- PermutationType iperm_c(m_perm_c.inverse());
665
-
681
+ PermutationType iperm_c(m_perm_c.inverse());
682
+
666
683
  // Identify initial relaxed snodes
667
684
  IndexVector relax_end(n);
668
- if ( m_symmetricmode == true )
685
+ if (m_symmetricmode == true)
669
686
  Base::heap_relax_snode(n, m_etree, m_perfv.relax, marker, relax_end);
670
687
  else
671
688
  Base::relax_snode(n, m_etree, m_perfv.relax, marker, relax_end);
672
-
673
-
674
- m_perm_r.resize(m);
689
+
690
+ m_perm_r.resize(m);
675
691
  m_perm_r.indices().setConstant(-1);
676
692
  marker.setConstant(-1);
677
- m_detPermR = 1; // Record the determinant of the row permutation
678
-
679
- m_glu.supno(0) = emptyIdxLU; m_glu.xsup.setConstant(0);
693
+ m_detPermR = 1; // Record the determinant of the row permutation
694
+
695
+ m_glu.supno(0) = emptyIdxLU;
696
+ m_glu.xsup.setConstant(0);
680
697
  m_glu.xsup(0) = m_glu.xlsub(0) = m_glu.xusub(0) = m_glu.xlusup(0) = Index(0);
681
-
698
+
682
699
  // Work on one 'panel' at a time. A panel is one of the following :
683
700
  // (a) a relaxed supernode at the bottom of the etree, or
684
701
  // (b) panel_size contiguous columns, <panel_size> defined by the user
685
- Index jcol;
686
- Index pivrow; // Pivotal row number in the original row matrix
687
- Index nseg1; // Number of segments in U-column above panel row jcol
688
- Index nseg; // Number of segments in each U-column
689
- Index irep;
690
- Index i, k, jj;
691
- for (jcol = 0; jcol < n; )
692
- {
693
- // Adjust panel size so that a panel won't overlap with the next relaxed snode.
694
- Index panel_size = m_perfv.panel_size; // upper bound on panel width
695
- for (k = jcol + 1; k < (std::min)(jcol+panel_size, n); k++)
696
- {
697
- if (relax_end(k) != emptyIdxLU)
698
- {
699
- panel_size = k - jcol;
700
- break;
702
+ Index jcol;
703
+ Index pivrow; // Pivotal row number in the original row matrix
704
+ Index nseg1; // Number of segments in U-column above panel row jcol
705
+ Index nseg; // Number of segments in each U-column
706
+ Index irep;
707
+ Index i, k, jj;
708
+ for (jcol = 0; jcol < n;) {
709
+ // Adjust panel size so that a panel won't overlap with the next relaxed snode.
710
+ Index panel_size = m_perfv.panel_size; // upper bound on panel width
711
+ for (k = jcol + 1; k < (std::min)(jcol + panel_size, n); k++) {
712
+ if (relax_end(k) != emptyIdxLU) {
713
+ panel_size = k - jcol;
714
+ break;
701
715
  }
702
716
  }
703
- if (k == n)
704
- panel_size = n - jcol;
705
-
706
- // Symbolic outer factorization on a panel of columns
707
- Base::panel_dfs(m, panel_size, jcol, m_mat, m_perm_r.indices(), nseg1, dense, panel_lsub, segrep, repfnz, xprune, marker, parent, xplore, m_glu);
708
-
709
- // Numeric sup-panel updates in topological order
710
- Base::panel_bmod(m, panel_size, jcol, nseg1, dense, tempv, segrep, repfnz, m_glu);
711
-
712
- // Sparse LU within the panel, and below the panel diagonal
713
- for ( jj = jcol; jj< jcol + panel_size; jj++)
714
- {
715
- k = (jj - jcol) * m; // Column index for w-wide arrays
716
-
717
- nseg = nseg1; // begin after all the panel segments
718
- //Depth-first-search for the current column
717
+ if (k == n) panel_size = n - jcol;
718
+
719
+ // Symbolic outer factorization on a panel of columns
720
+ Base::panel_dfs(m, panel_size, jcol, m_mat, m_perm_r.indices(), nseg1, dense, panel_lsub, segrep, repfnz, xprune,
721
+ marker, parent, xplore, m_glu);
722
+
723
+ // Numeric sup-panel updates in topological order
724
+ Base::panel_bmod(m, panel_size, jcol, nseg1, dense, tempv, segrep, repfnz, m_glu);
725
+
726
+ // Sparse LU within the panel, and below the panel diagonal
727
+ for (jj = jcol; jj < jcol + panel_size; jj++) {
728
+ k = (jj - jcol) * m; // Column index for w-wide arrays
729
+
730
+ nseg = nseg1; // begin after all the panel segments
731
+ // Depth-first-search for the current column
719
732
  VectorBlock<IndexVector> panel_lsubk(panel_lsub, k, m);
720
- VectorBlock<IndexVector> repfnz_k(repfnz, k, m);
721
- info = Base::column_dfs(m, jj, m_perm_r.indices(), m_perfv.maxsuper, nseg, panel_lsubk, segrep, repfnz_k, xprune, marker, parent, xplore, m_glu);
722
- if ( info )
723
- {
724
- m_lastError = "UNABLE TO EXPAND MEMORY IN COLUMN_DFS() ";
725
- m_info = NumericalIssue;
726
- m_factorizationIsOk = false;
727
- return;
733
+ VectorBlock<IndexVector> repfnz_k(repfnz, k, m);
734
+ // Return 0 on success and > 0 number of bytes allocated when run out of space.
735
+ info = Base::column_dfs(m, jj, m_perm_r.indices(), m_perfv.maxsuper, nseg, panel_lsubk, segrep, repfnz_k, xprune,
736
+ marker, parent, xplore, m_glu);
737
+ if (info) {
738
+ m_lastError = "UNABLE TO EXPAND MEMORY IN COLUMN_DFS() ";
739
+ m_info = NumericalIssue;
740
+ m_factorizationIsOk = false;
741
+ return;
728
742
  }
729
- // Numeric updates to this column
730
- VectorBlock<ScalarVector> dense_k(dense, k, m);
731
- VectorBlock<IndexVector> segrep_k(segrep, nseg1, m-nseg1);
732
- info = Base::column_bmod(jj, (nseg - nseg1), dense_k, tempv, segrep_k, repfnz_k, jcol, m_glu);
733
- if ( info )
734
- {
743
+ // Numeric updates to this column
744
+ VectorBlock<ScalarVector> dense_k(dense, k, m);
745
+ VectorBlock<IndexVector> segrep_k(segrep, nseg1, m - nseg1);
746
+ // Return 0 on success and > 0 number of bytes allocated when run out of space.
747
+ info = Base::column_bmod(jj, (nseg - nseg1), dense_k, tempv, segrep_k, repfnz_k, jcol, m_glu);
748
+ if (info) {
735
749
  m_lastError = "UNABLE TO EXPAND MEMORY IN COLUMN_BMOD() ";
736
- m_info = NumericalIssue;
737
- m_factorizationIsOk = false;
738
- return;
750
+ m_info = NumericalIssue;
751
+ m_factorizationIsOk = false;
752
+ return;
739
753
  }
740
-
754
+
741
755
  // Copy the U-segments to ucol(*)
742
- info = Base::copy_to_ucol(jj, nseg, segrep, repfnz_k ,m_perm_r.indices(), dense_k, m_glu);
743
- if ( info )
744
- {
756
+ // Return 0 on success and > 0 number of bytes allocated when run out of space.
757
+ info = Base::copy_to_ucol(jj, nseg, segrep, repfnz_k, m_perm_r.indices(), dense_k, m_glu);
758
+ if (info) {
745
759
  m_lastError = "UNABLE TO EXPAND MEMORY IN COPY_TO_UCOL() ";
746
- m_info = NumericalIssue;
747
- m_factorizationIsOk = false;
748
- return;
760
+ m_info = NumericalIssue;
761
+ m_factorizationIsOk = false;
762
+ return;
749
763
  }
750
-
751
- // Form the L-segment
764
+
765
+ // Form the L-segment
766
+ // Return O if success, i > 0 if U(i, i) is exactly zero.
752
767
  info = Base::pivotL(jj, m_diagpivotthresh, m_perm_r.indices(), iperm_c.indices(), pivrow, m_glu);
753
- if ( info )
754
- {
755
- m_lastError = "THE MATRIX IS STRUCTURALLY SINGULAR ... ZERO COLUMN AT ";
768
+ if (info) {
769
+ m_lastError = "THE MATRIX IS STRUCTURALLY SINGULAR";
770
+ #ifndef EIGEN_NO_IO
756
771
  std::ostringstream returnInfo;
757
- returnInfo << info;
772
+ returnInfo << " ... ZERO COLUMN AT ";
773
+ returnInfo << info;
758
774
  m_lastError += returnInfo.str();
759
- m_info = NumericalIssue;
760
- m_factorizationIsOk = false;
761
- return;
775
+ #endif
776
+ m_info = NumericalIssue;
777
+ m_factorizationIsOk = false;
778
+ return;
762
779
  }
763
-
780
+
764
781
  // Update the determinant of the row permutation matrix
765
- // FIXME: the following test is not correct, we should probably take iperm_c into account and pivrow is not directly the row pivot.
782
+ // FIXME: the following test is not correct, we should probably take iperm_c into account and pivrow is not
783
+ // directly the row pivot.
766
784
  if (pivrow != jj) m_detPermR = -m_detPermR;
767
785
 
768
786
  // Prune columns (0:jj-1) using column jj
769
- Base::pruneL(jj, m_perm_r.indices(), pivrow, nseg, segrep, repfnz_k, xprune, m_glu);
770
-
771
- // Reset repfnz for this column
772
- for (i = 0; i < nseg; i++)
773
- {
774
- irep = segrep(i);
775
- repfnz_k(irep) = emptyIdxLU;
787
+ Base::pruneL(jj, m_perm_r.indices(), pivrow, nseg, segrep, repfnz_k, xprune, m_glu);
788
+
789
+ // Reset repfnz for this column
790
+ for (i = 0; i < nseg; i++) {
791
+ irep = segrep(i);
792
+ repfnz_k(irep) = emptyIdxLU;
776
793
  }
777
- } // end SparseLU within the panel
794
+ } // end SparseLU within the panel
778
795
  jcol += panel_size; // Move to the next panel
779
- } // end for -- end elimination
780
-
796
+ } // end for -- end elimination
797
+
781
798
  m_detPermR = m_perm_r.determinant();
782
799
  m_detPermC = m_perm_c.determinant();
783
-
784
- // Count the number of nonzeros in factors
785
- Base::countnz(n, m_nnzL, m_nnzU, m_glu);
786
- // Apply permutation to the L subscripts
800
+
801
+ // Count the number of nonzeros in factors
802
+ Base::countnz(n, m_nnzL, m_nnzU, m_glu);
803
+ // Apply permutation to the L subscripts
787
804
  Base::fixupL(n, m_perm_r.indices(), m_glu);
788
-
789
- // Create supernode matrix L
790
- m_Lstore.setInfos(m, n, m_glu.lusup, m_glu.xlusup, m_glu.lsub, m_glu.xlsub, m_glu.supno, m_glu.xsup);
791
- // Create the column major upper sparse matrix U;
792
- new (&m_Ustore) MappedSparseMatrix<Scalar, ColMajor, StorageIndex> ( m, n, m_nnzU, m_glu.xusub.data(), m_glu.usub.data(), m_glu.ucol.data() );
793
-
805
+
806
+ // Create supernode matrix L
807
+ m_Lstore.setInfos(m, n, m_glu.lusup, m_glu.xlusup, m_glu.lsub, m_glu.xlsub, m_glu.supno, m_glu.xsup);
808
+ // Create the column major upper sparse matrix U;
809
+ new (&m_Ustore) Map<SparseMatrix<Scalar, ColMajor, StorageIndex>>(m, n, m_nnzU, m_glu.xusub.data(), m_glu.usub.data(),
810
+ m_glu.ucol.data());
811
+
794
812
  m_info = Success;
795
813
  m_factorizationIsOk = true;
796
814
  }
797
815
 
798
- template<typename MappedSupernodalType>
799
- struct SparseLUMatrixLReturnType : internal::no_assignment_operator
800
- {
816
+ template <typename MappedSupernodalType>
817
+ struct SparseLUMatrixLReturnType : internal::no_assignment_operator {
801
818
  typedef typename MappedSupernodalType::Scalar Scalar;
802
- explicit SparseLUMatrixLReturnType(const MappedSupernodalType& mapL) : m_mapL(mapL)
803
- { }
819
+ explicit SparseLUMatrixLReturnType(const MappedSupernodalType& mapL) : m_mapL(mapL) {}
804
820
  Index rows() const { return m_mapL.rows(); }
805
821
  Index cols() const { return m_mapL.cols(); }
806
- template<typename Dest>
807
- void solveInPlace( MatrixBase<Dest> &X) const
808
- {
822
+ template <typename Dest>
823
+ void solveInPlace(MatrixBase<Dest>& X) const {
809
824
  m_mapL.solveInPlace(X);
810
825
  }
811
- template<bool Conjugate, typename Dest>
812
- void solveTransposedInPlace( MatrixBase<Dest> &X) const
813
- {
826
+ template <bool Conjugate, typename Dest>
827
+ void solveTransposedInPlace(MatrixBase<Dest>& X) const {
814
828
  m_mapL.template solveTransposedInPlace<Conjugate>(X);
815
829
  }
816
830
 
831
+ SparseMatrix<Scalar, ColMajor, Index> toSparse() const {
832
+ ArrayXi colCount = ArrayXi::Ones(cols());
833
+ for (Index i = 0; i < cols(); i++) {
834
+ typename MappedSupernodalType::InnerIterator iter(m_mapL, i);
835
+ for (; iter; ++iter) {
836
+ if (iter.row() > iter.col()) {
837
+ colCount(iter.col())++;
838
+ }
839
+ }
840
+ }
841
+ SparseMatrix<Scalar, ColMajor, Index> sL(rows(), cols());
842
+ sL.reserve(colCount);
843
+ for (Index i = 0; i < cols(); i++) {
844
+ sL.insert(i, i) = 1.0;
845
+ typename MappedSupernodalType::InnerIterator iter(m_mapL, i);
846
+ for (; iter; ++iter) {
847
+ if (iter.row() > iter.col()) {
848
+ sL.insert(iter.row(), iter.col()) = iter.value();
849
+ }
850
+ }
851
+ }
852
+ sL.makeCompressed();
853
+ return sL;
854
+ }
855
+
817
856
  const MappedSupernodalType& m_mapL;
818
857
  };
819
858
 
820
- template<typename MatrixLType, typename MatrixUType>
821
- struct SparseLUMatrixUReturnType : internal::no_assignment_operator
822
- {
859
+ template <typename MatrixLType, typename MatrixUType>
860
+ struct SparseLUMatrixUReturnType : internal::no_assignment_operator {
823
861
  typedef typename MatrixLType::Scalar Scalar;
824
- SparseLUMatrixUReturnType(const MatrixLType& mapL, const MatrixUType& mapU)
825
- : m_mapL(mapL),m_mapU(mapU)
826
- { }
862
+ SparseLUMatrixUReturnType(const MatrixLType& mapL, const MatrixUType& mapU) : m_mapL(mapL), m_mapU(mapU) {}
827
863
  Index rows() const { return m_mapL.rows(); }
828
864
  Index cols() const { return m_mapL.cols(); }
829
865
 
830
- template<typename Dest> void solveInPlace(MatrixBase<Dest> &X) const
831
- {
866
+ template <typename Dest>
867
+ void solveInPlace(MatrixBase<Dest>& X) const {
832
868
  Index nrhs = X.cols();
833
- Index n = X.rows();
834
869
  // Backward solve with U
835
- for (Index k = m_mapL.nsuper(); k >= 0; k--)
836
- {
870
+ for (Index k = m_mapL.nsuper(); k >= 0; k--) {
837
871
  Index fsupc = m_mapL.supToCol()[k];
838
- Index lda = m_mapL.colIndexPtr()[fsupc+1] - m_mapL.colIndexPtr()[fsupc]; // leading dimension
839
- Index nsupc = m_mapL.supToCol()[k+1] - fsupc;
872
+ Index lda = m_mapL.colIndexPtr()[fsupc + 1] - m_mapL.colIndexPtr()[fsupc]; // leading dimension
873
+ Index nsupc = m_mapL.supToCol()[k + 1] - fsupc;
840
874
  Index luptr = m_mapL.colIndexPtr()[fsupc];
841
875
 
842
- if (nsupc == 1)
843
- {
844
- for (Index j = 0; j < nrhs; j++)
845
- {
876
+ if (nsupc == 1) {
877
+ for (Index j = 0; j < nrhs; j++) {
846
878
  X(fsupc, j) /= m_mapL.valuePtr()[luptr];
847
879
  }
848
- }
849
- else
850
- {
880
+ } else {
851
881
  // FIXME: the following lines should use Block expressions and not Map!
852
- Map<const Matrix<Scalar,Dynamic,Dynamic, ColMajor>, 0, OuterStride<> > A( &(m_mapL.valuePtr()[luptr]), nsupc, nsupc, OuterStride<>(lda) );
853
- Map< Matrix<Scalar,Dynamic,Dest::ColsAtCompileTime, ColMajor>, 0, OuterStride<> > U (&(X.coeffRef(fsupc,0)), nsupc, nrhs, OuterStride<>(n) );
882
+ Map<const Matrix<Scalar, Dynamic, Dynamic, ColMajor>, 0, OuterStride<>> A(&(m_mapL.valuePtr()[luptr]), nsupc,
883
+ nsupc, OuterStride<>(lda));
884
+ typename Dest::RowsBlockXpr U = X.derived().middleRows(fsupc, nsupc);
854
885
  U = A.template triangularView<Upper>().solve(U);
855
886
  }
856
887
 
857
- for (Index j = 0; j < nrhs; ++j)
858
- {
859
- for (Index jcol = fsupc; jcol < fsupc + nsupc; jcol++)
860
- {
888
+ for (Index j = 0; j < nrhs; ++j) {
889
+ for (Index jcol = fsupc; jcol < fsupc + nsupc; jcol++) {
861
890
  typename MatrixUType::InnerIterator it(m_mapU, jcol);
862
- for ( ; it; ++it)
863
- {
891
+ for (; it; ++it) {
864
892
  Index irow = it.index();
865
893
  X(irow, j) -= X(jcol, j) * it.value();
866
894
  }
867
895
  }
868
896
  }
869
- } // End For U-solve
897
+ } // End For U-solve
870
898
  }
871
899
 
872
- template<bool Conjugate, typename Dest> void solveTransposedInPlace(MatrixBase<Dest> &X) const
873
- {
900
+ template <bool Conjugate, typename Dest>
901
+ void solveTransposedInPlace(MatrixBase<Dest>& X) const {
874
902
  using numext::conj;
875
903
  Index nrhs = X.cols();
876
- Index n = X.rows();
877
904
  // Forward solve with U
878
- for (Index k = 0; k <= m_mapL.nsuper(); k++)
879
- {
905
+ for (Index k = 0; k <= m_mapL.nsuper(); k++) {
880
906
  Index fsupc = m_mapL.supToCol()[k];
881
- Index lda = m_mapL.colIndexPtr()[fsupc+1] - m_mapL.colIndexPtr()[fsupc]; // leading dimension
882
- Index nsupc = m_mapL.supToCol()[k+1] - fsupc;
907
+ Index lda = m_mapL.colIndexPtr()[fsupc + 1] - m_mapL.colIndexPtr()[fsupc]; // leading dimension
908
+ Index nsupc = m_mapL.supToCol()[k + 1] - fsupc;
883
909
  Index luptr = m_mapL.colIndexPtr()[fsupc];
884
910
 
885
- for (Index j = 0; j < nrhs; ++j)
886
- {
887
- for (Index jcol = fsupc; jcol < fsupc + nsupc; jcol++)
888
- {
911
+ for (Index j = 0; j < nrhs; ++j) {
912
+ for (Index jcol = fsupc; jcol < fsupc + nsupc; jcol++) {
889
913
  typename MatrixUType::InnerIterator it(m_mapU, jcol);
890
- for ( ; it; ++it)
891
- {
914
+ for (; it; ++it) {
892
915
  Index irow = it.index();
893
- X(jcol, j) -= X(irow, j) * (Conjugate? conj(it.value()): it.value());
916
+ X(jcol, j) -= X(irow, j) * (Conjugate ? conj(it.value()) : it.value());
894
917
  }
895
918
  }
896
919
  }
897
- if (nsupc == 1)
898
- {
899
- for (Index j = 0; j < nrhs; j++)
900
- {
901
- X(fsupc, j) /= (Conjugate? conj(m_mapL.valuePtr()[luptr]) : m_mapL.valuePtr()[luptr]);
920
+ if (nsupc == 1) {
921
+ for (Index j = 0; j < nrhs; j++) {
922
+ X(fsupc, j) /= (Conjugate ? conj(m_mapL.valuePtr()[luptr]) : m_mapL.valuePtr()[luptr]);
902
923
  }
903
- }
904
- else
905
- {
906
- Map<const Matrix<Scalar,Dynamic,Dynamic, ColMajor>, 0, OuterStride<> > A( &(m_mapL.valuePtr()[luptr]), nsupc, nsupc, OuterStride<>(lda) );
907
- Map< Matrix<Scalar,Dynamic,Dest::ColsAtCompileTime, ColMajor>, 0, OuterStride<> > U (&(X(fsupc,0)), nsupc, nrhs, OuterStride<>(n) );
908
- if(Conjugate)
924
+ } else {
925
+ Map<const Matrix<Scalar, Dynamic, Dynamic, ColMajor>, 0, OuterStride<>> A(&(m_mapL.valuePtr()[luptr]), nsupc,
926
+ nsupc, OuterStride<>(lda));
927
+ typename Dest::RowsBlockXpr U = X.derived().middleRows(fsupc, nsupc);
928
+ if (Conjugate)
909
929
  U = A.adjoint().template triangularView<Lower>().solve(U);
910
930
  else
911
931
  U = A.transpose().template triangularView<Lower>().solve(U);
912
932
  }
913
- }// End For U-solve
933
+ } // End For U-solve
914
934
  }
915
935
 
936
+ SparseMatrix<Scalar, RowMajor, Index> toSparse() {
937
+ ArrayXi rowCount = ArrayXi::Zero(rows());
938
+ for (Index i = 0; i < cols(); i++) {
939
+ typename MatrixLType::InnerIterator iter(m_mapL, i);
940
+ for (; iter; ++iter) {
941
+ if (iter.row() <= iter.col()) {
942
+ rowCount(iter.row())++;
943
+ }
944
+ }
945
+ }
946
+
947
+ SparseMatrix<Scalar, RowMajor, Index> sU(rows(), cols());
948
+ sU.reserve(rowCount);
949
+ for (Index i = 0; i < cols(); i++) {
950
+ typename MatrixLType::InnerIterator iter(m_mapL, i);
951
+ for (; iter; ++iter) {
952
+ if (iter.row() <= iter.col()) {
953
+ sU.insert(iter.row(), iter.col()) = iter.value();
954
+ }
955
+ }
956
+ }
957
+ sU.makeCompressed();
958
+ const SparseMatrix<Scalar, RowMajor, Index> u = m_mapU; // convert to RowMajor
959
+ sU += u;
960
+ return sU;
961
+ }
916
962
 
917
963
  const MatrixLType& m_mapL;
918
964
  const MatrixUType& m_mapU;
919
965
  };
920
966
 
921
- } // End namespace Eigen
967
+ } // End namespace Eigen
922
968
 
923
969
  #endif