Hi, Le jeudi 5 février 2015 15:15:54 UTC+1, Volker Braun a écrit : > > How often do you think people want to compute the image under the identity > map? If that is a common code path you could just have an cached > is_identity() and check it before doing the matrix multiplication. > > Writing a specialization for a particular value precisely saves you that > one check of a boolean flag at the end of the day. Unless you have > benchmarked the need for this minor optimization it you are almost > certainly wasting your time. > > Thanks for your answer. I am convinced by your argument. Indeed, I prefer having a clean parent/element implementation than having specific optimized subclasses. Actually, I am already using the cached is_identity trick to avoid a matrix multiplication in the method _call_() of free module morphisms in #15916. <http://trac.sagemath.org/ticket/15916>
What about isomorphisms ? Shall one use a cached is_isomorphism and implement an __invert__() method for all elements, raising an error if is_isomorphism is False ? Eric. -- 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. For more options, visit https://groups.google.com/d/optout.