ruby-eigen 0.0.9 → 0.0.10.pre1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE +22 -0
- data/README.md +21 -0
- data/ext/eigen/eigen3/COPYING.BSD +26 -0
- data/ext/eigen/eigen3/COPYING.MPL2 +373 -0
- data/ext/eigen/eigen3/COPYING.README +18 -0
- data/ext/eigen/eigen3/Eigen/Array +11 -0
- data/ext/eigen/eigen3/Eigen/Cholesky +32 -0
- data/ext/eigen/eigen3/Eigen/CholmodSupport +45 -0
- data/ext/eigen/eigen3/Eigen/Core +376 -0
- data/ext/eigen/eigen3/Eigen/Dense +7 -0
- data/ext/eigen/eigen3/Eigen/Eigen +2 -0
- data/ext/eigen/eigen3/Eigen/Eigen2Support +95 -0
- data/ext/eigen/eigen3/Eigen/Eigenvalues +48 -0
- data/ext/eigen/eigen3/Eigen/Geometry +63 -0
- data/ext/eigen/eigen3/Eigen/Householder +23 -0
- data/ext/eigen/eigen3/Eigen/IterativeLinearSolvers +40 -0
- data/ext/eigen/eigen3/Eigen/Jacobi +26 -0
- data/ext/eigen/eigen3/Eigen/LU +41 -0
- data/ext/eigen/eigen3/Eigen/LeastSquares +32 -0
- data/ext/eigen/eigen3/Eigen/MetisSupport +28 -0
- data/ext/eigen/eigen3/Eigen/PaStiXSupport +46 -0
- data/ext/eigen/eigen3/Eigen/PardisoSupport +30 -0
- data/ext/eigen/eigen3/Eigen/QR +45 -0
- data/ext/eigen/eigen3/Eigen/QtAlignedMalloc +34 -0
- data/ext/eigen/eigen3/Eigen/SPQRSupport +29 -0
- data/ext/eigen/eigen3/Eigen/SVD +37 -0
- data/ext/eigen/eigen3/Eigen/Sparse +27 -0
- data/ext/eigen/eigen3/Eigen/SparseCore +64 -0
- data/ext/eigen/eigen3/Eigen/SparseLU +49 -0
- data/ext/eigen/eigen3/Eigen/SparseQR +33 -0
- data/ext/eigen/eigen3/Eigen/StdDeque +27 -0
- data/ext/eigen/eigen3/Eigen/StdList +26 -0
- data/ext/eigen/eigen3/Eigen/StdVector +27 -0
- data/ext/eigen/eigen3/Eigen/SuperLUSupport +59 -0
- data/ext/eigen/eigen3/Eigen/UmfPackSupport +36 -0
- data/ext/eigen/eigen3/Eigen/src/Cholesky/LDLT.h +611 -0
- data/ext/eigen/eigen3/Eigen/src/Cholesky/LLT.h +498 -0
- data/ext/eigen/eigen3/Eigen/src/Cholesky/LLT_MKL.h +102 -0
- data/ext/eigen/eigen3/Eigen/src/CholmodSupport/CholmodSupport.h +607 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Array.h +323 -0
- data/ext/eigen/eigen3/Eigen/src/Core/ArrayBase.h +226 -0
- data/ext/eigen/eigen3/Eigen/src/Core/ArrayWrapper.h +264 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Assign.h +590 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Assign_MKL.h +224 -0
- data/ext/eigen/eigen3/Eigen/src/Core/BandMatrix.h +334 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Block.h +406 -0
- data/ext/eigen/eigen3/Eigen/src/Core/BooleanRedux.h +154 -0
- data/ext/eigen/eigen3/Eigen/src/Core/CommaInitializer.h +154 -0
- data/ext/eigen/eigen3/Eigen/src/Core/CoreIterators.h +61 -0
- data/ext/eigen/eigen3/Eigen/src/Core/CwiseBinaryOp.h +230 -0
- data/ext/eigen/eigen3/Eigen/src/Core/CwiseNullaryOp.h +864 -0
- data/ext/eigen/eigen3/Eigen/src/Core/CwiseUnaryOp.h +126 -0
- data/ext/eigen/eigen3/Eigen/src/Core/CwiseUnaryView.h +139 -0
- data/ext/eigen/eigen3/Eigen/src/Core/DenseBase.h +521 -0
- data/ext/eigen/eigen3/Eigen/src/Core/DenseCoeffsBase.h +754 -0
- data/ext/eigen/eigen3/Eigen/src/Core/DenseStorage.h +434 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Diagonal.h +237 -0
- data/ext/eigen/eigen3/Eigen/src/Core/DiagonalMatrix.h +313 -0
- data/ext/eigen/eigen3/Eigen/src/Core/DiagonalProduct.h +131 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Dot.h +263 -0
- data/ext/eigen/eigen3/Eigen/src/Core/EigenBase.h +131 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Flagged.h +140 -0
- data/ext/eigen/eigen3/Eigen/src/Core/ForceAlignedAccess.h +146 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Functors.h +1026 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Fuzzy.h +150 -0
- data/ext/eigen/eigen3/Eigen/src/Core/GeneralProduct.h +635 -0
- data/ext/eigen/eigen3/Eigen/src/Core/GenericPacketMath.h +350 -0
- data/ext/eigen/eigen3/Eigen/src/Core/GlobalFunctions.h +92 -0
- data/ext/eigen/eigen3/Eigen/src/Core/IO.h +250 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Map.h +192 -0
- data/ext/eigen/eigen3/Eigen/src/Core/MapBase.h +247 -0
- data/ext/eigen/eigen3/Eigen/src/Core/MathFunctions.h +768 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Matrix.h +420 -0
- data/ext/eigen/eigen3/Eigen/src/Core/MatrixBase.h +563 -0
- data/ext/eigen/eigen3/Eigen/src/Core/NestByValue.h +111 -0
- data/ext/eigen/eigen3/Eigen/src/Core/NoAlias.h +134 -0
- data/ext/eigen/eigen3/Eigen/src/Core/NumTraits.h +150 -0
- data/ext/eigen/eigen3/Eigen/src/Core/PermutationMatrix.h +721 -0
- data/ext/eigen/eigen3/Eigen/src/Core/PlainObjectBase.h +822 -0
- data/ext/eigen/eigen3/Eigen/src/Core/ProductBase.h +290 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Random.h +152 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Redux.h +409 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Ref.h +278 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Replicate.h +177 -0
- data/ext/eigen/eigen3/Eigen/src/Core/ReturnByValue.h +99 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Reverse.h +224 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Select.h +162 -0
- data/ext/eigen/eigen3/Eigen/src/Core/SelfAdjointView.h +314 -0
- data/ext/eigen/eigen3/Eigen/src/Core/SelfCwiseBinaryOp.h +191 -0
- data/ext/eigen/eigen3/Eigen/src/Core/SolveTriangular.h +260 -0
- data/ext/eigen/eigen3/Eigen/src/Core/StableNorm.h +203 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Stride.h +108 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Swap.h +126 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Transpose.h +419 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Transpositions.h +436 -0
- data/ext/eigen/eigen3/Eigen/src/Core/TriangularMatrix.h +839 -0
- data/ext/eigen/eigen3/Eigen/src/Core/VectorBlock.h +95 -0
- data/ext/eigen/eigen3/Eigen/src/Core/VectorwiseOp.h +642 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Visitor.h +237 -0
- data/ext/eigen/eigen3/Eigen/src/Core/arch/AltiVec/Complex.h +217 -0
- data/ext/eigen/eigen3/Eigen/src/Core/arch/AltiVec/PacketMath.h +501 -0
- data/ext/eigen/eigen3/Eigen/src/Core/arch/Default/Settings.h +49 -0
- data/ext/eigen/eigen3/Eigen/src/Core/arch/NEON/Complex.h +253 -0
- data/ext/eigen/eigen3/Eigen/src/Core/arch/NEON/PacketMath.h +420 -0
- data/ext/eigen/eigen3/Eigen/src/Core/arch/SSE/Complex.h +442 -0
- data/ext/eigen/eigen3/Eigen/src/Core/arch/SSE/MathFunctions.h +475 -0
- data/ext/eigen/eigen3/Eigen/src/Core/arch/SSE/PacketMath.h +649 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/CoeffBasedProduct.h +476 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/GeneralBlockPanelKernel.h +1341 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/GeneralMatrixMatrix.h +427 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/GeneralMatrixMatrixTriangular.h +278 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/GeneralMatrixMatrixTriangular_MKL.h +146 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/GeneralMatrixMatrix_MKL.h +118 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/GeneralMatrixVector.h +566 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/GeneralMatrixVector_MKL.h +131 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/Parallelizer.h +162 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/SelfadjointMatrixMatrix.h +436 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/SelfadjointMatrixMatrix_MKL.h +295 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/SelfadjointMatrixVector.h +281 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/SelfadjointMatrixVector_MKL.h +114 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/SelfadjointProduct.h +123 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/SelfadjointRank2Update.h +93 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/TriangularMatrixMatrix.h +427 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/TriangularMatrixMatrix_MKL.h +309 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/TriangularMatrixVector.h +348 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/TriangularMatrixVector_MKL.h +247 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/TriangularSolverMatrix.h +332 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/TriangularSolverMatrix_MKL.h +155 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/TriangularSolverVector.h +139 -0
- data/ext/eigen/eigen3/Eigen/src/Core/util/BlasUtil.h +264 -0
- data/ext/eigen/eigen3/Eigen/src/Core/util/Constants.h +451 -0
- data/ext/eigen/eigen3/Eigen/src/Core/util/DisableStupidWarnings.h +40 -0
- data/ext/eigen/eigen3/Eigen/src/Core/util/ForwardDeclarations.h +302 -0
- data/ext/eigen/eigen3/Eigen/src/Core/util/MKL_support.h +158 -0
- data/ext/eigen/eigen3/Eigen/src/Core/util/Macros.h +451 -0
- data/ext/eigen/eigen3/Eigen/src/Core/util/Memory.h +977 -0
- data/ext/eigen/eigen3/Eigen/src/Core/util/Meta.h +243 -0
- data/ext/eigen/eigen3/Eigen/src/Core/util/NonMPL2.h +3 -0
- data/ext/eigen/eigen3/Eigen/src/Core/util/ReenableStupidWarnings.h +14 -0
- data/ext/eigen/eigen3/Eigen/src/Core/util/StaticAssert.h +208 -0
- data/ext/eigen/eigen3/Eigen/src/Core/util/XprHelper.h +469 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Block.h +126 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Cwise.h +192 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/CwiseOperators.h +298 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/AlignedBox.h +159 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/All.h +115 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/AngleAxis.h +214 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/Hyperplane.h +254 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/ParametrizedLine.h +141 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/Quaternion.h +495 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/Rotation2D.h +145 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/RotationBase.h +123 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/Scaling.h +167 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/Transform.h +786 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/Translation.h +184 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/LU.h +120 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Lazy.h +71 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/LeastSquares.h +169 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Macros.h +20 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/MathFunctions.h +57 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Memory.h +45 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Meta.h +75 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Minor.h +117 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/QR.h +67 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/SVD.h +637 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/TriangularSolver.h +42 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/VectorBlock.h +94 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/ComplexEigenSolver.h +341 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/ComplexSchur.h +456 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/ComplexSchur_MKL.h +94 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/EigenSolver.h +607 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/GeneralizedEigenSolver.h +350 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h +227 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/HessenbergDecomposition.h +373 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/MatrixBaseEigenvalues.h +160 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/RealQZ.h +624 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/RealSchur.h +525 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/RealSchur_MKL.h +83 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h +801 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/SelfAdjointEigenSolver_MKL.h +92 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/Tridiagonalization.h +557 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/AlignedBox.h +392 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/AngleAxis.h +233 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/EulerAngles.h +104 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/Homogeneous.h +307 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/Hyperplane.h +280 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/OrthoMethods.h +218 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/ParametrizedLine.h +195 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/Quaternion.h +776 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/Rotation2D.h +160 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/RotationBase.h +206 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/Scaling.h +166 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/Transform.h +1455 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/Translation.h +206 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/Umeyama.h +177 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/arch/Geometry_SSE.h +115 -0
- data/ext/eigen/eigen3/Eigen/src/Householder/BlockHouseholder.h +68 -0
- data/ext/eigen/eigen3/Eigen/src/Householder/Householder.h +171 -0
- data/ext/eigen/eigen3/Eigen/src/Householder/HouseholderSequence.h +441 -0
- data/ext/eigen/eigen3/Eigen/src/IterativeLinearSolvers/BasicPreconditioners.h +149 -0
- data/ext/eigen/eigen3/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h +263 -0
- data/ext/eigen/eigen3/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h +256 -0
- data/ext/eigen/eigen3/Eigen/src/IterativeLinearSolvers/IterativeSolverBase.h +282 -0
- data/ext/eigen/eigen3/Eigen/src/Jacobi/Jacobi.h +433 -0
- data/ext/eigen/eigen3/Eigen/src/LU/Determinant.h +101 -0
- data/ext/eigen/eigen3/Eigen/src/LU/FullPivLU.h +751 -0
- data/ext/eigen/eigen3/Eigen/src/LU/Inverse.h +400 -0
- data/ext/eigen/eigen3/Eigen/src/LU/PartialPivLU.h +509 -0
- data/ext/eigen/eigen3/Eigen/src/LU/PartialPivLU_MKL.h +85 -0
- data/ext/eigen/eigen3/Eigen/src/LU/arch/Inverse_SSE.h +329 -0
- data/ext/eigen/eigen3/Eigen/src/MetisSupport/MetisSupport.h +137 -0
- data/ext/eigen/eigen3/Eigen/src/OrderingMethods/Amd.h +444 -0
- data/ext/eigen/eigen3/Eigen/src/OrderingMethods/Eigen_Colamd.h +1850 -0
- data/ext/eigen/eigen3/Eigen/src/PaStiXSupport/PaStiXSupport.h +721 -0
- data/ext/eigen/eigen3/Eigen/src/PardisoSupport/PardisoSupport.h +592 -0
- data/ext/eigen/eigen3/Eigen/src/QR/ColPivHouseholderQR.h +580 -0
- data/ext/eigen/eigen3/Eigen/src/QR/ColPivHouseholderQR_MKL.h +99 -0
- data/ext/eigen/eigen3/Eigen/src/QR/FullPivHouseholderQR.h +622 -0
- data/ext/eigen/eigen3/Eigen/src/QR/HouseholderQR.h +388 -0
- data/ext/eigen/eigen3/Eigen/src/QR/HouseholderQR_MKL.h +71 -0
- data/ext/eigen/eigen3/Eigen/src/SPQRSupport/SuiteSparseQRSupport.h +338 -0
- data/ext/eigen/eigen3/Eigen/src/SVD/JacobiSVD.h +976 -0
- data/ext/eigen/eigen3/Eigen/src/SVD/JacobiSVD_MKL.h +92 -0
- data/ext/eigen/eigen3/Eigen/src/SVD/UpperBidiagonalization.h +148 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCholesky/SimplicialCholesky.h +671 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h +199 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/AmbiVector.h +373 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/CompressedStorage.h +233 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/ConservativeSparseSparseProduct.h +245 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/MappedSparseMatrix.h +181 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseBlock.h +537 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseColEtree.h +206 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseCwiseBinaryOp.h +325 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseCwiseUnaryOp.h +163 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseDenseProduct.h +311 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseDiagonalProduct.h +196 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseDot.h +101 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseFuzzy.h +26 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseMatrix.h +1262 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseMatrixBase.h +461 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparsePermutation.h +148 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseProduct.h +188 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseRedux.h +45 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseSelfAdjointView.h +507 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseSparseProductWithPruning.h +150 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseTranspose.h +63 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseTriangularView.h +179 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseUtil.h +172 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseVector.h +448 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseView.h +99 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/TriangularSolver.h +334 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU.h +806 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLUImpl.h +66 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_Memory.h +227 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_Structs.h +111 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_SupernodalMatrix.h +298 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_Utils.h +80 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_column_bmod.h +180 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_column_dfs.h +177 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_copy_to_ucol.h +106 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_gemm_kernel.h +279 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_heap_relax_snode.h +127 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_kernel_bmod.h +130 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_panel_bmod.h +223 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_panel_dfs.h +258 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_pivotL.h +137 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_pruneL.h +135 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_relax_snode.h +83 -0
- data/ext/eigen/eigen3/Eigen/src/SparseQR/SparseQR.h +714 -0
- data/ext/eigen/eigen3/Eigen/src/StlSupport/StdDeque.h +134 -0
- data/ext/eigen/eigen3/Eigen/src/StlSupport/StdList.h +114 -0
- data/ext/eigen/eigen3/Eigen/src/StlSupport/StdVector.h +126 -0
- data/ext/eigen/eigen3/Eigen/src/StlSupport/details.h +84 -0
- data/ext/eigen/eigen3/Eigen/src/SuperLUSupport/SuperLUSupport.h +1026 -0
- data/ext/eigen/eigen3/Eigen/src/UmfPackSupport/UmfPackSupport.h +474 -0
- data/ext/eigen/eigen3/Eigen/src/misc/Image.h +84 -0
- data/ext/eigen/eigen3/Eigen/src/misc/Kernel.h +81 -0
- data/ext/eigen/eigen3/Eigen/src/misc/Solve.h +76 -0
- data/ext/eigen/eigen3/Eigen/src/misc/SparseSolve.h +128 -0
- data/ext/eigen/eigen3/Eigen/src/misc/blas.h +658 -0
- data/ext/eigen/eigen3/Eigen/src/plugins/ArrayCwiseBinaryOps.h +253 -0
- data/ext/eigen/eigen3/Eigen/src/plugins/ArrayCwiseUnaryOps.h +187 -0
- data/ext/eigen/eigen3/Eigen/src/plugins/BlockMethods.h +935 -0
- data/ext/eigen/eigen3/Eigen/src/plugins/CommonCwiseBinaryOps.h +46 -0
- data/ext/eigen/eigen3/Eigen/src/plugins/CommonCwiseUnaryOps.h +172 -0
- data/ext/eigen/eigen3/Eigen/src/plugins/MatrixCwiseBinaryOps.h +143 -0
- data/ext/eigen/eigen3/Eigen/src/plugins/MatrixCwiseUnaryOps.h +52 -0
- data/ext/eigen/eigen3/signature_of_eigen3_matrix_library +1 -0
- data/ext/eigen/eigen_wrap.cxx +19420 -10396
- data/ext/eigen/extconf.rb +37 -2
- data/lib/eigen.rb +146 -3
- metadata +294 -7
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
// This file is part of Eigen, a lightweight C++ template library
|
|
2
|
+
// for linear algebra.
|
|
3
|
+
//
|
|
4
|
+
// Copyright (C) 2011 Gael Guennebaud <gael.guennebaud@inria.fr>
|
|
5
|
+
//
|
|
6
|
+
// This Source Code Form is subject to the terms of the Mozilla
|
|
7
|
+
// Public License v. 2.0. If a copy of the MPL was not distributed
|
|
8
|
+
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
9
|
+
|
|
10
|
+
#ifndef EIGEN_BASIC_PRECONDITIONERS_H
|
|
11
|
+
#define EIGEN_BASIC_PRECONDITIONERS_H
|
|
12
|
+
|
|
13
|
+
namespace Eigen {
|
|
14
|
+
|
|
15
|
+
/** \ingroup IterativeLinearSolvers_Module
|
|
16
|
+
* \brief A preconditioner based on the digonal entries
|
|
17
|
+
*
|
|
18
|
+
* This class allows to approximately solve for A.x = b problems assuming A is a diagonal matrix.
|
|
19
|
+
* In other words, this preconditioner neglects all off diagonal entries and, in Eigen's language, solves for:
|
|
20
|
+
* \code
|
|
21
|
+
* A.diagonal().asDiagonal() . x = b
|
|
22
|
+
* \endcode
|
|
23
|
+
*
|
|
24
|
+
* \tparam _Scalar the type of the scalar.
|
|
25
|
+
*
|
|
26
|
+
* This preconditioner is suitable for both selfadjoint and general problems.
|
|
27
|
+
* The diagonal entries are pre-inverted and stored into a dense vector.
|
|
28
|
+
*
|
|
29
|
+
* \note A variant that has yet to be implemented would attempt to preserve the norm of each column.
|
|
30
|
+
*
|
|
31
|
+
*/
|
|
32
|
+
template <typename _Scalar>
|
|
33
|
+
class DiagonalPreconditioner
|
|
34
|
+
{
|
|
35
|
+
typedef _Scalar Scalar;
|
|
36
|
+
typedef Matrix<Scalar,Dynamic,1> Vector;
|
|
37
|
+
typedef typename Vector::Index Index;
|
|
38
|
+
|
|
39
|
+
public:
|
|
40
|
+
// this typedef is only to export the scalar type and compile-time dimensions to solve_retval
|
|
41
|
+
typedef Matrix<Scalar,Dynamic,Dynamic> MatrixType;
|
|
42
|
+
|
|
43
|
+
DiagonalPreconditioner() : m_isInitialized(false) {}
|
|
44
|
+
|
|
45
|
+
template<typename MatType>
|
|
46
|
+
DiagonalPreconditioner(const MatType& mat) : m_invdiag(mat.cols())
|
|
47
|
+
{
|
|
48
|
+
compute(mat);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
Index rows() const { return m_invdiag.size(); }
|
|
52
|
+
Index cols() const { return m_invdiag.size(); }
|
|
53
|
+
|
|
54
|
+
template<typename MatType>
|
|
55
|
+
DiagonalPreconditioner& analyzePattern(const MatType& )
|
|
56
|
+
{
|
|
57
|
+
return *this;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
template<typename MatType>
|
|
61
|
+
DiagonalPreconditioner& factorize(const MatType& mat)
|
|
62
|
+
{
|
|
63
|
+
m_invdiag.resize(mat.cols());
|
|
64
|
+
for(int j=0; j<mat.outerSize(); ++j)
|
|
65
|
+
{
|
|
66
|
+
typename MatType::InnerIterator it(mat,j);
|
|
67
|
+
while(it && it.index()!=j) ++it;
|
|
68
|
+
if(it && it.index()==j && it.value()!=Scalar(0))
|
|
69
|
+
m_invdiag(j) = Scalar(1)/it.value();
|
|
70
|
+
else
|
|
71
|
+
m_invdiag(j) = Scalar(1);
|
|
72
|
+
}
|
|
73
|
+
m_isInitialized = true;
|
|
74
|
+
return *this;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
template<typename MatType>
|
|
78
|
+
DiagonalPreconditioner& compute(const MatType& mat)
|
|
79
|
+
{
|
|
80
|
+
return factorize(mat);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
template<typename Rhs, typename Dest>
|
|
84
|
+
void _solve(const Rhs& b, Dest& x) const
|
|
85
|
+
{
|
|
86
|
+
x = m_invdiag.array() * b.array() ;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
template<typename Rhs> inline const internal::solve_retval<DiagonalPreconditioner, Rhs>
|
|
90
|
+
solve(const MatrixBase<Rhs>& b) const
|
|
91
|
+
{
|
|
92
|
+
eigen_assert(m_isInitialized && "DiagonalPreconditioner is not initialized.");
|
|
93
|
+
eigen_assert(m_invdiag.size()==b.rows()
|
|
94
|
+
&& "DiagonalPreconditioner::solve(): invalid number of rows of the right hand side matrix b");
|
|
95
|
+
return internal::solve_retval<DiagonalPreconditioner, Rhs>(*this, b.derived());
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
protected:
|
|
99
|
+
Vector m_invdiag;
|
|
100
|
+
bool m_isInitialized;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
namespace internal {
|
|
104
|
+
|
|
105
|
+
template<typename _MatrixType, typename Rhs>
|
|
106
|
+
struct solve_retval<DiagonalPreconditioner<_MatrixType>, Rhs>
|
|
107
|
+
: solve_retval_base<DiagonalPreconditioner<_MatrixType>, Rhs>
|
|
108
|
+
{
|
|
109
|
+
typedef DiagonalPreconditioner<_MatrixType> Dec;
|
|
110
|
+
EIGEN_MAKE_SOLVE_HELPERS(Dec,Rhs)
|
|
111
|
+
|
|
112
|
+
template<typename Dest> void evalTo(Dest& dst) const
|
|
113
|
+
{
|
|
114
|
+
dec()._solve(rhs(),dst);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** \ingroup IterativeLinearSolvers_Module
|
|
121
|
+
* \brief A naive preconditioner which approximates any matrix as the identity matrix
|
|
122
|
+
*
|
|
123
|
+
* \sa class DiagonalPreconditioner
|
|
124
|
+
*/
|
|
125
|
+
class IdentityPreconditioner
|
|
126
|
+
{
|
|
127
|
+
public:
|
|
128
|
+
|
|
129
|
+
IdentityPreconditioner() {}
|
|
130
|
+
|
|
131
|
+
template<typename MatrixType>
|
|
132
|
+
IdentityPreconditioner(const MatrixType& ) {}
|
|
133
|
+
|
|
134
|
+
template<typename MatrixType>
|
|
135
|
+
IdentityPreconditioner& analyzePattern(const MatrixType& ) { return *this; }
|
|
136
|
+
|
|
137
|
+
template<typename MatrixType>
|
|
138
|
+
IdentityPreconditioner& factorize(const MatrixType& ) { return *this; }
|
|
139
|
+
|
|
140
|
+
template<typename MatrixType>
|
|
141
|
+
IdentityPreconditioner& compute(const MatrixType& ) { return *this; }
|
|
142
|
+
|
|
143
|
+
template<typename Rhs>
|
|
144
|
+
inline const Rhs& solve(const Rhs& b) const { return b; }
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
} // end namespace Eigen
|
|
148
|
+
|
|
149
|
+
#endif // EIGEN_BASIC_PRECONDITIONERS_H
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
// This file is part of Eigen, a lightweight C++ template library
|
|
2
|
+
// for linear algebra.
|
|
3
|
+
//
|
|
4
|
+
// Copyright (C) 2011 Gael Guennebaud <gael.guennebaud@inria.fr>
|
|
5
|
+
// Copyright (C) 2012 Désiré Nuentsa-Wakam <desire.nuentsa_wakam@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_BICGSTAB_H
|
|
12
|
+
#define EIGEN_BICGSTAB_H
|
|
13
|
+
|
|
14
|
+
namespace Eigen {
|
|
15
|
+
|
|
16
|
+
namespace internal {
|
|
17
|
+
|
|
18
|
+
/** \internal Low-level bi conjugate gradient stabilized algorithm
|
|
19
|
+
* \param mat The matrix A
|
|
20
|
+
* \param rhs The right hand side vector b
|
|
21
|
+
* \param x On input and initial solution, on output the computed solution.
|
|
22
|
+
* \param precond A preconditioner being able to efficiently solve for an
|
|
23
|
+
* approximation of Ax=b (regardless of b)
|
|
24
|
+
* \param iters On input the max number of iteration, on output the number of performed iterations.
|
|
25
|
+
* \param tol_error On input the tolerance error, on output an estimation of the relative error.
|
|
26
|
+
* \return false in the case of numerical issue, for example a break down of BiCGSTAB.
|
|
27
|
+
*/
|
|
28
|
+
template<typename MatrixType, typename Rhs, typename Dest, typename Preconditioner>
|
|
29
|
+
bool bicgstab(const MatrixType& mat, const Rhs& rhs, Dest& x,
|
|
30
|
+
const Preconditioner& precond, int& iters,
|
|
31
|
+
typename Dest::RealScalar& tol_error)
|
|
32
|
+
{
|
|
33
|
+
using std::sqrt;
|
|
34
|
+
using std::abs;
|
|
35
|
+
typedef typename Dest::RealScalar RealScalar;
|
|
36
|
+
typedef typename Dest::Scalar Scalar;
|
|
37
|
+
typedef Matrix<Scalar,Dynamic,1> VectorType;
|
|
38
|
+
RealScalar tol = tol_error;
|
|
39
|
+
int maxIters = iters;
|
|
40
|
+
|
|
41
|
+
int n = mat.cols();
|
|
42
|
+
VectorType r = rhs - mat * x;
|
|
43
|
+
VectorType r0 = r;
|
|
44
|
+
|
|
45
|
+
RealScalar r0_sqnorm = r0.squaredNorm();
|
|
46
|
+
RealScalar rhs_sqnorm = rhs.squaredNorm();
|
|
47
|
+
if(rhs_sqnorm == 0)
|
|
48
|
+
{
|
|
49
|
+
x.setZero();
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
Scalar rho = 1;
|
|
53
|
+
Scalar alpha = 1;
|
|
54
|
+
Scalar w = 1;
|
|
55
|
+
|
|
56
|
+
VectorType v = VectorType::Zero(n), p = VectorType::Zero(n);
|
|
57
|
+
VectorType y(n), z(n);
|
|
58
|
+
VectorType kt(n), ks(n);
|
|
59
|
+
|
|
60
|
+
VectorType s(n), t(n);
|
|
61
|
+
|
|
62
|
+
RealScalar tol2 = tol*tol;
|
|
63
|
+
RealScalar eps2 = NumTraits<Scalar>::epsilon()*NumTraits<Scalar>::epsilon();
|
|
64
|
+
int i = 0;
|
|
65
|
+
int restarts = 0;
|
|
66
|
+
|
|
67
|
+
while ( r.squaredNorm()/rhs_sqnorm > tol2 && i<maxIters )
|
|
68
|
+
{
|
|
69
|
+
Scalar rho_old = rho;
|
|
70
|
+
|
|
71
|
+
rho = r0.dot(r);
|
|
72
|
+
if (abs(rho) < eps2*r0_sqnorm)
|
|
73
|
+
{
|
|
74
|
+
// The new residual vector became too orthogonal to the arbitrarily choosen direction r0
|
|
75
|
+
// Let's restart with a new r0:
|
|
76
|
+
r0 = r;
|
|
77
|
+
rho = r0_sqnorm = r.squaredNorm();
|
|
78
|
+
if(restarts++ == 0)
|
|
79
|
+
i = 0;
|
|
80
|
+
}
|
|
81
|
+
Scalar beta = (rho/rho_old) * (alpha / w);
|
|
82
|
+
p = r + beta * (p - w * v);
|
|
83
|
+
|
|
84
|
+
y = precond.solve(p);
|
|
85
|
+
|
|
86
|
+
v.noalias() = mat * y;
|
|
87
|
+
|
|
88
|
+
alpha = rho / r0.dot(v);
|
|
89
|
+
s = r - alpha * v;
|
|
90
|
+
|
|
91
|
+
z = precond.solve(s);
|
|
92
|
+
t.noalias() = mat * z;
|
|
93
|
+
|
|
94
|
+
RealScalar tmp = t.squaredNorm();
|
|
95
|
+
if(tmp>RealScalar(0))
|
|
96
|
+
w = t.dot(s) / tmp;
|
|
97
|
+
else
|
|
98
|
+
w = Scalar(0);
|
|
99
|
+
x += alpha * y + w * z;
|
|
100
|
+
r = s - w * t;
|
|
101
|
+
++i;
|
|
102
|
+
}
|
|
103
|
+
tol_error = sqrt(r.squaredNorm()/rhs_sqnorm);
|
|
104
|
+
iters = i;
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
template< typename _MatrixType,
|
|
111
|
+
typename _Preconditioner = DiagonalPreconditioner<typename _MatrixType::Scalar> >
|
|
112
|
+
class BiCGSTAB;
|
|
113
|
+
|
|
114
|
+
namespace internal {
|
|
115
|
+
|
|
116
|
+
template< typename _MatrixType, typename _Preconditioner>
|
|
117
|
+
struct traits<BiCGSTAB<_MatrixType,_Preconditioner> >
|
|
118
|
+
{
|
|
119
|
+
typedef _MatrixType MatrixType;
|
|
120
|
+
typedef _Preconditioner Preconditioner;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** \ingroup IterativeLinearSolvers_Module
|
|
126
|
+
* \brief A bi conjugate gradient stabilized solver for sparse square problems
|
|
127
|
+
*
|
|
128
|
+
* This class allows to solve for A.x = b sparse linear problems using a bi conjugate gradient
|
|
129
|
+
* stabilized algorithm. The vectors x and b can be either dense or sparse.
|
|
130
|
+
*
|
|
131
|
+
* \tparam _MatrixType the type of the sparse matrix A, can be a dense or a sparse matrix.
|
|
132
|
+
* \tparam _Preconditioner the type of the preconditioner. Default is DiagonalPreconditioner
|
|
133
|
+
*
|
|
134
|
+
* The maximal number of iterations and tolerance value can be controlled via the setMaxIterations()
|
|
135
|
+
* and setTolerance() methods. The defaults are the size of the problem for the maximal number of iterations
|
|
136
|
+
* and NumTraits<Scalar>::epsilon() for the tolerance.
|
|
137
|
+
*
|
|
138
|
+
* This class can be used as the direct solver classes. Here is a typical usage example:
|
|
139
|
+
* \code
|
|
140
|
+
* int n = 10000;
|
|
141
|
+
* VectorXd x(n), b(n);
|
|
142
|
+
* SparseMatrix<double> A(n,n);
|
|
143
|
+
* // fill A and b
|
|
144
|
+
* BiCGSTAB<SparseMatrix<double> > solver;
|
|
145
|
+
* solver.compute(A);
|
|
146
|
+
* x = solver.solve(b);
|
|
147
|
+
* std::cout << "#iterations: " << solver.iterations() << std::endl;
|
|
148
|
+
* std::cout << "estimated error: " << solver.error() << std::endl;
|
|
149
|
+
* // update b, and solve again
|
|
150
|
+
* x = solver.solve(b);
|
|
151
|
+
* \endcode
|
|
152
|
+
*
|
|
153
|
+
* By default the iterations start with x=0 as an initial guess of the solution.
|
|
154
|
+
* One can control the start using the solveWithGuess() method.
|
|
155
|
+
*
|
|
156
|
+
* \sa class SimplicialCholesky, DiagonalPreconditioner, IdentityPreconditioner
|
|
157
|
+
*/
|
|
158
|
+
template< typename _MatrixType, typename _Preconditioner>
|
|
159
|
+
class BiCGSTAB : public IterativeSolverBase<BiCGSTAB<_MatrixType,_Preconditioner> >
|
|
160
|
+
{
|
|
161
|
+
typedef IterativeSolverBase<BiCGSTAB> Base;
|
|
162
|
+
using Base::mp_matrix;
|
|
163
|
+
using Base::m_error;
|
|
164
|
+
using Base::m_iterations;
|
|
165
|
+
using Base::m_info;
|
|
166
|
+
using Base::m_isInitialized;
|
|
167
|
+
public:
|
|
168
|
+
typedef _MatrixType MatrixType;
|
|
169
|
+
typedef typename MatrixType::Scalar Scalar;
|
|
170
|
+
typedef typename MatrixType::Index Index;
|
|
171
|
+
typedef typename MatrixType::RealScalar RealScalar;
|
|
172
|
+
typedef _Preconditioner Preconditioner;
|
|
173
|
+
|
|
174
|
+
public:
|
|
175
|
+
|
|
176
|
+
/** Default constructor. */
|
|
177
|
+
BiCGSTAB() : Base() {}
|
|
178
|
+
|
|
179
|
+
/** Initialize the solver with matrix \a A for further \c Ax=b solving.
|
|
180
|
+
*
|
|
181
|
+
* This constructor is a shortcut for the default constructor followed
|
|
182
|
+
* by a call to compute().
|
|
183
|
+
*
|
|
184
|
+
* \warning this class stores a reference to the matrix A as well as some
|
|
185
|
+
* precomputed values that depend on it. Therefore, if \a A is changed
|
|
186
|
+
* this class becomes invalid. Call compute() to update it with the new
|
|
187
|
+
* matrix A, or modify a copy of A.
|
|
188
|
+
*/
|
|
189
|
+
template<typename MatrixDerived>
|
|
190
|
+
explicit BiCGSTAB(const EigenBase<MatrixDerived>& A) : Base(A.derived()) {}
|
|
191
|
+
|
|
192
|
+
~BiCGSTAB() {}
|
|
193
|
+
|
|
194
|
+
/** \returns the solution x of \f$ A x = b \f$ using the current decomposition of A
|
|
195
|
+
* \a x0 as an initial solution.
|
|
196
|
+
*
|
|
197
|
+
* \sa compute()
|
|
198
|
+
*/
|
|
199
|
+
template<typename Rhs,typename Guess>
|
|
200
|
+
inline const internal::solve_retval_with_guess<BiCGSTAB, Rhs, Guess>
|
|
201
|
+
solveWithGuess(const MatrixBase<Rhs>& b, const Guess& x0) const
|
|
202
|
+
{
|
|
203
|
+
eigen_assert(m_isInitialized && "BiCGSTAB is not initialized.");
|
|
204
|
+
eigen_assert(Base::rows()==b.rows()
|
|
205
|
+
&& "BiCGSTAB::solve(): invalid number of rows of the right hand side matrix b");
|
|
206
|
+
return internal::solve_retval_with_guess
|
|
207
|
+
<BiCGSTAB, Rhs, Guess>(*this, b.derived(), x0);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/** \internal */
|
|
211
|
+
template<typename Rhs,typename Dest>
|
|
212
|
+
void _solveWithGuess(const Rhs& b, Dest& x) const
|
|
213
|
+
{
|
|
214
|
+
bool failed = false;
|
|
215
|
+
for(int j=0; j<b.cols(); ++j)
|
|
216
|
+
{
|
|
217
|
+
m_iterations = Base::maxIterations();
|
|
218
|
+
m_error = Base::m_tolerance;
|
|
219
|
+
|
|
220
|
+
typename Dest::ColXpr xj(x,j);
|
|
221
|
+
if(!internal::bicgstab(*mp_matrix, b.col(j), xj, Base::m_preconditioner, m_iterations, m_error))
|
|
222
|
+
failed = true;
|
|
223
|
+
}
|
|
224
|
+
m_info = failed ? NumericalIssue
|
|
225
|
+
: m_error <= Base::m_tolerance ? Success
|
|
226
|
+
: NoConvergence;
|
|
227
|
+
m_isInitialized = true;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/** \internal */
|
|
231
|
+
template<typename Rhs,typename Dest>
|
|
232
|
+
void _solve(const Rhs& b, Dest& x) const
|
|
233
|
+
{
|
|
234
|
+
// x.setZero();
|
|
235
|
+
x = b;
|
|
236
|
+
_solveWithGuess(b,x);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
protected:
|
|
240
|
+
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
namespace internal {
|
|
245
|
+
|
|
246
|
+
template<typename _MatrixType, typename _Preconditioner, typename Rhs>
|
|
247
|
+
struct solve_retval<BiCGSTAB<_MatrixType, _Preconditioner>, Rhs>
|
|
248
|
+
: solve_retval_base<BiCGSTAB<_MatrixType, _Preconditioner>, Rhs>
|
|
249
|
+
{
|
|
250
|
+
typedef BiCGSTAB<_MatrixType, _Preconditioner> Dec;
|
|
251
|
+
EIGEN_MAKE_SOLVE_HELPERS(Dec,Rhs)
|
|
252
|
+
|
|
253
|
+
template<typename Dest> void evalTo(Dest& dst) const
|
|
254
|
+
{
|
|
255
|
+
dec()._solve(rhs(),dst);
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
} // end namespace internal
|
|
260
|
+
|
|
261
|
+
} // end namespace Eigen
|
|
262
|
+
|
|
263
|
+
#endif // EIGEN_BICGSTAB_H
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
// This file is part of Eigen, a lightweight C++ template library
|
|
2
|
+
// for linear algebra.
|
|
3
|
+
//
|
|
4
|
+
// Copyright (C) 2011 Gael Guennebaud <gael.guennebaud@inria.fr>
|
|
5
|
+
//
|
|
6
|
+
// This Source Code Form is subject to the terms of the Mozilla
|
|
7
|
+
// Public License v. 2.0. If a copy of the MPL was not distributed
|
|
8
|
+
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
9
|
+
|
|
10
|
+
#ifndef EIGEN_CONJUGATE_GRADIENT_H
|
|
11
|
+
#define EIGEN_CONJUGATE_GRADIENT_H
|
|
12
|
+
|
|
13
|
+
namespace Eigen {
|
|
14
|
+
|
|
15
|
+
namespace internal {
|
|
16
|
+
|
|
17
|
+
/** \internal Low-level conjugate gradient algorithm
|
|
18
|
+
* \param mat The matrix A
|
|
19
|
+
* \param rhs The right hand side vector b
|
|
20
|
+
* \param x On input and initial solution, on output the computed solution.
|
|
21
|
+
* \param precond A preconditioner being able to efficiently solve for an
|
|
22
|
+
* approximation of Ax=b (regardless of b)
|
|
23
|
+
* \param iters On input the max number of iteration, on output the number of performed iterations.
|
|
24
|
+
* \param tol_error On input the tolerance error, on output an estimation of the relative error.
|
|
25
|
+
*/
|
|
26
|
+
template<typename MatrixType, typename Rhs, typename Dest, typename Preconditioner>
|
|
27
|
+
EIGEN_DONT_INLINE
|
|
28
|
+
void conjugate_gradient(const MatrixType& mat, const Rhs& rhs, Dest& x,
|
|
29
|
+
const Preconditioner& precond, int& iters,
|
|
30
|
+
typename Dest::RealScalar& tol_error)
|
|
31
|
+
{
|
|
32
|
+
using std::sqrt;
|
|
33
|
+
using std::abs;
|
|
34
|
+
typedef typename Dest::RealScalar RealScalar;
|
|
35
|
+
typedef typename Dest::Scalar Scalar;
|
|
36
|
+
typedef Matrix<Scalar,Dynamic,1> VectorType;
|
|
37
|
+
|
|
38
|
+
RealScalar tol = tol_error;
|
|
39
|
+
int maxIters = iters;
|
|
40
|
+
|
|
41
|
+
int n = mat.cols();
|
|
42
|
+
|
|
43
|
+
VectorType residual = rhs - mat * x; //initial residual
|
|
44
|
+
|
|
45
|
+
RealScalar rhsNorm2 = rhs.squaredNorm();
|
|
46
|
+
if(rhsNorm2 == 0)
|
|
47
|
+
{
|
|
48
|
+
x.setZero();
|
|
49
|
+
iters = 0;
|
|
50
|
+
tol_error = 0;
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
RealScalar threshold = tol*tol*rhsNorm2;
|
|
54
|
+
RealScalar residualNorm2 = residual.squaredNorm();
|
|
55
|
+
if (residualNorm2 < threshold)
|
|
56
|
+
{
|
|
57
|
+
iters = 0;
|
|
58
|
+
tol_error = sqrt(residualNorm2 / rhsNorm2);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
VectorType p(n);
|
|
63
|
+
p = precond.solve(residual); //initial search direction
|
|
64
|
+
|
|
65
|
+
VectorType z(n), tmp(n);
|
|
66
|
+
RealScalar absNew = numext::real(residual.dot(p)); // the square of the absolute value of r scaled by invM
|
|
67
|
+
int i = 0;
|
|
68
|
+
while(i < maxIters)
|
|
69
|
+
{
|
|
70
|
+
tmp.noalias() = mat * p; // the bottleneck of the algorithm
|
|
71
|
+
|
|
72
|
+
Scalar alpha = absNew / p.dot(tmp); // the amount we travel on dir
|
|
73
|
+
x += alpha * p; // update solution
|
|
74
|
+
residual -= alpha * tmp; // update residue
|
|
75
|
+
|
|
76
|
+
residualNorm2 = residual.squaredNorm();
|
|
77
|
+
if(residualNorm2 < threshold)
|
|
78
|
+
break;
|
|
79
|
+
|
|
80
|
+
z = precond.solve(residual); // approximately solve for "A z = residual"
|
|
81
|
+
|
|
82
|
+
RealScalar absOld = absNew;
|
|
83
|
+
absNew = numext::real(residual.dot(z)); // update the absolute value of r
|
|
84
|
+
RealScalar beta = absNew / absOld; // calculate the Gram-Schmidt value used to create the new search direction
|
|
85
|
+
p = z + beta * p; // update search direction
|
|
86
|
+
i++;
|
|
87
|
+
}
|
|
88
|
+
tol_error = sqrt(residualNorm2 / rhsNorm2);
|
|
89
|
+
iters = i;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
template< typename _MatrixType, int _UpLo=Lower,
|
|
95
|
+
typename _Preconditioner = DiagonalPreconditioner<typename _MatrixType::Scalar> >
|
|
96
|
+
class ConjugateGradient;
|
|
97
|
+
|
|
98
|
+
namespace internal {
|
|
99
|
+
|
|
100
|
+
template< typename _MatrixType, int _UpLo, typename _Preconditioner>
|
|
101
|
+
struct traits<ConjugateGradient<_MatrixType,_UpLo,_Preconditioner> >
|
|
102
|
+
{
|
|
103
|
+
typedef _MatrixType MatrixType;
|
|
104
|
+
typedef _Preconditioner Preconditioner;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** \ingroup IterativeLinearSolvers_Module
|
|
110
|
+
* \brief A conjugate gradient solver for sparse self-adjoint problems
|
|
111
|
+
*
|
|
112
|
+
* This class allows to solve for A.x = b sparse linear problems using a conjugate gradient algorithm.
|
|
113
|
+
* The sparse matrix A must be selfadjoint. The vectors x and b can be either dense or sparse.
|
|
114
|
+
*
|
|
115
|
+
* \tparam _MatrixType the type of the matrix A, can be a dense or a sparse matrix.
|
|
116
|
+
* \tparam _UpLo the triangular part that will be used for the computations. It can be Lower,
|
|
117
|
+
* Upper, or Lower|Upper in which the full matrix entries will be considered. Default is Lower.
|
|
118
|
+
* \tparam _Preconditioner the type of the preconditioner. Default is DiagonalPreconditioner
|
|
119
|
+
*
|
|
120
|
+
* The maximal number of iterations and tolerance value can be controlled via the setMaxIterations()
|
|
121
|
+
* and setTolerance() methods. The defaults are the size of the problem for the maximal number of iterations
|
|
122
|
+
* and NumTraits<Scalar>::epsilon() for the tolerance.
|
|
123
|
+
*
|
|
124
|
+
* This class can be used as the direct solver classes. Here is a typical usage example:
|
|
125
|
+
* \code
|
|
126
|
+
* int n = 10000;
|
|
127
|
+
* VectorXd x(n), b(n);
|
|
128
|
+
* SparseMatrix<double> A(n,n);
|
|
129
|
+
* // fill A and b
|
|
130
|
+
* ConjugateGradient<SparseMatrix<double> > cg;
|
|
131
|
+
* cg.compute(A);
|
|
132
|
+
* x = cg.solve(b);
|
|
133
|
+
* std::cout << "#iterations: " << cg.iterations() << std::endl;
|
|
134
|
+
* std::cout << "estimated error: " << cg.error() << std::endl;
|
|
135
|
+
* // update b, and solve again
|
|
136
|
+
* x = cg.solve(b);
|
|
137
|
+
* \endcode
|
|
138
|
+
*
|
|
139
|
+
* By default the iterations start with x=0 as an initial guess of the solution.
|
|
140
|
+
* One can control the start using the solveWithGuess() method.
|
|
141
|
+
*
|
|
142
|
+
* \sa class SimplicialCholesky, DiagonalPreconditioner, IdentityPreconditioner
|
|
143
|
+
*/
|
|
144
|
+
template< typename _MatrixType, int _UpLo, typename _Preconditioner>
|
|
145
|
+
class ConjugateGradient : public IterativeSolverBase<ConjugateGradient<_MatrixType,_UpLo,_Preconditioner> >
|
|
146
|
+
{
|
|
147
|
+
typedef IterativeSolverBase<ConjugateGradient> Base;
|
|
148
|
+
using Base::mp_matrix;
|
|
149
|
+
using Base::m_error;
|
|
150
|
+
using Base::m_iterations;
|
|
151
|
+
using Base::m_info;
|
|
152
|
+
using Base::m_isInitialized;
|
|
153
|
+
public:
|
|
154
|
+
typedef _MatrixType MatrixType;
|
|
155
|
+
typedef typename MatrixType::Scalar Scalar;
|
|
156
|
+
typedef typename MatrixType::Index Index;
|
|
157
|
+
typedef typename MatrixType::RealScalar RealScalar;
|
|
158
|
+
typedef _Preconditioner Preconditioner;
|
|
159
|
+
|
|
160
|
+
enum {
|
|
161
|
+
UpLo = _UpLo
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
public:
|
|
165
|
+
|
|
166
|
+
/** Default constructor. */
|
|
167
|
+
ConjugateGradient() : Base() {}
|
|
168
|
+
|
|
169
|
+
/** Initialize the solver with matrix \a A for further \c Ax=b solving.
|
|
170
|
+
*
|
|
171
|
+
* This constructor is a shortcut for the default constructor followed
|
|
172
|
+
* by a call to compute().
|
|
173
|
+
*
|
|
174
|
+
* \warning this class stores a reference to the matrix A as well as some
|
|
175
|
+
* precomputed values that depend on it. Therefore, if \a A is changed
|
|
176
|
+
* this class becomes invalid. Call compute() to update it with the new
|
|
177
|
+
* matrix A, or modify a copy of A.
|
|
178
|
+
*/
|
|
179
|
+
template<typename MatrixDerived>
|
|
180
|
+
explicit ConjugateGradient(const EigenBase<MatrixDerived>& A) : Base(A.derived()) {}
|
|
181
|
+
|
|
182
|
+
~ConjugateGradient() {}
|
|
183
|
+
|
|
184
|
+
/** \returns the solution x of \f$ A x = b \f$ using the current decomposition of A
|
|
185
|
+
* \a x0 as an initial solution.
|
|
186
|
+
*
|
|
187
|
+
* \sa compute()
|
|
188
|
+
*/
|
|
189
|
+
template<typename Rhs,typename Guess>
|
|
190
|
+
inline const internal::solve_retval_with_guess<ConjugateGradient, Rhs, Guess>
|
|
191
|
+
solveWithGuess(const MatrixBase<Rhs>& b, const Guess& x0) const
|
|
192
|
+
{
|
|
193
|
+
eigen_assert(m_isInitialized && "ConjugateGradient is not initialized.");
|
|
194
|
+
eigen_assert(Base::rows()==b.rows()
|
|
195
|
+
&& "ConjugateGradient::solve(): invalid number of rows of the right hand side matrix b");
|
|
196
|
+
return internal::solve_retval_with_guess
|
|
197
|
+
<ConjugateGradient, Rhs, Guess>(*this, b.derived(), x0);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/** \internal */
|
|
201
|
+
template<typename Rhs,typename Dest>
|
|
202
|
+
void _solveWithGuess(const Rhs& b, Dest& x) const
|
|
203
|
+
{
|
|
204
|
+
typedef typename internal::conditional<UpLo==(Lower|Upper),
|
|
205
|
+
const MatrixType&,
|
|
206
|
+
SparseSelfAdjointView<const MatrixType, UpLo>
|
|
207
|
+
>::type MatrixWrapperType;
|
|
208
|
+
m_iterations = Base::maxIterations();
|
|
209
|
+
m_error = Base::m_tolerance;
|
|
210
|
+
|
|
211
|
+
for(int j=0; j<b.cols(); ++j)
|
|
212
|
+
{
|
|
213
|
+
m_iterations = Base::maxIterations();
|
|
214
|
+
m_error = Base::m_tolerance;
|
|
215
|
+
|
|
216
|
+
typename Dest::ColXpr xj(x,j);
|
|
217
|
+
internal::conjugate_gradient(MatrixWrapperType(*mp_matrix), b.col(j), xj, Base::m_preconditioner, m_iterations, m_error);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
m_isInitialized = true;
|
|
221
|
+
m_info = m_error <= Base::m_tolerance ? Success : NoConvergence;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/** \internal */
|
|
225
|
+
template<typename Rhs,typename Dest>
|
|
226
|
+
void _solve(const Rhs& b, Dest& x) const
|
|
227
|
+
{
|
|
228
|
+
x.setZero();
|
|
229
|
+
_solveWithGuess(b,x);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
protected:
|
|
233
|
+
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
namespace internal {
|
|
238
|
+
|
|
239
|
+
template<typename _MatrixType, int _UpLo, typename _Preconditioner, typename Rhs>
|
|
240
|
+
struct solve_retval<ConjugateGradient<_MatrixType,_UpLo,_Preconditioner>, Rhs>
|
|
241
|
+
: solve_retval_base<ConjugateGradient<_MatrixType,_UpLo,_Preconditioner>, Rhs>
|
|
242
|
+
{
|
|
243
|
+
typedef ConjugateGradient<_MatrixType,_UpLo,_Preconditioner> Dec;
|
|
244
|
+
EIGEN_MAKE_SOLVE_HELPERS(Dec,Rhs)
|
|
245
|
+
|
|
246
|
+
template<typename Dest> void evalTo(Dest& dst) const
|
|
247
|
+
{
|
|
248
|
+
dec()._solve(rhs(),dst);
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
} // end namespace internal
|
|
253
|
+
|
|
254
|
+
} // end namespace Eigen
|
|
255
|
+
|
|
256
|
+
#endif // EIGEN_CONJUGATE_GRADIENT_H
|