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

Method selectFirstColumns

kernel/linear_algebra/Minor.cc:498–536  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

496}
497
498void MinorKey::selectFirstColumns (const int k, const MinorKey& mk)
499{
500 int hitBits = 0; /* the number of bits we have hit; in the end, this
501 has to be equal to k, the dimension of the minor */
502 int blockIndex = -1; /* the index of the current int in mk */
503 unsigned int highestInt = 0; /* the new highest block of this MinorKey */
504 /* We determine which ints of mk we can copy. Their indices will be
505 0, 1, ..., blockIndex - 1. And highestInt is going to capture the highest
506 int (which may be only a portion of the corresponding int in mk.
507 We loop until hitBits = k: */
508 while (hitBits < k)
509 {
510 blockIndex++;
511 highestInt = 0;
512 unsigned int currentInt = mk.getColumnKey(blockIndex);
513 unsigned int shiftedBit = 1;
514 int exponent = 0;
515 /* invariant in the loop: shiftedBit = 2^exponent */
516 while (exponent < 32 && hitBits < k)
517 {
518 if (shiftedBit & currentInt)
519 {
520 highestInt += shiftedBit;
521 hitBits++;
522 }
523 shiftedBit = shiftedBit << 1;
524 exponent++;
525 }
526 }
527 /* free old memory */
528 omfree(_columnKey); _columnKey = NULL;
529 _numberOfColumnBlocks = blockIndex + 1;
530 /* allocate memory for new entries in _columnKey; */
531 _columnKey = (unsigned*)omAlloc(_numberOfColumnBlocks*sizeof(unsigned));
532 /* copying values from mk to this MinorKey */
533 for (int c = 0; c < blockIndex; c++)
534 _columnKey[c] = mk.getColumnKey(c);
535 _columnKey[blockIndex] = highestInt;
536}
537
538bool MinorKey::selectNextRows (const int k, const MinorKey& mk)
539{

Callers 1

setNextKeysMethod · 0.80

Calls 1

getColumnKeyMethod · 0.80

Tested by

no test coverage detected