[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: fortran_vec() vs data() - very first element is lost
From: |
Mike Miller |
Subject: |
Re: fortran_vec() vs data() - very first element is lost |
Date: |
Mon, 24 Oct 2016 08:59:30 -0700 |
User-agent: |
NeoMutt/20161014 (1.7.1) |
On Mon, Oct 24, 2016 at 16:07:18 +0200, Patrick Boettcher wrote:
> Hi list,
>
> I'm still working in an .oct-file to get in and out complex and
> double matrices.
>
> I noticed something strange which makes me wonder whether I really got
> it correctly:
>
> I read here
>
>
> https://www.gnu.org/software/octave/doc/v4.0.1/Matrices-and-Arrays-in-Oct_002dFiles.html
>
> that I should use the method fortran_vec() to get to the raw-buffer.
>
> It seems I'm using it correctly to fill data into a matrix returned by
> my oct-function. However, when using this method to access the data of
> a matrix given to my function as an argument the very first element
> contains garbage:
You may have found a bug with this example. I get the same bad result as
you, but other small variations on this theme give the correct values.
Try
auto matrix = args(0).complex_matrix_value ();
auto fdata = matrix.fortran_vec ();
auto data = matrix.data ();
or
octave_stdout << args(0).complex_matrix_value ().fortran_vec ()[0];
Both of these give me the correct value in the zeroth index.
If you continue to get the wrong value, please report on the bug tracker
(and investigate a little deeper or provide a patch if you can).
> When injecting data into octave I'm using fortran_vec() to get access
> to the raw-buffer. Displaying the matrix in octave shows the first
> element to be correctly set.
Yes, this is the right way to write copy external data into a matrix.
--
mike