Changeset 1c8bcb in git
- Timestamp:
- Apr 23, 1998, 12:00:49 PM (25 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
- Children:
- 54035bd37f9bb56d31efcf68edf64aecf6de38d9
- Parents:
- d6fc3c5cb4a5d2eed49001686d571df819c5496b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/clapsing.cc
rd6fc3c r1c8bcb 3 3 * Computer Algebra System SINGULAR * 4 4 ****************************************/ 5 // $Id: clapsing.cc,v 1.3 1 1998-04-23 09:52:08 SingularExp $5 // $Id: clapsing.cc,v 1.32 1998-04-23 10:00:49 schmidt Exp $ 6 6 /* 7 7 * ABSTRACT: interface between Singular and factory … … 29 29 // with appropriately translated new gcd. 30 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 31 // Time may be printed (and reset) with `system("gcdtime");'. 32 // For tis define, `timing.h' from the factory source directory 33 // has to be copied to the Singualr source directory. 34 // Note: for better readability, the macros `TIMING_START()' and 35 // `TIMING_END()' are used in any case. However, they expand to 36 // nothing if `FACTORY_GCD_TIMING' is off. 37 // FACTORY_GCD_DEBOUT: print polynomials involved in gcd calculations. 38 // The polynomials are printed by means of the macros 39 // `FACTORY_*OUT' which are defined to be empty if 40 // `FACTORY_GCD_DEBOUT' is off. 35 41 36 42 #ifdef FACTORY_GCD_STAT … … 39 45 40 46 #ifdef FACTORY_GCD_TIMING 41 #define FACTORY_GCD_TEST42 47 #define TIMING 43 48 #include "timing.h" … … 45 50 TIMING_DEFINE_PRINT( algContentTimer ); 46 51 TIMING_DEFINE_PRINT( algLcmTimer ); 52 #else 53 #define TIMING_START( timer ) 54 #define TIMING_END( timer ) 47 55 #endif 48 56 … … 50 58 #include "longalg.h" 51 59 #include "febase.h" 60 // alg f 61 #define FACTORY_ALGOUT( tag, f ) \ 62 StringSetS( tag ); \ 63 napWrite( f ); \ 64 PrintS(StringAppend("\n")); 65 // CanonicalForm f, represents transcendent extension 66 #define FACTORY_CFTROUT( tag, f ) \ 67 { \ 68 alg F=convClapPSingTr( f ); \ 69 StringSetS( tag ); \ 70 napWrite( F ); \ 71 PrintS(StringAppend("\n")); \ 72 napDelete( &F ); \ 73 } 74 // CanonicalForm f, represents algebraic extension 75 #define FACTORY_CFAOUT( tag, f ) \ 76 { \ 77 alg F=convClapASingA( f ); \ 78 StringSetS( tag ); \ 79 napWrite( F ); \ 80 PrintS(StringAppend("\n")); \ 81 napDelete( &F ); \ 82 } 83 #else 84 #define FACTORY_ALGOUT( tag, f ) 85 #define FACTORY_CFTROUT( tag, f ); 86 #define FACTORY_CFAOUT( tag, f ); 52 87 #endif 53 88 … … 365 400 poly p = pNext(f); 366 401 nTest(pGetCoeff(f)); 367 #ifdef FACTORY_GCD_DEBOUT 368 StringSetS("g0 = "); 369 if (f) napWrite(((lnumber)pGetCoeff(f))->z); 370 PrintS(StringAppend("\n")); 371 #endif 402 FACTORY_ALGOUT( "G = ", (((lnumber)pGetCoeff(f))->z) ); 372 403 g = convSingTrClapP( ((lnumber)pGetCoeff(f))->z ); 373 404 L.append( g ); 374 #ifdef FACTORY_GCD_TIMING375 405 TIMING_START( contentTimer ); 376 #endif377 406 while ( (p != NULL) && (g != 1) ) 378 407 { 379 408 nTest(pGetCoeff(p)); 380 #ifdef FACTORY_GCD_DEBOUT 381 StringSetS("h = "); 382 if (p) napWrite(((lnumber)pGetCoeff(p))->z); 383 PrintS(StringAppend("\n")); 384 #endif 409 FACTORY_ALGOUT( "h = ", (((lnumber)pGetCoeff(p))->z) ); 385 410 h = convSingTrClapP( ((lnumber)pGetCoeff(p))->z ); 386 411 p = pNext( p ); … … 391 416 g = CFPrimitiveGcdUtil::gcd( g, h ); 392 417 #else 393 394 // this part is translated if there are not any options at all395 418 g = gcd( g, h ); 396 397 #endif 398 #ifdef FACTORY_GCD_DEBOUT 399 StringSetS("g = "); 400 napWrite(convClapPSingTr(g)); 401 PrintS(StringAppend("\n")); 402 #endif 419 #endif 420 FACTORY_CFTROUT( "g = ", g ); 403 421 L.append( h ); 404 422 } 405 #ifdef FACTORY_GCD_TIMING406 423 TIMING_END( contentTimer ); 407 #endif 424 FACTORY_CFTROUT( "C = ", g ); 408 425 if ( g == 1 ) 409 426 { … … 956 973 alg singclap_alglcm ( alg f, alg g ) 957 974 { 958 #ifdef FACTORY_GCD_DEBOUT 959 StringSetS("f = "); 960 napWrite(f); 961 PrintS(StringAppend("\n")); 962 StringSetS("g = "); 963 napWrite(g); 964 PrintS(StringAppend("\n")); 965 #endif 966 // over Q(a) / Fp(a) 975 FACTORY_ALGOUT( "f = ", f ); 976 FACTORY_ALGOUT( "g = ", g ); 977 978 // over Q(a) / Fp(a) 967 979 if (nGetChar()==1) setCharacteristic( 0 ); 968 980 else setCharacteristic( -nGetChar() ); 969 981 alg res; 982 970 983 #ifdef FACTORY_GCD_STAT 971 984 fprintf( stderr, "algLcm:\t" ); 972 985 #endif 986 973 987 if (currRing->minpoly!=NULL) 974 988 { … … 976 990 Variable a=rootOf(mipo); 977 991 CanonicalForm F( convSingAClapA( f,a ) ), G( convSingAClapA( g,a ) ); 978 #ifdef FACTORY_GCD_TIMING979 992 CanonicalForm GCD; 993 980 994 TIMING_START( algLcmTimer ); 995 // calculate gcd 996 #ifdef FACTORY_GCD_TEST 981 997 GCD = CFPrimitiveGcdUtil::gcd( F, G ); 998 #else 999 GCD = gcd( F, G ); 1000 #endif 982 1001 TIMING_END( algLcmTimer ); 983 res= convClapASingA( (F/ GCD)*G ); 984 #elif defined( FACTORY_GCD_TEST ) 985 res= convClapASingA( (F/ CFPrimitiveGcdUtil::gcd( F, G ))*G ); 986 #else 987 988 // this part is translated if there are not any options at all 989 res= convClapASingA( (F/ gcd( F, G ))*G ); 990 991 #endif 1002 1003 FACTORY_CFAOUT( "gcd = ", GCD ); 1004 1005 // calculate lcm 1006 res= convClapASingA( (F/GCD)*G ); 992 1007 } 993 1008 else 994 1009 { 995 1010 CanonicalForm F( convSingTrClapP( f ) ), G( convSingTrClapP( g ) ); 996 #ifdef FACTORY_GCD_TIMING997 1011 CanonicalForm GCD; 998 1012 TIMING_START( algLcmTimer ); 1013 // calculate gcd 1014 #ifdef FACTORY_GCD_TEST 999 1015 GCD = CFPrimitiveGcdUtil::gcd( F, G ); 1016 #else 1017 GCD = gcd( F, G ); 1018 #endif 1000 1019 TIMING_END( algLcmTimer ); 1020 1021 FACTORY_CFTROUT( "gcd = ", GCD ); 1022 1023 // calculate lcm 1001 1024 res= convClapPSingTr( (F/GCD)*G ); 1002 #elif defined( FACTORY_GCD_TEST )1003 res= convClapPSingTr( (F/CFPrimitiveGcdUtil::gcd( F, G ))*G );1004 #else1005 1006 // this part is translated if there are not any options at all1007 res= convClapPSingTr( (F/gcd( F, G ))*G );1008 1009 #endif1010 1025 } 1026 1011 1027 Off(SW_RATIONAL); 1012 #ifdef FACTORY_GCD_DEBOUT1013 StringSetS("res = ");1014 napWrite(res);1015 PrintS(StringAppend("\n"));1016 #endif1017 1028 return res; 1018 1029 } … … 1020 1031 void singclap_algdividecontent ( alg f, alg g, alg &ff, alg &gg ) 1021 1032 { 1022 #ifdef FACTORY_GCD_DEBOUT 1023 alg algGcd; 1024 StringSetS("f = "); 1025 napWrite(f); 1026 PrintS(StringAppend("\n")); 1027 StringSetS("g = "); 1028 napWrite(g); 1029 PrintS(StringAppend("\n")); 1030 #endif 1031 // over Q(a) / Fp(a) 1033 FACTORY_ALGOUT( "f = ", f ); 1034 FACTORY_ALGOUT( "g = ", g ); 1035 1036 // over Q(a) / Fp(a) 1032 1037 if (nGetChar()==1) setCharacteristic( 0 ); 1033 1038 else setCharacteristic( -nGetChar() ); 1034 1039 ff=gg=NULL; 1040 1035 1041 #ifdef FACTORY_GCD_STAT 1036 1042 fprintf( stderr, "alCont:\t" ); 1037 1043 #endif 1044 1038 1045 if (currRing->minpoly!=NULL) 1039 1046 { … … 1041 1048 Variable a=rootOf(mipo); 1042 1049 CanonicalForm F( convSingAClapA( f,a ) ), G( convSingAClapA( g,a ) ); 1043 #ifdef FACTORY_GCD_TIMING1044 1050 CanonicalForm GCD; 1051 1045 1052 TIMING_START( algContentTimer ); 1053 #ifdef FACTORY_GCD_TEST 1046 1054 GCD=CFPrimitiveGcdUtil::gcd( F, G ); 1055 #else 1056 GCD=gcd( F, G ); 1057 #endif 1047 1058 TIMING_END( algContentTimer ); 1048 #elif defined( FACTORY_GCD_TEST ) 1049 CanonicalForm GCD=CFPrimitiveGcdUtil::gcd( F, G ); 1050 #else 1051 1052 // this part is translated if there are not any options at all 1053 CanonicalForm GCD=gcd( F, G ); 1054 1055 #endif 1059 1060 FACTORY_CFAOUT( "gcd = ", GCD ); 1061 1056 1062 if (GCD!=1) 1057 1063 { … … 1059 1065 gg= convClapASingA( G/ GCD ); 1060 1066 } 1061 #ifdef FACTORY_GCD_DEBOUT1062 algGcd=convClapASingA( GCD );1063 #endif1064 1067 } 1065 1068 else 1066 1069 { 1067 1070 CanonicalForm F( convSingTrClapP( f ) ), G( convSingTrClapP( g ) ); 1068 #ifdef FACTORY_GCD_TIMING1069 1071 CanonicalForm GCD; 1072 1070 1073 TIMING_START( algContentTimer ); 1074 #ifdef FACTORY_GCD_TEST 1071 1075 GCD=CFPrimitiveGcdUtil::gcd( F, G ); 1076 #else 1077 GCD=gcd( F, G ); 1078 #endif 1072 1079 TIMING_END( algContentTimer ); 1073 #elif defined( FACTORY_GCD_TEST ) 1074 CanonicalForm GCD=CFPrimitiveGcdUtil::gcd( F, G ); 1075 #else 1076 1077 // this part is translated if there are not any options at all 1078 CanonicalForm GCD=gcd( F, G ); 1079 1080 #endif 1080 1081 FACTORY_CFTROUT( "gcd = ", GCD ); 1082 1081 1083 if (GCD!=1) 1082 1084 { … … 1084 1086 gg= convClapPSingTr( G/ GCD ); 1085 1087 } 1086 #ifdef FACTORY_GCD_DEBOUT1087 algGcd=convClapPSingTr( GCD );1088 #endif1089 1088 } 1089 1090 1090 Off(SW_RATIONAL); 1091 #ifdef FACTORY_GCD_DEBOUT 1092 StringSetS("gcd = "); 1093 napWrite(algGcd); 1094 PrintS(StringAppend("\n")); 1095 napDelete(&algGcd); 1096 #endif 1097 } 1098 #endif 1091 } 1092 #endif
Note: See TracChangeset
for help on using the changeset viewer.