Thanks Jason, I opted to use Re(X) = (X + X.conjugate())/2 in the end. I don't know enough about Python's interpreter to know whether this is more or less efficient than your suggestion. Thank you for the info about the new version, I shall upgrade soon. Will.
On Nov 24, 3:01 pm, Jason Grout <[EMAIL PROTECTED]> wrote: > Bill wrote: > > Hello, > > given a matrix over CDF I would like to obtain its real and imaginary > > parts. > > I know how to write my own function to do this, but I was wondering if > > there is one built-in. Couldn't see anything in the docs. > > I don't think there is a built-in function for it, but you can easily > apply a function to each element of a matrix by using the apply_map method: > > sage: m=matrix(CDF, [[1,I],[1+2*I,3+4*I]]) > sage: m > > [ 1.0 1.0*I] > [1.0 + 2.0*I 3.0 + 4.0*I] > sage: m.apply_map(real) > > [1.0 0.0] > [1.0 3.0] > sage: m.apply_map(imag) > > [0.0 1.0] > [2.0 4.0] > > By the way, since 3.0.5, the RDF and CDF matrices have had a major > upgrade to use numpy as a backend. > > Thanks, > > Jason --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---