Martijn Brouwer wrote:
> Hi,
> I would like to create an octave matrix (of uint16) from an C++ array,
> but there is apparently no constructor that accepts this:
>
> unsigned a[11];
> for(int i=0; i<11; i++)
> { a[i]=i;
> }
> uint16NDArray A(a,11);
>
> Do I have to loop over all elements or is there a quicker way?
>
No you have to loop over the elements.. However you can access the
*uint16 of the array itself with something like
uint16NDArray A (dim_vector(11,1));
const uint16 *cp = A.fortran_vec();
uint16 *p = A.fortran_vec ();
Note the const version is useful if "A" comes from somewhere else in
Octave and you'll only be reading the data. You can avoid a copy of A
internally in Octave in that way if the reference point to the
underlying data of "A" is greater than 1.
D.
--
David Bateman [email protected]
35 rue Gambetta +33 1 46 04 02 18 (Home)
92100 Boulogne-Billancourt FRANCE +33 6 72 01 06 33 (Mob)
------------------------------------------------------------------------------
_______________________________________________
Octave-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/octave-dev