help-octave
[Top][All Lists]
Advanced

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

Re: Octave equivalent to A = mxGetPr(prhs[0]);


From: David Bateman
Subject: Re: Octave equivalent to A = mxGetPr(prhs[0]);
Date: Fri, 09 Jun 2006 12:27:53 +0200
User-agent: Mozilla Thunderbird 1.0.6-7.6.20060mdk (X11/20050322)

Fredrik Lingvall wrote:

> David Bateman wrote:
>
>>> Try
>>>
>>> const Matrix Am = args(0).matrix_value();
>>> const double *A = Am.fortran_vec();
>>> octave_idx_type A_M = A.rows();
>>> octave_idx_type A_N = A.cols();
>>>
>>> D.
>>>     
>>
> This works but is Am now a copy of the data?

Am is a copy of the container, not the data. Octave implements copy of
modify for all types. In general the fortran_vec method will make a copy
as giving you a pointer to the data allows you to modify it and octave
can't stop you. The fact that it is matrix is marked as const however,
means that you are promising not to modify it.

> I'm working with really big matrices and do not want to
> copy any data.
>
> Also, I don't want to declare the pointers as const
> since I want to preform in-place operations on the data.
> That is, change the input parameters like, for example,
>
>    A[0] = 1.0;

You are modifying the data, and so a copy will be made if you don't mark
it as const.

Regards
David


>
> This works fine i Matlab.
>
> /F
>


-- 
David Bateman                                address@hidden
Motorola Labs - Paris                        +33 1 69 35 48 04 (Ph) 
Parc Les Algorithmes, Commune de St Aubin    +33 6 72 01 06 33 (Mob) 
91193 Gif-Sur-Yvette FRANCE                  +33 1 69 35 77 01 (Fax) 

The information contained in this communication has been classified as: 

[x] General Business Information 
[ ] Motorola Internal Use Only 
[ ] Motorola Confidential Proprietary



reply via email to

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