spielwiese
Last change
on this file since e074407 was
e074407,
checked in by Jens Schmidt <schmidt@…>, 27 years ago
|
``Unconditional'' check-in.
Now it is my turn to develop factory.
git-svn-id: file:///usr/local/Singular/svn/trunk@50 2c84dea3-7e68-4137-9b89-c4e89433aadc
|
-
Property mode set to
100644
|
File size:
1.1 KB
|
Line | |
---|
1 | // emacs edit mode for this file is -*- C++ -*- |
---|
2 | // $Id: cf_chinese.cc,v 1.1 1996-12-05 18:24:52 schmidt Exp $ |
---|
3 | |
---|
4 | /* |
---|
5 | $Log: not supported by cvs2svn $ |
---|
6 | Revision 1.0 1996/05/17 10:59:43 stobbe |
---|
7 | Initial revision |
---|
8 | |
---|
9 | */ |
---|
10 | |
---|
11 | #include "assert.h" |
---|
12 | #include "cf_defs.h" |
---|
13 | #include "canonicalform.h" |
---|
14 | |
---|
15 | |
---|
16 | void chineseRemainder( const CanonicalForm x1, const CanonicalForm q1, const CanonicalForm x2, const CanonicalForm q2, CanonicalForm & xnew, CanonicalForm & qnew ) |
---|
17 | { |
---|
18 | CanonicalForm a1, a2; |
---|
19 | (void)iextgcd( q1, q2, a1, a2 ); |
---|
20 | qnew = q1 * q2; |
---|
21 | xnew = ( q1*a1*x2 + q2*a2*x1 ) % qnew; |
---|
22 | } |
---|
23 | |
---|
24 | void chineseRemainder( const CFArray & x, const CFArray & q, CanonicalForm & xnew, CanonicalForm & qnew ) |
---|
25 | { |
---|
26 | ASSERT( x.min() == q.min() && x.size() == q.size(), "incompatible arrays" ); |
---|
27 | CFArray X(x), Q(q); |
---|
28 | int i, j, n = x.size(); |
---|
29 | while ( n != 1 ) { |
---|
30 | i = j = x.min(); |
---|
31 | while ( i < x.min() + n - 1 ) { |
---|
32 | chineseRemainder( X[i], Q[i], X[i+1], Q[i+1], X[j], Q[j] ); |
---|
33 | i += 2; |
---|
34 | j++; |
---|
35 | } |
---|
36 | if ( n & 1 ) { |
---|
37 | X[j] = X[i]; |
---|
38 | Q[j] = Q[i]; |
---|
39 | } |
---|
40 | n = ( n + 1) / 2; |
---|
41 | } |
---|
42 | xnew = X[x.min()]; |
---|
43 | qnew = Q[q.min()]; |
---|
44 | } |
---|
45 | |
---|
46 | |
---|
47 | |
---|
48 | |
---|
49 | |
---|
50 | |
---|
51 | |
---|
Note: See
TracBrowser
for help on using the repository browser.