Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/GAP/pkg/standardff/ntl/   (Algebra von RWTH Aachen Version 4.15.1©)  Datei vom 13.8.2023 mit Größe 1 kB image not shown  

Quelle  findstdirrGF2.cc   Sprache: C

 
//   g++ -O3 -o findstdirrGF2 findstdirrGF2.cc -lntl
#include <NTL/ZZX.h>
#include <NTL/GF2XFactoring.h>

using namespace std;
using namespace NTL;

//  standard affine shift
ZZ sasm(ZZ q)
{
  ZZ m;
  for (m = (4*q)/5; GCD(m, q) > 1; m--);
  return m;
}
ZZ sasa(ZZ q)
{
  return (2*q)/3;
}
ZZ sas(ZZ q, long i, ZZ m, ZZ a)
{
    ZZ res;
    mul(res, m, i);
    add(res, res, a);
    rem(res, res, q);
    return res;
}

int main()
{
   ZZ st, qq, m, a, s;
   long inc, d, i, c;
   long p=2;
   long r, count;
   cin >> r;

   for (inc = 1, qq = p; qq < 2*r; qq *= p, inc++);
   d = 0;
   count = 0;
   GF2X f;
   // first polynomial to test
   SetCoeff(f, 0, 1);
   SetCoeff(f, 1, 1);
   SetCoeff(f, r, 1);
   // the test loop
   for (; ! IterIrredTest(f); count++) {
      //cout << "red: " << count << ":" << f << "\n";
      if ((count % r) == 0) {
        d = d + inc;
        if (d > r-1) d = r-1;
        power(qq, p, d-1);
        m = sasm(qq);
        a = sasa(qq);
        //cout << "d:" << d << "\n";
      }
      s = sas(qq, count, m, a);
      //cout << "st:" << s << "\n";
      for (i=1; i<=d; i++) {
        c = rem(s, p);
        s = (s-c)/p;
        SetCoeff(f, i, c);
      }
   }
   //cout << "# tried " << count << " polynomials.\n";
   //cout << f << "\n";
   SetCoeff(f, r, 0);
   st = 0;
   for (st = 0, i = deg(f); i >= 0; i--) {
     st *= 2;
     if (IsOne(coeff(f, i))) st++;
   }
   cout << st;
}

98%


¤ Dauer der Verarbeitung: 0.12 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung ist noch experimentell.