This file is indexed.

/usr/share/axiom-20170501/src/algebra/GALUTIL.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
)abbrev package GALUTIL GaloisGroupUtilities
++ Author: Frederic Lehobey
++ Date Created: 29 June 1994
++ Date Last Updated: 30 June 1994 
++ Description: 
++ \spadtype{GaloisGroupUtilities} provides several useful functions.

GaloisGroupUtilities(R) : SIG == CODE where
  R : Ring

  N ==> NonNegativeInteger
  Z ==> Integer

  SIG ==> with

    pascalTriangle : (N,Z) -> R
      ++ pascalTriangle(n,r) returns the binomial coefficient
      ++ \spad{C(n,r)=n!/(r! (n-r)!)}
      ++ and stores it in a table to prevent recomputation.

    rangePascalTriangle : N -> N
      ++ rangePascalTriangle(n) sets the maximal number of lines which
      ++ are stored and returns the previous value.

    rangePascalTriangle : () -> N
      ++ rangePascalTriangle() returns the maximal number of lines stored.

    sizePascalTriangle : () -> N
      ++ sizePascalTriangle() returns the number of entries currently stored
      ++ in the table.

    fillPascalTriangle : () -> Void
      ++ fillPascalTriangle() fills the stored table.

    if R has FloatingPointSystem then

      safeCeiling : R -> Z
        ++ safeCeiling(x) returns the integer which is greater than any integer
        ++ with the same floating point number representation.

      safeFloor : R -> Z
        ++ safeFloor(x) returns the integer which is lower or equal to the
        ++ largest integer which has the same floating point number
        ++ representation.

      safetyMargin : N -> N
        ++ safetyMargin(n) sets to n the number of low weight digits we do not
        ++ trust in the floating point representation and returns the previous
        ++ value (for use by \spadfun{safeCeiling}).

      safetyMargin : () -> N
        ++ safetyMargin() returns the number of low weight digits we do not
        ++ trust in the floating point representation (used by 
        ++ \spadfun{safeCeiling}).

  CODE ==> add

    if R has FloatingPointSystem then

      safetymargin : N := 6
      
      safeFloor(x:R):Z ==
        if (shift := order(x)-precision()$R+safetymargin) >= 0 then
          x := x+float(1,shift)
        retract(floor(x))@Z

      safeCeiling(x:R):Z ==
        if (shift := order(x)-precision()$R+safetymargin) >= 0 then
          x := x+float(1,shift)
        retract(ceiling(x))@Z

      safetyMargin(n:N):N == 
        (safetymargin,n) := (n,safetymargin)
        n

      safetyMargin():N == safetymargin

    pascaltriangle : FlexibleArray(R) := empty()
    ncomputed : N := 3
    rangepascaltriangle : N := 216

    pascalTriangle(n:N, r:Z):R ==
      negative? r => 0
      (d := n-r) < r => pascalTriangle(n,d)
      zero? r => 1$R
      (r = 1) => n :: R
      n > rangepascaltriangle => 
       binomial(n,r)$IntegerCombinatoricFunctions(Z) :: R
      n <= ncomputed =>
        m := divide(n-4,2)
        mq := m.quotient
        pascaltriangle((mq+1)*(mq+m.remainder)+r-1)
      -- compute the missing lines
      for i in (ncomputed+1)..n repeat
        for j in 2..(i quo 2) repeat
          pascaltriangle := concat!(pascaltriangle,pascalTriangle((i-1) 
           :: N, j-1)+pascalTriangle((i-1) :: N,j))
        ncomputed := i
      pascalTriangle(n,r)

    rangePascalTriangle(n:N):N ==
      if n<ncomputed then
        if n<3 then
          pascaltriangle := delete!(pascaltriangle,1..#pascaltriangle)
          ncomputed := 3
        else
          d := divide(n-3,2)
          dq := d.quotient
          pascaltriangle := delete!(pascaltriangle,((dq+1)*(dq+d.remainder)
           +1)..#pascaltriangle)
          ncomputed := n
      (rangepascaltriangle,n) := (n,rangepascaltriangle)
      n

    rangePascalTriangle():N == rangepascaltriangle

    sizePascalTriangle():N == #pascaltriangle

    fillPascalTriangle():Void == pascalTriangle(rangepascaltriangle,2)