j***@gmail.com
2015-07-31 23:05:09 UTC
Hi All:
I have a 3-d array (Float64), call it q, with dimensions (d1, d2, d3)
that needs to be to changed to an array, call it Q, with dimensions (d2,
d3, d1) to perform several computations.
I have tried using the reshape command but that does not respect the first
dimension (row) of the q array becoming the third dimension of the array Q.
The only solution I have found is to define an array Q = Array(Float64, d2,
d3, d1).
Next, create
q1 = squeeze(q[1,:,:],1)
q2 = squeeze(q[2,:,:],1)
...
qd1 = squeeze(q[d1,:,:],1)
and then set
Q[1,:,:] = q1
Q[2,:,:] = q2
...
Q[d1,:,:] = qd1.
Although this "works," it seems neither elegant nor efficient code. Also,
these computations are within a particle filter simulator in which d1 = 7,
but d2 = 180, and d3 >= 20,000.
Suggesting my solution will slow the simulations.
Your advice/suggestions are appreciated.
Thanks.
Jim Nason
I have a 3-d array (Float64), call it q, with dimensions (d1, d2, d3)
that needs to be to changed to an array, call it Q, with dimensions (d2,
d3, d1) to perform several computations.
I have tried using the reshape command but that does not respect the first
dimension (row) of the q array becoming the third dimension of the array Q.
The only solution I have found is to define an array Q = Array(Float64, d2,
d3, d1).
Next, create
q1 = squeeze(q[1,:,:],1)
q2 = squeeze(q[2,:,:],1)
...
qd1 = squeeze(q[d1,:,:],1)
and then set
Q[1,:,:] = q1
Q[2,:,:] = q2
...
Q[d1,:,:] = qd1.
Although this "works," it seems neither elegant nor efficient code. Also,
these computations are within a particle filter simulator in which d1 = 7,
but d2 = 180, and d3 >= 20,000.
Suggesting my solution will slow the simulations.
Your advice/suggestions are appreciated.
Thanks.
Jim Nason