Does Julia have an equivalent to MATLAB's linsolve?

Does Julia have the equivalent of MATLAB’s linsolve?

Link to MATLAB’s function

julia> A = [ 2 1 1
            -1 1 -1
            1 2 3 ]
3×3 Matrix{Int64}:
  2  1   1
 -1  1  -1
  1  2   3

julia> B = [2, 3, -10]
3-element Vector{Int64}:
   2
   3
 -10

julia> X = A \ B
3-element Vector{Float64}:
  3.0
  1.0
 -5.0

(I think Matlab has the same notation, doesn’t it?)

Well, through Matlab’s linsolve function you can also specify some additional parameters (X = linsolve(A,B,opts)). That is perhaps where the question is directed.

1 Like

But Julia will do it for you! If your system is sparse or has other special features, it is likely that the backsolve (\) method has a specialized method which will be invoked to take advantage of that.

3 Likes

In Julia, the analogue of linsolve's options to specify the matrix type are done using either special matrix types, e.g. UpperTriangular(A) \ B, or through factorization objects, e.g. cholesky(A) \ B (if A is SPD), and in general the factorization functions may accept additional parameters.

7 Likes