--* From postmaster%watson.vnet.ibm.com@yktvmv.watson.ibm.com  Wed Aug 17 08:05:32 1994
--* Received: from yktvmv-ob.watson.ibm.com by asharp.watson.ibm.com (AIX 3.2/UCB 5.64/930311)
--*           id AA23501; Wed, 17 Aug 1994 08:05:32 -0400
--* Received: from watson.vnet.ibm.com by yktvmv.watson.ibm.com (IBM VM SMTP V2R3)
--*    with BSMTP id 0509; Wed, 17 Aug 94 08:05:36 EDT
--* Received: from YKTVMV by watson.vnet.ibm.com with "VAGENT.V1.0"
--*           id <A.BILL.NOTE.YKTVMV.0393.Aug.17.08:05:36.-0400>
--*           for asbugs@watson; Wed, 17 Aug 94 08:05:36 -0400
--* Received: from nagrs2.nag.co.uk by watson.ibm.com (IBM VM SMTP V2R3) with TCP;
--*    Wed, 17 Aug 94 08:05:25 EDT
--* Received: by nagrs2.nag.co.uk (AIX 3.2/UCB 5.64/4.03)
--*           id AA17539; Wed, 17 Aug 1994 12:59:59 +0100
--* Date: Wed, 17 Aug 1994 12:59:59 +0100
--* From: bill@nagrs2.nag.co.uk (W.A.Naylor)
--* Message-Id: <9408171159.AA17539@nagrs2.nag.co.uk>
--* To: asbugs@watson.ibm.com
--* Subject: [2] gives error message Bug: tfAuditExportList on compilation of any file above a reasonable size

--@ Fixed  by:  SSD   Fri Nov 11 11:04:42 EST 1994 
--@ Tested by:  none 
--@ Summary:    tfAuditExportList was signalling bug in parent symbol meanings which was fixed just after r1-0-2. 

-- Command line: asharp -Faso -laxiom -Daxiom -M no-emax myEigFuns.as
-- Version: A# version 0.36.3 for AIX RS/6000
-- Original bug file name: myEigFuns.as

#include "axiom.as"

EIG ==> MyEigenFunctions;
B ==> Boolean;
S ==> Symbol;
I ==> Integer;
L ==> List;
M ==> Matrix;
E ==> Expression;
P ==> Polynomial;
V ==> Vector;
F ==> Fraction;
ST ==> SuchThat;
FCT ==> Factored;
EQ ==> Equation;
OF ==> OutputForm;
LOF ==> List OutputForm;
LLOF ==> List List OutputForm;
PI ==> Polynomial Integer;
FI ==> Fraction Integer;
NNI ==> NonNegativeInteger;
MPI ==> Matrix Polynomial Integer;
FPI ==> Fraction Polynomial Integer;
PFI ==> Polynomial Fraction Integer;
EI ==> Expression Integer;
VEI ==> Vector Expression Integer;
MEI ==> Matrix Expression Integer;
VFPI ==> Vector Fraction Polynomial Integer;
MFPI ==> Matrix Fraction Polynomial Integer;
VS ==> Vector Symbol;
V2 ==> VectorFunctions2;
L2 ==> ListFunctions2;
E2 ==> ExpressionFunctions2;
M2 ==> MatrixCategoryFunctions2;
GEVT ==> Record(GENVEC: VFPI,SYM: S);
ETYPEUN ==> Union(N:Enumeration (requireNumeric),SYMB:L L Expression Integer);
SSP ==> SystemSolvePackage Integer;
EP ==> EigenPackage;
UP ==> UnivariatePolynomial(x,Fraction Polynomial Integer);
PTUP ==> PolynomialToUnivariatePolynomial(x,Fraction Polynomial Integer);
SUPPI ==> SparseUnivariatePolynomial Polynomial Integer;
RETYPE ==>
  Record(retEval:
    Union(N:Enumeration (requireNumeric),SYMB:L L Expression Integer),retEvec:
      GEVT);
+++
MyEigenFunctions(): with {

--        myEvec: MPI -> GEVT;
--        eigenStuff: MPI -> RETYPE;
        quadratic: MPI -> ETYPEUN;
--        cubic: MPI -> ETYPEUN;
}
== add {
        cc ==> coefficient$SparseUnivariatePolynomial(Polynomial(Integer));
        uni ==> univariate$Polynomial(Integer);
        t (n:I):EI == {
                import from S;
                script("T"::S,[[n::OutputForm]$LOF]$LLOF)::EI;
        }

        quadratic (m:MPI):ETYPEUN == {

                import from EI;
                import from FI;
                import from EP(I);

                m2:MFPI := {import from M2(
                               PI,V(PI),V(PI),MPI,FPI,VFPI,VFPI,MFPI);
                  map(((%1:PI):FPI) +->%1::FPI,m)}
                x:S := new()$S;
                cP:PI := characteristicPolynomial(m2,x)$EP(I);
                a:EI :=
                  coefficient(univariate(cP,x)$PI,2@I pretend NNI)$SUPPI::EI;
                b:EI :=
                  coefficient(univariate(cP,x)$PI,1@I pretend NNI)$SUPPI::EI;
                c:EI :=
                  coefficient(univariate(cP,x)$PI,0@I pretend NNI)$SUPPI::EI;
                r:EI := (b ^ 2@I - 4@I * a * c) **$EI (1@I /$FI 2@I);

                 [[[r],[(- b + u) / (2@I * a) for u in [- t 0,t 0]]]]$ETYPEUN;
        }

        local w3:EI := {import from FI;

          - 1@EI + (- 3@I::EI) **$EI (1@I /$FI 2@I) / 2@I::EI;
        }

        lhs (eql:EQ(PI)):PI == {
          lhs(eql)$EQ(PI);}

        equ(x:EI,y:EI):Boolean == {
                import {coerce : I -> PFI;} from PFI;
                import from Union(value1:E(PFI),failed:'failed');
                z:E(PFI):= map(((%1:I):PFI) +->%1::PFI,(x -$EI y))$E2(I,PFI);
                G1078 := recip(z)$E(PFI) case failed;
                G1078 => true;
                false;
        }

        eigenStuff(m:MPI):RETYPE == {

                import {coerce:PI->EI;} from EI;
                import from GEVT;
                import from ETYPEUN;

                len:NNI := rank(m);
                len = 1@I pretend NNI =>
          [[[nil$L(EI),[apply(m,1@I,1@I)$MPI::EI]$L(EI)]$L(L(EI))]$ETYPEUN,
           [new(1@NNI,1@FPI)$VFPI,new()$S]$GEVT]$RETYPE;
                len = 2@NNI => [quadratic(m),myEvec(m)]$RETYPE;
                len = 3@NNI => [cubic(m),myEvec(m)]$RETYPE;
                [[requireNumeric]$ETYPEUN,
                 [new(1@NNI,1@FPI)$VFPI,"S"::S]$GEVT]$RETYPE;
        }

        myEvec(m:MPI):GEVT == {

                import from FPI;
                import from S;

                x := new()$S;
                m2:MFPI :=
map((%1:PI):FPI +-> %1::FPI,m)$M2(PI,V(PI),V(PI),MPI,FPI,VFPI,VFPI,MFPI);
                alpha:ST(S,PI) :=
construct("s"::S,characteristicPolynomial(m2,x)$EigenPackage(I))$SuchThat(S,PI);
               [column(
apply(generalizedEigenvector([alpha]$Union(value1 : FPI,value2 : ST(S,PI))
,m2,1@I pretend NNI,1@I pretend NNI)$EigenPackage(I),1@I)$L(MFPI)
  ,(1@I))$MFPI,x]$GEVT;
        }

--        cubic (m:MPI):ETYPEUN == {
--                import from EI;
--                import from SUPPI;
--                import from PI;
--                import {coerce:PI->FPI;} from FPI;
--                import from RETYPE;
--                m2:MFPI :=
--                  map(coerce$FPI,m)$M2(PI,V(PI),V(PI),MPI,FPI,VFPI,VFPI,MFPI);
--                retValVal:L EI := nil$L(EI);
--                x:S := new()$S;
--                cP:PI :=
--characteristicPolynomial(m2,x)$EP(I);
--                c3:EI := coefficient(univariate(cP,x)$PI,3@I pretend NNI
--                                    )$SUPPI::EI;
--                c2:EI := coefficient(univariate(cP,x)$PI,2@I pretend NNI
--                                    )$SUPPI::EI;
--                c1:EI := coefficient(univariate(cP,x)$PI,1@I pretend NNI
--                                    )$SUPPI::EI;
--                c0:EI := coefficient(univariate(cP,x)$PI,0@NNI)$SUPPI::EI;
--                a1:EI := c2 /$EI c3;
--                a2:EI := c1 /$EI c3;
--                a3:EI := c0 /$EI c3;
--                p:EI := -$EI t (2@I) /$EI (3@I)::EI;
--                G1079 := equ(a1 ^$EI 2@I,3@I *$EI a2);
--                G1079 => {
--                        s:EI :=
--                          -$EI t(2@I) +$EI t(1@I) ^$EI 3@I
--                            /$EI (27@I)::EI **$EI (1@I /$FI 3@I);
--                        [[[w3,a1,a3,p,s],
--                          [t (3@I) +$EI t (4@I) *$EI u
--                            for u in [(1@I)::EI,t 0,
--                              t 0 ^$EI 2@I]]]]$ETYPEUN;
--                }
--                q:EI :=
--                  3@I *$EI t (2@I) -$EI t (1@I) ^$EI 2@I /$EI (9@I)::EI;
--                r:EI :=
--                  9@I *$EI t(1@I) *$EI t(2@I) -$EI 27@I *$EI t(3@I) -$EI 2@I
--                  *$EI t(1@I) ^$EI 3@I /$EI (54@I)::EI;
--                d:EI :=
--                  (t(5@I) ^$EI 3@I +$EI t(6@I) ^$EI 2@I) **$EI (1@I /$FI 2@I);
--                s:EI :=
--                  t(6@I) +$EI t(7@I) **$EI (1@I /$FI 3@I);
--                [[[w3,a1,a2,a3,p,q,r,d,s],
--                  [t(4@I) +$EI t(8@I) *$EI u -$EI
--                    t(5@I) /$EI t(8@I) *$EI u
--                      for u in [1@Expression Integer,t 0,t 0 ^$EI 2@I]]]]$
--                  ETYPEUN;
--        }
}
 
--+ asharp% asharp -Y libaxiom -Faso -laxiom -Daxiom -M no-emax bug811.as
--+ "bug811.as", line 107: 
--+                  [[[r],[(- b + u) / (2@I * a) for u in [- t 0,t 0]]]]$ETYPEUN;
--+ ..............................................^...^
--+ [L107 C47] #1 (Error) There are no suitable meanings for the operator `u'.
--+ [L107 C51] #2 (Error) No meaning for identifier `u'.
--+ 
--+ "bug811.as", line 138: 
--+                 len = 3@NNI => [cubic(m),myEvec(m)]$RETYPE;
--+ ................................^
--+ [L138 C33] #3 (Error) There are no suitable meanings for the operator `cubic'.
--+ 
