Changeset 4ecee2 in git


Ignore:
Timestamp:
Nov 25, 2000, 9:30:19 PM (23 years ago)
Author:
Olaf Bachmann <obachman@…>
Branches:
(u'spielwiese', '5b153614cbc72bfa198d75b1e9e33dab2645d9fe')
Children:
fa8c7a7fb5cc720d8d29edced3eb44edabfc631b
Parents:
949cae53b67a55ec9c09d7ea7d86a5630a2ca9f4
Message:
* option HAVE_MULT_MOD for doing p*q with %


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

Legend:

Unmodified
Added
Removed
  • Singular/modulop.cc

    r949cae r4ecee2  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: modulop.cc,v 1.20 2000-11-17 14:07:11 Singular Exp $ */
     4/* $Id: modulop.cc,v 1.21 2000-11-25 20:30:19 obachman Exp $ */
    55/*
    66* ABSTRACT: numbers modulo p (<=32003)
     
    2626CARDINAL *npLogTable=NULL;
    2727
     28
    2829BOOLEAN npGreaterZero (number k)
    2930{
    3031  int h = (int) k;
    3132  return ((int)h !=0) && (h <= (npPrimeM>>1));
     33}
     34
     35unsigned long npMultMod(unsigned long a, unsigned long b)
     36{
     37  unsigned long c = a*b;
     38  c = c % npPrimeM;
     39  assume(c == (unsigned long) npMultM((number) a, (number) b));
     40  return c;
    3241}
    3342
  • Singular/modulop.h

    r949cae r4ecee2  
    44*  Computer Algebra System SINGULAR     *
    55****************************************/
    6 /* $Id: modulop.h,v 1.11 2000-11-16 16:52:37 Singular Exp $ */
     6/* $Id: modulop.h,v 1.12 2000-11-25 20:30:18 obachman Exp $ */
    77/*
    88* ABSTRACT: numbers modulo p (<=32003)
    99*/
    1010#include "structs.h"
     11
     12// define if a*b is with mod instead of tables
     13#define HAVE_MULT_MOD
    1114
    1215extern int npPrimeM;
     
    4750extern CARDINAL *npLogTable;
    4851
     52#ifdef HAVE_MULT_MOD
     53inline number npMultM(number a, number b)
     54{
     55  return (number)
     56    ((((unsigned long) a)*((unsigned long) b)) % ((unsigned long) npPrimeM));
     57}
     58#else
    4959inline number npMultM(number a, number b)
    5060{
     
    5262  return (number)npExpTable[x<npPminus1M ? x : x-npPminus1M];
    5363}
     64#endif
    5465
    5566#if 0
Note: See TracChangeset for help on using the changeset viewer.