Changeset 8c484e in git


Ignore:
Timestamp:
May 5, 2010, 3:05:12 PM (14 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'b4f17ed1d25f93d46dbe29e4b499baecc2fd51bb')
Children:
2336d0a674d92415a0e20e0b4abf6b1a96ab56e2
Parents:
63c3a8df898418cfb9484633a8d9eb78c299a95c
git-author:
Hans Schoenemann <hannes@mathematik.uni-kl.de>2010-05-05 15:05:12+02:00
git-committer:
Mohamed Barakat <mohamed.barakat@rwth-aachen.de>2011-11-09 11:51:39+01:00
Message:
init for Z/p
Location:
coeffs
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • coeffs/coeffs.h

    r63c3a8 r8c484e  
    128128   // ?
    129129   // initialisation:
    130    void (*cfInitChar)(coeffs r); // do one-time initialisations
     130   void (*cfInitChar)(coeffs r, int parameter); // do one-time initialisations
    131131   void (*cfKillChar)(coeffs r); //  undo all initialisations
    132132                                // or NULL
  • coeffs/modulop.cc

    r63c3a8 r8c484e  
    88
    99#include <string.h>
     10#include "config.h"
     11#include <omalloc.h>
    1012#include "coeffs.h"
     13#include "output.h"
    1114#include "numbers.h"
    1215#include "longrat.h"
    1316#include "mpr_complex.h"
     17#include "mylimits.h"
    1418#include "modulop.h"
    1519
    1620int npGen=0;
    17 long npMapPrime;
    1821
    1922#ifdef HAVE_DIV_MOD
     
    243246      ii *= 10;
    244247      ii += *s++ - '0';
    245       if (ii >= (MAX_INT_VAL / 10)) ii = ii % r->npPrimeM;
     248      if (ii >= (MAX_INT / 10)) ii = ii % r->npPrimeM;
    246249    }
    247250    while (((*s) >= '0') && ((*s) <= '9'));
     
    304307}
    305308
    306 void npInitChar(int c, coeffs r)
     309void npKillChar(coeffs r)
     310{
     311  #ifdef HAVE_DIV_MOD
     312  if (r->npInvTable!=NULL)
     313  omFreeSize( (void *)r->npInvTable, r->npPrimeM*sizeof(unsigned short) );
     314  r->npInvTable=NULL;
     315  #else
     316  if (r->npExpTable!=NULL)
     317  {
     318    omFreeSize( (void *)r->npExpTable, r->npPrimeM*sizeof(unsigned short) );
     319    omFreeSize( (void *)r->npLogTable, r->npPrimeM*sizeof(unsigned short) );
     320    r->npExpTable=NULL; r->npLogTable=NULL;
     321  }
     322  #endif
     323}
     324
     325void npInitChar(coeffs r, int c)
    307326{
    308327  int i, w;
     
    353372#endif
    354373    }
     374    r->cfKillChar=npKillChar;
     375    r->cfSetChar=NULL;
     376    r->cfInit = npInit;
     377    r->n_Int  = npInt;
     378    r->nAdd   = npAdd;
     379    r->nSub   = npSub;
     380    r->nMult  = npMult;
     381    r->nDiv   = npDiv;
     382    r->nExactDiv= npDiv;
     383    r->nNeg   = npNeg;
     384    r->nInvers= npInvers;
     385    r->cfCopy  = ndCopy;
     386    r->nGreater = npGreater;
     387    r->nEqual = npEqual;
     388    r->nIsZero = npIsZero;
     389    r->nIsOne = npIsOne;
     390    r->nIsMOne = npIsMOne;
     391    r->nGreaterZero = npGreaterZero;
     392    r->cfWrite = npWrite;
     393    r->nRead = npRead;
     394    r->nPower = npPower;
     395    r->cfSetMap = npSetMap;
     396    r->nName= ndName;
     397    r->nSize  = ndSize;
     398#ifdef LDEBUG
     399    r->nDBTest=npDBTest;
     400#endif
     401#ifdef NV_OPS
     402    if (c>NV_MAX_PRIME)
     403    {
     404      r->nMult  = nvMult;
     405      r->nDiv   = nvDiv;
     406      r->nExactDiv= nvDiv;
     407      r->nInvers= nvInvers;
     408      r->nPower= nvPower;
     409    }
     410#endif
    355411  }
    356412  else
     
    372428#endif
    373429
    374 number npMap0(number from, const coeffs dst_r)
     430number npMap0(number from, const coeffs src, const coeffs dst_r)
    375431{
    376432  return npInit(nlModP(from,dst_r->npPrimeM),dst_r);
    377433}
    378434
    379 number npMapP(number from, const coeffs dst_r)
     435number npMapP(number from, const coeffs src, const coeffs dst_r)
    380436{
    381437  long i = (long)from;
    382   if (i>npMapPrime/2)
    383   {
    384     i-=npMapPrime;
     438  if (i>src->npPrimeM/2)
     439  {
     440    i-=src->npPrimeM;
    385441    while (i < 0) i+=dst_r->npPrimeM;
    386442  }
     
    389445}
    390446
    391 static number npMapLongR(number from, const coeffs dst_r)
     447static number npMapLongR(number from, const coeffs src, const coeffs dst_r)
    392448{
    393449  gmp_float *ff=(gmp_float*)from;
     
    455511  mpz_clear(dest);
    456512  if(res->s==0)
    457     iz=(long)npDiv((number)iz,(number)in);
     513    iz=(long)npDiv((number)iz,(number)in,dst_r);
    458514  omFreeBin((void *)res, rnumber_bin);
    459515  return (number)iz;
     
    507563    if (n_GetChar(src) == n_GetChar(dst))
    508564    {
    509       return ndCopy;
     565      return ndCopyMap;
    510566    }
    511567    else
    512568    {
    513       npMapPrime=n_GetChar(src);
    514569      return npMapP;
    515570    }
  • coeffs/modulop.h

    r63c3a8 r8c484e  
    2424extern int npGen;
    2525extern long npMapPrime;
     26
     27void npInitChar(coeffs r, int ch);
    2628
    2729BOOLEAN npGreaterZero (number k, const coeffs r);
  • coeffs/numbers.cc

    r63c3a8 r8c484e  
    396396  /*----------------------char. p----------------*/
    397397  {
     398    /* never again:
    398399    npInitChar(c,r);
    399400    n->cfInit = npInit;
     
    417418    n->nPower = npPower;
    418419    n->cfSetMap = npSetMap;
    419     /* nName= ndName; */
    420     /*nSize  = ndSize;*/
     420    // nName= ndName;
     421    // nSize  = ndSize;
    421422#ifdef LDEBUG
    422423    n->nDBTest=npDBTest;
     
    433434    }
    434435#endif
     436    */
     437    r->cfInitChar=npInitChar;
     438    npInitChar(r,c);
    435439  }
    436440  /* -------------- GF(p^m) -----------------------*/
     
    594598        if (cf_root==r) cf_root=n->next;
    595599        r->cfDelete(&(r->nNULL),r);
     600        if (r->cfKillChar!=NULL) r->cfKillChar(r);
     601        /* was:
    596602        switch(r->type)
    597603        {
    598           case n_Zp:
    599                #ifdef HAVE_DIV_MOD
    600                if (r->npInvTable!=NULL)
    601                omFreeSize( (void *)r->npInvTable,
    602                            r->npPrimeM*sizeof(unsigned short) );
    603                #else
    604                if (r->npExpTable!=NULL)
    605                {
    606                  omFreeSize( (void *)r->npExpTable,
    607                              r->npPrimeM*sizeof(unsigned short) );
    608                  omFreeSize( (void *)r->npLogTable,
    609                              r->npPrimeM*sizeof(unsigned short) );
    610                }
    611                #endif
    612                break;
    613604          case n_Zp_a:
    614605          case n_Q_a:
     
    626617                 break;
    627618          }
     619          */
    628620          omFreeSize((void *)r, sizeof(n_Procs_s));
    629621          r=NULL;
  • coeffs/numbers.h

    r63c3a8 r8c484e  
    6666number ndCopy(number a, const coeffs r);
    6767number ndCopyMap(number a, const coeffs r, const coeffs aRing);
     68int ndSize(number a, const coeffs r);
     69char * ndName(number n, const coeffs r);
    6870
    6971void   ndInpMult(number &a, number b, const coeffs r);
Note: See TracChangeset for help on using the changeset viewer.