Changes between Initial Version and Version 10 of Ticket #10876


Ignore:
Timestamp:
03/17/11 15:36:27 (10 years ago)
Author:
kcrisman
Comment:
TypeError: scale must be an element of some ring, not junk 

Nice.

  • To deal with all this in general, couldn't you do something like the following, and then look for for the specific keywords row1, sparse, etc? (And raise an error if any others appear in the dictionary.)
    def elementary_matrix(arg0, arg1=None, **kwds):
    

Yes, much better.

A few programming ideas to make it more tight, though I don't think these are strictly necessary. Take what you want.

  • Couldn't the following just be n<=0, since you catch that later? Then you don't have to worry about the thing later.
    if n < 0: 
        raise ValueError('size of elementary matrix must be positive, not {0}'.format(n)) 
    
  • I'd move the checks like
    if row2 is None and scale is None:
    
    to right after where you turn col1 and col2 into row1 and row2, to improve readability later.
  • I think it might be possible to use simultaneous assignment for what comes after
    elif not row2 is None and scale is None:
    
    in the same way that
    a,b = 2,3
    

works.

Iteration 3 will be the bomb!

Yes?

Code checks out, passes tests, weird input doesn't slow it down...

One more weird result:

sage: elementary_matrix(4,2,row1=1,row2=3)
[1 0 0 0]
[0 0 0 1]
[0 0 1 0]
[0 1 0 0]

If the first argument isn't a ring, you just automatically make the ring the integer ring, the size the first argument, and ignore the second argument. Probably this should be caught. Needs work :(

Oh, and you didn't capitalize a letter:

to determine the representation used.  the default is ``False`` which 

On the plus side, this will have the biggest error test to example ratio ever!

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #10876

    • Property Status changed from new to needs_work
    • Property Reviewers changed from to Karl-Dieter Crisman
    • Property Authors changed from to Rob Beezer
  • Ticket #10876 – Description

    initial v10  
    11Patch adds a matrix constructor to build elementary matrices, which correspond to row operations.  These matrices are very useful when teaching properties of determinants.
     2
     3----
     4Apply attachment:trac_10876-elementary-matrices-v3.patch