0

One of the package that is used for finite field at the Maple is use in package. Although the use in package make easy working with the finite field, when the use in package is used in the procedure at the Maple, the procedure made the following error:

Error, G is not a module or member

For example consider the shown procedure:

ffield:= proc(x::integer,y::integer,n::integer)
 local G,a,b; 
 G := GF(2, abs(n));
 print(G);
 a:=G:-input(x); 
 b:=G:-input(y);  
 use G in a/b end use; 
 end proc;

My Question: How to solve this error. I defined $G$ as a module but did not work.

Thanks for any suggestion

Edit: When I run your updated code, the following error made:

https://i.stack.imgur.com/FnOFR.jpg

Amin235
  • 1,867

1 Answers1

2

The issue is that G has not yet been defined at the time the use ... end use statement is being processed in creating the procedure. The finite field (a module) G is defined when you execute the procedure with specific arguments. The use ... end use statement is processed when the procedure ffield is created. Since G is not yet known at that time, it is not possible to process the use statement, since the exports of G are, of course, not yet known.

The correct way to code this is to write explicit bindings for the module exports in the use statement. For example,

ffield:= proc(x::integer,y::integer,n::integer)
   local G,a,b; 
    G := GF(2, abs(n));
    print(G);
    a:=G:-input(x); 
    b:=G:-input(y);  
    use `*` = G:-`*`, `/` = G:-`/` in a/b end use; 
end proc;

This form of the use statement does not require the exports of G to be known (as they cannot be) when the procedure ffield is being created.

James
  • 9,272
  • At first i thank you for your answer but when I run your code at the Maple, the following error appear: Error, G does not evaluate to a module. did you run your code at the Maple? – Amin235 Jul 09 '17 at 22:24
  • 1
    Yes, I executed the procedure definition and ran it on a couple of sample inputs, and it worked correctly for me. For example, calling it as ffield( 2, 4, 11 ) produced the output $1 + T^7 + T^8 + T^{11}$. (I'm not sure whether you want the result in that form; if not you might write "G:-output( a/b )" instead of just "a/b".) – James Jul 09 '17 at 23:17
  • I edit my question to show the error. It is possible to ask you to see this error in picture and say what should I do to remove this error. Thanks – Amin235 Jul 09 '17 at 23:41
  • 1
    Well, I re-tried this in Maple 15 (I had used a more recent version earlier) just in case there was some difference, but it still worked fine for me. At this point, your issues seem to be going beyond just Maple concepts, so you should probably take this over to technical support for additional help, or ask about it over on the MaplePrimes site. – James Jul 10 '17 at 16:00
  • I appreciate for your useful comment. I think, it's better that I upgrade my Maple. Is it possible to tell me which version of Maple you have installed? – Amin235 Jul 10 '17 at 21:00
  • I have the latest release, Maple 2017. It was actually just released very recently. However, I do think your example should work in Maple 15 you already have, as it worked for me in that version too. – James Jul 10 '17 at 21:04
  • I dont know why your code run in your Maple 15 but for me did not work as I showed at the picture. By the way, thanks again for your answer and all comments. – Amin235 Jul 10 '17 at 21:06