Opened 11 years ago

Last modified 11 years ago

#10604 closed defect

Rewrite diagonal matrix constructor — at Version 1

Reported by: rbeezer Owned by: jason, was
Priority: minor Milestone: sage-4.6.2
Component: linear algebra Keywords:
Cc: ddrake Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by rbeezer)

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:

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)
   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

Change History (1)

comment:1 Changed 11 years ago by rbeezer

  • Description modified (diff)
Note: See TracTickets for help on using tickets.