| 2299 | } |
| 2300 | |
| 2301 | void rComposeRing(lists L, ring R) |
| 2302 | /* field is R or C */ |
| 2303 | { |
| 2304 | // ---------------------------------------- |
| 2305 | // 0: string: integer |
| 2306 | // no further entries --> Z |
| 2307 | mpz_t modBase; |
| 2308 | unsigned int modExponent = 1; |
| 2309 | |
| 2310 | if (L->nr == 0) |
| 2311 | { |
| 2312 | mpz_init_set_ui(modBase,0); |
| 2313 | modExponent = 1; |
| 2314 | } |
| 2315 | // ---------------------------------------- |
| 2316 | // 1: |
| 2317 | else |
| 2318 | { |
| 2319 | if (L->m[1].rtyp!=LIST_CMD) WerrorS("invalid data, expecting list of numbers"); |
| 2320 | lists LL=(lists)L->m[1].data; |
| 2321 | if ((LL->nr >= 0) && LL->m[0].rtyp == BIGINT_CMD) |
| 2322 | { |
| 2323 | number tmp= (number) LL->m[0].data; // never use CopyD() on list elements |
| 2324 | // assume that tmp is integer, not rational |
| 2325 | mpz_init(modBase); |
| 2326 | n_MPZ (modBase, tmp, coeffs_BIGINT); |
| 2327 | } |
| 2328 | else if (LL->nr >= 0 && LL->m[0].rtyp == INT_CMD) |
| 2329 | { |
| 2330 | mpz_init_set_ui(modBase,(unsigned long) LL->m[0].data); |
| 2331 | } |
| 2332 | else |
| 2333 | { |
| 2334 | mpz_init_set_ui(modBase,0); |
| 2335 | } |
| 2336 | if (LL->nr >= 1) |
| 2337 | { |
| 2338 | modExponent = (unsigned long) LL->m[1].data; |
| 2339 | } |
| 2340 | else |
| 2341 | { |
| 2342 | modExponent = 1; |
| 2343 | } |
| 2344 | } |
| 2345 | // ---------------------------------------- |
| 2346 | if ((mpz_cmp_ui(modBase, 1) == 0) && (mpz_sgn1(modBase) < 0)) |
| 2347 | { |
| 2348 | WerrorS("Wrong ground ring specification (module is 1)"); |
| 2349 | return; |
| 2350 | } |
| 2351 | if (modExponent < 1) |
| 2352 | { |
| 2353 | WerrorS("Wrong ground ring specification (exponent smaller than 1)"); |
| 2354 | return; |
| 2355 | } |
| 2356 | // module is 0 ---> integers |
| 2357 | if (mpz_sgn1(modBase) == 0) |
| 2358 | { |