On Wed, Jun 4, 2008 at 8:52 AM, Giovanni Samaey <[EMAIL PROTECTED]> wrote: > > Hi again, > > this seems to be more general of a problem than stated here below. It > appears as if data with types numpy.ndarray and numpy.float64 do not > mix well with types like RealNumber etc that are the sage default. > How do I ensure that everything I use are standard scipy numerical > types ? I have put > RealNumber = scipy.float64 > ComplexNumber = scipy.complex128 > at the beginning of my script. > > In order to get past a routine, I need to add a lot of casting; an > example is: > > def lambd_anal(D,beta,delta,n,dt,k): > eta = scipy.arange(1,n+1,dtype=scipy.float64) > h = 1./(n+1) > l = 2*D/h**2 * (scipy.cos(2*scipy.pi*h*eta)-1)+scipy.sqrt(-1) * > beta/h * scipy.sin(2*scipy.pi*h*eta) > l = scipy.array(l,dtype=scipy.complex128) > lambd = (1.-(1.+dt*l)**k)/(1.-1./(1.-l*k*dt)) > lambd = scipy.array(lambd,dtype=scipy.complex128) > return scipy.real(lambd),scipy.imag(lambd) > > But I still get errors of the type ... > > File "/Users/giovanni/.sage/sage_notebook/worksheets/admin/1/code/ > 24.py", line 9, in A_impl > T = scipy.linalg.inv(I_h-A_h*k*dt) > TypeError: unsupported operand type(s) for *: 'numpy.ndarray' and > 'numpy.float64' > > In which A_h is an ndarray and k and dt are float64 numbers. > > I love the sage notebook interface, but I would adore it to behave as > an ipython -pylab shell; or at the least, some guide of main > differences between python+scipy and sage. > > Any help would greatly be appreciated. > > Giovanni
In the top middle of the notebook, try changing the fourth drop-down selector from Sage to Python. William --~--~---------~--~----~------------~-------~--~----~ 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 URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---
