Ejemplo n.º 1
0
int run_mzed_add(void *_p, unsigned long long *data, int *data_len) {
  struct smallops_params *p = (struct smallops_params *)_p;
  *data_len = 2;

  gf2e *ff = gf2e_init(irreducible_polynomials[p->k][1]);

  mzed_t *A = mzed_init(ff,p->m,p->n);
  mzed_randomize(A);
  mzed_t *B = mzed_init(ff,p->m,p->n);
  mzed_randomize(B);
  mzed_t *C = mzed_init(ff,p->m,p->n);

  data[0] = walltime(0);
  data[1] = cpucycles();

  mzed_add(C, A, B);

  data[1] = cpucycles() - data[1];
  data[0] = walltime(data[0]);

  mzed_free(A);
  mzed_free(B);
  mzed_free(C);

  gf2e_free(ff);
  return 0;
}
Ejemplo n.º 2
0
void generate_matrix_MS_inverse()
{
	uint16_t int Irred[9]; /*Irreducible polynomials */
	Irred[0] = 1; Irred[1] = 1; Irred[2] = 0; Irred[3] = 1;
	Irred[4] = 1; Irred[5] = 0; Irred[6] = 0; Irred[7] = 0;
	Irred[8] = 1;

	gf2e *ff;
	int k;

	for(k = 2; k <= 8; k++)
	{
		ff = gf2e_init(Irred[k]);
	}

	const size_t mat_dim = m;
	int i,j;
	mzed_t *S = mzed_init(ff, ,mat_dim, mat_dim);

	for(i = 0; i < m; i++)
	{
		for(j = 0; j < m; j++)
		{
			mzed_add_elem(S, i, j, matrix_MS[i][j]);
		}
	}
	mzed_t *S_INV = mzed_init(ff, mat_dim, mat_dim);
	mzed_invert_newton_john(S_INV, S);
	mzed_free(S);

	matrix_MS_inverse = malloc(m*sizeof(int*));

	for(i = 0; i < m; i++)
	{
		matrix_MS_inverse[i] = malloc((m+1)*sizeof(int));
	}

	for(i = 0; i < m; i++)
	{
		for(j = 0; j < m; j++)
		{
			matrix_MS_inverse[i][j] = mzed_read_elem(S_INV, i, j);
		}
		matrix_MS_inverse[i][m] = matrix_MS[i][m];
	}
	mzed_free(S_INV);
	gf2e_free(ff);

}
Ejemplo n.º 3
0
void generate_matrix_MT_inverse()
{
	uint16_t int Irred[9];
	Irred[0] = 1; Irred[1] = 1; Irred[2] = 0; Irred[3] = 1;
	Irred[4] = 1; Irred[5] = 0; Irred[6] = 0; Irred[7] = 0;
	Irred[8] = 1;

	gf2e *ff;
	int k;

	for(k = 2; k <= 8; k++)
	{
		ff = gf2e_init(Irred[k]);
	}

	const size_t mat_dim = n;
	mzed_t *T = mzed_init(ff, mat_dim, mat_dim);
	int i, j;

	for(i = 0; i < n; i++)
	{
		for(j = 0; j < n; j++)
		{
			mzed_add_elem(T, i, j, matrix_MT[i][j]);
		}
	}

	mzed_t *T_INV = mzed_init(ff,mat_dim, mat_dim);
	mzed_invert_newton_john(T_INV, T);
	mzed_free(T);
	matrix_MT_inverse = malloc(n*sizeof(int*));

	for(i = 0; i < n; i++)
	{
		matrix_MT_inverse[i] = malloc((n+1)*int);
	}
	for(i = 0; i < n; i++)
	{
		for(j = 0; j < n; j++)
		{
			matrix_MT_inverse[i][j] = mzed_read_elem(T_INV, i, j);
		}
		matrix_MT_inverse[i][n] = matrix_MT[i][n];
	}
	mzed_free(T_INV);
	gf2e_free(ff);
}
Ejemplo n.º 4
0
void generate_matrix_MS22_inverse()
{
	uint16_t int Irred[9];
	Irred[0] = 1; Irred[1] = 1; Irred[2] = 0; Irred[3] = 1;
	Irred[4] = 1; Irred[5] = 0; Irred[6] = 0; Irred[7] = 0;
	Irred[8] = 1;

	gf2e *ff;
	int k;

	for(k = 2; k <= 8; k++)
	{
		ff = gf2e_init(Irred[k]);
	}

	const size_t mat_dim = o2;
	mzed_t *S22 = mzed_init(ff, mat_dim, mat_dim);
	int i, j;

	for(i = 0; i < o2; i++)
	{
		for(j = 0; j < o2; j++)
		{
			/* o1 + i >= o2 || o1 + j >= o2 .*/
			mzed_add_elem(S22, i, j, matrix_MS[o1+i][o1+j]);
		}
	}
	mzed_t *S22_INV = mzed_init(ff, mat_dim, mat_dim);
	mzed_invert_newton_john(S22_INV, S22);
	mzed_free(S22);

	matrix_MS22_inverse = malloc(o2*sizeof(int*));
	for(i = 0; i < o2; i++)
	{
		matrix_MS22_inverse[i] = malloc(o2*sizeof(int));
	}
	for(i = 0; i < o2; i++)
	{
		for(j = 0; j < o2; j++)
		{
			matrix_MS22_inverse[i][j] = mzed_read_elem(S22_INV, i, j);
		}
	}
	mzed_free(S22_INV);
	gf2e_free(ff);
}
Ejemplo n.º 5
0
void generate_matrix_A_inverse()
{
	uint16_t int Irred[9];
	Irred[0] = 1; Irred[1] = 1; Irred[2] = 0; Irred[3] = 1;
	Irred[4] = 1; Irred[5] = 0; Irred[6] = 0; Irred[7] = 0;
	Irred[8] = 1;
	int k;
	gf2e *ff;

	for(k = 2; k <= 8; k++)
	{
		ff = gf2e_init(Irred[k]);
	}

	const size_t mat_dim = D2;
	mzed_t *A = mzed_init(ff, mat_dim, mat_dim);
	int i,j;

	for(i = 0; i < D2; i++)
	{
		for(j = 0; j < D2; j++)
		{
			mzed_add_elem(A, i, j, matrix_A[i][j]);
		}
	}
	mzed_t *A_INV = mzed_init(ff, mat_dim, mat_dim);
	mzed_invert_newton_john(A_INV, A);
	matrix_A_inverse_T = malloc(D2*sizeof(int*));
	mzed_free(A);

	for(i = 0; i < D2; i++)
	{
		matrix_A_inverse_T[i] = malloc(D2*sizeof(int));
	}

	for(i = 0; i < D2; i++)
	{
		for(j = 0; j < D2; j++)
		{
			matrix_A_inverse_T[j][i] = mzed_read_elem(A_INV, i, j);
		}
	}
	mzed_free(A_INV);
	gf2e_free(ff);
}
Ejemplo n.º 6
0
int main(int argc, char **argv) {
  srandom(17);

  int runlong = parse_parameters(argc, argv);

  gf2e *ff;
  int fail_ret = 0;

  for(int k=2; k<=16; k++) {
    ff = gf2e_init(irreducible_polynomials[k][1]);

    fail_ret += test_batch(ff,   2,   5);
    fail_ret += test_batch(ff,   5,  10);
    fail_ret += test_batch(ff,   1,   1);
    fail_ret += test_batch(ff,   1,   2);
    fail_ret += test_batch(ff,  11,  12);
    fail_ret += test_batch(ff,  21,  22);
    fail_ret += test_batch(ff,  13,   2);
    fail_ret += test_batch(ff,  32,  33);
    fail_ret += test_batch(ff,  63,  64);
    if (k <= 12 || runlong) {
      fail_ret += test_batch(ff, 127, 128);
      fail_ret += test_batch(ff, 200,  20);
    }
    fail_ret += test_batch(ff,   1,   1);
    fail_ret += test_batch(ff,   1,   3);
    fail_ret += test_batch(ff,  11,  13);
    fail_ret += test_batch(ff,  21,  23);
    fail_ret += test_batch(ff,  13,  90);
    fail_ret += test_batch(ff,  32,  34);
    fail_ret += test_batch(ff,  63,  65);
    if (k <= 12 || runlong) {
      fail_ret += test_batch(ff, 127, 129);
      fail_ret += test_batch(ff, 200, 112);
      fail_ret += test_batch(ff,  10, 200);
    }
    gf2e_free(ff);
  }

  return fail_ret;
}
Ejemplo n.º 7
0
MatrixFn::~MatrixFn()
{
    mzed_free(matrix);
    gf2e_free(field);
}