diff --git a/test/arrayops.jl b/test/arrayops.jl index 6db4148f13694..6a90094e6894f 100644 --- a/test/arrayops.jl +++ b/test/arrayops.jl @@ -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 @@ -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 @@ -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) diff --git a/test/examples.jl b/test/examples.jl index 378e9038deda2..a3002e3240171 100644 --- a/test/examples.jl +++ b/test/examples.jl @@ -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")) diff --git a/test/linalg/blas.jl b/test/linalg/blas.jl index 51ef32e0d7a0b..1c877e6464bcc 100644 --- a/test/linalg/blas.jl +++ b/test/linalg/blas.jl @@ -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)) @@ -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 diff --git a/test/linalg/cholesky.jl b/test/linalg/cholesky.jl index 09d56e19f8037..2333d0defc64a 100644 --- a/test/linalg/cholesky.jl +++ b/test/linalg/cholesky.jl @@ -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] diff --git a/test/linalg/conjarray.jl b/test/linalg/conjarray.jl index 29839ff81bb5b..99663f9a12684 100644 --- a/test/linalg/conjarray.jl +++ b/test/linalg/conjarray.jl @@ -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] diff --git a/test/linalg/dense.jl b/test/linalg/dense.jl index e7c7d6d31e01d..a37b2f85489dc 100644 --- a/test/linalg/dense.jl +++ b/test/linalg/dense.jl @@ -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ε @@ -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 @@ -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}, @@ -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]) @@ -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 diff --git a/test/linalg/diagonal.jl b/test/linalg/diagonal.jl index f6053dae67206..2029ba69e201d 100644 --- a/test/linalg/diagonal.jl +++ b/test/linalg/diagonal.jl @@ -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 diff --git a/test/linalg/eigen.jl b/test/linalg/eigen.jl index a5c224f9f1489..eddca4d4f43a7 100644 --- a/test/linalg/eigen.jl +++ b/test/linalg/eigen.jl @@ -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), @@ -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) diff --git a/test/linalg/lapack.jl b/test/linalg/lapack.jl index 9c9117dc4c3b6..255e5a2ac97fa 100644 --- a/test/linalg/lapack.jl +++ b/test/linalg/lapack.jl @@ -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" @@ -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)) @@ -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) diff --git a/test/linalg/lq.jl b/test/linalg/lq.jl index adf7bb36323a3..15ab15101748b 100644 --- a/test/linalg/lq.jl +++ b/test/linalg/lq.jl @@ -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)))) @@ -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) diff --git a/test/linalg/lu.jl b/test/linalg/lu.jl index 83368fc8c1dea..706aad0745654 100644 --- a/test/linalg/lu.jl +++ b/test/linalg/lu.jl @@ -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 diff --git a/test/linalg/matmul.jl b/test/linalg/matmul.jl index 0a4c87ff2a985..9afe483dabc14 100644 --- a/test/linalg/matmul.jl +++ b/test/linalg/matmul.jl @@ -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 diff --git a/test/linalg/qr.jl b/test/linalg/qr.jl index 65fba4cf3dcad..1ad6a0d566fde 100644 --- a/test/linalg/qr.jl +++ b/test/linalg/qr.jl @@ -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)))) @@ -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 @@ -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)) @@ -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)) diff --git a/test/linalg/schur.jl b/test/linalg/schur.jl index 2115124d4d087..2dc9e81ac6a48 100644 --- a/test/linalg/schur.jl +++ b/test/linalg/schur.jl @@ -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), diff --git a/test/linalg/svd.jl b/test/linalg/svd.jl index 28e1b8d4159a3..1e1b9d904d692 100644 --- a/test/linalg/svd.jl +++ b/test/linalg/svd.jl @@ -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)))) @@ -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 @@ -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) diff --git a/test/linalg/symmetric.jl b/test/linalg/symmetric.jl index ec2959a7af7ca..6664a0750926d 100644 --- a/test/linalg/symmetric.jl +++ b/test/linalg/symmetric.jl @@ -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)) @@ -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 @@ -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 @@ -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)) diff --git a/test/linalg/triangular.jl b/test/linalg/triangular.jl index 4b1c5ec8bdfab..adbf0c7e8bf74 100644 --- a/test/linalg/triangular.jl +++ b/test/linalg/triangular.jl @@ -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 diff --git a/test/mod2pi.jl b/test/mod2pi.jl index e064eb02545a7..f0fe43b9ed776 100644 --- a/test/mod2pi.jl +++ b/test/mod2pi.jl @@ -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; @@ -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 diff --git a/test/offsetarray.jl b/test/offsetarray.jl index e669562ae87ea..9b5168c62a6af 100644 --- a/test/offsetarray.jl +++ b/test/offsetarray.jl @@ -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)) diff --git a/test/perf/lapack/eig.jl b/test/perf/lapack/eig.jl index 48036c481e19c..47d980bff88ea 100644 --- a/test/perf/lapack/eig.jl +++ b/test/perf/lapack/eig.jl @@ -14,7 +14,7 @@ end # Symmetric function symeigtest(n, iter) A = rand(n,n) - A = A + A' + A = A + adjoint(A) d = Vector{eltype(A)} v = similar(A) for i = 1:iter @@ -26,7 +26,7 @@ end # Hermitian function hermitianeigtest(n, iter) A = rand(n,n) + im*rand(n,n) - A = A + A' + A = A + adjoint(A) d = Vector{eltype(A)} v = similar(A) for i = 1:iter diff --git a/test/show.jl b/test/show.jl index 152c3549e0fe0..228e7e0c5bf05 100644 --- a/test/show.jl +++ b/test/show.jl @@ -608,7 +608,7 @@ let A = reshape(1:16, 4, 4) @test replstr(Diagonal(A)) == "4×4 Diagonal{$(Int),Array{$(Int),1}}:\n 1 ⋅ ⋅ ⋅\n ⋅ 6 ⋅ ⋅\n ⋅ ⋅ 11 ⋅\n ⋅ ⋅ ⋅ 16" @test replstr(Bidiagonal(A, :U)) == "4×4 Bidiagonal{$(Int),Array{$(Int),1}}:\n 1 5 ⋅ ⋅\n ⋅ 6 10 ⋅\n ⋅ ⋅ 11 15\n ⋅ ⋅ ⋅ 16" @test replstr(Bidiagonal(A, :L)) == "4×4 Bidiagonal{$(Int),Array{$(Int),1}}:\n 1 ⋅ ⋅ ⋅\n 2 6 ⋅ ⋅\n ⋅ 7 11 ⋅\n ⋅ ⋅ 12 16" - @test replstr(SymTridiagonal(A + A')) == "4×4 SymTridiagonal{$(Int),Array{$(Int),1}}:\n 2 7 ⋅ ⋅\n 7 12 17 ⋅\n ⋅ 17 22 27\n ⋅ ⋅ 27 32" + @test replstr(SymTridiagonal(A + adjoint(A))) == "4×4 SymTridiagonal{$(Int),Array{$(Int),1}}:\n 2 7 ⋅ ⋅\n 7 12 17 ⋅\n ⋅ 17 22 27\n ⋅ ⋅ 27 32" @test replstr(Tridiagonal(diag(A, -1), diag(A), diag(A, +1))) == "4×4 Tridiagonal{$(Int),Array{$(Int),1}}:\n 1 5 ⋅ ⋅\n 2 6 10 ⋅\n ⋅ 7 11 15\n ⋅ ⋅ 12 16" @test replstr(UpperTriangular(copy(A))) == "4×4 UpperTriangular{$Int,Array{$Int,2}}:\n 1 5 9 13\n ⋅ 6 10 14\n ⋅ ⋅ 11 15\n ⋅ ⋅ ⋅ 16" @test replstr(LowerTriangular(copy(A))) == "4×4 LowerTriangular{$Int,Array{$Int,2}}:\n 1 ⋅ ⋅ ⋅\n 2 6 ⋅ ⋅\n 3 7 11 ⋅\n 4 8 12 16" diff --git a/test/sparse/higherorderfns.jl b/test/sparse/higherorderfns.jl index d25b5eabd0ba6..719e9fa83ffdb 100644 --- a/test/sparse/higherorderfns.jl +++ b/test/sparse/higherorderfns.jl @@ -415,8 +415,8 @@ end @test broadcast(*, s, V, A, X)::SparseMatrixCSC == sparse(broadcast(*, s, fV, fA, X)) @test broadcast!(*, Z, s, V, A, X) == sparse(broadcast(*, s, fV, fA, X)) # Issue #20954 combinations of sparse arrays and Adjoint/Transpose vectors - @test broadcast(+, A, X')::SparseMatrixCSC == sparse(broadcast(+, fA, X')) - @test broadcast(*, V, X')::SparseMatrixCSC == sparse(broadcast(*, fV, X')) + @test broadcast(+, A, adjoint(X))::SparseMatrixCSC == sparse(broadcast(+, fA, adjoint(X))) + @test broadcast(*, V, adjoint(X))::SparseMatrixCSC == sparse(broadcast(*, fV, adjoint(X))) end @test V .+ ntuple(identity, N) isa Vector @test A .+ ntuple(identity, N) isa Matrix diff --git a/test/sparse/sparse.jl b/test/sparse/sparse.jl index cbcb5b2288981..4dc81a7619e53 100644 --- a/test/sparse/sparse.jl +++ b/test/sparse/sparse.jl @@ -201,7 +201,7 @@ end @test (maximum(abs.(a'b - Array(a)'b)) < 100*eps()) @test (maximum(abs.(Transpose(a)*b - Transpose(Array(a))*b)) < 100*eps()) @test (maximum(abs.(a\b - Array(a)\b)) < 1000*eps()) - @test (maximum(abs.(a'\b - Array(a')\b)) < 1000*eps()) + @test (maximum(abs.(a'\b - Array(adjoint(a))\b)) < 1000*eps()) @test (maximum(abs.(Transpose(a)\b - Array(transpose(a))\b)) < 1000*eps()) @test (maximum(abs.((a'*c + d) - (Array(a)'*c + d))) < 1000*eps()) @test (maximum(abs.((α*Transpose(a)*c + β*d) - (α*Transpose(Array(a))*c + β*d))) < 1000*eps()) @@ -216,7 +216,7 @@ end @test (maximum(abs.(a'b - Array(a)'b)) < 100*eps()) @test (maximum(abs.(Transpose(a)*b - Transpose(Array(a))*b)) < 100*eps()) @test (maximum(abs.(a\b - Array(a)\b)) < 1000*eps()) - @test (maximum(abs.(a'\b - Array(a')\b)) < 1000*eps()) + @test (maximum(abs.(a'\b - Array(adjoint(a))\b)) < 1000*eps()) @test (maximum(abs.(Transpose(a)\b - Array(transpose(a))\b)) < 1000*eps()) a = I + tril(0.1*sprandn(5, 5, 0.2)) @@ -225,7 +225,7 @@ end @test (maximum(abs.(a'b - Array(a)'b)) < 100*eps()) @test (maximum(abs.(Transpose(a)*b - Transpose(Array(a))*b)) < 100*eps()) @test (maximum(abs.(a\b - Array(a)\b)) < 1000*eps()) - @test (maximum(abs.(a'\b - Array(a')\b)) < 1000*eps()) + @test (maximum(abs.(a'\b - Array(adjoint(a))\b)) < 1000*eps()) @test (maximum(abs.(Transpose(a)\b - Array(transpose(a))\b)) < 1000*eps()) a = I + tril(0.1*sprandn(5, 5, 0.2) + 0.1*im*sprandn(5, 5, 0.2)) @@ -234,7 +234,7 @@ end @test (maximum(abs.(a'b - Array(a)'b)) < 100*eps()) @test (maximum(abs.(Transpose(a)*b - Transpose(Array(a))*b)) < 100*eps()) @test (maximum(abs.(a\b - Array(a)\b)) < 1000*eps()) - @test (maximum(abs.(a'\b - Array(a')\b)) < 1000*eps()) + @test (maximum(abs.(a'\b - Array(adjoint(a))\b)) < 1000*eps()) @test (maximum(abs.(Transpose(a)\b - Array(transpose(a))\b)) < 1000*eps()) a = I + triu(0.1*sprandn(5, 5, 0.2)) @@ -243,7 +243,7 @@ end @test (maximum(abs.(a'b - Array(a)'b)) < 100*eps()) @test (maximum(abs.(Transpose(a)*b - Transpose(Array(a))*b)) < 100*eps()) @test (maximum(abs.(a\b - Array(a)\b)) < 1000*eps()) - @test (maximum(abs.(a'\b - Array(a')\b)) < 1000*eps()) + @test (maximum(abs.(a'\b - Array(adjoint(a))\b)) < 1000*eps()) @test (maximum(abs.(Transpose(a)\b - Array(transpose(a))\b)) < 1000*eps()) a = I + triu(0.1*sprandn(5, 5, 0.2) + 0.1*im*sprandn(5, 5, 0.2)) @@ -252,7 +252,7 @@ end @test (maximum(abs.(a'b - Array(a)'b)) < 100*eps()) @test (maximum(abs.(Transpose(a)*b - Transpose(Array(a))*b)) < 100*eps()) @test (maximum(abs.(a\b - Array(a)\b)) < 1000*eps()) - @test (maximum(abs.(a'\b - Array(a')\b)) < 1000*eps()) + @test (maximum(abs.(a'\b - Array(adjoint(a))\b)) < 1000*eps()) @test (maximum(abs.(Transpose(a)\b - Array(transpose(a))\b)) < 1000*eps()) a = I + triu(0.1*sprandn(5, 5, 0.2)) @@ -261,7 +261,7 @@ end @test (maximum(abs.(a'b - Array(a)'b)) < 100*eps()) @test (maximum(abs.(Transpose(a)*b - Transpose(Array(a))*b)) < 100*eps()) @test (maximum(abs.(a\b - Array(a)\b)) < 1000*eps()) - @test (maximum(abs.(a'\b - Array(a')\b)) < 1000*eps()) + @test (maximum(abs.(a'\b - Array(adjoint(a))\b)) < 1000*eps()) @test (maximum(abs.(Transpose(a)\b - Array(transpose(a))\b)) < 1000*eps()) # UpperTriangular/LowerTriangular solve @@ -284,7 +284,7 @@ end @test (maximum(abs.(a'b - Array(a)'b)) < 100*eps()) @test (maximum(abs.(Transpose(a)*b - Transpose(Array(a))*b)) < 100*eps()) @test (maximum(abs.(a\b - Array(a)\b)) < 1000*eps()) - @test (maximum(abs.(a'\b - Array(a')\b)) < 1000*eps()) + @test (maximum(abs.(a'\b - Array(adjoint(a))\b)) < 1000*eps()) @test (maximum(abs.(Transpose(a)\b - Array(transpose(a))\b)) < 1000*eps()) b = randn(5,3) + im*randn(5,3) @@ -292,7 +292,7 @@ end @test (maximum(abs.(a'b - Array(a)'b)) < 100*eps()) @test (maximum(abs.(Transpose(a)*b - Transpose(Array(a))*b)) < 100*eps()) @test (maximum(abs.(a\b - Array(a)\b)) < 1000*eps()) - @test (maximum(abs.(a'\b - Array(a')\b)) < 1000*eps()) + @test (maximum(abs.(a'\b - Array(adjoint(a))\b)) < 1000*eps()) @test (maximum(abs.(Transpose(a)\b - Array(transpose(a))\b)) < 1000*eps()) end end @@ -1313,7 +1313,7 @@ end end @testset "issue #9917" begin - @test sparse([]') == reshape(sparse([]), 1, 0) + @test sparse(adjoint([])) == reshape(sparse([]), 1, 0) @test Array(sparse([])) == zeros(0) @test_throws BoundsError sparse([])[1] @test_throws BoundsError sparse([])[1] = 1 @@ -2014,7 +2014,7 @@ end A = guardsrand(1234) do sprand(5, 5, 1/5) end - A = max.(A, A') + A = max.(A, adjoint(A)) LinAlg.fillstored!(A, 1) B = A[5:-1:1, 5:-1:1] @test issymmetric(B) diff --git a/test/statistics.jl b/test/statistics.jl index 84d3ea0616ee7..757a3565c19d0 100644 --- a/test/statistics.jl +++ b/test/statistics.jl @@ -137,8 +137,8 @@ end @test var((1,2,3); mean=0, corrected=false) ≈ 14.0/3 @test_throws ArgumentError var((1,2,3); mean=()) - @test var([1 2 3 4 5; 6 7 8 9 10], 2) ≈ [2.5 2.5]' - @test var([1 2 3 4 5; 6 7 8 9 10], 2; corrected=false) ≈ [2.0 2.0]' + @test var([1 2 3 4 5; 6 7 8 9 10], 2) ≈ adjoint([2.5 2.5]) + @test var([1 2 3 4 5; 6 7 8 9 10], 2; corrected=false) ≈ adjoint([2.0 2.0]) @test stdm([1,2,3], 2) ≈ 1. @test std([1,2,3]) ≈ 1. @@ -152,8 +152,8 @@ end @test std((1,2,3); mean=0) ≈ sqrt(7.0) @test std((1,2,3); mean=0, corrected=false) ≈ sqrt(14.0/3) - @test std([1 2 3 4 5; 6 7 8 9 10], 2) ≈ sqrt.([2.5 2.5]') - @test std([1 2 3 4 5; 6 7 8 9 10], 2; corrected=false) ≈ sqrt.([2.0 2.0]') + @test std([1 2 3 4 5; 6 7 8 9 10], 2) ≈ sqrt.(adjoint([2.5 2.5])) + @test std([1 2 3 4 5; 6 7 8 9 10], 2; corrected=false) ≈ sqrt.(adjoint([2.0 2.0])) let A = ComplexF64[exp(i*im) for i in 1:10^4] @test varm(A, 0.) ≈ sum(map(abs2, A)) / (length(A) - 1) @@ -169,8 +169,8 @@ function safe_cov(x, y, zm::Bool, cr::Bool) end dot(vec(x), vec(y)) / (n - Int(cr)) end -X = [1. 2. 3. 4. 5.; 5. 4. 6. 2. 1.]' -Y = [6. 1. 5. 3. 2.; 2. 7. 8. 4. 3.]' +X = adjoint([1. 2. 3. 4. 5.; 5. 4. 6. 2. 1.]) +Y = adjoint([6. 1. 5. 3. 2.; 2. 7. 8. 4. 3.]) @testset "covariance" begin for vd in [1, 2], zm in [true, false], cr in [true, false]