@smake/eigen 1.0.2 → 1.1.1

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