[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: extract a row from an NDArray
From: |
Jaroslav Hajek |
Subject: |
Re: extract a row from an NDArray |
Date: |
Tue, 5 May 2009 07:27:58 +0200 |
On Tue, May 5, 2009 at 7:03 AM, c. <address@hidden> wrote:
> Hi,
> What is the best way to extract a row from an NDArray in an .oct file?
> I am looking for a way to translate an m-file containing
>
> w = squeeze(coefs(4,:,:))
>
> into C++.
> Thanks,
> Carlo
>
Indexing by more than two indices requires building an index array
(C++ offers no good way to create methods with arbitrary number of
arguments).
Array<idx_vector> idx(3, idx_vector::colon); idx(0) = 4;
NDArray w = coefs.index (idx).squeeze ();
cheers
--
RNDr. Jaroslav Hajek
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz