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,91 @@
|
|
1
|
+
/*
|
2
|
+
Copyright (c) 2011, Intel Corporation. All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without modification,
|
5
|
+
are permitted provided that the following conditions are met:
|
6
|
+
|
7
|
+
* Redistributions of source code must retain the above copyright notice, this
|
8
|
+
list of conditions and the following disclaimer.
|
9
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
10
|
+
this list of conditions and the following disclaimer in the documentation
|
11
|
+
and/or other materials provided with the distribution.
|
12
|
+
* Neither the name of Intel Corporation nor the names of its contributors may
|
13
|
+
be used to endorse or promote products derived from this software without
|
14
|
+
specific prior written permission.
|
15
|
+
|
16
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
17
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
18
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
19
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
20
|
+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
21
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
22
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
23
|
+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
24
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
25
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
26
|
+
|
27
|
+
********************************************************************************
|
28
|
+
* Content : Eigen bindings to LAPACKe
|
29
|
+
* Singular Value Decomposition - SVD.
|
30
|
+
********************************************************************************
|
31
|
+
*/
|
32
|
+
|
33
|
+
#ifndef EIGEN_JACOBISVD_LAPACKE_H
|
34
|
+
#define EIGEN_JACOBISVD_LAPACKE_H
|
35
|
+
|
36
|
+
namespace Eigen {
|
37
|
+
|
38
|
+
/** \internal Specialization for the data types supported by LAPACKe */
|
39
|
+
|
40
|
+
#define EIGEN_LAPACKE_SVD(EIGTYPE, LAPACKE_TYPE, LAPACKE_RTYPE, LAPACKE_PREFIX, EIGCOLROW, LAPACKE_COLROW) \
|
41
|
+
template<> inline \
|
42
|
+
JacobiSVD<Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW, Dynamic, Dynamic>, ColPivHouseholderQRPreconditioner>& \
|
43
|
+
JacobiSVD<Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW, Dynamic, Dynamic>, ColPivHouseholderQRPreconditioner>::compute(const Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW, Dynamic, Dynamic>& matrix, unsigned int computationOptions) \
|
44
|
+
{ \
|
45
|
+
typedef Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW, Dynamic, Dynamic> MatrixType; \
|
46
|
+
/*typedef MatrixType::Scalar Scalar;*/ \
|
47
|
+
/*typedef MatrixType::RealScalar RealScalar;*/ \
|
48
|
+
allocate(matrix.rows(), matrix.cols(), computationOptions); \
|
49
|
+
\
|
50
|
+
/*const RealScalar precision = RealScalar(2) * NumTraits<Scalar>::epsilon();*/ \
|
51
|
+
m_nonzeroSingularValues = m_diagSize; \
|
52
|
+
\
|
53
|
+
lapack_int lda = internal::convert_index<lapack_int>(matrix.outerStride()), ldu, ldvt; \
|
54
|
+
lapack_int matrix_order = LAPACKE_COLROW; \
|
55
|
+
char jobu, jobvt; \
|
56
|
+
LAPACKE_TYPE *u, *vt, dummy; \
|
57
|
+
jobu = (m_computeFullU) ? 'A' : (m_computeThinU) ? 'S' : 'N'; \
|
58
|
+
jobvt = (m_computeFullV) ? 'A' : (m_computeThinV) ? 'S' : 'N'; \
|
59
|
+
if (computeU()) { \
|
60
|
+
ldu = internal::convert_index<lapack_int>(m_matrixU.outerStride()); \
|
61
|
+
u = (LAPACKE_TYPE*)m_matrixU.data(); \
|
62
|
+
} else { ldu=1; u=&dummy; }\
|
63
|
+
MatrixType localV; \
|
64
|
+
lapack_int vt_rows = (m_computeFullV) ? internal::convert_index<lapack_int>(m_cols) : (m_computeThinV) ? internal::convert_index<lapack_int>(m_diagSize) : 1; \
|
65
|
+
if (computeV()) { \
|
66
|
+
localV.resize(vt_rows, m_cols); \
|
67
|
+
ldvt = internal::convert_index<lapack_int>(localV.outerStride()); \
|
68
|
+
vt = (LAPACKE_TYPE*)localV.data(); \
|
69
|
+
} else { ldvt=1; vt=&dummy; }\
|
70
|
+
Matrix<LAPACKE_RTYPE, Dynamic, Dynamic> superb; superb.resize(m_diagSize, 1); \
|
71
|
+
MatrixType m_temp; m_temp = matrix; \
|
72
|
+
LAPACKE_##LAPACKE_PREFIX##gesvd( matrix_order, jobu, jobvt, internal::convert_index<lapack_int>(m_rows), internal::convert_index<lapack_int>(m_cols), (LAPACKE_TYPE*)m_temp.data(), lda, (LAPACKE_RTYPE*)m_singularValues.data(), u, ldu, vt, ldvt, superb.data()); \
|
73
|
+
if (computeV()) m_matrixV = localV.adjoint(); \
|
74
|
+
/* for(int i=0;i<m_diagSize;i++) if (m_singularValues.coeffRef(i) < precision) { m_nonzeroSingularValues--; m_singularValues.coeffRef(i)=RealScalar(0);}*/ \
|
75
|
+
m_isInitialized = true; \
|
76
|
+
return *this; \
|
77
|
+
}
|
78
|
+
|
79
|
+
EIGEN_LAPACKE_SVD(double, double, double, d, ColMajor, LAPACK_COL_MAJOR)
|
80
|
+
EIGEN_LAPACKE_SVD(float, float, float , s, ColMajor, LAPACK_COL_MAJOR)
|
81
|
+
EIGEN_LAPACKE_SVD(dcomplex, lapack_complex_double, double, z, ColMajor, LAPACK_COL_MAJOR)
|
82
|
+
EIGEN_LAPACKE_SVD(scomplex, lapack_complex_float, float , c, ColMajor, LAPACK_COL_MAJOR)
|
83
|
+
|
84
|
+
EIGEN_LAPACKE_SVD(double, double, double, d, RowMajor, LAPACK_ROW_MAJOR)
|
85
|
+
EIGEN_LAPACKE_SVD(float, float, float , s, RowMajor, LAPACK_ROW_MAJOR)
|
86
|
+
EIGEN_LAPACKE_SVD(dcomplex, lapack_complex_double, double, z, RowMajor, LAPACK_ROW_MAJOR)
|
87
|
+
EIGEN_LAPACKE_SVD(scomplex, lapack_complex_float, float , c, RowMajor, LAPACK_ROW_MAJOR)
|
88
|
+
|
89
|
+
} // end namespace Eigen
|
90
|
+
|
91
|
+
#endif // EIGEN_JACOBISVD_LAPACKE_H
|
@@ -0,0 +1,315 @@
|
|
1
|
+
// This file is part of Eigen, a lightweight C++ template library
|
2
|
+
// for linear algebra.
|
3
|
+
//
|
4
|
+
// Copyright (C) 2009-2010 Benoit Jacob <jacob.benoit.1@gmail.com>
|
5
|
+
// Copyright (C) 2014 Gael Guennebaud <gael.guennebaud@inria.fr>
|
6
|
+
//
|
7
|
+
// Copyright (C) 2013 Gauthier Brun <brun.gauthier@gmail.com>
|
8
|
+
// Copyright (C) 2013 Nicolas Carre <nicolas.carre@ensimag.fr>
|
9
|
+
// Copyright (C) 2013 Jean Ceccato <jean.ceccato@ensimag.fr>
|
10
|
+
// Copyright (C) 2013 Pierre Zoppitelli <pierre.zoppitelli@ensimag.fr>
|
11
|
+
//
|
12
|
+
// This Source Code Form is subject to the terms of the Mozilla
|
13
|
+
// Public License v. 2.0. If a copy of the MPL was not distributed
|
14
|
+
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
15
|
+
|
16
|
+
#ifndef EIGEN_SVDBASE_H
|
17
|
+
#define EIGEN_SVDBASE_H
|
18
|
+
|
19
|
+
namespace Eigen {
|
20
|
+
/** \ingroup SVD_Module
|
21
|
+
*
|
22
|
+
*
|
23
|
+
* \class SVDBase
|
24
|
+
*
|
25
|
+
* \brief Base class of SVD algorithms
|
26
|
+
*
|
27
|
+
* \tparam Derived the type of the actual SVD decomposition
|
28
|
+
*
|
29
|
+
* SVD decomposition consists in decomposing any n-by-p matrix \a A as a product
|
30
|
+
* \f[ A = U S V^* \f]
|
31
|
+
* where \a U is a n-by-n unitary, \a V is a p-by-p unitary, and \a S is a n-by-p real positive matrix which is zero outside of its main diagonal;
|
32
|
+
* the diagonal entries of S are known as the \em singular \em values of \a A and the columns of \a U and \a V are known as the left
|
33
|
+
* and right \em singular \em vectors of \a A respectively.
|
34
|
+
*
|
35
|
+
* Singular values are always sorted in decreasing order.
|
36
|
+
*
|
37
|
+
*
|
38
|
+
* You can ask for only \em thin \a U or \a V to be computed, meaning the following. In case of a rectangular n-by-p matrix, letting \a m be the
|
39
|
+
* smaller value among \a n and \a p, there are only \a m singular vectors; the remaining columns of \a U and \a V do not correspond to actual
|
40
|
+
* singular vectors. Asking for \em thin \a U or \a V means asking for only their \a m first columns to be formed. So \a U is then a n-by-m matrix,
|
41
|
+
* and \a V is then a p-by-m matrix. Notice that thin \a U and \a V are all you need for (least squares) solving.
|
42
|
+
*
|
43
|
+
* If the input matrix has inf or nan coefficients, the result of the computation is undefined, but the computation is guaranteed to
|
44
|
+
* terminate in finite (and reasonable) time.
|
45
|
+
* \sa class BDCSVD, class JacobiSVD
|
46
|
+
*/
|
47
|
+
template<typename Derived>
|
48
|
+
class SVDBase
|
49
|
+
{
|
50
|
+
|
51
|
+
public:
|
52
|
+
typedef typename internal::traits<Derived>::MatrixType MatrixType;
|
53
|
+
typedef typename MatrixType::Scalar Scalar;
|
54
|
+
typedef typename NumTraits<typename MatrixType::Scalar>::Real RealScalar;
|
55
|
+
typedef typename MatrixType::StorageIndex StorageIndex;
|
56
|
+
typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3
|
57
|
+
enum {
|
58
|
+
RowsAtCompileTime = MatrixType::RowsAtCompileTime,
|
59
|
+
ColsAtCompileTime = MatrixType::ColsAtCompileTime,
|
60
|
+
DiagSizeAtCompileTime = EIGEN_SIZE_MIN_PREFER_DYNAMIC(RowsAtCompileTime,ColsAtCompileTime),
|
61
|
+
MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
|
62
|
+
MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime,
|
63
|
+
MaxDiagSizeAtCompileTime = EIGEN_SIZE_MIN_PREFER_FIXED(MaxRowsAtCompileTime,MaxColsAtCompileTime),
|
64
|
+
MatrixOptions = MatrixType::Options
|
65
|
+
};
|
66
|
+
|
67
|
+
typedef Matrix<Scalar, RowsAtCompileTime, RowsAtCompileTime, MatrixOptions, MaxRowsAtCompileTime, MaxRowsAtCompileTime> MatrixUType;
|
68
|
+
typedef Matrix<Scalar, ColsAtCompileTime, ColsAtCompileTime, MatrixOptions, MaxColsAtCompileTime, MaxColsAtCompileTime> MatrixVType;
|
69
|
+
typedef typename internal::plain_diag_type<MatrixType, RealScalar>::type SingularValuesType;
|
70
|
+
|
71
|
+
Derived& derived() { return *static_cast<Derived*>(this); }
|
72
|
+
const Derived& derived() const { return *static_cast<const Derived*>(this); }
|
73
|
+
|
74
|
+
/** \returns the \a U matrix.
|
75
|
+
*
|
76
|
+
* For the SVD decomposition of a n-by-p matrix, letting \a m be the minimum of \a n and \a p,
|
77
|
+
* the U matrix is n-by-n if you asked for \link Eigen::ComputeFullU ComputeFullU \endlink, and is n-by-m if you asked for \link Eigen::ComputeThinU ComputeThinU \endlink.
|
78
|
+
*
|
79
|
+
* The \a m first columns of \a U are the left singular vectors of the matrix being decomposed.
|
80
|
+
*
|
81
|
+
* This method asserts that you asked for \a U to be computed.
|
82
|
+
*/
|
83
|
+
const MatrixUType& matrixU() const
|
84
|
+
{
|
85
|
+
eigen_assert(m_isInitialized && "SVD is not initialized.");
|
86
|
+
eigen_assert(computeU() && "This SVD decomposition didn't compute U. Did you ask for it?");
|
87
|
+
return m_matrixU;
|
88
|
+
}
|
89
|
+
|
90
|
+
/** \returns the \a V matrix.
|
91
|
+
*
|
92
|
+
* For the SVD decomposition of a n-by-p matrix, letting \a m be the minimum of \a n and \a p,
|
93
|
+
* the V matrix is p-by-p if you asked for \link Eigen::ComputeFullV ComputeFullV \endlink, and is p-by-m if you asked for \link Eigen::ComputeThinV ComputeThinV \endlink.
|
94
|
+
*
|
95
|
+
* The \a m first columns of \a V are the right singular vectors of the matrix being decomposed.
|
96
|
+
*
|
97
|
+
* This method asserts that you asked for \a V to be computed.
|
98
|
+
*/
|
99
|
+
const MatrixVType& matrixV() const
|
100
|
+
{
|
101
|
+
eigen_assert(m_isInitialized && "SVD is not initialized.");
|
102
|
+
eigen_assert(computeV() && "This SVD decomposition didn't compute V. Did you ask for it?");
|
103
|
+
return m_matrixV;
|
104
|
+
}
|
105
|
+
|
106
|
+
/** \returns the vector of singular values.
|
107
|
+
*
|
108
|
+
* For the SVD decomposition of a n-by-p matrix, letting \a m be the minimum of \a n and \a p, the
|
109
|
+
* returned vector has size \a m. Singular values are always sorted in decreasing order.
|
110
|
+
*/
|
111
|
+
const SingularValuesType& singularValues() const
|
112
|
+
{
|
113
|
+
eigen_assert(m_isInitialized && "SVD is not initialized.");
|
114
|
+
return m_singularValues;
|
115
|
+
}
|
116
|
+
|
117
|
+
/** \returns the number of singular values that are not exactly 0 */
|
118
|
+
Index nonzeroSingularValues() const
|
119
|
+
{
|
120
|
+
eigen_assert(m_isInitialized && "SVD is not initialized.");
|
121
|
+
return m_nonzeroSingularValues;
|
122
|
+
}
|
123
|
+
|
124
|
+
/** \returns the rank of the matrix of which \c *this is the SVD.
|
125
|
+
*
|
126
|
+
* \note This method has to determine which singular values should be considered nonzero.
|
127
|
+
* For that, it uses the threshold value that you can control by calling
|
128
|
+
* setThreshold(const RealScalar&).
|
129
|
+
*/
|
130
|
+
inline Index rank() const
|
131
|
+
{
|
132
|
+
using std::abs;
|
133
|
+
eigen_assert(m_isInitialized && "JacobiSVD is not initialized.");
|
134
|
+
if(m_singularValues.size()==0) return 0;
|
135
|
+
RealScalar premultiplied_threshold = numext::maxi<RealScalar>(m_singularValues.coeff(0) * threshold(), (std::numeric_limits<RealScalar>::min)());
|
136
|
+
Index i = m_nonzeroSingularValues-1;
|
137
|
+
while(i>=0 && m_singularValues.coeff(i) < premultiplied_threshold) --i;
|
138
|
+
return i+1;
|
139
|
+
}
|
140
|
+
|
141
|
+
/** Allows to prescribe a threshold to be used by certain methods, such as rank() and solve(),
|
142
|
+
* which need to determine when singular values are to be considered nonzero.
|
143
|
+
* This is not used for the SVD decomposition itself.
|
144
|
+
*
|
145
|
+
* When it needs to get the threshold value, Eigen calls threshold().
|
146
|
+
* The default is \c NumTraits<Scalar>::epsilon()
|
147
|
+
*
|
148
|
+
* \param threshold The new value to use as the threshold.
|
149
|
+
*
|
150
|
+
* A singular value will be considered nonzero if its value is strictly greater than
|
151
|
+
* \f$ \vert singular value \vert \leqslant threshold \times \vert max singular value \vert \f$.
|
152
|
+
*
|
153
|
+
* If you want to come back to the default behavior, call setThreshold(Default_t)
|
154
|
+
*/
|
155
|
+
Derived& setThreshold(const RealScalar& threshold)
|
156
|
+
{
|
157
|
+
m_usePrescribedThreshold = true;
|
158
|
+
m_prescribedThreshold = threshold;
|
159
|
+
return derived();
|
160
|
+
}
|
161
|
+
|
162
|
+
/** Allows to come back to the default behavior, letting Eigen use its default formula for
|
163
|
+
* determining the threshold.
|
164
|
+
*
|
165
|
+
* You should pass the special object Eigen::Default as parameter here.
|
166
|
+
* \code svd.setThreshold(Eigen::Default); \endcode
|
167
|
+
*
|
168
|
+
* See the documentation of setThreshold(const RealScalar&).
|
169
|
+
*/
|
170
|
+
Derived& setThreshold(Default_t)
|
171
|
+
{
|
172
|
+
m_usePrescribedThreshold = false;
|
173
|
+
return derived();
|
174
|
+
}
|
175
|
+
|
176
|
+
/** Returns the threshold that will be used by certain methods such as rank().
|
177
|
+
*
|
178
|
+
* See the documentation of setThreshold(const RealScalar&).
|
179
|
+
*/
|
180
|
+
RealScalar threshold() const
|
181
|
+
{
|
182
|
+
eigen_assert(m_isInitialized || m_usePrescribedThreshold);
|
183
|
+
// this temporary is needed to workaround a MSVC issue
|
184
|
+
Index diagSize = (std::max<Index>)(1,m_diagSize);
|
185
|
+
return m_usePrescribedThreshold ? m_prescribedThreshold
|
186
|
+
: diagSize*NumTraits<Scalar>::epsilon();
|
187
|
+
}
|
188
|
+
|
189
|
+
/** \returns true if \a U (full or thin) is asked for in this SVD decomposition */
|
190
|
+
inline bool computeU() const { return m_computeFullU || m_computeThinU; }
|
191
|
+
/** \returns true if \a V (full or thin) is asked for in this SVD decomposition */
|
192
|
+
inline bool computeV() const { return m_computeFullV || m_computeThinV; }
|
193
|
+
|
194
|
+
inline Index rows() const { return m_rows; }
|
195
|
+
inline Index cols() const { return m_cols; }
|
196
|
+
|
197
|
+
/** \returns a (least squares) solution of \f$ A x = b \f$ using the current SVD decomposition of A.
|
198
|
+
*
|
199
|
+
* \param b the right-hand-side of the equation to solve.
|
200
|
+
*
|
201
|
+
* \note Solving requires both U and V to be computed. Thin U and V are enough, there is no need for full U or V.
|
202
|
+
*
|
203
|
+
* \note SVD solving is implicitly least-squares. Thus, this method serves both purposes of exact solving and least-squares solving.
|
204
|
+
* In other words, the returned solution is guaranteed to minimize the Euclidean norm \f$ \Vert A x - b \Vert \f$.
|
205
|
+
*/
|
206
|
+
template<typename Rhs>
|
207
|
+
inline const Solve<Derived, Rhs>
|
208
|
+
solve(const MatrixBase<Rhs>& b) const
|
209
|
+
{
|
210
|
+
eigen_assert(m_isInitialized && "SVD is not initialized.");
|
211
|
+
eigen_assert(computeU() && computeV() && "SVD::solve() requires both unitaries U and V to be computed (thin unitaries suffice).");
|
212
|
+
return Solve<Derived, Rhs>(derived(), b.derived());
|
213
|
+
}
|
214
|
+
|
215
|
+
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
216
|
+
template<typename RhsType, typename DstType>
|
217
|
+
EIGEN_DEVICE_FUNC
|
218
|
+
void _solve_impl(const RhsType &rhs, DstType &dst) const;
|
219
|
+
#endif
|
220
|
+
|
221
|
+
protected:
|
222
|
+
|
223
|
+
static void check_template_parameters()
|
224
|
+
{
|
225
|
+
EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar);
|
226
|
+
}
|
227
|
+
|
228
|
+
// return true if already allocated
|
229
|
+
bool allocate(Index rows, Index cols, unsigned int computationOptions) ;
|
230
|
+
|
231
|
+
MatrixUType m_matrixU;
|
232
|
+
MatrixVType m_matrixV;
|
233
|
+
SingularValuesType m_singularValues;
|
234
|
+
bool m_isInitialized, m_isAllocated, m_usePrescribedThreshold;
|
235
|
+
bool m_computeFullU, m_computeThinU;
|
236
|
+
bool m_computeFullV, m_computeThinV;
|
237
|
+
unsigned int m_computationOptions;
|
238
|
+
Index m_nonzeroSingularValues, m_rows, m_cols, m_diagSize;
|
239
|
+
RealScalar m_prescribedThreshold;
|
240
|
+
|
241
|
+
/** \brief Default Constructor.
|
242
|
+
*
|
243
|
+
* Default constructor of SVDBase
|
244
|
+
*/
|
245
|
+
SVDBase()
|
246
|
+
: m_isInitialized(false),
|
247
|
+
m_isAllocated(false),
|
248
|
+
m_usePrescribedThreshold(false),
|
249
|
+
m_computationOptions(0),
|
250
|
+
m_rows(-1), m_cols(-1), m_diagSize(0)
|
251
|
+
{
|
252
|
+
check_template_parameters();
|
253
|
+
}
|
254
|
+
|
255
|
+
|
256
|
+
};
|
257
|
+
|
258
|
+
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
259
|
+
template<typename Derived>
|
260
|
+
template<typename RhsType, typename DstType>
|
261
|
+
void SVDBase<Derived>::_solve_impl(const RhsType &rhs, DstType &dst) const
|
262
|
+
{
|
263
|
+
eigen_assert(rhs.rows() == rows());
|
264
|
+
|
265
|
+
// A = U S V^*
|
266
|
+
// So A^{-1} = V S^{-1} U^*
|
267
|
+
|
268
|
+
Matrix<Scalar, Dynamic, RhsType::ColsAtCompileTime, 0, MatrixType::MaxRowsAtCompileTime, RhsType::MaxColsAtCompileTime> tmp;
|
269
|
+
Index l_rank = rank();
|
270
|
+
tmp.noalias() = m_matrixU.leftCols(l_rank).adjoint() * rhs;
|
271
|
+
tmp = m_singularValues.head(l_rank).asDiagonal().inverse() * tmp;
|
272
|
+
dst = m_matrixV.leftCols(l_rank) * tmp;
|
273
|
+
}
|
274
|
+
#endif
|
275
|
+
|
276
|
+
template<typename MatrixType>
|
277
|
+
bool SVDBase<MatrixType>::allocate(Index rows, Index cols, unsigned int computationOptions)
|
278
|
+
{
|
279
|
+
eigen_assert(rows >= 0 && cols >= 0);
|
280
|
+
|
281
|
+
if (m_isAllocated &&
|
282
|
+
rows == m_rows &&
|
283
|
+
cols == m_cols &&
|
284
|
+
computationOptions == m_computationOptions)
|
285
|
+
{
|
286
|
+
return true;
|
287
|
+
}
|
288
|
+
|
289
|
+
m_rows = rows;
|
290
|
+
m_cols = cols;
|
291
|
+
m_isInitialized = false;
|
292
|
+
m_isAllocated = true;
|
293
|
+
m_computationOptions = computationOptions;
|
294
|
+
m_computeFullU = (computationOptions & ComputeFullU) != 0;
|
295
|
+
m_computeThinU = (computationOptions & ComputeThinU) != 0;
|
296
|
+
m_computeFullV = (computationOptions & ComputeFullV) != 0;
|
297
|
+
m_computeThinV = (computationOptions & ComputeThinV) != 0;
|
298
|
+
eigen_assert(!(m_computeFullU && m_computeThinU) && "SVDBase: you can't ask for both full and thin U");
|
299
|
+
eigen_assert(!(m_computeFullV && m_computeThinV) && "SVDBase: you can't ask for both full and thin V");
|
300
|
+
eigen_assert(EIGEN_IMPLIES(m_computeThinU || m_computeThinV, MatrixType::ColsAtCompileTime==Dynamic) &&
|
301
|
+
"SVDBase: thin U and V are only available when your matrix has a dynamic number of columns.");
|
302
|
+
|
303
|
+
m_diagSize = (std::min)(m_rows, m_cols);
|
304
|
+
m_singularValues.resize(m_diagSize);
|
305
|
+
if(RowsAtCompileTime==Dynamic)
|
306
|
+
m_matrixU.resize(m_rows, m_computeFullU ? m_rows : m_computeThinU ? m_diagSize : 0);
|
307
|
+
if(ColsAtCompileTime==Dynamic)
|
308
|
+
m_matrixV.resize(m_cols, m_computeFullV ? m_cols : m_computeThinV ? m_diagSize : 0);
|
309
|
+
|
310
|
+
return false;
|
311
|
+
}
|
312
|
+
|
313
|
+
}// end namespace
|
314
|
+
|
315
|
+
#endif // EIGEN_SVDBASE_H
|
@@ -0,0 +1,414 @@
|
|
1
|
+
// This file is part of Eigen, a lightweight C++ template library
|
2
|
+
// for linear algebra.
|
3
|
+
//
|
4
|
+
// Copyright (C) 2010 Benoit Jacob <jacob.benoit.1@gmail.com>
|
5
|
+
// Copyright (C) 2013-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
|
+
#ifndef EIGEN_BIDIAGONALIZATION_H
|
12
|
+
#define EIGEN_BIDIAGONALIZATION_H
|
13
|
+
|
14
|
+
namespace Eigen {
|
15
|
+
|
16
|
+
namespace internal {
|
17
|
+
// UpperBidiagonalization will probably be replaced by a Bidiagonalization class, don't want to make it stable API.
|
18
|
+
// At the same time, it's useful to keep for now as it's about the only thing that is testing the BandMatrix class.
|
19
|
+
|
20
|
+
template<typename _MatrixType> class UpperBidiagonalization
|
21
|
+
{
|
22
|
+
public:
|
23
|
+
|
24
|
+
typedef _MatrixType MatrixType;
|
25
|
+
enum {
|
26
|
+
RowsAtCompileTime = MatrixType::RowsAtCompileTime,
|
27
|
+
ColsAtCompileTime = MatrixType::ColsAtCompileTime,
|
28
|
+
ColsAtCompileTimeMinusOne = internal::decrement_size<ColsAtCompileTime>::ret
|
29
|
+
};
|
30
|
+
typedef typename MatrixType::Scalar Scalar;
|
31
|
+
typedef typename MatrixType::RealScalar RealScalar;
|
32
|
+
typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3
|
33
|
+
typedef Matrix<Scalar, 1, ColsAtCompileTime> RowVectorType;
|
34
|
+
typedef Matrix<Scalar, RowsAtCompileTime, 1> ColVectorType;
|
35
|
+
typedef BandMatrix<RealScalar, ColsAtCompileTime, ColsAtCompileTime, 1, 0, RowMajor> BidiagonalType;
|
36
|
+
typedef Matrix<Scalar, ColsAtCompileTime, 1> DiagVectorType;
|
37
|
+
typedef Matrix<Scalar, ColsAtCompileTimeMinusOne, 1> SuperDiagVectorType;
|
38
|
+
typedef HouseholderSequence<
|
39
|
+
const MatrixType,
|
40
|
+
const typename internal::remove_all<typename Diagonal<const MatrixType,0>::ConjugateReturnType>::type
|
41
|
+
> HouseholderUSequenceType;
|
42
|
+
typedef HouseholderSequence<
|
43
|
+
const typename internal::remove_all<typename MatrixType::ConjugateReturnType>::type,
|
44
|
+
Diagonal<const MatrixType,1>,
|
45
|
+
OnTheRight
|
46
|
+
> HouseholderVSequenceType;
|
47
|
+
|
48
|
+
/**
|
49
|
+
* \brief Default Constructor.
|
50
|
+
*
|
51
|
+
* The default constructor is useful in cases in which the user intends to
|
52
|
+
* perform decompositions via Bidiagonalization::compute(const MatrixType&).
|
53
|
+
*/
|
54
|
+
UpperBidiagonalization() : m_householder(), m_bidiagonal(), m_isInitialized(false) {}
|
55
|
+
|
56
|
+
explicit UpperBidiagonalization(const MatrixType& matrix)
|
57
|
+
: m_householder(matrix.rows(), matrix.cols()),
|
58
|
+
m_bidiagonal(matrix.cols(), matrix.cols()),
|
59
|
+
m_isInitialized(false)
|
60
|
+
{
|
61
|
+
compute(matrix);
|
62
|
+
}
|
63
|
+
|
64
|
+
UpperBidiagonalization& compute(const MatrixType& matrix);
|
65
|
+
UpperBidiagonalization& computeUnblocked(const MatrixType& matrix);
|
66
|
+
|
67
|
+
const MatrixType& householder() const { return m_householder; }
|
68
|
+
const BidiagonalType& bidiagonal() const { return m_bidiagonal; }
|
69
|
+
|
70
|
+
const HouseholderUSequenceType householderU() const
|
71
|
+
{
|
72
|
+
eigen_assert(m_isInitialized && "UpperBidiagonalization is not initialized.");
|
73
|
+
return HouseholderUSequenceType(m_householder, m_householder.diagonal().conjugate());
|
74
|
+
}
|
75
|
+
|
76
|
+
const HouseholderVSequenceType householderV() // const here gives nasty errors and i'm lazy
|
77
|
+
{
|
78
|
+
eigen_assert(m_isInitialized && "UpperBidiagonalization is not initialized.");
|
79
|
+
return HouseholderVSequenceType(m_householder.conjugate(), m_householder.const_derived().template diagonal<1>())
|
80
|
+
.setLength(m_householder.cols()-1)
|
81
|
+
.setShift(1);
|
82
|
+
}
|
83
|
+
|
84
|
+
protected:
|
85
|
+
MatrixType m_householder;
|
86
|
+
BidiagonalType m_bidiagonal;
|
87
|
+
bool m_isInitialized;
|
88
|
+
};
|
89
|
+
|
90
|
+
// Standard upper bidiagonalization without fancy optimizations
|
91
|
+
// This version should be faster for small matrix size
|
92
|
+
template<typename MatrixType>
|
93
|
+
void upperbidiagonalization_inplace_unblocked(MatrixType& mat,
|
94
|
+
typename MatrixType::RealScalar *diagonal,
|
95
|
+
typename MatrixType::RealScalar *upper_diagonal,
|
96
|
+
typename MatrixType::Scalar* tempData = 0)
|
97
|
+
{
|
98
|
+
typedef typename MatrixType::Scalar Scalar;
|
99
|
+
|
100
|
+
Index rows = mat.rows();
|
101
|
+
Index cols = mat.cols();
|
102
|
+
|
103
|
+
typedef Matrix<Scalar,Dynamic,1,ColMajor,MatrixType::MaxRowsAtCompileTime,1> TempType;
|
104
|
+
TempType tempVector;
|
105
|
+
if(tempData==0)
|
106
|
+
{
|
107
|
+
tempVector.resize(rows);
|
108
|
+
tempData = tempVector.data();
|
109
|
+
}
|
110
|
+
|
111
|
+
for (Index k = 0; /* breaks at k==cols-1 below */ ; ++k)
|
112
|
+
{
|
113
|
+
Index remainingRows = rows - k;
|
114
|
+
Index remainingCols = cols - k - 1;
|
115
|
+
|
116
|
+
// construct left householder transform in-place in A
|
117
|
+
mat.col(k).tail(remainingRows)
|
118
|
+
.makeHouseholderInPlace(mat.coeffRef(k,k), diagonal[k]);
|
119
|
+
// apply householder transform to remaining part of A on the left
|
120
|
+
mat.bottomRightCorner(remainingRows, remainingCols)
|
121
|
+
.applyHouseholderOnTheLeft(mat.col(k).tail(remainingRows-1), mat.coeff(k,k), tempData);
|
122
|
+
|
123
|
+
if(k == cols-1) break;
|
124
|
+
|
125
|
+
// construct right householder transform in-place in mat
|
126
|
+
mat.row(k).tail(remainingCols)
|
127
|
+
.makeHouseholderInPlace(mat.coeffRef(k,k+1), upper_diagonal[k]);
|
128
|
+
// apply householder transform to remaining part of mat on the left
|
129
|
+
mat.bottomRightCorner(remainingRows-1, remainingCols)
|
130
|
+
.applyHouseholderOnTheRight(mat.row(k).tail(remainingCols-1).transpose(), mat.coeff(k,k+1), tempData);
|
131
|
+
}
|
132
|
+
}
|
133
|
+
|
134
|
+
/** \internal
|
135
|
+
* Helper routine for the block reduction to upper bidiagonal form.
|
136
|
+
*
|
137
|
+
* Let's partition the matrix A:
|
138
|
+
*
|
139
|
+
* | A00 A01 |
|
140
|
+
* A = | |
|
141
|
+
* | A10 A11 |
|
142
|
+
*
|
143
|
+
* This function reduces to bidiagonal form the left \c rows x \a blockSize vertical panel [A00/A10]
|
144
|
+
* and the \a blockSize x \c cols horizontal panel [A00 A01] of the matrix \a A. The bottom-right block A11
|
145
|
+
* is updated using matrix-matrix products:
|
146
|
+
* A22 -= V * Y^T - X * U^T
|
147
|
+
* where V and U contains the left and right Householder vectors. U and V are stored in A10, and A01
|
148
|
+
* respectively, and the update matrices X and Y are computed during the reduction.
|
149
|
+
*
|
150
|
+
*/
|
151
|
+
template<typename MatrixType>
|
152
|
+
void upperbidiagonalization_blocked_helper(MatrixType& A,
|
153
|
+
typename MatrixType::RealScalar *diagonal,
|
154
|
+
typename MatrixType::RealScalar *upper_diagonal,
|
155
|
+
Index bs,
|
156
|
+
Ref<Matrix<typename MatrixType::Scalar, Dynamic, Dynamic,
|
157
|
+
traits<MatrixType>::Flags & RowMajorBit> > X,
|
158
|
+
Ref<Matrix<typename MatrixType::Scalar, Dynamic, Dynamic,
|
159
|
+
traits<MatrixType>::Flags & RowMajorBit> > Y)
|
160
|
+
{
|
161
|
+
typedef typename MatrixType::Scalar Scalar;
|
162
|
+
typedef typename MatrixType::RealScalar RealScalar;
|
163
|
+
typedef typename NumTraits<RealScalar>::Literal Literal;
|
164
|
+
enum { StorageOrder = traits<MatrixType>::Flags & RowMajorBit };
|
165
|
+
typedef InnerStride<int(StorageOrder) == int(ColMajor) ? 1 : Dynamic> ColInnerStride;
|
166
|
+
typedef InnerStride<int(StorageOrder) == int(ColMajor) ? Dynamic : 1> RowInnerStride;
|
167
|
+
typedef Ref<Matrix<Scalar, Dynamic, 1>, 0, ColInnerStride> SubColumnType;
|
168
|
+
typedef Ref<Matrix<Scalar, 1, Dynamic>, 0, RowInnerStride> SubRowType;
|
169
|
+
typedef Ref<Matrix<Scalar, Dynamic, Dynamic, StorageOrder > > SubMatType;
|
170
|
+
|
171
|
+
Index brows = A.rows();
|
172
|
+
Index bcols = A.cols();
|
173
|
+
|
174
|
+
Scalar tau_u, tau_u_prev(0), tau_v;
|
175
|
+
|
176
|
+
for(Index k = 0; k < bs; ++k)
|
177
|
+
{
|
178
|
+
Index remainingRows = brows - k;
|
179
|
+
Index remainingCols = bcols - k - 1;
|
180
|
+
|
181
|
+
SubMatType X_k1( X.block(k,0, remainingRows,k) );
|
182
|
+
SubMatType V_k1( A.block(k,0, remainingRows,k) );
|
183
|
+
|
184
|
+
// 1 - update the k-th column of A
|
185
|
+
SubColumnType v_k = A.col(k).tail(remainingRows);
|
186
|
+
v_k -= V_k1 * Y.row(k).head(k).adjoint();
|
187
|
+
if(k) v_k -= X_k1 * A.col(k).head(k);
|
188
|
+
|
189
|
+
// 2 - construct left Householder transform in-place
|
190
|
+
v_k.makeHouseholderInPlace(tau_v, diagonal[k]);
|
191
|
+
|
192
|
+
if(k+1<bcols)
|
193
|
+
{
|
194
|
+
SubMatType Y_k ( Y.block(k+1,0, remainingCols, k+1) );
|
195
|
+
SubMatType U_k1 ( A.block(0,k+1, k,remainingCols) );
|
196
|
+
|
197
|
+
// this eases the application of Householder transforAions
|
198
|
+
// A(k,k) will store tau_v later
|
199
|
+
A(k,k) = Scalar(1);
|
200
|
+
|
201
|
+
// 3 - Compute y_k^T = tau_v * ( A^T*v_k - Y_k-1*V_k-1^T*v_k - U_k-1*X_k-1^T*v_k )
|
202
|
+
{
|
203
|
+
SubColumnType y_k( Y.col(k).tail(remainingCols) );
|
204
|
+
|
205
|
+
// let's use the begining of column k of Y as a temporary vector
|
206
|
+
SubColumnType tmp( Y.col(k).head(k) );
|
207
|
+
y_k.noalias() = A.block(k,k+1, remainingRows,remainingCols).adjoint() * v_k; // bottleneck
|
208
|
+
tmp.noalias() = V_k1.adjoint() * v_k;
|
209
|
+
y_k.noalias() -= Y_k.leftCols(k) * tmp;
|
210
|
+
tmp.noalias() = X_k1.adjoint() * v_k;
|
211
|
+
y_k.noalias() -= U_k1.adjoint() * tmp;
|
212
|
+
y_k *= numext::conj(tau_v);
|
213
|
+
}
|
214
|
+
|
215
|
+
// 4 - update k-th row of A (it will become u_k)
|
216
|
+
SubRowType u_k( A.row(k).tail(remainingCols) );
|
217
|
+
u_k = u_k.conjugate();
|
218
|
+
{
|
219
|
+
u_k -= Y_k * A.row(k).head(k+1).adjoint();
|
220
|
+
if(k) u_k -= U_k1.adjoint() * X.row(k).head(k).adjoint();
|
221
|
+
}
|
222
|
+
|
223
|
+
// 5 - construct right Householder transform in-place
|
224
|
+
u_k.makeHouseholderInPlace(tau_u, upper_diagonal[k]);
|
225
|
+
|
226
|
+
// this eases the application of Householder transformations
|
227
|
+
// A(k,k+1) will store tau_u later
|
228
|
+
A(k,k+1) = Scalar(1);
|
229
|
+
|
230
|
+
// 6 - Compute x_k = tau_u * ( A*u_k - X_k-1*U_k-1^T*u_k - V_k*Y_k^T*u_k )
|
231
|
+
{
|
232
|
+
SubColumnType x_k ( X.col(k).tail(remainingRows-1) );
|
233
|
+
|
234
|
+
// let's use the begining of column k of X as a temporary vectors
|
235
|
+
// note that tmp0 and tmp1 overlaps
|
236
|
+
SubColumnType tmp0 ( X.col(k).head(k) ),
|
237
|
+
tmp1 ( X.col(k).head(k+1) );
|
238
|
+
|
239
|
+
x_k.noalias() = A.block(k+1,k+1, remainingRows-1,remainingCols) * u_k.transpose(); // bottleneck
|
240
|
+
tmp0.noalias() = U_k1 * u_k.transpose();
|
241
|
+
x_k.noalias() -= X_k1.bottomRows(remainingRows-1) * tmp0;
|
242
|
+
tmp1.noalias() = Y_k.adjoint() * u_k.transpose();
|
243
|
+
x_k.noalias() -= A.block(k+1,0, remainingRows-1,k+1) * tmp1;
|
244
|
+
x_k *= numext::conj(tau_u);
|
245
|
+
tau_u = numext::conj(tau_u);
|
246
|
+
u_k = u_k.conjugate();
|
247
|
+
}
|
248
|
+
|
249
|
+
if(k>0) A.coeffRef(k-1,k) = tau_u_prev;
|
250
|
+
tau_u_prev = tau_u;
|
251
|
+
}
|
252
|
+
else
|
253
|
+
A.coeffRef(k-1,k) = tau_u_prev;
|
254
|
+
|
255
|
+
A.coeffRef(k,k) = tau_v;
|
256
|
+
}
|
257
|
+
|
258
|
+
if(bs<bcols)
|
259
|
+
A.coeffRef(bs-1,bs) = tau_u_prev;
|
260
|
+
|
261
|
+
// update A22
|
262
|
+
if(bcols>bs && brows>bs)
|
263
|
+
{
|
264
|
+
SubMatType A11( A.bottomRightCorner(brows-bs,bcols-bs) );
|
265
|
+
SubMatType A10( A.block(bs,0, brows-bs,bs) );
|
266
|
+
SubMatType A01( A.block(0,bs, bs,bcols-bs) );
|
267
|
+
Scalar tmp = A01(bs-1,0);
|
268
|
+
A01(bs-1,0) = Literal(1);
|
269
|
+
A11.noalias() -= A10 * Y.topLeftCorner(bcols,bs).bottomRows(bcols-bs).adjoint();
|
270
|
+
A11.noalias() -= X.topLeftCorner(brows,bs).bottomRows(brows-bs) * A01;
|
271
|
+
A01(bs-1,0) = tmp;
|
272
|
+
}
|
273
|
+
}
|
274
|
+
|
275
|
+
/** \internal
|
276
|
+
*
|
277
|
+
* Implementation of a block-bidiagonal reduction.
|
278
|
+
* It is based on the following paper:
|
279
|
+
* The Design of a Parallel Dense Linear Algebra Software Library: Reduction to Hessenberg, Tridiagonal, and Bidiagonal Form.
|
280
|
+
* by Jaeyoung Choi, Jack J. Dongarra, David W. Walker. (1995)
|
281
|
+
* section 3.3
|
282
|
+
*/
|
283
|
+
template<typename MatrixType, typename BidiagType>
|
284
|
+
void upperbidiagonalization_inplace_blocked(MatrixType& A, BidiagType& bidiagonal,
|
285
|
+
Index maxBlockSize=32,
|
286
|
+
typename MatrixType::Scalar* /*tempData*/ = 0)
|
287
|
+
{
|
288
|
+
typedef typename MatrixType::Scalar Scalar;
|
289
|
+
typedef Block<MatrixType,Dynamic,Dynamic> BlockType;
|
290
|
+
|
291
|
+
Index rows = A.rows();
|
292
|
+
Index cols = A.cols();
|
293
|
+
Index size = (std::min)(rows, cols);
|
294
|
+
|
295
|
+
// X and Y are work space
|
296
|
+
enum { StorageOrder = traits<MatrixType>::Flags & RowMajorBit };
|
297
|
+
Matrix<Scalar,
|
298
|
+
MatrixType::RowsAtCompileTime,
|
299
|
+
Dynamic,
|
300
|
+
StorageOrder,
|
301
|
+
MatrixType::MaxRowsAtCompileTime> X(rows,maxBlockSize);
|
302
|
+
Matrix<Scalar,
|
303
|
+
MatrixType::ColsAtCompileTime,
|
304
|
+
Dynamic,
|
305
|
+
StorageOrder,
|
306
|
+
MatrixType::MaxColsAtCompileTime> Y(cols,maxBlockSize);
|
307
|
+
Index blockSize = (std::min)(maxBlockSize,size);
|
308
|
+
|
309
|
+
Index k = 0;
|
310
|
+
for(k = 0; k < size; k += blockSize)
|
311
|
+
{
|
312
|
+
Index bs = (std::min)(size-k,blockSize); // actual size of the block
|
313
|
+
Index brows = rows - k; // rows of the block
|
314
|
+
Index bcols = cols - k; // columns of the block
|
315
|
+
|
316
|
+
// partition the matrix A:
|
317
|
+
//
|
318
|
+
// | A00 A01 A02 |
|
319
|
+
// | |
|
320
|
+
// A = | A10 A11 A12 |
|
321
|
+
// | |
|
322
|
+
// | A20 A21 A22 |
|
323
|
+
//
|
324
|
+
// where A11 is a bs x bs diagonal block,
|
325
|
+
// and let:
|
326
|
+
// | A11 A12 |
|
327
|
+
// B = | |
|
328
|
+
// | A21 A22 |
|
329
|
+
|
330
|
+
BlockType B = A.block(k,k,brows,bcols);
|
331
|
+
|
332
|
+
// This stage performs the bidiagonalization of A11, A21, A12, and updating of A22.
|
333
|
+
// Finally, the algorithm continue on the updated A22.
|
334
|
+
//
|
335
|
+
// However, if B is too small, or A22 empty, then let's use an unblocked strategy
|
336
|
+
if(k+bs==cols || bcols<48) // somewhat arbitrary threshold
|
337
|
+
{
|
338
|
+
upperbidiagonalization_inplace_unblocked(B,
|
339
|
+
&(bidiagonal.template diagonal<0>().coeffRef(k)),
|
340
|
+
&(bidiagonal.template diagonal<1>().coeffRef(k)),
|
341
|
+
X.data()
|
342
|
+
);
|
343
|
+
break; // We're done
|
344
|
+
}
|
345
|
+
else
|
346
|
+
{
|
347
|
+
upperbidiagonalization_blocked_helper<BlockType>( B,
|
348
|
+
&(bidiagonal.template diagonal<0>().coeffRef(k)),
|
349
|
+
&(bidiagonal.template diagonal<1>().coeffRef(k)),
|
350
|
+
bs,
|
351
|
+
X.topLeftCorner(brows,bs),
|
352
|
+
Y.topLeftCorner(bcols,bs)
|
353
|
+
);
|
354
|
+
}
|
355
|
+
}
|
356
|
+
}
|
357
|
+
|
358
|
+
template<typename _MatrixType>
|
359
|
+
UpperBidiagonalization<_MatrixType>& UpperBidiagonalization<_MatrixType>::computeUnblocked(const _MatrixType& matrix)
|
360
|
+
{
|
361
|
+
Index rows = matrix.rows();
|
362
|
+
Index cols = matrix.cols();
|
363
|
+
EIGEN_ONLY_USED_FOR_DEBUG(cols);
|
364
|
+
|
365
|
+
eigen_assert(rows >= cols && "UpperBidiagonalization is only for Arices satisfying rows>=cols.");
|
366
|
+
|
367
|
+
m_householder = matrix;
|
368
|
+
|
369
|
+
ColVectorType temp(rows);
|
370
|
+
|
371
|
+
upperbidiagonalization_inplace_unblocked(m_householder,
|
372
|
+
&(m_bidiagonal.template diagonal<0>().coeffRef(0)),
|
373
|
+
&(m_bidiagonal.template diagonal<1>().coeffRef(0)),
|
374
|
+
temp.data());
|
375
|
+
|
376
|
+
m_isInitialized = true;
|
377
|
+
return *this;
|
378
|
+
}
|
379
|
+
|
380
|
+
template<typename _MatrixType>
|
381
|
+
UpperBidiagonalization<_MatrixType>& UpperBidiagonalization<_MatrixType>::compute(const _MatrixType& matrix)
|
382
|
+
{
|
383
|
+
Index rows = matrix.rows();
|
384
|
+
Index cols = matrix.cols();
|
385
|
+
EIGEN_ONLY_USED_FOR_DEBUG(rows);
|
386
|
+
EIGEN_ONLY_USED_FOR_DEBUG(cols);
|
387
|
+
|
388
|
+
eigen_assert(rows >= cols && "UpperBidiagonalization is only for Arices satisfying rows>=cols.");
|
389
|
+
|
390
|
+
m_householder = matrix;
|
391
|
+
upperbidiagonalization_inplace_blocked(m_householder, m_bidiagonal);
|
392
|
+
|
393
|
+
m_isInitialized = true;
|
394
|
+
return *this;
|
395
|
+
}
|
396
|
+
|
397
|
+
#if 0
|
398
|
+
/** \return the Householder QR decomposition of \c *this.
|
399
|
+
*
|
400
|
+
* \sa class Bidiagonalization
|
401
|
+
*/
|
402
|
+
template<typename Derived>
|
403
|
+
const UpperBidiagonalization<typename MatrixBase<Derived>::PlainObject>
|
404
|
+
MatrixBase<Derived>::bidiagonalization() const
|
405
|
+
{
|
406
|
+
return UpperBidiagonalization<PlainObject>(eval());
|
407
|
+
}
|
408
|
+
#endif
|
409
|
+
|
410
|
+
} // end namespace internal
|
411
|
+
|
412
|
+
} // end namespace Eigen
|
413
|
+
|
414
|
+
#endif // EIGEN_BIDIAGONALIZATION_H
|