MCPcopy Create free account
hub / github.com/Singular/Singular / charPoly

Function charPoly

kernel/linear_algebra/linearAlgebra.cc:748–779  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

746}
747
748bool charPoly(const matrix aMat, poly &charPoly)
749{
750 if (MATROWS(aMat) != 2) return false;
751 if (MATCOLS(aMat) != 2) return false;
752 number b = nInit(0); number t;
753 if (MATELEM(aMat, 1, 1) != NULL)
754 { t = nAdd(b, pGetCoeff(MATELEM(aMat, 1, 1))); nDelete(&b); b = t;}
755 if (MATELEM(aMat, 2, 2) != NULL)
756 { t = nAdd(b, pGetCoeff(MATELEM(aMat, 2, 2))); nDelete(&b); b = t;}
757 b = nInpNeg(b);
758 number t1;
759 if ((MATELEM(aMat, 1, 1) != NULL) && (MATELEM(aMat, 2, 2) != NULL))
760 t1 = nMult(pGetCoeff(MATELEM(aMat, 1, 1)),
761 pGetCoeff(MATELEM(aMat, 2, 2)));
762 else t1 = nInit(0);
763 number t2;
764 if ((MATELEM(aMat, 1, 2) != NULL) && (MATELEM(aMat, 2, 1) != NULL))
765 t2 = nMult(pGetCoeff(MATELEM(aMat, 1, 2)),
766 pGetCoeff(MATELEM(aMat, 2, 1)));
767 else t2 = nInit(0);
768 number c = nSub(t1, t2); nDelete(&t1); nDelete(&t2);
769 poly p = pOne(); pSetExp(p, 1, 2); pSetm(p);
770 poly q = NULL;
771 if (!nIsZero(b))
772 { q = pOne(); pSetExp(q, 1, 1); pSetm(q); pSetCoeff(q, b); }
773 poly r = NULL;
774 if (!nIsZero(c))
775 { r = pOne(); pSetCoeff(r, c); }
776 p = pAdd(p, q); p = pAdd(p, r);
777 charPoly = p;
778 return true;
779}
780
781void swapRows(int row1, int row2, matrix& aMat)
782{

Callers 1

qrDSFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected