help-octave
[Top][All Lists]
Advanced

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

Oct Indexing of individual elements in an NDArray


From: John Weatherwax
Subject: Oct Indexing of individual elements in an NDArray
Date: Thu, 13 Apr 2006 08:21:40 -0500
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.11) Gecko/20050729

Hello,
I would like to be able to access the individual elements in an NDArray (to fill them with another function) but have been unable to figure out how to make this work. I'm sure this is an easy answer but could someone point me in the correct direction?

 Effectively I need code like the following

 dim_vector dvp(NPDE,NX,NY); // dimension of each solution page
 // declare the NDArray to be filled (u T(ime) S(tep) solution):
 NDArray uTS( dvp );

   for( int ix=0; ix < NX; ix++ ){
     for( int iy=0; iy < NY; iy++ ){
     // Compute the data used to fill the NDArray ...
ColumnVector uinit_out = pdetwo_uinit_function( xbkpt(ix), ybkpt(iy) );
     // Fill the NDArray:
     for( int ip=0; ip < NPDE; ip++ ){
uTS(ix,iy,ip) = uinit_out(ip); // <- this line is not correct? How do?
     }
   }
 }

 BTW, I have tried something like the following:

 // Fill uTS with the initial conditions (for convenience):
 for( int ix=0; ix < NX; ix++ ){
   for( int iy=0; iy < NY; iy++ ){
ColumnVector uinit_out = pdetwo_uinit_function( xbkpt(ix), ybkpt(iy) );
     //octave_stdout << "..." << uinit_out << "\n";
     for( int ip=0; ip < NPDE; ip++ ){
     Array<idx_vector> idx(3);
     idx(0)=idx_vector(ip);
     idx(1)=idx_vector(ix);
     idx(2)=idx_vector(iy);
     uTS.index(idx,2.0);
     }
   }
 }

Sorry for my ignorance and I would be very appreciative of any light anyone could shed on this simple problem.

Thanks,

John Weatherwax

--

John L. Weatherwax

Lincoln Laboratory, Massachusetts Institute of Technology
244 Wood Street
Lexington, MA 02420-9108 USA

Phone : 781-981-5370
Fax   : 781-981-4739
Email : address@hidden

%--



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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