| 352 | */ |
| 353 | |
| 354 | ideal fast_map_common_subexp(const ideal map_id,const ring map_r,const ideal image_id,const ring image_r) |
| 355 | { |
| 356 | ring src_r, dest_r; |
| 357 | ideal dest_id/*, res_id*/; |
| 358 | int length = 0; |
| 359 | BOOLEAN no_sort; |
| 360 | |
| 361 | // construct rings we work in: |
| 362 | // src_r: Wp with Weights set to length of poly in image_id |
| 363 | // dest_r: Simple ring without degree ordering and short exponents |
| 364 | maMap_CreateRings(map_id, map_r, image_id, image_r, src_r, dest_r, no_sort); |
| 365 | |
| 366 | // construct dest_id |
| 367 | if (dest_r != image_r) |
| 368 | { |
| 369 | dest_id = idrShallowCopyR(image_id, image_r, dest_r); |
| 370 | } |
| 371 | else |
| 372 | dest_id = image_id; |
| 373 | |
| 374 | // construct mpoly and mideal |
| 375 | mapoly mp; |
| 376 | maideal mideal; |
| 377 | maMap_CreatePolyIdeal(map_id, map_r, src_r, dest_r, mp, mideal); |
| 378 | |
| 379 | if (TEST_OPT_PROT) |
| 380 | { |
| 381 | maPoly_GetLength(mp, length); |
| 382 | Print("map[%ld:%d]{%d:", dest_r->bitmask, dest_r->ExpL_Size, length); |
| 383 | } |
| 384 | |
| 385 | // do the optimization step |
| 386 | #if HAVE_MAP_OPTIMIZE > 0 |
| 387 | if (mp!=NULL) maPoly_Optimize(mp, src_r); |
| 388 | #endif |
| 389 | if (TEST_OPT_PROT) |
| 390 | { |
| 391 | maPoly_GetLength(mp, length); |
| 392 | Print("%d}", length); |
| 393 | } |
| 394 | |
| 395 | // do the actual evaluation |
| 396 | maPoly_Eval(mp, src_r, dest_id, dest_r, length); |
| 397 | if (TEST_OPT_PROT) PrintS("."); |
| 398 | |
| 399 | // collect the results back into an ideal, clean up mideal |
| 400 | ideal res_dest_id = maIdeal_2_Ideal(mideal, dest_r); |
| 401 | if (TEST_OPT_PROT) PrintS("."); |
| 402 | |
| 403 | // convert result back to image_r |
| 404 | ideal res_image_id; |
| 405 | if (dest_r != image_r) |
| 406 | { |
| 407 | //if (no_sort) see Old/m134si.tst |
| 408 | // res_image_id = idrShallowCopyR_NoSort(res_dest_id, dest_r, image_r); |
| 409 | //else |
| 410 | res_image_id = idrShallowCopyR(res_dest_id, dest_r, image_r); |
| 411 | id_ShallowDelete(&res_dest_id, dest_r); |
no test coverage detected