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 14:14:18 +0200
User-agent: Mozilla Thunderbird 1.0.6-7.6.20060mdk (X11/20050322)

Fredrik Lingvall wrote:

> David Bateman wrote:
>
>>
>>>   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
>>
>>  
>>
> Thanks!
>
>  const Matrix tmp = args(0).matrix_value();
>   //A_M = mxGetM(prhs[0]);
>   A_M = tmp.rows();
>   //A_N = mxGetN(prhs[0]);
>   A_N = tmp.cols();
>   //A = mxGetPr(prhs[0]);
>   A = (double*) tmp.fortran_vec();
>
> Solved my problem.

Yes, but the last line probably made a copy of the data with this last
line with the cast to (double *)!! Try adding A.print_info() after and
see what value rep->count has... If it is "1" you've made a copy..

D.


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