[Top][All Lists]

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

Re: How to return a ComplexMatrix from an OCT-file-function?

From: Patrick Boettcher
Subject: Re: How to return a ComplexMatrix from an OCT-file-function?
Date: Tue, 18 Oct 2016 18:35:03 +0200

On Tue, 18 Oct 2016 18:19:44 +0200
Patrick Boettcher <address@hidden> wrote:
> Here is what I get from the following code:
>   DEFUN_DLD(test, args, nargout,
>             "")
>   {
>       Matrix m = ComplexMatrix(8,8);
>       return octave_value(m);
>   }

Just after sending the mail I realized my mistake in my example.

Making it 

    ComplexMatrix m = ComplexMatrix(8,8);
    m = m + Complex(1, 1);
    return octave_value(m);

works as expected.

This was a (too much) reduced test-case of my real-problem. My real
problem is, that I would want to fill up a ComplexMatrix with raw data
read from somewhere and this is where returning a ComplexMatrix has
apparently no imaginary data:

I did (pseudo-code)

   double *r = get_complex_double(8,8);
   ComplexMatrix m = ComplexMatrix(8,8);
   memcpy(m.fortan_vec(), r, sizeof(std::complex<double) * 8 * 8);
      /* memcpy is not what I do in reality */
   return octave_value(m);

is this the right way to proceed?


reply via email to

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