liboctave's NDArray conversion to float array

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

liboctave's NDArray conversion to float array

Robert Brothers
To whom it may concern,

        I am using octave’s C++ compiler/wrapper to generate arrays. I need to store them in a binary dat file for later access. I need to convert the NDArray type to a double array for storage and later use using armadillo. I am having trouble finding a method to convert to a double array or pointer.

What I’m looking for:

        NDArray A = args.array_value();
       
        // convert this value to a double or float array
        float a[] = A.return_NDArray_raw_data();
       
        or
       
        double a[] = A.return_NDArray_raw_data();


Is this possible? (Not this ^^  exactly but some method that makes this possible) Or is there some work around that may be helpful?
_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: liboctave's NDArray conversion to float array

Andreas Weber-6
Am 08.11.2017 um 17:42 schrieb Robert Brothers:

> To whom it may concern,
> What I’m looking for:
>
> NDArray A = args.array_value();
>
> // convert this value to a double or float array
> float a[] = A.return_NDArray_raw_data();
>
> or
>
> double a[] = A.return_NDArray_raw_data();

yes, see the method fortran_vec() which gives you a double* so you can
interate up to numel()

http://octave.org/doxygen/4.2/d0/d26/classArray.html#a67b2e787997a741df610756815ed4f95

-- Andy

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave