From 034e97fa22fc511a7df40a266ad1c64bb2291d8b Mon Sep 17 00:00:00 2001 From: Sacha Verweij Date: Sun, 9 Oct 2016 15:42:04 -0700 Subject: [PATCH] Migrate full(X) to convert(Array, X) in tests in test/linalg. --- test/linalg/arnoldi.jl | 4 +- test/linalg/bidiag.jl | 24 ++--- test/linalg/cholesky.jl | 22 ++--- test/linalg/dense.jl | 4 +- test/linalg/diagonal.jl | 38 ++++---- test/linalg/hessenberg.jl | 4 +- test/linalg/lapack.jl | 2 +- test/linalg/lq.jl | 28 +++--- test/linalg/lu.jl | 22 ++--- test/linalg/matmul.jl | 2 +- test/linalg/qr.jl | 50 +++++----- test/linalg/schur.jl | 2 +- test/linalg/special.jl | 66 ++++++------- test/linalg/svd.jl | 2 +- test/linalg/symmetric.jl | 8 +- test/linalg/triangular.jl | 170 +++++++++++++++++----------------- test/linalg/tridiag.jl | 45 +++++---- test/linalg/uniformscaling.jl | 32 +++---- 18 files changed, 262 insertions(+), 263 deletions(-) diff --git a/test/linalg/arnoldi.jl b/test/linalg/arnoldi.jl index 76d904f3439a19..26e6653835c1f2 100644 --- a/test/linalg/arnoldi.jl +++ b/test/linalg/arnoldi.jl @@ -156,7 +156,7 @@ end let # svds test A = sparse([1, 1, 2, 3, 4], [2, 1, 1, 3, 1], [2.0, -1.0, 6.1, 7.0, 1.5]) S1 = svds(A, nsv = 2) - S2 = svd(full(A)) + S2 = svd(Array(A)) ## singular values match: @test S1[1][:S] ≈ S2[2][1:2] @@ -201,7 +201,7 @@ end let # complex svds test A = sparse([1, 1, 2, 3, 4], [2, 1, 1, 3, 1], exp.(im*[2.0:2:10;])) S1 = svds(A, nsv = 2) - S2 = svd(full(A)) + S2 = svd(Array(A)) ## singular values match: @test S1[1][:S] ≈ S2[2][1:2] diff --git a/test/linalg/bidiag.jl b/test/linalg/bidiag.jl index 0a102302f30cf9..0ce9dafd0543de 100644 --- a/test/linalg/bidiag.jl +++ b/test/linalg/bidiag.jl @@ -61,12 +61,12 @@ srand(1) @testset "Constructor and basic properties" begin @test size(T, 1) == size(T, 2) == n @test size(T) == (n, n) - @test full(T) == diagm(dv) + diagm(ev, isupper?1:-1) - @test Bidiagonal(full(T), isupper) == T + @test Array(T) == diagm(dv) + diagm(ev, isupper?1:-1) + @test Bidiagonal(Array(T), isupper) == T @test big(T) == T - @test full(abs.(T)) == abs.(diagm(dv)) + abs.(diagm(ev, isupper?1:-1)) - @test full(real(T)) == real(diagm(dv)) + real(diagm(ev, isupper?1:-1)) - @test full(imag(T)) == imag(diagm(dv)) + imag(diagm(ev, isupper?1:-1)) + @test Array(abs.(T)) == abs.(diagm(dv)) + abs.(diagm(ev, isupper?1:-1)) + @test Array(real(T)) == real(diagm(dv)) + real(diagm(ev, isupper?1:-1)) + @test Array(imag(T)) == imag(diagm(dv)) + imag(diagm(ev, isupper?1:-1)) end z = zeros(elty, n) @@ -100,7 +100,7 @@ srand(1) @test_throws ArgumentError triu!(Bidiagonal(dv,ev,'U'),n+1) end - Tfull = full(T) + Tfull = Array(T) @testset "Linear solves" begin if relty <: AbstractFloat c = convert(Matrix{elty}, randn(n,n)) @@ -189,7 +189,7 @@ srand(1) @testset "Singular systems" begin if (elty <: BlasReal) - @test full(svdfact(T)) ≈ full(svdfact!(copy(Tfull))) + @test Array(svdfact(T)) ≈ Array(svdfact!(copy(Tfull))) @test svdvals(Tfull) ≈ svdvals(T) u1, d1, v1 = svd(Tfull) u2, d2, v2 = svd(T) @@ -212,9 +212,9 @@ srand(1) dv = convert(Vector{elty}, relty <: AbstractFloat ? randn(n) : rand(1:10, n)) ev = convert(Vector{elty}, relty <: AbstractFloat ? randn(n-1) : rand(1:10, n-1)) T2 = Bidiagonal(dv, ev, isupper2) - Tfull2 = full(T2) + Tfull2 = Array(T2) for op in (+, -, *) - @test full(op(T, T2)) ≈ op(Tfull, Tfull2) + @test Array(op(T, T2)) ≈ op(Tfull, Tfull2) end end end @@ -240,7 +240,7 @@ end B = rand(Float64,10,10) C = Tridiagonal(rand(Float64,9),rand(Float64,10),rand(Float64,9)) @test promote_rule(Matrix{Float64}, Bidiagonal{Float64}) == Matrix{Float64} - @test promote(B,A) == (B,convert(Matrix{Float64},full(A))) + @test promote(B,A) == (B,convert(Matrix{Float64},Array(A))) @test promote(C,A) == (C,Tridiagonal(zeros(Float64,9),convert(Vector{Float64},A.dv),convert(Vector{Float64},A.ev))) end @@ -279,14 +279,14 @@ import Base.LinAlg: fillslots!, UnitLowerTriangular b = Bidiagonal(randn(1,1), true) st = SymTridiagonal(randn(1,1)) for x in (b, st) - @test full(fill!(x, val)) == fill!(full(x), val) + @test Array(fill!(x, val)) == fill!(Array(x), val) end b = Bidiagonal(randn(2,2), true) st = SymTridiagonal(randn(3), randn(2)) t = Tridiagonal(randn(3,3)) for x in (b, t, st) @test_throws ArgumentError fill!(x, val) - @test full(fill!(x, 0)) == fill!(full(x), 0) + @test Array(fill!(x, 0)) == fill!(Array(x), 0) end end end diff --git a/test/linalg/cholesky.jl b/test/linalg/cholesky.jl index 541012343232b2..e3dfd86d7ea11c 100644 --- a/test/linalg/cholesky.jl +++ b/test/linalg/cholesky.jl @@ -50,7 +50,7 @@ for eltya in (Float32, Float64, Complex64, Complex128, BigFloat, Int) for i=1:n, j=1:n @test E[i,j] <= (n+1)ε/(1-(n+1)ε)*real(sqrt(apd[i,i]*apd[j,j])) end - E = abs.(apd - full(capd)) + E = abs.(apd - Array(capd)) for i=1:n, j=1:n @test E[i,j] <= (n+1)ε/(1-(n+1)ε)*real(sqrt(apd[i,i]*apd[j,j])) end @@ -73,13 +73,13 @@ for eltya in (Float32, Float64, Complex64, Complex128, BigFloat, Int) end # test chol of 2x2 Strang matrix - S = convert(AbstractMatrix{eltya},full(SymTridiagonal([2,2],[-1]))) + S = convert(AbstractMatrix{eltya},Array(SymTridiagonal([2,2],[-1]))) U = Bidiagonal([2,sqrt(eltya(3))],[-1],true) / sqrt(eltya(2)) - @test full(chol(S)) ≈ full(U) + @test Array(chol(S)) ≈ Array(U) #lower Cholesky factor lapd = cholfact(apd, :L) - @test full(lapd) ≈ apd + @test Array(lapd) ≈ apd l = lapd[:L] @test l*l' ≈ apd @test triu(capd.factors) ≈ lapd[:U] @@ -118,12 +118,12 @@ for eltya in (Float32, Float64, Complex64, Complex128, BigFloat, Int) if isreal(apd) @test apd*inv(cpapd) ≈ eye(n) end - @test full(cpapd) ≈ apd + @test Array(cpapd) ≈ apd #getindex @test_throws KeyError cpapd[:Z] @test size(cpapd) == size(apd) - @test full(copy(cpapd)) ≈ apd + @test Array(copy(cpapd)) ≈ apd @test det(cpapd) ≈ det(apd) @test cpapd[:P]*cpapd[:L]*cpapd[:U]*cpapd[:P]' ≈ apd end @@ -174,9 +174,9 @@ begin # Cholesky factor of Matrix with non-commutative elements, here 2x2-matrices X = Matrix{Float64}[0.1*rand(2,2) for i in 1:3, j = 1:3] - L = full(Base.LinAlg._chol!(X*X', LowerTriangular)) - U = full(Base.LinAlg._chol!(X*X', UpperTriangular)) - XX = full(X*X') + L = Array(Base.LinAlg._chol!(X*X', LowerTriangular)) + U = Array(Base.LinAlg._chol!(X*X', UpperTriangular)) + XX = Array(X*X') @test sum(sum(norm, L*L' - XX)) < eps() @test sum(sum(norm, U'*U - XX)) < eps() @@ -190,8 +190,8 @@ for elty in (Float32, Float64, Complex{Float32}, Complex{Float64}) A = randn(5,5) end A = convert(Matrix{elty}, A'A) - @test full(cholfact(A)[:L]) ≈ full(invoke(Base.LinAlg._chol!, Tuple{AbstractMatrix, Type{LowerTriangular}}, copy(A), LowerTriangular)) - @test full(cholfact(A)[:U]) ≈ full(invoke(Base.LinAlg._chol!, Tuple{AbstractMatrix, Type{UpperTriangular}}, copy(A), UpperTriangular)) + @test Array(cholfact(A)[:L]) ≈ Array(invoke(Base.LinAlg._chol!, Tuple{AbstractMatrix, Type{LowerTriangular}}, copy(A), LowerTriangular)) + @test Array(cholfact(A)[:U]) ≈ Array(invoke(Base.LinAlg._chol!, Tuple{AbstractMatrix, Type{UpperTriangular}}, copy(A), UpperTriangular)) end # Test up- and downdates diff --git a/test/linalg/dense.jl b/test/linalg/dense.jl index 52d018a9b888d2..a0d846a6c5fed6 100644 --- a/test/linalg/dense.jl +++ b/test/linalg/dense.jl @@ -120,12 +120,12 @@ debug && println("Factorize") @test factorize(A) == Bidiagonal(d,e,true) if eltya <: Real A = diagm(d) + diagm(e,1) + diagm(e,-1) - @test full(factorize(A)) ≈ full(factorize(SymTridiagonal(d,e))) + @test Array(factorize(A)) ≈ Array(factorize(SymTridiagonal(d,e))) A = diagm(d) + diagm(e,1) + diagm(e,-1) + diagm(f,2) + diagm(f,-2) @test inv(factorize(A)) ≈ inv(factorize(Symmetric(A))) end A = diagm(d) + diagm(e,1) + diagm(e2,-1) - @test full(factorize(A)) ≈ full(factorize(Tridiagonal(e2,d,e))) + @test Array(factorize(A)) ≈ Array(factorize(Tridiagonal(e2,d,e))) A = diagm(d) + diagm(e,1) + diagm(f,2) @test factorize(A) == UpperTriangular(A) end # for eltya diff --git a/test/linalg/diagonal.jl b/test/linalg/diagonal.jl index bdefcc95d05214..35feae75ed5bde 100644 --- a/test/linalg/diagonal.jl +++ b/test/linalg/diagonal.jl @@ -24,9 +24,9 @@ srand(1) @test typeof(convert(Diagonal{Complex64},D)) == Diagonal{Complex64} @test typeof(convert(AbstractMatrix{Complex64},D)) == Diagonal{Complex64} - @test full(real(D)) == real(DM) - @test full(abs.(D)) == abs.(DM) - @test full(imag(D)) == imag(DM) + @test Array(real(D)) == real(DM) + @test Array(abs.(D)) == abs.(DM) + @test Array(imag(D)) == imag(DM) @test parent(D) == d @test diag(D) == d @@ -76,8 +76,8 @@ srand(1) @test_approx_eq_eps D*v DM*v n*eps(relty)*(elty<:Complex ? 2:1) @test_approx_eq_eps D*U DM*U n^2*eps(relty)*(elty<:Complex ? 2:1) - @test U.'*D ≈ U.'*full(D) - @test U'*D ≈ U'*full(D) + @test U.'*D ≈ U.'*Array(D) + @test U'*D ≈ U'*Array(D) if relty != BigFloat @test_approx_eq_eps D\v DM\v 2n^2*eps(relty)*(elty<:Complex ? 2:1) @@ -89,12 +89,12 @@ srand(1) @test_throws SingularException A_ldiv_B!(Diagonal(zeros(relty,n)),copy(v)) b = rand(elty,n,n) b = sparse(b) - @test A_ldiv_B!(D,copy(b)) ≈ full(D)\full(b) + @test A_ldiv_B!(D,copy(b)) ≈ Array(D)\Array(b) @test_throws SingularException A_ldiv_B!(Diagonal(zeros(elty,n)),copy(b)) b = view(rand(elty,n),collect(1:n)) b2 = copy(b) c = A_ldiv_B!(D,b) - d = full(D)\b2 + d = Array(D)\b2 for i in 1:n @test c[i] ≈ d[i] end @@ -113,27 +113,27 @@ srand(1) DM2= diagm(d) @testset "Binary operations" begin for op in (+, -, *) - @test full(op(D, D2)) ≈ op(DM, DM2) + @test Array(op(D, D2)) ≈ op(DM, DM2) end @testset "with plain numbers" begin a = rand() - @test full(a*D) ≈ a*DM - @test full(D*a) ≈ DM*a - @test full(D/a) ≈ DM/a + @test Array(a*D) ≈ a*DM + @test Array(D*a) ≈ DM*a + @test Array(D/a) ≈ DM/a if relty <: BlasFloat b = rand(elty,n,n) b = sparse(b) - @test A_mul_B!(copy(D), copy(b)) ≈ full(D)*full(b) - @test At_mul_B!(copy(D), copy(b)) ≈ full(D).'*full(b) - @test Ac_mul_B!(copy(D), copy(b)) ≈ full(D)'*full(b) + @test A_mul_B!(copy(D), copy(b)) ≈ Array(D)*Array(b) + @test At_mul_B!(copy(D), copy(b)) ≈ Array(D).'*Array(b) + @test Ac_mul_B!(copy(D), copy(b)) ≈ Array(D)'*Array(b) end end #a few missing mults bd = Bidiagonal(D2) - @test D*D2.' ≈ full(D)*full(D2).' - @test D2*D.' ≈ full(D2)*full(D).' - @test D2*D' ≈ full(D2)*full(D)' + @test D*D2.' ≈ Array(D)*Array(D2).' + @test D2*D.' ≈ Array(D2)*Array(D).' + @test D2*D' ≈ Array(D2)*Array(D)' #division of two Diagonals @test D/D2 ≈ Diagonal(D.diag./D2.diag) @@ -175,7 +175,7 @@ srand(1) @testset "conj and transpose" begin @test transpose(D) == D if elty <: BlasComplex - @test full(conj(D)) ≈ conj(DM) + @test Array(conj(D)) ≈ conj(DM) @test ctranspose(D) == conj(D) end end @@ -260,7 +260,7 @@ end @testset "inverse" begin for d in (randn(n), [1, 2, 3], [1im, 2im, 3im]) D = Diagonal(d) - @test inv(D) ≈ inv(full(D)) + @test inv(D) ≈ inv(Array(D)) end @test_throws SingularException inv(Diagonal(zeros(n))) @test_throws SingularException inv(Diagonal([0, 1, 2])) diff --git a/test/linalg/hessenberg.jl b/test/linalg/hessenberg.jl index 32669b2e0978dc..93c9b959d1ce93 100644 --- a/test/linalg/hessenberg.jl +++ b/test/linalg/hessenberg.jl @@ -23,11 +23,11 @@ let n = 10 @test size(H[:Q], 2) == size(A, 2) @test size(H[:Q]) == size(A) @test_throws KeyError H[:Z] - @test full(H) ≈ A + @test Array(H) ≈ A @test (H[:Q] * H[:H]) * H[:Q]' ≈ A @test (H[:Q]' *A) * H[:Q] ≈ H[:H] #getindex for HessenbergQ - @test H[:Q][1,1] ≈ full(H[:Q])[1,1] + @test H[:Q][1,1] ≈ Array(H[:Q])[1,1] end end end diff --git a/test/linalg/lapack.jl b/test/linalg/lapack.jl index d27955be7f568e..26320e3d00bcca 100644 --- a/test/linalg/lapack.jl +++ b/test/linalg/lapack.jl @@ -52,7 +52,7 @@ end d, e = convert(Vector{elty}, randn(n)), convert(Vector{elty}, randn(n - 1)) U, Vt, C = eye(elty, n), eye(elty, n), eye(elty, n) s, _ = LAPACK.bdsqr!('U', copy(d), copy(e), Vt, U, C) - @test full(Bidiagonal(d, e, true)) ≈ U*Diagonal(s)*Vt + @test Array(Bidiagonal(d, e, true)) ≈ U*Diagonal(s)*Vt @test_throws ArgumentError LAPACK.bdsqr!('A', d, e, Vt, U, C) @test_throws DimensionMismatch LAPACK.bdsqr!('U', d, [e; 1], Vt, U, C) diff --git a/test/linalg/lq.jl b/test/linalg/lq.jl index 798b6826c6b9ea..7728d78e146305 100644 --- a/test/linalg/lq.jl +++ b/test/linalg/lq.jl @@ -50,27 +50,27 @@ bimg = randn(n,2)/2 @test size(lqa[:Q],3) == 1 @test Base.LinAlg.getq(lqa) == lqa[:Q] @test_throws KeyError lqa[:Z] - @test full(lqa') ≈ a' + @test Array(lqa') ≈ a' @test lqa * lqa' ≈ a * a' @test lqa' * lqa ≈ a' * a - @test q*full(q, thin = false)' ≈ eye(eltya,n) + @test q*Base.LinAlg.thickQ(q)' ≈ eye(eltya,n) @test l*q ≈ a - @test full(lqa) ≈ a - @test full(copy(lqa)) ≈ a + @test Array(lqa) ≈ a + @test Array(copy(lqa)) ≈ a end @testset "Binary ops" begin @test_approx_eq_eps a*(lqa\b) b 3000ε @test_approx_eq_eps lqa*b qra[:Q]*qra[:R]*b 3000ε - @test_approx_eq_eps A_mul_Bc(eye(eltyb,size(q.factors,2)),q)*full(q, thin=false) eye(n) 5000ε + @test_approx_eq_eps A_mul_Bc(eye(eltyb,size(q.factors,2)),q)*Base.LinAlg.thickQ(q) eye(n) 5000ε if eltya != Int @test eye(eltyb,n)*q ≈ convert(AbstractMatrix{tab},q) end - @test_approx_eq_eps q*b full(q, thin=false)*b 100ε - @test_approx_eq_eps q.'*b full(q, thin=false).'*b 100ε - @test_approx_eq_eps q'*b full(q, thin=false)'*b 100ε - @test_approx_eq_eps a*q a*full(q, thin=false) 100ε - @test_approx_eq_eps a*q.' a*full(q, thin=false).' 100ε - @test_approx_eq_eps a*q' a*full(q, thin=false)' 100ε + @test_approx_eq_eps q*b Base.LinAlg.thickQ(q)*b 100ε + @test_approx_eq_eps q.'*b Base.LinAlg.thickQ(q).'*b 100ε + @test_approx_eq_eps q'*b Base.LinAlg.thickQ(q)'*b 100ε + @test_approx_eq_eps a*q a*Base.LinAlg.thickQ(q) 100ε + @test_approx_eq_eps a*q.' a*Base.LinAlg.thickQ(q).' 100ε + @test_approx_eq_eps a*q' a*Base.LinAlg.thickQ(q)' 100ε @test_throws DimensionMismatch q*b[1:n1 + 1] @test_throws DimensionMismatch Ac_mul_B(q,ones(eltya,n+2,n+2)) @test_throws DimensionMismatch ones(eltyb,n+2,n+2)*q @@ -81,10 +81,10 @@ bimg = randn(n,2)/2 @testset "Matmul with LQ factorizations" begin lqa = lqfact(a[:,1:n1]) l,q = lqa[:L], lqa[:Q] - @test full(q)*full(q)' ≈ eye(eltya,n1) - @test (full(q,thin=false)'*full(q,thin=false))[1:n1,:] ≈ eye(eltya,n1,n) + @test Array(q)*Array(q)' ≈ eye(eltya,n1) + @test (Base.LinAlg.thickQ(q)'*Base.LinAlg.thickQ(q))[1:n1,:] ≈ eye(eltya,n1,n) @test_throws DimensionMismatch A_mul_B!(eye(eltya,n+1),q) - @test Ac_mul_B!(q,full(q)) ≈ eye(eltya,n1) + @test Ac_mul_B!(q,Array(q)) ≈ eye(eltya,n1) @test_throws DimensionMismatch A_mul_Bc!(eye(eltya,n+1),q) @test_throws BoundsError size(q,-1) end diff --git a/test/linalg/lu.jl b/test/linalg/lu.jl index ca5831029d204a..a9ab68b2fdd058 100644 --- a/test/linalg/lu.jl +++ b/test/linalg/lu.jl @@ -36,7 +36,7 @@ for eltya in (Float32, Float64, Complex64, Complex128, BigFloat, Int) if eltya <: BlasFloat num = rand(eltya) @test lu(num) == (one(eltya),num,1) - @test full(lufact(num)) ≈ eltya[num] + @test Array(lufact(num)) ≈ eltya[num] end for eltyb in (Float32, Float64, Complex64, Complex128, Int) 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") @test norm(a'*(lua'\a') - a', 1) < ε*κ*n^2 @test norm(a*(lua\c) - c, 1) < ε*κ*n # c is a vector @test norm(a'*(lua'\c) - c, 1) < ε*κ*n # c is a vector - @test full(lua) ≈ a + @test Array(lua) ≈ a if eltya <: Real && eltyb <: Real @test norm(a.'*(lua.'\b) - b,1) < ε*κ*n*2 # Two because the right hand side has two columns @test norm(a.'*(lua.'\c) - c,1) < ε*κ*n @@ -81,13 +81,13 @@ debug && println("(Automatic) Square LU decomposition") end debug && println("Tridiagonal LU") - κd = cond(full(d),1) + κd = cond(Array(d),1) lud = lufact(d) @test lufact(lud) == lud @test_throws KeyError lud[:Z] - @test lud[:L]*lud[:U] ≈ lud[:P]*full(d) - @test lud[:L]*lud[:U] ≈ full(d)[lud[:p],:] - @test full(lud) ≈ d + @test lud[:L]*lud[:U] ≈ lud[:P]*Array(d) + @test lud[:L]*lud[:U] ≈ Array(d)[lud[:p],:] + @test Array(lud) ≈ d f = zeros(eltyb, n+1) @test_throws DimensionMismatch lud\f @test_throws DimensionMismatch lud.'\f @@ -102,17 +102,17 @@ debug && println("Tridiagonal LU") @test norm(d*(lud\b) - b, 1) < ε*κd*n*2 # Two because the right hand side has two columns if eltya <: Real - @test norm((lud.'\b) - full(d.')\b, 1) < ε*κd*n*2 # Two because the right hand side has two columns + @test norm((lud.'\b) - Array(d.')\b, 1) < ε*κd*n*2 # Two because the right hand side has two columns end if eltya <: Complex - @test norm((lud'\b) - full(d')\b, 1) < ε*κd*n*2 # Two because the right hand side has two columns + @test norm((lud'\b) - Array(d')\b, 1) < ε*κd*n*2 # Two because the right hand side has two columns end end end if eltya <: BlasFloat && eltyb <: BlasFloat e = rand(eltyb,n,n) @test norm(e/lud - e/d,1) < ε*κ*n^2 - @test norm((lud.'\e') - full(d.')\e',1) < ε*κd*n^2 + @test norm((lud.'\e') - Array(d.')\e',1) < ε*κd*n^2 #test singular du = rand(eltya,n-1) dl = rand(eltya,n-1) @@ -136,11 +136,11 @@ end # test conversion routine a = Tridiagonal(rand(9),rand(10),rand(9)) -fa = full(a) +fa = Array(a) falu = lufact(fa) alu = lufact(a) falu = convert(typeof(falu),alu) -@test full(alu) == fa +@test Array(alu) == fa # Test rational matrices ## Integrate in general tests when more linear algebra is implemented in julia diff --git a/test/linalg/matmul.jl b/test/linalg/matmul.jl index 354b2fc2e3c647..10b71597a4c897 100644 --- a/test/linalg/matmul.jl +++ b/test/linalg/matmul.jl @@ -336,7 +336,7 @@ A = [RootInt(3) RootInt(5)] function test_mul(C, A, B) A_mul_B!(C, A, B) - @test full(A) * full(B) ≈ C + @test Array(A) * Array(B) ≈ C @test A*B ≈ C end diff --git a/test/linalg/qr.jl b/test/linalg/qr.jl index 8df1097b926d63..7709d6625cf9d9 100644 --- a/test/linalg/qr.jl +++ b/test/linalg/qr.jl @@ -46,15 +46,15 @@ debug && println("QR decomposition (without pivoting)") @inferred qr(a) q, r = qra[:Q], qra[:R] @test_throws KeyError qra[:Z] - @test q'*full(q, thin=false) ≈ eye(n) - @test q*full(q, thin=false)' ≈ eye(n) - @test q'*eye(n)' ≈ full(q, thin=false)' - @test full(q, thin=false)'q ≈ eye(n) - @test eye(n)'q' ≈ full(q, thin=false)' + @test q'*Base.LinAlg.thickQ(q) ≈ eye(n) + @test q*Base.LinAlg.thickQ(q)' ≈ eye(n) + @test q'*eye(n)' ≈ Base.LinAlg.thickQ(q)' + @test Base.LinAlg.thickQ(q)'q ≈ eye(n) + @test eye(n)'q' ≈ Base.LinAlg.thickQ(q)' @test q*r ≈ a @test_approx_eq_eps a*(qra\b) b 3000ε - @test full(qra) ≈ a - @test_approx_eq_eps A_mul_Bc(eye(eltyb,size(q.factors,2)),q)*full(q, thin=false) eye(n) 5000ε + @test Array(qra) ≈ a + @test_approx_eq_eps A_mul_Bc(eye(eltyb,size(q.factors,2)),q)*Base.LinAlg.thickQ(q) eye(n) 5000ε if eltya != Int @test eye(eltyb,n)*q ≈ convert(AbstractMatrix{tab},q) ac = copy(a) @@ -66,14 +66,14 @@ debug && println("Thin QR decomposition (without pivoting)") @inferred qr(a[:,1:n1], Val{false}) q,r = qra[:Q], qra[:R] @test_throws KeyError qra[:Z] - @test q'*full(q, thin=false) ≈ eye(n) - @test q'*full(q) ≈ eye(n,n1) + @test q'*Base.LinAlg.thickQ(q) ≈ eye(n) + @test q'*Array(q) ≈ eye(n,n1) @test q*r ≈ a[:,1:n1] - @test_approx_eq_eps q*b[1:n1] full(q)*b[1:n1] 100ε - @test_approx_eq_eps q*b full(q, thin=false)*b 100ε + @test_approx_eq_eps q*b[1:n1] Array(q)*b[1:n1] 100ε + @test_approx_eq_eps q*b Base.LinAlg.thickQ(q)*b 100ε @test_throws DimensionMismatch q*b[1:n1 + 1] @test_throws DimensionMismatch b[1:n1 + 1]*q' - @test_approx_eq_eps A_mul_Bc(UpperTriangular(eye(eltyb,size(q.factors,2))),q)*full(q, thin=false) eye(n1,n) 5000ε + @test_approx_eq_eps A_mul_Bc(UpperTriangular(eye(eltyb,size(q.factors,2))),q)*Base.LinAlg.thickQ(q) eye(n1,n) 5000ε if eltya != Int @test eye(eltyb,n)*q ≈ convert(AbstractMatrix{tab},q) end @@ -86,14 +86,14 @@ debug && println("(Automatic) Fat (pivoted) QR decomposition") q,r = qrpa[:Q], qrpa[:R] @test_throws KeyError qrpa[:Z] p = qrpa[:p] - @test q'*full(q, thin=false) ≈ eye(n1) - @test q*full(q, thin=false)' ≈ eye(n1) - @test (UpperTriangular(eye(eltya,size(q,2)))*q')*full(q, thin=false) ≈ eye(n1) + @test q'*Base.LinAlg.thickQ(q) ≈ eye(n1) + @test q*Base.LinAlg.thickQ(q)' ≈ eye(n1) + @test (UpperTriangular(eye(eltya,size(q,2)))*q')*Base.LinAlg.thickQ(q) ≈ eye(n1) @test q*r ≈ (isa(qrpa,QRPivoted) ? a[1:n1,p] : a[1:n1,:]) @test q*r[:,invperm(p)] ≈ a[1:n1,:] @test q*r*qrpa[:P].' ≈ a[1:n1,:] @test_approx_eq_eps a[1:n1,:]*(qrpa\b[1:n1]) b[1:n1] 5000ε - @test full(qrpa) ≈ a[1:5,:] + @test Array(qrpa) ≈ a[1:5,:] @test_throws DimensionMismatch q*b[1:n1+1] @test_throws DimensionMismatch b[1:n1+1]*q' if eltya != Int @@ -105,14 +105,14 @@ debug && println("(Automatic) Thin (pivoted) QR decomposition") q,r = qrpa[:Q], qrpa[:R] @test_throws KeyError qrpa[:Z] p = qrpa[:p] - @test q'*full(q, thin=false) ≈ eye(n) - @test q*full(q, thin=false)' ≈ eye(n) + @test q'*Base.LinAlg.thickQ(q) ≈ eye(n) + @test q*Base.LinAlg.thickQ(q)' ≈ eye(n) @test q*r ≈ a[:,p] @test q*r[:,invperm(p)] ≈ a[:,1:n1] - @test full(qrpa) ≈ a[:,1:5] + @test Array(qrpa) ≈ a[:,1:5] @test_throws DimensionMismatch q*b[1:n1+1] @test_throws DimensionMismatch b[1:n1+1]*q' - @test_approx_eq_eps A_mul_Bc(UpperTriangular(eye(eltyb,size(q.factors,2))),q)*full(q, thin=false) eye(n1,n) 5000ε + @test_approx_eq_eps A_mul_Bc(UpperTriangular(eye(eltyb,size(q.factors,2))),q)*Base.LinAlg.thickQ(q) eye(n1,n) 5000ε if eltya != Int @test eye(eltyb,n)*q ≈ convert(AbstractMatrix{tab},q) end @@ -123,9 +123,9 @@ debug && println("Matmul with QR factorizations") if eltya != Int qrpa = factorize(a[:,1:n1]) q, r = qrpa[:Q], qrpa[:R] - @test A_mul_B!(full(q, thin=false)',q) ≈ eye(n) + @test A_mul_B!(Base.LinAlg.thickQ(q)',q) ≈ eye(n) @test_throws DimensionMismatch A_mul_B!(eye(eltya,n+1),q) - @test A_mul_Bc!(full(q, thin=false),q) ≈ eye(n) + @test A_mul_Bc!(Base.LinAlg.thickQ(q),q) ≈ eye(n) @test_throws DimensionMismatch A_mul_Bc!(eye(eltya,n+1),q) @test_throws BoundsError size(q,-1) @test_throws DimensionMismatch Base.LinAlg.A_mul_B!(q,zeros(eltya,n1+1)) @@ -133,9 +133,9 @@ debug && println("Matmul with QR factorizations") qra = qrfact(a[:,1:n1], Val{false}) q, r = qra[:Q], qra[:R] - @test A_mul_B!(full(q, thin=false)',q) ≈ eye(n) + @test A_mul_B!(Base.LinAlg.thickQ(q)',q) ≈ eye(n) @test_throws DimensionMismatch A_mul_B!(eye(eltya,n+1),q) - @test A_mul_Bc!(full(q, thin=false),q) ≈ eye(n) + @test A_mul_Bc!(Base.LinAlg.thickQ(q),q) ≈ eye(n) @test_throws DimensionMismatch A_mul_Bc!(eye(eltya,n+1),q) @test_throws BoundsError size(q,-1) @test_throws DimensionMismatch q * eye(Int8,n+4) @@ -154,7 +154,7 @@ end # Issue 7304 let A = [-√.5 -√.5; -√.5 √.5] - Q = full(qrfact(A)[:Q]) + Q = Array(qrfact(A)[:Q]) @test vecnorm(A-Q) < eps() end diff --git a/test/linalg/schur.jl b/test/linalg/schur.jl index dc1071c7bbd5ba..08f2b45ba74cd5 100644 --- a/test/linalg/schur.jl +++ b/test/linalg/schur.jl @@ -35,7 +35,7 @@ aimg = randn(n,n)/2 @test sort(real(f[:values])) ≈ sort(real(d)) @test sort(imag(f[:values])) ≈ sort(imag(d)) @test istriu(f[:Schur]) || eltype(a)<:Real - @test full(f) ≈ a + @test Array(f) ≈ a @test_throws KeyError f[:A] @testset "Reorder Schur" begin diff --git a/test/linalg/special.jl b/test/linalg/special.jl index 4a9d8d4e2576cf..bc9cfd1de4bf52 100644 --- a/test/linalg/special.jl +++ b/test/linalg/special.jl @@ -11,7 +11,7 @@ let a=[1.0:n;] A=Diagonal(a) for newtype in [Diagonal, Bidiagonal, SymTridiagonal, Tridiagonal, Matrix] debug && println("newtype is $(newtype)") - @test full(convert(newtype, A)) == full(A) + @test Array(convert(newtype, A)) == Array(A) end for isupper in (true, false) @@ -19,60 +19,60 @@ let a=[1.0:n;] A=Bidiagonal(a, [1.0:n-1;], isupper) for newtype in [Bidiagonal, Tridiagonal, Matrix] debug && println("newtype is $(newtype)") - @test full(convert(newtype, A)) == full(A) - @test full(newtype(A)) == full(A) + @test Array(convert(newtype, A)) == Array(A) + @test Array(newtype(A)) == Array(A) end @test_throws ArgumentError convert(SymTridiagonal, A) tritype = isupper ? UpperTriangular : LowerTriangular - @test full(tritype(A)) == full(A) + @test Array(tritype(A)) == Array(A) A=Bidiagonal(a, zeros(n-1), isupper) #morally Diagonal for newtype in [Diagonal, Bidiagonal, SymTridiagonal, Tridiagonal, Matrix] debug && println("newtype is $(newtype)") - @test full(convert(newtype, A)) == full(A) - @test full(newtype(A)) == full(A) + @test Array(convert(newtype, A)) == Array(A) + @test Array(newtype(A)) == Array(A) end - @test full(tritype(A)) == full(A) + @test Array(tritype(A)) == Array(A) end A = SymTridiagonal(a, [1.0:n-1;]) for newtype in [Tridiagonal, Matrix] - @test full(convert(newtype, A)) == full(A) + @test Array(convert(newtype, A)) == Array(A) end for newtype in [Diagonal, Bidiagonal] @test_throws ArgumentError convert(newtype,A) end A = SymTridiagonal(a, zeros(n-1)) - @test full(convert(Bidiagonal,A)) == full(A) + @test Array(convert(Bidiagonal,A)) == Array(A) A = Tridiagonal(zeros(n-1), [1.0:n;], zeros(n-1)) #morally Diagonal for newtype in [Diagonal, Bidiagonal, SymTridiagonal, Matrix] - @test full(convert(newtype, A)) == full(A) + @test Array(convert(newtype, A)) == Array(A) end A = Tridiagonal(ones(n-1), [1.0:n;], ones(n-1)) #not morally Diagonal for newtype in [SymTridiagonal, Matrix] - @test full(convert(newtype, A)) == full(A) + @test Array(convert(newtype, A)) == Array(A) end for newtype in [Diagonal, Bidiagonal] @test_throws ArgumentError convert(newtype,A) end A = Tridiagonal(zeros(n-1), [1.0:n;], ones(n-1)) #not morally Diagonal - @test full(convert(Bidiagonal, A)) == full(A) + @test Array(convert(Bidiagonal, A)) == Array(A) A = UpperTriangular(Tridiagonal(zeros(n-1), [1.0:n;], ones(n-1))) - @test full(convert(Bidiagonal, A)) == full(A) + @test Array(convert(Bidiagonal, A)) == Array(A) A = Tridiagonal(ones(n-1), [1.0:n;], zeros(n-1)) #not morally Diagonal - @test full(convert(Bidiagonal, A)) == full(A) + @test Array(convert(Bidiagonal, A)) == Array(A) A = LowerTriangular(Tridiagonal(ones(n-1), [1.0:n;], zeros(n-1))) - @test full(convert(Bidiagonal, A)) == full(A) + @test Array(convert(Bidiagonal, A)) == Array(A) @test_throws ArgumentError convert(SymTridiagonal,A) - A = LowerTriangular(full(Diagonal(a))) #morally Diagonal + A = LowerTriangular(Array(Diagonal(a))) #morally Diagonal for newtype in [Diagonal, Bidiagonal, SymTridiagonal, LowerTriangular, Matrix] - @test full(convert(newtype, A)) == full(A) + @test Array(convert(newtype, A)) == Array(A) end - A = UpperTriangular(full(Diagonal(a))) #morally Diagonal + A = UpperTriangular(Array(Diagonal(a))) #morally Diagonal for newtype in [Diagonal, Bidiagonal, SymTridiagonal, UpperTriangular, Matrix] - @test full(convert(newtype, A)) == full(A) + @test Array(convert(newtype, A)) == Array(A) end A = UpperTriangular(triu(rand(n,n))) for newtype in [Diagonal, Bidiagonal, Tridiagonal, SymTridiagonal] @@ -88,26 +88,26 @@ let a=[1.0:n;] for type2 in Spectypes B = convert(type1,A) C = convert(type2,A) - @test full(B + C) ≈ full(A + A) - @test full(B - C) ≈ full(A - A) + @test Array(B + C) ≈ Array(A + A) + @test Array(B - C) ≈ Array(A - A) end end B = SymTridiagonal(a, ones(n-1)) for Spectype in [Diagonal, Bidiagonal, Tridiagonal, Matrix] - @test full(B + convert(Spectype,A)) ≈ full(B + A) - @test full(convert(Spectype,A) + B) ≈ full(B + A) - @test full(B - convert(Spectype,A)) ≈ full(B - A) - @test full(convert(Spectype,A) - B) ≈ full(A - B) + @test Array(B + convert(Spectype,A)) ≈ Array(B + A) + @test Array(convert(Spectype,A) + B) ≈ Array(B + A) + @test Array(B - convert(Spectype,A)) ≈ Array(B - A) + @test Array(convert(Spectype,A) - B) ≈ Array(A - B) end C = rand(n,n) for TriType in [Base.LinAlg.UnitLowerTriangular, Base.LinAlg.UnitUpperTriangular, UpperTriangular, LowerTriangular] D = TriType(C) for Spectype in [Diagonal, Bidiagonal, Tridiagonal, Matrix] - @test full(D + convert(Spectype,A)) ≈ full(D + A) - @test full(convert(Spectype,A) + D) ≈ full(A + D) - @test full(D - convert(Spectype,A)) ≈ full(D - A) - @test full(convert(Spectype,A) - D) ≈ full(A - D) + @test Array(D + convert(Spectype,A)) ≈ Array(D + A) + @test Array(convert(Spectype,A) + D) ≈ Array(A + D) + @test Array(D - convert(Spectype,A)) ≈ Array(D - A) + @test Array(convert(Spectype,A) - D) ≈ Array(A - D) end end end @@ -118,11 +118,11 @@ for typ in [UpperTriangular,LowerTriangular,Base.LinAlg.UnitUpperTriangular,Base atri = typ(a) b = rand(n,n) qrb = qrfact(b,Val{true}) - @test Base.LinAlg.A_mul_Bc(atri,qrb[:Q]) ≈ full(atri) * qrb[:Q]' - @test Base.LinAlg.A_mul_Bc!(copy(atri),qrb[:Q]) ≈ full(atri) * qrb[:Q]' + @test Base.LinAlg.A_mul_Bc(atri,qrb[:Q]) ≈ Array(atri) * qrb[:Q]' + @test Base.LinAlg.A_mul_Bc!(copy(atri),qrb[:Q]) ≈ Array(atri) * qrb[:Q]' qrb = qrfact(b,Val{false}) - @test Base.LinAlg.A_mul_Bc(atri,qrb[:Q]) ≈ full(atri) * qrb[:Q]' - @test Base.LinAlg.A_mul_Bc!(copy(atri),qrb[:Q]) ≈ full(atri) * qrb[:Q]' + @test Base.LinAlg.A_mul_Bc(atri,qrb[:Q]) ≈ Array(atri) * qrb[:Q]' + @test Base.LinAlg.A_mul_Bc!(copy(atri),qrb[:Q]) ≈ Array(atri) * qrb[:Q]' end # Test that concatenations of combinations of special and other matrix types yield sparse arrays diff --git a/test/linalg/svd.jl b/test/linalg/svd.jl index 4ea9b81d45d01e..d6ee07e221e1f2 100644 --- a/test/linalg/svd.jl +++ b/test/linalg/svd.jl @@ -36,7 +36,7 @@ a2img = randn(n,n)/2 @testset "singular value decomposition" begin @test usv[:S] === svdvals(usv) @test usv[:U] * (Diagonal(usv[:S]) * usv[:Vt]) ≈ a - @test full(usv) ≈ a + @test Array(usv) ≈ a @test usv[:Vt]' ≈ usv[:V] @test_throws KeyError usv[:Z] b = rand(eltya,n) diff --git a/test/linalg/symmetric.jl b/test/linalg/symmetric.jl index 452637898f3619..a25b4492a4e4ca 100644 --- a/test/linalg/symmetric.jl +++ b/test/linalg/symmetric.jl @@ -56,8 +56,8 @@ let n=10 @test isa(similar(Symmetric(asym), Int, (3,2)), Matrix{Int}) @test isa(similar(Hermitian(asym), Int, (3,2)), Matrix{Int}) - # full - @test asym == full(Hermitian(asym)) + # convert(Array, _) AKA Array() + @test asym == Array(Hermitian(asym)) # parent @@ -111,7 +111,7 @@ let n=10 eig(Hermitian(asym), d[1] - 1, (d[2] + d[3])/2) # same result, but checks that method works @test eigvals(Hermitian(asym), 1:2) ≈ d[1:2] @test eigvals(Hermitian(asym), d[1] - 1, (d[2] + d[3])/2) ≈ d[1:2] - @test full(eigfact(asym)) ≈ asym + @test Array(eigfact(asym)) ≈ asym # relation to svdvals @test sum(sort(abs.(eigvals(Hermitian(asym))))) == sum(sort(svdvals(Hermitian(asym)))) @@ -213,7 +213,7 @@ end #Issue #7933 let A7933 = [1 2; 3 4] B7933 = copy(A7933) - C7933 = full(Symmetric(A7933)) + C7933 = Array(Symmetric(A7933)) @test A7933 == B7933 end diff --git a/test/linalg/triangular.jl b/test/linalg/triangular.jl index 3cb032ed9aa350..a21897c643eaf5 100644 --- a/test/linalg/triangular.jl +++ b/test/linalg/triangular.jl @@ -11,7 +11,7 @@ srand(123) debug && println("Test basic type functionality") @test_throws DimensionMismatch LowerTriangular(randn(5, 4)) -@test LowerTriangular(randn(3, 3)) |> t -> [size(t, i) for i = 1:3] == [size(full(t), i) for i = 1:3] +@test LowerTriangular(randn(3, 3)) |> t -> [size(t, i) for i = 1:3] == [size(Array(t), i) for i = 1:3] # The following test block tries to call all methods in base/linalg/triangular.jl in order for a combination of input element types. Keep the ordering when adding code. for elty1 in (Float32, Float64, BigFloat, Complex64, Complex128, Complex{BigFloat}, Int) @@ -29,13 +29,13 @@ for elty1 in (Float32, Float64, BigFloat, Complex64, Complex128, Complex{BigFloa # Convert @test convert(AbstractMatrix{elty1}, A1) == A1 - @test convert(Matrix, A1) == full(A1) + @test convert(Matrix, A1) == Array(A1) # full! - @test full!(copy(A1)) == full(A1) + @test full!(copy(A1)) == Array(A1) # fill! - @test full!(fill!(copy(A1), 1)) == full(t1(ones(size(A1)...))) + @test full!(fill!(copy(A1), 1)) == Array(t1(ones(size(A1)...))) # similar @test isa(similar(A1), t1) @@ -48,14 +48,14 @@ for elty1 in (Float32, Float64, BigFloat, Complex64, Complex128, Complex{BigFloa # getindex ## Linear indexing for i = 1:length(A1) - @test A1[i] == full(A1)[i] + @test A1[i] == Array(A1)[i] end @test isa(A1[2:4,1], Vector) ## Cartesian indexing for i = 1:size(A1, 1) for j = 1:size(A1, 2) - @test A1[i,j] == full(A1)[i,j] + @test A1[i,j] == Array(A1)[i,j] end end @@ -101,8 +101,8 @@ for elty1 in (Float32, Float64, BigFloat, Complex64, Complex128, Complex{BigFloa #tril/triu if uplo1 == :L @test tril(A1,0) == A1 - @test tril(A1,-1) == LowerTriangular(tril(full(A1),-1)) - @test tril(A1,1) == t1(tril(tril(full(A1),1))) + @test tril(A1,-1) == LowerTriangular(tril(Array(A1),-1)) + @test tril(A1,1) == t1(tril(tril(Array(A1),1))) @test_throws ArgumentError tril!(A1,n+1) @test triu(A1,0) == t1(diagm(diag(A1))) @test triu(A1,-1) == t1(tril(triu(A1.data,-1))) @@ -110,8 +110,8 @@ for elty1 in (Float32, Float64, BigFloat, Complex64, Complex128, Complex{BigFloa @test_throws ArgumentError triu!(A1,n+1) else @test triu(A1,0) == A1 - @test triu(A1,1) == UpperTriangular(triu(full(A1),1)) - @test triu(A1,-1) == t1(triu(triu(full(A1),-1))) + @test triu(A1,1) == UpperTriangular(triu(Array(A1),1)) + @test triu(A1,-1) == t1(triu(triu(Array(A1),-1))) @test_throws ArgumentError triu!(A1,n+1) @test tril(A1,0) == t1(diagm(diag(A1))) @test tril(A1,1) == t1(triu(tril(A1.data,1))) @@ -125,11 +125,11 @@ for elty1 in (Float32, Float64, BigFloat, Complex64, Complex128, Complex{BigFloa # [c]transpose[!] (test views as well, see issue #14317) let vrange = 1:n-1, viewA1 = t1(view(A1.data, vrange, vrange)) # transpose - @test full(A1.') == full(A1).' - @test full(viewA1.') == full(viewA1).' + @test Array(A1.') == Array(A1).' + @test Array(viewA1.') == Array(viewA1).' # ctranspose - @test full(A1') == full(A1)' - @test full(viewA1') == full(viewA1)' + @test Array(A1') == Array(A1)' + @test Array(viewA1') == Array(viewA1)' # transpose! @test transpose!(copy(A1)) == A1.' @test transpose!(t1(view(copy(A1).data, vrange, vrange))) == viewA1.' @@ -139,21 +139,21 @@ for elty1 in (Float32, Float64, BigFloat, Complex64, Complex128, Complex{BigFloa end # diag - @test diag(A1) == diag(full(A1)) + @test diag(A1) == diag(Array(A1)) # real - @test full(real(A1)) == real(full(A1)) - @test full(imag(A1)) == imag(full(A1)) - @test full(abs.(A1)) == abs.(full(A1)) + @test Array(real(A1)) == real(Array(A1)) + @test Array(imag(A1)) == imag(Array(A1)) + @test Array(abs.(A1)) == abs.(Array(A1)) # Unary operations - @test full(-A1) == -full(A1) + @test Array(-A1) == -Array(A1) # copy and copy! (test views as well, see issue #14317) let vrange = 1:n-1, viewA1 = t1(view(A1.data, vrange, vrange)) # copy - @test copy(A1) == copy(full(A1)) - @test copy(viewA1) == copy(full(viewA1)) + @test copy(A1) == copy(Array(A1)) + @test copy(viewA1) == copy(Array(viewA1)) # copy! B = similar(A1) copy!(B, A1) @@ -171,7 +171,7 @@ for elty1 in (Float32, Float64, BigFloat, Complex64, Complex128, Complex{BigFloa #expm/logm if (elty1 == Float64 || elty1 == Complex128) && (t1 == UpperTriangular || t1 == LowerTriangular) - @test expm(full(logm(A1))) ≈ full(A1) + @test expm(Array(logm(A1))) ≈ Array(A1) end # scale @@ -209,23 +209,23 @@ for elty1 in (Float32, Float64, BigFloat, Complex64, Complex128, Complex{BigFloa end # Binary operations - @test A1*0.5 == full(A1)*0.5 - @test 0.5*A1 == 0.5*full(A1) - @test A1/0.5 == full(A1)/0.5 - @test 0.5\A1 == 0.5\full(A1) + @test A1*0.5 == Array(A1)*0.5 + @test 0.5*A1 == 0.5*Array(A1) + @test A1/0.5 == Array(A1)/0.5 + @test 0.5\A1 == 0.5\Array(A1) # inversion - @test inv(A1) ≈ inv(lufact(full(A1))) - inv(full(A1)) # issue #11298 + @test inv(A1) ≈ inv(lufact(Array(A1))) + inv(Array(A1)) # issue #11298 @test isa(inv(A1), t1) # make sure the call to LAPACK works right if elty1 <: BlasFloat - @test Base.LinAlg.inv!(copy(A1)) ≈ inv(lufact(full(A1))) + @test Base.LinAlg.inv!(copy(A1)) ≈ inv(lufact(Array(A1))) end # Determinant - @test_approx_eq_eps det(A1) det(lufact(full(A1))) sqrt(eps(real(float(one(elty1)))))*n*n - @test_approx_eq_eps logdet(A1) logdet(lufact(full(A1))) sqrt(eps(real(float(one(elty1)))))*n*n + @test_approx_eq_eps det(A1) det(lufact(Array(A1))) sqrt(eps(real(float(one(elty1)))))*n*n + @test_approx_eq_eps logdet(A1) logdet(lufact(Array(A1))) sqrt(eps(real(float(one(elty1)))))*n*n # Matrix square root @test sqrtm(A1) |> t -> t*t ≈ A1 @@ -237,7 +237,7 @@ for elty1 in (Float32, Float64, BigFloat, Complex64, Complex128, Complex{BigFloa if !(elty1 in (BigFloat, Complex{BigFloat})) # Not handled yet vals, vecs = eig(A1) if (t1 == UpperTriangular || t1 == LowerTriangular) && elty1 != Int # Cannot really handle degenerate eigen space and Int matrices will probably have repeated eigenvalues. - @test_approx_eq_eps vecs*diagm(vals)/vecs full(A1) sqrt(eps(float(real(one(vals[1])))))*(norm(A1, Inf)*n)^2 + @test_approx_eq_eps vecs*diagm(vals)/vecs Array(A1) sqrt(eps(float(real(one(vals[1])))))*(norm(A1, Inf)*n)^2 end end @@ -246,7 +246,7 @@ for elty1 in (Float32, Float64, BigFloat, Complex64, Complex128, Complex{BigFloa for p in (1.0, Inf) @test_approx_eq_eps cond(A1, p) cond(A1, p) (cond(A1, p) + cond(A1, p)) end - @test cond(A1,2) == cond(full(A1),2) + @test cond(A1,2) == cond(Array(A1),2) end if !(elty1 in (BigFloat, Complex{BigFloat})) # Not implemented yet @@ -275,19 +275,19 @@ for elty1 in (Float32, Float64, BigFloat, Complex64, Complex128, Complex{BigFloa end # Binary operations - @test full(A1 + A2) == full(A1) + full(A2) - @test full(A1 - A2) == full(A1) - full(A2) + @test Array(A1 + A2) == Array(A1) + Array(A2) + @test Array(A1 - A2) == Array(A1) - Array(A2) # Triangular-Triangualar multiplication and division - @test full(A1*A2) ≈ full(A1)*full(A2) - @test full(A1.'A2) ≈ full(A1).'full(A2) - @test full(A1'A2) ≈ full(A1)'full(A2) - @test full(A1*A2.') ≈ full(A1)*full(A2).' - @test full(A1*A2') ≈ full(A1)*full(A2)' - @test full(A1.'A2.') ≈ full(A1).'full(A2).' - @test full(A1'A2') ≈ full(A1)'full(A2)' - @test full(A1/A2) ≈ full(A1)/full(A2) - @test full(A1\A2) ≈ full(A1)\full(A2) + @test Array(A1*A2) ≈ Array(A1)*Array(A2) + @test Array(A1.'A2) ≈ Array(A1).'Array(A2) + @test Array(A1'A2) ≈ Array(A1)'Array(A2) + @test Array(A1*A2.') ≈ Array(A1)*Array(A2).' + @test Array(A1*A2') ≈ Array(A1)*Array(A2)' + @test Array(A1.'A2.') ≈ Array(A1).'Array(A2).' + @test Array(A1'A2') ≈ Array(A1)'Array(A2)' + @test Array(A1/A2) ≈ Array(A1)/Array(A2) + @test Array(A1\A2) ≈ Array(A1)\Array(A2) @test_throws DimensionMismatch eye(n+1)/A2 @test_throws DimensionMismatch eye(n+1)/A2.' @test_throws DimensionMismatch eye(n+1)/A2' @@ -308,29 +308,29 @@ for elty1 in (Float32, Float64, BigFloat, Complex64, Complex128, Complex{BigFloa if !(eltyB in (BigFloat, Complex{BigFloat})) # rand does not support BigFloat and Complex{BigFloat} as of Dec 2015 Tri = Tridiagonal(rand(eltyB,n-1),rand(eltyB,n),rand(eltyB,n-1)) - @test Base.LinAlg.A_mul_B!(Tri,copy(A1)) ≈ Tri*full(A1) + @test Base.LinAlg.A_mul_B!(Tri,copy(A1)) ≈ Tri*Array(A1) end # Triangular-dense Matrix/vector multiplication - @test A1*B[:,1] ≈ full(A1)*B[:,1] - @test A1*B ≈ full(A1)*B - @test A1.'B[:,1] ≈ full(A1).'B[:,1] - @test A1'B[:,1] ≈ full(A1)'B[:,1] - @test A1.'B ≈ full(A1).'B - @test A1'B ≈ full(A1)'B - @test A1*B.' ≈ full(A1)*B.' - @test A1*B' ≈ full(A1)*B' - @test B*A1 ≈ B*full(A1) - @test B[:,1].'A1 ≈ B[:,1].'full(A1) - @test B[:,1]'A1 ≈ B[:,1]'full(A1) - @test B.'A1 ≈ B.'full(A1) - @test B'A1 ≈ B'full(A1) - @test B*A1.' ≈ B*full(A1).' - @test B*A1' ≈ B*full(A1)' - @test B[:,1].'A1.' ≈ B[:,1].'full(A1).' - @test B[:,1]'A1' ≈ B[:,1]'full(A1)' - @test B.'A1.' ≈ B.'full(A1).' - @test B'A1' ≈ B'full(A1)' + @test A1*B[:,1] ≈ Array(A1)*B[:,1] + @test A1*B ≈ Array(A1)*B + @test A1.'B[:,1] ≈ Array(A1).'B[:,1] + @test A1'B[:,1] ≈ Array(A1)'B[:,1] + @test A1.'B ≈ Array(A1).'B + @test A1'B ≈ Array(A1)'B + @test A1*B.' ≈ Array(A1)*B.' + @test A1*B' ≈ Array(A1)*B' + @test B*A1 ≈ B*Array(A1) + @test B[:,1].'A1 ≈ B[:,1].'Array(A1) + @test B[:,1]'A1 ≈ B[:,1]'Array(A1) + @test B.'A1 ≈ B.'Array(A1) + @test B'A1 ≈ B'Array(A1) + @test B*A1.' ≈ B*Array(A1).' + @test B*A1' ≈ B*Array(A1)' + @test B[:,1].'A1.' ≈ B[:,1].'Array(A1).' + @test B[:,1]'A1' ≈ B[:,1]'Array(A1)' + @test B.'A1.' ≈ B.'Array(A1).' + @test B'A1' ≈ B'Array(A1)' if eltyB == elty1 @test A_mul_B!(zeros(B),A1,B) ≈ A1*B @@ -346,29 +346,29 @@ for elty1 in (Float32, Float64, BigFloat, Complex64, Complex128, Complex{BigFloa @test_throws DimensionMismatch Base.LinAlg.A_mul_Bt!(ones(eltyB,n+1,n+1),A1) # ... and division - @test A1\B[:,1] ≈ full(A1)\B[:,1] - @test A1\B ≈ full(A1)\B - @test A1.'\B[:,1] ≈ full(A1).'\B[:,1] - @test A1'\B[:,1] ≈ full(A1)'\B[:,1] - @test A1.'\B ≈ full(A1).'\B - @test A1'\B ≈ full(A1)'\B - @test A1\B.' ≈ full(A1)\B.' - @test A1\B' ≈ full(A1)\B' - @test A1.'\B.' ≈ full(A1).'\B.' - @test A1'\B' ≈ full(A1)'\B' + @test A1\B[:,1] ≈ Array(A1)\B[:,1] + @test A1\B ≈ Array(A1)\B + @test A1.'\B[:,1] ≈ Array(A1).'\B[:,1] + @test A1'\B[:,1] ≈ Array(A1)'\B[:,1] + @test A1.'\B ≈ Array(A1).'\B + @test A1'\B ≈ Array(A1)'\B + @test A1\B.' ≈ Array(A1)\B.' + @test A1\B' ≈ Array(A1)\B' + @test A1.'\B.' ≈ Array(A1).'\B.' + @test A1'\B' ≈ Array(A1)'\B' @test_throws DimensionMismatch A1\ones(elty1,n+2) @test_throws DimensionMismatch A1'\ones(elty1,n+2) @test_throws DimensionMismatch A1.'\ones(elty1,n+2) if t1 == UpperTriangular || t1 == LowerTriangular @test_throws Base.LinAlg.SingularException naivesub!(t1(zeros(elty1,n,n)),ones(eltyB,n)) end - @test B/A1 ≈ B/full(A1) - @test B/A1.' ≈ B/full(A1).' - @test B/A1' ≈ B/full(A1)' - @test B.'/A1 ≈ B.'/full(A1) - @test B'/A1 ≈ B'/full(A1) - @test B.'/A1.' ≈ B.'/full(A1).' - @test B'/A1' ≈ B'/full(A1)' + @test B/A1 ≈ B/Array(A1) + @test B/A1.' ≈ B/Array(A1).' + @test B/A1' ≈ B/Array(A1)' + @test B.'/A1 ≈ B.'/Array(A1) + @test B'/A1 ≈ B'/Array(A1) + @test B.'/A1.' ≈ B.'/Array(A1).' + @test B'/A1' ≈ B'/Array(A1)' # Error bounds !(elty1 in (BigFloat, Complex{BigFloat})) && !(eltyB in (BigFloat, Complex{BigFloat})) && errorbounds(A1, A1\B, B) @@ -403,8 +403,8 @@ for eltya in (Float32, Float64, Complex64, Complex128, BigFloat, Int) debug && println("Solve upper triangular system") Atri = UpperTriangular(lufact(A)[:U]) |> t -> eltya <: Complex && eltyb <: Real ? real(t) : t # Here the triangular matrix can't be too badly conditioned - b = convert(Matrix{eltyb}, eltya <: Complex ? full(Atri)*ones(n, 2) : full(Atri)*ones(n, 2)) - x = full(Atri) \ b + b = convert(Matrix{eltyb}, eltya <: Complex ? Array(Atri)*ones(n, 2) : Array(Atri)*ones(n, 2)) + x = Array(Atri) \ b debug && println("Test error estimates") if eltya != BigFloat && eltyb != BigFloat @@ -431,8 +431,8 @@ for eltya in (Float32, Float64, Complex64, Complex128, BigFloat, Int) debug && println("Solve lower triangular system") Atri = UpperTriangular(lufact(A)[:U]) |> t -> eltya <: Complex && eltyb <: Real ? real(t) : t # Here the triangular matrix can't be too badly conditioned - b = convert(Matrix{eltyb}, eltya <: Complex ? full(Atri)*ones(n, 2) : full(Atri)*ones(n, 2)) - x = full(Atri)\b + b = convert(Matrix{eltyb}, eltya <: Complex ? Array(Atri)*ones(n, 2) : Array(Atri)*ones(n, 2)) + x = Array(Atri)\b debug && println("Test error estimates") if eltya != BigFloat && eltyb != BigFloat diff --git a/test/linalg/tridiag.jl b/test/linalg/tridiag.jl index 87ee2521668c18..eadce53d4945a5 100644 --- a/test/linalg/tridiag.jl +++ b/test/linalg/tridiag.jl @@ -42,7 +42,7 @@ for elty in (Float32, Float64, Complex64, Complex128, Int) F[i,i+1] = du[i] F[i+1,i] = dl[i] end - @test full(T) == F + @test Array(T) == F # elementary operations on tridiagonals @test conj(T) == Tridiagonal(conj(dl), conj(d), conj(du)) @@ -62,7 +62,7 @@ for elty in (Float32, Float64, Complex64, Complex128, Int) @test Tridiagonal(dl, d, du) + Tridiagonal(du, d, dl) == SymTridiagonal(2d, dl+du) @test SymTridiagonal(d, dl) + Tridiagonal(dl, d, du) == Tridiagonal(dl + dl, d+d, dl+du) @test convert(SymTridiagonal,Tridiagonal(Ts)) == Ts - @test full(convert(SymTridiagonal{Complex64},Tridiagonal(Ts))) == convert(Matrix{Complex64},full(Ts)) + @test Array(convert(SymTridiagonal{Complex64},Tridiagonal(Ts))) == convert(Matrix{Complex64},Array(Ts)) if elty == Int vv = rand(1:100, n) BB = rand(1:100, n, 2) @@ -101,7 +101,7 @@ for elty in (Float32, Float64, Complex64, Complex128, Int) # symmetric tridiagonal if elty <: Real Ts = SymTridiagonal(d, dl) - Fs = full(Ts) + Fs = Array(Ts) Tldlt = factorize(Ts) @test_throws DimensionMismatch Tldlt\rand(elty,n+1) @test size(Tldlt) == size(Ts) @@ -119,7 +119,7 @@ for elty in (Float32, Float64, Complex64, Complex128, Int) invFsv = Fs\vv x = Ts\vv @test x ≈ invFsv - @test full(full(Tldlt)) ≈ Fs + @test Array(Array(Tldlt)) ≈ Fs end # similar @@ -237,7 +237,7 @@ let n = 12 #Size of matrix problem to test @test_throws ArgumentError SymTridiagonal(rand(n,n)) A = SymTridiagonal(a, b) - fA = map(elty <: Complex ? Complex128 : Float64, full(A)) + fA = map(elty <: Complex ? Complex128 : Float64, Array(A)) debug && println("getindex") @test_throws BoundsError A[n+1,1] @@ -289,10 +289,10 @@ let n = 12 #Size of matrix problem to test @test B - A == A - B debug && println("Multiplication with strided vector") - @test A*ones(n) ≈ full(A)*ones(n) + @test A*ones(n) ≈ Array(A)*ones(n) debug && println("Multiplication with strided matrix") - @test A*ones(n, 2) ≈ full(A)*ones(n, 2) + @test A*ones(n, 2) ≈ Array(A)*ones(n, 2) debug && println("Eigensystems") if elty <: Real @@ -312,13 +312,13 @@ let n = 12 #Size of matrix problem to test debug && println("stegr! call with index range") F = eigfact(SymTridiagonal(a, b),1:2) - fF = eigfact(Symmetric(full(SymTridiagonal(a, b))),1:2) + fF = eigfact(Symmetric(Array(SymTridiagonal(a, b))),1:2) Test.test_approx_eq_modphase(F[:vectors], fF[:vectors]) @test F[:values] ≈ fF[:values] debug && println("stegr! call with value range") F = eigfact(SymTridiagonal(a, b),0.0,1.0) - fF = eigfact(Symmetric(full(SymTridiagonal(a, b))),0.0,1.0) + fF = eigfact(Symmetric(Array(SymTridiagonal(a, b))),0.0,1.0) Test.test_approx_eq_modphase(F[:vectors], fF[:vectors]) @test F[:values] ≈ fF[:values] end @@ -332,15 +332,15 @@ let n = 12 #Size of matrix problem to test end B = SymTridiagonal(a, b) - fB = map(elty <: Complex ? Complex128 : Float64, full(B)) + fB = map(elty <: Complex ? Complex128 : Float64, Array(B)) for op in (+, -, *) - @test full(op(A, B)) ≈ op(fA, fB) + @test Array(op(A, B)) ≈ op(fA, fB) end α = rand(elty) - @test full(α*A) ≈ α*full(A) - @test full(A*α) ≈ full(A)*α - @test full(A/α) ≈ full(A)/α + @test Array(α*A) ≈ α*Array(A) + @test Array(A*α) ≈ Array(A)*α + @test Array(A/α) ≈ Array(A)/α debug && println("A_mul_B!") @test_throws DimensionMismatch A_mul_B!(zeros(elty,n,n),B,ones(elty,n+1,n)) @@ -363,7 +363,7 @@ let n = 12 #Size of matrix problem to test @test_throws ArgumentError Tridiagonal(a,a,a) A = Tridiagonal(a, b, c) - fA = map(elty <: Complex ? Complex128 : Float64, full(A)) + fA = map(elty <: Complex ? Complex128 : Float64, Array(A)) debug && println("Similar, size, and copy!") B = similar(A) @@ -411,22 +411,21 @@ let n = 12 #Size of matrix problem to test end debug && println("Multiplication with strided vector") - @test A*ones(n) ≈ full(A)*ones(n) + @test A*ones(n) ≈ Array(A)*ones(n) debug && println("Multiplication with strided matrix") - @test A*ones(n, 2) ≈ full(A)*ones(n, 2) - + @test A*ones(n, 2) ≈ Array(A)*ones(n, 2) B = Tridiagonal(a, b, c) - fB = map(elty <: Complex ? Complex128 : Float64, full(B)) + fB = map(elty <: Complex ? Complex128 : Float64, Array(B)) for op in (+, -, *) - @test full(op(A, B)) ≈ op(fA, fB) + @test Array(op(A, B)) ≈ op(fA, fB) end α = rand(elty) - @test full(α*A) ≈ α*full(A) - @test full(A*α) ≈ full(A)*α - @test full(A/α) ≈ full(A)/α + @test Array(α*A) ≈ α*Array(A) + @test Array(A*α) ≈ Array(A)*α + @test Array(A/α) ≈ Array(A)/α @test_throws ArgumentError convert(SymTridiagonal{elty},A) diff --git a/test/linalg/uniformscaling.jl b/test/linalg/uniformscaling.jl index 60595c0c1260d7..7a0d3e40fdf561 100644 --- a/test/linalg/uniformscaling.jl +++ b/test/linalg/uniformscaling.jl @@ -96,10 +96,10 @@ B = bitrand(2,2) else T = LowerTriangular(view(randn(3,3), 1:3, 1:3)) end - @test @inferred(T + J) == full(T) + J - @test @inferred(J + T) == J + full(T) - @test @inferred(T - J) == full(T) - J - @test @inferred(J - T) == J - full(T) + @test @inferred(T + J) == Array(T) + J + @test @inferred(J + T) == J + Array(T) + @test @inferred(T - J) == Array(T) - J + @test @inferred(J - T) == J - Array(T) @test @inferred(T\I) == inv(T) if atype == "Array" @@ -107,10 +107,10 @@ B = bitrand(2,2) else T = LinAlg.UnitLowerTriangular(view(randn(3,3), 1:3, 1:3)) end - @test @inferred(T + J) == full(T) + J - @test @inferred(J + T) == J + full(T) - @test @inferred(T - J) == full(T) - J - @test @inferred(J - T) == J - full(T) + @test @inferred(T + J) == Array(T) + J + @test @inferred(J + T) == J + Array(T) + @test @inferred(T - J) == Array(T) - J + @test @inferred(J - T) == J - Array(T) @test @inferred(T\I) == inv(T) if atype == "Array" @@ -118,10 +118,10 @@ B = bitrand(2,2) else T = UpperTriangular(view(randn(3,3), 1:3, 1:3)) end - @test @inferred(T + J) == full(T) + J - @test @inferred(J + T) == J + full(T) - @test @inferred(T - J) == full(T) - J - @test @inferred(J - T) == J - full(T) + @test @inferred(T + J) == Array(T) + J + @test @inferred(J + T) == J + Array(T) + @test @inferred(T - J) == Array(T) - J + @test @inferred(J - T) == J - Array(T) @test @inferred(T\I) == inv(T) if atype == "Array" @@ -129,10 +129,10 @@ B = bitrand(2,2) else T = LinAlg.UnitUpperTriangular(view(randn(3,3), 1:3, 1:3)) end - @test @inferred(T + J) == full(T) + J - @test @inferred(J + T) == J + full(T) - @test @inferred(T - J) == full(T) - J - @test @inferred(J - T) == J - full(T) + @test @inferred(T + J) == Array(T) + J + @test @inferred(J + T) == J + Array(T) + @test @inferred(T - J) == Array(T) - J + @test @inferred(J - T) == J - Array(T) @test @inferred(T\I) == inv(T) @test @inferred(I\A) == A