Skip to content

Commit 9e37ae2

Browse files
committed
move Base.LinAlg to LinearAlgebra stdlib
1 parent c4b21ca commit 9e37ae2

File tree

124 files changed

+2449
-2375
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+2449
-2375
lines changed

NEWS.md

+3
Original file line numberDiff line numberDiff line change
@@ -899,6 +899,9 @@ Deprecated or removed
899899

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

902+
* Linear algebra functionality, and specifically the `LinAlg` module has moved to the
903+
`LinearAlgebra` standard library module ([#25571]).
904+
902905
* `@printf` and `@sprintf` have been moved to the `Printf` standard library ([#23929],[#25056]).
903906

904907
* The aliases `Complex32`, `Complex64` and `Complex128` have been deprecated in favor of `ComplexF16`,

base/array.jl

+6-1
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,12 @@ end
391391
function _one(unit::T, x::AbstractMatrix) where T
392392
m,n = size(x)
393393
m==n || throw(DimensionMismatch("multiplicative identity defined only for square matrices"))
394-
Matrix{T}(I, m, m)
394+
# Matrix{T}(I, m, m)
395+
I = zeros(T, m, m)
396+
for i in 1:m
397+
I[i,i] = 1
398+
end
399+
I
395400
end
396401

397402
one(x::AbstractMatrix{T}) where {T} = _one(one(T), x)

base/deprecated.jl

+147-1,378
Large diffs are not rendered by default.

base/exports.jl

+1-97
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ export
88
StackTraces,
99
Sys,
1010
Libc,
11-
LinAlg,
12-
BLAS,
13-
LAPACK,
1411
Serializer,
1512
Docs,
1613
Markdown,
@@ -29,7 +26,6 @@ export
2926
AbstractVecOrMat,
3027
Array,
3128
AbstractDict,
32-
Bidiagonal,
3329
BigFloat,
3430
BigInt,
3531
BitArray,
@@ -46,22 +42,16 @@ export
4642
ComplexF64,
4743
ComplexF32,
4844
ComplexF16,
49-
ConjVector,
50-
ConjMatrix,
5145
DenseMatrix,
5246
DenseVecOrMat,
5347
DenseVector,
5448
DevNull,
55-
Diagonal,
5649
Dict,
5750
Dims,
5851
EachLine,
5952
Enum,
6053
Enumerate,
6154
ExponentialBackOff,
62-
Factorization,
63-
Hermitian,
64-
UniformScaling,
6555
IndexCartesian,
6656
IndexLinear,
6757
IndexStyle,
@@ -70,7 +60,6 @@ export
7060
IOBuffer,
7161
IOStream,
7262
LinSpace,
73-
LowerTriangular,
7463
Irrational,
7564
Matrix,
7665
MergeSort,
@@ -94,8 +83,6 @@ export
9483
RoundNearestTiesUp,
9584
RoundToZero,
9685
RoundUp,
97-
Adjoint,
98-
Transpose,
9986
AbstractSerializer,
10087
SerializationState,
10188
Set,
@@ -108,12 +95,8 @@ export
10895
StridedVector,
10996
SubArray,
11097
SubString,
111-
Symmetric,
112-
SymTridiagonal,
11398
Timer,
114-
Tridiagonal,
11599
UnitRange,
116-
UpperTriangular,
117100
Val,
118101
VecOrMat,
119102
Vector,
@@ -178,7 +161,6 @@ export
178161
im,
179162
π, pi,
180163
ℯ,
181-
I,
182164

183165
# Operators
184166
!,
@@ -501,87 +483,9 @@ export
501483
startswith,
502484

503485
# linear algebra
504-
bkfact!,
505-
bkfact,
506-
chol,
507-
cholfact!,
508-
cholfact,
509-
cond,
510-
condskeel,
511-
cross,
512-
adjoint!,
513486
adjoint,
514-
det,
515-
diag,
516-
diagind,
517-
diagm,
518-
diff,
519-
dot,
520-
eig,
521-
eigfact!,
522-
eigfact,
523-
eigmax,
524-
eigmin,
525-
eigvals,
526-
eigvals!,
527-
eigvecs,
528-
factorize,
529-
givens,
530-
hessfact!,
531-
hessfact,
532-
isdiag,
533-
ishermitian,
534-
isposdef!,
535-
isposdef,
536-
issymmetric,
537-
istril,
538-
istriu,
539-
kron,
540-
ldltfact,
541-
ldltfact!,
542-
linreg,
543-
logabsdet,
544-
logdet,
545-
lu,
546-
lufact!,
547-
lufact,
548-
lyap,
549-
norm,
550-
normalize,
551-
normalize!,
552-
nullspace,
553-
ordschur!,
554-
ordschur,
555-
peakflops,
556-
pinv,
557-
qr,
558-
qrfact!,
559-
qrfact,
560-
lq,
561-
lqfact!,
562-
lqfact,
563-
rank,
564-
scale!,
565-
schur,
566-
schurfact!,
567-
schurfact,
568-
svd,
569-
svdfact!,
570-
svdfact,
571-
svdvals!,
572-
svdvals,
573-
sylvester,
574-
trace,
575-
transpose!,
576487
transpose,
577-
tril!,
578-
tril,
579-
triu!,
580-
triu,
581-
vecdot,
582-
vecnorm,
583-
,
584-
×,
488+
kron,
585489

586490
# bitarrays
587491
falses,

base/interactiveutil.jl

-7
Original file line numberDiff line numberDiff line change
@@ -322,13 +322,6 @@ function versioninfo(io::IO=STDOUT; verbose::Bool=false, packages::Bool=false)
322322
println(io)
323323
end
324324
println(io, " WORD_SIZE: ", Sys.WORD_SIZE)
325-
if Base.libblas_name == "libopenblas" || BLAS.vendor() == :openblas || BLAS.vendor() == :openblas64
326-
openblas_config = BLAS.openblas_get_config()
327-
println(io, " BLAS: libopenblas (", openblas_config, ")")
328-
else
329-
println(io, " BLAS: ",libblas_name)
330-
end
331-
println(io, " LAPACK: ",liblapack_name)
332325
println(io, " LIBM: ",libm_name)
333326
println(io, " LLVM: libLLVM-",libllvm_version," (", Sys.JIT, ", ", Sys.CPU_NAME, ")")
334327

base/math.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ end
506506
507507
Compute the hypotenuse ``\\sqrt{\\sum x_i^2}`` avoiding overflow and underflow.
508508
"""
509-
hypot(x::Number...) = vecnorm(x)
509+
hypot(x::Number...) = sqrt(sum(abs2(y) for y in x))
510510

511511
"""
512512
atan2(y, x)

base/precompile.jl

-1
Original file line numberDiff line numberDiff line change
@@ -1234,7 +1234,6 @@ precompile(Tuple{typeof(Base.join), Base.GenericIOBuffer{Array{UInt8, 1}}, Tuple
12341234
precompile(Tuple{typeof(Base.setindex!), Base.Dict{Int64, Nothing}, Nothing, Int64})
12351235
precompile(Tuple{Type{Array{Union{Tuple{Any, Int64}, Tuple{Tuple{}, Any, Bool}}, 1}}, Tuple{Int64}})
12361236
precompile(Tuple{typeof(Base.eachindex), Array{Union{Tuple{Any, Int64}, Tuple{Tuple{}, Any, Bool}}, 1}})
1237-
precompile(Tuple{typeof(Base.LinAlg.BLAS.set_num_threads), Int64})
12381237
precompile(Tuple{typeof(Base.eltype), Type{Base.Union{IO, Nothing}}})
12391238
precompile(Tuple{Type{Base.Union{IO, Nothing}}})
12401239
precompile(Tuple{typeof(Base.eltype), Type{Base.Union{AbstractString, Nothing}}})

base/statistics.jl

+14-6
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ julia> mean!([1. 1.], v)
5959
"""
6060
function mean!(R::AbstractArray, A::AbstractArray)
6161
sum!(R, A; init=true)
62-
scale!(R, max(1, _length(R)) // _length(A))
62+
x = max(1, _length(R)) // _length(A)
63+
R .= R .* x
6364
return R
6465
end
6566

@@ -175,7 +176,8 @@ function varm!(R::AbstractArray{S}, A::AbstractArray, m::AbstractArray; correcte
175176
fill!(R, convert(S, NaN))
176177
else
177178
rn = div(_length(A), _length(R)) - Int(corrected)
178-
scale!(centralize_sumabs2!(R, A, m), 1//rn)
179+
centralize_sumabs2!(R, A, m)
180+
R .= R .* (1 // rn)
179181
end
180182
return R
181183
end
@@ -328,7 +330,7 @@ unscaled_covzm(x::AbstractVector{<:Number}) = sum(abs2, x)
328330
unscaled_covzm(x::AbstractVector) = sum(t -> t*t', x)
329331
unscaled_covzm(x::AbstractMatrix, vardim::Int) = (vardim == 1 ? _conj(x'x) : x * x')
330332

331-
unscaled_covzm(x::AbstractVector, y::AbstractVector) = dot(y, x)
333+
unscaled_covzm(x::AbstractVector, y::AbstractVector) = sum(conj(y[i])*x[i] for i in eachindex(y, x))
332334
unscaled_covzm(x::AbstractVector, y::AbstractMatrix, vardim::Int) =
333335
(vardim == 1 ? *(transpose(x), _conj(y)) : *(transpose(x), transpose(_conj(y))))
334336
unscaled_covzm(x::AbstractMatrix, y::AbstractVector, vardim::Int) =
@@ -342,14 +344,20 @@ covzm(x::AbstractVector; corrected::Bool=true) = unscaled_covzm(x) / (_length(x)
342344
function covzm(x::AbstractMatrix, vardim::Int=1; corrected::Bool=true)
343345
C = unscaled_covzm(x, vardim)
344346
T = promote_type(typeof(first(C) / 1), eltype(C))
345-
return scale!(convert(AbstractMatrix{T}, C), 1//(size(x, vardim) - corrected))
347+
A = convert(AbstractMatrix{T}, C)
348+
b = 1//(size(x, vardim) - corrected)
349+
A .= A .* b
350+
return A
346351
end
347352
covzm(x::AbstractVector, y::AbstractVector; corrected::Bool=true) =
348353
unscaled_covzm(x, y) / (_length(x) - Int(corrected))
349354
function covzm(x::AbstractVecOrMat, y::AbstractVecOrMat, vardim::Int=1; corrected::Bool=true)
350355
C = unscaled_covzm(x, y, vardim)
351356
T = promote_type(typeof(first(C) / 1), eltype(C))
352-
return scale!(convert(AbstractArray{T}, C), 1//(_getnobs(x, y, vardim) - corrected))
357+
A = convert(AbstractArray{T}, C)
358+
b = 1//(_getnobs(x, y, vardim) - corrected)
359+
A .= A .* b
360+
return A
353361
end
354362

355363
# covm (with provided mean)
@@ -467,7 +475,7 @@ end
467475
corzm(x::AbstractVector{T}) where {T} = one(real(T))
468476
function corzm(x::AbstractMatrix, vardim::Int=1)
469477
c = unscaled_covzm(x, vardim)
470-
return cov2cor!(c, sqrt!(diag(c)))
478+
return cov2cor!(c, collect(sqrt(c[i,i]) for i in 1:min(size(c)...)))
471479
end
472480
corzm(x::AbstractVector, y::AbstractMatrix, vardim::Int=1) =
473481
cov2cor!(unscaled_covzm(x, y, vardim), sqrt(sum(abs2, x)), sqrt!(sum(abs2, y, vardim)))

base/sysimg.jl

+4-6
Original file line numberDiff line numberDiff line change
@@ -460,12 +460,6 @@ import Base64
460460

461461
INCLUDE_STATE = 2
462462

463-
# dense linear algebra
464-
include("linalg/linalg.jl")
465-
using .LinAlg
466-
const = dot
467-
const × = cross
468-
469463
include("asyncmap.jl")
470464

471465
include("multimedia.jl")
@@ -520,6 +514,7 @@ Base.require(:FileWatching)
520514
Base.require(:Future)
521515
Base.require(:IterativeEigensolvers)
522516
Base.require(:Libdl)
517+
Base.require(:LinearAlgebra)
523518
Base.require(:Logging)
524519
Base.require(:Mmap)
525520
Base.require(:Printf)
@@ -551,6 +546,9 @@ Base.require(:Unicode)
551546
", run `using SparseArrays` to load sparse array functionality")
552547
@deprecate_binding(SparseVector, root_module(:SparseArrays).SparseVector, true,
553548
", run `using SparseArrays` to load sparse array functionality")
549+
550+
# PR #25571
551+
@deprecate_binding LinAlg root_module(:LinearAlgebra) true ", run `using LinearAlgebra` instead"
554552
end
555553

556554
empty!(LOAD_PATH)

doc/make.jl

-2
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ const PAGES = [
6868
"manual/documentation.md",
6969
"manual/metaprogramming.md",
7070
"manual/arrays.md",
71-
"manual/linear-algebra.md",
7271
"manual/missing.md",
7372
"manual/networking-and-streams.md",
7473
"manual/parallel-computing.md",
@@ -98,7 +97,6 @@ const PAGES = [
9897
"base/arrays.md",
9998
"base/parallel.md",
10099
"base/multi-threading.md",
101-
"base/linalg.md",
102100
"base/constants.md",
103101
"base/file.md",
104102
"base/io-network.md",

doc/src/base/arrays.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ Base.IndexStyle
5050
Base.conj!
5151
Base.stride
5252
Base.strides
53-
Base.LinAlg.checksquare
5453
```
5554

5655
## Broadcast and vectorization
@@ -148,7 +147,7 @@ Base.cumprod
148147
Base.cumprod!
149148
Base.cumsum
150149
Base.cumsum!
151-
Base.LinAlg.diff
150+
LinearAlgebra.diff
152151
Base.repeat(::AbstractArray)
153152
Base.rot180
154153
Base.rotl90

doc/src/base/base.md

-3
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,10 @@ primitive type
8686

8787
## Base Modules
8888
```@docs
89-
Base.BLAS
9089
Base.Docs
9190
Base.Iterators
92-
Base.LAPACK
9391
Base.LibGit2
9492
Base.Libc
95-
Base.LinAlg
9693
Base.Markdown
9794
Base.Meta
9895
Base.Pkg

doc/src/base/index.md

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
* [Distributed Computing](@ref)
1111
* [Shared Arrays](@ref)
1212
* [Multi-Threading](@ref)
13-
* [Linear Algebra](@ref)
1413
* [Constants](@ref lib-constants)
1514
* [Filesystem](@ref)
1615
* [Delimited Files](@ref)

0 commit comments

Comments
 (0)