Yes, the callable could create only a few non-zero entries. And only the non-zero entries are retained in the SparseMatrix so it is reasonable to keep that code:
>>> SparseMatrix(3,3,lambda i,j: 1 if i==j else 0) [1, 0, 0] [0, 1, 0] [0, 0, 1] >>> _._smat {(0, 0): 1, (1, 1): 1, (2, 2): 1} Again, the "else" part allows dense input that has few entries to be stored in a compact way so there's no reason to disallow it AFAICT: >>> SparseMatrix([[0,0,1],[0,0,1]]) [0, 0, 1] [0, 0, 1] >>> _._smat {(1, 2): 1, (0, 2): 1} >>> SparseMatrix(3,3,lambda i,j: 1 if i==j else 0) (The bugginess that Aaron refers to is perhaps refering to the former state of SparseMatrix; I think things are currently in pretty good shape.) -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sympy+unsubscr...@googlegroups.com. To post to this group, send email to sympy@googlegroups.com. Visit this group at http://groups.google.com/group/sympy?hl=en-US. For more options, visit https://groups.google.com/groups/opt_out.