[英]LoadError: MethodError: convert(::Type{Union{}}, ::LinearAlgebra.Adjoint{Float64,Array{Float64,1}}) is ambiguous
While I'm using julia to compile a.jl file当我使用 julia 编译 a.jl 文件时
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: temx
是一维数组, temx'
由temx
转置,出现错误:
LoadError: MethodError: convert(::Type{Union{}}, ::LinearAlgebra.Adjoint{Float64,Array{Float64,1}}) is ambiguous.
LoadError: MethodError: convert(::Type{Union{}}, ::LinearAlgebra.Adjoint{Float64,Array{Float64,1}}) 不明确。
I can't see why it's wrong.Does anyone have any idea?我不明白为什么它是错的。有人知道吗?
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.这主要是因为对行或列向量求平方没有数学意义,因此在 Julia 中未定义。
If you want element-wise sqaure, do a'.^ 2
instead.如果你想要逐元素的 sqaure,请改为执行
a'.^ 2
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.