![]() |
Blitz Support : |
From: Patrik (patrik_at_[hidden])
Date: 2004-06-19 16:55:32
At 11:42 AM 6/18/2004 +0100, you wrote:
>I hope someone won't mind helping out with this query. I'm impressed by
>Blitz, especially the way it facilitates numerical programing by taking
>away some of the book keeping necessary using just C++. I'm hoping to
>use Blitz in a Monte Carlo simulation for my PhD, where speed is
>absolutely critical. The central data structure I need is a vector of
Funny, that's exactly what I'm using Blitz for! :-) mine is a Monte Carlo
radiative transfer, what about yours?
>vectors, where both will vary in length. My plan is to use a variable 1D
>array of variable 1D arrays in Blitz++:
>
>Array<Array<int,1>,1>
>
>I'll then use resize(), or resizeAndPreserve() to manipulate the
>structure while the simulation runs. My query is, what sort of overhead
>will the resize operations in Blitz++ inccur? Would it be much faster to
>explicity manage the data structure in C using pointers and the malloc,
>dealloc functions to allocate and deallocate memory for the structure?
>I'm hoping I can use Blitz++ as this would make my code much clearer,
>and much easier to write.
I wouldn't claim to be an expert on this, but my guess would be that
resizing in blitz will be just as slow as doing it explicitly either with
new or malloc. In other words, the overhead incurred by the actual
allocation is likely to be what kills you. If you're really critical about
speed, figure out a way of doing what you need without reallocating, for
example allocate a worst-case scenario and then don't use the extra
space. Also, because of the way you will access memory a structure like
the one you suggest is likely to be slower than just a simple 2D
array. But I guess whether or not that would be feasible depends on how
unequal your row lengths are likely to be....
Anyway, maybe that was helpful...
/Patrik