diff --git a/base/complex.jl b/base/complex.jl index c9f766253ad08..96f156fd51645 100644 --- a/base/complex.jl +++ b/base/complex.jl @@ -867,49 +867,3 @@ end ## promotion to complex ## _default_type(T::Type{Complex}) = Complex{Int} - -function complex{S<:Real,T<:Real}(A::AbstractArray{S}, B::AbstractArray{T}) - if size(A) != size(B); throw(DimensionMismatch()); end - F = similar(A, typeof(complex(zero(S),zero(T)))) - RF, RA, RB = eachindex(F), eachindex(A), eachindex(B) - if RF == RA == RB - for i in RA - @inbounds F[i] = complex(A[i], B[i]) - end - else - for (iF, iA, iB) in zip(RF, RA, RB) - @inbounds F[iF] = complex(A[iA], B[iB]) - end - end - return F -end - -function complex{T<:Real}(A::Real, B::AbstractArray{T}) - F = similar(B, typeof(complex(A,zero(T)))) - RF, RB = eachindex(F), eachindex(B) - if RF == RB - for i in RB - @inbounds F[i] = complex(A, B[i]) - end - else - for (iF, iB) in zip(RF, RB) - @inbounds F[iF] = complex(A, B[iB]) - end - end - return F -end - -function complex{T<:Real}(A::AbstractArray{T}, B::Real) - F = similar(A, typeof(complex(zero(T),B))) - RF, RA = eachindex(F), eachindex(A) - if RF == RA - for i in RA - @inbounds F[i] = complex(A[i], B) - end - else - for (iF, iA) in zip(RF, RA) - @inbounds F[iF] = complex(A[iA], B) - end - end - return F -end diff --git a/base/deprecated.jl b/base/deprecated.jl index c60de606849ba..265ed64e2fc2e 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -1380,6 +1380,11 @@ for f in (:sec, :sech, :secd, :asec, :asech, @eval @deprecate $f{T<:Number}(A::AbstractArray{T}) $f.(A) end +# Deprecate vectorized two-argument complex in favor of compact broadcast syntax +@deprecate complex(A::AbstractArray, b::Real) complex.(A, b) +@deprecate complex(a::Real, B::AbstractArray) complex.(a, B) +@deprecate complex(A::AbstractArray, B::AbstractArray) complex.(A, B) + # Deprecate manually vectorized clamp methods in favor of compact broadcast syntax @deprecate clamp(A::AbstractArray, lo, hi) clamp.(A, lo, hi) diff --git a/base/linalg/arpack.jl b/base/linalg/arpack.jl index db98510d17542..a024e2b41115a 100644 --- a/base/linalg/arpack.jl +++ b/base/linalg/arpack.jl @@ -171,7 +171,7 @@ function eupd_wrapper(T, n::Integer, sym::Bool, cmplx::Bool, bmat::String, if info[1] != 0 throw(ARPACKException(info[1])) end - evec = complex(Array{T}(n, nev+1), Array{T}(n, nev+1)) + evec = complex.(Array{T}(n, nev+1), Array{T}(n, nev+1)) j = 1 while j <= nev @@ -193,7 +193,7 @@ function eupd_wrapper(T, n::Integer, sym::Bool, cmplx::Bool, bmat::String, end end - d = complex(dr,di) + d = complex.(dr, di) if j == nev+1 p = sortperm(dmap(d[1:nev]), rev=true) diff --git a/base/linalg/blas.jl b/base/linalg/blas.jl index 21cfa6c8d0320..200e9dfc14775 100644 --- a/base/linalg/blas.jl +++ b/base/linalg/blas.jl @@ -235,7 +235,7 @@ conjugating the first vector. # Example: ```jldoctest -julia> Base.BLAS.dotc(10, im*ones(10), 1, complex(ones(20), ones(20)), 2) +julia> Base.BLAS.dotc(10, im*ones(10), 1, complex.(ones(20), ones(20)), 2) 10.0 - 10.0im ``` """ @@ -249,7 +249,7 @@ with stride `incx` and `n` elements of array `Y` with stride `incy`. # Example: ```jldoctest -julia> Base.BLAS.dotu(10, im*ones(10), 1, complex(ones(20), ones(20)), 2) +julia> Base.BLAS.dotu(10, im*ones(10), 1, complex.(ones(20), ones(20)), 2) -10.0 + 10.0im ``` """ diff --git a/base/linalg/eigen.jl b/base/linalg/eigen.jl index d5ea0d708cdfd..7f24c4244fa69 100644 --- a/base/linalg/eigen.jl +++ b/base/linalg/eigen.jl @@ -45,7 +45,7 @@ function eigfact!{T<:BlasReal}(A::StridedMatrix{T}; permute::Bool=true, scale::B end j += 1 end - return Eigen(complex(WR, WI), evec) + return Eigen(complex.(WR, WI), evec) end function eigfact!{T<:BlasComplex}(A::StridedMatrix{T}; permute::Bool=true, scale::Bool=true) @@ -162,7 +162,7 @@ make rows and columns more equal in norm. function eigvals!{T<:BlasReal}(A::StridedMatrix{T}; permute::Bool=true, scale::Bool=true) issymmetric(A) && return eigvals!(Symmetric(A)) _, valsre, valsim, _ = LAPACK.geevx!(permute ? (scale ? 'B' : 'P') : (scale ? 'S' : 'N'), 'N', 'N', 'N', A) - return iszero(valsim) ? valsre : complex(valsre, valsim) + return iszero(valsim) ? valsre : complex.(valsre, valsim) end function eigvals!{T<:BlasComplex}(A::StridedMatrix{T}; permute::Bool=true, scale::Bool=true) ishermitian(A) && return eigvals(Hermitian(A)) @@ -297,7 +297,7 @@ function eigfact!{T<:BlasReal}(A::StridedMatrix{T}, B::StridedMatrix{T}) end j += 1 end - return GeneralizedEigen(complex(alphar, alphai)./beta, vecs) + return GeneralizedEigen(complex.(alphar, alphai)./beta, vecs) end function eigfact!{T<:BlasComplex}(A::StridedMatrix{T}, B::StridedMatrix{T}) @@ -364,7 +364,7 @@ Same as [`eigvals`](@ref), but saves space by overwriting the input `A` (and `B` function eigvals!{T<:BlasReal}(A::StridedMatrix{T}, B::StridedMatrix{T}) issymmetric(A) && isposdef(B) && return eigvals!(Symmetric(A), Symmetric(B)) alphar, alphai, beta, vl, vr = LAPACK.ggev!('N', 'N', A, B) - return (iszero(alphai) ? alphar : complex(alphar, alphai))./beta + return (iszero(alphai) ? alphar : complex.(alphar, alphai))./beta end function eigvals!{T<:BlasComplex}(A::StridedMatrix{T}, B::StridedMatrix{T}) ishermitian(A) && isposdef(B) && return eigvals!(Hermitian(A), Hermitian(B)) diff --git a/base/linalg/lapack.jl b/base/linalg/lapack.jl index 4542cb847cc4f..462b765a1802d 100644 --- a/base/linalg/lapack.jl +++ b/base/linalg/lapack.jl @@ -5504,7 +5504,7 @@ for (gees, gges, elty) in work = Array{$elty}(lwork) end end - A, vs, iszero(wi) ? wr : complex(wr, wi) + A, vs, iszero(wi) ? wr : complex.(wr, wi) end # * .. Scalar Arguments .. @@ -5553,7 +5553,7 @@ for (gees, gges, elty) in work = Array{$elty}(lwork) end end - A, B, complex(alphar, alphai), beta, vsl[1:(jobvsl == 'V' ? n : 0),:], vsr[1:(jobvsr == 'V' ? n : 0),:] + A, B, complex.(alphar, alphai), beta, vsl[1:(jobvsl == 'V' ? n : 0),:], vsr[1:(jobvsr == 'V' ? n : 0),:] end end end @@ -5753,7 +5753,7 @@ for (trexc, trsen, tgsen, elty) in iwork = Array{BlasInt}(liwork) end end - T, Q, iszero(wi) ? wr : complex(wr, wi) + T, Q, iszero(wi) ? wr : complex.(wr, wi) end trsen!(select::StridedVector{BlasInt}, T::StridedMatrix{$elty}, Q::StridedMatrix{$elty}) = trsen!('N', 'V', select, T, Q) @@ -5822,7 +5822,7 @@ for (trexc, trsen, tgsen, elty) in iwork = Array{BlasInt}(liwork) end end - S, T, complex(alphar, alphai), beta, Q, Z + S, T, complex.(alphar, alphai), beta, Q, Z end end end diff --git a/base/sharedarray.jl b/base/sharedarray.jl index 297f5838cf63f..54241d7cdf2cf 100644 --- a/base/sharedarray.jl +++ b/base/sharedarray.jl @@ -537,8 +537,6 @@ function copy!(S::SharedArray, R::SharedArray) return S end -complex(S1::SharedArray,S2::SharedArray) = convert(SharedArray, complex(S1.s, S2.s)) - function print_shmem_limits(slen) try if is_linux() diff --git a/base/sparse/cholmod.jl b/base/sparse/cholmod.jl index 66e59fead6c37..5bccc8f270c26 100644 --- a/base/sparse/cholmod.jl +++ b/base/sparse/cholmod.jl @@ -1572,7 +1572,7 @@ end Ac_ldiv_B(L::FactorComponent, B) = ctranspose(L)\B (\){T<:VTypes}(L::Factor{T}, B::Dense{T}) = solve(CHOLMOD_A, L, B) -(\)(L::Factor{Float64}, B::VecOrMat{Complex{Float64}}) = complex(L\real(B), L\imag(B)) +(\)(L::Factor{Float64}, B::VecOrMat{Complex{Float64}}) = complex.(L\real(B), L\imag(B)) # First explicit TypeVars are necessary to avoid ambiguity errors with definition in # linalg/factorizations.jl (\){T<:VTypes}(L::Factor{T}, b::StridedVector) = Vector(L\convert(Dense{T}, b)) diff --git a/base/sparse/sparsematrix.jl b/base/sparse/sparsematrix.jl index 274f628131526..416ed5d3550b1 100644 --- a/base/sparse/sparsematrix.jl +++ b/base/sparse/sparsematrix.jl @@ -354,8 +354,6 @@ float(S::SparseMatrixCSC) = SparseMatrixCSC(S.m, S.n, copy(S.colptr), copy(S.row complex(S::SparseMatrixCSC) = SparseMatrixCSC(S.m, S.n, copy(S.colptr), copy(S.rowval), complex(copy(S.nzval))) -complex(A::SparseMatrixCSC, B::SparseMatrixCSC) = A + im*B - # Construct a sparse vector # Note that unlike `vec` for arrays, this does not share data diff --git a/base/sparse/umfpack.jl b/base/sparse/umfpack.jl index 1aadf522902bf..aeaa590dc82db 100644 --- a/base/sparse/umfpack.jl +++ b/base/sparse/umfpack.jl @@ -370,8 +370,8 @@ for itype in UmfpackIndexTypes Up,Ui,Ux,Uz, P, Q, C_NULL, C_NULL, &0, Rs, lu.numeric) - (transpose(SparseMatrixCSC(min(n_row, n_col), n_row, increment!(Lp), increment!(Lj), complex(Lx, Lz))), - SparseMatrixCSC(min(n_row, n_col), n_col, increment!(Up), increment!(Ui), complex(Ux, Uz)), + (transpose(SparseMatrixCSC(min(n_row, n_col), n_row, increment!(Lp), increment!(Lj), complex.(Lx, Lz))), + SparseMatrixCSC(min(n_row, n_col), n_col, increment!(Up), increment!(Ui), complex.(Ux, Uz)), increment!(P), increment!(Q), Rs) end end diff --git a/test/arrayops.jl b/test/arrayops.jl index b6eade5e97f1e..c073f0b21751a 100644 --- a/test/arrayops.jl +++ b/test/arrayops.jl @@ -1183,7 +1183,7 @@ end # Handle block matrices A = [randn(2,2) for i = 1:2, j = 1:2] @test issymmetric(A.'A) -A = [complex(randn(2,2), randn(2,2)) for i = 1:2, j = 1:2] +A = [complex.(randn(2,2), randn(2,2)) for i = 1:2, j = 1:2] @test ishermitian(A'A) # issue #7197 diff --git a/test/blas.jl b/test/blas.jl index d0d6ce31d55f9..1f6edf54c0853 100644 --- a/test/blas.jl +++ b/test/blas.jl @@ -8,8 +8,8 @@ for elty in (Float32, Float64, Complex64, Complex128) U = randn(5,2) V = randn(5,2) if elty == Complex64 || elty == Complex128 - U = complex(U, U) - V = complex(V, V) + U = complex.(U, U) + V = complex.(V, V) end U = convert(Array{elty, 2}, U) V = convert(Array{elty, 2}, V) @@ -23,8 +23,8 @@ for elty in (Complex64, Complex128) U = randn(5,2) V = randn(5,2) if elty == Complex64 || elty == Complex128 - U = complex(U, U) - V = complex(V, V) + U = complex.(U, U) + V = complex.(V, V) end U = convert(Array{elty, 2}, U) V = convert(Array{elty, 2}, V) @@ -58,8 +58,8 @@ for elty in [Float32, Float64, Complex64, Complex128] @test BLAS.dot(x1,x2) ≈ sum(x1.*x2) @test_throws DimensionMismatch BLAS.dot(x1,rand(elty, n + 1)) else - z1 = convert(Vector{elty}, complex(randn(n),randn(n))) - z2 = convert(Vector{elty}, complex(randn(n),randn(n))) + z1 = convert(Vector{elty}, complex.(randn(n),randn(n))) + z2 = convert(Vector{elty}, complex.(randn(n),randn(n))) @test BLAS.dotc(z1,z2) ≈ sum(conj(z1).*z2) @test BLAS.dotu(z1,z2) ≈ sum(z1.*z2) @test_throws DimensionMismatch BLAS.dotc(z1,rand(elty, n + 1)) @@ -71,7 +71,7 @@ for elty in [Float32, Float64, Complex64, Complex128] x = convert(Vector{elty}, randn(n)) @test BLAS.iamax(x) == indmax(abs.(x)) else - z = convert(Vector{elty}, complex(randn(n),randn(n))) + z = convert(Vector{elty}, complex.(randn(n),randn(n))) @test BLAS.iamax(z) == indmax(map(x -> abs(real(x)) + abs(imag(x)), z)) end @@ -87,8 +87,8 @@ for elty in [Float32, Float64, Complex64, Complex128] @test_throws ArgumentError BLAS.axpy!(α, copy(x1), 1:div(n,2), copy(x2), 0:(div(n, 2) - 1)) @test BLAS.axpy!(α,copy(x1),1:n,copy(x2),1:n) ≈ x2 + α*x1 else - z1 = convert(Vector{elty}, complex(randn(n), randn(n))) - z2 = convert(Vector{elty}, complex(randn(n), randn(n))) + z1 = convert(Vector{elty}, complex.(randn(n), randn(n))) + z2 = convert(Vector{elty}, complex.(randn(n), randn(n))) α = rand(elty) @test BLAS.axpy!(α, copy(z1), copy(z2)) ≈ z2 + α * z1 @test_throws DimensionMismatch BLAS.axpy!(α, copy(z1), rand(elty, n + 1)) diff --git a/test/complex.jl b/test/complex.jl index e14d9bd6d3efd..bb9aa2d0e7a02 100644 --- a/test/complex.jl +++ b/test/complex.jl @@ -813,8 +813,8 @@ end @test_throws DomainError complex(2,2)^(-2) @test complex(2.0,2.0)^(-2) === complex(0.0, -0.125) -@test complex(1.0,[1.0,1.0]) == [complex(1.0,1.0), complex(1.0,1.0)] -@test complex([1.0,1.0],1.0) == [complex(1.0,1.0), complex(1.0,1.0)] +@test complex.(1.0, [1.0, 1.0]) == [complex(1.0, 1.0), complex(1.0, 1.0)] +@test complex.([1.0, 1.0], 1.0) == [complex(1.0, 1.0), complex(1.0, 1.0)] # robust division of Float64 # hard complex divisions from Fig 6 of arxiv.1210.4539 z7 = Complex{Float64}(3.898125604559113300e289, 8.174961907852353577e295) diff --git a/test/dsp.jl b/test/dsp.jl index b9c62581a2aff..a40566edcf838 100644 --- a/test/dsp.jl +++ b/test/dsp.jl @@ -37,7 +37,7 @@ si = [0.9967207836936347,-1.4940914728163142,1.2841226760316475,-0.4524417279474 a = [1., 2., 1., 2.] b = [1., 2., 3.] @test conv(a, b) ≈ [1., 4., 8., 10., 7., 6.] -@test conv(complex(a, ones(4)), complex(b)) ≈ complex([1., 4., 8., 10., 7., 6.], [1., 3., 6., 6., 5., 3.]) +@test conv(complex.(a, ones(4)), complex(b)) ≈ complex.([1., 4., 8., 10., 7., 6.], [1., 3., 6., 6., 5., 3.]) # Discrete cosine transform (DCT) tests diff --git a/test/linalg/arnoldi.jl b/test/linalg/arnoldi.jl index 84f43d3cdf764..def962367fb0b 100644 --- a/test/linalg/arnoldi.jl +++ b/test/linalg/arnoldi.jl @@ -9,8 +9,8 @@ using Base.Test n = 10 areal = sprandn(n,n,0.4) breal = sprandn(n,n,0.4) - acmplx = complex(sprandn(n,n,0.4), sprandn(n,n,0.4)) - bcmplx = complex(sprandn(n,n,0.4), sprandn(n,n,0.4)) + acmplx = complex.(sprandn(n,n,0.4), sprandn(n,n,0.4)) + bcmplx = complex.(sprandn(n,n,0.4), sprandn(n,n,0.4)) testtol = 1e-6 diff --git a/test/linalg/bunchkaufman.jl b/test/linalg/bunchkaufman.jl index 734e7d705c95a..e117906889d30 100644 --- a/test/linalg/bunchkaufman.jl +++ b/test/linalg/bunchkaufman.jl @@ -20,8 +20,8 @@ breal = randn(n,2)/2 bimg = randn(n,2)/2 @testset for eltya in (Float32, Float64, Complex64, Complex128, Int) - 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) + 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) @testset for atype in ("Array", "SubArray") asym = a'+a # symmetric indefinite apd = a'*a # symmetric positive-definite @@ -37,7 +37,7 @@ bimg = randn(n,2)/2 ε = εa = eps(abs(float(one(eltya)))) @testset 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) + b = eltyb == Int ? rand(1:5, n, 2) : convert(Matrix{eltyb}, eltyb <: Complex ? complex.(breal, bimg) : breal) @testset for btype in ("Array", "SubArray") if btype == "Array" b = b diff --git a/test/linalg/cholesky.jl b/test/linalg/cholesky.jl index 9ffd228c13938..eb30eed5736a4 100644 --- a/test/linalg/cholesky.jl +++ b/test/linalg/cholesky.jl @@ -22,8 +22,8 @@ breal = randn(n,2)/2 bimg = randn(n,2)/2 for eltya in (Float32, Float64, Complex64, Complex128, BigFloat, Int) - 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) + 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) apd = a'*a # symmetric positive-definite apds = Symmetric(apd) @@ -144,7 +144,7 @@ for eltya in (Float32, Float64, Complex64, Complex128, BigFloat, Int) 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) + b = eltyb == Int ? rand(1:5, n, 2) : convert(Matrix{eltyb}, eltyb <: Complex ? complex.(breal, bimg) : breal) εb = eps(abs(float(one(eltyb)))) ε = max(εa,εb) @@ -200,7 +200,7 @@ end # Test generic cholfact! for elty in (Float32, Float64, Complex{Float32}, Complex{Float64}) if elty <: Complex - A = complex(randn(5,5), randn(5,5)) + A = complex.(randn(5,5), randn(5,5)) else A = randn(5,5) end @@ -210,7 +210,7 @@ for elty in (Float32, Float64, Complex{Float32}, Complex{Float64}) end # Test up- and downdates -let A = complex(randn(10,5), randn(10, 5)), v = complex(randn(5), randn(5)) +let A = complex.(randn(10,5), randn(10, 5)), v = complex.(randn(5), randn(5)) for uplo in (:U, :L) AcA = A'A BcB = AcA + v*v' @@ -257,7 +257,7 @@ end # Fail if non-Hermitian @test_throws ArgumentError cholfact(randn(5,5)) -@test_throws ArgumentError cholfact(complex(randn(5,5), randn(5,5))) +@test_throws ArgumentError cholfact(complex.(randn(5,5), randn(5,5))) @test_throws ArgumentError Base.LinAlg.chol!(randn(5,5)) @test_throws ArgumentError Base.LinAlg.cholfact!(randn(5,5),:U,Val{false}) @test_throws ArgumentError Base.LinAlg.cholfact!(randn(5,5),:U,Val{true}) diff --git a/test/linalg/dense.jl b/test/linalg/dense.jl index 310fb8751a554..f3c14beb9b779 100644 --- a/test/linalg/dense.jl +++ b/test/linalg/dense.jl @@ -42,14 +42,14 @@ breal = randn(n,2)/2 bimg = randn(n,2)/2 for eltya in (Float32, Float64, Complex64, Complex128, Int) - ainit = eltya == Int ? rand(1:7, n, n) : convert(Matrix{eltya}, eltya <: Complex ? complex(areal, aimg) : areal) - ainit2 = eltya == Int ? rand(1:7, n, n) : convert(Matrix{eltya}, eltya <: Complex ? complex(a2real, a2img) : a2real) + ainit = eltya == Int ? rand(1:7, n, n) : convert(Matrix{eltya}, eltya <: Complex ? complex.(areal, aimg) : areal) + ainit2 = eltya == Int ? rand(1:7, n, n) : convert(Matrix{eltya}, eltya <: Complex ? complex.(a2real, a2img) : a2real) ε = εa = eps(abs(float(one(eltya)))) apd = ainit'*ainit # symmetric positive-definite @test isposdef(apd,:U) for eltyb in (Float32, Float64, Complex64, Complex128, Int) - binit = eltyb == Int ? rand(1:5, n, 2) : convert(Matrix{eltyb}, eltyb <: Complex ? complex(breal, bimg) : breal) + binit = eltyb == Int ? rand(1:5, n, 2) : convert(Matrix{eltyb}, eltyb <: Complex ? complex.(breal, bimg) : breal) εb = eps(abs(float(one(eltyb)))) ε = max(εa,εb) @@ -176,8 +176,8 @@ for elty in (Int32, Int64, Float32, Float64, Complex64, Complex128) x = convert(Vector{elty}, [1:3;]) g = ones(elty, 3) else - x = convert(Vector{elty}, complex([1:3;], [1:3;])) - g = convert(Vector{elty}, complex(ones(3), ones(3))) + x = convert(Vector{elty}, complex.([1:3;], [1:3;])) + g = convert(Vector{elty}, complex.(ones(3), ones(3))) end xsub = view(x, 1:size(x, 1)) @test gradient(x) ≈ g @@ -232,10 +232,10 @@ for elty in (Float32, Float64, BigFloat, Complex{Float32}, Complex{Float64}, Com for i = 1:10 xinit = elty <: Integer ? convert(Vector{elty}, rand(1:10, nnorm)) : - elty <: Complex ? convert(Vector{elty}, complex(randn(nnorm), randn(nnorm))) : + elty <: Complex ? convert(Vector{elty}, complex.(randn(nnorm), randn(nnorm))) : convert(Vector{elty}, randn(nnorm)) yinit = elty <: Integer ? convert(Vector{elty}, rand(1:10, nnorm)) : - elty <: Complex ? convert(Vector{elty}, complex(randn(nnorm), randn(nnorm))) : + elty <: Complex ? convert(Vector{elty}, complex.(randn(nnorm), randn(nnorm))) : convert(Vector{elty}, randn(nnorm)) α = elty <: Integer ? randn() : elty <: Complex ? convert(elty, complex(randn(),randn())) : @@ -284,10 +284,10 @@ for elty in (Float32, Float64, BigFloat, Complex{Float32}, Complex{Float64}, Com for i = 1:10 Ainit = elty <: Integer ? convert(Matrix{elty}, rand(1:10, mmat, nmat)) : - elty <: Complex ? convert(Matrix{elty}, complex(randn(mmat, nmat), randn(mmat, nmat))) : + elty <: Complex ? convert(Matrix{elty}, complex.(randn(mmat, nmat), randn(mmat, nmat))) : convert(Matrix{elty}, randn(mmat, nmat)) Binit = elty <: Integer ? convert(Matrix{elty}, rand(1:10, mmat, nmat)) : - elty <: Complex ? convert(Matrix{elty}, complex(randn(mmat, nmat), randn(mmat, nmat))) : + elty <: Complex ? convert(Matrix{elty}, complex.(randn(mmat, nmat), randn(mmat, nmat))) : convert(Matrix{elty}, randn(mmat, nmat)) α = elty <: Integer ? randn() : elty <: Complex ? convert(elty, complex(randn(),randn())) : diff --git a/test/linalg/eigen.jl b/test/linalg/eigen.jl index 7054c68ce3dc0..f25bb65725abd 100644 --- a/test/linalg/eigen.jl +++ b/test/linalg/eigen.jl @@ -16,7 +16,7 @@ areal = randn(n,n)/2 aimg = randn(n,n)/2 @testset for eltya in (Float32, Float64, Complex64, Complex128, Int) - aa = eltya == Int ? rand(1:7, n, n) : convert(Matrix{eltya}, eltya <: Complex ? complex(areal, aimg) : areal) + aa = eltya == Int ? rand(1:7, n, n) : convert(Matrix{eltya}, eltya <: Complex ? complex.(areal, aimg) : areal) asym = aa'+aa # symmetric indefinite apd = aa'*aa # symmetric positive-definite @testset for atype in ("Array", "SubArray") diff --git a/test/linalg/generic.jl b/test/linalg/generic.jl index f31b099a05fcd..e6c9982a38b66 100644 --- a/test/linalg/generic.jl +++ b/test/linalg/generic.jl @@ -43,7 +43,7 @@ for elty in (Int, Rational{BigInt}, Float32, Float64, BigFloat, Complex{Float32} elseif elty <: Real A = convert(Matrix{elty}, randn(n,n)) + 10I else - A = convert(Matrix{elty}, complex(randn(n,n), randn(n,n))) + A = convert(Matrix{elty}, complex.(randn(n,n), randn(n,n))) end debug && println("element type: $elty") diff --git a/test/linalg/givens.jl b/test/linalg/givens.jl index 864d58a358a83..b9815b6303752 100644 --- a/test/linalg/givens.jl +++ b/test/linalg/givens.jl @@ -13,7 +13,7 @@ for elty in (Float32, Float64, Complex64, Complex128) if elty <: Real A = convert(Matrix{elty}, randn(10,10)) else - A = convert(Matrix{elty}, complex(randn(10,10),randn(10,10))) + A = convert(Matrix{elty}, complex.(randn(10,10),randn(10,10))) end for Atype in ("Array", "SubArray") if Atype == "Array" diff --git a/test/linalg/hessenberg.jl b/test/linalg/hessenberg.jl index 08f864e47d8e8..0e700fcd4c781 100644 --- a/test/linalg/hessenberg.jl +++ b/test/linalg/hessenberg.jl @@ -14,7 +14,7 @@ let n = 10 A = eltya == Int ? rand(1:7, n, n) : convert(Matrix{eltya}, eltya <: Complex ? - complex(Areal, Aimg) : + complex.(Areal, Aimg) : Areal) if eltya != BigFloat diff --git a/test/linalg/lapack.jl b/test/linalg/lapack.jl index efae0368c8b93..b0749da0133cb 100644 --- a/test/linalg/lapack.jl +++ b/test/linalg/lapack.jl @@ -15,7 +15,7 @@ import Base.LinAlg.BlasInt Ainit = randn(5,5) @testset for elty in (Float32, Float64, Complex64, Complex128) if elty == Complex64 || elty == Complex128 - A = complex(Ainit, Ainit) + A = complex.(Ainit, Ainit) else A = Ainit end @@ -590,7 +590,7 @@ end if elty <: Real A = convert(Matrix{elty}, randn(10,nn)) else - A = convert(Matrix{elty}, complex(randn(10,nn),randn(10,nn))) + A = convert(Matrix{elty}, complex.(randn(10,nn),randn(10,nn))) end ## LU (only equal for real because LAPACK uses different absolute value when choosing permutations) if elty <: Real FJulia = Base.LinAlg.generic_lufact!(copy(A)) diff --git a/test/linalg/lq.jl b/test/linalg/lq.jl index 798b6826c6b9e..48007daa9bf06 100644 --- a/test/linalg/lq.jl +++ b/test/linalg/lq.jl @@ -21,14 +21,14 @@ breal = randn(n,2)/2 bimg = randn(n,2)/2 @testset for eltya in (Float32, Float64, Complex64, Complex128) - 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) + 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 apd = a'*a # symmetric positive-definite ε = εa = eps(abs(float(one(eltya)))) @testset 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) + b = eltyb == Int ? rand(1:5, n, 2) : convert(Matrix{eltyb}, eltyb <: Complex ? complex.(breal, bimg) : breal) εb = eps(abs(float(one(eltyb)))) ε = max(εa,εb) diff --git a/test/linalg/lu.jl b/test/linalg/lu.jl index 6e5bbbffa7ab1..31c973c0a243e 100644 --- a/test/linalg/lu.jl +++ b/test/linalg/lu.jl @@ -29,8 +29,8 @@ dreal = randn(n)/2 dimg = randn(n)/2 for eltya in (Float32, Float64, Complex64, Complex128, BigFloat, Int) - a = eltya == Int ? rand(1:7, n, n) : convert(Matrix{eltya}, eltya <: Complex ? complex(areal, aimg) : areal) - d = eltya == Int ? Tridiagonal(rand(1:7, n-1), rand(1:7, n), rand(1:7, n-1)) : convert(Tridiagonal{eltya}, eltya <: Complex ? Tridiagonal(complex(dlreal, dlimg), complex(dreal, dimg), complex(dureal, duimg)) : Tridiagonal(dlreal, dreal, dureal)) + a = eltya == Int ? rand(1:7, n, n) : convert(Matrix{eltya}, eltya <: Complex ? complex.(areal, aimg) : areal) + d = eltya == Int ? Tridiagonal(rand(1:7, n-1), rand(1:7, n), rand(1:7, n-1)) : convert(Tridiagonal{eltya}, eltya <: Complex ? Tridiagonal(complex.(dlreal, dlimg), complex.(dreal, dimg), complex.(dureal, duimg)) : Tridiagonal(dlreal, dreal, dureal)) ε = εa = eps(abs(float(one(eltya)))) if eltya <: BlasFloat @@ -39,8 +39,8 @@ for eltya in (Float32, Float64, Complex64, Complex128, BigFloat, Int) @test AbstractArray(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) - c = eltyb == Int ? rand(1:5, n) : convert(Vector{eltyb}, eltyb <: Complex ? complex(creal, cimg) : creal) + b = eltyb == Int ? rand(1:5, n, 2) : convert(Matrix{eltyb}, eltyb <: Complex ? complex.(breal, bimg) : breal) + c = eltyb == Int ? rand(1:5, n) : convert(Vector{eltyb}, eltyb <: Complex ? complex.(creal, cimg) : creal) εb = eps(abs(float(one(eltyb)))) ε = max(εa,εb) diff --git a/test/linalg/qr.jl b/test/linalg/qr.jl index 5e42c2375a614..80f5c2a1d8686 100644 --- a/test/linalg/qr.jl +++ b/test/linalg/qr.jl @@ -21,14 +21,14 @@ breal = randn(n,2)/2 bimg = randn(n,2)/2 for eltya in (Float32, Float64, Complex64, Complex128, BigFloat, Int) - 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) + 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 apd = a'*a # symmetric positive-definite ε = εa = eps(abs(float(one(eltya)))) 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) + b = eltyb == Int ? rand(1:5, n, 2) : convert(Matrix{eltyb}, eltyb <: Complex ? complex.(breal, bimg) : breal) εb = eps(abs(float(one(eltyb)))) ε = max(εa,εb) diff --git a/test/linalg/schur.jl b/test/linalg/schur.jl index 365c32980e490..1eff3f4885e3a 100644 --- a/test/linalg/schur.jl +++ b/test/linalg/schur.jl @@ -16,7 +16,7 @@ areal = randn(n,n)/2 aimg = randn(n,n)/2 @testset for eltya in (Float32, Float64, Complex64, Complex128, Int) - a = eltya == Int ? rand(1:7, n, n) : convert(Matrix{eltya}, eltya <: Complex ? complex(areal, aimg) : areal) + a = eltya == Int ? rand(1:7, n, n) : convert(Matrix{eltya}, eltya <: Complex ? complex.(areal, aimg) : areal) asym = a'+a # symmetric indefinite apd = a'*a # symmetric positive-definite @testset for atype in ("Array", "SubArray") diff --git a/test/linalg/svd.jl b/test/linalg/svd.jl index a60b8cd6350be..5e26babf44cd6 100644 --- a/test/linalg/svd.jl +++ b/test/linalg/svd.jl @@ -18,8 +18,8 @@ a2real = randn(n,n)/2 a2img = randn(n,n)/2 @testset for eltya in (Float32, Float64, Complex64, Complex128, 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) + 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 apd = aa'*aa # symmetric positive-definite @testset for atype in ("Array", "SubArray") diff --git a/test/linalg/symmetric.jl b/test/linalg/symmetric.jl index 80e1976abad7b..dec32f8a21bf2 100644 --- a/test/linalg/symmetric.jl +++ b/test/linalg/symmetric.jl @@ -33,16 +33,16 @@ let n=10 aimg = randn(n,n)/2 debug && println("symmetric eigendecomposition") for eltya in (Float32, Float64, Complex64, Complex128, BigFloat, Int) - a = eltya == Int ? rand(1:7, n, n) : convert(Matrix{eltya}, eltya <: Complex ? complex(areal, aimg) : areal) + a = eltya == Int ? rand(1:7, n, n) : convert(Matrix{eltya}, eltya <: Complex ? complex.(areal, aimg) : areal) asym = a'+a # symmetric indefinite ε = εa = eps(abs(float(one(eltya)))) x = randn(n) y = randn(n) b = randn(n,n)/2 - x = eltya == Int ? rand(1:7, n) : convert(Vector{eltya}, eltya <: Complex ? complex(x, zeros(n)) : x) - y = eltya == Int ? rand(1:7, n) : convert(Vector{eltya}, eltya <: Complex ? complex(y, zeros(n)) : y) - b = eltya == Int ? rand(1:7, n, n) : convert(Matrix{eltya}, eltya <: Complex ? complex(b, zeros(n,n)) : b) + x = eltya == Int ? rand(1:7, n) : convert(Vector{eltya}, eltya <: Complex ? complex.(x, zeros(n)) : x) + y = eltya == Int ? rand(1:7, n) : convert(Vector{eltya}, eltya <: Complex ? complex.(y, zeros(n)) : y) + b = eltya == Int ? rand(1:7, n, n) : convert(Matrix{eltya}, eltya <: Complex ? complex.(b, zeros(n,n)) : b) debug && println("\ntype of a: ", eltya, "\n") @@ -240,7 +240,7 @@ end # 17780 let a = randn(2,2) a = a'a - b = complex(a,a) + b = complex.(a,a) c = Symmetric(b) @test conj(c) == conj(Array(c)) cc = copy(c) diff --git a/test/linalg/triangular.jl b/test/linalg/triangular.jl index 4eef3fb6cd8fc..8b20f96b59d4e 100644 --- a/test/linalg/triangular.jl +++ b/test/linalg/triangular.jl @@ -22,7 +22,7 @@ for elty1 in (Float32, Float64, BigFloat, Complex64, Complex128, Complex{BigFloa (UnitLowerTriangular, :L)) # Construct test matrix - A1 = t1(elty1 == Int ? rand(1:7, n, n) : convert(Matrix{elty1}, (elty1 <: Complex ? complex(randn(n, n), randn(n, n)) : randn(n, n)) |> t -> chol(t't) |> t -> uplo1 == :U ? t : ctranspose(t))) + A1 = t1(elty1 == Int ? rand(1:7, n, n) : convert(Matrix{elty1}, (elty1 <: Complex ? complex.(randn(n, n), randn(n, n)) : randn(n, n)) |> t -> chol(t't) |> t -> uplo1 == :U ? t : ctranspose(t))) debug && println("elty1: $elty1, A1: $t1") @@ -265,7 +265,7 @@ for elty1 in (Float32, Float64, BigFloat, Complex64, Complex128, Complex{BigFloa debug && println("elty1: $elty1, A1: $t1, elty2: $elty2") - A2 = t2(elty2 == Int ? rand(1:7, n, n) : convert(Matrix{elty2}, (elty2 <: Complex ? complex(randn(n, n), randn(n, n)) : randn(n, n)) |> t -> chol(t't) |> t -> uplo2 == :U ? t : ctranspose(t))) + A2 = t2(elty2 == Int ? rand(1:7, n, n) : convert(Matrix{elty2}, (elty2 <: Complex ? complex.(randn(n, n), randn(n, n)) : randn(n, n)) |> t -> chol(t't) |> t -> uplo2 == :U ? t : ctranspose(t))) # Convert if elty1 <: Real && !(elty2 <: Integer) @@ -391,8 +391,8 @@ A2real = randn(n, n)/2 A2img = randn(n, n)/2 for eltya in (Float32, Float64, Complex64, Complex128, BigFloat, Int) - 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) + 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) εa = eps(abs(float(one(eltya)))) for eltyb in (Float32, Float64, Complex64, Complex128) diff --git a/test/parallel_exec.jl b/test/parallel_exec.jl index a3dbb43ac7e14..5b71135236e30 100644 --- a/test/parallel_exec.jl +++ b/test/parallel_exec.jl @@ -480,7 +480,7 @@ se = SharedArray(Int,10) sd[i] = i se[i] = i end -sc = complex(sd,se) +sc = convert(SharedArray, complex.(sd,se)) for (x,i) in enumerate(sc) @test i == complex(x,x) end diff --git a/test/reduce.jl b/test/reduce.jl index bf55acd49cb50..4786e8f39ded2 100644 --- a/test/reduce.jl +++ b/test/reduce.jl @@ -60,7 +60,7 @@ a = sum(sin, z) z = [-4, -3, 2, 5] fz = float(z) a = randn(32) # need >16 elements to trigger BLAS code path -b = complex(randn(32), randn(32)) +b = complex.(randn(32), randn(32)) # check variants of summation for type-stability and other issues (#6069) sum2(itr) = invoke(sum, Tuple{Any}, itr) diff --git a/test/sparse/cholmod.jl b/test/sparse/cholmod.jl index 137933c887220..dee14b57b64d9 100644 --- a/test/sparse/cholmod.jl +++ b/test/sparse/cholmod.jl @@ -272,8 +272,8 @@ for elty in (Float64, Complex{Float64}) A = randn(5, 5) b = randn(5) else - A = complex(randn(5, 5), randn(5, 5)) - b = complex(randn(5), randn(5)) + A = complex.(randn(5, 5), randn(5, 5)) + b = complex.(randn(5), randn(5)) end ADense = CHOLMOD.Dense(A) bDense = CHOLMOD.Dense(b) @@ -312,8 +312,8 @@ p = ccall((:cholmod_l_allocate_sparse, :libcholmod), Ptr{CHOLMOD.C_Sparse{Float6 @test CHOLMOD.free_sparse!(p) for elty in (Float64, Complex{Float64}) - A1 = sparse([1:5, 1;], [1:5, 2;], elty == Float64 ? randn(6) : complex(randn(6), randn(6))) - A2 = sparse([1:5, 1;], [1:5, 2;], elty == Float64 ? randn(6) : complex(randn(6), randn(6))) + A1 = sparse([1:5, 1;], [1:5, 2;], elty == Float64 ? randn(6) : complex.(randn(6), randn(6))) + A2 = sparse([1:5, 1;], [1:5, 2;], elty == Float64 ? randn(6) : complex.(randn(6), randn(6))) A1pd = A1'A1 A1Sparse = CHOLMOD.Sparse(A1) A2Sparse = CHOLMOD.Sparse(A2) @@ -654,7 +654,7 @@ end # Real factorization and complex rhs A = sprandn(5,5,0.4) |> t -> t't + I -B = complex(randn(5,2), randn(5,2)) +B = complex.(randn(5,2), randn(5,2)) @test cholfact(A)\B ≈ A\B # Make sure that ldltfact performs an LDLt (Issue #19032) diff --git a/test/sparse/sparse.jl b/test/sparse/sparse.jl index 17cd8859c2bc8..b50051eec165b 100644 --- a/test/sparse/sparse.jl +++ b/test/sparse/sparse.jl @@ -10,7 +10,7 @@ end end @testset "sparse matrix construction" begin - @test isequal(Array(sparse(complex(ones(5,5),ones(5,5)))), complex(ones(5,5),ones(5,5))) + @test isequal(Array(sparse(complex.(ones(5,5), ones(5,5)))), complex.(ones(5,5), ones(5,5))) @test_throws ArgumentError sparse([1,2,3], [1,2], [1,2,3], 3, 3) @test_throws ArgumentError sparse([1,2,3], [1,2,3], [1,2], 3, 3) @test_throws ArgumentError sparse([1,2,3], [1,2,3], [1,2,3], 0, 1) diff --git a/test/sparse/sparsevector.jl b/test/sparse/sparsevector.jl index 80ef3784bc313..bc1d1ab071c81 100644 --- a/test/sparse/sparsevector.jl +++ b/test/sparse/sparsevector.jl @@ -629,11 +629,11 @@ end let x = spv_x1, x2 = spv_x2 # complex - @test exact_equal(complex(x, x), + @test exact_equal(complex.(x, x), SparseVector(8, [2,5,6], [1.25+1.25im, -0.75-0.75im, 3.5+3.5im])) - @test exact_equal(complex(x, x2), + @test exact_equal(complex.(x, x2), SparseVector(8, [1,2,5,6,7], [3.25im, 1.25+4.0im, -0.75+0.0im, 3.5-5.5im, -6.0im])) - @test exact_equal(complex(x2, x), + @test exact_equal(complex.(x2, x), SparseVector(8, [1,2,5,6,7], [3.25+0.0im, 4.0+1.25im, -0.75im, -5.5+3.5im, -6.0+0.0im])) # real & imag @@ -641,7 +641,7 @@ let x = spv_x1, x2 = spv_x2 @test real(x) === x @test exact_equal(imag(x), spzeros(Float64, length(x))) - xcp = complex(x, x2) + xcp = complex.(x, x2) @test exact_equal(real(xcp), x) @test exact_equal(imag(xcp), x2) end @@ -788,8 +788,8 @@ let x = sprand(16, 0.5), x2 = sprand(16, 0.4) end end -let x = complex(sprand(32, 0.6), sprand(32, 0.6)), - y = complex(sprand(32, 0.6), sprand(32, 0.6)) +let x = complex.(sprand(32, 0.6), sprand(32, 0.6)), + y = complex.(sprand(32, 0.6), sprand(32, 0.6)) xf = Array(x)::Vector{Complex128} yf = Array(y)::Vector{Complex128} @test dot(x, x) ≈ dot(xf, xf) @@ -857,9 +857,9 @@ let A = sprandn(16, 9, 0.5), x = sprand(16, 0.7) @test y ≈ At_mul_B(Af, xf) end -let A = complex(sprandn(7, 8, 0.5), sprandn(7, 8, 0.5)), - x = complex(sprandn(8, 0.6), sprandn(8, 0.6)), - x2 = complex(sprandn(7, 0.75), sprandn(7, 0.75)) +let A = complex.(sprandn(7, 8, 0.5), sprandn(7, 8, 0.5)), + x = complex.(sprandn(8, 0.6), sprandn(8, 0.6)), + x2 = complex.(sprandn(7, 0.75), sprandn(7, 0.75)) Af = Array(A) xf = Array(x) x2f = Array(x2) @@ -887,9 +887,9 @@ let A = sprandn(9, 16, 0.5), x = sprand(16, 0.7), x2 = sprand(9, 0.7) @test Array(y) ≈ Af'x2f end -let A = complex(sprandn(7, 8, 0.5), sprandn(7, 8, 0.5)), - x = complex(sprandn(8, 0.6), sprandn(8, 0.6)), - x2 = complex(sprandn(7, 0.75), sprandn(7, 0.75)) +let A = complex.(sprandn(7, 8, 0.5), sprandn(7, 8, 0.5)), + x = complex.(sprandn(8, 0.6), sprandn(8, 0.6)), + x2 = complex.(sprandn(7, 0.75), sprandn(7, 0.75)) Af = Array(A) xf = Array(x) x2f = Array(x2) @@ -911,16 +911,16 @@ end let m = 10 sparsefloatvecs = SparseVector[sprand(m, 0.4) for k in 1:3] sparseintvecs = SparseVector[SparseVector(m, sprvec.nzind, round.(Int, sprvec.nzval*10)) for sprvec in sparsefloatvecs] - sparsecomplexvecs = SparseVector[SparseVector(m, sprvec.nzind, complex(sprvec.nzval, sprvec.nzval)) for sprvec in sparsefloatvecs] + sparsecomplexvecs = SparseVector[SparseVector(m, sprvec.nzind, complex.(sprvec.nzval, sprvec.nzval)) for sprvec in sparsefloatvecs] sprmat = sprand(m, m, 0.2) sparsefloatmat = speye(m) + sprmat/(2m) - sparsecomplexmat = speye(m) + SparseMatrixCSC(m, m, sprmat.colptr, sprmat.rowval, complex(sprmat.nzval, sprmat.nzval)/(4m)) + sparsecomplexmat = speye(m) + SparseMatrixCSC(m, m, sprmat.colptr, sprmat.rowval, complex.(sprmat.nzval, sprmat.nzval)/(4m)) sparseintmat = speye(Int, m)*10m + SparseMatrixCSC(m, m, sprmat.colptr, sprmat.rowval, round.(Int, sprmat.nzval*10)) denseintmat = eye(Int, m)*10m + rand(1:m, m, m) densefloatmat = eye(m) + randn(m, m)/(2m) - densecomplexmat = eye(m) + complex(randn(m, m), randn(m, m))/(4m) + densecomplexmat = eye(m) + complex.(randn(m, m), randn(m, m))/(4m) inttypes = (Int32, Int64, BigInt) floattypes = (Float32, Float64, BigFloat) diff --git a/test/sparse/spqr.jl b/test/sparse/spqr.jl index da17f1386a5b0..2b137d028c28c 100644 --- a/test/sparse/spqr.jl +++ b/test/sparse/spqr.jl @@ -12,14 +12,14 @@ for eltyA in (Float64, Complex{Float64}) if eltyA <: Real A = sparse([1:n; rand(1:m, nn - n)], [1:n; rand(1:n, nn - n)], randn(nn), m, n) else - A = sparse([1:n; rand(1:m, nn - n)], [1:n; rand(1:n, nn - n)], complex(randn(nn), randn(nn)), m, n) + A = sparse([1:n; rand(1:m, nn - n)], [1:n; rand(1:n, nn - n)], complex.(randn(nn), randn(nn)), m, n) end if eltyB == Int B = rand(1:10, m, 2) elseif eltyB <: Real B = randn(m, 2) else - B = complex(randn(m, 2), randn(m, 2)) + B = complex.(randn(m, 2), randn(m, 2)) end @inferred A\B diff --git a/test/sparse/umfpack.jl b/test/sparse/umfpack.jl index 6b1966cbaf6aa..dbfe2dfae0387 100644 --- a/test/sparse/umfpack.jl +++ b/test/sparse/umfpack.jl @@ -28,12 +28,12 @@ for Tv in (Float64, Complex128) @test x ≈ float([1:5;]) @test norm(A*x-b,1) < eps(1e4) - z = complex(b,zeros(b)) + z = complex.(b,zeros(b)) x = Base.SparseArrays.A_ldiv_B!(lua, z) @test x ≈ float([1:5;]) @test z === x y = similar(z) - A_ldiv_B!(y, lua, complex(b,zeros(b))) + A_ldiv_B!(y, lua, complex.(b,zeros(b))) @test y ≈ x @test norm(A*x-b,1) < eps(1e4) @@ -43,12 +43,12 @@ for Tv in (Float64, Complex128) @test x ≈ float([1:5;]) @test norm(A'*x-b,1) < eps(1e4) - z = complex(b,zeros(b)) + z = complex.(b,zeros(b)) x = Base.SparseArrays.Ac_ldiv_B!(lua, z) @test x ≈ float([1:5;]) @test x === z y = similar(x) - Base.SparseArrays.Ac_ldiv_B!(y, lua, complex(b,zeros(b))) + Base.SparseArrays.Ac_ldiv_B!(y, lua, complex.(b,zeros(b))) @test y ≈ x @test norm(A'*x-b,1) < eps(1e4) @@ -56,10 +56,10 @@ for Tv in (Float64, Complex128) @test x ≈ float([1:5;]) @test norm(A.'*x-b,1) < eps(1e4) - x = Base.SparseArrays.At_ldiv_B!(lua,complex(b,zeros(b))) + x = Base.SparseArrays.At_ldiv_B!(lua,complex.(b,zeros(b))) @test x ≈ float([1:5;]) y = similar(x) - Base.SparseArrays.At_ldiv_B!(y, lua,complex(b,zeros(b))) + Base.SparseArrays.At_ldiv_B!(y, lua,complex.(b,zeros(b))) @test y ≈ x @test norm(A.'*x-b,1) < eps(1e4) @@ -69,7 +69,7 @@ for Tv in (Float64, Complex128) end end -Ac0 = complex(A0,A0) +Ac0 = complex.(A0,A0) for Ti in Base.SparseArrays.UMFPACK.UMFITypes.types Ac = convert(SparseMatrixCSC{Complex128,Ti}, Ac0) lua = lufact(Ac) @@ -79,7 +79,7 @@ end for elty in (Float64, Complex128) for (m, n) in ((10,5), (5, 10)) - A = sparse([1:min(m,n); rand(1:m, 10)], [1:min(m,n); rand(1:n, 10)], elty == Float64 ? randn(min(m, n) + 10) : complex(randn(min(m, n) + 10), randn(min(m, n) + 10))) + A = sparse([1:min(m,n); rand(1:m, 10)], [1:min(m,n); rand(1:n, 10)], elty == Float64 ? randn(min(m, n) + 10) : complex.(randn(min(m, n) + 10), randn(min(m, n) + 10))) F = lufact(A) L, U, p, q, Rs = F[:(:)] @test (Diagonal(Rs) * A)[p,q] ≈ L * U