- Timestamp:
- Apr 21, 1998, 12:42:57 PM (26 years ago)
- Branches:
- (u'spielwiese', '2a584933abf2a2d3082034c7586d38bb6de1a30a')
- Children:
- 54c713f739f37f3004843d2f9162eed12ffe61a3
- Parents:
- 2e92629c5af08f58ee4c2f8cf151daf6dd2edbd1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/clapsing.cc
r2e9262 r142b7b 3 3 * Computer Algebra System SINGULAR * 4 4 ****************************************/ 5 // $Id: clapsing.cc,v 1.2 8 1998-04-16 09:40:39 SingularExp $5 // $Id: clapsing.cc,v 1.29 1998-04-21 10:42:57 schmidt Exp $ 6 6 /* 7 7 * ABSTRACT: interface between Singular and factory 8 8 */ 9 10 9 11 10 #include "mod2.h" … … 24 23 #include <factor.h> 25 24 #endif 25 #include "ring.h" 26 27 // FACTORY_GCD_TEST: use new gcd instead of old one. 28 // FACTORY_GCD_STAT: print statistics on polynomials. Works only 29 // with appropriately translated new gcd. 30 // FACTORY_GCD_TIMING: accumulate time used for gcd calculations. 31 // For this option, the file `timing.h' from the Factory 32 // distribution has to be copied to the Singular source directory. 33 // Works only with new gcd. 34 // FACTORY_GCD_DEBOUT: print polynomials involved in gcd calculations 35 36 #ifdef FACTORY_GCD_STAT 37 #define FACTORY_GCD_TEST 38 #endif 39 40 #ifdef FACTORY_GCD_TIMING 41 #define FACTORY_GCD_TEST 42 #define TIMING 43 #include "timing.h" 44 TIMING_DEFINE_PRINT( contentTimer ); 45 TIMING_DEFINE_PRINT( algContentTimer ); 46 TIMING_DEFINE_PRINT( algLcmTimer ); 47 #endif 48 49 #ifdef FACTORY_GCD_DEBOUT 50 #include "longalg.h" 51 #include "febase.h" 52 #endif 26 53 27 54 poly singclap_gcd ( poly f, poly g ) 28 55 { 29 if (f==NULL)30 {31 if(g==NULL)32 return NULL;33 else34 return pCopy(g);35 }36 else if (g==NULL)37 return pCopy(f);38 39 56 poly res=NULL; 40 57 41 pCleardenom(f);42 pCleardenom(g);58 if (f) pCleardenom(f); 59 if (g) pCleardenom(g); 43 60 44 61 // for now there is only the possibility to handle polynomials over … … 341 358 poly p = pNext(f); 342 359 nTest(pGetCoeff(f)); 360 #ifdef FACTORY_GCD_DEBOUT 361 StringSetS("g0 = "); 362 if (f) napWrite(((lnumber)pGetCoeff(f))->z); 363 PrintS(StringAppend("\n")); 364 #endif 343 365 g = convSingTrClapP( ((lnumber)pGetCoeff(f))->z ); 344 366 L.append( g ); 367 #ifdef FACTORY_GCD_TIMING 368 TIMING_START( contentTimer ); 369 #endif 345 370 while ( p && (g != 1) ) 346 371 { 347 372 nTest(pGetCoeff(p)); 373 #ifdef FACTORY_GCD_DEBOUT 374 StringSetS("h = "); 375 if (p) napWrite(((lnumber)pGetCoeff(p))->z); 376 PrintS(StringAppend("\n")); 377 #endif 348 378 h = convSingTrClapP( ((lnumber)pGetCoeff(p))->z ); 349 379 p = pNext( p ); 380 #ifdef FACTORY_GCD_STAT 381 fprintf( stderr, "cont:\t" ); 382 #endif 383 #ifdef FACTORY_GCD_TEST 384 g = CFPrimitiveGcdUtil::gcd( g, h ); 385 #else 386 387 // this part is translated if there are not any options at all 350 388 g = gcd( g, h ); 389 390 #endif 391 #ifdef FACTORY_GCD_DEBOUT 392 StringSetS("g = "); 393 napWrite(convClapPSingTr(g)); 394 PrintS(StringAppend("\n")); 395 #endif 351 396 L.append( h ); 352 397 } 398 #ifdef FACTORY_GCD_TIMING 399 TIMING_END( contentTimer ); 400 #endif 353 401 if ( g == 1 ) 354 402 { … … 900 948 alg singclap_alglcm ( alg f, alg g ) 901 949 { 902 // over Q(a) / Fp(a) 903 if (nGetChar()==1) setCharacteristic( 0 ); 904 else setCharacteristic( -nGetChar() ); 905 alg res; 906 if (currRing->minpoly!=NULL) 907 { 908 CanonicalForm mipo=convSingTrClapP(((lnumber)currRing->minpoly)->z); 909 Variable a=rootOf(mipo); 910 CanonicalForm F( convSingAClapA( f,a ) ), G( convSingAClapA( g,a ) ); 911 res= convClapASingA( (F/ gcd( F, G ))*G ); 912 } 913 else 914 { 915 CanonicalForm F( convSingTrClapP( f ) ), G( convSingTrClapP( g ) ); 916 res= convClapPSingTr( (F/gcd( F, G ))*G ); 917 } 918 Off(SW_RATIONAL); 919 return res; 920 } 921 922 #ifdef FACTORY_DEBUG_OUT 923 #include "longalg.h" 924 #include "febase.h" 925 #endif 926 927 void singclap_algdividecontent ( alg f, alg g, alg &ff, alg &gg ) 928 { 929 #ifdef FACTORY_DEBUG_OUT 950 #ifdef FACTORY_GCD_DEBOUT 930 951 StringSetS("f = "); 931 952 napWrite(f); … … 938 959 if (nGetChar()==1) setCharacteristic( 0 ); 939 960 else setCharacteristic( -nGetChar() ); 940 ff=gg=NULL; 961 alg res; 962 #ifdef FACTORY_GCD_STAT 963 fprintf( stderr, "algLcm:\t" ); 964 #endif 941 965 if (currRing->minpoly!=NULL) 942 966 { … … 944 968 Variable a=rootOf(mipo); 945 969 CanonicalForm F( convSingAClapA( f,a ) ), G( convSingAClapA( g,a ) ); 970 #ifdef FACTORY_GCD_TIMING 971 CanonicalForm GCD; 972 TIMING_START( algLcmTimer ); 973 GCD = CFPrimitiveGcdUtil::gcd( F, G ); 974 TIMING_END( algLcmTimer ); 975 res= convClapASingA( (F/ GCD)*G ); 976 #elif defined( FACTORY_GCD_TEST ) 977 res= convClapASingA( (F/ CFPrimitiveGcdUtil::gcd( F, G ))*G ); 978 #else 979 980 // this part is translated if there are not any options at all 981 res= convClapASingA( (F/ gcd( F, G ))*G ); 982 983 #endif 984 } 985 else 986 { 987 CanonicalForm F( convSingTrClapP( f ) ), G( convSingTrClapP( g ) ); 988 #ifdef FACTORY_GCD_TIMING 989 CanonicalForm GCD; 990 TIMING_START( algLcmTimer ); 991 GCD = CFPrimitiveGcdUtil::gcd( F, G ); 992 TIMING_END( algLcmTimer ); 993 res= convClapPSingTr( (F/GCD)*G ); 994 #elif defined( FACTORY_GCD_TEST ) 995 res= convClapPSingTr( (F/CFPrimitiveGcdUtil::gcd( F, G ))*G ); 996 #else 997 998 // this part is translated if there are not any options at all 999 res= convClapPSingTr( (F/gcd( F, G ))*G ); 1000 1001 #endif 1002 } 1003 Off(SW_RATIONAL); 1004 #ifdef FACTORY_GCD_DEBOUT 1005 StringSetS("res = "); 1006 napWrite(res); 1007 PrintS(StringAppend("\n")); 1008 #endif 1009 return res; 1010 } 1011 1012 void singclap_algdividecontent ( alg f, alg g, alg &ff, alg &gg ) 1013 { 1014 #ifdef FACTORY_GCD_DEBOUT 1015 alg algGcd; 1016 StringSetS("f = "); 1017 napWrite(f); 1018 PrintS(StringAppend("\n")); 1019 StringSetS("g = "); 1020 napWrite(g); 1021 PrintS(StringAppend("\n")); 1022 #endif 1023 // over Q(a) / Fp(a) 1024 if (nGetChar()==1) setCharacteristic( 0 ); 1025 else setCharacteristic( -nGetChar() ); 1026 ff=gg=NULL; 1027 #ifdef FACTORY_GCD_STAT 1028 fprintf( stderr, "alCont:\t" ); 1029 #endif 1030 if (currRing->minpoly!=NULL) 1031 { 1032 CanonicalForm mipo=convSingTrClapP(((lnumber)currRing->minpoly)->z); 1033 Variable a=rootOf(mipo); 1034 CanonicalForm F( convSingAClapA( f,a ) ), G( convSingAClapA( g,a ) ); 1035 #ifdef FACTORY_GCD_TIMING 1036 CanonicalForm GCD; 1037 TIMING_START( algContentTimer ); 1038 GCD=CFPrimitiveGcdUtil::gcd( F, G ); 1039 TIMING_END( algContentTimer ); 1040 #elif defined( FACTORY_GCD_TEST ) 1041 CanonicalForm GCD=CFPrimitiveGcdUtil::gcd( F, G ); 1042 #else 1043 1044 // this part is translated if there are not any options at all 946 1045 CanonicalForm GCD=gcd( F, G ); 1046 1047 #endif 947 1048 if (GCD!=1) 948 1049 { … … 950 1051 gg= convClapASingA( G/ GCD ); 951 1052 } 1053 #ifdef FACTORY_GCD_DEBOUT 1054 algGcd=convClapASingA( GCD ); 1055 #endif 952 1056 } 953 1057 else 954 1058 { 955 1059 CanonicalForm F( convSingTrClapP( f ) ), G( convSingTrClapP( g ) ); 1060 #ifdef FACTORY_GCD_TIMING 1061 CanonicalForm GCD; 1062 TIMING_START( algContentTimer ); 1063 GCD=CFPrimitiveGcdUtil::gcd( F, G ); 1064 TIMING_END( algContentTimer ); 1065 #elif defined( FACTORY_GCD_TEST ) 1066 CanonicalForm GCD=CFPrimitiveGcdUtil::gcd( F, G ); 1067 #else 1068 1069 // this part is translated if there are not any options at all 956 1070 CanonicalForm GCD=gcd( F, G ); 1071 1072 #endif 957 1073 if (GCD!=1) 958 1074 { … … 960 1076 gg= convClapPSingTr( G/ GCD ); 961 1077 } 1078 #ifdef FACTORY_GCD_DEBOUT 1079 algGcd=convClapPSingTr( GCD ); 1080 #endif 962 1081 } 963 1082 Off(SW_RATIONAL); 964 #ifdef FACTORY_DEBUG_OUT 965 StringSetS("ff = "); 966 napWrite(ff); 967 PrintS(StringAppend("\n")); 968 StringSetS("gg = "); 969 napWrite(gg); 970 PrintS(StringAppend("\n")); 1083 #ifdef FACTORY_GCD_DEBOUT 1084 StringSetS("gcd = "); 1085 napWrite(algGcd); 1086 PrintS(StringAppend("\n")); 1087 napDelete(&algGcd); 971 1088 #endif 972 1089 }
Note: See TracChangeset
for help on using the changeset viewer.