Changeset 95a6f3 in git for Singular/MinorProcessor.cc


Ignore:
Timestamp:
Oct 9, 2009, 3:46:30 PM (15 years ago)
Author:
Frank Seelisch <seelisch@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
60e4be265398f8004f3b093179a74b59f4fdcb74
Parents:
70f63ab39d1a6a435e42e041336a21e13c1269d9
Message:
more functionality: compute int minors modulo p


git-svn-id: file:///usr/local/Singular/svn/trunk@12182 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/MinorProcessor.cc

    r70f63a r95a6f3  
    270270
    271271IntMinorValue IntMinorProcessor::getMinor(const int dimension, const int* rowIndices, const int* columnIndices,
    272                                             Cache<MinorKey, IntMinorValue>& c) {
     272                                            Cache<MinorKey, IntMinorValue>& c, const int characteristic) {
    273273    defineSubMatrix(dimension, rowIndices, dimension, columnIndices);
    274274    _minorSize = dimension;
    275275    // call a helper method which recursively computes the minor using the cache c:
    276     return getMinorPrivate(dimension, _container, false, c);
    277 }
    278 
    279 IntMinorValue IntMinorProcessor::getMinor(const int dimension, const int* rowIndices, const int* columnIndices) {
     276    return getMinorPrivate(dimension, _container, false, c, characteristic);
     277}
     278
     279IntMinorValue IntMinorProcessor::getMinor(const int dimension, const int* rowIndices, const int* columnIndices, const int characteristic) {
    280280    defineSubMatrix(dimension, rowIndices, dimension, columnIndices);
    281281    _minorSize = dimension;
    282282    // call a helper method which recursively computes the minor (without using a cache):
    283     return getMinorPrivate(_minorSize, _container);
    284 }
    285 
    286 IntMinorValue IntMinorProcessor::getNextMinor() {
     283    return getMinorPrivate(_minorSize, _container, characteristic);
     284}
     285
     286IntMinorValue IntMinorProcessor::getNextMinor(const int characteristic) {
    287287    // computation without cache
    288     return getMinorPrivate(_minorSize, _minor);
    289 }
    290 
    291 IntMinorValue IntMinorProcessor::getNextMinor(Cache<MinorKey, IntMinorValue>& c) {
     288    return getMinorPrivate(_minorSize, _minor, characteristic);
     289}
     290
     291IntMinorValue IntMinorProcessor::getNextMinor(Cache<MinorKey, IntMinorValue>& c, const int characteristic) {
    292292    // computation with cache
    293     return getMinorPrivate(_minorSize, _minor, true, c);
    294 }
    295 
    296 IntMinorValue IntMinorProcessor::getMinorPrivate(const int k, const MinorKey& mk) {
     293    return getMinorPrivate(_minorSize, _minor, true, c, characteristic);
     294}
     295
     296IntMinorValue IntMinorProcessor::getMinorPrivate(const int k, const MinorKey& mk, const int characteristic) {
    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.
     
    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                     IntMinorValue mv = getMinorPrivate(k - 1, subMk);  // recursive call
     319                    IntMinorValue mv = getMinorPrivate(k - 1, subMk, characteristic);  // recursive call
    320320                    m += mv.getMultiplications();
    321321                    s += mv.getAdditions();
     
    324324                    result += sign * mv.getResult() * _matrix[b][absoluteC]; // adding sub-determinante times matrix entry
    325325                                                                             // times appropriate sign
     326                    if (characteristic != 0) result = result % characteristic;
    326327                    s++; m++; as++, am++; // This is for the addition and multiplication in the previous line of code.
    327328                }
     
    339340                MinorKey subMk = mk.getSubMinorKey(absoluteR, b); // This is MinorKey when we omit row absoluteR and column b.
    340341                if (_matrix[absoluteR][b] != 0) { // Only then do we have to consider this sub-determinante.
    341                     IntMinorValue mv = getMinorPrivate(k - 1, subMk);  // recursive call
     342                    IntMinorValue mv = getMinorPrivate(k - 1, subMk, characteristic);  // recursive call
    342343                    m += mv.getMultiplications();
    343344                    s += mv.getAdditions();
     
    346347                    result += sign * mv.getResult() * _matrix[absoluteR][b]; // adding sub-determinante times matrix entry
    347348                                                                             // times appropriate sign
     349                    if (characteristic != 0) result = result % characteristic;
    348350                    s++; m++; as++, am++; // This is for the addition and multiplication in the previous line of code.
    349351                }
     
    362364
    363365IntMinorValue IntMinorProcessor::getMinorPrivate(const int k, const MinorKey& mk,
    364                                                    const bool multipleMinors,
    365                                                    Cache<MinorKey, IntMinorValue>& cch) {
     366                                                 const bool multipleMinors,
     367                                                 Cache<MinorKey, IntMinorValue>& cch,
     368                                                 const int characteristic) {
    366369    assert(k > 0); // k is the minor's dimension; the minor must be at least 1x1
    367370    // The method works by recursion, and using Lapace's Theorem along the row/column with the most zeros.
     
    392395                    }
    393396                    else {
    394                         mv = getMinorPrivate(k - 1, subMk, multipleMinors, cch); // recursive call
     397                        mv = getMinorPrivate(k - 1, subMk, multipleMinors, cch, characteristic); // recursive call
    395398                        // As this minor was not in the cache, we count the additions and
    396399                        // multiplications that we needed to do in the recursive call:
     
    403406                    result += sign * mv.getResult() * _matrix[b][absoluteC]; // adding sub-determinante times matrix entry
    404407                                                                             // times appropriate sign
     408                    if (characteristic != 0) result = result % characteristic;
    405409                    s++; m++; as++; am++; // This is for the addition and multiplication in the previous line of code.
    406410                }
     
    425429                    }
    426430                    else {
    427                         mv = getMinorPrivate(k - 1, subMk, multipleMinors, cch); // recursive call
     431                        mv = getMinorPrivate(k - 1, subMk, multipleMinors, cch, characteristic); // recursive call
    428432                        // As this minor was not in the cache, we count the additions and
    429433                        // multiplications that we needed to do in the recursive call:
     
    436440                    result += sign * mv.getResult() * _matrix[absoluteR][b]; // adding sub-determinante times matrix entry
    437441                                                                             // times appropriate sign
     442                    if (characteristic != 0) result = result % characteristic;
    438443                    s++; m++; as++; am++; // This is for the addition and multiplication in the previous line of code.
    439444                }
Note: See TracChangeset for help on using the changeset viewer.