/*---------------------------------------------------------------------------* * IT++ * *---------------------------------------------------------------------------* * Copyright (c) 1995-2004 by Tony Ottosson, Thomas Eriksson, Pål Frenger, * * Tobias Ringström, and Jonas Samuelsson. * * * * Permission to use, copy, modify, and distribute this software and its * * documentation under the terms of the GNU General Public License is hereby * * granted. No representations are made about the suitability of this * * software for any purpose. It is provided "as is" without expressed or * * implied warranty. See the GNU General Public License for more details. * *---------------------------------------------------------------------------*/ /*! \file \brief Implementation of Galois Field algebra classes and functions \author Tony Ottosson 1.8 2004/09/30 11:53:31 */ #include "comm/galois.h" #include using std::ostream; using std::istream; namespace itpp { Array > GF::alphapow; Array > GF::logalpha; ivec GF::q="1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384"; // set q=2^mvalue void GF::set_size(int qvalue) { int mtemp; mtemp = round_i(log2(double(qvalue))); it_assert((1< 14, "createfield : m out of range"); m=mtemp; if (alphapow.size() < (m+1) ) { alphapow.set_size(m+1); logalpha.set_size(m+1); } if (alphapow(m).size() == 0) { alphapow(m).set_size(qvalue); logalpha(m).set_size(qvalue); alphapow(m) = 0; logalpha(m) = 0; if (m == 1) { // GF(2), special case alphapow(1)(0)=1; logalpha(1)(0)=-1; logalpha(1)(1)=0; } else { reduce=reducetable[m-2]; alphapow(m)(0)=1; // alpha^0 = 1 for (n=1; n<(1<