Joe Riel

9660 Reputation

23 Badges

20 years, 3 days

MaplePrimes Activity


These are replies submitted by Joe Riel

Let me exand on what Alec mentioned. If you post Maple code (a good idea if you have a particular question concerning it), the most useful format is that which allows us to easily copy and paste it. Please use the 1D Maple format. When posting code I use the
 tag so that indentation is preserved.  A caveat with the 
 tag is that it does not handle the "<" character.  To insert it a "<" character, use < (the semicolon is required).
So far as I know, there isn't staff at Maplesoft assigned to answer these questions. Many, probably most, of the responses are from members of the Maple community. If the question is easy (say a usage or programming issue) it will probably be quickly interested. If the question is unclear (e.g. the one titled "scientific notation") it may not be answered at all. If the question involves some difficult mathematics, well then it depends if someone finds it interesting and has the time. The best way to get a question answered is to clearly formulate it, as simply as possible. Then give it an appropriate subject.
Another possibility, which works with pure reals and imaginaries, is (Re^2+Im^2)(z), or a variant. Here is a comparison of several methods for generating the magnitude (or square of magnitude).
restart;
use RandomTools in
    zs := [seq](Generate(complex(float(range=0..1,method=uniform))),i=1..10^3);
end use:

n := 2;
time(proc() to 10^n do map(z -> z*conjugate(z),zs) od end());
time(proc() to 10^n do map(Re^2+Im^2, zs) od end());
time(proc() to 10^n do map(z -> Re(z)^2+Im(z)^2, zs) od end());
time(proc() to 10^n do map(abs,zs) od end());
time(proc() to 10^n do map(z->op(1,z)^2+op(2,z)^2,zs) od end());

time(proc() to 10^n do [seq(Re(z)^2+Im(z)^2, z=zs)] od end());
time(proc() to 10^n do [seq(op(1,z)^2+op(2,z)^2,z=zs)] od end());

                                     7.570
                                     6.259
                                     6.879
                                    12.050
                                     7.079
                                     5.410
                                     5.610
Using seq is somewhat faster than map. The fastest here, Re(z)^2+Im(z)^2, is also robust, it works for pure reals and imaginaries.
Thanks for the suggestion, that looks like a useful function. One way to guarantee the order when mapping over Vectors and Matrices is to use LinearAlgebra:-Map. While its help page doesn't state that it maps from lowest to highest, it uses LinearAlgebra:-`Map/Internal` which uses a do loop with the indices.
counter := module()
export count,reset;
local cnt;
    reset := proc() cnt := 0 end;
    count := proc() cnt := cnt+1 end;
    reset()
end module:

M := Matrix([[0$5]$5]):
counter:-reset():
LinearAlgebra:-Map(counter:-count,M):
print(M);
                         [ 1     2     3     4     5]
                         [                          ]
                         [ 6     7     8     9    10]
                         [                          ]
                         [11    12    13    14    15]
                         [                          ]
                         [16    17    18    19    20]
                         [                          ]
                         [21    22    23    24    25]
That seems reasonable, however, there are a few cases where it would be convenient to be able to do just that. The order is unspecified. Is it consistent over rtables? That is, will consecutive maps over an rtable always use the same order (though it may change with versions of Maple)? I wouldn't count on that being the case for a regular table, but rtables are different. What about lists? Can I depend on the mapping order from call to call being consistent when mapping over a list?
To see the builtin commands do
seq(printf("%A\n",s), s=sort(map(convert,[anames](builtin),string)));
Also, using kernelopts(mapledir) makes Stephen's code work over any installation. I prefer a sorted single column of names, so:
L := LibraryTools:-ShowContents( cat(kernelopts(mapledir), "/lib/maple.mla" )):
L := map2( op, 1, L ):
L := remove( x->StringTools:-Search("/", x) > 0, L);
seq(printf("%A\n",s[1..-3]), s=sort(L));
Thanks for the explanation. I had tried using %1, however, I may have left off the backquotes so it didn't match. It works now.
Thanks for the explanation. I had tried using %1, however, I may have left off the backquotes so it didn't match. It works now.
See my notes on the problems I encountered while updating my Maple system. I did get it to work, with the helpful hints from Maplesoft.
Thanks Alec. Did you, by the way, edit you response a few times after originally posting it? I received about three email notifications, at 15:36, 15:39, and 15:41. I'm just wondering what caused that, or whether it is a bug in the system. Do you (or anyone) happen to know where the return address is placed on the stack in relation to the arguments? This could be system-dependent. It seems to me that if the caller is expected to clean the stack (which I think is the case for Linux), then the return address needs to be pushed on the stack after all the arguments have been. On the other hand, if the callee is supposed to be doing the cleaning, it is easier if the return address is first pushed onto the stack, followed by the arguments.
Thanks Alec. Did you, by the way, edit you response a few times after originally posting it? I received about three email notifications, at 15:36, 15:39, and 15:41. I'm just wondering what caused that, or whether it is a bug in the system. Do you (or anyone) happen to know where the return address is placed on the stack in relation to the arguments? This could be system-dependent. It seems to me that if the caller is expected to clean the stack (which I think is the case for Linux), then the return address needs to be pushed on the stack after all the arguments have been. On the other hand, if the callee is supposed to be doing the cleaning, it is easier if the return address is first pushed onto the stack, followed by the arguments.
I'm writing for Linux. So if I'm right (questionable) about the standard Linux/UNIX calling convention, then I don't need to pop the arguments off the stack, that will be handled by the code generated by define_external. I was trying to stay away from inline-assembly; this is more a learning project and that seemed one more detail.
I'm writing for Linux. So if I'm right (questionable) about the standard Linux/UNIX calling convention, then I don't need to pop the arguments off the stack, that will be handled by the code generated by define_external. I was trying to stay away from inline-assembly; this is more a learning project and that seemed one more detail.
How was the text that is between the input regions entered? That isn't possible with the current command-line maple. Or is this a display of a help page (rather than an interactive session)?
Maybe attachments can be larger for blogs. Or is that the only place that attachments are allowed? For instance, there is no option to add an attachment to a response.
First 188 189 190 191 192 193 194 Page 190 of 195