Mac Dude

1182 Reputation

16 Badges

8 years, 92 days

MaplePrimes Activity


These are replies submitted by Mac Dude

Ok, so here is what I came up with, based on your suggestion:

Subs:=proc(eqn::seq(equation),elemt::Element) # option overload;
description "subs command for Elements or BeamLines";
local qs:=[exports(elemt)];
return Record(seq(qs[i]=:-subs(eqn,q[qs[i]]),i=1..numelems(qs)));
end proc;

This is a part of a package that gets loaded using with() and that also defines the Element type I use in the arglist.

I did not yet manage to get the overload to work, that's why it is commented out. If I overload subs (with small s) then it fails to use my subs procedure for more than one replacement given.

Thanks,

M.D.

Ok, so here is what I came up with, based on your suggestion:

Subs:=proc(eqn::seq(equation),elemt::Element) # option overload;
description "subs command for Elements or BeamLines";
local qs:=[exports(elemt)];
return Record(seq(qs[i]=:-subs(eqn,q[qs[i]]),i=1..numelems(qs)));
end proc;

This is a part of a package that gets loaded using with() and that also defines the Element type I use in the arglist.

I did not yet manage to get the overload to work, that's why it is commented out. If I overload subs (with small s) then it fails to use my subs procedure for more than one replacement given.

Thanks,

M.D.

@ilods I have not looked at Preben's solution but in my own work I force numerics by substituting as many variables as I can with their explicit values early on, before doing any manipulation. Then Maple combines the numeric terms as much as possible (maybe I need to enlist the help of evalf, expand, simplify or such) and I am left with an expression depending only on x and y, or whatever the case may be; so I can e.g. plot it. Setting Digits to 15 as Axel suggests gives maximum accuracy while still allowing Maple to use hardware floating point arithmetic (I do that in my .mapleinit file) so things are at least reasonably fast.

As for the length: you can of course suppress output with ":" instead of ";" at the end. Maple will grind through the long expressions and when you then substitute the values it may all come out right, if not fast. I believe you could also change the threshold for this kind of message (maybe it is a kernelopt? I forgot) but that seems ill advised.

Mac Dude

@ilods I have not looked at Preben's solution but in my own work I force numerics by substituting as many variables as I can with their explicit values early on, before doing any manipulation. Then Maple combines the numeric terms as much as possible (maybe I need to enlist the help of evalf, expand, simplify or such) and I am left with an expression depending only on x and y, or whatever the case may be; so I can e.g. plot it. Setting Digits to 15 as Axel suggests gives maximum accuracy while still allowing Maple to use hardware floating point arithmetic (I do that in my .mapleinit file) so things are at least reasonably fast.

As for the length: you can of course suppress output with ":" instead of ";" at the end. Maple will grind through the long expressions and when you then substitute the values it may all come out right, if not fast. I believe you could also change the threshold for this kind of message (maybe it is a kernelopt? I forgot) but that seems ill advised.

Mac Dude

To expand a little on Jörg's answer:

In Maple, assignments are done by ":=". The "=" is a logical expression, not an assignment.

You define a function by writing f:=(x)-> a*x+b*x^2+c  i.e. using the arrow operator (there are other ways but this is the quickest way for a statement function). Assigning an expression to f(x) makes the whole f(x) a name (which is not f(y)); usually not what you want.

As to Maple vs Matlab: it really depends what you want to do. Maple is primarily a Computer Algebra System; Matlab is primarily a tool for numeric evaluations esp. involving matrices. So if you are looking for analytic solutions, Maple is your friend. If you routinely deal with large numerical problems; Matlab is. (And, yes, I am simplifying greatly here.)

Note however, that both systems have aspects of the other side as well (certainly Maple can do a lot of numerics; I believe late versions of Matlab have a certain amount of symbolic capability added) and in fact can access each other at a certain level (the details of which I have not explored at all).

HTH,

Mac Dude

To expand a little on Jörg's answer:

In Maple, assignments are done by ":=". The "=" is a logical expression, not an assignment.

You define a function by writing f:=(x)-> a*x+b*x^2+c  i.e. using the arrow operator (there are other ways but this is the quickest way for a statement function). Assigning an expression to f(x) makes the whole f(x) a name (which is not f(y)); usually not what you want.

As to Maple vs Matlab: it really depends what you want to do. Maple is primarily a Computer Algebra System; Matlab is primarily a tool for numeric evaluations esp. involving matrices. So if you are looking for analytic solutions, Maple is your friend. If you routinely deal with large numerical problems; Matlab is. (And, yes, I am simplifying greatly here.)

Note however, that both systems have aspects of the other side as well (certainly Maple can do a lot of numerics; I believe late versions of Matlab have a certain amount of symbolic capability added) and in fact can access each other at a certain level (the details of which I have not explored at all).

HTH,

Mac Dude

@Alejandro: It looks like I ran into this error because I created the Array with only one element so I may in fact have had a situation like you show, with the "unusual" range. I do this because I cannot have unused lements at the end of the array. It is quite curious.I don't have the crashing version anymore and my code (with datatype anything like Preben suggested) works so I can't reliably reproduce what I did but I know I did not specify an actual range (like 1..2 or so) in the Array constructing function (Array()). Now I am wondering whether I can get this to work with strings and a valid initial range...

The reason why I ranted about the bug is that in less than a year of doing serious (in the sense that I actually want and use the results) work with Maple I have run into quite a number of "undocumented features" that by and large are not that obscure. While I fully understand that software has bugs; it is also true that bugs can be fixed, esp. relatively simple ones like the issue we are talking about here. The dynamic length of rtables is an advertised (in the handbooks) feature and not some obscure, rarely known oddity. It would be a part of the test suite(s), one might have thunk...

Oh well, "Caveat Coder". Maybe I'l submit a software performance report.

Mac Dude.

@Alejandro: It looks like I ran into this error because I created the Array with only one element so I may in fact have had a situation like you show, with the "unusual" range. I do this because I cannot have unused lements at the end of the array. It is quite curious.I don't have the crashing version anymore and my code (with datatype anything like Preben suggested) works so I can't reliably reproduce what I did but I know I did not specify an actual range (like 1..2 or so) in the Array constructing function (Array()). Now I am wondering whether I can get this to work with strings and a valid initial range...

The reason why I ranted about the bug is that in less than a year of doing serious (in the sense that I actually want and use the results) work with Maple I have run into quite a number of "undocumented features" that by and large are not that obscure. While I fully understand that software has bugs; it is also true that bugs can be fixed, esp. relatively simple ones like the issue we are talking about here. The dynamic length of rtables is an advertised (in the handbooks) feature and not some obscure, rarely known oddity. It would be a part of the test suite(s), one might have thunk...

Oh well, "Caveat Coder". Maybe I'l submit a software performance report.

Mac Dude.

@Preben: You are correct; this morning I also traced my problem to the string datatype. Worse, trying to workaround by pre-allocating the space (e.g. assigning element 256 with a dummy value) fails also. Your test indicates that datatype=anything works, I need to check that on my system still.

This whole issue seems slightly disturbing, though. I use an Array rather then Vector for the strings; it seems entirely without reason why that should fail for strings (unless total memory exhaustion, of course). If this is a bug (which I am beginning to suspect), how can it have evaded detection?

Anyway, thanks for looking & finding a way out, much appreciated

Mac Dude.

@Preben: You are correct; this morning I also traced my problem to the string datatype. Worse, trying to workaround by pre-allocating the space (e.g. assigning element 256 with a dummy value) fails also. Your test indicates that datatype=anything works, I need to check that on my system still.

This whole issue seems slightly disturbing, though. I use an Array rather then Vector for the strings; it seems entirely without reason why that should fail for strings (unless total memory exhaustion, of course). If this is a bug (which I am beginning to suspect), how can it have evaded detection?

Anyway, thanks for looking & finding a way out, much appreciated

Mac Dude.

@acer My mistake was in the "topic" entry in makehelp. After I sorted this out it works using the package/command syntax indicated in the help for makehelp. Just have got to be consistent here... :-)

Thanks again,

M.D.

@acer My mistake was in the "topic" entry in makehelp. After I sorted this out it works using the package/command syntax indicated in the help for makehelp. Just have got to be consistent here... :-)

Thanks again,

M.D.

Well, the "Save to Database..." item does not exist in any menu in my Maple 15.01 on OS X 10.4. The only related item is "Save as Help Page..." on the "Help Database" menu item under Tools. However, that one brings up a nearly empty dialog (making me enter all the info all over again... highly annoying) and then refuses to overwrite the old page claiming it is already there (well, duh!).

Your hints above did get me further. The procedure you showed is a little too complicated for my taste; but I managed to get "makehelp" to work. It picked a different .hdb file than I wanted (I wanted to make a new one) but at least I get the help file displayed and updating.

I did run into another snag: How do I specify links to the other help pages? I have a top-level one (for the package) and one each for the commands in the package. I installed one under a name but the "Help:Package/command" link does not work. The command shows up in the help browser on the left side (as "Command (Package)" so all is not lost; but getting the link to work should not be that difficult.

Thanks,

M.D.

Well, the "Save to Database..." item does not exist in any menu in my Maple 15.01 on OS X 10.4. The only related item is "Save as Help Page..." on the "Help Database" menu item under Tools. However, that one brings up a nearly empty dialog (making me enter all the info all over again... highly annoying) and then refuses to overwrite the old page claiming it is already there (well, duh!).

Your hints above did get me further. The procedure you showed is a little too complicated for my taste; but I managed to get "makehelp" to work. It picked a different .hdb file than I wanted (I wanted to make a new one) but at least I get the help file displayed and updating.

I did run into another snag: How do I specify links to the other help pages? I have a top-level one (for the package) and one each for the commands in the package. I installed one under a name but the "Help:Package/command" link does not work. The command shows up in the help browser on the left side (as "Command (Package)" so all is not lost; but getting the link to work should not be that difficult.

Thanks,

M.D.

Now you guys make me curious! I know that I have a copy on Maple V R2 or even R3 lying around---on floppies, no less---maybe is should spend this weekend to dig it out & install it...?? But I certainly do not have any license numbers or keys for these anymore.

I do wonder, however, why you want to. As far as I can tell, the old packages (linalg etc.) are still around, if deprecated. I have downloaded quite a number of Maple V programs and code snippets from the net and so far have not run into any problems (this is with Maple 15). In those days I ran Mma so I don't have old Maple routines of myself.

One thing I would yearn for is to be able to use the older interface of Maple (I think they call that "classic"), Running on Mac's I do not have access to it. The Java interface we are made to use is in my view not quite up to it; being sluggish and having rendering issues. In addition it does not take full advantage of running in a separate thread: I find when the Maple kernel is busy the interface is mostly locked up. The only good thing I see is that, on a multicore machine, mserver can get 100% CPU on one core & let any GUI overhead run on the other one. I would run in CLI mode if it were not for the graphics output, which I would not want to miss; and I do not think Maple supports something like AquaTerm (graphics screen for CLI processes on Mac OS X).

Anyway, so far I thought Maple's backward compatibility to V is not bad.

Mac Dude

First 33 34 35 36 37 38 39 Page 35 of 39