Changeset 880433 in git


Ignore:
Timestamp:
Oct 31, 2012, 5:50:34 PM (11 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', '52dcfddee5ec87d404d5e0fb44f2d627608208f1')
Children:
8e3dbbf7777bf1a5f6acd0133065b3542d71b4fc
Parents:
f7286a23b786af032ab46ebb6351640245468492
Message:
fix: made local proc static, removed unsed variables (interpolation.cc)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/interpolation.cc

    rf7286a r880433  
    3737#define exponent int
    3838
    39 modp_number myp;  // all modp computation done mod myp
    40 int myp_index; // index of small prime in Singular table of primes
     39static modp_number myp;  // all modp computation done mod myp
     40static int myp_index; // index of small prime in Singular table of primes
    4141
    4242static inline modp_number modp_mul (modp_number x,modp_number y)
     
    8787typedef bool *coord_exist_table;
    8888
    89 int final_base_dim;    // dimension of the quotient space, known from the beginning
    90 int last_solve_column;  // last non-zero column in "solve" part of matrix, used for speed up
    91 int n_points;  // modp_number of ideals (points)
    92 int *multiplicity;  // multiplicities of points
    93 int variables;  // modp_number of variables
    94 int max_coord;  // maximal possible coordinate product used during Evaluation
    95 bool only_modp;  // perform only one modp computations
    96 
    97 modp_coordinates *modp_points; // coordinates of points for modp problem - used by Evaluate (this is also initial data for only modp)
    98 q_coordinates *q_points; // coordinates of points for rational data (not used for modp)
    99 int_coordinates *int_points; // coordinates of points for integer data - used to check generators (not used for modp)
    100 coord_exist_table *coord_exist; // checks whether all coordinates has been initialized
    101 mon_list_entry *check_list; // monomials to be checked in next stages
    102 coordinates *points; // power products of coordinates of points used in modp cycles
    103 condition_type *condition_list; // conditions stored in an array
    104 mon_list_entry *lt_list; // leading terms found so far
    105 mon_list_entry *base_list; // standard monomials found so far
    106 row_list_entry *row_list; // rows of the matrix (both parts)
    107 modp_number *my_row; // one special row to perform operations
    108 modp_number *my_solve_row; // one special row to find the linear dependence ("solve" part)
    109 mono_type *column_name; // monomials assigned to columns in solve_row
    110 
    111 int n_results;  // modp_number of performed modp computations (not discarded)
    112 modp_number modp_denom; // denominator of mod p computations
    113 modp_result_entry *modp_result; // list of results for various mod p calculations (used for modp - first result is the desired one)
    114 modp_result_entry *cur_result; // pointer to current result (as before)
    115 modp_number *congr; // primes used in computations (chinese remainder theorem) (not used for modp)
    116 modp_number *in_gamma; // inverts used in chinese remainder theorem (not used for modp)
    117 mpz_t bigcongr; // result, in fact, is given in mod bigcongr (not used for modp)
    118 
    119 mpz_t *polycoef; // polynomial integercoefficients (not used for modp)
    120 mono_type *polyexp; // polynomial exponents
     89static int final_base_dim;    // dimension of the quotient space, known from the beginning
     90static int last_solve_column;  // last non-zero column in "solve" part of matrix, used for speed up
     91static int n_points;  // modp_number of ideals (points)
     92static int *multiplicity;  // multiplicities of points
     93static int variables;  // modp_number of variables
     94static int max_coord;  // maximal possible coordinate product used during Evaluation
     95static bool only_modp;  // perform only one modp computations
     96
     97static modp_coordinates *modp_points; // coordinates of points for modp problem - used by Evaluate (this is also initial data for only modp)
     98static q_coordinates *q_points; // coordinates of points for rational data (not used for modp)
     99static int_coordinates *int_points; // coordinates of points for integer data - used to check generators (not used for modp)
     100static coord_exist_table *coord_exist; // checks whether all coordinates has been initialized
     101static mon_list_entry *check_list; // monomials to be checked in next stages
     102static coordinates *points; // power products of coordinates of points used in modp cycles
     103static condition_type *condition_list; // conditions stored in an array
     104static mon_list_entry *lt_list; // leading terms found so far
     105static mon_list_entry *base_list; // standard monomials found so far
     106static row_list_entry *row_list; // rows of the matrix (both parts)
     107static modp_number *my_row; // one special row to perform operations
     108static modp_number *my_solve_row; // one special row to find the linear dependence ("solve" part)
     109static mono_type *column_name; // monomials assigned to columns in solve_row
     110
     111static int n_results;  // modp_number of performed modp computations (not discarded)
     112static modp_number modp_denom; // denominator of mod p computations
     113static modp_result_entry *modp_result; // list of results for various mod p calculations (used for modp - first result is the desired one)
     114static modp_result_entry *cur_result; // pointer to current result (as before)
     115static modp_number *congr; // primes used in computations (chinese remainder theorem) (not used for modp)
     116static modp_number *in_gamma; // inverts used in chinese remainder theorem (not used for modp)
     117static mpz_t bigcongr; // result, in fact, is given in mod bigcongr (not used for modp)
     118
     119static mpz_t *polycoef; // polynomial integercoefficients (not used for modp)
     120static mono_type *polyexp; // polynomial exponents
    121121
    122122struct gen_list_struct {mpz_t *polycoef;
     
    125125typedef struct gen_list_struct gen_list_entry;
    126126
    127 gen_list_entry *gen_list=NULL; // list of resulting generators - output data (integer version)
    128 
    129 int generic_n_generators; // modp_number of generators - should be the same for all modp comp (not used for modp)
    130 mono_type *generic_column_name; // monomials assigned to columns in solve_row - should be the same for all modp comp (!!! used for modp)
    131 mon_list_entry *generic_lt=NULL; // leading terms for ordered generators - should be the same for all modp comp (not used for modp)
    132 int good_primes; // modp_number of good primes so far;
    133 int bad_primes; // modp_number of bad primes so far;
    134 mpz_t common_denom; // common denominator used to force points coordinates to Z (not used for modp)
    135 bool denom_divisible; // common denominator is divisible by p (not used for modp)
    136 
    137 poly comparizon_p1;  //polynomials used to do comparizons by Singular
    138 poly comparizon_p2;
    139 
    140 modp_number *modp_Reverse; // reverses in mod p
    141 
    142 bool protocol; // true to show the protocol
     127static gen_list_entry *gen_list=NULL; // list of resulting generators - output data (integer version)
     128
     129static int generic_n_generators; // modp_number of generators - should be the same for all modp comp (not used for modp)
     130static mono_type *generic_column_name; // monomials assigned to columns in solve_row - should be the same for all modp comp (!!! used for modp)
     131static mon_list_entry *generic_lt=NULL; // leading terms for ordered generators - should be the same for all modp comp (not used for modp)
     132static int good_primes; // modp_number of good primes so far;
     133static int bad_primes; // modp_number of bad primes so far;
     134static mpz_t common_denom; // common denominator used to force points coordinates to Z (not used for modp)
     135static bool denom_divisible; // common denominator is divisible by p (not used for modp)
     136
     137static poly comparizon_p1;  //polynomials used to do comparizons by Singular
     138static poly comparizon_p2;
     139
     140static modp_number *modp_Reverse; // reverses in mod p
     141
     142static bool protocol; // true to show the protocol
    143143
    144144#ifdef checksize
    145 int maximal_size=0;
     145static int maximal_size=0;
    146146#endif
    147147
     
    225225#endif
    226226
    227 modp_number OneInverse(modp_number a,modp_number p) // computes inverse of d mod p without using tables
     227static modp_number OneInverse(modp_number a,modp_number p) // computes inverse of d mod p without using tables
    228228{
    229229   long  u, v, u0, u1, u2, q, r;
     
    254254}
    255255
    256 int CalcBaseDim () // returns the maximal (expected) dimension of quotient space
     256static int CalcBaseDim () // returns the maximal (expected) dimension of quotient space
    257257{
    258258    int c;
     
    273273}
    274274
    275 bool EqualMon (mono_type m1, mono_type m2)  // compares two monomials, true if equal, false otherwise
     275static bool EqualMon (mono_type m1, mono_type m2)  // compares two monomials, true if equal, false otherwise
    276276{
    277277     int i;
     
    281281}
    282282
    283 exponent MonDegree (mono_type mon)  // computes the degree of a monomial
     283static exponent MonDegree (mono_type mon)  // computes the degree of a monomial
    284284{
    285285     exponent v=0;
     
    289289}
    290290
    291 bool Greater (mono_type m1, mono_type m2) // true if m1 > m2, false otherwise. uses Singular comparing function
     291static bool Greater (mono_type m1, mono_type m2) // true if m1 > m2, false otherwise. uses Singular comparing function
    292292{
    293293     for (int j = variables; j; j--)
     
    302302}
    303303
    304 mon_list_entry* MonListAdd (mon_list_entry *list, mono_type mon)  // adds one entry to the list of monomials structure
     304static mon_list_entry* MonListAdd (mon_list_entry *list, mono_type mon)  // adds one entry to the list of monomials structure
    305305{
    306306     mon_list_entry *curptr=list;
     
    327327}
    328328
    329 mono_type MonListElement (mon_list_entry *list, int n)  // returns ith element from list of monomials - no error checking!
     329static mono_type MonListElement (mon_list_entry *list, int n)  // returns ith element from list of monomials - no error checking!
    330330{
    331331     mon_list_entry *cur=list;
     
    335335}
    336336
    337 mono_type ZeroMonomial ()  // allocates memory for new monomial with all enries equal 0
     337static mono_type ZeroMonomial ()  // allocates memory for new monomial with all enries equal 0
    338338{
    339339     mono_type m;
     
    342342}
    343343
    344 void GeneralInit ()  // general initialization
    345 {
    346      int i,j,k;
     344static void GeneralInit ()  // general initialization
     345{
     346     int i,j;
    347347     points=(coordinates*)omAlloc(sizeof(coordinates)*n_points);
    348348     for (i=0;i<n_points;i++)
     
    403403}
    404404
    405 void InitProcData ()  // initialization for procedures which do computations mod p
    406 {
    407      int i,j;
     405static void InitProcData ()  // initialization for procedures which do computations mod p
     406{
     407     int i;
    408408     check_list=MonListAdd (check_list,ZeroMonomial ());
    409409     my_row=(modp_number*)omAlloc0(sizeof(modp_number)*final_base_dim);
     
    439439}
    440440
    441 mon_list_entry* FreeMonList (mon_list_entry *list)  // destroys a list of monomials, returns NULL pointer
     441static mon_list_entry* FreeMonList (mon_list_entry *list)  // destroys a list of monomials, returns NULL pointer
    442442{
    443443     mon_list_entry *ptr;
     
    453453}
    454454
    455 void GeneralDone ()  // to be called before exit to free memory
    456 {
    457      int i,j,k;
     455static void GeneralDone ()  // to be called before exit to free memory
     456{
     457     int i,j;
    458458     for (i=0;i<n_points;i++)
    459459     {
     
    504504}
    505505
    506 void FreeProcData ()  // to be called after one modp computation to free memory
     506static void FreeProcData ()  // to be called after one modp computation to free memory
    507507{
    508508     int i;
     
    531531}
    532532
    533 void modp_Evaluate(modp_number *ev, mono_type mon, condition_type con)  // evaluates monomial on condition (modp)
     533static void modp_Evaluate(modp_number *ev, mono_type mon, condition_type con)  // evaluates monomial on condition (modp)
    534534{
    535535    int i;
     
    554554}
    555555
    556 void int_Evaluate(mpz_t ev, mono_type mon, condition_type con) // (***) evaluates monomial on condition for integer numbers
     556static void int_Evaluate(mpz_t ev, mono_type mon, condition_type con) // (***) evaluates monomial on condition for integer numbers
    557557{
    558558    int i;
     
    581581}
    582582
    583 void ProduceRow(mono_type mon)  // produces a row for monomial - first part is an evaluated part, second 0 to obtain the coefs of dependence
     583static void ProduceRow(mono_type mon)  // produces a row for monomial - first part is an evaluated part, second 0 to obtain the coefs of dependence
    584584{
    585585     modp_number *row;
     
    602602}
    603603
    604 void IntegerPoints ()  // produces integer points from rationals by scaling the coordinate system
     604static void IntegerPoints ()  // produces integer points from rationals by scaling the coordinate system
    605605{
    606606     int i,j;
     
    630630}
    631631
    632 void int_PrepareProducts ()  // prepares coordinates of points and products for modp case (from integer coefs)
    633 {
    634      bool ok=true;
     632static void int_PrepareProducts ()  // prepares coordinates of points and products for modp case (from integer coefs)
     633{
    635634     int i,j,k;
    636635     mpz_t big_myp;
     
    655654}
    656655
    657 void modp_PrepareProducts () // prepares products for modp computation from modp data
     656static void modp_PrepareProducts () // prepares products for modp computation from modp data
    658657{
    659658     int i,j,k;
     
    669668}
    670669
    671 void MakeConditions ()  // prepares a list of conditions from list of multiplicities
     670static void MakeConditions ()  // prepares a list of conditions from list of multiplicities
    672671{
    673672     condition_type *con;
     
    700699}
    701700
    702 void ReduceRow ()  // reduces my_row by previous rows, does the same for solve row
     701static void ReduceRow ()  // reduces my_row by previous rows, does the same for solve row
    703702{
    704703     if (row_list==NULL) return ;
     
    776775}
    777776
    778 bool RowIsZero () // check whether a row is zero
     777static bool RowIsZero () // check whether a row is zero
    779778{
    780779     bool zero=1;
     
    790789}
    791790
    792 bool DivisibleMon (mono_type m1, mono_type m2) // checks whether m1 is divisible by m2
     791static bool DivisibleMon (mono_type m1, mono_type m2) // checks whether m1 is divisible by m2
    793792{
    794793     int i;
     
    798797}
    799798
    800 void ReduceCheckListByMon (mono_type m)  // from check_list monomials divisible by m are thrown out
     799static void ReduceCheckListByMon (mono_type m)  // from check_list monomials divisible by m are thrown out
    801800{
    802801     mon_list_entry *c_ptr;
     
    826825}
    827826
    828 void TakeNextMonomial (mono_type mon)  // reads first monomial from check_list, then it is deleted
     827static void TakeNextMonomial (mono_type mon)  // reads first monomial from check_list, then it is deleted
    829828{
    830829     mon_list_entry *n_check_list;
     
    839838}
    840839
    841 void UpdateCheckList (mono_type m) // adds all monomials which are "next" to m (divisible by m and degree +1)
     840static void UpdateCheckList (mono_type m) // adds all monomials which are "next" to m (divisible by m and degree +1)
    842841{
    843842     int i;
     
    850849}
    851850
    852 void ReduceCheckListByLTs ()  // deletes all monomials from check_list which are divisible by one of the leading terms
     851static void ReduceCheckListByLTs ()  // deletes all monomials from check_list which are divisible by one of the leading terms
    853852{
    854853     mon_list_entry *ptr;
     
    861860}
    862861
    863 void RowListAdd (int first_col, mono_type mon) // puts a row into matrix
     862static void RowListAdd (int first_col, mono_type mon) // puts a row into matrix
    864863{
    865864     row_list_entry *ptr;
     
    888887
    889888
    890 void PrepareRow (mono_type mon) // prepares a row and puts it into matrix
     889static void PrepareRow (mono_type mon) // prepares a row and puts it into matrix
    891890{
    892891     modp_number *row;
     
    941940}
    942941
    943 void NewResultEntry ()  // creates an entry for new modp result
     942static void NewResultEntry ()  // creates an entry for new modp result
    944943{
    945944    modp_result_entry *temp;
    946     int i;
    947945    temp=(modp_result_entry*)omAlloc0(sizeof(modp_result_entry));
    948946    if (cur_result==NULL)
     
    964962}
    965963
    966 void FreeResultEntry (modp_result_entry *e) // destroys the result entry, without worrying about where it is
     964static void FreeResultEntry (modp_result_entry *e) // destroys the result entry, without worrying about where it is
    967965{
    968966     generator_entry *cur_gen;
     
    981979
    982980
    983 void NewGenerator (mono_type mon)  // new generator in modp comp found, shoul be stored on the list
    984 {
    985      int i;
     981static void NewGenerator (mono_type mon)  // new generator in modp comp found, shoul be stored on the list
     982{
    986983     generator_entry *cur_ptr;
    987984     generator_entry *prev_ptr;
     
    10061003}
    10071004
    1008 void MultGenerators () // before reconstructing, all denominators must be cancelled
     1005static void MultGenerators () // before reconstructing, all denominators must be cancelled
    10091006{
    10101007#ifndef integerstrategy
     
    10441041#endif
    10451042
    1046 modp_number TakePrime (modp_number p)  // takes "previous" (smaller) prime
     1043static modp_number TakePrime (modp_number p)  // takes "previous" (smaller) prime
    10471044{
    10481045#ifdef HAVE_FACTORY
     
    10541051}
    10551052
    1056 void PrepareChinese (int n) // initialization for CRA
     1053static void PrepareChinese (int n) // initialization for CRA
    10571054{
    10581055     int i,k;
     
    10811078}
    10821079
    1083 void CloseChinese (int n) // after CRA
     1080static void CloseChinese () // after CRA
    10841081{
    10851082     omFree(in_gamma);
     
    10881085}
    10891086
    1090 void ClearGCD () // divides polynomials in basis by gcd of coefficients
     1087static void ClearGCD () // divides polynomials in basis by gcd of coefficients
    10911088{
    10921089     bool first_gcd=true;
     
    11111108}
    11121109
    1113 void ReconstructGenerator (int ngen,int n,bool show) // recostruction of generator from various modp comp
    1114 {
    1115      int size;
     1110static void ReconstructGenerator (int ngen,int n) // recostruction of generator from various modp comp
     1111{
    11161112     int i,j,k;
    11171113     int coef;
     
    11771173}
    11781174
    1179 void Discard ()  // some unlucky prime occures
     1175static void Discard ()  // some unlucky prime occures
    11801176{
    11811177     modp_result_entry *temp;
     
    12271223}
    12281224
    1229 void modp_SetColumnNames ()  // used by modp - sets column names, the old table will be destroyed
     1225static void modp_SetColumnNames ()  // used by modp - sets column names, the old table will be destroyed
    12301226{
    12311227    int i;
     
    12331229}
    12341230
    1235 void CheckColumnSequence () // checks if scheme of computations is as generic one
     1231static void CheckColumnSequence () // checks if scheme of computations is as generic one
    12361232{
    12371233     int i;
     
    13091305#endif
    13101306
    1311 bool CheckGenerator () // evaluates generator to check whether it is good
    1312 {
    1313      mpz_t val,sum,temp;
     1307static bool CheckGenerator () // evaluates generator to check whether it is good
     1308{
     1309     mpz_t val,sum;
    13141310     int con,i;
    13151311     mpz_init(val);
     
    13361332}
    13371333
    1338 void ClearGenList ()
     1334static void ClearGenList ()
    13391335{
    13401336     gen_list_entry *temp;
     
    13551351}
    13561352
    1357 void UpdateGenList ()
     1353static void UpdateGenList ()
    13581354{
    13591355     gen_list_entry *temp,*prev;
     
    14161412
    14171413
    1418 void modp_Main ()
     1414static void modp_Main ()
    14191415{
    14201416     mono_type cur_mon;
     
    14731469}
    14741470
    1475 void ResolveCoeff (mpq_t c, number m)
    1476 {
    1477      if ((long)m & SR_INT)
    1478      {
    1479         long m_val=SR_TO_INT(m);
    1480         mpq_set_si(c,m_val,1);
    1481      }
    1482      else
    1483      {
    1484         if (m->s<2)
    1485         {
    1486            mpz_set(mpq_numref(c),m->z);
    1487            mpz_set(mpq_denref(c),m->n);
    1488            mpq_canonicalize(c);
    1489         }
    1490         else
    1491         {
    1492            mpq_set_z(c,m->z);
    1493         }
    1494      }
     1471static void ResolveCoeff (mpq_t c, number m)
     1472{
     1473  if ((long)m & SR_INT)
     1474  {
     1475    long m_val=SR_TO_INT(m);
     1476    mpq_set_si(c,m_val,1);
     1477  }
     1478  else
     1479  {
     1480    if (m->s<2)
     1481    {
     1482      mpz_set(mpq_numref(c),m->z);
     1483      mpz_set(mpq_denref(c),m->n);
     1484      mpq_canonicalize(c);
     1485    }
     1486    else
     1487    {
     1488      mpq_set_z(c,m->z);
     1489    }
     1490  }
    14951491}
    14961492
     
    16731669           for (i=0;i<generic_n_generators;i++)
    16741670           {
    1675                ReconstructGenerator (i,modp_cycles,false);
     1671               ReconstructGenerator (i,modp_cycles);
    16761672               correct_gen=CheckGenerator ();
    16771673               if (!correct_gen)
     
    16931689           Print("maximal size of output: %d, precision bound: %d.\n",maximalsize,mpz_sizeinbase(bigcongr,10));
    16941690#endif
    1695            CloseChinese (modp_cycles);
     1691           CloseChinese ();
    16961692           modp_cycles=modp_cycles+10;
    16971693        }
Note: See TracChangeset for help on using the changeset viewer.