inv()对于一般方阵的求逆仅通过LU分解实现吗?

a = rand(10,10)
b = inv(a)
b*a
det(ans)
a*b
det(ans)

查了官方文档:

Matrix inverse. Computes matrix N such that M * N = I, where I is the identity matrix. Computed by solving the left-division N = M \ I.

\(A, B) Matrix division using a polyalgorithm. For input matrices A and B , the result X is such that A*X == B when A is square.

所以就是LU然后对三角阵求逆没有其他方法了对吧?

开源的好处就是没有啥遮遮掩掩的。从源代码看:

function (\)(A::AbstractMatrix, B::AbstractVecOrMat)
    require_one_based_indexing(A, B)
    m, n = size(A)
    if m == n
        if istril(A)
            if istriu(A)
                return Diagonal(A) \ B
            else
                return LowerTriangular(A) \ B
            end
        end
        if istriu(A)
            return UpperTriangular(A) \ B
        end
        return lu(A) \ B
    end
    return qr(A, ColumnNorm()) \ B
end