MCPcopy Create free account
hub / github.com/Singular/Singular / getMinorIdealCache_Int

Function getMinorIdealCache_Int

kernel/linear_algebra/MinorInterface.cc:302–354  ·  view source on GitHub ↗

special implementation for the case that the matrix has only number entries; if i is not the zero pointer, then it is assumed to contain a std basis, and the number entries of the matrix are then assumed to be reduced w.r.t. i and modulo the characteristic of the gound field/ring; this method should also work when currRing == null, i.e. when no ring has been declared */

Source from the content-addressed store, hash-verified

300 this method should also work when currRing == null, i.e. when no ring has
301 been declared */
302ideal getMinorIdealCache_Int(const int* intMatrix, const int rowCount,
303 const int columnCount, const int minorSize,
304 const int k, const ideal i,
305 const int cacheStrategy, const int cacheN,
306 const int cacheW, const bool allDifferent)
307{
308 /* setting up a MinorProcessor for matrices with integer entries: */
309 IntMinorProcessor mp;
310 mp.defineMatrix(rowCount, columnCount, intMatrix);
311 int *myRowIndices=(int*)omAlloc(rowCount*sizeof(int));
312 for (int j = 0; j < rowCount; j++) myRowIndices[j] = j;
313 int *myColumnIndices=(int*)omAlloc(columnCount*sizeof(int));
314 for (int j = 0; j < columnCount; j++) myColumnIndices[j] = j;
315 mp.defineSubMatrix(rowCount, myRowIndices, columnCount, myColumnIndices);
316 mp.setMinorSize(minorSize);
317 MinorValue::SetRankingStrategy(cacheStrategy);
318 Cache<MinorKey, IntMinorValue> cch(cacheN, cacheW);
319
320 /* containers for all upcoming results: */
321 IntMinorValue theMinor;
322 // int value = 0;
323 int collectedMinors = 0;
324 int characteristic = 0; if (currRing != 0) characteristic = rChar(currRing);
325
326 /* the ideal to be returned: */
327 ideal iii = idInit(1);
328
329 bool zeroOk = ((k < 0) ? true : false); /* for k = 0, all minors are
330 requested, omitting zero minors */
331 bool duplicatesOk = (allDifferent ? false : true);
332 int kk = ABS(k); /* absolute value of k */
333
334 /* looping over all minors: */
335 while (mp.hasNextMinor() && ((kk == 0) || (collectedMinors < kk)))
336 {
337 /* retrieving the next minor: */
338 theMinor = mp.getNextMinor(cch, characteristic, i);
339 poly f = NULL;
340 if (theMinor.getResult() != 0) f = pISet(theMinor.getResult());
341 if (idInsertPolyWithTests(iii, collectedMinors, f, zeroOk, duplicatesOk))
342 collectedMinors++;
343 }
344
345 /* before we return the result, let's omit zero generators
346 in iii which come after the computed minors */
347 ideal jjj;
348 if (collectedMinors == 0) jjj = idInit(1);
349 else jjj = idCopyFirstK(iii, collectedMinors);
350 idDelete(&iii);
351 omFree(myColumnIndices);
352 omFree(myRowIndices);
353 return jjj;
354}
355
356/* special implementation for the case that the matrix has non-number,
357 i.e. real poly entries;

Callers 1

Calls 11

rCharFunction · 0.85
idInitFunction · 0.85
ABSFunction · 0.85
idInsertPolyWithTestsFunction · 0.85
idCopyFirstKFunction · 0.85
defineMatrixMethod · 0.80
defineSubMatrixMethod · 0.80
setMinorSizeMethod · 0.80
hasNextMinorMethod · 0.80
getNextMinorMethod · 0.80
getResultMethod · 0.80

Tested by

no test coverage detected