Procedure/Module Help

March 22 2010 by Ukvayat 52
false
Maple

0


I've been working on my master's project and am at (at least I hope I've got it) the final stage of making Maple do everything that I want it to. I have the flow chart here which is a little hard to see while looking at the module I have set up.

The difficulty I'm having is getting it to run as a whole. I just do not know what I need to do to get the thing started. The way I have it set up is that each procedure references another until they are done - a loop structure. Which may be more appropriate but I humbly submit it to you.

I do not completely understand the module pieces. I do know that each procedure I have inside of here should work (and if not, that's why it's a master's problem :D)

Thank you again for looking!

 (I know the local and export may not be correct, and sorry for the matrix multiplication looking so ugly here)

> LocSubAlg:=module()
    description "the local subcase algorithm";
    option package;
    local Start, DegCk, Step1, Step2, UnitCk, Step3, Step4;
    export a, b, c, d, g, h, k, l, m, n, p, z, A, alpha, alpha1, beta, beta1, beta2, Print;
    Start:= proc()
        a:=readstat("Please enter the polynomial a: ");
        b:=readstat("Please enter the polynomial b: ");
        c:=readstat("Please enter the polynomial c: ");
        d:=readstat("Please enter the polynomial d: ");
          with(linalg):
          A:= Matrix(3,3);
          A[1,1]:= a;
          A[1,2]:= b;
          A[2,1]:= c;
          A[2,2]:= d;
          alpha:= Matrix(3, 3, shape = identity);
          beta:= Matrix(3, 3, shape = identity);
        DegCk;
    end proc;
    DegCk := proc ()
        m := degree(a, t);
        if m = 0 then
          Step4
        elif m>degree(b, t) then
          UnitCk
        elif m <= degree(b, t) then
          Step1
        end if;
    end proc;
    Step1:= proc()
        quo(b, a, t, 'q');
        with(linalg):
        A:=A*(Matrix([[1, -q, 0], [0, 1, 0], [0, 0, 1]]));
        beta:=beta*(Matrix([[1, -q, 0], [0, 1, 0], [0, 0, 1]]));
        UnitCk;
    end proc;
    UnitCk:= proc()
        z:=eval(b, t=0);
        if type(z, complex)=true and z<>0 then
           Step2
        else Step3
        end if;
    end proc;
    Step2:= proc()
        g:=eval(a, t=0);
        h:=eval(b, t=0);
        k:=(-g/h);
        l:=((h-b)/t);
        m:=(t*h);
        n:=((-c*(h-b)-a*d*t)/m);
        with(linalg):
        A:=A*(Matrix([[1, 0, 0], [k, 1, 0], [0, 0, 1]]));
        beta:=beta*(Matrix([[1, 0, 0], [k, 1, 0], [0, 0, 1]]));
        a:=a/t;
        alpha1:=(Matrix([[1, 0, 0], [0, 0, 1], [0, -1, 0]]))                                                        *(Matrix([[1, 0, 0], [0, 1, -a*d], [0, 0, 1]]))                                                     *(Matrix([[1, 0, 0], [c*d, 1, 0], [0, 0, 1]]));
        beta1:=(Matrix([[1, 0, 0], [0, 1, 0], [t*c, 0, 1]]))                                                        *(Matrix([[1, 0, 0], [0, 1, 0], [0, t*d, 1]]))                                                      *(Matrix([[1, 0, 0], [0, 1, -a], [0, 0, 1]]))                                                       *(Matrix([[1, 0, 0], [0, 0, 1], [0, -1, 0]]));
        beta2:=(Matrix([[1, l, 0], [0, 1, 0], [0, 0, 1]]))                                                          *(Matrix([[g, 0, 0], [0, g^(-1), 0],[0, 0, 1]]))                                                    *(Matrix([[0, -1, 0], [1, 0, 0], [0, 0, 1]]))                                                       *(Matrix([[1, m, 0], [0, 1, 0], [0, 0, 1]]))
                *(Matrix([[1, 0, 0], [n, 1, 0], [0, 0, 1]]))                                                        *(Matrix([[1, 0, 0], [0, 0, -1], [0, 1, 0]]));
        alpha:=alpha1*alpha;
        beta:=beta*beta1;
        A:=alpha1*A*beta1*beta2;
        DegCk;
    end proc;
    Step3:= proc()
        gcdex(a, b, resultant(a,b,t), t, 'v', 'w');
        p:=(w*d-v*c);
        with(linalg):
        alpha1:=(Matrix([[1, 1, 0], [0, 1, 0], [0, 0, 1]]))                                                         *(Matrix([[1, 0, 0], [p, 1, 0], [0, 0, 1]]));
        alpha:=alpha1*alpha;
        A:=alpha1*A;
        Step2;
    end proc;
    Step4:= proc()
        with(linalg):
        alpha1:=(Matrix([[1, -b, 0], [0, 1, 0], [0, 0, 1]]));
        beta1:=(Matrix([[1, 0, 0], [-c, 1, 0], [0, 0, 1]]));
        alpha:=alpha1*alpha;
        beta:=beta*beta1;
        A:=alpha1*A*beta1;
        Print;
    end proc;
    Print:=proc()
        print(A);
    end proc;
end module;
 
 
Loading Comments & Answers

You must be logged into your MaplePrimes account in order to post a comment. If you don't have an account, you can create an account here.

     

Forgot Your Password? Create an Account