Changeset 58603f in git for factory/FLINTconvert.cc


Ignore:
Timestamp:
Aug 4, 2019, 9:34:39 PM (5 years ago)
Author:
Murray Heymann <heymann.murray@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
2f9e3f171a90f561e7a3c81734eb72998dc8fe82
Parents:
112c79d4f91036791f523bcfbb261d1ba63c2d8f557b878dd8c840afb5ec95de122ba27a0ec99926
Message:
Merge branch 'spielwiese' into machine_learning
File:
1 edited

Legend:

Unmodified
Added
Removed
  • factory/FLINTconvert.cc

    r112c79 r58603f  
    163163  if (f.isImm ())
    164164  {
    165     fmpz_set_si (fmpq_numref (result), f.intval());
    166     fmpz_set_si (fmpq_denref (result), 1);
     165    fmpq_set_si (result, f.intval(), 1);
    167166  }
    168167  else if(f.inQ())
     
    182181    fmpz_set_mpz (fmpq_numref (result), gmp_val);
    183182    mpz_clear (gmp_val);
    184     fmpz_set_si (fmpq_denref (result), 1);
     183    fmpz_one(fmpq_denref(result));
    185184  }
    186185  else
     
    574573  else
    575574  {
    576     int c=f.intval();
    577     if (c<0) c+=getCharacteristic();
     575    int c=f.intval(); // with Off(SW_SYMMETRIC_FF): 0<=c<p
    578576    nmod_mpoly_push_term_ui_ui(result,c,exp,ctx);
    579577  }
     
    608606  ulong * exp = (ulong*)Alloc(N*sizeof(ulong));
    609607  memset(exp,0,N*sizeof(ulong));
     608  bool save_sym_ff= isOn (SW_SYMMETRIC_FF);
     609  if (save_sym_ff) Off (SW_SYMMETRIC_FF);
    610610  convFlint_RecPP( f, exp, res, ctx, N );
     611  if (save_sym_ff) On(SW_SYMMETRIC_FF);
    611612  Free(exp,N*sizeof(ulong));
    612613}
     
    692693  convFactoryPFlintMP(F,f,ctx,N);
    693694  convFactoryPFlintMP(G,g,ctx,N);
    694   nmod_mpoly_init3(res,lF+lG,bits+1,ctx);
     695  nmod_mpoly_init(res,ctx);
    695696  nmod_mpoly_mul(res,f,g,ctx);
    696697  nmod_mpoly_clear(g,ctx);
     
    713714  convFactoryPFlintMP(F,f,ctx,N);
    714715  convFactoryPFlintMP(G,g,ctx,N);
    715   fmpq_mpoly_init3(res,lF+lG,bits+1,ctx);
     716  fmpq_mpoly_init(res,ctx);
    716717  fmpq_mpoly_mul(res,f,g,ctx);
    717718  fmpq_mpoly_clear(g,ctx);
     
    737738  convFactoryPFlintMP(F,f,ctx,N);
    738739  convFactoryPFlintMP(G,g,ctx,N);
    739   nmod_mpoly_init3(res,lf,bits,ctx);
     740  nmod_mpoly_init(res,ctx);
    740741  int ok=nmod_mpoly_gcd(res,f,g,ctx);
    741742  nmod_mpoly_clear(g,ctx);
     
    750751  return RES;
    751752}
     753
     754static CanonicalForm b_content ( const CanonicalForm & f )
     755{
     756    if ( f.inCoeffDomain() )
     757        return f;
     758    else
     759    {
     760        CanonicalForm result = 0;
     761        CFIterator i;
     762        for ( i = f; i.hasTerms() && (!result.isOne()); i++ )
     763            result=bgcd( b_content(i.coeff()) , result );
     764        return result;
     765    }
     766}
     767
    752768
    753769CanonicalForm gcdFlintMP_QQ(const CanonicalForm& F, const CanonicalForm& G)
     
    779795    }
    780796    RES=convFlintMPFactoryP(res,ctx,N);
     797    // gcd(2x,4x) should be 2x, so RES should also have the gcd(lc(F),lc(G))
     798    RES*=bgcd(b_content(F),b_content(G));
    781799  }
    782800  fmpq_mpoly_clear(res,ctx);
Note: See TracChangeset for help on using the changeset viewer.