62void MinorKey::set(
const int lengthOfRowArray,
const unsigned int* rowKey,
63 const int lengthOfColumnArray,
64 const unsigned int* columnKey)
85 const unsigned int*
const rowKey,
86 const int lengthOfColumnArray,
87 const unsigned int*
const columnKey)
125 int matchedBits = -1;
132 unsigned int shiftedBit = 1;
138 if (shiftedBit & blockBits) matchedBits++;
140 shiftedBit = shiftedBit << 1;
157 int matchedBits = -1;
164 unsigned int shiftedBit = 1;
170 if (shiftedBit & blockBits) matchedBits++;
172 shiftedBit = shiftedBit << 1;
189 unsigned int shiftedBit = 1;
195 if (shiftedBit & blockBits) target[
i++] =
exponent + (32 *
block);
196 shiftedBit = shiftedBit << 1;
210 unsigned int shiftedBit = 1;
216 if (shiftedBit & blockBits) target[
i++] =
exponent + (32 *
block);
217 shiftedBit = shiftedBit << 1;
231 int matchedBits = -1;
238 unsigned int shiftedBit = 1;
244 if (shiftedBit & blockBits) matchedBits++;
246 shiftedBit = shiftedBit << 1;
263 int matchedBits = -1;
270 unsigned int shiftedBit = 1;
276 if (shiftedBit & blockBits) matchedBits++;
278 shiftedBit = shiftedBit << 1;
308int MinorKey::getSetBits(
const int a)
const
317 for (
int j = 0;
j < 32;
j++)
331 for (
int j = 0;
j < 32;
j++)
344 const int absoluteEraseColumnIndex)
const
346 int rowBlock = absoluteEraseRowIndex / 32;
347 int exponent = absoluteEraseRowIndex % 32;
352 if ((newRowBits == 0) && (rowBlock == highestRowBlock))
356 highestRowBlock -= 1;
359 highestRowBlock -= 1;
364 int columnBlock = absoluteEraseColumnIndex / 32;
365 exponent = absoluteEraseColumnIndex % 32;
370 if ((newColumnBits == 0) && (columnBlock == highestColumnBlock))
374 highestColumnBlock -= 1;
377 highestColumnBlock -= 1;
388 result.setRowKey(rowBlock, newRowBits);
390 result.setColumnKey(columnBlock, newColumnBits);
407 const unsigned int columnKey)
454 return this->
compare(mk) == -1;
462 unsigned int highestInt = 0;
471 unsigned int currentInt = mk.
getRowKey(blockIndex);
472 unsigned int shiftedBit = 1;
477 if (shiftedBit & currentInt)
479 highestInt += shiftedBit;
482 shiftedBit = shiftedBit << 1;
493 for (
int r = 0; r < blockIndex; r++)
495 _rowKey[blockIndex] = highestInt;
503 unsigned int highestInt = 0;
513 unsigned int shiftedBit = 1;
518 if (shiftedBit & currentInt)
520 highestInt += shiftedBit;
523 shiftedBit = shiftedBit << 1;
533 for (
int c = 0; c < blockIndex; c++)
557 int newBitBlockIndex = 0;
558 unsigned int newBitToBeSet = 0;
571 unsigned int currentInt = mk.
getRowKey(mkBlockIndex);
572 unsigned int shiftedBit = 1 << 31;
574 while (hitBits < k && shiftedBit > 0)
576 if ((blockCount - 1 >= mkBlockIndex) &&
577 (shiftedBit & this->
getRowKey(mkBlockIndex))) hitBits++;
578 else if (shiftedBit & currentInt)
580 newBitToBeSet = shiftedBit;
581 newBitBlockIndex = mkBlockIndex;
582 bitCounter = hitBits;
586 shiftedBit = shiftedBit >> 1;
589 if (newBitToBeSet == 0)
605 if (blockCount - 1 < newBitBlockIndex)
619 unsigned int anInt = this->
getRowKey(newBitBlockIndex);
620 unsigned int deleteBit = newBitToBeSet >> 1;
621 while (deleteBit > 0)
623 if (anInt & deleteBit) anInt -= deleteBit;
624 deleteBit = deleteBit >> 1;
626 _rowKey[newBitBlockIndex] = anInt;
629 for (
int i = 0;
i < newBitBlockIndex;
i++)
637 _rowKey[newBitBlockIndex] += newBitToBeSet;
646 while (bitCounter <
k)
649 unsigned int currentInt = mk.
getRowKey(mkBlockIndex);
650 unsigned int shiftedBit = 1;
655 if (shiftedBit & currentInt)
657 _rowKey[mkBlockIndex] += shiftedBit;
660 shiftedBit = shiftedBit << 1;
688 int newBitBlockIndex = 0;
689 unsigned int newBitToBeSet = 0;
702 unsigned int currentInt = mk.
getColumnKey(mkBlockIndex);
703 unsigned int shiftedBit = 1 << 31;
705 while (hitBits < k && shiftedBit > 0)
707 if ((blockCount - 1 >= mkBlockIndex) &&
708 (shiftedBit & this->
getColumnKey(mkBlockIndex))) hitBits++;
709 else if (shiftedBit & currentInt)
711 newBitToBeSet = shiftedBit;
712 newBitBlockIndex = mkBlockIndex;
713 bitCounter = hitBits;
717 shiftedBit = shiftedBit >> 1;
720 if (newBitToBeSet == 0)
737 if (blockCount - 1 < newBitBlockIndex)
751 unsigned int anInt = this->
getColumnKey(newBitBlockIndex);
752 unsigned int deleteBit = newBitToBeSet >> 1;
753 while (deleteBit > 0)
755 if (anInt & deleteBit) anInt -= deleteBit;
756 deleteBit = deleteBit >> 1;
761 for (
int i = 0;
i < newBitBlockIndex;
i++)
767 _columnKey[newBitBlockIndex] += newBitToBeSet;
777 while (bitCounter <
k)
780 unsigned int currentInt = mk.
getColumnKey(mkBlockIndex);
781 unsigned int shiftedBit = 1;
786 if (shiftedBit & currentInt)
791 shiftedBit = shiftedBit << 1;
851 return (
this == &mv);
990 const int accumulatedMultiplications,
991 const int accumulatedAdditions,
992 const int retrievals,
993 const int potentialRetrievals)
1029 bool cacheHasBeenUsed =
true;
1034 s +=
" [retrievals: ";
1035 if (cacheHasBeenUsed) { sprintf(
h,
"%d", this->
getRetrievals()); s +=
h; }
1038 if (cacheHasBeenUsed)
1046 s +=
" (accumulated: ";
1050 s +=
" (accumulated: ";
1053 if (cacheHasBeenUsed) { sprintf(
h,
"%d", this->
getUtility()); s +=
h; }
1071 const int additions,
1072 const int accumulatedMultiplications,
1073 const int accumulatedAdditions,
1074 const int retrievals,
1075 const int potentialRetrievals)
1119 bool cacheHasBeenUsed =
true;
1123 s +=
" [retrievals: ";
1124 if (cacheHasBeenUsed) { sprintf(
h,
"%d", this->
getRetrievals()); s +=
h; }
1127 if (cacheHasBeenUsed)
1135 s +=
" (accumulated: ";
1139 s +=
" (accumulated: ";
1142 if (cacheHasBeenUsed) { sprintf(
h,
"%d", this->
getUtility()); s +=
h; }
Class IntMinorValue is derived from MinorValue and can be used for representing values in a cache for...
int getResult() const
Accessor for the private field _result.
int _result
a store for the actual value of the minor
std::string toString() const
A method for providing a printable version of the represented MinorValue.
int getWeight() const
Accessor for the current weight of this class instance.
virtual ~IntMinorValue()
Destructor.
IntMinorValue()
just to make the compiler happy
Class MinorKey can be used for representing keys in a cache for sub-determinantes; see class Cache.
MinorKey(const int lengthOfRowArray=0, const unsigned int *const rowKey=NULL, const int lengthOfColumnArray=0, const unsigned int *const columnKey=NULL)
A constructor for class MinorKey.
int getNumberOfColumnBlocks() const
Accessor of _numberOfColumnBlocks.
unsigned int getRowKey(const int blockIndex) const
Inlined accessor of blockIndex-th element of _rowKey.
int _numberOfColumnBlocks
the number of ints (i.e.
void getAbsoluteColumnIndices(int *const target) const
A method for retrieving the 0-based indices of all columns encoded in this MinorKey.
void selectFirstRows(const int k, const MinorKey &mk)
This method redefines the set of rows represented by this MinorKey.
bool selectNextColumns(const int k, const MinorKey &mk)
This method redefines the set of columns represented by this MinorKey.
~MinorKey()
A destructor for deleting an instance.
bool operator==(const MinorKey &) const
just to make the compiler happy
bool operator<(const MinorKey &) const
just to make the compiler happy
void reset()
A method for deleting all entries of _rowKey and _columnKey.
unsigned int * _columnKey
a pointer to an array[0..k-1] of ints, capturing k*32 bits for determining which columns of a pre-def...
void selectFirstColumns(const int k, const MinorKey &mk)
This method redefines the set of columns represented by this MinorKey.
MinorKey getSubMinorKey(const int absoluteEraseRowIndex, const int absoluteEraseColumnIndex) const
A method for retrieving a sub-MinorKey resulting from omitting one row and one column of this MinorKe...
void setColumnKey(const int blockIndex, const unsigned int columnKey)
A method for setting the blockIndex-th element of _columnKey.
int getAbsoluteColumnIndex(const int i) const
A method for retrieving the (0-based) index of the i-th column in the set of columns encoded in this.
void set(const int lengthOfRowArray, const unsigned int *rowKey, const int lengthOfColumnArray, const unsigned int *columnKey)
A setter method for class MinorKey.
void getAbsoluteRowIndices(int *const target) const
A method for retrieving the 0-based indices of all rows encoded in this MinorKey.
void setRowKey(const int blockIndex, const unsigned int rowKey)
A method for setting the blockIndex-th element of _rowKey.
int getNumberOfRowBlocks() const
Accessor of _numberOfRowBlocks.
int getRelativeRowIndex(const int i) const
A method for retrieving the (0-based) relative index of the i-th row in this MinorKey.
bool selectNextRows(const int k, const MinorKey &mk)
This method redefines the set of rows represented by this MinorKey.
MinorKey & operator=(const MinorKey &)
just to make the compiler happy
unsigned int * _rowKey
a pointer to an array[0..k-1] of ints, capturing k*32 bits for determining which rows of a pre-define...
int getRelativeColumnIndex(const int i) const
A method for retrieving the (0-based) relative index of the i-th column in this MinorKey.
std::string toString() const
A method for providing a printable version of the represented MinorKey.
int compare(const MinorKey &mk) const
A comparator for two instances of MinorKey.
int getAbsoluteRowIndex(const int i) const
A method for retrieving the (0-based) index of the i-th row in the set of rows encoded in this.
unsigned int getColumnKey(const int blockIndex) const
Accessor of blockIndex-th element of _columnKey.
int _numberOfRowBlocks
the number of ints (i.e.
int getPotentialRetrievals() const
A method for accessing the maximum number of potential retrievals of this minor.
int _additions
a store for the actual number of additions to compute the current minor
int rankMeasure4() const
A method for obtaining a rank measure for the given MinorValue.
int getAdditions() const
A method for accessing the additions performed while computing this minor.
int _potentialRetrievals
-1 iff cache is not used, otherwise the maximum number of potential retrievals of this minor (e....
int _accumulatedMult
a store for the accumulated number of multiplications to compute the current minor; This also include...
int rankMeasure2() const
A method for obtaining a rank measure for the given MinorValue.
int _accumulatedSum
a store for the accumulated number of additions to compute the current minor; This also includes all ...
int getAccumulatedAdditions() const
A method for accessing the additions performed while computing this minor, including all nested addit...
int rankMeasure5() const
A method for obtaining a rank measure for the given MinorValue.
STATIC_VAR int g_rankingStrategy
private store for the current value ranking strategy; This member can be set using MinorValue::SetRan...
int getMultiplications() const
A method for accessing the multiplications performed while computing this minor.
static void SetRankingStrategy(const int rankingStrategy)
A method for determining the value ranking strategy.
void incrementRetrievals()
A method for incrementing the number of performed retrievals of this instance of MinorValue.
bool operator==(const MinorValue &mv) const
just to make the compiler happy
int rankMeasure3() const
A method for obtaining a rank measure for the given MinorValue.
virtual int getWeight() const
A method for retrieving the weight of a given MinorValue.
int _multiplications
a store for the actual number of multiplications to compute the current minor
int getUtility() const
A method for obtaining a rank measure for theiven MinorValue.
int getRetrievals() const
A method for accessing the number of retrievals of this minor.
int rankMeasure1() const
A method for obtaining a rank measure for the given MinorValue.
int _retrievals
-1 iff cache is not used, otherwise the number of retrievals so far of the current minor
virtual std::string toString() const
A method for providing a printable version of the represented MinorValue.
static int GetRankingStrategy()
Accessor for the static private field g_rankingStrategy.
int getAccumulatedMultiplications() const
A method for accessing the multiplications performed while computing this minor, including all nested...
bool operator<(const MinorValue &mv) const
just to make the compiler happy
void print() const
A method for printing a string representation of the given MinorValue to std::cout.
Class PolyMinorValue is derived from MinorValue and can be used for representing values in a cache fo...
PolyMinorValue()
just to make the compiler happy
void operator=(const PolyMinorValue &mv)
Assignment operator which creates a deep copy.
virtual ~PolyMinorValue()
Destructor.
std::string toString() const
A method for providing a printable version of the represented MinorValue.
int getWeight() const
Accessor for the current weight of this class instance.
poly _result
a store for the actual value of the minor
poly getResult() const
Accessor for the private field _result.
const CanonicalForm int s
static int pLength(poly a)
static void p_Delete(poly *p, const ring r)
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Compatibility layer for legacy polynomial operations (over currRing)
#define pCopy(p)
return a copy of the poly
void PrintS(const char *s)