# HG changeset patch
# User Jason Grout <jasonsage@creativetrax.com>
# Date 1218844983 18000
# Node ID 8f16ef06b1a85823913a55d29f2c0662976069b0
# Parent ae243fa83947454694c539f374acabbe5ab5a2b1
[mq]: trac3704diagonal_matrix2.patch
diff r ae243fa83947 r 8f16ef06b1a8 sage/matrix/constructor.py
a

b


696  696  [0 0 3] 
697  697  sage: a.parent() 
698  698  Full MatrixSpace of 3 by 3 dense matrices over Rational Field 
 699  sage: a = diagonal_matrix(v, sparse=True); a 
 700  [1 0 0] 
 701  [0 2 0] 
 702  [0 0 3] 
 703  sage: a.parent() 
 704  Full MatrixSpace of 3 by 3 sparse matrices over Rational Field 
699  705  """ 
700  706  
701  707  args = list(args) 
… 
… 

708  714  # Because we specify the diagonal entries as a dictionary, 
709  715  # matrix() wants to default to sparse. We want dense as a default, 
710  716  # though, so we have to specifically test for the sparse keyword. 
711   sparse = kwds.pop('sparse',False) 
712   kwds['sparse'] = sparse 
 717  kwds.setdefault('sparse', False) 
713  718  
714  719  # If the first item in args is a list or tuple, use that as the diagonal 
715  720  # Otherwise, assume that the entire list is the diagonal. 