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];
270 for (
int i = 0;
i < length;
i++)
272 nfPolyMatrix[
i] =
pCopy(myPolyMatrix[
i]);
273 if (iSB != 0) nfPolyMatrix[
i] =
kNF(iSB,
currRing->qideal,
277 if ((k == 0) && (strcmp(algorithm,
"Bareiss") == 0)
292 k, algorithm, iSB, allDifferent);
296 for (
int j = 0;
j < length;
j++)
pDelete(&nfPolyMatrix[
j]);
297 delete [] nfPolyMatrix;
309 const int columnCount,
const int minorSize,
310 const int k,
const ideal
i,
311 const int cacheStrategy,
const int cacheN,
312 const int cacheW,
const bool allDifferent)
317 int *myRowIndices=
new int[rowCount];
318 for (
int j = 0;
j < rowCount;
j++) myRowIndices[
j] =
j;
319 int *myColumnIndices=
new int[columnCount];
320 for (
int j = 0;
j < columnCount;
j++) myColumnIndices[
j] =
j;
321 mp.
defineSubMatrix(rowCount, myRowIndices, columnCount, myColumnIndices);
329 int collectedMinors = 0;
335 bool zeroOk = ((k < 0) ?
true :
false);
337 bool duplicatesOk = (allDifferent ?
false :
true);
338 int kk = ((k < 0) ? -k : k);
341 while (mp.
hasNextMinor() && ((kk == 0) || (collectedMinors < kk)))
354 if (collectedMinors == 0) jjj =
idInit(1);
357 delete[] myColumnIndices;
358 delete[] myRowIndices;
367 const int columnCount,
const int minorSize,
368 const int k,
const ideal
i,
369 const int cacheStrategy,
const int cacheN,
370 const int cacheW,
const bool allDifferent)
375 int *myRowIndices=
new int[rowCount];
376 for (
int j = 0;
j < rowCount;
j++) myRowIndices[
j] =
j;
377 int *myColumnIndices=
new int[columnCount];
378 for (
int j = 0;
j < columnCount;
j++) myColumnIndices[
j] =
j;
379 mp.
defineSubMatrix(rowCount, myRowIndices, columnCount, myColumnIndices);
387 int collectedMinors = 0;
392 bool zeroOk = ((k < 0) ?
true :
false);
394 bool duplicatesOk = (allDifferent ?
false :
true);
395 int kk = ((k < 0) ? -k : k);
396 #ifdef COUNT_AND_PRINT_OPERATIONS 401 while (mp.
hasNextMinor() && ((kk == 0) || (collectedMinors < kk)))
405 #if (defined COUNT_AND_PRINT_OPERATIONS) && (COUNT_AND_PRINT_OPERATIONS > 1) 407 Print(
"after %d", qqq);
415 #ifdef COUNT_AND_PRINT_OPERATIONS 422 if (collectedMinors == 0) jjj =
idInit(1);
425 delete[] myColumnIndices;
426 delete[] myRowIndices;
431 const int k,
const ideal iSB,
432 const int cacheStrategy,
const int cacheN,
433 const int cacheW,
const bool allDifferent)
435 int rowCount = mat->
nrows;
436 int columnCount = mat->
ncols;
443 int* myIntMatrix =
new int [rowCount * columnCount];
444 poly* nfPolyMatrix =
new poly[rowCount * columnCount];
446 myIntMatrix, nfPolyMatrix, zz))
448 minorSize, k, iSB, cacheStrategy, cacheN,
449 cacheW, allDifferent);
452 minorSize, k, iSB, cacheStrategy, cacheN,
453 cacheW, allDifferent);
456 delete [] myIntMatrix;
457 for (
int j = 0;
j < rowCount * columnCount;
j++)
pDelete(&nfPolyMatrix[
j]);
458 delete [] nfPolyMatrix;
464 const ideal iSB,
const int cacheStrategy,
465 const int cacheN,
const int cacheW,
466 const bool allDifferent)
473 int rowCount = mat->
nrows;
474 int columnCount = mat->
ncols;
476 int length = rowCount * columnCount;
477 poly* nfPolyMatrix =
new poly[length];
482 for (
int i = 0;
i < length;
i++)
484 nfPolyMatrix[
i] =
pCopy(myPolyMatrix[
i]);
485 if (iSB != 0) nfPolyMatrix[
i] =
kNF(iSB,
currRing->qideal,
490 minorSize, k, iSB, cacheStrategy,
491 cacheN, cacheW, allDifferent);
494 for (
int j = 0;
j < length;
j++)
pDelete(&nfPolyMatrix[
j]);
495 delete [] nfPolyMatrix;
501 const int k,
const ideal iSB,
502 const bool allDifferent)
505 int rowCount = mat->
nrows;
506 int columnCount = mat->
ncols;
533 if (minorSize <= 2) b =
true;
534 else if (vars <= 2) b =
true;
541 if (k != 0) l =
true;
544 int minorCount =
binom(rowCount, minorSize);
545 minorCount *=
binom(columnCount, minorSize);
554 if (b)
return getMinorIdeal(mat, minorSize, k,
"Bareiss", iSB,
556 else if (l)
return getMinorIdeal(mat, minorSize, k,
"Laplace", iSB,
559 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