miao
miao

Reputation: 33

LoadError: MethodError: convert(::Type{Union{}}, ::LinearAlgebra.Adjoint{Float64,Array{Float64,1}}) is ambiguous

While I'm using julia to compile a .jl file

pixelscale=4e-4
psfsize=4191.00

span = (2*pixelscale * floor(psfsize/2))/(psfsize-1)
temx = [-pixelscale * floor(psfsize/2)]
for i in psfsize
    b=-pixelscale * floor(psfsize/2) + i*span
    push!(temx,b)
end

meshtheta = temx   
meshphi = temx'
R_pup = sqrt(meshphi^2 + meshtheta^2)

temx is a one dimensional array and temx' is transposed from temx and error occurs:

LoadError: MethodError: convert(::Type{Union{}}, ::LinearAlgebra.Adjoint{Float64,Array{Float64,1}}) is ambiguous.

I can't see why it's wrong.Does anyone have any idea?

Upvotes: 1

Views: 511

Answers (1)

jling
jling

Reputation: 2301

The error you're seeing comes from this:

julia> a = rand(2);

julia> a'
1×2 adjoint(::Vector{Float64}) with eltype Float64:
 0.985248  0.651835

julia> (a')^2
ERROR: MethodError: convert(::Type{Union{}}, ::LinearAlgebra.Adjoint{Float64, Vector{Float64}}) is ambiguous. Candidates:

This is essentially because squaring a row or column vector doesn't make mathematical sense thus is undefined in Julia.

If you want element-wise sqaure, do a' .^ 2 instead.

Upvotes: 0

Related Questions