Here is a kluge that is closer to what I want. Can be copied into and run in a Sage cell. The deficiency in the construction is on lines 6-8 (within commented section).
class PoolingMatrix(sage.matrix.matrix_integer_dense.Matrix_integer_dense): # Example construction: # a = matrix(ZZ, [[1,1],[2,2]]) # m=PoolingMatrix(parent(a), [1,2,3,4], False, False) # # But the construction above is silly. You have to make a matrix of same dimensions and get its parent before # constructing the matrix you want. # I would prefer these construction capabilities: # m = PoolingMatrix(ZZ, [[1,0,0],[0,1,0]]) # m = PoolingMatrix(ZZ, 2, [1,0,0,0,1,0]) # m = PoolingMatrix(ZZ, 2, 3, [1,0,0,0,1,0]) # And since the ring is always ZZ, maybe the ZZ argument should be optional. def __init__(self, parent, data, arg1, arg2): print data sage.matrix.matrix_integer_dense.Matrix_integer_dense.__init__(self, parent, data, arg1, arg2) self.d_lower_bound = -1 # parent class, maybe dense integer matrices, provides the method ncols() self.d_upper_bound = self.ncols() a = matrix(ZZ, [[1,1],[2,2]]) m=PoolingMatrix(parent(a), [1,2,3,4], False, False) print m.ncols() On Wednesday, June 5, 2013 10:09:55 AM UTC-7, Rob wrote: > > Thanks for the responses. Probably the answer is I don't know what > __init__ method to call within the inheriting __init__ method. > > Maybe I'd like to say: > > class PoolingMatrix(parent_class): > def __init__(self, ring_arg, 2D_list_arg): > parent_class.__init__(self, ring_arg, 2D_list_arg) > self.my_variable1 = ... > self.my_variable2 = ... > > I'm getting confused by what's a class, what's a constructor, what's a > parent going into a Matrix_integer_dense.__init__ call, etc. (this is for > example, not saying Matrix_integer_dense is right). I do know that I want > dense integer matrices of whatever shape the the 2D_list_arg determines. > > I'd like to know what to put in for parent_class in both places above, and > whether the same thing goes in both places. > > Thanks, > Rob > > > > On Wednesday, June 5, 2013 9:37:01 AM UTC-7, David Roe wrote: >> >> Are you calling some_matrix_thingy.__init__ inside your __init__ method? >> David >> >> >> On Tue, Jun 4, 2013 at 8:10 PM, Rob <ulam...@gmail.com> wrote: >> >>> I am trying to make a class PoolingMatrix, which needs to be an >>> (binary) integer matrix with extra attributes and functions. For >>> example, I'd like to say: >>> >>> sage: m = PoolingMatrix(ZZ, [[1,0,0],[0,1,0],[0,0,1]]) >>> sage: m.nrows() >>> 2 >>> sage: m.is_disjunct(2) # the 3x3 identity matrix is 2-disjunct >>> True >>> >>> But the init specification for PoolingMatrix is tripping me up. Can >>> anyone provide a suggestion? >>> >>> I'm trying something like: >>> class PoolingMatrix(some_matrix_thingy): >>> def __init__(self, input_ring, input_array): >>> ... >>> >>> Thanks for any assistance >>> -Rob >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "sage-devel" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to sage-devel+...@googlegroups.com. >>> To post to this group, send email to sage-...@googlegroups.com. >>> Visit this group at http://groups.google.com/group/sage-devel?hl=en. >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >>> >>> >> -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel?hl=en. For more options, visit https://groups.google.com/groups/opt_out.