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,111 @@
|
|
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
|
+
// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
|
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_NESTBYVALUE_H
|
12
|
+
#define EIGEN_NESTBYVALUE_H
|
13
|
+
|
14
|
+
namespace Eigen {
|
15
|
+
|
16
|
+
/** \class NestByValue
|
17
|
+
* \ingroup Core_Module
|
18
|
+
*
|
19
|
+
* \brief Expression which must be nested by value
|
20
|
+
*
|
21
|
+
* \param ExpressionType the type of the object of which we are requiring nesting-by-value
|
22
|
+
*
|
23
|
+
* This class is the return type of MatrixBase::nestByValue()
|
24
|
+
* and most of the time this is the only way it is used.
|
25
|
+
*
|
26
|
+
* \sa MatrixBase::nestByValue()
|
27
|
+
*/
|
28
|
+
|
29
|
+
namespace internal {
|
30
|
+
template<typename ExpressionType>
|
31
|
+
struct traits<NestByValue<ExpressionType> > : public traits<ExpressionType>
|
32
|
+
{};
|
33
|
+
}
|
34
|
+
|
35
|
+
template<typename ExpressionType> class NestByValue
|
36
|
+
: public internal::dense_xpr_base< NestByValue<ExpressionType> >::type
|
37
|
+
{
|
38
|
+
public:
|
39
|
+
|
40
|
+
typedef typename internal::dense_xpr_base<NestByValue>::type Base;
|
41
|
+
EIGEN_DENSE_PUBLIC_INTERFACE(NestByValue)
|
42
|
+
|
43
|
+
inline NestByValue(const ExpressionType& matrix) : m_expression(matrix) {}
|
44
|
+
|
45
|
+
inline Index rows() const { return m_expression.rows(); }
|
46
|
+
inline Index cols() const { return m_expression.cols(); }
|
47
|
+
inline Index outerStride() const { return m_expression.outerStride(); }
|
48
|
+
inline Index innerStride() const { return m_expression.innerStride(); }
|
49
|
+
|
50
|
+
inline const CoeffReturnType coeff(Index row, Index col) const
|
51
|
+
{
|
52
|
+
return m_expression.coeff(row, col);
|
53
|
+
}
|
54
|
+
|
55
|
+
inline Scalar& coeffRef(Index row, Index col)
|
56
|
+
{
|
57
|
+
return m_expression.const_cast_derived().coeffRef(row, col);
|
58
|
+
}
|
59
|
+
|
60
|
+
inline const CoeffReturnType coeff(Index index) const
|
61
|
+
{
|
62
|
+
return m_expression.coeff(index);
|
63
|
+
}
|
64
|
+
|
65
|
+
inline Scalar& coeffRef(Index index)
|
66
|
+
{
|
67
|
+
return m_expression.const_cast_derived().coeffRef(index);
|
68
|
+
}
|
69
|
+
|
70
|
+
template<int LoadMode>
|
71
|
+
inline const PacketScalar packet(Index row, Index col) const
|
72
|
+
{
|
73
|
+
return m_expression.template packet<LoadMode>(row, col);
|
74
|
+
}
|
75
|
+
|
76
|
+
template<int LoadMode>
|
77
|
+
inline void writePacket(Index row, Index col, const PacketScalar& x)
|
78
|
+
{
|
79
|
+
m_expression.const_cast_derived().template writePacket<LoadMode>(row, col, x);
|
80
|
+
}
|
81
|
+
|
82
|
+
template<int LoadMode>
|
83
|
+
inline const PacketScalar packet(Index index) const
|
84
|
+
{
|
85
|
+
return m_expression.template packet<LoadMode>(index);
|
86
|
+
}
|
87
|
+
|
88
|
+
template<int LoadMode>
|
89
|
+
inline void writePacket(Index index, const PacketScalar& x)
|
90
|
+
{
|
91
|
+
m_expression.const_cast_derived().template writePacket<LoadMode>(index, x);
|
92
|
+
}
|
93
|
+
|
94
|
+
operator const ExpressionType&() const { return m_expression; }
|
95
|
+
|
96
|
+
protected:
|
97
|
+
const ExpressionType m_expression;
|
98
|
+
};
|
99
|
+
|
100
|
+
/** \returns an expression of the temporary version of *this.
|
101
|
+
*/
|
102
|
+
template<typename Derived>
|
103
|
+
inline const NestByValue<Derived>
|
104
|
+
DenseBase<Derived>::nestByValue() const
|
105
|
+
{
|
106
|
+
return NestByValue<Derived>(derived());
|
107
|
+
}
|
108
|
+
|
109
|
+
} // end namespace Eigen
|
110
|
+
|
111
|
+
#endif // EIGEN_NESTBYVALUE_H
|
@@ -0,0 +1,134 @@
|
|
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_NOALIAS_H
|
11
|
+
#define EIGEN_NOALIAS_H
|
12
|
+
|
13
|
+
namespace Eigen {
|
14
|
+
|
15
|
+
/** \class NoAlias
|
16
|
+
* \ingroup Core_Module
|
17
|
+
*
|
18
|
+
* \brief Pseudo expression providing an operator = assuming no aliasing
|
19
|
+
*
|
20
|
+
* \param ExpressionType the type of the object on which to do the lazy assignment
|
21
|
+
*
|
22
|
+
* This class represents an expression with special assignment operators
|
23
|
+
* assuming no aliasing between the target expression and the source expression.
|
24
|
+
* More precisely it alloas to bypass the EvalBeforeAssignBit flag of the source expression.
|
25
|
+
* It is the return type of MatrixBase::noalias()
|
26
|
+
* and most of the time this is the only way it is used.
|
27
|
+
*
|
28
|
+
* \sa MatrixBase::noalias()
|
29
|
+
*/
|
30
|
+
template<typename ExpressionType, template <typename> class StorageBase>
|
31
|
+
class NoAlias
|
32
|
+
{
|
33
|
+
typedef typename ExpressionType::Scalar Scalar;
|
34
|
+
public:
|
35
|
+
NoAlias(ExpressionType& expression) : m_expression(expression) {}
|
36
|
+
|
37
|
+
/** Behaves like MatrixBase::lazyAssign(other)
|
38
|
+
* \sa MatrixBase::lazyAssign() */
|
39
|
+
template<typename OtherDerived>
|
40
|
+
EIGEN_STRONG_INLINE ExpressionType& operator=(const StorageBase<OtherDerived>& other)
|
41
|
+
{ return internal::assign_selector<ExpressionType,OtherDerived,false>::run(m_expression,other.derived()); }
|
42
|
+
|
43
|
+
/** \sa MatrixBase::operator+= */
|
44
|
+
template<typename OtherDerived>
|
45
|
+
EIGEN_STRONG_INLINE ExpressionType& operator+=(const StorageBase<OtherDerived>& other)
|
46
|
+
{
|
47
|
+
typedef SelfCwiseBinaryOp<internal::scalar_sum_op<Scalar>, ExpressionType, OtherDerived> SelfAdder;
|
48
|
+
SelfAdder tmp(m_expression);
|
49
|
+
typedef typename internal::nested<OtherDerived>::type OtherDerivedNested;
|
50
|
+
typedef typename internal::remove_all<OtherDerivedNested>::type _OtherDerivedNested;
|
51
|
+
internal::assign_selector<SelfAdder,_OtherDerivedNested,false>::run(tmp,OtherDerivedNested(other.derived()));
|
52
|
+
return m_expression;
|
53
|
+
}
|
54
|
+
|
55
|
+
/** \sa MatrixBase::operator-= */
|
56
|
+
template<typename OtherDerived>
|
57
|
+
EIGEN_STRONG_INLINE ExpressionType& operator-=(const StorageBase<OtherDerived>& other)
|
58
|
+
{
|
59
|
+
typedef SelfCwiseBinaryOp<internal::scalar_difference_op<Scalar>, ExpressionType, OtherDerived> SelfAdder;
|
60
|
+
SelfAdder tmp(m_expression);
|
61
|
+
typedef typename internal::nested<OtherDerived>::type OtherDerivedNested;
|
62
|
+
typedef typename internal::remove_all<OtherDerivedNested>::type _OtherDerivedNested;
|
63
|
+
internal::assign_selector<SelfAdder,_OtherDerivedNested,false>::run(tmp,OtherDerivedNested(other.derived()));
|
64
|
+
return m_expression;
|
65
|
+
}
|
66
|
+
|
67
|
+
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
68
|
+
template<typename ProductDerived, typename Lhs, typename Rhs>
|
69
|
+
EIGEN_STRONG_INLINE ExpressionType& operator+=(const ProductBase<ProductDerived, Lhs,Rhs>& other)
|
70
|
+
{ other.derived().addTo(m_expression); return m_expression; }
|
71
|
+
|
72
|
+
template<typename ProductDerived, typename Lhs, typename Rhs>
|
73
|
+
EIGEN_STRONG_INLINE ExpressionType& operator-=(const ProductBase<ProductDerived, Lhs,Rhs>& other)
|
74
|
+
{ other.derived().subTo(m_expression); return m_expression; }
|
75
|
+
|
76
|
+
template<typename Lhs, typename Rhs, int NestingFlags>
|
77
|
+
EIGEN_STRONG_INLINE ExpressionType& operator+=(const CoeffBasedProduct<Lhs,Rhs,NestingFlags>& other)
|
78
|
+
{ return m_expression.derived() += CoeffBasedProduct<Lhs,Rhs,NestByRefBit>(other.lhs(), other.rhs()); }
|
79
|
+
|
80
|
+
template<typename Lhs, typename Rhs, int NestingFlags>
|
81
|
+
EIGEN_STRONG_INLINE ExpressionType& operator-=(const CoeffBasedProduct<Lhs,Rhs,NestingFlags>& other)
|
82
|
+
{ return m_expression.derived() -= CoeffBasedProduct<Lhs,Rhs,NestByRefBit>(other.lhs(), other.rhs()); }
|
83
|
+
|
84
|
+
template<typename OtherDerived>
|
85
|
+
ExpressionType& operator=(const ReturnByValue<OtherDerived>& func)
|
86
|
+
{ return m_expression = func; }
|
87
|
+
#endif
|
88
|
+
|
89
|
+
ExpressionType& expression() const
|
90
|
+
{
|
91
|
+
return m_expression;
|
92
|
+
}
|
93
|
+
|
94
|
+
protected:
|
95
|
+
ExpressionType& m_expression;
|
96
|
+
};
|
97
|
+
|
98
|
+
/** \returns a pseudo expression of \c *this with an operator= assuming
|
99
|
+
* no aliasing between \c *this and the source expression.
|
100
|
+
*
|
101
|
+
* More precisely, noalias() allows to bypass the EvalBeforeAssignBit flag.
|
102
|
+
* Currently, even though several expressions may alias, only product
|
103
|
+
* expressions have this flag. Therefore, noalias() is only usefull when
|
104
|
+
* the source expression contains a matrix product.
|
105
|
+
*
|
106
|
+
* Here are some examples where noalias is usefull:
|
107
|
+
* \code
|
108
|
+
* D.noalias() = A * B;
|
109
|
+
* D.noalias() += A.transpose() * B;
|
110
|
+
* D.noalias() -= 2 * A * B.adjoint();
|
111
|
+
* \endcode
|
112
|
+
*
|
113
|
+
* On the other hand the following example will lead to a \b wrong result:
|
114
|
+
* \code
|
115
|
+
* A.noalias() = A * B;
|
116
|
+
* \endcode
|
117
|
+
* because the result matrix A is also an operand of the matrix product. Therefore,
|
118
|
+
* there is no alternative than evaluating A * B in a temporary, that is the default
|
119
|
+
* behavior when you write:
|
120
|
+
* \code
|
121
|
+
* A = A * B;
|
122
|
+
* \endcode
|
123
|
+
*
|
124
|
+
* \sa class NoAlias
|
125
|
+
*/
|
126
|
+
template<typename Derived>
|
127
|
+
NoAlias<Derived,MatrixBase> MatrixBase<Derived>::noalias()
|
128
|
+
{
|
129
|
+
return derived();
|
130
|
+
}
|
131
|
+
|
132
|
+
} // end namespace Eigen
|
133
|
+
|
134
|
+
#endif // EIGEN_NOALIAS_H
|
@@ -0,0 +1,150 @@
|
|
1
|
+
// This file is part of Eigen, a lightweight C++ template library
|
2
|
+
// for linear algebra.
|
3
|
+
//
|
4
|
+
// Copyright (C) 2006-2010 Benoit Jacob <jacob.benoit.1@gmail.com>
|
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_NUMTRAITS_H
|
11
|
+
#define EIGEN_NUMTRAITS_H
|
12
|
+
|
13
|
+
namespace Eigen {
|
14
|
+
|
15
|
+
/** \class NumTraits
|
16
|
+
* \ingroup Core_Module
|
17
|
+
*
|
18
|
+
* \brief Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
|
19
|
+
*
|
20
|
+
* \param T the numeric type at hand
|
21
|
+
*
|
22
|
+
* This class stores enums, typedefs and static methods giving information about a numeric type.
|
23
|
+
*
|
24
|
+
* The provided data consists of:
|
25
|
+
* \li A typedef \a Real, giving the "real part" type of \a T. If \a T is already real,
|
26
|
+
* then \a Real is just a typedef to \a T. If \a T is \c std::complex<U> then \a Real
|
27
|
+
* is a typedef to \a U.
|
28
|
+
* \li A typedef \a NonInteger, giving the type that should be used for operations producing non-integral values,
|
29
|
+
* such as quotients, square roots, etc. If \a T is a floating-point type, then this typedef just gives
|
30
|
+
* \a T again. Note however that many Eigen functions such as internal::sqrt simply refuse to
|
31
|
+
* take integers. Outside of a few cases, Eigen doesn't do automatic type promotion. Thus, this typedef is
|
32
|
+
* only intended as a helper for code that needs to explicitly promote types.
|
33
|
+
* \li A typedef \a Nested giving the type to use to nest a value inside of the expression tree. If you don't know what
|
34
|
+
* this means, just use \a T here.
|
35
|
+
* \li An enum value \a IsComplex. It is equal to 1 if \a T is a \c std::complex
|
36
|
+
* type, and to 0 otherwise.
|
37
|
+
* \li An enum value \a IsInteger. It is equal to \c 1 if \a T is an integer type such as \c int,
|
38
|
+
* and to \c 0 otherwise.
|
39
|
+
* \li Enum values ReadCost, AddCost and MulCost representing a rough estimate of the number of CPU cycles needed
|
40
|
+
* to by move / add / mul instructions respectively, assuming the data is already stored in CPU registers.
|
41
|
+
* Stay vague here. No need to do architecture-specific stuff.
|
42
|
+
* \li An enum value \a IsSigned. It is equal to \c 1 if \a T is a signed type and to 0 if \a T is unsigned.
|
43
|
+
* \li An enum value \a RequireInitialization. It is equal to \c 1 if the constructor of the numeric type \a T must
|
44
|
+
* be called, and to 0 if it is safe not to call it. Default is 0 if \a T is an arithmetic type, and 1 otherwise.
|
45
|
+
* \li An epsilon() function which, unlike std::numeric_limits::epsilon(), returns a \a Real instead of a \a T.
|
46
|
+
* \li A dummy_precision() function returning a weak epsilon value. It is mainly used as a default
|
47
|
+
* value by the fuzzy comparison operators.
|
48
|
+
* \li highest() and lowest() functions returning the highest and lowest possible values respectively.
|
49
|
+
*/
|
50
|
+
|
51
|
+
template<typename T> struct GenericNumTraits
|
52
|
+
{
|
53
|
+
enum {
|
54
|
+
IsInteger = std::numeric_limits<T>::is_integer,
|
55
|
+
IsSigned = std::numeric_limits<T>::is_signed,
|
56
|
+
IsComplex = 0,
|
57
|
+
RequireInitialization = internal::is_arithmetic<T>::value ? 0 : 1,
|
58
|
+
ReadCost = 1,
|
59
|
+
AddCost = 1,
|
60
|
+
MulCost = 1
|
61
|
+
};
|
62
|
+
|
63
|
+
typedef T Real;
|
64
|
+
typedef typename internal::conditional<
|
65
|
+
IsInteger,
|
66
|
+
typename internal::conditional<sizeof(T)<=2, float, double>::type,
|
67
|
+
T
|
68
|
+
>::type NonInteger;
|
69
|
+
typedef T Nested;
|
70
|
+
|
71
|
+
static inline Real epsilon() { return std::numeric_limits<T>::epsilon(); }
|
72
|
+
static inline Real dummy_precision()
|
73
|
+
{
|
74
|
+
// make sure to override this for floating-point types
|
75
|
+
return Real(0);
|
76
|
+
}
|
77
|
+
static inline T highest() { return (std::numeric_limits<T>::max)(); }
|
78
|
+
static inline T lowest() { return IsInteger ? (std::numeric_limits<T>::min)() : (-(std::numeric_limits<T>::max)()); }
|
79
|
+
|
80
|
+
#ifdef EIGEN2_SUPPORT
|
81
|
+
enum {
|
82
|
+
HasFloatingPoint = !IsInteger
|
83
|
+
};
|
84
|
+
typedef NonInteger FloatingPoint;
|
85
|
+
#endif
|
86
|
+
};
|
87
|
+
|
88
|
+
template<typename T> struct NumTraits : GenericNumTraits<T>
|
89
|
+
{};
|
90
|
+
|
91
|
+
template<> struct NumTraits<float>
|
92
|
+
: GenericNumTraits<float>
|
93
|
+
{
|
94
|
+
static inline float dummy_precision() { return 1e-5f; }
|
95
|
+
};
|
96
|
+
|
97
|
+
template<> struct NumTraits<double> : GenericNumTraits<double>
|
98
|
+
{
|
99
|
+
static inline double dummy_precision() { return 1e-12; }
|
100
|
+
};
|
101
|
+
|
102
|
+
template<> struct NumTraits<long double>
|
103
|
+
: GenericNumTraits<long double>
|
104
|
+
{
|
105
|
+
static inline long double dummy_precision() { return 1e-15l; }
|
106
|
+
};
|
107
|
+
|
108
|
+
template<typename _Real> struct NumTraits<std::complex<_Real> >
|
109
|
+
: GenericNumTraits<std::complex<_Real> >
|
110
|
+
{
|
111
|
+
typedef _Real Real;
|
112
|
+
enum {
|
113
|
+
IsComplex = 1,
|
114
|
+
RequireInitialization = NumTraits<_Real>::RequireInitialization,
|
115
|
+
ReadCost = 2 * NumTraits<_Real>::ReadCost,
|
116
|
+
AddCost = 2 * NumTraits<Real>::AddCost,
|
117
|
+
MulCost = 4 * NumTraits<Real>::MulCost + 2 * NumTraits<Real>::AddCost
|
118
|
+
};
|
119
|
+
|
120
|
+
static inline Real epsilon() { return NumTraits<Real>::epsilon(); }
|
121
|
+
static inline Real dummy_precision() { return NumTraits<Real>::dummy_precision(); }
|
122
|
+
};
|
123
|
+
|
124
|
+
template<typename Scalar, int Rows, int Cols, int Options, int MaxRows, int MaxCols>
|
125
|
+
struct NumTraits<Array<Scalar, Rows, Cols, Options, MaxRows, MaxCols> >
|
126
|
+
{
|
127
|
+
typedef Array<Scalar, Rows, Cols, Options, MaxRows, MaxCols> ArrayType;
|
128
|
+
typedef typename NumTraits<Scalar>::Real RealScalar;
|
129
|
+
typedef Array<RealScalar, Rows, Cols, Options, MaxRows, MaxCols> Real;
|
130
|
+
typedef typename NumTraits<Scalar>::NonInteger NonIntegerScalar;
|
131
|
+
typedef Array<NonIntegerScalar, Rows, Cols, Options, MaxRows, MaxCols> NonInteger;
|
132
|
+
typedef ArrayType & Nested;
|
133
|
+
|
134
|
+
enum {
|
135
|
+
IsComplex = NumTraits<Scalar>::IsComplex,
|
136
|
+
IsInteger = NumTraits<Scalar>::IsInteger,
|
137
|
+
IsSigned = NumTraits<Scalar>::IsSigned,
|
138
|
+
RequireInitialization = 1,
|
139
|
+
ReadCost = ArrayType::SizeAtCompileTime==Dynamic ? Dynamic : ArrayType::SizeAtCompileTime * NumTraits<Scalar>::ReadCost,
|
140
|
+
AddCost = ArrayType::SizeAtCompileTime==Dynamic ? Dynamic : ArrayType::SizeAtCompileTime * NumTraits<Scalar>::AddCost,
|
141
|
+
MulCost = ArrayType::SizeAtCompileTime==Dynamic ? Dynamic : ArrayType::SizeAtCompileTime * NumTraits<Scalar>::MulCost
|
142
|
+
};
|
143
|
+
|
144
|
+
static inline RealScalar epsilon() { return NumTraits<RealScalar>::epsilon(); }
|
145
|
+
static inline RealScalar dummy_precision() { return NumTraits<RealScalar>::dummy_precision(); }
|
146
|
+
};
|
147
|
+
|
148
|
+
} // end namespace Eigen
|
149
|
+
|
150
|
+
#endif // EIGEN_NUMTRAITS_H
|
@@ -0,0 +1,721 @@
|
|
1
|
+
// This file is part of Eigen, a lightweight C++ template library
|
2
|
+
// for linear algebra.
|
3
|
+
//
|
4
|
+
// Copyright (C) 2009 Benoit Jacob <jacob.benoit.1@gmail.com>
|
5
|
+
// Copyright (C) 2009-2011 Gael Guennebaud <gael.guennebaud@inria.fr>
|
6
|
+
//
|
7
|
+
// This Source Code Form is subject to the terms of the Mozilla
|
8
|
+
// Public License v. 2.0. If a copy of the MPL was not distributed
|
9
|
+
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
10
|
+
|
11
|
+
#ifndef EIGEN_PERMUTATIONMATRIX_H
|
12
|
+
#define EIGEN_PERMUTATIONMATRIX_H
|
13
|
+
|
14
|
+
namespace Eigen {
|
15
|
+
|
16
|
+
template<int RowCol,typename IndicesType,typename MatrixType, typename StorageKind> class PermutedImpl;
|
17
|
+
|
18
|
+
/** \class PermutationBase
|
19
|
+
* \ingroup Core_Module
|
20
|
+
*
|
21
|
+
* \brief Base class for permutations
|
22
|
+
*
|
23
|
+
* \param Derived the derived class
|
24
|
+
*
|
25
|
+
* This class is the base class for all expressions representing a permutation matrix,
|
26
|
+
* internally stored as a vector of integers.
|
27
|
+
* The convention followed here is that if \f$ \sigma \f$ is a permutation, the corresponding permutation matrix
|
28
|
+
* \f$ P_\sigma \f$ is such that if \f$ (e_1,\ldots,e_p) \f$ is the canonical basis, we have:
|
29
|
+
* \f[ P_\sigma(e_i) = e_{\sigma(i)}. \f]
|
30
|
+
* This convention ensures that for any two permutations \f$ \sigma, \tau \f$, we have:
|
31
|
+
* \f[ P_{\sigma\circ\tau} = P_\sigma P_\tau. \f]
|
32
|
+
*
|
33
|
+
* Permutation matrices are square and invertible.
|
34
|
+
*
|
35
|
+
* Notice that in addition to the member functions and operators listed here, there also are non-member
|
36
|
+
* operator* to multiply any kind of permutation object with any kind of matrix expression (MatrixBase)
|
37
|
+
* on either side.
|
38
|
+
*
|
39
|
+
* \sa class PermutationMatrix, class PermutationWrapper
|
40
|
+
*/
|
41
|
+
|
42
|
+
namespace internal {
|
43
|
+
|
44
|
+
template<typename PermutationType, typename MatrixType, int Side, bool Transposed=false>
|
45
|
+
struct permut_matrix_product_retval;
|
46
|
+
template<typename PermutationType, typename MatrixType, int Side, bool Transposed=false>
|
47
|
+
struct permut_sparsematrix_product_retval;
|
48
|
+
enum PermPermProduct_t {PermPermProduct};
|
49
|
+
|
50
|
+
} // end namespace internal
|
51
|
+
|
52
|
+
template<typename Derived>
|
53
|
+
class PermutationBase : public EigenBase<Derived>
|
54
|
+
{
|
55
|
+
typedef internal::traits<Derived> Traits;
|
56
|
+
typedef EigenBase<Derived> Base;
|
57
|
+
public:
|
58
|
+
|
59
|
+
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
60
|
+
typedef typename Traits::IndicesType IndicesType;
|
61
|
+
enum {
|
62
|
+
Flags = Traits::Flags,
|
63
|
+
CoeffReadCost = Traits::CoeffReadCost,
|
64
|
+
RowsAtCompileTime = Traits::RowsAtCompileTime,
|
65
|
+
ColsAtCompileTime = Traits::ColsAtCompileTime,
|
66
|
+
MaxRowsAtCompileTime = Traits::MaxRowsAtCompileTime,
|
67
|
+
MaxColsAtCompileTime = Traits::MaxColsAtCompileTime
|
68
|
+
};
|
69
|
+
typedef typename Traits::Scalar Scalar;
|
70
|
+
typedef typename Traits::Index Index;
|
71
|
+
typedef Matrix<Scalar,RowsAtCompileTime,ColsAtCompileTime,0,MaxRowsAtCompileTime,MaxColsAtCompileTime>
|
72
|
+
DenseMatrixType;
|
73
|
+
typedef PermutationMatrix<IndicesType::SizeAtCompileTime,IndicesType::MaxSizeAtCompileTime,Index>
|
74
|
+
PlainPermutationType;
|
75
|
+
using Base::derived;
|
76
|
+
#endif
|
77
|
+
|
78
|
+
/** Copies the other permutation into *this */
|
79
|
+
template<typename OtherDerived>
|
80
|
+
Derived& operator=(const PermutationBase<OtherDerived>& other)
|
81
|
+
{
|
82
|
+
indices() = other.indices();
|
83
|
+
return derived();
|
84
|
+
}
|
85
|
+
|
86
|
+
/** Assignment from the Transpositions \a tr */
|
87
|
+
template<typename OtherDerived>
|
88
|
+
Derived& operator=(const TranspositionsBase<OtherDerived>& tr)
|
89
|
+
{
|
90
|
+
setIdentity(tr.size());
|
91
|
+
for(Index k=size()-1; k>=0; --k)
|
92
|
+
applyTranspositionOnTheRight(k,tr.coeff(k));
|
93
|
+
return derived();
|
94
|
+
}
|
95
|
+
|
96
|
+
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
97
|
+
/** This is a special case of the templated operator=. Its purpose is to
|
98
|
+
* prevent a default operator= from hiding the templated operator=.
|
99
|
+
*/
|
100
|
+
Derived& operator=(const PermutationBase& other)
|
101
|
+
{
|
102
|
+
indices() = other.indices();
|
103
|
+
return derived();
|
104
|
+
}
|
105
|
+
#endif
|
106
|
+
|
107
|
+
/** \returns the number of rows */
|
108
|
+
inline Index rows() const { return Index(indices().size()); }
|
109
|
+
|
110
|
+
/** \returns the number of columns */
|
111
|
+
inline Index cols() const { return Index(indices().size()); }
|
112
|
+
|
113
|
+
/** \returns the size of a side of the respective square matrix, i.e., the number of indices */
|
114
|
+
inline Index size() const { return Index(indices().size()); }
|
115
|
+
|
116
|
+
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
117
|
+
template<typename DenseDerived>
|
118
|
+
void evalTo(MatrixBase<DenseDerived>& other) const
|
119
|
+
{
|
120
|
+
other.setZero();
|
121
|
+
for (int i=0; i<rows();++i)
|
122
|
+
other.coeffRef(indices().coeff(i),i) = typename DenseDerived::Scalar(1);
|
123
|
+
}
|
124
|
+
#endif
|
125
|
+
|
126
|
+
/** \returns a Matrix object initialized from this permutation matrix. Notice that it
|
127
|
+
* is inefficient to return this Matrix object by value. For efficiency, favor using
|
128
|
+
* the Matrix constructor taking EigenBase objects.
|
129
|
+
*/
|
130
|
+
DenseMatrixType toDenseMatrix() const
|
131
|
+
{
|
132
|
+
return derived();
|
133
|
+
}
|
134
|
+
|
135
|
+
/** const version of indices(). */
|
136
|
+
const IndicesType& indices() const { return derived().indices(); }
|
137
|
+
/** \returns a reference to the stored array representing the permutation. */
|
138
|
+
IndicesType& indices() { return derived().indices(); }
|
139
|
+
|
140
|
+
/** Resizes to given size.
|
141
|
+
*/
|
142
|
+
inline void resize(Index newSize)
|
143
|
+
{
|
144
|
+
indices().resize(newSize);
|
145
|
+
}
|
146
|
+
|
147
|
+
/** Sets *this to be the identity permutation matrix */
|
148
|
+
void setIdentity()
|
149
|
+
{
|
150
|
+
for(Index i = 0; i < size(); ++i)
|
151
|
+
indices().coeffRef(i) = i;
|
152
|
+
}
|
153
|
+
|
154
|
+
/** Sets *this to be the identity permutation matrix of given size.
|
155
|
+
*/
|
156
|
+
void setIdentity(Index newSize)
|
157
|
+
{
|
158
|
+
resize(newSize);
|
159
|
+
setIdentity();
|
160
|
+
}
|
161
|
+
|
162
|
+
/** Multiplies *this by the transposition \f$(ij)\f$ on the left.
|
163
|
+
*
|
164
|
+
* \returns a reference to *this.
|
165
|
+
*
|
166
|
+
* \warning This is much slower than applyTranspositionOnTheRight(int,int):
|
167
|
+
* this has linear complexity and requires a lot of branching.
|
168
|
+
*
|
169
|
+
* \sa applyTranspositionOnTheRight(int,int)
|
170
|
+
*/
|
171
|
+
Derived& applyTranspositionOnTheLeft(Index i, Index j)
|
172
|
+
{
|
173
|
+
eigen_assert(i>=0 && j>=0 && i<size() && j<size());
|
174
|
+
for(Index k = 0; k < size(); ++k)
|
175
|
+
{
|
176
|
+
if(indices().coeff(k) == i) indices().coeffRef(k) = j;
|
177
|
+
else if(indices().coeff(k) == j) indices().coeffRef(k) = i;
|
178
|
+
}
|
179
|
+
return derived();
|
180
|
+
}
|
181
|
+
|
182
|
+
/** Multiplies *this by the transposition \f$(ij)\f$ on the right.
|
183
|
+
*
|
184
|
+
* \returns a reference to *this.
|
185
|
+
*
|
186
|
+
* This is a fast operation, it only consists in swapping two indices.
|
187
|
+
*
|
188
|
+
* \sa applyTranspositionOnTheLeft(int,int)
|
189
|
+
*/
|
190
|
+
Derived& applyTranspositionOnTheRight(Index i, Index j)
|
191
|
+
{
|
192
|
+
eigen_assert(i>=0 && j>=0 && i<size() && j<size());
|
193
|
+
std::swap(indices().coeffRef(i), indices().coeffRef(j));
|
194
|
+
return derived();
|
195
|
+
}
|
196
|
+
|
197
|
+
/** \returns the inverse permutation matrix.
|
198
|
+
*
|
199
|
+
* \note \note_try_to_help_rvo
|
200
|
+
*/
|
201
|
+
inline Transpose<PermutationBase> inverse() const
|
202
|
+
{ return derived(); }
|
203
|
+
/** \returns the tranpose permutation matrix.
|
204
|
+
*
|
205
|
+
* \note \note_try_to_help_rvo
|
206
|
+
*/
|
207
|
+
inline Transpose<PermutationBase> transpose() const
|
208
|
+
{ return derived(); }
|
209
|
+
|
210
|
+
/**** multiplication helpers to hopefully get RVO ****/
|
211
|
+
|
212
|
+
|
213
|
+
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
214
|
+
protected:
|
215
|
+
template<typename OtherDerived>
|
216
|
+
void assignTranspose(const PermutationBase<OtherDerived>& other)
|
217
|
+
{
|
218
|
+
for (int i=0; i<rows();++i) indices().coeffRef(other.indices().coeff(i)) = i;
|
219
|
+
}
|
220
|
+
template<typename Lhs,typename Rhs>
|
221
|
+
void assignProduct(const Lhs& lhs, const Rhs& rhs)
|
222
|
+
{
|
223
|
+
eigen_assert(lhs.cols() == rhs.rows());
|
224
|
+
for (int i=0; i<rows();++i) indices().coeffRef(i) = lhs.indices().coeff(rhs.indices().coeff(i));
|
225
|
+
}
|
226
|
+
#endif
|
227
|
+
|
228
|
+
public:
|
229
|
+
|
230
|
+
/** \returns the product permutation matrix.
|
231
|
+
*
|
232
|
+
* \note \note_try_to_help_rvo
|
233
|
+
*/
|
234
|
+
template<typename Other>
|
235
|
+
inline PlainPermutationType operator*(const PermutationBase<Other>& other) const
|
236
|
+
{ return PlainPermutationType(internal::PermPermProduct, derived(), other.derived()); }
|
237
|
+
|
238
|
+
/** \returns the product of a permutation with another inverse permutation.
|
239
|
+
*
|
240
|
+
* \note \note_try_to_help_rvo
|
241
|
+
*/
|
242
|
+
template<typename Other>
|
243
|
+
inline PlainPermutationType operator*(const Transpose<PermutationBase<Other> >& other) const
|
244
|
+
{ return PlainPermutationType(internal::PermPermProduct, *this, other.eval()); }
|
245
|
+
|
246
|
+
/** \returns the product of an inverse permutation with another permutation.
|
247
|
+
*
|
248
|
+
* \note \note_try_to_help_rvo
|
249
|
+
*/
|
250
|
+
template<typename Other> friend
|
251
|
+
inline PlainPermutationType operator*(const Transpose<PermutationBase<Other> >& other, const PermutationBase& perm)
|
252
|
+
{ return PlainPermutationType(internal::PermPermProduct, other.eval(), perm); }
|
253
|
+
|
254
|
+
/** \returns the determinant of the permutation matrix, which is either 1 or -1 depending on the parity of the permutation.
|
255
|
+
*
|
256
|
+
* This function is O(\c n) procedure allocating a buffer of \c n booleans.
|
257
|
+
*/
|
258
|
+
Index determinant() const
|
259
|
+
{
|
260
|
+
Index res = 1;
|
261
|
+
Index n = size();
|
262
|
+
Matrix<bool,RowsAtCompileTime,1,0,MaxRowsAtCompileTime> mask(n);
|
263
|
+
mask.fill(false);
|
264
|
+
Index r = 0;
|
265
|
+
while(r < n)
|
266
|
+
{
|
267
|
+
// search for the next seed
|
268
|
+
while(r<n && mask[r]) r++;
|
269
|
+
if(r>=n)
|
270
|
+
break;
|
271
|
+
// we got one, let's follow it until we are back to the seed
|
272
|
+
Index k0 = r++;
|
273
|
+
mask.coeffRef(k0) = true;
|
274
|
+
for(Index k=indices().coeff(k0); k!=k0; k=indices().coeff(k))
|
275
|
+
{
|
276
|
+
mask.coeffRef(k) = true;
|
277
|
+
res = -res;
|
278
|
+
}
|
279
|
+
}
|
280
|
+
return res;
|
281
|
+
}
|
282
|
+
|
283
|
+
protected:
|
284
|
+
|
285
|
+
};
|
286
|
+
|
287
|
+
/** \class PermutationMatrix
|
288
|
+
* \ingroup Core_Module
|
289
|
+
*
|
290
|
+
* \brief Permutation matrix
|
291
|
+
*
|
292
|
+
* \param SizeAtCompileTime the number of rows/cols, or Dynamic
|
293
|
+
* \param MaxSizeAtCompileTime the maximum number of rows/cols, or Dynamic. This optional parameter defaults to SizeAtCompileTime. Most of the time, you should not have to specify it.
|
294
|
+
* \param IndexType the interger type of the indices
|
295
|
+
*
|
296
|
+
* This class represents a permutation matrix, internally stored as a vector of integers.
|
297
|
+
*
|
298
|
+
* \sa class PermutationBase, class PermutationWrapper, class DiagonalMatrix
|
299
|
+
*/
|
300
|
+
|
301
|
+
namespace internal {
|
302
|
+
template<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename IndexType>
|
303
|
+
struct traits<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime, IndexType> >
|
304
|
+
: traits<Matrix<IndexType,SizeAtCompileTime,SizeAtCompileTime,0,MaxSizeAtCompileTime,MaxSizeAtCompileTime> >
|
305
|
+
{
|
306
|
+
typedef IndexType Index;
|
307
|
+
typedef Matrix<IndexType, SizeAtCompileTime, 1, 0, MaxSizeAtCompileTime, 1> IndicesType;
|
308
|
+
};
|
309
|
+
}
|
310
|
+
|
311
|
+
template<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename IndexType>
|
312
|
+
class PermutationMatrix : public PermutationBase<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime, IndexType> >
|
313
|
+
{
|
314
|
+
typedef PermutationBase<PermutationMatrix> Base;
|
315
|
+
typedef internal::traits<PermutationMatrix> Traits;
|
316
|
+
public:
|
317
|
+
|
318
|
+
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
319
|
+
typedef typename Traits::IndicesType IndicesType;
|
320
|
+
#endif
|
321
|
+
|
322
|
+
inline PermutationMatrix()
|
323
|
+
{}
|
324
|
+
|
325
|
+
/** Constructs an uninitialized permutation matrix of given size.
|
326
|
+
*/
|
327
|
+
inline PermutationMatrix(int size) : m_indices(size)
|
328
|
+
{}
|
329
|
+
|
330
|
+
/** Copy constructor. */
|
331
|
+
template<typename OtherDerived>
|
332
|
+
inline PermutationMatrix(const PermutationBase<OtherDerived>& other)
|
333
|
+
: m_indices(other.indices()) {}
|
334
|
+
|
335
|
+
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
336
|
+
/** Standard copy constructor. Defined only to prevent a default copy constructor
|
337
|
+
* from hiding the other templated constructor */
|
338
|
+
inline PermutationMatrix(const PermutationMatrix& other) : m_indices(other.indices()) {}
|
339
|
+
#endif
|
340
|
+
|
341
|
+
/** Generic constructor from expression of the indices. The indices
|
342
|
+
* array has the meaning that the permutations sends each integer i to indices[i].
|
343
|
+
*
|
344
|
+
* \warning It is your responsibility to check that the indices array that you passes actually
|
345
|
+
* describes a permutation, i.e., each value between 0 and n-1 occurs exactly once, where n is the
|
346
|
+
* array's size.
|
347
|
+
*/
|
348
|
+
template<typename Other>
|
349
|
+
explicit inline PermutationMatrix(const MatrixBase<Other>& a_indices) : m_indices(a_indices)
|
350
|
+
{}
|
351
|
+
|
352
|
+
/** Convert the Transpositions \a tr to a permutation matrix */
|
353
|
+
template<typename Other>
|
354
|
+
explicit PermutationMatrix(const TranspositionsBase<Other>& tr)
|
355
|
+
: m_indices(tr.size())
|
356
|
+
{
|
357
|
+
*this = tr;
|
358
|
+
}
|
359
|
+
|
360
|
+
/** Copies the other permutation into *this */
|
361
|
+
template<typename Other>
|
362
|
+
PermutationMatrix& operator=(const PermutationBase<Other>& other)
|
363
|
+
{
|
364
|
+
m_indices = other.indices();
|
365
|
+
return *this;
|
366
|
+
}
|
367
|
+
|
368
|
+
/** Assignment from the Transpositions \a tr */
|
369
|
+
template<typename Other>
|
370
|
+
PermutationMatrix& operator=(const TranspositionsBase<Other>& tr)
|
371
|
+
{
|
372
|
+
return Base::operator=(tr.derived());
|
373
|
+
}
|
374
|
+
|
375
|
+
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
376
|
+
/** This is a special case of the templated operator=. Its purpose is to
|
377
|
+
* prevent a default operator= from hiding the templated operator=.
|
378
|
+
*/
|
379
|
+
PermutationMatrix& operator=(const PermutationMatrix& other)
|
380
|
+
{
|
381
|
+
m_indices = other.m_indices;
|
382
|
+
return *this;
|
383
|
+
}
|
384
|
+
#endif
|
385
|
+
|
386
|
+
/** const version of indices(). */
|
387
|
+
const IndicesType& indices() const { return m_indices; }
|
388
|
+
/** \returns a reference to the stored array representing the permutation. */
|
389
|
+
IndicesType& indices() { return m_indices; }
|
390
|
+
|
391
|
+
|
392
|
+
/**** multiplication helpers to hopefully get RVO ****/
|
393
|
+
|
394
|
+
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
395
|
+
template<typename Other>
|
396
|
+
PermutationMatrix(const Transpose<PermutationBase<Other> >& other)
|
397
|
+
: m_indices(other.nestedPermutation().size())
|
398
|
+
{
|
399
|
+
for (int i=0; i<m_indices.size();++i) m_indices.coeffRef(other.nestedPermutation().indices().coeff(i)) = i;
|
400
|
+
}
|
401
|
+
template<typename Lhs,typename Rhs>
|
402
|
+
PermutationMatrix(internal::PermPermProduct_t, const Lhs& lhs, const Rhs& rhs)
|
403
|
+
: m_indices(lhs.indices().size())
|
404
|
+
{
|
405
|
+
Base::assignProduct(lhs,rhs);
|
406
|
+
}
|
407
|
+
#endif
|
408
|
+
|
409
|
+
protected:
|
410
|
+
|
411
|
+
IndicesType m_indices;
|
412
|
+
};
|
413
|
+
|
414
|
+
|
415
|
+
namespace internal {
|
416
|
+
template<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename IndexType, int _PacketAccess>
|
417
|
+
struct traits<Map<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime, IndexType>,_PacketAccess> >
|
418
|
+
: traits<Matrix<IndexType,SizeAtCompileTime,SizeAtCompileTime,0,MaxSizeAtCompileTime,MaxSizeAtCompileTime> >
|
419
|
+
{
|
420
|
+
typedef IndexType Index;
|
421
|
+
typedef Map<const Matrix<IndexType, SizeAtCompileTime, 1, 0, MaxSizeAtCompileTime, 1>, _PacketAccess> IndicesType;
|
422
|
+
};
|
423
|
+
}
|
424
|
+
|
425
|
+
template<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename IndexType, int _PacketAccess>
|
426
|
+
class Map<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime, IndexType>,_PacketAccess>
|
427
|
+
: public PermutationBase<Map<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime, IndexType>,_PacketAccess> >
|
428
|
+
{
|
429
|
+
typedef PermutationBase<Map> Base;
|
430
|
+
typedef internal::traits<Map> Traits;
|
431
|
+
public:
|
432
|
+
|
433
|
+
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
434
|
+
typedef typename Traits::IndicesType IndicesType;
|
435
|
+
typedef typename IndicesType::Scalar Index;
|
436
|
+
#endif
|
437
|
+
|
438
|
+
inline Map(const Index* indicesPtr)
|
439
|
+
: m_indices(indicesPtr)
|
440
|
+
{}
|
441
|
+
|
442
|
+
inline Map(const Index* indicesPtr, Index size)
|
443
|
+
: m_indices(indicesPtr,size)
|
444
|
+
{}
|
445
|
+
|
446
|
+
/** Copies the other permutation into *this */
|
447
|
+
template<typename Other>
|
448
|
+
Map& operator=(const PermutationBase<Other>& other)
|
449
|
+
{ return Base::operator=(other.derived()); }
|
450
|
+
|
451
|
+
/** Assignment from the Transpositions \a tr */
|
452
|
+
template<typename Other>
|
453
|
+
Map& operator=(const TranspositionsBase<Other>& tr)
|
454
|
+
{ return Base::operator=(tr.derived()); }
|
455
|
+
|
456
|
+
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
457
|
+
/** This is a special case of the templated operator=. Its purpose is to
|
458
|
+
* prevent a default operator= from hiding the templated operator=.
|
459
|
+
*/
|
460
|
+
Map& operator=(const Map& other)
|
461
|
+
{
|
462
|
+
m_indices = other.m_indices;
|
463
|
+
return *this;
|
464
|
+
}
|
465
|
+
#endif
|
466
|
+
|
467
|
+
/** const version of indices(). */
|
468
|
+
const IndicesType& indices() const { return m_indices; }
|
469
|
+
/** \returns a reference to the stored array representing the permutation. */
|
470
|
+
IndicesType& indices() { return m_indices; }
|
471
|
+
|
472
|
+
protected:
|
473
|
+
|
474
|
+
IndicesType m_indices;
|
475
|
+
};
|
476
|
+
|
477
|
+
/** \class PermutationWrapper
|
478
|
+
* \ingroup Core_Module
|
479
|
+
*
|
480
|
+
* \brief Class to view a vector of integers as a permutation matrix
|
481
|
+
*
|
482
|
+
* \param _IndicesType the type of the vector of integer (can be any compatible expression)
|
483
|
+
*
|
484
|
+
* This class allows to view any vector expression of integers as a permutation matrix.
|
485
|
+
*
|
486
|
+
* \sa class PermutationBase, class PermutationMatrix
|
487
|
+
*/
|
488
|
+
|
489
|
+
struct PermutationStorage {};
|
490
|
+
|
491
|
+
template<typename _IndicesType> class TranspositionsWrapper;
|
492
|
+
namespace internal {
|
493
|
+
template<typename _IndicesType>
|
494
|
+
struct traits<PermutationWrapper<_IndicesType> >
|
495
|
+
{
|
496
|
+
typedef PermutationStorage StorageKind;
|
497
|
+
typedef typename _IndicesType::Scalar Scalar;
|
498
|
+
typedef typename _IndicesType::Scalar Index;
|
499
|
+
typedef _IndicesType IndicesType;
|
500
|
+
enum {
|
501
|
+
RowsAtCompileTime = _IndicesType::SizeAtCompileTime,
|
502
|
+
ColsAtCompileTime = _IndicesType::SizeAtCompileTime,
|
503
|
+
MaxRowsAtCompileTime = IndicesType::MaxRowsAtCompileTime,
|
504
|
+
MaxColsAtCompileTime = IndicesType::MaxColsAtCompileTime,
|
505
|
+
Flags = 0,
|
506
|
+
CoeffReadCost = _IndicesType::CoeffReadCost
|
507
|
+
};
|
508
|
+
};
|
509
|
+
}
|
510
|
+
|
511
|
+
template<typename _IndicesType>
|
512
|
+
class PermutationWrapper : public PermutationBase<PermutationWrapper<_IndicesType> >
|
513
|
+
{
|
514
|
+
typedef PermutationBase<PermutationWrapper> Base;
|
515
|
+
typedef internal::traits<PermutationWrapper> Traits;
|
516
|
+
public:
|
517
|
+
|
518
|
+
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
519
|
+
typedef typename Traits::IndicesType IndicesType;
|
520
|
+
#endif
|
521
|
+
|
522
|
+
inline PermutationWrapper(const IndicesType& a_indices)
|
523
|
+
: m_indices(a_indices)
|
524
|
+
{}
|
525
|
+
|
526
|
+
/** const version of indices(). */
|
527
|
+
const typename internal::remove_all<typename IndicesType::Nested>::type&
|
528
|
+
indices() const { return m_indices; }
|
529
|
+
|
530
|
+
protected:
|
531
|
+
|
532
|
+
typename IndicesType::Nested m_indices;
|
533
|
+
};
|
534
|
+
|
535
|
+
/** \returns the matrix with the permutation applied to the columns.
|
536
|
+
*/
|
537
|
+
template<typename Derived, typename PermutationDerived>
|
538
|
+
inline const internal::permut_matrix_product_retval<PermutationDerived, Derived, OnTheRight>
|
539
|
+
operator*(const MatrixBase<Derived>& matrix,
|
540
|
+
const PermutationBase<PermutationDerived> &permutation)
|
541
|
+
{
|
542
|
+
return internal::permut_matrix_product_retval
|
543
|
+
<PermutationDerived, Derived, OnTheRight>
|
544
|
+
(permutation.derived(), matrix.derived());
|
545
|
+
}
|
546
|
+
|
547
|
+
/** \returns the matrix with the permutation applied to the rows.
|
548
|
+
*/
|
549
|
+
template<typename Derived, typename PermutationDerived>
|
550
|
+
inline const internal::permut_matrix_product_retval
|
551
|
+
<PermutationDerived, Derived, OnTheLeft>
|
552
|
+
operator*(const PermutationBase<PermutationDerived> &permutation,
|
553
|
+
const MatrixBase<Derived>& matrix)
|
554
|
+
{
|
555
|
+
return internal::permut_matrix_product_retval
|
556
|
+
<PermutationDerived, Derived, OnTheLeft>
|
557
|
+
(permutation.derived(), matrix.derived());
|
558
|
+
}
|
559
|
+
|
560
|
+
namespace internal {
|
561
|
+
|
562
|
+
template<typename PermutationType, typename MatrixType, int Side, bool Transposed>
|
563
|
+
struct traits<permut_matrix_product_retval<PermutationType, MatrixType, Side, Transposed> >
|
564
|
+
{
|
565
|
+
typedef typename MatrixType::PlainObject ReturnType;
|
566
|
+
};
|
567
|
+
|
568
|
+
template<typename PermutationType, typename MatrixType, int Side, bool Transposed>
|
569
|
+
struct permut_matrix_product_retval
|
570
|
+
: public ReturnByValue<permut_matrix_product_retval<PermutationType, MatrixType, Side, Transposed> >
|
571
|
+
{
|
572
|
+
typedef typename remove_all<typename MatrixType::Nested>::type MatrixTypeNestedCleaned;
|
573
|
+
typedef typename MatrixType::Index Index;
|
574
|
+
|
575
|
+
permut_matrix_product_retval(const PermutationType& perm, const MatrixType& matrix)
|
576
|
+
: m_permutation(perm), m_matrix(matrix)
|
577
|
+
{}
|
578
|
+
|
579
|
+
inline Index rows() const { return m_matrix.rows(); }
|
580
|
+
inline Index cols() const { return m_matrix.cols(); }
|
581
|
+
|
582
|
+
template<typename Dest> inline void evalTo(Dest& dst) const
|
583
|
+
{
|
584
|
+
const Index n = Side==OnTheLeft ? rows() : cols();
|
585
|
+
// FIXME we need an is_same for expression that is not sensitive to constness. For instance
|
586
|
+
// is_same_xpr<Block<const Matrix>, Block<Matrix> >::value should be true.
|
587
|
+
if( is_same<MatrixTypeNestedCleaned,Dest>::value
|
588
|
+
&& blas_traits<MatrixTypeNestedCleaned>::HasUsableDirectAccess
|
589
|
+
&& blas_traits<Dest>::HasUsableDirectAccess
|
590
|
+
&& extract_data(dst) == extract_data(m_matrix))
|
591
|
+
{
|
592
|
+
// apply the permutation inplace
|
593
|
+
Matrix<bool,PermutationType::RowsAtCompileTime,1,0,PermutationType::MaxRowsAtCompileTime> mask(m_permutation.size());
|
594
|
+
mask.fill(false);
|
595
|
+
Index r = 0;
|
596
|
+
while(r < m_permutation.size())
|
597
|
+
{
|
598
|
+
// search for the next seed
|
599
|
+
while(r<m_permutation.size() && mask[r]) r++;
|
600
|
+
if(r>=m_permutation.size())
|
601
|
+
break;
|
602
|
+
// we got one, let's follow it until we are back to the seed
|
603
|
+
Index k0 = r++;
|
604
|
+
Index kPrev = k0;
|
605
|
+
mask.coeffRef(k0) = true;
|
606
|
+
for(Index k=m_permutation.indices().coeff(k0); k!=k0; k=m_permutation.indices().coeff(k))
|
607
|
+
{
|
608
|
+
Block<Dest, Side==OnTheLeft ? 1 : Dest::RowsAtCompileTime, Side==OnTheRight ? 1 : Dest::ColsAtCompileTime>(dst, k)
|
609
|
+
.swap(Block<Dest, Side==OnTheLeft ? 1 : Dest::RowsAtCompileTime, Side==OnTheRight ? 1 : Dest::ColsAtCompileTime>
|
610
|
+
(dst,((Side==OnTheLeft) ^ Transposed) ? k0 : kPrev));
|
611
|
+
|
612
|
+
mask.coeffRef(k) = true;
|
613
|
+
kPrev = k;
|
614
|
+
}
|
615
|
+
}
|
616
|
+
}
|
617
|
+
else
|
618
|
+
{
|
619
|
+
for(int i = 0; i < n; ++i)
|
620
|
+
{
|
621
|
+
Block<Dest, Side==OnTheLeft ? 1 : Dest::RowsAtCompileTime, Side==OnTheRight ? 1 : Dest::ColsAtCompileTime>
|
622
|
+
(dst, ((Side==OnTheLeft) ^ Transposed) ? m_permutation.indices().coeff(i) : i)
|
623
|
+
|
624
|
+
=
|
625
|
+
|
626
|
+
Block<const MatrixTypeNestedCleaned,Side==OnTheLeft ? 1 : MatrixType::RowsAtCompileTime,Side==OnTheRight ? 1 : MatrixType::ColsAtCompileTime>
|
627
|
+
(m_matrix, ((Side==OnTheRight) ^ Transposed) ? m_permutation.indices().coeff(i) : i);
|
628
|
+
}
|
629
|
+
}
|
630
|
+
}
|
631
|
+
|
632
|
+
protected:
|
633
|
+
const PermutationType& m_permutation;
|
634
|
+
typename MatrixType::Nested m_matrix;
|
635
|
+
};
|
636
|
+
|
637
|
+
/* Template partial specialization for transposed/inverse permutations */
|
638
|
+
|
639
|
+
template<typename Derived>
|
640
|
+
struct traits<Transpose<PermutationBase<Derived> > >
|
641
|
+
: traits<Derived>
|
642
|
+
{};
|
643
|
+
|
644
|
+
} // end namespace internal
|
645
|
+
|
646
|
+
template<typename Derived>
|
647
|
+
class Transpose<PermutationBase<Derived> >
|
648
|
+
: public EigenBase<Transpose<PermutationBase<Derived> > >
|
649
|
+
{
|
650
|
+
typedef Derived PermutationType;
|
651
|
+
typedef typename PermutationType::IndicesType IndicesType;
|
652
|
+
typedef typename PermutationType::PlainPermutationType PlainPermutationType;
|
653
|
+
public:
|
654
|
+
|
655
|
+
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
656
|
+
typedef internal::traits<PermutationType> Traits;
|
657
|
+
typedef typename Derived::DenseMatrixType DenseMatrixType;
|
658
|
+
enum {
|
659
|
+
Flags = Traits::Flags,
|
660
|
+
CoeffReadCost = Traits::CoeffReadCost,
|
661
|
+
RowsAtCompileTime = Traits::RowsAtCompileTime,
|
662
|
+
ColsAtCompileTime = Traits::ColsAtCompileTime,
|
663
|
+
MaxRowsAtCompileTime = Traits::MaxRowsAtCompileTime,
|
664
|
+
MaxColsAtCompileTime = Traits::MaxColsAtCompileTime
|
665
|
+
};
|
666
|
+
typedef typename Traits::Scalar Scalar;
|
667
|
+
#endif
|
668
|
+
|
669
|
+
Transpose(const PermutationType& p) : m_permutation(p) {}
|
670
|
+
|
671
|
+
inline int rows() const { return m_permutation.rows(); }
|
672
|
+
inline int cols() const { return m_permutation.cols(); }
|
673
|
+
|
674
|
+
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
675
|
+
template<typename DenseDerived>
|
676
|
+
void evalTo(MatrixBase<DenseDerived>& other) const
|
677
|
+
{
|
678
|
+
other.setZero();
|
679
|
+
for (int i=0; i<rows();++i)
|
680
|
+
other.coeffRef(i, m_permutation.indices().coeff(i)) = typename DenseDerived::Scalar(1);
|
681
|
+
}
|
682
|
+
#endif
|
683
|
+
|
684
|
+
/** \return the equivalent permutation matrix */
|
685
|
+
PlainPermutationType eval() const { return *this; }
|
686
|
+
|
687
|
+
DenseMatrixType toDenseMatrix() const { return *this; }
|
688
|
+
|
689
|
+
/** \returns the matrix with the inverse permutation applied to the columns.
|
690
|
+
*/
|
691
|
+
template<typename OtherDerived> friend
|
692
|
+
inline const internal::permut_matrix_product_retval<PermutationType, OtherDerived, OnTheRight, true>
|
693
|
+
operator*(const MatrixBase<OtherDerived>& matrix, const Transpose& trPerm)
|
694
|
+
{
|
695
|
+
return internal::permut_matrix_product_retval<PermutationType, OtherDerived, OnTheRight, true>(trPerm.m_permutation, matrix.derived());
|
696
|
+
}
|
697
|
+
|
698
|
+
/** \returns the matrix with the inverse permutation applied to the rows.
|
699
|
+
*/
|
700
|
+
template<typename OtherDerived>
|
701
|
+
inline const internal::permut_matrix_product_retval<PermutationType, OtherDerived, OnTheLeft, true>
|
702
|
+
operator*(const MatrixBase<OtherDerived>& matrix) const
|
703
|
+
{
|
704
|
+
return internal::permut_matrix_product_retval<PermutationType, OtherDerived, OnTheLeft, true>(m_permutation, matrix.derived());
|
705
|
+
}
|
706
|
+
|
707
|
+
const PermutationType& nestedPermutation() const { return m_permutation; }
|
708
|
+
|
709
|
+
protected:
|
710
|
+
const PermutationType& m_permutation;
|
711
|
+
};
|
712
|
+
|
713
|
+
template<typename Derived>
|
714
|
+
const PermutationWrapper<const Derived> MatrixBase<Derived>::asPermutation() const
|
715
|
+
{
|
716
|
+
return derived();
|
717
|
+
}
|
718
|
+
|
719
|
+
} // end namespace Eigen
|
720
|
+
|
721
|
+
#endif // EIGEN_PERMUTATIONMATRIX_H
|