[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

3D array index as the element itself?

From: Temp Orary
Subject: 3D array index as the element itself?
Date: Thu, 19 Apr 2007 05:05:25 +0900

I'm a user using octave not on a daily basis but only sparcely. Something came up to me that I believe is very easy to vectorize (if you are a frequent user of octave) but it's not so obvious to me. So here it is:

for i=1:3
 for j=1:3
   for k=1:3
     r(i,j,k, 1)=i;
     r(i,j,k, 2)=j;
     r(i,j,k, 3)=k;

Namely, in 3D grid space, r(i,j,k, 1) extracts and assigns to itself the x-axis index, r(i,j,k, 2) the y-axis index, and so forth. First I thought it'd be very easy to convert this loop into one vectorized expression, but now it's just confusing. For 3x3x3 loop, this is not a problem but when it becomes something like 512x512x512, this loop seems to take forever. Any idea, friends?

편리한 웹하드가 최대 1G 까지 무료!

reply via email to

[Prev in Thread] Current Thread [Next in Thread]