From help-octave-request at bevo dot che dot wisc dot edu Thu Dec 19 18:56:54 2002 Subject: Re: A bit puzzled... From: Al Niessner To: Paul Kienzle Cc: Octave Help Date: 19 Dec 2002 19:58:43 -0500 It all works now. Apparently 25 years away from Fortran made my code a little error prone. I octave with ddd (gdb front end basically) and was able to find the problem in no time. It was in my code -- obviously. Thank you for your help and patience. Al Niessner On Wed, 2002-12-18 at 23:55, Paul Kienzle wrote: > > ----- Original Message ----- > From: "Albert F. Niessner" > To: "Paul Kienzle" > Cc: "Octave Help" > 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 > > (http://www.octave.org/mailing-lists/help-octave/2002/1164), you wrote: > > "The data is not actually copied until you do A.fortran_vec() to access > > the data for modification." > > > > However, in the other > > (http://www.octave.org/mailing-lists/help-octave/2002/1163) 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)(A.data(),B.data(),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 > other > 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 > pkienzle at users dot sf dot net > > > > ------------------------------------------------------------- > 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 > ------------------------------------------------------------- > ------------------------------------------------------------- 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 -------------------------------------------------------------