Skip to content

Commit

Permalink
Rewrite isolated ' calls in test/ to preserve behavior through ' lowe…
Browse files Browse the repository at this point in the history
…ring changes.
  • Loading branch information
Sacha0 committed Dec 18, 2017
1 parent 9ec817f commit 90cf0ba
Show file tree
Hide file tree
Showing 24 changed files with 73 additions and 73 deletions.
6 changes: 3 additions & 3 deletions test/arrayops.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ using Main.TestHelpers.OAs
a[1,2] = 2
a[2,1] = 3
a[2,2] = 4
b = a'
b = adjoint(a)
@test a[1,1] == 1. && a[1,2] == 2. && a[2,1] == 3. && a[2,2] == 4.
@test b[1,1] == 1. && b[2,1] == 2. && b[1,2] == 3. && b[2,2] == 4.
a[[1 2 3 4]] = 0
Expand Down Expand Up @@ -624,7 +624,7 @@ end
@testset "large matrices transpose" begin
for i = 1 : 3
a = rand(200, 300)
@test isequal(a', permutedims(a, [2, 1]))
@test isequal(adjoint(a), permutedims(a, [2, 1]))
end
end

Expand Down Expand Up @@ -2050,7 +2050,7 @@ end # module AutoRetType
@test isa([[1,2,3]'; [1,2,3]'], Matrix{Int})
@test isa([[1,2,3]' [1,2,3]'], Transpose{Int, Vector{Int}})
@test isa([Any[1.0, 2]'; Any[2.0, 2]'], Matrix{Any})
@test isa([Any[1.0, 2]' Any[2.0, 2']'], Adjoint{Any, Vector{Any}})
@test isa([Any[1.0, 2]' Any[2.0, 2]'], Adjoint{Any, Vector{Any}})
# Test that concatenations of heterogeneous Matrix-Vector pairs yield dense matrices
@test isa(hcat(densemat, densevec), Array)
@test isa(hcat(densevec, densemat), Array)
Expand Down
4 changes: 2 additions & 2 deletions test/examples.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ include(joinpath(dir, "ndgrid.jl"))
r = repmat(1:10,1,10)
r1, r2 = ndgrid(1:10, 1:10)
@test r1 == r
@test r2 == r'
@test r2 == adjoint(r)
r3, r4 = meshgrid(1:10,1:10)
@test r3 == r'
@test r3 == adjoint(r)
@test r4 == r

include(joinpath(dir, "queens.jl"))
Expand Down
4 changes: 2 additions & 2 deletions test/linalg/blas.jl
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ srand(100)

if elty <: Complex
A = rand(elty,n,n)
A = A + A'
A = A + adjoint(A)
α = real(α)
@test triu(BLAS.her!('U',α,x,copy(A))) triu(A + α*x*x')
@test_throws DimensionMismatch BLAS.her!('U',α,ones(elty,n+1),copy(A))
Expand Down Expand Up @@ -278,7 +278,7 @@ srand(100)
@test_throws DimensionMismatch BLAS.gemm!('N','N', one(elty), I43, I4, elm1, I4)
@test_throws DimensionMismatch BLAS.gemm!('T','N', one(elty), I43, I4, elm1, I43)
@test_throws DimensionMismatch BLAS.gemm!('N','T', one(elty), I43, I43, elm1, I43)
@test_throws DimensionMismatch BLAS.gemm!('T','T', one(elty), I43, I43, elm1, I43')
@test_throws DimensionMismatch BLAS.gemm!('T','T', one(elty), I43, I43, elm1, adjoint(I43))
end
@testset "gemm compared to (sy)(he)rk" begin
if eltype(elm1) <: Complex
Expand Down
2 changes: 1 addition & 1 deletion test/linalg/cholesky.jl
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ end
for uplo in (:U, :L)
AcA = A'A
BcB = AcA + v*v'
BcB = (BcB + BcB')/2
BcB = (BcB + adjoint(BcB))/2
F = cholfact(Hermitian(AcA, uplo))
G = cholfact(Hermitian(BcB, uplo))
@test LinAlg.lowrankupdate(F, v)[uplo] G[uplo]
Expand Down
2 changes: 1 addition & 1 deletion test/linalg/conjarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
@test cm[1,1] == 1-im
@test cm[1] == 1-im
@test trace(cm*m) == 27
@test cm' == m
@test adjoint(cm) == m

cm[:,2] = [3; 3-im] #setindex! with a vector
@test conj(cm) == [1+im 3; 2 3+im]
Expand Down
14 changes: 7 additions & 7 deletions test/linalg/dense.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ bimg = randn(n,2)/2
end

@testset "Test nullspace" begin
a15null = nullspace(a[:,1:n1]')
a15null = nullspace(adjoint(a[:,1:n1]))
@test rank([a[:,1:n1] a15null]) == 10
@test norm(a[:,1:n1]'a15null,Inf) zero(eltya) atol=300ε
@test norm(a15null'a[:,1:n1],Inf) zero(eltya) atol=400ε
Expand Down Expand Up @@ -95,7 +95,7 @@ bimg = randn(n,2)/2
@testset "Matrix square root" begin
asq = sqrt(a)
@test asq*asq a
asym = a'+a # symmetric indefinite
asym = adjoint(a)+a # symmetric indefinite
asymsq = sqrt(asym)
@test asymsq*asymsq asym
end
Expand Down Expand Up @@ -349,9 +349,9 @@ end
@testset "Matrix exponential" begin
@testset "Tests for $elty" for elty in (Float32, Float64, ComplexF32, ComplexF64)
A1 = convert(Matrix{elty}, [4 2 0; 1 4 1; 1 1 4])
eA1 = convert(Matrix{elty}, [147.866622446369 127.781085523181 127.781085523182;
eA1 = convert(Matrix{elty}, adjoint([147.866622446369 127.781085523181 127.781085523182;
183.765138646367 183.765138646366 163.679601723179;
71.797032399996 91.8825693231832 111.968106246371]')
71.797032399996 91.8825693231832 111.968106246371]))
@test exp(A1) eA1

A2 = convert(Matrix{elty},
Expand All @@ -365,9 +365,9 @@ end
@test exp(A2) eA2

A3 = convert(Matrix{elty}, [-131 19 18;-390 56 54;-387 57 52])
eA3 = convert(Matrix{elty}, [-1.50964415879218 -5.6325707998812 -4.934938326092;
eA3 = convert(Matrix{elty}, adjoint([-1.50964415879218 -5.6325707998812 -4.934938326092;
0.367879439109187 1.47151775849686 1.10363831732856;
0.135335281175235 0.406005843524598 0.541341126763207]')
0.135335281175235 0.406005843524598 0.541341126763207]))
@test exp(A3) eA3

A4 = convert(Matrix{elty}, [0.25 0.25; 0 0])
Expand Down Expand Up @@ -790,7 +790,7 @@ end
@testset "/ and \\ consistency with pinv for vectors" begin
@testset "Tests for type $elty" for elty in (Float32, Float64, ComplexF32, ComplexF64)
c = rand(elty, 5)
r = rand(elty, 5)'
r = (elty <: Complex ? Adjoint : Transpose)(rand(elty, 5))
cm = rand(elty, 5, 1)
rm = rand(elty, 1, 5)
@testset "inner prodcuts" begin
Expand Down
2 changes: 1 addition & 1 deletion test/linalg/diagonal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ srand(1)
r = VV * Transpose(Array(D))
@test Array(mul!(VV, Transpose(DD))) r
DD = copy(D)
r = VV * (Array(D)')
r = VV * Array(D)'
@test Array(mul!(VV, Adjoint(DD))) r
end
@testset "triu/tril" begin
Expand Down
6 changes: 3 additions & 3 deletions test/linalg/eigen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ aimg = randn(n,n)/2

@testset for eltya in (Float32, Float64, ComplexF32, ComplexF64, Int)
aa = eltya == Int ? rand(1:7, n, n) : convert(Matrix{eltya}, eltya <: Complex ? complex.(areal, aimg) : areal)
asym = aa'+aa # symmetric indefinite
asym = adjoint(aa)+aa # symmetric indefinite
apd = aa'*aa # symmetric positive-definite
for (a, asym, apd) in ((aa, asym, apd),
(view(aa, 1:n, 1:n),
Expand Down Expand Up @@ -49,8 +49,8 @@ aimg = randn(n,n)/2
h = asym
@test minimum(eigvals(h)) eigmin(h)
@test maximum(eigvals(h)) eigmax(h)
@test_throws DomainError eigmin(a - a')
@test_throws DomainError eigmax(a - a')
@test_throws DomainError eigmin(a - adjoint(a))
@test_throws DomainError eigmax(a - adjoint(a))
end
@testset "symmetric generalized eigenproblem" begin
if isa(a, Array)
Expand Down
8 changes: 4 additions & 4 deletions test/linalg/lapack.jl
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ end
lU,lS,lVt = LAPACK.gesvd!('S','S',A)
@test U lU
@test S lS
@test V' lVt
@test adjoint(V) lVt
B = rand(elty,10,10)
# xggsvd3 replaced xggsvd in LAPACK 3.6.0
if LAPACK.version() < v"3.6.0"
Expand Down Expand Up @@ -391,7 +391,7 @@ end
@testset "hetrf, hetrs" begin
@testset for elty in (ComplexF32, ComplexF64)
A = rand(elty,10,10)
A = A + A' #hermitian!
A = A + adjoint(A) #hermitian!
B = copy(A)
B,ipiv = LAPACK.hetrf!('U',B)
@test_throws DimensionMismatch LAPACK.hetrs!('U',B,ipiv,rand(elty,11,5))
Expand Down Expand Up @@ -449,14 +449,14 @@ end
@testset for elty in (ComplexF32, ComplexF64)
srand(935)
A = rand(elty,10,10)
A = A + A' #hermitian!
A = A + adjoint(A) #hermitian!
b = rand(elty,10)
c = A \ b
b,A = LAPACK.hesv!('U',A,b)
@test b c
@test_throws DimensionMismatch LAPACK.hesv!('U',A,rand(elty,11))
A = rand(elty,10,10)
A = A + A' #hermitian!
A = A + adjoint(A) #hermitian!
b = rand(elty,10)
c = A \ b
b,A = LAPACK.hesv_rook!('U',A,b)
Expand Down
4 changes: 2 additions & 2 deletions test/linalg/lq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ rectangularQ(Q::LinAlg.LQPackedQ) = convert(Array, Q)
@testset for eltya in (Float32, Float64, ComplexF32, ComplexF64)
a = eltya == Int ? rand(1:7, n, n) : convert(Matrix{eltya}, eltya <: Complex ? complex.(areal, aimg) : areal)
a2 = eltya == Int ? rand(1:7, n, n) : convert(Matrix{eltya}, eltya <: Complex ? complex.(a2real, a2img) : a2real)
asym = a'+a # symmetric indefinite
asym = adjoint(a)+a # symmetric indefinite
apd = a'*a # symmetric positive-definite
ε = εa = eps(abs(float(one(eltya))))

Expand All @@ -54,7 +54,7 @@ rectangularQ(Q::LinAlg.LQPackedQ) = convert(Array, Q)
@test size(lqa[:Q],3) == 1
@test Base.LinAlg.getq(lqa) == lqa[:Q]
@test_throws KeyError lqa[:Z]
@test Array(lqa') a'
@test Array(adjoint(lqa)) adjoint(a)
@test lqa * lqa' a * a'
@test lqa' * lqa a' * a
@test q*squareQ(q)' Matrix(I, n, n)
Expand Down
2 changes: 1 addition & 1 deletion test/linalg/lu.jl
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ dimg = randn(n)/2
for (bb, cc) in ((Bs, Cs), (view(Bs, 1:n, 1), view(Cs, 1:n)))
@test norm(a*(lua\bb) - bb, 1) < ε*κ*n*2 # Two because the right hand side has two columns
@test norm(a'*(lua'\bb) - bb, 1) < ε*κ*n*2 # Two because the right hand side has two columns
@test norm(a'*(lua'\a') - a', 1) < ε*κ*n^2
@test norm(a'*(lua'\a') - adjoint(a), 1) < ε*κ*n^2
@test norm(a*(lua\cc) - cc, 1) < ε*κ*n # cc is a vector
@test norm(a'*(lua'\cc) - cc, 1) < ε*κ*n # cc is a vector
@test AbstractArray(lua) a
Expand Down
2 changes: 1 addition & 1 deletion test/linalg/matmul.jl
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ end
res = Float64[135228751 9979252 -115270247; 9979252 10481254 10983256; -115270247 10983256 137236759]
for A in (copy(AA), view(AA, 1:501, 1:3))
@test *(Transpose(A), A) == res
@test *(A', Transpose(A')) == res
@test *(Adjoint(A), Transpose(adjoint(A))) == res
end
cutoff = 501
A = reshape(1:6*cutoff,2*cutoff,3).-(6*cutoff)/2
Expand Down
10 changes: 5 additions & 5 deletions test/linalg/qr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ rectangularQ(Q::LinAlg.AbstractQ) = convert(Array, Q)
@testset for eltya in (Float32, Float64, ComplexF32, ComplexF64, BigFloat, Int)
raw_a = eltya == Int ? rand(1:7, n, n) : convert(Matrix{eltya}, eltya <: Complex ? complex.(areal, aimg) : areal)
raw_a2 = eltya == Int ? rand(1:7, n, n) : convert(Matrix{eltya}, eltya <: Complex ? complex.(a2real, a2img) : a2real)
asym = raw_a' + raw_a # symmetric indefinite
asym = adjoint(raw_a) + raw_a # symmetric indefinite
apd = raw_a' * raw_a # symmetric positive-definite
ε = εa = eps(abs(float(one(eltya))))

Expand All @@ -53,9 +53,9 @@ rectangularQ(Q::LinAlg.AbstractQ) = convert(Array, Q)
@test_throws KeyError qra[:Z]
@test q'*squareQ(q) Matrix(I, a_1, a_1)
@test q*squareQ(q)' Matrix(I, a_1, a_1)
@test q'*Matrix(1.0I, a_1, a_1)' squareQ(q)'
@test q'*Matrix(1.0I, a_1, a_1)' adjoint(squareQ(q))
@test squareQ(q)'q Matrix(I, a_1, a_1)
@test Matrix(1.0I, a_1, a_1)'q' squareQ(q)'
@test Matrix(1.0I, a_1, a_1)'q' adjoint(squareQ(q))
@test q*r a
@test a*(qra\b) b atol=3000ε
@test Array(qra) a
Expand Down Expand Up @@ -135,7 +135,7 @@ rectangularQ(Q::LinAlg.AbstractQ) = convert(Array, Q)
a = raw_a
qrpa = factorize(a[:,1:n1])
q, r = qrpa[:Q], qrpa[:R]
@test mul!(squareQ(q)', q) Matrix(I, n, n)
@test mul!(adjoint(squareQ(q)), q) Matrix(I, n, n)
@test_throws DimensionMismatch mul!(Matrix{eltya}(I, n+1, n+1),q)
@test mul!(squareQ(q), Adjoint(q)) Matrix(I, n, n)
@test_throws DimensionMismatch mul!(Matrix{eltya}(I, n+1, n+1), Adjoint(q))
Expand All @@ -145,7 +145,7 @@ rectangularQ(Q::LinAlg.AbstractQ) = convert(Array, Q)

qra = qrfact(a[:,1:n1], Val(false))
q, r = qra[:Q], qra[:R]
@test mul!(squareQ(q)', q) Matrix(I, n, n)
@test mul!(adjoint(squareQ(q)), q) Matrix(I, n, n)
@test_throws DimensionMismatch mul!(Matrix{eltya}(I, n+1, n+1),q)
@test mul!(squareQ(q), Adjoint(q)) Matrix(I, n, n)
@test_throws DimensionMismatch mul!(Matrix{eltya}(I, n+1, n+1),Adjoint(q))
Expand Down
2 changes: 1 addition & 1 deletion test/linalg/schur.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ aimg = randn(n,n)/2

@testset for eltya in (Float32, Float64, ComplexF32, ComplexF64, Int)
a = eltya == Int ? rand(1:7, n, n) : convert(Matrix{eltya}, eltya <: Complex ? complex.(areal, aimg) : areal)
asym = a'+a # symmetric indefinite
asym = adjoint(a)+a # symmetric indefinite
apd = a'*a # symmetric positive-definite
for (a, asym, apd) in ((a, asym, apd),
(view(a, 1:n, 1:n),
Expand Down
6 changes: 3 additions & 3 deletions test/linalg/svd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ a2img = randn(n,n)/2
@testset for eltya in (Float32, Float64, ComplexF32, ComplexF64, Int)
aa = eltya == Int ? rand(1:7, n, n) : convert(Matrix{eltya}, eltya <: Complex ? complex.(areal, aimg) : areal)
aa2 = eltya == Int ? rand(1:7, n, n) : convert(Matrix{eltya}, eltya <: Complex ? complex.(a2real, a2img) : a2real)
asym = aa'+aa # symmetric indefinite
asym = adjoint(aa)+aa # symmetric indefinite
apd = aa'*aa # symmetric positive-definite
for (a, a2) in ((aa, aa2), (view(aa, 1:n, 1:n), view(aa2, 1:n, 1:n)))
ε = εa = eps(abs(float(one(eltya))))
Expand All @@ -56,7 +56,7 @@ a2img = randn(n,n)/2
@test usv[:S] === svdvals(usv)
@test usv[:U] * (Diagonal(usv[:S]) * usv[:Vt]) a
@test convert(Array, usv) a
@test usv[:Vt]' usv[:V]
@test adjoint(usv[:Vt]) usv[:V]
@test_throws KeyError usv[:Z]
b = rand(eltya,n)
@test usv\b a\b
Expand All @@ -73,7 +73,7 @@ a2img = randn(n,n)/2
gsvd = svdfact(a,a_svd)
@test gsvd[:U]*gsvd[:D1]*gsvd[:R]*gsvd[:Q]' a
@test gsvd[:V]*gsvd[:D2]*gsvd[:R]*gsvd[:Q]' a_svd
@test usv[:Vt]' usv[:V]
@test adjoint(usv[:Vt]) usv[:V]
@test_throws KeyError usv[:Z]
@test_throws KeyError gsvd[:Z]
@test gsvd[:vals] svdvals(a,a_svd)
Expand Down
12 changes: 6 additions & 6 deletions test/linalg/symmetric.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ end

@testset "Hermitian matrix exponential/log" begin
A1 = randn(4,4) + im*randn(4,4)
A2 = A1 + A1'
A2 = A1 + adjoint(A1)
@test exp(A2) exp(Hermitian(A2))
@test log(A2) log(Hermitian(A2))
A3 = A1 * A1' # posdef
A3 = A1 * adjoint(A1) # posdef
@test exp(A3) exp(Hermitian(A3))
@test log(A3) log(Hermitian(A3))

A1 = randn(4,4)
A3 = A1 * A1'
A3 = A1 * adjoint(A1)
A4 = A1 + transpose(A1)
@test exp(A4) exp(Symmetric(A4))
@test log(A3) log(Symmetric(A3))
Expand Down Expand Up @@ -121,7 +121,7 @@ end
elseif eltya <: Complex
# test that zero imaginary component is
# handled properly
@test ishermitian(Symmetric(b + b'))
@test ishermitian(Symmetric(b + adjoint(b)))
end
end

Expand Down Expand Up @@ -255,7 +255,7 @@ end
let A = a[:,1:5]*a[:,1:5]'
# Make sure A is Hermitian even in the presence of rounding error
# xianyi/OpenBLAS#729
A = (A' + A) / 2
A = (adjoint(A) + A) / 2
@test rank(A) == rank(Hermitian(A))
end
end
Expand Down Expand Up @@ -383,7 +383,7 @@ end
@test conj(c) == conj(Array(c))
cc = copy(c)
@test conj!(c) == conj(Array(cc))
c = Hermitian(b + b')
c = Hermitian(b + adjoint(b))
@test conj(c) == conj(Array(c))
cc = copy(c)
@test conj!(c) == conj(Array(cc))
Expand Down
8 changes: 4 additions & 4 deletions test/linalg/triangular.jl
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,14 @@ for elty1 in (Float32, Float64, BigFloat, ComplexF32, ComplexF64, Complex{BigFlo
@test transpose(A1) == transpose(Matrix(A1))
@test transpose(viewA1) == transpose(Matrix(viewA1))
# adjoint
@test A1' == Matrix(A1)'
@test viewA1' == Matrix(viewA1)'
@test adjoint(A1) == adjoint(Matrix(A1))
@test adjoint(viewA1) == adjoint(Matrix(viewA1))
# transpose!
@test transpose!(copy(A1)) == transpose(A1)
@test transpose!(t1(view(copy(A1).data, vrange, vrange))) == transpose(viewA1)
# adjoint!
@test adjoint!(copy(A1)) == A1'
@test adjoint!(t1(view(copy(A1).data, vrange, vrange))) == viewA1'
@test adjoint!(copy(A1)) == adjoint(A1)
@test adjoint!(t1(view(copy(A1).data, vrange, vrange))) == adjoint(viewA1)
end

# diag
Expand Down
4 changes: 2 additions & 2 deletions test/mod2pi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ testModPi()

# ieee754_rem_pio2_return contains the returned value from the ieee754_rem_pio2
# function in openlibm: https://github.com/JuliaLang/openlibm/blob/0598080ca09468490a13ae393ba17d8620c1b201/src/e_rem_pio2.c
ieee754_rem_pio2_return = [1.5707963267948966 1.5707963267948966;
ieee754_rem_pio2_return = adjoint([1.5707963267948966 1.5707963267948966;
1.0471975511965979 -1.0471975511965979;
0.10000000000000014 -0.10000000000000014;
6.123233995736766e-17 -6.123233995736766e-17;
Expand All @@ -238,7 +238,7 @@ testModPi()
-0.6853981633974484 0.6853981633974484;
3.135095805817224e-14 -3.135095805817224e-14;
3.287386219680602e-8 -3.287386219680602e-8;
-0.1757159771004682 0.1757159771004682]'
-0.1757159771004682 0.1757159771004682])

for (i, case) in enumerate(cases)
# negative argument
Expand Down
4 changes: 2 additions & 2 deletions test/offsetarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,8 @@ cv = copy(v)

A = OffsetArray(rand(4,4), (-3,5))
@test A A
@test axes(A') === (6:9, -2:1)
@test parent(A') == parent(A)'
@test axes(adjoint(A)) === (6:9, -2:1)
@test parent(adjoint(A)) == adjoint(parent(A))
@test collect(A) == parent(A)
@test maximum(A) == maximum(parent(A))
@test minimum(A) == minimum(parent(A))
Expand Down
Loading

0 comments on commit 90cf0ba

Please sign in to comment.