help-octave
[Top][All Lists]
Advanced

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

Memory copy or not?


From: John W. Eaton
Subject: Memory copy or not?
Date: Tue, 04 Sep 2007 13:06:02 -0400

On  4-Sep-2007, Fredrik Lingvall wrote:

| I have an oct-file where I do something like:
| 
| Matrix Ymat(M,N);
| Y = Ymat.fortran_vec();
| 
| % Do some stuff here.
| 
|  oct_retval.append(Ymat);
|  return oct_retval;
| 
| Does the operation,
| 
|     oct_retval.append(Ymat);
| 
| copy the data in Ymat

No, copying a Matrix object only increments a reference count.

Copies happen when the count is larger than 1 and you modify elements
or call a method like fortran_vec.  If your call to fortran_vec above
is (as you show) just after the creation of Ymat, then that won't
force a copy.

jwe


reply via email to

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