Changeset 806c18 in git for factory/gengftables.cc


Ignore:
Timestamp:
Nov 15, 2010, 4:34:57 PM (13 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
7c3bca08c96331a56864c1d35b8c2e8ff2e0be89
Parents:
c840d97af622b4e4da8761738b540e21144f716b
Message:
format

git-svn-id: file:///usr/local/Singular/svn/trunk@13655 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • factory/gengftables.cc

    rc840d9 r806c18  
    7979    CanonicalForm prod = x;
    8080    while ( e <= q && ! prod.isOne() ) {
    81         e++;
    82         prod = ( prod * x ) % f;
     81        e++;
     82        prod = ( prod * x ) % f;
    8383    }
    8484    return e;
     
    108108bool
    109109findGenRec ( int d, int n, int q,
    110              const CanonicalForm & m, const Variable & x,
    111              CanonicalForm & result )
     110             const CanonicalForm & m, const Variable & x,
     111             CanonicalForm & result )
    112112{
    113113    int i, p = getCharacteristic();
    114114    if ( n < 0 ) {
    115         cerr << "."; cerr.flush();
    116         // check whether m is irreducible
    117         if ( isIrreducible( m ) ) {
    118             cerr << "*"; cerr.flush();
    119             // check whether m generates multiplicative group
    120             if ( exponent( m, q ) == q - 1 ) {
    121                 result = m;
    122                 return true;
    123             }
    124             else
    125                 return false;
    126         }
    127         else
    128             return false;
     115        cerr << "."; cerr.flush();
     116        // check whether m is irreducible
     117        if ( isIrreducible( m ) ) {
     118            cerr << "*"; cerr.flush();
     119            // check whether m generates multiplicative group
     120            if ( exponent( m, q ) == q - 1 ) {
     121                result = m;
     122                return true;
     123            }
     124            else
     125                return false;
     126        }
     127        else
     128            return false;
    129129    }
    130130    // for each monomial x^0, ..., x^n, ..., x^d, try all possible coefficients
    131131    else  if ( n == d || n == 0 ) {
    132         // we want to have a leading coefficient and a constant term,
    133         // so start with coefficient >= 1
    134         for ( i = 1; i < p; i++ )
    135             if ( findGenRec( d, n-1, q, m + i * power( x, n ), x, result ) )
    136                 return true;
     132        // we want to have a leading coefficient and a constant term,
     133        // so start with coefficient >= 1
     134        for ( i = 1; i < p; i++ )
     135            if ( findGenRec( d, n-1, q, m + i * power( x, n ), x, result ) )
     136                return true;
    137137    }
    138138    else {
    139         for ( i = 0; i < p; i++ )
    140             if ( findGenRec( d, n-1, q, m + i * power( x, n ), x, result ) )
    141                 return true;
     139        for ( i = 0; i < p; i++ )
     140            if ( findGenRec( d, n-1, q, m + i * power( x, n ), x, result ) )
     141                return true;
    142142    }
    143143    return false;
     
    164164    cerr << endl;
    165165    if ( ! ok )
    166         return 0;
     166        return 0;
    167167    else
    168         return result;
     168        return result;
    169169}
    170170//}}}
     
    206206    T[0] = 1;
    207207    for ( i = 1; i < q; i++ )
    208         T[i] = ( T[i-1] * x ) % mipo;
     208        T[i] = ( T[i-1] * x ) % mipo;
    209209
    210210    cerr << "generating addition table ... ";
     
    216216
    217217    for ( i = 0; i < q; i++ ) {
    218         f = T[i] + 1;
    219         int j = 0;
    220         while ( j < q && T[j] != f ) j++;
    221         table[i] = j;
     218        f = T[i] + 1;
     219        int j = 0;
     220        while ( j < q && T[j] != f ) j++;
     221        table[i] = j;
    222222    }
    223223
     
    232232    CFIterator MiPo = mipo;
    233233    for ( i = d; MiPo.hasTerms(); i--, MiPo++ ) {
    234         int exp;
    235         for ( exp = MiPo.exp(); exp < i; i-- )
    236             outfile << " 0";
    237         outfile << " " << MiPo.coeff();
     234        int exp;
     235        for ( exp = MiPo.exp(); exp < i; i-- )
     236            outfile << " 0";
     237        outfile << " " << MiPo.coeff();
    238238    }
    239239    // since mipo is irreducible, it has a constant term,
     
    246246    i = 1;
    247247    while ( i < q ) {
    248         int k = 0;
    249         char * sptr = outstr;
    250         while ( i < q && k < 30 ) {
    251             convert62( table[i], m, sptr );
    252             sptr += m;
    253             k++; i++;
    254         }
    255         while ( k < 30 ) {
    256             convert62( 0, m, sptr );
    257             sptr += m;
    258             k++;
    259         }
    260         outfile << outstr << endl;
     248        int k = 0;
     249        char * sptr = outstr;
     250        while ( i < q && k < 30 ) {
     251            convert62( table[i], m, sptr );
     252            sptr += m;
     253            k++; i++;
     254        }
     255        while ( k < 30 ) {
     256            convert62( 0, m, sptr );
     257            sptr += m;
     258            k++;
     259        }
     260        outfile << outstr << endl;
    261261    }
    262262    outfile.close();
     
    275275    int i, p, q, n;
    276276    for ( i = 0; i < primes_len; i++ ) {
    277         p = primes[i];
    278         q = p*p;
    279         n = 2;
    280         setCharacteristic( p );
    281         while ( q < maxtable ) {
    282             CanonicalForm f = findGen( n, q );
    283             ASSERT( f != 0, "no generator found" );
    284             printTable( n, q, f );
    285             n++; q *= p;
    286         }
    287     }
    288 }
     277        p = primes[i];
     278        q = p*p;
     279        n = 2;
     280        setCharacteristic( p );
     281        while ( q < maxtable ) {
     282            CanonicalForm f = findGen( n, q );
     283            ASSERT( f != 0, "no generator found" );
     284            printTable( n, q, f );
     285            n++; q *= p;
     286        }
     287    }
     288}
Note: See TracChangeset for help on using the changeset viewer.