Re: Converting v[3,N] to vx[N], vy[N], vz[N] without additionalmemory [message #19883] |
Tue, 02 May 2000 00:00 |
John-David T. Smith
Messages: 384 Registered: January 2000
|
Senior Member |
|
|
Ricardo Fonseca wrote:
>
> Hi everyone
>
> I need to transform an array v[3,Nx,Ny,Nz] to three arrays vx[Nx,Ny,Nz],
> vy[Nx,Ny,Nz], vz[Nx,Ny,Nz] for use with the interpolate function. The simple
> way to do it is
>
> vx = reform(v[0,*,*,*])
>
> and so on, and then freeing the memory used by v. But the problem is v is a
> very large (>180 Mb) array so the additional memory needed to do this
> becomes a problem. Is there another way of doing this, that doesn't require
> additional memory?
Trace it upstream to the creation of v, and, if you can, modify it to be in 3
separate cubes instead of a single hypercube. If you'd like to keep it all neat
and avoid having separate variables carried around, make v[3] a list of 3
pointers to heap data containing each cube. Then *v[0],*v[1],*v[2] yield the
three. Be sure to free the pointers when necessary to avoid a major memory
leak. It's possible you don't have control of how v is created, but this is the
most straightforward route.
JD
--
J.D. Smith |*| WORK: (607) 255-5842
Cornell University Dept. of Astronomy |*| (607) 255-6263
304 Space Sciences Bldg. |*| FAX: (607) 255-5875
Ithaca, NY 14853 |*|
|
|
|