Changeset 40349c in git


Ignore:
Timestamp:
Oct 27, 2009, 12:16:28 PM (15 years ago)
Author:
Frank Seelisch <seelisch@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
dbae50869afb5b721e8bfae30624eb8837092c57
Parents:
e42a57379ec1ada42cdd06c9e7290bada59643fc
Message:
dealing with polynomials / pDelete


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

Legend:

Unmodified
Added
Removed
  • Singular/MinorProcessor.cc

    re42a57 r40349c  
    270270
    271271IntMinorValue IntMinorProcessor::getMinor(const int dimension, const int* rowIndices, const int* columnIndices,
    272                                             Cache<MinorKey, IntMinorValue>& c, const int characteristic) {
     272                                          Cache<MinorKey, IntMinorValue>& c, const int characteristic) {
    273273    defineSubMatrix(dimension, rowIndices, dimension, columnIndices);
    274274    _minorSize = dimension;
     
    356356        if (s < 0) s = 0; // may happen when all subminors are zero and no addition needs to be performed
    357357        if (as < 0) as = 0; // may happen when all subminors are zero and no addition needs to be performed
    358         IntMinorValue newMV = IntMinorValue(result, m, s, am, as, -1, -1); // "-1" is to signal that any statistics about the
    359                                                                              // number of retrievals does not make sense, as we
    360                                                                              // do not use a cache.
     358        IntMinorValue newMV(result, m, s, am, as, -1, -1); // "-1" is to signal that any statistics about the
     359                                                           // number of retrievals does not make sense, as we
     360                                                           // do not use a cache.
    361361        return newMV;
    362362    }
     
    378378        int s = 0; int m = 0; int as = 0; int am = 0;        // counters for additions and multiplications,
    379379                                                             // ..."a*" for accumulated operation counters
    380         IntMinorValue mv = IntMinorValue(0, 0, 0, 0, 0, 0, 0);     // for storing all intermediate minors
     380        IntMinorValue mv(0, 0, 0, 0, 0, 0, 0);               // for storing all intermediate minors
    381381        if (b >= 0) {
    382382            // This means that the best line is the row with absolute (0-based) index b.
     
    451451        if (s < 0) s = 0; // may happen when all subminors are zero and no addition needs to be performed
    452452        if (as < 0) as = 0; // may happen when all subminors are zero and no addition needs to be performed
    453         IntMinorValue newMV = IntMinorValue(result, m, s, am, as, 1, potentialRetrievals);
     453        IntMinorValue newMV(result, m, s, am, as, 1, potentialRetrievals);
    454454        cch.put(mk, newMV); // Here's the actual put inside the cache.
    455455        return newMV;
     
    493493bool PolyMinorProcessor::isEntryZero (const int absoluteRowIndex, const int absoluteColumnIndex) const
    494494{
    495   poly zeroPoly = pISet(0);
    496   return pEqualPolys(_polyMatrix[absoluteRowIndex][absoluteColumnIndex], zeroPoly);
     495  return (_polyMatrix[absoluteRowIndex][absoluteColumnIndex] == NULL);
    497496}
    498497
     
    557556// performs the assignment a = a + (b * c * d)
    558557// c and d must neither be destroyed nor modified
    559 // b may be destroyed
    560 // a must finally contain the new value
    561 poly ops(poly a, poly b, poly c, poly d)
     558// the old value of a and b will be destroyed
     559// a will finally contain the new value
     560void ops(poly a, poly b, poly c, poly d)
    562561{
    563   return p_Add_q(a, p_Mult_q(b, pp_Mult_qq(c, d, currRing), currRing), currRing);
     562  a = p_Add_q(a, p_Mult_q(b, pp_Mult_qq(c, d, currRing), currRing), currRing);
    564563}
    565564
     
    583582            // the initial sign depends on the relative index of b in minorRowKey:
    584583            int sign = (mk.getRelativeRowIndex(b) % 2 == 0 ? 1 : -1);
    585             poly signPoly = pISet(sign);
     584            poly signPoly = NULL;
    586585            for (int c = 0; c < k; c++) {
    587586                int absoluteC = mk.getAbsoluteColumnIndex(c);      // This iterates over all involved columns.
     
    593592                    am += mv.getAccumulatedMultiplications();
    594593                    as += mv.getAccumulatedAdditions();
    595                     result = ops(result, signPoly, mv.getResult(), _polyMatrix[b][absoluteC]); // adding sub-determinante times matrix entry
    596                                                                                                // times appropriate sign
     594                    pDelete(&signPoly);
     595                    signPoly = pISet(sign);
     596                    ops(result, signPoly, mv.getResult(), _polyMatrix[b][absoluteC]); // adding in "result" the product of sign,
     597                                                                                      // sub-determinante, and matrix entry
     598                    signPoly = NULL;
    597599                    s++; m++; as++, am++; // This is for the addition and multiplication in the previous line of code.
    598600                }
    599601                sign = - sign; // alternating the sign
    600                 signPoly = pISet(sign);
    601602            }
    602             // p_Delete(&signPoly, currRing);
    603603        }
    604604        else {
     
    608608            // the initial sign depends on the relative index of b in minorColumnKey:
    609609            int sign = (mk.getRelativeColumnIndex(b) % 2 == 0 ? 1 : -1);
    610             poly signPoly = pISet(sign);
     610            poly signPoly = NULL;
    611611            for (int r = 0; r < k; r++) {
    612612                int absoluteR = mk.getAbsoluteRowIndex(r);        // This iterates over all involved rows.
     
    618618                    am += mv.getAccumulatedMultiplications();
    619619                    as += mv.getAccumulatedAdditions();
    620                     result = ops(result, signPoly, mv.getResult(), _polyMatrix[absoluteR][b]); // adding sub-determinante times matrix entry
    621                                                                                                // times appropriate sign
     620                    pDelete(&signPoly);
     621                    signPoly = pISet(sign);
     622                    ops(result, signPoly, mv.getResult(), _polyMatrix[absoluteR][b]); // adding in "result" the product of sign,
     623                                                                                      // sub-determinante, and matrix entry
     624                    signPoly = NULL;
    622625                    s++; m++; as++, am++; // This is for the addition and multiplication in the previous line of code.
    623626                }
    624627                sign = - sign; // alternating the sign
    625                 signPoly = pISet(sign);
    626628            }
    627             // p_Delete(&signPoly, currRing);
    628629        }
    629630        s--; as--; // first addition was 0 + ..., so we do not count it
     
    633634                                                            // number of retrievals does not make sense, as we
    634635                                                            // do not use a cache.
    635         // p_Delete(&result, currRing);
     636        pDelete(&result);
    636637        return newMV;
    637638    }
     
    652653        int s = 0; int m = 0; int as = 0; int am = 0;        // counters for additions and multiplications,
    653654                                                             // ..."a*" for accumulated operation counters
    654         PolyMinorValue mv = PolyMinorValue(0, 0, 0, 0, 0, 0, 0);     // for storing all intermediate minors
    655655        if (b >= 0) {
    656656            // This means that the best line is the row with absolute (0-based) index b.
     
    658658            // the initial sign depends on the relative index of b in minorRowKey:
    659659            int sign = (mk.getRelativeRowIndex(b) % 2 == 0 ? 1 : -1);
    660             poly signPoly = pISet(sign);
     660            poly signPoly = NULL;
    661661            for (int c = 0; c < k; c++) {
    662662                int absoluteC = mk.getAbsoluteColumnIndex(c);      // This iterates over all involved columns.
    663663                MinorKey subMk = mk.getSubMinorKey(b, absoluteC);  // This is MinorKey when we omit row b and column absoluteC.
    664664                if (!isEntryZero(b, absoluteC)) { // Only then do we have to consider this sub-determinante.
     665                    PolyMinorValue mv;              // for storing all intermediate minors
    665666                    if (cch.hasKey(subMk)) { // trying to find the result in the cache
    666667                        mv = cch.getValue(subMk);
     
    679680                    am += mv.getAccumulatedMultiplications();
    680681                    as += mv.getAccumulatedAdditions();
    681                     result = ops(result, signPoly, mv.getResult(), _polyMatrix[b][absoluteC]); // adding sub-determinante times matrix entry
    682                                                                                                // times appropriate sign
     682                    pDelete(&signPoly);
     683                    signPoly = pISet(sign);
     684                    ops(result, signPoly, mv.getResult(), _polyMatrix[b][absoluteC]); // adding in "result" the product of sign,
     685                                                                                      // sub-determinante, and matrix entry
     686                    signPoly = NULL;
    683687                    s++; m++; as++; am++; // This is for the addition and multiplication in the previous line of code.
    684688                }
    685689                sign = - sign; // alternating the sign
    686                 signPoly = pISet(sign);
    687690            }
    688691        }
     
    693696            // the initial sign depends on the relative index of b in minorColumnKey:
    694697            int sign = (mk.getRelativeColumnIndex(b) % 2 == 0 ? 1 : -1);
    695             poly signPoly = pISet(sign);
     698            poly signPoly = NULL;
    696699            for (int r = 0; r < k; r++) {
    697700                int absoluteR = mk.getAbsoluteRowIndex(r);        // This iterates over all involved rows.
    698701                MinorKey subMk = mk.getSubMinorKey(absoluteR, b); // This is MinorKey when we omit row absoluteR and column b.
    699702                if (!isEntryZero(absoluteR, b)) { // Only then do we have to consider this sub-determinante.
     703                    PolyMinorValue mv;              // for storing all intermediate minors
    700704                    if (cch.hasKey(subMk)) { // trying to find the result in the cache
    701705                        mv = cch.getValue(subMk);
     
    714718                    am += mv.getAccumulatedMultiplications();
    715719                    as += mv.getAccumulatedAdditions();
    716                     result = ops(result, signPoly, mv.getResult(), _polyMatrix[absoluteR][b]); // adding sub-determinante times matrix entry
    717                                                                                                // times appropriate sign
     720                    pDelete(&signPoly);
     721                    signPoly = pISet(sign);
     722                    ops(result, signPoly, mv.getResult(), _polyMatrix[absoluteR][b]); // adding in "result" the product of sign,
     723                                                                                      // sub-determinante, and matrix entry
     724                    signPoly = NULL;
    718725                    s++; m++; as++; am++; // This is for the addition and multiplication in the previous line of code.
    719726                }
    720727                sign = - sign; // alternating the sign
    721                 signPoly = pISet(sign);
    722728            }
    723729        }
     
    727733        if (s < 0) s = 0; // may happen when all subminors are zero and no addition needs to be performed
    728734        if (as < 0) as = 0; // may happen when all subminors are zero and no addition needs to be performed
    729         PolyMinorValue newMV = PolyMinorValue(result, m, s, am, as, 1, potentialRetrievals);
     735        PolyMinorValue newMV(result, m, s, am, as, 1, potentialRetrievals);
     736        pDelete(&result);
    730737        cch.put(mk, newMV); // Here's the actual put inside the cache.
    731738        return newMV;
Note: See TracChangeset for help on using the changeset viewer.