Changeset aa5055 in git for factory


Ignore:
Timestamp:
Dec 17, 2008, 4:06:45 PM (15 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
5d68a6461c92be4d1e47a759b7bafae1be5ffb12
Parents:
35e3a67b3cf2f0f3347c117abbfc926bf620ca3a
Message:
*hannes: format


git-svn-id: file:///usr/local/Singular/svn/trunk@11252 2c84dea3-7e68-4137-9b89-c4e89433aadc
Location:
factory
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • factory/cf_inline.cc

    r35e3a6 raa5055  
    11/* emacs edit mode for this file is -*- C++ -*- */
    2 /* $Id: cf_inline.cc,v 1.1 1998-06-29 10:46:07 schmidt Exp $ */
     2/* $Id: cf_inline.cc,v 1.2 2008-12-17 15:06:45 Singular Exp $ */
    33
    44//{{{ docu
     
    373373    int what = is_imm( value );
    374374
    375     if ( ! what )
     375    if ( what == 0 )
    376376        return value->isZero();
    377377    else  if ( what == INTMARK )
  • factory/gfops.cc

    r35e3a6 raa5055  
    11/* emacs edit mode for this file is -*- C++ -*- */
    2 /* $Id: gfops.cc,v 1.8 2008-08-20 14:44:49 Singular Exp $ */
     2/* $Id: gfops.cc,v 1.9 2008-12-17 15:06:24 Singular Exp $ */
    33
    44#include <config.h>
     
    5959    for ( i = 0; i <= degree; i++ )
    6060    {
    61         result += CanonicalForm( coeffs[ i ] ) * power( Variable( level ), degree - i );
     61        result += CanonicalForm( coeffs[ i ] ) * power( Variable( level ), degree - i );
    6262    }
    6363    return result;
     
    6969    char buffer[gf_maxbuffer];
    7070    int q = ipower( p, n );
    71     if ( gf_table == 0 )
    72         gf_table = new unsigned short[gf_maxtable];
    7371
    7472    // do not read the table a second time
    7573    if ( gf_q == q )
    7674    {
    77         return;
    78     }
     75        return;
     76    }
     77
     78    if ( gf_table == 0 )
     79        gf_table = new unsigned short[gf_maxtable];
    7980
    8081#ifdef SINGULAR
    8182    // just copy the table if Singular already read it
     83    //printf("init_gf(gf_get_table) q=%d, nfCharQ=%d\n",q,nfCharQ);
    8284    if ( q == nfCharQ )
    8385    {
    84         gf_p = p; gf_n = n;
    85         gf_q = q; gf_q1 = q - 1;
    86         gf_m1 = nfM1;
    87         gf_mipo = intVec2CF( nfMinPoly[0], nfMinPoly + 1, 1 );
    88         (void)memcpy( gf_table, nfPlus1Table, gf_q * sizeof( unsigned short ) );
    89         gf_table[gf_q] = 0;
    90         return;
     86        gf_p = p; gf_n = n;
     87        gf_q = q; gf_q1 = q - 1;
     88        gf_m1 = nfM1;
     89        gf_mipo = intVec2CF( nfMinPoly[0], nfMinPoly + 1, 1 );
     90        (void)memcpy( gf_table, nfPlus1Table, gf_q * sizeof( unsigned short ) );
     91        gf_table[gf_q] = 0;
     92        return;
    9193    }
    9294#endif
     
    124126    for ( i = 0; i <= degree; i++ )
    125127    {
    126         sscanf( bufptr, "%d", mipo + i );
    127         bufptr = (char *)strchr( bufptr, ' ' ) + 1;
     128        sscanf( bufptr, "%d", mipo + i );
     129        bufptr = (char *)strchr( bufptr, ' ' ) + 1;
    128130    }
    129131
     
    138140    while ( i < gf_q )
    139141    {
    140         success = fgets( buffer, gf_maxbuffer, inputfile );
    141         STICKYASSERT( strlen( buffer ) - 1 == (size_t)digs * 30, "illegal table" );
    142         bufptr = buffer;
    143         k = 0;
    144         while ( i < gf_q && k < 30 )
     142        success = fgets( buffer, gf_maxbuffer, inputfile );
     143        STICKYASSERT( strlen( buffer ) - 1 == (size_t)digs * 30, "illegal table" );
     144        bufptr = buffer;
     145        k = 0;
     146        while ( i < gf_q && k < 30 )
    145147        {
    146             gf_table[i] = convertback62( bufptr, digs );
    147             bufptr += digs;
     148            gf_table[i] = convertback62( bufptr, digs );
     149            bufptr += digs;
    148150            if ( gf_table[i] == gf_q )
    149                 if ( i == gf_q1 )
    150                     gf_m1 = 0;
    151                 else
    152                     gf_m1 = i;
    153             i++; k++;
    154         }
     151                if ( i == gf_q1 )
     152                    gf_m1 = 0;
     153                else
     154                    gf_m1 = i;
     155            i++; k++;
     156        }
    155157    }
    156158    gf_table[0] = gf_table[gf_q1];
     
    166168    while ( i < gf_primes_len && gf_primes[i] != p ) i++;
    167169    if ( i == gf_primes_len )
    168         return false;
     170        return false;
    169171    else
    170172    {
    171         i = n;
    172         int a = 1;
    173         while ( a < gf_maxtable && i > 0 )
     173        i = n;
     174        int a = 1;
     175        while ( a < gf_maxtable && i > 0 )
    174176        {
    175             a *= p;
    176             i--;
    177         }
    178         if ( i > 0 || a > gf_maxtable )
    179             return false;
    180         else
    181             return true;
     177            a *= p;
     178            i--;
     179        }
     180        if ( i > 0 || a > gf_maxtable )
     181            return false;
     182        else
     183            return true;
    182184    }
    183185}
     
    195197{
    196198    if ( gf_iszero( a ) )
    197         return 0;
     199        return 0;
    198200    else
    199201    {
    200         // starting from z^0=1, step through the table
    201         // counting the steps until we hit z^a or z^0
    202         // again.  since we are working in char(p), the
    203         // latter is guaranteed to be fulfilled.
    204         int i = 0, ff = 1;
    205         do
     202        // starting from z^0=1, step through the table
     203        // counting the steps until we hit z^a or z^0
     204        // again.  since we are working in char(p), the
     205        // latter is guaranteed to be fulfilled.
     206        int i = 0, ff = 1;
     207        do
    206208        {
    207             if ( i == a )
    208                 return ff;
    209             ff++;
    210             i = gf_table[i];
    211         } while ( i != 0 );
    212         return -1;
     209            if ( i == a )
     210                return ff;
     211            ff++;
     212            i = gf_table[i];
     213        } while ( i != 0 );
     214        return -1;
    213215    }
    214216}
     
    218220{
    219221    if ( gf_iszero( a ) )
    220         return true;
     222        return true;
    221223    else
    222224    {
    223         // z^a in GF(p) iff (z^a)^p-1=1
    224         return gf_isone( gf_power( a, gf_p - 1 ) );
    225     }
    226 }
     225        // z^a in GF(p) iff (z^a)^p-1=1
     226        return gf_isone( gf_power( a, gf_p - 1 ) );
     227    }
     228}
Note: See TracChangeset for help on using the changeset viewer.