Carl Love

Carl Love

19037 Reputation

24 Badges

7 years, 347 days
Mt Laurel, New Jersey, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are replies submitted by Carl Love

@JonMcLoone Thanks for the code. From a quick glance, I'd say that it was competently and honestly written. I'd guess that I could tweak it a bit for efficiency, but without making major gains.

I've seen posted over the years numerous timing comparisons---made by third parties---where the Maple code was utterly incompetent, some of it scraped from my own ancient posts on Usenet and used out of context. Your benchmarking code is nothing like that. 

@vs140580 As Kitonum said, what you're asking for is usually called a Cartesian product, not a permutation with repetition, although it is possible to represent it as a permutations with repetition like this:

CP:= (S::{list,set}, m::nonnegint)->
    combinat:-permute(map(`$`, [S[]], m), m)
:

 

@opus64 It can't be called a bug in the usual sense of that word because it was designed to have that behavior, the design is documented (albeit quite tersely) at ?rtable_eval, and as far as I can see the actual behavior follows the design.

@Scot Gould This issue of when things are evaluated is something that only affects symbolic languages. You can't fairly compare this behavior to that of any nonsymbolic language. If the policy "evaluate everything fully, all the time" were adopted, the last example at ?rtable_eval shows what would go wrong.

That being said, this behavior can be quite annoying and difficult to understand, and only an expert can remember rtable_eval. There should be a package FullyEvaluatedRtables which would be suitable for small-scale, student, and desktop use. I think that I could write it in 50-100 lines of code. The internal representation would be lists of lists, because they fully evaluate. The ModulePrint would simply convert to an ordinary rtable.

@JonMcLoone Jon, I would like to see any of that Maple benchmarking code that you can provide. I'll give my opinion on whether it's competently written, and I'll try to rewrite it to be more efficient. I'd be particularly interested in the code used for the quadruple-precision matrix arithmetic tests shown at the bottom of https://www.advanpix.com/, mentioned in the ninth Comment in this thread. Those tests show Mathematica to be many times faster than Maple at these tasks. Does Mathematica have any special support for quadruple precision (as opposed to just general support for arbitrary precision)?

If you'd rather not post the code publically, use the Contact Author under the More... pull-down, and I'll send you my email address.

@vs140580 Here's the generalization of the seq method to Cartesian products of an arbitrary number of factors:

CP:= (S::{list, set}, m::nonnegint)->
local k, i, j:= i= 1..m;
    [value](foldl(%seq, [k[i] $ j], (k[i]= S) $ j))
:

If you only want to see certain iterations, you could do something like this:

L:= CP({0, 1, 2}, 10): #end with a colon!
L[2100..2199];

@AHSAN You're wasting my time. Give all the details of what you want at the start. Now you have 5 x values and 4 F values. Do you need me to tell you that that doesn't make sense? If not, then why haven't you corrected it already?

@AHSAN So what are the x-values then? Certainly not the 1, 2, 3, 4 that I used.

@vv Yes, you're right: I meant to write what you wrote. The way I wrote it, there is a small inefficiency due to a one-step recursive call. Thanks for pointing it out.

@nm What acer means by "unnecessary mappings and conversions" is that your map(x-> select(...), ...could be replaced by

{seq}(select[flatten](type, sol, indexed)); #no map, no (explicit) convert

but, as he said, that still relies on the free variables appearing as isolated entries in the solution vector, which may be an algorithm-dependent feature of LinearSolve (which actually chooses among several algorithms depending on the input type of the data). As I've told you before, select only does a top-level search of a structure; indets searches deep within the structure.

Also, while I personally don't think that ilcm should've been designed to take a list argument, Maple lets you redefine any procedure (even a kernel built-in like ilcm) to take any type of argument(s) that you want, without altering the original usage of the procedure. So here's how to make ilcm take a list or set argument:

restart:
ilcm__orig:= eval(ilcm):
unprotect(ilcm):
ilcm:= overload([
    proc(L::{list, set}, $) option overload; ilcm(L[]) end proc,
    ilcm__orig
]):
protect(ilcm, ilcm__orig):

ilcm([2, 4, 7]);
                               28

 

@nm Sorry that I neglected that possibility. Replace with

indets(sol, typeindex(nonnegint, suffixed(_t)));

Or replace _t with a name constructed as acer suggested.

@Rouben Rostamian  The syntax f(x):= y is very long established (at least 20 years), and indeed absolutely essential, for remember table assignments. It's extensively used in library and package code. So there's no way that that can be changed. The design mistake was to (relatively recently) allow it also for function definition. Since that's only allowed for top-level use and only in 2D input, that usage could be removed without breaking things, I think. 

@wlferguson19 It's a dimensionless number, in this case a ratio of two things with the same units. I think that the Units package can only handle units on the ratio scale of measurement (I'll put a Wikipedia link when I get a chance). AFAIK, it can't handle other scales such as ordinal (e.g., Mohs hardness), difference (e.g., calendar year), or logarithmic (e.g., pH).

@MapleEnthusiast Your expression is simply a polynomial with a huge number of variables  (when you count the indices), a huge number of terms, no coefficients, and a low degree (4 or 5). simplify is too generic to be of much help. Actually, I think that it might make patterns even harder to see. The relevant patterns are in the indices, which simplify won't even look at. Perhaps something can be achieved by encoding the indices as exponents.

Were you able to make use of the sorting procedures that I posted for you in another thread?

I suppose that you've been given a Maple procedure text2num? Have you also been given its inverse num2text? Or are you supposed to write it? Due to the simplicity of the text-to-number encoding, I was able to write num2text without seeing text2num.

Hint: My num2text took 3 lines of code. The most important part is a convert(..., base, ...command. The rest of the decoding took only one line of code, the central part of which is a solve command for the equations, then applying num2text to the numbers found for x, y, and z, then inserting spaces between the words.

1 2 3 4 5 6 7 Last Page 1 of 546