/usr/include/linbox/field/ntl-GF2E.h is in liblinbox-dev 1.1.6~rc0-4.1.
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 | /* -*- mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* linbox/field/ntl-z_pE.h
* Copyright (C) 2004 Pascal Giorgi
*
* Written by Pascal Giorgi <pascal.giorgi@ens-lyon.fr>
*
* Modified by W. J. Turner <wjturner@acm.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __NTL_GF2E_H
#define __NTL_GF2E_H
#include <linbox/util/debug.h>
#include <linbox/field/unparametric.h>
#include <linbox/randiter/unparametric.h>
#include <linbox/util/debug.h>
#include <NTL/GF2XFactoring.h>
#include <NTL/GF2E.h>
#include <time.h>
#include "linbox/linbox-config.h"
#include <linbox/field/field-traits.h>
namespace LinBox {
template <class Ring>
struct ClassifyRing;
template <class Element>
struct ClassifyRing<UnparametricRandIter<Element> >;
template <>
struct ClassifyRing<UnparametricRandIter<NTL::GF2E> > {
typedef RingCategories::ModularTag categoryTag;
};
/// \ingroup field
template<>
class UnparametricRandIter<NTL::GF2E>
{
public:
typedef NTL::GF2E Element;
UnparametricRandIter<NTL::GF2E>(const UnparametricField<NTL::GF2E>& F =UnparametricField<NTL::GF2E>(),
const size_t& size = 0,
const size_t& seed = 0
)
: _size(size), _seed(seed)
{
if(_seed == 0)
NTL::SetSeed(NTL::to_ZZ(time(0)));
else
NTL::SetSeed(NTL::to_ZZ(_seed));
}
UnparametricRandIter<NTL::GF2E>(const UnparametricRandIter<NTL::GF2E>& R)
: _size(R._size), _seed(R._seed)
{
if(_seed == 0)
NTL::SetSeed(NTL::to_ZZ(time(0)));
else
NTL::SetSeed(NTL::to_ZZ(_seed));
}
Element& random (Element& x) const
{
NTL::random(x);
return x;
}
protected:
size_t _size;
size_t _seed;
};
/*
* Define a parameterized class to easily handle UnparametricField<NTL::GF2E> field
*/
class NTL_GF2E : public UnparametricField<NTL::GF2E>
{
public:
NTL_GF2E (const integer &p, const integer &k) {
if(p != 2) throw PreconditionFailed(__FUNCTION__,__LINE__,"modulus must be 2");
NTL::GF2X irredPoly = NTL::BuildSparseIrred_GF2X((long) k);
NTL::GF2E::init(irredPoly);
}
}; // end o class NTL_GF2E
/*
* Specialization of UnparametricField<> for NTL::GF2E type
*/
template<>
NTL::GF2E& UnparametricField<NTL::GF2E>::init (NTL::GF2E &x, const integer &y) const
{
x=NTL::to_GF2E(static_cast<long>(y));
return x;
}
template<>
integer& UnparametricField<NTL::GF2E>::convert (integer& x, const NTL::GF2E &y) const {
NTL::GF2X poly = rep(y);
long i;
x = 0;
for(i = deg(poly); i >= 0; --i) {
x <<= 1;
x += rep(coeff(poly, i));
}
return x;
}
template<>
bool UnparametricField<NTL::GF2E>::isZero (const NTL::GF2E& a) const
{
return NTL::IsZero(a);
}
template<>
bool UnparametricField<NTL::GF2E>::isOne (const NTL::GF2E& a) const
{
return NTL::IsOne(a);
}
template<>
integer& UnparametricField<NTL::GF2E>::characteristic (integer &c) const
{
return c = 2;
}
template<>
integer& UnparametricField<NTL::GF2E>::cardinality(integer& c) const
{
c=1;
c<<= NTL::GF2E::degree();
return c;
}
template<>
NTL::GF2E& UnparametricField<NTL::GF2E>::inv(NTL::GF2E& x, const NTL::GF2E& y) const
{
x=NTL::to_GF2E(1)/y;
return x;
}
template<>
NTL::GF2E& UnparametricField<NTL::GF2E>::invin(NTL::GF2E& x) const
{
x=NTL::to_GF2E(1)/x;
return x;
}
template<>
std::istream& UnparametricField<NTL::GF2E>::read(std::istream& is, NTL::GF2E& x) const
{
long tmp;
is>>tmp;
x=NTL::to_GF2E(tmp);
return is;
}
}
#endif
|