Carl Love

Carl Love

28035 Reputation

25 Badges

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

MaplePrimes Activity


These are replies submitted by Carl Love

I can't run your code because I don't have the module action1.

@tomleslie Your Answer doesn't take into account that the final product is supposed to be an animation of two frames.

@Jason Lee For the new problem, you should have

b:= A[.., 7];
C:= A[.., [1..6, 8..11]];

Is that what you have? The indexing for C can also be abbreviated to A[.., [..6, 8..]].

@qyyj

faultcom={};

should be changed to

faultcom:= {};

and likewise for the following line.

 

@juju1234 After you change a cell value, try pressing Ctrl-Shift-Enter. This'll re-execute everything. Changing something on the screen, such as a cell value in B, doesn't change what's stored in Maple's computational memory (aka the kernel). That B stored in memory won't change until you press Enter on the line (or execution group) with the updated cell. Ctrl-Shift-Enter is like pressing Enter on every line (or execution group) that contains code.

@Volker Lehner I thought that it'd be important to re-emphasize this for a new user: To enter a new line in a block of code (a procedure or whatever), you must use Shift-Enter, not Enter. Using Enter makes the cursor "jump out" as you say. It also causes the code to be syntax checked and evaluated.

@Rouben Rostamian  In order to use arguments that are passed in square brackets immediately to the right of the procedure's name, the procedure must access those arguments via the construct op(procname). If this isn't done, then those arguments are completely ignored, which is what's happening in your g[12](5) example.

By tracing the execution by using high settings of printlevel, I see that is(ex, rational) and is(ex, irrational) (for symbolic constant expressions ex) uses a lot of decimal approximations. This suggests that the setting of Digits might affect the outcome.

Surely either you have transcribed the problem incorrectly or your copy has a typo. Let f(k) = 2*k/(2*k+3), and consider the limit

L:= limit(n^p*sum(f(k), k= 1..n), n= infinity)

for a fixed real parameter p. It is easy to prove (and I'll prove it if you want) that L = 0 if p < -1, L = 1 if p = -1, and L = infinity if p > -1. One doesn't even need to know a closed form for the sum to prove this.

@_Maxim_ Yes, I see that 'type' now; I missed it last night. I was thrown off by the And(complexcons, Not(infinity)). That's already a valid type, so why does it get special mention? Perhaps infinity wasn't a type when the code was written.

The age of the code is also shown by map(type, {op(e)}, 'property') = {true} . In modern Maple, this could (and should) be replaced by andmap(type, e, 'property').

I didn't disagree with Acer about a type being usable anywhere that a property was. I merely said that if it isn't also specifically coded as a property (e.g., by being listed in `property/ParentTable`), then there was nothing interesting that is could do with it. I mean, yes, you can use is as a replacement for a dedicated type checker, but I don't think that it's wise to do so.

@vv It was mostly wishful thinking on my part. Upon delving into the code, I think that is is a huge mess, and that a lot of what I wrote above is wrong. Since is is fundamental to Maple, and the person who wrote it (Gaston Gonnet, I believe) is not maintaining/updating it, perhaps Maplesoft is afraid to touch it for fear of breaking something.

Regarding "Of course, any type is a property": Read the very simple procedure `type/property`. That'll tell you exactly which types are properties. It'll also help you distinguish the proper properties: those that have a definition other than as types.

@Ramakrishnan You need to enclose the SetProperty commands inside of print commands, like this: print(SetProperty(  whatever ));

It makes no difference whether you end the commands inside the loop with colons or semicolons.

Are you going to post your algorithm?

@tomleslie CodeTools:-Usage is just a Maple-level wrapper for calling the kernel command time(); there's no finer-resolution tool available. You can see this in the code

kernelopts(opaquemodules= false):
showstat(CodeTools:-Usage);
showstat(CodeTools:-DoUsage);

In particular, pay attention to lines 5-10 of DoUsage.

The following explicitly measures the time quantum:

restart:
Quantum:= proc()
local n, T:= 0;
   for n while T=0 do
      T:= CodeTools:-Usage(0, output= cputime, quiet)
   end do;
   [n, T]
end proc:
    
Interval:= proc()
   Quantum();
   Quantum()
end proc:

gc(): gc(): gc(): gc():
CodeTools:-Usage(Quantum());
CodeTools:-Usage(Interval());

memory used=35.14MiB, alloc change=0 bytes, cpu time=250.00ms, real time=247.00ms, gc time=15.62ms
                         [11335, 0.015]
memory used=44.19MiB, alloc change=0 bytes, cpu time=282.00ms, real time=285.00ms, gc time=15.62ms
                         [8498, 0.016]

This shows that CodeTools:-Usage will report 0 seconds thousands of times for the cpu time of a trivial expression, and then report either 15 or 16 milliseconds for a single execution of the same trivial computation. The number of times (11335 and 8498 in this case) will vary, but the second number will always be 0.015 or 0.016.

Please show an example where CodeTools:-Usage shows a smaller nonzero cpu time. Examples using the iterations option, which averages the time over a large number of iterations, don't count.

@Kitonum Here's the code modified to produce all 6x6 binary matrices with three 1s in every row and column. It produces 297200 such matrices in listlist form in 33 seconds.

restart:
gc():
st:= time():
n:= 6:
N:= [$1..n]:
Sn:= combinat:-permute(n):
Id:= [seq([seq(`if`(i=j, 1, 0), j= 1..n)], i= 1..n)]:
D1:= remove(p-> ormap(evalb, p =~ N), Sn):
MA:= {seq(
   seq(M[p], p= Sn), 
   M= seq(
      seq(
         Id+Id[d1]+Id[d2], 
         d2= remove(p-> ormap(evalb, p =~ d1), D1)
      ), 
      d1= D1
   )
)}:
time() - st;

 

First 352 353 354 355 356 357 358 Last Page 354 of 708