/usr/share/axiom-20170501/src/algebra/FACUTIL.spad is in axiom-source 20170501-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | )abbrev package FACUTIL FactoringUtilities
++ Author: Barry Trager
++ Date Created: March 12, 1992
++ Description:
++ This package provides utilities used by the factorizers
++ which operate on polynomials represented as univariate polynomials
++ with multivariate coefficients.
FactoringUtilities(E,OV,R,P) : SIG == CODE where
  E : OrderedAbelianMonoidSup
  OV : OrderedSet
  R : Ring
  P : PolynomialCategory(R,E,OV)
  SUP ==> SparseUnivariatePolynomial
  NNI ==> NonNegativeInteger
  Z   ==> Integer
  SIG ==> with
    completeEval : (SUP P,List OV,List R) -> SUP R
      ++ completeEval(upoly, lvar, lval) evaluates the polynomial upoly
      ++ with each variable in lvar replaced by the corresponding value
      ++ in lval. Substitutions are done for all variables in upoly
      ++ producing a univariate polynomial over R.
    degree : (SUP P,List OV) -> List NNI
      ++ degree(upoly, lvar) returns a list containing the maximum
      ++ degree for each variable in lvar.
    variables : SUP P -> List OV
      ++ variables(upoly) returns the list of variables for the coefficients
      ++ of upoly.
    lowerPolynomial : SUP P -> SUP R
      ++ lowerPolynomial(upoly) converts upoly to be a univariate polynomial
      ++ over R. An error if the coefficients contain variables.
    raisePolynomial : SUP R -> SUP P
      ++ raisePolynomial(rpoly) converts rpoly from a univariate polynomial
      ++ over r to be a univariate polynomial with polynomial coefficients.
    normalDeriv : (SUP P,Z) -> SUP P
      ++ normalDeriv(poly,i) computes the ith derivative of poly divided
      ++ by i!.
    ran : Z -> R
      ++ ran(k) computes a random integer between -k and k as member of R.
  CODE ==> add
     lowerPolynomial(f:SUP P) : SUP R ==
       zero? f => 0$SUP(R)
       monomial(ground leadingCoefficient f, degree f)$SUP(R) +
           lowerPolynomial(reductum f)
     raisePolynomial(u:SUP R) : SUP P ==
       zero? u => 0$SUP(P)
       monomial(leadingCoefficient(u)::P, degree u)$SUP(P) +
           raisePolynomial(reductum u)
     completeEval(f:SUP P,lvar:List OV,lval:List R) : SUP R ==
       zero? f => 0$SUP(R)
       monomial(ground eval(leadingCoefficient f,lvar,lval),degree f)$SUP(R) +
              completeEval(reductum f,lvar,lval)
     degree(f:SUP P,lvar:List OV) : List NNI ==
       coefs := coefficients f
       ldeg:= ["max"/[degree(fc,xx) for fc in coefs] for xx in lvar]
     variables(f:SUP P) : List OV ==
       "setUnion"/[variables cf for cf in coefficients f]
     if R has FiniteFieldCategory then
        ran(k:Z):R == random()$R
     else
        ran(k:Z):R == (random(2*k+1)$Z -k)::R
  -- Compute the normalized m derivative
     normalDeriv(f:SUP P,m:Z) : SUP P==
       (n1:Z:=degree f) < m => 0$SUP(P)
       n1=m => (leadingCoefficient f)::SUP(P)
       k:=binomial(n1,m)
       ris:SUP:=0$SUP(P)
       n:Z:=n1
       while n>= m repeat
         while n1>n repeat
           k:=(k*(n1-m)) quo n1
           n1:=n1-1
         ris:=ris+monomial(k*leadingCoefficient f,(n-m)::NNI)
         f:=reductum f
         n:=degree f
       ris
 |