The lack of this specific issue appearing in say Python may be that the
relative speed penalty is not that large? It seems that one of the strong
features of Julia is its speed, having to deal with complex numbers in this
way means that people have to pay more attention to coding than when
The lack of this specific issue appearing in say Python may be that the
relative speed penalty is not that large? It seems that one of the strong
features of Julia is its speed, having to deal with complex numbers in this
way means that people have to pay more attention to coding than when
I guess I have a long way to go with Julia. Thanks everyone for taking an
interest.
On Wednesday, July 22, 2015 11:32:19 PM Joe Tusek wrote:
O.k., should I be writing all my Julia with variables defined as complex so
as to avoid runtime assignment errors that may arise when outcomes of
calculations result in complex numbers such as square roots of negative
numbers or eigen
O.k., should I be writing all my Julia with variables defined as complex so
as to avoid runtime assignment errors that may arise when outcomes of
calculations result in complex numbers such as square roots of negative
numbers or eigen values etc? Will there be a performance penalty coding
this
I'm not convinced that the pickiness of Julia's square root is a serious
problem. Python's sqrt(x) behaves the same way for real x, and it hasn't
been an obstacle to SciPy's adoption. For that matter, in strongly typed
languages like C and Fortran this has pretty much always been the behavior
I think it has to do with type stability. Knowing beforehand the types of
the inputs and outputs of functions gives the compiler info for much faster
performance. It is explained in the manual.
Guess you could also do
mysqrt{T:Real}(x::T) = x=0 ? sqrt(x) : sqrt(x+0im)
but it will be slower.
How about
mysqrt(x::Real) = sqrt(complex(x))
mysqrt(x::Complex) = sqrt(x)
You can write const i=im at the top of your code if you'd like to use i
instead of im.
On Wednesday, July 22, 2015 at 8:49:04 AM UTC-4, Joe Tusek wrote:
Having come from Electrical Engineering with a Matlab background and being
new to Julia, I can't understand why assignment of complex
On Wednesday, July 22, 2015 at 9:40:47 AM UTC-4, David P. Sanders wrote:
How about
mysqrt(x::Real) = sqrt(complex(x))
mysqrt(x::Complex) = sqrt(x)
Just
mysqrt(x) = sqrt(complex(x))
should be sufficient if you always want a complex result. complex(x) is a
no-op if x is already
11 matches
Mail list logo