tomoto 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +123 -0
- data/ext/tomoto/ext.cpp +245 -0
- data/ext/tomoto/extconf.rb +28 -0
- data/lib/tomoto.rb +12 -0
- data/lib/tomoto/ct.rb +11 -0
- data/lib/tomoto/hdp.rb +11 -0
- data/lib/tomoto/lda.rb +67 -0
- data/lib/tomoto/version.rb +3 -0
- data/vendor/EigenRand/EigenRand/Core.h +1139 -0
- data/vendor/EigenRand/EigenRand/Dists/Basic.h +111 -0
- data/vendor/EigenRand/EigenRand/Dists/Discrete.h +877 -0
- data/vendor/EigenRand/EigenRand/Dists/GammaPoisson.h +108 -0
- data/vendor/EigenRand/EigenRand/Dists/NormalExp.h +626 -0
- data/vendor/EigenRand/EigenRand/EigenRand +19 -0
- data/vendor/EigenRand/EigenRand/Macro.h +24 -0
- data/vendor/EigenRand/EigenRand/MorePacketMath.h +978 -0
- data/vendor/EigenRand/EigenRand/PacketFilter.h +286 -0
- data/vendor/EigenRand/EigenRand/PacketRandomEngine.h +624 -0
- data/vendor/EigenRand/EigenRand/RandUtils.h +413 -0
- data/vendor/EigenRand/EigenRand/doc.h +220 -0
- data/vendor/EigenRand/LICENSE +21 -0
- data/vendor/EigenRand/README.md +288 -0
- data/vendor/eigen/COPYING.BSD +26 -0
- data/vendor/eigen/COPYING.GPL +674 -0
- data/vendor/eigen/COPYING.LGPL +502 -0
- data/vendor/eigen/COPYING.MINPACK +52 -0
- data/vendor/eigen/COPYING.MPL2 +373 -0
- data/vendor/eigen/COPYING.README +18 -0
- data/vendor/eigen/Eigen/CMakeLists.txt +19 -0
- data/vendor/eigen/Eigen/Cholesky +46 -0
- data/vendor/eigen/Eigen/CholmodSupport +48 -0
- data/vendor/eigen/Eigen/Core +537 -0
- data/vendor/eigen/Eigen/Dense +7 -0
- data/vendor/eigen/Eigen/Eigen +2 -0
- data/vendor/eigen/Eigen/Eigenvalues +61 -0
- data/vendor/eigen/Eigen/Geometry +62 -0
- data/vendor/eigen/Eigen/Householder +30 -0
- data/vendor/eigen/Eigen/IterativeLinearSolvers +48 -0
- data/vendor/eigen/Eigen/Jacobi +33 -0
- data/vendor/eigen/Eigen/LU +50 -0
- data/vendor/eigen/Eigen/MetisSupport +35 -0
- data/vendor/eigen/Eigen/OrderingMethods +73 -0
- data/vendor/eigen/Eigen/PaStiXSupport +48 -0
- data/vendor/eigen/Eigen/PardisoSupport +35 -0
- data/vendor/eigen/Eigen/QR +51 -0
- data/vendor/eigen/Eigen/QtAlignedMalloc +40 -0
- data/vendor/eigen/Eigen/SPQRSupport +34 -0
- data/vendor/eigen/Eigen/SVD +51 -0
- data/vendor/eigen/Eigen/Sparse +36 -0
- data/vendor/eigen/Eigen/SparseCholesky +45 -0
- data/vendor/eigen/Eigen/SparseCore +69 -0
- data/vendor/eigen/Eigen/SparseLU +46 -0
- data/vendor/eigen/Eigen/SparseQR +37 -0
- data/vendor/eigen/Eigen/StdDeque +27 -0
- data/vendor/eigen/Eigen/StdList +26 -0
- data/vendor/eigen/Eigen/StdVector +27 -0
- data/vendor/eigen/Eigen/SuperLUSupport +64 -0
- data/vendor/eigen/Eigen/UmfPackSupport +40 -0
- data/vendor/eigen/Eigen/src/Cholesky/LDLT.h +673 -0
- data/vendor/eigen/Eigen/src/Cholesky/LLT.h +542 -0
- data/vendor/eigen/Eigen/src/Cholesky/LLT_LAPACKE.h +99 -0
- data/vendor/eigen/Eigen/src/CholmodSupport/CholmodSupport.h +639 -0
- data/vendor/eigen/Eigen/src/Core/Array.h +329 -0
- data/vendor/eigen/Eigen/src/Core/ArrayBase.h +226 -0
- data/vendor/eigen/Eigen/src/Core/ArrayWrapper.h +209 -0
- data/vendor/eigen/Eigen/src/Core/Assign.h +90 -0
- data/vendor/eigen/Eigen/src/Core/AssignEvaluator.h +935 -0
- data/vendor/eigen/Eigen/src/Core/Assign_MKL.h +178 -0
- data/vendor/eigen/Eigen/src/Core/BandMatrix.h +353 -0
- data/vendor/eigen/Eigen/src/Core/Block.h +452 -0
- data/vendor/eigen/Eigen/src/Core/BooleanRedux.h +164 -0
- data/vendor/eigen/Eigen/src/Core/CommaInitializer.h +160 -0
- data/vendor/eigen/Eigen/src/Core/ConditionEstimator.h +175 -0
- data/vendor/eigen/Eigen/src/Core/CoreEvaluators.h +1688 -0
- data/vendor/eigen/Eigen/src/Core/CoreIterators.h +127 -0
- data/vendor/eigen/Eigen/src/Core/CwiseBinaryOp.h +184 -0
- data/vendor/eigen/Eigen/src/Core/CwiseNullaryOp.h +866 -0
- data/vendor/eigen/Eigen/src/Core/CwiseTernaryOp.h +197 -0
- data/vendor/eigen/Eigen/src/Core/CwiseUnaryOp.h +103 -0
- data/vendor/eigen/Eigen/src/Core/CwiseUnaryView.h +128 -0
- data/vendor/eigen/Eigen/src/Core/DenseBase.h +611 -0
- data/vendor/eigen/Eigen/src/Core/DenseCoeffsBase.h +681 -0
- data/vendor/eigen/Eigen/src/Core/DenseStorage.h +570 -0
- data/vendor/eigen/Eigen/src/Core/Diagonal.h +260 -0
- data/vendor/eigen/Eigen/src/Core/DiagonalMatrix.h +343 -0
- data/vendor/eigen/Eigen/src/Core/DiagonalProduct.h +28 -0
- data/vendor/eigen/Eigen/src/Core/Dot.h +318 -0
- data/vendor/eigen/Eigen/src/Core/EigenBase.h +159 -0
- data/vendor/eigen/Eigen/src/Core/ForceAlignedAccess.h +146 -0
- data/vendor/eigen/Eigen/src/Core/Fuzzy.h +155 -0
- data/vendor/eigen/Eigen/src/Core/GeneralProduct.h +455 -0
- data/vendor/eigen/Eigen/src/Core/GenericPacketMath.h +593 -0
- data/vendor/eigen/Eigen/src/Core/GlobalFunctions.h +187 -0
- data/vendor/eigen/Eigen/src/Core/IO.h +225 -0
- data/vendor/eigen/Eigen/src/Core/Inverse.h +118 -0
- data/vendor/eigen/Eigen/src/Core/Map.h +171 -0
- data/vendor/eigen/Eigen/src/Core/MapBase.h +303 -0
- data/vendor/eigen/Eigen/src/Core/MathFunctions.h +1415 -0
- data/vendor/eigen/Eigen/src/Core/MathFunctionsImpl.h +101 -0
- data/vendor/eigen/Eigen/src/Core/Matrix.h +459 -0
- data/vendor/eigen/Eigen/src/Core/MatrixBase.h +529 -0
- data/vendor/eigen/Eigen/src/Core/NestByValue.h +110 -0
- data/vendor/eigen/Eigen/src/Core/NoAlias.h +108 -0
- data/vendor/eigen/Eigen/src/Core/NumTraits.h +248 -0
- data/vendor/eigen/Eigen/src/Core/PermutationMatrix.h +633 -0
- data/vendor/eigen/Eigen/src/Core/PlainObjectBase.h +1035 -0
- data/vendor/eigen/Eigen/src/Core/Product.h +186 -0
- data/vendor/eigen/Eigen/src/Core/ProductEvaluators.h +1112 -0
- data/vendor/eigen/Eigen/src/Core/Random.h +182 -0
- data/vendor/eigen/Eigen/src/Core/Redux.h +505 -0
- data/vendor/eigen/Eigen/src/Core/Ref.h +283 -0
- data/vendor/eigen/Eigen/src/Core/Replicate.h +142 -0
- data/vendor/eigen/Eigen/src/Core/ReturnByValue.h +117 -0
- data/vendor/eigen/Eigen/src/Core/Reverse.h +211 -0
- data/vendor/eigen/Eigen/src/Core/Select.h +162 -0
- data/vendor/eigen/Eigen/src/Core/SelfAdjointView.h +352 -0
- data/vendor/eigen/Eigen/src/Core/SelfCwiseBinaryOp.h +47 -0
- data/vendor/eigen/Eigen/src/Core/Solve.h +188 -0
- data/vendor/eigen/Eigen/src/Core/SolveTriangular.h +235 -0
- data/vendor/eigen/Eigen/src/Core/SolverBase.h +130 -0
- data/vendor/eigen/Eigen/src/Core/StableNorm.h +221 -0
- data/vendor/eigen/Eigen/src/Core/Stride.h +111 -0
- data/vendor/eigen/Eigen/src/Core/Swap.h +67 -0
- data/vendor/eigen/Eigen/src/Core/Transpose.h +403 -0
- data/vendor/eigen/Eigen/src/Core/Transpositions.h +407 -0
- data/vendor/eigen/Eigen/src/Core/TriangularMatrix.h +983 -0
- data/vendor/eigen/Eigen/src/Core/VectorBlock.h +96 -0
- data/vendor/eigen/Eigen/src/Core/VectorwiseOp.h +695 -0
- data/vendor/eigen/Eigen/src/Core/Visitor.h +273 -0
- data/vendor/eigen/Eigen/src/Core/arch/AVX/Complex.h +451 -0
- data/vendor/eigen/Eigen/src/Core/arch/AVX/MathFunctions.h +439 -0
- data/vendor/eigen/Eigen/src/Core/arch/AVX/PacketMath.h +637 -0
- data/vendor/eigen/Eigen/src/Core/arch/AVX/TypeCasting.h +51 -0
- data/vendor/eigen/Eigen/src/Core/arch/AVX512/MathFunctions.h +391 -0
- data/vendor/eigen/Eigen/src/Core/arch/AVX512/PacketMath.h +1316 -0
- data/vendor/eigen/Eigen/src/Core/arch/AltiVec/Complex.h +430 -0
- data/vendor/eigen/Eigen/src/Core/arch/AltiVec/MathFunctions.h +322 -0
- data/vendor/eigen/Eigen/src/Core/arch/AltiVec/PacketMath.h +1061 -0
- data/vendor/eigen/Eigen/src/Core/arch/CUDA/Complex.h +103 -0
- data/vendor/eigen/Eigen/src/Core/arch/CUDA/Half.h +674 -0
- data/vendor/eigen/Eigen/src/Core/arch/CUDA/MathFunctions.h +91 -0
- data/vendor/eigen/Eigen/src/Core/arch/CUDA/PacketMath.h +333 -0
- data/vendor/eigen/Eigen/src/Core/arch/CUDA/PacketMathHalf.h +1124 -0
- data/vendor/eigen/Eigen/src/Core/arch/CUDA/TypeCasting.h +212 -0
- data/vendor/eigen/Eigen/src/Core/arch/Default/ConjHelper.h +29 -0
- data/vendor/eigen/Eigen/src/Core/arch/Default/Settings.h +49 -0
- data/vendor/eigen/Eigen/src/Core/arch/NEON/Complex.h +490 -0
- data/vendor/eigen/Eigen/src/Core/arch/NEON/MathFunctions.h +91 -0
- data/vendor/eigen/Eigen/src/Core/arch/NEON/PacketMath.h +760 -0
- data/vendor/eigen/Eigen/src/Core/arch/SSE/Complex.h +471 -0
- data/vendor/eigen/Eigen/src/Core/arch/SSE/MathFunctions.h +562 -0
- data/vendor/eigen/Eigen/src/Core/arch/SSE/PacketMath.h +895 -0
- data/vendor/eigen/Eigen/src/Core/arch/SSE/TypeCasting.h +77 -0
- data/vendor/eigen/Eigen/src/Core/arch/ZVector/Complex.h +397 -0
- data/vendor/eigen/Eigen/src/Core/arch/ZVector/MathFunctions.h +137 -0
- data/vendor/eigen/Eigen/src/Core/arch/ZVector/PacketMath.h +945 -0
- data/vendor/eigen/Eigen/src/Core/functors/AssignmentFunctors.h +168 -0
- data/vendor/eigen/Eigen/src/Core/functors/BinaryFunctors.h +475 -0
- data/vendor/eigen/Eigen/src/Core/functors/NullaryFunctors.h +188 -0
- data/vendor/eigen/Eigen/src/Core/functors/StlFunctors.h +136 -0
- data/vendor/eigen/Eigen/src/Core/functors/TernaryFunctors.h +25 -0
- data/vendor/eigen/Eigen/src/Core/functors/UnaryFunctors.h +792 -0
- data/vendor/eigen/Eigen/src/Core/products/GeneralBlockPanelKernel.h +2156 -0
- data/vendor/eigen/Eigen/src/Core/products/GeneralMatrixMatrix.h +492 -0
- data/vendor/eigen/Eigen/src/Core/products/GeneralMatrixMatrixTriangular.h +311 -0
- data/vendor/eigen/Eigen/src/Core/products/GeneralMatrixMatrixTriangular_BLAS.h +145 -0
- data/vendor/eigen/Eigen/src/Core/products/GeneralMatrixMatrix_BLAS.h +122 -0
- data/vendor/eigen/Eigen/src/Core/products/GeneralMatrixVector.h +619 -0
- data/vendor/eigen/Eigen/src/Core/products/GeneralMatrixVector_BLAS.h +136 -0
- data/vendor/eigen/Eigen/src/Core/products/Parallelizer.h +163 -0
- data/vendor/eigen/Eigen/src/Core/products/SelfadjointMatrixMatrix.h +521 -0
- data/vendor/eigen/Eigen/src/Core/products/SelfadjointMatrixMatrix_BLAS.h +287 -0
- data/vendor/eigen/Eigen/src/Core/products/SelfadjointMatrixVector.h +260 -0
- data/vendor/eigen/Eigen/src/Core/products/SelfadjointMatrixVector_BLAS.h +118 -0
- data/vendor/eigen/Eigen/src/Core/products/SelfadjointProduct.h +133 -0
- data/vendor/eigen/Eigen/src/Core/products/SelfadjointRank2Update.h +93 -0
- data/vendor/eigen/Eigen/src/Core/products/TriangularMatrixMatrix.h +466 -0
- data/vendor/eigen/Eigen/src/Core/products/TriangularMatrixMatrix_BLAS.h +315 -0
- data/vendor/eigen/Eigen/src/Core/products/TriangularMatrixVector.h +350 -0
- data/vendor/eigen/Eigen/src/Core/products/TriangularMatrixVector_BLAS.h +255 -0
- data/vendor/eigen/Eigen/src/Core/products/TriangularSolverMatrix.h +335 -0
- data/vendor/eigen/Eigen/src/Core/products/TriangularSolverMatrix_BLAS.h +163 -0
- data/vendor/eigen/Eigen/src/Core/products/TriangularSolverVector.h +145 -0
- data/vendor/eigen/Eigen/src/Core/util/BlasUtil.h +398 -0
- data/vendor/eigen/Eigen/src/Core/util/Constants.h +547 -0
- data/vendor/eigen/Eigen/src/Core/util/DisableStupidWarnings.h +83 -0
- data/vendor/eigen/Eigen/src/Core/util/ForwardDeclarations.h +302 -0
- data/vendor/eigen/Eigen/src/Core/util/MKL_support.h +130 -0
- data/vendor/eigen/Eigen/src/Core/util/Macros.h +1001 -0
- data/vendor/eigen/Eigen/src/Core/util/Memory.h +993 -0
- data/vendor/eigen/Eigen/src/Core/util/Meta.h +534 -0
- data/vendor/eigen/Eigen/src/Core/util/NonMPL2.h +3 -0
- data/vendor/eigen/Eigen/src/Core/util/ReenableStupidWarnings.h +27 -0
- data/vendor/eigen/Eigen/src/Core/util/StaticAssert.h +218 -0
- data/vendor/eigen/Eigen/src/Core/util/XprHelper.h +821 -0
- data/vendor/eigen/Eigen/src/Eigenvalues/ComplexEigenSolver.h +346 -0
- data/vendor/eigen/Eigen/src/Eigenvalues/ComplexSchur.h +459 -0
- data/vendor/eigen/Eigen/src/Eigenvalues/ComplexSchur_LAPACKE.h +91 -0
- data/vendor/eigen/Eigen/src/Eigenvalues/EigenSolver.h +622 -0
- data/vendor/eigen/Eigen/src/Eigenvalues/GeneralizedEigenSolver.h +418 -0
- data/vendor/eigen/Eigen/src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h +226 -0
- data/vendor/eigen/Eigen/src/Eigenvalues/HessenbergDecomposition.h +374 -0
- data/vendor/eigen/Eigen/src/Eigenvalues/MatrixBaseEigenvalues.h +158 -0
- data/vendor/eigen/Eigen/src/Eigenvalues/RealQZ.h +654 -0
- data/vendor/eigen/Eigen/src/Eigenvalues/RealSchur.h +546 -0
- data/vendor/eigen/Eigen/src/Eigenvalues/RealSchur_LAPACKE.h +77 -0
- data/vendor/eigen/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h +870 -0
- data/vendor/eigen/Eigen/src/Eigenvalues/SelfAdjointEigenSolver_LAPACKE.h +87 -0
- data/vendor/eigen/Eigen/src/Eigenvalues/Tridiagonalization.h +556 -0
- data/vendor/eigen/Eigen/src/Geometry/AlignedBox.h +392 -0
- data/vendor/eigen/Eigen/src/Geometry/AngleAxis.h +247 -0
- data/vendor/eigen/Eigen/src/Geometry/EulerAngles.h +114 -0
- data/vendor/eigen/Eigen/src/Geometry/Homogeneous.h +497 -0
- data/vendor/eigen/Eigen/src/Geometry/Hyperplane.h +282 -0
- data/vendor/eigen/Eigen/src/Geometry/OrthoMethods.h +234 -0
- data/vendor/eigen/Eigen/src/Geometry/ParametrizedLine.h +195 -0
- data/vendor/eigen/Eigen/src/Geometry/Quaternion.h +814 -0
- data/vendor/eigen/Eigen/src/Geometry/Rotation2D.h +199 -0
- data/vendor/eigen/Eigen/src/Geometry/RotationBase.h +206 -0
- data/vendor/eigen/Eigen/src/Geometry/Scaling.h +170 -0
- data/vendor/eigen/Eigen/src/Geometry/Transform.h +1542 -0
- data/vendor/eigen/Eigen/src/Geometry/Translation.h +208 -0
- data/vendor/eigen/Eigen/src/Geometry/Umeyama.h +166 -0
- data/vendor/eigen/Eigen/src/Geometry/arch/Geometry_SSE.h +161 -0
- data/vendor/eigen/Eigen/src/Householder/BlockHouseholder.h +103 -0
- data/vendor/eigen/Eigen/src/Householder/Householder.h +172 -0
- data/vendor/eigen/Eigen/src/Householder/HouseholderSequence.h +470 -0
- data/vendor/eigen/Eigen/src/IterativeLinearSolvers/BasicPreconditioners.h +226 -0
- data/vendor/eigen/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h +228 -0
- data/vendor/eigen/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h +246 -0
- data/vendor/eigen/Eigen/src/IterativeLinearSolvers/IncompleteCholesky.h +400 -0
- data/vendor/eigen/Eigen/src/IterativeLinearSolvers/IncompleteLUT.h +462 -0
- data/vendor/eigen/Eigen/src/IterativeLinearSolvers/IterativeSolverBase.h +394 -0
- data/vendor/eigen/Eigen/src/IterativeLinearSolvers/LeastSquareConjugateGradient.h +216 -0
- data/vendor/eigen/Eigen/src/IterativeLinearSolvers/SolveWithGuess.h +115 -0
- data/vendor/eigen/Eigen/src/Jacobi/Jacobi.h +462 -0
- data/vendor/eigen/Eigen/src/LU/Determinant.h +101 -0
- data/vendor/eigen/Eigen/src/LU/FullPivLU.h +891 -0
- data/vendor/eigen/Eigen/src/LU/InverseImpl.h +415 -0
- data/vendor/eigen/Eigen/src/LU/PartialPivLU.h +611 -0
- data/vendor/eigen/Eigen/src/LU/PartialPivLU_LAPACKE.h +83 -0
- data/vendor/eigen/Eigen/src/LU/arch/Inverse_SSE.h +338 -0
- data/vendor/eigen/Eigen/src/MetisSupport/MetisSupport.h +137 -0
- data/vendor/eigen/Eigen/src/OrderingMethods/Amd.h +445 -0
- data/vendor/eigen/Eigen/src/OrderingMethods/Eigen_Colamd.h +1843 -0
- data/vendor/eigen/Eigen/src/OrderingMethods/Ordering.h +157 -0
- data/vendor/eigen/Eigen/src/PaStiXSupport/PaStiXSupport.h +678 -0
- data/vendor/eigen/Eigen/src/PardisoSupport/PardisoSupport.h +543 -0
- data/vendor/eigen/Eigen/src/QR/ColPivHouseholderQR.h +653 -0
- data/vendor/eigen/Eigen/src/QR/ColPivHouseholderQR_LAPACKE.h +97 -0
- data/vendor/eigen/Eigen/src/QR/CompleteOrthogonalDecomposition.h +562 -0
- data/vendor/eigen/Eigen/src/QR/FullPivHouseholderQR.h +676 -0
- data/vendor/eigen/Eigen/src/QR/HouseholderQR.h +409 -0
- data/vendor/eigen/Eigen/src/QR/HouseholderQR_LAPACKE.h +68 -0
- data/vendor/eigen/Eigen/src/SPQRSupport/SuiteSparseQRSupport.h +313 -0
- data/vendor/eigen/Eigen/src/SVD/BDCSVD.h +1246 -0
- data/vendor/eigen/Eigen/src/SVD/JacobiSVD.h +804 -0
- data/vendor/eigen/Eigen/src/SVD/JacobiSVD_LAPACKE.h +91 -0
- data/vendor/eigen/Eigen/src/SVD/SVDBase.h +315 -0
- data/vendor/eigen/Eigen/src/SVD/UpperBidiagonalization.h +414 -0
- data/vendor/eigen/Eigen/src/SparseCholesky/SimplicialCholesky.h +689 -0
- data/vendor/eigen/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h +199 -0
- data/vendor/eigen/Eigen/src/SparseCore/AmbiVector.h +377 -0
- data/vendor/eigen/Eigen/src/SparseCore/CompressedStorage.h +258 -0
- data/vendor/eigen/Eigen/src/SparseCore/ConservativeSparseSparseProduct.h +352 -0
- data/vendor/eigen/Eigen/src/SparseCore/MappedSparseMatrix.h +67 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseAssign.h +216 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseBlock.h +603 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseColEtree.h +206 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseCompressedBase.h +341 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseCwiseBinaryOp.h +726 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseCwiseUnaryOp.h +148 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseDenseProduct.h +320 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseDiagonalProduct.h +138 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseDot.h +98 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseFuzzy.h +29 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseMap.h +305 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseMatrix.h +1403 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseMatrixBase.h +405 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparsePermutation.h +178 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseProduct.h +169 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseRedux.h +49 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseRef.h +397 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseSelfAdjointView.h +656 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseSolverBase.h +124 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseSparseProductWithPruning.h +198 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseTranspose.h +92 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseTriangularView.h +189 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseUtil.h +178 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseVector.h +478 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseView.h +253 -0
- data/vendor/eigen/Eigen/src/SparseCore/TriangularSolver.h +315 -0
- data/vendor/eigen/Eigen/src/SparseLU/SparseLU.h +773 -0
- data/vendor/eigen/Eigen/src/SparseLU/SparseLUImpl.h +66 -0
- data/vendor/eigen/Eigen/src/SparseLU/SparseLU_Memory.h +226 -0
- data/vendor/eigen/Eigen/src/SparseLU/SparseLU_Structs.h +110 -0
- data/vendor/eigen/Eigen/src/SparseLU/SparseLU_SupernodalMatrix.h +301 -0
- data/vendor/eigen/Eigen/src/SparseLU/SparseLU_Utils.h +80 -0
- data/vendor/eigen/Eigen/src/SparseLU/SparseLU_column_bmod.h +181 -0
- data/vendor/eigen/Eigen/src/SparseLU/SparseLU_column_dfs.h +179 -0
- data/vendor/eigen/Eigen/src/SparseLU/SparseLU_copy_to_ucol.h +107 -0
- data/vendor/eigen/Eigen/src/SparseLU/SparseLU_gemm_kernel.h +280 -0
- data/vendor/eigen/Eigen/src/SparseLU/SparseLU_heap_relax_snode.h +126 -0
- data/vendor/eigen/Eigen/src/SparseLU/SparseLU_kernel_bmod.h +130 -0
- data/vendor/eigen/Eigen/src/SparseLU/SparseLU_panel_bmod.h +223 -0
- data/vendor/eigen/Eigen/src/SparseLU/SparseLU_panel_dfs.h +258 -0
- data/vendor/eigen/Eigen/src/SparseLU/SparseLU_pivotL.h +137 -0
- data/vendor/eigen/Eigen/src/SparseLU/SparseLU_pruneL.h +136 -0
- data/vendor/eigen/Eigen/src/SparseLU/SparseLU_relax_snode.h +83 -0
- data/vendor/eigen/Eigen/src/SparseQR/SparseQR.h +745 -0
- data/vendor/eigen/Eigen/src/StlSupport/StdDeque.h +126 -0
- data/vendor/eigen/Eigen/src/StlSupport/StdList.h +106 -0
- data/vendor/eigen/Eigen/src/StlSupport/StdVector.h +131 -0
- data/vendor/eigen/Eigen/src/StlSupport/details.h +84 -0
- data/vendor/eigen/Eigen/src/SuperLUSupport/SuperLUSupport.h +1027 -0
- data/vendor/eigen/Eigen/src/UmfPackSupport/UmfPackSupport.h +506 -0
- data/vendor/eigen/Eigen/src/misc/Image.h +82 -0
- data/vendor/eigen/Eigen/src/misc/Kernel.h +79 -0
- data/vendor/eigen/Eigen/src/misc/RealSvd2x2.h +55 -0
- data/vendor/eigen/Eigen/src/misc/blas.h +440 -0
- data/vendor/eigen/Eigen/src/misc/lapack.h +152 -0
- data/vendor/eigen/Eigen/src/misc/lapacke.h +16291 -0
- data/vendor/eigen/Eigen/src/misc/lapacke_mangling.h +17 -0
- data/vendor/eigen/Eigen/src/plugins/ArrayCwiseBinaryOps.h +332 -0
- data/vendor/eigen/Eigen/src/plugins/ArrayCwiseUnaryOps.h +552 -0
- data/vendor/eigen/Eigen/src/plugins/BlockMethods.h +1058 -0
- data/vendor/eigen/Eigen/src/plugins/CommonCwiseBinaryOps.h +115 -0
- data/vendor/eigen/Eigen/src/plugins/CommonCwiseUnaryOps.h +163 -0
- data/vendor/eigen/Eigen/src/plugins/MatrixCwiseBinaryOps.h +152 -0
- data/vendor/eigen/Eigen/src/plugins/MatrixCwiseUnaryOps.h +85 -0
- data/vendor/eigen/README.md +3 -0
- data/vendor/eigen/bench/README.txt +55 -0
- data/vendor/eigen/bench/btl/COPYING +340 -0
- data/vendor/eigen/bench/btl/README +154 -0
- data/vendor/eigen/bench/tensors/README +21 -0
- data/vendor/eigen/blas/README.txt +6 -0
- data/vendor/eigen/demos/mandelbrot/README +10 -0
- data/vendor/eigen/demos/mix_eigen_and_c/README +9 -0
- data/vendor/eigen/demos/opengl/README +13 -0
- data/vendor/eigen/unsupported/Eigen/CXX11/src/Tensor/README.md +1760 -0
- data/vendor/eigen/unsupported/README.txt +50 -0
- data/vendor/tomotopy/LICENSE +21 -0
- data/vendor/tomotopy/README.kr.rst +375 -0
- data/vendor/tomotopy/README.rst +382 -0
- data/vendor/tomotopy/src/Labeling/FoRelevance.cpp +362 -0
- data/vendor/tomotopy/src/Labeling/FoRelevance.h +88 -0
- data/vendor/tomotopy/src/Labeling/Labeler.h +50 -0
- data/vendor/tomotopy/src/TopicModel/CT.h +37 -0
- data/vendor/tomotopy/src/TopicModel/CTModel.cpp +13 -0
- data/vendor/tomotopy/src/TopicModel/CTModel.hpp +293 -0
- data/vendor/tomotopy/src/TopicModel/DMR.h +51 -0
- data/vendor/tomotopy/src/TopicModel/DMRModel.cpp +13 -0
- data/vendor/tomotopy/src/TopicModel/DMRModel.hpp +374 -0
- data/vendor/tomotopy/src/TopicModel/DT.h +65 -0
- data/vendor/tomotopy/src/TopicModel/DTM.h +22 -0
- data/vendor/tomotopy/src/TopicModel/DTModel.cpp +15 -0
- data/vendor/tomotopy/src/TopicModel/DTModel.hpp +572 -0
- data/vendor/tomotopy/src/TopicModel/GDMR.h +37 -0
- data/vendor/tomotopy/src/TopicModel/GDMRModel.cpp +14 -0
- data/vendor/tomotopy/src/TopicModel/GDMRModel.hpp +485 -0
- data/vendor/tomotopy/src/TopicModel/HDP.h +74 -0
- data/vendor/tomotopy/src/TopicModel/HDPModel.cpp +13 -0
- data/vendor/tomotopy/src/TopicModel/HDPModel.hpp +592 -0
- data/vendor/tomotopy/src/TopicModel/HLDA.h +40 -0
- data/vendor/tomotopy/src/TopicModel/HLDAModel.cpp +13 -0
- data/vendor/tomotopy/src/TopicModel/HLDAModel.hpp +681 -0
- data/vendor/tomotopy/src/TopicModel/HPA.h +27 -0
- data/vendor/tomotopy/src/TopicModel/HPAModel.cpp +21 -0
- data/vendor/tomotopy/src/TopicModel/HPAModel.hpp +588 -0
- data/vendor/tomotopy/src/TopicModel/LDA.h +144 -0
- data/vendor/tomotopy/src/TopicModel/LDACVB0Model.hpp +442 -0
- data/vendor/tomotopy/src/TopicModel/LDAModel.cpp +13 -0
- data/vendor/tomotopy/src/TopicModel/LDAModel.hpp +1058 -0
- data/vendor/tomotopy/src/TopicModel/LLDA.h +45 -0
- data/vendor/tomotopy/src/TopicModel/LLDAModel.cpp +13 -0
- data/vendor/tomotopy/src/TopicModel/LLDAModel.hpp +203 -0
- data/vendor/tomotopy/src/TopicModel/MGLDA.h +63 -0
- data/vendor/tomotopy/src/TopicModel/MGLDAModel.cpp +17 -0
- data/vendor/tomotopy/src/TopicModel/MGLDAModel.hpp +558 -0
- data/vendor/tomotopy/src/TopicModel/PA.h +43 -0
- data/vendor/tomotopy/src/TopicModel/PAModel.cpp +13 -0
- data/vendor/tomotopy/src/TopicModel/PAModel.hpp +467 -0
- data/vendor/tomotopy/src/TopicModel/PLDA.h +17 -0
- data/vendor/tomotopy/src/TopicModel/PLDAModel.cpp +13 -0
- data/vendor/tomotopy/src/TopicModel/PLDAModel.hpp +214 -0
- data/vendor/tomotopy/src/TopicModel/SLDA.h +54 -0
- data/vendor/tomotopy/src/TopicModel/SLDAModel.cpp +17 -0
- data/vendor/tomotopy/src/TopicModel/SLDAModel.hpp +456 -0
- data/vendor/tomotopy/src/TopicModel/TopicModel.hpp +692 -0
- data/vendor/tomotopy/src/Utils/AliasMethod.hpp +169 -0
- data/vendor/tomotopy/src/Utils/Dictionary.h +80 -0
- data/vendor/tomotopy/src/Utils/EigenAddonOps.hpp +181 -0
- data/vendor/tomotopy/src/Utils/LBFGS.h +202 -0
- data/vendor/tomotopy/src/Utils/LBFGS/LineSearchBacktracking.h +120 -0
- data/vendor/tomotopy/src/Utils/LBFGS/LineSearchBracketing.h +122 -0
- data/vendor/tomotopy/src/Utils/LBFGS/Param.h +213 -0
- data/vendor/tomotopy/src/Utils/LUT.hpp +82 -0
- data/vendor/tomotopy/src/Utils/MultiNormalDistribution.hpp +69 -0
- data/vendor/tomotopy/src/Utils/PolyaGamma.hpp +200 -0
- data/vendor/tomotopy/src/Utils/PolyaGammaHybrid.hpp +672 -0
- data/vendor/tomotopy/src/Utils/ThreadPool.hpp +150 -0
- data/vendor/tomotopy/src/Utils/Trie.hpp +220 -0
- data/vendor/tomotopy/src/Utils/TruncMultiNormal.hpp +94 -0
- data/vendor/tomotopy/src/Utils/Utils.hpp +337 -0
- data/vendor/tomotopy/src/Utils/avx_gamma.h +46 -0
- data/vendor/tomotopy/src/Utils/avx_mathfun.h +736 -0
- data/vendor/tomotopy/src/Utils/exception.h +28 -0
- data/vendor/tomotopy/src/Utils/math.h +281 -0
- data/vendor/tomotopy/src/Utils/rtnorm.hpp +2690 -0
- data/vendor/tomotopy/src/Utils/sample.hpp +192 -0
- data/vendor/tomotopy/src/Utils/serializer.hpp +695 -0
- data/vendor/tomotopy/src/Utils/slp.hpp +131 -0
- data/vendor/tomotopy/src/Utils/sse_gamma.h +48 -0
- data/vendor/tomotopy/src/Utils/sse_mathfun.h +710 -0
- data/vendor/tomotopy/src/Utils/text.hpp +49 -0
- data/vendor/tomotopy/src/Utils/tvector.hpp +543 -0
- metadata +531 -0
@@ -0,0 +1,773 @@
|
|
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-2014 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::StorageIndex> > 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
|
+
* \implsparsesolverconcept
|
69
|
+
*
|
70
|
+
* \sa \ref TutorialSparseSolverConcept
|
71
|
+
* \sa \ref OrderingMethods_Module
|
72
|
+
*/
|
73
|
+
template <typename _MatrixType, typename _OrderingType>
|
74
|
+
class SparseLU : public SparseSolverBase<SparseLU<_MatrixType,_OrderingType> >, public internal::SparseLUImpl<typename _MatrixType::Scalar, typename _MatrixType::StorageIndex>
|
75
|
+
{
|
76
|
+
protected:
|
77
|
+
typedef SparseSolverBase<SparseLU<_MatrixType,_OrderingType> > APIBase;
|
78
|
+
using APIBase::m_isInitialized;
|
79
|
+
public:
|
80
|
+
using APIBase::_solve_impl;
|
81
|
+
|
82
|
+
typedef _MatrixType MatrixType;
|
83
|
+
typedef _OrderingType OrderingType;
|
84
|
+
typedef typename MatrixType::Scalar Scalar;
|
85
|
+
typedef typename MatrixType::RealScalar RealScalar;
|
86
|
+
typedef typename MatrixType::StorageIndex StorageIndex;
|
87
|
+
typedef SparseMatrix<Scalar,ColMajor,StorageIndex> NCMatrix;
|
88
|
+
typedef internal::MappedSuperNodalMatrix<Scalar, StorageIndex> SCMatrix;
|
89
|
+
typedef Matrix<Scalar,Dynamic,1> ScalarVector;
|
90
|
+
typedef Matrix<StorageIndex,Dynamic,1> IndexVector;
|
91
|
+
typedef PermutationMatrix<Dynamic, Dynamic, StorageIndex> PermutationType;
|
92
|
+
typedef internal::SparseLUImpl<Scalar, StorageIndex> Base;
|
93
|
+
|
94
|
+
enum {
|
95
|
+
ColsAtCompileTime = MatrixType::ColsAtCompileTime,
|
96
|
+
MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
|
97
|
+
};
|
98
|
+
|
99
|
+
public:
|
100
|
+
SparseLU():m_lastError(""),m_Ustore(0,0,0,0,0,0),m_symmetricmode(false),m_diagpivotthresh(1.0),m_detPermR(1)
|
101
|
+
{
|
102
|
+
initperfvalues();
|
103
|
+
}
|
104
|
+
explicit SparseLU(const MatrixType& matrix)
|
105
|
+
: m_lastError(""),m_Ustore(0,0,0,0,0,0),m_symmetricmode(false),m_diagpivotthresh(1.0),m_detPermR(1)
|
106
|
+
{
|
107
|
+
initperfvalues();
|
108
|
+
compute(matrix);
|
109
|
+
}
|
110
|
+
|
111
|
+
~SparseLU()
|
112
|
+
{
|
113
|
+
// Free all explicit dynamic pointers
|
114
|
+
}
|
115
|
+
|
116
|
+
void analyzePattern (const MatrixType& matrix);
|
117
|
+
void factorize (const MatrixType& matrix);
|
118
|
+
void simplicialfactorize(const MatrixType& matrix);
|
119
|
+
|
120
|
+
/**
|
121
|
+
* Compute the symbolic and numeric factorization of the input sparse matrix.
|
122
|
+
* The input matrix should be in column-major storage.
|
123
|
+
*/
|
124
|
+
void compute (const MatrixType& matrix)
|
125
|
+
{
|
126
|
+
// Analyze
|
127
|
+
analyzePattern(matrix);
|
128
|
+
//Factorize
|
129
|
+
factorize(matrix);
|
130
|
+
}
|
131
|
+
|
132
|
+
inline Index rows() const { return m_mat.rows(); }
|
133
|
+
inline Index cols() const { return m_mat.cols(); }
|
134
|
+
/** Indicate that the pattern of the input matrix is symmetric */
|
135
|
+
void isSymmetric(bool sym)
|
136
|
+
{
|
137
|
+
m_symmetricmode = sym;
|
138
|
+
}
|
139
|
+
|
140
|
+
/** \returns an expression of the matrix L, internally stored as supernodes
|
141
|
+
* The only operation available with this expression is the triangular solve
|
142
|
+
* \code
|
143
|
+
* y = b; matrixL().solveInPlace(y);
|
144
|
+
* \endcode
|
145
|
+
*/
|
146
|
+
SparseLUMatrixLReturnType<SCMatrix> matrixL() const
|
147
|
+
{
|
148
|
+
return SparseLUMatrixLReturnType<SCMatrix>(m_Lstore);
|
149
|
+
}
|
150
|
+
/** \returns an expression of the matrix U,
|
151
|
+
* The only operation available with this expression is the triangular solve
|
152
|
+
* \code
|
153
|
+
* y = b; matrixU().solveInPlace(y);
|
154
|
+
* \endcode
|
155
|
+
*/
|
156
|
+
SparseLUMatrixUReturnType<SCMatrix,MappedSparseMatrix<Scalar,ColMajor,StorageIndex> > matrixU() const
|
157
|
+
{
|
158
|
+
return SparseLUMatrixUReturnType<SCMatrix, MappedSparseMatrix<Scalar,ColMajor,StorageIndex> >(m_Lstore, m_Ustore);
|
159
|
+
}
|
160
|
+
|
161
|
+
/**
|
162
|
+
* \returns a reference to the row matrix permutation \f$ P_r \f$ such that \f$P_r A P_c^T = L U\f$
|
163
|
+
* \sa colsPermutation()
|
164
|
+
*/
|
165
|
+
inline const PermutationType& rowsPermutation() const
|
166
|
+
{
|
167
|
+
return m_perm_r;
|
168
|
+
}
|
169
|
+
/**
|
170
|
+
* \returns a reference to the column matrix permutation\f$ P_c^T \f$ such that \f$P_r A P_c^T = L U\f$
|
171
|
+
* \sa rowsPermutation()
|
172
|
+
*/
|
173
|
+
inline const PermutationType& colsPermutation() const
|
174
|
+
{
|
175
|
+
return m_perm_c;
|
176
|
+
}
|
177
|
+
/** Set the threshold used for a diagonal entry to be an acceptable pivot. */
|
178
|
+
void setPivotThreshold(const RealScalar& thresh)
|
179
|
+
{
|
180
|
+
m_diagpivotthresh = thresh;
|
181
|
+
}
|
182
|
+
|
183
|
+
#ifdef EIGEN_PARSED_BY_DOXYGEN
|
184
|
+
/** \returns the solution X of \f$ A X = B \f$ using the current decomposition of A.
|
185
|
+
*
|
186
|
+
* \warning the destination matrix X in X = this->solve(B) must be colmun-major.
|
187
|
+
*
|
188
|
+
* \sa compute()
|
189
|
+
*/
|
190
|
+
template<typename Rhs>
|
191
|
+
inline const Solve<SparseLU, Rhs> solve(const MatrixBase<Rhs>& B) const;
|
192
|
+
#endif // EIGEN_PARSED_BY_DOXYGEN
|
193
|
+
|
194
|
+
/** \brief Reports whether previous computation was successful.
|
195
|
+
*
|
196
|
+
* \returns \c Success if computation was succesful,
|
197
|
+
* \c NumericalIssue if the LU factorization reports a problem, zero diagonal for instance
|
198
|
+
* \c InvalidInput if the input matrix is invalid
|
199
|
+
*
|
200
|
+
* \sa iparm()
|
201
|
+
*/
|
202
|
+
ComputationInfo info() const
|
203
|
+
{
|
204
|
+
eigen_assert(m_isInitialized && "Decomposition is not initialized.");
|
205
|
+
return m_info;
|
206
|
+
}
|
207
|
+
|
208
|
+
/**
|
209
|
+
* \returns A string describing the type of error
|
210
|
+
*/
|
211
|
+
std::string lastErrorMessage() const
|
212
|
+
{
|
213
|
+
return m_lastError;
|
214
|
+
}
|
215
|
+
|
216
|
+
template<typename Rhs, typename Dest>
|
217
|
+
bool _solve_impl(const MatrixBase<Rhs> &B, MatrixBase<Dest> &X_base) const
|
218
|
+
{
|
219
|
+
Dest& X(X_base.derived());
|
220
|
+
eigen_assert(m_factorizationIsOk && "The matrix should be factorized first");
|
221
|
+
EIGEN_STATIC_ASSERT((Dest::Flags&RowMajorBit)==0,
|
222
|
+
THIS_METHOD_IS_ONLY_FOR_COLUMN_MAJOR_MATRICES);
|
223
|
+
|
224
|
+
// Permute the right hand side to form X = Pr*B
|
225
|
+
// on return, X is overwritten by the computed solution
|
226
|
+
X.resize(B.rows(),B.cols());
|
227
|
+
|
228
|
+
// this ugly const_cast_derived() helps to detect aliasing when applying the permutations
|
229
|
+
for(Index j = 0; j < B.cols(); ++j)
|
230
|
+
X.col(j) = rowsPermutation() * B.const_cast_derived().col(j);
|
231
|
+
|
232
|
+
//Forward substitution with L
|
233
|
+
this->matrixL().solveInPlace(X);
|
234
|
+
this->matrixU().solveInPlace(X);
|
235
|
+
|
236
|
+
// Permute back the solution
|
237
|
+
for (Index j = 0; j < B.cols(); ++j)
|
238
|
+
X.col(j) = colsPermutation().inverse() * X.col(j);
|
239
|
+
|
240
|
+
return true;
|
241
|
+
}
|
242
|
+
|
243
|
+
/**
|
244
|
+
* \returns the absolute value of the determinant of the matrix of which
|
245
|
+
* *this is the QR decomposition.
|
246
|
+
*
|
247
|
+
* \warning a determinant can be very big or small, so for matrices
|
248
|
+
* of large enough dimension, there is a risk of overflow/underflow.
|
249
|
+
* One way to work around that is to use logAbsDeterminant() instead.
|
250
|
+
*
|
251
|
+
* \sa logAbsDeterminant(), signDeterminant()
|
252
|
+
*/
|
253
|
+
Scalar absDeterminant()
|
254
|
+
{
|
255
|
+
using std::abs;
|
256
|
+
eigen_assert(m_factorizationIsOk && "The matrix should be factorized first.");
|
257
|
+
// Initialize with the determinant of the row matrix
|
258
|
+
Scalar det = Scalar(1.);
|
259
|
+
// Note that the diagonal blocks of U are stored in supernodes,
|
260
|
+
// which are available in the L part :)
|
261
|
+
for (Index j = 0; j < this->cols(); ++j)
|
262
|
+
{
|
263
|
+
for (typename SCMatrix::InnerIterator it(m_Lstore, j); it; ++it)
|
264
|
+
{
|
265
|
+
if(it.index() == j)
|
266
|
+
{
|
267
|
+
det *= abs(it.value());
|
268
|
+
break;
|
269
|
+
}
|
270
|
+
}
|
271
|
+
}
|
272
|
+
return det;
|
273
|
+
}
|
274
|
+
|
275
|
+
/** \returns the natural log of the absolute value of the determinant of the matrix
|
276
|
+
* of which **this is the QR decomposition
|
277
|
+
*
|
278
|
+
* \note This method is useful to work around the risk of overflow/underflow that's
|
279
|
+
* inherent to the determinant computation.
|
280
|
+
*
|
281
|
+
* \sa absDeterminant(), signDeterminant()
|
282
|
+
*/
|
283
|
+
Scalar logAbsDeterminant() const
|
284
|
+
{
|
285
|
+
using std::log;
|
286
|
+
using std::abs;
|
287
|
+
|
288
|
+
eigen_assert(m_factorizationIsOk && "The matrix should be factorized first.");
|
289
|
+
Scalar det = Scalar(0.);
|
290
|
+
for (Index j = 0; j < this->cols(); ++j)
|
291
|
+
{
|
292
|
+
for (typename SCMatrix::InnerIterator it(m_Lstore, j); it; ++it)
|
293
|
+
{
|
294
|
+
if(it.row() < j) continue;
|
295
|
+
if(it.row() == j)
|
296
|
+
{
|
297
|
+
det += log(abs(it.value()));
|
298
|
+
break;
|
299
|
+
}
|
300
|
+
}
|
301
|
+
}
|
302
|
+
return det;
|
303
|
+
}
|
304
|
+
|
305
|
+
/** \returns A number representing the sign of the determinant
|
306
|
+
*
|
307
|
+
* \sa absDeterminant(), logAbsDeterminant()
|
308
|
+
*/
|
309
|
+
Scalar signDeterminant()
|
310
|
+
{
|
311
|
+
eigen_assert(m_factorizationIsOk && "The matrix should be factorized first.");
|
312
|
+
// Initialize with the determinant of the row matrix
|
313
|
+
Index det = 1;
|
314
|
+
// Note that the diagonal blocks of U are stored in supernodes,
|
315
|
+
// which are available in the L part :)
|
316
|
+
for (Index j = 0; j < this->cols(); ++j)
|
317
|
+
{
|
318
|
+
for (typename SCMatrix::InnerIterator it(m_Lstore, j); it; ++it)
|
319
|
+
{
|
320
|
+
if(it.index() == j)
|
321
|
+
{
|
322
|
+
if(it.value()<0)
|
323
|
+
det = -det;
|
324
|
+
else if(it.value()==0)
|
325
|
+
return 0;
|
326
|
+
break;
|
327
|
+
}
|
328
|
+
}
|
329
|
+
}
|
330
|
+
return det * m_detPermR * m_detPermC;
|
331
|
+
}
|
332
|
+
|
333
|
+
/** \returns The determinant of the matrix.
|
334
|
+
*
|
335
|
+
* \sa absDeterminant(), logAbsDeterminant()
|
336
|
+
*/
|
337
|
+
Scalar determinant()
|
338
|
+
{
|
339
|
+
eigen_assert(m_factorizationIsOk && "The matrix should be factorized first.");
|
340
|
+
// Initialize with the determinant of the row matrix
|
341
|
+
Scalar det = Scalar(1.);
|
342
|
+
// Note that the diagonal blocks of U are stored in supernodes,
|
343
|
+
// which are available in the L part :)
|
344
|
+
for (Index j = 0; j < this->cols(); ++j)
|
345
|
+
{
|
346
|
+
for (typename SCMatrix::InnerIterator it(m_Lstore, j); it; ++it)
|
347
|
+
{
|
348
|
+
if(it.index() == j)
|
349
|
+
{
|
350
|
+
det *= it.value();
|
351
|
+
break;
|
352
|
+
}
|
353
|
+
}
|
354
|
+
}
|
355
|
+
return (m_detPermR * m_detPermC) > 0 ? det : -det;
|
356
|
+
}
|
357
|
+
|
358
|
+
protected:
|
359
|
+
// Functions
|
360
|
+
void initperfvalues()
|
361
|
+
{
|
362
|
+
m_perfv.panel_size = 16;
|
363
|
+
m_perfv.relax = 1;
|
364
|
+
m_perfv.maxsuper = 128;
|
365
|
+
m_perfv.rowblk = 16;
|
366
|
+
m_perfv.colblk = 8;
|
367
|
+
m_perfv.fillfactor = 20;
|
368
|
+
}
|
369
|
+
|
370
|
+
// Variables
|
371
|
+
mutable ComputationInfo m_info;
|
372
|
+
bool m_factorizationIsOk;
|
373
|
+
bool m_analysisIsOk;
|
374
|
+
std::string m_lastError;
|
375
|
+
NCMatrix m_mat; // The input (permuted ) matrix
|
376
|
+
SCMatrix m_Lstore; // The lower triangular matrix (supernodal)
|
377
|
+
MappedSparseMatrix<Scalar,ColMajor,StorageIndex> m_Ustore; // The upper triangular matrix
|
378
|
+
PermutationType m_perm_c; // Column permutation
|
379
|
+
PermutationType m_perm_r ; // Row permutation
|
380
|
+
IndexVector m_etree; // Column elimination tree
|
381
|
+
|
382
|
+
typename Base::GlobalLU_t m_glu;
|
383
|
+
|
384
|
+
// SparseLU options
|
385
|
+
bool m_symmetricmode;
|
386
|
+
// values for performance
|
387
|
+
internal::perfvalues m_perfv;
|
388
|
+
RealScalar m_diagpivotthresh; // Specifies the threshold used for a diagonal entry to be an acceptable pivot
|
389
|
+
Index m_nnzL, m_nnzU; // Nonzeros in L and U factors
|
390
|
+
Index m_detPermR, m_detPermC; // Determinants of the permutation matrices
|
391
|
+
private:
|
392
|
+
// Disable copy constructor
|
393
|
+
SparseLU (const SparseLU& );
|
394
|
+
|
395
|
+
}; // End class SparseLU
|
396
|
+
|
397
|
+
|
398
|
+
|
399
|
+
// Functions needed by the anaysis phase
|
400
|
+
/**
|
401
|
+
* Compute the column permutation to minimize the fill-in
|
402
|
+
*
|
403
|
+
* - Apply this permutation to the input matrix -
|
404
|
+
*
|
405
|
+
* - Compute the column elimination tree on the permuted matrix
|
406
|
+
*
|
407
|
+
* - Postorder the elimination tree and the column permutation
|
408
|
+
*
|
409
|
+
*/
|
410
|
+
template <typename MatrixType, typename OrderingType>
|
411
|
+
void SparseLU<MatrixType, OrderingType>::analyzePattern(const MatrixType& mat)
|
412
|
+
{
|
413
|
+
|
414
|
+
//TODO It is possible as in SuperLU to compute row and columns scaling vectors to equilibrate the matrix mat.
|
415
|
+
|
416
|
+
// Firstly, copy the whole input matrix.
|
417
|
+
m_mat = mat;
|
418
|
+
|
419
|
+
// Compute fill-in ordering
|
420
|
+
OrderingType ord;
|
421
|
+
ord(m_mat,m_perm_c);
|
422
|
+
|
423
|
+
// Apply the permutation to the column of the input matrix
|
424
|
+
if (m_perm_c.size())
|
425
|
+
{
|
426
|
+
m_mat.uncompress(); //NOTE: The effect of this command is only to create the InnerNonzeros pointers. FIXME : This vector is filled but not subsequently used.
|
427
|
+
// Then, permute only the column pointers
|
428
|
+
ei_declare_aligned_stack_constructed_variable(StorageIndex,outerIndexPtr,mat.cols()+1,mat.isCompressed()?const_cast<StorageIndex*>(mat.outerIndexPtr()):0);
|
429
|
+
|
430
|
+
// If the input matrix 'mat' is uncompressed, then the outer-indices do not match the ones of m_mat, and a copy is thus needed.
|
431
|
+
if(!mat.isCompressed())
|
432
|
+
IndexVector::Map(outerIndexPtr, mat.cols()+1) = IndexVector::Map(m_mat.outerIndexPtr(),mat.cols()+1);
|
433
|
+
|
434
|
+
// Apply the permutation and compute the nnz per column.
|
435
|
+
for (Index i = 0; i < mat.cols(); i++)
|
436
|
+
{
|
437
|
+
m_mat.outerIndexPtr()[m_perm_c.indices()(i)] = outerIndexPtr[i];
|
438
|
+
m_mat.innerNonZeroPtr()[m_perm_c.indices()(i)] = outerIndexPtr[i+1] - outerIndexPtr[i];
|
439
|
+
}
|
440
|
+
}
|
441
|
+
|
442
|
+
// Compute the column elimination tree of the permuted matrix
|
443
|
+
IndexVector firstRowElt;
|
444
|
+
internal::coletree(m_mat, m_etree,firstRowElt);
|
445
|
+
|
446
|
+
// In symmetric mode, do not do postorder here
|
447
|
+
if (!m_symmetricmode) {
|
448
|
+
IndexVector post, iwork;
|
449
|
+
// Post order etree
|
450
|
+
internal::treePostorder(StorageIndex(m_mat.cols()), m_etree, post);
|
451
|
+
|
452
|
+
|
453
|
+
// Renumber etree in postorder
|
454
|
+
Index m = m_mat.cols();
|
455
|
+
iwork.resize(m+1);
|
456
|
+
for (Index i = 0; i < m; ++i) iwork(post(i)) = post(m_etree(i));
|
457
|
+
m_etree = iwork;
|
458
|
+
|
459
|
+
// Postmultiply A*Pc by post, i.e reorder the matrix according to the postorder of the etree
|
460
|
+
PermutationType post_perm(m);
|
461
|
+
for (Index i = 0; i < m; i++)
|
462
|
+
post_perm.indices()(i) = post(i);
|
463
|
+
|
464
|
+
// Combine the two permutations : postorder the permutation for future use
|
465
|
+
if(m_perm_c.size()) {
|
466
|
+
m_perm_c = post_perm * m_perm_c;
|
467
|
+
}
|
468
|
+
|
469
|
+
} // end postordering
|
470
|
+
|
471
|
+
m_analysisIsOk = true;
|
472
|
+
}
|
473
|
+
|
474
|
+
// Functions needed by the numerical factorization phase
|
475
|
+
|
476
|
+
|
477
|
+
/**
|
478
|
+
* - Numerical factorization
|
479
|
+
* - Interleaved with the symbolic factorization
|
480
|
+
* On exit, info is
|
481
|
+
*
|
482
|
+
* = 0: successful factorization
|
483
|
+
*
|
484
|
+
* > 0: if info = i, and i is
|
485
|
+
*
|
486
|
+
* <= A->ncol: U(i,i) is exactly zero. The factorization has
|
487
|
+
* been completed, but the factor U is exactly singular,
|
488
|
+
* and division by zero will occur if it is used to solve a
|
489
|
+
* system of equations.
|
490
|
+
*
|
491
|
+
* > A->ncol: number of bytes allocated when memory allocation
|
492
|
+
* failure occurred, plus A->ncol. If lwork = -1, it is
|
493
|
+
* the estimated amount of space needed, plus A->ncol.
|
494
|
+
*/
|
495
|
+
template <typename MatrixType, typename OrderingType>
|
496
|
+
void SparseLU<MatrixType, OrderingType>::factorize(const MatrixType& matrix)
|
497
|
+
{
|
498
|
+
using internal::emptyIdxLU;
|
499
|
+
eigen_assert(m_analysisIsOk && "analyzePattern() should be called first");
|
500
|
+
eigen_assert((matrix.rows() == matrix.cols()) && "Only for squared matrices");
|
501
|
+
|
502
|
+
m_isInitialized = true;
|
503
|
+
|
504
|
+
|
505
|
+
// Apply the column permutation computed in analyzepattern()
|
506
|
+
// m_mat = matrix * m_perm_c.inverse();
|
507
|
+
m_mat = matrix;
|
508
|
+
if (m_perm_c.size())
|
509
|
+
{
|
510
|
+
m_mat.uncompress(); //NOTE: The effect of this command is only to create the InnerNonzeros pointers.
|
511
|
+
//Then, permute only the column pointers
|
512
|
+
const StorageIndex * outerIndexPtr;
|
513
|
+
if (matrix.isCompressed()) outerIndexPtr = matrix.outerIndexPtr();
|
514
|
+
else
|
515
|
+
{
|
516
|
+
StorageIndex* outerIndexPtr_t = new StorageIndex[matrix.cols()+1];
|
517
|
+
for(Index i = 0; i <= matrix.cols(); i++) outerIndexPtr_t[i] = m_mat.outerIndexPtr()[i];
|
518
|
+
outerIndexPtr = outerIndexPtr_t;
|
519
|
+
}
|
520
|
+
for (Index i = 0; i < matrix.cols(); i++)
|
521
|
+
{
|
522
|
+
m_mat.outerIndexPtr()[m_perm_c.indices()(i)] = outerIndexPtr[i];
|
523
|
+
m_mat.innerNonZeroPtr()[m_perm_c.indices()(i)] = outerIndexPtr[i+1] - outerIndexPtr[i];
|
524
|
+
}
|
525
|
+
if(!matrix.isCompressed()) delete[] outerIndexPtr;
|
526
|
+
}
|
527
|
+
else
|
528
|
+
{ //FIXME This should not be needed if the empty permutation is handled transparently
|
529
|
+
m_perm_c.resize(matrix.cols());
|
530
|
+
for(StorageIndex i = 0; i < matrix.cols(); ++i) m_perm_c.indices()(i) = i;
|
531
|
+
}
|
532
|
+
|
533
|
+
Index m = m_mat.rows();
|
534
|
+
Index n = m_mat.cols();
|
535
|
+
Index nnz = m_mat.nonZeros();
|
536
|
+
Index maxpanel = m_perfv.panel_size * m;
|
537
|
+
// Allocate working storage common to the factor routines
|
538
|
+
Index lwork = 0;
|
539
|
+
Index info = Base::memInit(m, n, nnz, lwork, m_perfv.fillfactor, m_perfv.panel_size, m_glu);
|
540
|
+
if (info)
|
541
|
+
{
|
542
|
+
m_lastError = "UNABLE TO ALLOCATE WORKING MEMORY\n\n" ;
|
543
|
+
m_factorizationIsOk = false;
|
544
|
+
return ;
|
545
|
+
}
|
546
|
+
|
547
|
+
// Set up pointers for integer working arrays
|
548
|
+
IndexVector segrep(m); segrep.setZero();
|
549
|
+
IndexVector parent(m); parent.setZero();
|
550
|
+
IndexVector xplore(m); xplore.setZero();
|
551
|
+
IndexVector repfnz(maxpanel);
|
552
|
+
IndexVector panel_lsub(maxpanel);
|
553
|
+
IndexVector xprune(n); xprune.setZero();
|
554
|
+
IndexVector marker(m*internal::LUNoMarker); marker.setZero();
|
555
|
+
|
556
|
+
repfnz.setConstant(-1);
|
557
|
+
panel_lsub.setConstant(-1);
|
558
|
+
|
559
|
+
// Set up pointers for scalar working arrays
|
560
|
+
ScalarVector dense;
|
561
|
+
dense.setZero(maxpanel);
|
562
|
+
ScalarVector tempv;
|
563
|
+
tempv.setZero(internal::LUnumTempV(m, m_perfv.panel_size, m_perfv.maxsuper, /*m_perfv.rowblk*/m) );
|
564
|
+
|
565
|
+
// Compute the inverse of perm_c
|
566
|
+
PermutationType iperm_c(m_perm_c.inverse());
|
567
|
+
|
568
|
+
// Identify initial relaxed snodes
|
569
|
+
IndexVector relax_end(n);
|
570
|
+
if ( m_symmetricmode == true )
|
571
|
+
Base::heap_relax_snode(n, m_etree, m_perfv.relax, marker, relax_end);
|
572
|
+
else
|
573
|
+
Base::relax_snode(n, m_etree, m_perfv.relax, marker, relax_end);
|
574
|
+
|
575
|
+
|
576
|
+
m_perm_r.resize(m);
|
577
|
+
m_perm_r.indices().setConstant(-1);
|
578
|
+
marker.setConstant(-1);
|
579
|
+
m_detPermR = 1; // Record the determinant of the row permutation
|
580
|
+
|
581
|
+
m_glu.supno(0) = emptyIdxLU; m_glu.xsup.setConstant(0);
|
582
|
+
m_glu.xsup(0) = m_glu.xlsub(0) = m_glu.xusub(0) = m_glu.xlusup(0) = Index(0);
|
583
|
+
|
584
|
+
// Work on one 'panel' at a time. A panel is one of the following :
|
585
|
+
// (a) a relaxed supernode at the bottom of the etree, or
|
586
|
+
// (b) panel_size contiguous columns, <panel_size> defined by the user
|
587
|
+
Index jcol;
|
588
|
+
IndexVector panel_histo(n);
|
589
|
+
Index pivrow; // Pivotal row number in the original row matrix
|
590
|
+
Index nseg1; // Number of segments in U-column above panel row jcol
|
591
|
+
Index nseg; // Number of segments in each U-column
|
592
|
+
Index irep;
|
593
|
+
Index i, k, jj;
|
594
|
+
for (jcol = 0; jcol < n; )
|
595
|
+
{
|
596
|
+
// Adjust panel size so that a panel won't overlap with the next relaxed snode.
|
597
|
+
Index panel_size = m_perfv.panel_size; // upper bound on panel width
|
598
|
+
for (k = jcol + 1; k < (std::min)(jcol+panel_size, n); k++)
|
599
|
+
{
|
600
|
+
if (relax_end(k) != emptyIdxLU)
|
601
|
+
{
|
602
|
+
panel_size = k - jcol;
|
603
|
+
break;
|
604
|
+
}
|
605
|
+
}
|
606
|
+
if (k == n)
|
607
|
+
panel_size = n - jcol;
|
608
|
+
|
609
|
+
// Symbolic outer factorization on a panel of columns
|
610
|
+
Base::panel_dfs(m, panel_size, jcol, m_mat, m_perm_r.indices(), nseg1, dense, panel_lsub, segrep, repfnz, xprune, marker, parent, xplore, m_glu);
|
611
|
+
|
612
|
+
// Numeric sup-panel updates in topological order
|
613
|
+
Base::panel_bmod(m, panel_size, jcol, nseg1, dense, tempv, segrep, repfnz, m_glu);
|
614
|
+
|
615
|
+
// Sparse LU within the panel, and below the panel diagonal
|
616
|
+
for ( jj = jcol; jj< jcol + panel_size; jj++)
|
617
|
+
{
|
618
|
+
k = (jj - jcol) * m; // Column index for w-wide arrays
|
619
|
+
|
620
|
+
nseg = nseg1; // begin after all the panel segments
|
621
|
+
//Depth-first-search for the current column
|
622
|
+
VectorBlock<IndexVector> panel_lsubk(panel_lsub, k, m);
|
623
|
+
VectorBlock<IndexVector> repfnz_k(repfnz, k, m);
|
624
|
+
info = Base::column_dfs(m, jj, m_perm_r.indices(), m_perfv.maxsuper, nseg, panel_lsubk, segrep, repfnz_k, xprune, marker, parent, xplore, m_glu);
|
625
|
+
if ( info )
|
626
|
+
{
|
627
|
+
m_lastError = "UNABLE TO EXPAND MEMORY IN COLUMN_DFS() ";
|
628
|
+
m_info = NumericalIssue;
|
629
|
+
m_factorizationIsOk = false;
|
630
|
+
return;
|
631
|
+
}
|
632
|
+
// Numeric updates to this column
|
633
|
+
VectorBlock<ScalarVector> dense_k(dense, k, m);
|
634
|
+
VectorBlock<IndexVector> segrep_k(segrep, nseg1, m-nseg1);
|
635
|
+
info = Base::column_bmod(jj, (nseg - nseg1), dense_k, tempv, segrep_k, repfnz_k, jcol, m_glu);
|
636
|
+
if ( info )
|
637
|
+
{
|
638
|
+
m_lastError = "UNABLE TO EXPAND MEMORY IN COLUMN_BMOD() ";
|
639
|
+
m_info = NumericalIssue;
|
640
|
+
m_factorizationIsOk = false;
|
641
|
+
return;
|
642
|
+
}
|
643
|
+
|
644
|
+
// Copy the U-segments to ucol(*)
|
645
|
+
info = Base::copy_to_ucol(jj, nseg, segrep, repfnz_k ,m_perm_r.indices(), dense_k, m_glu);
|
646
|
+
if ( info )
|
647
|
+
{
|
648
|
+
m_lastError = "UNABLE TO EXPAND MEMORY IN COPY_TO_UCOL() ";
|
649
|
+
m_info = NumericalIssue;
|
650
|
+
m_factorizationIsOk = false;
|
651
|
+
return;
|
652
|
+
}
|
653
|
+
|
654
|
+
// Form the L-segment
|
655
|
+
info = Base::pivotL(jj, m_diagpivotthresh, m_perm_r.indices(), iperm_c.indices(), pivrow, m_glu);
|
656
|
+
if ( info )
|
657
|
+
{
|
658
|
+
m_lastError = "THE MATRIX IS STRUCTURALLY SINGULAR ... ZERO COLUMN AT ";
|
659
|
+
std::ostringstream returnInfo;
|
660
|
+
returnInfo << info;
|
661
|
+
m_lastError += returnInfo.str();
|
662
|
+
m_info = NumericalIssue;
|
663
|
+
m_factorizationIsOk = false;
|
664
|
+
return;
|
665
|
+
}
|
666
|
+
|
667
|
+
// Update the determinant of the row permutation matrix
|
668
|
+
// FIXME: the following test is not correct, we should probably take iperm_c into account and pivrow is not directly the row pivot.
|
669
|
+
if (pivrow != jj) m_detPermR = -m_detPermR;
|
670
|
+
|
671
|
+
// Prune columns (0:jj-1) using column jj
|
672
|
+
Base::pruneL(jj, m_perm_r.indices(), pivrow, nseg, segrep, repfnz_k, xprune, m_glu);
|
673
|
+
|
674
|
+
// Reset repfnz for this column
|
675
|
+
for (i = 0; i < nseg; i++)
|
676
|
+
{
|
677
|
+
irep = segrep(i);
|
678
|
+
repfnz_k(irep) = emptyIdxLU;
|
679
|
+
}
|
680
|
+
} // end SparseLU within the panel
|
681
|
+
jcol += panel_size; // Move to the next panel
|
682
|
+
} // end for -- end elimination
|
683
|
+
|
684
|
+
m_detPermR = m_perm_r.determinant();
|
685
|
+
m_detPermC = m_perm_c.determinant();
|
686
|
+
|
687
|
+
// Count the number of nonzeros in factors
|
688
|
+
Base::countnz(n, m_nnzL, m_nnzU, m_glu);
|
689
|
+
// Apply permutation to the L subscripts
|
690
|
+
Base::fixupL(n, m_perm_r.indices(), m_glu);
|
691
|
+
|
692
|
+
// Create supernode matrix L
|
693
|
+
m_Lstore.setInfos(m, n, m_glu.lusup, m_glu.xlusup, m_glu.lsub, m_glu.xlsub, m_glu.supno, m_glu.xsup);
|
694
|
+
// Create the column major upper sparse matrix U;
|
695
|
+
new (&m_Ustore) MappedSparseMatrix<Scalar, ColMajor, StorageIndex> ( m, n, m_nnzU, m_glu.xusub.data(), m_glu.usub.data(), m_glu.ucol.data() );
|
696
|
+
|
697
|
+
m_info = Success;
|
698
|
+
m_factorizationIsOk = true;
|
699
|
+
}
|
700
|
+
|
701
|
+
template<typename MappedSupernodalType>
|
702
|
+
struct SparseLUMatrixLReturnType : internal::no_assignment_operator
|
703
|
+
{
|
704
|
+
typedef typename MappedSupernodalType::Scalar Scalar;
|
705
|
+
explicit SparseLUMatrixLReturnType(const MappedSupernodalType& mapL) : m_mapL(mapL)
|
706
|
+
{ }
|
707
|
+
Index rows() { return m_mapL.rows(); }
|
708
|
+
Index cols() { return m_mapL.cols(); }
|
709
|
+
template<typename Dest>
|
710
|
+
void solveInPlace( MatrixBase<Dest> &X) const
|
711
|
+
{
|
712
|
+
m_mapL.solveInPlace(X);
|
713
|
+
}
|
714
|
+
const MappedSupernodalType& m_mapL;
|
715
|
+
};
|
716
|
+
|
717
|
+
template<typename MatrixLType, typename MatrixUType>
|
718
|
+
struct SparseLUMatrixUReturnType : internal::no_assignment_operator
|
719
|
+
{
|
720
|
+
typedef typename MatrixLType::Scalar Scalar;
|
721
|
+
SparseLUMatrixUReturnType(const MatrixLType& mapL, const MatrixUType& mapU)
|
722
|
+
: m_mapL(mapL),m_mapU(mapU)
|
723
|
+
{ }
|
724
|
+
Index rows() { return m_mapL.rows(); }
|
725
|
+
Index cols() { return m_mapL.cols(); }
|
726
|
+
|
727
|
+
template<typename Dest> void solveInPlace(MatrixBase<Dest> &X) const
|
728
|
+
{
|
729
|
+
Index nrhs = X.cols();
|
730
|
+
Index n = X.rows();
|
731
|
+
// Backward solve with U
|
732
|
+
for (Index k = m_mapL.nsuper(); k >= 0; k--)
|
733
|
+
{
|
734
|
+
Index fsupc = m_mapL.supToCol()[k];
|
735
|
+
Index lda = m_mapL.colIndexPtr()[fsupc+1] - m_mapL.colIndexPtr()[fsupc]; // leading dimension
|
736
|
+
Index nsupc = m_mapL.supToCol()[k+1] - fsupc;
|
737
|
+
Index luptr = m_mapL.colIndexPtr()[fsupc];
|
738
|
+
|
739
|
+
if (nsupc == 1)
|
740
|
+
{
|
741
|
+
for (Index j = 0; j < nrhs; j++)
|
742
|
+
{
|
743
|
+
X(fsupc, j) /= m_mapL.valuePtr()[luptr];
|
744
|
+
}
|
745
|
+
}
|
746
|
+
else
|
747
|
+
{
|
748
|
+
Map<const Matrix<Scalar,Dynamic,Dynamic, ColMajor>, 0, OuterStride<> > A( &(m_mapL.valuePtr()[luptr]), nsupc, nsupc, OuterStride<>(lda) );
|
749
|
+
Map< Matrix<Scalar,Dynamic,Dest::ColsAtCompileTime, ColMajor>, 0, OuterStride<> > U (&(X(fsupc,0)), nsupc, nrhs, OuterStride<>(n) );
|
750
|
+
U = A.template triangularView<Upper>().solve(U);
|
751
|
+
}
|
752
|
+
|
753
|
+
for (Index j = 0; j < nrhs; ++j)
|
754
|
+
{
|
755
|
+
for (Index jcol = fsupc; jcol < fsupc + nsupc; jcol++)
|
756
|
+
{
|
757
|
+
typename MatrixUType::InnerIterator it(m_mapU, jcol);
|
758
|
+
for ( ; it; ++it)
|
759
|
+
{
|
760
|
+
Index irow = it.index();
|
761
|
+
X(irow, j) -= X(jcol, j) * it.value();
|
762
|
+
}
|
763
|
+
}
|
764
|
+
}
|
765
|
+
} // End For U-solve
|
766
|
+
}
|
767
|
+
const MatrixLType& m_mapL;
|
768
|
+
const MatrixUType& m_mapU;
|
769
|
+
};
|
770
|
+
|
771
|
+
} // End namespace Eigen
|
772
|
+
|
773
|
+
#endif
|