/////////////// rInit itself: INPUT: pn: ch & parameter (names), rv: variable (names) ord: ordering (all !=NULL) RETURN: currRingHdl on success NULL on error NOTE: * makes new ring to current ring, on success considers input sleftv's as read-only
| 5618 | // NOTE: * makes new ring to current ring, on success |
| 5619 | // * considers input sleftv's as read-only |
| 5620 | ring rInit(leftv pn, leftv rv, leftv ord) |
| 5621 | { |
| 5622 | int float_len=0; |
| 5623 | int float_len2=0; |
| 5624 | ring R = NULL; |
| 5625 | //BOOLEAN ffChar=FALSE; |
| 5626 | |
| 5627 | /* ch -------------------------------------------------------*/ |
| 5628 | // get ch of ground field |
| 5629 | |
| 5630 | // allocated ring |
| 5631 | R = (ring) omAlloc0Bin(sip_sring_bin); |
| 5632 | |
| 5633 | coeffs cf = NULL; |
| 5634 | |
| 5635 | assume( pn != NULL ); |
| 5636 | const int P = pn->listLength(); |
| 5637 | |
| 5638 | if (pn->Typ()==CRING_CMD) |
| 5639 | { |
| 5640 | cf=(coeffs)pn->CopyD(); |
| 5641 | leftv pnn=pn; |
| 5642 | if(P>1) /*parameter*/ |
| 5643 | { |
| 5644 | pnn = pnn->next; |
| 5645 | const int pars = pnn->listLength(); |
| 5646 | assume( pars > 0 ); |
| 5647 | char ** names = (char**)omAlloc0(pars * sizeof(char_ptr)); |
| 5648 | |
| 5649 | if (rSleftvList2StringArray(pnn, names)) |
| 5650 | { |
| 5651 | WerrorS("parameter expected"); |
| 5652 | goto rInitError; |
| 5653 | } |
| 5654 | |
| 5655 | TransExtInfo extParam; |
| 5656 | |
| 5657 | extParam.r = rDefault( cf, pars, names); // Q/Zp [ p_1, ... p_pars ] |
| 5658 | for(int i=pars-1; i>=0;i--) |
| 5659 | { |
| 5660 | omFree(names[i]); |
| 5661 | } |
| 5662 | omFree(names); |
| 5663 | |
| 5664 | cf = nInitChar(n_transExt, &extParam); |
| 5665 | } |
| 5666 | assume( cf != NULL ); |
| 5667 | } |
| 5668 | else if (pn->Typ()==INT_CMD) |
| 5669 | { |
| 5670 | int ch = (int)(long)pn->Data(); |
| 5671 | leftv pnn=pn; |
| 5672 | |
| 5673 | /* parameter? -------------------------------------------------------*/ |
| 5674 | pnn = pnn->next; |
| 5675 | |
| 5676 | if (pnn == NULL) // no params!? |
| 5677 | { |
no test coverage detected