Opened 10 years ago
Closed 3 years ago
#10613 closed defect (duplicate)
Trouble coercing a vector directly to a matrix
Reported by: | jonhanke | Owned by: | jason, was |
---|---|---|---|
Priority: | minor | Milestone: | sage-duplicate/invalid/wontfix |
Component: | linear algebra | Keywords: | matrix, vector, coercion |
Cc: | was, jonhanke | Merged in: | |
Authors: | Reviewers: | ||
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description
Vector to matrix coercion appears not to work unless going through a list.
sage: v = vector(QQ,[1,2,3]) sage: v (1, 2, 3) sage: type(v) <type 'sage.modules.vector_rational_dense.Vector_rational_dense'> sage: sage: Matrix(QQ, 3,1,v) --------------------------------------------------------------------------- TypeError Traceback (most recent call last) /Users/jonhanke/Documents/SAGE/sage-4.6/<ipython console> in <module>() /Users/jonhanke/Documents/SAGE/sage-4.6/local/lib/python2.6/site-packages/sage/matrix/constructor.pyc in matrix(*args, **kwds) 660 ring = rings.ZZ 661 --> 662 return matrix_space.MatrixSpace(ring, nrows, ncols, sparse=sparse)(entries) 663 664 /Users/jonhanke/Documents/SAGE/sage-4.6/local/lib/python2.6/site-packages/sage/matrix/matrix_space.pyc in __call__(self, entries, coerce, copy, rows) 403 return self(entries.matrix(), copy=False) 404 --> 405 return self.matrix(entries, copy=copy, coerce=coerce, rows=rows) 406 407 def change_ring(self, R): /Users/jonhanke/Documents/SAGE/sage-4.6/local/lib/python2.6/site-packages/sage/matrix/matrix_space.pyc in matrix(self, x, coerce, copy, rows) 1134 x = new_x 1135 -> 1136 return self.__matrix_class(self, entries=x, copy=copy, coerce=coerce) 1137 1138 def matrix_space(self, nrows=None, ncols=None, sparse=False): /Users/jonhanke/Documents/SAGE/sage-4.6/local/lib/python2.6/site-packages/sage/matrix/matrix_rational_dense.so in sage.matrix.matrix_rational_dense.Matrix_rational_dense.__init__ (sage/matrix/matrix_rational_dense.c:5774)() TypeError: entries must be coercible to a list or integer sage: Matrix(QQ, 3,1, list(v)) [1] [2] [3] sage:
Change History (6)
comment:1 Changed 10 years ago by
comment:2 Changed 8 years ago by
- Milestone changed from sage-5.11 to sage-5.12
comment:3 Changed 7 years ago by
- Milestone changed from sage-6.1 to sage-6.2
comment:4 Changed 7 years ago by
- Milestone changed from sage-6.2 to sage-6.3
comment:5 Changed 7 years ago by
- Milestone changed from sage-6.3 to sage-6.4
comment:6 Changed 3 years ago by
- Milestone changed from sage-6.4 to sage-duplicate/invalid/wontfix
- Resolution set to duplicate
- Status changed from new to closed
Fixed in #24742
Note: See
TracTickets for help on using
tickets.
If you leave out the dimensions (which would be inferred from the vector), it is possible to build a matrix from a vector.