Will you allow single-argument indexing as well?

The Matlab convention is that indexing using a single argument indexes
vec(A) instead of A.
That's often useful, e.g., to update the diagonal of an nxn matrix,
you could write A[::n+1] = 1.0.

More generally, it allows you to easily update a subset of the
elements in A by writing
A[I] = b  where I is an index-set.   Without single-argument
indexing,  you
would need to write a loop for doing that.

I think I raised the same question on the Scipy list long ago,  and as
I remember it the developers
didn't like the idea. Personally, I like the convention,  and it makes
matrix computions more
flexible than having to use a helper routine for things like that.

Joachim

On Mar 5, 4:21 pm, Dan Christensen <[EMAIL PROTECTED]> wrote:
> "didier deshommes" <[EMAIL PROTECTED]> writes:
> > SAGE now tries to support numpy (and matlab)-style indexing, by poking
> > at its underlying __getitem__ and __getslice__ (thanks to a suggestion
> > by William):
>
> Great!
>
> Another nice feature of numpy is *assigning* using numpy-style indexing.
> For example, to add a multiple of column j to column i, you can do
>
>   A[:,i] += m*A[:,j]
>
> And you can zero out a region with
>
>   A[2:4, 3:8] = 0    (broadcasting used here)
>
> About the efficiency concern raised by William, does it work to first
> assume the indices are not fancy, and if that fails, then catch an
> exception and try to interpret them as numpy-style indices?
>
> Dan
--~--~---------~--~----~------------~-------~--~----~
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://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to