Changeset 66a322 in git
 Timestamp:
 Feb 1, 2010, 11:39:46 AM (13 years ago)
 Branches:
 (u'jengelhdatetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a657104b677b4c461d018cbf3204d72d34ad66a9')
 Children:
 8361387586493cc88d13e1a0d60ee25bf4b70cb3
 Parents:
 835604146a3a1dabecdf5653b203f926bfc98aa1
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

Singular/iparith.cc
r835604 r66a322 56 56 #include "walkProc.h" 57 57 #include "mod_raw.h" 58 #include "MinorInterface.h" 58 59 #ifdef HAVE_FACTORY 59 60 #include "clapsing.h" … … 317 318 { "memory", 0, MEMORY_CMD , CMD_1}, 318 319 { "minbase", 0, MINBASE_CMD , CMD_1}, 319 { "minor", 0, MINOR_CMD , CMD_ 23},320 { "minor", 0, MINOR_CMD , CMD_M}, 320 321 { "minres", 0, MINRES_CMD , CMD_1}, 321 322 { "mod", 0, INTMOD_CMD , MULDIV_OP}, … … 2552 2553 WerrorS("load(\"libname\" [,\"with\"]);"); 2553 2554 return TRUE; 2554 }2555 static BOOLEAN jjMINOR(leftv res, leftv u, leftv v)2556 {2557 res>data = (char *)idMinors((matrix)u>Data(),(int)(long)v>Data());2558 return (res>data==NULL);2559 2555 } 2560 2556 static BOOLEAN jjMODULO(leftv res, leftv u, leftv v) … … 3600 3596 ,{jjLOAD_E, LOAD_CMD, NONE, STRING_CMD, STRING_CMD, ALLOW_PLURAL ALLOW_RING} 3601 3597 ,{jjRES, LRES_CMD, RESOLUTION_CMD, IDEAL_CMD, INT_CMD, NO_PLURAL NO_RING} 3602 ,{jjMINOR, MINOR_CMD, IDEAL_CMD, MATRIX_CMD, INT_CMD, NO_PLURAL ALLOW_RING}3603 3598 ,{jjCALL2MANY, MODUL_CMD, MODUL_CMD, DEF_CMD, DEF_CMD, ALLOW_PLURAL ALLOW_RING} 3604 3599 ,{jjMODULO, MODULO_CMD, MODUL_CMD, IDEAL_CMD, IDEAL_CMD, ALLOW_PLURAL ALLOW_RING} … … 5959 5954 return FALSE; 5960 5955 } 5961 static BOOLEAN jjMINOR3(leftv res, leftv u, leftv v, leftv w) 5962 { 5963 assumeStdFlag(w); 5964 res>data = (char *)idMinors( 5965 (matrix)u>Data(),(int)(long)v>Data(),(ideal)w>Data()); 5956 static BOOLEAN currRingIsOverIntegralDomain () 5957 { 5958 /* true for fields and Z, false otherwise */ 5959 if (rField_is_Ring_PtoM()) return FALSE; 5960 if (rField_is_Ring_2toM()) return FALSE; 5961 if (rField_is_Ring_ModN()) return FALSE; 5962 return TRUE; 5963 } 5964 static BOOLEAN jjMINOR_M(leftv res, leftv v) 5965 { 5966 /* Here's the use pattern for the minor command: 5967 minor ( matrix_expression m, int_expression minorSize, 5968 optional ideal_expression IasSB, optional int_expression k, 5969 optional string_expression algorithm, 5970 optional int_expression cachedMinors, 5971 optional int_expression cachedMonomials ) 5972 This method here assumes that there are at least two arguments. 5973  If IasSB is present, it must be a std basis. All minors will be 5974 reduced w.r.t. IasSB. 5975  If k is absent, all nonzero minors will be computed. 5976 If k is present and k > 0, the first k nonzero minors will be 5977 computed. 5978 If k is present and k < 0, the first k minors (some of which 5979 may be zero) will be computed. 5980 If k is present and k = 0, an error is reported. 5981  If algorithm is absent, all the following arguments must be absent too. 5982 In this case, a heuristic picks the bestsuited algorithm (among 5983 Bareiss, Laplace, and Laplace with caching). 5984 If algorithm is present, it must be one of "Bareiss", "bareiss", 5985 "Laplace", "laplace", "Cache", "cache". In the cases "Cache" and 5986 "cache" two more arguments are expected, determining how many entries 5987 the cache may have at most, and how many cached monomials there are at 5988 most. (Cached monomials are counted over all cached polynomials.) 5989 */ 5990 const matrix m = (const matrix)v>Data(); 5991 const int mk = (const int)(long)v>next>Data(); 5992 bool noIdeal = true; bool noK = true; bool noAlgorithm = true; 5993 bool noCacheMinors = true; bool noCacheMonomials = true; 5994 ideal IasSB; int k; char* algorithm; int cacheMinors; int cacheMonomials; 5995 5996 /* here come the different cases of correct argument sets */ 5997 if ((v>next>next != NULL) && (v>next>next>Typ() == IDEAL_CMD)) 5998 { 5999 IasSB = (ideal)v>next>next>Data(); 6000 noIdeal = false; 6001 if ((v>next>next>next != NULL) && (v>next>next>next>Typ() == INT_CMD)) 6002 { 6003 k = (int)(long)v>next>next>next>Data(); 6004 noK = false; 6005 assume(k != 0); 6006 if ((v>next>next>next>next != NULL) && (v>next>next>next>next>Typ() == STRING_CMD)) 6007 { 6008 algorithm = (char*)v>next>next>next>next>Data(); 6009 noAlgorithm = false; 6010 if ((v>next>next>next>next>next != NULL) && (v>next>next>next>next>next>Typ() == INT_CMD)) 6011 { 6012 cacheMinors = (int)(long)v>next>next>next>next>next>Data(); 6013 noCacheMinors = false; 6014 if ((v>next>next>next>next>next>next != NULL) && (v>next>next>next>next>next>next>Typ() == INT_CMD)) 6015 { 6016 cacheMonomials = (int)(long)v>next>next>next>next>next>next>Data(); 6017 noCacheMonomials = false; 6018 } 6019 } 6020 } 6021 } 6022 } 6023 else if ((v>next>next != NULL) && (v>next>next>Typ() == INT_CMD)) 6024 { 6025 k = (int)(long)v>next>next>Data(); 6026 noK = false; 6027 assume(k != 0); 6028 if ((v>next>next>next != NULL) && (v>next>next>next>Typ() == STRING_CMD)) 6029 { 6030 algorithm = (char*)v>next>next>next>Data(); 6031 noAlgorithm = false; 6032 if ((v>next>next>next>next != NULL) && (v>next>next>next>next>Typ() == INT_CMD)) 6033 { 6034 cacheMinors = (int)(long)v>next>next>next>next>Data(); 6035 noCacheMinors = false; 6036 if ((v>next>next>next>next>next != NULL) && (v>next>next>next>next>next>Typ() == INT_CMD)) 6037 { 6038 cacheMonomials = (int)(long)v>next>next>next>next>next>Data(); 6039 noCacheMonomials = false; 6040 } 6041 } 6042 } 6043 } 6044 else if ((v>next>next != NULL) && (v>next>next>Typ() == STRING_CMD)) 6045 { 6046 algorithm = (char*)v>next>next>Data(); 6047 noAlgorithm = false; 6048 if ((v>next>next>next != NULL) && (v>next>next>next>Typ() == INT_CMD)) 6049 { 6050 cacheMinors = (int)(long)v>next>next>next>Data(); 6051 noCacheMinors = false; 6052 if ((v>next>next>next>next != NULL) && (v>next>next>next>next>Typ() == INT_CMD)) 6053 { 6054 cacheMonomials = (int)(long)v>next>next>next>next>Data(); 6055 noCacheMonomials = false; 6056 } 6057 } 6058 } 6059 6060 /* upper case conversion for the algorithm if present */ 6061 if (!noAlgorithm) 6062 { 6063 if (strcmp(algorithm, "bareiss") == 0) 6064 algorithm = "Bareiss"; 6065 if (strcmp(algorithm, "laplace") == 0) 6066 algorithm = "Laplace"; 6067 if (strcmp(algorithm, "cache") == 0) 6068 algorithm = "Cache"; 6069 } 6070 6071 /* here come some tests */ 6072 if ((!noIdeal) && (!hasFlag(v>next>next, FLAG_STD))) 6073 { 6074 WerrorS("Provided ideal is not a standard basis."); 6075 return TRUE; 6076 } 6077 if ((!noK) && (k == 0)) 6078 { 6079 WerrorS("Provided number of minors to be computed is zero."); 6080 return TRUE; 6081 } 6082 if ((!noAlgorithm) && (strcmp(algorithm, "Bareiss") != 0) 6083 && (strcmp(algorithm, "Laplace") != 0) && (strcmp(algorithm, "Cache") != 0)) 6084 { 6085 WerrorS("Expected as algorithm one of 'B/bareiss', 'L/laplace', or 'C/cache'."); 6086 return TRUE; 6087 } 6088 if ((!noAlgorithm) && (strcmp(algorithm, "Bareiss") == 0) 6089 && (!currRingIsOverIntegralDomain())) 6090 { 6091 WerrorS("Bareiss algorithm not defined over coefficient rings with zero divisors."); 6092 return TRUE; 6093 } 6094 if ((!noAlgorithm) && (strcmp(algorithm, "Cache") == 0) 6095 && (noCacheMinors  noCacheMonomials)) 6096 { 6097 WerrorS("Expected two more int arguments after algorithm 'C/cache' ."); 6098 return TRUE; 6099 } 6100 6101 /* here come the actual procedure calls */ 6102 if (noAlgorithm) 6103 res>data = getMinorIdealHeuristic(m, mk, (noK ? 0 : k), (noIdeal ? 0 : IasSB), false); 6104 else if (strcmp(algorithm, "Cache") == 0) 6105 res>data = getMinorIdealCache(m, mk, (noK ? 0 : k), (noIdeal ? 0 : IasSB), 3, cacheMinors, cacheMonomials, false); 6106 else 6107 res>data = getMinorIdeal(m, mk, (noK ? 0 : k), algorithm, (noIdeal ? 0 : IasSB), false); 6108 res>rtyp = IDEAL_CMD; 5966 6109 return FALSE; 5967 6110 } … … 6408 6551 ,{jjMATRIX_Mo, MATRIX_CMD, MATRIX_CMD, MODUL_CMD, INT_CMD, INT_CMD, ALLOW_PLURAL ALLOW_RING} 6409 6552 ,{jjMATRIX_Ma, MATRIX_CMD, MATRIX_CMD, MATRIX_CMD, INT_CMD, INT_CMD, ALLOW_PLURAL ALLOW_RING} 6410 ,{jjMINOR3, MINOR_CMD, IDEAL_CMD, MATRIX_CMD, INT_CMD, IDEAL_CMD, NO_PLURAL ALLOW_RING}6411 6553 ,{jjCALL3MANY, MODUL_CMD, MODUL_CMD, DEF_CMD, DEF_CMD, DEF_CMD, ALLOW_PLURAL ALLOW_RING} 6412 6554 #ifdef OLD_RES … … 7267 7409 ,{jjJET4, JET_CMD, POLY_CMD,/*or set by p*/ 4 , ALLOW_PLURAL ALLOW_RING} 7268 7410 ,{jjLIST_PL, LIST_CMD, LIST_CMD, 1 , ALLOW_PLURAL ALLOW_RING} 7411 ,{jjWRONG, MINOR_CMD, NONE, 1 , ALLOW_PLURAL ALLOW_RING} 7412 ,{jjMINOR_M, MINOR_CMD, IDEAL_CMD, 2 , ALLOW_PLURAL ALLOW_RING} 7269 7413 ,{jjCALL1ARG, MODUL_CMD, MODUL_CMD, 1 , ALLOW_PLURAL ALLOW_RING} 7270 7414 ,{jjIDEAL_PL, MODUL_CMD, MODUL_CMD, 1 , ALLOW_PLURAL ALLOW_RING}
Note: See TracChangeset
for help on using the changeset viewer.