Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

document that inv(x) is not just for matrices #22610

Merged
merged 3 commits into from
Jul 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion base/number.jl
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,35 @@ copysign(x::Real, y::Real) = ifelse(signbit(x)!=signbit(y), -x, +x)
conj(x::Real) = x
transpose(x::Number) = x
ctranspose(x::Number) = conj(x)
inv(x::Number) = one(x)/x
angle(z::Real) = atan2(zero(z), z)

"""
inv(x)

Return the multiplicative inverse of `x`, such that `x*inv(x)` or `inv(x)*x`
yields [`one(x)`](@ref) (the multiplicative identity) up to roundoff errors.

If `x` is a number, this is essentially the same as `one(x)/x`, but for
some types `inv(x)` may be slightly more efficient.

# Examples
```jldoctest
julia> inv(2)
0.5

julia> inv(1 + 2im)
0.2 - 0.4im

julia> inv(1 + 2im) * (1 + 2im)
1.0 + 0.0im

julia> inv(2//3)
3//2
```
"""
inv(x::Number) = one(x)/x


"""
widemul(x, y)

Expand Down
2 changes: 1 addition & 1 deletion doc/src/stdlib/linalg.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Base.LinAlg.trace
Base.LinAlg.det
Base.LinAlg.logdet
Base.LinAlg.logabsdet
Base.inv
Base.inv(::AbstractMatrix)
Base.LinAlg.pinv
Base.LinAlg.nullspace
Base.repmat
Expand Down
1 change: 1 addition & 0 deletions doc/src/stdlib/math.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Base.:\(::Any, ::Any)
Base.:^(::Number, ::Number)
Base.fma
Base.muladd
Base.inv(::Number)
Base.div
Base.fld
Base.cld
Expand Down