Linear solver optimization: pre-compute matrix factorization