b .+ 2 creates a new array, which then b is assigned to.

On Friday, May 30, 2014 12:32:00 PM UTC+3, paul analyst wrote:
>
>  I see, but what is the difference between:
>
> b [2,3] = 3 
> and 
> b = b.+2 
>
> Paul
>
>
> W dniu 2014-05-30 10:11, Tomas Lycken pisze:
>  
> @Paul,
>
> Try
>
> julia> a = ones(5,5);
> julia> b = a;
> julia> b[2,3] = 2;
> julia> a == b
> true
>
> On Wednesday, May 28, 2014 9:22:26 PM UTC+2, Jameson wrote: 
>>
>> b+3 is not the same as a (or b, from the prior stage, for that matter). 
>> It doesn't matter whether a and b are numbers or matrices, large or small
>>
>> On Wednesday, May 28, 2014, paul analyst <[email protected]> wrote:
>>
>>> Thx,
>>> I'm surprised. I suspect, and I did: 
>>> a = ones (5,5) 
>>> b = a 
>>> b = b +3 
>>> a == b 
>>> false 
>>> That is not the case for small and large objects? This is not OK :/
>>>
>>> W dniu środa, 28 maja 2014 21:11:12 UTC+2 użytkownik Patrick O'Leary 
>>> napisał: 
>>>>
>>>> > FSbis=FS
>>>>
>>>> This binds the identifier FSbis to the same memory that FS is bound to, 
>>>> so the identifiers are aliases for one another.
>>>>
>>>> If you want FSbis to start out initialized to the same values as those 
>>>> in FS, but be a separate container, use `FSbis = copy(FS)`.
>>>>
>>>> On Wednesday, May 28, 2014 2:07:38 PM UTC-5, paul analyst wrote: 
>>>>>
>>>>>   Code running back? what happens? 
>>>>> I have a array FS 
>>>>>
>>>>>
>>>>> julia> println(sum(FS));
>>>>> 9.8267205e7
>>>>>
>>>>> julia> l,m=size(FS);
>>>>>
>>>>> julia> FSbis=FS;
>>>>>
>>>>> julia>
>>>>>
>>>>> julia>
>>>>>
>>>>> julia> for i=1:l; #println(i)
>>>>>            if w[i]==1 us=hcat(F[i,:]',[1:1:m]);
>>>>>            us=sortrows(us, by=x->x[1],rev=true);
>>>>>                for j=1:m
>>>>>                    if in(us[j,2],Su) FSbis[i,us[j,2]]=us[j,2]; break 
>>>>> end;
>>>>>                end;
>>>>>            end;
>>>>>        end;
>>>>>
>>>>> julia>
>>>>>
>>>>> julia> println(sum(FSbis));
>>>>> 1.03295914e8
>>>>>
>>>>> julia>
>>>>>
>>>>> julia> println(sum(FS));
>>>>> 1.03295914e8
>>>>>
>>>>>
>>>>>  after the code array FSbis changing and well. But the array FS too is 
>>>>> changing! Why? Compare sum(FS) before and after.
>>>>> Paul
>>>>>    
>>>>     
> 

Reply via email to