Difference between revisions of "Solving sparse systems"

From Medusa: Coordinate Free Mehless Method implementation
Jump to: navigation, search
Line 13: Line 13:
 
* iterative: bicgstab, cg
 
* iterative: bicgstab, cg
  
Solving a simple sparse system $A x = b$ with $A = \begin{bmatrix}  -2 & 1 & \\ 1 & \ddots & \ddots \\ & \ddots & \end{bmatrix}$ and $b = \begin{bmatrix} 1 \\ \vdots \\ 1 \end{bmatrix}$ with dimension $n$
+
Solving a simple sparse system $A x = b$ for steady space of heat equation in 1d with $n$ nodes.
 
has the following timings in seconds:
 
has the following timings in seconds:
  
Line 26: Line 26:
 
| 0.16
 
| 0.16
 
| 0.28
 
| 0.28
| /
+
| 0.04
 
|-
 
|-
 
! SparseLU
 
! SparseLU
Line 33: Line 33:
 
| 0.69
 
| 0.69
 
|-
 
|-
! Bicgstab / Krylov
+
! BICGStab / Krylov
 
| ??
 
| ??
 
| 0.39
 
| 0.39
| ??
+
| 0.53
 
|}
 
|}
  
Preconditioners matter a lot.
+
Incomplete LU preconditioner was used for Eigen BICGStab.

Revision as of 12:25, 16 March 2017

There are many methods available for solving sparse systems. We compare some of them here.

Mathematica has the following methods available (https://reference.wolfram.com/language/ref/LinearSolve.html#DetailsAndOptions)

  • direct: banded, cholesky, multifrontal (direct sparse LU)
  • iterative: Krylov

Matlab has the following methods:

Eigen has the following methods: (https://eigen.tuxfamily.org/dox-devel/group__TopicSparseSystems.html)

  • direct: sparse LU
  • iterative: bicgstab, cg

Solving a simple sparse system $A x = b$ for steady space of heat equation in 1d with $n$ nodes. has the following timings in seconds:

$n = 10^6$ Matlab Mathematica Eigen
Banded 0.16 0.28 0.04
SparseLU / 1.73 0.69
BICGStab / Krylov  ?? 0.39 0.53

Incomplete LU preconditioner was used for Eigen BICGStab.