scalamatrixlinear-algebrascalala

How to solve a linear system of matrices in scala breeze?


How to solve a linear system of matrices in scala breeze? ie, I have Ax = b, where A is a matrix (usually positive definite), and x and b are vectors.

I can see that there is a cholesky decomposition available, but I couldn't seem to find a solver? (if it was matlab I could do x = b \ A. If it was scipy I could do x = A.solve(b) )


Solution

  • Apparently, it is quite simple in fact, and built into scala-breeze as an operator:

    x = A \ b
    

    It doesnt use Cholesky, it uses LU decomposition, which is I think about half as fast, but they are both O(n^3), so comparable.