Joe Riel

9660 Reputation

23 Badges

20 years, 3 days

MaplePrimes Activity


These are replies submitted by Joe Riel

An annoying change is that deleting a post as spam doesn't remove the link without refreshing the page. Actually its worse than that.  The link does not appear to go away.  It's no longer active, but it remains.  

Followup Apparently the link does get deleted, just not right away as it used to. 

@Carl Love That worked, thanks.  An improvement would be to include the title of the original post in the notification; possibly that could replace the generic "someone commented on ..." or whatever it currently says.

@Carl Love I don't understand how the notification is supposed to work. I see various notifications, but the only active links take me to the author's summary page, not the topic. How do I get to the topic? 

@Carl Love Thanks, fixed it.

While not as fast as the three faster ones, using Threads:-Mul is quick

irem(Threads:-Mul(x, x = L), p);

I tried using Threads:-Task with a task that computes the product modulo p, but it was slower.

@sigl1982 Good question.  Here I'd probably add a flag to the top-level condition, set it where the goto is, then call break to get out of the inner loop. You could also use a procedure and a return statement; that requires some refactoring, though possibly not much here.  An ugly method is to use try/catch and throw an error; I would avoid doing so for various reasons, including it makes debugging a bit of a nuisance. 

There is nothing useful in that file; it is pretty much all zeros.

@vv While I have access to the source code, I didn't need it to figure that out. I just used my Emacs-Maple debugger to step into the procedure; it displayed the full name. Hmm.  A month or more ago I promised on this site I'd get the Emacs debugger distribution sorted out (it's currently available as source, but uses some custom build tools that aren't available). Haven't got around to it as yet. Regardless, you could do the same with the regular Maple debugger.  It will display the full name when you step into it.

@vv Look at combinat:-Combinations:-Choose1.

@tomleslie c changes during the execution of seq.  C is an iterator (i.e.a module with a ModuleIterator method); when used in a seq statement, Maple's kernel uses the two procedures (hasnext and getnext) returned by ModuleIterator during the evalution of the seq. The hasnext procedure is a predicate that returns true until there are no more values, at which point it returns false, which seq uses to end the evaluation.  For the iterators in the Iterator package, the hasnext procedure also updates the elements stored in the Array that is returned by getnext.  The getnext procedure always returns the same Array (that is the address stays the same, no new Array is allocated), only with different values. 

@Carl Love It's doubtful tables, etc. will help here.  Here's a slight rewrite of rcomb2 that uses _rest instead of declaring p; it isn't faster but I find it easier to read.

rcomb3 := proc(n::nonnegint, k::nonnegint)
local i;
    if   k>n then ();
    elif k=0 then [];
    else
        proc(n,k)
            if   k=n then [seq(1..n), _rest]
            elif k=1 then seq([i, _rest], i=1..n)
            else thisproc(n-1, k, _rest), thisproc(n-1, k-1, n, _rest)
            end if;
        end proc(n,k);
    end if;
end proc:

@sigl1982 A Maple repository has extension mla. Use savelib to save the procedure to one. For example

savelib(squarefree, "somepath/mylib.mla"):

@Carl Love Nice contribution Carl.  I'll have to consider using it to replace the algorithm in combinat:-choose.

@tomleslie My point was that option 2 produces a list of the same Array.  It is not what anyone would want.  You can modify it to produce a list of distinct Arrays by doing B := [seq(c[], c = C)].

@tomleslie That doesn't return what you think it returns.  Try creating B as a set rather than a list, you'll see that numelems(B) then returns 1.  The reason for this is that this iterator---as all the iterators in the Iterator package---returns an Array whose address does not change, only its content.  That is part of what makes the code fast; it reuses a mutable object.  To create a sequence of distinct elements from an iterator, you can do seq(c[], c = C). The square brackets force the value of the Array that is assigned to c to be returned. Note also, because adding a constant to Array does so element-wise, one could do seq(c[]+1, c=C) to obtain a sequence of 10 element Arrays with the elements from 1 to 20.

First 35 36 37 38 39 40 41 Last Page 37 of 195