#10876: Create elementary matrices
-----------------------------------+----------------------------------------
Reporter: rbeezer | Owner: jason, was
Type: enhancement | Status: needs_review
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 rbeezer):
* status: needs_work => needs_review
Comment:
Replying to [comment:8 kcrisman]:
> First, illegal/unwanted input.
>
> * This should be caught. Though see my comments below about keywords
versus arguments.
> {{{
> sage: E = elementary_matrix(ZZ, 5, row1=3, col2=3, scale=12)
> sage: E
> [ 1 0 0 0 0]
> [ 0 1 0 0 0]
> [ 0 0 1 0 0]
> [ 0 0 0 12 0]
> [ 0 0 0 0 1]
> }}}
>
Now a doctest, raises an error.
> * Here is a similar example from your own doctests. Either we require
named arguments, or we don't; this is confusing.
Just forgot these, now fixed.
> * 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.
> * An example with a negative scale would be nice, though certainly not
necessary. Similarly with a rational scale, so that people know it's ok
to do so (the doctests scare one away from it):
> {{{
> sage: elementary_matrix(4,row1=3,row2=2,scale=-4)
> sage: elementary_matrix(QQ,4,row1=3,row2=2,scale=4/3)
> }}}
Changed one doctest over QQ to a scale factor of 1/2. Did not add a
negative.
> * Other possibilities I don't use, but might be fun if they are
intended behavior, which I presume they are:
> {{{
> sage: elementary_matrix(SR,4,row1=3,row2=2,scale=sqrt(3))
> sage: elementary_matrix(SR,4,row1=3,row2=2,scale=i)
> sage: elementary_matrix(CC,4,row1=3,row2=2,scale=i)
> }}}
Several different rings appear when testing automated ring defaults.
> * The following is something people DO use, though, all the time in
Gaussian elimination say, and will wonder why it gives an error:
> {{{
> sage: sage: elementary_matrix(4,row1=3,scale=4/3)
>
---------------------------------------------------------------------------
> TypeError: scale parameter of elementary matrix must an element of
> Integer Ring, not 4/3
> }}}
> You should be able to massage the default ring so that if there IS a
scale keyword, its parent chooses the ring:
> {{{
> sage: elementary_matrix(parent(4/3),4,row1=3,scale=4/3)
> [ 1 0 0 0]
> [ 0 1 0 0]
> [ 0 0 1 0]
> [ 0 0 0 4/3]
> }}}
This is working now, see new doctests.
> Iteration 3 will be the bomb!
Yes?
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/10876#comment:9>
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.