Question: 2-D Input vs 1-D Input

I have run into a "funny" feature of 2-D input: It seems to convert something like k/2 into this k*`^`(2,-1). While this would often not be an issue (it is correct after all), it becomes a problem when used in an argument list to a procedure. It becomes even more of a problem when, by chance, I have overloaded `^` to act on specific types that I have defined.

Let me try to explain briefly. I have a package called "Lattice" that does whatever it does (not of relevance here). I am writing a little manual for this package, for which I use 2-D input so I can write it in Maple and have the examples right in it and "live".

Here is what happens:

with(Lattice) # load the package

QFh:=Quad(0,kf/2) # Define an element for Lattice

Error, invalid input: Lattice:-`^` expects its 1st argument, element, to be of type Element, but received 2

Copy-pasting kf/2 into a 1-d worksheet, I get

QFh := Quad(0, kf*Lattice[`^`](2, -1));

So it uses Lattice[`^`] which actually appears to bypass the overload I have in the Lattice package. `^` is defined like this in Lattice:

`^`:=proc(element::Element,n::algebraic) option overload; # Element is a defined type in Lattice
...
end proc;

How can I possibly rewrite `^` to fall-back to Maple's ^ operator when called as Lattice[`^`] ?? I know there is a function overload() but have no experience with it. Would it even help?

Or am I missing something completely here? I do not use 2-D input for my usual work, but in this case I want and need to use it. The reason for its bizarre rewrite of "/2" is beyond me. Note that I can replace /2 by *0.5; but that causes problems later on for algebraic work as 1/2 is not 0.5 in Maple. I tried *1/2 but that has the same problem.

Has anyone a clean solution for this? I assume this effect is not limited to my own package but would affect others as well.

M.D.

PS: I ran into this using Maple 15 but I doubt it is specific to this particular version.

Please Wait...