Skip to content

Commit 8f30511

Browse files
committed
some test clean
1 parent 49b9433 commit 8f30511

File tree

1 file changed

+18
-41
lines changed

1 file changed

+18
-41
lines changed

stdlib/LinearAlgebra/test/blas.jl

Lines changed: 18 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,8 @@ Random.seed!(100)
2727
@testset for elty in [Float32, Float64, ComplexF32, ComplexF64]
2828

2929
@testset "syr2k!" begin
30-
U = randn(5,2)
31-
V = randn(5,2)
32-
if elty == ComplexF32 || elty == ComplexF64
33-
U = complex.(U, U)
34-
V = complex.(V, V)
35-
end
36-
U = convert(Array{elty, 2}, U)
37-
V = convert(Array{elty, 2}, V)
30+
U = randn(elty, 5, 2)
31+
V = randn(elty, 5, 2)
3832
@test tril(LinearAlgebra.BLAS.syr2k('L','N',U,V)) tril(U*transpose(V) + V*transpose(U))
3933
@test triu(LinearAlgebra.BLAS.syr2k('U','N',U,V)) triu(U*transpose(V) + V*transpose(U))
4034
@test tril(LinearAlgebra.BLAS.syr2k('L','T',U,V)) tril(transpose(U)*V + transpose(V)*U)
@@ -43,12 +37,8 @@ Random.seed!(100)
4337

4438
if elty in (ComplexF32, ComplexF64)
4539
@testset "her2k!" begin
46-
U = randn(5,2)
47-
V = randn(5,2)
48-
U = complex.(U, U)
49-
V = complex.(V, V)
50-
U = convert(Array{elty, 2}, U)
51-
V = convert(Array{elty, 2}, V)
40+
U = randn(elty, 5, 2)
41+
V = randn(elty, 5, 2)
5242
@test tril(LinearAlgebra.BLAS.her2k('L','N',U,V)) tril(U*V' + V*U')
5343
@test triu(LinearAlgebra.BLAS.her2k('U','N',U,V)) triu(U*V' + V*U')
5444
@test tril(LinearAlgebra.BLAS.her2k('L','C',U,V)) tril(U'*V + V'*U)
@@ -65,21 +55,21 @@ Random.seed!(100)
6555
U4 = triu(fill(elty(1), 4,4))
6656
Z4 = zeros(elty, (4,4))
6757

68-
elm1 = convert(elty, -1)
69-
el2 = convert(elty, 2)
70-
v14 = convert(Vector{elty}, [1:4;])
71-
v41 = convert(Vector{elty}, [4:-1:1;])
58+
elm1 = elty(-1)
59+
el2 = elty(2)
60+
v14 = elty[1:4;]
61+
v41 = elty[4:-1:1;]
7262

7363
let n = 10
7464
@testset "dot products" begin
7565
if elty <: Real
76-
x1 = convert(Vector{elty}, randn(n))
77-
x2 = convert(Vector{elty}, randn(n))
66+
x1 = randn(elty, n)
67+
x2 = randn(elty, n)
7868
@test BLAS.dot(x1,x2) sum(x1.*x2)
7969
@test_throws DimensionMismatch BLAS.dot(x1,rand(elty, n + 1))
8070
else
81-
z1 = convert(Vector{elty}, complex.(randn(n),randn(n)))
82-
z2 = convert(Vector{elty}, complex.(randn(n),randn(n)))
71+
z1 = randn(elty, n)
72+
z2 = randn(elty, n)
8373
@test BLAS.dotc(z1,z2) sum(conj(z1).*z2)
8474
@test BLAS.dotu(z1,z2) sum(z1.*z2)
8575
@test_throws DimensionMismatch BLAS.dotc(z1,rand(elty, n + 1))
@@ -91,29 +81,16 @@ Random.seed!(100)
9181
@test BLAS.iamax(x) == findmax(fabs, x)[2]
9282
end
9383
@testset "rot!" begin
94-
if elty <: Real
95-
x = convert(Vector{elty}, randn(n))
96-
y = convert(Vector{elty}, randn(n))
97-
c = rand(elty)
98-
s = rand(elty)
84+
x = randn(elty, n)
85+
y = randn(elty, n)
86+
c = rand(real(elty))
87+
for sty in unique!([real(elty), elty])
88+
s = rand(sty)
9989
x2 = copy(x)
10090
y2 = copy(y)
10191
BLAS.rot!(n, x, 1, y, 1, c, s)
10292
@test x c*x2 + s*y2
103-
@test y -s*x2 + c*y2
104-
else
105-
x = convert(Vector{elty}, complex.(randn(n),rand(n)))
106-
y = convert(Vector{elty}, complex.(randn(n),rand(n)))
107-
cty = (elty == ComplexF32) ? Float32 : Float64
108-
c = rand(cty)
109-
for sty in [cty, elty]
110-
s = rand(sty)
111-
x2 = copy(x)
112-
y2 = copy(y)
113-
BLAS.rot!(n, x, 1, y, 1, c, s)
114-
@test x c*x2 + s*y2
115-
@test y -conj(s)*x2 + c*y2
116-
end
93+
@test y -conj(s)*x2 + c*y2
11794
end
11895
end
11996
@testset "axp(b)y" begin

0 commit comments

Comments
 (0)