1 reputation
bio website
location
age
visits member for 1 year, 9 months
seen 2 days ago

Mar
31
comment Alleviating a bottleneck involving a function call with symbolic derivatives
I found defining a Module and preallocating elements required multiple times at the start of each Module call gave the best speedup, but preallocating large matrices was slower than reiterating the inbuilt functions (this I find very strange, but such is life). Replacing Module with Block was around 15% faster again. It's passably fast for my immediate use, but it's still completely impractical for what I want to do long-term. Any other insights, especially into why the preallocated matrices are so slow to pull from, would be great. Thanks Jens.
Mar
22
comment Alleviating a bottleneck involving a function call with symbolic derivatives
Thank you for your suggestions, Jens. The speed of my implementation is still woefully inadequate, but you were very helpful in pointing out the limited scope of Compile[] and confirming the wisdom of pre-populating matrices for reiterated elements. Unrelated: I love your MathematicaGraphics page, and now for an Honours talk I'm trying to reproduce the appearance of your spherical coordinate system plot using your 3D text labels and vector styles. I don't think mine will look any where near as nice, but thank you for this resource!
Mar
21
comment Alleviating a bottleneck involving a function call with symbolic derivatives
So you are suggesting pre-populating a 2D lookup matrix (say matrixH1) for the SphericalHankel case threaded over my range of l values and a mesh of r values, then calling matrixH1[[l,krIndex]] in each of my AAA/BBB/CCC contributions to mainTerm. And then obviously repeating the process for preallocating the D[] and D[D[]] terms in each of AAA/BBB/CCC. I tried this last week, but it slowed my algorithm down - I assumed this was something to do with the cost of looking up elements in a 4D matrix? I'll try again, more carefully, and see if it was just my implementation.
Mar
21
comment Alleviating a bottleneck involving a function call with symbolic derivatives
Oh... silly me... seeing as SphericalHarmonicY and SphericalHankelH1 do not appear anywhere on that list, I might just be bum out of luck. There has to be a way to speed this up... The loop iterates at least 40 million times and it is taking aeons. Any ideas would be hugely appreciated.
Mar
21
comment Alleviating a bottleneck involving a function call with symbolic derivatives
Thanks for pointing out my inappropriate use of SetDelayed (I thought this was necessary to force evaluation of AAA, BBB & CCC with the new arguments in mainTerm). I just made this change, but unfortunately it does not appear to speed things up appreciably (I'm running a very reduced number of iterations to check speed). Is there an obvious way to pre-compile the spherical harmonics/Hankel function derivatives, and could this improve run time? Thanks!
Mar
21
asked Alleviating a bottleneck involving a function call with symbolic derivatives