On 11 January 2013 09:29, Johhannes <dajo.m...@web.de> wrote: > > > Am Freitag, 11. Januar 2013 00:53:08 UTC+1 schrieb Nils Bruin: > >> >> >> It could be more appropriate to fix this by making 2x2 matrices always >> immutable (then the methods accessing that can be special-cases on the >> class) or by lying and just making set_immutable a no-op. >> > > this could be one way, but maybe some other functionallity gets broken > then. > >> >> Or perhaps by documenting "2x2 matrices aren't a full implementation >> of matrices, but we inherit from it anyway by way of a hack. Don't >> expect that ... will always properly work. Only use 2x2 matrices when >> you need the speed and don't care about the unimplemented features". >> > > I think as long as we inherit from one object, we should implement all > base methods. An 'end-user'-class should not have unimplemented functions. > > the best would be, to do some timing tests, in order to see how much > adding this line affects the performance. >
The class Matrix_integer_2x2 isn't really an "end-user" class. If a user does sage: m = matrix(ZZ, 2, [1,2,3,4]) what they get is an instance of Matrix_integer_dense which happens to have size 2x2, not of Matrix_integer_2x2. The latter exists *solely* in order that it can get used by the modular forms code which does a lot of arithmetic with 2x2 integer matrices; arithmetic operations are a great deal faster with Matrix_integer_2x2 (a factor of 10 or so). The only way users can explicitly get their hands on a Matrix_integer_2x2 in a Sage session would be either to import the class constructor (which is not in the default Sage namespace) or to use the .matrix() object of SL2Z elements; the class sage.modular.arithgroup.arithgroup_element.ArithmeticSubgroupElement is a wrapper around Matrix_integer_2x2. So I think it's acceptable if Matrix_integer_2x2 doesn't implement everything in the Sage matrix specification, and in particular if we set it up so its elements are *always* immutable; and we change the .matrix() element of SL2Z elements to return a Matrix_integer_dense copy of the internal Matrix_integer_2x2. What do others think about this suggestion? David -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To post to this group, send email to sage-devel@googlegroups.com. To unsubscribe from this group, send email to sage-devel+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel?hl=en.