sigl1982

95 Reputation

4 Badges

9 years, 54 days

MaplePrimes Activity


These are questions asked by sigl1982

Hi,

The error "warning bad name, cannot profile...." occurred and I don't know why. Here my minimal example,

test.mw

Does anyone knows the reason?

 

Hi,

I want to write my first module, and I failed!  I create an instance of the class (module?)

myList := TestModule(3);                    # works.

But I've no acess to the members, since I use export! What's wrong?

myList:-get_n;
myList:-set_n(20);
myList:-run();

Error, `myList` does not evaluate to a module
Error, `myList` does not evaluate to a module
Error, `myList` does not evaluate to a module


# *****************************************************************************

TestModule := module()
    export get_n, set_n, run;
    local  n, result, ModuleApply, profileRun;
    option package;
    description "A testmodule";

    # Constructor
    ModuleApply := proc(n)
        print("Calling of Module Apply...");
         thismodule:-n := n;
         result := [];
         profileRun();
         return result;
     end proc:


    # Implementation of member run
     run := proc()
         print("Calling of run...");
         dummy := [];
         for i from 1 to 20000 do
            dummy := [op(dummy), i]
         end do;
         result := TRUE;
    end proc;
    
    # Implementation of member runprofile;
     profileRun := proc()
          print("Call of profileRun...");
          CodeTools[Profiling]:-Profile(run);
           run();
           CodeTools[Profiling]:-PrintProfiles(run);
           CodeTools[Profiling]:-UnProfile(run);
     end proc;

     # getter
     get_n := proc()
         n;
     end proc;

     # setter
     set_n := proc(n)
         thismodule:-n := n;
     end proc;
     
end module;

 

Hello again,

Everytime I start an (I thought deteministic) algorithm the number, how often a loop run through, is different. That makes debugging and profiling hard. But tests say, the algorithm works well.

I analized my code, I think different set orders can cause the problem.

Can indexing a set change its order ?
Can set operations like minus or union gives different result-orders in different times?

Can a set operation like minus or union change the order of the origin sets?

Hello,

my problem is as follows. Given


g := [g1, g2, ... , g99];    # a list of polynomials,  high  in degree and with big coefficients

S := [1, 3, 14, 29];        # Set of indices, which polynomials we want to multiply

p := 11;   # the modulus

------------------------------------------------------------------------------------------------------------------------------


I want to calculate the product of the constant-terms of the indexed g, that means for example

cg1 * cg3 * cg14 * cg29  mod p         

where cgi means coeff(g[i], x, 0), and mod should be mods,  using symmetric representatives

 

Till now I'm using:

    mods(mul(coeff(g[i], x, 0), i in S), p)


It works, but the problem is, that the order is not optimal and costs too much time.

The order is for example:
(3  *  5 * 7 * 9) mod 11;

But I need for efficieny an order like:
(((3 * 5 mod 11) * 7 mod 11) * 9 mod 11

I read about the fold operators, but I've no idea how to combine these with mul and mods to get what I need.

 

Hi everybody,

I got an error message, when i try to profile code with a goto statement inside.
Here is my minimal-example in Maple18. Is there a known conflict or what's wrong?

f := proc(x)
    if x < 0 then goto(POS): end if;
    return "A";
    
    POS:
    return "B";
end proc:

f(-3);
                              "B"
f(3);
                              "A"

CodeTools[Profiling]:-Profile(f);
f(-3);
CodeTools[Profiling]:-PrintProfiles(f);
CodeTools[Profiling]:-UnProfile(f);

Error, (in f) goto to an undefined or unreachable label
f
f := proc(x)
     |Calls Seconds  Words|
PROC |    1   0.000      3|
      1 |    1   0.000      3| if x < 0 then
      2 |    1   0.000      0|   goto(POS)
                               end if;
      3 |    0   0.000      0| return "A";
      4 |    0   0.000      0| POS;
      5 |    0   0.000      0| return "B"
end proc

1 2 3 Page 2 of 3