2 * converts a module into a matrix, destroyes the input */
| 1517 | * converts a module into a matrix, destroyes the input |
| 1518 | */ |
| 1519 | matrix id_Module2Matrix(ideal mod, const ring R) |
| 1520 | { |
| 1521 | matrix result = mpNew(mod->rank,IDELEMS(mod)); |
| 1522 | long i; long cp; |
| 1523 | poly p,h; |
| 1524 | |
| 1525 | for(i=0;i<IDELEMS(mod);i++) |
| 1526 | { |
| 1527 | p=pReverse(mod->m[i]); |
| 1528 | mod->m[i]=NULL; |
| 1529 | while (p!=NULL) |
| 1530 | { |
| 1531 | h=p; |
| 1532 | pIter(p); |
| 1533 | pNext(h)=NULL; |
| 1534 | cp = si_max(1L,p_GetComp(h, R)); // if used for ideals too |
| 1535 | //cp = p_GetComp(h,R); |
| 1536 | p_SetComp(h,0,R); |
| 1537 | p_SetmComp(h,R); |
| 1538 | #ifdef TEST |
| 1539 | if (cp>mod->rank) |
| 1540 | { |
| 1541 | Print("## inv. rank %ld -> %ld\n",mod->rank,cp); |
| 1542 | int k,l,o=mod->rank; |
| 1543 | mod->rank=cp; |
| 1544 | matrix d=mpNew(mod->rank,IDELEMS(mod)); |
| 1545 | for (l=0; l<o; l++) |
| 1546 | { |
| 1547 | for (k=0; k<IDELEMS(mod); k++) |
| 1548 | { |
| 1549 | MATELEM0(d,l,k)=MATELEM0(result,l,k); |
| 1550 | MATELEM0(result,l,k)=NULL; |
| 1551 | } |
| 1552 | } |
| 1553 | id_Delete((ideal *)&result,R); |
| 1554 | result=d; |
| 1555 | } |
| 1556 | #endif |
| 1557 | MATELEM0(result,cp-1,i) = p_Add_q(MATELEM0(result,cp-1,i),h,R); |
| 1558 | } |
| 1559 | } |
| 1560 | // obachman 10/99: added the following line, otherwise memory leack! |
| 1561 | id_Delete(&mod,R); |
| 1562 | return result; |
| 1563 | } |
| 1564 | |
| 1565 | matrix id_Module2formatedMatrix(ideal mod,int rows, int cols, const ring R) |
| 1566 | { |
no test coverage detected