Joe Riel

9660 Reputation

23 Badges

20 years, 3 days

MaplePrimes Activity


These are replies submitted by Joe Riel

@Bendesarts You are welcome.  I just pushed a small improvement to the package, see the main post for the link.

For those not familar with Code Edit regions, it may pay to read the help page for them. They do provide a method (templates) to insert/expand common structures in the code (conditionals, loops, etc).

@dharr Bonus points for a purely mathematical approach.  This can fail with some content, for example, if a cell contains NULL.

@Carl Love Thanks; I had fixed that before seeing your response.  Wasn't sure at the time.

@Carl Love Yes, but that will have the same issue with the memory allocation.  If the Matrix were in row major order (C_order) one could use ArrayTools:-Alias to select a slice, without allocating, followed by ArrayTools:-IsZero, however, that seems rather esoteric and doesn't work for the (default) column-major order (Fortran_order). 

@John Fredsted While the subs method works here, it is a bit dicey. For example, it won't give the proper result if beta-1 appeared elsewhere in one of the terms.  Safer is to use my second suggestion, which divides each term by beta-1.

@Carl Love A theoretical advantage is that one doesn't have to construct the sublist that is used by ormap.  Compare 

ormap(f, [seq(1..100)]);

with

orseq(f(k), k=1..100);

Both would return the same result, but the first allocates memory for a 100 element list. A second advantage, at least for some cases, is that one doesn't have to evaluate a procedure for each iteration. For example

ormap(proc(x) 3 < x and x < 4 end proc,L);

vs

orseq(3 < x and x < 4, x = L);

Neither advantage seems compelling, but it does have its uses.

@Bendesarts The fold marks are embedded in Maple comments.  As such, they can be inserted anywhere.  They come in pairs, an opening mark and a closing mark.  Nested folds can be used inside folds, so long as the nested is properly structured (that is independent of the Maple code).  Inside a procedure I might do

foo := proc(L :: list)
    #{{{ setup the loop 
    T := table();
    cnt := 0;
    #}}}
    for x in L do
        if x = 23 then
           #{{{ add x to table T
           cnt := cnt+1;
           T[cnt] := x;
           #}}}
        end if;
    end do;
With the buffer folded, this looks like
foo := proc(L :: list)
    #{{{ setup the loop ...
    for x in L do
        if x = 23 then
           #{{{ add x to table T ...
        end if;
    end do;

@Bendesarts I use the folding package in Emacs to group sections of Maple code in a Maple source code file.  Folded it might look like this

mypackage := module()
option package;
#{{{ declare external ...
#{{{ declare locals ...
#{{{ include definitions
end module:

With a mouse-click or keypress any/all section headers can be opened to show the content. Folds can be enclosed inside other folds to support a hierarchical structure.

@Lawablaster Don't copy it into the mw file you are attempting to restore. Instead, create a separate mw file with it, and run that worksheet, modifying the string passed to the DeleteBadChararacters procedure to be the path to the corrupted mw file.

@rstellian I'll guess you are using Windows and running Maple so that its current directory is in a location to which it cannot write. Assign a writable file. For example

  file := FileTools:-JoinPath([kernelopts('homedir'), sprintf("SIM_%d.mpl", i)]);

You could also just change the current directory. A simple way is to click on the display of the current directory in the bar at the bottom of the worksheet.

@acer The thread-safety issue does seem a concern.

I'm still surprised that sort works under the power.  More generally, one can do

y := sqrt(x^2+1);
sort(1/(1+y),order=plex(x),ascending);
Nice, but not expected.

@sigl1982 Yes, the statements in henselSquareStep that call quo with T as the optional third argument are problematic.  In your call to henselSquareStep, T is x, so the call to quo assigns an expression in x to x, which leads to an infinite recursion when attempting to display that value. 

The error is a bug in maplemint.  Could you show what input you used to get the other issues you mentioned?

@Carl Love Less typing is

KeepThese := ''{one,two}'':

@Carl Love He's using MapleSim, so its more likely an issue with a model. He should either contact Maple support or upload the msim file here.

First 32 33 34 35 36 37 38 Last Page 34 of 195