[julia-users] Re: Splitting a multidimensional function

2015-08-21 Thread David P. Sanders
Here is a fun and possibly useful solution (that works only on 0.4 due to call overloading): https://gist.github.com/dpsanders/d8ef239ec8c78c4debee It introduces a `MultidimFunction` type, and a macro `@multidim` that works as follows: julia @multidim f(x) = [sqrt(x[1]), 2x[2]]

[julia-users] Re: Splitting a multidimensional function

2015-08-19 Thread John Myles White
Since f1(x) requires a call to f(x), there's no way for your approach to work in Julia. You probably should define f1(x) as sqrt(x[1]) and f2(x) as 2 * x[2]. -- John On Wednesday, August 19, 2015 at 2:32:38 PM UTC-7, Nikolay Kryukov wrote: I have a problem when I try to separate the

Re: [julia-users] Re: Splitting a multidimensional function

2015-08-19 Thread Elliot Saba
You may expect the optimizer to completely omit calculating the first element, but unfortunately for you, the negativity check before the square root will never be optimized away, since it affects the whole program execution and thus *shouldn't* be omitted from the compiled program, even though