Skip to content

Commit

Permalink
Merge pull request #25571 from fredrikekre/so-long-and-thanks-for-all…
Browse files Browse the repository at this point in the history
…-the-fish

Base.LinAlg to LinearAlgebra stdlib
  • Loading branch information
Sacha0 authored Jan 18, 2018
2 parents 86ca591 + a056c2f commit 7deac81
Show file tree
Hide file tree
Showing 124 changed files with 2,428 additions and 2,374 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,9 @@ Deprecated or removed

* Sparse array functionality has moved to the `SparseArrays` standard library module ([#25249]).

* Linear algebra functionality, and specifically the `LinAlg` module has moved to the
`LinearAlgebra` standard library module ([#25571]).

* `@printf` and `@sprintf` have been moved to the `Printf` standard library ([#23929],[#25056]).

* The aliases `Complex32`, `Complex64` and `Complex128` have been deprecated in favor of `ComplexF16`,
Expand Down
7 changes: 6 additions & 1 deletion base/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,12 @@ end
function _one(unit::T, x::AbstractMatrix) where T
m,n = size(x)
m==n || throw(DimensionMismatch("multiplicative identity defined only for square matrices"))
Matrix{T}(I, m, m)
# Matrix{T}(I, m, m)
I = zeros(T, m, m)
for i in 1:m
I[i,i] = 1
end
I
end

one(x::AbstractMatrix{T}) where {T} = _one(one(T), x)
Expand Down
1,525 changes: 147 additions & 1,378 deletions base/deprecated.jl

Large diffs are not rendered by default.

98 changes: 1 addition & 97 deletions base/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ export
StackTraces,
Sys,
Libc,
LinAlg,
BLAS,
LAPACK,
Serializer,
Docs,
Markdown,
Expand All @@ -29,7 +26,6 @@ export
AbstractVecOrMat,
Array,
AbstractDict,
Bidiagonal,
BigFloat,
BigInt,
BitArray,
Expand All @@ -46,22 +42,16 @@ export
ComplexF64,
ComplexF32,
ComplexF16,
ConjVector,
ConjMatrix,
DenseMatrix,
DenseVecOrMat,
DenseVector,
DevNull,
Diagonal,
Dict,
Dims,
EachLine,
Enum,
Enumerate,
ExponentialBackOff,
Factorization,
Hermitian,
UniformScaling,
IndexCartesian,
IndexLinear,
IndexStyle,
Expand All @@ -70,7 +60,6 @@ export
IOBuffer,
IOStream,
LinSpace,
LowerTriangular,
Irrational,
Matrix,
MergeSort,
Expand All @@ -94,8 +83,6 @@ export
RoundNearestTiesUp,
RoundToZero,
RoundUp,
Adjoint,
Transpose,
AbstractSerializer,
SerializationState,
Set,
Expand All @@ -108,12 +95,8 @@ export
StridedVector,
SubArray,
SubString,
Symmetric,
SymTridiagonal,
Timer,
Tridiagonal,
UnitRange,
UpperTriangular,
Val,
VecOrMat,
Vector,
Expand Down Expand Up @@ -178,7 +161,6 @@ export
im,
π, pi,
ℯ,
I,

# Operators
!,
Expand Down Expand Up @@ -501,87 +483,9 @@ export
startswith,

# linear algebra
bkfact!,
bkfact,
chol,
cholfact!,
cholfact,
cond,
condskeel,
cross,
adjoint!,
adjoint,
det,
diag,
diagind,
diagm,
diff,
dot,
eig,
eigfact!,
eigfact,
eigmax,
eigmin,
eigvals,
eigvals!,
eigvecs,
factorize,
givens,
hessfact!,
hessfact,
isdiag,
ishermitian,
isposdef!,
isposdef,
issymmetric,
istril,
istriu,
kron,
ldltfact,
ldltfact!,
linreg,
logabsdet,
logdet,
lu,
lufact!,
lufact,
lyap,
norm,
normalize,
normalize!,
nullspace,
ordschur!,
ordschur,
peakflops,
pinv,
qr,
qrfact!,
qrfact,
lq,
lqfact!,
lqfact,
rank,
scale!,
schur,
schurfact!,
schurfact,
svd,
svdfact!,
svdfact,
svdvals!,
svdvals,
sylvester,
trace,
transpose!,
transpose,
tril!,
tril,
triu!,
triu,
vecdot,
vecnorm,
,
×,
kron,

# bitarrays
falses,
Expand Down
7 changes: 0 additions & 7 deletions base/interactiveutil.jl
Original file line number Diff line number Diff line change
Expand Up @@ -322,13 +322,6 @@ function versioninfo(io::IO=STDOUT; verbose::Bool=false, packages::Bool=false)
println(io)
end
println(io, " WORD_SIZE: ", Sys.WORD_SIZE)
if Base.libblas_name == "libopenblas" || BLAS.vendor() == :openblas || BLAS.vendor() == :openblas64
openblas_config = BLAS.openblas_get_config()
println(io, " BLAS: libopenblas (", openblas_config, ")")
else
println(io, " BLAS: ",libblas_name)
end
println(io, " LAPACK: ",liblapack_name)
println(io, " LIBM: ",libm_name)
println(io, " LLVM: libLLVM-",libllvm_version," (", Sys.JIT, ", ", Sys.CPU_NAME, ")")

Expand Down
2 changes: 1 addition & 1 deletion base/math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ end
Compute the hypotenuse ``\\sqrt{\\sum x_i^2}`` avoiding overflow and underflow.
"""
hypot(x::Number...) = vecnorm(x)
hypot(x::Number...) = sqrt(sum(abs2(y) for y in x))

"""
atan2(y, x)
Expand Down
1 change: 0 additions & 1 deletion base/precompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1234,7 +1234,6 @@ precompile(Tuple{typeof(Base.join), Base.GenericIOBuffer{Array{UInt8, 1}}, Tuple
precompile(Tuple{typeof(Base.setindex!), Base.Dict{Int64, Nothing}, Nothing, Int64})
precompile(Tuple{Type{Array{Union{Tuple{Any, Int64}, Tuple{Tuple{}, Any, Bool}}, 1}}, Tuple{Int64}})
precompile(Tuple{typeof(Base.eachindex), Array{Union{Tuple{Any, Int64}, Tuple{Tuple{}, Any, Bool}}, 1}})
precompile(Tuple{typeof(Base.LinAlg.BLAS.set_num_threads), Int64})
precompile(Tuple{typeof(Base.eltype), Type{Base.Union{IO, Nothing}}})
precompile(Tuple{Type{Base.Union{IO, Nothing}}})
precompile(Tuple{typeof(Base.eltype), Type{Base.Union{AbstractString, Nothing}}})
Expand Down
20 changes: 14 additions & 6 deletions base/statistics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ julia> mean!([1. 1.], v)
"""
function mean!(R::AbstractArray, A::AbstractArray)
sum!(R, A; init=true)
scale!(R, max(1, _length(R)) // _length(A))
x = max(1, _length(R)) // _length(A)
R .= R .* x
return R
end

Expand Down Expand Up @@ -175,7 +176,8 @@ function varm!(R::AbstractArray{S}, A::AbstractArray, m::AbstractArray; correcte
fill!(R, convert(S, NaN))
else
rn = div(_length(A), _length(R)) - Int(corrected)
scale!(centralize_sumabs2!(R, A, m), 1//rn)
centralize_sumabs2!(R, A, m)
R .= R .* (1 // rn)
end
return R
end
Expand Down Expand Up @@ -328,7 +330,7 @@ unscaled_covzm(x::AbstractVector{<:Number}) = sum(abs2, x)
unscaled_covzm(x::AbstractVector) = sum(t -> t*t', x)
unscaled_covzm(x::AbstractMatrix, vardim::Int) = (vardim == 1 ? _conj(x'x) : x * x')

unscaled_covzm(x::AbstractVector, y::AbstractVector) = dot(y, x)
unscaled_covzm(x::AbstractVector, y::AbstractVector) = sum(conj(y[i])*x[i] for i in eachindex(y, x))
unscaled_covzm(x::AbstractVector, y::AbstractMatrix, vardim::Int) =
(vardim == 1 ? *(transpose(x), _conj(y)) : *(transpose(x), transpose(_conj(y))))
unscaled_covzm(x::AbstractMatrix, y::AbstractVector, vardim::Int) =
Expand All @@ -342,14 +344,20 @@ covzm(x::AbstractVector; corrected::Bool=true) = unscaled_covzm(x) / (_length(x)
function covzm(x::AbstractMatrix, vardim::Int=1; corrected::Bool=true)
C = unscaled_covzm(x, vardim)
T = promote_type(typeof(first(C) / 1), eltype(C))
return scale!(convert(AbstractMatrix{T}, C), 1//(size(x, vardim) - corrected))
A = convert(AbstractMatrix{T}, C)
b = 1//(size(x, vardim) - corrected)
A .= A .* b
return A
end
covzm(x::AbstractVector, y::AbstractVector; corrected::Bool=true) =
unscaled_covzm(x, y) / (_length(x) - Int(corrected))
function covzm(x::AbstractVecOrMat, y::AbstractVecOrMat, vardim::Int=1; corrected::Bool=true)
C = unscaled_covzm(x, y, vardim)
T = promote_type(typeof(first(C) / 1), eltype(C))
return scale!(convert(AbstractArray{T}, C), 1//(_getnobs(x, y, vardim) - corrected))
A = convert(AbstractArray{T}, C)
b = 1//(_getnobs(x, y, vardim) - corrected)
A .= A .* b
return A
end

# covm (with provided mean)
Expand Down Expand Up @@ -467,7 +475,7 @@ end
corzm(x::AbstractVector{T}) where {T} = one(real(T))
function corzm(x::AbstractMatrix, vardim::Int=1)
c = unscaled_covzm(x, vardim)
return cov2cor!(c, sqrt!(diag(c)))
return cov2cor!(c, collect(sqrt(c[i,i]) for i in 1:min(size(c)...)))
end
corzm(x::AbstractVector, y::AbstractMatrix, vardim::Int=1) =
cov2cor!(unscaled_covzm(x, y, vardim), sqrt(sum(abs2, x)), sqrt!(sum(abs2, y, vardim)))
Expand Down
10 changes: 4 additions & 6 deletions base/sysimg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -460,12 +460,6 @@ import Base64

INCLUDE_STATE = 2

# dense linear algebra
include("linalg/linalg.jl")
using .LinAlg
const = dot
const × = cross

include("asyncmap.jl")

include("multimedia.jl")
Expand Down Expand Up @@ -520,6 +514,7 @@ Base.require(:FileWatching)
Base.require(:Future)
Base.require(:IterativeEigensolvers)
Base.require(:Libdl)
Base.require(:LinearAlgebra)
Base.require(:Logging)
Base.require(:Mmap)
Base.require(:Printf)
Expand Down Expand Up @@ -551,6 +546,9 @@ Base.require(:Unicode)
", run `using SparseArrays` to load sparse array functionality")
@deprecate_binding(SparseVector, root_module(:SparseArrays).SparseVector, true,
", run `using SparseArrays` to load sparse array functionality")

# PR #25571
@deprecate_binding LinAlg root_module(:LinearAlgebra) true ", run `using LinearAlgebra` instead"
end

empty!(LOAD_PATH)
Expand Down
2 changes: 0 additions & 2 deletions doc/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ const PAGES = [
"manual/documentation.md",
"manual/metaprogramming.md",
"manual/arrays.md",
"manual/linear-algebra.md",
"manual/missing.md",
"manual/networking-and-streams.md",
"manual/parallel-computing.md",
Expand Down Expand Up @@ -98,7 +97,6 @@ const PAGES = [
"base/arrays.md",
"base/parallel.md",
"base/multi-threading.md",
"base/linalg.md",
"base/constants.md",
"base/file.md",
"base/io-network.md",
Expand Down
3 changes: 1 addition & 2 deletions doc/src/base/arrays.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ Base.IndexStyle
Base.conj!
Base.stride
Base.strides
Base.LinAlg.checksquare
```

## Broadcast and vectorization
Expand Down Expand Up @@ -148,7 +147,7 @@ Base.cumprod
Base.cumprod!
Base.cumsum
Base.cumsum!
Base.LinAlg.diff
LinearAlgebra.diff
Base.repeat(::AbstractArray)
Base.rot180
Base.rotl90
Expand Down
3 changes: 0 additions & 3 deletions doc/src/base/base.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,10 @@ primitive type

## Base Modules
```@docs
Base.BLAS
Base.Docs
Base.Iterators
Base.LAPACK
Base.LibGit2
Base.Libc
Base.LinAlg
Base.Markdown
Base.Meta
Base.Pkg
Expand Down
1 change: 0 additions & 1 deletion doc/src/base/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
* [Distributed Computing](@ref)
* [Shared Arrays](@ref)
* [Multi-Threading](@ref)
* [Linear Algebra](@ref)
* [Constants](@ref lib-constants)
* [Filesystem](@ref)
* [Delimited Files](@ref)
Expand Down
Loading

0 comments on commit 7deac81

Please sign in to comment.