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.
- checksums.yaml +4 -4
- data/LICENSE +22 -0
- data/README.md +21 -0
- data/ext/eigen/eigen3/COPYING.BSD +26 -0
- data/ext/eigen/eigen3/COPYING.MPL2 +373 -0
- data/ext/eigen/eigen3/COPYING.README +18 -0
- data/ext/eigen/eigen3/Eigen/Array +11 -0
- data/ext/eigen/eigen3/Eigen/Cholesky +32 -0
- data/ext/eigen/eigen3/Eigen/CholmodSupport +45 -0
- data/ext/eigen/eigen3/Eigen/Core +376 -0
- data/ext/eigen/eigen3/Eigen/Dense +7 -0
- data/ext/eigen/eigen3/Eigen/Eigen +2 -0
- data/ext/eigen/eigen3/Eigen/Eigen2Support +95 -0
- data/ext/eigen/eigen3/Eigen/Eigenvalues +48 -0
- data/ext/eigen/eigen3/Eigen/Geometry +63 -0
- data/ext/eigen/eigen3/Eigen/Householder +23 -0
- data/ext/eigen/eigen3/Eigen/IterativeLinearSolvers +40 -0
- data/ext/eigen/eigen3/Eigen/Jacobi +26 -0
- data/ext/eigen/eigen3/Eigen/LU +41 -0
- data/ext/eigen/eigen3/Eigen/LeastSquares +32 -0
- data/ext/eigen/eigen3/Eigen/MetisSupport +28 -0
- data/ext/eigen/eigen3/Eigen/PaStiXSupport +46 -0
- data/ext/eigen/eigen3/Eigen/PardisoSupport +30 -0
- data/ext/eigen/eigen3/Eigen/QR +45 -0
- data/ext/eigen/eigen3/Eigen/QtAlignedMalloc +34 -0
- data/ext/eigen/eigen3/Eigen/SPQRSupport +29 -0
- data/ext/eigen/eigen3/Eigen/SVD +37 -0
- data/ext/eigen/eigen3/Eigen/Sparse +27 -0
- data/ext/eigen/eigen3/Eigen/SparseCore +64 -0
- data/ext/eigen/eigen3/Eigen/SparseLU +49 -0
- data/ext/eigen/eigen3/Eigen/SparseQR +33 -0
- data/ext/eigen/eigen3/Eigen/StdDeque +27 -0
- data/ext/eigen/eigen3/Eigen/StdList +26 -0
- data/ext/eigen/eigen3/Eigen/StdVector +27 -0
- data/ext/eigen/eigen3/Eigen/SuperLUSupport +59 -0
- data/ext/eigen/eigen3/Eigen/UmfPackSupport +36 -0
- data/ext/eigen/eigen3/Eigen/src/Cholesky/LDLT.h +611 -0
- data/ext/eigen/eigen3/Eigen/src/Cholesky/LLT.h +498 -0
- data/ext/eigen/eigen3/Eigen/src/Cholesky/LLT_MKL.h +102 -0
- data/ext/eigen/eigen3/Eigen/src/CholmodSupport/CholmodSupport.h +607 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Array.h +323 -0
- data/ext/eigen/eigen3/Eigen/src/Core/ArrayBase.h +226 -0
- data/ext/eigen/eigen3/Eigen/src/Core/ArrayWrapper.h +264 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Assign.h +590 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Assign_MKL.h +224 -0
- data/ext/eigen/eigen3/Eigen/src/Core/BandMatrix.h +334 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Block.h +406 -0
- data/ext/eigen/eigen3/Eigen/src/Core/BooleanRedux.h +154 -0
- data/ext/eigen/eigen3/Eigen/src/Core/CommaInitializer.h +154 -0
- data/ext/eigen/eigen3/Eigen/src/Core/CoreIterators.h +61 -0
- data/ext/eigen/eigen3/Eigen/src/Core/CwiseBinaryOp.h +230 -0
- data/ext/eigen/eigen3/Eigen/src/Core/CwiseNullaryOp.h +864 -0
- data/ext/eigen/eigen3/Eigen/src/Core/CwiseUnaryOp.h +126 -0
- data/ext/eigen/eigen3/Eigen/src/Core/CwiseUnaryView.h +139 -0
- data/ext/eigen/eigen3/Eigen/src/Core/DenseBase.h +521 -0
- data/ext/eigen/eigen3/Eigen/src/Core/DenseCoeffsBase.h +754 -0
- data/ext/eigen/eigen3/Eigen/src/Core/DenseStorage.h +434 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Diagonal.h +237 -0
- data/ext/eigen/eigen3/Eigen/src/Core/DiagonalMatrix.h +313 -0
- data/ext/eigen/eigen3/Eigen/src/Core/DiagonalProduct.h +131 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Dot.h +263 -0
- data/ext/eigen/eigen3/Eigen/src/Core/EigenBase.h +131 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Flagged.h +140 -0
- data/ext/eigen/eigen3/Eigen/src/Core/ForceAlignedAccess.h +146 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Functors.h +1026 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Fuzzy.h +150 -0
- data/ext/eigen/eigen3/Eigen/src/Core/GeneralProduct.h +635 -0
- data/ext/eigen/eigen3/Eigen/src/Core/GenericPacketMath.h +350 -0
- data/ext/eigen/eigen3/Eigen/src/Core/GlobalFunctions.h +92 -0
- data/ext/eigen/eigen3/Eigen/src/Core/IO.h +250 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Map.h +192 -0
- data/ext/eigen/eigen3/Eigen/src/Core/MapBase.h +247 -0
- data/ext/eigen/eigen3/Eigen/src/Core/MathFunctions.h +768 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Matrix.h +420 -0
- data/ext/eigen/eigen3/Eigen/src/Core/MatrixBase.h +563 -0
- data/ext/eigen/eigen3/Eigen/src/Core/NestByValue.h +111 -0
- data/ext/eigen/eigen3/Eigen/src/Core/NoAlias.h +134 -0
- data/ext/eigen/eigen3/Eigen/src/Core/NumTraits.h +150 -0
- data/ext/eigen/eigen3/Eigen/src/Core/PermutationMatrix.h +721 -0
- data/ext/eigen/eigen3/Eigen/src/Core/PlainObjectBase.h +822 -0
- data/ext/eigen/eigen3/Eigen/src/Core/ProductBase.h +290 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Random.h +152 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Redux.h +409 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Ref.h +278 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Replicate.h +177 -0
- data/ext/eigen/eigen3/Eigen/src/Core/ReturnByValue.h +99 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Reverse.h +224 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Select.h +162 -0
- data/ext/eigen/eigen3/Eigen/src/Core/SelfAdjointView.h +314 -0
- data/ext/eigen/eigen3/Eigen/src/Core/SelfCwiseBinaryOp.h +191 -0
- data/ext/eigen/eigen3/Eigen/src/Core/SolveTriangular.h +260 -0
- data/ext/eigen/eigen3/Eigen/src/Core/StableNorm.h +203 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Stride.h +108 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Swap.h +126 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Transpose.h +419 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Transpositions.h +436 -0
- data/ext/eigen/eigen3/Eigen/src/Core/TriangularMatrix.h +839 -0
- data/ext/eigen/eigen3/Eigen/src/Core/VectorBlock.h +95 -0
- data/ext/eigen/eigen3/Eigen/src/Core/VectorwiseOp.h +642 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Visitor.h +237 -0
- data/ext/eigen/eigen3/Eigen/src/Core/arch/AltiVec/Complex.h +217 -0
- data/ext/eigen/eigen3/Eigen/src/Core/arch/AltiVec/PacketMath.h +501 -0
- data/ext/eigen/eigen3/Eigen/src/Core/arch/Default/Settings.h +49 -0
- data/ext/eigen/eigen3/Eigen/src/Core/arch/NEON/Complex.h +253 -0
- data/ext/eigen/eigen3/Eigen/src/Core/arch/NEON/PacketMath.h +420 -0
- data/ext/eigen/eigen3/Eigen/src/Core/arch/SSE/Complex.h +442 -0
- data/ext/eigen/eigen3/Eigen/src/Core/arch/SSE/MathFunctions.h +475 -0
- data/ext/eigen/eigen3/Eigen/src/Core/arch/SSE/PacketMath.h +649 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/CoeffBasedProduct.h +476 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/GeneralBlockPanelKernel.h +1341 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/GeneralMatrixMatrix.h +427 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/GeneralMatrixMatrixTriangular.h +278 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/GeneralMatrixMatrixTriangular_MKL.h +146 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/GeneralMatrixMatrix_MKL.h +118 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/GeneralMatrixVector.h +566 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/GeneralMatrixVector_MKL.h +131 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/Parallelizer.h +162 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/SelfadjointMatrixMatrix.h +436 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/SelfadjointMatrixMatrix_MKL.h +295 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/SelfadjointMatrixVector.h +281 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/SelfadjointMatrixVector_MKL.h +114 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/SelfadjointProduct.h +123 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/SelfadjointRank2Update.h +93 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/TriangularMatrixMatrix.h +427 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/TriangularMatrixMatrix_MKL.h +309 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/TriangularMatrixVector.h +348 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/TriangularMatrixVector_MKL.h +247 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/TriangularSolverMatrix.h +332 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/TriangularSolverMatrix_MKL.h +155 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/TriangularSolverVector.h +139 -0
- data/ext/eigen/eigen3/Eigen/src/Core/util/BlasUtil.h +264 -0
- data/ext/eigen/eigen3/Eigen/src/Core/util/Constants.h +451 -0
- data/ext/eigen/eigen3/Eigen/src/Core/util/DisableStupidWarnings.h +40 -0
- data/ext/eigen/eigen3/Eigen/src/Core/util/ForwardDeclarations.h +302 -0
- data/ext/eigen/eigen3/Eigen/src/Core/util/MKL_support.h +158 -0
- data/ext/eigen/eigen3/Eigen/src/Core/util/Macros.h +451 -0
- data/ext/eigen/eigen3/Eigen/src/Core/util/Memory.h +977 -0
- data/ext/eigen/eigen3/Eigen/src/Core/util/Meta.h +243 -0
- data/ext/eigen/eigen3/Eigen/src/Core/util/NonMPL2.h +3 -0
- data/ext/eigen/eigen3/Eigen/src/Core/util/ReenableStupidWarnings.h +14 -0
- data/ext/eigen/eigen3/Eigen/src/Core/util/StaticAssert.h +208 -0
- data/ext/eigen/eigen3/Eigen/src/Core/util/XprHelper.h +469 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Block.h +126 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Cwise.h +192 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/CwiseOperators.h +298 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/AlignedBox.h +159 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/All.h +115 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/AngleAxis.h +214 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/Hyperplane.h +254 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/ParametrizedLine.h +141 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/Quaternion.h +495 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/Rotation2D.h +145 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/RotationBase.h +123 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/Scaling.h +167 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/Transform.h +786 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/Translation.h +184 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/LU.h +120 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Lazy.h +71 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/LeastSquares.h +169 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Macros.h +20 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/MathFunctions.h +57 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Memory.h +45 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Meta.h +75 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Minor.h +117 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/QR.h +67 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/SVD.h +637 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/TriangularSolver.h +42 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/VectorBlock.h +94 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/ComplexEigenSolver.h +341 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/ComplexSchur.h +456 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/ComplexSchur_MKL.h +94 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/EigenSolver.h +607 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/GeneralizedEigenSolver.h +350 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h +227 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/HessenbergDecomposition.h +373 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/MatrixBaseEigenvalues.h +160 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/RealQZ.h +624 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/RealSchur.h +525 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/RealSchur_MKL.h +83 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h +801 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/SelfAdjointEigenSolver_MKL.h +92 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/Tridiagonalization.h +557 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/AlignedBox.h +392 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/AngleAxis.h +233 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/EulerAngles.h +104 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/Homogeneous.h +307 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/Hyperplane.h +280 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/OrthoMethods.h +218 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/ParametrizedLine.h +195 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/Quaternion.h +776 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/Rotation2D.h +160 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/RotationBase.h +206 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/Scaling.h +166 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/Transform.h +1455 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/Translation.h +206 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/Umeyama.h +177 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/arch/Geometry_SSE.h +115 -0
- data/ext/eigen/eigen3/Eigen/src/Householder/BlockHouseholder.h +68 -0
- data/ext/eigen/eigen3/Eigen/src/Householder/Householder.h +171 -0
- data/ext/eigen/eigen3/Eigen/src/Householder/HouseholderSequence.h +441 -0
- data/ext/eigen/eigen3/Eigen/src/IterativeLinearSolvers/BasicPreconditioners.h +149 -0
- data/ext/eigen/eigen3/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h +263 -0
- data/ext/eigen/eigen3/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h +256 -0
- data/ext/eigen/eigen3/Eigen/src/IterativeLinearSolvers/IterativeSolverBase.h +282 -0
- data/ext/eigen/eigen3/Eigen/src/Jacobi/Jacobi.h +433 -0
- data/ext/eigen/eigen3/Eigen/src/LU/Determinant.h +101 -0
- data/ext/eigen/eigen3/Eigen/src/LU/FullPivLU.h +751 -0
- data/ext/eigen/eigen3/Eigen/src/LU/Inverse.h +400 -0
- data/ext/eigen/eigen3/Eigen/src/LU/PartialPivLU.h +509 -0
- data/ext/eigen/eigen3/Eigen/src/LU/PartialPivLU_MKL.h +85 -0
- data/ext/eigen/eigen3/Eigen/src/LU/arch/Inverse_SSE.h +329 -0
- data/ext/eigen/eigen3/Eigen/src/MetisSupport/MetisSupport.h +137 -0
- data/ext/eigen/eigen3/Eigen/src/OrderingMethods/Amd.h +444 -0
- data/ext/eigen/eigen3/Eigen/src/OrderingMethods/Eigen_Colamd.h +1850 -0
- data/ext/eigen/eigen3/Eigen/src/PaStiXSupport/PaStiXSupport.h +721 -0
- data/ext/eigen/eigen3/Eigen/src/PardisoSupport/PardisoSupport.h +592 -0
- data/ext/eigen/eigen3/Eigen/src/QR/ColPivHouseholderQR.h +580 -0
- data/ext/eigen/eigen3/Eigen/src/QR/ColPivHouseholderQR_MKL.h +99 -0
- data/ext/eigen/eigen3/Eigen/src/QR/FullPivHouseholderQR.h +622 -0
- data/ext/eigen/eigen3/Eigen/src/QR/HouseholderQR.h +388 -0
- data/ext/eigen/eigen3/Eigen/src/QR/HouseholderQR_MKL.h +71 -0
- data/ext/eigen/eigen3/Eigen/src/SPQRSupport/SuiteSparseQRSupport.h +338 -0
- data/ext/eigen/eigen3/Eigen/src/SVD/JacobiSVD.h +976 -0
- data/ext/eigen/eigen3/Eigen/src/SVD/JacobiSVD_MKL.h +92 -0
- data/ext/eigen/eigen3/Eigen/src/SVD/UpperBidiagonalization.h +148 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCholesky/SimplicialCholesky.h +671 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h +199 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/AmbiVector.h +373 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/CompressedStorage.h +233 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/ConservativeSparseSparseProduct.h +245 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/MappedSparseMatrix.h +181 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseBlock.h +537 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseColEtree.h +206 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseCwiseBinaryOp.h +325 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseCwiseUnaryOp.h +163 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseDenseProduct.h +311 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseDiagonalProduct.h +196 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseDot.h +101 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseFuzzy.h +26 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseMatrix.h +1262 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseMatrixBase.h +461 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparsePermutation.h +148 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseProduct.h +188 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseRedux.h +45 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseSelfAdjointView.h +507 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseSparseProductWithPruning.h +150 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseTranspose.h +63 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseTriangularView.h +179 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseUtil.h +172 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseVector.h +448 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseView.h +99 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/TriangularSolver.h +334 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU.h +806 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLUImpl.h +66 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_Memory.h +227 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_Structs.h +111 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_SupernodalMatrix.h +298 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_Utils.h +80 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_column_bmod.h +180 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_column_dfs.h +177 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_copy_to_ucol.h +106 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_gemm_kernel.h +279 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_heap_relax_snode.h +127 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_kernel_bmod.h +130 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_panel_bmod.h +223 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_panel_dfs.h +258 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_pivotL.h +137 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_pruneL.h +135 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_relax_snode.h +83 -0
- data/ext/eigen/eigen3/Eigen/src/SparseQR/SparseQR.h +714 -0
- data/ext/eigen/eigen3/Eigen/src/StlSupport/StdDeque.h +134 -0
- data/ext/eigen/eigen3/Eigen/src/StlSupport/StdList.h +114 -0
- data/ext/eigen/eigen3/Eigen/src/StlSupport/StdVector.h +126 -0
- data/ext/eigen/eigen3/Eigen/src/StlSupport/details.h +84 -0
- data/ext/eigen/eigen3/Eigen/src/SuperLUSupport/SuperLUSupport.h +1026 -0
- data/ext/eigen/eigen3/Eigen/src/UmfPackSupport/UmfPackSupport.h +474 -0
- data/ext/eigen/eigen3/Eigen/src/misc/Image.h +84 -0
- data/ext/eigen/eigen3/Eigen/src/misc/Kernel.h +81 -0
- data/ext/eigen/eigen3/Eigen/src/misc/Solve.h +76 -0
- data/ext/eigen/eigen3/Eigen/src/misc/SparseSolve.h +128 -0
- data/ext/eigen/eigen3/Eigen/src/misc/blas.h +658 -0
- data/ext/eigen/eigen3/Eigen/src/plugins/ArrayCwiseBinaryOps.h +253 -0
- data/ext/eigen/eigen3/Eigen/src/plugins/ArrayCwiseUnaryOps.h +187 -0
- data/ext/eigen/eigen3/Eigen/src/plugins/BlockMethods.h +935 -0
- data/ext/eigen/eigen3/Eigen/src/plugins/CommonCwiseBinaryOps.h +46 -0
- data/ext/eigen/eigen3/Eigen/src/plugins/CommonCwiseUnaryOps.h +172 -0
- data/ext/eigen/eigen3/Eigen/src/plugins/MatrixCwiseBinaryOps.h +143 -0
- data/ext/eigen/eigen3/Eigen/src/plugins/MatrixCwiseUnaryOps.h +52 -0
- data/ext/eigen/eigen3/signature_of_eigen3_matrix_library +1 -0
- data/ext/eigen/eigen_wrap.cxx +19420 -10396
- data/ext/eigen/extconf.rb +37 -2
- data/lib/eigen.rb +146 -3
- metadata +294 -7
@@ -0,0 +1,334 @@
|
|
1
|
+
// This file is part of Eigen, a lightweight C++ template library
|
2
|
+
// for linear algebra.
|
3
|
+
//
|
4
|
+
// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
|
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_SPARSETRIANGULARSOLVER_H
|
11
|
+
#define EIGEN_SPARSETRIANGULARSOLVER_H
|
12
|
+
|
13
|
+
namespace Eigen {
|
14
|
+
|
15
|
+
namespace internal {
|
16
|
+
|
17
|
+
template<typename Lhs, typename Rhs, int Mode,
|
18
|
+
int UpLo = (Mode & Lower)
|
19
|
+
? Lower
|
20
|
+
: (Mode & Upper)
|
21
|
+
? Upper
|
22
|
+
: -1,
|
23
|
+
int StorageOrder = int(traits<Lhs>::Flags) & RowMajorBit>
|
24
|
+
struct sparse_solve_triangular_selector;
|
25
|
+
|
26
|
+
// forward substitution, row-major
|
27
|
+
template<typename Lhs, typename Rhs, int Mode>
|
28
|
+
struct sparse_solve_triangular_selector<Lhs,Rhs,Mode,Lower,RowMajor>
|
29
|
+
{
|
30
|
+
typedef typename Rhs::Scalar Scalar;
|
31
|
+
static void run(const Lhs& lhs, Rhs& other)
|
32
|
+
{
|
33
|
+
for(int col=0 ; col<other.cols() ; ++col)
|
34
|
+
{
|
35
|
+
for(int i=0; i<lhs.rows(); ++i)
|
36
|
+
{
|
37
|
+
Scalar tmp = other.coeff(i,col);
|
38
|
+
Scalar lastVal(0);
|
39
|
+
int lastIndex = 0;
|
40
|
+
for(typename Lhs::InnerIterator it(lhs, i); it; ++it)
|
41
|
+
{
|
42
|
+
lastVal = it.value();
|
43
|
+
lastIndex = it.index();
|
44
|
+
if(lastIndex==i)
|
45
|
+
break;
|
46
|
+
tmp -= lastVal * other.coeff(lastIndex,col);
|
47
|
+
}
|
48
|
+
if (Mode & UnitDiag)
|
49
|
+
other.coeffRef(i,col) = tmp;
|
50
|
+
else
|
51
|
+
{
|
52
|
+
eigen_assert(lastIndex==i);
|
53
|
+
other.coeffRef(i,col) = tmp/lastVal;
|
54
|
+
}
|
55
|
+
}
|
56
|
+
}
|
57
|
+
}
|
58
|
+
};
|
59
|
+
|
60
|
+
// backward substitution, row-major
|
61
|
+
template<typename Lhs, typename Rhs, int Mode>
|
62
|
+
struct sparse_solve_triangular_selector<Lhs,Rhs,Mode,Upper,RowMajor>
|
63
|
+
{
|
64
|
+
typedef typename Rhs::Scalar Scalar;
|
65
|
+
static void run(const Lhs& lhs, Rhs& other)
|
66
|
+
{
|
67
|
+
for(int col=0 ; col<other.cols() ; ++col)
|
68
|
+
{
|
69
|
+
for(int i=lhs.rows()-1 ; i>=0 ; --i)
|
70
|
+
{
|
71
|
+
Scalar tmp = other.coeff(i,col);
|
72
|
+
Scalar l_ii(0);
|
73
|
+
typename Lhs::InnerIterator it(lhs, i);
|
74
|
+
while(it && it.index()<i)
|
75
|
+
++it;
|
76
|
+
if(!(Mode & UnitDiag))
|
77
|
+
{
|
78
|
+
eigen_assert(it && it.index()==i);
|
79
|
+
l_ii = it.value();
|
80
|
+
++it;
|
81
|
+
}
|
82
|
+
else if (it && it.index() == i)
|
83
|
+
++it;
|
84
|
+
for(; it; ++it)
|
85
|
+
{
|
86
|
+
tmp -= it.value() * other.coeff(it.index(),col);
|
87
|
+
}
|
88
|
+
|
89
|
+
if (Mode & UnitDiag)
|
90
|
+
other.coeffRef(i,col) = tmp;
|
91
|
+
else
|
92
|
+
other.coeffRef(i,col) = tmp/l_ii;
|
93
|
+
}
|
94
|
+
}
|
95
|
+
}
|
96
|
+
};
|
97
|
+
|
98
|
+
// forward substitution, col-major
|
99
|
+
template<typename Lhs, typename Rhs, int Mode>
|
100
|
+
struct sparse_solve_triangular_selector<Lhs,Rhs,Mode,Lower,ColMajor>
|
101
|
+
{
|
102
|
+
typedef typename Rhs::Scalar Scalar;
|
103
|
+
static void run(const Lhs& lhs, Rhs& other)
|
104
|
+
{
|
105
|
+
for(int col=0 ; col<other.cols() ; ++col)
|
106
|
+
{
|
107
|
+
for(int i=0; i<lhs.cols(); ++i)
|
108
|
+
{
|
109
|
+
Scalar& tmp = other.coeffRef(i,col);
|
110
|
+
if (tmp!=Scalar(0)) // optimization when other is actually sparse
|
111
|
+
{
|
112
|
+
typename Lhs::InnerIterator it(lhs, i);
|
113
|
+
while(it && it.index()<i)
|
114
|
+
++it;
|
115
|
+
if(!(Mode & UnitDiag))
|
116
|
+
{
|
117
|
+
eigen_assert(it && it.index()==i);
|
118
|
+
tmp /= it.value();
|
119
|
+
}
|
120
|
+
if (it && it.index()==i)
|
121
|
+
++it;
|
122
|
+
for(; it; ++it)
|
123
|
+
other.coeffRef(it.index(), col) -= tmp * it.value();
|
124
|
+
}
|
125
|
+
}
|
126
|
+
}
|
127
|
+
}
|
128
|
+
};
|
129
|
+
|
130
|
+
// backward substitution, col-major
|
131
|
+
template<typename Lhs, typename Rhs, int Mode>
|
132
|
+
struct sparse_solve_triangular_selector<Lhs,Rhs,Mode,Upper,ColMajor>
|
133
|
+
{
|
134
|
+
typedef typename Rhs::Scalar Scalar;
|
135
|
+
static void run(const Lhs& lhs, Rhs& other)
|
136
|
+
{
|
137
|
+
for(int col=0 ; col<other.cols() ; ++col)
|
138
|
+
{
|
139
|
+
for(int i=lhs.cols()-1; i>=0; --i)
|
140
|
+
{
|
141
|
+
Scalar& tmp = other.coeffRef(i,col);
|
142
|
+
if (tmp!=Scalar(0)) // optimization when other is actually sparse
|
143
|
+
{
|
144
|
+
if(!(Mode & UnitDiag))
|
145
|
+
{
|
146
|
+
// TODO replace this by a binary search. make sure the binary search is safe for partially sorted elements
|
147
|
+
typename Lhs::ReverseInnerIterator it(lhs, i);
|
148
|
+
while(it && it.index()!=i)
|
149
|
+
--it;
|
150
|
+
eigen_assert(it && it.index()==i);
|
151
|
+
other.coeffRef(i,col) /= it.value();
|
152
|
+
}
|
153
|
+
typename Lhs::InnerIterator it(lhs, i);
|
154
|
+
for(; it && it.index()<i; ++it)
|
155
|
+
other.coeffRef(it.index(), col) -= tmp * it.value();
|
156
|
+
}
|
157
|
+
}
|
158
|
+
}
|
159
|
+
}
|
160
|
+
};
|
161
|
+
|
162
|
+
} // end namespace internal
|
163
|
+
|
164
|
+
template<typename ExpressionType,int Mode>
|
165
|
+
template<typename OtherDerived>
|
166
|
+
void SparseTriangularView<ExpressionType,Mode>::solveInPlace(MatrixBase<OtherDerived>& other) const
|
167
|
+
{
|
168
|
+
eigen_assert(m_matrix.cols() == m_matrix.rows() && m_matrix.cols() == other.rows());
|
169
|
+
eigen_assert((!(Mode & ZeroDiag)) && bool(Mode & (Upper|Lower)));
|
170
|
+
|
171
|
+
enum { copy = internal::traits<OtherDerived>::Flags & RowMajorBit };
|
172
|
+
|
173
|
+
typedef typename internal::conditional<copy,
|
174
|
+
typename internal::plain_matrix_type_column_major<OtherDerived>::type, OtherDerived&>::type OtherCopy;
|
175
|
+
OtherCopy otherCopy(other.derived());
|
176
|
+
|
177
|
+
internal::sparse_solve_triangular_selector<ExpressionType, typename internal::remove_reference<OtherCopy>::type, Mode>::run(m_matrix, otherCopy);
|
178
|
+
|
179
|
+
if (copy)
|
180
|
+
other = otherCopy;
|
181
|
+
}
|
182
|
+
|
183
|
+
template<typename ExpressionType,int Mode>
|
184
|
+
template<typename OtherDerived>
|
185
|
+
typename internal::plain_matrix_type_column_major<OtherDerived>::type
|
186
|
+
SparseTriangularView<ExpressionType,Mode>::solve(const MatrixBase<OtherDerived>& other) const
|
187
|
+
{
|
188
|
+
typename internal::plain_matrix_type_column_major<OtherDerived>::type res(other);
|
189
|
+
solveInPlace(res);
|
190
|
+
return res;
|
191
|
+
}
|
192
|
+
|
193
|
+
// pure sparse path
|
194
|
+
|
195
|
+
namespace internal {
|
196
|
+
|
197
|
+
template<typename Lhs, typename Rhs, int Mode,
|
198
|
+
int UpLo = (Mode & Lower)
|
199
|
+
? Lower
|
200
|
+
: (Mode & Upper)
|
201
|
+
? Upper
|
202
|
+
: -1,
|
203
|
+
int StorageOrder = int(Lhs::Flags) & (RowMajorBit)>
|
204
|
+
struct sparse_solve_triangular_sparse_selector;
|
205
|
+
|
206
|
+
// forward substitution, col-major
|
207
|
+
template<typename Lhs, typename Rhs, int Mode, int UpLo>
|
208
|
+
struct sparse_solve_triangular_sparse_selector<Lhs,Rhs,Mode,UpLo,ColMajor>
|
209
|
+
{
|
210
|
+
typedef typename Rhs::Scalar Scalar;
|
211
|
+
typedef typename promote_index_type<typename traits<Lhs>::Index,
|
212
|
+
typename traits<Rhs>::Index>::type Index;
|
213
|
+
static void run(const Lhs& lhs, Rhs& other)
|
214
|
+
{
|
215
|
+
const bool IsLower = (UpLo==Lower);
|
216
|
+
AmbiVector<Scalar,Index> tempVector(other.rows()*2);
|
217
|
+
tempVector.setBounds(0,other.rows());
|
218
|
+
|
219
|
+
Rhs res(other.rows(), other.cols());
|
220
|
+
res.reserve(other.nonZeros());
|
221
|
+
|
222
|
+
for(int col=0 ; col<other.cols() ; ++col)
|
223
|
+
{
|
224
|
+
// FIXME estimate number of non zeros
|
225
|
+
tempVector.init(.99/*float(other.col(col).nonZeros())/float(other.rows())*/);
|
226
|
+
tempVector.setZero();
|
227
|
+
tempVector.restart();
|
228
|
+
for (typename Rhs::InnerIterator rhsIt(other, col); rhsIt; ++rhsIt)
|
229
|
+
{
|
230
|
+
tempVector.coeffRef(rhsIt.index()) = rhsIt.value();
|
231
|
+
}
|
232
|
+
|
233
|
+
for(int i=IsLower?0:lhs.cols()-1;
|
234
|
+
IsLower?i<lhs.cols():i>=0;
|
235
|
+
i+=IsLower?1:-1)
|
236
|
+
{
|
237
|
+
tempVector.restart();
|
238
|
+
Scalar& ci = tempVector.coeffRef(i);
|
239
|
+
if (ci!=Scalar(0))
|
240
|
+
{
|
241
|
+
// find
|
242
|
+
typename Lhs::InnerIterator it(lhs, i);
|
243
|
+
if(!(Mode & UnitDiag))
|
244
|
+
{
|
245
|
+
if (IsLower)
|
246
|
+
{
|
247
|
+
eigen_assert(it.index()==i);
|
248
|
+
ci /= it.value();
|
249
|
+
}
|
250
|
+
else
|
251
|
+
ci /= lhs.coeff(i,i);
|
252
|
+
}
|
253
|
+
tempVector.restart();
|
254
|
+
if (IsLower)
|
255
|
+
{
|
256
|
+
if (it.index()==i)
|
257
|
+
++it;
|
258
|
+
for(; it; ++it)
|
259
|
+
tempVector.coeffRef(it.index()) -= ci * it.value();
|
260
|
+
}
|
261
|
+
else
|
262
|
+
{
|
263
|
+
for(; it && it.index()<i; ++it)
|
264
|
+
tempVector.coeffRef(it.index()) -= ci * it.value();
|
265
|
+
}
|
266
|
+
}
|
267
|
+
}
|
268
|
+
|
269
|
+
|
270
|
+
int count = 0;
|
271
|
+
// FIXME compute a reference value to filter zeros
|
272
|
+
for (typename AmbiVector<Scalar,Index>::Iterator it(tempVector/*,1e-12*/); it; ++it)
|
273
|
+
{
|
274
|
+
++ count;
|
275
|
+
// std::cerr << "fill " << it.index() << ", " << col << "\n";
|
276
|
+
// std::cout << it.value() << " ";
|
277
|
+
// FIXME use insertBack
|
278
|
+
res.insert(it.index(), col) = it.value();
|
279
|
+
}
|
280
|
+
// std::cout << "tempVector.nonZeros() == " << int(count) << " / " << (other.rows()) << "\n";
|
281
|
+
}
|
282
|
+
res.finalize();
|
283
|
+
other = res.markAsRValue();
|
284
|
+
}
|
285
|
+
};
|
286
|
+
|
287
|
+
} // end namespace internal
|
288
|
+
|
289
|
+
template<typename ExpressionType,int Mode>
|
290
|
+
template<typename OtherDerived>
|
291
|
+
void SparseTriangularView<ExpressionType,Mode>::solveInPlace(SparseMatrixBase<OtherDerived>& other) const
|
292
|
+
{
|
293
|
+
eigen_assert(m_matrix.cols() == m_matrix.rows() && m_matrix.cols() == other.rows());
|
294
|
+
eigen_assert( (!(Mode & ZeroDiag)) && bool(Mode & (Upper|Lower)));
|
295
|
+
|
296
|
+
// enum { copy = internal::traits<OtherDerived>::Flags & RowMajorBit };
|
297
|
+
|
298
|
+
// typedef typename internal::conditional<copy,
|
299
|
+
// typename internal::plain_matrix_type_column_major<OtherDerived>::type, OtherDerived&>::type OtherCopy;
|
300
|
+
// OtherCopy otherCopy(other.derived());
|
301
|
+
|
302
|
+
internal::sparse_solve_triangular_sparse_selector<ExpressionType, OtherDerived, Mode>::run(m_matrix, other.derived());
|
303
|
+
|
304
|
+
// if (copy)
|
305
|
+
// other = otherCopy;
|
306
|
+
}
|
307
|
+
|
308
|
+
#ifdef EIGEN2_SUPPORT
|
309
|
+
|
310
|
+
// deprecated stuff:
|
311
|
+
|
312
|
+
/** \deprecated */
|
313
|
+
template<typename Derived>
|
314
|
+
template<typename OtherDerived>
|
315
|
+
void SparseMatrixBase<Derived>::solveTriangularInPlace(MatrixBase<OtherDerived>& other) const
|
316
|
+
{
|
317
|
+
this->template triangular<Flags&(Upper|Lower)>().solveInPlace(other);
|
318
|
+
}
|
319
|
+
|
320
|
+
/** \deprecated */
|
321
|
+
template<typename Derived>
|
322
|
+
template<typename OtherDerived>
|
323
|
+
typename internal::plain_matrix_type_column_major<OtherDerived>::type
|
324
|
+
SparseMatrixBase<Derived>::solveTriangular(const MatrixBase<OtherDerived>& other) const
|
325
|
+
{
|
326
|
+
typename internal::plain_matrix_type_column_major<OtherDerived>::type res(other);
|
327
|
+
derived().solveTriangularInPlace(res);
|
328
|
+
return res;
|
329
|
+
}
|
330
|
+
#endif // EIGEN2_SUPPORT
|
331
|
+
|
332
|
+
} // end namespace Eigen
|
333
|
+
|
334
|
+
#endif // EIGEN_SPARSETRIANGULARSOLVER_H
|
@@ -0,0 +1,806 @@
|
|
1
|
+
// This file is part of Eigen, a lightweight C++ template library
|
2
|
+
// for linear algebra.
|
3
|
+
//
|
4
|
+
// Copyright (C) 2012 Désiré Nuentsa-Wakam <desire.nuentsa_wakam@inria.fr>
|
5
|
+
// Copyright (C) 2012 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
|
+
|
12
|
+
#ifndef EIGEN_SPARSE_LU_H
|
13
|
+
#define EIGEN_SPARSE_LU_H
|
14
|
+
|
15
|
+
namespace Eigen {
|
16
|
+
|
17
|
+
template <typename _MatrixType, typename _OrderingType = COLAMDOrdering<typename _MatrixType::Index> > class SparseLU;
|
18
|
+
template <typename MappedSparseMatrixType> struct SparseLUMatrixLReturnType;
|
19
|
+
template <typename MatrixLType, typename MatrixUType> struct SparseLUMatrixUReturnType;
|
20
|
+
|
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, ColMajor> A;
|
47
|
+
* SparseLU<SparseMatrix<scalar, ColMajor>, COLAMDOrdering<Index> > 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
|
+
*
|
69
|
+
* \sa \ref TutorialSparseDirectSolvers
|
70
|
+
* \sa \ref OrderingMethods_Module
|
71
|
+
*/
|
72
|
+
template <typename _MatrixType, typename _OrderingType>
|
73
|
+
class SparseLU : public internal::SparseLUImpl<typename _MatrixType::Scalar, typename _MatrixType::Index>
|
74
|
+
{
|
75
|
+
public:
|
76
|
+
typedef _MatrixType MatrixType;
|
77
|
+
typedef _OrderingType OrderingType;
|
78
|
+
typedef typename MatrixType::Scalar Scalar;
|
79
|
+
typedef typename MatrixType::RealScalar RealScalar;
|
80
|
+
typedef typename MatrixType::Index Index;
|
81
|
+
typedef SparseMatrix<Scalar,ColMajor,Index> NCMatrix;
|
82
|
+
typedef internal::MappedSuperNodalMatrix<Scalar, Index> SCMatrix;
|
83
|
+
typedef Matrix<Scalar,Dynamic,1> ScalarVector;
|
84
|
+
typedef Matrix<Index,Dynamic,1> IndexVector;
|
85
|
+
typedef PermutationMatrix<Dynamic, Dynamic, Index> PermutationType;
|
86
|
+
typedef internal::SparseLUImpl<Scalar, Index> Base;
|
87
|
+
|
88
|
+
public:
|
89
|
+
SparseLU():m_isInitialized(true),m_lastError(""),m_Ustore(0,0,0,0,0,0),m_symmetricmode(false),m_diagpivotthresh(1.0),m_detPermR(1)
|
90
|
+
{
|
91
|
+
initperfvalues();
|
92
|
+
}
|
93
|
+
SparseLU(const MatrixType& matrix):m_isInitialized(true),m_lastError(""),m_Ustore(0,0,0,0,0,0),m_symmetricmode(false),m_diagpivotthresh(1.0),m_detPermR(1)
|
94
|
+
{
|
95
|
+
initperfvalues();
|
96
|
+
compute(matrix);
|
97
|
+
}
|
98
|
+
|
99
|
+
~SparseLU()
|
100
|
+
{
|
101
|
+
// Free all explicit dynamic pointers
|
102
|
+
}
|
103
|
+
|
104
|
+
void analyzePattern (const MatrixType& matrix);
|
105
|
+
void factorize (const MatrixType& matrix);
|
106
|
+
void simplicialfactorize(const MatrixType& matrix);
|
107
|
+
|
108
|
+
/**
|
109
|
+
* Compute the symbolic and numeric factorization of the input sparse matrix.
|
110
|
+
* The input matrix should be in column-major storage.
|
111
|
+
*/
|
112
|
+
void compute (const MatrixType& matrix)
|
113
|
+
{
|
114
|
+
// Analyze
|
115
|
+
analyzePattern(matrix);
|
116
|
+
//Factorize
|
117
|
+
factorize(matrix);
|
118
|
+
}
|
119
|
+
|
120
|
+
inline Index rows() const { return m_mat.rows(); }
|
121
|
+
inline Index cols() const { return m_mat.cols(); }
|
122
|
+
/** Indicate that the pattern of the input matrix is symmetric */
|
123
|
+
void isSymmetric(bool sym)
|
124
|
+
{
|
125
|
+
m_symmetricmode = sym;
|
126
|
+
}
|
127
|
+
|
128
|
+
/** \returns an expression of the matrix L, internally stored as supernodes
|
129
|
+
* The only operation available with this expression is the triangular solve
|
130
|
+
* \code
|
131
|
+
* y = b; matrixL().solveInPlace(y);
|
132
|
+
* \endcode
|
133
|
+
*/
|
134
|
+
SparseLUMatrixLReturnType<SCMatrix> matrixL() const
|
135
|
+
{
|
136
|
+
return SparseLUMatrixLReturnType<SCMatrix>(m_Lstore);
|
137
|
+
}
|
138
|
+
/** \returns an expression of the matrix U,
|
139
|
+
* The only operation available with this expression is the triangular solve
|
140
|
+
* \code
|
141
|
+
* y = b; matrixU().solveInPlace(y);
|
142
|
+
* \endcode
|
143
|
+
*/
|
144
|
+
SparseLUMatrixUReturnType<SCMatrix,MappedSparseMatrix<Scalar,ColMajor,Index> > matrixU() const
|
145
|
+
{
|
146
|
+
return SparseLUMatrixUReturnType<SCMatrix, MappedSparseMatrix<Scalar,ColMajor,Index> >(m_Lstore, m_Ustore);
|
147
|
+
}
|
148
|
+
|
149
|
+
/**
|
150
|
+
* \returns a reference to the row matrix permutation \f$ P_r \f$ such that \f$P_r A P_c^T = L U\f$
|
151
|
+
* \sa colsPermutation()
|
152
|
+
*/
|
153
|
+
inline const PermutationType& rowsPermutation() const
|
154
|
+
{
|
155
|
+
return m_perm_r;
|
156
|
+
}
|
157
|
+
/**
|
158
|
+
* \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$
|
159
|
+
* \sa rowsPermutation()
|
160
|
+
*/
|
161
|
+
inline const PermutationType& colsPermutation() const
|
162
|
+
{
|
163
|
+
return m_perm_c;
|
164
|
+
}
|
165
|
+
/** Set the threshold used for a diagonal entry to be an acceptable pivot. */
|
166
|
+
void setPivotThreshold(const RealScalar& thresh)
|
167
|
+
{
|
168
|
+
m_diagpivotthresh = thresh;
|
169
|
+
}
|
170
|
+
|
171
|
+
/** \returns the solution X of \f$ A X = B \f$ using the current decomposition of A.
|
172
|
+
*
|
173
|
+
* \warning the destination matrix X in X = this->solve(B) must be colmun-major.
|
174
|
+
*
|
175
|
+
* \sa compute()
|
176
|
+
*/
|
177
|
+
template<typename Rhs>
|
178
|
+
inline const internal::solve_retval<SparseLU, Rhs> solve(const MatrixBase<Rhs>& B) const
|
179
|
+
{
|
180
|
+
eigen_assert(m_factorizationIsOk && "SparseLU is not initialized.");
|
181
|
+
eigen_assert(rows()==B.rows()
|
182
|
+
&& "SparseLU::solve(): invalid number of rows of the right hand side matrix B");
|
183
|
+
return internal::solve_retval<SparseLU, Rhs>(*this, B.derived());
|
184
|
+
}
|
185
|
+
|
186
|
+
/** \returns the solution X of \f$ A X = B \f$ using the current decomposition of A.
|
187
|
+
*
|
188
|
+
* \sa compute()
|
189
|
+
*/
|
190
|
+
template<typename Rhs>
|
191
|
+
inline const internal::sparse_solve_retval<SparseLU, Rhs> solve(const SparseMatrixBase<Rhs>& B) const
|
192
|
+
{
|
193
|
+
eigen_assert(m_factorizationIsOk && "SparseLU is not initialized.");
|
194
|
+
eigen_assert(rows()==B.rows()
|
195
|
+
&& "SparseLU::solve(): invalid number of rows of the right hand side matrix B");
|
196
|
+
return internal::sparse_solve_retval<SparseLU, Rhs>(*this, B.derived());
|
197
|
+
}
|
198
|
+
|
199
|
+
/** \brief Reports whether previous computation was successful.
|
200
|
+
*
|
201
|
+
* \returns \c Success if computation was succesful,
|
202
|
+
* \c NumericalIssue if the LU factorization reports a problem, zero diagonal for instance
|
203
|
+
* \c InvalidInput if the input matrix is invalid
|
204
|
+
*
|
205
|
+
* \sa iparm()
|
206
|
+
*/
|
207
|
+
ComputationInfo info() const
|
208
|
+
{
|
209
|
+
eigen_assert(m_isInitialized && "Decomposition is not initialized.");
|
210
|
+
return m_info;
|
211
|
+
}
|
212
|
+
|
213
|
+
/**
|
214
|
+
* \returns A string describing the type of error
|
215
|
+
*/
|
216
|
+
std::string lastErrorMessage() const
|
217
|
+
{
|
218
|
+
return m_lastError;
|
219
|
+
}
|
220
|
+
|
221
|
+
template<typename Rhs, typename Dest>
|
222
|
+
bool _solve(const MatrixBase<Rhs> &B, MatrixBase<Dest> &X_base) const
|
223
|
+
{
|
224
|
+
Dest& X(X_base.derived());
|
225
|
+
eigen_assert(m_factorizationIsOk && "The matrix should be factorized first");
|
226
|
+
EIGEN_STATIC_ASSERT((Dest::Flags&RowMajorBit)==0,
|
227
|
+
THIS_METHOD_IS_ONLY_FOR_COLUMN_MAJOR_MATRICES);
|
228
|
+
|
229
|
+
// Permute the right hand side to form X = Pr*B
|
230
|
+
// on return, X is overwritten by the computed solution
|
231
|
+
X.resize(B.rows(),B.cols());
|
232
|
+
|
233
|
+
// this ugly const_cast_derived() helps to detect aliasing when applying the permutations
|
234
|
+
for(Index j = 0; j < B.cols(); ++j)
|
235
|
+
X.col(j) = rowsPermutation() * B.const_cast_derived().col(j);
|
236
|
+
|
237
|
+
//Forward substitution with L
|
238
|
+
this->matrixL().solveInPlace(X);
|
239
|
+
this->matrixU().solveInPlace(X);
|
240
|
+
|
241
|
+
// Permute back the solution
|
242
|
+
for (Index j = 0; j < B.cols(); ++j)
|
243
|
+
X.col(j) = colsPermutation().inverse() * X.col(j);
|
244
|
+
|
245
|
+
return true;
|
246
|
+
}
|
247
|
+
|
248
|
+
/**
|
249
|
+
* \returns the absolute value of the determinant of the matrix of which
|
250
|
+
* *this is the QR decomposition.
|
251
|
+
*
|
252
|
+
* \warning a determinant can be very big or small, so for matrices
|
253
|
+
* of large enough dimension, there is a risk of overflow/underflow.
|
254
|
+
* One way to work around that is to use logAbsDeterminant() instead.
|
255
|
+
*
|
256
|
+
* \sa logAbsDeterminant(), signDeterminant()
|
257
|
+
*/
|
258
|
+
Scalar absDeterminant()
|
259
|
+
{
|
260
|
+
eigen_assert(m_factorizationIsOk && "The matrix should be factorized first.");
|
261
|
+
// Initialize with the determinant of the row matrix
|
262
|
+
Scalar det = Scalar(1.);
|
263
|
+
// Note that the diagonal blocks of U are stored in supernodes,
|
264
|
+
// which are available in the L part :)
|
265
|
+
for (Index j = 0; j < this->cols(); ++j)
|
266
|
+
{
|
267
|
+
for (typename SCMatrix::InnerIterator it(m_Lstore, j); it; ++it)
|
268
|
+
{
|
269
|
+
if(it.index() == j)
|
270
|
+
{
|
271
|
+
using std::abs;
|
272
|
+
det *= abs(it.value());
|
273
|
+
break;
|
274
|
+
}
|
275
|
+
}
|
276
|
+
}
|
277
|
+
return det;
|
278
|
+
}
|
279
|
+
|
280
|
+
/** \returns the natural log of the absolute value of the determinant of the matrix
|
281
|
+
* of which **this is the QR decomposition
|
282
|
+
*
|
283
|
+
* \note This method is useful to work around the risk of overflow/underflow that's
|
284
|
+
* inherent to the determinant computation.
|
285
|
+
*
|
286
|
+
* \sa absDeterminant(), signDeterminant()
|
287
|
+
*/
|
288
|
+
Scalar logAbsDeterminant() const
|
289
|
+
{
|
290
|
+
eigen_assert(m_factorizationIsOk && "The matrix should be factorized first.");
|
291
|
+
Scalar det = Scalar(0.);
|
292
|
+
for (Index j = 0; j < this->cols(); ++j)
|
293
|
+
{
|
294
|
+
for (typename SCMatrix::InnerIterator it(m_Lstore, j); it; ++it)
|
295
|
+
{
|
296
|
+
if(it.row() < j) continue;
|
297
|
+
if(it.row() == j)
|
298
|
+
{
|
299
|
+
using std::log; using std::abs;
|
300
|
+
det += log(abs(it.value()));
|
301
|
+
break;
|
302
|
+
}
|
303
|
+
}
|
304
|
+
}
|
305
|
+
return det;
|
306
|
+
}
|
307
|
+
|
308
|
+
/** \returns A number representing the sign of the determinant
|
309
|
+
*
|
310
|
+
* \sa absDeterminant(), logAbsDeterminant()
|
311
|
+
*/
|
312
|
+
Scalar signDeterminant()
|
313
|
+
{
|
314
|
+
eigen_assert(m_factorizationIsOk && "The matrix should be factorized first.");
|
315
|
+
// Initialize with the determinant of the row matrix
|
316
|
+
Index det = 1;
|
317
|
+
// Note that the diagonal blocks of U are stored in supernodes,
|
318
|
+
// which are available in the L part :)
|
319
|
+
for (Index j = 0; j < this->cols(); ++j)
|
320
|
+
{
|
321
|
+
for (typename SCMatrix::InnerIterator it(m_Lstore, j); it; ++it)
|
322
|
+
{
|
323
|
+
if(it.index() == j)
|
324
|
+
{
|
325
|
+
if(it.value()<0)
|
326
|
+
det = -det;
|
327
|
+
else if(it.value()==0)
|
328
|
+
return 0;
|
329
|
+
break;
|
330
|
+
}
|
331
|
+
}
|
332
|
+
}
|
333
|
+
return det * m_detPermR * m_detPermC;
|
334
|
+
}
|
335
|
+
|
336
|
+
/** \returns The determinant of the matrix.
|
337
|
+
*
|
338
|
+
* \sa absDeterminant(), logAbsDeterminant()
|
339
|
+
*/
|
340
|
+
Scalar determinant()
|
341
|
+
{
|
342
|
+
eigen_assert(m_factorizationIsOk && "The matrix should be factorized first.");
|
343
|
+
// Initialize with the determinant of the row matrix
|
344
|
+
Scalar det = Scalar(1.);
|
345
|
+
// Note that the diagonal blocks of U are stored in supernodes,
|
346
|
+
// which are available in the L part :)
|
347
|
+
for (Index j = 0; j < this->cols(); ++j)
|
348
|
+
{
|
349
|
+
for (typename SCMatrix::InnerIterator it(m_Lstore, j); it; ++it)
|
350
|
+
{
|
351
|
+
if(it.index() == j)
|
352
|
+
{
|
353
|
+
det *= it.value();
|
354
|
+
break;
|
355
|
+
}
|
356
|
+
}
|
357
|
+
}
|
358
|
+
return det * Scalar(m_detPermR * m_detPermC);
|
359
|
+
}
|
360
|
+
|
361
|
+
protected:
|
362
|
+
// Functions
|
363
|
+
void initperfvalues()
|
364
|
+
{
|
365
|
+
m_perfv.panel_size = 16;
|
366
|
+
m_perfv.relax = 1;
|
367
|
+
m_perfv.maxsuper = 128;
|
368
|
+
m_perfv.rowblk = 16;
|
369
|
+
m_perfv.colblk = 8;
|
370
|
+
m_perfv.fillfactor = 20;
|
371
|
+
}
|
372
|
+
|
373
|
+
// Variables
|
374
|
+
mutable ComputationInfo m_info;
|
375
|
+
bool m_isInitialized;
|
376
|
+
bool m_factorizationIsOk;
|
377
|
+
bool m_analysisIsOk;
|
378
|
+
std::string m_lastError;
|
379
|
+
NCMatrix m_mat; // The input (permuted ) matrix
|
380
|
+
SCMatrix m_Lstore; // The lower triangular matrix (supernodal)
|
381
|
+
MappedSparseMatrix<Scalar,ColMajor,Index> m_Ustore; // The upper triangular matrix
|
382
|
+
PermutationType m_perm_c; // Column permutation
|
383
|
+
PermutationType m_perm_r ; // Row permutation
|
384
|
+
IndexVector m_etree; // Column elimination tree
|
385
|
+
|
386
|
+
typename Base::GlobalLU_t m_glu;
|
387
|
+
|
388
|
+
// SparseLU options
|
389
|
+
bool m_symmetricmode;
|
390
|
+
// values for performance
|
391
|
+
internal::perfvalues<Index> m_perfv;
|
392
|
+
RealScalar m_diagpivotthresh; // Specifies the threshold used for a diagonal entry to be an acceptable pivot
|
393
|
+
Index m_nnzL, m_nnzU; // Nonzeros in L and U factors
|
394
|
+
Index m_detPermR, m_detPermC; // Determinants of the permutation matrices
|
395
|
+
private:
|
396
|
+
// Disable copy constructor
|
397
|
+
SparseLU (const SparseLU& );
|
398
|
+
|
399
|
+
}; // End class SparseLU
|
400
|
+
|
401
|
+
|
402
|
+
|
403
|
+
// Functions needed by the anaysis phase
|
404
|
+
/**
|
405
|
+
* Compute the column permutation to minimize the fill-in
|
406
|
+
*
|
407
|
+
* - Apply this permutation to the input matrix -
|
408
|
+
*
|
409
|
+
* - Compute the column elimination tree on the permuted matrix
|
410
|
+
*
|
411
|
+
* - Postorder the elimination tree and the column permutation
|
412
|
+
*
|
413
|
+
*/
|
414
|
+
template <typename MatrixType, typename OrderingType>
|
415
|
+
void SparseLU<MatrixType, OrderingType>::analyzePattern(const MatrixType& mat)
|
416
|
+
{
|
417
|
+
|
418
|
+
//TODO It is possible as in SuperLU to compute row and columns scaling vectors to equilibrate the matrix mat.
|
419
|
+
|
420
|
+
OrderingType ord;
|
421
|
+
ord(mat,m_perm_c);
|
422
|
+
|
423
|
+
// Apply the permutation to the column of the input matrix
|
424
|
+
//First copy the whole input matrix.
|
425
|
+
m_mat = mat;
|
426
|
+
if (m_perm_c.size()) {
|
427
|
+
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.
|
428
|
+
//Then, permute only the column pointers
|
429
|
+
const Index * outerIndexPtr;
|
430
|
+
if (mat.isCompressed()) outerIndexPtr = mat.outerIndexPtr();
|
431
|
+
else
|
432
|
+
{
|
433
|
+
Index *outerIndexPtr_t = new Index[mat.cols()+1];
|
434
|
+
for(Index i = 0; i <= mat.cols(); i++) outerIndexPtr_t[i] = m_mat.outerIndexPtr()[i];
|
435
|
+
outerIndexPtr = outerIndexPtr_t;
|
436
|
+
}
|
437
|
+
for (Index i = 0; i < mat.cols(); i++)
|
438
|
+
{
|
439
|
+
m_mat.outerIndexPtr()[m_perm_c.indices()(i)] = outerIndexPtr[i];
|
440
|
+
m_mat.innerNonZeroPtr()[m_perm_c.indices()(i)] = outerIndexPtr[i+1] - outerIndexPtr[i];
|
441
|
+
}
|
442
|
+
if(!mat.isCompressed()) delete[] outerIndexPtr;
|
443
|
+
}
|
444
|
+
// Compute the column elimination tree of the permuted matrix
|
445
|
+
IndexVector firstRowElt;
|
446
|
+
internal::coletree(m_mat, m_etree,firstRowElt);
|
447
|
+
|
448
|
+
// In symmetric mode, do not do postorder here
|
449
|
+
if (!m_symmetricmode) {
|
450
|
+
IndexVector post, iwork;
|
451
|
+
// Post order etree
|
452
|
+
internal::treePostorder(m_mat.cols(), m_etree, post);
|
453
|
+
|
454
|
+
|
455
|
+
// Renumber etree in postorder
|
456
|
+
Index m = m_mat.cols();
|
457
|
+
iwork.resize(m+1);
|
458
|
+
for (Index i = 0; i < m; ++i) iwork(post(i)) = post(m_etree(i));
|
459
|
+
m_etree = iwork;
|
460
|
+
|
461
|
+
// Postmultiply A*Pc by post, i.e reorder the matrix according to the postorder of the etree
|
462
|
+
PermutationType post_perm(m);
|
463
|
+
for (Index i = 0; i < m; i++)
|
464
|
+
post_perm.indices()(i) = post(i);
|
465
|
+
|
466
|
+
// Combine the two permutations : postorder the permutation for future use
|
467
|
+
if(m_perm_c.size()) {
|
468
|
+
m_perm_c = post_perm * m_perm_c;
|
469
|
+
}
|
470
|
+
|
471
|
+
} // end postordering
|
472
|
+
|
473
|
+
m_analysisIsOk = true;
|
474
|
+
}
|
475
|
+
|
476
|
+
// Functions needed by the numerical factorization phase
|
477
|
+
|
478
|
+
|
479
|
+
/**
|
480
|
+
* - Numerical factorization
|
481
|
+
* - Interleaved with the symbolic factorization
|
482
|
+
* On exit, info is
|
483
|
+
*
|
484
|
+
* = 0: successful factorization
|
485
|
+
*
|
486
|
+
* > 0: if info = i, and i is
|
487
|
+
*
|
488
|
+
* <= A->ncol: U(i,i) is exactly zero. The factorization has
|
489
|
+
* been completed, but the factor U is exactly singular,
|
490
|
+
* and division by zero will occur if it is used to solve a
|
491
|
+
* system of equations.
|
492
|
+
*
|
493
|
+
* > A->ncol: number of bytes allocated when memory allocation
|
494
|
+
* failure occurred, plus A->ncol. If lwork = -1, it is
|
495
|
+
* the estimated amount of space needed, plus A->ncol.
|
496
|
+
*/
|
497
|
+
template <typename MatrixType, typename OrderingType>
|
498
|
+
void SparseLU<MatrixType, OrderingType>::factorize(const MatrixType& matrix)
|
499
|
+
{
|
500
|
+
using internal::emptyIdxLU;
|
501
|
+
eigen_assert(m_analysisIsOk && "analyzePattern() should be called first");
|
502
|
+
eigen_assert((matrix.rows() == matrix.cols()) && "Only for squared matrices");
|
503
|
+
|
504
|
+
typedef typename IndexVector::Scalar Index;
|
505
|
+
|
506
|
+
|
507
|
+
// Apply the column permutation computed in analyzepattern()
|
508
|
+
// m_mat = matrix * m_perm_c.inverse();
|
509
|
+
m_mat = matrix;
|
510
|
+
if (m_perm_c.size())
|
511
|
+
{
|
512
|
+
m_mat.uncompress(); //NOTE: The effect of this command is only to create the InnerNonzeros pointers.
|
513
|
+
//Then, permute only the column pointers
|
514
|
+
const Index * outerIndexPtr;
|
515
|
+
if (matrix.isCompressed()) outerIndexPtr = matrix.outerIndexPtr();
|
516
|
+
else
|
517
|
+
{
|
518
|
+
Index* outerIndexPtr_t = new Index[matrix.cols()+1];
|
519
|
+
for(Index i = 0; i <= matrix.cols(); i++) outerIndexPtr_t[i] = m_mat.outerIndexPtr()[i];
|
520
|
+
outerIndexPtr = outerIndexPtr_t;
|
521
|
+
}
|
522
|
+
for (Index i = 0; i < matrix.cols(); i++)
|
523
|
+
{
|
524
|
+
m_mat.outerIndexPtr()[m_perm_c.indices()(i)] = outerIndexPtr[i];
|
525
|
+
m_mat.innerNonZeroPtr()[m_perm_c.indices()(i)] = outerIndexPtr[i+1] - outerIndexPtr[i];
|
526
|
+
}
|
527
|
+
if(!matrix.isCompressed()) delete[] outerIndexPtr;
|
528
|
+
}
|
529
|
+
else
|
530
|
+
{ //FIXME This should not be needed if the empty permutation is handled transparently
|
531
|
+
m_perm_c.resize(matrix.cols());
|
532
|
+
for(Index i = 0; i < matrix.cols(); ++i) m_perm_c.indices()(i) = i;
|
533
|
+
}
|
534
|
+
|
535
|
+
Index m = m_mat.rows();
|
536
|
+
Index n = m_mat.cols();
|
537
|
+
Index nnz = m_mat.nonZeros();
|
538
|
+
Index maxpanel = m_perfv.panel_size * m;
|
539
|
+
// Allocate working storage common to the factor routines
|
540
|
+
Index lwork = 0;
|
541
|
+
Index info = Base::memInit(m, n, nnz, lwork, m_perfv.fillfactor, m_perfv.panel_size, m_glu);
|
542
|
+
if (info)
|
543
|
+
{
|
544
|
+
m_lastError = "UNABLE TO ALLOCATE WORKING MEMORY\n\n" ;
|
545
|
+
m_factorizationIsOk = false;
|
546
|
+
return ;
|
547
|
+
}
|
548
|
+
|
549
|
+
// Set up pointers for integer working arrays
|
550
|
+
IndexVector segrep(m); segrep.setZero();
|
551
|
+
IndexVector parent(m); parent.setZero();
|
552
|
+
IndexVector xplore(m); xplore.setZero();
|
553
|
+
IndexVector repfnz(maxpanel);
|
554
|
+
IndexVector panel_lsub(maxpanel);
|
555
|
+
IndexVector xprune(n); xprune.setZero();
|
556
|
+
IndexVector marker(m*internal::LUNoMarker); marker.setZero();
|
557
|
+
|
558
|
+
repfnz.setConstant(-1);
|
559
|
+
panel_lsub.setConstant(-1);
|
560
|
+
|
561
|
+
// Set up pointers for scalar working arrays
|
562
|
+
ScalarVector dense;
|
563
|
+
dense.setZero(maxpanel);
|
564
|
+
ScalarVector tempv;
|
565
|
+
tempv.setZero(internal::LUnumTempV(m, m_perfv.panel_size, m_perfv.maxsuper, /*m_perfv.rowblk*/m) );
|
566
|
+
|
567
|
+
// Compute the inverse of perm_c
|
568
|
+
PermutationType iperm_c(m_perm_c.inverse());
|
569
|
+
|
570
|
+
// Identify initial relaxed snodes
|
571
|
+
IndexVector relax_end(n);
|
572
|
+
if ( m_symmetricmode == true )
|
573
|
+
Base::heap_relax_snode(n, m_etree, m_perfv.relax, marker, relax_end);
|
574
|
+
else
|
575
|
+
Base::relax_snode(n, m_etree, m_perfv.relax, marker, relax_end);
|
576
|
+
|
577
|
+
|
578
|
+
m_perm_r.resize(m);
|
579
|
+
m_perm_r.indices().setConstant(-1);
|
580
|
+
marker.setConstant(-1);
|
581
|
+
m_detPermR = 1; // Record the determinant of the row permutation
|
582
|
+
|
583
|
+
m_glu.supno(0) = emptyIdxLU; m_glu.xsup.setConstant(0);
|
584
|
+
m_glu.xsup(0) = m_glu.xlsub(0) = m_glu.xusub(0) = m_glu.xlusup(0) = Index(0);
|
585
|
+
|
586
|
+
// Work on one 'panel' at a time. A panel is one of the following :
|
587
|
+
// (a) a relaxed supernode at the bottom of the etree, or
|
588
|
+
// (b) panel_size contiguous columns, <panel_size> defined by the user
|
589
|
+
Index jcol;
|
590
|
+
IndexVector panel_histo(n);
|
591
|
+
Index pivrow; // Pivotal row number in the original row matrix
|
592
|
+
Index nseg1; // Number of segments in U-column above panel row jcol
|
593
|
+
Index nseg; // Number of segments in each U-column
|
594
|
+
Index irep;
|
595
|
+
Index i, k, jj;
|
596
|
+
for (jcol = 0; jcol < n; )
|
597
|
+
{
|
598
|
+
// Adjust panel size so that a panel won't overlap with the next relaxed snode.
|
599
|
+
Index panel_size = m_perfv.panel_size; // upper bound on panel width
|
600
|
+
for (k = jcol + 1; k < (std::min)(jcol+panel_size, n); k++)
|
601
|
+
{
|
602
|
+
if (relax_end(k) != emptyIdxLU)
|
603
|
+
{
|
604
|
+
panel_size = k - jcol;
|
605
|
+
break;
|
606
|
+
}
|
607
|
+
}
|
608
|
+
if (k == n)
|
609
|
+
panel_size = n - jcol;
|
610
|
+
|
611
|
+
// Symbolic outer factorization on a panel of columns
|
612
|
+
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);
|
613
|
+
|
614
|
+
// Numeric sup-panel updates in topological order
|
615
|
+
Base::panel_bmod(m, panel_size, jcol, nseg1, dense, tempv, segrep, repfnz, m_glu);
|
616
|
+
|
617
|
+
// Sparse LU within the panel, and below the panel diagonal
|
618
|
+
for ( jj = jcol; jj< jcol + panel_size; jj++)
|
619
|
+
{
|
620
|
+
k = (jj - jcol) * m; // Column index for w-wide arrays
|
621
|
+
|
622
|
+
nseg = nseg1; // begin after all the panel segments
|
623
|
+
//Depth-first-search for the current column
|
624
|
+
VectorBlock<IndexVector> panel_lsubk(panel_lsub, k, m);
|
625
|
+
VectorBlock<IndexVector> repfnz_k(repfnz, k, m);
|
626
|
+
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);
|
627
|
+
if ( info )
|
628
|
+
{
|
629
|
+
m_lastError = "UNABLE TO EXPAND MEMORY IN COLUMN_DFS() ";
|
630
|
+
m_info = NumericalIssue;
|
631
|
+
m_factorizationIsOk = false;
|
632
|
+
return;
|
633
|
+
}
|
634
|
+
// Numeric updates to this column
|
635
|
+
VectorBlock<ScalarVector> dense_k(dense, k, m);
|
636
|
+
VectorBlock<IndexVector> segrep_k(segrep, nseg1, m-nseg1);
|
637
|
+
info = Base::column_bmod(jj, (nseg - nseg1), dense_k, tempv, segrep_k, repfnz_k, jcol, m_glu);
|
638
|
+
if ( info )
|
639
|
+
{
|
640
|
+
m_lastError = "UNABLE TO EXPAND MEMORY IN COLUMN_BMOD() ";
|
641
|
+
m_info = NumericalIssue;
|
642
|
+
m_factorizationIsOk = false;
|
643
|
+
return;
|
644
|
+
}
|
645
|
+
|
646
|
+
// Copy the U-segments to ucol(*)
|
647
|
+
info = Base::copy_to_ucol(jj, nseg, segrep, repfnz_k ,m_perm_r.indices(), dense_k, m_glu);
|
648
|
+
if ( info )
|
649
|
+
{
|
650
|
+
m_lastError = "UNABLE TO EXPAND MEMORY IN COPY_TO_UCOL() ";
|
651
|
+
m_info = NumericalIssue;
|
652
|
+
m_factorizationIsOk = false;
|
653
|
+
return;
|
654
|
+
}
|
655
|
+
|
656
|
+
// Form the L-segment
|
657
|
+
info = Base::pivotL(jj, m_diagpivotthresh, m_perm_r.indices(), iperm_c.indices(), pivrow, m_glu);
|
658
|
+
if ( info )
|
659
|
+
{
|
660
|
+
m_lastError = "THE MATRIX IS STRUCTURALLY SINGULAR ... ZERO COLUMN AT ";
|
661
|
+
std::ostringstream returnInfo;
|
662
|
+
returnInfo << info;
|
663
|
+
m_lastError += returnInfo.str();
|
664
|
+
m_info = NumericalIssue;
|
665
|
+
m_factorizationIsOk = false;
|
666
|
+
return;
|
667
|
+
}
|
668
|
+
|
669
|
+
// Update the determinant of the row permutation matrix
|
670
|
+
// FIXME: the following test is not correct, we should probably take iperm_c into account and pivrow is not directly the row pivot.
|
671
|
+
if (pivrow != jj) m_detPermR = -m_detPermR;
|
672
|
+
|
673
|
+
// Prune columns (0:jj-1) using column jj
|
674
|
+
Base::pruneL(jj, m_perm_r.indices(), pivrow, nseg, segrep, repfnz_k, xprune, m_glu);
|
675
|
+
|
676
|
+
// Reset repfnz for this column
|
677
|
+
for (i = 0; i < nseg; i++)
|
678
|
+
{
|
679
|
+
irep = segrep(i);
|
680
|
+
repfnz_k(irep) = emptyIdxLU;
|
681
|
+
}
|
682
|
+
} // end SparseLU within the panel
|
683
|
+
jcol += panel_size; // Move to the next panel
|
684
|
+
} // end for -- end elimination
|
685
|
+
|
686
|
+
m_detPermR = m_perm_r.determinant();
|
687
|
+
m_detPermC = m_perm_c.determinant();
|
688
|
+
|
689
|
+
// Count the number of nonzeros in factors
|
690
|
+
Base::countnz(n, m_nnzL, m_nnzU, m_glu);
|
691
|
+
// Apply permutation to the L subscripts
|
692
|
+
Base::fixupL(n, m_perm_r.indices(), m_glu);
|
693
|
+
|
694
|
+
// Create supernode matrix L
|
695
|
+
m_Lstore.setInfos(m, n, m_glu.lusup, m_glu.xlusup, m_glu.lsub, m_glu.xlsub, m_glu.supno, m_glu.xsup);
|
696
|
+
// Create the column major upper sparse matrix U;
|
697
|
+
new (&m_Ustore) MappedSparseMatrix<Scalar, ColMajor, Index> ( m, n, m_nnzU, m_glu.xusub.data(), m_glu.usub.data(), m_glu.ucol.data() );
|
698
|
+
|
699
|
+
m_info = Success;
|
700
|
+
m_factorizationIsOk = true;
|
701
|
+
}
|
702
|
+
|
703
|
+
template<typename MappedSupernodalType>
|
704
|
+
struct SparseLUMatrixLReturnType : internal::no_assignment_operator
|
705
|
+
{
|
706
|
+
typedef typename MappedSupernodalType::Index Index;
|
707
|
+
typedef typename MappedSupernodalType::Scalar Scalar;
|
708
|
+
SparseLUMatrixLReturnType(const MappedSupernodalType& mapL) : m_mapL(mapL)
|
709
|
+
{ }
|
710
|
+
Index rows() { return m_mapL.rows(); }
|
711
|
+
Index cols() { return m_mapL.cols(); }
|
712
|
+
template<typename Dest>
|
713
|
+
void solveInPlace( MatrixBase<Dest> &X) const
|
714
|
+
{
|
715
|
+
m_mapL.solveInPlace(X);
|
716
|
+
}
|
717
|
+
const MappedSupernodalType& m_mapL;
|
718
|
+
};
|
719
|
+
|
720
|
+
template<typename MatrixLType, typename MatrixUType>
|
721
|
+
struct SparseLUMatrixUReturnType : internal::no_assignment_operator
|
722
|
+
{
|
723
|
+
typedef typename MatrixLType::Index Index;
|
724
|
+
typedef typename MatrixLType::Scalar Scalar;
|
725
|
+
SparseLUMatrixUReturnType(const MatrixLType& mapL, const MatrixUType& mapU)
|
726
|
+
: m_mapL(mapL),m_mapU(mapU)
|
727
|
+
{ }
|
728
|
+
Index rows() { return m_mapL.rows(); }
|
729
|
+
Index cols() { return m_mapL.cols(); }
|
730
|
+
|
731
|
+
template<typename Dest> void solveInPlace(MatrixBase<Dest> &X) const
|
732
|
+
{
|
733
|
+
Index nrhs = X.cols();
|
734
|
+
Index n = X.rows();
|
735
|
+
// Backward solve with U
|
736
|
+
for (Index k = m_mapL.nsuper(); k >= 0; k--)
|
737
|
+
{
|
738
|
+
Index fsupc = m_mapL.supToCol()[k];
|
739
|
+
Index lda = m_mapL.colIndexPtr()[fsupc+1] - m_mapL.colIndexPtr()[fsupc]; // leading dimension
|
740
|
+
Index nsupc = m_mapL.supToCol()[k+1] - fsupc;
|
741
|
+
Index luptr = m_mapL.colIndexPtr()[fsupc];
|
742
|
+
|
743
|
+
if (nsupc == 1)
|
744
|
+
{
|
745
|
+
for (Index j = 0; j < nrhs; j++)
|
746
|
+
{
|
747
|
+
X(fsupc, j) /= m_mapL.valuePtr()[luptr];
|
748
|
+
}
|
749
|
+
}
|
750
|
+
else
|
751
|
+
{
|
752
|
+
Map<const Matrix<Scalar,Dynamic,Dynamic, ColMajor>, 0, OuterStride<> > A( &(m_mapL.valuePtr()[luptr]), nsupc, nsupc, OuterStride<>(lda) );
|
753
|
+
Map< Matrix<Scalar,Dynamic,Dynamic, ColMajor>, 0, OuterStride<> > U (&(X(fsupc,0)), nsupc, nrhs, OuterStride<>(n) );
|
754
|
+
U = A.template triangularView<Upper>().solve(U);
|
755
|
+
}
|
756
|
+
|
757
|
+
for (Index j = 0; j < nrhs; ++j)
|
758
|
+
{
|
759
|
+
for (Index jcol = fsupc; jcol < fsupc + nsupc; jcol++)
|
760
|
+
{
|
761
|
+
typename MatrixUType::InnerIterator it(m_mapU, jcol);
|
762
|
+
for ( ; it; ++it)
|
763
|
+
{
|
764
|
+
Index irow = it.index();
|
765
|
+
X(irow, j) -= X(jcol, j) * it.value();
|
766
|
+
}
|
767
|
+
}
|
768
|
+
}
|
769
|
+
} // End For U-solve
|
770
|
+
}
|
771
|
+
const MatrixLType& m_mapL;
|
772
|
+
const MatrixUType& m_mapU;
|
773
|
+
};
|
774
|
+
|
775
|
+
namespace internal {
|
776
|
+
|
777
|
+
template<typename _MatrixType, typename Derived, typename Rhs>
|
778
|
+
struct solve_retval<SparseLU<_MatrixType,Derived>, Rhs>
|
779
|
+
: solve_retval_base<SparseLU<_MatrixType,Derived>, Rhs>
|
780
|
+
{
|
781
|
+
typedef SparseLU<_MatrixType,Derived> Dec;
|
782
|
+
EIGEN_MAKE_SOLVE_HELPERS(Dec,Rhs)
|
783
|
+
|
784
|
+
template<typename Dest> void evalTo(Dest& dst) const
|
785
|
+
{
|
786
|
+
dec()._solve(rhs(),dst);
|
787
|
+
}
|
788
|
+
};
|
789
|
+
|
790
|
+
template<typename _MatrixType, typename Derived, typename Rhs>
|
791
|
+
struct sparse_solve_retval<SparseLU<_MatrixType,Derived>, Rhs>
|
792
|
+
: sparse_solve_retval_base<SparseLU<_MatrixType,Derived>, Rhs>
|
793
|
+
{
|
794
|
+
typedef SparseLU<_MatrixType,Derived> Dec;
|
795
|
+
EIGEN_MAKE_SPARSE_SOLVE_HELPERS(Dec,Rhs)
|
796
|
+
|
797
|
+
template<typename Dest> void evalTo(Dest& dst) const
|
798
|
+
{
|
799
|
+
this->defaultEvalTo(dst);
|
800
|
+
}
|
801
|
+
};
|
802
|
+
} // end namespace internal
|
803
|
+
|
804
|
+
} // End namespace Eigen
|
805
|
+
|
806
|
+
#endif
|