On Jun 20, 2007, at 10:41 , didier deshommes wrote:

>
> On 6/20/07, Marshall Hampton <[EMAIL PROTECTED]> wrote:
>> I now want to do some loops and update certain entries of the matrix.
>> But the entries seem immutable, e.g. one can do:
>>
>> my_matrix[0][0] += 1
>>
>> and the entry is still zero, although no exception seems to be  
>> raised.
>>
>> So my question is, how can one manipulate individual matrix entries?
>
> To update entries, you should use the [i,j] notation instead of [i] 
> [j]:
> {{{
> sage: my_matrix = matrix(3,10, [0r for x in range(30)])
> sage: my_matrix[0,0]=1
> sage: my_matrix
> [1 0 0 0 0 0 0 0 0 0]
> [0 0 0 0 0 0 0 0 0 0]
> [0 0 0 0 0 0 0 0 0 0]
> }}}
>
> I don't know why you can use one notation and not the other but I'm
> sure theare are more knowledgeable Matrix people here :)

Without pawing through the code, I think that "my_matrix[0]" results  
in a copy, so the 0th element of that copy is set to 1 (in your  
example).  Because you don't do anything with it after the  
assignment, it just evaporates :-}.

Justin

--
Justin C. Walker, Curmudgeon-At-Large
Institute for the Enhancement of the Director's Income
--------
When LuteFisk is outlawed,
Only outlaws will have LuteFisk
--------




--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to