47 const int length,
int* intArray,
48 poly* nfPolyArray,
int& zeroCounter)
55 for (
int i = 0;
i < length;
i++)
57 nfPolyArray[
i] =
pCopy(polyArray[
i]);
58 if (iSB != 0) nfPolyArray[
i] =
kNF(iSB,
currRing->qideal, nfPolyArray[i]);
59 if (nfPolyArray[i] ==
NULL)
66 bool isConstant =
true;
67 for (
int j = 1;
j <= n;
j++)
70 if (!isConstant) result =
false;
74 if (characteristic != 0) intArray[
i] = intArray[
i] % characteristic;
75 if (intArray[i] == 0) zeroCounter++;
89 const int columnCount,
const int minorSize,
90 const int k,
const char* algorithm,
91 const ideal
i,
const bool allDifferent)
96 int *myRowIndices=
new int[rowCount];
97 for (
int j = 0;
j < rowCount;
j++) myRowIndices[
j] =
j;
98 int *myColumnIndices=
new int[columnCount];
99 for (
int j = 0;
j < columnCount;
j++) myColumnIndices[
j] =
j;
100 mp.
defineSubMatrix(rowCount, myRowIndices, columnCount, myColumnIndices);
106 int collectedMinors = 0;
112 bool zeroOk = ((k < 0) ?
true :
false);
114 bool duplicatesOk = (allDifferent ?
false :
true);
115 int kk = ((k < 0) ? -k : k);
118 while (mp.
hasNextMinor() && ((kk == 0) || (collectedMinors < kk)))
121 theMinor = mp.
getNextMinor(characteristic, i, algorithm);
131 if (collectedMinors == 0) jjj =
idInit(1);
134 delete[] myColumnIndices;
135 delete[] myRowIndices;
144 const int columnCount,
const int minorSize,
145 const int k,
const char* algorithm,
146 const ideal
i,
const bool allDifferent)
151 int *myRowIndices=
new int[rowCount];
152 for (
int j = 0;
j < rowCount;
j++) myRowIndices[
j] =
j;
153 int *myColumnIndices=
new int[columnCount];
154 for (
int j = 0;
j < columnCount;
j++) myColumnIndices[
j] =
j;
155 mp.
defineSubMatrix(rowCount, myRowIndices, columnCount, myColumnIndices);
161 int collectedMinors = 0;
166 bool zeroOk = ((k < 0) ?
true :
false);
168 bool duplicatesOk = (allDifferent ?
false :
true);
169 int kk = ((k < 0) ? -k : k);
170 #ifdef COUNT_AND_PRINT_OPERATIONS 175 while (mp.
hasNextMinor() && ((kk == 0) || (collectedMinors < kk)))
179 #if (defined COUNT_AND_PRINT_OPERATIONS) && (COUNT_AND_PRINT_OPERATIONS > 1) 181 Print(
"after %d", qqq);
186 zeroOk, duplicatesOk))
189 #ifdef COUNT_AND_PRINT_OPERATIONS 196 delete[] myColumnIndices;
197 delete[] myRowIndices;
202 const int k,
const char* algorithm,
203 const ideal
i,
const bool allDifferent)
205 int rowCount = mat->
nrows;
206 int columnCount = mat->
ncols;
213 int* myIntMatrix =
new int [rowCount * columnCount];
214 poly* nfPolyMatrix =
new poly[rowCount * columnCount];
216 myIntMatrix, nfPolyMatrix, zz))
218 algorithm, i, allDifferent);
221 if ((k == 0) && (strcmp(algorithm,
"Bareiss") == 0)
235 k, algorithm, i, allDifferent);
240 delete [] myIntMatrix;
241 for (
int j = 0;
j < rowCount * columnCount;
j++)
pDelete(&nfPolyMatrix[
j]);
242 delete [] nfPolyMatrix;
253 const char* algorithm,
const ideal iSB,
254 const bool allDifferent)
261 int rowCount = mat->
nrows;
262 int columnCount = mat->
ncols;
264 int length = rowCount * columnCount;
265 poly* nfPolyMatrix =
new poly[length];
272 for (
int i = 0;
i < length;
i++)
274 nfPolyMatrix[
i] =
kNF(iSB,
currRing->qideal,myPolyMatrix[
i]);
279 for (
int i = 0;
i < length;
i++)
281 nfPolyMatrix[
i] =
pCopy(myPolyMatrix[
i]);
285 if ((k == 0) && (strcmp(algorithm,
"Bareiss") == 0)
300 k, algorithm, iSB, allDifferent);
304 for (
int j = 0;
j < length;
j++)
pDelete(&nfPolyMatrix[
j]);
305 delete [] nfPolyMatrix;
317 const int columnCount,
const int minorSize,
318 const int k,
const ideal
i,
319 const int cacheStrategy,
const int cacheN,
320 const int cacheW,
const bool allDifferent)
325 int *myRowIndices=
new int[rowCount];
326 for (
int j = 0;
j < rowCount;
j++) myRowIndices[
j] =
j;
327 int *myColumnIndices=
new int[columnCount];
328 for (
int j = 0;
j < columnCount;
j++) myColumnIndices[
j] =
j;
329 mp.
defineSubMatrix(rowCount, myRowIndices, columnCount, myColumnIndices);
337 int collectedMinors = 0;
343 bool zeroOk = ((k < 0) ?
true :
false);
345 bool duplicatesOk = (allDifferent ?
false :
true);
346 int kk = ((k < 0) ? -k : k);
349 while (mp.
hasNextMinor() && ((kk == 0) || (collectedMinors < kk)))
362 if (collectedMinors == 0) jjj =
idInit(1);
365 delete[] myColumnIndices;
366 delete[] myRowIndices;
375 const int columnCount,
const int minorSize,
376 const int k,
const ideal
i,
377 const int cacheStrategy,
const int cacheN,
378 const int cacheW,
const bool allDifferent)
383 int *myRowIndices=
new int[rowCount];
384 for (
int j = 0;
j < rowCount;
j++) myRowIndices[
j] =
j;
385 int *myColumnIndices=
new int[columnCount];
386 for (
int j = 0;
j < columnCount;
j++) myColumnIndices[
j] =
j;
387 mp.
defineSubMatrix(rowCount, myRowIndices, columnCount, myColumnIndices);
395 int collectedMinors = 0;
400 bool zeroOk = ((k < 0) ?
true :
false);
402 bool duplicatesOk = (allDifferent ?
false :
true);
403 int kk = ((k < 0) ? -k : k);
404 #ifdef COUNT_AND_PRINT_OPERATIONS 409 while (mp.
hasNextMinor() && ((kk == 0) || (collectedMinors < kk)))
413 #if (defined COUNT_AND_PRINT_OPERATIONS) && (COUNT_AND_PRINT_OPERATIONS > 1) 415 Print(
"after %d", qqq);
423 #ifdef COUNT_AND_PRINT_OPERATIONS 430 if (collectedMinors == 0) jjj =
idInit(1);
433 delete[] myColumnIndices;
434 delete[] myRowIndices;
439 const int k,
const ideal iSB,
440 const int cacheStrategy,
const int cacheN,
441 const int cacheW,
const bool allDifferent)
443 int rowCount = mat->
nrows;
444 int columnCount = mat->
ncols;
451 int* myIntMatrix =
new int [rowCount * columnCount];
452 poly* nfPolyMatrix =
new poly[rowCount * columnCount];
454 myIntMatrix, nfPolyMatrix, zz))
456 minorSize, k, iSB, cacheStrategy, cacheN,
457 cacheW, allDifferent);
460 minorSize, k, iSB, cacheStrategy, cacheN,
461 cacheW, allDifferent);
464 delete [] myIntMatrix;
465 for (
int j = 0;
j < rowCount * columnCount;
j++)
pDelete(&nfPolyMatrix[
j]);
466 delete [] nfPolyMatrix;
472 const ideal iSB,
const int cacheStrategy,
473 const int cacheN,
const int cacheW,
474 const bool allDifferent)
481 int rowCount = mat->
nrows;
482 int columnCount = mat->
ncols;
484 int length = rowCount * columnCount;
485 poly* nfPolyMatrix =
new poly[length];
490 for (
int i = 0;
i < length;
i++)
492 nfPolyMatrix[
i] =
pCopy(myPolyMatrix[
i]);
493 if (iSB != 0) nfPolyMatrix[
i] =
kNF(iSB,
currRing->qideal,
498 minorSize, k, iSB, cacheStrategy,
499 cacheN, cacheW, allDifferent);
502 for (
int j = 0;
j < length;
j++)
pDelete(&nfPolyMatrix[
j]);
503 delete [] nfPolyMatrix;
509 const int k,
const ideal iSB,
510 const bool allDifferent)
513 int rowCount = mat->
nrows;
514 int columnCount = mat->
ncols;
541 if (minorSize <= 2) b =
true;
542 else if (vars <= 2) b =
true;
549 if (k != 0) l =
true;
552 int minorCount =
binom(rowCount, minorSize);
553 minorCount *=
binom(columnCount, minorSize);
562 if (b)
return getMinorIdeal(mat, minorSize, k,
"Bareiss", iSB,
564 else if (l)
return getMinorIdeal(mat, minorSize, k,
"Laplace", iSB,
567 3, 200, 100000, allDifferent);
ideal getMinorIdeal(const matrix mat, const int minorSize, const int k, const char *algorithm, const ideal iSB, const bool allDifferent)
Returns the specified set of minors (= subdeterminantes) of the given matrix.
poly kNF(ideal F, ideal Q, poly p, int syzComp, int lazyReduce)
void idKeepFirstK(ideal id, const int k)
keeps the first k (>= 1) entries of the given ideal (Note that the kept polynomials may be zero...
bool currRingIsOverIntegralDomain()
Class PolyMinorProcessor is derived from class MinorProcessor.
#define idDelete(H)
delete an ideal
static BOOLEAN rField_is_Ring_PtoM(const ring r)
Compatiblity layer for legacy polynomial operations (over currRing)
static BOOLEAN rField_is_Ring_ModN(const ring r)
int getResult() const
Accessor for the private field _result.
ideal getMinorIdeal_Int(const int *intMatrix, const int rowCount, const int columnCount, const int minorSize, const int k, const char *algorithm, const ideal i, const bool allDifferent)
ideal getMinorIdealCache(const matrix mat, const int minorSize, const int k, const ideal iSB, const int cacheStrategy, const int cacheN, const int cacheW, const bool allDifferent)
Returns the specified set of minors (= subdeterminantes) of the given matrix.
static void SetRankingStrategy(const int rankingStrategy)
A method for determining the value ranking strategy.
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
Class IntMinorValue is derived from MinorValue and can be used for representing values in a cache for...
bool arrayIsNumberArray(const poly *polyArray, const ideal iSB, const int length, int *intArray, poly *nfPolyArray, int &zeroCounter)
poly getResult() const
Accessor for the private field _result.
Class Cache is a template-implementation of a cache with arbitrary classes for representing keys and ...
PolyMinorValue getNextMinor(const char *algorithm, const ideal &iSB)
A method for obtaining the next minor when iterating through all minors of a given size within a pre-...
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
#define pGetExp(p, i)
Exponent.
IntMinorValue getNextMinor(const int characteristic, const ideal &iSB, const char *algorithm)
A method for obtaining the next minor when iterating through all minors of a given size within a pre-...
bool hasNextMinor()
A method for checking whether there is a next choice of rows and columns when iterating through all m...
static FORCE_INLINE long n_Int(number &n, const coeffs r)
conversion of n to an int; 0 if not possible in Z/pZ: the representing int lying in (-p/2 ...
ideal idMinors(matrix a, int ar, ideal R)
compute all ar-minors of the matrix a the caller of mpRecMin the elements of the result are not in R ...
Class PolyMinorValue is derived from MinorValue and can be used for representing values in a cache fo...
ideal getMinorIdealCache_Poly(const poly *polyMatrix, const int rowCount, const int columnCount, const int minorSize, const int k, const ideal i, const int cacheStrategy, const int cacheN, const int cacheW, const bool allDifferent)
ideal idInit(int idsize, int rank)
initialise an ideal / module
BOOLEAN idInsertPolyWithTests(ideal h1, const int validEntries, const poly h2, const bool zeroOk, const bool duplicateOk)
void defineMatrix(const int numberOfRows, const int numberOfColumns, const poly *polyMatrix)
A method for defining a matrix with polynomial entries.
bool currRingIsOverField()
ideal getMinorIdealHeuristic(const matrix mat, const int minorSize, const int k, const ideal iSB, const bool allDifferent)
Returns the specified set of minors (= subdeterminantes) of the given matrix.
static ideal idCopyFirstK(const ideal ide, const int k)
static BOOLEAN rField_is_Ring_2toM(const ring r)
void printCounters(char *prefix, bool resetToZero)
ideal getMinorIdeal_Poly(const poly *polyMatrix, const int rowCount, const int columnCount, const int minorSize, const int k, const char *algorithm, const ideal i, const bool allDifferent)
static BOOLEAN rField_is_Ring_Z(const ring r)
void setMinorSize(const int minorSize)
Sets the size of the minor(s) of interest.
Class IntMinorProcessor is derived from class MinorProcessor.
void defineMatrix(const int numberOfRows, const int numberOfColumns, const int *matrix)
A method for defining a matrix with integer entries.
ideal getMinorIdealCache_toBeDone(const matrix mat, const int minorSize, const int k, const ideal iSB, const int cacheStrategy, const int cacheN, const int cacheW, const bool allDifferent)
ideal getMinorIdealCache_Int(const int *intMatrix, const int rowCount, const int columnCount, const int minorSize, const int k, const ideal i, const int cacheStrategy, const int cacheN, const int cacheW, const bool allDifferent)
void defineSubMatrix(const int numberOfRows, const int *rowIndices, const int numberOfColumns, const int *columnIndices)
A method for defining a sub-matrix within a pre-defined matrix.
ideal getMinorIdeal_toBeDone(const matrix mat, const int minorSize, const int k, const char *algorithm, const ideal i, const bool allDifferent)
#define pCopy(p)
return a copy of the poly