Changeset 8c484e in git for coeffs/modulop.cc


Ignore:
Timestamp:
May 5, 2010, 3:05:12 PM (13 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', '8e0ad00ce244dfd0756200662572aef8402f13d5')
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
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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    }
Note: See TracChangeset for help on using the changeset viewer.