@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
|
@@ -182,32 +182,14 @@ public:
|
|
|
182
182
|
|
|
183
183
|
/** \internal */
|
|
184
184
|
template<typename Rhs,typename Dest>
|
|
185
|
-
void
|
|
185
|
+
void _solve_vector_with_guess_impl(const Rhs& b, Dest& x) const
|
|
186
186
|
{
|
|
187
187
|
m_iterations = Base::maxIterations();
|
|
188
188
|
m_error = Base::m_tolerance;
|
|
189
189
|
|
|
190
|
-
|
|
191
|
-
{
|
|
192
|
-
m_iterations = Base::maxIterations();
|
|
193
|
-
m_error = Base::m_tolerance;
|
|
194
|
-
|
|
195
|
-
typename Dest::ColXpr xj(x,j);
|
|
196
|
-
internal::least_square_conjugate_gradient(matrix(), b.col(j), xj, Base::m_preconditioner, m_iterations, m_error);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
m_isInitialized = true;
|
|
190
|
+
internal::least_square_conjugate_gradient(matrix(), b, x, Base::m_preconditioner, m_iterations, m_error);
|
|
200
191
|
m_info = m_error <= Base::m_tolerance ? Success : NoConvergence;
|
|
201
192
|
}
|
|
202
|
-
|
|
203
|
-
/** \internal */
|
|
204
|
-
using Base::_solve_impl;
|
|
205
|
-
template<typename Rhs,typename Dest>
|
|
206
|
-
void _solve_impl(const MatrixBase<Rhs>& b, Dest& x) const
|
|
207
|
-
{
|
|
208
|
-
x.setZero();
|
|
209
|
-
_solve_with_guess_impl(b.derived(),x);
|
|
210
|
-
}
|
|
211
193
|
|
|
212
194
|
};
|
|
213
195
|
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
namespace Eigen {
|
|
14
14
|
|
|
15
15
|
template<typename Decomposition, typename RhsType, typename GuessType> class SolveWithGuess;
|
|
16
|
-
|
|
16
|
+
|
|
17
17
|
/** \class SolveWithGuess
|
|
18
18
|
* \ingroup IterativeLinearSolvers_Module
|
|
19
19
|
*
|
|
@@ -45,13 +45,15 @@ public:
|
|
|
45
45
|
typedef typename internal::traits<SolveWithGuess>::PlainObject PlainObject;
|
|
46
46
|
typedef typename internal::generic_xpr_base<SolveWithGuess<Decomposition,RhsType,GuessType>, MatrixXpr, typename internal::traits<RhsType>::StorageKind>::type Base;
|
|
47
47
|
typedef typename internal::ref_selector<SolveWithGuess>::type Nested;
|
|
48
|
-
|
|
48
|
+
|
|
49
49
|
SolveWithGuess(const Decomposition &dec, const RhsType &rhs, const GuessType &guess)
|
|
50
50
|
: m_dec(dec), m_rhs(rhs), m_guess(guess)
|
|
51
51
|
{}
|
|
52
|
-
|
|
53
|
-
EIGEN_DEVICE_FUNC
|
|
54
|
-
|
|
52
|
+
|
|
53
|
+
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
|
|
54
|
+
Index rows() const EIGEN_NOEXCEPT { return m_dec.cols(); }
|
|
55
|
+
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
|
|
56
|
+
Index cols() const EIGEN_NOEXCEPT { return m_rhs.cols(); }
|
|
55
57
|
|
|
56
58
|
EIGEN_DEVICE_FUNC const Decomposition& dec() const { return m_dec; }
|
|
57
59
|
EIGEN_DEVICE_FUNC const RhsType& rhs() const { return m_rhs; }
|
|
@@ -61,7 +63,7 @@ protected:
|
|
|
61
63
|
const Decomposition &m_dec;
|
|
62
64
|
const RhsType &m_rhs;
|
|
63
65
|
const GuessType &m_guess;
|
|
64
|
-
|
|
66
|
+
|
|
65
67
|
private:
|
|
66
68
|
Scalar coeff(Index row, Index col) const;
|
|
67
69
|
Scalar coeff(Index i) const;
|
|
@@ -85,8 +87,8 @@ struct evaluator<SolveWithGuess<Decomposition,RhsType, GuessType> >
|
|
|
85
87
|
m_result = solve.guess();
|
|
86
88
|
solve.dec()._solve_with_guess_impl(solve.rhs(), m_result);
|
|
87
89
|
}
|
|
88
|
-
|
|
89
|
-
protected:
|
|
90
|
+
|
|
91
|
+
protected:
|
|
90
92
|
PlainObject m_result;
|
|
91
93
|
};
|
|
92
94
|
|
|
@@ -108,7 +110,7 @@ struct Assignment<DstXprType, SolveWithGuess<DecType,RhsType,GuessType>, interna
|
|
|
108
110
|
}
|
|
109
111
|
};
|
|
110
112
|
|
|
111
|
-
} // end
|
|
113
|
+
} // end namespace internal
|
|
112
114
|
|
|
113
115
|
} // end namespace Eigen
|
|
114
116
|
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
#ifndef EIGEN_JACOBI_H
|
|
12
12
|
#define EIGEN_JACOBI_H
|
|
13
13
|
|
|
14
|
-
namespace Eigen {
|
|
14
|
+
namespace Eigen {
|
|
15
15
|
|
|
16
16
|
/** \ingroup Jacobi_Module
|
|
17
17
|
* \jacobi_module
|
|
@@ -37,17 +37,20 @@ template<typename Scalar> class JacobiRotation
|
|
|
37
37
|
typedef typename NumTraits<Scalar>::Real RealScalar;
|
|
38
38
|
|
|
39
39
|
/** Default constructor without any initialization. */
|
|
40
|
+
EIGEN_DEVICE_FUNC
|
|
40
41
|
JacobiRotation() {}
|
|
41
42
|
|
|
42
43
|
/** Construct a planar rotation from a cosine-sine pair (\a c, \c s). */
|
|
44
|
+
EIGEN_DEVICE_FUNC
|
|
43
45
|
JacobiRotation(const Scalar& c, const Scalar& s) : m_c(c), m_s(s) {}
|
|
44
46
|
|
|
45
|
-
Scalar& c() { return m_c; }
|
|
46
|
-
Scalar c() const { return m_c; }
|
|
47
|
-
Scalar& s() { return m_s; }
|
|
48
|
-
Scalar s() const { return m_s; }
|
|
47
|
+
EIGEN_DEVICE_FUNC Scalar& c() { return m_c; }
|
|
48
|
+
EIGEN_DEVICE_FUNC Scalar c() const { return m_c; }
|
|
49
|
+
EIGEN_DEVICE_FUNC Scalar& s() { return m_s; }
|
|
50
|
+
EIGEN_DEVICE_FUNC Scalar s() const { return m_s; }
|
|
49
51
|
|
|
50
52
|
/** Concatenates two planar rotation */
|
|
53
|
+
EIGEN_DEVICE_FUNC
|
|
51
54
|
JacobiRotation operator*(const JacobiRotation& other)
|
|
52
55
|
{
|
|
53
56
|
using numext::conj;
|
|
@@ -56,19 +59,26 @@ template<typename Scalar> class JacobiRotation
|
|
|
56
59
|
}
|
|
57
60
|
|
|
58
61
|
/** Returns the transposed transformation */
|
|
62
|
+
EIGEN_DEVICE_FUNC
|
|
59
63
|
JacobiRotation transpose() const { using numext::conj; return JacobiRotation(m_c, -conj(m_s)); }
|
|
60
64
|
|
|
61
65
|
/** Returns the adjoint transformation */
|
|
66
|
+
EIGEN_DEVICE_FUNC
|
|
62
67
|
JacobiRotation adjoint() const { using numext::conj; return JacobiRotation(conj(m_c), -m_s); }
|
|
63
68
|
|
|
64
69
|
template<typename Derived>
|
|
70
|
+
EIGEN_DEVICE_FUNC
|
|
65
71
|
bool makeJacobi(const MatrixBase<Derived>&, Index p, Index q);
|
|
72
|
+
EIGEN_DEVICE_FUNC
|
|
66
73
|
bool makeJacobi(const RealScalar& x, const Scalar& y, const RealScalar& z);
|
|
67
74
|
|
|
75
|
+
EIGEN_DEVICE_FUNC
|
|
68
76
|
void makeGivens(const Scalar& p, const Scalar& q, Scalar* r=0);
|
|
69
77
|
|
|
70
78
|
protected:
|
|
79
|
+
EIGEN_DEVICE_FUNC
|
|
71
80
|
void makeGivens(const Scalar& p, const Scalar& q, Scalar* r, internal::true_type);
|
|
81
|
+
EIGEN_DEVICE_FUNC
|
|
72
82
|
void makeGivens(const Scalar& p, const Scalar& q, Scalar* r, internal::false_type);
|
|
73
83
|
|
|
74
84
|
Scalar m_c, m_s;
|
|
@@ -80,10 +90,12 @@ template<typename Scalar> class JacobiRotation
|
|
|
80
90
|
* \sa MatrixBase::makeJacobi(const MatrixBase<Derived>&, Index, Index), MatrixBase::applyOnTheLeft(), MatrixBase::applyOnTheRight()
|
|
81
91
|
*/
|
|
82
92
|
template<typename Scalar>
|
|
93
|
+
EIGEN_DEVICE_FUNC
|
|
83
94
|
bool JacobiRotation<Scalar>::makeJacobi(const RealScalar& x, const Scalar& y, const RealScalar& z)
|
|
84
95
|
{
|
|
85
96
|
using std::sqrt;
|
|
86
97
|
using std::abs;
|
|
98
|
+
|
|
87
99
|
RealScalar deno = RealScalar(2)*abs(y);
|
|
88
100
|
if(deno < (std::numeric_limits<RealScalar>::min)())
|
|
89
101
|
{
|
|
@@ -123,6 +135,7 @@ bool JacobiRotation<Scalar>::makeJacobi(const RealScalar& x, const Scalar& y, co
|
|
|
123
135
|
*/
|
|
124
136
|
template<typename Scalar>
|
|
125
137
|
template<typename Derived>
|
|
138
|
+
EIGEN_DEVICE_FUNC
|
|
126
139
|
inline bool JacobiRotation<Scalar>::makeJacobi(const MatrixBase<Derived>& m, Index p, Index q)
|
|
127
140
|
{
|
|
128
141
|
return makeJacobi(numext::real(m.coeff(p,p)), m.coeff(p,q), numext::real(m.coeff(q,q)));
|
|
@@ -145,6 +158,7 @@ inline bool JacobiRotation<Scalar>::makeJacobi(const MatrixBase<Derived>& m, Ind
|
|
|
145
158
|
* \sa MatrixBase::applyOnTheLeft(), MatrixBase::applyOnTheRight()
|
|
146
159
|
*/
|
|
147
160
|
template<typename Scalar>
|
|
161
|
+
EIGEN_DEVICE_FUNC
|
|
148
162
|
void JacobiRotation<Scalar>::makeGivens(const Scalar& p, const Scalar& q, Scalar* r)
|
|
149
163
|
{
|
|
150
164
|
makeGivens(p, q, r, typename internal::conditional<NumTraits<Scalar>::IsComplex, internal::true_type, internal::false_type>::type());
|
|
@@ -153,12 +167,13 @@ void JacobiRotation<Scalar>::makeGivens(const Scalar& p, const Scalar& q, Scalar
|
|
|
153
167
|
|
|
154
168
|
// specialization for complexes
|
|
155
169
|
template<typename Scalar>
|
|
170
|
+
EIGEN_DEVICE_FUNC
|
|
156
171
|
void JacobiRotation<Scalar>::makeGivens(const Scalar& p, const Scalar& q, Scalar* r, internal::true_type)
|
|
157
172
|
{
|
|
158
173
|
using std::sqrt;
|
|
159
174
|
using std::abs;
|
|
160
175
|
using numext::conj;
|
|
161
|
-
|
|
176
|
+
|
|
162
177
|
if(q==Scalar(0))
|
|
163
178
|
{
|
|
164
179
|
m_c = numext::real(p)<0 ? Scalar(-1) : Scalar(1);
|
|
@@ -212,6 +227,7 @@ void JacobiRotation<Scalar>::makeGivens(const Scalar& p, const Scalar& q, Scalar
|
|
|
212
227
|
|
|
213
228
|
// specialization for reals
|
|
214
229
|
template<typename Scalar>
|
|
230
|
+
EIGEN_DEVICE_FUNC
|
|
215
231
|
void JacobiRotation<Scalar>::makeGivens(const Scalar& p, const Scalar& q, Scalar* r, internal::false_type)
|
|
216
232
|
{
|
|
217
233
|
using std::sqrt;
|
|
@@ -257,12 +273,13 @@ void JacobiRotation<Scalar>::makeGivens(const Scalar& p, const Scalar& q, Scalar
|
|
|
257
273
|
|
|
258
274
|
namespace internal {
|
|
259
275
|
/** \jacobi_module
|
|
260
|
-
* Applies the clock wise 2D rotation \a j to the set of 2D vectors of
|
|
276
|
+
* Applies the clock wise 2D rotation \a j to the set of 2D vectors of coordinates \a x and \a y:
|
|
261
277
|
* \f$ \left ( \begin{array}{cc} x \\ y \end{array} \right ) = J \left ( \begin{array}{cc} x \\ y \end{array} \right ) \f$
|
|
262
278
|
*
|
|
263
279
|
* \sa MatrixBase::applyOnTheLeft(), MatrixBase::applyOnTheRight()
|
|
264
280
|
*/
|
|
265
281
|
template<typename VectorX, typename VectorY, typename OtherScalar>
|
|
282
|
+
EIGEN_DEVICE_FUNC
|
|
266
283
|
void apply_rotation_in_the_plane(DenseBase<VectorX>& xpr_x, DenseBase<VectorY>& xpr_y, const JacobiRotation<OtherScalar>& j);
|
|
267
284
|
}
|
|
268
285
|
|
|
@@ -274,6 +291,7 @@ void apply_rotation_in_the_plane(DenseBase<VectorX>& xpr_x, DenseBase<VectorY>&
|
|
|
274
291
|
*/
|
|
275
292
|
template<typename Derived>
|
|
276
293
|
template<typename OtherScalar>
|
|
294
|
+
EIGEN_DEVICE_FUNC
|
|
277
295
|
inline void MatrixBase<Derived>::applyOnTheLeft(Index p, Index q, const JacobiRotation<OtherScalar>& j)
|
|
278
296
|
{
|
|
279
297
|
RowXpr x(this->row(p));
|
|
@@ -289,6 +307,7 @@ inline void MatrixBase<Derived>::applyOnTheLeft(Index p, Index q, const JacobiRo
|
|
|
289
307
|
*/
|
|
290
308
|
template<typename Derived>
|
|
291
309
|
template<typename OtherScalar>
|
|
310
|
+
EIGEN_DEVICE_FUNC
|
|
292
311
|
inline void MatrixBase<Derived>::applyOnTheRight(Index p, Index q, const JacobiRotation<OtherScalar>& j)
|
|
293
312
|
{
|
|
294
313
|
ColXpr x(this->col(p));
|
|
@@ -302,7 +321,8 @@ template<typename Scalar, typename OtherScalar,
|
|
|
302
321
|
int SizeAtCompileTime, int MinAlignment, bool Vectorizable>
|
|
303
322
|
struct apply_rotation_in_the_plane_selector
|
|
304
323
|
{
|
|
305
|
-
static
|
|
324
|
+
static EIGEN_DEVICE_FUNC
|
|
325
|
+
inline void run(Scalar *x, Index incrx, Scalar *y, Index incry, Index size, OtherScalar c, OtherScalar s)
|
|
306
326
|
{
|
|
307
327
|
for(Index i=0; i<size; ++i)
|
|
308
328
|
{
|
|
@@ -429,10 +449,11 @@ struct apply_rotation_in_the_plane_selector<Scalar,OtherScalar,SizeAtCompileTime
|
|
|
429
449
|
};
|
|
430
450
|
|
|
431
451
|
template<typename VectorX, typename VectorY, typename OtherScalar>
|
|
452
|
+
EIGEN_DEVICE_FUNC
|
|
432
453
|
void /*EIGEN_DONT_INLINE*/ apply_rotation_in_the_plane(DenseBase<VectorX>& xpr_x, DenseBase<VectorY>& xpr_y, const JacobiRotation<OtherScalar>& j)
|
|
433
454
|
{
|
|
434
455
|
typedef typename VectorX::Scalar Scalar;
|
|
435
|
-
const bool Vectorizable = (VectorX::Flags & VectorY::Flags & PacketAccessBit)
|
|
456
|
+
const bool Vectorizable = (int(VectorX::Flags) & int(VectorY::Flags) & PacketAccessBit)
|
|
436
457
|
&& (int(packet_traits<Scalar>::size) == int(packet_traits<OtherScalar>::size));
|
|
437
458
|
|
|
438
459
|
eigen_assert(xpr_x.size() == xpr_y.size());
|
|
@@ -442,7 +463,7 @@ void /*EIGEN_DONT_INLINE*/ apply_rotation_in_the_plane(DenseBase<VectorX>& xpr_x
|
|
|
442
463
|
|
|
443
464
|
Scalar* EIGEN_RESTRICT x = &xpr_x.derived().coeffRef(0);
|
|
444
465
|
Scalar* EIGEN_RESTRICT y = &xpr_y.derived().coeffRef(0);
|
|
445
|
-
|
|
466
|
+
|
|
446
467
|
OtherScalar c = j.c();
|
|
447
468
|
OtherScalar s = j.s();
|
|
448
469
|
if (c==OtherScalar(1) && s==OtherScalar(0))
|
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
// This file is part of Eigen, a lightweight C++ template library
|
|
2
|
+
// for linear algebra.
|
|
3
|
+
//
|
|
4
|
+
// Copyright (C) 2017 Kyle Macfarlan <kyle.macfarlan@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_KLUSUPPORT_H
|
|
11
|
+
#define EIGEN_KLUSUPPORT_H
|
|
12
|
+
|
|
13
|
+
namespace Eigen {
|
|
14
|
+
|
|
15
|
+
/* TODO extract L, extract U, compute det, etc... */
|
|
16
|
+
|
|
17
|
+
/** \ingroup KLUSupport_Module
|
|
18
|
+
* \brief A sparse LU factorization and solver based on KLU
|
|
19
|
+
*
|
|
20
|
+
* This class allows to solve for A.X = B sparse linear problems via a LU factorization
|
|
21
|
+
* using the KLU library. The sparse matrix A must be squared and full rank.
|
|
22
|
+
* The vectors or matrices X and B can be either dense or sparse.
|
|
23
|
+
*
|
|
24
|
+
* \warning The input matrix A should be in a \b compressed and \b column-major form.
|
|
25
|
+
* Otherwise an expensive copy will be made. You can call the inexpensive makeCompressed() to get a compressed matrix.
|
|
26
|
+
* \tparam _MatrixType the type of the sparse matrix A, it must be a SparseMatrix<>
|
|
27
|
+
*
|
|
28
|
+
* \implsparsesolverconcept
|
|
29
|
+
*
|
|
30
|
+
* \sa \ref TutorialSparseSolverConcept, class UmfPackLU, class SparseLU
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
inline int klu_solve(klu_symbolic *Symbolic, klu_numeric *Numeric, Index ldim, Index nrhs, double B [ ], klu_common *Common, double) {
|
|
35
|
+
return klu_solve(Symbolic, Numeric, internal::convert_index<int>(ldim), internal::convert_index<int>(nrhs), B, Common);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
inline int klu_solve(klu_symbolic *Symbolic, klu_numeric *Numeric, Index ldim, Index nrhs, std::complex<double>B[], klu_common *Common, std::complex<double>) {
|
|
39
|
+
return klu_z_solve(Symbolic, Numeric, internal::convert_index<int>(ldim), internal::convert_index<int>(nrhs), &numext::real_ref(B[0]), Common);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
inline int klu_tsolve(klu_symbolic *Symbolic, klu_numeric *Numeric, Index ldim, Index nrhs, double B[], klu_common *Common, double) {
|
|
43
|
+
return klu_tsolve(Symbolic, Numeric, internal::convert_index<int>(ldim), internal::convert_index<int>(nrhs), B, Common);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
inline int klu_tsolve(klu_symbolic *Symbolic, klu_numeric *Numeric, Index ldim, Index nrhs, std::complex<double>B[], klu_common *Common, std::complex<double>) {
|
|
47
|
+
return klu_z_tsolve(Symbolic, Numeric, internal::convert_index<int>(ldim), internal::convert_index<int>(nrhs), &numext::real_ref(B[0]), 0, Common);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
inline klu_numeric* klu_factor(int Ap [ ], int Ai [ ], double Ax [ ], klu_symbolic *Symbolic, klu_common *Common, double) {
|
|
51
|
+
return klu_factor(Ap, Ai, Ax, Symbolic, Common);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
inline klu_numeric* klu_factor(int Ap[], int Ai[], std::complex<double> Ax[], klu_symbolic *Symbolic, klu_common *Common, std::complex<double>) {
|
|
55
|
+
return klu_z_factor(Ap, Ai, &numext::real_ref(Ax[0]), Symbolic, Common);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
template<typename _MatrixType>
|
|
60
|
+
class KLU : public SparseSolverBase<KLU<_MatrixType> >
|
|
61
|
+
{
|
|
62
|
+
protected:
|
|
63
|
+
typedef SparseSolverBase<KLU<_MatrixType> > Base;
|
|
64
|
+
using Base::m_isInitialized;
|
|
65
|
+
public:
|
|
66
|
+
using Base::_solve_impl;
|
|
67
|
+
typedef _MatrixType MatrixType;
|
|
68
|
+
typedef typename MatrixType::Scalar Scalar;
|
|
69
|
+
typedef typename MatrixType::RealScalar RealScalar;
|
|
70
|
+
typedef typename MatrixType::StorageIndex StorageIndex;
|
|
71
|
+
typedef Matrix<Scalar,Dynamic,1> Vector;
|
|
72
|
+
typedef Matrix<int, 1, MatrixType::ColsAtCompileTime> IntRowVectorType;
|
|
73
|
+
typedef Matrix<int, MatrixType::RowsAtCompileTime, 1> IntColVectorType;
|
|
74
|
+
typedef SparseMatrix<Scalar> LUMatrixType;
|
|
75
|
+
typedef SparseMatrix<Scalar,ColMajor,int> KLUMatrixType;
|
|
76
|
+
typedef Ref<const KLUMatrixType, StandardCompressedFormat> KLUMatrixRef;
|
|
77
|
+
enum {
|
|
78
|
+
ColsAtCompileTime = MatrixType::ColsAtCompileTime,
|
|
79
|
+
MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
public:
|
|
83
|
+
|
|
84
|
+
KLU()
|
|
85
|
+
: m_dummy(0,0), mp_matrix(m_dummy)
|
|
86
|
+
{
|
|
87
|
+
init();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
template<typename InputMatrixType>
|
|
91
|
+
explicit KLU(const InputMatrixType& matrix)
|
|
92
|
+
: mp_matrix(matrix)
|
|
93
|
+
{
|
|
94
|
+
init();
|
|
95
|
+
compute(matrix);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
~KLU()
|
|
99
|
+
{
|
|
100
|
+
if(m_symbolic) klu_free_symbolic(&m_symbolic,&m_common);
|
|
101
|
+
if(m_numeric) klu_free_numeric(&m_numeric,&m_common);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
EIGEN_CONSTEXPR inline Index rows() const EIGEN_NOEXCEPT { return mp_matrix.rows(); }
|
|
105
|
+
EIGEN_CONSTEXPR inline Index cols() const EIGEN_NOEXCEPT { return mp_matrix.cols(); }
|
|
106
|
+
|
|
107
|
+
/** \brief Reports whether previous computation was successful.
|
|
108
|
+
*
|
|
109
|
+
* \returns \c Success if computation was successful,
|
|
110
|
+
* \c NumericalIssue if the matrix.appears to be negative.
|
|
111
|
+
*/
|
|
112
|
+
ComputationInfo info() const
|
|
113
|
+
{
|
|
114
|
+
eigen_assert(m_isInitialized && "Decomposition is not initialized.");
|
|
115
|
+
return m_info;
|
|
116
|
+
}
|
|
117
|
+
#if 0 // not implemented yet
|
|
118
|
+
inline const LUMatrixType& matrixL() const
|
|
119
|
+
{
|
|
120
|
+
if (m_extractedDataAreDirty) extractData();
|
|
121
|
+
return m_l;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
inline const LUMatrixType& matrixU() const
|
|
125
|
+
{
|
|
126
|
+
if (m_extractedDataAreDirty) extractData();
|
|
127
|
+
return m_u;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
inline const IntColVectorType& permutationP() const
|
|
131
|
+
{
|
|
132
|
+
if (m_extractedDataAreDirty) extractData();
|
|
133
|
+
return m_p;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
inline const IntRowVectorType& permutationQ() const
|
|
137
|
+
{
|
|
138
|
+
if (m_extractedDataAreDirty) extractData();
|
|
139
|
+
return m_q;
|
|
140
|
+
}
|
|
141
|
+
#endif
|
|
142
|
+
/** Computes the sparse Cholesky decomposition of \a matrix
|
|
143
|
+
* Note that the matrix should be column-major, and in compressed format for best performance.
|
|
144
|
+
* \sa SparseMatrix::makeCompressed().
|
|
145
|
+
*/
|
|
146
|
+
template<typename InputMatrixType>
|
|
147
|
+
void compute(const InputMatrixType& matrix)
|
|
148
|
+
{
|
|
149
|
+
if(m_symbolic) klu_free_symbolic(&m_symbolic, &m_common);
|
|
150
|
+
if(m_numeric) klu_free_numeric(&m_numeric, &m_common);
|
|
151
|
+
grab(matrix.derived());
|
|
152
|
+
analyzePattern_impl();
|
|
153
|
+
factorize_impl();
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** Performs a symbolic decomposition on the sparcity of \a matrix.
|
|
157
|
+
*
|
|
158
|
+
* This function is particularly useful when solving for several problems having the same structure.
|
|
159
|
+
*
|
|
160
|
+
* \sa factorize(), compute()
|
|
161
|
+
*/
|
|
162
|
+
template<typename InputMatrixType>
|
|
163
|
+
void analyzePattern(const InputMatrixType& matrix)
|
|
164
|
+
{
|
|
165
|
+
if(m_symbolic) klu_free_symbolic(&m_symbolic, &m_common);
|
|
166
|
+
if(m_numeric) klu_free_numeric(&m_numeric, &m_common);
|
|
167
|
+
|
|
168
|
+
grab(matrix.derived());
|
|
169
|
+
|
|
170
|
+
analyzePattern_impl();
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
/** Provides access to the control settings array used by KLU.
|
|
175
|
+
*
|
|
176
|
+
* See KLU documentation for details.
|
|
177
|
+
*/
|
|
178
|
+
inline const klu_common& kluCommon() const
|
|
179
|
+
{
|
|
180
|
+
return m_common;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** Provides access to the control settings array used by UmfPack.
|
|
184
|
+
*
|
|
185
|
+
* If this array contains NaN's, the default values are used.
|
|
186
|
+
*
|
|
187
|
+
* See KLU documentation for details.
|
|
188
|
+
*/
|
|
189
|
+
inline klu_common& kluCommon()
|
|
190
|
+
{
|
|
191
|
+
return m_common;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/** Performs a numeric decomposition of \a matrix
|
|
195
|
+
*
|
|
196
|
+
* The given matrix must has the same sparcity than the matrix on which the pattern anylysis has been performed.
|
|
197
|
+
*
|
|
198
|
+
* \sa analyzePattern(), compute()
|
|
199
|
+
*/
|
|
200
|
+
template<typename InputMatrixType>
|
|
201
|
+
void factorize(const InputMatrixType& matrix)
|
|
202
|
+
{
|
|
203
|
+
eigen_assert(m_analysisIsOk && "KLU: you must first call analyzePattern()");
|
|
204
|
+
if(m_numeric)
|
|
205
|
+
klu_free_numeric(&m_numeric,&m_common);
|
|
206
|
+
|
|
207
|
+
grab(matrix.derived());
|
|
208
|
+
|
|
209
|
+
factorize_impl();
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/** \internal */
|
|
213
|
+
template<typename BDerived,typename XDerived>
|
|
214
|
+
bool _solve_impl(const MatrixBase<BDerived> &b, MatrixBase<XDerived> &x) const;
|
|
215
|
+
|
|
216
|
+
#if 0 // not implemented yet
|
|
217
|
+
Scalar determinant() const;
|
|
218
|
+
|
|
219
|
+
void extractData() const;
|
|
220
|
+
#endif
|
|
221
|
+
|
|
222
|
+
protected:
|
|
223
|
+
|
|
224
|
+
void init()
|
|
225
|
+
{
|
|
226
|
+
m_info = InvalidInput;
|
|
227
|
+
m_isInitialized = false;
|
|
228
|
+
m_numeric = 0;
|
|
229
|
+
m_symbolic = 0;
|
|
230
|
+
m_extractedDataAreDirty = true;
|
|
231
|
+
|
|
232
|
+
klu_defaults(&m_common);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
void analyzePattern_impl()
|
|
236
|
+
{
|
|
237
|
+
m_info = InvalidInput;
|
|
238
|
+
m_analysisIsOk = false;
|
|
239
|
+
m_factorizationIsOk = false;
|
|
240
|
+
m_symbolic = klu_analyze(internal::convert_index<int>(mp_matrix.rows()),
|
|
241
|
+
const_cast<StorageIndex*>(mp_matrix.outerIndexPtr()), const_cast<StorageIndex*>(mp_matrix.innerIndexPtr()),
|
|
242
|
+
&m_common);
|
|
243
|
+
if (m_symbolic) {
|
|
244
|
+
m_isInitialized = true;
|
|
245
|
+
m_info = Success;
|
|
246
|
+
m_analysisIsOk = true;
|
|
247
|
+
m_extractedDataAreDirty = true;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
void factorize_impl()
|
|
252
|
+
{
|
|
253
|
+
|
|
254
|
+
m_numeric = klu_factor(const_cast<StorageIndex*>(mp_matrix.outerIndexPtr()), const_cast<StorageIndex*>(mp_matrix.innerIndexPtr()), const_cast<Scalar*>(mp_matrix.valuePtr()),
|
|
255
|
+
m_symbolic, &m_common, Scalar());
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
m_info = m_numeric ? Success : NumericalIssue;
|
|
259
|
+
m_factorizationIsOk = m_numeric ? 1 : 0;
|
|
260
|
+
m_extractedDataAreDirty = true;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
template<typename MatrixDerived>
|
|
264
|
+
void grab(const EigenBase<MatrixDerived> &A)
|
|
265
|
+
{
|
|
266
|
+
mp_matrix.~KLUMatrixRef();
|
|
267
|
+
::new (&mp_matrix) KLUMatrixRef(A.derived());
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
void grab(const KLUMatrixRef &A)
|
|
271
|
+
{
|
|
272
|
+
if(&(A.derived()) != &mp_matrix)
|
|
273
|
+
{
|
|
274
|
+
mp_matrix.~KLUMatrixRef();
|
|
275
|
+
::new (&mp_matrix) KLUMatrixRef(A);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// cached data to reduce reallocation, etc.
|
|
280
|
+
#if 0 // not implemented yet
|
|
281
|
+
mutable LUMatrixType m_l;
|
|
282
|
+
mutable LUMatrixType m_u;
|
|
283
|
+
mutable IntColVectorType m_p;
|
|
284
|
+
mutable IntRowVectorType m_q;
|
|
285
|
+
#endif
|
|
286
|
+
|
|
287
|
+
KLUMatrixType m_dummy;
|
|
288
|
+
KLUMatrixRef mp_matrix;
|
|
289
|
+
|
|
290
|
+
klu_numeric* m_numeric;
|
|
291
|
+
klu_symbolic* m_symbolic;
|
|
292
|
+
klu_common m_common;
|
|
293
|
+
mutable ComputationInfo m_info;
|
|
294
|
+
int m_factorizationIsOk;
|
|
295
|
+
int m_analysisIsOk;
|
|
296
|
+
mutable bool m_extractedDataAreDirty;
|
|
297
|
+
|
|
298
|
+
private:
|
|
299
|
+
KLU(const KLU& ) { }
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
#if 0 // not implemented yet
|
|
303
|
+
template<typename MatrixType>
|
|
304
|
+
void KLU<MatrixType>::extractData() const
|
|
305
|
+
{
|
|
306
|
+
if (m_extractedDataAreDirty)
|
|
307
|
+
{
|
|
308
|
+
eigen_assert(false && "KLU: extractData Not Yet Implemented");
|
|
309
|
+
|
|
310
|
+
// get size of the data
|
|
311
|
+
int lnz, unz, rows, cols, nz_udiag;
|
|
312
|
+
umfpack_get_lunz(&lnz, &unz, &rows, &cols, &nz_udiag, m_numeric, Scalar());
|
|
313
|
+
|
|
314
|
+
// allocate data
|
|
315
|
+
m_l.resize(rows,(std::min)(rows,cols));
|
|
316
|
+
m_l.resizeNonZeros(lnz);
|
|
317
|
+
|
|
318
|
+
m_u.resize((std::min)(rows,cols),cols);
|
|
319
|
+
m_u.resizeNonZeros(unz);
|
|
320
|
+
|
|
321
|
+
m_p.resize(rows);
|
|
322
|
+
m_q.resize(cols);
|
|
323
|
+
|
|
324
|
+
// extract
|
|
325
|
+
umfpack_get_numeric(m_l.outerIndexPtr(), m_l.innerIndexPtr(), m_l.valuePtr(),
|
|
326
|
+
m_u.outerIndexPtr(), m_u.innerIndexPtr(), m_u.valuePtr(),
|
|
327
|
+
m_p.data(), m_q.data(), 0, 0, 0, m_numeric);
|
|
328
|
+
|
|
329
|
+
m_extractedDataAreDirty = false;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
template<typename MatrixType>
|
|
334
|
+
typename KLU<MatrixType>::Scalar KLU<MatrixType>::determinant() const
|
|
335
|
+
{
|
|
336
|
+
eigen_assert(false && "KLU: extractData Not Yet Implemented");
|
|
337
|
+
return Scalar();
|
|
338
|
+
}
|
|
339
|
+
#endif
|
|
340
|
+
|
|
341
|
+
template<typename MatrixType>
|
|
342
|
+
template<typename BDerived,typename XDerived>
|
|
343
|
+
bool KLU<MatrixType>::_solve_impl(const MatrixBase<BDerived> &b, MatrixBase<XDerived> &x) const
|
|
344
|
+
{
|
|
345
|
+
Index rhsCols = b.cols();
|
|
346
|
+
EIGEN_STATIC_ASSERT((XDerived::Flags&RowMajorBit)==0, THIS_METHOD_IS_ONLY_FOR_COLUMN_MAJOR_MATRICES);
|
|
347
|
+
eigen_assert(m_factorizationIsOk && "The decomposition is not in a valid state for solving, you must first call either compute() or analyzePattern()/factorize()");
|
|
348
|
+
|
|
349
|
+
x = b;
|
|
350
|
+
int info = klu_solve(m_symbolic, m_numeric, b.rows(), rhsCols, x.const_cast_derived().data(), const_cast<klu_common*>(&m_common), Scalar());
|
|
351
|
+
|
|
352
|
+
m_info = info!=0 ? Success : NumericalIssue;
|
|
353
|
+
return true;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
} // end namespace Eigen
|
|
357
|
+
|
|
358
|
+
#endif // EIGEN_KLUSUPPORT_H
|