Changeset e63e239 in git
- Timestamp:
- Jan 19, 2002, 6:11:43 PM (22 years ago)
- Branches:
- (u'spielwiese', 'e7cc1ebecb61be8b9ca6c18016352af89940b21a')
- Children:
- b9020c376e237c88f9dffd14d84ef432f4734b95
- Parents:
- 33293b6db9d4cea6e4dd38872ad570795569fc75
- Location:
- Singular
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/fast_maps.cc
r33293b6 re63e239 7 7 * Author: obachman (Olaf Bachmann) 8 8 * Created: 02/01 9 * Version: $Id: fast_maps.cc,v 1.1 5 2002-01-19 16:14:46 SingularExp $9 * Version: $Id: fast_maps.cc,v 1.16 2002-01-19 17:11:42 obachman Exp $ 10 10 *******************************************************************/ 11 11 #include "mod2.h" … … 18 18 #include "fast_maps.h" 19 19 20 // define if you want to use special dest_ring 21 #define HAVE_DEST_R 1 22 // define if you want to use special src_ring 23 #define HAVE_SRC_R 0 24 // define if you want to use optimization step 25 #define HAVE_MAP_OPTIMIZATION 0 26 27 28 29 /******************************************************************************* 30 ** 31 *F maMaxExp . . . . . . . . . . . . returns maximal exponent of result of map 32 */ 33 // return maximal monomial if max_map_monomials are substituted into pi_m 34 static poly maGetMaxExpP(poly* max_map_monomials, 35 int n_max_map_monomials, ring map_r, 36 poly pi_m, ring pi_r) 37 { 38 int n = min(pi_r->N, n_max_map_monomials); 39 int i, j; 40 Exponent_t e_i, e_j; 41 poly m_i, map_j = p_Init(map_r); 42 43 for (i=1; i <= n; i++) 44 { 45 e_i = p_GetExp(pi_m, i, pi_r); 46 m_i = max_map_monomials[i-1]; 47 if (e_i > 0 && m_i != NULL && ! p_IsConstantComp(m_i, map_r)) 48 { 49 for (j = 1; j<= map_r->N; j++) 50 { 51 e_j = p_GetExp(m_i, j, map_r); 52 if (e_j > 0) 53 { 54 p_AddExp(map_j, j, e_j*e_i, map_r); 55 } 56 } 57 } 58 } 59 return map_j; 60 } 61 62 // returns maximal exponent if map_id is applied to pi_id 63 static Exponent_t maGetMaxExp(ideal map_id, ring map_r, ideal pi_id, ring pi_r) 64 { 65 Exponent_t max=0; 66 poly* max_map_monomials = (poly*) omAlloc(IDELEMS(map_id)*sizeof(poly)); 67 poly max_pi_i, max_map_i; 68 69 int i, j; 70 for (i=0; i<IDELEMS(map_id); i++) 71 { 72 max_map_monomials[i] = p_GetMaxExpP(map_id->m[i], map_r); 73 } 74 75 for (i=0; i<IDELEMS(pi_id); i++) 76 { 77 max_pi_i = p_GetMaxExpP(pi_id->m[i], pi_r); 78 max_map_i = maGetMaxExpP(max_map_monomials, IDELEMS(map_id), map_r, 79 max_pi_i, pi_r); 80 Exponent_t temp = p_GetMaxExp(max_map_i, map_r); 81 if (temp > max){ 82 max=temp; 83 } 84 85 p_LmFree(max_pi_i, pi_r); 86 p_LmFree(max_map_i, map_r); 87 } 88 return max; 89 } 90 91 20 92 #if 0 21 93 // paste into extra.cc … … 52 124 53 125 #endif 126 54 127 /******************************************************************************* 55 128 ** … … 222 295 } 223 296 297 224 298 void maMap_CreateRings(ideal map_id, ring map_r, 225 299 ideal image_id, ring image_r, 226 300 ring &src_r, ring &dest_r) 227 301 { 302 #if HAVE_SRC_R > 0 303 #else 228 304 src_r = map_r; 305 #endif 306 307 #if HAVE_DEST_R > 0 308 Exponent_t maxExp = maGetMaxExp(map_id, map_r, image_id, map_r); 309 dest_r = rModifyRing_Simple(image_r, TRUE, TRUE, maxExp); 310 #else 229 311 dest_r = image_r; 230 } 231 312 #endif 313 } 314 315 void maMap_KillRings(ring map_r, ring image_r, ring src_r, ring dest_r) 316 { 317 if (map_r != src_r) 318 rKillModified_Wp_Ring(src_r); 319 if (image_r != dest_r) 320 rKillModifiedRing_Simple(dest_r); 321 } 322 232 323 ideal maIdeal_2_Ideal(maideal m_id, ring dest_r) 233 324 { … … 247 338 { 248 339 ring src_r, dest_r; 340 ideal dest_id, res_id; 341 342 // construct rings we work in: 343 // src_r: Wp with Weights set to length of poly in image_id 344 // dest_r: Simple ring without degree ordering and short exponents 249 345 maMap_CreateRings(map_id, map_r, image_id, image_r, src_r, dest_r); 250 346 347 // construct dest_id 348 if (dest_r != image_r) 349 dest_id = idrShallowCopyR(image_id, image_r, dest_r); 350 else 351 dest_id = image_id; 352 353 // construct mpoly and mideal 251 354 mapoly mp; 252 355 maideal mideal; 253 356 maMap_CreatePolyIdeal(map_id, map_r, src_r, dest_r, mp, mideal); 254 maPoly_Eval(mp, src_r, image_id, dest_r); 255 256 return maIdeal_2_Ideal(mideal, dest_r); 257 } 357 358 // do the optimization step 359 #if HAVE_MAP_OPTIMIZE > 0 360 maPoly_Optimize(mp, src_r); 361 #endif 362 363 // do the actual evaluation 364 maPoly_Eval(mp, src_r, dest_id, dest_r); 365 366 // collect the results back into an ideal 367 ideal res_dest_id = maIdeal_2_Ideal(mideal, dest_r); 368 369 // convert result back to image_r 370 ideal res_image_id; 371 if (dest_r != image_r) 372 { 373 res_image_id = idrShallowCopyR(res_dest_id, dest_r, image_r); 374 id_ShallowDelete(&res_dest_id, dest_r); 375 } 376 else 377 res_image_id = res_dest_id; 378 379 // clean-up the rings 380 maMap_KillRings(map_r, image_r, src_r, dest_r); 381 382 return res_image_id; 383 } 384 258 385 259 386 #if 0 -
Singular/ring.cc
r33293b6 re63e239 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: ring.cc,v 1.17 5 2002-01-19 14:48:18obachman Exp $ */4 /* $Id: ring.cc,v 1.176 2002-01-19 17:11:42 obachman Exp $ */ 5 5 6 6 /* … … 2657 2657 } 2658 2658 2659 // construct lp ring 2660 ring rModifyRing_Simple(ring r, BOOLEAN ommit_degree, BOOLEAN ommit_comp, int exp_limit) 2661 { 2662 if (!rHasSimpleOrder(r)) 2663 WarnS("Hannes: you still need to implement this"); 2664 return rModifyRing(r, ommit_degree, ommit_comp, exp_limit); 2665 } 2666 2667 void rKillModifiedRing_Simple(ring r) 2668 { 2669 rKillModifiedRing(r); 2670 } 2671 2659 2672 2660 2673 void rKillModifiedRing(ring r) -
Singular/ring.h
r33293b6 re63e239 7 7 * ABSTRACT - the interpreter related ring operations 8 8 */ 9 /* $Id: ring.h,v 1. 69 2002-01-19 14:48:19obachman Exp $ */9 /* $Id: ring.h,v 1.70 2002-01-19 17:11:43 obachman Exp $ */ 10 10 11 11 /* includes */ … … 268 268 void rKillModified_Wp_Ring(ring r); 269 269 270 ring rModifyRing_Simple(ring r, BOOLEAN omit_degree, BOOLEAN omit_comp, unsigned long exp_limit); 271 void rKillModifiedRing_Simple(ring r); 272 270 273 void rDebugPrint(ring r); 271 274 void pDebugPrint(poly p);
Note: See TracChangeset
for help on using the changeset viewer.