Direct representation of matrices with simple data structures (no need for indexing data structure)
Mostly \(O(n^3)\) factorization algorithms
Software Strategies: Dense Case
Assuming you want to use (vs develop) dense LA code:
Learn enough to identify right algorithm
(e.g. is it symmetric? definite? banded? etc)
Learn high-level organizational ideas
Make sure you have a good BLAS
Call LAPACK/ScaLAPACK!
For \(n\) large: wait a while
Sparse direct methods
% Sparse direct (UMFPACK + COLAMD)
[L,U,P,Q] = lu(A);
x = Q*(U\(L\(P*b)));
Direct representation, keep only the nonzeros
Factorization costs depend on problem structure (1D cheap; 2D reasonable; 3D gets expensive; not easy to give a general rule, and NP hard to order for optimal sparsity)
Robust, but hard to scale to large 3D problems
Sparse Direct Strategies
Assuming you want to use (vs develop) sparse LA code
Identify right algorithm (mainly Cholesky vs LU)
Get a good solver (often from list)
You don’t want to roll your own!
Order your unknowns for sparsity
Again, good to use someone else’s software!
For \(n\) large, 3D: get lots of memory and wait
Sparse iterations
% Sparse iterative (PCG + incomplete Cholesky)
tol = 1e-6;
maxit = 500;
R = cholinc(A,'0');
x = pcg(A,b,tol,maxit,R',R);
Only need\(y = Ax\) (maybe \(y = A^T x\))
Produce successively better (?) approximations
Good convergence depends on preconditioning
Best preconditioners are often hard to parallelize