| 1043 | } |
| 1044 | |
| 1045 | static ideal |
| 1046 | GroebnerViaFunctionals( const idealFunctionals & l, |
| 1047 | fglmVector iv = fglmVector() ) |
| 1048 | // If iv is zero, calculates the groebnerBasis for the ideal which is |
| 1049 | // defined by l. |
| 1050 | // If iv is not zero, then the groebnerBasis if i:p is calculated where |
| 1051 | // i is defined by l and iv is the vector-representation of nf(p) wrt. i |
| 1052 | // The dimension of l has to be finite. |
| 1053 | // The result is in reduced form. |
| 1054 | { |
| 1055 | fglmDdata data( l.dimen() ); |
| 1056 | |
| 1057 | // insert pOne() and update workinglist according to iv: |
| 1058 | fglmVector initv; |
| 1059 | if ( iv.isZero() ) { |
| 1060 | // STICKYPROT("initv is zero\n"); |
| 1061 | initv = fglmVector( l.dimen(), 1 ); |
| 1062 | } |
| 1063 | else { |
| 1064 | // STICKYPROT("initv is not zero\n"); |
| 1065 | initv = iv; |
| 1066 | } |
| 1067 | |
| 1068 | poly one = pOne(); |
| 1069 | data.updateCandidates( one, initv ); |
| 1070 | number nOne = nInit( 1 ); |
| 1071 | data.newBasisElem( one, initv, fglmVector( 1, 1 ), nOne ); |
| 1072 | STICKYPROT( "." ); |
| 1073 | while ( data.candidatesLeft() == TRUE ) { |
| 1074 | fglmDelem candidate = data.nextCandidate(); |
| 1075 | if ( candidate.isBasisOrEdge() == TRUE ) { |
| 1076 | // Now we have the chance to find a new groebner polynomial |
| 1077 | |
| 1078 | // v is the vector-representation of candidate.monom |
| 1079 | // some elements of v are zeroed in data.gaussreduce(). Which |
| 1080 | // ones and how this was done is stored in p. |
| 1081 | // originalV contains the unchanged v, which is later inserted |
| 1082 | // into the working list (via data.updateCandidates(). |
| 1083 | fglmVector v = l.multiply( candidate.v, candidate.var ); |
| 1084 | fglmVector originalV = v; |
| 1085 | fglmVector p( data.getBasisSize()+1, data.getBasisSize()+1 ); |
| 1086 | number pdenom = NULL; |
| 1087 | data.gaussreduce( v, p, pdenom ); |
| 1088 | if ( v.isZero() ) { |
| 1089 | // Now v is linear dependent to the already found basis elements. |
| 1090 | // This means that v (resp. candidate.monom) is the leading |
| 1091 | // monomial of the next groebner-basis polynomial. |
| 1092 | data.newGroebnerPoly( p, candidate.monom ); |
| 1093 | nDelete( & pdenom ); |
| 1094 | STICKYPROT( "+" ); |
| 1095 | } |
| 1096 | else { |
| 1097 | // no linear dependence could be found, so v ( rsp. monom ) |
| 1098 | // is a basis monomial. We store the zeroed version ( i.e. v |
| 1099 | // and not originalV ) as well as p, the denomiator and all |
| 1100 | // the other stuff. |
| 1101 | // erst updateCandidates, dann newBasisELem!!! |
| 1102 | data.updateCandidates( candidate.monom, originalV ); |
no test coverage detected