Changeset 40349c in git
- Timestamp:
- Oct 27, 2009, 12:16:28 PM (14 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a657104b677b4c461d018cbf3204d72d34ad66a9')
- Children:
- dbae50869afb5b721e8bfae30624eb8837092c57
- Parents:
- e42a57379ec1ada42cdd06c9e7290bada59643fc
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/MinorProcessor.cc
re42a57 r40349c 270 270 271 271 IntMinorValue IntMinorProcessor::getMinor(const int dimension, const int* rowIndices, const int* columnIndices, 272 272 Cache<MinorKey, IntMinorValue>& c, const int characteristic) { 273 273 defineSubMatrix(dimension, rowIndices, dimension, columnIndices); 274 274 _minorSize = dimension; … … 356 356 if (s < 0) s = 0; // may happen when all subminors are zero and no addition needs to be performed 357 357 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 the359 360 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. 361 361 return newMV; 362 362 } … … 378 378 int s = 0; int m = 0; int as = 0; int am = 0; // counters for additions and multiplications, 379 379 // ..."a*" for accumulated operation counters 380 IntMinorValue mv = IntMinorValue(0, 0, 0, 0, 0, 0, 0);// for storing all intermediate minors380 IntMinorValue mv(0, 0, 0, 0, 0, 0, 0); // for storing all intermediate minors 381 381 if (b >= 0) { 382 382 // This means that the best line is the row with absolute (0-based) index b. … … 451 451 if (s < 0) s = 0; // may happen when all subminors are zero and no addition needs to be performed 452 452 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); 454 454 cch.put(mk, newMV); // Here's the actual put inside the cache. 455 455 return newMV; … … 493 493 bool PolyMinorProcessor::isEntryZero (const int absoluteRowIndex, const int absoluteColumnIndex) const 494 494 { 495 poly zeroPoly = pISet(0); 496 return pEqualPolys(_polyMatrix[absoluteRowIndex][absoluteColumnIndex], zeroPoly); 495 return (_polyMatrix[absoluteRowIndex][absoluteColumnIndex] == NULL); 497 496 } 498 497 … … 557 556 // performs the assignment a = a + (b * c * d) 558 557 // c and d must neither be destroyed nor modified 559 // b maybe destroyed560 // a mustfinally contain the new value561 polyops(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 560 void ops(poly a, poly b, poly c, poly d) 562 561 { 563 returnp_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); 564 563 } 565 564 … … 583 582 // the initial sign depends on the relative index of b in minorRowKey: 584 583 int sign = (mk.getRelativeRowIndex(b) % 2 == 0 ? 1 : -1); 585 poly signPoly = pISet(sign);584 poly signPoly = NULL; 586 585 for (int c = 0; c < k; c++) { 587 586 int absoluteC = mk.getAbsoluteColumnIndex(c); // This iterates over all involved columns. … … 593 592 am += mv.getAccumulatedMultiplications(); 594 593 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; 597 599 s++; m++; as++, am++; // This is for the addition and multiplication in the previous line of code. 598 600 } 599 601 sign = - sign; // alternating the sign 600 signPoly = pISet(sign);601 602 } 602 // p_Delete(&signPoly, currRing);603 603 } 604 604 else { … … 608 608 // the initial sign depends on the relative index of b in minorColumnKey: 609 609 int sign = (mk.getRelativeColumnIndex(b) % 2 == 0 ? 1 : -1); 610 poly signPoly = pISet(sign);610 poly signPoly = NULL; 611 611 for (int r = 0; r < k; r++) { 612 612 int absoluteR = mk.getAbsoluteRowIndex(r); // This iterates over all involved rows. … … 618 618 am += mv.getAccumulatedMultiplications(); 619 619 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; 622 625 s++; m++; as++, am++; // This is for the addition and multiplication in the previous line of code. 623 626 } 624 627 sign = - sign; // alternating the sign 625 signPoly = pISet(sign);626 628 } 627 // p_Delete(&signPoly, currRing);628 629 } 629 630 s--; as--; // first addition was 0 + ..., so we do not count it … … 633 634 // number of retrievals does not make sense, as we 634 635 // do not use a cache. 635 // p_Delete(&result, currRing);636 pDelete(&result); 636 637 return newMV; 637 638 } … … 652 653 int s = 0; int m = 0; int as = 0; int am = 0; // counters for additions and multiplications, 653 654 // ..."a*" for accumulated operation counters 654 PolyMinorValue mv = PolyMinorValue(0, 0, 0, 0, 0, 0, 0); // for storing all intermediate minors655 655 if (b >= 0) { 656 656 // This means that the best line is the row with absolute (0-based) index b. … … 658 658 // the initial sign depends on the relative index of b in minorRowKey: 659 659 int sign = (mk.getRelativeRowIndex(b) % 2 == 0 ? 1 : -1); 660 poly signPoly = pISet(sign);660 poly signPoly = NULL; 661 661 for (int c = 0; c < k; c++) { 662 662 int absoluteC = mk.getAbsoluteColumnIndex(c); // This iterates over all involved columns. 663 663 MinorKey subMk = mk.getSubMinorKey(b, absoluteC); // This is MinorKey when we omit row b and column absoluteC. 664 664 if (!isEntryZero(b, absoluteC)) { // Only then do we have to consider this sub-determinante. 665 PolyMinorValue mv; // for storing all intermediate minors 665 666 if (cch.hasKey(subMk)) { // trying to find the result in the cache 666 667 mv = cch.getValue(subMk); … … 679 680 am += mv.getAccumulatedMultiplications(); 680 681 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; 683 687 s++; m++; as++; am++; // This is for the addition and multiplication in the previous line of code. 684 688 } 685 689 sign = - sign; // alternating the sign 686 signPoly = pISet(sign);687 690 } 688 691 } … … 693 696 // the initial sign depends on the relative index of b in minorColumnKey: 694 697 int sign = (mk.getRelativeColumnIndex(b) % 2 == 0 ? 1 : -1); 695 poly signPoly = pISet(sign);698 poly signPoly = NULL; 696 699 for (int r = 0; r < k; r++) { 697 700 int absoluteR = mk.getAbsoluteRowIndex(r); // This iterates over all involved rows. 698 701 MinorKey subMk = mk.getSubMinorKey(absoluteR, b); // This is MinorKey when we omit row absoluteR and column b. 699 702 if (!isEntryZero(absoluteR, b)) { // Only then do we have to consider this sub-determinante. 703 PolyMinorValue mv; // for storing all intermediate minors 700 704 if (cch.hasKey(subMk)) { // trying to find the result in the cache 701 705 mv = cch.getValue(subMk); … … 714 718 am += mv.getAccumulatedMultiplications(); 715 719 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; 718 725 s++; m++; as++; am++; // This is for the addition and multiplication in the previous line of code. 719 726 } 720 727 sign = - sign; // alternating the sign 721 signPoly = pISet(sign);722 728 } 723 729 } … … 727 733 if (s < 0) s = 0; // may happen when all subminors are zero and no addition needs to be performed 728 734 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); 730 737 cch.put(mk, newMV); // Here's the actual put inside the cache. 731 738 return newMV;
Note: See TracChangeset
for help on using the changeset viewer.