#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
Comment:
Nice addition of the column stuff/doc.
This functionality would be especially valuable as an interact - you
choose the elementary matrix type, the row1, row2, scale, and it creates
the matrix - or, better, changes the unit circle or a pair of vectors
*based* on your elementary matrix. If only we could get interact controls
to depend on other interact controls... (yes, there is a ticket for this)
Holes coming up!
----
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]
}}}
* Here is a similar example from your own doctests. Either we require
named arguments, or we don't; this is confusing.
{{{
sage: elementary_matrix(QQ, 1, 0, 0)
[1]
}}}
* This still works, which it probably shouldn't at all:
{{{
sage: elementary_matrix(4,3,3,3)
[1 0 0 0]
[0 1 0 0]
[0 0 1 0]
[0 0 0 1]
}}}
* 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):
}}}
I think this would make checking for illegal cases easier, too.
----
Then, examples and tests which could be useful.
* 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)
}}}
* 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)
}}}
* 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]
}}}
----
Iteration 3 will be the bomb!
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/10876#comment:8>
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.