Changeset a1e8742 in git


Ignore:
Timestamp:
Mar 2, 2000, 7:44:39 PM (24 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '648d28f488f6ff08f5607ff229b9ad9e4a5b93c2')
Children:
b74df82da5481f8597c226c901371bb6fb30e477
Parents:
ff5e0d08ed70bf7df92e057766905c2014edc1bb
Message:
*hannes: npAdd/npSub


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

Legend:

Unmodified
Added
Removed
  • Singular/modulop.cc

    rff5e0d ra1e8742  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: modulop.cc,v 1.14 1999-11-15 17:20:28 obachman Exp $ */
     4/* $Id: modulop.cc,v 1.15 2000-03-02 18:44:39 Singular Exp $ */
    55/*
    66* ABSTRACT: numbers modulo p (<=32003)
     
    6363number npAdd (number a, number b)
    6464{
    65   int ka = (int)a + (int)b;
    66   if (ka >= npPrimeM) ka -= npPrimeM;
    67   return (number)ka;
     65  return npAddM(a,b);
    6866}
    6967
    7068number npSub (number a, number b)
    7169{
    72 //  int ka = (int)a - (int)b;
    73 //  if (ka < 0)  ka += npPrimeM;
    74 //  *(int *)c = ka;
    7570  return npSubM(a,b);
    7671}
  • Singular/modulop.h

    rff5e0d ra1e8742  
    44*  Computer Algebra System SINGULAR     *
    55****************************************/
    6 /* $Id: modulop.h,v 1.9 1999-11-15 17:20:29 obachman Exp $ */
     6/* $Id: modulop.h,v 1.10 2000-03-02 18:44:39 Singular Exp $ */
    77/*
    88* ABSTRACT: numbers modulo p (<=32003)
     
    5151}
    5252
     53#if 0
     54inline number npAddAsm(number a, number b, int m)
     55{
     56  number r;
     57    asm ("addl %2, %1; cmpl %3, %1; jb 0f; subl %3, %1; 0:"
     58         : "=&r" (r)
     59         : "%0" (a), "g" (b), "g" (m)
     60         : "cc");
     61  return r;
     62}
     63inline number npSubAsm(number a, number b, int m)
     64{
     65  number r;
     66  asm ("subl %2, %1; jnc 0f; addl %3, %1; 0:"
     67        : "=&r" (r)
     68        : "%0" (a), "g" (b), "g" (m)
     69        : "cc");
     70  return r;
     71}
     72#endif
     73
    5374inline number npAddM(number a, number b)
    5475{
    55   int ka = (int)a + (int)b;
    56   if (ka >= npPrimeM) ka -= npPrimeM;
    57   return (number)ka;
     76  int r = (int)a + (int)b;
     77  return (number)(r >= npPrimeM ? r - npPrimeM : r);
    5878}
    5979
Note: See TracChangeset for help on using the changeset viewer.