[SCM] Fast arithmetic with dense matrices over F_{2^e} branch, upstream, updated. 9faf6ece9a183a703670566609063ab274b1c544

Martin Albrecht martinralbrecht at googlemail.com
Mon Sep 10 12:24:27 UTC 2012


The following commit has been merged in the upstream branch:
commit 60802a803fdfe7c133f3d22b4c97742099c4939c
Author: Martin Albrecht <martinralbrecht at googlemail.com>
Date:   Wed Aug 15 11:41:41 2012 +0100

    more tests for degrees > 10 and <= 16

diff --git a/tests/test_elimination.cc b/tests/test_elimination.cc
index 02a46fd..2e1a25d 100644
--- a/tests/test_elimination.cc
+++ b/tests/test_elimination.cc
@@ -96,39 +96,40 @@ int test_batch(gf2e *ff, rci_t m, rci_t n) {
 int main(int argc, char **argv) {
   srandom(17);
 
-  gf2e *ff[17];
-  int fail_ret = 0;
-
-  for(int k=2; k<=16; k++) {
-    ff[k] = gf2e_init(irreducible_polynomials[k][1]);
-  }
+  int runlong = parse_parameters(argc, argv);
 
-  for(int k=2; k<=16; k++) {
-    fail_ret += test_batch(ff[k],   2,   5);
-    fail_ret += test_batch(ff[k],   5,  10);
-    fail_ret += test_batch(ff[k],   1,   1);
-    fail_ret += test_batch(ff[k],   1,   2);
-    fail_ret += test_batch(ff[k],  11,  12);
-    fail_ret += test_batch(ff[k],  21,  22);
-    fail_ret += test_batch(ff[k],  13,   2);
-    fail_ret += test_batch(ff[k],  32,  33);
-    fail_ret += test_batch(ff[k],  63,  64);
-    fail_ret += test_batch(ff[k], 127, 128);
-    fail_ret += test_batch(ff[k], 200,  20);
-    fail_ret += test_batch(ff[k],   1,   1);
-    fail_ret += test_batch(ff[k],   1,   3);
-    fail_ret += test_batch(ff[k],  11,  13);
-    fail_ret += test_batch(ff[k],  21,  23);
-    fail_ret += test_batch(ff[k],  13,  90);
-    fail_ret += test_batch(ff[k],  32,  34);
-    fail_ret += test_batch(ff[k],  63,  65);
-    fail_ret += test_batch(ff[k], 127, 129);
-    fail_ret += test_batch(ff[k], 200, 112);
-    fail_ret += test_batch(ff[k],  10, 200);
-  };
+  gf2e *ff;
+  int fail_ret = 0;
 
   for(int k=2; k<=16; k++) {
-    gf2e_free(ff[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;
diff --git a/tests/test_multiplication.cc b/tests/test_multiplication.cc
index 8fc3008..c7255d4 100644
--- a/tests/test_multiplication.cc
+++ b/tests/test_multiplication.cc
@@ -25,7 +25,6 @@
 ******************************************************************************/
 
 #include "testing.h"
-#include <unistd.h>
 
 int test_addmul(gf2e *ff, rci_t m, rci_t n, rci_t l) {
   int fail_ret = 0;
@@ -218,45 +217,27 @@ int test_batch(gf2e *ff, rci_t m, rci_t l, rci_t n) {
 int main(int argc, char **argv) {
   srandom(17);
 
-  int runlong = 0;
-
-  int c;
-  while ((c = getopt(argc, argv, "l")) != -1) {
-    switch (c) {
-    case 'l':
-      runlong = 1;
-      break;
-    case '?':
-      printf(" -l   run long tests.\n");
-      abort();
-    default:
-      abort();
-    }
-  }
+  int runlong = parse_parameters(argc, argv);
 
-  gf2e *ff[17];
+  gf2e *ff;
   int fail_ret = 0;
 
   for(int k=2; k<=16; k++) {
-    ff[k] = gf2e_init(irreducible_polynomials[k][1]);
-  }
-
-  for(int k=2; k<=16; k++) {
-    fail_ret += test_batch(ff[k],   1,   1,   1);
-    fail_ret += test_batch(ff[k],   1,   2,   3);
-    fail_ret += test_batch(ff[k],  11,  12,  13);
-    fail_ret += test_batch(ff[k],  21,  22,  23);
-    fail_ret += test_batch(ff[k],  13,   2,  90);
-    fail_ret += test_batch(ff[k],  32,  33,  34);
-    fail_ret += test_batch(ff[k],  63,  64,  65);
+    ff = gf2e_init(irreducible_polynomials[k][1]);
+
+    fail_ret += test_batch(ff,   1,   1,   1);
+    fail_ret += test_batch(ff,   1,   2,   3);
+    fail_ret += test_batch(ff,  11,  12,  13);
+    fail_ret += test_batch(ff,  21,  22,  23);
+    fail_ret += test_batch(ff,  13,   2,  90);
+    fail_ret += test_batch(ff,  32,  33,  34);
+    fail_ret += test_batch(ff,  63,  64,  65);
     if(k<=12 || runlong) {
-      fail_ret += test_batch(ff[k], 127, 128, 129);
-      fail_ret += test_batch(ff[k], 200,  20, 112);
+      fail_ret += test_batch(ff, 127, 128, 129);
+      fail_ret += test_batch(ff, 200,  20, 112);
     }
-  };
 
-  for(int k=2; k<=16; k++) {
-    gf2e_free(ff[k]);
+    gf2e_free(ff);
   }
 
   return fail_ret;
diff --git a/tests/test_ple.cc b/tests/test_ple.cc
index 4cac5b4..7dd6b79 100644
--- a/tests/test_ple.cc
+++ b/tests/test_ple.cc
@@ -170,7 +170,7 @@ int test_batch(gf2e *ff, const rci_t m, const rci_t n, const rci_t r) {
   assert(r <= m);
   assert(r <= n);
 
-  printf("ple: k: %2d, minpoly: 0x%03x m: %5d, n: %5d, r: %5d ",(int)ff->degree, (unsigned int)ff->minpoly, (int)m, (int)n, (int)r);
+  printf("ple: k: %2d, minpoly: 0x%05x m: %5d, n: %5d, r: %5d ",(int)ff->degree, (unsigned int)ff->minpoly, (int)m, (int)n, (int)r);
 
   int fail_ret = 0;
 
@@ -207,42 +207,44 @@ int test_batch(gf2e *ff, const rci_t m, const rci_t n, const rci_t r) {
 int main(int argc, char **argv) {
   srandom(17);
 
-  gf2e *ff[11];
+  int runlong = parse_parameters(argc, argv);
+
+  gf2e *ff;
   int fail_ret = 0;
 
-  for(int k=2; k<=10; k++) {
-    ff[k] = gf2e_init(irreducible_polynomials[k][1]);
+  for(int k=2; k<=16; k++) {
+    ff = gf2e_init(irreducible_polynomials[k][1]);
+
+    fail_ret += test_batch(ff,   1,   1,   1);
+    fail_ret += test_batch(ff,   1,   2,   1);
+    fail_ret += test_batch(ff,   2,   2,   2);
+    fail_ret += test_batch(ff,   2,   3,   2);
+    fail_ret += test_batch(ff,  11,  12,  10);
+    fail_ret += test_batch(ff,  21,  22,  21);
+    fail_ret += test_batch(ff,  13,   2,   2);
+    fail_ret += test_batch(ff,  32,  33,  31);
+    fail_ret += test_batch(ff,  63,  64,  62);
+    if(k <= 12 || runlong) {
+      fail_ret += test_batch(ff, 127, 128, 125);
+      fail_ret += test_batch(ff, 127, 128,  12);
+      fail_ret += test_batch(ff, 127, 128,  37);
+      fail_ret += test_batch(ff, 127, 128,  67);
+      fail_ret += test_batch(ff, 200,  20,  19);
+    }
+    fail_ret += test_batch(ff,   1,   1,   0);
+    fail_ret += test_batch(ff,   1,   3,   1);
+    fail_ret += test_batch(ff,  11,  13,  10);
+    fail_ret += test_batch(ff,  21,  23,  20);
+    fail_ret += test_batch(ff,  13,  90,  10);
+    fail_ret += test_batch(ff,  32,  34,  31);
+    fail_ret += test_batch(ff,  63,  65,  62);
+    if(k <= 12 || runlong) {
+      fail_ret += test_batch(ff, 127, 129, 127);
+      fail_ret += test_batch(ff, 200, 112, 111);
+    }
+    gf2e_free(ff);
   }
 
-  for(int k=2; k<=10; k++) {
-    fail_ret += test_batch(ff[k],   1,   1,   1);
-    fail_ret += test_batch(ff[k],   1,   2,   1);
-    fail_ret += test_batch(ff[k],   2,   2,   2);
-    fail_ret += test_batch(ff[k],   2,   3,   2);
-    fail_ret += test_batch(ff[k],  11,  12,  10);
-    fail_ret += test_batch(ff[k],  21,  22,  21);
-    fail_ret += test_batch(ff[k],  13,   2,   2);
-    fail_ret += test_batch(ff[k],  32,  33,  31);
-    fail_ret += test_batch(ff[k],  63,  64,  62);
-    fail_ret += test_batch(ff[k], 127, 128, 125);
-    fail_ret += test_batch(ff[k], 127, 128,  12);
-    fail_ret += test_batch(ff[k], 127, 128,  37);
-    fail_ret += test_batch(ff[k], 127, 128,  67);
-    fail_ret += test_batch(ff[k], 200,  20,  19);
-    fail_ret += test_batch(ff[k],   1,   1,   0);
-    fail_ret += test_batch(ff[k],   1,   3,   1);
-    fail_ret += test_batch(ff[k],  11,  13,  10);
-    fail_ret += test_batch(ff[k],  21,  23,  20);
-    fail_ret += test_batch(ff[k],  13,  90,  10);
-    fail_ret += test_batch(ff[k],  32,  34,  31);
-    fail_ret += test_batch(ff[k],  63,  65,  62);
-    fail_ret += test_batch(ff[k], 127, 129, 127);
-    fail_ret += test_batch(ff[k], 200, 112, 111);
-  };
-
-  for(int k=2; k<=10; k++) {
-    gf2e_free(ff[k]);
-  }
   if (fail_ret == 0)
     printf("success\n");
 
diff --git a/tests/test_trsm.cc b/tests/test_trsm.cc
index 9f0db40..75d73ea 100644
--- a/tests/test_trsm.cc
+++ b/tests/test_trsm.cc
@@ -438,7 +438,7 @@ int test_mzd_slice_trsm_lower_left(gf2e *ff, rci_t m, rci_t n) {
 
 int test_batch(gf2e *ff, rci_t m, rci_t n) {
   int fail_ret = 0;
-  printf("trsm: k: %2d, minpoly: 0x%03x m: %5d, n: %5d ",(int)ff->degree, (unsigned int)ff->minpoly, (int)m,(int)n);
+  printf("trsm: k: %2d, minpoly: 0x%05x m: %5d, n: %5d ",(int)ff->degree, (unsigned int)ff->minpoly, (int)m,(int)n);
 
   m4rie_check(test_mzed_trsm_lower_left(ff, m, n) == 0); printf("."); fflush(0);
   m4rie_check(test_mzed_trsm_upper_left(ff, m, n) == 0); printf("."); fflush(0);
@@ -468,30 +468,30 @@ int test_batch(gf2e *ff, rci_t m, rci_t n) {
 int main(int argc, char **argv) {
   srandom(17);
 
-  gf2e *ff[11];
+  int runlong = parse_parameters(argc, argv);
+
+  gf2e *ff;
   int fail_ret = 0;
 
-  for(int k=2; k<=10; k++) {
-    ff[k] = gf2e_init(irreducible_polynomials[k][1]);
+  for(int k=2; k<=16; k++) {
+    ff = gf2e_init(irreducible_polynomials[k][1]);
+
+    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);
+    fail_ret += test_batch(ff,  65,  1);
+    fail_ret += test_batch(ff,  65,  66);
+    if(k<=12 || runlong) {
+      fail_ret += test_batch(ff, 127, 128);
+      fail_ret += test_batch(ff, 200,  20);
+    }
+    gf2e_free(ff);
   }
 
-  for(int k=2; k<=10; k++) {
-    fail_ret += test_batch(ff[k],   1,   1);
-    fail_ret += test_batch(ff[k],   1,   2);
-    fail_ret += test_batch(ff[k],  11,  12);
-    fail_ret += test_batch(ff[k],  21,  22);
-    fail_ret += test_batch(ff[k],  13,   2);
-    fail_ret += test_batch(ff[k],  32,  33);
-    fail_ret += test_batch(ff[k],  63,  64);
-    fail_ret += test_batch(ff[k],  65,  1);
-    fail_ret += test_batch(ff[k],  65,  66);
-    fail_ret += test_batch(ff[k], 127, 128);
-    fail_ret += test_batch(ff[k], 200,  20);
-  };
-
-  for(int k=2; k<=10; k++) {
-    gf2e_free(ff[k]);
-  }
   if (fail_ret == 0)
     printf("success\n");
 
diff --git a/tests/testing.h b/tests/testing.h
index ea2669d..d72c499 100644
--- a/tests/testing.h
+++ b/tests/testing.h
@@ -1,3 +1,4 @@
+#include <unistd.h>
 #include <m4rie.h>
 
 #define m4rie_check(expr)						\
@@ -202,3 +203,22 @@ static inline mzed_t *random_mzed_t_rank(gf2e *ff, const rci_t m, const rci_t n,
   mzed_set_canary(A);
   return A;
 }
+
+
+static inline int parse_parameters(int argc, char **argv) {
+  int runlong = 0;
+  int c;
+  while ((c = getopt(argc, argv, "l")) != -1) {
+    switch (c) {
+    case 'l':
+      runlong = 1;
+      break;
+    case '?':
+      printf(" -l   run long tests.\n");
+      abort();
+    default:
+      abort();
+    }
+  }
+  return runlong;
+}

-- 
Fast arithmetic with dense matrices over F_{2^e}



More information about the debian-science-commits mailing list