Someone knows how to convert an array{Float64,1} to a Float64?
When I do:
M=rand(5,5)
a=M[:,1]' * M[:,1]
if a<0
print("Less than 0")
else
print("more")
end
I have an error: " isless has no method matching isless(::Array{Float64,2}, ::Int 32) in < at operators.jl:32
Can anyone tell me please how to convert the array{Float64,1}
a to a float64
or tell me how to compare a 1 element array a to a float?
Thank you
This operation really only makes sense when you are certain that your Array{Float64, 1}
has a single element. In this case you can access it as a[1]
.
For your example I'd recommend using the dot
function ( a = dot(M[:,1], M[:, 1])
) or the norm
function ( a = norm(M[:, 1])^2
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.