Changeset e28e6d in git
- Timestamp:
- Jul 6, 2011, 10:31:05 AM (12 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
- Children:
- ec970ef2b3d7d5253124f91a7c731ac3c7c540c3
- Parents:
- 276c3f35a3633a214a6c43c7426a9f3e9609bd35
- Location:
- factory
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
factory/canonicalform.cc
r276c3f re28e6d 791 791 } 792 792 793 //same as divremt but handles zero divisors in case we are in Z_p[x]/(f) where f is not irreducible 794 CanonicalForm & 795 CanonicalForm::tryDiv ( const CanonicalForm & cf, const CanonicalForm& M, bool& fail ) 796 { 797 ASSERT (getCharacteristic() > 0, "expected positive characteristic"); 798 ASSERT (!getReduce (M.mvar()), "do not reduce modulo M"); 799 fail= false; 800 int what = is_imm( value ); 801 if ( what ) { 802 ASSERT ( ! is_imm( cf.value ) || (what==is_imm( cf.value )), "illegal base coefficients" ); 803 if ( (what = is_imm( cf.value )) == FFMARK ) 804 value = imm_div_p( value, cf.value ); 805 else if ( what == GFMARK ) 806 value = imm_div_gf( value, cf.value ); 807 else { 808 InternalCF * dummy = cf.value->copyObject(); 809 value = dummy->divcoeff( value, true ); 810 } 811 } 812 else if ( is_imm( cf.value ) ) 813 value = value->tryDivcoeff (cf.value, false, M, fail); 814 else if ( value->level() == cf.value->level() ) { 815 if ( value->levelcoeff() == cf.value->levelcoeff() ) 816 value = value->tryDivsame( cf.value, M, fail ); 817 else if ( value->levelcoeff() > cf.value->levelcoeff() ) 818 value = value->tryDivcoeff( cf.value, false, M, fail ); 819 else { 820 InternalCF * dummy = cf.value->copyObject(); 821 dummy = dummy->tryDivcoeff( value, true, M, fail ); 822 if ( value->deleteObject() ) delete value; 823 value = dummy; 824 } 825 } 826 else if ( level() > cf.level() ) 827 value = value->tryDivcoeff( cf.value, false, M, fail ); 828 else { 829 InternalCF * dummy = cf.value->copyObject(); 830 dummy = dummy->tryDivcoeff( value, true, M, fail ); 831 if ( value->deleteObject() ) delete value; 832 value = dummy; 833 } 834 return *this; 835 } 836 793 837 CanonicalForm & 794 838 CanonicalForm::operator %= ( const CanonicalForm & cf ) … … 949 993 return result; 950 994 } 995 996 //same as divremt but handles zero divisors in case we are in Z_p[x]/(f) where f is not irreducible 997 bool 998 tryDivremt ( const CanonicalForm & f, const CanonicalForm & g, CanonicalForm & q, CanonicalForm & r, const CanonicalForm& M, bool& fail ) 999 { 1000 ASSERT (getCharacteristic() > 0, "expected positive characteristic"); 1001 ASSERT (!getReduce (M.mvar()), "do not reduce modulo M"); 1002 fail= false; 1003 InternalCF * qq = 0, * rr = 0; 1004 int what = is_imm( f.value ); 1005 bool result = true; 1006 if ( what ) 1007 if ( is_imm( g.value ) ) { 1008 if ( what == FFMARK ) 1009 imm_divrem_p( f.value, g.value, qq, rr ); 1010 else if ( what == GFMARK ) 1011 imm_divrem_gf( f.value, g.value, qq, rr ); 1012 } 1013 else 1014 result = g.value->tryDivremcoefft( f.value, qq, rr, true, M, fail ); 1015 else if ( (what=is_imm( g.value )) ) 1016 result = f.value->tryDivremcoefft( g.value, qq, rr, false, M, fail ); 1017 else if ( f.value->level() == g.value->level() ) 1018 if ( f.value->levelcoeff() == g.value->levelcoeff() ) 1019 result = f.value->tryDivremsamet( g.value, qq, rr, M, fail ); 1020 else if ( f.value->levelcoeff() > g.value->levelcoeff() ) 1021 result = f.value->tryDivremcoefft( g.value, qq, rr, false, M, fail ); 1022 else 1023 result = g.value->tryDivremcoefft( f.value, qq, rr, true, M, fail ); 1024 else if ( f.value->level() > g.value->level() ) 1025 result = f.value->tryDivremcoefft( g.value, qq, rr, false, M, fail ); 1026 else 1027 result = g.value->tryDivremcoefft( f.value, qq, rr, true, M, fail ); 1028 if (fail) 1029 { 1030 q= 0; 1031 r= 0; 1032 return false; 1033 } 1034 if ( result ) { 1035 ASSERT( qq != 0 && rr != 0, "error in divrem" ); 1036 q = CanonicalForm( qq ); 1037 r = CanonicalForm( rr ); 1038 q= reduce (q, M); 1039 r= reduce (r, M); 1040 } 1041 else { 1042 q = 0; r = 0; 1043 } 1044 return result; 1045 } 1046 951 1047 //}}} 952 1048 -
factory/canonicalform.h
r276c3f re28e6d 131 131 CanonicalForm& operator %= ( const CanonicalForm& ); 132 132 CanonicalForm& div ( const CanonicalForm& ); 133 CanonicalForm& tryDiv (const CanonicalForm&, const CanonicalForm&, bool& ); 133 134 CanonicalForm& mod ( const CanonicalForm& ); 134 135 … … 157 158 friend void divrem ( const CanonicalForm&, const CanonicalForm&, CanonicalForm&, CanonicalForm& ); 158 159 friend bool divremt ( const CanonicalForm&, const CanonicalForm&, CanonicalForm&, CanonicalForm& ); 160 friend bool tryDivremt ( const CanonicalForm&, const CanonicalForm&, CanonicalForm&, CanonicalForm&, const CanonicalForm&, bool& ); 159 161 160 162 friend CanonicalForm bgcd ( const CanonicalForm &, const CanonicalForm & ); -
factory/int_cf.cc
r276c3f re28e6d 173 173 return 0; 174 174 } 175 176 InternalCF* 177 InternalCF::tryMulsame( InternalCF* F, const CanonicalForm& M) 178 { 179 ASSERT1( 0, "tryMulsame() not implemented for class %s", this->classname() ); 180 return 0; 181 } 182 183 InternalCF* 184 InternalCF::tryInvert ( const CanonicalForm& M, bool& fail) 185 { 186 ASSERT1( 0, "tryInvert() not implemented for class %s", this->classname() ); 187 return 0; 188 } 189 190 bool 191 InternalCF::tryDivremsamet ( InternalCF* F, InternalCF*& S, InternalCF*& T, const CanonicalForm& M, bool& fail) 192 { 193 ASSERT1( 0, "tryDivremsamet() not implemented for class %s", this->classname() ); 194 return 0; 195 } 196 197 bool 198 InternalCF::tryDivremcoefft ( InternalCF* F, InternalCF*& S, InternalCF*& T, bool invert, const CanonicalForm& M, bool& fail) 199 { 200 ASSERT1( 0, "tryDivremcoefft() not implemented for class %s", this->classname() ); 201 return 0; 202 } 203 204 InternalCF* 205 InternalCF::tryDivsame ( InternalCF* F, const CanonicalForm& M, bool& fail) 206 { 207 ASSERT1( 0, "tryDivsame() not implemented for class %s", this->classname() ); 208 return 0; 209 } 210 211 InternalCF* 212 InternalCF::tryDivcoeff ( InternalCF* F, bool invert, const CanonicalForm& M, bool& fail) 213 { 214 ASSERT1( 0, "tryDivcoeff() not implemented for class %s", this->classname() ); 215 return 0; 216 } 217 218 InternalCF* 219 InternalCF::tryDividecoeff ( InternalCF* F, bool invert, const CanonicalForm& M, bool& fail) 220 { 221 ASSERT1( 0, "tryDividecoeff() not implemented for class %s", this->classname() ); 222 return 0; 223 } -
factory/int_cf.h
r276c3f re28e6d 68 68 virtual InternalCF* neg() PVIRT_INTCF("neg"); 69 69 virtual InternalCF* invert(); // semantically const, changes refCount 70 virtual InternalCF* tryInvert( const CanonicalForm&, bool& ); 70 71 virtual int comparesame ( InternalCF * ) PVIRT_INT("comparesame"); 71 72 virtual int comparecoeff ( InternalCF * ) PVIRT_INT("comparecoeff"); … … 74 75 virtual InternalCF* subsame( InternalCF* ) PVIRT_INTCF("subsame"); 75 76 virtual InternalCF* mulsame( InternalCF* ) PVIRT_INTCF("mulsame"); 77 virtual InternalCF* tryMulsame( InternalCF*, const CanonicalForm& ); 76 78 virtual InternalCF* dividesame( InternalCF* ) PVIRT_INTCF("dividesame"); 77 79 virtual InternalCF* modulosame( InternalCF* ) PVIRT_INTCF("modulosame"); 78 80 virtual InternalCF* divsame( InternalCF* ) PVIRT_INTCF("divsame"); 81 virtual InternalCF* tryDivsame ( InternalCF* , const CanonicalForm&, bool& ); 79 82 virtual InternalCF* modsame( InternalCF* ) PVIRT_INTCF("modsame"); 80 83 virtual void divremsame( InternalCF*, InternalCF*&, InternalCF*& ) PVIRT_VOID("divremsame"); 81 84 virtual bool divremsamet( InternalCF*, InternalCF*&, InternalCF*& ) PVIRT_BOOL("divremsamet"); 85 virtual bool tryDivremsamet ( InternalCF*, InternalCF*&, InternalCF*&, const CanonicalForm&, bool& ); 82 86 83 87 virtual InternalCF* addcoeff( InternalCF* ) PVIRT_INTCF("addcoeff"); … … 85 89 virtual InternalCF* mulcoeff( InternalCF* ) PVIRT_INTCF("mulcoeff"); 86 90 virtual InternalCF* dividecoeff( InternalCF*, bool ) PVIRT_INTCF("dividecoeff"); 91 virtual InternalCF* tryDividecoeff ( InternalCF*, bool, const CanonicalForm&, bool& ); 87 92 virtual InternalCF* modulocoeff( InternalCF*, bool ) PVIRT_INTCF("dividecoeff"); 88 93 virtual InternalCF* divcoeff( InternalCF*, bool ) PVIRT_INTCF("divcoeff"); 94 virtual InternalCF* tryDivcoeff ( InternalCF*, bool, const CanonicalForm&, bool& ); 89 95 virtual InternalCF* modcoeff( InternalCF*, bool ) PVIRT_INTCF("modcoeff"); 90 96 virtual void divremcoeff( InternalCF*, InternalCF*&, InternalCF*&, bool ) PVIRT_VOID("divremcoeff"); 91 97 virtual bool divremcoefft( InternalCF*, InternalCF*&, InternalCF*&, bool ) PVIRT_BOOL("divremcoefft"); 98 virtual bool tryDivremcoefft( InternalCF*, InternalCF*&, InternalCF*&, bool, const CanonicalForm&, bool& ); 92 99 93 100 virtual InternalCF * bgcdsame ( const InternalCF * const ) const;
Note: See TracChangeset
for help on using the changeset viewer.