1) Your Matlab code is not doing exactly the same as the Julia code
2) The answer to your question about the difference between timings and
looped timings can be seen from these two lines
0.000565 seconds (13 allocations: 1.603 MB)
>
>
3.205262 seconds (118.99 k allocations: 15.651 GB, 14.08%
Thanks for the research. I also did some testing with the original code and
to me it seems like the problem has nothing to do with the interpolation
method but with the memory allocation. Matlab is just faster because it
doesn't reallocate memory in every iteration, as you said. It also explains
Hi
I attached the code I used and timings I get.
I used MSpline. If Dierckx is used my changes will be
less visible in timings since interpolations
take much more time.
Regards
splinetry.jl
Description: Binary data
4.728200 seconds (197.23 k allocations: 5.225 GB, 10.38% gc time)
3.798389 s
I found that reducing memory allocation in the loop does not do much in
terms of speed.
E.g. when doing something like
xx = xprime[:]
the timing difference between
sql(xprime[:]) and sql(xx)
is only about 5%. so my guess is most of the time is just
spent inside the sql() function call and t
I tried this examples. It only improves if xprime is not allocated over and
over. Instead, try fill!(xprime,1.0) for ones(...). Also, colon indexing
xprime[:] allocates memory. Instead, you can use reinterpret/reshape. In real
code, xprime should not be re-allocated with ones method.
You can upd
I did not pay attention to stackoverflow post. There all code is wrapped around
a function for some.
However, I was talking about examples here as in
for banana=1:NoIter
xprime=ones(Nalal,Naa)
W_temp = spl(xprime[:])
end
If all code run as it shown in the example here th
Ok. My original code certainly spends most of the time on looping the
interpolation. In that sense, the example I post here is similar to the
original code and hightlights the problem I am facing I think. Fwiw, I wrap
the original code in a function. I also do it above, at least for the
perform
When I say Dierckx isn't a bottleneck for me, I mean my own code spends
most of its time doing things other than interpolation, like solving
non-linear equations and other calculations. All your loop does is
interpolate, so there it must be the bottleneck.
For the expectation, you can reuse th
My understanding is that it's fine to read the text & mathematical description,
but you shouldn't look at the code.
Best,
--Tim
On Saturday, January 30, 2016 10:02:25 AM Isaiah Norton wrote:
> > Numerical Recipes in C: The Art of Scientific Computing, 2nd edition.
>
> Please note that code deri
>
> Numerical Recipes in C: The Art of Scientific Computing, 2nd edition.
Please note that code derived from this book cannot be included in BSD,
LGPL, or GPL licensed libraries (which is to say, most Julia packages).
Distribution is restricted to compiled binaries only, with commercial and
non-c
If you do not change length of xprime or use it later for another purposes then
just update existing array instead of re-allocating each time. Also, using
global variables in the innermost loop is very inefficient in Julia.
It would be good to revise the code in the light of this tips from docs
@Tomas: maybe check out Numerical Recipes in C: The Art of Scientific
Computing, 2nd edition. There is also an edition for Fortran. The code that
I use in C is basically from there.
@Andrew: The xprime needs to be in the loop. I just made it ones to
simplify but normally it changes every itera
I'd love to add non-uniform interpolation schemes of higher degree than linear
to Interpolations.jl - the two main reasons for why it hasn't been done already
are time (focus has been on reaching feature parity with Grid.jl, for which the
package started out as a replacement effort) and knowledg
Your loop has a ton of unnecessary allocation. You can
move xprime=ones(Nalal,Naa) outside the loop.
Also, you are converting xprime to a vector at every iteration. You can
also do this outside the loop.
After the changes, I get
julia> include("test2.jl");
WARNING: redefining constant lib
3.7
14 matches
Mail list logo