Changeset a2ed8d6 in git for libpolys


Ignore:
Timestamp:
Jul 4, 2019, 5:13:28 PM (5 years ago)
Author:
tthsqe12 <tthsqe12@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
d7e478b022286a7b9c6c3b8ad497909018f6560d
Parents:
4a01ebd2f5ca06a90cbb276af9f9218468199595
Message:
reorganize
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libpolys/polys/flint_mpoly.cc

    r4a01eb ra2ed8d6  
    1717#include "polys/monomials/p_polys.h"
    1818
     19/****** ring conversion ******/
     20
    1921BOOLEAN convSingRFlintR(fmpq_mpoly_ctx_t ctx, const ring r)
    2022{
     
    3638  return TRUE;
    3739}
     40
     41BOOLEAN 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 ***********/
    3862
    3963void convSingPFlintMP(fmpq_mpoly_t res, fmpq_mpoly_ctx_t ctx, poly p, int lp, const ring r)
     
    89113  return p;
    90114}
     115
     116poly 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
     141void 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 ***********/
    91162
    92163poly Flint_Mult_MP(poly p,int lp, poly q, int lq, fmpq_mpoly_ctx_t ctx, const ring r)
     
    107178}
    108179
    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==8
    139     nmod_mpoly_get_term_exp_ui(exp,f,i,ctx);
    140     p_SetExpVL(pp,(int64*)exp,r);
    141     #else
    142     nmod_mpoly_get_term_exp_ui(&(exp[1]),f,i,ctx);
    143     p_SetExpV(pp,(int*)exp,r);
    144     #endif
    145     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==8
    162     p_GetExpVL(p,(int64*)exp,r);
    163     nmod_mpoly_push_term_ui_ui(res, (ulong)n, exp, ctx);
    164     #else
    165     p_GetExpV(p,(int*)exp,r);
    166     nmod_mpoly_push_term_ui_ui(res, (ulong)n, &(exp[1]), ctx);
    167     #endif
    168     pIter(p);
    169   }
    170   omFreeSize(exp,(r->N+1)*sizeof(ulong));
    171 }
    172 
    173180poly Flint_Mult_MP(poly p,int lp, poly q, int lq, nmod_mpoly_ctx_t ctx, const ring r)
    174181{
     
    237244  return pres;
    238245}
     246
    239247#endif
    240248#endif
Note: See TracChangeset for help on using the changeset viewer.