This file is indexed.

/usr/share/axiom-20170501/src/algebra/MODMON.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
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
)abbrev domain MODMON ModMonic
++ Author: Mark Botch
++ Description:
++ This package has not been documented
-- following line prevents caching ModMonic
)bo PUSH('ModMonic, $mutableDomains)
 
ModMonic(R,Rep) : SIG == CODE where
  R : Ring
  Rep : UnivariatePolynomialCategory(R)

  SIG ==> UnivariatePolynomialCategory(R) with

    setPoly : Rep -> Rep
      ++ setPoly(x) is not documented

    modulus : -> Rep
      ++ modulus() is not documented

    reduce : Rep -> %
      ++ reduce(x) is not documented

    lift : % -> Rep --reduce lift = identity
      ++ lift(x) is not documented

    coerce : Rep -> %
      ++ coerce(x) is not documented

    Vectorise : % -> Vector(R)
      ++ Vectorise(x) is not documented

    UnVectorise : Vector(R) -> %
      ++ UnVectorise(v) is not documented

    An : % -> Vector(R)
      ++ An(x) is not documented

    pow : -> PrimitiveArray(%)
      ++ pow() is not documented

    computePowers : -> PrimitiveArray(%)
      ++ computePowers() is not documented

    if R has FiniteFieldCategory then

       frobenius : % -> %
         ++ frobenius(x) is not documented

    if R has Finite then Finite

  CODE ==> add

      m:Rep := monomial(1,1)$Rep --| degree(m) > 0 and LeadingCoef(m) = R$1
      d := degree(m)$Rep
      d1 := (d-1):NonNegativeInteger
      twod := 2*d1+1
      frobenius?:Boolean := R has FiniteFieldCategory
      --VectorRep:= DirectProduct(d:NonNegativeInteger,R)

      x,y: %
      p: Rep
      d,n: Integer
      e,k1,k2: NonNegativeInteger
      c: R
      --vect: Vector(R)
      power:PrimitiveArray(%)
      frobeniusPower:PrimitiveArray(%)
      computeFrobeniusPowers : () -> PrimitiveArray(%)

      power := new(0,0)

      frobeniusPower := new(0,0)

      setPoly (mon : Rep) ==
        mon =$Rep m => mon
        oldm := m
        leadingCoefficient mon ^= 1 => error "polynomial must be monic"
        -- following copy code needed since FFPOLY can modify mon
        copymon:Rep:= 0
        while not zero? mon repeat
          copymon := monomial(leadingCoefficient mon, degree mon)$Rep + copymon
          mon := reductum mon
        m := copymon
        d := degree(m)$Rep
        d1 := (d-1)::NonNegativeInteger
        twod := 2*d1+1
        power := computePowers()
        if frobenius? then
          degree(oldm)>1 and not((oldm exquo$Rep m) case "failed") =>
              for i in 1..d1 repeat
                frobeniusPower(i) := reduce lift frobeniusPower(i)
          frobeniusPower := computeFrobeniusPowers()
        m

      modulus == m

      if R has Finite then

         size == d * size$R

         random == UnVectorise([random()$R for i in 0..d1])

      0 == 0$Rep

      1 == 1$Rep

      c * x == c *$Rep x

      n * x == (n::R) *$Rep x

      coerce(c:R):% == monomial(c,0)$Rep

      coerce(x:%):OutputForm == coerce(x)$Rep

      coefficient(x,e):R == coefficient(x,e)$Rep

      reductum(x) == reductum(x)$Rep

      leadingCoefficient x == (leadingCoefficient x)$Rep

      degree x == (degree x)$Rep

      lift(x) == x pretend Rep

      reduce(p) == (monicDivide(p,m)$Rep).remainder

      coerce(p) == reduce(p)

      x = y == x =$Rep y

      x + y == x +$Rep y

      - x == -$Rep x

      x * y ==
        p := x *$Rep y
        ans:=0$Rep
        while (n:=degree p)>d1 repeat
           ans:=ans + leadingCoefficient(p)*power.(n-d)
           p := reductum p
        ans+p

      Vectorise(x) == [coefficient(lift(x),i) for i in 0..d1]

      UnVectorise(vect) ==
        reduce(+/[monomial(vect.(i+1),i) for i in 0..d1])

      computePowers ==
           mat : PrimitiveArray(%):= new(d,0)
           mat.0:= reductum(-m)$Rep
           w: % := monomial$Rep (1,1)
           for i in 1..d1 repeat
              mat.i := w *$Rep mat.(i-1)
              if degree mat.i=d then
                mat.i:= reductum mat.i + leadingCoefficient mat.i * mat.0
           mat

      if frobenius? then

          computeFrobeniusPowers() ==
            mat : PrimitiveArray(%):= new(d,1)
            mat.1:= mult := monomial(1, size$R)$%
            for i in 2..d1 repeat
               mat.i := mult * mat.(i-1)
            mat

          frobenius(a:%):% ==
            aq:% := 0
            while a^=0 repeat
              aq:= aq + leadingCoefficient(a)*frobeniusPower(degree a)
              a := reductum a
            aq
         
      pow == power

      monomial(c,e)==
         if e<d then monomial(c,e)$Rep
         else
            if e<=twod then
               c * power.(e-d)
            else
               k1:=e quo twod
               k2 := (e-k1*twod)::NonNegativeInteger
               reduce((power.d1 **k1)*monomial(c,k2))

      if R has Field then

         (x:% exquo y:%):Union(%, "failed") ==
            uv := extendedEuclidean(y, modulus(), x)$Rep
            uv case "failed" => "failed"
            return reduce(uv.coef1)

         recip(y:%):Union(%, "failed") ==  1 exquo y

         divide(x:%, y:%) ==
            (q := (x exquo y)) case "failed" => error "not divisible"
            [q, 0]