[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
real/imag part of ComplexMatrix in liboctave
From: |
John W. Eaton |
Subject: |
real/imag part of ComplexMatrix in liboctave |
Date: |
Mon, 5 Feb 2001 16:43:40 -0600 |
On 5-Feb-2001, Maurice Janssen <address@hidden> wrote:
| I have to do some numerical computations in C (using the GMP library),
| but I'd like to call the functions from Octave, so I am using liboctave
| as a wrapper.
|
| The code for the computations returns two matrices, one for the
| real part and one for the imaginary part. I want to return a single
| ComplexMatrix to Octave, but I can't figure out how to assign the data
| to a ComplexMatrix.
|
| Something like:
| ComplexMatrix CM;
| Matrix Mr, Mi;
|
| /* some C-code */
|
| CM.real=Mr;
| CM.imag=Mi;
|
| Can you please tell me how I can accomplish this?
// Assumes conforming Mr, Mi.
nr = Mr.rows ();
nc = Mr.columns ();
ComplexMatrix CM (nr, nc);
for (int j = 0; j < nc; j++)
for (int i = 0; i < nr; i++)
CM(i,j) = Complex (Mr(i,j), Mi(i,j));
As far as I know, this doesn't come up all that frequently in Octave's
source code (if I had needed this functionality a lot, i suppose there
would already be a function to do it).
jwe
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------