[Top][All Lists]

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

Re: A bit puzzled...

From: Paul Kienzle
Subject: Re: A bit puzzled...
Date: Wed, 18 Dec 2002 23:55:06 -0500

----- Original Message -----
From: "Albert F. Niessner" <address@hidden>
To: "Paul Kienzle" <address@hidden>
Cc: "Octave Help" <address@hidden>
Sent: Wednesday, December 18, 2002 3:19 PM
Subject: A bit puzzled...

> Thanks for your responses to my posts, but your replies have me a bit
> puzzled.
> In one of them
> (, you wrote:
> "The data is not actually copied until you do A.fortran_vec() to access
> the data for modification."
> However, in the other
> ( you wrote:
> "If the operation is not in place, or if you need a working vector,
> allocate it beforehand:
>     octave_value_list retval;
>     const Matrix A(args(0).matrix_value());
>     const Matrix B(args(1).matrix_value());
>     Matrix C(A.rows(),B.columns());
>     F77_FUNC(f,F)(,,C.fortran_vec());
>     retval(0) = C;
>     return retval;"
> But, if the data is being copied at the C.fortran_vec() routine, then
> retval(0) = C cannot possibly contain the answer.

I should have said that C.fortran_vec() checks the reference count for the
data in matrix C, and if it is greater than 1, allocates new data for C,
copies the values from the old data to the new data and decrements the
reference count in the old data.  C.fortran_vec() does not return a copy
of the data --- it returns the real data but with the assurance that no
matrix is referencing it.  That way when you change the data directly, you
can be sure that no matrices other than C are affected.

Does this help?

Paul Kienzle

Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:
How to fund new projects:
Subscription information:

reply via email to

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