| 456 | } |
| 457 | |
| 458 | number fglmVector::gcd () const |
| 459 | { |
| 460 | int i = rep->size (); |
| 461 | BOOLEAN found = FALSE; |
| 462 | BOOLEAN gcdIsOne = FALSE; |
| 463 | number theGcd; |
| 464 | number current; |
| 465 | while(i > 0 && !found) |
| 466 | { |
| 467 | current = rep->getconstelem (i); |
| 468 | if(!nIsZero (current)) |
| 469 | { |
| 470 | theGcd = nCopy (current); |
| 471 | found = TRUE; |
| 472 | if(!nGreaterZero (theGcd)) |
| 473 | { |
| 474 | theGcd = nInpNeg (theGcd); |
| 475 | } |
| 476 | if(nIsOne (theGcd)) |
| 477 | gcdIsOne = TRUE; |
| 478 | } |
| 479 | i--; |
| 480 | } |
| 481 | if(found) |
| 482 | { |
| 483 | if (getCoeffType(currRing->cf)!=n_Zp) |
| 484 | { |
| 485 | while(i > 0 && !gcdIsOne) |
| 486 | { |
| 487 | current = rep->getconstelem (i); |
| 488 | if(!nIsZero (current)) |
| 489 | { |
| 490 | number temp = n_SubringGcd (theGcd, current, currRing->cf); |
| 491 | nDelete (&theGcd); |
| 492 | theGcd = temp; |
| 493 | if(nIsOne (theGcd)) |
| 494 | gcdIsOne = TRUE; |
| 495 | } |
| 496 | i--; |
| 497 | } |
| 498 | } |
| 499 | } |
| 500 | else |
| 501 | theGcd = nInit (0); |
| 502 | return theGcd; |
| 503 | } |
| 504 | |
| 505 | number fglmVector::clearDenom () |
| 506 | { |
no test coverage detected