36#include <itpp/itexports.h>
106 int get_size()
const {
return ((m != 0) ? q[m] : 0); }
112 bvec get_vectorspace()
const;
114 int get_value()
const;
116 int operator==(
const GF &
ingf)
const;
118 int operator!=(
const GF &
ingf)
const;
125 void operator+=(
const GF &
ingf);
129 void operator-=(
const GF &
ingf);
133 void operator*=(
const GF &
ingf);
137 void operator/=(
const GF &
ingf);
155#if (defined(_MSC_VER) && defined (ITPP_SHARED_LIB))
157template class ITPP_EXPORT Array<GF>;
165ITPP_EXPORT GFX
operator*(
const GF &ingf,
const GFX &ingfx);
167ITPP_EXPORT GFX
operator*(
const GFX &ingfx,
const GF &ingf);
169ITPP_EXPORT GFX
operator/(
const GFX &ingfx,
const GF &ingf);
171ITPP_EXPORT std::ostream &
operator<<(std::ostream &os,
const GFX &ingfx);
193 int get_size()
const;
195 int get_degree()
const;
201 int get_true_degree()
const;
213 return coeffs(index);
218 return coeffs(index);
257ITPP_EXPORT GFX
divgfx(
const GFX &c,
const GFX &g);
263ITPP_EXPORT GFX
modgfx(
const GFX &a,
const GFX &b);
293 if (value == -1 &&
ingf.value == -1)
295 if (m ==
ingf.m && value ==
ingf.value)
325 else if (
ingf.value != -1) {
327 value = logalpha(m)(alphapow(m)(value) ^ alphapow(m)(
ingf.value));
352 if (value == -1 ||
ingf.value == -1)
356 value = (value +
ingf.value) % (q[m] - 1);
369 it_assert(
ingf.value != -1,
"GF::operator/: division by zero element");
374 value = (value -
ingf.value + q[m] - 1) % (q[m] - 1);
403 for (
int i = 0;
i < degree + 1;
i++)
424 for (
int i = 0;
i < degree + 1;
i++)
425 coeffs(
i).set(q, -1);
444 degree =
ingfx.degree;
445 coeffs =
ingfx.coeffs;
469 while (coeffs(
i).get_value() == -1) {
480 for (
int i = 0;
i < degree + 1;
i++)
481 coeffs(
i).set(q, -1);
486 degree =
ingfx.degree;
487 coeffs =
ingfx.coeffs;
494 if (
ingfx.degree > degree) {
497 for (
int j = degree + 1;
j < coeffs.
size();
j++) { coeffs(
j).set(q, -1); }
498 degree =
ingfx.degree;
500 for (
int i = 0;
i <
ingfx.degree + 1;
i++) { coeffs(
i) +=
ingfx.coeffs(
i); }
528 for (
j = 0;
j < coeffs.
size();
j++)
529 coeffs(
j).set(q, -1);
530 for (
i = 0;
i < degree + 1;
i++)
531 for (
j = 0;
j <
ingfx.degree + 1;
j++)
533 degree = coeffs.
size() - 1;
547 for (
int i = 0;
i <
ingfx.degree + 1;
i++)
561 for (
int i = 0;
i <
ingfx.degree + 1;
i++)
570 for (
int i = 1;
i < degree + 1;
i++) {
Definition of Array class (container)
Import/Export definitions for some templates defined in base folder.
int size() const
Returns the number of data elements in the array object.
Array< T > & operator=(const T &e)
Assignment operator.
std::istream & operator>>(std::istream &is, Array< T > &a)
Input stream for Array<T>. T must have istream operator>> defined.
std::ostream & operator<<(std::ostream &os, const Array< T > &a)
Output stream for Array<T>. T must have ostream operator<< defined.
void set_size(int n, bool copy=false)
Resizing an Array<T>.
int length() const
Returns the number of data elements in the array object.
Polynomials over GF(q)[x], where q=2^m, m=1,...,16.
GFX operator+(const GFX &ingfx) const
sum of two GF(q)[x]
GF & operator[](int index)
Acces to individual element in the GF(q)[x] polynomial.
int get_true_degree() const
Return true degree of GF(q)[x].
void set_degree(int indegree, bool copy=false)
Resize the polynomial to the given indegree. If copy is set to true, the old polynomial's coefficient...
void operator+=(const GFX &ingfx)
sum of two GF(q)[x]
void operator=(const GFX &ingfx)
Copy.
void operator-=(const GFX &ingfx)
Difference of two GF(q), same as sum for q=2^m.
int get_degree() const
Return degree of GF(q)[x].
ITPP_EXPORT friend GFX operator*(const GF &ingf, const GFX &ingfx)
Multiply a GF element with a GF(q)[x].
void set(int qvalue, const char *invalues)
Set the GF(q)[x] polynomial.
GF operator[](int index) const
Acces to individual element in the GF(q)[x] polynomial.
void operator*=(const GFX &ingfx)
product of two GF(q)[x]
int get_size() const
Return q.
GF operator()(const GF &ingf)
Evaluate polynom at alpha^inexp.
void clear()
Set all coefficients to zero.
GFX operator-(const GFX &ingfx) const
Difference of two GF(q), same as sum for q=2^m.
GF(int qvalue, int inexp)
Constructor.
int operator==(const GF &ingf) const
Equality check.
GF operator*(const GF &ingf) const
product of two GF(q)
GF operator-(const GF &ingf) const
Difference of two GF(q), same as sum for q=2^m.
void operator=(const GF &ingf)
GF(q) equals ingf.
void operator-=(const GF &ingf)
Difference of two GF(q), same as sum for q=2^m.
int get_value() const
Returns the alpha exponent.
void set_size(int qvalue)
set q=2^mvalue
void operator*=(const GF &ingf)
product of two GF(q)
int get_size() const
Return q.
void set(int qvalue, int inexp)
GF(q) equals alpha ^ inexp.
bvec get_vectorspace() const
Returns the vector space representation of GF(q).
GF operator+(const GF &ingf) const
sum of two GF(q)
GF(int qvalue)
Constructor.
int operator!=(const GF &ingf) const
Not-equality check.
void operator/=(const GF &ingf)
division of two GF(q)
GF(const GF &ingf)
Copy constructor.
void operator+=(const GF &ingf)
sum of two GF(q)
GF operator/(const GF &ingf) const
product of two GF(q)
Definitions of converters between different vector and matrix types.
#define it_assert_debug(t, s)
Abort if t is not true and NDEBUG is not defined.
#define it_assert(t, s)
Abort if t is not true.
std::ostream & operator<<(std::ostream &output, const bin &inbin)
Output stream of bin.
ITPP_EXPORT int bin2dec(const bvec &inbvec, bool msb_first=true)
Convert a bvec to decimal int with the first bit as MSB if msb_first == true.
Mat< Num_T > operator-(const Mat< Num_T > &m1, const Mat< Num_T > &m2)
Subtraction of two matrices.
GF2mat operator*(const GF2mat &X, const GF2mat &Y)
GF(2) matrix multiplication.
ITPP_EXPORT bvec dec2bin(int length, int index)
Convert a decimal int index to bvec using length bits in the representation.
Mat< Num_T > operator/(const Mat< Num_T > &m, Num_T t)
Element-wise division by a scalar.
GFX divgfx(const GFX &c, const GFX &g)
Division of two GFX (local help function)
GF2mat operator+(const GF2mat &X, const GF2mat &Y)
GF(2) matrix addition.
GFX modgfx(const GFX &a, const GFX &b)
Modulo function of two GFX (local help function)
Templated Vector Class Definitions.