Carl Love

Carl Love

26488 Reputation

25 Badges

12 years, 305 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are replies submitted by Carl Love

@Carl Love Here's an efficiency improvement. The index array can be pre-partitioned into block-sized pieces with each subarray Aliased. Again, this works for any number of blocks of any sizes. 

restart:
SizedSetParts:= proc(s::{list,set}, B::list(nonnegint))
local SP:= Iterator:-SetPartitionFixedSize(B), J:= output(SP), p:= 0, A, b;
    J:= [for b in B do A:= ArrayTools:-Alias(J, p, [b]); p+= b; A od];
    {in SP do {seq}(s[[seq](b)], b= J) od}
end proc
:
SizedSetParts({"a", "b", "c", "d", "e", "f"}, [3,3]);
{{{"a", "b", "c"}, {"d", "e", "f"}}, {{"a", "b", "d"}, {"c", "e", "f"}}, 
{{"a", "b", "e"}, {"c", "d", "f"}}, {{"a", "b", "f"}, {"c", "d", "e"}}, 
{{"a", "c", "d"}, {"b", "e", "f"}}, {{"a", "c", "e"}, {"b", "d", "f"}},
{{"a", "c", "f"}, {"b", "d", "e"}}, {{"a", "d", "e"}, {"b", "c", "f"}}, 
{{"a", "d", "f"}, {"b", "c", "e"}}, {{"a", "e", "f"}, {"b", "c", "d"}}}

For the case of partitioning a 15-set into 5 3-subsets, my code above is over 5 times faster than combinat:-setpartition and over 500 times faster than Kitonum's custom procedure (which, to be fair, was written a long time ago).

@lcz Sorry, I switched P to (for blocks) at the last second, but I missed 2 Ps. I will correct. My code does give 10 solutions for the 3,3 case, as can be seen in the output I posted.

I just corrected the posted code.

@zenterix The information that you're asking about is printed by default after each garbage collection. You can turn it off by

interface(printbytes= false);

The first number, "memory used", is the total amount of memory recovered by garbage collection since the beginning of the session (regardless of restart). Since the same physical memory location can be garbage collected many times, this number may be higher than you expect. The second number, "alloc", is the amount of memory currently allocated to the Maple kernel currently being used. This number can go down. The third number, "time", is the CPU time in seconds for the current kernel (regardless of restart). Multiprocessing done with the Grid package uses different kernels, so you won't see the total CPU time for that. Multiprocessing done with the Threads package will show the total for all processors.

Some help for the Command Line Interface (CLI) can be found on these help pages: ?editing, ?edit_history, ?commandline. There are some setttings of the interface command that are particularly (some exclusively) useful for the CLI. See ?interface.

@vs140580 Here is some code that I wrote for fuzzy C-means clustering in any number of dimensions:  Fuzzy_clusters_(2).mw

I think that I've written some for k-means clustering also, but I haven't found it yet.

@zenterix If it couldn't find a package by that name, it would've returned an error message.

The global variable libname tells it where to look for packages. Show the output of

libname;

Show the output of

exports(MyPackage);

@sand15 When you refer to "KNN" that I've implemented, is that the same as identifying the "clusters" in a set of points?

Please show the output of the command

with(MyPackage);

@mmcdara The OP is referring to indentation within formatted expository text (i.e., word-processor-style text), not within code.

What happened to mmcdara's Answer to this Question? 

@Mike Mc Dermott You should be able to find those details with the built-in debugger, but I can't say any more about it. Hopefully someone else can provide details. 

If you just post your code (or worksheet), someone will likely track down the error.

OMG, that corrected primes code is tedious and amateurish (nearly elementary-school level) to say the least. How is it learning to program in Maple? And why did it make such a glaring syntax error on its first attempt? Does it just search the web for a single example program?

@mmcdara Yes, I meant to include option nolist. No, it hasn't become the default, although it's quite a nuisance that it wasn't the default from the very beginning. Thank you for finding my error.

@Mike Mc Dermott The error is from a procedure named `PD/PD`. It is indeed a recursive procedure, and it has something to do with Partial Derivatives, but I don't know any more. You can view its code with

showstat(`PD/PD`);

The vast majority of Maple procedures are not "commands", meaning that they're not intended for use by top-level users, and they aren't documented. This includes almost all procedures that have the character `/` in their name.

@tomleslie One can tell from the error message that it's caused by a recursive procedure, not a recursive assignment. The error message for a recursive assignment is simply "Error, recursive assignment".

You left out the most important detail: What is the ODE and its initial or boundary values?

First 42 43 44 45 46 47 48 Last Page 44 of 688