- Timestamp:
- Jul 4, 2019, 5:13:28 PM (5 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- d7e478b022286a7b9c6c3b8ad497909018f6560d
- Parents:
- 4a01ebd2f5ca06a90cbb276af9f9218468199595
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libpolys/polys/flint_mpoly.cc
r4a01eb ra2ed8d6 17 17 #include "polys/monomials/p_polys.h" 18 18 19 /****** ring conversion ******/ 20 19 21 BOOLEAN convSingRFlintR(fmpq_mpoly_ctx_t ctx, const ring r) 20 22 { … … 36 38 return TRUE; 37 39 } 40 41 BOOLEAN convSingRFlintR(nmod_mpoly_ctx_t ctx, const ring r) 42 { 43 if (rRing_ord_pure_dp(r)) 44 { 45 nmod_mpoly_ctx_init(ctx,r->N,ORD_DEGREVLEX,r->cf->ch); 46 return FALSE; 47 } 48 else if (rRing_ord_pure_Dp(r)) 49 { 50 nmod_mpoly_ctx_init(ctx,r->N,ORD_DEGLEX,r->cf->ch); 51 return FALSE; 52 } 53 else if (rRing_ord_pure_lp(r)) 54 { 55 nmod_mpoly_ctx_init(ctx,r->N,ORD_LEX,r->cf->ch); 56 return FALSE; 57 } 58 return TRUE; 59 } 60 61 /******** polynomial conversion ***********/ 38 62 39 63 void convSingPFlintMP(fmpq_mpoly_t res, fmpq_mpoly_ctx_t ctx, poly p, int lp, const ring r) … … 89 113 return p; 90 114 } 115 116 poly convFlintMPSingP(nmod_mpoly_t f, nmod_mpoly_ctx_t ctx, const ring r) 117 { 118 int d=nmod_mpoly_length(f,ctx)-1; 119 poly p=NULL; 120 ulong* exp=(ulong*)omAlloc0((r->N+1)*sizeof(ulong)); 121 for(int i=d; i>=0; i--) 122 { 123 ulong c=nmod_mpoly_get_term_coeff_ui(f,i,ctx); 124 poly pp=p_Init(r); 125 #if SIZEOF_LONG==8 126 nmod_mpoly_get_term_exp_ui(exp,f,i,ctx); 127 p_SetExpVL(pp,(int64*)exp,r); 128 #else 129 nmod_mpoly_get_term_exp_ui(&(exp[1]),f,i,ctx); 130 p_SetExpV(pp,(int*)exp,r); 131 #endif 132 p_Setm(pp,r); 133 pSetCoeff0(pp,(number)c); 134 pNext(pp)=p; 135 p=pp; 136 } 137 p_Test(p,r); 138 return p; 139 } 140 141 void convSingPFlintMP(nmod_mpoly_t res, nmod_mpoly_ctx_t ctx, poly p, int lp,const ring r) 142 { 143 nmod_mpoly_init2(res, lp, ctx); 144 ulong* exp=(ulong*)omAlloc((r->N+1)*sizeof(ulong)); 145 while(p!=NULL) 146 { 147 number n=pGetCoeff(p); 148 #if SIZEOF_LONG==8 149 p_GetExpVL(p,(int64*)exp,r); 150 nmod_mpoly_push_term_ui_ui(res, (ulong)n, exp, ctx); 151 #else 152 p_GetExpV(p,(int*)exp,r); 153 nmod_mpoly_push_term_ui_ui(res, (ulong)n, &(exp[1]), ctx); 154 #endif 155 pIter(p); 156 } 157 omFreeSize(exp,(r->N+1)*sizeof(ulong)); 158 } 159 160 161 /****** polynomial operations ***********/ 91 162 92 163 poly Flint_Mult_MP(poly p,int lp, poly q, int lq, fmpq_mpoly_ctx_t ctx, const ring r) … … 107 178 } 108 179 109 BOOLEAN convSingRFlintR(nmod_mpoly_ctx_t ctx, const ring r)110 {111 if (rRing_ord_pure_dp(r))112 {113 nmod_mpoly_ctx_init(ctx,r->N,ORD_DEGREVLEX,r->cf->ch);114 return FALSE;115 }116 else if (rRing_ord_pure_Dp(r))117 {118 nmod_mpoly_ctx_init(ctx,r->N,ORD_DEGLEX,r->cf->ch);119 return FALSE;120 }121 else if (rRing_ord_pure_lp(r))122 {123 nmod_mpoly_ctx_init(ctx,r->N,ORD_LEX,r->cf->ch);124 return FALSE;125 }126 return TRUE;127 }128 129 poly convFlintMPSingP(nmod_mpoly_t f, nmod_mpoly_ctx_t ctx, const ring r)130 {131 int d=nmod_mpoly_length(f,ctx)-1;132 poly p=NULL;133 ulong* exp=(ulong*)omAlloc0((r->N+1)*sizeof(ulong));134 for(int i=d; i>=0; i--)135 {136 ulong c=nmod_mpoly_get_term_coeff_ui(f,i,ctx);137 poly pp=p_Init(r);138 #if SIZEOF_LONG==8139 nmod_mpoly_get_term_exp_ui(exp,f,i,ctx);140 p_SetExpVL(pp,(int64*)exp,r);141 #else142 nmod_mpoly_get_term_exp_ui(&(exp[1]),f,i,ctx);143 p_SetExpV(pp,(int*)exp,r);144 #endif145 p_Setm(pp,r);146 pSetCoeff0(pp,(number)c);147 pNext(pp)=p;148 p=pp;149 }150 p_Test(p,r);151 return p;152 }153 154 void convSingPFlintMP(nmod_mpoly_t res, nmod_mpoly_ctx_t ctx, poly p, int lp,const ring r)155 {156 nmod_mpoly_init2(res, lp, ctx);157 ulong* exp=(ulong*)omAlloc((r->N+1)*sizeof(ulong));158 while(p!=NULL)159 {160 number n=pGetCoeff(p);161 #if SIZEOF_LONG==8162 p_GetExpVL(p,(int64*)exp,r);163 nmod_mpoly_push_term_ui_ui(res, (ulong)n, exp, ctx);164 #else165 p_GetExpV(p,(int*)exp,r);166 nmod_mpoly_push_term_ui_ui(res, (ulong)n, &(exp[1]), ctx);167 #endif168 pIter(p);169 }170 omFreeSize(exp,(r->N+1)*sizeof(ulong));171 }172 173 180 poly Flint_Mult_MP(poly p,int lp, poly q, int lq, nmod_mpoly_ctx_t ctx, const ring r) 174 181 { … … 237 244 return pres; 238 245 } 246 239 247 #endif 240 248 #endif
Note: See TracChangeset
for help on using the changeset viewer.