Carl Love

Carl Love

28025 Reputation

25 Badges

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

MaplePrimes Activity


These are replies submitted by Carl Love

Erik wrote:

I am not entirely sure how you make the computer use all processors? I am not an expert on programming, so please be detailed ;)

For a start, how about downloading the code that I uploaded and taking a look at it and/or using it? Also, let's see how many processors Maple thinks that you have. Execute the following line in any Maple session.

kernelopts(numcpus);

And, do know how many processors your computer actually has?

The most basic technique for parallelizing is to take the outermost loop and and re-express it using seq or map instead of for. You can't change variables that are global to (or at higher scope than) the loop because of conflicts that would occur when separate processes try to change them at the same time. So, you make them local. Then change the seq or map to Threads:-Seq or Threads:-Map. That's all there is to it for the most basic technique. Parallelizing will only work if the loop iterations are independent. In other words, the results of later iterations cannot depend on the results of earlier iterations.

Erik wrote:

I am not entirely sure how you make the computer use all processors? I am not an expert on programming, so please be detailed ;)

For a start, how about downloading the code that I uploaded and taking a look at it and/or using it? Also, let's see how many processors Maple thinks that you have. Execute the following line in any Maple session.

kernelopts(numcpus);

And, do know how many processors your computer actually has?

The most basic technique for parallelizing is to take the outermost loop and and re-express it using seq or map instead of for. You can't change variables that are global to (or at higher scope than) the loop because of conflicts that would occur when separate processes try to change them at the same time. So, you make them local. Then change the seq or map to Threads:-Seq or Threads:-Map. That's all there is to it for the most basic technique. Parallelizing will only work if the loop iterations are independent. In other words, the results of later iterations cannot depend on the results of earlier iterations.

@tuGUTS 

Most of what you say makes some sense, but I have a lot of trouble understanding your English. However, what you start off with is utter nonsense: A matrix is not a group. A matrix can be a member of a group, but it is not by itself a group. A group is a set together with a binary operation on that set that satisfies certain properties.

@tuGUTS 

Most of what you say makes some sense, but I have a lot of trouble understanding your English. However, what you start off with is utter nonsense: A matrix is not a group. A matrix can be a member of a group, but it is not by itself a group. A group is a set together with a binary operation on that set that satisfies certain properties.

The thing that stands out to me based on a "mental compile" of the code (meaning that I'm just reading it, not running it until you upload it) is the same loop that Acer mentions. It looks to me like you're just throwing away the first 999 Arrays A. You're doing that 1000 times, and each A contains 3000 random numbers. So you're throwing away close to 3 billion random numbers. And Maple's algorithm for generating those numbers is not trivial.

@Markiyan Hirnyk Without randomize(), you will get the same sequence of random numbers every time. For example, I run your code on my computer...

restart: with(Statistics):
X := RandomVariable(Uniform(0, 10)):
seq(Sample(X, 1 .. 5), j = 1 .. 3):
lprint(%);
Array(1 .. 5, {1 = HFloat(8.14723686393178959), 2 = HFloat(9.05791937075619202), 3 = HFloat(1.26986816293506055), 4 = HFloat(9.13375856139019326), 5 = HFloat(6.32359246225409510)}, datatype = float[8], storage = rectangular, order = Fortran_order, attributes = [source_rtable = Array(1 .. 5, {1 = HFloat(8.14723686393178959), 2 = HFloat(9.05791937075619202), 3 = HFloat(1.26986816293506055), 4 = HFloat(9.13375856139019326), 5 = HFloat(6.32359246225409510)}, datatype = float[8], storage = rectangular, order = Fortran_order)]), Array(1 .. 5, {1 = HFloat(.975404049994095246), 2 = HFloat(2.78498218867048397), 3 = HFloat(5.46881519204983846), 4 = HFloat(9.57506835434297621), 5 = HFloat(9.64888535199276554)}, datatype = float[8], storage = rectangular, order = Fortran_order, attributes = [source_rtable = Array(1 .. 5, {1 = HFloat(.975404049994095246), 2 = HFloat(2.78498218867048397), 3 = HFloat(5.46881519204983846), 4 = HFloat(9.57506835434297621), 5 = HFloat(9.64888535199276554)}, datatype = float[8], storage = rectangular, order = Fortran_order)]), Array(1 .. 5, {1 = HFloat(1.57613081677548283), 2 = HFloat(9.70592781760615608), 3 = HFloat(9.57166948242945637), 4 = HFloat(4.85375648722841202), 5 = HFloat(8.00280468888800200)}, datatype = float[8], storage = rectangular, order = Fortran_order, attributes = [source_rtable = Array(1 .. 5, {1 = HFloat(1.57613081677548283), 2 = HFloat(9.70592781760615608), 3 = HFloat(9.57166948242945637), 4 = HFloat(4.85375648722841202), 5 = HFloat(8.00280468888800200)}, datatype = float[8], storage = rectangular, order = Fortran_order)])

...and you can see that I got exactly the same random numbers as you. Sometimes that type of reproducibility is desirable. Certainly it is desirable for debugging. But if you want independent results in separate executions, then you want a different sequence of random numbers, and for that you need to use randomize().

@Markiyan Hirnyk Without randomize(), you will get the same sequence of random numbers every time. For example, I run your code on my computer...

restart: with(Statistics):
X := RandomVariable(Uniform(0, 10)):
seq(Sample(X, 1 .. 5), j = 1 .. 3):
lprint(%);
Array(1 .. 5, {1 = HFloat(8.14723686393178959), 2 = HFloat(9.05791937075619202), 3 = HFloat(1.26986816293506055), 4 = HFloat(9.13375856139019326), 5 = HFloat(6.32359246225409510)}, datatype = float[8], storage = rectangular, order = Fortran_order, attributes = [source_rtable = Array(1 .. 5, {1 = HFloat(8.14723686393178959), 2 = HFloat(9.05791937075619202), 3 = HFloat(1.26986816293506055), 4 = HFloat(9.13375856139019326), 5 = HFloat(6.32359246225409510)}, datatype = float[8], storage = rectangular, order = Fortran_order)]), Array(1 .. 5, {1 = HFloat(.975404049994095246), 2 = HFloat(2.78498218867048397), 3 = HFloat(5.46881519204983846), 4 = HFloat(9.57506835434297621), 5 = HFloat(9.64888535199276554)}, datatype = float[8], storage = rectangular, order = Fortran_order, attributes = [source_rtable = Array(1 .. 5, {1 = HFloat(.975404049994095246), 2 = HFloat(2.78498218867048397), 3 = HFloat(5.46881519204983846), 4 = HFloat(9.57506835434297621), 5 = HFloat(9.64888535199276554)}, datatype = float[8], storage = rectangular, order = Fortran_order)]), Array(1 .. 5, {1 = HFloat(1.57613081677548283), 2 = HFloat(9.70592781760615608), 3 = HFloat(9.57166948242945637), 4 = HFloat(4.85375648722841202), 5 = HFloat(8.00280468888800200)}, datatype = float[8], storage = rectangular, order = Fortran_order, attributes = [source_rtable = Array(1 .. 5, {1 = HFloat(1.57613081677548283), 2 = HFloat(9.70592781760615608), 3 = HFloat(9.57166948242945637), 4 = HFloat(4.85375648722841202), 5 = HFloat(8.00280468888800200)}, datatype = float[8], storage = rectangular, order = Fortran_order)])

...and you can see that I got exactly the same random numbers as you. Sometimes that type of reproducibility is desirable. Certainly it is desirable for debugging. But if you want independent results in separate executions, then you want a different sequence of random numbers, and for that you need to use randomize().

Please upload a worksheet containing the code that you showed. In the form that you showed it, it cannot be cut-and-pasted.

@erik10 I'm just confirming that you understand perfectly what I said.

@erik10 I'm just confirming that you understand perfectly what I said.

@tuGUTS The x and y are members of a finite group. Yes, every finite group can be represented as a permutation group. (Finding the permutation representation of minimal degree can be difficult (NP-hard I believe--not sure).) That is not the same thing as being a permutation matrix. An n x n permutation matrix represents a permutation on n elements.

A permutation is a member of a permutation group; the permutation is not itself the group.

@tuGUTS The x and y are members of a finite group. Yes, every finite group can be represented as a permutation group. (Finding the permutation representation of minimal degree can be difficult (NP-hard I believe--not sure).) That is not the same thing as being a permutation matrix. An n x n permutation matrix represents a permutation on n elements.

A permutation is a member of a permutation group; the permutation is not itself the group.

@tuGUTS Could you say that again please, using full sentences? I don't understand the connection between the title and the body of your Reply.

@tuGUTS Could you say that again please, using full sentences? I don't understand the connection between the title and the body of your Reply.

@Markiyan Hirnyk 

A randomize() is required if you want different random numbers after a restart. This is what happens if you don't use it:

restart: rand();
                          395718860534
restart: rand();
                          395718860534
restart: randomize(): rand();
                          953915355483

You wrote:

Also I don't see any repetition of randomize() in the code under consideration.

But I know that he is repeating it because that is the only way that he could be having the problem that he describes.

First 643 644 645 646 647 648 649 Last Page 645 of 708