Opened 8 years ago

# random_matrix fails with variable reference error

Reported by: Owned by: jason jason, was major sage-6.4 linear algebra rbeezer N/A

sage: random_matrix(QQ,5,algorithm='echelonizable', rank=1,upper_bound=10)
---------------------------------------------------------------------------
UnboundLocalError                         Traceback (most recent call last)
<ipython-input-23-e4c44e36a25b> in <module>()
----> 1 random_matrix(QQ,Integer(5),algorithm='echelonizable', rank=randint(Integer(1),Integer(5)),upper_bound=Integer(10))

/Users/grout/sage-trees/sage-5.9/local/lib/python2.7/site-packages/sage/matrix/constructor.pyc in random_matrix(ring, nrows, ncols, algorithm, *args, **kwds)
1348         return random_rref_matrix(parent, *args, **kwds)
1349     elif algorithm == 'echelonizable':
-> 1350         return random_echelonizable_matrix(parent, *args, **kwds)
1351     elif algorithm == 'diagonalizable':
1352         return random_diagonalizable_matrix(parent, *args, **kwds)

/Users/grout/sage-trees/sage-5.9/local/lib/python2.7/site-packages/sage/matrix/constructor.pyc in random_echelonizable_matrix(parent, rank, upper_bound)
3321                         # Range for scalar multiples determined experimentally.
-> 3322                     if max(map(abs,matrix_copy.list()))<upper_bound:
3323                     # Continue if the the largest entry after a row operation is within the bound.
3324                         matrix=matrix_copy

UnboundLocalError: local variable 'matrix_copy' referenced before assignment

### comment:1 Changed 8 years ago by jason

• Description modified (diff)

### comment:2 Changed 7 years ago by jdemeyer

• Milestone changed from sage-5.11 to sage-5.12

### comment:3 Changed 7 years ago by rbeezer

Rank 1 case (which is subject of report) is fixed as part of current patches up at #11772.

### comment:4 Changed 7 years ago by vbraun_spam

• Milestone changed from sage-6.1 to sage-6.2

### comment:5 Changed 7 years ago by vbraun_spam

• Milestone changed from sage-6.2 to sage-6.3

### comment:6 Changed 6 years ago by vbraun_spam

• Milestone changed from sage-6.3 to sage-6.4
Note: See TracTickets for help on using tickets.