[Date Index]
[Thread Index]
[Author Index]
Re: Mathematica 20x slower than Java at arithmetic/special functions, is
*To*: mathgroup at smc.vnet.net
*Subject*: [mg115890] Re: Mathematica 20x slower than Java at arithmetic/special functions, is
*From*: "Sjoerd C. de Vries" <sjoerd.c.devries at gmail.com>
*Date*: Mon, 24 Jan 2011 05:56:45 -0500 (EST)
*References*: <ihiab8$m3b$1@smc.vnet.net>
Using Mathematica's Compile your function can be speeded up by a
factor of about 7. Still a factor of 3 to explain...
How did you do the timing BTW?
Cheers -- Sjoerd
On Jan 23, 11:33 pm, Leo Alekseyev <dnqu... at gmail.com> wrote:
> I was playing around with JLink the other day, and noticed that Java
> seems to outperform Mathematica by ~20x in an area where I'd expect
> Mathematica to be rather well optimized -- arithmetic involving special
> functions. In my particular example, I am simply evaluating a sum of
> Bessel functions. I understand that much depends on the underlying
> implementation, but I just want to run this by Mathgroup to see if
> this is to be expected, or maybe if I'm doing something suboptimal in
> Mathematica. Here's the code that I'm running:
>
> grid1dc[x_,
> y_] = (With[{d = 0.1, NN = 50},
> Sum[Re[N[
> d BesselJ[1, 2 Pi d Sqrt[m^2 + n^2]]/
> Sqrt[m^2 + n^2 + 10^-7]] Exp[
> I 2.0 Pi (m x + n y)]], {m, -NN, NN, 1}, {n, -NN, NN, 1}]=
]) //
> N
>
> and
>
> gridres1da =
> With[{delta = 0.5, xlim = 2.5, ylim = 2.5},
> Table[{x, y, grid1dc[x, y]}, {x, -xlim, xlim, delta}, {y, -ylim,
> ylim, delta}]]
>
> Java implementation uses Colt and Apache common math libraries for the
> Bessels and complex numbers, uses a double for loop, and consistently
> runs 15-20 times faster.
>
> --Leo
Prev by Date:
**Re: Do I need MathLink to run finite-difference fast enough for**
Next by Date:
**Re: Mathematica 20x slower than Java at arithmetic/special functions, is**
Previous by thread:
**Re: Mathematica 20x slower than Java at arithmetic/special functions, is**
Next by thread:
**Re: Mathematica 20x slower than Java at arithmetic/special functions, is**
| |