help-octave
[Top][All Lists]
Advanced

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

Re: Passing big data arrays to oct-files


From: Jordi Gutiérrez Hermoso
Subject: Re: Passing big data arrays to oct-files
Date: Tue, 25 Sep 2012 13:23:53 -0400

On 25 September 2012 11:09, Reza Housseini <address@hidden> wrote:
> I want to pass a Matrix from Octave to my C++ script via the oct API.
> My question is now, how can I get an Matrix class into an
> vector<valarray<float> > class?

You can use Array<T>::fortran_vector function for getting a pointer to
the raw data, in colum-major order. Don't use Array<T>::operator() for
looping over the elements of a Matrix since this does checks relating
to COWs that really slow down the looping.

I also don't recommend using C++ valarrays. Their intended use was for
some optimisations that no compiler ever really implemented due to
aliasing problems. If Octave's own array types don't suffice for you,
use another array library like Armadillo or the GNU Scientific Library
in C.

HTH,
- Jordi G. H.


reply via email to

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