On Mon, Oct 27, 2008 at 8:18 AM, Andy Ray Terrel <[EMAIL PROTECTED]> wrote: > > On Sun, Oct 26, 2008 at 11:06 PM, Alan Bromborsky <[EMAIL PROTECTED]> wrote: >> >> Andy Ray Terrel wrote: >>> On Sat, Oct 25, 2008 at 10:32 PM, Andy Ray Terrel <[EMAIL PROTECTED]> wrote: >>> >>>> On Sat, Oct 25, 2008 at 3:39 PM, Alan Bromborsky <[EMAIL PROTECTED]> wrote: >>>> >>>>> Ondrej Certik wrote: >>>>> >>>>>> On Fri, Oct 24, 2008 at 1:35 PM, Alan Bromborsky <[EMAIL PROTECTED]> >>>>>> wrote: >>>>>> >>>>>> >>>>>>> Ondrej Certik wrote: >>>>>>> >>>>>>> >>>>>>>> On Wed, Oct 22, 2008 at 7:11 AM, Alan Bromborsky <[EMAIL PROTECTED]> >>>>>>>> wrote: >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>>> Using sympy I have attached a program (LaTeX.py) demonstrating >>>>>>>>> Maxwell's >>>>>>>>> equations using geometric calculus. Also attached is a version of >>>>>>>>> GAsympy.py with some geometric calculus extensions (the version in >>>>>>>>> sympy >>>>>>>>> only does geometric algebra). The demo program is called LaTeX.py >>>>>>>>> since >>>>>>>>> it uses LaTeX to show the equations in a nice format. Eventually I >>>>>>>>> will >>>>>>>>> use the standard latex printing system in sympy with some >>>>>>>>> modifications. Just run LaTeX.py and see what come out! >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>> Wow, this is impressive! Thanks for doing this. >>>>>>>> >>>>>>>> I would like the LaTeX class to be integrated with our LatexPrinter, >>>>>>>> see sympy/printing/latex.py. Do you have any comments on that? Because >>>>>>>> you are duplicating a lot of stuff in your own class. >>>>>>>> >>>>>>>> Ondrej >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>> I need to consult with you more on how your printer classes in general >>>>>>> work before starting integrating my latex with your latex. Also with >>>>>>> regard to the actual math part of geometric calculus, now that I can do >>>>>>> geometric derivatives in rectangular coordinates I need to implement >>>>>>> curvilinear coordinates for practical applications which means I need to >>>>>>> do some pencil and paper derivations. >>>>>>> >>>>>>> >>>>>> Ok. >>>>>> >>>>>> Related note I wrote recently regarding my research: >>>>>> >>>>>> I had to convert the Laplace equation with nonconstant conductivity >>>>>> into cylindrical coordinates. One can find such formulas on the >>>>>> internet, but in fact, I wasn't able to quickly find formulas if the >>>>>> conductivity is not constant. Now, obviously in this is simple example >>>>>> the result is obvious. But nevertheless, as an >>>>>> excersise, I wrote some notes how such things can be done using >>>>>> differential geometry, see the geom.ps referenced in the above wiki, >>>>>> or this link: >>>>>> >>>>>> http://github.com/certik/differential-geometry/tree/0552cdd5b99ebfb356c1d469f84314027cc3ffb0%2Fgeom.ps?raw=true >>>>>> >>>>>> See the section 3.1. I can imagine that converting more complex >>>>>> equation, or using other curvilinear coordinates such conversions >>>>>> quickly become very messy. Using my notes above, the task can be >>>>>> completely automated and it is in my TODO list to implement this in >>>>>> SymPy. >>>>>> >>>>>> --------- >>>>>> >>>>>> It'd be cool if we could do all the stuff in geom.ps in sympy. >>>>>> >>>>>> Ondrej >>>>>> >>>>>> >>>>>> >>>>> Code below works for pretty printing, but not for latex. What am I doing >>>>> wrong? It is not clear to me how to refer to doprint for latex. One I >>>>> know the correct way to do the below I will start modifying LatexPrinter >>>>> to do the required formatting. On general philosophy with regard to >>>>> different types of printers I think there should be a global switch to >>>>> determine the type of printer and fomatting options for each type of >>>>> printer. To output one should always be able to just use print and str! >>>>> >>>>> >>>>> #!/usr/bin/python >>>>> #Printer.py >>>>> >>>>> import sympy >>>>> from sympy import * >>>>> from sympy.printing.pretty.pretty import PrettyPrinter >>>>> from sympy.printing.latex import LatexPrinter >>>>> >>>>> class Printer: >>>>> >>>>> printer_types = 0 >>>>> >>>>> normal = sympy.Basic.__str__ >>>>> >>>>> @staticmethod >>>>> def pretty(x): >>>>> return(PrettyPrinter().doprint(x)) >>>>> >>>>> @staticmethod >>>>> def latex(x): >>>>> return(LatexPrinter().doprint(x)) >>>>> >>>>> @staticmethod >>>>> def set(printer='normal'): >>>>> if Printer.printer_types == 0: >>>>> Printer.printer_types = {'normal':Printer.normal,\ >>>>> 'pretty':Printer.pretty,\ >>>>> 'latex':Printer.latex} >>>>> sympy.Basic.__str__ = Printer.printer_types[printer] >>>>> return >>>>> >>>>> Printer.set('pretty') >>>>> var('x') >>>>> print x**2+1 >>>>> >>>>> Printer.set('latex') >>>>> print x**2+1 >>>>> >>>>> >>>>> >>>> Overload __repr__ not __str__ and it works. The default for >>>> sympy.printing.printer is the __str__ method, PrettyPrinter overloads >>>> this, LatexPrinter doesn't, which is reasonable. >>>> >>>> -- Andy >>>> >>>> >>> >>> Oops that doesn't print what you want either. >>> >>> -- Andy >>> >>> > >>> >>> >> More printing questions. I have a class MV and have defined the function >> in my printer class _print_MV. >> When I try to print an instance of MV (for now _print_MV only outputs >> the string 'MV' for debugging) _print_MV is not used. Do I also have to >> add MV to some list of classes that _print searches? >> >> > >> > > Each printer class looks for the function '_print_'+cls.__name__ (see > sympy/printing/printer.py:96). I would guess that either a) something > is not working with the __name__ attribute or b) you are not calling > it from a printer that is instantiated with the _print_MV function. > >>>> f = x**2 >>>> print f # instantiates the StrPrinter > x**2 >>>> pretty_print(f) # instantiates the PrettyPrinter. > 2 > x > > Hope that helps.
Thanks Andy for answering. Alan, if you have further problems, please ask. Ondrej --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy" group. 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/sympy?hl=en -~----------~----~----~----~------~----~------~--~---
