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 way?
On Thursday, July 23, 2015 at 12:22:28 AM UTC+10, Steven G. Johnson wrote: > > > > 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 complex. But it would probably be clearer just to > write sqrt(complex(x)) where that is what you want. >
