It seems I misremembered _eval_power. It handles when the object is the base, not the exponent. So I'm actually not sure if there is a way to override this. This ties in to the dispatch thing that is often discussed here.
Aaron Meurer On Wed, Jun 26, 2013 at 5:48 PM, F. B. <franz.bona...@gmail.com> wrote: > I don't understand how it works... > > I tried to do a test: > > class A(Basic): > def _eval_power(self, a): > return Integer(12345) > > a = A() > print exp(a) > print E**a > > this gives me exp(A()) and not 12345 > > On Tuesday, June 25, 2013 9:39:09 PM UTC+2, Aaron Meurer wrote: >> >> On Tue, Jun 25, 2013 at 2:32 PM, F. B. <franz....@gmail.com> wrote: >> > Can this be done on the DifferentialOperator too? >> >> Sure, _eval_power works on everything. >> >> > >> > It would be nice to have a simple implementation of the exponential of a >> > diff operator, such as exp(diff_op_instance), it would be very helpful >> > for >> > many physicists. >> > >> > (by the way, the exp of a DifferentialOperator requires pdsolve to be >> > able >> > to handle initial conditions... I think it's going to take some time) >> >> Not if you submit a pull request... >> >> Aaron Meurer >> >> > >> > >> > On Monday, June 24, 2013 11:06:24 PM UTC+2, Aaron Meurer wrote: >> >> >> >> Actually, fixing this just involves fixing >> >> https://code.google.com/p/sympy/issues/detail?id=1799, because Pow >> >> already has this logic (_eval_power). >> >> >> >> Oh, and I guess Matrix._eval_power would need to be implemented >> >> (currently it raises NotImplementedError, but this is easy to fix, >> >> just make a**Matrix give exp(log(a)*Matrix). Even with that fixed, you >> >> could do E**Matrix, before issue 1799 is fixed. >> >> >> >> Aaron Meurer >> >> >> >> On Mon, Jun 24, 2013 at 12:37 PM, F. B. <franz....@gmail.com> wrote: >> >> > Hi, I noticed the Matrix.exp() function which calculates the >> >> > exponential >> >> > of >> >> > a Matrix. >> >> > >> >> > The exp() function fails when calling exp(matrix) because it does not >> >> > recognize the matrix object. >> >> > >> >> > exp is a class inheriting the "Function" object. >> >> > >> >> > What about creating an "ForwardFunction" object which tries to look >> >> > for >> >> > methods having the same name of the class to apply it? >> >> > >> >> > For example, the exp() function would not recognize a Matrix object >> >> > in >> >> > its >> >> > algorithm, but would notice the Matrix.exp() method on its arg and >> >> > call >> >> > it. >> >> > >> >> > -- >> >> > 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+un...@googlegroups.com. >> >> > To post to this group, send email to sy...@googlegroups.com. >> >> > Visit this group at http://groups.google.com/group/sympy. >> >> > For more options, visit https://groups.google.com/groups/opt_out. >> >> > >> >> > >> > >> > -- >> > 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+un...@googlegroups.com. >> > To post to this group, send email to sy...@googlegroups.com. >> > Visit this group at http://groups.google.com/group/sympy. >> > For more options, visit https://groups.google.com/groups/opt_out. >> > >> > > > -- > 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. > For more options, visit https://groups.google.com/groups/opt_out. > > -- 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. For more options, visit https://groups.google.com/groups/opt_out.