echo "IF YOU ARE LOOKING FOR IRREDUCIBLE/PRIMITIVE TRINOMIALS JUST LOOK"
echo "IN THE FILE 'TRINOMIALS' THAT IS DISTRIBUTED TOGETHER WITH THE"
echo "LIBECC PACKAGE!"
echo

if ! test -d irred150; then
  mkdir irred150
  echo "Change directory into irred150 and untar"
  echo "ftp://ftp.comlab.ox.ac.uk/pub/Documents/techpapers/Richard.Brent/trinom/irred150.tar.gz"
  echo "into it.  Edit irred135.c and correct the defines:"
  echo "#define VERBOSE FALSE"
  echo "#define CONTINUE TRUE"
  echo "#define IBMPC TRUE"
  echo "#define SPARC FALSE"
  echo "#define ASM FALSE"
  echo "Then run gcc -O1 -fomit-frame-pointer -o irred135 irred135.c"
  exit
fi
if ! test -x irred150/irred135; then
  echo "irred150/irred135 is missing.  Please compile it first."
  echo "See http://web.comlab.ox.ac.uk/oucl/work/richard.brent/irred.html for details."
  echo "See this script for a description of how to compile it."
  exit
fi

# Because irred doesn't work for small m, I manually generated
# the possible values for k for small values of m (using
# rngTestMatrix.cc) and wrote those to the file smallk.
m=3
while test $m -ne 64; do
  m_plus_one_devided_by_two=`expr '(' $m + 1 ')' / 2`
  RESULTS=`grep '^'$m' ' smallk`
  if ! test -z "$RESULTS"; then
    KVALUES=`echo "$RESULTS" | sed -e 's/'$m'//g'`
    for k in $KVALUES; do
      test_primitive $m $k
    done
  fi
  m=`expr $m + 1`
done
m=64
while test $m -ne 1201; do
  m_plus_one_devided_by_two=`expr '(' $m + 1 ')' / 2`
  RESULTS=`echo $m 1 $m_plus_one_devided_by_two | irred150/irred135 | grep 'primitive LOG' | sed -e 's/ primitive.*//' -e 's/ /	/'`
  if ! test -z "$RESULTS"; then
    KVALUES=`echo "$RESULTS" | sed -e 's/'$m'//g'`
    for k in $KVALUES; do
      test_primitive $m $k
    done
  fi
  m=`expr $m + 1`
done

