Changeset cbb3fa in git
- Timestamp:
- Sep 8, 1997, 6:02:02 PM (26 years ago)
- Branches:
- (u'spielwiese', '8e0ad00ce244dfd0756200662572aef8402f13d5')
- Children:
- 06723319e8641168ca5cb089e3bdc6d0f24285d3
- Parents:
- 8e6674ec04c524b77f3d7fdc1570fddadfaa16c3
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
factory/cf_algorithm.cc
r8e6674 rcbb3fa 1 1 /* emacs edit mode for this file is -*- C++ -*- */ 2 /* $Id: cf_algorithm.cc,v 1. 1 1997-09-04 15:30:20schmidt Exp $ */2 /* $Id: cf_algorithm.cc,v 1.2 1997-09-08 16:02:02 schmidt Exp $ */ 3 3 4 4 //{{{ docu … … 10 10 // algorithm which gives structural information on polynomials. 11 11 // 12 // Compare these functions with the functions in cf_ops.cc, which 13 // are structural algorithms. 12 // Compare these functions to the functions in cf_ops.cc, which are 13 // structural algorithms. 14 // 15 // Used by: cf_gcd.cc, cf_resultant.cc 14 16 // 15 17 //}}} 16 18 17 19 #include <config.h> 20 21 #include "assert.h" 18 22 19 23 #include "cf_defs.h" … … 22 26 #include "cf_iter.h" 23 27 28 //{{{ CanonicalForm psr ( const CanonicalForm & f, const CanonicalForm & g, const Variable & x ) 29 //{{{ docu 30 // 31 // psr() - calculate pseudo remainder of f and g with respect to x. 32 // 33 // x should be a polynomial variable. 34 // 35 // For f and g in R[x], R an integral domain, g != 0, there is a 36 // unique representation 37 // 38 // lc(g)^s*f = g*q + r 39 // 40 // with r = 0 or deg(r) < deg(g) and s = 0 if f = 0 or 41 // s = max( 0, deg(f)-deg(g)+1 ) otherwise. 42 // Then r = psr(f, g) and q = psq(f, g) are called pseudo 43 // remainder and pseudo quotient, resp. 44 // 45 // See H.-J. Reiffen/G. Scheja/U. Vetter - 'Algebra', 2nd ed., 46 // par. 15 for a reference. 47 // 48 //}}} 24 49 CanonicalForm 25 50 psr ( const CanonicalForm & f, const CanonicalForm & g, const Variable & x ) 26 51 { 27 int m = f.degree( x ); 28 int n = g.degree( x ); 29 if ( m < n ) 52 ASSERT( x.level() > 0, "cannot calculate pseudo remainder/quotient with respect to algebraic variables" ); 53 ASSERT( g != 0, "division by zero" ); 54 55 int m = degree( f, x ); 56 int n = degree( g, x ); 57 if ( m < 0 || m < n ) 30 58 return f; 31 59 else 32 60 return ( power( LC( g, x ), m-n+1 ) * f ) % g; 33 61 } 62 //}}} 34 63 64 //{{{ CanonicalForm psq ( const CanonicalForm & f, const CanonicalForm & g, const Variable & x ) 65 //{{{ docu 66 // 67 // psq() - calculate pseudo quotient of f and g with respect to x. 68 // 69 // x should be a polynomial variable. See psr() for more 70 // detailed information. 71 // 72 //}}} 35 73 CanonicalForm 36 74 psq ( const CanonicalForm & f, const CanonicalForm & g, const Variable & x ) 37 75 { 38 return ( power( LC( g, x ), degree( f, x )-degree( g, x )+1 ) * f ) / g; 76 ASSERT( x.level() > 0, "cannot calculate pseudo remainder/quotient with respect to algebraic variables" ); 77 ASSERT( g != 0, "division by zero" ); 78 79 int m = degree( f, x ); 80 int n = degree( g, x ); 81 if ( m < 0 || m < n ) 82 return 0; 83 else 84 return ( power( LC( g, x ), m-n+1 ) * f ) / g; 39 85 } 86 //}}} 40 87 88 //{{{ void psqr ( const CanonicalForm & f, const CanonicalForm & g, CanonicalForm & q, CanonicalForm & r, const Variable & x ) 89 //{{{ docu 90 // 91 // psqr() - calculate pseudo quotient and remainder of f and g with respect to x. 92 // 93 // x should be a polynomial variable. See psr() for more 94 // detailed information. 95 // 96 //}}} 41 97 void 42 98 psqr ( const CanonicalForm & f, const CanonicalForm & g, CanonicalForm & q, CanonicalForm & r, const Variable& x ) 43 99 { 44 divrem( power( LC( g, x ), degree( f, x )-degree( g, x )+1 ) * f, g, q, r ); 100 ASSERT( x.level() > 0, "cannot calculate pseudo remainder/quotient with respect to algebraic variables" ); 101 ASSERT( g != 0, "division by zero" ); 102 103 int m = degree( f, x ); 104 int n = degree( g, x ); 105 if ( m < 0 || m < n ) { 106 q = 0; r = f; 107 } 108 else 109 divrem( power( LC( g, x ), m-n+1 ) * f, g, q, r ); 45 110 } 111 //}}} 46 112 113 //{{{ static CanonicalForm cden ( const CanonicalForm & f ) 114 //{{{ docu 115 // 116 // cden() - recursively calculate multivariate common denominator 117 // of coefficients of f. 118 // 119 // Used by: common_den() 120 // 121 //}}} 47 122 static CanonicalForm 48 123 cden ( const CanonicalForm & f ) 49 124 { 50 if ( f.in CoeffDomain() )125 if ( f.inBaseDomain() ) 51 126 return f.den(); 52 127 else { … … 58 133 } 59 134 } 135 //}}} 60 136 137 //{{{ CanonicalForm common_den ( const CanonicalForm & f ) 138 //{{{ docu 139 // 140 // common_den() - calculate multivariate common denominator of 141 // coefficients of f. 142 // 143 // The common denominator is calculated with respect to all 144 // coefficients of f which are in a base domain. In other words, 145 // common_den( f ) * f is guaranteed to have integer 146 // coefficients only. 147 // 148 // Returns one for domains other than Q. 149 // 150 //}}} 61 151 CanonicalForm 62 152 common_den ( const CanonicalForm & f ) 63 153 { 64 154 if ( getCharacteristic() == 0 && isOn( SW_RATIONAL ) ) { 155 // switch to Z so lcm() will work correctly 65 156 Off( SW_RATIONAL ); 66 157 CanonicalForm cd = cden( f ); … … 71 162 return 1; 72 163 } 164 //}}}
Note: See TracChangeset
for help on using the changeset viewer.