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,131 @@
|
|
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 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_EIGENBASE_H
|
12
|
+
#define EIGEN_EIGENBASE_H
|
13
|
+
|
14
|
+
namespace Eigen {
|
15
|
+
|
16
|
+
/** Common base class for all classes T such that MatrixBase has an operator=(T) and a constructor MatrixBase(T).
|
17
|
+
*
|
18
|
+
* In other words, an EigenBase object is an object that can be copied into a MatrixBase.
|
19
|
+
*
|
20
|
+
* Besides MatrixBase-derived classes, this also includes special matrix classes such as diagonal matrices, etc.
|
21
|
+
*
|
22
|
+
* Notice that this class is trivial, it is only used to disambiguate overloaded functions.
|
23
|
+
*
|
24
|
+
* \sa \ref TopicClassHierarchy
|
25
|
+
*/
|
26
|
+
template<typename Derived> struct EigenBase
|
27
|
+
{
|
28
|
+
// typedef typename internal::plain_matrix_type<Derived>::type PlainObject;
|
29
|
+
|
30
|
+
typedef typename internal::traits<Derived>::StorageKind StorageKind;
|
31
|
+
typedef typename internal::traits<Derived>::Index Index;
|
32
|
+
|
33
|
+
/** \returns a reference to the derived object */
|
34
|
+
Derived& derived() { return *static_cast<Derived*>(this); }
|
35
|
+
/** \returns a const reference to the derived object */
|
36
|
+
const Derived& derived() const { return *static_cast<const Derived*>(this); }
|
37
|
+
|
38
|
+
inline Derived& const_cast_derived() const
|
39
|
+
{ return *static_cast<Derived*>(const_cast<EigenBase*>(this)); }
|
40
|
+
inline const Derived& const_derived() const
|
41
|
+
{ return *static_cast<const Derived*>(this); }
|
42
|
+
|
43
|
+
/** \returns the number of rows. \sa cols(), RowsAtCompileTime */
|
44
|
+
inline Index rows() const { return derived().rows(); }
|
45
|
+
/** \returns the number of columns. \sa rows(), ColsAtCompileTime*/
|
46
|
+
inline Index cols() const { return derived().cols(); }
|
47
|
+
/** \returns the number of coefficients, which is rows()*cols().
|
48
|
+
* \sa rows(), cols(), SizeAtCompileTime. */
|
49
|
+
inline Index size() const { return rows() * cols(); }
|
50
|
+
|
51
|
+
/** \internal Don't use it, but do the equivalent: \code dst = *this; \endcode */
|
52
|
+
template<typename Dest> inline void evalTo(Dest& dst) const
|
53
|
+
{ derived().evalTo(dst); }
|
54
|
+
|
55
|
+
/** \internal Don't use it, but do the equivalent: \code dst += *this; \endcode */
|
56
|
+
template<typename Dest> inline void addTo(Dest& dst) const
|
57
|
+
{
|
58
|
+
// This is the default implementation,
|
59
|
+
// derived class can reimplement it in a more optimized way.
|
60
|
+
typename Dest::PlainObject res(rows(),cols());
|
61
|
+
evalTo(res);
|
62
|
+
dst += res;
|
63
|
+
}
|
64
|
+
|
65
|
+
/** \internal Don't use it, but do the equivalent: \code dst -= *this; \endcode */
|
66
|
+
template<typename Dest> inline void subTo(Dest& dst) const
|
67
|
+
{
|
68
|
+
// This is the default implementation,
|
69
|
+
// derived class can reimplement it in a more optimized way.
|
70
|
+
typename Dest::PlainObject res(rows(),cols());
|
71
|
+
evalTo(res);
|
72
|
+
dst -= res;
|
73
|
+
}
|
74
|
+
|
75
|
+
/** \internal Don't use it, but do the equivalent: \code dst.applyOnTheRight(*this); \endcode */
|
76
|
+
template<typename Dest> inline void applyThisOnTheRight(Dest& dst) const
|
77
|
+
{
|
78
|
+
// This is the default implementation,
|
79
|
+
// derived class can reimplement it in a more optimized way.
|
80
|
+
dst = dst * this->derived();
|
81
|
+
}
|
82
|
+
|
83
|
+
/** \internal Don't use it, but do the equivalent: \code dst.applyOnTheLeft(*this); \endcode */
|
84
|
+
template<typename Dest> inline void applyThisOnTheLeft(Dest& dst) const
|
85
|
+
{
|
86
|
+
// This is the default implementation,
|
87
|
+
// derived class can reimplement it in a more optimized way.
|
88
|
+
dst = this->derived() * dst;
|
89
|
+
}
|
90
|
+
|
91
|
+
};
|
92
|
+
|
93
|
+
/***************************************************************************
|
94
|
+
* Implementation of matrix base methods
|
95
|
+
***************************************************************************/
|
96
|
+
|
97
|
+
/** \brief Copies the generic expression \a other into *this.
|
98
|
+
*
|
99
|
+
* \details The expression must provide a (templated) evalTo(Derived& dst) const
|
100
|
+
* function which does the actual job. In practice, this allows any user to write
|
101
|
+
* its own special matrix without having to modify MatrixBase
|
102
|
+
*
|
103
|
+
* \returns a reference to *this.
|
104
|
+
*/
|
105
|
+
template<typename Derived>
|
106
|
+
template<typename OtherDerived>
|
107
|
+
Derived& DenseBase<Derived>::operator=(const EigenBase<OtherDerived> &other)
|
108
|
+
{
|
109
|
+
other.derived().evalTo(derived());
|
110
|
+
return derived();
|
111
|
+
}
|
112
|
+
|
113
|
+
template<typename Derived>
|
114
|
+
template<typename OtherDerived>
|
115
|
+
Derived& DenseBase<Derived>::operator+=(const EigenBase<OtherDerived> &other)
|
116
|
+
{
|
117
|
+
other.derived().addTo(derived());
|
118
|
+
return derived();
|
119
|
+
}
|
120
|
+
|
121
|
+
template<typename Derived>
|
122
|
+
template<typename OtherDerived>
|
123
|
+
Derived& DenseBase<Derived>::operator-=(const EigenBase<OtherDerived> &other)
|
124
|
+
{
|
125
|
+
other.derived().subTo(derived());
|
126
|
+
return derived();
|
127
|
+
}
|
128
|
+
|
129
|
+
} // end namespace Eigen
|
130
|
+
|
131
|
+
#endif // EIGEN_EIGENBASE_H
|
@@ -0,0 +1,140 @@
|
|
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
|
+
//
|
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_FLAGGED_H
|
11
|
+
#define EIGEN_FLAGGED_H
|
12
|
+
|
13
|
+
namespace Eigen {
|
14
|
+
|
15
|
+
/** \class Flagged
|
16
|
+
* \ingroup Core_Module
|
17
|
+
*
|
18
|
+
* \brief Expression with modified flags
|
19
|
+
*
|
20
|
+
* \param ExpressionType the type of the object of which we are modifying the flags
|
21
|
+
* \param Added the flags added to the expression
|
22
|
+
* \param Removed the flags removed from the expression (has priority over Added).
|
23
|
+
*
|
24
|
+
* This class represents an expression whose flags have been modified.
|
25
|
+
* It is the return type of MatrixBase::flagged()
|
26
|
+
* and most of the time this is the only way it is used.
|
27
|
+
*
|
28
|
+
* \sa MatrixBase::flagged()
|
29
|
+
*/
|
30
|
+
|
31
|
+
namespace internal {
|
32
|
+
template<typename ExpressionType, unsigned int Added, unsigned int Removed>
|
33
|
+
struct traits<Flagged<ExpressionType, Added, Removed> > : traits<ExpressionType>
|
34
|
+
{
|
35
|
+
enum { Flags = (ExpressionType::Flags | Added) & ~Removed };
|
36
|
+
};
|
37
|
+
}
|
38
|
+
|
39
|
+
template<typename ExpressionType, unsigned int Added, unsigned int Removed> class Flagged
|
40
|
+
: public MatrixBase<Flagged<ExpressionType, Added, Removed> >
|
41
|
+
{
|
42
|
+
public:
|
43
|
+
|
44
|
+
typedef MatrixBase<Flagged> Base;
|
45
|
+
|
46
|
+
EIGEN_DENSE_PUBLIC_INTERFACE(Flagged)
|
47
|
+
typedef typename internal::conditional<internal::must_nest_by_value<ExpressionType>::ret,
|
48
|
+
ExpressionType, const ExpressionType&>::type ExpressionTypeNested;
|
49
|
+
typedef typename ExpressionType::InnerIterator InnerIterator;
|
50
|
+
|
51
|
+
inline Flagged(const ExpressionType& matrix) : m_matrix(matrix) {}
|
52
|
+
|
53
|
+
inline Index rows() const { return m_matrix.rows(); }
|
54
|
+
inline Index cols() const { return m_matrix.cols(); }
|
55
|
+
inline Index outerStride() const { return m_matrix.outerStride(); }
|
56
|
+
inline Index innerStride() const { return m_matrix.innerStride(); }
|
57
|
+
|
58
|
+
inline CoeffReturnType coeff(Index row, Index col) const
|
59
|
+
{
|
60
|
+
return m_matrix.coeff(row, col);
|
61
|
+
}
|
62
|
+
|
63
|
+
inline CoeffReturnType coeff(Index index) const
|
64
|
+
{
|
65
|
+
return m_matrix.coeff(index);
|
66
|
+
}
|
67
|
+
|
68
|
+
inline const Scalar& coeffRef(Index row, Index col) const
|
69
|
+
{
|
70
|
+
return m_matrix.const_cast_derived().coeffRef(row, col);
|
71
|
+
}
|
72
|
+
|
73
|
+
inline const Scalar& coeffRef(Index index) const
|
74
|
+
{
|
75
|
+
return m_matrix.const_cast_derived().coeffRef(index);
|
76
|
+
}
|
77
|
+
|
78
|
+
inline Scalar& coeffRef(Index row, Index col)
|
79
|
+
{
|
80
|
+
return m_matrix.const_cast_derived().coeffRef(row, col);
|
81
|
+
}
|
82
|
+
|
83
|
+
inline Scalar& coeffRef(Index index)
|
84
|
+
{
|
85
|
+
return m_matrix.const_cast_derived().coeffRef(index);
|
86
|
+
}
|
87
|
+
|
88
|
+
template<int LoadMode>
|
89
|
+
inline const PacketScalar packet(Index row, Index col) const
|
90
|
+
{
|
91
|
+
return m_matrix.template packet<LoadMode>(row, col);
|
92
|
+
}
|
93
|
+
|
94
|
+
template<int LoadMode>
|
95
|
+
inline void writePacket(Index row, Index col, const PacketScalar& x)
|
96
|
+
{
|
97
|
+
m_matrix.const_cast_derived().template writePacket<LoadMode>(row, col, x);
|
98
|
+
}
|
99
|
+
|
100
|
+
template<int LoadMode>
|
101
|
+
inline const PacketScalar packet(Index index) const
|
102
|
+
{
|
103
|
+
return m_matrix.template packet<LoadMode>(index);
|
104
|
+
}
|
105
|
+
|
106
|
+
template<int LoadMode>
|
107
|
+
inline void writePacket(Index index, const PacketScalar& x)
|
108
|
+
{
|
109
|
+
m_matrix.const_cast_derived().template writePacket<LoadMode>(index, x);
|
110
|
+
}
|
111
|
+
|
112
|
+
const ExpressionType& _expression() const { return m_matrix; }
|
113
|
+
|
114
|
+
template<typename OtherDerived>
|
115
|
+
typename ExpressionType::PlainObject solveTriangular(const MatrixBase<OtherDerived>& other) const;
|
116
|
+
|
117
|
+
template<typename OtherDerived>
|
118
|
+
void solveTriangularInPlace(const MatrixBase<OtherDerived>& other) const;
|
119
|
+
|
120
|
+
protected:
|
121
|
+
ExpressionTypeNested m_matrix;
|
122
|
+
};
|
123
|
+
|
124
|
+
/** \returns an expression of *this with added and removed flags
|
125
|
+
*
|
126
|
+
* This is mostly for internal use.
|
127
|
+
*
|
128
|
+
* \sa class Flagged
|
129
|
+
*/
|
130
|
+
template<typename Derived>
|
131
|
+
template<unsigned int Added,unsigned int Removed>
|
132
|
+
inline const Flagged<Derived, Added, Removed>
|
133
|
+
DenseBase<Derived>::flagged() const
|
134
|
+
{
|
135
|
+
return derived();
|
136
|
+
}
|
137
|
+
|
138
|
+
} // end namespace Eigen
|
139
|
+
|
140
|
+
#endif // EIGEN_FLAGGED_H
|
@@ -0,0 +1,146 @@
|
|
1
|
+
// This file is part of Eigen, a lightweight C++ template library
|
2
|
+
// for linear algebra.
|
3
|
+
//
|
4
|
+
// Copyright (C) 2009-2010 Gael Guennebaud <gael.guennebaud@inria.fr>
|
5
|
+
//
|
6
|
+
// This Source Code Form is subject to the terms of the Mozilla
|
7
|
+
// Public License v. 2.0. If a copy of the MPL was not distributed
|
8
|
+
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
9
|
+
|
10
|
+
#ifndef EIGEN_FORCEALIGNEDACCESS_H
|
11
|
+
#define EIGEN_FORCEALIGNEDACCESS_H
|
12
|
+
|
13
|
+
namespace Eigen {
|
14
|
+
|
15
|
+
/** \class ForceAlignedAccess
|
16
|
+
* \ingroup Core_Module
|
17
|
+
*
|
18
|
+
* \brief Enforce aligned packet loads and stores regardless of what is requested
|
19
|
+
*
|
20
|
+
* \param ExpressionType the type of the object of which we are forcing aligned packet access
|
21
|
+
*
|
22
|
+
* This class is the return type of MatrixBase::forceAlignedAccess()
|
23
|
+
* and most of the time this is the only way it is used.
|
24
|
+
*
|
25
|
+
* \sa MatrixBase::forceAlignedAccess()
|
26
|
+
*/
|
27
|
+
|
28
|
+
namespace internal {
|
29
|
+
template<typename ExpressionType>
|
30
|
+
struct traits<ForceAlignedAccess<ExpressionType> > : public traits<ExpressionType>
|
31
|
+
{};
|
32
|
+
}
|
33
|
+
|
34
|
+
template<typename ExpressionType> class ForceAlignedAccess
|
35
|
+
: public internal::dense_xpr_base< ForceAlignedAccess<ExpressionType> >::type
|
36
|
+
{
|
37
|
+
public:
|
38
|
+
|
39
|
+
typedef typename internal::dense_xpr_base<ForceAlignedAccess>::type Base;
|
40
|
+
EIGEN_DENSE_PUBLIC_INTERFACE(ForceAlignedAccess)
|
41
|
+
|
42
|
+
inline ForceAlignedAccess(const ExpressionType& matrix) : m_expression(matrix) {}
|
43
|
+
|
44
|
+
inline Index rows() const { return m_expression.rows(); }
|
45
|
+
inline Index cols() const { return m_expression.cols(); }
|
46
|
+
inline Index outerStride() const { return m_expression.outerStride(); }
|
47
|
+
inline Index innerStride() const { return m_expression.innerStride(); }
|
48
|
+
|
49
|
+
inline const CoeffReturnType coeff(Index row, Index col) const
|
50
|
+
{
|
51
|
+
return m_expression.coeff(row, col);
|
52
|
+
}
|
53
|
+
|
54
|
+
inline Scalar& coeffRef(Index row, Index col)
|
55
|
+
{
|
56
|
+
return m_expression.const_cast_derived().coeffRef(row, col);
|
57
|
+
}
|
58
|
+
|
59
|
+
inline const CoeffReturnType coeff(Index index) const
|
60
|
+
{
|
61
|
+
return m_expression.coeff(index);
|
62
|
+
}
|
63
|
+
|
64
|
+
inline Scalar& coeffRef(Index index)
|
65
|
+
{
|
66
|
+
return m_expression.const_cast_derived().coeffRef(index);
|
67
|
+
}
|
68
|
+
|
69
|
+
template<int LoadMode>
|
70
|
+
inline const PacketScalar packet(Index row, Index col) const
|
71
|
+
{
|
72
|
+
return m_expression.template packet<Aligned>(row, col);
|
73
|
+
}
|
74
|
+
|
75
|
+
template<int LoadMode>
|
76
|
+
inline void writePacket(Index row, Index col, const PacketScalar& x)
|
77
|
+
{
|
78
|
+
m_expression.const_cast_derived().template writePacket<Aligned>(row, col, x);
|
79
|
+
}
|
80
|
+
|
81
|
+
template<int LoadMode>
|
82
|
+
inline const PacketScalar packet(Index index) const
|
83
|
+
{
|
84
|
+
return m_expression.template packet<Aligned>(index);
|
85
|
+
}
|
86
|
+
|
87
|
+
template<int LoadMode>
|
88
|
+
inline void writePacket(Index index, const PacketScalar& x)
|
89
|
+
{
|
90
|
+
m_expression.const_cast_derived().template writePacket<Aligned>(index, x);
|
91
|
+
}
|
92
|
+
|
93
|
+
operator const ExpressionType&() const { return m_expression; }
|
94
|
+
|
95
|
+
protected:
|
96
|
+
const ExpressionType& m_expression;
|
97
|
+
|
98
|
+
private:
|
99
|
+
ForceAlignedAccess& operator=(const ForceAlignedAccess&);
|
100
|
+
};
|
101
|
+
|
102
|
+
/** \returns an expression of *this with forced aligned access
|
103
|
+
* \sa forceAlignedAccessIf(),class ForceAlignedAccess
|
104
|
+
*/
|
105
|
+
template<typename Derived>
|
106
|
+
inline const ForceAlignedAccess<Derived>
|
107
|
+
MatrixBase<Derived>::forceAlignedAccess() const
|
108
|
+
{
|
109
|
+
return ForceAlignedAccess<Derived>(derived());
|
110
|
+
}
|
111
|
+
|
112
|
+
/** \returns an expression of *this with forced aligned access
|
113
|
+
* \sa forceAlignedAccessIf(), class ForceAlignedAccess
|
114
|
+
*/
|
115
|
+
template<typename Derived>
|
116
|
+
inline ForceAlignedAccess<Derived>
|
117
|
+
MatrixBase<Derived>::forceAlignedAccess()
|
118
|
+
{
|
119
|
+
return ForceAlignedAccess<Derived>(derived());
|
120
|
+
}
|
121
|
+
|
122
|
+
/** \returns an expression of *this with forced aligned access if \a Enable is true.
|
123
|
+
* \sa forceAlignedAccess(), class ForceAlignedAccess
|
124
|
+
*/
|
125
|
+
template<typename Derived>
|
126
|
+
template<bool Enable>
|
127
|
+
inline typename internal::add_const_on_value_type<typename internal::conditional<Enable,ForceAlignedAccess<Derived>,Derived&>::type>::type
|
128
|
+
MatrixBase<Derived>::forceAlignedAccessIf() const
|
129
|
+
{
|
130
|
+
return derived();
|
131
|
+
}
|
132
|
+
|
133
|
+
/** \returns an expression of *this with forced aligned access if \a Enable is true.
|
134
|
+
* \sa forceAlignedAccess(), class ForceAlignedAccess
|
135
|
+
*/
|
136
|
+
template<typename Derived>
|
137
|
+
template<bool Enable>
|
138
|
+
inline typename internal::conditional<Enable,ForceAlignedAccess<Derived>,Derived&>::type
|
139
|
+
MatrixBase<Derived>::forceAlignedAccessIf()
|
140
|
+
{
|
141
|
+
return derived();
|
142
|
+
}
|
143
|
+
|
144
|
+
} // end namespace Eigen
|
145
|
+
|
146
|
+
#endif // EIGEN_FORCEALIGNEDACCESS_H
|
@@ -0,0 +1,1026 @@
|
|
1
|
+
// This file is part of Eigen, a lightweight C++ template library
|
2
|
+
// for linear algebra.
|
3
|
+
//
|
4
|
+
// Copyright (C) 2008-2010 Gael Guennebaud <gael.guennebaud@inria.fr>
|
5
|
+
//
|
6
|
+
// This Source Code Form is subject to the terms of the Mozilla
|
7
|
+
// Public License v. 2.0. If a copy of the MPL was not distributed
|
8
|
+
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
9
|
+
|
10
|
+
#ifndef EIGEN_FUNCTORS_H
|
11
|
+
#define EIGEN_FUNCTORS_H
|
12
|
+
|
13
|
+
namespace Eigen {
|
14
|
+
|
15
|
+
namespace internal {
|
16
|
+
|
17
|
+
// associative functors:
|
18
|
+
|
19
|
+
/** \internal
|
20
|
+
* \brief Template functor to compute the sum of two scalars
|
21
|
+
*
|
22
|
+
* \sa class CwiseBinaryOp, MatrixBase::operator+, class VectorwiseOp, MatrixBase::sum()
|
23
|
+
*/
|
24
|
+
template<typename Scalar> struct scalar_sum_op {
|
25
|
+
EIGEN_EMPTY_STRUCT_CTOR(scalar_sum_op)
|
26
|
+
EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a, const Scalar& b) const { return a + b; }
|
27
|
+
template<typename Packet>
|
28
|
+
EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a, const Packet& b) const
|
29
|
+
{ return internal::padd(a,b); }
|
30
|
+
template<typename Packet>
|
31
|
+
EIGEN_STRONG_INLINE const Scalar predux(const Packet& a) const
|
32
|
+
{ return internal::predux(a); }
|
33
|
+
};
|
34
|
+
template<typename Scalar>
|
35
|
+
struct functor_traits<scalar_sum_op<Scalar> > {
|
36
|
+
enum {
|
37
|
+
Cost = NumTraits<Scalar>::AddCost,
|
38
|
+
PacketAccess = packet_traits<Scalar>::HasAdd
|
39
|
+
};
|
40
|
+
};
|
41
|
+
|
42
|
+
/** \internal
|
43
|
+
* \brief Template functor to compute the product of two scalars
|
44
|
+
*
|
45
|
+
* \sa class CwiseBinaryOp, Cwise::operator*(), class VectorwiseOp, MatrixBase::redux()
|
46
|
+
*/
|
47
|
+
template<typename LhsScalar,typename RhsScalar> struct scalar_product_op {
|
48
|
+
enum {
|
49
|
+
// TODO vectorize mixed product
|
50
|
+
Vectorizable = is_same<LhsScalar,RhsScalar>::value && packet_traits<LhsScalar>::HasMul && packet_traits<RhsScalar>::HasMul
|
51
|
+
};
|
52
|
+
typedef typename scalar_product_traits<LhsScalar,RhsScalar>::ReturnType result_type;
|
53
|
+
EIGEN_EMPTY_STRUCT_CTOR(scalar_product_op)
|
54
|
+
EIGEN_STRONG_INLINE const result_type operator() (const LhsScalar& a, const RhsScalar& b) const { return a * b; }
|
55
|
+
template<typename Packet>
|
56
|
+
EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a, const Packet& b) const
|
57
|
+
{ return internal::pmul(a,b); }
|
58
|
+
template<typename Packet>
|
59
|
+
EIGEN_STRONG_INLINE const result_type predux(const Packet& a) const
|
60
|
+
{ return internal::predux_mul(a); }
|
61
|
+
};
|
62
|
+
template<typename LhsScalar,typename RhsScalar>
|
63
|
+
struct functor_traits<scalar_product_op<LhsScalar,RhsScalar> > {
|
64
|
+
enum {
|
65
|
+
Cost = (NumTraits<LhsScalar>::MulCost + NumTraits<RhsScalar>::MulCost)/2, // rough estimate!
|
66
|
+
PacketAccess = scalar_product_op<LhsScalar,RhsScalar>::Vectorizable
|
67
|
+
};
|
68
|
+
};
|
69
|
+
|
70
|
+
/** \internal
|
71
|
+
* \brief Template functor to compute the conjugate product of two scalars
|
72
|
+
*
|
73
|
+
* This is a short cut for conj(x) * y which is needed for optimization purpose; in Eigen2 support mode, this becomes x * conj(y)
|
74
|
+
*/
|
75
|
+
template<typename LhsScalar,typename RhsScalar> struct scalar_conj_product_op {
|
76
|
+
|
77
|
+
enum {
|
78
|
+
Conj = NumTraits<LhsScalar>::IsComplex
|
79
|
+
};
|
80
|
+
|
81
|
+
typedef typename scalar_product_traits<LhsScalar,RhsScalar>::ReturnType result_type;
|
82
|
+
|
83
|
+
EIGEN_EMPTY_STRUCT_CTOR(scalar_conj_product_op)
|
84
|
+
EIGEN_STRONG_INLINE const result_type operator() (const LhsScalar& a, const RhsScalar& b) const
|
85
|
+
{ return conj_helper<LhsScalar,RhsScalar,Conj,false>().pmul(a,b); }
|
86
|
+
|
87
|
+
template<typename Packet>
|
88
|
+
EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a, const Packet& b) const
|
89
|
+
{ return conj_helper<Packet,Packet,Conj,false>().pmul(a,b); }
|
90
|
+
};
|
91
|
+
template<typename LhsScalar,typename RhsScalar>
|
92
|
+
struct functor_traits<scalar_conj_product_op<LhsScalar,RhsScalar> > {
|
93
|
+
enum {
|
94
|
+
Cost = NumTraits<LhsScalar>::MulCost,
|
95
|
+
PacketAccess = internal::is_same<LhsScalar, RhsScalar>::value && packet_traits<LhsScalar>::HasMul
|
96
|
+
};
|
97
|
+
};
|
98
|
+
|
99
|
+
/** \internal
|
100
|
+
* \brief Template functor to compute the min of two scalars
|
101
|
+
*
|
102
|
+
* \sa class CwiseBinaryOp, MatrixBase::cwiseMin, class VectorwiseOp, MatrixBase::minCoeff()
|
103
|
+
*/
|
104
|
+
template<typename Scalar> struct scalar_min_op {
|
105
|
+
EIGEN_EMPTY_STRUCT_CTOR(scalar_min_op)
|
106
|
+
EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a, const Scalar& b) const { using std::min; return (min)(a, b); }
|
107
|
+
template<typename Packet>
|
108
|
+
EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a, const Packet& b) const
|
109
|
+
{ return internal::pmin(a,b); }
|
110
|
+
template<typename Packet>
|
111
|
+
EIGEN_STRONG_INLINE const Scalar predux(const Packet& a) const
|
112
|
+
{ return internal::predux_min(a); }
|
113
|
+
};
|
114
|
+
template<typename Scalar>
|
115
|
+
struct functor_traits<scalar_min_op<Scalar> > {
|
116
|
+
enum {
|
117
|
+
Cost = NumTraits<Scalar>::AddCost,
|
118
|
+
PacketAccess = packet_traits<Scalar>::HasMin
|
119
|
+
};
|
120
|
+
};
|
121
|
+
|
122
|
+
/** \internal
|
123
|
+
* \brief Template functor to compute the max of two scalars
|
124
|
+
*
|
125
|
+
* \sa class CwiseBinaryOp, MatrixBase::cwiseMax, class VectorwiseOp, MatrixBase::maxCoeff()
|
126
|
+
*/
|
127
|
+
template<typename Scalar> struct scalar_max_op {
|
128
|
+
EIGEN_EMPTY_STRUCT_CTOR(scalar_max_op)
|
129
|
+
EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a, const Scalar& b) const { using std::max; return (max)(a, b); }
|
130
|
+
template<typename Packet>
|
131
|
+
EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a, const Packet& b) const
|
132
|
+
{ return internal::pmax(a,b); }
|
133
|
+
template<typename Packet>
|
134
|
+
EIGEN_STRONG_INLINE const Scalar predux(const Packet& a) const
|
135
|
+
{ return internal::predux_max(a); }
|
136
|
+
};
|
137
|
+
template<typename Scalar>
|
138
|
+
struct functor_traits<scalar_max_op<Scalar> > {
|
139
|
+
enum {
|
140
|
+
Cost = NumTraits<Scalar>::AddCost,
|
141
|
+
PacketAccess = packet_traits<Scalar>::HasMax
|
142
|
+
};
|
143
|
+
};
|
144
|
+
|
145
|
+
/** \internal
|
146
|
+
* \brief Template functor to compute the hypot of two scalars
|
147
|
+
*
|
148
|
+
* \sa MatrixBase::stableNorm(), class Redux
|
149
|
+
*/
|
150
|
+
template<typename Scalar> struct scalar_hypot_op {
|
151
|
+
EIGEN_EMPTY_STRUCT_CTOR(scalar_hypot_op)
|
152
|
+
// typedef typename NumTraits<Scalar>::Real result_type;
|
153
|
+
EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& _x, const Scalar& _y) const
|
154
|
+
{
|
155
|
+
using std::max;
|
156
|
+
using std::min;
|
157
|
+
using std::sqrt;
|
158
|
+
Scalar p = (max)(_x, _y);
|
159
|
+
Scalar q = (min)(_x, _y);
|
160
|
+
Scalar qp = q/p;
|
161
|
+
return p * sqrt(Scalar(1) + qp*qp);
|
162
|
+
}
|
163
|
+
};
|
164
|
+
template<typename Scalar>
|
165
|
+
struct functor_traits<scalar_hypot_op<Scalar> > {
|
166
|
+
enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess=0 };
|
167
|
+
};
|
168
|
+
|
169
|
+
/** \internal
|
170
|
+
* \brief Template functor to compute the pow of two scalars
|
171
|
+
*/
|
172
|
+
template<typename Scalar, typename OtherScalar> struct scalar_binary_pow_op {
|
173
|
+
EIGEN_EMPTY_STRUCT_CTOR(scalar_binary_pow_op)
|
174
|
+
inline Scalar operator() (const Scalar& a, const OtherScalar& b) const { return numext::pow(a, b); }
|
175
|
+
};
|
176
|
+
template<typename Scalar, typename OtherScalar>
|
177
|
+
struct functor_traits<scalar_binary_pow_op<Scalar,OtherScalar> > {
|
178
|
+
enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = false };
|
179
|
+
};
|
180
|
+
|
181
|
+
// other binary functors:
|
182
|
+
|
183
|
+
/** \internal
|
184
|
+
* \brief Template functor to compute the difference of two scalars
|
185
|
+
*
|
186
|
+
* \sa class CwiseBinaryOp, MatrixBase::operator-
|
187
|
+
*/
|
188
|
+
template<typename Scalar> struct scalar_difference_op {
|
189
|
+
EIGEN_EMPTY_STRUCT_CTOR(scalar_difference_op)
|
190
|
+
EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a, const Scalar& b) const { return a - b; }
|
191
|
+
template<typename Packet>
|
192
|
+
EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a, const Packet& b) const
|
193
|
+
{ return internal::psub(a,b); }
|
194
|
+
};
|
195
|
+
template<typename Scalar>
|
196
|
+
struct functor_traits<scalar_difference_op<Scalar> > {
|
197
|
+
enum {
|
198
|
+
Cost = NumTraits<Scalar>::AddCost,
|
199
|
+
PacketAccess = packet_traits<Scalar>::HasSub
|
200
|
+
};
|
201
|
+
};
|
202
|
+
|
203
|
+
/** \internal
|
204
|
+
* \brief Template functor to compute the quotient of two scalars
|
205
|
+
*
|
206
|
+
* \sa class CwiseBinaryOp, Cwise::operator/()
|
207
|
+
*/
|
208
|
+
template<typename LhsScalar,typename RhsScalar> struct scalar_quotient_op {
|
209
|
+
enum {
|
210
|
+
// TODO vectorize mixed product
|
211
|
+
Vectorizable = is_same<LhsScalar,RhsScalar>::value && packet_traits<LhsScalar>::HasDiv && packet_traits<RhsScalar>::HasDiv
|
212
|
+
};
|
213
|
+
typedef typename scalar_product_traits<LhsScalar,RhsScalar>::ReturnType result_type;
|
214
|
+
EIGEN_EMPTY_STRUCT_CTOR(scalar_quotient_op)
|
215
|
+
EIGEN_STRONG_INLINE const result_type operator() (const LhsScalar& a, const RhsScalar& b) const { return a / b; }
|
216
|
+
template<typename Packet>
|
217
|
+
EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a, const Packet& b) const
|
218
|
+
{ return internal::pdiv(a,b); }
|
219
|
+
};
|
220
|
+
template<typename LhsScalar,typename RhsScalar>
|
221
|
+
struct functor_traits<scalar_quotient_op<LhsScalar,RhsScalar> > {
|
222
|
+
enum {
|
223
|
+
Cost = (NumTraits<LhsScalar>::MulCost + NumTraits<RhsScalar>::MulCost), // rough estimate!
|
224
|
+
PacketAccess = scalar_quotient_op<LhsScalar,RhsScalar>::Vectorizable
|
225
|
+
};
|
226
|
+
};
|
227
|
+
|
228
|
+
|
229
|
+
|
230
|
+
/** \internal
|
231
|
+
* \brief Template functor to compute the and of two booleans
|
232
|
+
*
|
233
|
+
* \sa class CwiseBinaryOp, ArrayBase::operator&&
|
234
|
+
*/
|
235
|
+
struct scalar_boolean_and_op {
|
236
|
+
EIGEN_EMPTY_STRUCT_CTOR(scalar_boolean_and_op)
|
237
|
+
EIGEN_STRONG_INLINE bool operator() (const bool& a, const bool& b) const { return a && b; }
|
238
|
+
};
|
239
|
+
template<> struct functor_traits<scalar_boolean_and_op> {
|
240
|
+
enum {
|
241
|
+
Cost = NumTraits<bool>::AddCost,
|
242
|
+
PacketAccess = false
|
243
|
+
};
|
244
|
+
};
|
245
|
+
|
246
|
+
/** \internal
|
247
|
+
* \brief Template functor to compute the or of two booleans
|
248
|
+
*
|
249
|
+
* \sa class CwiseBinaryOp, ArrayBase::operator||
|
250
|
+
*/
|
251
|
+
struct scalar_boolean_or_op {
|
252
|
+
EIGEN_EMPTY_STRUCT_CTOR(scalar_boolean_or_op)
|
253
|
+
EIGEN_STRONG_INLINE bool operator() (const bool& a, const bool& b) const { return a || b; }
|
254
|
+
};
|
255
|
+
template<> struct functor_traits<scalar_boolean_or_op> {
|
256
|
+
enum {
|
257
|
+
Cost = NumTraits<bool>::AddCost,
|
258
|
+
PacketAccess = false
|
259
|
+
};
|
260
|
+
};
|
261
|
+
|
262
|
+
/** \internal
|
263
|
+
* \brief Template functors for comparison of two scalars
|
264
|
+
* \todo Implement packet-comparisons
|
265
|
+
*/
|
266
|
+
template<typename Scalar, ComparisonName cmp> struct scalar_cmp_op;
|
267
|
+
|
268
|
+
template<typename Scalar, ComparisonName cmp>
|
269
|
+
struct functor_traits<scalar_cmp_op<Scalar, cmp> > {
|
270
|
+
enum {
|
271
|
+
Cost = NumTraits<Scalar>::AddCost,
|
272
|
+
PacketAccess = false
|
273
|
+
};
|
274
|
+
};
|
275
|
+
|
276
|
+
template<ComparisonName Cmp, typename Scalar>
|
277
|
+
struct result_of<scalar_cmp_op<Scalar, Cmp>(Scalar,Scalar)> {
|
278
|
+
typedef bool type;
|
279
|
+
};
|
280
|
+
|
281
|
+
|
282
|
+
template<typename Scalar> struct scalar_cmp_op<Scalar, cmp_EQ> {
|
283
|
+
EIGEN_EMPTY_STRUCT_CTOR(scalar_cmp_op)
|
284
|
+
EIGEN_STRONG_INLINE bool operator()(const Scalar& a, const Scalar& b) const {return a==b;}
|
285
|
+
};
|
286
|
+
template<typename Scalar> struct scalar_cmp_op<Scalar, cmp_LT> {
|
287
|
+
EIGEN_EMPTY_STRUCT_CTOR(scalar_cmp_op)
|
288
|
+
EIGEN_STRONG_INLINE bool operator()(const Scalar& a, const Scalar& b) const {return a<b;}
|
289
|
+
};
|
290
|
+
template<typename Scalar> struct scalar_cmp_op<Scalar, cmp_LE> {
|
291
|
+
EIGEN_EMPTY_STRUCT_CTOR(scalar_cmp_op)
|
292
|
+
EIGEN_STRONG_INLINE bool operator()(const Scalar& a, const Scalar& b) const {return a<=b;}
|
293
|
+
};
|
294
|
+
template<typename Scalar> struct scalar_cmp_op<Scalar, cmp_UNORD> {
|
295
|
+
EIGEN_EMPTY_STRUCT_CTOR(scalar_cmp_op)
|
296
|
+
EIGEN_STRONG_INLINE bool operator()(const Scalar& a, const Scalar& b) const {return !(a<=b || b<=a);}
|
297
|
+
};
|
298
|
+
template<typename Scalar> struct scalar_cmp_op<Scalar, cmp_NEQ> {
|
299
|
+
EIGEN_EMPTY_STRUCT_CTOR(scalar_cmp_op)
|
300
|
+
EIGEN_STRONG_INLINE bool operator()(const Scalar& a, const Scalar& b) const {return a!=b;}
|
301
|
+
};
|
302
|
+
|
303
|
+
// unary functors:
|
304
|
+
|
305
|
+
/** \internal
|
306
|
+
* \brief Template functor to compute the opposite of a scalar
|
307
|
+
*
|
308
|
+
* \sa class CwiseUnaryOp, MatrixBase::operator-
|
309
|
+
*/
|
310
|
+
template<typename Scalar> struct scalar_opposite_op {
|
311
|
+
EIGEN_EMPTY_STRUCT_CTOR(scalar_opposite_op)
|
312
|
+
EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a) const { return -a; }
|
313
|
+
template<typename Packet>
|
314
|
+
EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a) const
|
315
|
+
{ return internal::pnegate(a); }
|
316
|
+
};
|
317
|
+
template<typename Scalar>
|
318
|
+
struct functor_traits<scalar_opposite_op<Scalar> >
|
319
|
+
{ enum {
|
320
|
+
Cost = NumTraits<Scalar>::AddCost,
|
321
|
+
PacketAccess = packet_traits<Scalar>::HasNegate };
|
322
|
+
};
|
323
|
+
|
324
|
+
/** \internal
|
325
|
+
* \brief Template functor to compute the absolute value of a scalar
|
326
|
+
*
|
327
|
+
* \sa class CwiseUnaryOp, Cwise::abs
|
328
|
+
*/
|
329
|
+
template<typename Scalar> struct scalar_abs_op {
|
330
|
+
EIGEN_EMPTY_STRUCT_CTOR(scalar_abs_op)
|
331
|
+
typedef typename NumTraits<Scalar>::Real result_type;
|
332
|
+
EIGEN_STRONG_INLINE const result_type operator() (const Scalar& a) const { using std::abs; return abs(a); }
|
333
|
+
template<typename Packet>
|
334
|
+
EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a) const
|
335
|
+
{ return internal::pabs(a); }
|
336
|
+
};
|
337
|
+
template<typename Scalar>
|
338
|
+
struct functor_traits<scalar_abs_op<Scalar> >
|
339
|
+
{
|
340
|
+
enum {
|
341
|
+
Cost = NumTraits<Scalar>::AddCost,
|
342
|
+
PacketAccess = packet_traits<Scalar>::HasAbs
|
343
|
+
};
|
344
|
+
};
|
345
|
+
|
346
|
+
/** \internal
|
347
|
+
* \brief Template functor to compute the squared absolute value of a scalar
|
348
|
+
*
|
349
|
+
* \sa class CwiseUnaryOp, Cwise::abs2
|
350
|
+
*/
|
351
|
+
template<typename Scalar> struct scalar_abs2_op {
|
352
|
+
EIGEN_EMPTY_STRUCT_CTOR(scalar_abs2_op)
|
353
|
+
typedef typename NumTraits<Scalar>::Real result_type;
|
354
|
+
EIGEN_STRONG_INLINE const result_type operator() (const Scalar& a) const { return numext::abs2(a); }
|
355
|
+
template<typename Packet>
|
356
|
+
EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a) const
|
357
|
+
{ return internal::pmul(a,a); }
|
358
|
+
};
|
359
|
+
template<typename Scalar>
|
360
|
+
struct functor_traits<scalar_abs2_op<Scalar> >
|
361
|
+
{ enum { Cost = NumTraits<Scalar>::MulCost, PacketAccess = packet_traits<Scalar>::HasAbs2 }; };
|
362
|
+
|
363
|
+
/** \internal
|
364
|
+
* \brief Template functor to compute the conjugate of a complex value
|
365
|
+
*
|
366
|
+
* \sa class CwiseUnaryOp, MatrixBase::conjugate()
|
367
|
+
*/
|
368
|
+
template<typename Scalar> struct scalar_conjugate_op {
|
369
|
+
EIGEN_EMPTY_STRUCT_CTOR(scalar_conjugate_op)
|
370
|
+
EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a) const { using numext::conj; return conj(a); }
|
371
|
+
template<typename Packet>
|
372
|
+
EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a) const { return internal::pconj(a); }
|
373
|
+
};
|
374
|
+
template<typename Scalar>
|
375
|
+
struct functor_traits<scalar_conjugate_op<Scalar> >
|
376
|
+
{
|
377
|
+
enum {
|
378
|
+
Cost = NumTraits<Scalar>::IsComplex ? NumTraits<Scalar>::AddCost : 0,
|
379
|
+
PacketAccess = packet_traits<Scalar>::HasConj
|
380
|
+
};
|
381
|
+
};
|
382
|
+
|
383
|
+
/** \internal
|
384
|
+
* \brief Template functor to cast a scalar to another type
|
385
|
+
*
|
386
|
+
* \sa class CwiseUnaryOp, MatrixBase::cast()
|
387
|
+
*/
|
388
|
+
template<typename Scalar, typename NewType>
|
389
|
+
struct scalar_cast_op {
|
390
|
+
EIGEN_EMPTY_STRUCT_CTOR(scalar_cast_op)
|
391
|
+
typedef NewType result_type;
|
392
|
+
EIGEN_STRONG_INLINE const NewType operator() (const Scalar& a) const { return cast<Scalar, NewType>(a); }
|
393
|
+
};
|
394
|
+
template<typename Scalar, typename NewType>
|
395
|
+
struct functor_traits<scalar_cast_op<Scalar,NewType> >
|
396
|
+
{ enum { Cost = is_same<Scalar, NewType>::value ? 0 : NumTraits<NewType>::AddCost, PacketAccess = false }; };
|
397
|
+
|
398
|
+
/** \internal
|
399
|
+
* \brief Template functor to extract the real part of a complex
|
400
|
+
*
|
401
|
+
* \sa class CwiseUnaryOp, MatrixBase::real()
|
402
|
+
*/
|
403
|
+
template<typename Scalar>
|
404
|
+
struct scalar_real_op {
|
405
|
+
EIGEN_EMPTY_STRUCT_CTOR(scalar_real_op)
|
406
|
+
typedef typename NumTraits<Scalar>::Real result_type;
|
407
|
+
EIGEN_STRONG_INLINE result_type operator() (const Scalar& a) const { return numext::real(a); }
|
408
|
+
};
|
409
|
+
template<typename Scalar>
|
410
|
+
struct functor_traits<scalar_real_op<Scalar> >
|
411
|
+
{ enum { Cost = 0, PacketAccess = false }; };
|
412
|
+
|
413
|
+
/** \internal
|
414
|
+
* \brief Template functor to extract the imaginary part of a complex
|
415
|
+
*
|
416
|
+
* \sa class CwiseUnaryOp, MatrixBase::imag()
|
417
|
+
*/
|
418
|
+
template<typename Scalar>
|
419
|
+
struct scalar_imag_op {
|
420
|
+
EIGEN_EMPTY_STRUCT_CTOR(scalar_imag_op)
|
421
|
+
typedef typename NumTraits<Scalar>::Real result_type;
|
422
|
+
EIGEN_STRONG_INLINE result_type operator() (const Scalar& a) const { return numext::imag(a); }
|
423
|
+
};
|
424
|
+
template<typename Scalar>
|
425
|
+
struct functor_traits<scalar_imag_op<Scalar> >
|
426
|
+
{ enum { Cost = 0, PacketAccess = false }; };
|
427
|
+
|
428
|
+
/** \internal
|
429
|
+
* \brief Template functor to extract the real part of a complex as a reference
|
430
|
+
*
|
431
|
+
* \sa class CwiseUnaryOp, MatrixBase::real()
|
432
|
+
*/
|
433
|
+
template<typename Scalar>
|
434
|
+
struct scalar_real_ref_op {
|
435
|
+
EIGEN_EMPTY_STRUCT_CTOR(scalar_real_ref_op)
|
436
|
+
typedef typename NumTraits<Scalar>::Real result_type;
|
437
|
+
EIGEN_STRONG_INLINE result_type& operator() (const Scalar& a) const { return numext::real_ref(*const_cast<Scalar*>(&a)); }
|
438
|
+
};
|
439
|
+
template<typename Scalar>
|
440
|
+
struct functor_traits<scalar_real_ref_op<Scalar> >
|
441
|
+
{ enum { Cost = 0, PacketAccess = false }; };
|
442
|
+
|
443
|
+
/** \internal
|
444
|
+
* \brief Template functor to extract the imaginary part of a complex as a reference
|
445
|
+
*
|
446
|
+
* \sa class CwiseUnaryOp, MatrixBase::imag()
|
447
|
+
*/
|
448
|
+
template<typename Scalar>
|
449
|
+
struct scalar_imag_ref_op {
|
450
|
+
EIGEN_EMPTY_STRUCT_CTOR(scalar_imag_ref_op)
|
451
|
+
typedef typename NumTraits<Scalar>::Real result_type;
|
452
|
+
EIGEN_STRONG_INLINE result_type& operator() (const Scalar& a) const { return numext::imag_ref(*const_cast<Scalar*>(&a)); }
|
453
|
+
};
|
454
|
+
template<typename Scalar>
|
455
|
+
struct functor_traits<scalar_imag_ref_op<Scalar> >
|
456
|
+
{ enum { Cost = 0, PacketAccess = false }; };
|
457
|
+
|
458
|
+
/** \internal
|
459
|
+
*
|
460
|
+
* \brief Template functor to compute the exponential of a scalar
|
461
|
+
*
|
462
|
+
* \sa class CwiseUnaryOp, Cwise::exp()
|
463
|
+
*/
|
464
|
+
template<typename Scalar> struct scalar_exp_op {
|
465
|
+
EIGEN_EMPTY_STRUCT_CTOR(scalar_exp_op)
|
466
|
+
inline const Scalar operator() (const Scalar& a) const { using std::exp; return exp(a); }
|
467
|
+
typedef typename packet_traits<Scalar>::type Packet;
|
468
|
+
inline Packet packetOp(const Packet& a) const { return internal::pexp(a); }
|
469
|
+
};
|
470
|
+
template<typename Scalar>
|
471
|
+
struct functor_traits<scalar_exp_op<Scalar> >
|
472
|
+
{ enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = packet_traits<Scalar>::HasExp }; };
|
473
|
+
|
474
|
+
/** \internal
|
475
|
+
*
|
476
|
+
* \brief Template functor to compute the logarithm of a scalar
|
477
|
+
*
|
478
|
+
* \sa class CwiseUnaryOp, Cwise::log()
|
479
|
+
*/
|
480
|
+
template<typename Scalar> struct scalar_log_op {
|
481
|
+
EIGEN_EMPTY_STRUCT_CTOR(scalar_log_op)
|
482
|
+
inline const Scalar operator() (const Scalar& a) const { using std::log; return log(a); }
|
483
|
+
typedef typename packet_traits<Scalar>::type Packet;
|
484
|
+
inline Packet packetOp(const Packet& a) const { return internal::plog(a); }
|
485
|
+
};
|
486
|
+
template<typename Scalar>
|
487
|
+
struct functor_traits<scalar_log_op<Scalar> >
|
488
|
+
{ enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = packet_traits<Scalar>::HasLog }; };
|
489
|
+
|
490
|
+
/** \internal
|
491
|
+
* \brief Template functor to multiply a scalar by a fixed other one
|
492
|
+
*
|
493
|
+
* \sa class CwiseUnaryOp, MatrixBase::operator*, MatrixBase::operator/
|
494
|
+
*/
|
495
|
+
/* NOTE why doing the pset1() in packetOp *is* an optimization ?
|
496
|
+
* indeed it seems better to declare m_other as a Packet and do the pset1() once
|
497
|
+
* in the constructor. However, in practice:
|
498
|
+
* - GCC does not like m_other as a Packet and generate a load every time it needs it
|
499
|
+
* - on the other hand GCC is able to moves the pset1() outside the loop :)
|
500
|
+
* - simpler code ;)
|
501
|
+
* (ICC and gcc 4.4 seems to perform well in both cases, the issue is visible with y = a*x + b*y)
|
502
|
+
*/
|
503
|
+
template<typename Scalar>
|
504
|
+
struct scalar_multiple_op {
|
505
|
+
typedef typename packet_traits<Scalar>::type Packet;
|
506
|
+
// FIXME default copy constructors seems bugged with std::complex<>
|
507
|
+
EIGEN_STRONG_INLINE scalar_multiple_op(const scalar_multiple_op& other) : m_other(other.m_other) { }
|
508
|
+
EIGEN_STRONG_INLINE scalar_multiple_op(const Scalar& other) : m_other(other) { }
|
509
|
+
EIGEN_STRONG_INLINE Scalar operator() (const Scalar& a) const { return a * m_other; }
|
510
|
+
EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a) const
|
511
|
+
{ return internal::pmul(a, pset1<Packet>(m_other)); }
|
512
|
+
typename add_const_on_value_type<typename NumTraits<Scalar>::Nested>::type m_other;
|
513
|
+
};
|
514
|
+
template<typename Scalar>
|
515
|
+
struct functor_traits<scalar_multiple_op<Scalar> >
|
516
|
+
{ enum { Cost = NumTraits<Scalar>::MulCost, PacketAccess = packet_traits<Scalar>::HasMul }; };
|
517
|
+
|
518
|
+
template<typename Scalar1, typename Scalar2>
|
519
|
+
struct scalar_multiple2_op {
|
520
|
+
typedef typename scalar_product_traits<Scalar1,Scalar2>::ReturnType result_type;
|
521
|
+
EIGEN_STRONG_INLINE scalar_multiple2_op(const scalar_multiple2_op& other) : m_other(other.m_other) { }
|
522
|
+
EIGEN_STRONG_INLINE scalar_multiple2_op(const Scalar2& other) : m_other(other) { }
|
523
|
+
EIGEN_STRONG_INLINE result_type operator() (const Scalar1& a) const { return a * m_other; }
|
524
|
+
typename add_const_on_value_type<typename NumTraits<Scalar2>::Nested>::type m_other;
|
525
|
+
};
|
526
|
+
template<typename Scalar1,typename Scalar2>
|
527
|
+
struct functor_traits<scalar_multiple2_op<Scalar1,Scalar2> >
|
528
|
+
{ enum { Cost = NumTraits<Scalar1>::MulCost, PacketAccess = false }; };
|
529
|
+
|
530
|
+
/** \internal
|
531
|
+
* \brief Template functor to divide a scalar by a fixed other one
|
532
|
+
*
|
533
|
+
* This functor is used to implement the quotient of a matrix by
|
534
|
+
* a scalar where the scalar type is not necessarily a floating point type.
|
535
|
+
*
|
536
|
+
* \sa class CwiseUnaryOp, MatrixBase::operator/
|
537
|
+
*/
|
538
|
+
template<typename Scalar>
|
539
|
+
struct scalar_quotient1_op {
|
540
|
+
typedef typename packet_traits<Scalar>::type Packet;
|
541
|
+
// FIXME default copy constructors seems bugged with std::complex<>
|
542
|
+
EIGEN_STRONG_INLINE scalar_quotient1_op(const scalar_quotient1_op& other) : m_other(other.m_other) { }
|
543
|
+
EIGEN_STRONG_INLINE scalar_quotient1_op(const Scalar& other) : m_other(other) {}
|
544
|
+
EIGEN_STRONG_INLINE Scalar operator() (const Scalar& a) const { return a / m_other; }
|
545
|
+
EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a) const
|
546
|
+
{ return internal::pdiv(a, pset1<Packet>(m_other)); }
|
547
|
+
typename add_const_on_value_type<typename NumTraits<Scalar>::Nested>::type m_other;
|
548
|
+
};
|
549
|
+
template<typename Scalar>
|
550
|
+
struct functor_traits<scalar_quotient1_op<Scalar> >
|
551
|
+
{ enum { Cost = 2 * NumTraits<Scalar>::MulCost, PacketAccess = packet_traits<Scalar>::HasDiv }; };
|
552
|
+
|
553
|
+
// nullary functors
|
554
|
+
|
555
|
+
template<typename Scalar>
|
556
|
+
struct scalar_constant_op {
|
557
|
+
typedef typename packet_traits<Scalar>::type Packet;
|
558
|
+
EIGEN_STRONG_INLINE scalar_constant_op(const scalar_constant_op& other) : m_other(other.m_other) { }
|
559
|
+
EIGEN_STRONG_INLINE scalar_constant_op(const Scalar& other) : m_other(other) { }
|
560
|
+
template<typename Index>
|
561
|
+
EIGEN_STRONG_INLINE const Scalar operator() (Index, Index = 0) const { return m_other; }
|
562
|
+
template<typename Index>
|
563
|
+
EIGEN_STRONG_INLINE const Packet packetOp(Index, Index = 0) const { return internal::pset1<Packet>(m_other); }
|
564
|
+
const Scalar m_other;
|
565
|
+
};
|
566
|
+
template<typename Scalar>
|
567
|
+
struct functor_traits<scalar_constant_op<Scalar> >
|
568
|
+
// FIXME replace this packet test by a safe one
|
569
|
+
{ enum { Cost = 1, PacketAccess = packet_traits<Scalar>::Vectorizable, IsRepeatable = true }; };
|
570
|
+
|
571
|
+
template<typename Scalar> struct scalar_identity_op {
|
572
|
+
EIGEN_EMPTY_STRUCT_CTOR(scalar_identity_op)
|
573
|
+
template<typename Index>
|
574
|
+
EIGEN_STRONG_INLINE const Scalar operator() (Index row, Index col) const { return row==col ? Scalar(1) : Scalar(0); }
|
575
|
+
};
|
576
|
+
template<typename Scalar>
|
577
|
+
struct functor_traits<scalar_identity_op<Scalar> >
|
578
|
+
{ enum { Cost = NumTraits<Scalar>::AddCost, PacketAccess = false, IsRepeatable = true }; };
|
579
|
+
|
580
|
+
template <typename Scalar, bool RandomAccess> struct linspaced_op_impl;
|
581
|
+
|
582
|
+
// linear access for packet ops:
|
583
|
+
// 1) initialization
|
584
|
+
// base = [low, ..., low] + ([step, ..., step] * [-size, ..., 0])
|
585
|
+
// 2) each step (where size is 1 for coeff access or PacketSize for packet access)
|
586
|
+
// base += [size*step, ..., size*step]
|
587
|
+
//
|
588
|
+
// TODO: Perhaps it's better to initialize lazily (so not in the constructor but in packetOp)
|
589
|
+
// in order to avoid the padd() in operator() ?
|
590
|
+
template <typename Scalar>
|
591
|
+
struct linspaced_op_impl<Scalar,false>
|
592
|
+
{
|
593
|
+
typedef typename packet_traits<Scalar>::type Packet;
|
594
|
+
|
595
|
+
linspaced_op_impl(const Scalar& low, const Scalar& step) :
|
596
|
+
m_low(low), m_step(step),
|
597
|
+
m_packetStep(pset1<Packet>(packet_traits<Scalar>::size*step)),
|
598
|
+
m_base(padd(pset1<Packet>(low), pmul(pset1<Packet>(step),plset<Scalar>(-packet_traits<Scalar>::size)))) {}
|
599
|
+
|
600
|
+
template<typename Index>
|
601
|
+
EIGEN_STRONG_INLINE const Scalar operator() (Index i) const
|
602
|
+
{
|
603
|
+
m_base = padd(m_base, pset1<Packet>(m_step));
|
604
|
+
return m_low+Scalar(i)*m_step;
|
605
|
+
}
|
606
|
+
|
607
|
+
template<typename Index>
|
608
|
+
EIGEN_STRONG_INLINE const Packet packetOp(Index) const { return m_base = padd(m_base,m_packetStep); }
|
609
|
+
|
610
|
+
const Scalar m_low;
|
611
|
+
const Scalar m_step;
|
612
|
+
const Packet m_packetStep;
|
613
|
+
mutable Packet m_base;
|
614
|
+
};
|
615
|
+
|
616
|
+
// random access for packet ops:
|
617
|
+
// 1) each step
|
618
|
+
// [low, ..., low] + ( [step, ..., step] * ( [i, ..., i] + [0, ..., size] ) )
|
619
|
+
template <typename Scalar>
|
620
|
+
struct linspaced_op_impl<Scalar,true>
|
621
|
+
{
|
622
|
+
typedef typename packet_traits<Scalar>::type Packet;
|
623
|
+
|
624
|
+
linspaced_op_impl(const Scalar& low, const Scalar& step) :
|
625
|
+
m_low(low), m_step(step),
|
626
|
+
m_lowPacket(pset1<Packet>(m_low)), m_stepPacket(pset1<Packet>(m_step)), m_interPacket(plset<Scalar>(0)) {}
|
627
|
+
|
628
|
+
template<typename Index>
|
629
|
+
EIGEN_STRONG_INLINE const Scalar operator() (Index i) const { return m_low+i*m_step; }
|
630
|
+
|
631
|
+
template<typename Index>
|
632
|
+
EIGEN_STRONG_INLINE const Packet packetOp(Index i) const
|
633
|
+
{ return internal::padd(m_lowPacket, pmul(m_stepPacket, padd(pset1<Packet>(Scalar(i)),m_interPacket))); }
|
634
|
+
|
635
|
+
const Scalar m_low;
|
636
|
+
const Scalar m_step;
|
637
|
+
const Packet m_lowPacket;
|
638
|
+
const Packet m_stepPacket;
|
639
|
+
const Packet m_interPacket;
|
640
|
+
};
|
641
|
+
|
642
|
+
// ----- Linspace functor ----------------------------------------------------------------
|
643
|
+
|
644
|
+
// Forward declaration (we default to random access which does not really give
|
645
|
+
// us a speed gain when using packet access but it allows to use the functor in
|
646
|
+
// nested expressions).
|
647
|
+
template <typename Scalar, bool RandomAccess = true> struct linspaced_op;
|
648
|
+
template <typename Scalar, bool RandomAccess> struct functor_traits< linspaced_op<Scalar,RandomAccess> >
|
649
|
+
{ enum { Cost = 1, PacketAccess = packet_traits<Scalar>::HasSetLinear, IsRepeatable = true }; };
|
650
|
+
template <typename Scalar, bool RandomAccess> struct linspaced_op
|
651
|
+
{
|
652
|
+
typedef typename packet_traits<Scalar>::type Packet;
|
653
|
+
linspaced_op(const Scalar& low, const Scalar& high, DenseIndex num_steps) : impl((num_steps==1 ? high : low), (num_steps==1 ? Scalar() : (high-low)/Scalar(num_steps-1))) {}
|
654
|
+
|
655
|
+
template<typename Index>
|
656
|
+
EIGEN_STRONG_INLINE const Scalar operator() (Index i) const { return impl(i); }
|
657
|
+
|
658
|
+
// We need this function when assigning e.g. a RowVectorXd to a MatrixXd since
|
659
|
+
// there row==0 and col is used for the actual iteration.
|
660
|
+
template<typename Index>
|
661
|
+
EIGEN_STRONG_INLINE const Scalar operator() (Index row, Index col) const
|
662
|
+
{
|
663
|
+
eigen_assert(col==0 || row==0);
|
664
|
+
return impl(col + row);
|
665
|
+
}
|
666
|
+
|
667
|
+
template<typename Index>
|
668
|
+
EIGEN_STRONG_INLINE const Packet packetOp(Index i) const { return impl.packetOp(i); }
|
669
|
+
|
670
|
+
// We need this function when assigning e.g. a RowVectorXd to a MatrixXd since
|
671
|
+
// there row==0 and col is used for the actual iteration.
|
672
|
+
template<typename Index>
|
673
|
+
EIGEN_STRONG_INLINE const Packet packetOp(Index row, Index col) const
|
674
|
+
{
|
675
|
+
eigen_assert(col==0 || row==0);
|
676
|
+
return impl.packetOp(col + row);
|
677
|
+
}
|
678
|
+
|
679
|
+
// This proxy object handles the actual required temporaries, the different
|
680
|
+
// implementations (random vs. sequential access) as well as the
|
681
|
+
// correct piping to size 2/4 packet operations.
|
682
|
+
const linspaced_op_impl<Scalar,RandomAccess> impl;
|
683
|
+
};
|
684
|
+
|
685
|
+
// all functors allow linear access, except scalar_identity_op. So we fix here a quick meta
|
686
|
+
// to indicate whether a functor allows linear access, just always answering 'yes' except for
|
687
|
+
// scalar_identity_op.
|
688
|
+
// FIXME move this to functor_traits adding a functor_default
|
689
|
+
template<typename Functor> struct functor_has_linear_access { enum { ret = 1 }; };
|
690
|
+
template<typename Scalar> struct functor_has_linear_access<scalar_identity_op<Scalar> > { enum { ret = 0 }; };
|
691
|
+
|
692
|
+
// In Eigen, any binary op (Product, CwiseBinaryOp) require the Lhs and Rhs to have the same scalar type, except for multiplication
|
693
|
+
// where the mixing of different types is handled by scalar_product_traits
|
694
|
+
// In particular, real * complex<real> is allowed.
|
695
|
+
// FIXME move this to functor_traits adding a functor_default
|
696
|
+
template<typename Functor> struct functor_is_product_like { enum { ret = 0 }; };
|
697
|
+
template<typename LhsScalar,typename RhsScalar> struct functor_is_product_like<scalar_product_op<LhsScalar,RhsScalar> > { enum { ret = 1 }; };
|
698
|
+
template<typename LhsScalar,typename RhsScalar> struct functor_is_product_like<scalar_conj_product_op<LhsScalar,RhsScalar> > { enum { ret = 1 }; };
|
699
|
+
template<typename LhsScalar,typename RhsScalar> struct functor_is_product_like<scalar_quotient_op<LhsScalar,RhsScalar> > { enum { ret = 1 }; };
|
700
|
+
|
701
|
+
|
702
|
+
/** \internal
|
703
|
+
* \brief Template functor to add a scalar to a fixed other one
|
704
|
+
* \sa class CwiseUnaryOp, Array::operator+
|
705
|
+
*/
|
706
|
+
/* If you wonder why doing the pset1() in packetOp() is an optimization check scalar_multiple_op */
|
707
|
+
template<typename Scalar>
|
708
|
+
struct scalar_add_op {
|
709
|
+
typedef typename packet_traits<Scalar>::type Packet;
|
710
|
+
// FIXME default copy constructors seems bugged with std::complex<>
|
711
|
+
inline scalar_add_op(const scalar_add_op& other) : m_other(other.m_other) { }
|
712
|
+
inline scalar_add_op(const Scalar& other) : m_other(other) { }
|
713
|
+
inline Scalar operator() (const Scalar& a) const { return a + m_other; }
|
714
|
+
inline const Packet packetOp(const Packet& a) const
|
715
|
+
{ return internal::padd(a, pset1<Packet>(m_other)); }
|
716
|
+
const Scalar m_other;
|
717
|
+
};
|
718
|
+
template<typename Scalar>
|
719
|
+
struct functor_traits<scalar_add_op<Scalar> >
|
720
|
+
{ enum { Cost = NumTraits<Scalar>::AddCost, PacketAccess = packet_traits<Scalar>::HasAdd }; };
|
721
|
+
|
722
|
+
/** \internal
|
723
|
+
* \brief Template functor to compute the square root of a scalar
|
724
|
+
* \sa class CwiseUnaryOp, Cwise::sqrt()
|
725
|
+
*/
|
726
|
+
template<typename Scalar> struct scalar_sqrt_op {
|
727
|
+
EIGEN_EMPTY_STRUCT_CTOR(scalar_sqrt_op)
|
728
|
+
inline const Scalar operator() (const Scalar& a) const { using std::sqrt; return sqrt(a); }
|
729
|
+
typedef typename packet_traits<Scalar>::type Packet;
|
730
|
+
inline Packet packetOp(const Packet& a) const { return internal::psqrt(a); }
|
731
|
+
};
|
732
|
+
template<typename Scalar>
|
733
|
+
struct functor_traits<scalar_sqrt_op<Scalar> >
|
734
|
+
{ enum {
|
735
|
+
Cost = 5 * NumTraits<Scalar>::MulCost,
|
736
|
+
PacketAccess = packet_traits<Scalar>::HasSqrt
|
737
|
+
};
|
738
|
+
};
|
739
|
+
|
740
|
+
/** \internal
|
741
|
+
* \brief Template functor to compute the cosine of a scalar
|
742
|
+
* \sa class CwiseUnaryOp, ArrayBase::cos()
|
743
|
+
*/
|
744
|
+
template<typename Scalar> struct scalar_cos_op {
|
745
|
+
EIGEN_EMPTY_STRUCT_CTOR(scalar_cos_op)
|
746
|
+
inline Scalar operator() (const Scalar& a) const { using std::cos; return cos(a); }
|
747
|
+
typedef typename packet_traits<Scalar>::type Packet;
|
748
|
+
inline Packet packetOp(const Packet& a) const { return internal::pcos(a); }
|
749
|
+
};
|
750
|
+
template<typename Scalar>
|
751
|
+
struct functor_traits<scalar_cos_op<Scalar> >
|
752
|
+
{
|
753
|
+
enum {
|
754
|
+
Cost = 5 * NumTraits<Scalar>::MulCost,
|
755
|
+
PacketAccess = packet_traits<Scalar>::HasCos
|
756
|
+
};
|
757
|
+
};
|
758
|
+
|
759
|
+
/** \internal
|
760
|
+
* \brief Template functor to compute the sine of a scalar
|
761
|
+
* \sa class CwiseUnaryOp, ArrayBase::sin()
|
762
|
+
*/
|
763
|
+
template<typename Scalar> struct scalar_sin_op {
|
764
|
+
EIGEN_EMPTY_STRUCT_CTOR(scalar_sin_op)
|
765
|
+
inline const Scalar operator() (const Scalar& a) const { using std::sin; return sin(a); }
|
766
|
+
typedef typename packet_traits<Scalar>::type Packet;
|
767
|
+
inline Packet packetOp(const Packet& a) const { return internal::psin(a); }
|
768
|
+
};
|
769
|
+
template<typename Scalar>
|
770
|
+
struct functor_traits<scalar_sin_op<Scalar> >
|
771
|
+
{
|
772
|
+
enum {
|
773
|
+
Cost = 5 * NumTraits<Scalar>::MulCost,
|
774
|
+
PacketAccess = packet_traits<Scalar>::HasSin
|
775
|
+
};
|
776
|
+
};
|
777
|
+
|
778
|
+
|
779
|
+
/** \internal
|
780
|
+
* \brief Template functor to compute the tan of a scalar
|
781
|
+
* \sa class CwiseUnaryOp, ArrayBase::tan()
|
782
|
+
*/
|
783
|
+
template<typename Scalar> struct scalar_tan_op {
|
784
|
+
EIGEN_EMPTY_STRUCT_CTOR(scalar_tan_op)
|
785
|
+
inline const Scalar operator() (const Scalar& a) const { using std::tan; return tan(a); }
|
786
|
+
typedef typename packet_traits<Scalar>::type Packet;
|
787
|
+
inline Packet packetOp(const Packet& a) const { return internal::ptan(a); }
|
788
|
+
};
|
789
|
+
template<typename Scalar>
|
790
|
+
struct functor_traits<scalar_tan_op<Scalar> >
|
791
|
+
{
|
792
|
+
enum {
|
793
|
+
Cost = 5 * NumTraits<Scalar>::MulCost,
|
794
|
+
PacketAccess = packet_traits<Scalar>::HasTan
|
795
|
+
};
|
796
|
+
};
|
797
|
+
|
798
|
+
/** \internal
|
799
|
+
* \brief Template functor to compute the arc cosine of a scalar
|
800
|
+
* \sa class CwiseUnaryOp, ArrayBase::acos()
|
801
|
+
*/
|
802
|
+
template<typename Scalar> struct scalar_acos_op {
|
803
|
+
EIGEN_EMPTY_STRUCT_CTOR(scalar_acos_op)
|
804
|
+
inline const Scalar operator() (const Scalar& a) const { using std::acos; return acos(a); }
|
805
|
+
typedef typename packet_traits<Scalar>::type Packet;
|
806
|
+
inline Packet packetOp(const Packet& a) const { return internal::pacos(a); }
|
807
|
+
};
|
808
|
+
template<typename Scalar>
|
809
|
+
struct functor_traits<scalar_acos_op<Scalar> >
|
810
|
+
{
|
811
|
+
enum {
|
812
|
+
Cost = 5 * NumTraits<Scalar>::MulCost,
|
813
|
+
PacketAccess = packet_traits<Scalar>::HasACos
|
814
|
+
};
|
815
|
+
};
|
816
|
+
|
817
|
+
/** \internal
|
818
|
+
* \brief Template functor to compute the arc sine of a scalar
|
819
|
+
* \sa class CwiseUnaryOp, ArrayBase::asin()
|
820
|
+
*/
|
821
|
+
template<typename Scalar> struct scalar_asin_op {
|
822
|
+
EIGEN_EMPTY_STRUCT_CTOR(scalar_asin_op)
|
823
|
+
inline const Scalar operator() (const Scalar& a) const { using std::asin; return asin(a); }
|
824
|
+
typedef typename packet_traits<Scalar>::type Packet;
|
825
|
+
inline Packet packetOp(const Packet& a) const { return internal::pasin(a); }
|
826
|
+
};
|
827
|
+
template<typename Scalar>
|
828
|
+
struct functor_traits<scalar_asin_op<Scalar> >
|
829
|
+
{
|
830
|
+
enum {
|
831
|
+
Cost = 5 * NumTraits<Scalar>::MulCost,
|
832
|
+
PacketAccess = packet_traits<Scalar>::HasASin
|
833
|
+
};
|
834
|
+
};
|
835
|
+
|
836
|
+
/** \internal
|
837
|
+
* \brief Template functor to raise a scalar to a power
|
838
|
+
* \sa class CwiseUnaryOp, Cwise::pow
|
839
|
+
*/
|
840
|
+
template<typename Scalar>
|
841
|
+
struct scalar_pow_op {
|
842
|
+
// FIXME default copy constructors seems bugged with std::complex<>
|
843
|
+
inline scalar_pow_op(const scalar_pow_op& other) : m_exponent(other.m_exponent) { }
|
844
|
+
inline scalar_pow_op(const Scalar& exponent) : m_exponent(exponent) {}
|
845
|
+
inline Scalar operator() (const Scalar& a) const { return numext::pow(a, m_exponent); }
|
846
|
+
const Scalar m_exponent;
|
847
|
+
};
|
848
|
+
template<typename Scalar>
|
849
|
+
struct functor_traits<scalar_pow_op<Scalar> >
|
850
|
+
{ enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = false }; };
|
851
|
+
|
852
|
+
/** \internal
|
853
|
+
* \brief Template functor to compute the quotient between a scalar and array entries.
|
854
|
+
* \sa class CwiseUnaryOp, Cwise::inverse()
|
855
|
+
*/
|
856
|
+
template<typename Scalar>
|
857
|
+
struct scalar_inverse_mult_op {
|
858
|
+
scalar_inverse_mult_op(const Scalar& other) : m_other(other) {}
|
859
|
+
inline Scalar operator() (const Scalar& a) const { return m_other / a; }
|
860
|
+
template<typename Packet>
|
861
|
+
inline const Packet packetOp(const Packet& a) const
|
862
|
+
{ return internal::pdiv(pset1<Packet>(m_other),a); }
|
863
|
+
Scalar m_other;
|
864
|
+
};
|
865
|
+
|
866
|
+
/** \internal
|
867
|
+
* \brief Template functor to compute the inverse of a scalar
|
868
|
+
* \sa class CwiseUnaryOp, Cwise::inverse()
|
869
|
+
*/
|
870
|
+
template<typename Scalar>
|
871
|
+
struct scalar_inverse_op {
|
872
|
+
EIGEN_EMPTY_STRUCT_CTOR(scalar_inverse_op)
|
873
|
+
inline Scalar operator() (const Scalar& a) const { return Scalar(1)/a; }
|
874
|
+
template<typename Packet>
|
875
|
+
inline const Packet packetOp(const Packet& a) const
|
876
|
+
{ return internal::pdiv(pset1<Packet>(Scalar(1)),a); }
|
877
|
+
};
|
878
|
+
template<typename Scalar>
|
879
|
+
struct functor_traits<scalar_inverse_op<Scalar> >
|
880
|
+
{ enum { Cost = NumTraits<Scalar>::MulCost, PacketAccess = packet_traits<Scalar>::HasDiv }; };
|
881
|
+
|
882
|
+
/** \internal
|
883
|
+
* \brief Template functor to compute the square of a scalar
|
884
|
+
* \sa class CwiseUnaryOp, Cwise::square()
|
885
|
+
*/
|
886
|
+
template<typename Scalar>
|
887
|
+
struct scalar_square_op {
|
888
|
+
EIGEN_EMPTY_STRUCT_CTOR(scalar_square_op)
|
889
|
+
inline Scalar operator() (const Scalar& a) const { return a*a; }
|
890
|
+
template<typename Packet>
|
891
|
+
inline const Packet packetOp(const Packet& a) const
|
892
|
+
{ return internal::pmul(a,a); }
|
893
|
+
};
|
894
|
+
template<typename Scalar>
|
895
|
+
struct functor_traits<scalar_square_op<Scalar> >
|
896
|
+
{ enum { Cost = NumTraits<Scalar>::MulCost, PacketAccess = packet_traits<Scalar>::HasMul }; };
|
897
|
+
|
898
|
+
/** \internal
|
899
|
+
* \brief Template functor to compute the cube of a scalar
|
900
|
+
* \sa class CwiseUnaryOp, Cwise::cube()
|
901
|
+
*/
|
902
|
+
template<typename Scalar>
|
903
|
+
struct scalar_cube_op {
|
904
|
+
EIGEN_EMPTY_STRUCT_CTOR(scalar_cube_op)
|
905
|
+
inline Scalar operator() (const Scalar& a) const { return a*a*a; }
|
906
|
+
template<typename Packet>
|
907
|
+
inline const Packet packetOp(const Packet& a) const
|
908
|
+
{ return internal::pmul(a,pmul(a,a)); }
|
909
|
+
};
|
910
|
+
template<typename Scalar>
|
911
|
+
struct functor_traits<scalar_cube_op<Scalar> >
|
912
|
+
{ enum { Cost = 2*NumTraits<Scalar>::MulCost, PacketAccess = packet_traits<Scalar>::HasMul }; };
|
913
|
+
|
914
|
+
// default functor traits for STL functors:
|
915
|
+
|
916
|
+
template<typename T>
|
917
|
+
struct functor_traits<std::multiplies<T> >
|
918
|
+
{ enum { Cost = NumTraits<T>::MulCost, PacketAccess = false }; };
|
919
|
+
|
920
|
+
template<typename T>
|
921
|
+
struct functor_traits<std::divides<T> >
|
922
|
+
{ enum { Cost = NumTraits<T>::MulCost, PacketAccess = false }; };
|
923
|
+
|
924
|
+
template<typename T>
|
925
|
+
struct functor_traits<std::plus<T> >
|
926
|
+
{ enum { Cost = NumTraits<T>::AddCost, PacketAccess = false }; };
|
927
|
+
|
928
|
+
template<typename T>
|
929
|
+
struct functor_traits<std::minus<T> >
|
930
|
+
{ enum { Cost = NumTraits<T>::AddCost, PacketAccess = false }; };
|
931
|
+
|
932
|
+
template<typename T>
|
933
|
+
struct functor_traits<std::negate<T> >
|
934
|
+
{ enum { Cost = NumTraits<T>::AddCost, PacketAccess = false }; };
|
935
|
+
|
936
|
+
template<typename T>
|
937
|
+
struct functor_traits<std::logical_or<T> >
|
938
|
+
{ enum { Cost = 1, PacketAccess = false }; };
|
939
|
+
|
940
|
+
template<typename T>
|
941
|
+
struct functor_traits<std::logical_and<T> >
|
942
|
+
{ enum { Cost = 1, PacketAccess = false }; };
|
943
|
+
|
944
|
+
template<typename T>
|
945
|
+
struct functor_traits<std::logical_not<T> >
|
946
|
+
{ enum { Cost = 1, PacketAccess = false }; };
|
947
|
+
|
948
|
+
template<typename T>
|
949
|
+
struct functor_traits<std::greater<T> >
|
950
|
+
{ enum { Cost = 1, PacketAccess = false }; };
|
951
|
+
|
952
|
+
template<typename T>
|
953
|
+
struct functor_traits<std::less<T> >
|
954
|
+
{ enum { Cost = 1, PacketAccess = false }; };
|
955
|
+
|
956
|
+
template<typename T>
|
957
|
+
struct functor_traits<std::greater_equal<T> >
|
958
|
+
{ enum { Cost = 1, PacketAccess = false }; };
|
959
|
+
|
960
|
+
template<typename T>
|
961
|
+
struct functor_traits<std::less_equal<T> >
|
962
|
+
{ enum { Cost = 1, PacketAccess = false }; };
|
963
|
+
|
964
|
+
template<typename T>
|
965
|
+
struct functor_traits<std::equal_to<T> >
|
966
|
+
{ enum { Cost = 1, PacketAccess = false }; };
|
967
|
+
|
968
|
+
template<typename T>
|
969
|
+
struct functor_traits<std::not_equal_to<T> >
|
970
|
+
{ enum { Cost = 1, PacketAccess = false }; };
|
971
|
+
|
972
|
+
template<typename T>
|
973
|
+
struct functor_traits<std::binder2nd<T> >
|
974
|
+
{ enum { Cost = functor_traits<T>::Cost, PacketAccess = false }; };
|
975
|
+
|
976
|
+
template<typename T>
|
977
|
+
struct functor_traits<std::binder1st<T> >
|
978
|
+
{ enum { Cost = functor_traits<T>::Cost, PacketAccess = false }; };
|
979
|
+
|
980
|
+
template<typename T>
|
981
|
+
struct functor_traits<std::unary_negate<T> >
|
982
|
+
{ enum { Cost = 1 + functor_traits<T>::Cost, PacketAccess = false }; };
|
983
|
+
|
984
|
+
template<typename T>
|
985
|
+
struct functor_traits<std::binary_negate<T> >
|
986
|
+
{ enum { Cost = 1 + functor_traits<T>::Cost, PacketAccess = false }; };
|
987
|
+
|
988
|
+
#ifdef EIGEN_STDEXT_SUPPORT
|
989
|
+
|
990
|
+
template<typename T0,typename T1>
|
991
|
+
struct functor_traits<std::project1st<T0,T1> >
|
992
|
+
{ enum { Cost = 0, PacketAccess = false }; };
|
993
|
+
|
994
|
+
template<typename T0,typename T1>
|
995
|
+
struct functor_traits<std::project2nd<T0,T1> >
|
996
|
+
{ enum { Cost = 0, PacketAccess = false }; };
|
997
|
+
|
998
|
+
template<typename T0,typename T1>
|
999
|
+
struct functor_traits<std::select2nd<std::pair<T0,T1> > >
|
1000
|
+
{ enum { Cost = 0, PacketAccess = false }; };
|
1001
|
+
|
1002
|
+
template<typename T0,typename T1>
|
1003
|
+
struct functor_traits<std::select1st<std::pair<T0,T1> > >
|
1004
|
+
{ enum { Cost = 0, PacketAccess = false }; };
|
1005
|
+
|
1006
|
+
template<typename T0,typename T1>
|
1007
|
+
struct functor_traits<std::unary_compose<T0,T1> >
|
1008
|
+
{ enum { Cost = functor_traits<T0>::Cost + functor_traits<T1>::Cost, PacketAccess = false }; };
|
1009
|
+
|
1010
|
+
template<typename T0,typename T1,typename T2>
|
1011
|
+
struct functor_traits<std::binary_compose<T0,T1,T2> >
|
1012
|
+
{ enum { Cost = functor_traits<T0>::Cost + functor_traits<T1>::Cost + functor_traits<T2>::Cost, PacketAccess = false }; };
|
1013
|
+
|
1014
|
+
#endif // EIGEN_STDEXT_SUPPORT
|
1015
|
+
|
1016
|
+
// allow to add new functors and specializations of functor_traits from outside Eigen.
|
1017
|
+
// this macro is really needed because functor_traits must be specialized after it is declared but before it is used...
|
1018
|
+
#ifdef EIGEN_FUNCTORS_PLUGIN
|
1019
|
+
#include EIGEN_FUNCTORS_PLUGIN
|
1020
|
+
#endif
|
1021
|
+
|
1022
|
+
} // end namespace internal
|
1023
|
+
|
1024
|
+
} // end namespace Eigen
|
1025
|
+
|
1026
|
+
#endif // EIGEN_FUNCTORS_H
|