On Sat, Jan 22, 2011 at 8:19 PM, ancienthart <[email protected]> wrote: > This tip, which seems the most effective and least likely to blow up, has > made it to the following blog. > http://doxdrum.wordpress.com/2011/01/22/sage-tip-simplifying-a-matrix/ > > So is it possible that this could become an approach to matrices, either > automagically, or by a smarter map function? > Proposal one: > All method calls to matrices first try to find a method that is native to > the matrix. > Then if this fails, sage attempts to map the method to all the matrix > elements. > Proposal two: > <matrix>.map accepts either a function OR a method name. If the function > call fails, tries to apply as a method of each element. > E.g. > D.map(simplify_full) currently gives > NameError: name 'simplify_full' is not defined > > Instead > D.map(simplify_full) fails on the function call, but instead of returning > NameError, it then tries Simon's approach, by doing an invisible call to > self.map(lambda x: x.simplify_full) > If that fails, then let the errorsĀ propagateĀ back up. (Have to make sure > that this semi-recursive approach doesn't result in an infinite recursion of > course.) > Sound good?
How would this second method be implemented? The NameError is raised before map even gets called. I'm +1 to the first option. - Robert -- To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
