ruby-eigen 0.0.9 → 0.0.10.pre1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE +22 -0
- data/README.md +21 -0
- data/ext/eigen/eigen3/COPYING.BSD +26 -0
- data/ext/eigen/eigen3/COPYING.MPL2 +373 -0
- data/ext/eigen/eigen3/COPYING.README +18 -0
- data/ext/eigen/eigen3/Eigen/Array +11 -0
- data/ext/eigen/eigen3/Eigen/Cholesky +32 -0
- data/ext/eigen/eigen3/Eigen/CholmodSupport +45 -0
- data/ext/eigen/eigen3/Eigen/Core +376 -0
- data/ext/eigen/eigen3/Eigen/Dense +7 -0
- data/ext/eigen/eigen3/Eigen/Eigen +2 -0
- data/ext/eigen/eigen3/Eigen/Eigen2Support +95 -0
- data/ext/eigen/eigen3/Eigen/Eigenvalues +48 -0
- data/ext/eigen/eigen3/Eigen/Geometry +63 -0
- data/ext/eigen/eigen3/Eigen/Householder +23 -0
- data/ext/eigen/eigen3/Eigen/IterativeLinearSolvers +40 -0
- data/ext/eigen/eigen3/Eigen/Jacobi +26 -0
- data/ext/eigen/eigen3/Eigen/LU +41 -0
- data/ext/eigen/eigen3/Eigen/LeastSquares +32 -0
- data/ext/eigen/eigen3/Eigen/MetisSupport +28 -0
- data/ext/eigen/eigen3/Eigen/PaStiXSupport +46 -0
- data/ext/eigen/eigen3/Eigen/PardisoSupport +30 -0
- data/ext/eigen/eigen3/Eigen/QR +45 -0
- data/ext/eigen/eigen3/Eigen/QtAlignedMalloc +34 -0
- data/ext/eigen/eigen3/Eigen/SPQRSupport +29 -0
- data/ext/eigen/eigen3/Eigen/SVD +37 -0
- data/ext/eigen/eigen3/Eigen/Sparse +27 -0
- data/ext/eigen/eigen3/Eigen/SparseCore +64 -0
- data/ext/eigen/eigen3/Eigen/SparseLU +49 -0
- data/ext/eigen/eigen3/Eigen/SparseQR +33 -0
- data/ext/eigen/eigen3/Eigen/StdDeque +27 -0
- data/ext/eigen/eigen3/Eigen/StdList +26 -0
- data/ext/eigen/eigen3/Eigen/StdVector +27 -0
- data/ext/eigen/eigen3/Eigen/SuperLUSupport +59 -0
- data/ext/eigen/eigen3/Eigen/UmfPackSupport +36 -0
- data/ext/eigen/eigen3/Eigen/src/Cholesky/LDLT.h +611 -0
- data/ext/eigen/eigen3/Eigen/src/Cholesky/LLT.h +498 -0
- data/ext/eigen/eigen3/Eigen/src/Cholesky/LLT_MKL.h +102 -0
- data/ext/eigen/eigen3/Eigen/src/CholmodSupport/CholmodSupport.h +607 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Array.h +323 -0
- data/ext/eigen/eigen3/Eigen/src/Core/ArrayBase.h +226 -0
- data/ext/eigen/eigen3/Eigen/src/Core/ArrayWrapper.h +264 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Assign.h +590 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Assign_MKL.h +224 -0
- data/ext/eigen/eigen3/Eigen/src/Core/BandMatrix.h +334 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Block.h +406 -0
- data/ext/eigen/eigen3/Eigen/src/Core/BooleanRedux.h +154 -0
- data/ext/eigen/eigen3/Eigen/src/Core/CommaInitializer.h +154 -0
- data/ext/eigen/eigen3/Eigen/src/Core/CoreIterators.h +61 -0
- data/ext/eigen/eigen3/Eigen/src/Core/CwiseBinaryOp.h +230 -0
- data/ext/eigen/eigen3/Eigen/src/Core/CwiseNullaryOp.h +864 -0
- data/ext/eigen/eigen3/Eigen/src/Core/CwiseUnaryOp.h +126 -0
- data/ext/eigen/eigen3/Eigen/src/Core/CwiseUnaryView.h +139 -0
- data/ext/eigen/eigen3/Eigen/src/Core/DenseBase.h +521 -0
- data/ext/eigen/eigen3/Eigen/src/Core/DenseCoeffsBase.h +754 -0
- data/ext/eigen/eigen3/Eigen/src/Core/DenseStorage.h +434 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Diagonal.h +237 -0
- data/ext/eigen/eigen3/Eigen/src/Core/DiagonalMatrix.h +313 -0
- data/ext/eigen/eigen3/Eigen/src/Core/DiagonalProduct.h +131 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Dot.h +263 -0
- data/ext/eigen/eigen3/Eigen/src/Core/EigenBase.h +131 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Flagged.h +140 -0
- data/ext/eigen/eigen3/Eigen/src/Core/ForceAlignedAccess.h +146 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Functors.h +1026 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Fuzzy.h +150 -0
- data/ext/eigen/eigen3/Eigen/src/Core/GeneralProduct.h +635 -0
- data/ext/eigen/eigen3/Eigen/src/Core/GenericPacketMath.h +350 -0
- data/ext/eigen/eigen3/Eigen/src/Core/GlobalFunctions.h +92 -0
- data/ext/eigen/eigen3/Eigen/src/Core/IO.h +250 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Map.h +192 -0
- data/ext/eigen/eigen3/Eigen/src/Core/MapBase.h +247 -0
- data/ext/eigen/eigen3/Eigen/src/Core/MathFunctions.h +768 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Matrix.h +420 -0
- data/ext/eigen/eigen3/Eigen/src/Core/MatrixBase.h +563 -0
- data/ext/eigen/eigen3/Eigen/src/Core/NestByValue.h +111 -0
- data/ext/eigen/eigen3/Eigen/src/Core/NoAlias.h +134 -0
- data/ext/eigen/eigen3/Eigen/src/Core/NumTraits.h +150 -0
- data/ext/eigen/eigen3/Eigen/src/Core/PermutationMatrix.h +721 -0
- data/ext/eigen/eigen3/Eigen/src/Core/PlainObjectBase.h +822 -0
- data/ext/eigen/eigen3/Eigen/src/Core/ProductBase.h +290 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Random.h +152 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Redux.h +409 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Ref.h +278 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Replicate.h +177 -0
- data/ext/eigen/eigen3/Eigen/src/Core/ReturnByValue.h +99 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Reverse.h +224 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Select.h +162 -0
- data/ext/eigen/eigen3/Eigen/src/Core/SelfAdjointView.h +314 -0
- data/ext/eigen/eigen3/Eigen/src/Core/SelfCwiseBinaryOp.h +191 -0
- data/ext/eigen/eigen3/Eigen/src/Core/SolveTriangular.h +260 -0
- data/ext/eigen/eigen3/Eigen/src/Core/StableNorm.h +203 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Stride.h +108 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Swap.h +126 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Transpose.h +419 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Transpositions.h +436 -0
- data/ext/eigen/eigen3/Eigen/src/Core/TriangularMatrix.h +839 -0
- data/ext/eigen/eigen3/Eigen/src/Core/VectorBlock.h +95 -0
- data/ext/eigen/eigen3/Eigen/src/Core/VectorwiseOp.h +642 -0
- data/ext/eigen/eigen3/Eigen/src/Core/Visitor.h +237 -0
- data/ext/eigen/eigen3/Eigen/src/Core/arch/AltiVec/Complex.h +217 -0
- data/ext/eigen/eigen3/Eigen/src/Core/arch/AltiVec/PacketMath.h +501 -0
- data/ext/eigen/eigen3/Eigen/src/Core/arch/Default/Settings.h +49 -0
- data/ext/eigen/eigen3/Eigen/src/Core/arch/NEON/Complex.h +253 -0
- data/ext/eigen/eigen3/Eigen/src/Core/arch/NEON/PacketMath.h +420 -0
- data/ext/eigen/eigen3/Eigen/src/Core/arch/SSE/Complex.h +442 -0
- data/ext/eigen/eigen3/Eigen/src/Core/arch/SSE/MathFunctions.h +475 -0
- data/ext/eigen/eigen3/Eigen/src/Core/arch/SSE/PacketMath.h +649 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/CoeffBasedProduct.h +476 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/GeneralBlockPanelKernel.h +1341 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/GeneralMatrixMatrix.h +427 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/GeneralMatrixMatrixTriangular.h +278 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/GeneralMatrixMatrixTriangular_MKL.h +146 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/GeneralMatrixMatrix_MKL.h +118 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/GeneralMatrixVector.h +566 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/GeneralMatrixVector_MKL.h +131 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/Parallelizer.h +162 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/SelfadjointMatrixMatrix.h +436 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/SelfadjointMatrixMatrix_MKL.h +295 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/SelfadjointMatrixVector.h +281 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/SelfadjointMatrixVector_MKL.h +114 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/SelfadjointProduct.h +123 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/SelfadjointRank2Update.h +93 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/TriangularMatrixMatrix.h +427 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/TriangularMatrixMatrix_MKL.h +309 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/TriangularMatrixVector.h +348 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/TriangularMatrixVector_MKL.h +247 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/TriangularSolverMatrix.h +332 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/TriangularSolverMatrix_MKL.h +155 -0
- data/ext/eigen/eigen3/Eigen/src/Core/products/TriangularSolverVector.h +139 -0
- data/ext/eigen/eigen3/Eigen/src/Core/util/BlasUtil.h +264 -0
- data/ext/eigen/eigen3/Eigen/src/Core/util/Constants.h +451 -0
- data/ext/eigen/eigen3/Eigen/src/Core/util/DisableStupidWarnings.h +40 -0
- data/ext/eigen/eigen3/Eigen/src/Core/util/ForwardDeclarations.h +302 -0
- data/ext/eigen/eigen3/Eigen/src/Core/util/MKL_support.h +158 -0
- data/ext/eigen/eigen3/Eigen/src/Core/util/Macros.h +451 -0
- data/ext/eigen/eigen3/Eigen/src/Core/util/Memory.h +977 -0
- data/ext/eigen/eigen3/Eigen/src/Core/util/Meta.h +243 -0
- data/ext/eigen/eigen3/Eigen/src/Core/util/NonMPL2.h +3 -0
- data/ext/eigen/eigen3/Eigen/src/Core/util/ReenableStupidWarnings.h +14 -0
- data/ext/eigen/eigen3/Eigen/src/Core/util/StaticAssert.h +208 -0
- data/ext/eigen/eigen3/Eigen/src/Core/util/XprHelper.h +469 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Block.h +126 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Cwise.h +192 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/CwiseOperators.h +298 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/AlignedBox.h +159 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/All.h +115 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/AngleAxis.h +214 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/Hyperplane.h +254 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/ParametrizedLine.h +141 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/Quaternion.h +495 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/Rotation2D.h +145 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/RotationBase.h +123 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/Scaling.h +167 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/Transform.h +786 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/Translation.h +184 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/LU.h +120 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Lazy.h +71 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/LeastSquares.h +169 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Macros.h +20 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/MathFunctions.h +57 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Memory.h +45 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Meta.h +75 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Minor.h +117 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/QR.h +67 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/SVD.h +637 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/TriangularSolver.h +42 -0
- data/ext/eigen/eigen3/Eigen/src/Eigen2Support/VectorBlock.h +94 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/ComplexEigenSolver.h +341 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/ComplexSchur.h +456 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/ComplexSchur_MKL.h +94 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/EigenSolver.h +607 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/GeneralizedEigenSolver.h +350 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h +227 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/HessenbergDecomposition.h +373 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/MatrixBaseEigenvalues.h +160 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/RealQZ.h +624 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/RealSchur.h +525 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/RealSchur_MKL.h +83 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h +801 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/SelfAdjointEigenSolver_MKL.h +92 -0
- data/ext/eigen/eigen3/Eigen/src/Eigenvalues/Tridiagonalization.h +557 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/AlignedBox.h +392 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/AngleAxis.h +233 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/EulerAngles.h +104 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/Homogeneous.h +307 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/Hyperplane.h +280 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/OrthoMethods.h +218 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/ParametrizedLine.h +195 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/Quaternion.h +776 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/Rotation2D.h +160 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/RotationBase.h +206 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/Scaling.h +166 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/Transform.h +1455 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/Translation.h +206 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/Umeyama.h +177 -0
- data/ext/eigen/eigen3/Eigen/src/Geometry/arch/Geometry_SSE.h +115 -0
- data/ext/eigen/eigen3/Eigen/src/Householder/BlockHouseholder.h +68 -0
- data/ext/eigen/eigen3/Eigen/src/Householder/Householder.h +171 -0
- data/ext/eigen/eigen3/Eigen/src/Householder/HouseholderSequence.h +441 -0
- data/ext/eigen/eigen3/Eigen/src/IterativeLinearSolvers/BasicPreconditioners.h +149 -0
- data/ext/eigen/eigen3/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h +263 -0
- data/ext/eigen/eigen3/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h +256 -0
- data/ext/eigen/eigen3/Eigen/src/IterativeLinearSolvers/IterativeSolverBase.h +282 -0
- data/ext/eigen/eigen3/Eigen/src/Jacobi/Jacobi.h +433 -0
- data/ext/eigen/eigen3/Eigen/src/LU/Determinant.h +101 -0
- data/ext/eigen/eigen3/Eigen/src/LU/FullPivLU.h +751 -0
- data/ext/eigen/eigen3/Eigen/src/LU/Inverse.h +400 -0
- data/ext/eigen/eigen3/Eigen/src/LU/PartialPivLU.h +509 -0
- data/ext/eigen/eigen3/Eigen/src/LU/PartialPivLU_MKL.h +85 -0
- data/ext/eigen/eigen3/Eigen/src/LU/arch/Inverse_SSE.h +329 -0
- data/ext/eigen/eigen3/Eigen/src/MetisSupport/MetisSupport.h +137 -0
- data/ext/eigen/eigen3/Eigen/src/OrderingMethods/Amd.h +444 -0
- data/ext/eigen/eigen3/Eigen/src/OrderingMethods/Eigen_Colamd.h +1850 -0
- data/ext/eigen/eigen3/Eigen/src/PaStiXSupport/PaStiXSupport.h +721 -0
- data/ext/eigen/eigen3/Eigen/src/PardisoSupport/PardisoSupport.h +592 -0
- data/ext/eigen/eigen3/Eigen/src/QR/ColPivHouseholderQR.h +580 -0
- data/ext/eigen/eigen3/Eigen/src/QR/ColPivHouseholderQR_MKL.h +99 -0
- data/ext/eigen/eigen3/Eigen/src/QR/FullPivHouseholderQR.h +622 -0
- data/ext/eigen/eigen3/Eigen/src/QR/HouseholderQR.h +388 -0
- data/ext/eigen/eigen3/Eigen/src/QR/HouseholderQR_MKL.h +71 -0
- data/ext/eigen/eigen3/Eigen/src/SPQRSupport/SuiteSparseQRSupport.h +338 -0
- data/ext/eigen/eigen3/Eigen/src/SVD/JacobiSVD.h +976 -0
- data/ext/eigen/eigen3/Eigen/src/SVD/JacobiSVD_MKL.h +92 -0
- data/ext/eigen/eigen3/Eigen/src/SVD/UpperBidiagonalization.h +148 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCholesky/SimplicialCholesky.h +671 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h +199 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/AmbiVector.h +373 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/CompressedStorage.h +233 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/ConservativeSparseSparseProduct.h +245 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/MappedSparseMatrix.h +181 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseBlock.h +537 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseColEtree.h +206 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseCwiseBinaryOp.h +325 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseCwiseUnaryOp.h +163 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseDenseProduct.h +311 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseDiagonalProduct.h +196 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseDot.h +101 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseFuzzy.h +26 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseMatrix.h +1262 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseMatrixBase.h +461 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparsePermutation.h +148 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseProduct.h +188 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseRedux.h +45 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseSelfAdjointView.h +507 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseSparseProductWithPruning.h +150 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseTranspose.h +63 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseTriangularView.h +179 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseUtil.h +172 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseVector.h +448 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseView.h +99 -0
- data/ext/eigen/eigen3/Eigen/src/SparseCore/TriangularSolver.h +334 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU.h +806 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLUImpl.h +66 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_Memory.h +227 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_Structs.h +111 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_SupernodalMatrix.h +298 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_Utils.h +80 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_column_bmod.h +180 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_column_dfs.h +177 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_copy_to_ucol.h +106 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_gemm_kernel.h +279 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_heap_relax_snode.h +127 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_kernel_bmod.h +130 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_panel_bmod.h +223 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_panel_dfs.h +258 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_pivotL.h +137 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_pruneL.h +135 -0
- data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_relax_snode.h +83 -0
- data/ext/eigen/eigen3/Eigen/src/SparseQR/SparseQR.h +714 -0
- data/ext/eigen/eigen3/Eigen/src/StlSupport/StdDeque.h +134 -0
- data/ext/eigen/eigen3/Eigen/src/StlSupport/StdList.h +114 -0
- data/ext/eigen/eigen3/Eigen/src/StlSupport/StdVector.h +126 -0
- data/ext/eigen/eigen3/Eigen/src/StlSupport/details.h +84 -0
- data/ext/eigen/eigen3/Eigen/src/SuperLUSupport/SuperLUSupport.h +1026 -0
- data/ext/eigen/eigen3/Eigen/src/UmfPackSupport/UmfPackSupport.h +474 -0
- data/ext/eigen/eigen3/Eigen/src/misc/Image.h +84 -0
- data/ext/eigen/eigen3/Eigen/src/misc/Kernel.h +81 -0
- data/ext/eigen/eigen3/Eigen/src/misc/Solve.h +76 -0
- data/ext/eigen/eigen3/Eigen/src/misc/SparseSolve.h +128 -0
- data/ext/eigen/eigen3/Eigen/src/misc/blas.h +658 -0
- data/ext/eigen/eigen3/Eigen/src/plugins/ArrayCwiseBinaryOps.h +253 -0
- data/ext/eigen/eigen3/Eigen/src/plugins/ArrayCwiseUnaryOps.h +187 -0
- data/ext/eigen/eigen3/Eigen/src/plugins/BlockMethods.h +935 -0
- data/ext/eigen/eigen3/Eigen/src/plugins/CommonCwiseBinaryOps.h +46 -0
- data/ext/eigen/eigen3/Eigen/src/plugins/CommonCwiseUnaryOps.h +172 -0
- data/ext/eigen/eigen3/Eigen/src/plugins/MatrixCwiseBinaryOps.h +143 -0
- data/ext/eigen/eigen3/Eigen/src/plugins/MatrixCwiseUnaryOps.h +52 -0
- data/ext/eigen/eigen3/signature_of_eigen3_matrix_library +1 -0
- data/ext/eigen/eigen_wrap.cxx +19420 -10396
- data/ext/eigen/extconf.rb +37 -2
- data/lib/eigen.rb +146 -3
- metadata +294 -7
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
// This file is part of Eigen, a lightweight C++ template library
|
|
2
|
+
// for linear algebra.
|
|
3
|
+
//
|
|
4
|
+
// Copyright (C) 2010-2011 Gael Guennebaud <gael.guennebaud@inria.fr>
|
|
5
|
+
//
|
|
6
|
+
// This Source Code Form is subject to the terms of the Mozilla
|
|
7
|
+
// Public License v. 2.0. If a copy of the MPL was not distributed
|
|
8
|
+
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
9
|
+
|
|
10
|
+
#ifndef EIGEN_TRANSPOSITIONS_H
|
|
11
|
+
#define EIGEN_TRANSPOSITIONS_H
|
|
12
|
+
|
|
13
|
+
namespace Eigen {
|
|
14
|
+
|
|
15
|
+
/** \class Transpositions
|
|
16
|
+
* \ingroup Core_Module
|
|
17
|
+
*
|
|
18
|
+
* \brief Represents a sequence of transpositions (row/column interchange)
|
|
19
|
+
*
|
|
20
|
+
* \param SizeAtCompileTime the number of transpositions, or Dynamic
|
|
21
|
+
* \param MaxSizeAtCompileTime the maximum number of transpositions, or Dynamic. This optional parameter defaults to SizeAtCompileTime. Most of the time, you should not have to specify it.
|
|
22
|
+
*
|
|
23
|
+
* This class represents a permutation transformation as a sequence of \em n transpositions
|
|
24
|
+
* \f$[T_{n-1} \ldots T_{i} \ldots T_{0}]\f$. It is internally stored as a vector of integers \c indices.
|
|
25
|
+
* Each transposition \f$ T_{i} \f$ applied on the left of a matrix (\f$ T_{i} M\f$) interchanges
|
|
26
|
+
* the rows \c i and \c indices[i] of the matrix \c M.
|
|
27
|
+
* A transposition applied on the right (e.g., \f$ M T_{i}\f$) yields a column interchange.
|
|
28
|
+
*
|
|
29
|
+
* Compared to the class PermutationMatrix, such a sequence of transpositions is what is
|
|
30
|
+
* computed during a decomposition with pivoting, and it is faster when applying the permutation in-place.
|
|
31
|
+
*
|
|
32
|
+
* To apply a sequence of transpositions to a matrix, simply use the operator * as in the following example:
|
|
33
|
+
* \code
|
|
34
|
+
* Transpositions tr;
|
|
35
|
+
* MatrixXf mat;
|
|
36
|
+
* mat = tr * mat;
|
|
37
|
+
* \endcode
|
|
38
|
+
* In this example, we detect that the matrix appears on both side, and so the transpositions
|
|
39
|
+
* are applied in-place without any temporary or extra copy.
|
|
40
|
+
*
|
|
41
|
+
* \sa class PermutationMatrix
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
namespace internal {
|
|
45
|
+
template<typename TranspositionType, typename MatrixType, int Side, bool Transposed=false> struct transposition_matrix_product_retval;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
template<typename Derived>
|
|
49
|
+
class TranspositionsBase
|
|
50
|
+
{
|
|
51
|
+
typedef internal::traits<Derived> Traits;
|
|
52
|
+
|
|
53
|
+
public:
|
|
54
|
+
|
|
55
|
+
typedef typename Traits::IndicesType IndicesType;
|
|
56
|
+
typedef typename IndicesType::Scalar Index;
|
|
57
|
+
|
|
58
|
+
Derived& derived() { return *static_cast<Derived*>(this); }
|
|
59
|
+
const Derived& derived() const { return *static_cast<const Derived*>(this); }
|
|
60
|
+
|
|
61
|
+
/** Copies the \a other transpositions into \c *this */
|
|
62
|
+
template<typename OtherDerived>
|
|
63
|
+
Derived& operator=(const TranspositionsBase<OtherDerived>& other)
|
|
64
|
+
{
|
|
65
|
+
indices() = other.indices();
|
|
66
|
+
return derived();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
|
70
|
+
/** This is a special case of the templated operator=. Its purpose is to
|
|
71
|
+
* prevent a default operator= from hiding the templated operator=.
|
|
72
|
+
*/
|
|
73
|
+
Derived& operator=(const TranspositionsBase& other)
|
|
74
|
+
{
|
|
75
|
+
indices() = other.indices();
|
|
76
|
+
return derived();
|
|
77
|
+
}
|
|
78
|
+
#endif
|
|
79
|
+
|
|
80
|
+
/** \returns the number of transpositions */
|
|
81
|
+
inline Index size() const { return indices().size(); }
|
|
82
|
+
|
|
83
|
+
/** Direct access to the underlying index vector */
|
|
84
|
+
inline const Index& coeff(Index i) const { return indices().coeff(i); }
|
|
85
|
+
/** Direct access to the underlying index vector */
|
|
86
|
+
inline Index& coeffRef(Index i) { return indices().coeffRef(i); }
|
|
87
|
+
/** Direct access to the underlying index vector */
|
|
88
|
+
inline const Index& operator()(Index i) const { return indices()(i); }
|
|
89
|
+
/** Direct access to the underlying index vector */
|
|
90
|
+
inline Index& operator()(Index i) { return indices()(i); }
|
|
91
|
+
/** Direct access to the underlying index vector */
|
|
92
|
+
inline const Index& operator[](Index i) const { return indices()(i); }
|
|
93
|
+
/** Direct access to the underlying index vector */
|
|
94
|
+
inline Index& operator[](Index i) { return indices()(i); }
|
|
95
|
+
|
|
96
|
+
/** const version of indices(). */
|
|
97
|
+
const IndicesType& indices() const { return derived().indices(); }
|
|
98
|
+
/** \returns a reference to the stored array representing the transpositions. */
|
|
99
|
+
IndicesType& indices() { return derived().indices(); }
|
|
100
|
+
|
|
101
|
+
/** Resizes to given size. */
|
|
102
|
+
inline void resize(int newSize)
|
|
103
|
+
{
|
|
104
|
+
indices().resize(newSize);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** Sets \c *this to represents an identity transformation */
|
|
108
|
+
void setIdentity()
|
|
109
|
+
{
|
|
110
|
+
for(int i = 0; i < indices().size(); ++i)
|
|
111
|
+
coeffRef(i) = i;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// FIXME: do we want such methods ?
|
|
115
|
+
// might be usefull when the target matrix expression is complex, e.g.:
|
|
116
|
+
// object.matrix().block(..,..,..,..) = trans * object.matrix().block(..,..,..,..);
|
|
117
|
+
/*
|
|
118
|
+
template<typename MatrixType>
|
|
119
|
+
void applyForwardToRows(MatrixType& mat) const
|
|
120
|
+
{
|
|
121
|
+
for(Index k=0 ; k<size() ; ++k)
|
|
122
|
+
if(m_indices(k)!=k)
|
|
123
|
+
mat.row(k).swap(mat.row(m_indices(k)));
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
template<typename MatrixType>
|
|
127
|
+
void applyBackwardToRows(MatrixType& mat) const
|
|
128
|
+
{
|
|
129
|
+
for(Index k=size()-1 ; k>=0 ; --k)
|
|
130
|
+
if(m_indices(k)!=k)
|
|
131
|
+
mat.row(k).swap(mat.row(m_indices(k)));
|
|
132
|
+
}
|
|
133
|
+
*/
|
|
134
|
+
|
|
135
|
+
/** \returns the inverse transformation */
|
|
136
|
+
inline Transpose<TranspositionsBase> inverse() const
|
|
137
|
+
{ return Transpose<TranspositionsBase>(derived()); }
|
|
138
|
+
|
|
139
|
+
/** \returns the tranpose transformation */
|
|
140
|
+
inline Transpose<TranspositionsBase> transpose() const
|
|
141
|
+
{ return Transpose<TranspositionsBase>(derived()); }
|
|
142
|
+
|
|
143
|
+
protected:
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
namespace internal {
|
|
147
|
+
template<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename IndexType>
|
|
148
|
+
struct traits<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,IndexType> >
|
|
149
|
+
{
|
|
150
|
+
typedef IndexType Index;
|
|
151
|
+
typedef Matrix<Index, SizeAtCompileTime, 1, 0, MaxSizeAtCompileTime, 1> IndicesType;
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
template<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename IndexType>
|
|
156
|
+
class Transpositions : public TranspositionsBase<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,IndexType> >
|
|
157
|
+
{
|
|
158
|
+
typedef internal::traits<Transpositions> Traits;
|
|
159
|
+
public:
|
|
160
|
+
|
|
161
|
+
typedef TranspositionsBase<Transpositions> Base;
|
|
162
|
+
typedef typename Traits::IndicesType IndicesType;
|
|
163
|
+
typedef typename IndicesType::Scalar Index;
|
|
164
|
+
|
|
165
|
+
inline Transpositions() {}
|
|
166
|
+
|
|
167
|
+
/** Copy constructor. */
|
|
168
|
+
template<typename OtherDerived>
|
|
169
|
+
inline Transpositions(const TranspositionsBase<OtherDerived>& other)
|
|
170
|
+
: m_indices(other.indices()) {}
|
|
171
|
+
|
|
172
|
+
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
|
173
|
+
/** Standard copy constructor. Defined only to prevent a default copy constructor
|
|
174
|
+
* from hiding the other templated constructor */
|
|
175
|
+
inline Transpositions(const Transpositions& other) : m_indices(other.indices()) {}
|
|
176
|
+
#endif
|
|
177
|
+
|
|
178
|
+
/** Generic constructor from expression of the transposition indices. */
|
|
179
|
+
template<typename Other>
|
|
180
|
+
explicit inline Transpositions(const MatrixBase<Other>& a_indices) : m_indices(a_indices)
|
|
181
|
+
{}
|
|
182
|
+
|
|
183
|
+
/** Copies the \a other transpositions into \c *this */
|
|
184
|
+
template<typename OtherDerived>
|
|
185
|
+
Transpositions& operator=(const TranspositionsBase<OtherDerived>& other)
|
|
186
|
+
{
|
|
187
|
+
return Base::operator=(other);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
|
191
|
+
/** This is a special case of the templated operator=. Its purpose is to
|
|
192
|
+
* prevent a default operator= from hiding the templated operator=.
|
|
193
|
+
*/
|
|
194
|
+
Transpositions& operator=(const Transpositions& other)
|
|
195
|
+
{
|
|
196
|
+
m_indices = other.m_indices;
|
|
197
|
+
return *this;
|
|
198
|
+
}
|
|
199
|
+
#endif
|
|
200
|
+
|
|
201
|
+
/** Constructs an uninitialized permutation matrix of given size.
|
|
202
|
+
*/
|
|
203
|
+
inline Transpositions(Index size) : m_indices(size)
|
|
204
|
+
{}
|
|
205
|
+
|
|
206
|
+
/** const version of indices(). */
|
|
207
|
+
const IndicesType& indices() const { return m_indices; }
|
|
208
|
+
/** \returns a reference to the stored array representing the transpositions. */
|
|
209
|
+
IndicesType& indices() { return m_indices; }
|
|
210
|
+
|
|
211
|
+
protected:
|
|
212
|
+
|
|
213
|
+
IndicesType m_indices;
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
namespace internal {
|
|
218
|
+
template<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename IndexType, int _PacketAccess>
|
|
219
|
+
struct traits<Map<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,IndexType>,_PacketAccess> >
|
|
220
|
+
{
|
|
221
|
+
typedef IndexType Index;
|
|
222
|
+
typedef Map<const Matrix<Index,SizeAtCompileTime,1,0,MaxSizeAtCompileTime,1>, _PacketAccess> IndicesType;
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
template<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename IndexType, int PacketAccess>
|
|
227
|
+
class Map<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,IndexType>,PacketAccess>
|
|
228
|
+
: public TranspositionsBase<Map<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,IndexType>,PacketAccess> >
|
|
229
|
+
{
|
|
230
|
+
typedef internal::traits<Map> Traits;
|
|
231
|
+
public:
|
|
232
|
+
|
|
233
|
+
typedef TranspositionsBase<Map> Base;
|
|
234
|
+
typedef typename Traits::IndicesType IndicesType;
|
|
235
|
+
typedef typename IndicesType::Scalar Index;
|
|
236
|
+
|
|
237
|
+
inline Map(const Index* indicesPtr)
|
|
238
|
+
: m_indices(indicesPtr)
|
|
239
|
+
{}
|
|
240
|
+
|
|
241
|
+
inline Map(const Index* indicesPtr, Index size)
|
|
242
|
+
: m_indices(indicesPtr,size)
|
|
243
|
+
{}
|
|
244
|
+
|
|
245
|
+
/** Copies the \a other transpositions into \c *this */
|
|
246
|
+
template<typename OtherDerived>
|
|
247
|
+
Map& operator=(const TranspositionsBase<OtherDerived>& other)
|
|
248
|
+
{
|
|
249
|
+
return Base::operator=(other);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
|
253
|
+
/** This is a special case of the templated operator=. Its purpose is to
|
|
254
|
+
* prevent a default operator= from hiding the templated operator=.
|
|
255
|
+
*/
|
|
256
|
+
Map& operator=(const Map& other)
|
|
257
|
+
{
|
|
258
|
+
m_indices = other.m_indices;
|
|
259
|
+
return *this;
|
|
260
|
+
}
|
|
261
|
+
#endif
|
|
262
|
+
|
|
263
|
+
/** const version of indices(). */
|
|
264
|
+
const IndicesType& indices() const { return m_indices; }
|
|
265
|
+
|
|
266
|
+
/** \returns a reference to the stored array representing the transpositions. */
|
|
267
|
+
IndicesType& indices() { return m_indices; }
|
|
268
|
+
|
|
269
|
+
protected:
|
|
270
|
+
|
|
271
|
+
IndicesType m_indices;
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
namespace internal {
|
|
275
|
+
template<typename _IndicesType>
|
|
276
|
+
struct traits<TranspositionsWrapper<_IndicesType> >
|
|
277
|
+
{
|
|
278
|
+
typedef typename _IndicesType::Scalar Index;
|
|
279
|
+
typedef _IndicesType IndicesType;
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
template<typename _IndicesType>
|
|
284
|
+
class TranspositionsWrapper
|
|
285
|
+
: public TranspositionsBase<TranspositionsWrapper<_IndicesType> >
|
|
286
|
+
{
|
|
287
|
+
typedef internal::traits<TranspositionsWrapper> Traits;
|
|
288
|
+
public:
|
|
289
|
+
|
|
290
|
+
typedef TranspositionsBase<TranspositionsWrapper> Base;
|
|
291
|
+
typedef typename Traits::IndicesType IndicesType;
|
|
292
|
+
typedef typename IndicesType::Scalar Index;
|
|
293
|
+
|
|
294
|
+
inline TranspositionsWrapper(IndicesType& a_indices)
|
|
295
|
+
: m_indices(a_indices)
|
|
296
|
+
{}
|
|
297
|
+
|
|
298
|
+
/** Copies the \a other transpositions into \c *this */
|
|
299
|
+
template<typename OtherDerived>
|
|
300
|
+
TranspositionsWrapper& operator=(const TranspositionsBase<OtherDerived>& other)
|
|
301
|
+
{
|
|
302
|
+
return Base::operator=(other);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
|
306
|
+
/** This is a special case of the templated operator=. Its purpose is to
|
|
307
|
+
* prevent a default operator= from hiding the templated operator=.
|
|
308
|
+
*/
|
|
309
|
+
TranspositionsWrapper& operator=(const TranspositionsWrapper& other)
|
|
310
|
+
{
|
|
311
|
+
m_indices = other.m_indices;
|
|
312
|
+
return *this;
|
|
313
|
+
}
|
|
314
|
+
#endif
|
|
315
|
+
|
|
316
|
+
/** const version of indices(). */
|
|
317
|
+
const IndicesType& indices() const { return m_indices; }
|
|
318
|
+
|
|
319
|
+
/** \returns a reference to the stored array representing the transpositions. */
|
|
320
|
+
IndicesType& indices() { return m_indices; }
|
|
321
|
+
|
|
322
|
+
protected:
|
|
323
|
+
|
|
324
|
+
const typename IndicesType::Nested m_indices;
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
/** \returns the \a matrix with the \a transpositions applied to the columns.
|
|
328
|
+
*/
|
|
329
|
+
template<typename Derived, typename TranspositionsDerived>
|
|
330
|
+
inline const internal::transposition_matrix_product_retval<TranspositionsDerived, Derived, OnTheRight>
|
|
331
|
+
operator*(const MatrixBase<Derived>& matrix,
|
|
332
|
+
const TranspositionsBase<TranspositionsDerived> &transpositions)
|
|
333
|
+
{
|
|
334
|
+
return internal::transposition_matrix_product_retval
|
|
335
|
+
<TranspositionsDerived, Derived, OnTheRight>
|
|
336
|
+
(transpositions.derived(), matrix.derived());
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/** \returns the \a matrix with the \a transpositions applied to the rows.
|
|
340
|
+
*/
|
|
341
|
+
template<typename Derived, typename TranspositionDerived>
|
|
342
|
+
inline const internal::transposition_matrix_product_retval
|
|
343
|
+
<TranspositionDerived, Derived, OnTheLeft>
|
|
344
|
+
operator*(const TranspositionsBase<TranspositionDerived> &transpositions,
|
|
345
|
+
const MatrixBase<Derived>& matrix)
|
|
346
|
+
{
|
|
347
|
+
return internal::transposition_matrix_product_retval
|
|
348
|
+
<TranspositionDerived, Derived, OnTheLeft>
|
|
349
|
+
(transpositions.derived(), matrix.derived());
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
namespace internal {
|
|
353
|
+
|
|
354
|
+
template<typename TranspositionType, typename MatrixType, int Side, bool Transposed>
|
|
355
|
+
struct traits<transposition_matrix_product_retval<TranspositionType, MatrixType, Side, Transposed> >
|
|
356
|
+
{
|
|
357
|
+
typedef typename MatrixType::PlainObject ReturnType;
|
|
358
|
+
};
|
|
359
|
+
|
|
360
|
+
template<typename TranspositionType, typename MatrixType, int Side, bool Transposed>
|
|
361
|
+
struct transposition_matrix_product_retval
|
|
362
|
+
: public ReturnByValue<transposition_matrix_product_retval<TranspositionType, MatrixType, Side, Transposed> >
|
|
363
|
+
{
|
|
364
|
+
typedef typename remove_all<typename MatrixType::Nested>::type MatrixTypeNestedCleaned;
|
|
365
|
+
typedef typename TranspositionType::Index Index;
|
|
366
|
+
|
|
367
|
+
transposition_matrix_product_retval(const TranspositionType& tr, const MatrixType& matrix)
|
|
368
|
+
: m_transpositions(tr), m_matrix(matrix)
|
|
369
|
+
{}
|
|
370
|
+
|
|
371
|
+
inline int rows() const { return m_matrix.rows(); }
|
|
372
|
+
inline int cols() const { return m_matrix.cols(); }
|
|
373
|
+
|
|
374
|
+
template<typename Dest> inline void evalTo(Dest& dst) const
|
|
375
|
+
{
|
|
376
|
+
const int size = m_transpositions.size();
|
|
377
|
+
Index j = 0;
|
|
378
|
+
|
|
379
|
+
if(!(is_same<MatrixTypeNestedCleaned,Dest>::value && extract_data(dst) == extract_data(m_matrix)))
|
|
380
|
+
dst = m_matrix;
|
|
381
|
+
|
|
382
|
+
for(int k=(Transposed?size-1:0) ; Transposed?k>=0:k<size ; Transposed?--k:++k)
|
|
383
|
+
if((j=m_transpositions.coeff(k))!=k)
|
|
384
|
+
{
|
|
385
|
+
if(Side==OnTheLeft)
|
|
386
|
+
dst.row(k).swap(dst.row(j));
|
|
387
|
+
else if(Side==OnTheRight)
|
|
388
|
+
dst.col(k).swap(dst.col(j));
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
protected:
|
|
393
|
+
const TranspositionType& m_transpositions;
|
|
394
|
+
typename MatrixType::Nested m_matrix;
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
} // end namespace internal
|
|
398
|
+
|
|
399
|
+
/* Template partial specialization for transposed/inverse transpositions */
|
|
400
|
+
|
|
401
|
+
template<typename TranspositionsDerived>
|
|
402
|
+
class Transpose<TranspositionsBase<TranspositionsDerived> >
|
|
403
|
+
{
|
|
404
|
+
typedef TranspositionsDerived TranspositionType;
|
|
405
|
+
typedef typename TranspositionType::IndicesType IndicesType;
|
|
406
|
+
public:
|
|
407
|
+
|
|
408
|
+
Transpose(const TranspositionType& t) : m_transpositions(t) {}
|
|
409
|
+
|
|
410
|
+
inline int size() const { return m_transpositions.size(); }
|
|
411
|
+
|
|
412
|
+
/** \returns the \a matrix with the inverse transpositions applied to the columns.
|
|
413
|
+
*/
|
|
414
|
+
template<typename Derived> friend
|
|
415
|
+
inline const internal::transposition_matrix_product_retval<TranspositionType, Derived, OnTheRight, true>
|
|
416
|
+
operator*(const MatrixBase<Derived>& matrix, const Transpose& trt)
|
|
417
|
+
{
|
|
418
|
+
return internal::transposition_matrix_product_retval<TranspositionType, Derived, OnTheRight, true>(trt.m_transpositions, matrix.derived());
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
/** \returns the \a matrix with the inverse transpositions applied to the rows.
|
|
422
|
+
*/
|
|
423
|
+
template<typename Derived>
|
|
424
|
+
inline const internal::transposition_matrix_product_retval<TranspositionType, Derived, OnTheLeft, true>
|
|
425
|
+
operator*(const MatrixBase<Derived>& matrix) const
|
|
426
|
+
{
|
|
427
|
+
return internal::transposition_matrix_product_retval<TranspositionType, Derived, OnTheLeft, true>(m_transpositions, matrix.derived());
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
protected:
|
|
431
|
+
const TranspositionType& m_transpositions;
|
|
432
|
+
};
|
|
433
|
+
|
|
434
|
+
} // end namespace Eigen
|
|
435
|
+
|
|
436
|
+
#endif // EIGEN_TRANSPOSITIONS_H
|
|
@@ -0,0 +1,839 @@
|
|
|
1
|
+
// This file is part of Eigen, a lightweight C++ template library
|
|
2
|
+
// for linear algebra.
|
|
3
|
+
//
|
|
4
|
+
// Copyright (C) 2008 Benoit Jacob <jacob.benoit.1@gmail.com>
|
|
5
|
+
// Copyright (C) 2008-2009 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_TRIANGULARMATRIX_H
|
|
12
|
+
#define EIGEN_TRIANGULARMATRIX_H
|
|
13
|
+
|
|
14
|
+
namespace Eigen {
|
|
15
|
+
|
|
16
|
+
namespace internal {
|
|
17
|
+
|
|
18
|
+
template<int Side, typename TriangularType, typename Rhs> struct triangular_solve_retval;
|
|
19
|
+
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** \internal
|
|
23
|
+
*
|
|
24
|
+
* \class TriangularBase
|
|
25
|
+
* \ingroup Core_Module
|
|
26
|
+
*
|
|
27
|
+
* \brief Base class for triangular part in a matrix
|
|
28
|
+
*/
|
|
29
|
+
template<typename Derived> class TriangularBase : public EigenBase<Derived>
|
|
30
|
+
{
|
|
31
|
+
public:
|
|
32
|
+
|
|
33
|
+
enum {
|
|
34
|
+
Mode = internal::traits<Derived>::Mode,
|
|
35
|
+
CoeffReadCost = internal::traits<Derived>::CoeffReadCost,
|
|
36
|
+
RowsAtCompileTime = internal::traits<Derived>::RowsAtCompileTime,
|
|
37
|
+
ColsAtCompileTime = internal::traits<Derived>::ColsAtCompileTime,
|
|
38
|
+
MaxRowsAtCompileTime = internal::traits<Derived>::MaxRowsAtCompileTime,
|
|
39
|
+
MaxColsAtCompileTime = internal::traits<Derived>::MaxColsAtCompileTime
|
|
40
|
+
};
|
|
41
|
+
typedef typename internal::traits<Derived>::Scalar Scalar;
|
|
42
|
+
typedef typename internal::traits<Derived>::StorageKind StorageKind;
|
|
43
|
+
typedef typename internal::traits<Derived>::Index Index;
|
|
44
|
+
typedef typename internal::traits<Derived>::DenseMatrixType DenseMatrixType;
|
|
45
|
+
typedef DenseMatrixType DenseType;
|
|
46
|
+
|
|
47
|
+
inline TriangularBase() { eigen_assert(!((Mode&UnitDiag) && (Mode&ZeroDiag))); }
|
|
48
|
+
|
|
49
|
+
inline Index rows() const { return derived().rows(); }
|
|
50
|
+
inline Index cols() const { return derived().cols(); }
|
|
51
|
+
inline Index outerStride() const { return derived().outerStride(); }
|
|
52
|
+
inline Index innerStride() const { return derived().innerStride(); }
|
|
53
|
+
|
|
54
|
+
inline Scalar coeff(Index row, Index col) const { return derived().coeff(row,col); }
|
|
55
|
+
inline Scalar& coeffRef(Index row, Index col) { return derived().coeffRef(row,col); }
|
|
56
|
+
|
|
57
|
+
/** \see MatrixBase::copyCoeff(row,col)
|
|
58
|
+
*/
|
|
59
|
+
template<typename Other>
|
|
60
|
+
EIGEN_STRONG_INLINE void copyCoeff(Index row, Index col, Other& other)
|
|
61
|
+
{
|
|
62
|
+
derived().coeffRef(row, col) = other.coeff(row, col);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
inline Scalar operator()(Index row, Index col) const
|
|
66
|
+
{
|
|
67
|
+
check_coordinates(row, col);
|
|
68
|
+
return coeff(row,col);
|
|
69
|
+
}
|
|
70
|
+
inline Scalar& operator()(Index row, Index col)
|
|
71
|
+
{
|
|
72
|
+
check_coordinates(row, col);
|
|
73
|
+
return coeffRef(row,col);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
|
77
|
+
inline const Derived& derived() const { return *static_cast<const Derived*>(this); }
|
|
78
|
+
inline Derived& derived() { return *static_cast<Derived*>(this); }
|
|
79
|
+
#endif // not EIGEN_PARSED_BY_DOXYGEN
|
|
80
|
+
|
|
81
|
+
template<typename DenseDerived>
|
|
82
|
+
void evalTo(MatrixBase<DenseDerived> &other) const;
|
|
83
|
+
template<typename DenseDerived>
|
|
84
|
+
void evalToLazy(MatrixBase<DenseDerived> &other) const;
|
|
85
|
+
|
|
86
|
+
DenseMatrixType toDenseMatrix() const
|
|
87
|
+
{
|
|
88
|
+
DenseMatrixType res(rows(), cols());
|
|
89
|
+
evalToLazy(res);
|
|
90
|
+
return res;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
protected:
|
|
94
|
+
|
|
95
|
+
void check_coordinates(Index row, Index col) const
|
|
96
|
+
{
|
|
97
|
+
EIGEN_ONLY_USED_FOR_DEBUG(row);
|
|
98
|
+
EIGEN_ONLY_USED_FOR_DEBUG(col);
|
|
99
|
+
eigen_assert(col>=0 && col<cols() && row>=0 && row<rows());
|
|
100
|
+
const int mode = int(Mode) & ~SelfAdjoint;
|
|
101
|
+
EIGEN_ONLY_USED_FOR_DEBUG(mode);
|
|
102
|
+
eigen_assert((mode==Upper && col>=row)
|
|
103
|
+
|| (mode==Lower && col<=row)
|
|
104
|
+
|| ((mode==StrictlyUpper || mode==UnitUpper) && col>row)
|
|
105
|
+
|| ((mode==StrictlyLower || mode==UnitLower) && col<row));
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
#ifdef EIGEN_INTERNAL_DEBUGGING
|
|
109
|
+
void check_coordinates_internal(Index row, Index col) const
|
|
110
|
+
{
|
|
111
|
+
check_coordinates(row, col);
|
|
112
|
+
}
|
|
113
|
+
#else
|
|
114
|
+
void check_coordinates_internal(Index , Index ) const {}
|
|
115
|
+
#endif
|
|
116
|
+
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
/** \class TriangularView
|
|
120
|
+
* \ingroup Core_Module
|
|
121
|
+
*
|
|
122
|
+
* \brief Base class for triangular part in a matrix
|
|
123
|
+
*
|
|
124
|
+
* \param MatrixType the type of the object in which we are taking the triangular part
|
|
125
|
+
* \param Mode the kind of triangular matrix expression to construct. Can be #Upper,
|
|
126
|
+
* #Lower, #UnitUpper, #UnitLower, #StrictlyUpper, or #StrictlyLower.
|
|
127
|
+
* This is in fact a bit field; it must have either #Upper or #Lower,
|
|
128
|
+
* and additionnaly it may have #UnitDiag or #ZeroDiag or neither.
|
|
129
|
+
*
|
|
130
|
+
* This class represents a triangular part of a matrix, not necessarily square. Strictly speaking, for rectangular
|
|
131
|
+
* matrices one should speak of "trapezoid" parts. This class is the return type
|
|
132
|
+
* of MatrixBase::triangularView() and most of the time this is the only way it is used.
|
|
133
|
+
*
|
|
134
|
+
* \sa MatrixBase::triangularView()
|
|
135
|
+
*/
|
|
136
|
+
namespace internal {
|
|
137
|
+
template<typename MatrixType, unsigned int _Mode>
|
|
138
|
+
struct traits<TriangularView<MatrixType, _Mode> > : traits<MatrixType>
|
|
139
|
+
{
|
|
140
|
+
typedef typename nested<MatrixType>::type MatrixTypeNested;
|
|
141
|
+
typedef typename remove_reference<MatrixTypeNested>::type MatrixTypeNestedNonRef;
|
|
142
|
+
typedef typename remove_all<MatrixTypeNested>::type MatrixTypeNestedCleaned;
|
|
143
|
+
typedef MatrixType ExpressionType;
|
|
144
|
+
typedef typename MatrixType::PlainObject DenseMatrixType;
|
|
145
|
+
enum {
|
|
146
|
+
Mode = _Mode,
|
|
147
|
+
Flags = (MatrixTypeNestedCleaned::Flags & (HereditaryBits) & (~(PacketAccessBit | DirectAccessBit | LinearAccessBit))) | Mode,
|
|
148
|
+
CoeffReadCost = MatrixTypeNestedCleaned::CoeffReadCost
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
template<int Mode, bool LhsIsTriangular,
|
|
154
|
+
typename Lhs, bool LhsIsVector,
|
|
155
|
+
typename Rhs, bool RhsIsVector>
|
|
156
|
+
struct TriangularProduct;
|
|
157
|
+
|
|
158
|
+
template<typename _MatrixType, unsigned int _Mode> class TriangularView
|
|
159
|
+
: public TriangularBase<TriangularView<_MatrixType, _Mode> >
|
|
160
|
+
{
|
|
161
|
+
public:
|
|
162
|
+
|
|
163
|
+
typedef TriangularBase<TriangularView> Base;
|
|
164
|
+
typedef typename internal::traits<TriangularView>::Scalar Scalar;
|
|
165
|
+
|
|
166
|
+
typedef _MatrixType MatrixType;
|
|
167
|
+
typedef typename internal::traits<TriangularView>::DenseMatrixType DenseMatrixType;
|
|
168
|
+
typedef DenseMatrixType PlainObject;
|
|
169
|
+
|
|
170
|
+
protected:
|
|
171
|
+
typedef typename internal::traits<TriangularView>::MatrixTypeNested MatrixTypeNested;
|
|
172
|
+
typedef typename internal::traits<TriangularView>::MatrixTypeNestedNonRef MatrixTypeNestedNonRef;
|
|
173
|
+
typedef typename internal::traits<TriangularView>::MatrixTypeNestedCleaned MatrixTypeNestedCleaned;
|
|
174
|
+
|
|
175
|
+
typedef typename internal::remove_all<typename MatrixType::ConjugateReturnType>::type MatrixConjugateReturnType;
|
|
176
|
+
|
|
177
|
+
public:
|
|
178
|
+
using Base::evalToLazy;
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
typedef typename internal::traits<TriangularView>::StorageKind StorageKind;
|
|
182
|
+
typedef typename internal::traits<TriangularView>::Index Index;
|
|
183
|
+
|
|
184
|
+
enum {
|
|
185
|
+
Mode = _Mode,
|
|
186
|
+
TransposeMode = (Mode & Upper ? Lower : 0)
|
|
187
|
+
| (Mode & Lower ? Upper : 0)
|
|
188
|
+
| (Mode & (UnitDiag))
|
|
189
|
+
| (Mode & (ZeroDiag))
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
inline TriangularView(const MatrixType& matrix) : m_matrix(matrix)
|
|
193
|
+
{}
|
|
194
|
+
|
|
195
|
+
inline Index rows() const { return m_matrix.rows(); }
|
|
196
|
+
inline Index cols() const { return m_matrix.cols(); }
|
|
197
|
+
inline Index outerStride() const { return m_matrix.outerStride(); }
|
|
198
|
+
inline Index innerStride() const { return m_matrix.innerStride(); }
|
|
199
|
+
|
|
200
|
+
/** \sa MatrixBase::operator+=() */
|
|
201
|
+
template<typename Other> TriangularView& operator+=(const DenseBase<Other>& other) { return *this = m_matrix + other.derived(); }
|
|
202
|
+
/** \sa MatrixBase::operator-=() */
|
|
203
|
+
template<typename Other> TriangularView& operator-=(const DenseBase<Other>& other) { return *this = m_matrix - other.derived(); }
|
|
204
|
+
/** \sa MatrixBase::operator*=() */
|
|
205
|
+
TriangularView& operator*=(const typename internal::traits<MatrixType>::Scalar& other) { return *this = m_matrix * other; }
|
|
206
|
+
/** \sa MatrixBase::operator/=() */
|
|
207
|
+
TriangularView& operator/=(const typename internal::traits<MatrixType>::Scalar& other) { return *this = m_matrix / other; }
|
|
208
|
+
|
|
209
|
+
/** \sa MatrixBase::fill() */
|
|
210
|
+
void fill(const Scalar& value) { setConstant(value); }
|
|
211
|
+
/** \sa MatrixBase::setConstant() */
|
|
212
|
+
TriangularView& setConstant(const Scalar& value)
|
|
213
|
+
{ return *this = MatrixType::Constant(rows(), cols(), value); }
|
|
214
|
+
/** \sa MatrixBase::setZero() */
|
|
215
|
+
TriangularView& setZero() { return setConstant(Scalar(0)); }
|
|
216
|
+
/** \sa MatrixBase::setOnes() */
|
|
217
|
+
TriangularView& setOnes() { return setConstant(Scalar(1)); }
|
|
218
|
+
|
|
219
|
+
/** \sa MatrixBase::coeff()
|
|
220
|
+
* \warning the coordinates must fit into the referenced triangular part
|
|
221
|
+
*/
|
|
222
|
+
inline Scalar coeff(Index row, Index col) const
|
|
223
|
+
{
|
|
224
|
+
Base::check_coordinates_internal(row, col);
|
|
225
|
+
return m_matrix.coeff(row, col);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/** \sa MatrixBase::coeffRef()
|
|
229
|
+
* \warning the coordinates must fit into the referenced triangular part
|
|
230
|
+
*/
|
|
231
|
+
inline Scalar& coeffRef(Index row, Index col)
|
|
232
|
+
{
|
|
233
|
+
Base::check_coordinates_internal(row, col);
|
|
234
|
+
return m_matrix.const_cast_derived().coeffRef(row, col);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
const MatrixTypeNestedCleaned& nestedExpression() const { return m_matrix; }
|
|
238
|
+
MatrixTypeNestedCleaned& nestedExpression() { return *const_cast<MatrixTypeNestedCleaned*>(&m_matrix); }
|
|
239
|
+
|
|
240
|
+
/** Assigns a triangular matrix to a triangular part of a dense matrix */
|
|
241
|
+
template<typename OtherDerived>
|
|
242
|
+
TriangularView& operator=(const TriangularBase<OtherDerived>& other);
|
|
243
|
+
|
|
244
|
+
template<typename OtherDerived>
|
|
245
|
+
TriangularView& operator=(const MatrixBase<OtherDerived>& other);
|
|
246
|
+
|
|
247
|
+
TriangularView& operator=(const TriangularView& other)
|
|
248
|
+
{ return *this = other.nestedExpression(); }
|
|
249
|
+
|
|
250
|
+
template<typename OtherDerived>
|
|
251
|
+
void lazyAssign(const TriangularBase<OtherDerived>& other);
|
|
252
|
+
|
|
253
|
+
template<typename OtherDerived>
|
|
254
|
+
void lazyAssign(const MatrixBase<OtherDerived>& other);
|
|
255
|
+
|
|
256
|
+
/** \sa MatrixBase::conjugate() */
|
|
257
|
+
inline TriangularView<MatrixConjugateReturnType,Mode> conjugate()
|
|
258
|
+
{ return m_matrix.conjugate(); }
|
|
259
|
+
/** \sa MatrixBase::conjugate() const */
|
|
260
|
+
inline const TriangularView<MatrixConjugateReturnType,Mode> conjugate() const
|
|
261
|
+
{ return m_matrix.conjugate(); }
|
|
262
|
+
|
|
263
|
+
/** \sa MatrixBase::adjoint() const */
|
|
264
|
+
inline const TriangularView<const typename MatrixType::AdjointReturnType,TransposeMode> adjoint() const
|
|
265
|
+
{ return m_matrix.adjoint(); }
|
|
266
|
+
|
|
267
|
+
/** \sa MatrixBase::transpose() */
|
|
268
|
+
inline TriangularView<Transpose<MatrixType>,TransposeMode> transpose()
|
|
269
|
+
{
|
|
270
|
+
EIGEN_STATIC_ASSERT_LVALUE(MatrixType)
|
|
271
|
+
return m_matrix.const_cast_derived().transpose();
|
|
272
|
+
}
|
|
273
|
+
/** \sa MatrixBase::transpose() const */
|
|
274
|
+
inline const TriangularView<Transpose<MatrixType>,TransposeMode> transpose() const
|
|
275
|
+
{
|
|
276
|
+
return m_matrix.transpose();
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/** Efficient triangular matrix times vector/matrix product */
|
|
280
|
+
template<typename OtherDerived>
|
|
281
|
+
TriangularProduct<Mode, true, MatrixType, false, OtherDerived, OtherDerived::ColsAtCompileTime==1>
|
|
282
|
+
operator*(const MatrixBase<OtherDerived>& rhs) const
|
|
283
|
+
{
|
|
284
|
+
return TriangularProduct
|
|
285
|
+
<Mode, true, MatrixType, false, OtherDerived, OtherDerived::ColsAtCompileTime==1>
|
|
286
|
+
(m_matrix, rhs.derived());
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/** Efficient vector/matrix times triangular matrix product */
|
|
290
|
+
template<typename OtherDerived> friend
|
|
291
|
+
TriangularProduct<Mode, false, OtherDerived, OtherDerived::RowsAtCompileTime==1, MatrixType, false>
|
|
292
|
+
operator*(const MatrixBase<OtherDerived>& lhs, const TriangularView& rhs)
|
|
293
|
+
{
|
|
294
|
+
return TriangularProduct
|
|
295
|
+
<Mode, false, OtherDerived, OtherDerived::RowsAtCompileTime==1, MatrixType, false>
|
|
296
|
+
(lhs.derived(),rhs.m_matrix);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
#ifdef EIGEN2_SUPPORT
|
|
300
|
+
template<typename OtherDerived>
|
|
301
|
+
struct eigen2_product_return_type
|
|
302
|
+
{
|
|
303
|
+
typedef typename TriangularView<MatrixType,Mode>::DenseMatrixType DenseMatrixType;
|
|
304
|
+
typedef typename OtherDerived::PlainObject::DenseType OtherPlainObject;
|
|
305
|
+
typedef typename ProductReturnType<DenseMatrixType, OtherPlainObject>::Type ProdRetType;
|
|
306
|
+
typedef typename ProdRetType::PlainObject type;
|
|
307
|
+
};
|
|
308
|
+
template<typename OtherDerived>
|
|
309
|
+
const typename eigen2_product_return_type<OtherDerived>::type
|
|
310
|
+
operator*(const EigenBase<OtherDerived>& rhs) const
|
|
311
|
+
{
|
|
312
|
+
typename OtherDerived::PlainObject::DenseType rhsPlainObject;
|
|
313
|
+
rhs.evalTo(rhsPlainObject);
|
|
314
|
+
return this->toDenseMatrix() * rhsPlainObject;
|
|
315
|
+
}
|
|
316
|
+
template<typename OtherMatrixType>
|
|
317
|
+
bool isApprox(const TriangularView<OtherMatrixType, Mode>& other, typename NumTraits<Scalar>::Real precision = NumTraits<Scalar>::dummy_precision()) const
|
|
318
|
+
{
|
|
319
|
+
return this->toDenseMatrix().isApprox(other.toDenseMatrix(), precision);
|
|
320
|
+
}
|
|
321
|
+
template<typename OtherDerived>
|
|
322
|
+
bool isApprox(const MatrixBase<OtherDerived>& other, typename NumTraits<Scalar>::Real precision = NumTraits<Scalar>::dummy_precision()) const
|
|
323
|
+
{
|
|
324
|
+
return this->toDenseMatrix().isApprox(other, precision);
|
|
325
|
+
}
|
|
326
|
+
#endif // EIGEN2_SUPPORT
|
|
327
|
+
|
|
328
|
+
template<int Side, typename Other>
|
|
329
|
+
inline const internal::triangular_solve_retval<Side,TriangularView, Other>
|
|
330
|
+
solve(const MatrixBase<Other>& other) const;
|
|
331
|
+
|
|
332
|
+
template<int Side, typename OtherDerived>
|
|
333
|
+
void solveInPlace(const MatrixBase<OtherDerived>& other) const;
|
|
334
|
+
|
|
335
|
+
template<typename Other>
|
|
336
|
+
inline const internal::triangular_solve_retval<OnTheLeft,TriangularView, Other>
|
|
337
|
+
solve(const MatrixBase<Other>& other) const
|
|
338
|
+
{ return solve<OnTheLeft>(other); }
|
|
339
|
+
|
|
340
|
+
template<typename OtherDerived>
|
|
341
|
+
void solveInPlace(const MatrixBase<OtherDerived>& other) const
|
|
342
|
+
{ return solveInPlace<OnTheLeft>(other); }
|
|
343
|
+
|
|
344
|
+
const SelfAdjointView<MatrixTypeNestedNonRef,Mode> selfadjointView() const
|
|
345
|
+
{
|
|
346
|
+
EIGEN_STATIC_ASSERT((Mode&UnitDiag)==0,PROGRAMMING_ERROR);
|
|
347
|
+
return SelfAdjointView<MatrixTypeNestedNonRef,Mode>(m_matrix);
|
|
348
|
+
}
|
|
349
|
+
SelfAdjointView<MatrixTypeNestedNonRef,Mode> selfadjointView()
|
|
350
|
+
{
|
|
351
|
+
EIGEN_STATIC_ASSERT((Mode&UnitDiag)==0,PROGRAMMING_ERROR);
|
|
352
|
+
return SelfAdjointView<MatrixTypeNestedNonRef,Mode>(m_matrix);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
template<typename OtherDerived>
|
|
356
|
+
void swap(TriangularBase<OtherDerived> const & other)
|
|
357
|
+
{
|
|
358
|
+
TriangularView<SwapWrapper<MatrixType>,Mode>(const_cast<MatrixType&>(m_matrix)).lazyAssign(other.derived());
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
template<typename OtherDerived>
|
|
362
|
+
void swap(MatrixBase<OtherDerived> const & other)
|
|
363
|
+
{
|
|
364
|
+
SwapWrapper<MatrixType> swaper(const_cast<MatrixType&>(m_matrix));
|
|
365
|
+
TriangularView<SwapWrapper<MatrixType>,Mode>(swaper).lazyAssign(other.derived());
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
Scalar determinant() const
|
|
369
|
+
{
|
|
370
|
+
if (Mode & UnitDiag)
|
|
371
|
+
return 1;
|
|
372
|
+
else if (Mode & ZeroDiag)
|
|
373
|
+
return 0;
|
|
374
|
+
else
|
|
375
|
+
return m_matrix.diagonal().prod();
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
// TODO simplify the following:
|
|
379
|
+
template<typename ProductDerived, typename Lhs, typename Rhs>
|
|
380
|
+
EIGEN_STRONG_INLINE TriangularView& operator=(const ProductBase<ProductDerived, Lhs,Rhs>& other)
|
|
381
|
+
{
|
|
382
|
+
setZero();
|
|
383
|
+
return assignProduct(other.derived(),1);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
template<typename ProductDerived, typename Lhs, typename Rhs>
|
|
387
|
+
EIGEN_STRONG_INLINE TriangularView& operator+=(const ProductBase<ProductDerived, Lhs,Rhs>& other)
|
|
388
|
+
{
|
|
389
|
+
return assignProduct(other.derived(),1);
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
template<typename ProductDerived, typename Lhs, typename Rhs>
|
|
393
|
+
EIGEN_STRONG_INLINE TriangularView& operator-=(const ProductBase<ProductDerived, Lhs,Rhs>& other)
|
|
394
|
+
{
|
|
395
|
+
return assignProduct(other.derived(),-1);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
|
|
399
|
+
template<typename ProductDerived>
|
|
400
|
+
EIGEN_STRONG_INLINE TriangularView& operator=(const ScaledProduct<ProductDerived>& other)
|
|
401
|
+
{
|
|
402
|
+
setZero();
|
|
403
|
+
return assignProduct(other.derived(),other.alpha());
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
template<typename ProductDerived>
|
|
407
|
+
EIGEN_STRONG_INLINE TriangularView& operator+=(const ScaledProduct<ProductDerived>& other)
|
|
408
|
+
{
|
|
409
|
+
return assignProduct(other.derived(),other.alpha());
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
template<typename ProductDerived>
|
|
413
|
+
EIGEN_STRONG_INLINE TriangularView& operator-=(const ScaledProduct<ProductDerived>& other)
|
|
414
|
+
{
|
|
415
|
+
return assignProduct(other.derived(),-other.alpha());
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
protected:
|
|
419
|
+
|
|
420
|
+
template<typename ProductDerived, typename Lhs, typename Rhs>
|
|
421
|
+
EIGEN_STRONG_INLINE TriangularView& assignProduct(const ProductBase<ProductDerived, Lhs,Rhs>& prod, const Scalar& alpha);
|
|
422
|
+
|
|
423
|
+
template<int Mode, bool LhsIsTriangular,
|
|
424
|
+
typename Lhs, bool LhsIsVector,
|
|
425
|
+
typename Rhs, bool RhsIsVector>
|
|
426
|
+
EIGEN_STRONG_INLINE TriangularView& assignProduct(const TriangularProduct<Mode, LhsIsTriangular, Lhs, LhsIsVector, Rhs, RhsIsVector>& prod, const Scalar& alpha)
|
|
427
|
+
{
|
|
428
|
+
lazyAssign(alpha*prod.eval());
|
|
429
|
+
return *this;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
MatrixTypeNested m_matrix;
|
|
433
|
+
};
|
|
434
|
+
|
|
435
|
+
/***************************************************************************
|
|
436
|
+
* Implementation of triangular evaluation/assignment
|
|
437
|
+
***************************************************************************/
|
|
438
|
+
|
|
439
|
+
namespace internal {
|
|
440
|
+
|
|
441
|
+
template<typename Derived1, typename Derived2, unsigned int Mode, int UnrollCount, bool ClearOpposite>
|
|
442
|
+
struct triangular_assignment_selector
|
|
443
|
+
{
|
|
444
|
+
enum {
|
|
445
|
+
col = (UnrollCount-1) / Derived1::RowsAtCompileTime,
|
|
446
|
+
row = (UnrollCount-1) % Derived1::RowsAtCompileTime
|
|
447
|
+
};
|
|
448
|
+
|
|
449
|
+
typedef typename Derived1::Scalar Scalar;
|
|
450
|
+
|
|
451
|
+
static inline void run(Derived1 &dst, const Derived2 &src)
|
|
452
|
+
{
|
|
453
|
+
triangular_assignment_selector<Derived1, Derived2, Mode, UnrollCount-1, ClearOpposite>::run(dst, src);
|
|
454
|
+
|
|
455
|
+
eigen_assert( Mode == Upper || Mode == Lower
|
|
456
|
+
|| Mode == StrictlyUpper || Mode == StrictlyLower
|
|
457
|
+
|| Mode == UnitUpper || Mode == UnitLower);
|
|
458
|
+
if((Mode == Upper && row <= col)
|
|
459
|
+
|| (Mode == Lower && row >= col)
|
|
460
|
+
|| (Mode == StrictlyUpper && row < col)
|
|
461
|
+
|| (Mode == StrictlyLower && row > col)
|
|
462
|
+
|| (Mode == UnitUpper && row < col)
|
|
463
|
+
|| (Mode == UnitLower && row > col))
|
|
464
|
+
dst.copyCoeff(row, col, src);
|
|
465
|
+
else if(ClearOpposite)
|
|
466
|
+
{
|
|
467
|
+
if (Mode&UnitDiag && row==col)
|
|
468
|
+
dst.coeffRef(row, col) = Scalar(1);
|
|
469
|
+
else
|
|
470
|
+
dst.coeffRef(row, col) = Scalar(0);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
};
|
|
474
|
+
|
|
475
|
+
// prevent buggy user code from causing an infinite recursion
|
|
476
|
+
template<typename Derived1, typename Derived2, unsigned int Mode, bool ClearOpposite>
|
|
477
|
+
struct triangular_assignment_selector<Derived1, Derived2, Mode, 0, ClearOpposite>
|
|
478
|
+
{
|
|
479
|
+
static inline void run(Derived1 &, const Derived2 &) {}
|
|
480
|
+
};
|
|
481
|
+
|
|
482
|
+
template<typename Derived1, typename Derived2, bool ClearOpposite>
|
|
483
|
+
struct triangular_assignment_selector<Derived1, Derived2, Upper, Dynamic, ClearOpposite>
|
|
484
|
+
{
|
|
485
|
+
typedef typename Derived1::Index Index;
|
|
486
|
+
typedef typename Derived1::Scalar Scalar;
|
|
487
|
+
static inline void run(Derived1 &dst, const Derived2 &src)
|
|
488
|
+
{
|
|
489
|
+
for(Index j = 0; j < dst.cols(); ++j)
|
|
490
|
+
{
|
|
491
|
+
Index maxi = (std::min)(j, dst.rows()-1);
|
|
492
|
+
for(Index i = 0; i <= maxi; ++i)
|
|
493
|
+
dst.copyCoeff(i, j, src);
|
|
494
|
+
if (ClearOpposite)
|
|
495
|
+
for(Index i = maxi+1; i < dst.rows(); ++i)
|
|
496
|
+
dst.coeffRef(i, j) = Scalar(0);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
};
|
|
500
|
+
|
|
501
|
+
template<typename Derived1, typename Derived2, bool ClearOpposite>
|
|
502
|
+
struct triangular_assignment_selector<Derived1, Derived2, Lower, Dynamic, ClearOpposite>
|
|
503
|
+
{
|
|
504
|
+
typedef typename Derived1::Index Index;
|
|
505
|
+
static inline void run(Derived1 &dst, const Derived2 &src)
|
|
506
|
+
{
|
|
507
|
+
for(Index j = 0; j < dst.cols(); ++j)
|
|
508
|
+
{
|
|
509
|
+
for(Index i = j; i < dst.rows(); ++i)
|
|
510
|
+
dst.copyCoeff(i, j, src);
|
|
511
|
+
Index maxi = (std::min)(j, dst.rows());
|
|
512
|
+
if (ClearOpposite)
|
|
513
|
+
for(Index i = 0; i < maxi; ++i)
|
|
514
|
+
dst.coeffRef(i, j) = static_cast<typename Derived1::Scalar>(0);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
};
|
|
518
|
+
|
|
519
|
+
template<typename Derived1, typename Derived2, bool ClearOpposite>
|
|
520
|
+
struct triangular_assignment_selector<Derived1, Derived2, StrictlyUpper, Dynamic, ClearOpposite>
|
|
521
|
+
{
|
|
522
|
+
typedef typename Derived1::Index Index;
|
|
523
|
+
typedef typename Derived1::Scalar Scalar;
|
|
524
|
+
static inline void run(Derived1 &dst, const Derived2 &src)
|
|
525
|
+
{
|
|
526
|
+
for(Index j = 0; j < dst.cols(); ++j)
|
|
527
|
+
{
|
|
528
|
+
Index maxi = (std::min)(j, dst.rows());
|
|
529
|
+
for(Index i = 0; i < maxi; ++i)
|
|
530
|
+
dst.copyCoeff(i, j, src);
|
|
531
|
+
if (ClearOpposite)
|
|
532
|
+
for(Index i = maxi; i < dst.rows(); ++i)
|
|
533
|
+
dst.coeffRef(i, j) = Scalar(0);
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
};
|
|
537
|
+
|
|
538
|
+
template<typename Derived1, typename Derived2, bool ClearOpposite>
|
|
539
|
+
struct triangular_assignment_selector<Derived1, Derived2, StrictlyLower, Dynamic, ClearOpposite>
|
|
540
|
+
{
|
|
541
|
+
typedef typename Derived1::Index Index;
|
|
542
|
+
static inline void run(Derived1 &dst, const Derived2 &src)
|
|
543
|
+
{
|
|
544
|
+
for(Index j = 0; j < dst.cols(); ++j)
|
|
545
|
+
{
|
|
546
|
+
for(Index i = j+1; i < dst.rows(); ++i)
|
|
547
|
+
dst.copyCoeff(i, j, src);
|
|
548
|
+
Index maxi = (std::min)(j, dst.rows()-1);
|
|
549
|
+
if (ClearOpposite)
|
|
550
|
+
for(Index i = 0; i <= maxi; ++i)
|
|
551
|
+
dst.coeffRef(i, j) = static_cast<typename Derived1::Scalar>(0);
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
};
|
|
555
|
+
|
|
556
|
+
template<typename Derived1, typename Derived2, bool ClearOpposite>
|
|
557
|
+
struct triangular_assignment_selector<Derived1, Derived2, UnitUpper, Dynamic, ClearOpposite>
|
|
558
|
+
{
|
|
559
|
+
typedef typename Derived1::Index Index;
|
|
560
|
+
static inline void run(Derived1 &dst, const Derived2 &src)
|
|
561
|
+
{
|
|
562
|
+
for(Index j = 0; j < dst.cols(); ++j)
|
|
563
|
+
{
|
|
564
|
+
Index maxi = (std::min)(j, dst.rows());
|
|
565
|
+
for(Index i = 0; i < maxi; ++i)
|
|
566
|
+
dst.copyCoeff(i, j, src);
|
|
567
|
+
if (ClearOpposite)
|
|
568
|
+
{
|
|
569
|
+
for(Index i = maxi+1; i < dst.rows(); ++i)
|
|
570
|
+
dst.coeffRef(i, j) = 0;
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
dst.diagonal().setOnes();
|
|
574
|
+
}
|
|
575
|
+
};
|
|
576
|
+
template<typename Derived1, typename Derived2, bool ClearOpposite>
|
|
577
|
+
struct triangular_assignment_selector<Derived1, Derived2, UnitLower, Dynamic, ClearOpposite>
|
|
578
|
+
{
|
|
579
|
+
typedef typename Derived1::Index Index;
|
|
580
|
+
static inline void run(Derived1 &dst, const Derived2 &src)
|
|
581
|
+
{
|
|
582
|
+
for(Index j = 0; j < dst.cols(); ++j)
|
|
583
|
+
{
|
|
584
|
+
Index maxi = (std::min)(j, dst.rows());
|
|
585
|
+
for(Index i = maxi+1; i < dst.rows(); ++i)
|
|
586
|
+
dst.copyCoeff(i, j, src);
|
|
587
|
+
if (ClearOpposite)
|
|
588
|
+
{
|
|
589
|
+
for(Index i = 0; i < maxi; ++i)
|
|
590
|
+
dst.coeffRef(i, j) = 0;
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
dst.diagonal().setOnes();
|
|
594
|
+
}
|
|
595
|
+
};
|
|
596
|
+
|
|
597
|
+
} // end namespace internal
|
|
598
|
+
|
|
599
|
+
// FIXME should we keep that possibility
|
|
600
|
+
template<typename MatrixType, unsigned int Mode>
|
|
601
|
+
template<typename OtherDerived>
|
|
602
|
+
inline TriangularView<MatrixType, Mode>&
|
|
603
|
+
TriangularView<MatrixType, Mode>::operator=(const MatrixBase<OtherDerived>& other)
|
|
604
|
+
{
|
|
605
|
+
if(OtherDerived::Flags & EvalBeforeAssigningBit)
|
|
606
|
+
{
|
|
607
|
+
typename internal::plain_matrix_type<OtherDerived>::type other_evaluated(other.rows(), other.cols());
|
|
608
|
+
other_evaluated.template triangularView<Mode>().lazyAssign(other.derived());
|
|
609
|
+
lazyAssign(other_evaluated);
|
|
610
|
+
}
|
|
611
|
+
else
|
|
612
|
+
lazyAssign(other.derived());
|
|
613
|
+
return *this;
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
// FIXME should we keep that possibility
|
|
617
|
+
template<typename MatrixType, unsigned int Mode>
|
|
618
|
+
template<typename OtherDerived>
|
|
619
|
+
void TriangularView<MatrixType, Mode>::lazyAssign(const MatrixBase<OtherDerived>& other)
|
|
620
|
+
{
|
|
621
|
+
enum {
|
|
622
|
+
unroll = MatrixType::SizeAtCompileTime != Dynamic
|
|
623
|
+
&& internal::traits<OtherDerived>::CoeffReadCost != Dynamic
|
|
624
|
+
&& MatrixType::SizeAtCompileTime*internal::traits<OtherDerived>::CoeffReadCost/2 <= EIGEN_UNROLLING_LIMIT
|
|
625
|
+
};
|
|
626
|
+
eigen_assert(m_matrix.rows() == other.rows() && m_matrix.cols() == other.cols());
|
|
627
|
+
|
|
628
|
+
internal::triangular_assignment_selector
|
|
629
|
+
<MatrixType, OtherDerived, int(Mode),
|
|
630
|
+
unroll ? int(MatrixType::SizeAtCompileTime) : Dynamic,
|
|
631
|
+
false // do not change the opposite triangular part
|
|
632
|
+
>::run(m_matrix.const_cast_derived(), other.derived());
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
|
|
636
|
+
|
|
637
|
+
template<typename MatrixType, unsigned int Mode>
|
|
638
|
+
template<typename OtherDerived>
|
|
639
|
+
inline TriangularView<MatrixType, Mode>&
|
|
640
|
+
TriangularView<MatrixType, Mode>::operator=(const TriangularBase<OtherDerived>& other)
|
|
641
|
+
{
|
|
642
|
+
eigen_assert(Mode == int(OtherDerived::Mode));
|
|
643
|
+
if(internal::traits<OtherDerived>::Flags & EvalBeforeAssigningBit)
|
|
644
|
+
{
|
|
645
|
+
typename OtherDerived::DenseMatrixType other_evaluated(other.rows(), other.cols());
|
|
646
|
+
other_evaluated.template triangularView<Mode>().lazyAssign(other.derived().nestedExpression());
|
|
647
|
+
lazyAssign(other_evaluated);
|
|
648
|
+
}
|
|
649
|
+
else
|
|
650
|
+
lazyAssign(other.derived().nestedExpression());
|
|
651
|
+
return *this;
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
template<typename MatrixType, unsigned int Mode>
|
|
655
|
+
template<typename OtherDerived>
|
|
656
|
+
void TriangularView<MatrixType, Mode>::lazyAssign(const TriangularBase<OtherDerived>& other)
|
|
657
|
+
{
|
|
658
|
+
enum {
|
|
659
|
+
unroll = MatrixType::SizeAtCompileTime != Dynamic
|
|
660
|
+
&& internal::traits<OtherDerived>::CoeffReadCost != Dynamic
|
|
661
|
+
&& MatrixType::SizeAtCompileTime * internal::traits<OtherDerived>::CoeffReadCost / 2
|
|
662
|
+
<= EIGEN_UNROLLING_LIMIT
|
|
663
|
+
};
|
|
664
|
+
eigen_assert(m_matrix.rows() == other.rows() && m_matrix.cols() == other.cols());
|
|
665
|
+
|
|
666
|
+
internal::triangular_assignment_selector
|
|
667
|
+
<MatrixType, OtherDerived, int(Mode),
|
|
668
|
+
unroll ? int(MatrixType::SizeAtCompileTime) : Dynamic,
|
|
669
|
+
false // preserve the opposite triangular part
|
|
670
|
+
>::run(m_matrix.const_cast_derived(), other.derived().nestedExpression());
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
/***************************************************************************
|
|
674
|
+
* Implementation of TriangularBase methods
|
|
675
|
+
***************************************************************************/
|
|
676
|
+
|
|
677
|
+
/** Assigns a triangular or selfadjoint matrix to a dense matrix.
|
|
678
|
+
* If the matrix is triangular, the opposite part is set to zero. */
|
|
679
|
+
template<typename Derived>
|
|
680
|
+
template<typename DenseDerived>
|
|
681
|
+
void TriangularBase<Derived>::evalTo(MatrixBase<DenseDerived> &other) const
|
|
682
|
+
{
|
|
683
|
+
if(internal::traits<Derived>::Flags & EvalBeforeAssigningBit)
|
|
684
|
+
{
|
|
685
|
+
typename internal::plain_matrix_type<Derived>::type other_evaluated(rows(), cols());
|
|
686
|
+
evalToLazy(other_evaluated);
|
|
687
|
+
other.derived().swap(other_evaluated);
|
|
688
|
+
}
|
|
689
|
+
else
|
|
690
|
+
evalToLazy(other.derived());
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
/** Assigns a triangular or selfadjoint matrix to a dense matrix.
|
|
694
|
+
* If the matrix is triangular, the opposite part is set to zero. */
|
|
695
|
+
template<typename Derived>
|
|
696
|
+
template<typename DenseDerived>
|
|
697
|
+
void TriangularBase<Derived>::evalToLazy(MatrixBase<DenseDerived> &other) const
|
|
698
|
+
{
|
|
699
|
+
enum {
|
|
700
|
+
unroll = DenseDerived::SizeAtCompileTime != Dynamic
|
|
701
|
+
&& internal::traits<Derived>::CoeffReadCost != Dynamic
|
|
702
|
+
&& DenseDerived::SizeAtCompileTime * internal::traits<Derived>::CoeffReadCost / 2
|
|
703
|
+
<= EIGEN_UNROLLING_LIMIT
|
|
704
|
+
};
|
|
705
|
+
other.derived().resize(this->rows(), this->cols());
|
|
706
|
+
|
|
707
|
+
internal::triangular_assignment_selector
|
|
708
|
+
<DenseDerived, typename internal::traits<Derived>::MatrixTypeNestedCleaned, Derived::Mode,
|
|
709
|
+
unroll ? int(DenseDerived::SizeAtCompileTime) : Dynamic,
|
|
710
|
+
true // clear the opposite triangular part
|
|
711
|
+
>::run(other.derived(), derived().nestedExpression());
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
/***************************************************************************
|
|
715
|
+
* Implementation of TriangularView methods
|
|
716
|
+
***************************************************************************/
|
|
717
|
+
|
|
718
|
+
/***************************************************************************
|
|
719
|
+
* Implementation of MatrixBase methods
|
|
720
|
+
***************************************************************************/
|
|
721
|
+
|
|
722
|
+
#ifdef EIGEN2_SUPPORT
|
|
723
|
+
|
|
724
|
+
// implementation of part<>(), including the SelfAdjoint case.
|
|
725
|
+
|
|
726
|
+
namespace internal {
|
|
727
|
+
template<typename MatrixType, unsigned int Mode>
|
|
728
|
+
struct eigen2_part_return_type
|
|
729
|
+
{
|
|
730
|
+
typedef TriangularView<MatrixType, Mode> type;
|
|
731
|
+
};
|
|
732
|
+
|
|
733
|
+
template<typename MatrixType>
|
|
734
|
+
struct eigen2_part_return_type<MatrixType, SelfAdjoint>
|
|
735
|
+
{
|
|
736
|
+
typedef SelfAdjointView<MatrixType, Upper> type;
|
|
737
|
+
};
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
/** \deprecated use MatrixBase::triangularView() */
|
|
741
|
+
template<typename Derived>
|
|
742
|
+
template<unsigned int Mode>
|
|
743
|
+
const typename internal::eigen2_part_return_type<Derived, Mode>::type MatrixBase<Derived>::part() const
|
|
744
|
+
{
|
|
745
|
+
return derived();
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
/** \deprecated use MatrixBase::triangularView() */
|
|
749
|
+
template<typename Derived>
|
|
750
|
+
template<unsigned int Mode>
|
|
751
|
+
typename internal::eigen2_part_return_type<Derived, Mode>::type MatrixBase<Derived>::part()
|
|
752
|
+
{
|
|
753
|
+
return derived();
|
|
754
|
+
}
|
|
755
|
+
#endif
|
|
756
|
+
|
|
757
|
+
/**
|
|
758
|
+
* \returns an expression of a triangular view extracted from the current matrix
|
|
759
|
+
*
|
|
760
|
+
* The parameter \a Mode can have the following values: \c #Upper, \c #StrictlyUpper, \c #UnitUpper,
|
|
761
|
+
* \c #Lower, \c #StrictlyLower, \c #UnitLower.
|
|
762
|
+
*
|
|
763
|
+
* Example: \include MatrixBase_extract.cpp
|
|
764
|
+
* Output: \verbinclude MatrixBase_extract.out
|
|
765
|
+
*
|
|
766
|
+
* \sa class TriangularView
|
|
767
|
+
*/
|
|
768
|
+
template<typename Derived>
|
|
769
|
+
template<unsigned int Mode>
|
|
770
|
+
typename MatrixBase<Derived>::template TriangularViewReturnType<Mode>::Type
|
|
771
|
+
MatrixBase<Derived>::triangularView()
|
|
772
|
+
{
|
|
773
|
+
return derived();
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
/** This is the const version of MatrixBase::triangularView() */
|
|
777
|
+
template<typename Derived>
|
|
778
|
+
template<unsigned int Mode>
|
|
779
|
+
typename MatrixBase<Derived>::template ConstTriangularViewReturnType<Mode>::Type
|
|
780
|
+
MatrixBase<Derived>::triangularView() const
|
|
781
|
+
{
|
|
782
|
+
return derived();
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
/** \returns true if *this is approximately equal to an upper triangular matrix,
|
|
786
|
+
* within the precision given by \a prec.
|
|
787
|
+
*
|
|
788
|
+
* \sa isLowerTriangular()
|
|
789
|
+
*/
|
|
790
|
+
template<typename Derived>
|
|
791
|
+
bool MatrixBase<Derived>::isUpperTriangular(const RealScalar& prec) const
|
|
792
|
+
{
|
|
793
|
+
using std::abs;
|
|
794
|
+
RealScalar maxAbsOnUpperPart = static_cast<RealScalar>(-1);
|
|
795
|
+
for(Index j = 0; j < cols(); ++j)
|
|
796
|
+
{
|
|
797
|
+
Index maxi = (std::min)(j, rows()-1);
|
|
798
|
+
for(Index i = 0; i <= maxi; ++i)
|
|
799
|
+
{
|
|
800
|
+
RealScalar absValue = abs(coeff(i,j));
|
|
801
|
+
if(absValue > maxAbsOnUpperPart) maxAbsOnUpperPart = absValue;
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
RealScalar threshold = maxAbsOnUpperPart * prec;
|
|
805
|
+
for(Index j = 0; j < cols(); ++j)
|
|
806
|
+
for(Index i = j+1; i < rows(); ++i)
|
|
807
|
+
if(abs(coeff(i, j)) > threshold) return false;
|
|
808
|
+
return true;
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
/** \returns true if *this is approximately equal to a lower triangular matrix,
|
|
812
|
+
* within the precision given by \a prec.
|
|
813
|
+
*
|
|
814
|
+
* \sa isUpperTriangular()
|
|
815
|
+
*/
|
|
816
|
+
template<typename Derived>
|
|
817
|
+
bool MatrixBase<Derived>::isLowerTriangular(const RealScalar& prec) const
|
|
818
|
+
{
|
|
819
|
+
using std::abs;
|
|
820
|
+
RealScalar maxAbsOnLowerPart = static_cast<RealScalar>(-1);
|
|
821
|
+
for(Index j = 0; j < cols(); ++j)
|
|
822
|
+
for(Index i = j; i < rows(); ++i)
|
|
823
|
+
{
|
|
824
|
+
RealScalar absValue = abs(coeff(i,j));
|
|
825
|
+
if(absValue > maxAbsOnLowerPart) maxAbsOnLowerPart = absValue;
|
|
826
|
+
}
|
|
827
|
+
RealScalar threshold = maxAbsOnLowerPart * prec;
|
|
828
|
+
for(Index j = 1; j < cols(); ++j)
|
|
829
|
+
{
|
|
830
|
+
Index maxi = (std::min)(j, rows()-1);
|
|
831
|
+
for(Index i = 0; i < maxi; ++i)
|
|
832
|
+
if(abs(coeff(i, j)) > threshold) return false;
|
|
833
|
+
}
|
|
834
|
+
return true;
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
} // end namespace Eigen
|
|
838
|
+
|
|
839
|
+
#endif // EIGEN_TRIANGULARMATRIX_H
|