Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for matrix numpy-style indexing #2396

Closed
dfdeshom opened this issue Mar 5, 2008 · 2 comments
Closed

add support for matrix numpy-style indexing #2396

dfdeshom opened this issue Mar 5, 2008 · 2 comments

Comments

@dfdeshom
Copy link

dfdeshom commented Mar 5, 2008

Dan Christensen:

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

This is currently not implemented in sage.

Component: linear algebra

Issue created by migration from https://trac.sagemath.org/ticket/2396

@jasongrout
Copy link
Member

comment:2

See #4972, which may fix this.

@sagetrac-mvngu
Copy link
Mannequin

sagetrac-mvngu mannequin commented Oct 1, 2009

comment:3

This has been fixed in Sage 4.1.2.alpha4:

[mvngu@sage sage-4.1.2.alpha4-sage.math]$ ./sage
----------------------------------------------------------------------
| Sage Version 4.1.2.alpha4, Release Date: 2009-09-27                |
| Type notebook() for the GUI, and license() for information.        |
----------------------------------------------------------------------
**********************************************************************
*                                                                    *
* Warning: this is a prerelease version, and it may be unstable.     *
*                                                                    *
**********************************************************************
sage: M = MatrixSpace(QQ, 9)
sage: A = M.random_element(); A

[   1   -2    2    2    0   -2  1/2    1  1/2]
[   0   -1    1    2    2    0    1   -1  1/2]
[ 1/2    2   -1    2  1/2    0   -1    2    1]
[   1   -1   -2    0 -1/2   -1   -1    0    2]
[   0   -1    0    0 -1/2   -2   -1    2    2]
[  -1    1   -1    0    2    0    1    0    1]
[   0    1    0    1 -1/2    1    1    2   -1]
[  -1 -1/2   -1    0   -1    0    0    2    0]
[   0 -1/2   -1    2    1    0    0    0    0]
sage: m = 3
sage: A[:,1] += m * A[:,4]
sage: A

[   1   -2    2    2    0   -2  1/2    1  1/2]
[   0    5    1    2    2    0    1   -1  1/2]
[ 1/2  7/2   -1    2  1/2    0   -1    2    1]
[   1 -5/2   -2    0 -1/2   -1   -1    0    2]
[   0 -5/2    0    0 -1/2   -2   -1    2    2]
[  -1    7   -1    0    2    0    1    0    1]
[   0 -1/2    0    1 -1/2    1    1    2   -1]
[  -1 -7/2   -1    0   -1    0    0    2    0]
[   0  5/2   -1    2    1    0    0    0    0]
sage: 
sage: A[2:4, 3:8] = 0
sage: A

[   1   -2    2    2    0   -2  1/2    1  1/2]
[   0    5    1    2    2    0    1   -1  1/2]
[ 1/2  7/2   -1    0    0    0    0    0    1]
[   1 -5/2   -2    0    0    0    0    0    2]
[   0 -5/2    0    0 -1/2   -2   -1    2    2]
[  -1    7   -1    0    2    0    1    0    1]
[   0 -1/2    0    1 -1/2    1    1    2   -1]
[  -1 -7/2   -1    0   -1    0    0    2    0]
[   0  5/2   -1    2    1    0    0    0    0]
sage: A[:,:] = 0
sage: A

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

Closing this as a duplicate of #4972.

@sagetrac-mvngu sagetrac-mvngu mannequin added r: duplicate and removed p: minor / 4 labels Oct 1, 2009
@sagetrac-mvngu sagetrac-mvngu mannequin closed this as completed Oct 1, 2009
@sagetrac-mvngu sagetrac-mvngu mannequin removed this from the sage-4.1.2 milestone Oct 1, 2009
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants