| 1511 | *************************************************************************/ |
| 1512 | VAR int Xnlev; |
| 1513 | intvec* Mfpertvector(ideal G, intvec* ivtarget) |
| 1514 | { |
| 1515 | int i, j, nG = IDELEMS(G); |
| 1516 | int nV = currRing->N; |
| 1517 | int niv = nV*nV; |
| 1518 | |
| 1519 | |
| 1520 | // Calculate maxA = Max(A2) + Max(A3) + ... + Max(AnV), |
| 1521 | // where the Ai are the i-te rows of the matrix 'targer_ord'. |
| 1522 | int ntemp, maxAi, maxA=0; |
| 1523 | for(i=1; i<nV; i++) |
| 1524 | { |
| 1525 | maxAi = (*ivtarget)[i*nV]; |
| 1526 | if(maxAi<0) |
| 1527 | { |
| 1528 | maxAi = -maxAi; |
| 1529 | } |
| 1530 | for(j=i*nV+1; j<(i+1)*nV; j++) |
| 1531 | { |
| 1532 | ntemp = (*ivtarget)[j]; |
| 1533 | if(ntemp < 0) |
| 1534 | { |
| 1535 | ntemp = -ntemp; |
| 1536 | } |
| 1537 | if(ntemp > maxAi) |
| 1538 | { |
| 1539 | maxAi = ntemp; |
| 1540 | } |
| 1541 | } |
| 1542 | maxA = maxA + maxAi; |
| 1543 | } |
| 1544 | intvec* ivUnit = Mivdp(nV); |
| 1545 | |
| 1546 | // Calculate inveps = 1/eps, where 1/eps > deg(p)*maxA for all p in G. |
| 1547 | mpz_t tot_deg; mpz_init(tot_deg); |
| 1548 | mpz_t maxdeg; mpz_init(maxdeg); |
| 1549 | mpz_t inveps; mpz_init(inveps); |
| 1550 | |
| 1551 | |
| 1552 | for(i=nG-1; i>=0; i--) |
| 1553 | { |
| 1554 | mpz_set_ui(maxdeg, MwalkWeightDegree(G->m[i], ivUnit)); |
| 1555 | if (mpz_cmp(maxdeg, tot_deg) > 0 ) |
| 1556 | { |
| 1557 | mpz_set(tot_deg, maxdeg); |
| 1558 | } |
| 1559 | } |
| 1560 | |
| 1561 | delete ivUnit; |
| 1562 | //inveps = (tot_deg * maxA) + 1; |
| 1563 | mpz_mul_ui(inveps, tot_deg, maxA); |
| 1564 | mpz_add_ui(inveps, inveps, 1); |
| 1565 | |
| 1566 | // takes "small" inveps |
| 1567 | #ifdef INVEPS_SMALL_IN_FRACTAL |
| 1568 | if(mpz_cmp_ui(inveps, nV)>0 && nV > 3) |
| 1569 | { |
| 1570 | mpz_cdiv_q_ui(inveps, inveps, nV); |
no test coverage detected