Changeset 806c18 in git for factory/cf_binom.cc
- Timestamp:
- Nov 15, 2010, 4:34:57 PM (13 years ago)
- Branches:
- (u'spielwiese', '5b153614cbc72bfa198d75b1e9e33dab2645d9fe')
- Children:
- 7c3bca08c96331a56864c1d35b8c2e8ff2e0be89
- Parents:
- c840d97af622b4e4da8761738b540e21144f716b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
factory/cf_binom.cc
rc840d9 r806c18 34 34 35 35 if ( ! initialized ) { 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 36 initialized = true; 37 ptZ = new CFArray[MAXPT+1]; 38 ptF = new CFArray[MAXPT+1]; 39 int i, j; 40 ptZ[0] = CFArray(1); ptZ[0][0] = 1; 41 ptF[0] = CFArray(1); 42 for ( i = 1; i <= INITPT; i++ ) { 43 ptF[i] = CFArray(i+1); 44 ptZ[i] = CFArray(i+1); 45 (ptZ[i])[0] = 1; 46 for ( j = 1; j < i; j++ ) 47 (ptZ[i])[j] = (ptZ[i-1])[j-1] + (ptZ[i-1])[j]; 48 (ptZ[i])[i] = 1; 49 } 50 for ( i = INITPT+1; i <= MAXPT; i++ ) { 51 ptF[i] = CFArray(i+1); 52 ptZ[i] = CFArray(i+1); 53 } 54 ptZmax = INITPT; 55 ptFmax = 0; 56 56 } 57 57 } … … 61 61 { 62 62 if ( n == 0 ) 63 63 return 1; 64 64 else if ( n == 1 ) 65 65 return x + a; 66 66 else if ( getCharacteristic() == 0 ) { 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 67 if ( n <= MAXPT ) { 68 if ( n > ptZmax ) { 69 int i, j; 70 for ( i = ptZmax+1; i <= n; i++ ) { 71 (ptZ[i])[0] = 1; 72 for ( j = 1; j < i; j++ ) 73 (ptZ[i])[j] = (ptZ[i-1])[j-1] + (ptZ[i-1])[j]; 74 (ptZ[i])[i] = 1; 75 } 76 ptZmax = n; 77 } 78 CanonicalForm result = 0, apower = 1; 79 int k; 80 for ( k = n; k >= 0; k-- ) { 81 result += power( x, k ) * apower * (ptZ[n])[k]; 82 if ( k != 0 ) 83 apower *= a; 84 } 85 return result; 86 } 87 else { 88 CanonicalForm result = binomialpower( x, a, MAXPT ); 89 CanonicalForm xa = x + a; 90 int i; 91 for ( i = MAXPT; i < n; i++ ) 92 result *= xa; 93 return result; 94 } 95 95 } 96 96 else { 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 97 if ( getCharacteristic() != charac || gfdeg != getGFDegree() ) { 98 ptFmax = 0; 99 charac = getCharacteristic(); 100 gfdeg = getGFDegree(); 101 (ptF[0])[0] = 1; 102 } 103 if ( n <= MAXPT ) { 104 if ( n > ptFmax ) { 105 int i, j; 106 for ( i = ptFmax+1; i <= n; i++ ) { 107 (ptF[i])[0] = 1; 108 for ( j = 1; j < i; j++ ) 109 (ptF[i])[j] = (ptF[i-1])[j-1] + (ptF[i-1])[j]; 110 (ptF[i])[i] = 1; 111 } 112 ptFmax = n; 113 } 114 CanonicalForm result = 0, apower = 1; 115 int k; 116 for ( k = n; k >= 0; k-- ) { 117 result += power( x, k ) * apower * (ptF[n])[k]; 118 if ( k != 0 ) 119 apower *= a; 120 } 121 return result; 122 } 123 else { 124 CanonicalForm result = binomialpower( x, a, MAXPT ); 125 CanonicalForm xa = x + a; 126 int i; 127 for ( i = MAXPT; i < n; i++ ) 128 result *= xa; 129 return result; 130 } 131 131 } 132 132 }
Note: See TracChangeset
for help on using the changeset viewer.