Skip to content

Commit

Permalink
Replace Array{...}(shape...) calls with Array{...}(uninitialized, sha…
Browse files Browse the repository at this point in the history
…pe...) in test/linalg.
  • Loading branch information
Sacha0 committed Nov 22, 2017
1 parent 80d8719 commit ef9f0f2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion test/linalg/generic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ end
@test scale!(similar(a), [1.; 2.], a) == a.*[1; 2]
@test scale!(similar(a), [1; 2], a) == a.*[1; 2]
@test_throws DimensionMismatch scale!(similar(a), ones(3), a)
@test_throws DimensionMismatch scale!(Array{Float64}(3, 2), a, ones(3))
@test_throws DimensionMismatch scale!(Matrix{Float64}(uninitialized, 3, 2), a, ones(3))

if isa(a, Array)
@test scale!(similar(a), a, [1.; 2.; 3.]) == a.*[1 2 3]
Expand Down
20 changes: 10 additions & 10 deletions test/linalg/matmul.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ using Test
@test ones(0,0)*ones(0,4) == zeros(0,4)
@test ones(3,0)*ones(0,0) == zeros(3,0)
@test ones(0,0)*ones(0,0) == zeros(0,0)
@test Array{Float64}(5, 0) |> t -> t't == zeros(0,0)
@test Array{Float64}(5, 0) |> t -> t*t' == zeros(5,5)
@test Array{Complex128}(5, 0) |> t -> t't == zeros(0,0)
@test Array{Complex128}(5, 0) |> t -> t*t' == zeros(5,5)
@test Matrix{Float64}(uninitialized, 5, 0) |> t -> t't == zeros(0,0)
@test Matrix{Float64}(uninitialized, 5, 0) |> t -> t*t' == zeros(5,5)
@test Matrix{Complex128}(uninitialized, 5, 0) |> t -> t't == zeros(0,0)
@test Matrix{Complex128}(uninitialized, 5, 0) |> t -> t*t' == zeros(5,5)
end
@testset "2x2 matmul" begin
AA = [1 2; 3 4]
Expand Down Expand Up @@ -89,7 +89,7 @@ end
end
AA = rand(1:20, 5, 5) .- 10
BB = rand(1:20, 5, 5) .- 10
CC = Array{Int}(size(AA, 1), size(BB, 2))
CC = Matrix{Int}(uninitialized, size(AA, 1), size(BB, 2))
for A in (copy(AA), view(AA, 1:5, 1:5)), B in (copy(BB), view(BB, 1:5, 1:5)), C in (copy(CC), view(CC, 1:5, 1:5))
@test At_mul_B(A, B) == A'*B
@test A_mul_Bt(A, B) == A*B'
Expand All @@ -105,7 +105,7 @@ end
@test_throws DimensionMismatch Base.LinAlg.Ac_mul_Bt!(C,ones(Int,4,4),B)
end
vv = [1,2]
CC = Array{Int}(2, 2)
CC = Matrix{Int}(uninitialized, 2, 2)
for v in (copy(vv), view(vv, 1:2)), C in (copy(CC), view(CC, 1:2, 1:2))
@test @inferred(A_mul_Bc!(C, v, v)) == [1 2; 2 4]
end
Expand All @@ -119,12 +119,12 @@ end
@test_throws DimensionMismatch Base.LinAlg.generic_matvecmul!(B,'N',A,zeros(6))
end
vv = [1,2,3]
CC = Array{Int}(3, 3)
CC = Matrix{Int}(uninitialized, 3, 3)
for v in (copy(vv), view(vv, 1:3)), C in (copy(CC), view(CC, 1:3, 1:3))
@test A_mul_Bt!(C, v, v) == v*v'
end
vvf = map(Float64,vv)
CC = Array{Float64}(3, 3)
CC = Matrix{Float64}(uninitialized, 3, 3)
for vf in (copy(vvf), view(vvf, 1:3)), C in (copy(CC), view(CC, 1:3, 1:3))
@test A_mul_Bt!(C, vf, vf) == vf*vf'
end
Expand Down Expand Up @@ -247,12 +247,12 @@ vecdot_(x,y) = invoke(vecdot, Tuple{Any,Any}, x,y)
end

@testset "Issue 11978" begin
A = Array{Matrix{Float64}}(2, 2)
A = Matrix{Matrix{Float64}}(uninitialized, 2, 2)
A[1,1] = Matrix(1.0I, 3, 3)
A[2,2] = Matrix(1.0I, 2, 2)
A[1,2] = Matrix(1.0I, 3, 2)
A[2,1] = Matrix(1.0I, 2, 3)
b = Array{Vector{Float64}}(2)
b = Vector{Vector{Float64}}(uninitialized, 2)
b[1] = ones(3)
b[2] = ones(2)
@test A*b == Vector{Float64}[[2,2,1], [2,2]]
Expand Down
8 changes: 4 additions & 4 deletions test/linalg/pinv.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ using Test
srand(12345)

function hilb(T::Type, n::Integer)
a=Array{T}(n,n)
a = Matrix{T}(uninitialized, n, n)
for i=1:n
for j=1:n
a[j,i]=one(T)/(i+j-one(T))
Expand All @@ -20,7 +20,7 @@ end
hilb(n::Integer) = hilb(Float64,n)

function hilb(T::Type, m::Integer, n::Integer)
a=Array{T}(m,n)
a = Matrix{T}(uninitialized, m, n)
for i=1:n
for j=1:m
a[j,i]=one(T)/(i+j-one(T))
Expand Down Expand Up @@ -67,7 +67,7 @@ tridiag(m::Integer, n::Integer) = tridiag(Float64, m::Integer, n::Integer)

function randn_float64(m::Integer, n::Integer)
a=randn(m,n)
b=Array{Float64}(m,n)
b = Matrix{Float64}(uninitialized, m, n)
for i=1:n
for j=1:m
b[j,i]=convert(Float64,a[j,i])
Expand All @@ -78,7 +78,7 @@ end

function randn_float32(m::Integer, n::Integer)
a=randn(m,n)
b=Array{Float32}(m,n)
b = Matrix{Float32}(uninitialized, m, n)
for i=1:n
for j=1:m
b[j,i]=convert(Float32,a[j,i])
Expand Down

0 comments on commit ef9f0f2

Please sign in to comment.