645{
646 if(ncol != nrow)
647 {
error(
"G4ErrorMatrix::invert: G4ErrorMatrix is not NxN"); }
648
651
652 if (ncol > max_array)
653 {
654 delete [] ir;
655 max_array = nrow;
656 ir =
new G4int [max_array+1];
657 }
661 switch(nrow)
662 {
663 case 3:
664 G4double c11,c12,c13,c21,c22,c23,c31,c32,c33;
665 ifail = 0;
666 c11 = (*(m.begin()+4)) * (*(m.begin()+8))
667 - (*(m.begin()+5)) * (*(m.begin()+7));
668 c12 = (*(m.begin()+5)) * (*(m.begin()+6))
669 - (*(m.begin()+3)) * (*(m.begin()+8));
670 c13 = (*(m.begin()+3)) * (*(m.begin()+7))
671 - (*(m.begin()+4)) * (*(m.begin()+6));
672 c21 = (*(m.begin()+7)) * (*(m.begin()+2))
673 - (*(m.begin()+8)) * (*(m.begin()+1));
674 c22 = (*(m.begin()+8)) * (*m.begin())
675 - (*(m.begin()+6)) * (*(m.begin()+2));
676 c23 = (*(m.begin()+6)) * (*(m.begin()+1))
677 - (*(m.begin()+7)) * (*m.begin());
678 c31 = (*(m.begin()+1)) * (*(m.begin()+5))
679 - (*(m.begin()+2)) * (*(m.begin()+4));
680 c32 = (*(m.begin()+2)) * (*(m.begin()+3))
681 - (*m.begin()) * (*(m.begin()+5));
682 c33 = (*m.begin()) * (*(m.begin()+4))
683 - (*(m.begin()+1)) * (*(m.begin()+3));
684 t1 = std::fabs(*m.begin());
685 t2 = std::fabs(*(m.begin()+3));
686 t3 = std::fabs(*(m.begin()+6));
687 if (t1 >= t2)
688 {
689 if (t3 >= t1)
690 {
691 temp = *(m.begin()+6);
692 det = c23*c12-c22*c13;
693 }
694 else
695 {
696 temp = *(m.begin());
697 det = c22*c33-c23*c32;
698 }
699 }
700 else if (t3 >= t2)
701 {
702 temp = *(m.begin()+6);
703 det = c23*c12-c22*c13;
704 }
705 else
706 {
707 temp = *(m.begin()+3);
708 det = c13*c32-c12*c33;
709 }
710 if (det==0)
711 {
712 ierr = 1;
713 return;
714 }
715 {
716 ss = temp/det;
718 *(mq++) = ss*c11;
719 *(mq++) = ss*c21;
720 *(mq++) = ss*c31;
721 *(mq++) = ss*c12;
722 *(mq++) = ss*c22;
723 *(mq++) = ss*c32;
724 *(mq++) = ss*c13;
725 *(mq++) = ss*c23;
726 *(mq) = ss*c33;
727 }
728 break;
729 case 2:
730 ifail = 0;
731 det = (*m.begin())*(*(m.begin()+3)) - (*(m.begin()+1))*(*(m.begin()+2));
732 if (det==0)
733 {
734 ierr = 1;
735 return;
736 }
737 ss = 1.0/det;
738 temp = ss*(*(m.begin()+3));
739 *(m.begin()+1) *= -ss;
740 *(m.begin()+2) *= -ss;
741 *(m.begin()+3) = ss*(*m.begin());
742 *(m.begin()) = temp;
743 break;
744 case 1:
745 ifail = 0;
746 if ((*(m.begin()))==0)
747 {
748 ierr = 1;
749 return;
750 }
751 *(m.begin()) = 1.0/(*(m.begin()));
752 break;
753 case 4:
755 return;
756 case 5:
758 return;
759 case 6:
761 return;
762 default:
763 ifail = dfact_matrix(det, ir);
764 if(ifail) {
765 ierr = 1;
766 return;
767 }
768 dfinv_matrix(ir);
769 break;
770 }
771 ierr = 0;
772 return;
773}
virtual void invertHaywood4(G4int &ierr)
virtual void invertHaywood5(G4int &ierr)
virtual void invertHaywood6(G4int &ierr)