ruby-eigen 0.0.9 → 0.0.10.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (293) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +22 -0
  3. data/README.md +21 -0
  4. data/ext/eigen/eigen3/COPYING.BSD +26 -0
  5. data/ext/eigen/eigen3/COPYING.MPL2 +373 -0
  6. data/ext/eigen/eigen3/COPYING.README +18 -0
  7. data/ext/eigen/eigen3/Eigen/Array +11 -0
  8. data/ext/eigen/eigen3/Eigen/Cholesky +32 -0
  9. data/ext/eigen/eigen3/Eigen/CholmodSupport +45 -0
  10. data/ext/eigen/eigen3/Eigen/Core +376 -0
  11. data/ext/eigen/eigen3/Eigen/Dense +7 -0
  12. data/ext/eigen/eigen3/Eigen/Eigen +2 -0
  13. data/ext/eigen/eigen3/Eigen/Eigen2Support +95 -0
  14. data/ext/eigen/eigen3/Eigen/Eigenvalues +48 -0
  15. data/ext/eigen/eigen3/Eigen/Geometry +63 -0
  16. data/ext/eigen/eigen3/Eigen/Householder +23 -0
  17. data/ext/eigen/eigen3/Eigen/IterativeLinearSolvers +40 -0
  18. data/ext/eigen/eigen3/Eigen/Jacobi +26 -0
  19. data/ext/eigen/eigen3/Eigen/LU +41 -0
  20. data/ext/eigen/eigen3/Eigen/LeastSquares +32 -0
  21. data/ext/eigen/eigen3/Eigen/MetisSupport +28 -0
  22. data/ext/eigen/eigen3/Eigen/PaStiXSupport +46 -0
  23. data/ext/eigen/eigen3/Eigen/PardisoSupport +30 -0
  24. data/ext/eigen/eigen3/Eigen/QR +45 -0
  25. data/ext/eigen/eigen3/Eigen/QtAlignedMalloc +34 -0
  26. data/ext/eigen/eigen3/Eigen/SPQRSupport +29 -0
  27. data/ext/eigen/eigen3/Eigen/SVD +37 -0
  28. data/ext/eigen/eigen3/Eigen/Sparse +27 -0
  29. data/ext/eigen/eigen3/Eigen/SparseCore +64 -0
  30. data/ext/eigen/eigen3/Eigen/SparseLU +49 -0
  31. data/ext/eigen/eigen3/Eigen/SparseQR +33 -0
  32. data/ext/eigen/eigen3/Eigen/StdDeque +27 -0
  33. data/ext/eigen/eigen3/Eigen/StdList +26 -0
  34. data/ext/eigen/eigen3/Eigen/StdVector +27 -0
  35. data/ext/eigen/eigen3/Eigen/SuperLUSupport +59 -0
  36. data/ext/eigen/eigen3/Eigen/UmfPackSupport +36 -0
  37. data/ext/eigen/eigen3/Eigen/src/Cholesky/LDLT.h +611 -0
  38. data/ext/eigen/eigen3/Eigen/src/Cholesky/LLT.h +498 -0
  39. data/ext/eigen/eigen3/Eigen/src/Cholesky/LLT_MKL.h +102 -0
  40. data/ext/eigen/eigen3/Eigen/src/CholmodSupport/CholmodSupport.h +607 -0
  41. data/ext/eigen/eigen3/Eigen/src/Core/Array.h +323 -0
  42. data/ext/eigen/eigen3/Eigen/src/Core/ArrayBase.h +226 -0
  43. data/ext/eigen/eigen3/Eigen/src/Core/ArrayWrapper.h +264 -0
  44. data/ext/eigen/eigen3/Eigen/src/Core/Assign.h +590 -0
  45. data/ext/eigen/eigen3/Eigen/src/Core/Assign_MKL.h +224 -0
  46. data/ext/eigen/eigen3/Eigen/src/Core/BandMatrix.h +334 -0
  47. data/ext/eigen/eigen3/Eigen/src/Core/Block.h +406 -0
  48. data/ext/eigen/eigen3/Eigen/src/Core/BooleanRedux.h +154 -0
  49. data/ext/eigen/eigen3/Eigen/src/Core/CommaInitializer.h +154 -0
  50. data/ext/eigen/eigen3/Eigen/src/Core/CoreIterators.h +61 -0
  51. data/ext/eigen/eigen3/Eigen/src/Core/CwiseBinaryOp.h +230 -0
  52. data/ext/eigen/eigen3/Eigen/src/Core/CwiseNullaryOp.h +864 -0
  53. data/ext/eigen/eigen3/Eigen/src/Core/CwiseUnaryOp.h +126 -0
  54. data/ext/eigen/eigen3/Eigen/src/Core/CwiseUnaryView.h +139 -0
  55. data/ext/eigen/eigen3/Eigen/src/Core/DenseBase.h +521 -0
  56. data/ext/eigen/eigen3/Eigen/src/Core/DenseCoeffsBase.h +754 -0
  57. data/ext/eigen/eigen3/Eigen/src/Core/DenseStorage.h +434 -0
  58. data/ext/eigen/eigen3/Eigen/src/Core/Diagonal.h +237 -0
  59. data/ext/eigen/eigen3/Eigen/src/Core/DiagonalMatrix.h +313 -0
  60. data/ext/eigen/eigen3/Eigen/src/Core/DiagonalProduct.h +131 -0
  61. data/ext/eigen/eigen3/Eigen/src/Core/Dot.h +263 -0
  62. data/ext/eigen/eigen3/Eigen/src/Core/EigenBase.h +131 -0
  63. data/ext/eigen/eigen3/Eigen/src/Core/Flagged.h +140 -0
  64. data/ext/eigen/eigen3/Eigen/src/Core/ForceAlignedAccess.h +146 -0
  65. data/ext/eigen/eigen3/Eigen/src/Core/Functors.h +1026 -0
  66. data/ext/eigen/eigen3/Eigen/src/Core/Fuzzy.h +150 -0
  67. data/ext/eigen/eigen3/Eigen/src/Core/GeneralProduct.h +635 -0
  68. data/ext/eigen/eigen3/Eigen/src/Core/GenericPacketMath.h +350 -0
  69. data/ext/eigen/eigen3/Eigen/src/Core/GlobalFunctions.h +92 -0
  70. data/ext/eigen/eigen3/Eigen/src/Core/IO.h +250 -0
  71. data/ext/eigen/eigen3/Eigen/src/Core/Map.h +192 -0
  72. data/ext/eigen/eigen3/Eigen/src/Core/MapBase.h +247 -0
  73. data/ext/eigen/eigen3/Eigen/src/Core/MathFunctions.h +768 -0
  74. data/ext/eigen/eigen3/Eigen/src/Core/Matrix.h +420 -0
  75. data/ext/eigen/eigen3/Eigen/src/Core/MatrixBase.h +563 -0
  76. data/ext/eigen/eigen3/Eigen/src/Core/NestByValue.h +111 -0
  77. data/ext/eigen/eigen3/Eigen/src/Core/NoAlias.h +134 -0
  78. data/ext/eigen/eigen3/Eigen/src/Core/NumTraits.h +150 -0
  79. data/ext/eigen/eigen3/Eigen/src/Core/PermutationMatrix.h +721 -0
  80. data/ext/eigen/eigen3/Eigen/src/Core/PlainObjectBase.h +822 -0
  81. data/ext/eigen/eigen3/Eigen/src/Core/ProductBase.h +290 -0
  82. data/ext/eigen/eigen3/Eigen/src/Core/Random.h +152 -0
  83. data/ext/eigen/eigen3/Eigen/src/Core/Redux.h +409 -0
  84. data/ext/eigen/eigen3/Eigen/src/Core/Ref.h +278 -0
  85. data/ext/eigen/eigen3/Eigen/src/Core/Replicate.h +177 -0
  86. data/ext/eigen/eigen3/Eigen/src/Core/ReturnByValue.h +99 -0
  87. data/ext/eigen/eigen3/Eigen/src/Core/Reverse.h +224 -0
  88. data/ext/eigen/eigen3/Eigen/src/Core/Select.h +162 -0
  89. data/ext/eigen/eigen3/Eigen/src/Core/SelfAdjointView.h +314 -0
  90. data/ext/eigen/eigen3/Eigen/src/Core/SelfCwiseBinaryOp.h +191 -0
  91. data/ext/eigen/eigen3/Eigen/src/Core/SolveTriangular.h +260 -0
  92. data/ext/eigen/eigen3/Eigen/src/Core/StableNorm.h +203 -0
  93. data/ext/eigen/eigen3/Eigen/src/Core/Stride.h +108 -0
  94. data/ext/eigen/eigen3/Eigen/src/Core/Swap.h +126 -0
  95. data/ext/eigen/eigen3/Eigen/src/Core/Transpose.h +419 -0
  96. data/ext/eigen/eigen3/Eigen/src/Core/Transpositions.h +436 -0
  97. data/ext/eigen/eigen3/Eigen/src/Core/TriangularMatrix.h +839 -0
  98. data/ext/eigen/eigen3/Eigen/src/Core/VectorBlock.h +95 -0
  99. data/ext/eigen/eigen3/Eigen/src/Core/VectorwiseOp.h +642 -0
  100. data/ext/eigen/eigen3/Eigen/src/Core/Visitor.h +237 -0
  101. data/ext/eigen/eigen3/Eigen/src/Core/arch/AltiVec/Complex.h +217 -0
  102. data/ext/eigen/eigen3/Eigen/src/Core/arch/AltiVec/PacketMath.h +501 -0
  103. data/ext/eigen/eigen3/Eigen/src/Core/arch/Default/Settings.h +49 -0
  104. data/ext/eigen/eigen3/Eigen/src/Core/arch/NEON/Complex.h +253 -0
  105. data/ext/eigen/eigen3/Eigen/src/Core/arch/NEON/PacketMath.h +420 -0
  106. data/ext/eigen/eigen3/Eigen/src/Core/arch/SSE/Complex.h +442 -0
  107. data/ext/eigen/eigen3/Eigen/src/Core/arch/SSE/MathFunctions.h +475 -0
  108. data/ext/eigen/eigen3/Eigen/src/Core/arch/SSE/PacketMath.h +649 -0
  109. data/ext/eigen/eigen3/Eigen/src/Core/products/CoeffBasedProduct.h +476 -0
  110. data/ext/eigen/eigen3/Eigen/src/Core/products/GeneralBlockPanelKernel.h +1341 -0
  111. data/ext/eigen/eigen3/Eigen/src/Core/products/GeneralMatrixMatrix.h +427 -0
  112. data/ext/eigen/eigen3/Eigen/src/Core/products/GeneralMatrixMatrixTriangular.h +278 -0
  113. data/ext/eigen/eigen3/Eigen/src/Core/products/GeneralMatrixMatrixTriangular_MKL.h +146 -0
  114. data/ext/eigen/eigen3/Eigen/src/Core/products/GeneralMatrixMatrix_MKL.h +118 -0
  115. data/ext/eigen/eigen3/Eigen/src/Core/products/GeneralMatrixVector.h +566 -0
  116. data/ext/eigen/eigen3/Eigen/src/Core/products/GeneralMatrixVector_MKL.h +131 -0
  117. data/ext/eigen/eigen3/Eigen/src/Core/products/Parallelizer.h +162 -0
  118. data/ext/eigen/eigen3/Eigen/src/Core/products/SelfadjointMatrixMatrix.h +436 -0
  119. data/ext/eigen/eigen3/Eigen/src/Core/products/SelfadjointMatrixMatrix_MKL.h +295 -0
  120. data/ext/eigen/eigen3/Eigen/src/Core/products/SelfadjointMatrixVector.h +281 -0
  121. data/ext/eigen/eigen3/Eigen/src/Core/products/SelfadjointMatrixVector_MKL.h +114 -0
  122. data/ext/eigen/eigen3/Eigen/src/Core/products/SelfadjointProduct.h +123 -0
  123. data/ext/eigen/eigen3/Eigen/src/Core/products/SelfadjointRank2Update.h +93 -0
  124. data/ext/eigen/eigen3/Eigen/src/Core/products/TriangularMatrixMatrix.h +427 -0
  125. data/ext/eigen/eigen3/Eigen/src/Core/products/TriangularMatrixMatrix_MKL.h +309 -0
  126. data/ext/eigen/eigen3/Eigen/src/Core/products/TriangularMatrixVector.h +348 -0
  127. data/ext/eigen/eigen3/Eigen/src/Core/products/TriangularMatrixVector_MKL.h +247 -0
  128. data/ext/eigen/eigen3/Eigen/src/Core/products/TriangularSolverMatrix.h +332 -0
  129. data/ext/eigen/eigen3/Eigen/src/Core/products/TriangularSolverMatrix_MKL.h +155 -0
  130. data/ext/eigen/eigen3/Eigen/src/Core/products/TriangularSolverVector.h +139 -0
  131. data/ext/eigen/eigen3/Eigen/src/Core/util/BlasUtil.h +264 -0
  132. data/ext/eigen/eigen3/Eigen/src/Core/util/Constants.h +451 -0
  133. data/ext/eigen/eigen3/Eigen/src/Core/util/DisableStupidWarnings.h +40 -0
  134. data/ext/eigen/eigen3/Eigen/src/Core/util/ForwardDeclarations.h +302 -0
  135. data/ext/eigen/eigen3/Eigen/src/Core/util/MKL_support.h +158 -0
  136. data/ext/eigen/eigen3/Eigen/src/Core/util/Macros.h +451 -0
  137. data/ext/eigen/eigen3/Eigen/src/Core/util/Memory.h +977 -0
  138. data/ext/eigen/eigen3/Eigen/src/Core/util/Meta.h +243 -0
  139. data/ext/eigen/eigen3/Eigen/src/Core/util/NonMPL2.h +3 -0
  140. data/ext/eigen/eigen3/Eigen/src/Core/util/ReenableStupidWarnings.h +14 -0
  141. data/ext/eigen/eigen3/Eigen/src/Core/util/StaticAssert.h +208 -0
  142. data/ext/eigen/eigen3/Eigen/src/Core/util/XprHelper.h +469 -0
  143. data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Block.h +126 -0
  144. data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Cwise.h +192 -0
  145. data/ext/eigen/eigen3/Eigen/src/Eigen2Support/CwiseOperators.h +298 -0
  146. data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/AlignedBox.h +159 -0
  147. data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/All.h +115 -0
  148. data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/AngleAxis.h +214 -0
  149. data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/Hyperplane.h +254 -0
  150. data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/ParametrizedLine.h +141 -0
  151. data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/Quaternion.h +495 -0
  152. data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/Rotation2D.h +145 -0
  153. data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/RotationBase.h +123 -0
  154. data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/Scaling.h +167 -0
  155. data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/Transform.h +786 -0
  156. data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/Translation.h +184 -0
  157. data/ext/eigen/eigen3/Eigen/src/Eigen2Support/LU.h +120 -0
  158. data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Lazy.h +71 -0
  159. data/ext/eigen/eigen3/Eigen/src/Eigen2Support/LeastSquares.h +169 -0
  160. data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Macros.h +20 -0
  161. data/ext/eigen/eigen3/Eigen/src/Eigen2Support/MathFunctions.h +57 -0
  162. data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Memory.h +45 -0
  163. data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Meta.h +75 -0
  164. data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Minor.h +117 -0
  165. data/ext/eigen/eigen3/Eigen/src/Eigen2Support/QR.h +67 -0
  166. data/ext/eigen/eigen3/Eigen/src/Eigen2Support/SVD.h +637 -0
  167. data/ext/eigen/eigen3/Eigen/src/Eigen2Support/TriangularSolver.h +42 -0
  168. data/ext/eigen/eigen3/Eigen/src/Eigen2Support/VectorBlock.h +94 -0
  169. data/ext/eigen/eigen3/Eigen/src/Eigenvalues/ComplexEigenSolver.h +341 -0
  170. data/ext/eigen/eigen3/Eigen/src/Eigenvalues/ComplexSchur.h +456 -0
  171. data/ext/eigen/eigen3/Eigen/src/Eigenvalues/ComplexSchur_MKL.h +94 -0
  172. data/ext/eigen/eigen3/Eigen/src/Eigenvalues/EigenSolver.h +607 -0
  173. data/ext/eigen/eigen3/Eigen/src/Eigenvalues/GeneralizedEigenSolver.h +350 -0
  174. data/ext/eigen/eigen3/Eigen/src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h +227 -0
  175. data/ext/eigen/eigen3/Eigen/src/Eigenvalues/HessenbergDecomposition.h +373 -0
  176. data/ext/eigen/eigen3/Eigen/src/Eigenvalues/MatrixBaseEigenvalues.h +160 -0
  177. data/ext/eigen/eigen3/Eigen/src/Eigenvalues/RealQZ.h +624 -0
  178. data/ext/eigen/eigen3/Eigen/src/Eigenvalues/RealSchur.h +525 -0
  179. data/ext/eigen/eigen3/Eigen/src/Eigenvalues/RealSchur_MKL.h +83 -0
  180. data/ext/eigen/eigen3/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h +801 -0
  181. data/ext/eigen/eigen3/Eigen/src/Eigenvalues/SelfAdjointEigenSolver_MKL.h +92 -0
  182. data/ext/eigen/eigen3/Eigen/src/Eigenvalues/Tridiagonalization.h +557 -0
  183. data/ext/eigen/eigen3/Eigen/src/Geometry/AlignedBox.h +392 -0
  184. data/ext/eigen/eigen3/Eigen/src/Geometry/AngleAxis.h +233 -0
  185. data/ext/eigen/eigen3/Eigen/src/Geometry/EulerAngles.h +104 -0
  186. data/ext/eigen/eigen3/Eigen/src/Geometry/Homogeneous.h +307 -0
  187. data/ext/eigen/eigen3/Eigen/src/Geometry/Hyperplane.h +280 -0
  188. data/ext/eigen/eigen3/Eigen/src/Geometry/OrthoMethods.h +218 -0
  189. data/ext/eigen/eigen3/Eigen/src/Geometry/ParametrizedLine.h +195 -0
  190. data/ext/eigen/eigen3/Eigen/src/Geometry/Quaternion.h +776 -0
  191. data/ext/eigen/eigen3/Eigen/src/Geometry/Rotation2D.h +160 -0
  192. data/ext/eigen/eigen3/Eigen/src/Geometry/RotationBase.h +206 -0
  193. data/ext/eigen/eigen3/Eigen/src/Geometry/Scaling.h +166 -0
  194. data/ext/eigen/eigen3/Eigen/src/Geometry/Transform.h +1455 -0
  195. data/ext/eigen/eigen3/Eigen/src/Geometry/Translation.h +206 -0
  196. data/ext/eigen/eigen3/Eigen/src/Geometry/Umeyama.h +177 -0
  197. data/ext/eigen/eigen3/Eigen/src/Geometry/arch/Geometry_SSE.h +115 -0
  198. data/ext/eigen/eigen3/Eigen/src/Householder/BlockHouseholder.h +68 -0
  199. data/ext/eigen/eigen3/Eigen/src/Householder/Householder.h +171 -0
  200. data/ext/eigen/eigen3/Eigen/src/Householder/HouseholderSequence.h +441 -0
  201. data/ext/eigen/eigen3/Eigen/src/IterativeLinearSolvers/BasicPreconditioners.h +149 -0
  202. data/ext/eigen/eigen3/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h +263 -0
  203. data/ext/eigen/eigen3/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h +256 -0
  204. data/ext/eigen/eigen3/Eigen/src/IterativeLinearSolvers/IterativeSolverBase.h +282 -0
  205. data/ext/eigen/eigen3/Eigen/src/Jacobi/Jacobi.h +433 -0
  206. data/ext/eigen/eigen3/Eigen/src/LU/Determinant.h +101 -0
  207. data/ext/eigen/eigen3/Eigen/src/LU/FullPivLU.h +751 -0
  208. data/ext/eigen/eigen3/Eigen/src/LU/Inverse.h +400 -0
  209. data/ext/eigen/eigen3/Eigen/src/LU/PartialPivLU.h +509 -0
  210. data/ext/eigen/eigen3/Eigen/src/LU/PartialPivLU_MKL.h +85 -0
  211. data/ext/eigen/eigen3/Eigen/src/LU/arch/Inverse_SSE.h +329 -0
  212. data/ext/eigen/eigen3/Eigen/src/MetisSupport/MetisSupport.h +137 -0
  213. data/ext/eigen/eigen3/Eigen/src/OrderingMethods/Amd.h +444 -0
  214. data/ext/eigen/eigen3/Eigen/src/OrderingMethods/Eigen_Colamd.h +1850 -0
  215. data/ext/eigen/eigen3/Eigen/src/PaStiXSupport/PaStiXSupport.h +721 -0
  216. data/ext/eigen/eigen3/Eigen/src/PardisoSupport/PardisoSupport.h +592 -0
  217. data/ext/eigen/eigen3/Eigen/src/QR/ColPivHouseholderQR.h +580 -0
  218. data/ext/eigen/eigen3/Eigen/src/QR/ColPivHouseholderQR_MKL.h +99 -0
  219. data/ext/eigen/eigen3/Eigen/src/QR/FullPivHouseholderQR.h +622 -0
  220. data/ext/eigen/eigen3/Eigen/src/QR/HouseholderQR.h +388 -0
  221. data/ext/eigen/eigen3/Eigen/src/QR/HouseholderQR_MKL.h +71 -0
  222. data/ext/eigen/eigen3/Eigen/src/SPQRSupport/SuiteSparseQRSupport.h +338 -0
  223. data/ext/eigen/eigen3/Eigen/src/SVD/JacobiSVD.h +976 -0
  224. data/ext/eigen/eigen3/Eigen/src/SVD/JacobiSVD_MKL.h +92 -0
  225. data/ext/eigen/eigen3/Eigen/src/SVD/UpperBidiagonalization.h +148 -0
  226. data/ext/eigen/eigen3/Eigen/src/SparseCholesky/SimplicialCholesky.h +671 -0
  227. data/ext/eigen/eigen3/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h +199 -0
  228. data/ext/eigen/eigen3/Eigen/src/SparseCore/AmbiVector.h +373 -0
  229. data/ext/eigen/eigen3/Eigen/src/SparseCore/CompressedStorage.h +233 -0
  230. data/ext/eigen/eigen3/Eigen/src/SparseCore/ConservativeSparseSparseProduct.h +245 -0
  231. data/ext/eigen/eigen3/Eigen/src/SparseCore/MappedSparseMatrix.h +181 -0
  232. data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseBlock.h +537 -0
  233. data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseColEtree.h +206 -0
  234. data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseCwiseBinaryOp.h +325 -0
  235. data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseCwiseUnaryOp.h +163 -0
  236. data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseDenseProduct.h +311 -0
  237. data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseDiagonalProduct.h +196 -0
  238. data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseDot.h +101 -0
  239. data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseFuzzy.h +26 -0
  240. data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseMatrix.h +1262 -0
  241. data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseMatrixBase.h +461 -0
  242. data/ext/eigen/eigen3/Eigen/src/SparseCore/SparsePermutation.h +148 -0
  243. data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseProduct.h +188 -0
  244. data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseRedux.h +45 -0
  245. data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseSelfAdjointView.h +507 -0
  246. data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseSparseProductWithPruning.h +150 -0
  247. data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseTranspose.h +63 -0
  248. data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseTriangularView.h +179 -0
  249. data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseUtil.h +172 -0
  250. data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseVector.h +448 -0
  251. data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseView.h +99 -0
  252. data/ext/eigen/eigen3/Eigen/src/SparseCore/TriangularSolver.h +334 -0
  253. data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU.h +806 -0
  254. data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLUImpl.h +66 -0
  255. data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_Memory.h +227 -0
  256. data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_Structs.h +111 -0
  257. data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_SupernodalMatrix.h +298 -0
  258. data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_Utils.h +80 -0
  259. data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_column_bmod.h +180 -0
  260. data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_column_dfs.h +177 -0
  261. data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_copy_to_ucol.h +106 -0
  262. data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_gemm_kernel.h +279 -0
  263. data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_heap_relax_snode.h +127 -0
  264. data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_kernel_bmod.h +130 -0
  265. data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_panel_bmod.h +223 -0
  266. data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_panel_dfs.h +258 -0
  267. data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_pivotL.h +137 -0
  268. data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_pruneL.h +135 -0
  269. data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_relax_snode.h +83 -0
  270. data/ext/eigen/eigen3/Eigen/src/SparseQR/SparseQR.h +714 -0
  271. data/ext/eigen/eigen3/Eigen/src/StlSupport/StdDeque.h +134 -0
  272. data/ext/eigen/eigen3/Eigen/src/StlSupport/StdList.h +114 -0
  273. data/ext/eigen/eigen3/Eigen/src/StlSupport/StdVector.h +126 -0
  274. data/ext/eigen/eigen3/Eigen/src/StlSupport/details.h +84 -0
  275. data/ext/eigen/eigen3/Eigen/src/SuperLUSupport/SuperLUSupport.h +1026 -0
  276. data/ext/eigen/eigen3/Eigen/src/UmfPackSupport/UmfPackSupport.h +474 -0
  277. data/ext/eigen/eigen3/Eigen/src/misc/Image.h +84 -0
  278. data/ext/eigen/eigen3/Eigen/src/misc/Kernel.h +81 -0
  279. data/ext/eigen/eigen3/Eigen/src/misc/Solve.h +76 -0
  280. data/ext/eigen/eigen3/Eigen/src/misc/SparseSolve.h +128 -0
  281. data/ext/eigen/eigen3/Eigen/src/misc/blas.h +658 -0
  282. data/ext/eigen/eigen3/Eigen/src/plugins/ArrayCwiseBinaryOps.h +253 -0
  283. data/ext/eigen/eigen3/Eigen/src/plugins/ArrayCwiseUnaryOps.h +187 -0
  284. data/ext/eigen/eigen3/Eigen/src/plugins/BlockMethods.h +935 -0
  285. data/ext/eigen/eigen3/Eigen/src/plugins/CommonCwiseBinaryOps.h +46 -0
  286. data/ext/eigen/eigen3/Eigen/src/plugins/CommonCwiseUnaryOps.h +172 -0
  287. data/ext/eigen/eigen3/Eigen/src/plugins/MatrixCwiseBinaryOps.h +143 -0
  288. data/ext/eigen/eigen3/Eigen/src/plugins/MatrixCwiseUnaryOps.h +52 -0
  289. data/ext/eigen/eigen3/signature_of_eigen3_matrix_library +1 -0
  290. data/ext/eigen/eigen_wrap.cxx +19420 -10396
  291. data/ext/eigen/extconf.rb +37 -2
  292. data/lib/eigen.rb +146 -3
  293. metadata +294 -7
@@ -0,0 +1,400 @@
1
+ // This file is part of Eigen, a lightweight C++ template library
2
+ // for linear algebra.
3
+ //
4
+ // Copyright (C) 2008-2010 Benoit Jacob <jacob.benoit.1@gmail.com>
5
+ //
6
+ // This Source Code Form is subject to the terms of the Mozilla
7
+ // Public License v. 2.0. If a copy of the MPL was not distributed
8
+ // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9
+
10
+ #ifndef EIGEN_INVERSE_H
11
+ #define EIGEN_INVERSE_H
12
+
13
+ namespace Eigen {
14
+
15
+ namespace internal {
16
+
17
+ /**********************************
18
+ *** General case implementation ***
19
+ **********************************/
20
+
21
+ template<typename MatrixType, typename ResultType, int Size = MatrixType::RowsAtCompileTime>
22
+ struct compute_inverse
23
+ {
24
+ static inline void run(const MatrixType& matrix, ResultType& result)
25
+ {
26
+ result = matrix.partialPivLu().inverse();
27
+ }
28
+ };
29
+
30
+ template<typename MatrixType, typename ResultType, int Size = MatrixType::RowsAtCompileTime>
31
+ struct compute_inverse_and_det_with_check { /* nothing! general case not supported. */ };
32
+
33
+ /****************************
34
+ *** Size 1 implementation ***
35
+ ****************************/
36
+
37
+ template<typename MatrixType, typename ResultType>
38
+ struct compute_inverse<MatrixType, ResultType, 1>
39
+ {
40
+ static inline void run(const MatrixType& matrix, ResultType& result)
41
+ {
42
+ typedef typename MatrixType::Scalar Scalar;
43
+ result.coeffRef(0,0) = Scalar(1) / matrix.coeff(0,0);
44
+ }
45
+ };
46
+
47
+ template<typename MatrixType, typename ResultType>
48
+ struct compute_inverse_and_det_with_check<MatrixType, ResultType, 1>
49
+ {
50
+ static inline void run(
51
+ const MatrixType& matrix,
52
+ const typename MatrixType::RealScalar& absDeterminantThreshold,
53
+ ResultType& result,
54
+ typename ResultType::Scalar& determinant,
55
+ bool& invertible
56
+ )
57
+ {
58
+ using std::abs;
59
+ determinant = matrix.coeff(0,0);
60
+ invertible = abs(determinant) > absDeterminantThreshold;
61
+ if(invertible) result.coeffRef(0,0) = typename ResultType::Scalar(1) / determinant;
62
+ }
63
+ };
64
+
65
+ /****************************
66
+ *** Size 2 implementation ***
67
+ ****************************/
68
+
69
+ template<typename MatrixType, typename ResultType>
70
+ inline void compute_inverse_size2_helper(
71
+ const MatrixType& matrix, const typename ResultType::Scalar& invdet,
72
+ ResultType& result)
73
+ {
74
+ result.coeffRef(0,0) = matrix.coeff(1,1) * invdet;
75
+ result.coeffRef(1,0) = -matrix.coeff(1,0) * invdet;
76
+ result.coeffRef(0,1) = -matrix.coeff(0,1) * invdet;
77
+ result.coeffRef(1,1) = matrix.coeff(0,0) * invdet;
78
+ }
79
+
80
+ template<typename MatrixType, typename ResultType>
81
+ struct compute_inverse<MatrixType, ResultType, 2>
82
+ {
83
+ static inline void run(const MatrixType& matrix, ResultType& result)
84
+ {
85
+ typedef typename ResultType::Scalar Scalar;
86
+ const Scalar invdet = typename MatrixType::Scalar(1) / matrix.determinant();
87
+ compute_inverse_size2_helper(matrix, invdet, result);
88
+ }
89
+ };
90
+
91
+ template<typename MatrixType, typename ResultType>
92
+ struct compute_inverse_and_det_with_check<MatrixType, ResultType, 2>
93
+ {
94
+ static inline void run(
95
+ const MatrixType& matrix,
96
+ const typename MatrixType::RealScalar& absDeterminantThreshold,
97
+ ResultType& inverse,
98
+ typename ResultType::Scalar& determinant,
99
+ bool& invertible
100
+ )
101
+ {
102
+ using std::abs;
103
+ typedef typename ResultType::Scalar Scalar;
104
+ determinant = matrix.determinant();
105
+ invertible = abs(determinant) > absDeterminantThreshold;
106
+ if(!invertible) return;
107
+ const Scalar invdet = Scalar(1) / determinant;
108
+ compute_inverse_size2_helper(matrix, invdet, inverse);
109
+ }
110
+ };
111
+
112
+ /****************************
113
+ *** Size 3 implementation ***
114
+ ****************************/
115
+
116
+ template<typename MatrixType, int i, int j>
117
+ inline typename MatrixType::Scalar cofactor_3x3(const MatrixType& m)
118
+ {
119
+ enum {
120
+ i1 = (i+1) % 3,
121
+ i2 = (i+2) % 3,
122
+ j1 = (j+1) % 3,
123
+ j2 = (j+2) % 3
124
+ };
125
+ return m.coeff(i1, j1) * m.coeff(i2, j2)
126
+ - m.coeff(i1, j2) * m.coeff(i2, j1);
127
+ }
128
+
129
+ template<typename MatrixType, typename ResultType>
130
+ inline void compute_inverse_size3_helper(
131
+ const MatrixType& matrix,
132
+ const typename ResultType::Scalar& invdet,
133
+ const Matrix<typename ResultType::Scalar,3,1>& cofactors_col0,
134
+ ResultType& result)
135
+ {
136
+ result.row(0) = cofactors_col0 * invdet;
137
+ result.coeffRef(1,0) = cofactor_3x3<MatrixType,0,1>(matrix) * invdet;
138
+ result.coeffRef(1,1) = cofactor_3x3<MatrixType,1,1>(matrix) * invdet;
139
+ result.coeffRef(1,2) = cofactor_3x3<MatrixType,2,1>(matrix) * invdet;
140
+ result.coeffRef(2,0) = cofactor_3x3<MatrixType,0,2>(matrix) * invdet;
141
+ result.coeffRef(2,1) = cofactor_3x3<MatrixType,1,2>(matrix) * invdet;
142
+ result.coeffRef(2,2) = cofactor_3x3<MatrixType,2,2>(matrix) * invdet;
143
+ }
144
+
145
+ template<typename MatrixType, typename ResultType>
146
+ struct compute_inverse<MatrixType, ResultType, 3>
147
+ {
148
+ static inline void run(const MatrixType& matrix, ResultType& result)
149
+ {
150
+ typedef typename ResultType::Scalar Scalar;
151
+ Matrix<typename MatrixType::Scalar,3,1> cofactors_col0;
152
+ cofactors_col0.coeffRef(0) = cofactor_3x3<MatrixType,0,0>(matrix);
153
+ cofactors_col0.coeffRef(1) = cofactor_3x3<MatrixType,1,0>(matrix);
154
+ cofactors_col0.coeffRef(2) = cofactor_3x3<MatrixType,2,0>(matrix);
155
+ const Scalar det = (cofactors_col0.cwiseProduct(matrix.col(0))).sum();
156
+ const Scalar invdet = Scalar(1) / det;
157
+ compute_inverse_size3_helper(matrix, invdet, cofactors_col0, result);
158
+ }
159
+ };
160
+
161
+ template<typename MatrixType, typename ResultType>
162
+ struct compute_inverse_and_det_with_check<MatrixType, ResultType, 3>
163
+ {
164
+ static inline void run(
165
+ const MatrixType& matrix,
166
+ const typename MatrixType::RealScalar& absDeterminantThreshold,
167
+ ResultType& inverse,
168
+ typename ResultType::Scalar& determinant,
169
+ bool& invertible
170
+ )
171
+ {
172
+ using std::abs;
173
+ typedef typename ResultType::Scalar Scalar;
174
+ Matrix<Scalar,3,1> cofactors_col0;
175
+ cofactors_col0.coeffRef(0) = cofactor_3x3<MatrixType,0,0>(matrix);
176
+ cofactors_col0.coeffRef(1) = cofactor_3x3<MatrixType,1,0>(matrix);
177
+ cofactors_col0.coeffRef(2) = cofactor_3x3<MatrixType,2,0>(matrix);
178
+ determinant = (cofactors_col0.cwiseProduct(matrix.col(0))).sum();
179
+ invertible = abs(determinant) > absDeterminantThreshold;
180
+ if(!invertible) return;
181
+ const Scalar invdet = Scalar(1) / determinant;
182
+ compute_inverse_size3_helper(matrix, invdet, cofactors_col0, inverse);
183
+ }
184
+ };
185
+
186
+ /****************************
187
+ *** Size 4 implementation ***
188
+ ****************************/
189
+
190
+ template<typename Derived>
191
+ inline const typename Derived::Scalar general_det3_helper
192
+ (const MatrixBase<Derived>& matrix, int i1, int i2, int i3, int j1, int j2, int j3)
193
+ {
194
+ return matrix.coeff(i1,j1)
195
+ * (matrix.coeff(i2,j2) * matrix.coeff(i3,j3) - matrix.coeff(i2,j3) * matrix.coeff(i3,j2));
196
+ }
197
+
198
+ template<typename MatrixType, int i, int j>
199
+ inline typename MatrixType::Scalar cofactor_4x4(const MatrixType& matrix)
200
+ {
201
+ enum {
202
+ i1 = (i+1) % 4,
203
+ i2 = (i+2) % 4,
204
+ i3 = (i+3) % 4,
205
+ j1 = (j+1) % 4,
206
+ j2 = (j+2) % 4,
207
+ j3 = (j+3) % 4
208
+ };
209
+ return general_det3_helper(matrix, i1, i2, i3, j1, j2, j3)
210
+ + general_det3_helper(matrix, i2, i3, i1, j1, j2, j3)
211
+ + general_det3_helper(matrix, i3, i1, i2, j1, j2, j3);
212
+ }
213
+
214
+ template<int Arch, typename Scalar, typename MatrixType, typename ResultType>
215
+ struct compute_inverse_size4
216
+ {
217
+ static void run(const MatrixType& matrix, ResultType& result)
218
+ {
219
+ result.coeffRef(0,0) = cofactor_4x4<MatrixType,0,0>(matrix);
220
+ result.coeffRef(1,0) = -cofactor_4x4<MatrixType,0,1>(matrix);
221
+ result.coeffRef(2,0) = cofactor_4x4<MatrixType,0,2>(matrix);
222
+ result.coeffRef(3,0) = -cofactor_4x4<MatrixType,0,3>(matrix);
223
+ result.coeffRef(0,2) = cofactor_4x4<MatrixType,2,0>(matrix);
224
+ result.coeffRef(1,2) = -cofactor_4x4<MatrixType,2,1>(matrix);
225
+ result.coeffRef(2,2) = cofactor_4x4<MatrixType,2,2>(matrix);
226
+ result.coeffRef(3,2) = -cofactor_4x4<MatrixType,2,3>(matrix);
227
+ result.coeffRef(0,1) = -cofactor_4x4<MatrixType,1,0>(matrix);
228
+ result.coeffRef(1,1) = cofactor_4x4<MatrixType,1,1>(matrix);
229
+ result.coeffRef(2,1) = -cofactor_4x4<MatrixType,1,2>(matrix);
230
+ result.coeffRef(3,1) = cofactor_4x4<MatrixType,1,3>(matrix);
231
+ result.coeffRef(0,3) = -cofactor_4x4<MatrixType,3,0>(matrix);
232
+ result.coeffRef(1,3) = cofactor_4x4<MatrixType,3,1>(matrix);
233
+ result.coeffRef(2,3) = -cofactor_4x4<MatrixType,3,2>(matrix);
234
+ result.coeffRef(3,3) = cofactor_4x4<MatrixType,3,3>(matrix);
235
+ result /= (matrix.col(0).cwiseProduct(result.row(0).transpose())).sum();
236
+ }
237
+ };
238
+
239
+ template<typename MatrixType, typename ResultType>
240
+ struct compute_inverse<MatrixType, ResultType, 4>
241
+ : compute_inverse_size4<Architecture::Target, typename MatrixType::Scalar,
242
+ MatrixType, ResultType>
243
+ {
244
+ };
245
+
246
+ template<typename MatrixType, typename ResultType>
247
+ struct compute_inverse_and_det_with_check<MatrixType, ResultType, 4>
248
+ {
249
+ static inline void run(
250
+ const MatrixType& matrix,
251
+ const typename MatrixType::RealScalar& absDeterminantThreshold,
252
+ ResultType& inverse,
253
+ typename ResultType::Scalar& determinant,
254
+ bool& invertible
255
+ )
256
+ {
257
+ using std::abs;
258
+ determinant = matrix.determinant();
259
+ invertible = abs(determinant) > absDeterminantThreshold;
260
+ if(invertible) compute_inverse<MatrixType, ResultType>::run(matrix, inverse);
261
+ }
262
+ };
263
+
264
+ /*************************
265
+ *** MatrixBase methods ***
266
+ *************************/
267
+
268
+ template<typename MatrixType>
269
+ struct traits<inverse_impl<MatrixType> >
270
+ {
271
+ typedef typename MatrixType::PlainObject ReturnType;
272
+ };
273
+
274
+ template<typename MatrixType>
275
+ struct inverse_impl : public ReturnByValue<inverse_impl<MatrixType> >
276
+ {
277
+ typedef typename MatrixType::Index Index;
278
+ typedef typename internal::eval<MatrixType>::type MatrixTypeNested;
279
+ typedef typename remove_all<MatrixTypeNested>::type MatrixTypeNestedCleaned;
280
+ MatrixTypeNested m_matrix;
281
+
282
+ inverse_impl(const MatrixType& matrix)
283
+ : m_matrix(matrix)
284
+ {}
285
+
286
+ inline Index rows() const { return m_matrix.rows(); }
287
+ inline Index cols() const { return m_matrix.cols(); }
288
+
289
+ template<typename Dest> inline void evalTo(Dest& dst) const
290
+ {
291
+ const int Size = EIGEN_PLAIN_ENUM_MIN(MatrixType::ColsAtCompileTime,Dest::ColsAtCompileTime);
292
+ EIGEN_ONLY_USED_FOR_DEBUG(Size);
293
+ eigen_assert(( (Size<=1) || (Size>4) || (extract_data(m_matrix)!=extract_data(dst)))
294
+ && "Aliasing problem detected in inverse(), you need to do inverse().eval() here.");
295
+
296
+ compute_inverse<MatrixTypeNestedCleaned, Dest>::run(m_matrix, dst);
297
+ }
298
+ };
299
+
300
+ } // end namespace internal
301
+
302
+ /** \lu_module
303
+ *
304
+ * \returns the matrix inverse of this matrix.
305
+ *
306
+ * For small fixed sizes up to 4x4, this method uses cofactors.
307
+ * In the general case, this method uses class PartialPivLU.
308
+ *
309
+ * \note This matrix must be invertible, otherwise the result is undefined. If you need an
310
+ * invertibility check, do the following:
311
+ * \li for fixed sizes up to 4x4, use computeInverseAndDetWithCheck().
312
+ * \li for the general case, use class FullPivLU.
313
+ *
314
+ * Example: \include MatrixBase_inverse.cpp
315
+ * Output: \verbinclude MatrixBase_inverse.out
316
+ *
317
+ * \sa computeInverseAndDetWithCheck()
318
+ */
319
+ template<typename Derived>
320
+ inline const internal::inverse_impl<Derived> MatrixBase<Derived>::inverse() const
321
+ {
322
+ EIGEN_STATIC_ASSERT(!NumTraits<Scalar>::IsInteger,THIS_FUNCTION_IS_NOT_FOR_INTEGER_NUMERIC_TYPES)
323
+ eigen_assert(rows() == cols());
324
+ return internal::inverse_impl<Derived>(derived());
325
+ }
326
+
327
+ /** \lu_module
328
+ *
329
+ * Computation of matrix inverse and determinant, with invertibility check.
330
+ *
331
+ * This is only for fixed-size square matrices of size up to 4x4.
332
+ *
333
+ * \param inverse Reference to the matrix in which to store the inverse.
334
+ * \param determinant Reference to the variable in which to store the determinant.
335
+ * \param invertible Reference to the bool variable in which to store whether the matrix is invertible.
336
+ * \param absDeterminantThreshold Optional parameter controlling the invertibility check.
337
+ * The matrix will be declared invertible if the absolute value of its
338
+ * determinant is greater than this threshold.
339
+ *
340
+ * Example: \include MatrixBase_computeInverseAndDetWithCheck.cpp
341
+ * Output: \verbinclude MatrixBase_computeInverseAndDetWithCheck.out
342
+ *
343
+ * \sa inverse(), computeInverseWithCheck()
344
+ */
345
+ template<typename Derived>
346
+ template<typename ResultType>
347
+ inline void MatrixBase<Derived>::computeInverseAndDetWithCheck(
348
+ ResultType& inverse,
349
+ typename ResultType::Scalar& determinant,
350
+ bool& invertible,
351
+ const RealScalar& absDeterminantThreshold
352
+ ) const
353
+ {
354
+ // i'd love to put some static assertions there, but SFINAE means that they have no effect...
355
+ eigen_assert(rows() == cols());
356
+ // for 2x2, it's worth giving a chance to avoid evaluating.
357
+ // for larger sizes, evaluating has negligible cost and limits code size.
358
+ typedef typename internal::conditional<
359
+ RowsAtCompileTime == 2,
360
+ typename internal::remove_all<typename internal::nested<Derived, 2>::type>::type,
361
+ PlainObject
362
+ >::type MatrixType;
363
+ internal::compute_inverse_and_det_with_check<MatrixType, ResultType>::run
364
+ (derived(), absDeterminantThreshold, inverse, determinant, invertible);
365
+ }
366
+
367
+ /** \lu_module
368
+ *
369
+ * Computation of matrix inverse, with invertibility check.
370
+ *
371
+ * This is only for fixed-size square matrices of size up to 4x4.
372
+ *
373
+ * \param inverse Reference to the matrix in which to store the inverse.
374
+ * \param invertible Reference to the bool variable in which to store whether the matrix is invertible.
375
+ * \param absDeterminantThreshold Optional parameter controlling the invertibility check.
376
+ * The matrix will be declared invertible if the absolute value of its
377
+ * determinant is greater than this threshold.
378
+ *
379
+ * Example: \include MatrixBase_computeInverseWithCheck.cpp
380
+ * Output: \verbinclude MatrixBase_computeInverseWithCheck.out
381
+ *
382
+ * \sa inverse(), computeInverseAndDetWithCheck()
383
+ */
384
+ template<typename Derived>
385
+ template<typename ResultType>
386
+ inline void MatrixBase<Derived>::computeInverseWithCheck(
387
+ ResultType& inverse,
388
+ bool& invertible,
389
+ const RealScalar& absDeterminantThreshold
390
+ ) const
391
+ {
392
+ RealScalar determinant;
393
+ // i'd love to put some static assertions there, but SFINAE means that they have no effect...
394
+ eigen_assert(rows() == cols());
395
+ computeInverseAndDetWithCheck(inverse,determinant,invertible,absDeterminantThreshold);
396
+ }
397
+
398
+ } // end namespace Eigen
399
+
400
+ #endif // EIGEN_INVERSE_H
@@ -0,0 +1,509 @@
1
+ // This file is part of Eigen, a lightweight C++ template library
2
+ // for linear algebra.
3
+ //
4
+ // Copyright (C) 2006-2009 Benoit Jacob <jacob.benoit.1@gmail.com>
5
+ // Copyright (C) 2009 Gael Guennebaud <gael.guennebaud@inria.fr>
6
+ //
7
+ // This Source Code Form is subject to the terms of the Mozilla
8
+ // Public License v. 2.0. If a copy of the MPL was not distributed
9
+ // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
10
+
11
+ #ifndef EIGEN_PARTIALLU_H
12
+ #define EIGEN_PARTIALLU_H
13
+
14
+ namespace Eigen {
15
+
16
+ /** \ingroup LU_Module
17
+ *
18
+ * \class PartialPivLU
19
+ *
20
+ * \brief LU decomposition of a matrix with partial pivoting, and related features
21
+ *
22
+ * \param MatrixType the type of the matrix of which we are computing the LU decomposition
23
+ *
24
+ * This class represents a LU decomposition of a \b square \b invertible matrix, with partial pivoting: the matrix A
25
+ * is decomposed as A = PLU where L is unit-lower-triangular, U is upper-triangular, and P
26
+ * is a permutation matrix.
27
+ *
28
+ * Typically, partial pivoting LU decomposition is only considered numerically stable for square invertible
29
+ * matrices. Thus LAPACK's dgesv and dgesvx require the matrix to be square and invertible. The present class
30
+ * does the same. It will assert that the matrix is square, but it won't (actually it can't) check that the
31
+ * matrix is invertible: it is your task to check that you only use this decomposition on invertible matrices.
32
+ *
33
+ * The guaranteed safe alternative, working for all matrices, is the full pivoting LU decomposition, provided
34
+ * by class FullPivLU.
35
+ *
36
+ * This is \b not a rank-revealing LU decomposition. Many features are intentionally absent from this class,
37
+ * such as rank computation. If you need these features, use class FullPivLU.
38
+ *
39
+ * This LU decomposition is suitable to invert invertible matrices. It is what MatrixBase::inverse() uses
40
+ * in the general case.
41
+ * On the other hand, it is \b not suitable to determine whether a given matrix is invertible.
42
+ *
43
+ * The data of the LU decomposition can be directly accessed through the methods matrixLU(), permutationP().
44
+ *
45
+ * \sa MatrixBase::partialPivLu(), MatrixBase::determinant(), MatrixBase::inverse(), MatrixBase::computeInverse(), class FullPivLU
46
+ */
47
+ template<typename _MatrixType> class PartialPivLU
48
+ {
49
+ public:
50
+
51
+ typedef _MatrixType MatrixType;
52
+ enum {
53
+ RowsAtCompileTime = MatrixType::RowsAtCompileTime,
54
+ ColsAtCompileTime = MatrixType::ColsAtCompileTime,
55
+ Options = MatrixType::Options,
56
+ MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
57
+ MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
58
+ };
59
+ typedef typename MatrixType::Scalar Scalar;
60
+ typedef typename NumTraits<typename MatrixType::Scalar>::Real RealScalar;
61
+ typedef typename internal::traits<MatrixType>::StorageKind StorageKind;
62
+ typedef typename MatrixType::Index Index;
63
+ typedef PermutationMatrix<RowsAtCompileTime, MaxRowsAtCompileTime> PermutationType;
64
+ typedef Transpositions<RowsAtCompileTime, MaxRowsAtCompileTime> TranspositionType;
65
+
66
+
67
+ /**
68
+ * \brief Default Constructor.
69
+ *
70
+ * The default constructor is useful in cases in which the user intends to
71
+ * perform decompositions via PartialPivLU::compute(const MatrixType&).
72
+ */
73
+ PartialPivLU();
74
+
75
+ /** \brief Default Constructor with memory preallocation
76
+ *
77
+ * Like the default constructor but with preallocation of the internal data
78
+ * according to the specified problem \a size.
79
+ * \sa PartialPivLU()
80
+ */
81
+ PartialPivLU(Index size);
82
+
83
+ /** Constructor.
84
+ *
85
+ * \param matrix the matrix of which to compute the LU decomposition.
86
+ *
87
+ * \warning The matrix should have full rank (e.g. if it's square, it should be invertible).
88
+ * If you need to deal with non-full rank, use class FullPivLU instead.
89
+ */
90
+ PartialPivLU(const MatrixType& matrix);
91
+
92
+ PartialPivLU& compute(const MatrixType& matrix);
93
+
94
+ /** \returns the LU decomposition matrix: the upper-triangular part is U, the
95
+ * unit-lower-triangular part is L (at least for square matrices; in the non-square
96
+ * case, special care is needed, see the documentation of class FullPivLU).
97
+ *
98
+ * \sa matrixL(), matrixU()
99
+ */
100
+ inline const MatrixType& matrixLU() const
101
+ {
102
+ eigen_assert(m_isInitialized && "PartialPivLU is not initialized.");
103
+ return m_lu;
104
+ }
105
+
106
+ /** \returns the permutation matrix P.
107
+ */
108
+ inline const PermutationType& permutationP() const
109
+ {
110
+ eigen_assert(m_isInitialized && "PartialPivLU is not initialized.");
111
+ return m_p;
112
+ }
113
+
114
+ /** This method returns the solution x to the equation Ax=b, where A is the matrix of which
115
+ * *this is the LU decomposition.
116
+ *
117
+ * \param b the right-hand-side of the equation to solve. Can be a vector or a matrix,
118
+ * the only requirement in order for the equation to make sense is that
119
+ * b.rows()==A.rows(), where A is the matrix of which *this is the LU decomposition.
120
+ *
121
+ * \returns the solution.
122
+ *
123
+ * Example: \include PartialPivLU_solve.cpp
124
+ * Output: \verbinclude PartialPivLU_solve.out
125
+ *
126
+ * Since this PartialPivLU class assumes anyway that the matrix A is invertible, the solution
127
+ * theoretically exists and is unique regardless of b.
128
+ *
129
+ * \sa TriangularView::solve(), inverse(), computeInverse()
130
+ */
131
+ template<typename Rhs>
132
+ inline const internal::solve_retval<PartialPivLU, Rhs>
133
+ solve(const MatrixBase<Rhs>& b) const
134
+ {
135
+ eigen_assert(m_isInitialized && "PartialPivLU is not initialized.");
136
+ return internal::solve_retval<PartialPivLU, Rhs>(*this, b.derived());
137
+ }
138
+
139
+ /** \returns the inverse of the matrix of which *this is the LU decomposition.
140
+ *
141
+ * \warning The matrix being decomposed here is assumed to be invertible. If you need to check for
142
+ * invertibility, use class FullPivLU instead.
143
+ *
144
+ * \sa MatrixBase::inverse(), LU::inverse()
145
+ */
146
+ inline const internal::solve_retval<PartialPivLU,typename MatrixType::IdentityReturnType> inverse() const
147
+ {
148
+ eigen_assert(m_isInitialized && "PartialPivLU is not initialized.");
149
+ return internal::solve_retval<PartialPivLU,typename MatrixType::IdentityReturnType>
150
+ (*this, MatrixType::Identity(m_lu.rows(), m_lu.cols()));
151
+ }
152
+
153
+ /** \returns the determinant of the matrix of which
154
+ * *this is the LU decomposition. It has only linear complexity
155
+ * (that is, O(n) where n is the dimension of the square matrix)
156
+ * as the LU decomposition has already been computed.
157
+ *
158
+ * \note For fixed-size matrices of size up to 4, MatrixBase::determinant() offers
159
+ * optimized paths.
160
+ *
161
+ * \warning a determinant can be very big or small, so for matrices
162
+ * of large enough dimension, there is a risk of overflow/underflow.
163
+ *
164
+ * \sa MatrixBase::determinant()
165
+ */
166
+ typename internal::traits<MatrixType>::Scalar determinant() const;
167
+
168
+ MatrixType reconstructedMatrix() const;
169
+
170
+ inline Index rows() const { return m_lu.rows(); }
171
+ inline Index cols() const { return m_lu.cols(); }
172
+
173
+ protected:
174
+
175
+ static void check_template_parameters()
176
+ {
177
+ EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar);
178
+ }
179
+
180
+ MatrixType m_lu;
181
+ PermutationType m_p;
182
+ TranspositionType m_rowsTranspositions;
183
+ Index m_det_p;
184
+ bool m_isInitialized;
185
+ };
186
+
187
+ template<typename MatrixType>
188
+ PartialPivLU<MatrixType>::PartialPivLU()
189
+ : m_lu(),
190
+ m_p(),
191
+ m_rowsTranspositions(),
192
+ m_det_p(0),
193
+ m_isInitialized(false)
194
+ {
195
+ }
196
+
197
+ template<typename MatrixType>
198
+ PartialPivLU<MatrixType>::PartialPivLU(Index size)
199
+ : m_lu(size, size),
200
+ m_p(size),
201
+ m_rowsTranspositions(size),
202
+ m_det_p(0),
203
+ m_isInitialized(false)
204
+ {
205
+ }
206
+
207
+ template<typename MatrixType>
208
+ PartialPivLU<MatrixType>::PartialPivLU(const MatrixType& matrix)
209
+ : m_lu(matrix.rows(), matrix.rows()),
210
+ m_p(matrix.rows()),
211
+ m_rowsTranspositions(matrix.rows()),
212
+ m_det_p(0),
213
+ m_isInitialized(false)
214
+ {
215
+ compute(matrix);
216
+ }
217
+
218
+ namespace internal {
219
+
220
+ /** \internal This is the blocked version of fullpivlu_unblocked() */
221
+ template<typename Scalar, int StorageOrder, typename PivIndex>
222
+ struct partial_lu_impl
223
+ {
224
+ // FIXME add a stride to Map, so that the following mapping becomes easier,
225
+ // another option would be to create an expression being able to automatically
226
+ // warp any Map, Matrix, and Block expressions as a unique type, but since that's exactly
227
+ // a Map + stride, why not adding a stride to Map, and convenient ctors from a Matrix,
228
+ // and Block.
229
+ typedef Map<Matrix<Scalar, Dynamic, Dynamic, StorageOrder> > MapLU;
230
+ typedef Block<MapLU, Dynamic, Dynamic> MatrixType;
231
+ typedef Block<MatrixType,Dynamic,Dynamic> BlockType;
232
+ typedef typename MatrixType::RealScalar RealScalar;
233
+ typedef typename MatrixType::Index Index;
234
+
235
+ /** \internal performs the LU decomposition in-place of the matrix \a lu
236
+ * using an unblocked algorithm.
237
+ *
238
+ * In addition, this function returns the row transpositions in the
239
+ * vector \a row_transpositions which must have a size equal to the number
240
+ * of columns of the matrix \a lu, and an integer \a nb_transpositions
241
+ * which returns the actual number of transpositions.
242
+ *
243
+ * \returns The index of the first pivot which is exactly zero if any, or a negative number otherwise.
244
+ */
245
+ static Index unblocked_lu(MatrixType& lu, PivIndex* row_transpositions, PivIndex& nb_transpositions)
246
+ {
247
+ const Index rows = lu.rows();
248
+ const Index cols = lu.cols();
249
+ const Index size = (std::min)(rows,cols);
250
+ nb_transpositions = 0;
251
+ Index first_zero_pivot = -1;
252
+ for(Index k = 0; k < size; ++k)
253
+ {
254
+ Index rrows = rows-k-1;
255
+ Index rcols = cols-k-1;
256
+
257
+ Index row_of_biggest_in_col;
258
+ RealScalar biggest_in_corner
259
+ = lu.col(k).tail(rows-k).cwiseAbs().maxCoeff(&row_of_biggest_in_col);
260
+ row_of_biggest_in_col += k;
261
+
262
+ row_transpositions[k] = PivIndex(row_of_biggest_in_col);
263
+
264
+ if(biggest_in_corner != RealScalar(0))
265
+ {
266
+ if(k != row_of_biggest_in_col)
267
+ {
268
+ lu.row(k).swap(lu.row(row_of_biggest_in_col));
269
+ ++nb_transpositions;
270
+ }
271
+
272
+ // FIXME shall we introduce a safe quotient expression in cas 1/lu.coeff(k,k)
273
+ // overflow but not the actual quotient?
274
+ lu.col(k).tail(rrows) /= lu.coeff(k,k);
275
+ }
276
+ else if(first_zero_pivot==-1)
277
+ {
278
+ // the pivot is exactly zero, we record the index of the first pivot which is exactly 0,
279
+ // and continue the factorization such we still have A = PLU
280
+ first_zero_pivot = k;
281
+ }
282
+
283
+ if(k<rows-1)
284
+ lu.bottomRightCorner(rrows,rcols).noalias() -= lu.col(k).tail(rrows) * lu.row(k).tail(rcols);
285
+ }
286
+ return first_zero_pivot;
287
+ }
288
+
289
+ /** \internal performs the LU decomposition in-place of the matrix represented
290
+ * by the variables \a rows, \a cols, \a lu_data, and \a lu_stride using a
291
+ * recursive, blocked algorithm.
292
+ *
293
+ * In addition, this function returns the row transpositions in the
294
+ * vector \a row_transpositions which must have a size equal to the number
295
+ * of columns of the matrix \a lu, and an integer \a nb_transpositions
296
+ * which returns the actual number of transpositions.
297
+ *
298
+ * \returns The index of the first pivot which is exactly zero if any, or a negative number otherwise.
299
+ *
300
+ * \note This very low level interface using pointers, etc. is to:
301
+ * 1 - reduce the number of instanciations to the strict minimum
302
+ * 2 - avoid infinite recursion of the instanciations with Block<Block<Block<...> > >
303
+ */
304
+ static Index blocked_lu(Index rows, Index cols, Scalar* lu_data, Index luStride, PivIndex* row_transpositions, PivIndex& nb_transpositions, Index maxBlockSize=256)
305
+ {
306
+ MapLU lu1(lu_data,StorageOrder==RowMajor?rows:luStride,StorageOrder==RowMajor?luStride:cols);
307
+ MatrixType lu(lu1,0,0,rows,cols);
308
+
309
+ const Index size = (std::min)(rows,cols);
310
+
311
+ // if the matrix is too small, no blocking:
312
+ if(size<=16)
313
+ {
314
+ return unblocked_lu(lu, row_transpositions, nb_transpositions);
315
+ }
316
+
317
+ // automatically adjust the number of subdivisions to the size
318
+ // of the matrix so that there is enough sub blocks:
319
+ Index blockSize;
320
+ {
321
+ blockSize = size/8;
322
+ blockSize = (blockSize/16)*16;
323
+ blockSize = (std::min)((std::max)(blockSize,Index(8)), maxBlockSize);
324
+ }
325
+
326
+ nb_transpositions = 0;
327
+ Index first_zero_pivot = -1;
328
+ for(Index k = 0; k < size; k+=blockSize)
329
+ {
330
+ Index bs = (std::min)(size-k,blockSize); // actual size of the block
331
+ Index trows = rows - k - bs; // trailing rows
332
+ Index tsize = size - k - bs; // trailing size
333
+
334
+ // partition the matrix:
335
+ // A00 | A01 | A02
336
+ // lu = A_0 | A_1 | A_2 = A10 | A11 | A12
337
+ // A20 | A21 | A22
338
+ BlockType A_0(lu,0,0,rows,k);
339
+ BlockType A_2(lu,0,k+bs,rows,tsize);
340
+ BlockType A11(lu,k,k,bs,bs);
341
+ BlockType A12(lu,k,k+bs,bs,tsize);
342
+ BlockType A21(lu,k+bs,k,trows,bs);
343
+ BlockType A22(lu,k+bs,k+bs,trows,tsize);
344
+
345
+ PivIndex nb_transpositions_in_panel;
346
+ // recursively call the blocked LU algorithm on [A11^T A21^T]^T
347
+ // with a very small blocking size:
348
+ Index ret = blocked_lu(trows+bs, bs, &lu.coeffRef(k,k), luStride,
349
+ row_transpositions+k, nb_transpositions_in_panel, 16);
350
+ if(ret>=0 && first_zero_pivot==-1)
351
+ first_zero_pivot = k+ret;
352
+
353
+ nb_transpositions += nb_transpositions_in_panel;
354
+ // update permutations and apply them to A_0
355
+ for(Index i=k; i<k+bs; ++i)
356
+ {
357
+ Index piv = (row_transpositions[i] += k);
358
+ A_0.row(i).swap(A_0.row(piv));
359
+ }
360
+
361
+ if(trows)
362
+ {
363
+ // apply permutations to A_2
364
+ for(Index i=k;i<k+bs; ++i)
365
+ A_2.row(i).swap(A_2.row(row_transpositions[i]));
366
+
367
+ // A12 = A11^-1 A12
368
+ A11.template triangularView<UnitLower>().solveInPlace(A12);
369
+
370
+ A22.noalias() -= A21 * A12;
371
+ }
372
+ }
373
+ return first_zero_pivot;
374
+ }
375
+ };
376
+
377
+ /** \internal performs the LU decomposition with partial pivoting in-place.
378
+ */
379
+ template<typename MatrixType, typename TranspositionType>
380
+ void partial_lu_inplace(MatrixType& lu, TranspositionType& row_transpositions, typename TranspositionType::Index& nb_transpositions)
381
+ {
382
+ eigen_assert(lu.cols() == row_transpositions.size());
383
+ eigen_assert((&row_transpositions.coeffRef(1)-&row_transpositions.coeffRef(0)) == 1);
384
+
385
+ partial_lu_impl
386
+ <typename MatrixType::Scalar, MatrixType::Flags&RowMajorBit?RowMajor:ColMajor, typename TranspositionType::Index>
387
+ ::blocked_lu(lu.rows(), lu.cols(), &lu.coeffRef(0,0), lu.outerStride(), &row_transpositions.coeffRef(0), nb_transpositions);
388
+ }
389
+
390
+ } // end namespace internal
391
+
392
+ template<typename MatrixType>
393
+ PartialPivLU<MatrixType>& PartialPivLU<MatrixType>::compute(const MatrixType& matrix)
394
+ {
395
+ check_template_parameters();
396
+
397
+ // the row permutation is stored as int indices, so just to be sure:
398
+ eigen_assert(matrix.rows()<NumTraits<int>::highest());
399
+
400
+ m_lu = matrix;
401
+
402
+ eigen_assert(matrix.rows() == matrix.cols() && "PartialPivLU is only for square (and moreover invertible) matrices");
403
+ const Index size = matrix.rows();
404
+
405
+ m_rowsTranspositions.resize(size);
406
+
407
+ typename TranspositionType::Index nb_transpositions;
408
+ internal::partial_lu_inplace(m_lu, m_rowsTranspositions, nb_transpositions);
409
+ m_det_p = (nb_transpositions%2) ? -1 : 1;
410
+
411
+ m_p = m_rowsTranspositions;
412
+
413
+ m_isInitialized = true;
414
+ return *this;
415
+ }
416
+
417
+ template<typename MatrixType>
418
+ typename internal::traits<MatrixType>::Scalar PartialPivLU<MatrixType>::determinant() const
419
+ {
420
+ eigen_assert(m_isInitialized && "PartialPivLU is not initialized.");
421
+ return Scalar(m_det_p) * m_lu.diagonal().prod();
422
+ }
423
+
424
+ /** \returns the matrix represented by the decomposition,
425
+ * i.e., it returns the product: P^{-1} L U.
426
+ * This function is provided for debug purpose. */
427
+ template<typename MatrixType>
428
+ MatrixType PartialPivLU<MatrixType>::reconstructedMatrix() const
429
+ {
430
+ eigen_assert(m_isInitialized && "LU is not initialized.");
431
+ // LU
432
+ MatrixType res = m_lu.template triangularView<UnitLower>().toDenseMatrix()
433
+ * m_lu.template triangularView<Upper>();
434
+
435
+ // P^{-1}(LU)
436
+ res = m_p.inverse() * res;
437
+
438
+ return res;
439
+ }
440
+
441
+ /***** Implementation of solve() *****************************************************/
442
+
443
+ namespace internal {
444
+
445
+ template<typename _MatrixType, typename Rhs>
446
+ struct solve_retval<PartialPivLU<_MatrixType>, Rhs>
447
+ : solve_retval_base<PartialPivLU<_MatrixType>, Rhs>
448
+ {
449
+ EIGEN_MAKE_SOLVE_HELPERS(PartialPivLU<_MatrixType>,Rhs)
450
+
451
+ template<typename Dest> void evalTo(Dest& dst) const
452
+ {
453
+ /* The decomposition PA = LU can be rewritten as A = P^{-1} L U.
454
+ * So we proceed as follows:
455
+ * Step 1: compute c = Pb.
456
+ * Step 2: replace c by the solution x to Lx = c.
457
+ * Step 3: replace c by the solution x to Ux = c.
458
+ */
459
+
460
+ eigen_assert(rhs().rows() == dec().matrixLU().rows());
461
+
462
+ // Step 1
463
+ dst = dec().permutationP() * rhs();
464
+
465
+ // Step 2
466
+ dec().matrixLU().template triangularView<UnitLower>().solveInPlace(dst);
467
+
468
+ // Step 3
469
+ dec().matrixLU().template triangularView<Upper>().solveInPlace(dst);
470
+ }
471
+ };
472
+
473
+ } // end namespace internal
474
+
475
+ /******** MatrixBase methods *******/
476
+
477
+ /** \lu_module
478
+ *
479
+ * \return the partial-pivoting LU decomposition of \c *this.
480
+ *
481
+ * \sa class PartialPivLU
482
+ */
483
+ template<typename Derived>
484
+ inline const PartialPivLU<typename MatrixBase<Derived>::PlainObject>
485
+ MatrixBase<Derived>::partialPivLu() const
486
+ {
487
+ return PartialPivLU<PlainObject>(eval());
488
+ }
489
+
490
+ #if EIGEN2_SUPPORT_STAGE > STAGE20_RESOLVE_API_CONFLICTS
491
+ /** \lu_module
492
+ *
493
+ * Synonym of partialPivLu().
494
+ *
495
+ * \return the partial-pivoting LU decomposition of \c *this.
496
+ *
497
+ * \sa class PartialPivLU
498
+ */
499
+ template<typename Derived>
500
+ inline const PartialPivLU<typename MatrixBase<Derived>::PlainObject>
501
+ MatrixBase<Derived>::lu() const
502
+ {
503
+ return PartialPivLU<PlainObject>(eval());
504
+ }
505
+ #endif
506
+
507
+ } // end namespace Eigen
508
+
509
+ #endif // EIGEN_PARTIALLU_H