#10604: Rewrite diagonal matrix constructor
-------------------------------------+--------------------------------------
Reporter: rbeezer | Owner: ddrake
Type: defect | Status: positive_review
Priority: minor | Milestone: sage-4.6.2
Component: linear algebra | Keywords:
Author: Rob Beezer, Dan Drake | Upstream: N/A
Reviewer: Dan Drake, Rob Beezer | Merged:
Work_issues: |
-------------------------------------+--------------------------------------
Changes (by newvalueoldvalue):
* status: needs_review => positive_review
* reviewer: Dan Drake => Dan Drake, Rob Beezer
* author: Rob Beezer => Rob Beezer, Dan Drake
Old description:
> Diagonal matrix constructor fails when given a tuple, and there is a
> request to support numpy arrays as input. This seems easiest to
> accomplish with a re-write and documentation upgrade.
>
> `NumPy` array request:
> http://groups.google.com/group/sage-
> devel/browse_thread/thread/f0ecd06fcf9efb1b
>
> {{{
> sage: diagonal_matrix( (1,2,3) )
> ---------------------------------------------------------------------------
> ValueError Traceback (most recent call
> last)
>
> /home/sage/sage-4.6.1.rc1/devel/sage-main/<ipython console> in <module>()
>
> /home/sage/sage-4.6.1.rc1/local/lib/python2.6/site-
> packages/sage/matrix/constructor.pyc in diagonal_matrix(arg0, arg1, arg2,
> sparse)
> 1271
> 1272 if ring is None:
> -> 1273 return matrix(nrows, nrows, w, sparse=sparse)
> 1274 else:
> 1275 return matrix(ring, nrows, nrows, w, sparse=sparse)
>
> /home/sage/sage-4.6.1.rc1/local/lib/python2.6/site-
> packages/sage/matrix/constructor.pyc in matrix(*args, **kwds)
> 577 ncols = len(args[0]) // nrows
> 578 elif ncols != len(args[0]) // nrows:
> --> 579 raise ValueError, "entries has the wrong
> length"
> 580 elif len(args[0]) > 0:
> 581 raise ValueError, "entries has the wrong
> length"
>
> ValueError: entries has the wrong length
> }}}
>
> '''Apply:'''
>
> * attachment:trac_10604-diagonal-matrix-constructor-v2.patch
> * attachment:trac_10604_fix_matrix_stack
New description:
Diagonal matrix constructor fails when given a tuple, and there is a
request to support numpy arrays as input. This seems easiest to
accomplish with a re-write and documentation upgrade.
`NumPy` array request:
http://groups.google.com/group/sage-
devel/browse_thread/thread/f0ecd06fcf9efb1b
{{{
sage: diagonal_matrix( (1,2,3) )
---------------------------------------------------------------------------
ValueError Traceback (most recent call
last)
/home/sage/sage-4.6.1.rc1/devel/sage-main/<ipython console> in <module>()
/home/sage/sage-4.6.1.rc1/local/lib/python2.6/site-
packages/sage/matrix/constructor.pyc in diagonal_matrix(arg0, arg1, arg2,
sparse)
1271
1272 if ring is None:
-> 1273 return matrix(nrows, nrows, w, sparse=sparse)
1274 else:
1275 return matrix(ring, nrows, nrows, w, sparse=sparse)
/home/sage/sage-4.6.1.rc1/local/lib/python2.6/site-
packages/sage/matrix/constructor.pyc in matrix(*args, **kwds)
577 ncols = len(args[0]) // nrows
578 elif ncols != len(args[0]) // nrows:
--> 579 raise ValueError, "entries has the wrong
length"
580 elif len(args[0]) > 0:
581 raise ValueError, "entries has the wrong
length"
ValueError: entries has the wrong length
}}}
'''Apply:'''
* attachment:trac_10604-diagonal-matrix-constructor-v2.patch
* attachment:trac_10604_fix_matrix_stack
Depends: #10626
--
Comment:
Replying to [comment:20 ddrake]:
> Can someone who knows the matrix code take a look at my patch? All
doctests pass with the two patches here applied to 4.6.2.alpha2.
Dan's patch looks good and with it, all tests pass. So I'll flip this
back to positive review.
Thanks, Dan.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/10604#comment:23>
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.