From help-request at octave dot org Tue Feb 1 10:10:40 2005 Subject: Re: ND arrays again From: David Bateman To: Brian Blais Cc: help at octave dot org Date: Tue, 01 Feb 2005 17:11:59 +0100 Brian Blais wrote: > Hello, > > I've been trying to decypher the octave class code for this, but I am > having trouble. Would someone be able to send me a simple example of > C++ code to do the following: > > pass in a 3 dimensional matrix, and return a 2-dimensional matrix with > the value comparable to the octave line: var(5:15,3:8,3) > > > this would help me a lot! > > > thanks in advance, > > Brian Blais > With no testing whatsoever, I believe something like NDArray m = args(0).array_value(); Array idx (3); idx(0) =idx_vector (Range (5., 15.)) idx(1) = idx_vector (Range (3., 8.)); idx(2) = idx_vector (3); NDArray ret = m.index (idx, 0); is probably what you want. D. -- David Bateman David dot Bateman at motorola dot com Motorola CRM +33 1 69 35 48 04 (Ph) Parc Les Algorithmes, Commune de St Aubin +33 1 69 35 77 01 (Fax) 91193 Gif-Sur-Yvette FRANCE The information contained in this communication has been classified as: [x] General Business Information [ ] Motorola Internal Use Only [ ] Motorola Confidential Proprietary ------------------------------------------------------------- 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 -------------------------------------------------------------