| 2778 | } |
| 2779 | |
| 2780 | ring rCompose(const lists L, const BOOLEAN check_comp, const long bitmask,const int isLetterplace) |
| 2781 | { |
| 2782 | if ((L->nr!=3) |
| 2783 | #ifdef HAVE_PLURAL |
| 2784 | &&(L->nr!=5) |
| 2785 | #endif |
| 2786 | ) |
| 2787 | return NULL; |
| 2788 | int is_gf_char=0; |
| 2789 | // 0: char/ cf - ring |
| 2790 | // 1: list (var) |
| 2791 | // 2: list (ord) |
| 2792 | // 3: qideal |
| 2793 | // possibly: |
| 2794 | // 4: C |
| 2795 | // 5: D |
| 2796 | |
| 2797 | ring R = (ring) omAlloc0Bin(sip_sring_bin); |
| 2798 | |
| 2799 | // ------------------------------------------------------------------ |
| 2800 | // 0: char: |
| 2801 | if (L->m[0].Typ()==CRING_CMD) |
| 2802 | { |
| 2803 | R->cf=(coeffs)L->m[0].Data(); |
| 2804 | R->cf->ref++; |
| 2805 | } |
| 2806 | else if (L->m[0].Typ()==INT_CMD) |
| 2807 | { |
| 2808 | int ch = (int)(long)L->m[0].Data(); |
| 2809 | assume( ch >= 0 ); |
| 2810 | |
| 2811 | if (ch == 0) // Q? |
| 2812 | R->cf = nInitChar(n_Q, NULL); |
| 2813 | else |
| 2814 | { |
| 2815 | int l = IsPrime(ch); // Zp? |
| 2816 | if( l != ch ) |
| 2817 | { |
| 2818 | Warn("%d is invalid characteristic of ground field. %d is used.", ch, l); |
| 2819 | ch = l; |
| 2820 | } |
| 2821 | #ifndef TEST_ZN_AS_ZP |
| 2822 | R->cf = nInitChar(n_Zp, (void*)(long)ch); |
| 2823 | #else |
| 2824 | mpz_t modBase; |
| 2825 | mpz_init_set_ui(modBase,(long) ch); |
| 2826 | ZnmInfo info; |
| 2827 | info.base= modBase; |
| 2828 | info.exp= 1; |
| 2829 | R->cf=nInitChar(n_Zn,(void*) &info); //exponent is missing |
| 2830 | R->cf->is_field=1; |
| 2831 | R->cf->is_domain=1; |
| 2832 | R->cf->has_simple_Inverse=1; |
| 2833 | #endif |
| 2834 | } |
| 2835 | } |
| 2836 | else if (L->m[0].Typ()==LIST_CMD) // something complicated... |
| 2837 | { |
no test coverage detected