help-octave
[Top][All Lists]
Advanced

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

index() function in the C++ API


From: mpuglia
Subject: index() function in the C++ API
Date: Fri, 31 May 2013 06:49:12 -0700 (PDT)

Hi,

I have a quick question here.  I'm trying to implement generally the
following in C++ in an Oct file:

a = [1 2 3; 4 5 6; 7 8 9];
idx = [3; 1; 2];
b = a(:,idx);
b =

   3   1   2
   6   4   5
   9   7   8

Using a for loop to do the reindexing even in C++ seems a bit slow (when
working with much larger matrices). I was looking around the API and found
what looks to be the faster implementation in idx-vector.h.  The function

octave_idx_type index (const T *src, octave_idx_type n, T *dest)

looks like what I want, but I can't quite figure out the syntax of what I
want to do from the headers.  I have data in a 8x20,000 Matrix "a"  and a
20,000x1 reindexing Matrix "idx" that holds column indices in an arbitrary
order.  Can someone please give me a few pointers on setting up the
idx_vector, Array<idx_vector> etc. that I will need to implement this?

Thanks in advance,

Mike

  




--
View this message in context: 
http://octave.1599824.n4.nabble.com/index-function-in-the-C-API-tp4653527.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

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