Changeset 66e0d2 in git
- Timestamp:
- Jul 19, 1997, 10:13:16 AM (27 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- 1b73cc07cc26f967458468610090985974afb204
- Parents:
- e4eea0e6a7c23a276208a1ffe76b6d127f2e95e6
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
factory/cf_chinese.cc
re4eea0e r66e0d2 1 1 /* emacs edit mode for this file is -*- C++ -*- */ 2 /* $Id: cf_chinese.cc,v 1.3 1997-06-19 12:27:25 schmidt Exp $ */ 2 /* $Id: cf_chinese.cc,v 1.4 1997-07-19 08:13:16 schmidt Exp $ */ 3 4 //{{{ docu 5 // 6 // cf_chinese.cc - algorithms for chinese remaindering. 7 // 8 // Used by: cf_gcd.cc, cf_linsys.cc, sm_util.cc 9 // 10 //}}} 3 11 4 12 #include <config.h> … … 9 17 #include "canonicalform.h" 10 18 11 19 //{{{ void chineseRemainder( const CanonicalForm x1, const CanonicalForm q1, const CanonicalForm x2, const CanonicalForm q2, CanonicalForm & xnew, CanonicalForm & qnew ) 20 //{{{ docu 21 // 22 // chineseRemainder - (simple) integer chinese remaindering. 23 // 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. 27 // 28 // Note: be sure you are calculating in Z, and not in Q! 29 // 30 //}}} 12 31 void chineseRemainder( const CanonicalForm x1, const CanonicalForm q1, const CanonicalForm x2, const CanonicalForm q2, CanonicalForm & xnew, CanonicalForm & qnew ) 13 32 { … … 15 34 (void)iextgcd( q1, q2, a1, a2 ); 16 35 qnew = q1 * q2; 36 // xnew = mod( q1*a1*x2 + q2*a2*x1, qnew); 17 37 xnew = ( q1*a1*x2 + q2*a2*x1 ) % qnew; 18 38 } 39 //}}} 19 40 41 //{{{ void chineseRemainder( const CFArray & x, const CFArray & q, CanonicalForm & xnew, CanonicalForm & qnew ) 42 //{{{ docu 43 // 44 // chineseRemainder - integer chinese remaindering. 45 // 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 // 49 // Note: be sure you are calculating in Z, and not in Q! 50 // 51 //}}} 20 52 void chineseRemainder( const CFArray & x, const CFArray & q, CanonicalForm & xnew, CanonicalForm & qnew ) 21 53 { … … 23 55 CFArray X(x), Q(q); 24 56 int i, j, n = x.size(); 57 // we use a divide-and-conquer algorithm to reduce the number 58 // of remainderings 25 59 while ( n != 1 ) { 26 60 i = j = x.min(); … … 39 73 qnew = Q[q.min()]; 40 74 } 75 //}}}
Note: See TracChangeset
for help on using the changeset viewer.