Skip to content

Commit f80ea1c

Browse files
Sacha0andreasnoack
authored andcommitted
Replace full(X) with Array(X)/AbstractArray(X) in base/linalg/lu.jl and test/linalg/lu.jl. (#19086)
1 parent 488465e commit f80ea1c

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

base/linalg/lu.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,15 +327,15 @@ factorize(A::Tridiagonal) = lufact(A)
327327
function getindex{T}(F::Base.LinAlg.LU{T,Tridiagonal{T}}, d::Symbol)
328328
m, n = size(F)
329329
if d == :L
330-
L = full(Bidiagonal(ones(T, n), F.factors.dl, false))
330+
L = Array(Bidiagonal(ones(T, n), F.factors.dl, false))
331331
for i = 2:n
332332
tmp = L[F.ipiv[i], 1:i - 1]
333333
L[F.ipiv[i], 1:i - 1] = L[i, 1:i - 1]
334334
L[i, 1:i - 1] = tmp
335335
end
336336
return L
337337
elseif d == :U
338-
U = full(Bidiagonal(F.factors.d, F.factors.du, true))
338+
U = Array(Bidiagonal(F.factors.d, F.factors.du, true))
339339
for i = 1:n - 2
340340
U[i,i + 2] = F.factors.du2[i]
341341
end

test/linalg/lu.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ for eltya in (Float32, Float64, Complex64, Complex128, BigFloat, Int)
3636
if eltya <: BlasFloat
3737
num = rand(eltya)
3838
@test lu(num) == (one(eltya),num,1)
39-
@test full(lufact(num)) eltya[num]
39+
@test AbstractArray(lufact(num)) eltya[num]
4040
end
4141
for eltyb in (Float32, Float64, Complex64, Complex128, Int)
4242
b = eltyb == Int ? rand(1:5, n, 2) : convert(Matrix{eltyb}, eltyb <: Complex ? complex(breal, bimg) : breal)
@@ -68,7 +68,7 @@ debug && println("(Automatic) Square LU decomposition")
6868
@test norm(a'*(lua'\a') - a', 1) < ε*κ*n^2
6969
@test norm(a*(lua\c) - c, 1) < ε*κ*n # c is a vector
7070
@test norm(a'*(lua'\c) - c, 1) < ε*κ*n # c is a vector
71-
@test full(lua) a
71+
@test AbstractArray(lua) a
7272
if eltya <: Real && eltyb <: Real
7373
@test norm(a.'*(lua.'\b) - b,1) < ε*κ*n*2 # Two because the right hand side has two columns
7474
@test norm(a.'*(lua.'\c) - c,1) < ε*κ*n
@@ -81,13 +81,13 @@ debug && println("(Automatic) Square LU decomposition")
8181
end
8282

8383
debug && println("Tridiagonal LU")
84-
κd = cond(full(d),1)
84+
κd = cond(Array(d),1)
8585
lud = lufact(d)
8686
@test lufact(lud) == lud
8787
@test_throws KeyError lud[:Z]
88-
@test lud[:L]*lud[:U] lud[:P]*full(d)
89-
@test lud[:L]*lud[:U] full(d)[lud[:p],:]
90-
@test full(lud) d
88+
@test lud[:L]*lud[:U] lud[:P]*Array(d)
89+
@test lud[:L]*lud[:U] Array(d)[lud[:p],:]
90+
@test AbstractArray(lud) d
9191
f = zeros(eltyb, n+1)
9292
@test_throws DimensionMismatch lud\f
9393
@test_throws DimensionMismatch lud.'\f
@@ -102,17 +102,17 @@ debug && println("Tridiagonal LU")
102102

103103
@test norm(d*(lud\b) - b, 1) < ε*κd*n*2 # Two because the right hand side has two columns
104104
if eltya <: Real
105-
@test norm((lud.'\b) - full(d.')\b, 1) < ε*κd*n*2 # Two because the right hand side has two columns
105+
@test norm((lud.'\b) - Array(d.')\b, 1) < ε*κd*n*2 # Two because the right hand side has two columns
106106
end
107107
if eltya <: Complex
108-
@test norm((lud'\b) - full(d')\b, 1) < ε*κd*n*2 # Two because the right hand side has two columns
108+
@test norm((lud'\b) - Array(d')\b, 1) < ε*κd*n*2 # Two because the right hand side has two columns
109109
end
110110
end
111111
end
112112
if eltya <: BlasFloat && eltyb <: BlasFloat
113113
e = rand(eltyb,n,n)
114114
@test norm(e/lud - e/d,1) < ε*κ*n^2
115-
@test norm((lud.'\e') - full(d.')\e',1) < ε*κd*n^2
115+
@test norm((lud.'\e') - Array(d.')\e',1) < ε*κd*n^2
116116
#test singular
117117
du = rand(eltya,n-1)
118118
dl = rand(eltya,n-1)
@@ -136,11 +136,11 @@ end
136136

137137
# test conversion routine
138138
a = Tridiagonal(rand(9),rand(10),rand(9))
139-
fa = full(a)
139+
fa = Array(a)
140140
falu = lufact(fa)
141141
alu = lufact(a)
142142
falu = convert(typeof(falu),alu)
143-
@test full(alu) == fa
143+
@test AbstractArray(alu) == fa
144144

145145
# Test rational matrices
146146
## Integrate in general tests when more linear algebra is implemented in julia

0 commit comments

Comments
 (0)