converts mat to module, destroys mat
| 1483 | |
| 1484 | /// converts mat to module, destroys mat |
| 1485 | ideal id_Matrix2Module(matrix mat, const ring R) |
| 1486 | { |
| 1487 | int mc=MATCOLS(mat); |
| 1488 | int mr=MATROWS(mat); |
| 1489 | ideal result = idInit(mc,mr); |
| 1490 | int i,j,l; |
| 1491 | poly h; |
| 1492 | sBucket_pt bucket = sBucketCreate(R); |
| 1493 | |
| 1494 | for(j=0;j<mc /*MATCOLS(mat)*/;j++) /* j is also index in result->m */ |
| 1495 | { |
| 1496 | for (i=0;i<mr /*MATROWS(mat)*/;i++) |
| 1497 | { |
| 1498 | h = MATELEM0(mat,i,j); |
| 1499 | if (h!=NULL) |
| 1500 | { |
| 1501 | l=pLength(h); |
| 1502 | MATELEM0(mat,i,j)=NULL; |
| 1503 | p_SetCompP(h,i+1, R); |
| 1504 | sBucket_Merge_p(bucket, h, l); |
| 1505 | } |
| 1506 | } |
| 1507 | sBucketClearMerge(bucket, &(result->m[j]), &l); |
| 1508 | } |
| 1509 | sBucketDestroy(&bucket); |
| 1510 | |
| 1511 | // obachman: need to clean this up |
| 1512 | id_Delete((ideal*) &mat,R); |
| 1513 | return result; |
| 1514 | } |
| 1515 | |
| 1516 | /*2 |
| 1517 | * converts a module into a matrix, destroyes the input |
no test coverage detected