./PaxHeaders.3802/communications-1.2.1 0000644 0000000 0000000 00000000132 12510010473 014265 x ustar 00 30 mtime=1428164923.938510295
30 atime=1428164983.712815029
30 ctime=1428164983.712815029
communications-1.2.1/ 0000755 0000000 0000000 00000000000 12510010473 014532 5 ustar 00root root 0000000 0000000 communications-1.2.1/PaxHeaders.3802/src 0000644 0000000 0000000 00000000132 12510010567 014723 x ustar 00 30 mtime=1428164983.708815162
30 atime=1428164983.712815029
30 ctime=1428164983.712815029
communications-1.2.1/src/ 0000755 0000000 0000000 00000000000 12510010567 015325 5 ustar 00root root 0000000 0000000 communications-1.2.1/src/PaxHeaders.3802/op-gm-m.cc 0000644 0000000 0000000 00000000132 12510010473 016554 x ustar 00 30 mtime=1428164923.954509931
30 atime=1428164924.034508105
30 ctime=1428164983.712815029
communications-1.2.1/src/op-gm-m.cc 0000644 0000000 0000000 00000007417 12510010473 017112 0 ustar 00root root 0000000 0000000 //Copyright (C) 2003 David Bateman
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 3 of the
// License, or (at your option) any later version.
//
// This program 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
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, see
// .
//
// In addition to the terms of the GPL, you are permitted to link this
// program with any Open Source program, as defined by the Open Source
// Initiative (www.opensource.org)
#include
#include
#include
#include "galois.h"
#include "ov-galois.h"
#include "galois-ops.h"
// galois by matrix ops.
DEFBINOP_OP_G (add, galois, matrix, +)
DEFBINOP_OP_G (sub, galois, matrix, -)
DEFBINOP_OP_G (mul, galois, matrix, *)
DEFBINOP_FN_G (div, galois, matrix, xdiv)
DEFBINOPX (pow, galois, matrix)
{
error ("for A^x, A must be square and x scalar");
return octave_value ();
}
DEFBINOP_FN_G (ldiv, galois, matrix, xleftdiv)
DEFBINOP_FN (lt, galois, matrix, mx_el_lt)
DEFBINOP_FN (le, galois, matrix, mx_el_le)
DEFBINOP_FN (eq, galois, matrix, mx_el_eq)
DEFBINOP_FN (ge, galois, matrix, mx_el_ge)
DEFBINOP_FN (gt, galois, matrix, mx_el_gt)
DEFBINOP_FN (ne, galois, matrix, mx_el_ne)
DEFBINOP_FN_G (el_mul, galois, matrix, product)
DEFBINOP_FN_G (el_div, galois, matrix, quotient)
DEFBINOP_FN_G (el_pow, galois, matrix, elem_pow)
DEFBINOP (el_ldiv, galois, matrix)
{
CAST_BINOP_ARGS (const octave_galois&, const octave_matrix&);
return new octave_galois (quotient (v2.matrix_value (), v1.galois_value ()));
}
DEFBINOP_FN (el_and, galois, matrix, mx_el_and)
DEFBINOP_FN (el_or, galois, matrix, mx_el_or)
DEFCATOP_G_METHOD (gm_m, galois, matrix, concat)
// Need to create temporary Galois array so that matrix values are checked
DEFASSIGNOP (assign, galois, matrix)
{
CAST_BINOP_ARGS (octave_galois&, const octave_matrix&);
v1.assign (idx, galois (v2.matrix_value (), v1.galois_value ().m (),
v1.galois_value ().primpoly ()));
return octave_value ();
}
void
install_gm_m_ops (void)
{
INSTALL_BINOP (op_add, octave_galois, octave_matrix, add);
INSTALL_BINOP (op_sub, octave_galois, octave_matrix, sub);
INSTALL_BINOP (op_mul, octave_galois, octave_matrix, mul);
INSTALL_BINOP (op_div, octave_galois, octave_matrix, div);
INSTALL_BINOP (op_pow, octave_galois, octave_matrix, pow);
INSTALL_BINOP (op_ldiv, octave_galois, octave_matrix, ldiv);
INSTALL_BINOP (op_lt, octave_galois, octave_matrix, lt);
INSTALL_BINOP (op_le, octave_galois, octave_matrix, le);
INSTALL_BINOP (op_eq, octave_galois, octave_matrix, eq);
INSTALL_BINOP (op_ge, octave_galois, octave_matrix, ge);
INSTALL_BINOP (op_gt, octave_galois, octave_matrix, gt);
INSTALL_BINOP (op_ne, octave_galois, octave_matrix, ne);
INSTALL_BINOP (op_el_mul, octave_galois, octave_matrix, el_mul);
INSTALL_BINOP (op_el_div, octave_galois, octave_matrix, el_div);
INSTALL_BINOP (op_el_pow, octave_galois, octave_matrix, el_pow);
INSTALL_BINOP (op_el_ldiv, octave_galois, octave_matrix, el_ldiv);
INSTALL_BINOP (op_el_and, octave_galois, octave_matrix, el_and);
INSTALL_BINOP (op_el_or, octave_galois, octave_matrix, el_or);
INSTALL_G_CATOP (octave_galois, octave_matrix, gm_m);
INSTALL_ASSIGNOP (op_asn_eq, octave_galois, octave_matrix, assign);
INSTALL_ASSIGNCONV (octave_base_value, octave_galois, octave_matrix);
}
/*
;;; Local Variables: ***
;;; mode: C++ ***
;;; End: ***
*/
communications-1.2.1/src/PaxHeaders.3802/op-gm-s.cc 0000644 0000000 0000000 00000000131 12510010473 016561 x ustar 00 29 mtime=1428164923.95850984
30 atime=1428164924.034508105
30 ctime=1428164983.712815029
communications-1.2.1/src/op-gm-s.cc 0000644 0000000 0000000 00000007700 12510010473 017113 0 ustar 00root root 0000000 0000000 //Copyright (C) 2003 David Bateman
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 3 of the
// License, or (at your option) any later version.
//
// This program 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
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, see
// .
//
// In addition to the terms of the GPL, you are permitted to link this
// program with any Open Source program, as defined by the Open Source
// Initiative (www.opensource.org)
#include
#include
#include
#include "galois.h"
#include "ov-galois.h"
#include "galois-ops.h"
// galois by scalar ops.
DEFBINOP_OP_G_S2 (add, galois, scalar, +)
DEFBINOP_OP_G_S2 (sub, galois, scalar, -)
DEFBINOP_FN_G_S2 (mul, galois, scalar, product)
DEFBINOP_FN_G_S2 (div, galois, scalar, quotient)
DEFBINOP (pow, galois, scalar)
{
CAST_BINOP_ARGS (const octave_galois&, const octave_scalar&);
return new octave_galois (pow (v1.galois_value (), v2.double_value ()));
}
DEFBINOP_FN_G_S2 (ldiv, galois, scalar, xleftdiv)
DEFBINOP_FN_B_S2 (lt, galois, scalar, mx_el_lt)
DEFBINOP_FN_B_S2 (le, galois, scalar, mx_el_le)
DEFBINOP_FN_B_S2 (eq, galois, scalar, mx_el_eq)
DEFBINOP_FN_B_S2 (ge, galois, scalar, mx_el_ge)
DEFBINOP_FN_B_S2 (gt, galois, scalar, mx_el_gt)
DEFBINOP_FN_B_S2 (ne, galois, scalar, mx_el_ne)
DEFBINOP_FN_G_S2 (el_mul, galois, scalar, product)
DEFBINOP_FN_G_S2 (el_div, galois, scalar, quotient)
DEFBINOP_FN_G (el_pow, galois, scalar, elem_pow)
DEFBINOP (el_ldiv, galois, scalar)
{
CAST_BINOP_ARGS (const octave_galois&, const octave_scalar&);
return new octave_galois (quotient (v2.matrix_value (), v1.galois_value ()));
}
DEFBINOP_FN_B_S2 (el_and, galois, scalar, mx_el_and)
DEFBINOP_FN_B_S2 (el_or, galois, scalar, mx_el_or)
DEFCATOP (gm_s, galois, scalar)
{
CAST_BINOP_ARGS (octave_galois&, const octave_scalar&);
return new octave_galois (v1.galois_value (). concat (v2.matrix_value (),
ra_idx));
}
DEFASSIGNOP (assign, galois, scalar)
{
CAST_BINOP_ARGS (octave_galois&, const octave_scalar&);
v1.assign (idx, galois (1, 1, v2.scalar_value (), v1.galois_value ().m (),
v1.galois_value ().primpoly ()));
return octave_value ();
}
void
install_gm_s_ops (void)
{
INSTALL_BINOP (op_add, octave_galois, octave_scalar, add);
INSTALL_BINOP (op_sub, octave_galois, octave_scalar, sub);
INSTALL_BINOP (op_mul, octave_galois, octave_scalar, mul);
INSTALL_BINOP (op_div, octave_galois, octave_scalar, div);
INSTALL_BINOP (op_pow, octave_galois, octave_scalar, pow);
INSTALL_BINOP (op_ldiv, octave_galois, octave_scalar, ldiv);
INSTALL_BINOP (op_lt, octave_galois, octave_scalar, lt);
INSTALL_BINOP (op_le, octave_galois, octave_scalar, le);
INSTALL_BINOP (op_eq, octave_galois, octave_scalar, eq);
INSTALL_BINOP (op_ge, octave_galois, octave_scalar, ge);
INSTALL_BINOP (op_gt, octave_galois, octave_scalar, gt);
INSTALL_BINOP (op_ne, octave_galois, octave_scalar, ne);
INSTALL_BINOP (op_el_mul, octave_galois, octave_scalar, el_mul);
INSTALL_BINOP (op_el_div, octave_galois, octave_scalar, el_div);
INSTALL_BINOP (op_el_pow, octave_galois, octave_scalar, el_pow);
INSTALL_BINOP (op_el_ldiv, octave_galois, octave_scalar, el_ldiv);
INSTALL_BINOP (op_el_and, octave_galois, octave_scalar, el_and);
INSTALL_BINOP (op_el_or, octave_galois, octave_scalar, el_or);
INSTALL_G_CATOP (octave_galois, octave_scalar, gm_s);
INSTALL_ASSIGNOP (op_asn_eq, octave_galois, octave_scalar, assign);
}
/*
;;; Local Variables: ***
;;; mode: C++ ***
;;; End: ***
*/
communications-1.2.1/src/PaxHeaders.3802/cyclpoly.cc 0000644 0000000 0000000 00000000132 12510010473 017141 x ustar 00 30 mtime=1428164923.942510204
30 atime=1428164924.034508105
30 ctime=1428164983.712815029
communications-1.2.1/src/cyclpoly.cc 0000644 0000000 0000000 00000017337 12510010473 017501 0 ustar 00root root 0000000 0000000 //Copyright (C) 2003 David Bateman
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 3 of the
// License, or (at your option) any later version.
//
// This program 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
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, see
// .
//
// In addition to the terms of the GPL, you are permitted to link this
// program with any Open Source program, as defined by the Open Source
// Initiative (www.opensource.org)
#include
#include
#include
enum cyclic_poly_type
{
CYCLIC_POLY_MIN=0,
CYCLIC_POLY_MAX,
CYCLIC_POLY_ALL,
CYCLIC_POLY_L
};
// A simplified version of the filter function for specific lengths of
// a and b in the Galois field GF(2)
Array
filter_gf2 (const Array& b, const Array& a,
const Array& x, const int& n)
{
int x_len = x.length ();
Array si (dim_vector (n, 1), 0);
Array y (dim_vector (x_len, 1), 0);
for (int i = 0; i < x_len; i++)
{
y(i) = si(0);
if (b(0) && x(i))
y(i) ^= 1;
for (int j = 0; j < n - 1; j++)
{
si(j) = si(j+1);
if (a(j+1) && y(i))
si(j) ^= 1;
if (b(j+1) && x(i))
si(j) ^= 1;
}
si(n-1) = 0;
if (a(n) && y(i))
si(n-1) ^= 1;
if (b(n) && x(i))
si(n-1) ^= 1;
}
return y;
}
// Cyclic polynomial is irreducible. I.E. it divides into x^n-1
// without remainder There must surely be an easier way of doing this
// as the polynomials are over GF(2).
static bool
do_is_cyclic_polynomial (const unsigned long long& a1, const int& n,
const int& m)
{
Array a (dim_vector (n+1, 1), 0);
Array y (dim_vector (n+1, 1), 0);
Array x (dim_vector (n-m+2, 1), 0);
y(0) = 1;
y(n) = 1;
x(0) = 1;
for (int i=0; i < m+1; i++)
a(i) = (a1 & (1UL << i) ? 1 : 0);
Array b = filter_gf2 (y, a, x, n);
b.resize(dim_vector (n+1, 1), 0);
Array p (dim_vector (m+1, 1), 0);
p(0) = 1;
Array q = filter_gf2 (a, p, b, m);
for (int i=0; i < n+1; i++)
if (y(i) ^ q(i))
return false;
return true;
}
DEFUN_DLD (cyclpoly, args, nargout,
"-*- texinfo -*-\n\
@deftypefn {Loadable Function} {@var{y} =} cyclpoly (@var{n}, @var{k})\n\
@deftypefnx {Loadable Function} {@var{y} =} cyclpoly (@var{n}, @var{k}, @var{opt})\n\
@deftypefnx {Loadable Function} {@var{y} =} cyclpoly (@var{n}, @var{k}, @var{opt}, @var{rep})\n\
This function returns the cyclic generator polynomials of the code\n\
[@var{n},@var{k}]. By default the polynomial with the smallest weight\n\
is returned. However this behavior can be overridden with the @var{opt}\n\
flag. Valid values of @var{opt} are:\n\
\n\
@table @asis\n\
@item @code{\"all\"}\n\
Returns all of the polynomials of the code [@var{n},@var{k}]\n\
@item @code{\"min\"}\n\
Returns the polynomial of minimum weight of the code [@var{n},@var{k}]\n\
@item @code{\"max\"}\n\
Returns the polynomial of the maximum weight of the code [@var{n},@var{k}]\n\
@item @var{l}\n\
Returns the polynomials having exactly the weight @var{l}\n\
@end table\n\
\n\
The polynomials are returns as row-vectors in the variable @var{y}. Each\n\
row of @var{y} represents a polynomial with the least-significant term\n\
first. The polynomials can be returned with an integer representation\n\
if @var{rep} is @code{\"integer\"}. The default behavior is given if @var{rep}\n\
is @code{\"polynomial\"}.\n\
@seealso{gf, isprimitive}\n\
@end deftypefn")
{
octave_value retval;
int nargin = args.length ();
bool polyrep = true;
enum cyclic_poly_type type = CYCLIC_POLY_MIN;
RowVector cyclic_polys;
int l=0;
if (nargin < 2 || nargin > 4)
{
print_usage ();
return retval;
}
int n = args(0).int_value ();
int k = args(1).int_value ();;
if (n < 1)
{
error ("cyclpoly: n must be 1 or greater");
return retval;
}
if (n <= k)
{
error ("cyclpoly: k must be less than n");
return retval;
}
for (int i = 2; i < nargin; i++)
{
if (args(i).is_scalar_type ())
{
l = args(i).int_value ();
type = CYCLIC_POLY_L;
}
else if (args(i).is_string ())
{
std::string s_arg = args(i).string_value ();
if (s_arg == "integer")
polyrep = false;
else if (s_arg == "polynomial")
polyrep = true;
else if (s_arg == "min")
type = CYCLIC_POLY_MIN;
else if (s_arg == "max")
type = CYCLIC_POLY_MAX;
else if (s_arg == "all")
type = CYCLIC_POLY_ALL;
else
{
error ("cyclpoly: invalid argument");
return retval;
}
}
else
{
error ("cyclpoly: incorrect argument type");
return retval;
}
}
int m = n - k;
// Matlab code seems to think that 1+x+x^3 is of larger weight than
// 1+x^2+x^3. So for matlab compatiability the list of polynomials
// should be reversed by replacing "i+=2" with "i-=2" and visa-versa.
// Thats not going to happen!!!
switch (type)
{
case CYCLIC_POLY_MIN:
cyclic_polys.resize (1);
for (unsigned long long i = (1UL< (1UL<