Changeset c12372 in git for factory/cf_chinese.cc


Ignore:
Timestamp:
Jul 24, 1997, 12:39:35 PM (27 years ago)
Author:
Jens Schmidt <schmidt@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
063ebbbe875cacd2b1e4f25d7006348a5823fc8a
Parents:
960f2ac0a38ea1611c75e0b2fd1764a6c0554fe1
Message:
	* cf_chinese.cc (chineseRemainder( CF, ... )): operator % replaced
	  by function mod()


git-svn-id: file:///usr/local/Singular/svn/trunk@576 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • factory/cf_chinese.cc

    r960f2a rc12372  
    11/* emacs edit mode for this file is -*- C++ -*- */
    2 /* $Id: cf_chinese.cc,v 1.4 1997-07-19 08:13:16 schmidt Exp $ */
     2/* $Id: cf_chinese.cc,v 1.5 1997-07-24 10:39:35 schmidt Exp $ */
    33
    44//{{{ docu
     
    1414#include "assert.h"
    1515
    16 #include "cf_defs.h"
    1716#include "canonicalform.h"
    1817
     
    2019//{{{ docu
    2120//
    22 // chineseRemainder - (simple) integer chinese remaindering.
     21// chineseRemainder - integer chinese remaindering.
    2322//
    24 // Calculate xnew such that xnew=x1 (mod q1) and xnew=x2
    25 // (mod q2) and qnew = q1*q2.  q1 and q2 should be integers,
    26 // pairwise prime, x1 and x2 should be integers.
     23// Calculate xnew such that xnew=x1 (mod q1) and xnew=x2 (mod q2)
     24// and qnew = q1*q2.  q1 and q2 should be positive integers,
     25// pairwise prime, x1 and x2 should be polynomials with integer
     26// coefficients.  If x1 and x2 are polynomials with positive
     27// coefficients, the result is guaranteed to have positive
     28// coefficients, too.
    2729//
    2830// Note: be sure you are calculating in Z, and not in Q!
    2931//
    3032//}}}
    31 void chineseRemainder( const CanonicalForm x1, const CanonicalForm q1, const CanonicalForm x2, const CanonicalForm q2, CanonicalForm & xnew, CanonicalForm & qnew )
     33void
     34chineseRemainder( const CanonicalForm x1, const CanonicalForm q1, const CanonicalForm x2, const CanonicalForm q2, CanonicalForm & xnew, CanonicalForm & qnew )
    3235{
    3336    CanonicalForm a1, a2;
    3437    (void)iextgcd( q1, q2, a1, a2 );
    3538    qnew = q1 * q2;
    36     // xnew = mod( q1*a1*x2 + q2*a2*x1, qnew);
    37     xnew = ( q1*a1*x2 + q2*a2*x1 ) % qnew;
     39    xnew = mod( q1*a1*x2 + q2*a2*x1, qnew );
    3840}
    3941//}}}
     
    4446// chineseRemainder - integer chinese remaindering.
    4547//
    46 // Calculate xnew such that xnew=x[i] (mod q[i]).  q[i] should be
    47 // integers, pairwise prime. x[i] should be integers.
     48// Calculate xnew such that xnew=x[i] (mod q[i]) and qnew is the
     49// product of all q[i].  q[i] should be positive integers,
     50// pairwise prime.  x[i] should be polynomials with integer
     51// coefficients.  If all coefficients of all x[i] are positive
     52// integers, the result is guaranteed to have positive
     53// coefficients, too.
    4854//
    4955// Note: be sure you are calculating in Z, and not in Q!
    5056//
    5157//}}}
    52 void chineseRemainder( const CFArray & x, const CFArray & q, CanonicalForm & xnew, CanonicalForm & qnew )
     58void
     59chineseRemainder( const CFArray & x, const CFArray & q, CanonicalForm & xnew, CanonicalForm & qnew )
    5360{
    5461    ASSERT( x.min() == q.min() && x.size() == q.size(), "incompatible arrays" );
    5562    CFArray X(x), Q(q);
    5663    int i, j, n = x.size();
    57     // we use a divide-and-conquer algorithm to reduce the number
    58     // of remainderings
     64
    5965    while ( n != 1 ) {
    6066        i = j = x.min();
Note: See TracChangeset for help on using the changeset viewer.