help-octave
[Top][All Lists]
Advanced

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

Re: basic DLD help?


From: John W. Eaton
Subject: Re: basic DLD help?
Date: Tue, 12 Jul 2005 23:43:40 -0400

On 13-Jul-2005, David Bateman wrote:

| Even better would be
| 
|    const RowVector y(args(0).vector_value());
|    const double *py = y.fortran_vec();
| 
| since as you say fortran_vec calls make_unique except when "const", and 
| since you aren't altering the data past to the function, in this manner 
| you avoid a copy.

Still better would be

  const RowVector y(args(0).vector_value());
  const double *py = y.data();

because if you are only asking for read-only access, you can use the
const data() method and avoid the call to make_unique().

As I recall, the reason for having different names (fortran_vec and
data) was because it was not possible to overload on const in early
C++ dialects.  Now that it is possible, I suppose we could use just
one name instead of two.

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
-------------------------------------------------------------



reply via email to

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