diff --git a/stdlib/LinearAlgebra/docs/src/index.md b/stdlib/LinearAlgebra/docs/src/index.md index 6ce749aa66647..dda32ce74b13f 100644 --- a/stdlib/LinearAlgebra/docs/src/index.md +++ b/stdlib/LinearAlgebra/docs/src/index.md @@ -315,6 +315,7 @@ Other sparse solvers are available as Julia packages. ```@docs Base.:*(::AbstractMatrix, ::AbstractMatrix) Base.:\(::AbstractMatrix, ::AbstractVecOrMat) +Base.:/(::AbstractVecOrMat, ::AbstractVecOrMat) LinearAlgebra.SingularException LinearAlgebra.PosDefException LinearAlgebra.ZeroPivotException diff --git a/stdlib/LinearAlgebra/src/generic.jl b/stdlib/LinearAlgebra/src/generic.jl index 5db2b525ee584..d6d56c1df670f 100644 --- a/stdlib/LinearAlgebra/src/generic.jl +++ b/stdlib/LinearAlgebra/src/generic.jl @@ -1112,6 +1112,30 @@ function (\)(A::AbstractMatrix, B::AbstractVecOrMat) end (\)(a::AbstractVector, b::AbstractArray) = pinv(a) * b +""" + A / B + +Matrix right-division: `A / B` is equivalent to `(B' \\ A')'` where [`\\`](@ref) is the left-division operator. +For square matrices, the result `X` is such that `A == X*B`. + +See also: [`rdiv!`](@ref). + +# Examples +```jldoctest +julia> A = Float64[1 4 5; 3 9 2]; B = Float64[1 4 2; 3 4 2; 8 7 1]; + +julia> X = A / B +2×3 Matrix{Float64}: + -0.65 3.75 -1.2 + 3.25 -2.75 1.0 + +julia> isapprox(A, X*B) +true + +julia> isapprox(X, A*pinv(B)) +true +``` +""" function (/)(A::AbstractVecOrMat, B::AbstractVecOrMat) size(A,2) != size(B,2) && throw(DimensionMismatch("Both inputs should have the same number of columns")) return copy(adjoint(adjoint(B) \ adjoint(A)))