On Thu, Apr 17, 2008 at 05:09:07PM +0200, Ondrej Certik wrote: > On Thu, Apr 17, 2008 at 4:42 PM, Friedrich Hagedorn <[EMAIL PROTECTED]> wrote: > > > > On Thu, Apr 17, 2008 at 03:59:32PM +0200, Gael Varoquaux wrote: > > > On Thu, Apr 17, 2008 at 03:58:31PM +0200, Ondrej Certik wrote: > > > > However, how about this syntax: > > > > > > > In [18]: f = Lambda(x, term, evalf=True) > > > > > > Or rather f = Lamdba(x, term, numerical=True) > > > > > > The reason I say this is that the keyword numerical could in the long run > > > be added to many functions in sympy (probably by making them call scipy > > > in the backend). This would thus be transparent to the user. > > > > May be > > > > In [21]: sin(2) > > Out[21]: sin(2) > > > > In [22]: sin(2).evalf() > > Out[22]: 0.9092974268256816953960198659 > > > > An now, do you mean this? > > > > In [22]: sin(2, numerical=True) > > Out[22]: 0.9092974268256816953960198659 > > > > ? > > > > But this leads me to an other question. What is the (abstract, user level) > > difference between > > > > sin(2) > > > > and > > > > term = x + x*+2 > > f = Lambda(x, term) > > f(2) > > > > ? There should be no difference. So, when we discuss to get > > > > >>> f([0, 1, 2]) > > [0, 2, 6] > > > > then also I want so get > > > > >>> sin([0, 1, 2]) > > [0, 0.841, 0.909] > > > > So, I want to have many input type to a function: > > > > x : a sympy symbol > > > > 2.3+2j : a symbol number (no difference to a sympy symbol) > > > > 2.3+2j : a numeric number (complex) > > Yes. Feel free to find cases where it doesn't work and report it in issues. > > > > > tuples, lists, numpy.arrays of them. > > Well, ufuncs? Looking at the sourcecode of the Function class, maybe > it's as easy as adding a line checking for a list and returning a list > of the function > applied element wise. Something similar could be done for Matrices, see below.
I dont know the ufuncs. What is the idea behind them? > > And matrices? > > > > In [35]: M=Matrix([1,2],[3,4]) > > > > In [36]: M > > Out[36]: > > ⎡1 2⎤ > > ⎣3 4⎦ > > > > In [37]: exp(x) > > Out[37]: > > x > > ℯ > > > > In [38]: exp(M) > > --------------------------------------------------------------------------- > > <type 'exceptions.NotImplementedError'> Traceback (most recent call last) > > As to matrices, I think sympy should implement functions on matrices, > i.e. do singular value decomposition, apply the function to the > diagonal matrix and assemble the result back. > > so exp(M) would produce an exponential of the matrix. NumPy seems to > be applying the functions element-wise, which I think is wrong. What > do you think? You are right. But what should be done when the element-wise eval is needed? Shape the Matrix to an array, eval, and shape it back? > > It seems to get more complex this topic. But we can compound to get this > > behaviour only with a Lambda Function. > > I feel it's doable for all functions. Any objections? Hmm, ... This have to answer the experts. By, Friedrich --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to sympy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sympy?hl=en -~----------~----~----~----~------~----~------~--~---