@smake/eigen 1.0.1 → 1.1.0
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.
- package/README.md +1 -1
- package/eigen/COPYING.APACHE +203 -0
- package/eigen/COPYING.BSD +1 -1
- package/eigen/COPYING.MINPACK +51 -52
- package/eigen/Eigen/Cholesky +0 -1
- package/eigen/Eigen/Core +108 -266
- package/eigen/Eigen/Eigenvalues +0 -1
- package/eigen/Eigen/Geometry +3 -6
- package/eigen/Eigen/Householder +0 -1
- package/eigen/Eigen/Jacobi +0 -1
- package/eigen/Eigen/KLUSupport +41 -0
- package/eigen/Eigen/LU +2 -5
- package/eigen/Eigen/OrderingMethods +0 -3
- package/eigen/Eigen/PaStiXSupport +1 -0
- package/eigen/Eigen/PardisoSupport +0 -0
- package/eigen/Eigen/QR +0 -1
- package/eigen/Eigen/QtAlignedMalloc +0 -1
- package/eigen/Eigen/SVD +0 -1
- package/eigen/Eigen/Sparse +0 -2
- package/eigen/Eigen/SparseCholesky +0 -8
- package/eigen/Eigen/SparseLU +4 -0
- package/eigen/Eigen/src/Cholesky/LDLT.h +42 -27
- package/eigen/Eigen/src/Cholesky/LLT.h +39 -23
- package/eigen/Eigen/src/CholmodSupport/CholmodSupport.h +90 -47
- package/eigen/Eigen/src/Core/ArithmeticSequence.h +413 -0
- package/eigen/Eigen/src/Core/Array.h +99 -11
- package/eigen/Eigen/src/Core/ArrayBase.h +1 -1
- package/eigen/Eigen/src/Core/ArrayWrapper.h +21 -21
- package/eigen/Eigen/src/Core/Assign.h +1 -1
- package/eigen/Eigen/src/Core/AssignEvaluator.h +125 -50
- package/eigen/Eigen/src/Core/Assign_MKL.h +10 -10
- package/eigen/Eigen/src/Core/BandMatrix.h +16 -16
- package/eigen/Eigen/src/Core/Block.h +56 -60
- package/eigen/Eigen/src/Core/BooleanRedux.h +29 -31
- package/eigen/Eigen/src/Core/CommaInitializer.h +7 -3
- package/eigen/Eigen/src/Core/CoreEvaluators.h +325 -272
- package/eigen/Eigen/src/Core/CoreIterators.h +5 -0
- package/eigen/Eigen/src/Core/CwiseBinaryOp.h +21 -22
- package/eigen/Eigen/src/Core/CwiseNullaryOp.h +153 -18
- package/eigen/Eigen/src/Core/CwiseUnaryOp.h +6 -6
- package/eigen/Eigen/src/Core/CwiseUnaryView.h +12 -10
- package/eigen/Eigen/src/Core/DenseBase.h +128 -39
- package/eigen/Eigen/src/Core/DenseCoeffsBase.h +25 -21
- package/eigen/Eigen/src/Core/DenseStorage.h +150 -68
- package/eigen/Eigen/src/Core/Diagonal.h +21 -23
- package/eigen/Eigen/src/Core/DiagonalMatrix.h +50 -2
- package/eigen/Eigen/src/Core/DiagonalProduct.h +1 -1
- package/eigen/Eigen/src/Core/Dot.h +10 -10
- package/eigen/Eigen/src/Core/EigenBase.h +10 -9
- package/eigen/Eigen/src/Core/ForceAlignedAccess.h +8 -4
- package/eigen/Eigen/src/Core/Fuzzy.h +3 -3
- package/eigen/Eigen/src/Core/GeneralProduct.h +20 -10
- package/eigen/Eigen/src/Core/GenericPacketMath.h +597 -147
- package/eigen/Eigen/src/Core/GlobalFunctions.h +40 -33
- package/eigen/Eigen/src/Core/IO.h +40 -7
- package/eigen/Eigen/src/Core/IndexedView.h +237 -0
- package/eigen/Eigen/src/Core/Inverse.h +9 -10
- package/eigen/Eigen/src/Core/Map.h +7 -7
- package/eigen/Eigen/src/Core/MapBase.h +5 -3
- package/eigen/Eigen/src/Core/MathFunctions.h +756 -120
- package/eigen/Eigen/src/Core/MathFunctionsImpl.h +118 -19
- package/eigen/Eigen/src/Core/Matrix.h +131 -25
- package/eigen/Eigen/src/Core/MatrixBase.h +19 -2
- package/eigen/Eigen/src/Core/NestByValue.h +25 -50
- package/eigen/Eigen/src/Core/NoAlias.h +4 -3
- package/eigen/Eigen/src/Core/NumTraits.h +107 -20
- package/eigen/Eigen/src/Core/PartialReduxEvaluator.h +232 -0
- package/eigen/Eigen/src/Core/PermutationMatrix.h +3 -3
- package/eigen/Eigen/src/Core/PlainObjectBase.h +145 -54
- package/eigen/Eigen/src/Core/Product.h +30 -25
- package/eigen/Eigen/src/Core/ProductEvaluators.h +183 -142
- package/eigen/Eigen/src/Core/Random.h +37 -1
- package/eigen/Eigen/src/Core/Redux.h +180 -170
- package/eigen/Eigen/src/Core/Ref.h +118 -21
- package/eigen/Eigen/src/Core/Replicate.h +8 -8
- package/eigen/Eigen/src/Core/Reshaped.h +454 -0
- package/eigen/Eigen/src/Core/ReturnByValue.h +7 -5
- package/eigen/Eigen/src/Core/Reverse.h +18 -12
- package/eigen/Eigen/src/Core/Select.h +8 -6
- package/eigen/Eigen/src/Core/SelfAdjointView.h +33 -20
- package/eigen/Eigen/src/Core/Solve.h +14 -14
- package/eigen/Eigen/src/Core/SolveTriangular.h +13 -13
- package/eigen/Eigen/src/Core/SolverBase.h +41 -3
- package/eigen/Eigen/src/Core/StableNorm.h +100 -70
- package/eigen/Eigen/src/Core/StlIterators.h +463 -0
- package/eigen/Eigen/src/Core/Stride.h +9 -4
- package/eigen/Eigen/src/Core/Swap.h +5 -4
- package/eigen/Eigen/src/Core/Transpose.h +86 -27
- package/eigen/Eigen/src/Core/Transpositions.h +26 -8
- package/eigen/Eigen/src/Core/TriangularMatrix.h +88 -72
- package/eigen/Eigen/src/Core/VectorBlock.h +5 -5
- package/eigen/Eigen/src/Core/VectorwiseOp.h +159 -70
- package/eigen/Eigen/src/Core/Visitor.h +137 -29
- package/eigen/Eigen/src/Core/arch/AVX/Complex.h +50 -129
- package/eigen/Eigen/src/Core/arch/AVX/MathFunctions.h +126 -337
- package/eigen/Eigen/src/Core/arch/AVX/PacketMath.h +1092 -155
- package/eigen/Eigen/src/Core/arch/AVX/TypeCasting.h +65 -1
- package/eigen/Eigen/src/Core/arch/AVX512/Complex.h +422 -0
- package/eigen/Eigen/src/Core/arch/AVX512/MathFunctions.h +186 -213
- package/eigen/Eigen/src/Core/arch/AVX512/PacketMath.h +1250 -252
- package/eigen/Eigen/src/Core/arch/AVX512/TypeCasting.h +89 -0
- package/eigen/Eigen/src/Core/arch/AltiVec/Complex.h +152 -165
- package/eigen/Eigen/src/Core/arch/AltiVec/MathFunctions.h +19 -251
- package/eigen/Eigen/src/Core/arch/AltiVec/MatrixProduct.h +2937 -0
- package/eigen/Eigen/src/Core/arch/AltiVec/MatrixProductCommon.h +221 -0
- package/eigen/Eigen/src/Core/arch/AltiVec/MatrixProductMMA.h +629 -0
- package/eigen/Eigen/src/Core/arch/AltiVec/PacketMath.h +2042 -392
- package/eigen/Eigen/src/Core/arch/CUDA/Complex.h +235 -80
- package/eigen/Eigen/src/Core/arch/Default/BFloat16.h +700 -0
- package/eigen/Eigen/src/Core/arch/Default/ConjHelper.h +102 -14
- package/eigen/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h +1649 -0
- package/eigen/Eigen/src/Core/arch/Default/GenericPacketMathFunctionsFwd.h +110 -0
- package/eigen/Eigen/src/Core/arch/Default/Half.h +942 -0
- package/eigen/Eigen/src/Core/arch/Default/Settings.h +1 -1
- package/eigen/Eigen/src/Core/arch/Default/TypeCasting.h +120 -0
- package/eigen/Eigen/src/Core/arch/{CUDA → GPU}/MathFunctions.h +16 -4
- package/eigen/Eigen/src/Core/arch/GPU/PacketMath.h +1685 -0
- package/eigen/Eigen/src/Core/arch/GPU/TypeCasting.h +80 -0
- package/eigen/Eigen/src/Core/arch/HIP/hcc/math_constants.h +23 -0
- package/eigen/Eigen/src/Core/arch/MSA/Complex.h +648 -0
- package/eigen/Eigen/src/Core/arch/MSA/MathFunctions.h +387 -0
- package/eigen/Eigen/src/Core/arch/MSA/PacketMath.h +1233 -0
- package/eigen/Eigen/src/Core/arch/NEON/Complex.h +313 -219
- package/eigen/Eigen/src/Core/arch/NEON/GeneralBlockPanelKernel.h +183 -0
- package/eigen/Eigen/src/Core/arch/NEON/MathFunctions.h +54 -70
- package/eigen/Eigen/src/Core/arch/NEON/PacketMath.h +4376 -549
- package/eigen/Eigen/src/Core/arch/NEON/TypeCasting.h +1419 -0
- package/eigen/Eigen/src/Core/arch/SSE/Complex.h +59 -179
- package/eigen/Eigen/src/Core/arch/SSE/MathFunctions.h +65 -428
- package/eigen/Eigen/src/Core/arch/SSE/PacketMath.h +893 -283
- package/eigen/Eigen/src/Core/arch/SSE/TypeCasting.h +65 -0
- package/eigen/Eigen/src/Core/arch/SVE/MathFunctions.h +44 -0
- package/eigen/Eigen/src/Core/arch/SVE/PacketMath.h +752 -0
- package/eigen/Eigen/src/Core/arch/SVE/TypeCasting.h +49 -0
- package/eigen/Eigen/src/Core/arch/SYCL/InteropHeaders.h +232 -0
- package/eigen/Eigen/src/Core/arch/SYCL/MathFunctions.h +301 -0
- package/eigen/Eigen/src/Core/arch/SYCL/PacketMath.h +670 -0
- package/eigen/Eigen/src/Core/arch/SYCL/SyclMemoryModel.h +694 -0
- package/eigen/Eigen/src/Core/arch/SYCL/TypeCasting.h +85 -0
- package/eigen/Eigen/src/Core/arch/ZVector/Complex.h +212 -183
- package/eigen/Eigen/src/Core/arch/ZVector/MathFunctions.h +101 -5
- package/eigen/Eigen/src/Core/arch/ZVector/PacketMath.h +510 -395
- package/eigen/Eigen/src/Core/functors/AssignmentFunctors.h +11 -2
- package/eigen/Eigen/src/Core/functors/BinaryFunctors.h +112 -46
- package/eigen/Eigen/src/Core/functors/NullaryFunctors.h +31 -30
- package/eigen/Eigen/src/Core/functors/StlFunctors.h +32 -2
- package/eigen/Eigen/src/Core/functors/UnaryFunctors.h +354 -15
- package/eigen/Eigen/src/Core/products/GeneralBlockPanelKernel.h +1073 -585
- package/eigen/Eigen/src/Core/products/GeneralMatrixMatrix.h +29 -7
- package/eigen/Eigen/src/Core/products/GeneralMatrixMatrixTriangular.h +4 -4
- package/eigen/Eigen/src/Core/products/GeneralMatrixMatrixTriangular_BLAS.h +1 -1
- package/eigen/Eigen/src/Core/products/GeneralMatrixVector.h +382 -483
- package/eigen/Eigen/src/Core/products/Parallelizer.h +23 -9
- package/eigen/Eigen/src/Core/products/SelfadjointMatrixMatrix.h +23 -6
- package/eigen/Eigen/src/Core/products/SelfadjointMatrixVector.h +8 -6
- package/eigen/Eigen/src/Core/products/SelfadjointProduct.h +2 -2
- package/eigen/Eigen/src/Core/products/SelfadjointRank2Update.h +5 -4
- package/eigen/Eigen/src/Core/products/TriangularMatrixMatrix.h +3 -3
- package/eigen/Eigen/src/Core/products/TriangularSolverMatrix.h +5 -3
- package/eigen/Eigen/src/Core/products/TriangularSolverVector.h +13 -10
- package/eigen/Eigen/src/Core/util/BlasUtil.h +208 -124
- package/eigen/Eigen/src/Core/util/ConfigureVectorization.h +512 -0
- package/eigen/Eigen/src/Core/util/Constants.h +25 -9
- package/eigen/Eigen/src/Core/util/DisableStupidWarnings.h +14 -2
- package/eigen/Eigen/src/Core/util/ForwardDeclarations.h +28 -4
- package/eigen/Eigen/src/Core/util/IndexedViewHelper.h +186 -0
- package/eigen/Eigen/src/Core/util/IntegralConstant.h +272 -0
- package/eigen/Eigen/src/Core/util/MKL_support.h +8 -1
- package/eigen/Eigen/src/Core/util/Macros.h +661 -250
- package/eigen/Eigen/src/Core/util/Memory.h +222 -52
- package/eigen/Eigen/src/Core/util/Meta.h +349 -105
- package/eigen/Eigen/src/Core/util/ReshapedHelper.h +51 -0
- package/eigen/Eigen/src/Core/util/StaticAssert.h +8 -5
- package/eigen/Eigen/src/Core/util/SymbolicIndex.h +293 -0
- package/eigen/Eigen/src/Core/util/XprHelper.h +48 -30
- package/eigen/Eigen/src/Eigenvalues/ComplexEigenSolver.h +1 -1
- package/eigen/Eigen/src/Eigenvalues/ComplexSchur.h +1 -1
- package/eigen/Eigen/src/Eigenvalues/EigenSolver.h +2 -2
- package/eigen/Eigen/src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h +1 -1
- package/eigen/Eigen/src/Eigenvalues/HessenbergDecomposition.h +2 -2
- package/eigen/Eigen/src/Eigenvalues/MatrixBaseEigenvalues.h +2 -2
- package/eigen/Eigen/src/Eigenvalues/RealQZ.h +9 -6
- package/eigen/Eigen/src/Eigenvalues/RealSchur.h +10 -5
- package/eigen/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h +75 -42
- package/eigen/Eigen/src/Eigenvalues/Tridiagonalization.h +20 -15
- package/eigen/Eigen/src/Geometry/AlignedBox.h +99 -5
- package/eigen/Eigen/src/Geometry/AngleAxis.h +4 -4
- package/eigen/Eigen/src/Geometry/EulerAngles.h +3 -3
- package/eigen/Eigen/src/Geometry/Homogeneous.h +15 -11
- package/eigen/Eigen/src/Geometry/Hyperplane.h +1 -1
- package/eigen/Eigen/src/Geometry/OrthoMethods.h +3 -2
- package/eigen/Eigen/src/Geometry/ParametrizedLine.h +39 -2
- package/eigen/Eigen/src/Geometry/Quaternion.h +52 -14
- package/eigen/Eigen/src/Geometry/Rotation2D.h +3 -3
- package/eigen/Eigen/src/Geometry/Scaling.h +22 -4
- package/eigen/Eigen/src/Geometry/Transform.h +86 -65
- package/eigen/Eigen/src/Geometry/Translation.h +6 -6
- package/eigen/Eigen/src/Geometry/arch/Geometry_SIMD.h +168 -0
- package/eigen/Eigen/src/Householder/BlockHouseholder.h +9 -2
- package/eigen/Eigen/src/Householder/Householder.h +8 -4
- package/eigen/Eigen/src/Householder/HouseholderSequence.h +123 -48
- package/eigen/Eigen/src/IterativeLinearSolvers/BasicPreconditioners.h +15 -15
- package/eigen/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h +7 -23
- package/eigen/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h +5 -22
- package/eigen/Eigen/src/IterativeLinearSolvers/IncompleteCholesky.h +41 -47
- package/eigen/Eigen/src/IterativeLinearSolvers/IncompleteLUT.h +51 -60
- package/eigen/Eigen/src/IterativeLinearSolvers/IterativeSolverBase.h +70 -20
- package/eigen/Eigen/src/IterativeLinearSolvers/LeastSquareConjugateGradient.h +2 -20
- package/eigen/Eigen/src/IterativeLinearSolvers/SolveWithGuess.h +11 -9
- package/eigen/Eigen/src/Jacobi/Jacobi.h +31 -10
- package/eigen/Eigen/src/KLUSupport/KLUSupport.h +358 -0
- package/eigen/Eigen/src/LU/Determinant.h +35 -19
- package/eigen/Eigen/src/LU/FullPivLU.h +29 -43
- package/eigen/Eigen/src/LU/InverseImpl.h +25 -8
- package/eigen/Eigen/src/LU/PartialPivLU.h +67 -57
- package/eigen/Eigen/src/LU/arch/InverseSize4.h +351 -0
- package/eigen/Eigen/src/OrderingMethods/Amd.h +7 -17
- package/eigen/Eigen/src/OrderingMethods/Eigen_Colamd.h +297 -277
- package/eigen/Eigen/src/OrderingMethods/Ordering.h +6 -10
- package/eigen/Eigen/src/PaStiXSupport/PaStiXSupport.h +1 -1
- package/eigen/Eigen/src/PardisoSupport/PardisoSupport.h +10 -9
- package/eigen/Eigen/src/QR/ColPivHouseholderQR.h +41 -20
- package/eigen/Eigen/src/QR/CompleteOrthogonalDecomposition.h +100 -27
- package/eigen/Eigen/src/QR/FullPivHouseholderQR.h +59 -22
- package/eigen/Eigen/src/QR/HouseholderQR.h +48 -23
- package/eigen/Eigen/src/SPQRSupport/SuiteSparseQRSupport.h +25 -3
- package/eigen/Eigen/src/SVD/BDCSVD.h +137 -48
- package/eigen/Eigen/src/SVD/JacobiSVD.h +22 -14
- package/eigen/Eigen/src/SVD/SVDBase.h +82 -21
- package/eigen/Eigen/src/SVD/UpperBidiagonalization.h +3 -3
- package/eigen/Eigen/src/SparseCholesky/SimplicialCholesky.h +16 -8
- package/eigen/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h +11 -36
- package/eigen/Eigen/src/SparseCore/CompressedStorage.h +16 -0
- package/eigen/Eigen/src/SparseCore/ConservativeSparseSparseProduct.h +6 -6
- package/eigen/Eigen/src/SparseCore/SparseAssign.h +81 -27
- package/eigen/Eigen/src/SparseCore/SparseBlock.h +25 -57
- package/eigen/Eigen/src/SparseCore/SparseCompressedBase.h +40 -11
- package/eigen/Eigen/src/SparseCore/SparseCwiseBinaryOp.h +11 -15
- package/eigen/Eigen/src/SparseCore/SparseCwiseUnaryOp.h +2 -2
- package/eigen/Eigen/src/SparseCore/SparseDenseProduct.h +30 -8
- package/eigen/Eigen/src/SparseCore/SparseMatrix.h +124 -10
- package/eigen/Eigen/src/SparseCore/SparseMatrixBase.h +5 -12
- package/eigen/Eigen/src/SparseCore/SparseProduct.h +13 -1
- package/eigen/Eigen/src/SparseCore/SparseRef.h +7 -7
- package/eigen/Eigen/src/SparseCore/SparseSelfAdjointView.h +3 -0
- package/eigen/Eigen/src/SparseCore/SparseUtil.h +8 -0
- package/eigen/Eigen/src/SparseCore/SparseVector.h +1 -1
- package/eigen/Eigen/src/SparseLU/SparseLU.h +160 -10
- package/eigen/Eigen/src/SparseLU/SparseLU_Memory.h +1 -1
- package/eigen/Eigen/src/SparseLU/SparseLU_SupernodalMatrix.h +76 -2
- package/eigen/Eigen/src/SparseLU/SparseLU_column_dfs.h +2 -2
- package/eigen/Eigen/src/SparseLU/SparseLU_gemm_kernel.h +1 -1
- package/eigen/Eigen/src/SparseLU/SparseLU_panel_bmod.h +1 -1
- package/eigen/Eigen/src/SparseQR/SparseQR.h +19 -6
- package/eigen/Eigen/src/StlSupport/StdDeque.h +2 -14
- package/eigen/Eigen/src/StlSupport/StdList.h +2 -2
- package/eigen/Eigen/src/StlSupport/StdVector.h +2 -2
- package/eigen/Eigen/src/SuperLUSupport/SuperLUSupport.h +6 -8
- package/eigen/Eigen/src/UmfPackSupport/UmfPackSupport.h +175 -39
- package/eigen/Eigen/src/misc/lapacke.h +5 -4
- package/eigen/Eigen/src/plugins/ArrayCwiseBinaryOps.h +27 -1
- package/eigen/Eigen/src/plugins/ArrayCwiseUnaryOps.h +155 -11
- package/eigen/Eigen/src/plugins/BlockMethods.h +626 -242
- package/eigen/Eigen/src/plugins/CommonCwiseUnaryOps.h +14 -0
- package/eigen/Eigen/src/plugins/IndexedViewMethods.h +262 -0
- package/eigen/Eigen/src/plugins/MatrixCwiseBinaryOps.h +4 -4
- package/eigen/Eigen/src/plugins/MatrixCwiseUnaryOps.h +10 -0
- package/eigen/Eigen/src/plugins/ReshapedMethods.h +149 -0
- package/eigen/README.md +2 -0
- package/lib/LibEigen.d.ts +4 -0
- package/lib/LibEigen.js +14 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +7 -3
- package/package.json +2 -10
- package/eigen/Eigen/CMakeLists.txt +0 -19
- package/eigen/Eigen/src/Core/arch/CUDA/Half.h +0 -675
- package/eigen/Eigen/src/Core/arch/CUDA/PacketMath.h +0 -333
- package/eigen/Eigen/src/Core/arch/CUDA/PacketMathHalf.h +0 -1124
- package/eigen/Eigen/src/Core/arch/CUDA/TypeCasting.h +0 -212
- package/eigen/Eigen/src/Geometry/arch/Geometry_SSE.h +0 -161
- package/eigen/Eigen/src/LU/arch/Inverse_SSE.h +0 -338
- package/lib/eigen.d.ts +0 -2
- package/lib/eigen.js +0 -15
|
@@ -83,7 +83,7 @@ void assign_sparse_to_sparse(DstXprType &dst, const SrcXprType &src)
|
|
|
83
83
|
// eval without temporary
|
|
84
84
|
dst.resize(src.rows(), src.cols());
|
|
85
85
|
dst.setZero();
|
|
86
|
-
dst.reserve((std::max)(src.rows(),src.cols())*2);
|
|
86
|
+
dst.reserve((std::min)(src.rows()*src.cols(), (std::max)(src.rows(),src.cols())*2));
|
|
87
87
|
for (Index j=0; j<outerEvaluationSize; ++j)
|
|
88
88
|
{
|
|
89
89
|
dst.startVec(j);
|
|
@@ -107,7 +107,7 @@ void assign_sparse_to_sparse(DstXprType &dst, const SrcXprType &src)
|
|
|
107
107
|
|
|
108
108
|
DstXprType temp(src.rows(), src.cols());
|
|
109
109
|
|
|
110
|
-
temp.reserve((std::max)(src.rows(),src.cols())*2);
|
|
110
|
+
temp.reserve((std::min)(src.rows()*src.cols(), (std::max)(src.rows(),src.cols())*2));
|
|
111
111
|
for (Index j=0; j<outerEvaluationSize; ++j)
|
|
112
112
|
{
|
|
113
113
|
temp.startVec(j);
|
|
@@ -134,8 +134,8 @@ struct Assignment<DstXprType, SrcXprType, Functor, Sparse2Sparse>
|
|
|
134
134
|
};
|
|
135
135
|
|
|
136
136
|
// Generic Sparse to Dense assignment
|
|
137
|
-
template< typename DstXprType, typename SrcXprType, typename Functor>
|
|
138
|
-
struct Assignment<DstXprType, SrcXprType, Functor, Sparse2Dense>
|
|
137
|
+
template< typename DstXprType, typename SrcXprType, typename Functor, typename Weak>
|
|
138
|
+
struct Assignment<DstXprType, SrcXprType, Functor, Sparse2Dense, Weak>
|
|
139
139
|
{
|
|
140
140
|
static void run(DstXprType &dst, const SrcXprType &src, const Functor &func)
|
|
141
141
|
{
|
|
@@ -153,6 +153,73 @@ struct Assignment<DstXprType, SrcXprType, Functor, Sparse2Dense>
|
|
|
153
153
|
}
|
|
154
154
|
};
|
|
155
155
|
|
|
156
|
+
// Specialization for dense ?= dense +/- sparse and dense ?= sparse +/- dense
|
|
157
|
+
template<typename DstXprType, typename Func1, typename Func2>
|
|
158
|
+
struct assignment_from_dense_op_sparse
|
|
159
|
+
{
|
|
160
|
+
template<typename SrcXprType, typename InitialFunc>
|
|
161
|
+
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
|
162
|
+
void run(DstXprType &dst, const SrcXprType &src, const InitialFunc& /*func*/)
|
|
163
|
+
{
|
|
164
|
+
#ifdef EIGEN_SPARSE_ASSIGNMENT_FROM_DENSE_OP_SPARSE_PLUGIN
|
|
165
|
+
EIGEN_SPARSE_ASSIGNMENT_FROM_DENSE_OP_SPARSE_PLUGIN
|
|
166
|
+
#endif
|
|
167
|
+
|
|
168
|
+
call_assignment_no_alias(dst, src.lhs(), Func1());
|
|
169
|
+
call_assignment_no_alias(dst, src.rhs(), Func2());
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// Specialization for dense1 = sparse + dense2; -> dense1 = dense2; dense1 += sparse;
|
|
173
|
+
template<typename Lhs, typename Rhs, typename Scalar>
|
|
174
|
+
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
|
175
|
+
typename internal::enable_if<internal::is_same<typename internal::evaluator_traits<Rhs>::Shape,DenseShape>::value>::type
|
|
176
|
+
run(DstXprType &dst, const CwiseBinaryOp<internal::scalar_sum_op<Scalar,Scalar>, const Lhs, const Rhs> &src,
|
|
177
|
+
const internal::assign_op<typename DstXprType::Scalar,Scalar>& /*func*/)
|
|
178
|
+
{
|
|
179
|
+
#ifdef EIGEN_SPARSE_ASSIGNMENT_FROM_SPARSE_ADD_DENSE_PLUGIN
|
|
180
|
+
EIGEN_SPARSE_ASSIGNMENT_FROM_SPARSE_ADD_DENSE_PLUGIN
|
|
181
|
+
#endif
|
|
182
|
+
|
|
183
|
+
// Apply the dense matrix first, then the sparse one.
|
|
184
|
+
call_assignment_no_alias(dst, src.rhs(), Func1());
|
|
185
|
+
call_assignment_no_alias(dst, src.lhs(), Func2());
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// Specialization for dense1 = sparse - dense2; -> dense1 = -dense2; dense1 += sparse;
|
|
189
|
+
template<typename Lhs, typename Rhs, typename Scalar>
|
|
190
|
+
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
|
191
|
+
typename internal::enable_if<internal::is_same<typename internal::evaluator_traits<Rhs>::Shape,DenseShape>::value>::type
|
|
192
|
+
run(DstXprType &dst, const CwiseBinaryOp<internal::scalar_difference_op<Scalar,Scalar>, const Lhs, const Rhs> &src,
|
|
193
|
+
const internal::assign_op<typename DstXprType::Scalar,Scalar>& /*func*/)
|
|
194
|
+
{
|
|
195
|
+
#ifdef EIGEN_SPARSE_ASSIGNMENT_FROM_SPARSE_SUB_DENSE_PLUGIN
|
|
196
|
+
EIGEN_SPARSE_ASSIGNMENT_FROM_SPARSE_SUB_DENSE_PLUGIN
|
|
197
|
+
#endif
|
|
198
|
+
|
|
199
|
+
// Apply the dense matrix first, then the sparse one.
|
|
200
|
+
call_assignment_no_alias(dst, -src.rhs(), Func1());
|
|
201
|
+
call_assignment_no_alias(dst, src.lhs(), add_assign_op<typename DstXprType::Scalar,typename Lhs::Scalar>());
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
#define EIGEN_CATCH_ASSIGN_DENSE_OP_SPARSE(ASSIGN_OP,BINOP,ASSIGN_OP2) \
|
|
206
|
+
template< typename DstXprType, typename Lhs, typename Rhs, typename Scalar> \
|
|
207
|
+
struct Assignment<DstXprType, CwiseBinaryOp<internal::BINOP<Scalar,Scalar>, const Lhs, const Rhs>, internal::ASSIGN_OP<typename DstXprType::Scalar,Scalar>, \
|
|
208
|
+
Sparse2Dense, \
|
|
209
|
+
typename internal::enable_if< internal::is_same<typename internal::evaluator_traits<Lhs>::Shape,DenseShape>::value \
|
|
210
|
+
|| internal::is_same<typename internal::evaluator_traits<Rhs>::Shape,DenseShape>::value>::type> \
|
|
211
|
+
: assignment_from_dense_op_sparse<DstXprType, internal::ASSIGN_OP<typename DstXprType::Scalar,typename Lhs::Scalar>, internal::ASSIGN_OP2<typename DstXprType::Scalar,typename Rhs::Scalar> > \
|
|
212
|
+
{}
|
|
213
|
+
|
|
214
|
+
EIGEN_CATCH_ASSIGN_DENSE_OP_SPARSE(assign_op, scalar_sum_op,add_assign_op);
|
|
215
|
+
EIGEN_CATCH_ASSIGN_DENSE_OP_SPARSE(add_assign_op,scalar_sum_op,add_assign_op);
|
|
216
|
+
EIGEN_CATCH_ASSIGN_DENSE_OP_SPARSE(sub_assign_op,scalar_sum_op,sub_assign_op);
|
|
217
|
+
|
|
218
|
+
EIGEN_CATCH_ASSIGN_DENSE_OP_SPARSE(assign_op, scalar_difference_op,sub_assign_op);
|
|
219
|
+
EIGEN_CATCH_ASSIGN_DENSE_OP_SPARSE(add_assign_op,scalar_difference_op,sub_assign_op);
|
|
220
|
+
EIGEN_CATCH_ASSIGN_DENSE_OP_SPARSE(sub_assign_op,scalar_difference_op,add_assign_op);
|
|
221
|
+
|
|
222
|
+
|
|
156
223
|
// Specialization for "dst = dec.solve(rhs)"
|
|
157
224
|
// NOTE we need to specialize it for Sparse2Sparse to avoid ambiguous specialization error
|
|
158
225
|
template<typename DstXprType, typename DecType, typename RhsType, typename Scalar>
|
|
@@ -179,35 +246,22 @@ struct Assignment<DstXprType, SrcXprType, Functor, Diagonal2Sparse>
|
|
|
179
246
|
{
|
|
180
247
|
typedef typename DstXprType::StorageIndex StorageIndex;
|
|
181
248
|
typedef typename DstXprType::Scalar Scalar;
|
|
182
|
-
typedef Array<StorageIndex,Dynamic,1> ArrayXI;
|
|
183
|
-
typedef Array<Scalar,Dynamic,1> ArrayXS;
|
|
184
|
-
template<int Options>
|
|
185
|
-
static void run(SparseMatrix<Scalar,Options,StorageIndex> &dst, const SrcXprType &src, const internal::assign_op<typename DstXprType::Scalar,typename SrcXprType::Scalar> &/*func*/)
|
|
186
|
-
{
|
|
187
|
-
Index dstRows = src.rows();
|
|
188
|
-
Index dstCols = src.cols();
|
|
189
|
-
if((dst.rows()!=dstRows) || (dst.cols()!=dstCols))
|
|
190
|
-
dst.resize(dstRows, dstCols);
|
|
191
249
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
Map<ArrayXI>(dst.innerIndexPtr(), size).setLinSpaced(0,StorageIndex(size)-1);
|
|
196
|
-
Map<ArrayXI>(dst.outerIndexPtr(), size+1).setLinSpaced(0,StorageIndex(size));
|
|
197
|
-
Map<ArrayXS>(dst.valuePtr(), size) = src.diagonal();
|
|
198
|
-
}
|
|
250
|
+
template<int Options, typename AssignFunc>
|
|
251
|
+
static void run(SparseMatrix<Scalar,Options,StorageIndex> &dst, const SrcXprType &src, const AssignFunc &func)
|
|
252
|
+
{ dst.assignDiagonal(src.diagonal(), func); }
|
|
199
253
|
|
|
200
254
|
template<typename DstDerived>
|
|
201
255
|
static void run(SparseMatrixBase<DstDerived> &dst, const SrcXprType &src, const internal::assign_op<typename DstXprType::Scalar,typename SrcXprType::Scalar> &/*func*/)
|
|
202
|
-
{
|
|
203
|
-
dst.diagonal() = src.diagonal();
|
|
204
|
-
}
|
|
256
|
+
{ dst.derived().diagonal() = src.diagonal(); }
|
|
205
257
|
|
|
206
|
-
|
|
207
|
-
|
|
258
|
+
template<typename DstDerived>
|
|
259
|
+
static void run(SparseMatrixBase<DstDerived> &dst, const SrcXprType &src, const internal::add_assign_op<typename DstXprType::Scalar,typename SrcXprType::Scalar> &/*func*/)
|
|
260
|
+
{ dst.derived().diagonal() += src.diagonal(); }
|
|
208
261
|
|
|
209
|
-
|
|
210
|
-
|
|
262
|
+
template<typename DstDerived>
|
|
263
|
+
static void run(SparseMatrixBase<DstDerived> &dst, const SrcXprType &src, const internal::sub_assign_op<typename DstXprType::Scalar,typename SrcXprType::Scalar> &/*func*/)
|
|
264
|
+
{ dst.derived().diagonal() -= src.diagonal(); }
|
|
211
265
|
};
|
|
212
266
|
} // end namespace internal
|
|
213
267
|
|
|
@@ -164,7 +164,7 @@ public:
|
|
|
164
164
|
}
|
|
165
165
|
else
|
|
166
166
|
{
|
|
167
|
-
if(m_matrix.isCompressed())
|
|
167
|
+
if(m_matrix.isCompressed() && nnz!=block_size)
|
|
168
168
|
{
|
|
169
169
|
// no need to realloc, simply copy the tail at its respective position and insert tmp
|
|
170
170
|
matrix.data().resize(start + nnz + tail_size);
|
|
@@ -326,46 +326,6 @@ private:
|
|
|
326
326
|
|
|
327
327
|
//----------
|
|
328
328
|
|
|
329
|
-
/** \returns the \a outer -th column (resp. row) of the matrix \c *this if \c *this
|
|
330
|
-
* is col-major (resp. row-major).
|
|
331
|
-
*/
|
|
332
|
-
template<typename Derived>
|
|
333
|
-
typename SparseMatrixBase<Derived>::InnerVectorReturnType SparseMatrixBase<Derived>::innerVector(Index outer)
|
|
334
|
-
{ return InnerVectorReturnType(derived(), outer); }
|
|
335
|
-
|
|
336
|
-
/** \returns the \a outer -th column (resp. row) of the matrix \c *this if \c *this
|
|
337
|
-
* is col-major (resp. row-major). Read-only.
|
|
338
|
-
*/
|
|
339
|
-
template<typename Derived>
|
|
340
|
-
const typename SparseMatrixBase<Derived>::ConstInnerVectorReturnType SparseMatrixBase<Derived>::innerVector(Index outer) const
|
|
341
|
-
{ return ConstInnerVectorReturnType(derived(), outer); }
|
|
342
|
-
|
|
343
|
-
/** \returns the \a outer -th column (resp. row) of the matrix \c *this if \c *this
|
|
344
|
-
* is col-major (resp. row-major).
|
|
345
|
-
*/
|
|
346
|
-
template<typename Derived>
|
|
347
|
-
typename SparseMatrixBase<Derived>::InnerVectorsReturnType
|
|
348
|
-
SparseMatrixBase<Derived>::innerVectors(Index outerStart, Index outerSize)
|
|
349
|
-
{
|
|
350
|
-
return Block<Derived,Dynamic,Dynamic,true>(derived(),
|
|
351
|
-
IsRowMajor ? outerStart : 0, IsRowMajor ? 0 : outerStart,
|
|
352
|
-
IsRowMajor ? outerSize : rows(), IsRowMajor ? cols() : outerSize);
|
|
353
|
-
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
/** \returns the \a outer -th column (resp. row) of the matrix \c *this if \c *this
|
|
357
|
-
* is col-major (resp. row-major). Read-only.
|
|
358
|
-
*/
|
|
359
|
-
template<typename Derived>
|
|
360
|
-
const typename SparseMatrixBase<Derived>::ConstInnerVectorsReturnType
|
|
361
|
-
SparseMatrixBase<Derived>::innerVectors(Index outerStart, Index outerSize) const
|
|
362
|
-
{
|
|
363
|
-
return Block<const Derived,Dynamic,Dynamic,true>(derived(),
|
|
364
|
-
IsRowMajor ? outerStart : 0, IsRowMajor ? 0 : outerStart,
|
|
365
|
-
IsRowMajor ? outerSize : rows(), IsRowMajor ? cols() : outerSize);
|
|
366
|
-
|
|
367
|
-
}
|
|
368
|
-
|
|
369
329
|
/** Generic implementation of sparse Block expression.
|
|
370
330
|
* Real-only.
|
|
371
331
|
*/
|
|
@@ -486,9 +446,13 @@ struct unary_evaluator<Block<ArgType,BlockRows,BlockCols,InnerPanel>, IteratorBa
|
|
|
486
446
|
{}
|
|
487
447
|
|
|
488
448
|
inline Index nonZerosEstimate() const {
|
|
489
|
-
Index nnz = m_block.nonZeros();
|
|
490
|
-
if(nnz<0)
|
|
491
|
-
|
|
449
|
+
const Index nnz = m_block.nonZeros();
|
|
450
|
+
if(nnz < 0) {
|
|
451
|
+
// Scale the non-zero estimate for the underlying expression linearly with block size.
|
|
452
|
+
// Return zero if the underlying block is empty.
|
|
453
|
+
const Index nested_sz = m_block.nestedExpression().size();
|
|
454
|
+
return nested_sz == 0 ? 0 : m_argImpl.nonZerosEstimate() * m_block.size() / nested_sz;
|
|
455
|
+
}
|
|
492
456
|
return nnz;
|
|
493
457
|
}
|
|
494
458
|
|
|
@@ -503,22 +467,25 @@ template<typename ArgType, int BlockRows, int BlockCols, bool InnerPanel>
|
|
|
503
467
|
class unary_evaluator<Block<ArgType,BlockRows,BlockCols,InnerPanel>, IteratorBased>::InnerVectorInnerIterator
|
|
504
468
|
: public EvalIterator
|
|
505
469
|
{
|
|
506
|
-
|
|
470
|
+
// NOTE MSVC fails to compile if we don't explicitely "import" IsRowMajor from unary_evaluator
|
|
471
|
+
// because the base class EvalIterator has a private IsRowMajor enum too. (bug #1786)
|
|
472
|
+
// NOTE We cannot call it IsRowMajor because it would shadow unary_evaluator::IsRowMajor
|
|
473
|
+
enum { XprIsRowMajor = unary_evaluator::IsRowMajor };
|
|
507
474
|
const XprType& m_block;
|
|
508
475
|
Index m_end;
|
|
509
476
|
public:
|
|
510
477
|
|
|
511
478
|
EIGEN_STRONG_INLINE InnerVectorInnerIterator(const unary_evaluator& aEval, Index outer)
|
|
512
|
-
: EvalIterator(aEval.m_argImpl, outer + (
|
|
479
|
+
: EvalIterator(aEval.m_argImpl, outer + (XprIsRowMajor ? aEval.m_block.startRow() : aEval.m_block.startCol())),
|
|
513
480
|
m_block(aEval.m_block),
|
|
514
|
-
m_end(
|
|
481
|
+
m_end(XprIsRowMajor ? aEval.m_block.startCol()+aEval.m_block.blockCols() : aEval.m_block.startRow()+aEval.m_block.blockRows())
|
|
515
482
|
{
|
|
516
|
-
while( (EvalIterator::operator bool()) && (EvalIterator::index() < (
|
|
483
|
+
while( (EvalIterator::operator bool()) && (EvalIterator::index() < (XprIsRowMajor ? m_block.startCol() : m_block.startRow())) )
|
|
517
484
|
EvalIterator::operator++();
|
|
518
485
|
}
|
|
519
486
|
|
|
520
|
-
inline StorageIndex index() const { return EvalIterator::index() - convert_index<StorageIndex>(
|
|
521
|
-
inline Index outer() const { return EvalIterator::outer() - (
|
|
487
|
+
inline StorageIndex index() const { return EvalIterator::index() - convert_index<StorageIndex>(XprIsRowMajor ? m_block.startCol() : m_block.startRow()); }
|
|
488
|
+
inline Index outer() const { return EvalIterator::outer() - (XprIsRowMajor ? m_block.startRow() : m_block.startCol()); }
|
|
522
489
|
inline Index row() const { return EvalIterator::row() - m_block.startRow(); }
|
|
523
490
|
inline Index col() const { return EvalIterator::col() - m_block.startCol(); }
|
|
524
491
|
|
|
@@ -528,7 +495,8 @@ public:
|
|
|
528
495
|
template<typename ArgType, int BlockRows, int BlockCols, bool InnerPanel>
|
|
529
496
|
class unary_evaluator<Block<ArgType,BlockRows,BlockCols,InnerPanel>, IteratorBased>::OuterVectorInnerIterator
|
|
530
497
|
{
|
|
531
|
-
|
|
498
|
+
// NOTE see above
|
|
499
|
+
enum { XprIsRowMajor = unary_evaluator::IsRowMajor };
|
|
532
500
|
const unary_evaluator& m_eval;
|
|
533
501
|
Index m_outerPos;
|
|
534
502
|
const Index m_innerIndex;
|
|
@@ -538,9 +506,9 @@ public:
|
|
|
538
506
|
|
|
539
507
|
EIGEN_STRONG_INLINE OuterVectorInnerIterator(const unary_evaluator& aEval, Index outer)
|
|
540
508
|
: m_eval(aEval),
|
|
541
|
-
m_outerPos( (
|
|
542
|
-
m_innerIndex(
|
|
543
|
-
m_end(
|
|
509
|
+
m_outerPos( (XprIsRowMajor ? aEval.m_block.startCol() : aEval.m_block.startRow()) ),
|
|
510
|
+
m_innerIndex(XprIsRowMajor ? aEval.m_block.startRow() : aEval.m_block.startCol()),
|
|
511
|
+
m_end(XprIsRowMajor ? aEval.m_block.startCol()+aEval.m_block.blockCols() : aEval.m_block.startRow()+aEval.m_block.blockRows()),
|
|
544
512
|
m_it(m_eval.m_argImpl, m_outerPos)
|
|
545
513
|
{
|
|
546
514
|
EIGEN_UNUSED_VARIABLE(outer);
|
|
@@ -551,10 +519,10 @@ public:
|
|
|
551
519
|
++(*this);
|
|
552
520
|
}
|
|
553
521
|
|
|
554
|
-
inline StorageIndex index() const { return convert_index<StorageIndex>(m_outerPos - (
|
|
522
|
+
inline StorageIndex index() const { return convert_index<StorageIndex>(m_outerPos - (XprIsRowMajor ? m_eval.m_block.startCol() : m_eval.m_block.startRow())); }
|
|
555
523
|
inline Index outer() const { return 0; }
|
|
556
|
-
inline Index row() const { return
|
|
557
|
-
inline Index col() const { return
|
|
524
|
+
inline Index row() const { return XprIsRowMajor ? 0 : index(); }
|
|
525
|
+
inline Index col() const { return XprIsRowMajor ? index() : 0; }
|
|
558
526
|
|
|
559
527
|
inline Scalar value() const { return m_it.value(); }
|
|
560
528
|
inline Scalar& valueRef() { return m_it.valueRef(); }
|
|
@@ -128,6 +128,28 @@ class SparseCompressedBase
|
|
|
128
128
|
protected:
|
|
129
129
|
/** Default constructor. Do nothing. */
|
|
130
130
|
SparseCompressedBase() {}
|
|
131
|
+
|
|
132
|
+
/** \internal return the index of the coeff at (row,col) or just before if it does not exist.
|
|
133
|
+
* This is an analogue of std::lower_bound.
|
|
134
|
+
*/
|
|
135
|
+
internal::LowerBoundIndex lower_bound(Index row, Index col) const
|
|
136
|
+
{
|
|
137
|
+
eigen_internal_assert(row>=0 && row<this->rows() && col>=0 && col<this->cols());
|
|
138
|
+
|
|
139
|
+
const Index outer = Derived::IsRowMajor ? row : col;
|
|
140
|
+
const Index inner = Derived::IsRowMajor ? col : row;
|
|
141
|
+
|
|
142
|
+
Index start = this->outerIndexPtr()[outer];
|
|
143
|
+
Index end = this->isCompressed() ? this->outerIndexPtr()[outer+1] : this->outerIndexPtr()[outer] + this->innerNonZeroPtr()[outer];
|
|
144
|
+
eigen_assert(end>=start && "you are using a non finalized sparse matrix or written coefficient does not exist");
|
|
145
|
+
internal::LowerBoundIndex p;
|
|
146
|
+
p.value = std::lower_bound(this->innerIndexPtr()+start, this->innerIndexPtr()+end,inner) - this->innerIndexPtr();
|
|
147
|
+
p.found = (p.value<end) && (this->innerIndexPtr()[p.value]==inner);
|
|
148
|
+
return p;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
friend struct internal::evaluator<SparseCompressedBase<Derived> >;
|
|
152
|
+
|
|
131
153
|
private:
|
|
132
154
|
template<typename OtherDerived> explicit SparseCompressedBase(const SparseCompressedBase<OtherDerived>&);
|
|
133
155
|
};
|
|
@@ -185,6 +207,14 @@ class SparseCompressedBase<Derived>::InnerIterator
|
|
|
185
207
|
}
|
|
186
208
|
|
|
187
209
|
inline InnerIterator& operator++() { m_id++; return *this; }
|
|
210
|
+
inline InnerIterator& operator+=(Index i) { m_id += i ; return *this; }
|
|
211
|
+
|
|
212
|
+
inline InnerIterator operator+(Index i)
|
|
213
|
+
{
|
|
214
|
+
InnerIterator result = *this;
|
|
215
|
+
result += i;
|
|
216
|
+
return result;
|
|
217
|
+
}
|
|
188
218
|
|
|
189
219
|
inline const Scalar& value() const { return m_values[m_id]; }
|
|
190
220
|
inline Scalar& valueRef() { return const_cast<Scalar&>(m_values[m_id]); }
|
|
@@ -245,6 +275,14 @@ class SparseCompressedBase<Derived>::ReverseInnerIterator
|
|
|
245
275
|
}
|
|
246
276
|
|
|
247
277
|
inline ReverseInnerIterator& operator--() { --m_id; return *this; }
|
|
278
|
+
inline ReverseInnerIterator& operator-=(Index i) { m_id -= i; return *this; }
|
|
279
|
+
|
|
280
|
+
inline ReverseInnerIterator operator-(Index i)
|
|
281
|
+
{
|
|
282
|
+
ReverseInnerIterator result = *this;
|
|
283
|
+
result -= i;
|
|
284
|
+
return result;
|
|
285
|
+
}
|
|
248
286
|
|
|
249
287
|
inline const Scalar& value() const { return m_values[m_id-1]; }
|
|
250
288
|
inline Scalar& valueRef() { return const_cast<Scalar&>(m_values[m_id-1]); }
|
|
@@ -317,17 +355,8 @@ protected:
|
|
|
317
355
|
|
|
318
356
|
Index find(Index row, Index col) const
|
|
319
357
|
{
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
const Index outer = Derived::IsRowMajor ? row : col;
|
|
323
|
-
const Index inner = Derived::IsRowMajor ? col : row;
|
|
324
|
-
|
|
325
|
-
Index start = m_matrix->outerIndexPtr()[outer];
|
|
326
|
-
Index end = m_matrix->isCompressed() ? m_matrix->outerIndexPtr()[outer+1] : m_matrix->outerIndexPtr()[outer] + m_matrix->innerNonZeroPtr()[outer];
|
|
327
|
-
eigen_assert(end>=start && "you are using a non finalized sparse matrix or written coefficient does not exist");
|
|
328
|
-
const Index p = std::lower_bound(m_matrix->innerIndexPtr()+start, m_matrix->innerIndexPtr()+end,inner) - m_matrix->innerIndexPtr();
|
|
329
|
-
|
|
330
|
-
return ((p<end) && (m_matrix->innerIndexPtr()[p]==inner)) ? p : Dynamic;
|
|
358
|
+
internal::LowerBoundIndex p = m_matrix->lower_bound(row,col);
|
|
359
|
+
return p.found ? p.value : Dynamic;
|
|
331
360
|
}
|
|
332
361
|
|
|
333
362
|
const Derived *m_matrix;
|
|
@@ -101,7 +101,7 @@ public:
|
|
|
101
101
|
}
|
|
102
102
|
else
|
|
103
103
|
{
|
|
104
|
-
m_value = 0; // this is to avoid a compilation warning
|
|
104
|
+
m_value = Scalar(0); // this is to avoid a compilation warning
|
|
105
105
|
m_id = -1;
|
|
106
106
|
}
|
|
107
107
|
return *this;
|
|
@@ -126,7 +126,7 @@ public:
|
|
|
126
126
|
|
|
127
127
|
|
|
128
128
|
enum {
|
|
129
|
-
CoeffReadCost = evaluator<Lhs>::CoeffReadCost + evaluator<Rhs>::CoeffReadCost + functor_traits<BinaryOp>::Cost,
|
|
129
|
+
CoeffReadCost = int(evaluator<Lhs>::CoeffReadCost) + int(evaluator<Rhs>::CoeffReadCost) + int(functor_traits<BinaryOp>::Cost),
|
|
130
130
|
Flags = XprType::Flags
|
|
131
131
|
};
|
|
132
132
|
|
|
@@ -211,9 +211,8 @@ public:
|
|
|
211
211
|
|
|
212
212
|
|
|
213
213
|
enum {
|
|
214
|
-
CoeffReadCost = evaluator<Lhs>::CoeffReadCost + evaluator<Rhs>::CoeffReadCost + functor_traits<BinaryOp>::Cost,
|
|
215
|
-
|
|
216
|
-
Flags = (XprType::Flags & ~RowMajorBit) | (int(Rhs::Flags)&RowMajorBit)
|
|
214
|
+
CoeffReadCost = int(evaluator<Lhs>::CoeffReadCost) + int(evaluator<Rhs>::CoeffReadCost) + int(functor_traits<BinaryOp>::Cost),
|
|
215
|
+
Flags = XprType::Flags
|
|
217
216
|
};
|
|
218
217
|
|
|
219
218
|
explicit binary_evaluator(const XprType& xpr)
|
|
@@ -299,9 +298,8 @@ public:
|
|
|
299
298
|
|
|
300
299
|
|
|
301
300
|
enum {
|
|
302
|
-
CoeffReadCost = evaluator<Lhs>::CoeffReadCost + evaluator<Rhs>::CoeffReadCost + functor_traits<BinaryOp>::Cost,
|
|
303
|
-
|
|
304
|
-
Flags = (XprType::Flags & ~RowMajorBit) | (int(Lhs::Flags)&RowMajorBit)
|
|
301
|
+
CoeffReadCost = int(evaluator<Lhs>::CoeffReadCost) + int(evaluator<Rhs>::CoeffReadCost) + int(functor_traits<BinaryOp>::Cost),
|
|
302
|
+
Flags = XprType::Flags
|
|
305
303
|
};
|
|
306
304
|
|
|
307
305
|
explicit binary_evaluator(const XprType& xpr)
|
|
@@ -459,7 +457,7 @@ public:
|
|
|
459
457
|
|
|
460
458
|
|
|
461
459
|
enum {
|
|
462
|
-
CoeffReadCost = evaluator<LhsArg>::CoeffReadCost + evaluator<RhsArg>::CoeffReadCost + functor_traits<BinaryOp>::Cost,
|
|
460
|
+
CoeffReadCost = int(evaluator<LhsArg>::CoeffReadCost) + int(evaluator<RhsArg>::CoeffReadCost) + int(functor_traits<BinaryOp>::Cost),
|
|
463
461
|
Flags = XprType::Flags
|
|
464
462
|
};
|
|
465
463
|
|
|
@@ -532,9 +530,8 @@ public:
|
|
|
532
530
|
|
|
533
531
|
|
|
534
532
|
enum {
|
|
535
|
-
CoeffReadCost = evaluator<LhsArg>::CoeffReadCost + evaluator<RhsArg>::CoeffReadCost + functor_traits<BinaryOp>::Cost,
|
|
536
|
-
|
|
537
|
-
Flags = (XprType::Flags & ~RowMajorBit) | (int(RhsArg::Flags)&RowMajorBit)
|
|
533
|
+
CoeffReadCost = int(evaluator<LhsArg>::CoeffReadCost) + int(evaluator<RhsArg>::CoeffReadCost) + int(functor_traits<BinaryOp>::Cost),
|
|
534
|
+
Flags = XprType::Flags
|
|
538
535
|
};
|
|
539
536
|
|
|
540
537
|
explicit sparse_conjunction_evaluator(const XprType& xpr)
|
|
@@ -607,9 +604,8 @@ public:
|
|
|
607
604
|
|
|
608
605
|
|
|
609
606
|
enum {
|
|
610
|
-
CoeffReadCost = evaluator<LhsArg>::CoeffReadCost + evaluator<RhsArg>::CoeffReadCost + functor_traits<BinaryOp>::Cost,
|
|
611
|
-
|
|
612
|
-
Flags = (XprType::Flags & ~RowMajorBit) | (int(LhsArg::Flags)&RowMajorBit)
|
|
607
|
+
CoeffReadCost = int(evaluator<LhsArg>::CoeffReadCost) + int(evaluator<RhsArg>::CoeffReadCost) + int(functor_traits<BinaryOp>::Cost),
|
|
608
|
+
Flags = XprType::Flags
|
|
613
609
|
};
|
|
614
610
|
|
|
615
611
|
explicit sparse_conjunction_evaluator(const XprType& xpr)
|
|
@@ -24,7 +24,7 @@ struct unary_evaluator<CwiseUnaryOp<UnaryOp,ArgType>, IteratorBased>
|
|
|
24
24
|
class InnerIterator;
|
|
25
25
|
|
|
26
26
|
enum {
|
|
27
|
-
CoeffReadCost = evaluator<ArgType>::CoeffReadCost + functor_traits<UnaryOp>::Cost,
|
|
27
|
+
CoeffReadCost = int(evaluator<ArgType>::CoeffReadCost) + int(functor_traits<UnaryOp>::Cost),
|
|
28
28
|
Flags = XprType::Flags
|
|
29
29
|
};
|
|
30
30
|
|
|
@@ -79,7 +79,7 @@ struct unary_evaluator<CwiseUnaryView<ViewOp,ArgType>, IteratorBased>
|
|
|
79
79
|
class InnerIterator;
|
|
80
80
|
|
|
81
81
|
enum {
|
|
82
|
-
CoeffReadCost = evaluator<ArgType>::CoeffReadCost + functor_traits<ViewOp>::Cost,
|
|
82
|
+
CoeffReadCost = int(evaluator<ArgType>::CoeffReadCost) + int(functor_traits<ViewOp>::Cost),
|
|
83
83
|
Flags = XprType::Flags
|
|
84
84
|
};
|
|
85
85
|
|
|
@@ -88,10 +88,11 @@ struct sparse_time_dense_product_impl<SparseLhsType,DenseRhsType,DenseResType, A
|
|
|
88
88
|
typedef typename internal::remove_all<SparseLhsType>::type Lhs;
|
|
89
89
|
typedef typename internal::remove_all<DenseRhsType>::type Rhs;
|
|
90
90
|
typedef typename internal::remove_all<DenseResType>::type Res;
|
|
91
|
-
typedef
|
|
91
|
+
typedef evaluator<Lhs> LhsEval;
|
|
92
|
+
typedef typename LhsEval::InnerIterator LhsInnerIterator;
|
|
92
93
|
static void run(const SparseLhsType& lhs, const DenseRhsType& rhs, DenseResType& res, const AlphaType& alpha)
|
|
93
94
|
{
|
|
94
|
-
|
|
95
|
+
LhsEval lhsEval(lhs);
|
|
95
96
|
for(Index c=0; c<rhs.cols(); ++c)
|
|
96
97
|
{
|
|
97
98
|
for(Index j=0; j<lhs.outerSize(); ++j)
|
|
@@ -111,17 +112,38 @@ struct sparse_time_dense_product_impl<SparseLhsType,DenseRhsType,DenseResType, t
|
|
|
111
112
|
typedef typename internal::remove_all<SparseLhsType>::type Lhs;
|
|
112
113
|
typedef typename internal::remove_all<DenseRhsType>::type Rhs;
|
|
113
114
|
typedef typename internal::remove_all<DenseResType>::type Res;
|
|
114
|
-
typedef
|
|
115
|
+
typedef evaluator<Lhs> LhsEval;
|
|
116
|
+
typedef typename LhsEval::InnerIterator LhsInnerIterator;
|
|
115
117
|
static void run(const SparseLhsType& lhs, const DenseRhsType& rhs, DenseResType& res, const typename Res::Scalar& alpha)
|
|
116
118
|
{
|
|
117
|
-
|
|
118
|
-
|
|
119
|
+
Index n = lhs.rows();
|
|
120
|
+
LhsEval lhsEval(lhs);
|
|
121
|
+
|
|
122
|
+
#ifdef EIGEN_HAS_OPENMP
|
|
123
|
+
Eigen::initParallel();
|
|
124
|
+
Index threads = Eigen::nbThreads();
|
|
125
|
+
// This 20000 threshold has been found experimentally on 2D and 3D Poisson problems.
|
|
126
|
+
// It basically represents the minimal amount of work to be done to be worth it.
|
|
127
|
+
if(threads>1 && lhsEval.nonZerosEstimate()*rhs.cols() > 20000)
|
|
119
128
|
{
|
|
120
|
-
|
|
121
|
-
for(
|
|
122
|
-
|
|
129
|
+
#pragma omp parallel for schedule(dynamic,(n+threads*4-1)/(threads*4)) num_threads(threads)
|
|
130
|
+
for(Index i=0; i<n; ++i)
|
|
131
|
+
processRow(lhsEval,rhs,res,alpha,i);
|
|
132
|
+
}
|
|
133
|
+
else
|
|
134
|
+
#endif
|
|
135
|
+
{
|
|
136
|
+
for(Index i=0; i<n; ++i)
|
|
137
|
+
processRow(lhsEval, rhs, res, alpha, i);
|
|
123
138
|
}
|
|
124
139
|
}
|
|
140
|
+
|
|
141
|
+
static void processRow(const LhsEval& lhsEval, const DenseRhsType& rhs, Res& res, const typename Res::Scalar& alpha, Index i)
|
|
142
|
+
{
|
|
143
|
+
typename Res::RowXpr res_i(res.row(i));
|
|
144
|
+
for(LhsInnerIterator it(lhsEval,i); it ;++it)
|
|
145
|
+
res_i += (alpha*it.value()) * rhs.row(it.index());
|
|
146
|
+
}
|
|
125
147
|
};
|
|
126
148
|
|
|
127
149
|
template<typename SparseLhsType, typename DenseRhsType, typename DenseResType>
|