ruby-eigen 0.0.9 → 0.0.10.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +22 -0
- data/README.md +21 -0
- data/ext/eigen/eigen3/COPYING.BSD +26 -0
- data/ext/eigen/eigen3/COPYING.MPL2 +373 -0
- data/ext/eigen/eigen3/COPYING.README +18 -0
- data/ext/eigen/eigen3/Eigen/Array +11 -0
- data/ext/eigen/eigen3/Eigen/Cholesky +32 -0
- data/ext/eigen/eigen3/Eigen/CholmodSupport +45 -0
- data/ext/eigen/eigen3/Eigen/Core +376 -0
- data/ext/eigen/eigen3/Eigen/Dense +7 -0
- data/ext/eigen/eigen3/Eigen/Eigen +2 -0
- data/ext/eigen/eigen3/Eigen/Eigen2Support +95 -0
- data/ext/eigen/eigen3/Eigen/Eigenvalues +48 -0
- data/ext/eigen/eigen3/Eigen/Geometry +63 -0
- data/ext/eigen/eigen3/Eigen/Householder +23 -0
- data/ext/eigen/eigen3/Eigen/IterativeLinearSolvers +40 -0
- data/ext/eigen/eigen3/Eigen/Jacobi +26 -0
- data/ext/eigen/eigen3/Eigen/LU +41 -0
- data/ext/eigen/eigen3/Eigen/LeastSquares +32 -0
- data/ext/eigen/eigen3/Eigen/MetisSupport +28 -0
- data/ext/eigen/eigen3/Eigen/PaStiXSupport +46 -0
- data/ext/eigen/eigen3/Eigen/PardisoSupport +30 -0
- data/ext/eigen/eigen3/Eigen/QR +45 -0
- data/ext/eigen/eigen3/Eigen/QtAlignedMalloc +34 -0
- data/ext/eigen/eigen3/Eigen/SPQRSupport +29 -0
- data/ext/eigen/eigen3/Eigen/SVD +37 -0
- data/ext/eigen/eigen3/Eigen/Sparse +27 -0
- data/ext/eigen/eigen3/Eigen/SparseCore +64 -0
- data/ext/eigen/eigen3/Eigen/SparseLU +49 -0
- data/ext/eigen/eigen3/Eigen/SparseQR +33 -0
- data/ext/eigen/eigen3/Eigen/StdDeque +27 -0
- data/ext/eigen/eigen3/Eigen/StdList +26 -0
- data/ext/eigen/eigen3/Eigen/StdVector +27 -0
- data/ext/eigen/eigen3/Eigen/SuperLUSupport +59 -0
- data/ext/eigen/eigen3/Eigen/UmfPackSupport +36 -0
- data/ext/eigen/eigen3/Eigen/src/Cholesky/LDLT.h +611 -0
- data/ext/eigen/eigen3/Eigen/src/Cholesky/LLT.h +498 -0
- data/ext/eigen/eigen3/Eigen/src/Cholesky/LLT_MKL.h +102 -0
- data/ext/eigen/eigen3/Eigen/src/CholmodSupport/CholmodSupport.h +607 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Array.h +323 -0
- data/ext/eigen/eigen3/Eigen/src/Core/ArrayBase.h +226 -0
- data/ext/eigen/eigen3/Eigen/src/Core/ArrayWrapper.h +264 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Assign.h +590 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Assign_MKL.h +224 -0
- data/ext/eigen/eigen3/Eigen/src/Core/BandMatrix.h +334 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Block.h +406 -0
- data/ext/eigen/eigen3/Eigen/src/Core/BooleanRedux.h +154 -0
- data/ext/eigen/eigen3/Eigen/src/Core/CommaInitializer.h +154 -0
- data/ext/eigen/eigen3/Eigen/src/Core/CoreIterators.h +61 -0
- data/ext/eigen/eigen3/Eigen/src/Core/CwiseBinaryOp.h +230 -0
- data/ext/eigen/eigen3/Eigen/src/Core/CwiseNullaryOp.h +864 -0
- data/ext/eigen/eigen3/Eigen/src/Core/CwiseUnaryOp.h +126 -0
- data/ext/eigen/eigen3/Eigen/src/Core/CwiseUnaryView.h +139 -0
- data/ext/eigen/eigen3/Eigen/src/Core/DenseBase.h +521 -0
- data/ext/eigen/eigen3/Eigen/src/Core/DenseCoeffsBase.h +754 -0
- data/ext/eigen/eigen3/Eigen/src/Core/DenseStorage.h +434 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Diagonal.h +237 -0
- data/ext/eigen/eigen3/Eigen/src/Core/DiagonalMatrix.h +313 -0
- data/ext/eigen/eigen3/Eigen/src/Core/DiagonalProduct.h +131 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Dot.h +263 -0
- data/ext/eigen/eigen3/Eigen/src/Core/EigenBase.h +131 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Flagged.h +140 -0
- data/ext/eigen/eigen3/Eigen/src/Core/ForceAlignedAccess.h +146 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Functors.h +1026 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Fuzzy.h +150 -0
- data/ext/eigen/eigen3/Eigen/src/Core/GeneralProduct.h +635 -0
- data/ext/eigen/eigen3/Eigen/src/Core/GenericPacketMath.h +350 -0
- data/ext/eigen/eigen3/Eigen/src/Core/GlobalFunctions.h +92 -0
- data/ext/eigen/eigen3/Eigen/src/Core/IO.h +250 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Map.h +192 -0
- data/ext/eigen/eigen3/Eigen/src/Core/MapBase.h +247 -0
- data/ext/eigen/eigen3/Eigen/src/Core/MathFunctions.h +768 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Matrix.h +420 -0
- data/ext/eigen/eigen3/Eigen/src/Core/MatrixBase.h +563 -0
- data/ext/eigen/eigen3/Eigen/src/Core/NestByValue.h +111 -0
- data/ext/eigen/eigen3/Eigen/src/Core/NoAlias.h +134 -0
- data/ext/eigen/eigen3/Eigen/src/Core/NumTraits.h +150 -0
- data/ext/eigen/eigen3/Eigen/src/Core/PermutationMatrix.h +721 -0
- data/ext/eigen/eigen3/Eigen/src/Core/PlainObjectBase.h +822 -0
- data/ext/eigen/eigen3/Eigen/src/Core/ProductBase.h +290 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Random.h +152 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Redux.h +409 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Ref.h +278 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Replicate.h +177 -0
- data/ext/eigen/eigen3/Eigen/src/Core/ReturnByValue.h +99 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Reverse.h +224 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Select.h +162 -0
- data/ext/eigen/eigen3/Eigen/src/Core/SelfAdjointView.h +314 -0
- data/ext/eigen/eigen3/Eigen/src/Core/SelfCwiseBinaryOp.h +191 -0
- data/ext/eigen/eigen3/Eigen/src/Core/SolveTriangular.h +260 -0
- data/ext/eigen/eigen3/Eigen/src/Core/StableNorm.h +203 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Stride.h +108 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Swap.h +126 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Transpose.h +419 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Transpositions.h +436 -0
- data/ext/eigen/eigen3/Eigen/src/Core/TriangularMatrix.h +839 -0
- data/ext/eigen/eigen3/Eigen/src/Core/VectorBlock.h +95 -0
- data/ext/eigen/eigen3/Eigen/src/Core/VectorwiseOp.h +642 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Visitor.h +237 -0
- data/ext/eigen/eigen3/Eigen/src/Core/arch/AltiVec/Complex.h +217 -0
- data/ext/eigen/eigen3/Eigen/src/Core/arch/AltiVec/PacketMath.h +501 -0
- data/ext/eigen/eigen3/Eigen/src/Core/arch/Default/Settings.h +49 -0
- data/ext/eigen/eigen3/Eigen/src/Core/arch/NEON/Complex.h +253 -0
- data/ext/eigen/eigen3/Eigen/src/Core/arch/NEON/PacketMath.h +420 -0
- data/ext/eigen/eigen3/Eigen/src/Core/arch/SSE/Complex.h +442 -0
- data/ext/eigen/eigen3/Eigen/src/Core/arch/SSE/MathFunctions.h +475 -0
- data/ext/eigen/eigen3/Eigen/src/Core/arch/SSE/PacketMath.h +649 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/CoeffBasedProduct.h +476 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/GeneralBlockPanelKernel.h +1341 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/GeneralMatrixMatrix.h +427 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/GeneralMatrixMatrixTriangular.h +278 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/GeneralMatrixMatrixTriangular_MKL.h +146 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/GeneralMatrixMatrix_MKL.h +118 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/GeneralMatrixVector.h +566 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/GeneralMatrixVector_MKL.h +131 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/Parallelizer.h +162 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/SelfadjointMatrixMatrix.h +436 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/SelfadjointMatrixMatrix_MKL.h +295 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/SelfadjointMatrixVector.h +281 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/SelfadjointMatrixVector_MKL.h +114 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/SelfadjointProduct.h +123 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/SelfadjointRank2Update.h +93 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/TriangularMatrixMatrix.h +427 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/TriangularMatrixMatrix_MKL.h +309 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/TriangularMatrixVector.h +348 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/TriangularMatrixVector_MKL.h +247 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/TriangularSolverMatrix.h +332 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/TriangularSolverMatrix_MKL.h +155 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/TriangularSolverVector.h +139 -0
- data/ext/eigen/eigen3/Eigen/src/Core/util/BlasUtil.h +264 -0
- data/ext/eigen/eigen3/Eigen/src/Core/util/Constants.h +451 -0
- data/ext/eigen/eigen3/Eigen/src/Core/util/DisableStupidWarnings.h +40 -0
- data/ext/eigen/eigen3/Eigen/src/Core/util/ForwardDeclarations.h +302 -0
- data/ext/eigen/eigen3/Eigen/src/Core/util/MKL_support.h +158 -0
- data/ext/eigen/eigen3/Eigen/src/Core/util/Macros.h +451 -0
- data/ext/eigen/eigen3/Eigen/src/Core/util/Memory.h +977 -0
- data/ext/eigen/eigen3/Eigen/src/Core/util/Meta.h +243 -0
- data/ext/eigen/eigen3/Eigen/src/Core/util/NonMPL2.h +3 -0
- data/ext/eigen/eigen3/Eigen/src/Core/util/ReenableStupidWarnings.h +14 -0
- data/ext/eigen/eigen3/Eigen/src/Core/util/StaticAssert.h +208 -0
- data/ext/eigen/eigen3/Eigen/src/Core/util/XprHelper.h +469 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Block.h +126 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Cwise.h +192 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/CwiseOperators.h +298 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/AlignedBox.h +159 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/All.h +115 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/AngleAxis.h +214 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/Hyperplane.h +254 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/ParametrizedLine.h +141 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/Quaternion.h +495 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/Rotation2D.h +145 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/RotationBase.h +123 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/Scaling.h +167 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/Transform.h +786 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/Translation.h +184 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/LU.h +120 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Lazy.h +71 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/LeastSquares.h +169 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Macros.h +20 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/MathFunctions.h +57 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Memory.h +45 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Meta.h +75 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Minor.h +117 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/QR.h +67 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/SVD.h +637 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/TriangularSolver.h +42 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/VectorBlock.h +94 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/ComplexEigenSolver.h +341 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/ComplexSchur.h +456 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/ComplexSchur_MKL.h +94 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/EigenSolver.h +607 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/GeneralizedEigenSolver.h +350 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h +227 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/HessenbergDecomposition.h +373 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/MatrixBaseEigenvalues.h +160 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/RealQZ.h +624 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/RealSchur.h +525 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/RealSchur_MKL.h +83 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h +801 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/SelfAdjointEigenSolver_MKL.h +92 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/Tridiagonalization.h +557 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/AlignedBox.h +392 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/AngleAxis.h +233 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/EulerAngles.h +104 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/Homogeneous.h +307 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/Hyperplane.h +280 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/OrthoMethods.h +218 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/ParametrizedLine.h +195 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/Quaternion.h +776 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/Rotation2D.h +160 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/RotationBase.h +206 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/Scaling.h +166 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/Transform.h +1455 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/Translation.h +206 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/Umeyama.h +177 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/arch/Geometry_SSE.h +115 -0
- data/ext/eigen/eigen3/Eigen/src/Householder/BlockHouseholder.h +68 -0
- data/ext/eigen/eigen3/Eigen/src/Householder/Householder.h +171 -0
- data/ext/eigen/eigen3/Eigen/src/Householder/HouseholderSequence.h +441 -0
- data/ext/eigen/eigen3/Eigen/src/IterativeLinearSolvers/BasicPreconditioners.h +149 -0
- data/ext/eigen/eigen3/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h +263 -0
- data/ext/eigen/eigen3/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h +256 -0
- data/ext/eigen/eigen3/Eigen/src/IterativeLinearSolvers/IterativeSolverBase.h +282 -0
- data/ext/eigen/eigen3/Eigen/src/Jacobi/Jacobi.h +433 -0
- data/ext/eigen/eigen3/Eigen/src/LU/Determinant.h +101 -0
- data/ext/eigen/eigen3/Eigen/src/LU/FullPivLU.h +751 -0
- data/ext/eigen/eigen3/Eigen/src/LU/Inverse.h +400 -0
- data/ext/eigen/eigen3/Eigen/src/LU/PartialPivLU.h +509 -0
- data/ext/eigen/eigen3/Eigen/src/LU/PartialPivLU_MKL.h +85 -0
- data/ext/eigen/eigen3/Eigen/src/LU/arch/Inverse_SSE.h +329 -0
- data/ext/eigen/eigen3/Eigen/src/MetisSupport/MetisSupport.h +137 -0
- data/ext/eigen/eigen3/Eigen/src/OrderingMethods/Amd.h +444 -0
- data/ext/eigen/eigen3/Eigen/src/OrderingMethods/Eigen_Colamd.h +1850 -0
- data/ext/eigen/eigen3/Eigen/src/PaStiXSupport/PaStiXSupport.h +721 -0
- data/ext/eigen/eigen3/Eigen/src/PardisoSupport/PardisoSupport.h +592 -0
- data/ext/eigen/eigen3/Eigen/src/QR/ColPivHouseholderQR.h +580 -0
- data/ext/eigen/eigen3/Eigen/src/QR/ColPivHouseholderQR_MKL.h +99 -0
- data/ext/eigen/eigen3/Eigen/src/QR/FullPivHouseholderQR.h +622 -0
- data/ext/eigen/eigen3/Eigen/src/QR/HouseholderQR.h +388 -0
- data/ext/eigen/eigen3/Eigen/src/QR/HouseholderQR_MKL.h +71 -0
- data/ext/eigen/eigen3/Eigen/src/SPQRSupport/SuiteSparseQRSupport.h +338 -0
- data/ext/eigen/eigen3/Eigen/src/SVD/JacobiSVD.h +976 -0
- data/ext/eigen/eigen3/Eigen/src/SVD/JacobiSVD_MKL.h +92 -0
- data/ext/eigen/eigen3/Eigen/src/SVD/UpperBidiagonalization.h +148 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCholesky/SimplicialCholesky.h +671 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h +199 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/AmbiVector.h +373 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/CompressedStorage.h +233 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/ConservativeSparseSparseProduct.h +245 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/MappedSparseMatrix.h +181 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseBlock.h +537 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseColEtree.h +206 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseCwiseBinaryOp.h +325 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseCwiseUnaryOp.h +163 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseDenseProduct.h +311 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseDiagonalProduct.h +196 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseDot.h +101 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseFuzzy.h +26 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseMatrix.h +1262 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseMatrixBase.h +461 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparsePermutation.h +148 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseProduct.h +188 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseRedux.h +45 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseSelfAdjointView.h +507 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseSparseProductWithPruning.h +150 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseTranspose.h +63 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseTriangularView.h +179 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseUtil.h +172 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseVector.h +448 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseView.h +99 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/TriangularSolver.h +334 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU.h +806 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLUImpl.h +66 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_Memory.h +227 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_Structs.h +111 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_SupernodalMatrix.h +298 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_Utils.h +80 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_column_bmod.h +180 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_column_dfs.h +177 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_copy_to_ucol.h +106 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_gemm_kernel.h +279 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_heap_relax_snode.h +127 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_kernel_bmod.h +130 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_panel_bmod.h +223 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_panel_dfs.h +258 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_pivotL.h +137 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_pruneL.h +135 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_relax_snode.h +83 -0
- data/ext/eigen/eigen3/Eigen/src/SparseQR/SparseQR.h +714 -0
- data/ext/eigen/eigen3/Eigen/src/StlSupport/StdDeque.h +134 -0
- data/ext/eigen/eigen3/Eigen/src/StlSupport/StdList.h +114 -0
- data/ext/eigen/eigen3/Eigen/src/StlSupport/StdVector.h +126 -0
- data/ext/eigen/eigen3/Eigen/src/StlSupport/details.h +84 -0
- data/ext/eigen/eigen3/Eigen/src/SuperLUSupport/SuperLUSupport.h +1026 -0
- data/ext/eigen/eigen3/Eigen/src/UmfPackSupport/UmfPackSupport.h +474 -0
- data/ext/eigen/eigen3/Eigen/src/misc/Image.h +84 -0
- data/ext/eigen/eigen3/Eigen/src/misc/Kernel.h +81 -0
- data/ext/eigen/eigen3/Eigen/src/misc/Solve.h +76 -0
- data/ext/eigen/eigen3/Eigen/src/misc/SparseSolve.h +128 -0
- data/ext/eigen/eigen3/Eigen/src/misc/blas.h +658 -0
- data/ext/eigen/eigen3/Eigen/src/plugins/ArrayCwiseBinaryOps.h +253 -0
- data/ext/eigen/eigen3/Eigen/src/plugins/ArrayCwiseUnaryOps.h +187 -0
- data/ext/eigen/eigen3/Eigen/src/plugins/BlockMethods.h +935 -0
- data/ext/eigen/eigen3/Eigen/src/plugins/CommonCwiseBinaryOps.h +46 -0
- data/ext/eigen/eigen3/Eigen/src/plugins/CommonCwiseUnaryOps.h +172 -0
- data/ext/eigen/eigen3/Eigen/src/plugins/MatrixCwiseBinaryOps.h +143 -0
- data/ext/eigen/eigen3/Eigen/src/plugins/MatrixCwiseUnaryOps.h +52 -0
- data/ext/eigen/eigen3/signature_of_eigen3_matrix_library +1 -0
- data/ext/eigen/eigen_wrap.cxx +19420 -10396
- data/ext/eigen/extconf.rb +37 -2
- data/lib/eigen.rb +146 -3
- metadata +294 -7
@@ -0,0 +1,148 @@
|
|
1
|
+
// This file is part of Eigen, a lightweight C++ template library
|
2
|
+
// for linear algebra.
|
3
|
+
//
|
4
|
+
// Copyright (C) 2012 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_SPARSE_PERMUTATION_H
|
11
|
+
#define EIGEN_SPARSE_PERMUTATION_H
|
12
|
+
|
13
|
+
// This file implements sparse * permutation products
|
14
|
+
|
15
|
+
namespace Eigen {
|
16
|
+
|
17
|
+
namespace internal {
|
18
|
+
|
19
|
+
template<typename PermutationType, typename MatrixType, int Side, bool Transposed>
|
20
|
+
struct traits<permut_sparsematrix_product_retval<PermutationType, MatrixType, Side, Transposed> >
|
21
|
+
{
|
22
|
+
typedef typename remove_all<typename MatrixType::Nested>::type MatrixTypeNestedCleaned;
|
23
|
+
typedef typename MatrixTypeNestedCleaned::Scalar Scalar;
|
24
|
+
typedef typename MatrixTypeNestedCleaned::Index Index;
|
25
|
+
enum {
|
26
|
+
SrcStorageOrder = MatrixTypeNestedCleaned::Flags&RowMajorBit ? RowMajor : ColMajor,
|
27
|
+
MoveOuter = SrcStorageOrder==RowMajor ? Side==OnTheLeft : Side==OnTheRight
|
28
|
+
};
|
29
|
+
|
30
|
+
typedef typename internal::conditional<MoveOuter,
|
31
|
+
SparseMatrix<Scalar,SrcStorageOrder,Index>,
|
32
|
+
SparseMatrix<Scalar,int(SrcStorageOrder)==RowMajor?ColMajor:RowMajor,Index> >::type ReturnType;
|
33
|
+
};
|
34
|
+
|
35
|
+
template<typename PermutationType, typename MatrixType, int Side, bool Transposed>
|
36
|
+
struct permut_sparsematrix_product_retval
|
37
|
+
: public ReturnByValue<permut_sparsematrix_product_retval<PermutationType, MatrixType, Side, Transposed> >
|
38
|
+
{
|
39
|
+
typedef typename remove_all<typename MatrixType::Nested>::type MatrixTypeNestedCleaned;
|
40
|
+
typedef typename MatrixTypeNestedCleaned::Scalar Scalar;
|
41
|
+
typedef typename MatrixTypeNestedCleaned::Index Index;
|
42
|
+
|
43
|
+
enum {
|
44
|
+
SrcStorageOrder = MatrixTypeNestedCleaned::Flags&RowMajorBit ? RowMajor : ColMajor,
|
45
|
+
MoveOuter = SrcStorageOrder==RowMajor ? Side==OnTheLeft : Side==OnTheRight
|
46
|
+
};
|
47
|
+
|
48
|
+
permut_sparsematrix_product_retval(const PermutationType& perm, const MatrixType& matrix)
|
49
|
+
: m_permutation(perm), m_matrix(matrix)
|
50
|
+
{}
|
51
|
+
|
52
|
+
inline int rows() const { return m_matrix.rows(); }
|
53
|
+
inline int cols() const { return m_matrix.cols(); }
|
54
|
+
|
55
|
+
template<typename Dest> inline void evalTo(Dest& dst) const
|
56
|
+
{
|
57
|
+
if(MoveOuter)
|
58
|
+
{
|
59
|
+
SparseMatrix<Scalar,SrcStorageOrder,Index> tmp(m_matrix.rows(), m_matrix.cols());
|
60
|
+
Matrix<Index,Dynamic,1> sizes(m_matrix.outerSize());
|
61
|
+
for(Index j=0; j<m_matrix.outerSize(); ++j)
|
62
|
+
{
|
63
|
+
Index jp = m_permutation.indices().coeff(j);
|
64
|
+
sizes[((Side==OnTheLeft) ^ Transposed) ? jp : j] = m_matrix.innerVector(((Side==OnTheRight) ^ Transposed) ? jp : j).nonZeros();
|
65
|
+
}
|
66
|
+
tmp.reserve(sizes);
|
67
|
+
for(Index j=0; j<m_matrix.outerSize(); ++j)
|
68
|
+
{
|
69
|
+
Index jp = m_permutation.indices().coeff(j);
|
70
|
+
Index jsrc = ((Side==OnTheRight) ^ Transposed) ? jp : j;
|
71
|
+
Index jdst = ((Side==OnTheLeft) ^ Transposed) ? jp : j;
|
72
|
+
for(typename MatrixTypeNestedCleaned::InnerIterator it(m_matrix,jsrc); it; ++it)
|
73
|
+
tmp.insertByOuterInner(jdst,it.index()) = it.value();
|
74
|
+
}
|
75
|
+
dst = tmp;
|
76
|
+
}
|
77
|
+
else
|
78
|
+
{
|
79
|
+
SparseMatrix<Scalar,int(SrcStorageOrder)==RowMajor?ColMajor:RowMajor,Index> tmp(m_matrix.rows(), m_matrix.cols());
|
80
|
+
Matrix<Index,Dynamic,1> sizes(tmp.outerSize());
|
81
|
+
sizes.setZero();
|
82
|
+
PermutationMatrix<Dynamic,Dynamic,Index> perm;
|
83
|
+
if((Side==OnTheLeft) ^ Transposed)
|
84
|
+
perm = m_permutation;
|
85
|
+
else
|
86
|
+
perm = m_permutation.transpose();
|
87
|
+
|
88
|
+
for(Index j=0; j<m_matrix.outerSize(); ++j)
|
89
|
+
for(typename MatrixTypeNestedCleaned::InnerIterator it(m_matrix,j); it; ++it)
|
90
|
+
sizes[perm.indices().coeff(it.index())]++;
|
91
|
+
tmp.reserve(sizes);
|
92
|
+
for(Index j=0; j<m_matrix.outerSize(); ++j)
|
93
|
+
for(typename MatrixTypeNestedCleaned::InnerIterator it(m_matrix,j); it; ++it)
|
94
|
+
tmp.insertByOuterInner(perm.indices().coeff(it.index()),j) = it.value();
|
95
|
+
dst = tmp;
|
96
|
+
}
|
97
|
+
}
|
98
|
+
|
99
|
+
protected:
|
100
|
+
const PermutationType& m_permutation;
|
101
|
+
typename MatrixType::Nested m_matrix;
|
102
|
+
};
|
103
|
+
|
104
|
+
}
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
/** \returns the matrix with the permutation applied to the columns
|
109
|
+
*/
|
110
|
+
template<typename SparseDerived, typename PermDerived>
|
111
|
+
inline const internal::permut_sparsematrix_product_retval<PermutationBase<PermDerived>, SparseDerived, OnTheRight, false>
|
112
|
+
operator*(const SparseMatrixBase<SparseDerived>& matrix, const PermutationBase<PermDerived>& perm)
|
113
|
+
{
|
114
|
+
return internal::permut_sparsematrix_product_retval<PermutationBase<PermDerived>, SparseDerived, OnTheRight, false>(perm, matrix.derived());
|
115
|
+
}
|
116
|
+
|
117
|
+
/** \returns the matrix with the permutation applied to the rows
|
118
|
+
*/
|
119
|
+
template<typename SparseDerived, typename PermDerived>
|
120
|
+
inline const internal::permut_sparsematrix_product_retval<PermutationBase<PermDerived>, SparseDerived, OnTheLeft, false>
|
121
|
+
operator*( const PermutationBase<PermDerived>& perm, const SparseMatrixBase<SparseDerived>& matrix)
|
122
|
+
{
|
123
|
+
return internal::permut_sparsematrix_product_retval<PermutationBase<PermDerived>, SparseDerived, OnTheLeft, false>(perm, matrix.derived());
|
124
|
+
}
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
/** \returns the matrix with the inverse permutation applied to the columns.
|
129
|
+
*/
|
130
|
+
template<typename SparseDerived, typename PermDerived>
|
131
|
+
inline const internal::permut_sparsematrix_product_retval<PermutationBase<PermDerived>, SparseDerived, OnTheRight, true>
|
132
|
+
operator*(const SparseMatrixBase<SparseDerived>& matrix, const Transpose<PermutationBase<PermDerived> >& tperm)
|
133
|
+
{
|
134
|
+
return internal::permut_sparsematrix_product_retval<PermutationBase<PermDerived>, SparseDerived, OnTheRight, true>(tperm.nestedPermutation(), matrix.derived());
|
135
|
+
}
|
136
|
+
|
137
|
+
/** \returns the matrix with the inverse permutation applied to the rows.
|
138
|
+
*/
|
139
|
+
template<typename SparseDerived, typename PermDerived>
|
140
|
+
inline const internal::permut_sparsematrix_product_retval<PermutationBase<PermDerived>, SparseDerived, OnTheLeft, true>
|
141
|
+
operator*(const Transpose<PermutationBase<PermDerived> >& tperm, const SparseMatrixBase<SparseDerived>& matrix)
|
142
|
+
{
|
143
|
+
return internal::permut_sparsematrix_product_retval<PermutationBase<PermDerived>, SparseDerived, OnTheLeft, true>(tperm.nestedPermutation(), matrix.derived());
|
144
|
+
}
|
145
|
+
|
146
|
+
} // end namespace Eigen
|
147
|
+
|
148
|
+
#endif // EIGEN_SPARSE_SELFADJOINTVIEW_H
|
@@ -0,0 +1,188 @@
|
|
1
|
+
// This file is part of Eigen, a lightweight C++ template library
|
2
|
+
// for linear algebra.
|
3
|
+
//
|
4
|
+
// Copyright (C) 2008-2010 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_SPARSEPRODUCT_H
|
11
|
+
#define EIGEN_SPARSEPRODUCT_H
|
12
|
+
|
13
|
+
namespace Eigen {
|
14
|
+
|
15
|
+
template<typename Lhs, typename Rhs>
|
16
|
+
struct SparseSparseProductReturnType
|
17
|
+
{
|
18
|
+
typedef typename internal::traits<Lhs>::Scalar Scalar;
|
19
|
+
typedef typename internal::traits<Lhs>::Index Index;
|
20
|
+
enum {
|
21
|
+
LhsRowMajor = internal::traits<Lhs>::Flags & RowMajorBit,
|
22
|
+
RhsRowMajor = internal::traits<Rhs>::Flags & RowMajorBit,
|
23
|
+
TransposeRhs = (!LhsRowMajor) && RhsRowMajor,
|
24
|
+
TransposeLhs = LhsRowMajor && (!RhsRowMajor)
|
25
|
+
};
|
26
|
+
|
27
|
+
typedef typename internal::conditional<TransposeLhs,
|
28
|
+
SparseMatrix<Scalar,0,Index>,
|
29
|
+
typename internal::nested<Lhs,Rhs::RowsAtCompileTime>::type>::type LhsNested;
|
30
|
+
|
31
|
+
typedef typename internal::conditional<TransposeRhs,
|
32
|
+
SparseMatrix<Scalar,0,Index>,
|
33
|
+
typename internal::nested<Rhs,Lhs::RowsAtCompileTime>::type>::type RhsNested;
|
34
|
+
|
35
|
+
typedef SparseSparseProduct<LhsNested, RhsNested> Type;
|
36
|
+
};
|
37
|
+
|
38
|
+
namespace internal {
|
39
|
+
template<typename LhsNested, typename RhsNested>
|
40
|
+
struct traits<SparseSparseProduct<LhsNested, RhsNested> >
|
41
|
+
{
|
42
|
+
typedef MatrixXpr XprKind;
|
43
|
+
// clean the nested types:
|
44
|
+
typedef typename remove_all<LhsNested>::type _LhsNested;
|
45
|
+
typedef typename remove_all<RhsNested>::type _RhsNested;
|
46
|
+
typedef typename _LhsNested::Scalar Scalar;
|
47
|
+
typedef typename promote_index_type<typename traits<_LhsNested>::Index,
|
48
|
+
typename traits<_RhsNested>::Index>::type Index;
|
49
|
+
|
50
|
+
enum {
|
51
|
+
LhsCoeffReadCost = _LhsNested::CoeffReadCost,
|
52
|
+
RhsCoeffReadCost = _RhsNested::CoeffReadCost,
|
53
|
+
LhsFlags = _LhsNested::Flags,
|
54
|
+
RhsFlags = _RhsNested::Flags,
|
55
|
+
|
56
|
+
RowsAtCompileTime = _LhsNested::RowsAtCompileTime,
|
57
|
+
ColsAtCompileTime = _RhsNested::ColsAtCompileTime,
|
58
|
+
MaxRowsAtCompileTime = _LhsNested::MaxRowsAtCompileTime,
|
59
|
+
MaxColsAtCompileTime = _RhsNested::MaxColsAtCompileTime,
|
60
|
+
|
61
|
+
InnerSize = EIGEN_SIZE_MIN_PREFER_FIXED(_LhsNested::ColsAtCompileTime, _RhsNested::RowsAtCompileTime),
|
62
|
+
|
63
|
+
EvalToRowMajor = (RhsFlags & LhsFlags & RowMajorBit),
|
64
|
+
|
65
|
+
RemovedBits = ~(EvalToRowMajor ? 0 : RowMajorBit),
|
66
|
+
|
67
|
+
Flags = (int(LhsFlags | RhsFlags) & HereditaryBits & RemovedBits)
|
68
|
+
| EvalBeforeAssigningBit
|
69
|
+
| EvalBeforeNestingBit,
|
70
|
+
|
71
|
+
CoeffReadCost = Dynamic
|
72
|
+
};
|
73
|
+
|
74
|
+
typedef Sparse StorageKind;
|
75
|
+
};
|
76
|
+
|
77
|
+
} // end namespace internal
|
78
|
+
|
79
|
+
template<typename LhsNested, typename RhsNested>
|
80
|
+
class SparseSparseProduct : internal::no_assignment_operator,
|
81
|
+
public SparseMatrixBase<SparseSparseProduct<LhsNested, RhsNested> >
|
82
|
+
{
|
83
|
+
public:
|
84
|
+
|
85
|
+
typedef SparseMatrixBase<SparseSparseProduct> Base;
|
86
|
+
EIGEN_DENSE_PUBLIC_INTERFACE(SparseSparseProduct)
|
87
|
+
|
88
|
+
private:
|
89
|
+
|
90
|
+
typedef typename internal::traits<SparseSparseProduct>::_LhsNested _LhsNested;
|
91
|
+
typedef typename internal::traits<SparseSparseProduct>::_RhsNested _RhsNested;
|
92
|
+
|
93
|
+
public:
|
94
|
+
|
95
|
+
template<typename Lhs, typename Rhs>
|
96
|
+
EIGEN_STRONG_INLINE SparseSparseProduct(const Lhs& lhs, const Rhs& rhs)
|
97
|
+
: m_lhs(lhs), m_rhs(rhs), m_tolerance(0), m_conservative(true)
|
98
|
+
{
|
99
|
+
init();
|
100
|
+
}
|
101
|
+
|
102
|
+
template<typename Lhs, typename Rhs>
|
103
|
+
EIGEN_STRONG_INLINE SparseSparseProduct(const Lhs& lhs, const Rhs& rhs, const RealScalar& tolerance)
|
104
|
+
: m_lhs(lhs), m_rhs(rhs), m_tolerance(tolerance), m_conservative(false)
|
105
|
+
{
|
106
|
+
init();
|
107
|
+
}
|
108
|
+
|
109
|
+
SparseSparseProduct pruned(const Scalar& reference = 0, const RealScalar& epsilon = NumTraits<RealScalar>::dummy_precision()) const
|
110
|
+
{
|
111
|
+
using std::abs;
|
112
|
+
return SparseSparseProduct(m_lhs,m_rhs,abs(reference)*epsilon);
|
113
|
+
}
|
114
|
+
|
115
|
+
template<typename Dest>
|
116
|
+
void evalTo(Dest& result) const
|
117
|
+
{
|
118
|
+
if(m_conservative)
|
119
|
+
internal::conservative_sparse_sparse_product_selector<_LhsNested, _RhsNested, Dest>::run(lhs(),rhs(),result);
|
120
|
+
else
|
121
|
+
internal::sparse_sparse_product_with_pruning_selector<_LhsNested, _RhsNested, Dest>::run(lhs(),rhs(),result,m_tolerance);
|
122
|
+
}
|
123
|
+
|
124
|
+
EIGEN_STRONG_INLINE Index rows() const { return m_lhs.rows(); }
|
125
|
+
EIGEN_STRONG_INLINE Index cols() const { return m_rhs.cols(); }
|
126
|
+
|
127
|
+
EIGEN_STRONG_INLINE const _LhsNested& lhs() const { return m_lhs; }
|
128
|
+
EIGEN_STRONG_INLINE const _RhsNested& rhs() const { return m_rhs; }
|
129
|
+
|
130
|
+
protected:
|
131
|
+
void init()
|
132
|
+
{
|
133
|
+
eigen_assert(m_lhs.cols() == m_rhs.rows());
|
134
|
+
|
135
|
+
enum {
|
136
|
+
ProductIsValid = _LhsNested::ColsAtCompileTime==Dynamic
|
137
|
+
|| _RhsNested::RowsAtCompileTime==Dynamic
|
138
|
+
|| int(_LhsNested::ColsAtCompileTime)==int(_RhsNested::RowsAtCompileTime),
|
139
|
+
AreVectors = _LhsNested::IsVectorAtCompileTime && _RhsNested::IsVectorAtCompileTime,
|
140
|
+
SameSizes = EIGEN_PREDICATE_SAME_MATRIX_SIZE(_LhsNested,_RhsNested)
|
141
|
+
};
|
142
|
+
// note to the lost user:
|
143
|
+
// * for a dot product use: v1.dot(v2)
|
144
|
+
// * for a coeff-wise product use: v1.cwise()*v2
|
145
|
+
EIGEN_STATIC_ASSERT(ProductIsValid || !(AreVectors && SameSizes),
|
146
|
+
INVALID_VECTOR_VECTOR_PRODUCT__IF_YOU_WANTED_A_DOT_OR_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTIONS)
|
147
|
+
EIGEN_STATIC_ASSERT(ProductIsValid || !(SameSizes && !AreVectors),
|
148
|
+
INVALID_MATRIX_PRODUCT__IF_YOU_WANTED_A_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTION)
|
149
|
+
EIGEN_STATIC_ASSERT(ProductIsValid || SameSizes, INVALID_MATRIX_PRODUCT)
|
150
|
+
}
|
151
|
+
|
152
|
+
LhsNested m_lhs;
|
153
|
+
RhsNested m_rhs;
|
154
|
+
RealScalar m_tolerance;
|
155
|
+
bool m_conservative;
|
156
|
+
};
|
157
|
+
|
158
|
+
// sparse = sparse * sparse
|
159
|
+
template<typename Derived>
|
160
|
+
template<typename Lhs, typename Rhs>
|
161
|
+
inline Derived& SparseMatrixBase<Derived>::operator=(const SparseSparseProduct<Lhs,Rhs>& product)
|
162
|
+
{
|
163
|
+
product.evalTo(derived());
|
164
|
+
return derived();
|
165
|
+
}
|
166
|
+
|
167
|
+
/** \returns an expression of the product of two sparse matrices.
|
168
|
+
* By default a conservative product preserving the symbolic non zeros is performed.
|
169
|
+
* The automatic pruning of the small values can be achieved by calling the pruned() function
|
170
|
+
* in which case a totally different product algorithm is employed:
|
171
|
+
* \code
|
172
|
+
* C = (A*B).pruned(); // supress numerical zeros (exact)
|
173
|
+
* C = (A*B).pruned(ref);
|
174
|
+
* C = (A*B).pruned(ref,epsilon);
|
175
|
+
* \endcode
|
176
|
+
* where \c ref is a meaningful non zero reference value.
|
177
|
+
* */
|
178
|
+
template<typename Derived>
|
179
|
+
template<typename OtherDerived>
|
180
|
+
inline const typename SparseSparseProductReturnType<Derived,OtherDerived>::Type
|
181
|
+
SparseMatrixBase<Derived>::operator*(const SparseMatrixBase<OtherDerived> &other) const
|
182
|
+
{
|
183
|
+
return typename SparseSparseProductReturnType<Derived,OtherDerived>::Type(derived(), other.derived());
|
184
|
+
}
|
185
|
+
|
186
|
+
} // end namespace Eigen
|
187
|
+
|
188
|
+
#endif // EIGEN_SPARSEPRODUCT_H
|
@@ -0,0 +1,45 @@
|
|
1
|
+
// This file is part of Eigen, a lightweight C++ template library
|
2
|
+
// for linear algebra.
|
3
|
+
//
|
4
|
+
// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
|
5
|
+
//
|
6
|
+
// This Source Code Form is subject to the terms of the Mozilla
|
7
|
+
// Public License v. 2.0. If a copy of the MPL was not distributed
|
8
|
+
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
9
|
+
|
10
|
+
#ifndef EIGEN_SPARSEREDUX_H
|
11
|
+
#define EIGEN_SPARSEREDUX_H
|
12
|
+
|
13
|
+
namespace Eigen {
|
14
|
+
|
15
|
+
template<typename Derived>
|
16
|
+
typename internal::traits<Derived>::Scalar
|
17
|
+
SparseMatrixBase<Derived>::sum() const
|
18
|
+
{
|
19
|
+
eigen_assert(rows()>0 && cols()>0 && "you are using a non initialized matrix");
|
20
|
+
Scalar res(0);
|
21
|
+
for (Index j=0; j<outerSize(); ++j)
|
22
|
+
for (typename Derived::InnerIterator iter(derived(),j); iter; ++iter)
|
23
|
+
res += iter.value();
|
24
|
+
return res;
|
25
|
+
}
|
26
|
+
|
27
|
+
template<typename _Scalar, int _Options, typename _Index>
|
28
|
+
typename internal::traits<SparseMatrix<_Scalar,_Options,_Index> >::Scalar
|
29
|
+
SparseMatrix<_Scalar,_Options,_Index>::sum() const
|
30
|
+
{
|
31
|
+
eigen_assert(rows()>0 && cols()>0 && "you are using a non initialized matrix");
|
32
|
+
return Matrix<Scalar,1,Dynamic>::Map(&m_data.value(0), m_data.size()).sum();
|
33
|
+
}
|
34
|
+
|
35
|
+
template<typename _Scalar, int _Options, typename _Index>
|
36
|
+
typename internal::traits<SparseVector<_Scalar,_Options, _Index> >::Scalar
|
37
|
+
SparseVector<_Scalar,_Options,_Index>::sum() const
|
38
|
+
{
|
39
|
+
eigen_assert(rows()>0 && cols()>0 && "you are using a non initialized matrix");
|
40
|
+
return Matrix<Scalar,1,Dynamic>::Map(&m_data.value(0), m_data.size()).sum();
|
41
|
+
}
|
42
|
+
|
43
|
+
} // end namespace Eigen
|
44
|
+
|
45
|
+
#endif // EIGEN_SPARSEREDUX_H
|
@@ -0,0 +1,507 @@
|
|
1
|
+
// This file is part of Eigen, a lightweight C++ template library
|
2
|
+
// for linear algebra.
|
3
|
+
//
|
4
|
+
// Copyright (C) 2009 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_SPARSE_SELFADJOINTVIEW_H
|
11
|
+
#define EIGEN_SPARSE_SELFADJOINTVIEW_H
|
12
|
+
|
13
|
+
namespace Eigen {
|
14
|
+
|
15
|
+
/** \ingroup SparseCore_Module
|
16
|
+
* \class SparseSelfAdjointView
|
17
|
+
*
|
18
|
+
* \brief Pseudo expression to manipulate a triangular sparse matrix as a selfadjoint matrix.
|
19
|
+
*
|
20
|
+
* \param MatrixType the type of the dense matrix storing the coefficients
|
21
|
+
* \param UpLo can be either \c #Lower or \c #Upper
|
22
|
+
*
|
23
|
+
* This class is an expression of a sefladjoint matrix from a triangular part of a matrix
|
24
|
+
* with given dense storage of the coefficients. It is the return type of MatrixBase::selfadjointView()
|
25
|
+
* and most of the time this is the only way that it is used.
|
26
|
+
*
|
27
|
+
* \sa SparseMatrixBase::selfadjointView()
|
28
|
+
*/
|
29
|
+
template<typename Lhs, typename Rhs, int UpLo>
|
30
|
+
class SparseSelfAdjointTimeDenseProduct;
|
31
|
+
|
32
|
+
template<typename Lhs, typename Rhs, int UpLo>
|
33
|
+
class DenseTimeSparseSelfAdjointProduct;
|
34
|
+
|
35
|
+
namespace internal {
|
36
|
+
|
37
|
+
template<typename MatrixType, unsigned int UpLo>
|
38
|
+
struct traits<SparseSelfAdjointView<MatrixType,UpLo> > : traits<MatrixType> {
|
39
|
+
};
|
40
|
+
|
41
|
+
template<int SrcUpLo,int DstUpLo,typename MatrixType,int DestOrder>
|
42
|
+
void permute_symm_to_symm(const MatrixType& mat, SparseMatrix<typename MatrixType::Scalar,DestOrder,typename MatrixType::Index>& _dest, const typename MatrixType::Index* perm = 0);
|
43
|
+
|
44
|
+
template<int UpLo,typename MatrixType,int DestOrder>
|
45
|
+
void permute_symm_to_fullsymm(const MatrixType& mat, SparseMatrix<typename MatrixType::Scalar,DestOrder,typename MatrixType::Index>& _dest, const typename MatrixType::Index* perm = 0);
|
46
|
+
|
47
|
+
}
|
48
|
+
|
49
|
+
template<typename MatrixType, unsigned int UpLo> class SparseSelfAdjointView
|
50
|
+
: public EigenBase<SparseSelfAdjointView<MatrixType,UpLo> >
|
51
|
+
{
|
52
|
+
public:
|
53
|
+
|
54
|
+
typedef typename MatrixType::Scalar Scalar;
|
55
|
+
typedef typename MatrixType::Index Index;
|
56
|
+
typedef Matrix<Index,Dynamic,1> VectorI;
|
57
|
+
typedef typename MatrixType::Nested MatrixTypeNested;
|
58
|
+
typedef typename internal::remove_all<MatrixTypeNested>::type _MatrixTypeNested;
|
59
|
+
|
60
|
+
inline SparseSelfAdjointView(const MatrixType& matrix) : m_matrix(matrix)
|
61
|
+
{
|
62
|
+
eigen_assert(rows()==cols() && "SelfAdjointView is only for squared matrices");
|
63
|
+
}
|
64
|
+
|
65
|
+
inline Index rows() const { return m_matrix.rows(); }
|
66
|
+
inline Index cols() const { return m_matrix.cols(); }
|
67
|
+
|
68
|
+
/** \internal \returns a reference to the nested matrix */
|
69
|
+
const _MatrixTypeNested& matrix() const { return m_matrix; }
|
70
|
+
_MatrixTypeNested& matrix() { return m_matrix.const_cast_derived(); }
|
71
|
+
|
72
|
+
/** \returns an expression of the matrix product between a sparse self-adjoint matrix \c *this and a sparse matrix \a rhs.
|
73
|
+
*
|
74
|
+
* Note that there is no algorithmic advantage of performing such a product compared to a general sparse-sparse matrix product.
|
75
|
+
* Indeed, the SparseSelfadjointView operand is first copied into a temporary SparseMatrix before computing the product.
|
76
|
+
*/
|
77
|
+
template<typename OtherDerived>
|
78
|
+
SparseSparseProduct<typename OtherDerived::PlainObject, OtherDerived>
|
79
|
+
operator*(const SparseMatrixBase<OtherDerived>& rhs) const
|
80
|
+
{
|
81
|
+
return SparseSparseProduct<typename OtherDerived::PlainObject, OtherDerived>(*this, rhs.derived());
|
82
|
+
}
|
83
|
+
|
84
|
+
/** \returns an expression of the matrix product between a sparse matrix \a lhs and a sparse self-adjoint matrix \a rhs.
|
85
|
+
*
|
86
|
+
* Note that there is no algorithmic advantage of performing such a product compared to a general sparse-sparse matrix product.
|
87
|
+
* Indeed, the SparseSelfadjointView operand is first copied into a temporary SparseMatrix before computing the product.
|
88
|
+
*/
|
89
|
+
template<typename OtherDerived> friend
|
90
|
+
SparseSparseProduct<OtherDerived, typename OtherDerived::PlainObject >
|
91
|
+
operator*(const SparseMatrixBase<OtherDerived>& lhs, const SparseSelfAdjointView& rhs)
|
92
|
+
{
|
93
|
+
return SparseSparseProduct<OtherDerived, typename OtherDerived::PlainObject>(lhs.derived(), rhs);
|
94
|
+
}
|
95
|
+
|
96
|
+
/** Efficient sparse self-adjoint matrix times dense vector/matrix product */
|
97
|
+
template<typename OtherDerived>
|
98
|
+
SparseSelfAdjointTimeDenseProduct<MatrixType,OtherDerived,UpLo>
|
99
|
+
operator*(const MatrixBase<OtherDerived>& rhs) const
|
100
|
+
{
|
101
|
+
return SparseSelfAdjointTimeDenseProduct<MatrixType,OtherDerived,UpLo>(m_matrix, rhs.derived());
|
102
|
+
}
|
103
|
+
|
104
|
+
/** Efficient dense vector/matrix times sparse self-adjoint matrix product */
|
105
|
+
template<typename OtherDerived> friend
|
106
|
+
DenseTimeSparseSelfAdjointProduct<OtherDerived,MatrixType,UpLo>
|
107
|
+
operator*(const MatrixBase<OtherDerived>& lhs, const SparseSelfAdjointView& rhs)
|
108
|
+
{
|
109
|
+
return DenseTimeSparseSelfAdjointProduct<OtherDerived,_MatrixTypeNested,UpLo>(lhs.derived(), rhs.m_matrix);
|
110
|
+
}
|
111
|
+
|
112
|
+
/** Perform a symmetric rank K update of the selfadjoint matrix \c *this:
|
113
|
+
* \f$ this = this + \alpha ( u u^* ) \f$ where \a u is a vector or matrix.
|
114
|
+
*
|
115
|
+
* \returns a reference to \c *this
|
116
|
+
*
|
117
|
+
* To perform \f$ this = this + \alpha ( u^* u ) \f$ you can simply
|
118
|
+
* call this function with u.adjoint().
|
119
|
+
*/
|
120
|
+
template<typename DerivedU>
|
121
|
+
SparseSelfAdjointView& rankUpdate(const SparseMatrixBase<DerivedU>& u, const Scalar& alpha = Scalar(1));
|
122
|
+
|
123
|
+
/** \internal triggered by sparse_matrix = SparseSelfadjointView; */
|
124
|
+
template<typename DestScalar,int StorageOrder> void evalTo(SparseMatrix<DestScalar,StorageOrder,Index>& _dest) const
|
125
|
+
{
|
126
|
+
internal::permute_symm_to_fullsymm<UpLo>(m_matrix, _dest);
|
127
|
+
}
|
128
|
+
|
129
|
+
template<typename DestScalar> void evalTo(DynamicSparseMatrix<DestScalar,ColMajor,Index>& _dest) const
|
130
|
+
{
|
131
|
+
// TODO directly evaluate into _dest;
|
132
|
+
SparseMatrix<DestScalar,ColMajor,Index> tmp(_dest.rows(),_dest.cols());
|
133
|
+
internal::permute_symm_to_fullsymm<UpLo>(m_matrix, tmp);
|
134
|
+
_dest = tmp;
|
135
|
+
}
|
136
|
+
|
137
|
+
/** \returns an expression of P H P^-1 */
|
138
|
+
SparseSymmetricPermutationProduct<_MatrixTypeNested,UpLo> twistedBy(const PermutationMatrix<Dynamic,Dynamic,Index>& perm) const
|
139
|
+
{
|
140
|
+
return SparseSymmetricPermutationProduct<_MatrixTypeNested,UpLo>(m_matrix, perm);
|
141
|
+
}
|
142
|
+
|
143
|
+
template<typename SrcMatrixType,int SrcUpLo>
|
144
|
+
SparseSelfAdjointView& operator=(const SparseSymmetricPermutationProduct<SrcMatrixType,SrcUpLo>& permutedMatrix)
|
145
|
+
{
|
146
|
+
permutedMatrix.evalTo(*this);
|
147
|
+
return *this;
|
148
|
+
}
|
149
|
+
|
150
|
+
|
151
|
+
SparseSelfAdjointView& operator=(const SparseSelfAdjointView& src)
|
152
|
+
{
|
153
|
+
PermutationMatrix<Dynamic> pnull;
|
154
|
+
return *this = src.twistedBy(pnull);
|
155
|
+
}
|
156
|
+
|
157
|
+
template<typename SrcMatrixType,unsigned int SrcUpLo>
|
158
|
+
SparseSelfAdjointView& operator=(const SparseSelfAdjointView<SrcMatrixType,SrcUpLo>& src)
|
159
|
+
{
|
160
|
+
PermutationMatrix<Dynamic> pnull;
|
161
|
+
return *this = src.twistedBy(pnull);
|
162
|
+
}
|
163
|
+
|
164
|
+
|
165
|
+
// const SparseLLT<PlainObject, UpLo> llt() const;
|
166
|
+
// const SparseLDLT<PlainObject, UpLo> ldlt() const;
|
167
|
+
|
168
|
+
protected:
|
169
|
+
|
170
|
+
typename MatrixType::Nested m_matrix;
|
171
|
+
mutable VectorI m_countPerRow;
|
172
|
+
mutable VectorI m_countPerCol;
|
173
|
+
};
|
174
|
+
|
175
|
+
/***************************************************************************
|
176
|
+
* Implementation of SparseMatrixBase methods
|
177
|
+
***************************************************************************/
|
178
|
+
|
179
|
+
template<typename Derived>
|
180
|
+
template<unsigned int UpLo>
|
181
|
+
const SparseSelfAdjointView<Derived, UpLo> SparseMatrixBase<Derived>::selfadjointView() const
|
182
|
+
{
|
183
|
+
return derived();
|
184
|
+
}
|
185
|
+
|
186
|
+
template<typename Derived>
|
187
|
+
template<unsigned int UpLo>
|
188
|
+
SparseSelfAdjointView<Derived, UpLo> SparseMatrixBase<Derived>::selfadjointView()
|
189
|
+
{
|
190
|
+
return derived();
|
191
|
+
}
|
192
|
+
|
193
|
+
/***************************************************************************
|
194
|
+
* Implementation of SparseSelfAdjointView methods
|
195
|
+
***************************************************************************/
|
196
|
+
|
197
|
+
template<typename MatrixType, unsigned int UpLo>
|
198
|
+
template<typename DerivedU>
|
199
|
+
SparseSelfAdjointView<MatrixType,UpLo>&
|
200
|
+
SparseSelfAdjointView<MatrixType,UpLo>::rankUpdate(const SparseMatrixBase<DerivedU>& u, const Scalar& alpha)
|
201
|
+
{
|
202
|
+
SparseMatrix<Scalar,MatrixType::Flags&RowMajorBit?RowMajor:ColMajor> tmp = u * u.adjoint();
|
203
|
+
if(alpha==Scalar(0))
|
204
|
+
m_matrix.const_cast_derived() = tmp.template triangularView<UpLo>();
|
205
|
+
else
|
206
|
+
m_matrix.const_cast_derived() += alpha * tmp.template triangularView<UpLo>();
|
207
|
+
|
208
|
+
return *this;
|
209
|
+
}
|
210
|
+
|
211
|
+
/***************************************************************************
|
212
|
+
* Implementation of sparse self-adjoint time dense matrix
|
213
|
+
***************************************************************************/
|
214
|
+
|
215
|
+
namespace internal {
|
216
|
+
template<typename Lhs, typename Rhs, int UpLo>
|
217
|
+
struct traits<SparseSelfAdjointTimeDenseProduct<Lhs,Rhs,UpLo> >
|
218
|
+
: traits<ProductBase<SparseSelfAdjointTimeDenseProduct<Lhs,Rhs,UpLo>, Lhs, Rhs> >
|
219
|
+
{
|
220
|
+
typedef Dense StorageKind;
|
221
|
+
};
|
222
|
+
}
|
223
|
+
|
224
|
+
template<typename Lhs, typename Rhs, int UpLo>
|
225
|
+
class SparseSelfAdjointTimeDenseProduct
|
226
|
+
: public ProductBase<SparseSelfAdjointTimeDenseProduct<Lhs,Rhs,UpLo>, Lhs, Rhs>
|
227
|
+
{
|
228
|
+
public:
|
229
|
+
EIGEN_PRODUCT_PUBLIC_INTERFACE(SparseSelfAdjointTimeDenseProduct)
|
230
|
+
|
231
|
+
SparseSelfAdjointTimeDenseProduct(const Lhs& lhs, const Rhs& rhs) : Base(lhs,rhs)
|
232
|
+
{}
|
233
|
+
|
234
|
+
template<typename Dest> void scaleAndAddTo(Dest& dest, const Scalar& alpha) const
|
235
|
+
{
|
236
|
+
EIGEN_ONLY_USED_FOR_DEBUG(alpha);
|
237
|
+
// TODO use alpha
|
238
|
+
eigen_assert(alpha==Scalar(1) && "alpha != 1 is not implemented yet, sorry");
|
239
|
+
typedef typename internal::remove_all<Lhs>::type _Lhs;
|
240
|
+
typedef typename _Lhs::InnerIterator LhsInnerIterator;
|
241
|
+
enum {
|
242
|
+
LhsIsRowMajor = (_Lhs::Flags&RowMajorBit)==RowMajorBit,
|
243
|
+
ProcessFirstHalf =
|
244
|
+
((UpLo&(Upper|Lower))==(Upper|Lower))
|
245
|
+
|| ( (UpLo&Upper) && !LhsIsRowMajor)
|
246
|
+
|| ( (UpLo&Lower) && LhsIsRowMajor),
|
247
|
+
ProcessSecondHalf = !ProcessFirstHalf
|
248
|
+
};
|
249
|
+
for (Index j=0; j<m_lhs.outerSize(); ++j)
|
250
|
+
{
|
251
|
+
LhsInnerIterator i(m_lhs,j);
|
252
|
+
if (ProcessSecondHalf)
|
253
|
+
{
|
254
|
+
while (i && i.index()<j) ++i;
|
255
|
+
if(i && i.index()==j)
|
256
|
+
{
|
257
|
+
dest.row(j) += i.value() * m_rhs.row(j);
|
258
|
+
++i;
|
259
|
+
}
|
260
|
+
}
|
261
|
+
for(; (ProcessFirstHalf ? i && i.index() < j : i) ; ++i)
|
262
|
+
{
|
263
|
+
Index a = LhsIsRowMajor ? j : i.index();
|
264
|
+
Index b = LhsIsRowMajor ? i.index() : j;
|
265
|
+
typename Lhs::Scalar v = i.value();
|
266
|
+
dest.row(a) += (v) * m_rhs.row(b);
|
267
|
+
dest.row(b) += numext::conj(v) * m_rhs.row(a);
|
268
|
+
}
|
269
|
+
if (ProcessFirstHalf && i && (i.index()==j))
|
270
|
+
dest.row(j) += i.value() * m_rhs.row(j);
|
271
|
+
}
|
272
|
+
}
|
273
|
+
|
274
|
+
private:
|
275
|
+
SparseSelfAdjointTimeDenseProduct& operator=(const SparseSelfAdjointTimeDenseProduct&);
|
276
|
+
};
|
277
|
+
|
278
|
+
namespace internal {
|
279
|
+
template<typename Lhs, typename Rhs, int UpLo>
|
280
|
+
struct traits<DenseTimeSparseSelfAdjointProduct<Lhs,Rhs,UpLo> >
|
281
|
+
: traits<ProductBase<DenseTimeSparseSelfAdjointProduct<Lhs,Rhs,UpLo>, Lhs, Rhs> >
|
282
|
+
{};
|
283
|
+
}
|
284
|
+
|
285
|
+
template<typename Lhs, typename Rhs, int UpLo>
|
286
|
+
class DenseTimeSparseSelfAdjointProduct
|
287
|
+
: public ProductBase<DenseTimeSparseSelfAdjointProduct<Lhs,Rhs,UpLo>, Lhs, Rhs>
|
288
|
+
{
|
289
|
+
public:
|
290
|
+
EIGEN_PRODUCT_PUBLIC_INTERFACE(DenseTimeSparseSelfAdjointProduct)
|
291
|
+
|
292
|
+
DenseTimeSparseSelfAdjointProduct(const Lhs& lhs, const Rhs& rhs) : Base(lhs,rhs)
|
293
|
+
{}
|
294
|
+
|
295
|
+
template<typename Dest> void scaleAndAddTo(Dest& /*dest*/, const Scalar& /*alpha*/) const
|
296
|
+
{
|
297
|
+
// TODO
|
298
|
+
}
|
299
|
+
|
300
|
+
private:
|
301
|
+
DenseTimeSparseSelfAdjointProduct& operator=(const DenseTimeSparseSelfAdjointProduct&);
|
302
|
+
};
|
303
|
+
|
304
|
+
/***************************************************************************
|
305
|
+
* Implementation of symmetric copies and permutations
|
306
|
+
***************************************************************************/
|
307
|
+
namespace internal {
|
308
|
+
|
309
|
+
template<typename MatrixType, int UpLo>
|
310
|
+
struct traits<SparseSymmetricPermutationProduct<MatrixType,UpLo> > : traits<MatrixType> {
|
311
|
+
};
|
312
|
+
|
313
|
+
template<int UpLo,typename MatrixType,int DestOrder>
|
314
|
+
void permute_symm_to_fullsymm(const MatrixType& mat, SparseMatrix<typename MatrixType::Scalar,DestOrder,typename MatrixType::Index>& _dest, const typename MatrixType::Index* perm)
|
315
|
+
{
|
316
|
+
typedef typename MatrixType::Index Index;
|
317
|
+
typedef typename MatrixType::Scalar Scalar;
|
318
|
+
typedef SparseMatrix<Scalar,DestOrder,Index> Dest;
|
319
|
+
typedef Matrix<Index,Dynamic,1> VectorI;
|
320
|
+
|
321
|
+
Dest& dest(_dest.derived());
|
322
|
+
enum {
|
323
|
+
StorageOrderMatch = int(Dest::IsRowMajor) == int(MatrixType::IsRowMajor)
|
324
|
+
};
|
325
|
+
|
326
|
+
Index size = mat.rows();
|
327
|
+
VectorI count;
|
328
|
+
count.resize(size);
|
329
|
+
count.setZero();
|
330
|
+
dest.resize(size,size);
|
331
|
+
for(Index j = 0; j<size; ++j)
|
332
|
+
{
|
333
|
+
Index jp = perm ? perm[j] : j;
|
334
|
+
for(typename MatrixType::InnerIterator it(mat,j); it; ++it)
|
335
|
+
{
|
336
|
+
Index i = it.index();
|
337
|
+
Index r = it.row();
|
338
|
+
Index c = it.col();
|
339
|
+
Index ip = perm ? perm[i] : i;
|
340
|
+
if(UpLo==(Upper|Lower))
|
341
|
+
count[StorageOrderMatch ? jp : ip]++;
|
342
|
+
else if(r==c)
|
343
|
+
count[ip]++;
|
344
|
+
else if(( UpLo==Lower && r>c) || ( UpLo==Upper && r<c))
|
345
|
+
{
|
346
|
+
count[ip]++;
|
347
|
+
count[jp]++;
|
348
|
+
}
|
349
|
+
}
|
350
|
+
}
|
351
|
+
Index nnz = count.sum();
|
352
|
+
|
353
|
+
// reserve space
|
354
|
+
dest.resizeNonZeros(nnz);
|
355
|
+
dest.outerIndexPtr()[0] = 0;
|
356
|
+
for(Index j=0; j<size; ++j)
|
357
|
+
dest.outerIndexPtr()[j+1] = dest.outerIndexPtr()[j] + count[j];
|
358
|
+
for(Index j=0; j<size; ++j)
|
359
|
+
count[j] = dest.outerIndexPtr()[j];
|
360
|
+
|
361
|
+
// copy data
|
362
|
+
for(Index j = 0; j<size; ++j)
|
363
|
+
{
|
364
|
+
for(typename MatrixType::InnerIterator it(mat,j); it; ++it)
|
365
|
+
{
|
366
|
+
Index i = it.index();
|
367
|
+
Index r = it.row();
|
368
|
+
Index c = it.col();
|
369
|
+
|
370
|
+
Index jp = perm ? perm[j] : j;
|
371
|
+
Index ip = perm ? perm[i] : i;
|
372
|
+
|
373
|
+
if(UpLo==(Upper|Lower))
|
374
|
+
{
|
375
|
+
Index k = count[StorageOrderMatch ? jp : ip]++;
|
376
|
+
dest.innerIndexPtr()[k] = StorageOrderMatch ? ip : jp;
|
377
|
+
dest.valuePtr()[k] = it.value();
|
378
|
+
}
|
379
|
+
else if(r==c)
|
380
|
+
{
|
381
|
+
Index k = count[ip]++;
|
382
|
+
dest.innerIndexPtr()[k] = ip;
|
383
|
+
dest.valuePtr()[k] = it.value();
|
384
|
+
}
|
385
|
+
else if(( (UpLo&Lower)==Lower && r>c) || ( (UpLo&Upper)==Upper && r<c))
|
386
|
+
{
|
387
|
+
if(!StorageOrderMatch)
|
388
|
+
std::swap(ip,jp);
|
389
|
+
Index k = count[jp]++;
|
390
|
+
dest.innerIndexPtr()[k] = ip;
|
391
|
+
dest.valuePtr()[k] = it.value();
|
392
|
+
k = count[ip]++;
|
393
|
+
dest.innerIndexPtr()[k] = jp;
|
394
|
+
dest.valuePtr()[k] = numext::conj(it.value());
|
395
|
+
}
|
396
|
+
}
|
397
|
+
}
|
398
|
+
}
|
399
|
+
|
400
|
+
template<int _SrcUpLo,int _DstUpLo,typename MatrixType,int DstOrder>
|
401
|
+
void permute_symm_to_symm(const MatrixType& mat, SparseMatrix<typename MatrixType::Scalar,DstOrder,typename MatrixType::Index>& _dest, const typename MatrixType::Index* perm)
|
402
|
+
{
|
403
|
+
typedef typename MatrixType::Index Index;
|
404
|
+
typedef typename MatrixType::Scalar Scalar;
|
405
|
+
SparseMatrix<Scalar,DstOrder,Index>& dest(_dest.derived());
|
406
|
+
typedef Matrix<Index,Dynamic,1> VectorI;
|
407
|
+
enum {
|
408
|
+
SrcOrder = MatrixType::IsRowMajor ? RowMajor : ColMajor,
|
409
|
+
StorageOrderMatch = int(SrcOrder) == int(DstOrder),
|
410
|
+
DstUpLo = DstOrder==RowMajor ? (_DstUpLo==Upper ? Lower : Upper) : _DstUpLo,
|
411
|
+
SrcUpLo = SrcOrder==RowMajor ? (_SrcUpLo==Upper ? Lower : Upper) : _SrcUpLo
|
412
|
+
};
|
413
|
+
|
414
|
+
Index size = mat.rows();
|
415
|
+
VectorI count(size);
|
416
|
+
count.setZero();
|
417
|
+
dest.resize(size,size);
|
418
|
+
for(Index j = 0; j<size; ++j)
|
419
|
+
{
|
420
|
+
Index jp = perm ? perm[j] : j;
|
421
|
+
for(typename MatrixType::InnerIterator it(mat,j); it; ++it)
|
422
|
+
{
|
423
|
+
Index i = it.index();
|
424
|
+
if((int(SrcUpLo)==int(Lower) && i<j) || (int(SrcUpLo)==int(Upper) && i>j))
|
425
|
+
continue;
|
426
|
+
|
427
|
+
Index ip = perm ? perm[i] : i;
|
428
|
+
count[int(DstUpLo)==int(Lower) ? (std::min)(ip,jp) : (std::max)(ip,jp)]++;
|
429
|
+
}
|
430
|
+
}
|
431
|
+
dest.outerIndexPtr()[0] = 0;
|
432
|
+
for(Index j=0; j<size; ++j)
|
433
|
+
dest.outerIndexPtr()[j+1] = dest.outerIndexPtr()[j] + count[j];
|
434
|
+
dest.resizeNonZeros(dest.outerIndexPtr()[size]);
|
435
|
+
for(Index j=0; j<size; ++j)
|
436
|
+
count[j] = dest.outerIndexPtr()[j];
|
437
|
+
|
438
|
+
for(Index j = 0; j<size; ++j)
|
439
|
+
{
|
440
|
+
|
441
|
+
for(typename MatrixType::InnerIterator it(mat,j); it; ++it)
|
442
|
+
{
|
443
|
+
Index i = it.index();
|
444
|
+
if((int(SrcUpLo)==int(Lower) && i<j) || (int(SrcUpLo)==int(Upper) && i>j))
|
445
|
+
continue;
|
446
|
+
|
447
|
+
Index jp = perm ? perm[j] : j;
|
448
|
+
Index ip = perm? perm[i] : i;
|
449
|
+
|
450
|
+
Index k = count[int(DstUpLo)==int(Lower) ? (std::min)(ip,jp) : (std::max)(ip,jp)]++;
|
451
|
+
dest.innerIndexPtr()[k] = int(DstUpLo)==int(Lower) ? (std::max)(ip,jp) : (std::min)(ip,jp);
|
452
|
+
|
453
|
+
if(!StorageOrderMatch) std::swap(ip,jp);
|
454
|
+
if( ((int(DstUpLo)==int(Lower) && ip<jp) || (int(DstUpLo)==int(Upper) && ip>jp)))
|
455
|
+
dest.valuePtr()[k] = numext::conj(it.value());
|
456
|
+
else
|
457
|
+
dest.valuePtr()[k] = it.value();
|
458
|
+
}
|
459
|
+
}
|
460
|
+
}
|
461
|
+
|
462
|
+
}
|
463
|
+
|
464
|
+
template<typename MatrixType,int UpLo>
|
465
|
+
class SparseSymmetricPermutationProduct
|
466
|
+
: public EigenBase<SparseSymmetricPermutationProduct<MatrixType,UpLo> >
|
467
|
+
{
|
468
|
+
public:
|
469
|
+
typedef typename MatrixType::Scalar Scalar;
|
470
|
+
typedef typename MatrixType::Index Index;
|
471
|
+
protected:
|
472
|
+
typedef PermutationMatrix<Dynamic,Dynamic,Index> Perm;
|
473
|
+
public:
|
474
|
+
typedef Matrix<Index,Dynamic,1> VectorI;
|
475
|
+
typedef typename MatrixType::Nested MatrixTypeNested;
|
476
|
+
typedef typename internal::remove_all<MatrixTypeNested>::type _MatrixTypeNested;
|
477
|
+
|
478
|
+
SparseSymmetricPermutationProduct(const MatrixType& mat, const Perm& perm)
|
479
|
+
: m_matrix(mat), m_perm(perm)
|
480
|
+
{}
|
481
|
+
|
482
|
+
inline Index rows() const { return m_matrix.rows(); }
|
483
|
+
inline Index cols() const { return m_matrix.cols(); }
|
484
|
+
|
485
|
+
template<typename DestScalar, int Options, typename DstIndex>
|
486
|
+
void evalTo(SparseMatrix<DestScalar,Options,DstIndex>& _dest) const
|
487
|
+
{
|
488
|
+
// internal::permute_symm_to_fullsymm<UpLo>(m_matrix,_dest,m_perm.indices().data());
|
489
|
+
SparseMatrix<DestScalar,(Options&RowMajor)==RowMajor ? ColMajor : RowMajor, DstIndex> tmp;
|
490
|
+
internal::permute_symm_to_fullsymm<UpLo>(m_matrix,tmp,m_perm.indices().data());
|
491
|
+
_dest = tmp;
|
492
|
+
}
|
493
|
+
|
494
|
+
template<typename DestType,unsigned int DestUpLo> void evalTo(SparseSelfAdjointView<DestType,DestUpLo>& dest) const
|
495
|
+
{
|
496
|
+
internal::permute_symm_to_symm<UpLo,DestUpLo>(m_matrix,dest.matrix(),m_perm.indices().data());
|
497
|
+
}
|
498
|
+
|
499
|
+
protected:
|
500
|
+
MatrixTypeNested m_matrix;
|
501
|
+
const Perm& m_perm;
|
502
|
+
|
503
|
+
};
|
504
|
+
|
505
|
+
} // end namespace Eigen
|
506
|
+
|
507
|
+
#endif // EIGEN_SPARSE_SELFADJOINTVIEW_H
|