JuliaLang / JuliaLang/LinearAlgebra.jl

Disambiguate division and pseudo-division?

Open
#554 6 comments 3 reactions 0 assignees View on GitHub
needs decision
Dominant language
Julia
Stars
77
Forks
65
Avg merge
3d 23h
Merged PRs (30d)
10

Description

...where division means "equivalent to multiplication with inverse" and pseudo-division means "equivalent to multiplication with pseudo-inverse" (with equivalence neglecting any numerical issues). Briefly came up in JuliaLang/julia#23067. Motivating example:
```julia
julia> using LinearAlgebra

julia> foo(n) = zeros(n, 3) \ zeros(n, 1)
foo (generic function with 1 method)

julia> foo(1)
3×1 Array{Float64,2}:
0.0
0.0
0.0

julia> foo(2)
3×1 Array{Float64,2}:
0.0
0.0
0.0

julia> foo(3)
ERROR: SingularException(1)
Stacktrace:
[1] ldiv!(::Diagonal{Float64,Array{Float64,1}}, ::Array{Float64,2}) at stdlib/v1.1/LinearAlgebra/src/diagonal.jl:438
[2] \(::Diagonal{Float64,Array{Float64,1}}, ::Array{Float64,2}) at stdlib/v1.1/LinearAlgebra/src/diagonal.jl:445
[3] \(::Array{Float64,2}, ::Array{Float64,2}) at stdlib/v1.1/LinearAlgebra/src/generic.jl:862
[4] foo(::Int64) at ./REPL[2]:1
[5] top-level scope at none:0

julia> foo(4)
3×1 Array{Float64,2}:
0.0
0.0
0.0
```

Here, it would be useful if there was a dedicated operator to ask for the least-squares solution. But if there was one, `\` should probably always mean exact solution and fail for rectangular matrices.

So if we do this, it would be quite breaking. Is it justified? Should we explore this?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.