Changeset e2afced in git


Ignore:
Timestamp:
Oct 8, 2009, 12:11:57 PM (14 years ago)
Author:
Frank Seelisch <seelisch@…>
Branches:
(u'spielwiese', '8d54773d6c9e2f1d2593a28bc68b7eeab54ed529')
Children:
0a52b49fcfbb9270ac1d60e85d52e30fd24bbd96
Parents:
967a9d48cc1d702f106bf47d327d87adbaf6833c
Message:
changes due to 32bit vs. 64bit (to make code run on compute servers)


git-svn-id: file:///usr/local/Singular/svn/trunk@12170 2c84dea3-7e68-4137-9b89-c4e89433aadc
Location:
Singular
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • Singular/Cache.h

    r967a9d re2afced  
    9090             list<ValueClass> _value;
    9191             
    92              list<long> _weights;
     92             list<int> _weights;
    9393
    9494             mutable typename list<KeyClass>::const_iterator _itKey;
     
    100100             * i.e., over all cached values.
    101101             */
    102              long _weight;
     102             int _weight;
    103103
    104104             /**
     
    114114             * see Cache::shrink (const KeyClass&) and Cache::deleteLast ().
    115115             */
    116              long _maxWeight;
     116             int _maxWeight;
    117117
    118118             /**
     
    179179             * @param maxWeight the (positive) maximal weight of the cache
    180180             */
    181              Cache (const int maxEntries, const long maxWeight);
     181             Cache (const int maxEntries, const int maxWeight);
    182182
    183183             /**
     
    190190             * @see MinorValue::getWeight () const
    191191             */
    192              long getWeight () const;
     192             int getWeight () const;
    193193
    194194             /**
     
    221221             * @see Cache::Cache (const int, const int)
    222222             */
    223              long getMaxWeight () const;
     223             int getMaxWeight () const;
    224224
    225225             /**
  • Singular/CacheImplementation.h

    r967a9d re2afced  
    55
    66template<class KeyClass, class ValueClass>
    7 Cache<KeyClass, ValueClass>::Cache (const int maxEntries, const long maxWeight) {
     7Cache<KeyClass, ValueClass>::Cache (const int maxEntries, const int maxWeight) {
    88    _maxEntries = maxEntries;
    99    _maxWeight = maxWeight;
     
    1818
    1919template<class KeyClass, class ValueClass>
    20 long Cache<KeyClass, ValueClass>::getWeight() const {
     20int Cache<KeyClass, ValueClass>::getWeight() const {
    2121    return _weight;
    2222}
     
    9191
    9292template<class KeyClass, class ValueClass>
    93 long Cache<KeyClass, ValueClass>::getMaxWeight() const {
     93int Cache<KeyClass, ValueClass>::getMaxWeight() const {
    9494    return _maxWeight;
    9595}
     
    114114    typename list<KeyClass>::iterator itKey;
    115115    typename list<ValueClass>::iterator itValue = _value.begin();
    116     typename list<long>::iterator itWeights = _weights.begin();
     116    typename list<int>::iterator itWeights = _weights.begin();
    117117    for (itKey = _key.begin(); itKey != _key.end(); itKey++) {
    118118        if (k == deleteIndex) {
     
    125125    }
    126126    _key.erase(itKey);
    127     long deleteWeight = *itWeights;
     127    int deleteWeight = *itWeights;
    128128    _value.erase(itValue);
    129129    _weights.erase(itWeights);
     
    151151    typename list<KeyClass>::iterator itKey;
    152152    typename list<ValueClass>::iterator itOldValue = _value.begin(); // will later only be used in the case keyWasContained == true
    153     typename list<long>::iterator itOldWeights = _weights.begin(); // will later only be used in the case keyWasContained == true
     153    typename list<int>::iterator itOldWeights = _weights.begin(); // will later only be used in the case keyWasContained == true
    154154    for (itKey = _key.begin(); itKey != _key.end(); itKey++) {
    155155        int c = key.compare(*itKey);
     
    168168    }
    169169    int utility = value.getUtility();
    170     long newWeight = value.getWeight();
     170    int newWeight = value.getWeight();
    171171    k = 0;
    172172    typename list<ValueClass>::iterator itValue = _value.begin();
     
    266266        // let's insert new key and new value at index newIndexInKey:
    267267        itValue = _value.begin();
    268         typename list<long>::iterator itWeights = _weights.begin();
     268        typename list<int>::iterator itWeights = _weights.begin();
    269269        k = 0;
    270270        for (itKey = _key.begin(); itKey != _key.end(); itKey++) {
     
    299299    sprintf(h, "%d", getMaxNumberOfEntries()); s += h;
    300300    s += "\n   weight: ";
    301     sprintf(h, "%ld", getWeight()); s += h;
     301    sprintf(h, "%d", getWeight()); s += h;
    302302    s += " of at most ";
    303     sprintf(h, "%ld", getMaxWeight()); s += h;
     303    sprintf(h, "%d", getMaxWeight()); s += h;
    304304    if (_key.size() == 0) {
    305305        s += "\n   no pairs, i.e. cache is empty";
  • Singular/Minor.cc

    r967a9d re2afced  
    66#include "polys.h"
    77#include <Minor.h>
     8#include "febase.h"
    89
    910void MinorKey::reset() {
     
    2122
    2223    // allocate memory for new entries in _rowKey and _columnKey;
    23     _rowKey = new unsigned long[_numberOfRowBlocks];
    24     _columnKey = new unsigned long[_numberOfColumnBlocks];
     24    _rowKey = new unsigned int[_numberOfRowBlocks];
     25    _columnKey = new unsigned int[_numberOfColumnBlocks];
    2526
    2627    // copying values from parameter arrays to private arrays
     
    4344
    4445    // allocate memory for new entries in _rowKey and _columnKey;
    45     _rowKey = new unsigned long[_numberOfRowBlocks];
    46     _columnKey = new unsigned long[_numberOfColumnBlocks];
     46    _rowKey = new unsigned int[_numberOfRowBlocks];
     47    _columnKey = new unsigned int[_numberOfColumnBlocks];
    4748
    4849    // copying values from parameter arrays to private arrays
     
    5556}
    5657
    57 void MinorKey::set(const int lengthOfRowArray, const unsigned long* rowKey,
    58                    const int lengthOfColumnArray, const unsigned long* columnKey) {
     58void MinorKey::set(const int lengthOfRowArray, const unsigned int* rowKey,
     59                   const int lengthOfColumnArray, const unsigned int* columnKey) {
    5960    // free memory of _rowKey and _columnKey
    6061    if (_numberOfRowBlocks > 0) { delete [] _rowKey; }
     
    6566
    6667    // allocate memory for new entries in _rowKey and _columnKey;
    67     _rowKey = new unsigned long[_numberOfRowBlocks];
    68     _columnKey = new unsigned long[_numberOfColumnBlocks];
     68    _rowKey = new unsigned int[_numberOfRowBlocks];
     69    _columnKey = new unsigned int[_numberOfColumnBlocks];
    6970
    7071    // copying values from parameter arrays to private arrays
     
    7576}
    7677
    77 MinorKey::MinorKey(const int lengthOfRowArray, const unsigned long* const rowKey,
    78                    const int lengthOfColumnArray, const unsigned long* const columnKey) {
     78MinorKey::MinorKey(const int lengthOfRowArray, const unsigned int* const rowKey,
     79                   const int lengthOfColumnArray, const unsigned int* const columnKey) {
    7980    _numberOfRowBlocks = lengthOfRowArray;
    8081    _numberOfColumnBlocks = lengthOfColumnArray;
    8182
    8283    // allocate memory for new entries in _rowKey and _columnKey;
    83     _rowKey = new unsigned long[_numberOfRowBlocks];
    84     _columnKey = new unsigned long[_numberOfColumnBlocks];
     84    _rowKey = new unsigned int[_numberOfRowBlocks];
     85    _columnKey = new unsigned int[_numberOfColumnBlocks];
    8586
    8687    // copying values from parameter arrays to private arrays
     
    109110    int matchedBits = -1; // counter for matched bits; this needs to reach i, then we're done
    110111    for (int block = 0; block < getNumberOfRowBlocks(); block ++) { // start with lowest bits, i.e. in block No. 0
    111         unsigned long blockBits = getRowKey(block); // the bits in this block of 32 bits
    112         unsigned long shiftedBit = 1;
     112        unsigned int blockBits = getRowKey(block); // the bits in this block of 32 bits
     113        unsigned int shiftedBit = 1;
    113114        int exponent = 0;
    114115        // The invariant "shiftedBit = 2^exponent" will hold throughout the entire while loop.
     
    131132    int matchedBits = -1; // counter for matched bits; this needs to reach i, then we're done
    132133    for (int block = 0; block < getNumberOfColumnBlocks(); block ++) { // start with lowest bits, i.e. in block No. 0
    133         unsigned long blockBits = getColumnKey(block); // the bits in this block of 32 bits
    134         unsigned long shiftedBit = 1;
     134        unsigned int blockBits = getColumnKey(block); // the bits in this block of 32 bits
     135        unsigned int shiftedBit = 1;
    135136        int exponent = 0;
    136137        // The invariant "shiftedBit = 2^exponent" will hold throughout the entire while loop.
     
    149150    int i = 0; // index for filling the target array
    150151    for (int block = 0; block < getNumberOfRowBlocks(); block ++) { // start with lowest bits, i.e. in block No. 0
    151         unsigned long blockBits = getRowKey(block); // the bits in this block of 32 bits
    152         unsigned long shiftedBit = 1;
     152        unsigned int blockBits = getRowKey(block); // the bits in this block of 32 bits
     153        unsigned int shiftedBit = 1;
    153154        int exponent = 0;
    154155        // The invariant "shiftedBit = 2^exponent" will hold throughout the entire while loop.
     
    165166    int i = 0; // index for filling the target array
    166167    for (int block = 0; block < getNumberOfColumnBlocks(); block ++) { // start with lowest bits, i.e. in block No. 0
    167         unsigned long blockBits = getColumnKey(block); // the bits in this block of 32 bits
    168         unsigned long shiftedBit = 1;
     168        unsigned int blockBits = getColumnKey(block); // the bits in this block of 32 bits
     169        unsigned int shiftedBit = 1;
    169170        int exponent = 0;
    170171        // The invariant "shiftedBit = 2^exponent" will hold throughout the entire while loop.
     
    186187    int matchedBits = -1; // counter for matched bits; this is going to contain our return value
    187188    for (int block = 0; block < getNumberOfRowBlocks(); block ++) { // start with lowest bits, i.e. in block No. 0
    188         unsigned long blockBits = getRowKey(block); // the bits in this block of 32 bits
    189         unsigned long shiftedBit = 1;
     189        unsigned int blockBits = getRowKey(block); // the bits in this block of 32 bits
     190        unsigned int shiftedBit = 1;
    190191        int exponent = 0;
    191192        // The invariant "shiftedBit = 2^exponent" will hold throughout the entire while loop.
     
    209210    int matchedBits = -1; // counter for matched bits; this is going to contain our return value
    210211    for (int block = 0; block < getNumberOfColumnBlocks(); block ++) { // start with lowest bits, i.e. in block No. 0
    211         unsigned long blockBits = getColumnKey(block); // the bits in this block of 32 bits
    212         unsigned long shiftedBit = 1;
     212        unsigned int blockBits = getColumnKey(block); // the bits in this block of 32 bits
     213        unsigned int shiftedBit = 1;
    213214        int exponent = 0;
    214215        // The invariant "shiftedBit = 2^exponent" will hold throughout the entire while loop.
     
    224225}
    225226
    226 unsigned long MinorKey::getRowKey(const int blockIndex) const {
     227unsigned int MinorKey::getRowKey(const int blockIndex) const {
    227228    return _rowKey[blockIndex];
    228229}
    229230
    230 unsigned long MinorKey::getColumnKey(const int blockIndex) const {
     231unsigned int MinorKey::getColumnKey(const int blockIndex) const {
    231232    return _columnKey[blockIndex];
    232233}
     
    244245    if (a == 1) { // rows
    245246        for (int i = 0; i < _numberOfRowBlocks; i++) {
    246             unsigned long m = _rowKey[i];
    247             unsigned long k = 1;
     247            unsigned int m = _rowKey[i];
     248            unsigned int k = 1;
    248249            for (int j = 0; j < 32; j++) {
    249250                // k = 2^j
     
    255256    else { // columns
    256257        for (int i = 0; i < _numberOfColumnBlocks; i++) {
    257             unsigned long m = _columnKey[i];
    258             unsigned long k = 1;
     258            unsigned int m = _columnKey[i];
     259            unsigned int k = 1;
    259260            for (int j = 0; j < 32; j++) {
    260261                // k = 2^j
     
    271272    int rowBlock = absoluteEraseRowIndex / 32;
    272273    int exponent = absoluteEraseRowIndex % 32;
    273     unsigned long newRowBits = getRowKey(rowBlock) - (1 << exponent);
     274    unsigned int newRowBits = getRowKey(rowBlock) - (1 << exponent);
    274275    int highestRowBlock = getNumberOfRowBlocks() - 1;
    275276    // highestRowBlock will finally contain the highest block index with non-zero bit pattern
     
    285286    int columnBlock = absoluteEraseColumnIndex / 32;
    286287    exponent = absoluteEraseColumnIndex % 32;
    287     unsigned long newColumnBits = getColumnKey(columnBlock) - (1 << exponent);
     288    unsigned int newColumnBits = getColumnKey(columnBlock) - (1 << exponent);
    288289    int highestColumnBlock = getNumberOfColumnBlocks() - 1;
    289290    // highestColumnBlock will finally contain the highest block index with non-zero bit pattern
     
    318319}
    319320
    320 void MinorKey::setRowKey (const int blockIndex, const unsigned long rowKey) {
     321void MinorKey::setRowKey (const int blockIndex, const unsigned int rowKey) {
    321322    _rowKey[blockIndex] = rowKey;
    322323}
    323324
    324 void MinorKey::setColumnKey (const int blockIndex, const unsigned long columnKey) {
     325void MinorKey::setColumnKey (const int blockIndex, const unsigned int columnKey) {
    325326    _columnKey[blockIndex] = columnKey;
    326327}
     
    369370    int hitBits = 0;      // the number of bits we have hit; in the end, this has to be equal to k,
    370371                          // the dimension of the minor
    371     int blockIndex = -1;  // the index of the current long in mk
    372     unsigned long highestLong = 0;  // the new highest block of this MinorKey
    373     // We determine which longs of mk we can copy. Their indices will be 0, 1, ..., blockIndex - 1.
    374     // And highestLong is going to capture the highest long (which may be only a portion of
    375     // the corresponding long in mk. We loop until hitBits = k:
     372    int blockIndex = -1;  // the index of the current int in mk
     373    unsigned int highestInt = 0;  // the new highest block of this MinorKey
     374    // We determine which ints of mk we can copy. Their indices will be 0, 1, ..., blockIndex - 1.
     375    // And highestInt is going to capture the highest int (which may be only a portion of
     376    // the corresponding int in mk. We loop until hitBits = k:
    376377    while (hitBits < k) {
    377378        blockIndex++;
    378         highestLong = 0;
    379         unsigned long currentLong = mk.getRowKey(blockIndex);
    380         unsigned long shiftedBit = 1;
     379        highestInt = 0;
     380        unsigned int currentInt = mk.getRowKey(blockIndex);
     381        unsigned int shiftedBit = 1;
    381382        int exponent = 0;
    382383        // invariant in the loop: shiftedBit = 2^exponent
    383384        while (exponent < 32 && hitBits < k) {
    384             if (shiftedBit & currentLong) {
    385                 highestLong += shiftedBit;
     385            if (shiftedBit & currentInt) {
     386                highestInt += shiftedBit;
    386387                hitBits++;
    387388            }
     
    394395    _numberOfRowBlocks = blockIndex + 1;
    395396    // allocate memory for new entries in _rowKey;
    396     _rowKey = new unsigned long[_numberOfRowBlocks];
     397    _rowKey = new unsigned int[_numberOfRowBlocks];
    397398    // copying values from mk to this MinorKey
    398399    for (int r = 0; r < blockIndex; r++)
    399400        _rowKey[r] = mk.getRowKey(r);
    400     _rowKey[blockIndex] = highestLong;
     401    _rowKey[blockIndex] = highestInt;
    401402}
    402403
     
    404405    int hitBits = 0;      // the number of bits we have hit; in the end, this has to be equal to k,
    405406                          // the dimension of the minor
    406     int blockIndex = -1;  // the index of the current long in mk
    407     unsigned long highestLong = 0;  // the new highest block of this MinorKey
    408     // We determine which longs of mk we can copy. Their indices will be 0, 1, ..., blockIndex - 1.
    409     // And highestLong is going to capture the highest long (which may be only a portion of
    410     // the corresponding long in mk. We loop until hitBits = k:
     407    int blockIndex = -1;  // the index of the current int in mk
     408    unsigned int highestInt = 0;  // the new highest block of this MinorKey
     409    // We determine which ints of mk we can copy. Their indices will be 0, 1, ..., blockIndex - 1.
     410    // And highestInt is going to capture the highest int (which may be only a portion of
     411    // the corresponding int in mk. We loop until hitBits = k:
    411412    while (hitBits < k) {
    412413        blockIndex++;
    413         highestLong = 0;
    414         unsigned long currentLong = mk.getColumnKey(blockIndex);
    415         unsigned long shiftedBit = 1;
     414        highestInt = 0;
     415        unsigned int currentInt = mk.getColumnKey(blockIndex);
     416        unsigned int shiftedBit = 1;
    416417        int exponent = 0;
    417418        // invariant in the loop: shiftedBit = 2^exponent
    418419        while (exponent < 32 && hitBits < k) {
    419             if (shiftedBit & currentLong) {
    420                 highestLong += shiftedBit;
     420            if (shiftedBit & currentInt) {
     421                highestInt += shiftedBit;
    421422                hitBits++;
    422423            }
     
    429430    _numberOfColumnBlocks = blockIndex + 1;
    430431    // allocate memory for new entries in _columnKey;
    431     _columnKey = new unsigned long[_numberOfColumnBlocks];
     432    _columnKey = new unsigned int[_numberOfColumnBlocks];
    432433    // copying values from mk to this MinorKey
    433434    for (int c = 0; c < blockIndex; c++)
    434435        _columnKey[c] = mk.getColumnKey(c);
    435     _columnKey[blockIndex] = highestLong;
     436    _columnKey[blockIndex] = highestInt;
    436437}
    437438
     
    453454    // In this case, the method will return false; otherwise always true.
    454455    int newBitBlockIndex = 0;         // the block index of the bit
    455     unsigned long newBitToBeSet = 0;  // the bit as 2^e, where 0 <= e <= 31
    456 
    457     int blockCount = this->getNumberOfRowBlocks();  // number of longs (representing rows) in this MinorKey
     456    unsigned int newBitToBeSet = 0;  // the bit as 2^e, where 0 <= e <= 31
     457
     458    int blockCount = this->getNumberOfRowBlocks();  // number of ints (representing rows) in this MinorKey
    458459    int mkBlockIndex = mk.getNumberOfRowBlocks();   // for iterating along the blocks of mk
    459460
     
    463464    while (hitBits < k) {
    464465        mkBlockIndex--;
    465         unsigned long currentLong = mk.getRowKey(mkBlockIndex);
    466         unsigned long shiftedBit = 1 << 31; // initially, this equals 2^31, i.e. the highest bit
     466        unsigned int currentInt = mk.getRowKey(mkBlockIndex);
     467        unsigned int shiftedBit = 1 << 31; // initially, this equals 2^31, i.e. the highest bit
    467468        while (hitBits < k && shiftedBit > 0) {
    468             if (blockCount - 1 >= mkBlockIndex &&
    469                 shiftedBit & this->getRowKey(mkBlockIndex)) hitBits++;
    470             else if (shiftedBit & currentLong) {
     469            if ((blockCount - 1 >= mkBlockIndex) &&
     470                (shiftedBit & this->getRowKey(mkBlockIndex))) hitBits++;
     471            else if (shiftedBit & currentInt) {
    471472                newBitToBeSet = shiftedBit;
    472473                newBitBlockIndex = mkBlockIndex;
     
    496497            _numberOfRowBlocks = newBitBlockIndex + 1;
    497498            // allocate memory for new entries in _rowKey;
    498             _rowKey = new unsigned long[_numberOfRowBlocks];
     499            _rowKey = new unsigned int[_numberOfRowBlocks];
    499500        }
    500501        else {
    501502            // We need to delete all bits in _rowKey[newBitBlockIndex] that are below newBitToBeSet:
    502             unsigned long aLong = this->getRowKey(newBitBlockIndex);
    503             unsigned long deleteBit = newBitToBeSet >> 1; // in example: = 2^5
     503            unsigned int anInt = this->getRowKey(newBitBlockIndex);
     504            unsigned int deleteBit = newBitToBeSet >> 1; // in example: = 2^5
    504505            while (deleteBit > 0) {
    505                 if (aLong & deleteBit) aLong -= deleteBit;
     506                if (anInt & deleteBit) anInt -= deleteBit;
    506507                deleteBit = deleteBit >> 1;
    507508            };
    508             _rowKey[newBitBlockIndex] = aLong;
     509            _rowKey[newBitBlockIndex] = anInt;
    509510            // ...and we delete all entries in _rowKey[i] for 0 <= i < newBitBlockIndex
    510511            for (int i = 0; i < newBitBlockIndex; i++)
     
    525526        while (bitCounter < k) {
    526527            mkBlockIndex++;
    527             unsigned long currentLong = mk.getRowKey(mkBlockIndex);
    528             unsigned long shiftedBit = 1;
     528            unsigned int currentInt = mk.getRowKey(mkBlockIndex);
     529            unsigned int shiftedBit = 1;
    529530            int exponent = 0;
    530531            // invariant: shiftedBit = 2^exponent
    531532            while (bitCounter < k && exponent < 32) {
    532                 if (shiftedBit & currentLong) {
     533                if (shiftedBit & currentInt) {
    533534                    _rowKey[mkBlockIndex] += shiftedBit;
    534535                    bitCounter++;
     
    561562    // In this case, the method will return false; otherwise always true.
    562563    int newBitBlockIndex = 0;         // the block index of the bit
    563     unsigned long newBitToBeSet = 0;  // the bit as 2^e, where 0 <= e <= 31
    564 
    565     int blockCount = this->getNumberOfColumnBlocks();  // number of longs (representing columns) in this MinorKey
     564    unsigned int newBitToBeSet = 0;  // the bit as 2^e, where 0 <= e <= 31
     565
     566    int blockCount = this->getNumberOfColumnBlocks();  // number of ints (representing columns) in this MinorKey
    566567    int mkBlockIndex = mk.getNumberOfColumnBlocks();   // for iterating along the blocks of mk
    567568
     
    571572    while (hitBits < k) {
    572573        mkBlockIndex--;
    573         unsigned long currentLong = mk.getColumnKey(mkBlockIndex);
    574         unsigned long shiftedBit = 1 << 31; // initially, this equals 2^31, i.e. the highest bit
     574        unsigned int currentInt = mk.getColumnKey(mkBlockIndex);
     575        unsigned int shiftedBit = 1 << 31; // initially, this equals 2^31, i.e. the highest bit
    575576        while (hitBits < k && shiftedBit > 0) {
    576             if (blockCount - 1 >= mkBlockIndex &&
    577                 shiftedBit & this->getColumnKey(mkBlockIndex)) hitBits++;
    578             else if (shiftedBit & currentLong) {
     577            if ((blockCount - 1 >= mkBlockIndex) &&
     578                (shiftedBit & this->getColumnKey(mkBlockIndex))) hitBits++;
     579            else if (shiftedBit & currentInt) {
    579580                newBitToBeSet = shiftedBit;
    580581                newBitBlockIndex = mkBlockIndex;
     
    583584            }
    584585            shiftedBit = shiftedBit >> 1;
    585         }
     586        }                                           
    586587    }
    587588
     
    604605            _numberOfColumnBlocks = newBitBlockIndex + 1;
    605606            // allocate memory for new entries in _columnKey;
    606             _columnKey = new unsigned long[_numberOfColumnBlocks];
     607            _columnKey = new unsigned int[_numberOfColumnBlocks];
    607608        }
    608609        else {
    609610            // We need to delete all bits in _columnKey[newBitBlockIndex] that are below newBitToBeSet:
    610             unsigned long aLong = this->getColumnKey(newBitBlockIndex);
    611             unsigned long deleteBit = newBitToBeSet >> 1; // in example: = 2^5
     611            unsigned int anInt = this->getColumnKey(newBitBlockIndex);
     612            unsigned int deleteBit = newBitToBeSet >> 1; // in example: = 2^5
    612613            while (deleteBit > 0) {
    613                 if (aLong & deleteBit) aLong -= deleteBit;
     614                if (anInt & deleteBit) anInt -= deleteBit;
    614615                deleteBit = deleteBit >> 1;
    615616            };
    616             _columnKey[newBitBlockIndex] = aLong;
     617            _columnKey[newBitBlockIndex] = anInt;
    617618            // ...and we delete all entries in _columnKey[i] for 0 <= i < newBitBlockIndex
    618619            for (int i = 0; i < newBitBlockIndex; i++)
     
    633634        while (bitCounter < k) {
    634635            mkBlockIndex++;
    635             unsigned long currentLong = mk.getColumnKey(mkBlockIndex);
    636             unsigned long shiftedBit = 1;
     636            unsigned int currentInt = mk.getColumnKey(mkBlockIndex);
     637            unsigned int shiftedBit = 1;
    637638            int exponent = 0;
    638639            // invariant: shiftedBit = 2^exponent
    639640            while (bitCounter < k && exponent < 32) {
    640                 if (shiftedBit & currentLong) {
     641                if (shiftedBit & currentInt) {
    641642                    _columnKey[mkBlockIndex] += shiftedBit;
    642643                    bitCounter++;
     
    657658    string s = "(";
    658659    for (int r = this->getNumberOfRowBlocks() - 1; r >= 0; r--) {
    659         sprintf(h, "%ld", this->getRowKey(r)); t += h;
     660        sprintf(h, "%du", this->getRowKey(r)); t += h;
    660661        if (r < this->getNumberOfRowBlocks() - 1)
    661662            t = string(32 - t.length(), '0') + t;
     
    664665    s += ", ";
    665666    for (int c = this->getNumberOfColumnBlocks() - 1; c >= 0; c--) {
    666         sprintf(h, "%ld", this->getColumnKey(c)); t += h;
     667        sprintf(h, "%du", this->getColumnKey(c)); t += h;
    667668        if (c < this->getNumberOfColumnBlocks() - 1)
    668669            t = string(32 - t.length(), '0') + t;
     
    675676int MinorValue::_RankingStrategy = -1;
    676677
    677 long MinorValue::getWeight () const
     678int MinorValue::getWeight () const
    678679{
    679680  assert(false);  // must be overridden in derived classes
     
    701702}
    702703
    703 long MinorValue::getRetrievals() const {
     704int MinorValue::getRetrievals() const {
    704705    return _retrievals;
    705706}
     
    709710}
    710711
    711 long MinorValue::getPotentialRetrievals() const {
     712int MinorValue::getPotentialRetrievals() const {
    712713    return _potentialRetrievals;
    713714}
    714715
    715 long MinorValue::getMultiplications() const {
     716int MinorValue::getMultiplications() const {
    716717    return _multiplications;
    717718}
    718719
    719 long MinorValue::getAdditions() const {
     720int MinorValue::getAdditions() const {
    720721    return _additions;
    721722}
    722723
    723 long MinorValue::getAccumulatedMultiplications() const {
     724int MinorValue::getAccumulatedMultiplications() const {
    724725    return _accumulatedMult;
    725726}
    726727
    727 long MinorValue::getAccumulatedAdditions() const {
     728int MinorValue::getAccumulatedAdditions() const {
    728729    return _accumulatedSum;
    729730}
     
    789790}
    790791
    791 long LongMinorValue::getWeight () const {
     792int IntMinorValue::getWeight () const {
    792793    // put measure for size of MinorValue here, i.e. number of monomials in polynomial;
    793794    // so far, we use the accumulated number of multiplications (i.e., including all nested ones)
     
    796797}
    797798
    798 LongMinorValue::LongMinorValue (const long result, const int multiplications, const int additions,
     799IntMinorValue::IntMinorValue (const int result, const int multiplications, const int additions,
    799800                                const int accumulatedMultiplications, const int accumulatedAdditions,
    800801                                const int retrievals, const int potentialRetrievals) {
     
    808809}
    809810
    810 LongMinorValue::LongMinorValue () {
     811IntMinorValue::IntMinorValue () {
    811812    _result = -1;
    812813    _multiplications = -1;
     
    818819}
    819820
    820 LongMinorValue::~LongMinorValue()
     821IntMinorValue::~IntMinorValue()
    821822{
    822823}
    823824
    824 long LongMinorValue::getResult() const {
     825int IntMinorValue::getResult() const {
    825826    return _result;
    826827}
    827828
    828 string LongMinorValue::toString () const {
     829string IntMinorValue::toString () const {
    829830    char h[10];
    830831
     
    833834    if (this->getRetrievals() == -1) cacheHasBeenUsed = false;
    834835
    835     sprintf(h, "%ld", this->getResult());
     836    sprintf(h, "%d", this->getResult());
    836837    string s = h;
    837838    s += " [retrievals: ";
    838     if (cacheHasBeenUsed) { sprintf(h, "%ld", this->getRetrievals()); s += h; }
     839    if (cacheHasBeenUsed) { sprintf(h, "%d", this->getRetrievals()); s += h; }
    839840    else s += "/";
    840841    s += " (of ";
    841     if (cacheHasBeenUsed) { sprintf(h, "%ld", this->getPotentialRetrievals()); s += h; }
     842    if (cacheHasBeenUsed) { sprintf(h, "%d", this->getPotentialRetrievals()); s += h; }
    842843    else s += "/";
    843844    s += "), *: ";
    844     sprintf(h, "%ld", this->getMultiplications()); s += h;
     845    sprintf(h, "%d", this->getMultiplications()); s += h;
    845846    s += " (accumulated: ";
    846     sprintf(h, "%ld", this->getAccumulatedMultiplications()); s += h;
     847    sprintf(h, "%d", this->getAccumulatedMultiplications()); s += h;
    847848    s += "), +: ";
    848     sprintf(h, "%ld", this->getAdditions()); s += h;
     849    sprintf(h, "%d", this->getAdditions()); s += h;
    849850    s += " (accumulated: ";
    850     sprintf(h, "%ld", this->getAccumulatedAdditions()); s += h;
     851    sprintf(h, "%d", this->getAccumulatedAdditions()); s += h;
    851852    s += "), rank: ";
    852853    if (cacheHasBeenUsed) { sprintf(h, "%d", this->getUtility()); s += h; }
     
    856857}
    857858
    858 LongMinorValue::LongMinorValue (const LongMinorValue& mv) {
     859IntMinorValue::IntMinorValue (const IntMinorValue& mv) {
    859860    _result = mv.getResult();
    860861    _retrievals = mv.getRetrievals();
     
    899900}
    900901
    901 long PolyMinorValue::getWeight () const {
     902int PolyMinorValue::getWeight () const {
    902903    // put measure for size of PolyMinorValue here, e.g. the number of monomials
    903904    // the cached polynomial
     
    914915    string s = pString(_result);
    915916    s += " [retrievals: ";
    916     if (cacheHasBeenUsed) { sprintf(h, "%ld", this->getRetrievals()); s += h; }
     917    if (cacheHasBeenUsed) { sprintf(h, "%d", this->getRetrievals()); s += h; }
    917918    else s += "/";
    918919    s += " (of ";
    919     if (cacheHasBeenUsed) { sprintf(h, "%ld", this->getPotentialRetrievals()); s += h; }
     920    if (cacheHasBeenUsed) { sprintf(h, "%d", this->getPotentialRetrievals()); s += h; }
    920921    else s += "/";
    921922    s += "), *: ";
    922     sprintf(h, "%ld", this->getMultiplications()); s += h;
     923    sprintf(h, "%d", this->getMultiplications()); s += h;
    923924    s += " (accumulated: ";
    924     sprintf(h, "%ld", this->getAccumulatedMultiplications()); s += h;
     925    sprintf(h, "%d", this->getAccumulatedMultiplications()); s += h;
    925926    s += "), +: ";
    926     sprintf(h, "%ld", this->getAdditions()); s += h;
     927    sprintf(h, "%d", this->getAdditions()); s += h;
    927928    s += " (accumulated: ";
    928     sprintf(h, "%ld", this->getAccumulatedAdditions()); s += h;
     929    sprintf(h, "%d", this->getAccumulatedAdditions()); s += h;
    929930    s += "), rank: ";
    930931    if (cacheHasBeenUsed) { sprintf(h, "%d", this->getUtility()); s += h; }
  • Singular/Minor.h

    r967a9d re2afced  
    1919    <c>bool MinorKey::operator< (const MinorKey& key),</c><br>
    2020    <c>bool MinorKey::operator== (const MinorKey& key),</c><br>
    21     MinorKey uses two private arrays of unsigned longs \c _rowKey and \c _columnKey to encode rows and
     21    MinorKey uses two private arrays of ints \c _rowKey and \c _columnKey to encode rows and
    2222    columns of a pre-defined matrix. Semantically, the row indices and column indices form the key
    2323    for caching the value of the corresponding minor.<br>
    2424    More concretely, let us assume that the pre-defined matrix has <em>32*R+r, r<32,</em> rows and
    25     <em>32*C+c, c<32,</em> columns. All row indices can then be captured using R+1 unsigned longs, since
    26     a long is a 32-bit-number. The analog holds for the columns. Consequently, each instance of MinorKey
     25    <em>32*C+c, c<32,</em> columns. All row indices can then be captured using R+1 ints, since
     26    an int is a 32-bit-number (regardless of the platform). The analog holds for the columns. Consequently, each instance of MinorKey
    2727    encodes the sets of rows and columns which shall belong to the minor of interest (and which shall not).<br>
    2828    Example: The \c _rowKey with \c _rowKey[1] = 0...011 and \c _rowKey[0] = 0...01101 encodes the rows with
     
    3333      private:
    3434             /**
    35              * a pointer to an array[0..k-1] of longs, capturing k*32 bits for determining which
     35             * a pointer to an array[0..k-1] of ints, capturing k*32 bits for determining which
    3636             * rows of a pre-defined matrix shall belong to the minor of interest;
    3737             * for i < j, _rowKey[i] holds lower bits than _rowKey[j]
    3838             */
    39              unsigned long* _rowKey;
    40 
    41              /**
    42              * a pointer to an array[0..k-1] of longs, capturing k*32 bits for determining which
     39             unsigned int* _rowKey;
     40
     41             /**
     42             * a pointer to an array[0..k-1] of ints, capturing k*32 bits for determining which
    4343             * columns of a pre-defined matrix shall belong to the minor of interest;
    4444             * for i < j, _columnKey[i] holds lower bits than _columnKey[j]
    4545             */
    46              unsigned long* _columnKey;
    47 
    48              /**
    49              * the number of unsigned longs (i.e. 32-bit-numbers) we need to encode the set of rows;
     46             unsigned int* _columnKey;
     47
     48             /**
     49             * the number of ints (i.e. 32-bit-numbers) we need to encode the set of rows;
    5050             * If the higest row index is 70, we need 3 blocks of 32 bits to also encode the 70th bit.
    5151             */
     
    5353
    5454             /**
    55              * the number of unsigned longs (i.e. 32-bit-numbers) we need to encode the set of columns;
     55             * the number of ints (i.e. 32-bit-numbers) we need to encode the set of columns;
    5656             * If the higest column index is 70, we need 3 blocks of 32 bits to also encode the 70th bit.
    5757             */
     
    6060             /**
    6161             * Inlined accessor of blockIndex-th element of _rowKey.
    62              * @param blockIndex the index of the long to be retrieved
     62             * @param blockIndex the index of the int to be retrieved
    6363             * @return an entry of _rowKey
    6464             */
    65              unsigned long getRowKey (const int blockIndex) const;
     65             unsigned int getRowKey (const int blockIndex) const;
    6666
    6767             /**
    6868             * Inlined accessor of blockIndex-th element of _columnKey.
    69              * @param blockIndex the index of the long to be retrieved
     69             * @param blockIndex the index of the int to be retrieved
    7070             * @return an entry of _columnKey
    7171             */
    72              unsigned long getColumnKey (const int blockIndex) const;
    73 
    74              void setRowKey (const int blockIndex, const unsigned long rowKey);
    75 
    76              void setColumnKey (const int blockIndex, const unsigned long columnKey);
     72             unsigned int getColumnKey (const int blockIndex) const;
     73
     74             void setRowKey (const int blockIndex, const unsigned int rowKey);
     75
     76             void setColumnKey (const int blockIndex, const unsigned int columnKey);
    7777
    7878             /**
     
    9797             /**
    9898             * A constructor for class MinorKey.
    99              * The longs given in the array rowKey encode all rows which shall belong to the minor.
     99             * The ints given in the array rowKey encode all rows which shall belong to the minor.
    100100             * Each array entry encodes 32 rows, e.g. the i-th array entry 0...01101 encodes the rows with
    101101             * absolute matrix row indices 3+i*32, 2+i*32, and 0+i*32. Analog for columns.
    102102             * @param lengthOfRowArray the length of the array rowKey
    103              * @param rowKey a pointer to an array of longs encoding the set of rows of the minor
     103             * @param rowKey a pointer to an array of ints encoding the set of rows of the minor
    104104             * @param lengthOfColumnArray the length of the array columnKey
    105              * @param columnKey a pointer to an array of longs encoding the set of columns of the minor
    106              */
    107              MinorKey (const int lengthOfRowArray = 0, const unsigned long* const rowKey = 0,
    108                        const int lengthOfColumnArray = 0, const unsigned long* const columnKey = 0);
     105             * @param columnKey a pointer to an array of ints encoding the set of columns of the minor
     106             */
     107             MinorKey (const int lengthOfRowArray = 0, const unsigned int* const rowKey = 0,
     108                       const int lengthOfColumnArray = 0, const unsigned int* const columnKey = 0);
    109109
    110110             /**
     
    114114             * instance of MinorKey.
    115115             * @param lengthOfRowArray the length of the array rowKey
    116              * @param rowKey a pointer to an array of longs encoding the set of rows of the minor
     116             * @param rowKey a pointer to an array of ints encoding the set of rows of the minor
    117117             * @param lengthOfColumnArray the length of the array columnKey
    118              * @param columnKey a pointer to an array of longs encoding the set of columns of the minor
    119              * @see MinorKey::MinorKey (const int lengthOfRowArray, const unsigned long* rowKey, const int lengthOfColumnArray, const unsigned long* columnKey)
    120              */
    121              void set(const int lengthOfRowArray, const unsigned long* rowKey,
    122                       const int lengthOfColumnArray, const unsigned long* columnKey);
     118             * @param columnKey a pointer to an array of ints encoding the set of columns of the minor
     119             * @see MinorKey::MinorKey (const int lengthOfRowArray, const int* rowKey, const int lengthOfColumnArray, const int* columnKey)
     120             */
     121             void set(const int lengthOfRowArray, const unsigned int* rowKey,
     122                      const int lengthOfColumnArray, const unsigned int* columnKey);
    123123
    124124             /**
     
    330330             * -1 iff cache is not used, otherwise the number of retrievals so far of the current minor
    331331             */
    332              long _retrievals;
     332             int _retrievals;
    333333
    334334             /**
     
    336336             * this minor (e.g. when the minor would be kept in cache forever)
    337337             */
    338              long _potentialRetrievals;
     338             int _potentialRetrievals;
    339339
    340340             /**
    341341             * a store for the actual number of multiplications to compute the current minor
    342342             */
    343              long _multiplications;
     343             int _multiplications;
    344344
    345345             /**
    346346             * a store for the actual number of additions to compute the current minor
    347347             */
    348              long _additions;
     348             int _additions;
    349349
    350350             /**
     
    353353             * from a cache. (Thus, these nested operations do not need to be performed again.)
    354354             */
    355              long _accumulatedMult;
     355             int _accumulatedMult;
    356356
    357357             /**
     
    360360             * from a cache. (Thus, these nested operations do not need to be performed again.)
    361361             */
    362              long _accumulatedSum;
     362             int _accumulatedSum;
    363363
    364364             /**
     
    459459             * @see Cache::getWeight () const
    460460             */
    461              virtual long getWeight () const;
     461             virtual int getWeight () const;
    462462
    463463             /**
     
    468468             * @see MinorValue::getPotentialRetrievals () const
    469469             */
    470              long getRetrievals () const;
     470             int getRetrievals () const;
    471471
    472472             /**
     
    478478             * @see MinorValue::getRetrievals () const
    479479             */
    480              long getPotentialRetrievals () const;
     480             int getPotentialRetrievals () const;
    481481
    482482             /**
     
    490490             * @see MinorValue::getAccumulatedMultiplications () const
    491491             */
    492              long getMultiplications () const;
     492             int getMultiplications () const;
    493493
    494494             /**
     
    501501             * @see MinorValue::getMultiplications () const
    502502             */
    503              long getAccumulatedMultiplications () const;
     503             int getAccumulatedMultiplications () const;
    504504
    505505             /**
     
    510510             * @see MinorValue::getAccumulatedAdditions () const
    511511             */
    512              long getAdditions () const;
     512             int getAdditions () const;
    513513
    514514             /**
     
    521521             * @see MinorValue::getAdditions () const
    522522             */
    523              long getAccumulatedAdditions () const;
     523             int getAccumulatedAdditions () const;
    524524
    525525             /**
     
    572572};
    573573
    574 /*! \class LongMinorValue
    575     \brief Class LongMinorValue can be used for representing values in a cache for
     574/*! \class IntMinorValue
     575    \brief Class IntMinorValue can be used for representing values in a cache for
    576576    sub-determinantes; see class Cache.
    577577
     
    579579    the declaration of class Cache. Following the documentation of class Cache, we
    580580    need to implement at least the methods:<br>
    581     <c>bool LongMinorValue::operator< (const LongMinorValue& key),</c><br>
    582     <c>bool LongMinorValue::operator== (const LongMinorValue& key),</c><br>
    583     <c>int LongMinorValue::getWeight ().</c><br><br>
    584     The main purpose of LongMinorValue is to represent values of sub-determinantes of a pre-defined
     581    <c>bool IntMinorValue::operator< (const IntMinorValue& key),</c><br>
     582    <c>bool IntMinorValue::operator== (const IntMinorValue& key),</c><br>
     583    <c>int IntMinorValue::getWeight ().</c><br><br>
     584    The main purpose of IntMinorValue is to represent values of sub-determinantes of a pre-defined
    585585    matrix. Class MinorKey is used to determine which rows and columns of this pre-defined matrix
    586     ought to belong to the respective sub-determinante of interest. So far, LongMinorValue is just
    587     an example implementation which assumes matrices with long entries, such that the result
    588     of any minor is a long again.<br>
    589     Besides capturing the actual value of a minor, LongMinorValue also has built-in facilities to
     586    ought to belong to the respective sub-determinante of interest. So far, IntMinorValue is just
     587    an example implementation which assumes matrices with int entries, such that the result
     588    of any minor is again an int.<br>
     589    Besides capturing the actual value of a minor, IntMinorValue also has built-in facilities to
    590590    count the number of additions and multiplications performed when computing a minor. These two
    591591    counters, especially the latter, are important measures when we want to investigate the complexity
     
    596596    \author Frank Seelisch, http://www.mathematik.uni-kl.de/~seelisch
    597597*/
    598 class LongMinorValue : public MinorValue {
     598class IntMinorValue : public MinorValue {
    599599      private:
    600600             /**
    601601             * a store for the actual value of the minor
    602602             */
    603              long _result;
     603             int _result;
    604604      public:
    605605             /**
     
    613613             * @param potentialRetrievals maximum number of times this minor may be retrieved from cache
    614614             */
    615              LongMinorValue (const long result, const int multiplications, const int additions,
     615             IntMinorValue (const int result, const int multiplications, const int additions,
    616616                             const int accumulatedMultiplications, const int accumulatedAdditions,
    617617                             const int retrievals, const int potentialRetrievals);
    618618
    619              LongMinorValue (const LongMinorValue& mv);
     619             IntMinorValue (const IntMinorValue& mv);
    620620             
    621621             // just to make the compiler happy
    622              LongMinorValue ();
     622             IntMinorValue ();
    623623             
    624              virtual ~LongMinorValue ();
     624             virtual ~IntMinorValue ();
    625625             
    626              long getResult() const;
    627 
    628              long getWeight () const;
     626             int getResult() const;
     627
     628             int getWeight () const;
    629629
    630630             /**
     
    665665             poly getResult() const;
    666666
    667              long getWeight () const;
     667             int getWeight () const;
    668668
    669669             /**
  • Singular/MinorProcessor.cc

    r967a9d re2afced  
    7272    // The method assumes ascending row and column indices in the two argument arrays.
    7373    // These indices are understood to be zero-based.
    74     // The method will set the two arrays of unsigned longs in _container.
    75     // Example: The indices 0, 2, 3, 7 will be converted to an array with one unsigned long
     74    // The method will set the two arrays of ints in _container.
     75    // Example: The indices 0, 2, 3, 7 will be converted to an array with one int
    7676    // representing the binary number 10001101 (check bits from right to left).
    7777
     
    7979    int highestRowIndex = rowIndices[numberOfRows - 1];
    8080    int rowBlockCount = (highestRowIndex / 32) + 1;
    81     unsigned long rowBlocks[rowBlockCount];
     81    unsigned int rowBlocks[rowBlockCount];
    8282    for (int i = 0; i < rowBlockCount; i++) rowBlocks[i] = 0;
    8383    for (int i = 0; i < numberOfRows; i++) {
     
    9090    int highestColumnIndex = columnIndices[numberOfColumns - 1];
    9191    int columnBlockCount = (highestColumnIndex / 32) + 1;
    92     unsigned long columnBlocks[columnBlockCount];
     92    unsigned int columnBlocks[columnBlockCount];
    9393    for (int i = 0; i < columnBlockCount; i++) columnBlocks[i] = 0;
    9494    for (int i = 0; i < numberOfColumns; i++) {
     
    194194}
    195195
    196 LongMinorProcessor::LongMinorProcessor () {
     196IntMinorProcessor::IntMinorProcessor () {
    197197    _matrix = 0;
    198198}
    199199
    200 string LongMinorProcessor::toString () const {
     200string IntMinorProcessor::toString () const {
    201201    char h[32];
    202202    string t = "";
    203     string s = "LongMinorProcessor:";
     203    string s = "IntMinorProcessor:";
    204204    s += "\n   matrix: ";
    205205    sprintf(h, "%d", _rows); s += h;
     
    236236}
    237237
    238 bool LongMinorProcessor::isEntryZero (const int absoluteRowIndex, const int absoluteColumnIndex) const
     238bool IntMinorProcessor::isEntryZero (const int absoluteRowIndex, const int absoluteColumnIndex) const
    239239{
    240240  return _matrix[absoluteRowIndex][absoluteColumnIndex] == 0;
    241241}
    242242
    243 LongMinorProcessor::~LongMinorProcessor() {
     243IntMinorProcessor::~IntMinorProcessor() {
    244244    // free memory of _matrix
    245245    for (int i = 0; i < _rows; i++) {
     
    249249}
    250250
    251 void LongMinorProcessor::defineMatrix (const int numberOfRows, const int numberOfColumns, const int* matrix) {
     251void IntMinorProcessor::defineMatrix (const int numberOfRows, const int numberOfColumns, const int* matrix) {
    252252    // free memory of _matrix
    253253    for (int i = 0; i < _rows; i++) {
     
    269269}
    270270
    271 LongMinorValue LongMinorProcessor::getMinor(const int dimension, const int* rowIndices, const int* columnIndices,
    272                                             Cache<MinorKey, LongMinorValue>& c) {
     271IntMinorValue IntMinorProcessor::getMinor(const int dimension, const int* rowIndices, const int* columnIndices,
     272                                            Cache<MinorKey, IntMinorValue>& c) {
    273273    defineSubMatrix(dimension, rowIndices, dimension, columnIndices);
    274274    _minorSize = dimension;
     
    277277}
    278278
    279 LongMinorValue LongMinorProcessor::getMinor(const int dimension, const int* rowIndices, const int* columnIndices) {
     279IntMinorValue IntMinorProcessor::getMinor(const int dimension, const int* rowIndices, const int* columnIndices) {
    280280    defineSubMatrix(dimension, rowIndices, dimension, columnIndices);
    281281    _minorSize = dimension;
     
    284284}
    285285
    286 LongMinorValue LongMinorProcessor::getNextMinor() {
     286IntMinorValue IntMinorProcessor::getNextMinor() {
    287287    // computation without cache
    288288    return getMinorPrivate(_minorSize, _minor);
    289289}
    290290
    291 LongMinorValue LongMinorProcessor::getNextMinor(Cache<MinorKey, LongMinorValue>& c) {
     291IntMinorValue IntMinorProcessor::getNextMinor(Cache<MinorKey, IntMinorValue>& c) {
    292292    // computation with cache
    293293    return getMinorPrivate(_minorSize, _minor, true, c);
    294294}
    295295
    296 LongMinorValue LongMinorProcessor::getMinorPrivate(const int k, const MinorKey& mk) {
     296IntMinorValue IntMinorProcessor::getMinorPrivate(const int k, const MinorKey& mk) {
    297297    assert(k > 0); // k is the minor's dimension; the minor must be at least 1x1
    298298    // The method works by recursion, and using Lapace's Theorem along the row/column with the most zeros.
    299299    if (k == 1) {
    300         return LongMinorValue(_matrix[mk.getAbsoluteRowIndex(0)][mk.getAbsoluteColumnIndex(0)],
     300        return IntMinorValue(_matrix[mk.getAbsoluteRowIndex(0)][mk.getAbsoluteColumnIndex(0)],
    301301                              0, 0, 0, 0, -1, -1); // "-1" is to signal that any statistics about the
    302302                                                   // number of retrievals does not make sense, as we do not use a cache.
     
    317317                MinorKey subMk = mk.getSubMinorKey(b, absoluteC);  // This is MinorKey when we omit row b and column absoluteC.
    318318                if (_matrix[b][absoluteC] != 0) { // Only then do we have to consider this sub-determinante.
    319                     LongMinorValue mv = getMinorPrivate(k - 1, subMk);  // recursive call
     319                    IntMinorValue mv = getMinorPrivate(k - 1, subMk);  // recursive call
    320320                    m += mv.getMultiplications();
    321321                    s += mv.getAdditions();
     
    339339                MinorKey subMk = mk.getSubMinorKey(absoluteR, b); // This is MinorKey when we omit row absoluteR and column b.
    340340                if (_matrix[absoluteR][b] != 0) { // Only then do we have to consider this sub-determinante.
    341                     LongMinorValue mv = getMinorPrivate(k - 1, subMk);  // recursive call
     341                    IntMinorValue mv = getMinorPrivate(k - 1, subMk);  // recursive call
    342342                    m += mv.getMultiplications();
    343343                    s += mv.getAdditions();
     
    354354        if (s < 0) s = 0; // may happen when all subminors are zero and no addition needs to be performed
    355355        if (as < 0) as = 0; // may happen when all subminors are zero and no addition needs to be performed
    356         LongMinorValue newMV = LongMinorValue(result, m, s, am, as, -1, -1); // "-1" is to signal that any statistics about the
     356        IntMinorValue newMV = IntMinorValue(result, m, s, am, as, -1, -1); // "-1" is to signal that any statistics about the
    357357                                                                             // number of retrievals does not make sense, as we
    358358                                                                             // do not use a cache.
     
    361361}
    362362
    363 LongMinorValue LongMinorProcessor::getMinorPrivate(const int k, const MinorKey& mk,
     363IntMinorValue IntMinorProcessor::getMinorPrivate(const int k, const MinorKey& mk,
    364364                                                   const bool multipleMinors,
    365                                                    Cache<MinorKey, LongMinorValue>& cch) {
     365                                                   Cache<MinorKey, IntMinorValue>& cch) {
    366366    assert(k > 0); // k is the minor's dimension; the minor must be at least 1x1
    367367    // The method works by recursion, and using Lapace's Theorem along the row/column with the most zeros.
    368368    if (k == 1) {
    369         return LongMinorValue(_matrix[mk.getAbsoluteRowIndex(0)][mk.getAbsoluteColumnIndex(0)],
     369        return IntMinorValue(_matrix[mk.getAbsoluteRowIndex(0)][mk.getAbsoluteColumnIndex(0)],
    370370                              0, 0, 0, 0, -1, -1); // we set "-1" as, for k == 1, we do not have any cache retrievals
    371371    }
     
    375375        int s = 0; int m = 0; int as = 0; int am = 0;        // counters for additions and multiplications,
    376376                                                             // ..."a*" for accumulated operation counters
    377         LongMinorValue mv = LongMinorValue(0, 0, 0, 0, 0, 0, 0);     // for storing all intermediate minors
     377        IntMinorValue mv = IntMinorValue(0, 0, 0, 0, 0, 0, 0);     // for storing all intermediate minors
    378378        if (b >= 0) {
    379379            // This means that the best line is the row with absolute (0-based) index b.
     
    446446        if (s < 0) s = 0; // may happen when all subminors are zero and no addition needs to be performed
    447447        if (as < 0) as = 0; // may happen when all subminors are zero and no addition needs to be performed
    448         LongMinorValue newMV = LongMinorValue(result, m, s, am, as, 1, potentialRetrievals);
     448        IntMinorValue newMV = IntMinorValue(result, m, s, am, as, 1, potentialRetrievals);
    449449        cch.put(mk, newMV); // Here's the actual put inside the cache.
    450450        return newMV;
  • Singular/MinorProcessor.h

    r967a9d re2afced  
    217217};
    218218
    219 class LongMinorProcessor : public MinorProcessor {
     219class IntMinorProcessor : public MinorProcessor {
    220220    private:
    221221        /**
     
    236236        * @see MinorProcessor::getMinorPrivate (const int, const MinorKey&)
    237237        */
    238         LongMinorValue getMinorPrivate (const int k, const MinorKey& mk,
     238        IntMinorValue getMinorPrivate (const int k, const MinorKey& mk,
    239239                                        const bool multipleMinors,
    240                                         Cache<MinorKey, LongMinorValue>& c);
     240                                        Cache<MinorKey, IntMinorValue>& c);
    241241
    242242        /**
     
    250250        * @see MinorProcessor::getMinorPrivate (const int, const MinorKey&, const bool, Cache<MinorKey, MinorValue>&)
    251251        */
    252         LongMinorValue getMinorPrivate (const int k, const MinorKey& mk);
     252        IntMinorValue getMinorPrivate (const int k, const MinorKey& mk);
    253253    protected:
    254254        bool isEntryZero (const int absoluteRowIndex, const int absoluteColumnIndex) const;
     
    257257        * A constructor for creating an instance.
    258258        */
    259         LongMinorProcessor ();
     259        IntMinorProcessor ();
    260260
    261261        /**
    262262        * A destructor for deleting an instance.
    263263        */
    264         ~LongMinorProcessor ();
     264        ~IntMinorProcessor ();
    265265
    266266        /**
     
    277277        * The sub-matrix is determined by \c rowIndices and \c columnIndices. Computation works recursively
    278278        * using Laplace's Theorem. We always develop along the row or column with most zeros; see
    279         * MinorProcessor::getBestLine (const int, const unsigned long, const unsigned long).
     279        * MinorProcessor::getBestLine (const int, const int, const int).
    280280        * @param dimension the size of the minor to be computed
    281281        * @param rowIndices 0-based indices of the rows of the minor
     
    284284        * @see MinorProcessor::getMinor (const int, const int*, const int*, Cache<MinorKey, MinorValue>&)
    285285        */
    286         LongMinorValue getMinor (const int dimension, const int* rowIndices, const int* columnIndices);
     286        IntMinorValue getMinor (const int dimension, const int* rowIndices, const int* columnIndices);
    287287
    288288        /**
     
    290290        * The sub-matrix is determined by \c rowIndices and \c columnIndices. Computation works recursively
    291291        * using Laplace's Theorem. We always develop along the row or column with most zeros; see
    292         * MinorProcessor::getBestLine (const int, const unsigned long, const unsigned long).
     292        * MinorProcessor::getBestLine (const int, const int, const int).
    293293        * @param dimension the size of the minor to be computed
    294294        * @param rowIndices 0-based indices of the rows of the minor
     
    298298        * @see MinorProcessor::getMinor (const int, const int*, const int*)
    299299        */
    300         LongMinorValue getMinor (const int dimension, const int* rowIndices, const int* columnIndices,
    301                                  Cache<MinorKey, LongMinorValue>& c);
     300        IntMinorValue getMinor (const int dimension, const int* rowIndices, const int* columnIndices,
     301                                 Cache<MinorKey, IntMinorValue>& c);
    302302
    303303        /**
     
    311311        * @see MinorProcessor::hasNextMinor ()
    312312        */
    313         LongMinorValue getNextMinor ();
     313        IntMinorValue getNextMinor ();
    314314
    315315        /**
     
    324324        * @see MinorProcessor::hasNextMinor ()
    325325        */
    326         LongMinorValue getNextMinor (Cache<MinorKey, LongMinorValue>& c);
     326        IntMinorValue getNextMinor (Cache<MinorKey, IntMinorValue>& c);
    327327
    328328        /**
     
    393393        * The sub-matrix is determined by \c rowIndices and \c columnIndices. Computation works recursively
    394394        * using Laplace's Theorem. We always develop along the row or column with most zeros; see
    395         * MinorProcessor::getBestLine (const int, const unsigned long, const unsigned long).
     395        * MinorProcessor::getBestLine (const int, const int, const int).
    396396        * @param dimension the size of the minor to be computed
    397397        * @param rowIndices 0-based indices of the rows of the minor
     
    406406        * The sub-matrix is determined by \c rowIndices and \c columnIndices. Computation works recursively
    407407        * using Laplace's Theorem. We always develop along the row or column with most zeros; see
    408         * MinorProcessor::getBestLine (const int, const unsigned long, const unsigned long).
     408        * MinorProcessor::getBestLine (const int, const int, const int).
    409409        * @param dimension the size of the minor to be computed
    410410        * @param rowIndices 0-based indices of the rows of the minor
  • Singular/TestMinors.cc

    r967a9d re2afced  
    2323
    2424void testOneMinor(PrettyPrinter& prpr, string testHeader, int rowCount, int columnCount, int entryBound, int zeroPercentage,
    25                   int minorSize, int randomSeed, int cacheEntries, long cacheWeight);
     25                  int minorSize, int randomSeed, int cacheEntries, int cacheWeight);
    2626void testAllMinors(PrettyPrinter& prpr, string testHeader, int rowCount, int columnCount, int entryBound, int zeroPercentage,
    27                    int minorRows, int minorColumns, int minorSize, int randomSeed, int cacheEntries, long cacheWeight);
     27                   int minorRows, int minorColumns, int minorSize, int randomSeed, int cacheEntries, int cacheWeight);
    2828void testAllMinorsUntil(PrettyPrinter& prpr, string testHeader, int rowCount, int columnCount, int entryBound, int zeroPercentage,
    29                         int minorSize, int randomSeed, int cacheEntries, long cacheWeight, int targetMinor,
     29                        int minorSize, int randomSeed, int cacheEntries, int cacheWeight, int targetMinor,
    3030                        bool checkForEquality, int maxLoops);
    3131
     
    3434  PrintS("\nType 'system(\"minors\", 0);' to run 5 default tests with a random");
    3535  PrintS("\ninteger matrix. This test, for which no ring needs to be declared");
    36   PrintS("\nbeforehand, will generate the file 'minor_output_results_longs.txt'");
     36  PrintS("\nbeforehand, will generate the file 'minor_output_results_ints.txt'");
    3737  PrintS("\nincluding all results and runtimes, and a much more detailed file");
    38   PrintS("\n'minor_output_complete_longs.txt' (both in the folder of the SIN-");
     38  PrintS("\n'minor_output_complete_ints.txt' (both in the folder of the SIN-");
    3939  PrintS("\nGULAR executable).");
    4040  PrintS("\n\nType 'system(\"minors\", m, k, strategies, nCache, wCache,");
     
    107107int testIntMinors (const int dummy) {
    108108  // for output of non-zero minors into file
    109   PrettyPrinter prpr("minor_output_complete_longs.txt", "minor_output_results_longs.txt", false, false, -1, "   ");
     109  PrettyPrinter prpr("minor_output_complete_ints.txt", "minor_output_results_int.txt", false, false, -1, "   ");
    110110
    111111  // computes just one minor:
     
    140140}
    141141
    142 int testAllPolyMinors(matrix mat, int minorSize, int strategies, int cacheEntries, long cacheWeight,
     142int testAllPolyMinors(matrix mat, int minorSize, int strategies, int cacheEntries, int cacheWeight,
    143143                      int dumpMinors, int dumpResults, int dumpComplete, int dumpConsole) {
    144144  // for pretty printing and file output of results and runtimes
     
    327327}
    328328
    329 ideal testAllPolyMinorsAsIdeal(matrix mat, int minorSize, int strategy, int cacheEntries, long cacheWeight)
     329ideal testAllPolyMinorsAsIdeal(matrix mat, int minorSize, int strategy, int cacheEntries, int cacheWeight)
    330330{
    331331    // counters + auxiliary stuff
    332   long totalMultiplications = 0;
    333   long totalAdditions = 0;
    334   long totalMultiplicationsAccumulated = 0;
    335   long totalAdditionsAccumulated = 0;
     332  int totalMultiplications = 0;
     333  int totalAdditions = 0;
     334  int totalMultiplicationsAccumulated = 0;
     335  int totalAdditionsAccumulated = 0;
    336336  char h[30];
    337337
     
    397397  PrintLn(); PrintS("numbers of performed operations");
    398398  PrintLn(); PrintS("   polynomial-to-polynomial multiplications: ");
    399   sprintf(h, "%ld", totalMultiplications); PrintS(h);
     399  sprintf(h, "%d", totalMultiplications); PrintS(h);
    400400  PrintLn(); PrintS("   polynomial-to-polynomial additions: ");
    401   sprintf(h, "%ld", totalAdditions); PrintS(h);
     401  sprintf(h, "%d", totalAdditions); PrintS(h);
    402402  PrintLn(); PrintS("   (polynomial-to-polynomial multiplications without cache would be: ");
    403   sprintf(h, "%ld", totalMultiplicationsAccumulated); PrintS(h); PrintS(")");
     403  sprintf(h, "%d", totalMultiplicationsAccumulated); PrintS(h); PrintS(")");
    404404  PrintLn(); PrintS("   (polynomial-to-polynomial additions without cache would be: ");
    405   sprintf(h, "%ld", totalAdditionsAccumulated); PrintS(h); PrintS(")");
     405  sprintf(h, "%d", totalAdditionsAccumulated); PrintS(h); PrintS(")");
    406406  PrintLn(); PrintLn();
    407407
     
    415415*/
    416416void testOneMinor(PrettyPrinter& prpr, string testHeader, int rowCount, int columnCount, int entryBound, int zeroPercentage,
    417                   int minorSize, int randomSeed, int cacheEntries, long cacheWeight) {
    418     long start, end;
     417                  int minorSize, int randomSeed, int cacheEntries, int cacheWeight) {
     418    int start, end;
    419419
    420420    prpr < testHeader;
     
    426426    fillRandomMatrix(rowCount, columnCount, randomSeed, zeroPercentage, entryBound, myMatrix);
    427427
    428     LongMinorProcessor mp;
     428    IntMinorProcessor mp;
    429429    mp.defineMatrix(rowCount, columnCount, myMatrix);
    430430
     
    442442    prpr << "Results - " << testHeader << " - no cache";
    443443    start = clock();
    444     LongMinorValue mv = mp.getMinor(minorSize, myRowIndices, myColumnIndices);
     444    IntMinorValue mv = mp.getMinor(minorSize, myRowIndices, myColumnIndices);
    445445    end = clock();
    446446    ++prpr << "value of minor = " << mv.toString();
     
    448448
    449449    // define the cache:
    450     Cache<MinorKey, LongMinorValue> cch = Cache<MinorKey, LongMinorValue>(cacheEntries, cacheWeight);
     450    Cache<MinorKey, IntMinorValue> cch = Cache<MinorKey, IntMinorValue>(cacheEntries, cacheWeight);
    451451
    452452    // compute minor using the cache, for all implemented caching strategies:
     
    457457
    458458        // compute the minor using the cache and current strategy
    459         LongMinorValue::SetRankingStrategy(strategy);
     459        IntMinorValue::SetRankingStrategy(strategy);
    460460        start = clock();
    461461        mv = mp.getMinor(minorSize, myRowIndices, myColumnIndices, cch);
     
    480480*/
    481481void testAllMinors(PrettyPrinter& prpr, string testHeader, int rowCount, int columnCount, int entryBound, int zeroPercentage,
    482                    int minorRows, int minorColumns, int minorSize, int randomSeed, int cacheEntries, long cacheWeight) {
     482                   int minorRows, int minorColumns, int minorSize, int randomSeed, int cacheEntries, int cacheWeight) {
    483483    long totalTimeStart, totalTime, printTimeStart, printTime;
    484484
     
    491491    fillRandomMatrix(rowCount, columnCount, randomSeed, zeroPercentage, entryBound, myMatrix);
    492492
    493     LongMinorProcessor mp;
     493    IntMinorProcessor mp;
    494494    mp.defineMatrix(rowCount, columnCount, myMatrix);
    495495
     
    504504
    505505    // define the cache:
    506     Cache<MinorKey, LongMinorValue> cch = Cache<MinorKey, LongMinorValue>(cacheEntries, cacheWeight);
     506    Cache<MinorKey, IntMinorValue> cch = Cache<MinorKey, IntMinorValue>(cacheEntries, cacheWeight);
    507507
    508508    // container for all upcoming results
    509     LongMinorValue theMinor;
     509    IntMinorValue theMinor;
    510510
    511511    // counters...
     
    567567        mp.defineSubMatrix(minorRows, myRowIndices, minorColumns, myColumnIndices);
    568568        mp.setMinorSize(minorSize);
    569         LongMinorValue::SetRankingStrategy(strategy);
     569        IntMinorValue::SetRankingStrategy(strategy);
    570570
    571571        // counters...
     
    578578        // cleaning up and redefinition of the cache:
    579579        cch.clear();
    580         cch = Cache<MinorKey, LongMinorValue>(cacheEntries, cacheWeight);
     580        cch = Cache<MinorKey, IntMinorValue>(cacheEntries, cacheWeight);
    581581
    582582        +prpr; +prpr < "Results - " < testHeader < " - using cache - deploying caching strategy #" < strategy;
     
    641641*/
    642642void testAllMinorsUntil(PrettyPrinter& prpr, string testHeader, int rowCount, int columnCount, int entryBound, int zeroPercentage,
    643                         int minorSize, int randomSeed, int cacheEntries, long cacheWeight, int targetMinor,
     643                        int minorSize, int randomSeed, int cacheEntries, int cacheWeight, int targetMinor,
    644644                        bool checkForEquality, int maxLoops) {
    645645    long totalTimeStart, totalTime, printTimeStart, printTime;
     
    661661    fillRandomMatrix(rowCount, columnCount, randomSeed, zeroPercentage, entryBound, myMatrix);
    662662
    663     LongMinorProcessor mp;
     663    IntMinorProcessor mp;
    664664    mp.defineMatrix(rowCount, columnCount, myMatrix);
    665665
     
    668668
    669669    // define the cache:
    670     Cache<MinorKey, LongMinorValue> cch = Cache<MinorKey, LongMinorValue>(cacheEntries, cacheWeight);
     670    Cache<MinorKey, IntMinorValue> cch = Cache<MinorKey, IntMinorValue>(cacheEntries, cacheWeight);
    671671
    672672    // container for all upcoming results
    673     LongMinorValue theMinor;
     673    IntMinorValue theMinor;
    674674
    675675    // counters...
     
    724724        mp.defineSubMatrix(rowCount, myRowIndices, columnCount, myColumnIndices);
    725725        mp.setMinorSize(minorSize);
    726         LongMinorValue::SetRankingStrategy(strategy);
     726        IntMinorValue::SetRankingStrategy(strategy);
    727727
    728728        // counters...
     
    735735        // cleaning up and redefinition of the cache:
    736736        cch.clear();
    737         cch = Cache<MinorKey, LongMinorValue>(cacheEntries, cacheWeight);
     737        cch = Cache<MinorKey, IntMinorValue>(cacheEntries, cacheWeight);
    738738
    739739        +prpr; +prpr < testHeader < " - using cache - deploying caching strategy #" < strategy;
  • Singular/TestMinors.h

    r967a9d re2afced  
    99void minorUsageInfo();
    1010int testIntMinors (const int dummy);
    11 int testAllPolyMinors(matrix m, int minorSize, int strategies, int cacheEntries, long cacheWeight,
     11int testAllPolyMinors(matrix m, int minorSize, int strategies, int cacheEntries, int cacheWeight,
    1212                      int dumpMinors, int dumpResults, int dumpComplete, int dumpConsole);
    13 ideal testAllPolyMinorsAsIdeal(matrix m, int minorSize, int strategy, int cacheEntries, long cacheWeight);
     13ideal testAllPolyMinorsAsIdeal(matrix m, int minorSize, int strategy, int cacheEntries, int cacheWeight);
    1414void testStuff (const poly p);
    1515
  • Singular/claptmpl.cc

    r967a9d re2afced  
    33*  Computer Algebra System SINGULAR     *
    44****************************************/
    5 // $Id: claptmpl.cc,v 1.51 2009-10-07 09:05:27 seelisch Exp $
     5// $Id: claptmpl.cc,v 1.52 2009-10-08 10:11:56 seelisch Exp $
    66/*
    77* ABSTRACT - instantiation of all templates
     
    262262#include "Cache.h"
    263263template class std::list<int>;
    264 template class std::list<long>;
    265264template class std::list<MinorKey>;
    266 template class std::list<LongMinorValue>;
     265template class std::list<IntMinorValue>;
    267266template class std::list<PolyMinorValue>;
    268 template class Cache<MinorKey, LongMinorValue>;
     267template class Cache<MinorKey, IntMinorValue>;
    269268template class Cache<MinorKey, PolyMinorValue>;
    270269#endif // HAVE_MINOR
  • Singular/extra.cc

    r967a9d re2afced  
    22*  Computer Algebra System SINGULAR      *
    33*****************************************/
    4 /* $Id: extra.cc,v 1.321 2009-10-06 12:09:00 seelisch Exp $ */
     4/* $Id: extra.cc,v 1.322 2009-10-08 10:11:57 seelisch Exp $ */
    55/*
    66* ABSTRACT: general interface to internals of Singular ("system" command)
     
    21432143          const int strategy       = (const int)(long)h->next->next->Data();
    21442144          const int cacheEntries   = (const int)(long)h->next->next->next->Data();
    2145           const long cacheWeight   = (const long)h->next->next->next->next->Data();
     2145          const int cacheWeight    = (const int)(long)h->next->next->next->next->Data();
    21462146          ideal iii = testAllPolyMinorsAsIdeal(m, k, strategy, cacheEntries, cacheWeight);
    21472147            // starts the computation of all k x k minors in the
     
    21682168          const int strategies     = (const int)(long)h->next->next->Data();
    21692169          const int cacheEntries   = (const int)(long)h->next->next->next->Data();
    2170           const long cacheWeight   = (const long)h->next->next->next->next->Data();
     2170          const int cacheWeight    = (const int)(long)h->next->next->next->next->Data();
    21712171          const int dumpMinors     = (const int)(long)h->next->next->next->next->next->Data();
    21722172          const int dumpResults    = (const int)(long)h->next->next->next->next->next->next->Data();
     
    21882188          testStuff(p);
    21892189        }
     2190        return FALSE;
     2191      }
     2192      else
     2193      if(strcmp(sys_cmd,"changeVars")==0)
     2194      {
     2195        /*
     2196        The following code changes the N variables names in currRing in
     2197        the following way: var(i) is replaced by f(i), 1 <= i <= N,
     2198        where f(j) is j written to the base of 26 with the digit '0'
     2199        written as 'a', '1' as 'b', ..., '25' as 'z'.
     2200        E.g. var(1) goes to f(1)='b', ..., var(25) goes to f(25)='z',
     2201             var(26) goes to f(26)='ba', etc.
     2202        The purpose of this rewriting is to eliminate indexed variables,
     2203        as they may cause problems when generating scripts for Magma,
     2204        Maple, or Macaulay2.
     2205        */
     2206        ring newRing = rCopy0(currRing);
     2207        int varN = newRing->N;
     2208        char* alphabet = "abcdefghijklmnopqrstuvwxyz";
     2209        char theName[10];
     2210        char tempChars[10];
     2211        int j; int k; int l;
     2212        for (int i = 1; i <= varN; i++)
     2213        {
     2214          k = i;
     2215          l = 9;
     2216          j = k % 26;
     2217          tempChars[l--] = alphabet[j];
     2218          k = (k - j) / 26;
     2219          while (k != 0)
     2220          {
     2221            j = k % 26;
     2222            tempChars[l--] = alphabet[j];
     2223            k = (k - j) / 26;
     2224          }
     2225          l++;
     2226          for (j = l; j < 10; j++) theName[j - l] = tempChars[j];
     2227          theName[10 - l] = '\0';
     2228          newRing->names[i - 1] = omStrDup(theName);
     2229        }
     2230        rComplete(newRing);
     2231        currRing = newRing;
    21902232        return FALSE;
    21912233      }
Note: See TracChangeset for help on using the changeset viewer.