[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[] indexing of Array type.
From: |
John W. Eaton |
Subject: |
[] indexing of Array type. |
Date: |
Mon, 21 Nov 2005 13:24:34 -0500 |
On 21-Nov-2005, Quentin Spencer wrote:
| I'm writing a function in C that I would like to make available to an
| other program without requiring the octave headers, so I'm writing an
| octave wrapper around it. I'd like to be able to create an octave array
| of the size I want, and then pass a pointer to the data within the array
| to the external function so that the external function does not require
| octave headers. I have been able to do something like this:
|
| RowVector x(SIZE);
| const double* y=x.data();
| external_func(y);
|
| However, this gives read-only access to the data (it won't compile
| unless y is declared as a const double*). Suppose I want to create an
| external_func(const double* y, double* z) that takes y as input, and
| puts values in z. The only way I've successfully done this so far is by
| creating the array and then copying the results into an octave Array
| type in the wrapper function, which seems like unnecessary overhead. Is
| there any way I can just access the pointer directly using the data
| member function without making the declaration a const?
You want the fortran_vec() method instead of data(). That will also
ensure that the reference count of the data you are passing is just one.
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
-------------------------------------------------------------