Joe Riel

9660 Reputation

23 Badges

20 years, 7 days

MaplePrimes Activity


These are replies submitted by Joe Riel

@JacquesC Thanks.  I'm familiar with the let function from lisp (emacs-lisp, actually) and would welcome a similar construct in Maple. Lisp's let binding is not immutable and I cannot comment on any efficiency advantages, but as a user I find it exceptionally convenient to be able to locally declare variables. It's not clear, though, that a let-expression would be as useful (programming-wise) if the bound variables were immutable, particularly in a mainly imperative language (which Maple is).

@herclau Are you asking how to view a postscript file on Windows?  One way is to use the ghostscript interpreter; a suitable previewer for use with it is GSview, which is available for multiple platforms.  I normally run Linux and inspected the plots there.

In 9, what do you mean by a 'let ... in' statement?

Following is a quick-and-dirty procedure to work-around this. I've tested it on Windows and Linux.  It creates a temporary maple script that it runs through tty maple, which currently uses a different postscript driver, one that defines the thin, medium, and thick macros.  Here is how you might use it,

PlotPS(plot3d(x*sin(y),x=0..1,y=0..2*Pi,axes=normal), plotoptions="color=rgb", medium=10);

By default the postscript file goes into plotfile.eps.

PlotPS := proc( plt
                , { plotoutput :: string := "plotfile.eps" }
                , { thin :: posint := 3 }
                , { medium :: posint := 7 }
                , { thick :: posint := 16 }
                , { plotoptions :: string := "" }
                , { tmpfile :: string := "plotfile.mpl" }
              )
local cmd, fd, str;
uses FT = FileTools, ST = StringTools;

    if IsWorksheetInterface() then
        # Create temporary file
        fd := fopen(tmpfile, 'WRITE', 'TEXT');
        fprintf(fd, "plotsetup('ps', 'plotoutput' = %a, 'plotoptions' = %a);\n"
                , plotoutput
                , plotoptions
               );
        fprintf(fd, "print(%a);\n", plt);
        fclose(fd);

        # Pass temporary file to maple tty executable
        if kernelopts('platform') = "unix" then
            cmd := "maple";
        else
            cmd := cat(kernelopts('bindir','dirsep'),"cmaple");
        end if;
        cmd := sprintf("%s %s", cmd, tmpfile);
        ssystem(cmd);
    else
        plotsetup('ps', _options['plotoutput'], _options['plotoptions']);
        print(plt);
        plotsetup('default');
    end if;

    # Modify the generated postscript file
    str := FT:-Text:-ReadFile(plotoutput);
    fclose(plotoutput);

    str := ST:-RegSubs("\n/thin ([0-9]+) def" = sprintf("\n/thin %d def", thin), str);
    str := ST:-RegSubs("\n/medium ([0-9]+) def" = sprintf("\n/medium %d def", medium), str);
    str := ST:-RegSubs("\n/thick ([0-9]+) def" = sprintf("\n/thick %d def", thick), str);

    FT:-Text:-WriteString(plotoutput, str);
    fclose(plotoutput);

end proc:

Followup: modified the above to fix a bug and work faster when called in tty maple.  Also changed option epsfile to plotoutput to match option name used in plotsetup.

Further: in case it isn't clear, this procedure can be run in the Standard GUI. The conversion to postscript is done in a separate process, via a call to tty maple.  That isn't particularly efficient, but I doubt that is an issue.

@Alejandro Jakubi I had forgotten that Maple uses different postscript drivers. The embedded image makes my method unworkable.

@John Starrett How did you create the plots?  Could you post a simple example?  I tried creating a 3D plot of the trajectory of a differential system, using ?plots[odeplot], and the generated postscript included the PostScript definitions I mentioned.  I did so by doing

plotsetup('ps', 'plotoutput' = "myplot.eps"):
plots:-odeplot(...);

@John Starrett While it requires a bit of postscript hacking, it's fairly easy to figure out how to tweak the eps file to produce thicker lines.  For a typical 2D plot created with Maple, change the numeric values of

/thin 3 def
/medium 7 def
/thick 16 def
/boundarythick 20 def % thichess of bounding box

The medium thickness is used for the axes and the graph, the thin is used for the tickmarks.  Writing a script that updates several files would be straightforward.

What format was that graph that Maple generated?  Postscript? 

 

 

@Axel Vogt I see what you mean; I had only tried my code using cmaple.  For once I thought things would be much simpler in Windows. 

@Axel Vogt I see what you mean; I had only tried my code using cmaple.  For once I thought things would be much simpler in Windows. 

@Axel Vogt Thanks.  Apparently it is in different locations depending on the Windows version. I found it on my Windows 7 installation at c:\User\joe\AppData\Roaming\Maple\15\Maple.ini.

@Axel Vogt Thanks.  Apparently it is in different locations depending on the Windows version. I found it on my Windows 7 installation at c:\User\joe\AppData\Roaming\Maple\15\Maple.ini.

@Villeson v = omega*R

@Villeson v = omega*R

Better might be a purely inert name; using ?conjugate means that some Maple routine will interpret that as a conjugate and act accordingly. For the inert name you can do

macro(YAB=`#mover(mi("Y*"),mo("¯"))`):

?alias can also be used, with the equation swapped left to right.

First 69 70 71 72 73 74 75 Last Page 71 of 195