46 const int length,
int* intArray,
47 poly* nfPolyArray,
int& zeroCounter)
54 for (
int i = 0;
i < length;
i++)
56 nfPolyArray[
i] =
pCopy(polyArray[
i]);
57 if (iSB != 0) nfPolyArray[
i] =
kNF(iSB,
currRing->qideal, nfPolyArray[i]);
58 if (nfPolyArray[i] ==
NULL)
65 bool isConstant =
true;
66 for (
int j = 1;
j <= n;
j++)
69 if (!isConstant) result =
false;
73 if (characteristic != 0) intArray[
i] = intArray[
i] % characteristic;
74 if (intArray[i] == 0) zeroCounter++;
88 const int columnCount,
const int minorSize,
89 const int k,
const char* algorithm,
90 const ideal
i,
const bool allDifferent)
95 int *myRowIndices=
new int[rowCount];
96 for (
int j = 0;
j < rowCount;
j++) myRowIndices[
j] =
j;
97 int *myColumnIndices=
new int[columnCount];
98 for (
int j = 0;
j < columnCount;
j++) myColumnIndices[
j] =
j;
99 mp.
defineSubMatrix(rowCount, myRowIndices, columnCount, myColumnIndices);
105 int collectedMinors = 0;
111 bool zeroOk = ((k < 0) ?
true :
false);
113 bool duplicatesOk = (allDifferent ?
false :
true);
114 int kk = ((k < 0) ? -k : k);
117 while (mp.
hasNextMinor() && ((kk == 0) || (collectedMinors < kk)))
120 theMinor = mp.
getNextMinor(characteristic, i, algorithm);
130 if (collectedMinors == 0) jjj =
idInit(1);
133 delete[] myColumnIndices;
134 delete[] myRowIndices;
143 const int columnCount,
const int minorSize,
144 const int k,
const char* algorithm,
145 const ideal
i,
const bool allDifferent)
150 int *myRowIndices=
new int[rowCount];
151 for (
int j = 0;
j < rowCount;
j++) myRowIndices[
j] =
j;
152 int *myColumnIndices=
new int[columnCount];
153 for (
int j = 0;
j < columnCount;
j++) myColumnIndices[
j] =
j;
154 mp.
defineSubMatrix(rowCount, myRowIndices, columnCount, myColumnIndices);
160 int collectedMinors = 0;
165 bool zeroOk = ((k < 0) ?
true :
false);
167 bool duplicatesOk = (allDifferent ?
false :
true);
168 int kk = ((k < 0) ? -k : k);
169 #ifdef COUNT_AND_PRINT_OPERATIONS 174 while (mp.
hasNextMinor() && ((kk == 0) || (collectedMinors < kk)))
178 #if (defined COUNT_AND_PRINT_OPERATIONS) && (COUNT_AND_PRINT_OPERATIONS > 1) 180 Print(
"after %d", qqq);
185 zeroOk, duplicatesOk))
188 #ifdef COUNT_AND_PRINT_OPERATIONS 195 delete[] myColumnIndices;
196 delete[] myRowIndices;
201 const int k,
const char* algorithm,
202 const ideal
i,
const bool allDifferent)
204 int rowCount = mat->
nrows;
205 int columnCount = mat->
ncols;
212 int* myIntMatrix =
new int [rowCount * columnCount];
213 poly* nfPolyMatrix =
new poly[rowCount * columnCount];
215 myIntMatrix, nfPolyMatrix, zz))
217 algorithm, i, allDifferent);
220 if ((k == 0) && (strcmp(algorithm,
"Bareiss") == 0)
234 k, algorithm, i, allDifferent);
239 delete [] myIntMatrix;
240 for (
int j = 0;
j < rowCount * columnCount;
j++)
pDelete(&nfPolyMatrix[
j]);
241 delete [] nfPolyMatrix;
252 const char* algorithm,
const ideal iSB,
253 const bool allDifferent)
260 int rowCount = mat->
nrows;
261 int columnCount = mat->
ncols;
263 int length = rowCount * columnCount;
264 poly* nfPolyMatrix =
new poly[length];
269 for (
int i = 0;
i < length;
i++)
271 nfPolyMatrix[
i] =
pCopy(myPolyMatrix[
i]);
272 if (iSB != 0) nfPolyMatrix[
i] =
kNF(iSB,
currRing->qideal,
276 if ((k == 0) && (strcmp(algorithm,
"Bareiss") == 0)
291 k, algorithm, iSB, allDifferent);
295 for (
int j = 0;
j < length;
j++)
pDelete(&nfPolyMatrix[
j]);
296 delete [] nfPolyMatrix;
308 const int columnCount,
const int minorSize,
309 const int k,
const ideal
i,
310 const int cacheStrategy,
const int cacheN,
311 const int cacheW,
const bool allDifferent)
316 int *myRowIndices=
new int[rowCount];
317 for (
int j = 0;
j < rowCount;
j++) myRowIndices[
j] =
j;
318 int *myColumnIndices=
new int[columnCount];
319 for (
int j = 0;
j < columnCount;
j++) myColumnIndices[
j] =
j;
320 mp.
defineSubMatrix(rowCount, myRowIndices, columnCount, myColumnIndices);
328 int collectedMinors = 0;
334 bool zeroOk = ((k < 0) ?
true :
false);
336 bool duplicatesOk = (allDifferent ?
false :
true);
337 int kk = ((k < 0) ? -k : k);
340 while (mp.
hasNextMinor() && ((kk == 0) || (collectedMinors < kk)))
353 if (collectedMinors == 0) jjj =
idInit(1);
356 delete[] myColumnIndices;
357 delete[] myRowIndices;
366 const int columnCount,
const int minorSize,
367 const int k,
const ideal
i,
368 const int cacheStrategy,
const int cacheN,
369 const int cacheW,
const bool allDifferent)
374 int *myRowIndices=
new int[rowCount];
375 for (
int j = 0;
j < rowCount;
j++) myRowIndices[
j] =
j;
376 int *myColumnIndices=
new int[columnCount];
377 for (
int j = 0;
j < columnCount;
j++) myColumnIndices[
j] =
j;
378 mp.
defineSubMatrix(rowCount, myRowIndices, columnCount, myColumnIndices);
386 int collectedMinors = 0;
391 bool zeroOk = ((k < 0) ?
true :
false);
393 bool duplicatesOk = (allDifferent ?
false :
true);
394 int kk = ((k < 0) ? -k : k);
395 #ifdef COUNT_AND_PRINT_OPERATIONS 400 while (mp.
hasNextMinor() && ((kk == 0) || (collectedMinors < kk)))
404 #if (defined COUNT_AND_PRINT_OPERATIONS) && (COUNT_AND_PRINT_OPERATIONS > 1) 406 Print(
"after %d", qqq);
414 #ifdef COUNT_AND_PRINT_OPERATIONS 421 if (collectedMinors == 0) jjj =
idInit(1);
424 delete[] myColumnIndices;
425 delete[] myRowIndices;
430 const int k,
const ideal iSB,
431 const int cacheStrategy,
const int cacheN,
432 const int cacheW,
const bool allDifferent)
434 int rowCount = mat->
nrows;
435 int columnCount = mat->
ncols;
442 int* myIntMatrix =
new int [rowCount * columnCount];
443 poly* nfPolyMatrix =
new poly[rowCount * columnCount];
445 myIntMatrix, nfPolyMatrix, zz))
447 minorSize, k, iSB, cacheStrategy, cacheN,
448 cacheW, allDifferent);
451 minorSize, k, iSB, cacheStrategy, cacheN,
452 cacheW, allDifferent);
455 delete [] myIntMatrix;
456 for (
int j = 0;
j < rowCount * columnCount;
j++)
pDelete(&nfPolyMatrix[
j]);
457 delete [] nfPolyMatrix;
463 const ideal iSB,
const int cacheStrategy,
464 const int cacheN,
const int cacheW,
465 const bool allDifferent)
472 int rowCount = mat->
nrows;
473 int columnCount = mat->
ncols;
475 int length = rowCount * columnCount;
476 poly* nfPolyMatrix =
new poly[length];
481 for (
int i = 0;
i < length;
i++)
483 nfPolyMatrix[
i] =
pCopy(myPolyMatrix[
i]);
484 if (iSB != 0) nfPolyMatrix[
i] =
kNF(iSB,
currRing->qideal,
489 minorSize, k, iSB, cacheStrategy,
490 cacheN, cacheW, allDifferent);
493 for (
int j = 0;
j < length;
j++)
pDelete(&nfPolyMatrix[
j]);
494 delete [] nfPolyMatrix;
500 const int k,
const ideal iSB,
501 const bool allDifferent)
504 int rowCount = mat->
nrows;
505 int columnCount = mat->
ncols;
532 if (minorSize <= 2) b =
true;
533 else if (vars <= 2) b =
true;
540 if (k != 0) l =
true;
543 int minorCount =
binom(rowCount, minorSize);
544 minorCount *=
binom(columnCount, minorSize);
553 if (b)
return getMinorIdeal(mat, minorSize, k,
"Bareiss", iSB,
555 else if (l)
return getMinorIdeal(mat, minorSize, k,
"Laplace", iSB,
558 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)
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)
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...
poly getResult() const
Accessor for the private field _result.
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)
int getResult() const
Accessor for the private field _result.
#define pCopy(p)
return a copy of the poly