#10876: Create elementary matrices
-----------------------------------+----------------------------------------
Reporter: rbeezer | Owner: jason, was
Type: enhancement | Status: needs_work
Priority: minor | Milestone: sage-4.7
Component: linear algebra | Keywords:
Author: Rob Beezer | Upstream: N/A
Reviewer: Karl-Dieter Crisman | Merged:
Work_issues: |
-----------------------------------+----------------------------------------
Changes (by kcrisman):
* status: needs_review => needs_work
Old description:
> Patch adds a matrix constructor to build elementary matrices, which
> correspond to row operations. These matrices are very useful when
> teaching properties of determinants.
New description:
Patch adds a matrix constructor to build elementary matrices, which
correspond to row operations. These matrices are very useful when
teaching properties of determinants.
----
Apply attachment:trac_10876-elementary-matrices-v3.patch
--
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!
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/10876#comment:10>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.