Changeset 7c4341 in git


Ignore:
Timestamp:
Jan 8, 2014, 11:36:50 AM (10 years ago)
Author:
Martin Lee <martinlee84@…>
Branches:
(u'spielwiese', '8e0ad00ce244dfd0756200662572aef8402f13d5')
Children:
9fd8d2daa9bdbfb7c4a46ffcb388107cecceaa6b
Parents:
cb7b21794203a8052a1a05063ef1cc77ef771639
git-author:
Martin Lee <martinlee84@web.de>2014-01-08 11:36:50+01:00
git-committer:
Martin Lee <martinlee84@web.de>2014-01-20 16:45:04+01:00
Message:
chg: replace NTL by FLINT in bivariate factorization over FF in case a field extension is needed
File:
1 edited

Legend:

Unmodified
Added
Removed
  • factory/facFqBivar.cc

    rcb7b21 r7c4341  
    829829  adaptedLiftBound= 0;
    830830  int d= degree (F), l= 0;
    831   bool isRat= (isOn (SW_RATIONAL) && getCharacteristic() == 0) || getCharacteristic() > 0;
     831  bool isRat= (isOn (SW_RATIONAL) && getCharacteristic() == 0) ||
     832               getCharacteristic() > 0;
    832833  if (!isRat)
    833834    On (SW_RATIONAL);
     
    28732874}
    28742875
    2875 /*#ifdef HAVE_FLINT
     2876#ifdef HAVE_FLINT
    28762877//over field extension
    28772878int
     
    29882989                                     gamma, source, dest
    29892990                                    );
    2990               buf= getCoeffs (A[ii] [i], k, l, degMipo, gamma, 0, FLINTMatInv); //TODO
     2991              buf= getCoeffs (A[ii] [i], k, l, degMipo, gamma, 0, FLINTMatInv);
    29912992            }
    29922993            else
     
    29972998                                    gamma, source, dest
    29982999                                   );
    2999               buf= getCoeffs (A[ii] [i], k, l, degMipo, gamma, 0, FLINTMatInv); //TODO
     3000              buf= getCoeffs (A[ii] [i], k, l, degMipo, gamma, 0, FLINTMatInv);
    30003001            }
    30013002            writeInMatrix (C, buf, ii + 1, 0);
     
    30793080  return l;
    30803081}
    3081 #endif*/
     3082#endif
    30823083
    30833084// over Fq
     
    37693770  CFArray * A= new CFArray [factors.length()];
    37703771  CFArray bufQ= CFArray (factors.length());
     3772#ifdef HAVE_FLINT
     3773  nmod_mat_t FLINTN;
     3774  nmod_mat_init (FLINTN,factors.length(),factors.length(), getCharacteristic());
     3775  for (long i=factors.length()-1; i >= 0; i--)
     3776    nmod_mat_entry (FLINTN, i, i)= 1;
     3777#else
    37713778  if (fac_NTL_char != getCharacteristic())
    37723779  {
     
    37763783  mat_zz_p NTLN;
    37773784  ident (NTLN, factors.length());
     3785#endif
    37783786  int minBound= bounds[0];
    37793787  for (int i= 1; i < d; i++)
     
    37953803  CFMatrix Mat, C;
    37963804  CFIterator iter;
     3805#ifdef HAVE_FLINT
     3806  long rank;
     3807  nmod_mat_t FLINTMat, FLINTMatInv, FLINTC, FLINTK, null;
     3808#else
    37973809  mat_zz_p* NTLMat,*NTLC, NTLK;
     3810#endif
    37983811  CFArray buf;
    37993812  while (l <= precision)
     
    38143827    }
    38153828
     3829#ifdef HAVE_FLINT
     3830    convertFacCFMatrix2nmod_mat_t (FLINTMat, Mat);
     3831    nmod_mat_init (FLINTMatInv, nmod_mat_nrows (FLINTMat),
     3832                   nmod_mat_nrows (FLINTMat), getCharacteristic());
     3833    nmod_mat_inv (FLINTMatInv, FLINTMat);
     3834#else
    38163835    NTLMat= convertFacCFMatrix2NTLmat_zz_p (Mat);
    38173836    *NTLMat= inv (*NTLMat);
     3837#endif
     3838
    38183839    if (GF)
    38193840      setCharacteristic (getCharacteristic(), degMipo, info.getGFName());
     
    38523873                                     gamma, source, dest
    38533874                                    );
     3875#ifdef HAVE_FLINT
     3876              buf= getCoeffs (A[ii] [i], k, l, degMipo, gamma, 0, FLINTMatInv);
     3877#else
    38543878              buf= getCoeffs (A[ii] [i], k, l, degMipo, gamma, 0, *NTLMat);
     3879#endif
    38553880            }
    38563881            else
     
    38613886                                    gamma, source, dest
    38623887                                   );
     3888#ifdef HAVE_FLINT
     3889              buf= getCoeffs (A[ii] [i], k, l, degMipo, gamma, 0, FLINTMatInv);
     3890#else
    38633891              buf= getCoeffs (A[ii] [i], k, l, degMipo, gamma, 0, *NTLMat);
     3892#endif
    38643893            }
    38653894            writeInMatrix (C, buf, ii + 1, 0);
     
    38723901          setCharacteristic(getCharacteristic());
    38733902
     3903#ifdef HAVE_FLINT
     3904        convertFacCFMatrix2nmod_mat_t (FLINTC, C);
     3905        nmod_mat_init (FLINTK, nmod_mat_nrows (FLINTC), nmod_mat_ncols (FLINTN),
     3906                       getCharacteristic());
     3907        nmod_mat_mul (FLINTK, FLINTC, FLINTN);
     3908        nmod_mat_init (null, nmod_mat_ncols (FLINTK), nmod_mat_ncols (FLINTK),
     3909                       getCharacteristic());
     3910        rank= nmod_mat_nullspace (null, FLINTK);
     3911        nmod_mat_clear (FLINTK);
     3912        nmod_mat_window_init (FLINTK, null, 0, 0, nmod_mat_nrows(null), rank);
     3913        nmod_mat_clear (FLINTC);
     3914        nmod_mat_init_set (FLINTC, FLINTN);
     3915        nmod_mat_clear (FLINTN);
     3916        nmod_mat_init (FLINTN, nmod_mat_nrows (FLINTC), nmod_mat_ncols (FLINTK),
     3917                       getCharacteristic());
     3918        nmod_mat_mul (FLINTN, FLINTC, FLINTK); //no aliasing allowed!!
     3919
     3920        nmod_mat_clear (FLINTC);
     3921        nmod_mat_window_clear (FLINTK);
     3922        nmod_mat_clear (null);
     3923#else
    38743924        NTLC= convertFacCFMatrix2NTLmat_zz_p(C);
    38753925        NTLK= (*NTLC)*NTLN;
     
    38793929        NTLN *= NTLK;
    38803930        delete NTLC;
     3931#endif
    38813932
    38823933        if (GF)
    38833934          setCharacteristic (getCharacteristic(), degMipo, info.getGFName());
    38843935
     3936#ifdef HAVE_FLINT
     3937        if (nmod_mat_ncols (FLINTN) == 1)
     3938        {
     3939          nmod_mat_clear (FLINTMat);
     3940          nmod_mat_clear (FLINTMatInv);
     3941          nmod_mat_clear (FLINTN);
     3942#else
    38853943        if (NTLN.NumCols() == 1)
    38863944        {
     3945          delete NTLMat;
     3946#endif
    38873947          Variable y= Variable (2);
    38883948          CanonicalForm tmp= F (y - evaluation, y);
    38893949          CFList source, dest;
    38903950          tmp= mapDown (tmp, info, source, dest);
    3891           delete NTLMat;
    38923951          delete [] A;
    38933952          delete [] bounds;
     
    38983957    }
    38993958
     3959#ifdef HAVE_FLINT
     3960    nmod_mat_clear (FLINTMat);
     3961    nmod_mat_clear (FLINTMatInv);
     3962#else
    39003963    delete NTLMat;
    3901 
     3964#endif
     3965
     3966#ifdef HAVE_FLINT
     3967    if (nmod_mat_ncols (FLINTN) < oldNumCols - factorsFound)
     3968    {
     3969      if (isReduced (FLINTN))
     3970      {
     3971        int * factorsFoundIndex= new int [nmod_mat_ncols (FLINTN)];
     3972        for (long i= 0; i < nmod_mat_ncols (FLINTN); i++)
     3973#else
    39023974    if (NTLN.NumCols() < oldNumCols - factorsFound)
    39033975    {
     
    39063978        int * factorsFoundIndex= new int [NTLN.NumCols()];
    39073979        for (long i= 0; i < NTLN.NumCols(); i++)
     3980#endif
    39083981          factorsFoundIndex[i]= 0;
    39093982        int factorsFound2= 0;
    39103983        CFList result;
    39113984        CanonicalForm bufF= F;
     3985#ifdef HAVE_FLINT
     3986        extReconstructionTry (result, bufF, factors,degree (F)+1, factorsFound2,
     3987                              factorsFoundIndex, FLINTN, false, info, evaluation
     3988                             );
     3989        if (result.length() == nmod_mat_ncols (FLINTN))
     3990        {
     3991          nmod_mat_clear (FLINTN);
     3992#else
    39123993        extReconstructionTry (result, bufF, factors,degree (F)+1, factorsFound2,
    39133994                              factorsFoundIndex, NTLN, false, info, evaluation
     
    39153996        if (result.length() == NTLN.NumCols())
    39163997        {
     3998#endif
    39173999          delete [] factorsFoundIndex;
    39184000          delete [] A;
     
    39264008      {
    39274009        CanonicalForm bufF= F;
     4010#ifdef HAVE_FLINT
     4011        int * zeroOne= extractZeroOneVecs (FLINTN);
     4012        CFList result= extReconstruction (bufF, factors, zeroOne, precision,
     4013                                          FLINTN, info, evaluation
     4014                                         );
     4015        nmod_mat_clear (FLINTN);
     4016#else
    39284017        int * zeroOne= extractZeroOneVecs (NTLN);
    39294018        CFList result= extReconstruction (bufF, factors, zeroOne, precision,
    39304019                                          NTLN, info, evaluation
    39314020                                         );
     4021#endif
    39324022        F= bufF;
    39334023        delete [] zeroOne;
     
    39514041    }
    39524042  }
     4043
     4044#ifdef HAVE_FLINT
     4045  nmod_mat_clear (FLINTN);
     4046#endif
    39534047  delete [] bounds;
    39544048  delete [] A;
     
    45684662
    45694663//over field extension
     4664#ifdef HAVE_FLINT
     4665CFList
     4666extIncreasePrecision (CanonicalForm& F, CFList& factors, int oldL, int l, int d,
     4667                      int* bounds, CFArray& bufQ, nmod_mat_t FLINTN, const
     4668                      CanonicalForm& evaluation, const ExtensionInfo& info,
     4669                      CFList& source, CFList& dest
     4670                     )
     4671#else
    45704672CFList
    45714673extIncreasePrecision (CanonicalForm& F, CFList& factors, int oldL, int l, int d,
     
    45744676                      CFList& source, CFList& dest
    45754677                     )
     4678#endif
    45764679{
    45774680  CFList result= CFList();
     
    45874690  CanonicalForm primElemAlpha= info.getGamma();
    45884691  CanonicalForm imPrimElemAlpha= info.getDelta();
     4692#ifdef HAVE_FLINT
     4693  nmod_mat_clear (FLINTN);
     4694  nmod_mat_init (FLINTN,factors.length(),factors.length(), getCharacteristic());
     4695  for (long i=factors.length()-1; i >= 0; i--)
     4696    nmod_mat_entry (FLINTN, i, i)= 1;
     4697#else
    45894698  if (NTLN.NumRows() != factors.length()) //refined factors
    45904699    ident (NTLN, factors.length());
     4700#endif
    45914701  Variable y= F.mvar();
    45924702  CFListIterator j;
     
    45944704  CFMatrix Mat, C;
    45954705  CFIterator iter;
    4596   mat_zz_p* NTLMat;
    45974706  CFArray buf;
    4598   mat_zz_p* NTLC, NTLK;
     4707#ifdef HAVE_FLINT
     4708  long rank;
     4709  nmod_mat_t FLINTMat, FLINTMatInv, FLINTC, FLINTK, null;
     4710#else
     4711  mat_zz_p* NTLC, NTLK, *NTLMat;
     4712#endif
    45994713  CFList bufUniFactors;
    46004714  while (oldL <= l)
     
    46164730    }
    46174731
     4732#ifdef HAVE_FLINT
     4733    convertFacCFMatrix2nmod_mat_t (FLINTMat, Mat);
     4734    nmod_mat_init (FLINTMatInv, nmod_mat_nrows (FLINTMat),
     4735                   nmod_mat_nrows (FLINTMat), getCharacteristic());
     4736    nmod_mat_inv (FLINTMatInv, FLINTMat);
     4737#else
    46184738    NTLMat= convertFacCFMatrix2NTLmat_zz_p (Mat);
    46194739    *NTLMat= inv (*NTLMat);
     4740#endif
     4741
    46204742    if (GF)
    46214743      setCharacteristic (getCharacteristic(), degMipo, info.getGFName());
     
    46544776                                     gamma, source, dest
    46554777                                    );
     4778#ifdef HAVE_FLINT
     4779              buf= getCoeffs (A[ii] [i], k, oldL, degMipo, gamma, 0, FLINTMatInv);
     4780#else
    46564781              buf= getCoeffs (A[ii] [i], k, oldL, degMipo, gamma, 0, *NTLMat);
     4782#endif
    46574783            }
    46584784            else
     
    46634789                                    gamma, source, dest
    46644790                                   );
     4791#ifdef HAVE_FLINT
     4792              buf= getCoeffs (A[ii] [i], k, oldL, degMipo, gamma, 0, FLINTMatInv);
     4793#else
    46654794              buf= getCoeffs (A[ii] [i], k, oldL, degMipo, gamma, 0, *NTLMat);
     4795#endif
    46664796            }
    46674797            writeInMatrix (C, buf, ii + 1, 0);
     
    46744804          setCharacteristic(getCharacteristic());
    46754805
     4806#ifdef HAVE_FLINT
     4807        convertFacCFMatrix2nmod_mat_t (FLINTC, C);
     4808        nmod_mat_init (FLINTK, nmod_mat_nrows (FLINTC), nmod_mat_ncols (FLINTN),
     4809                       getCharacteristic());
     4810        nmod_mat_mul (FLINTK, FLINTC, FLINTN);
     4811        nmod_mat_init (null, nmod_mat_ncols (FLINTK), nmod_mat_ncols (FLINTK),
     4812                       getCharacteristic());
     4813        rank= nmod_mat_nullspace (null, FLINTK);
     4814        nmod_mat_clear (FLINTK);
     4815        nmod_mat_window_init (FLINTK, null, 0, 0, nmod_mat_nrows(null), rank);
     4816        nmod_mat_clear (FLINTC);
     4817        nmod_mat_init_set (FLINTC, FLINTN);
     4818        nmod_mat_clear (FLINTN);
     4819        nmod_mat_init (FLINTN, nmod_mat_nrows (FLINTC), nmod_mat_ncols (FLINTK),
     4820                       getCharacteristic());
     4821        nmod_mat_mul (FLINTN, FLINTC, FLINTK); //no aliasing allowed!!
     4822
     4823        nmod_mat_clear (FLINTC);
     4824        nmod_mat_window_clear (FLINTK);
     4825        nmod_mat_clear (null);
     4826#else
    46764827        NTLC= convertFacCFMatrix2NTLmat_zz_p(C);
    46774828        NTLK= (*NTLC)*NTLN;
     
    46814832        NTLN *= NTLK;
    46824833        delete NTLC;
     4834#endif
    46834835
    46844836        if (GF)
    46854837          setCharacteristic (getCharacteristic(), degMipo, info.getGFName());
    46864838
     4839#ifdef HAVE_FLINT
     4840        if (nmod_mat_ncols (FLINTN) == 1)
     4841        {
     4842          nmod_mat_clear (FLINTMat);
     4843          nmod_mat_clear (FLINTMatInv);
     4844#else
    46874845        if (NTLN.NumCols() == 1)
    46884846        {
     4847          delete NTLMat;
     4848#endif
    46894849          Variable y= Variable (2);
    46904850          CanonicalForm tmp= F (y - evaluation, y);
     
    46924852          tmp= mapDown (tmp, info, source, dest);
    46934853          delete [] A;
    4694           delete NTLMat;
    46954854          return CFList (tmp);
    46964855        }
     
    46984857    }
    46994858
     4859#ifdef HAVE_FLINT
     4860    nmod_mat_clear (FLINTMat);
     4861    nmod_mat_clear (FLINTMatInv);
     4862#else
    47004863    delete NTLMat;
    4701 
     4864#endif
     4865
     4866#ifdef HAVE_FLINT
     4867    if (nmod_mat_ncols (FLINTN) == 1)
     4868#else
    47024869    if (NTLN.NumCols() == 1)
     4870#endif
    47034871    {
    47044872      Variable y= Variable (2);
     
    47114879
    47124880    int * zeroOneVecs;
    4713     zeroOneVecs= extractZeroOneVecs (NTLN);
    47144881    bufF= F;
    47154882    bufUniFactors= factors;
     4883#ifdef HAVE_FLINT
     4884    zeroOneVecs= extractZeroOneVecs (FLINTN);
     4885    result= extReconstruction (bufF, bufUniFactors, zeroOneVecs, oldL, FLINTN,
     4886                               info, evaluation
     4887                              );
     4888#else
     4889    zeroOneVecs= extractZeroOneVecs (NTLN);
    47164890    result= extReconstruction (bufF, bufUniFactors, zeroOneVecs, oldL, NTLN,
    47174891                               info, evaluation
    47184892                              );
     4893#endif
    47194894    delete [] zeroOneVecs;
    47204895    if (degree (bufF) + 1 + degree (LC (bufF, 1)) < l && result.length() > 0)
     
    52685443
    52695444//over field extension
     5445#ifdef HAVE_FLINT
     5446CFList
     5447extFurtherLiftingAndIncreasePrecision (CanonicalForm& F, CFList& factors, int l,
     5448                                       int liftBound, int d, int* bounds,
     5449                                       nmod_mat_t FLINTN, CFList& diophant,
     5450                                       CFMatrix& M, CFArray& Pi, CFArray& bufQ,
     5451                                       const CanonicalForm& evaluation, const
     5452                                       ExtensionInfo& info, CFList& source,
     5453                                       CFList& dest
     5454                                      )
     5455#else
    52705456CFList
    52715457extFurtherLiftingAndIncreasePrecision (CanonicalForm& F, CFList& factors, int l,
     
    52775463                                       CFList& dest
    52785464                                      )
     5465#endif
    52795466{
    52805467  CanonicalForm LCF= LC (F, 1);
     
    52945481  CanonicalForm primElemAlpha= info.getGamma();
    52955482  CanonicalForm imPrimElemAlpha= info.getDelta();
     5483#ifdef HAVE_FLINT
     5484  nmod_mat_clear (FLINTN);
     5485  nmod_mat_init (FLINTN,factors.length(),factors.length(), getCharacteristic());
     5486  for (long i=factors.length()-1; i >= 0; i--)
     5487    nmod_mat_entry (FLINTN, i, i)= 1;
     5488#else
    52965489  if (NTLN.NumRows() != factors.length()) //refined factors
    52975490    ident (NTLN, factors.length());
     5491#endif
    52985492  Variable y= F.mvar();
    52995493  CanonicalForm powX, imBasis, bufF, truncF;
    53005494  CFMatrix Mat, C;
    53015495  CFIterator iter;
     5496#ifdef HAVE_FLINT
     5497  long rank;
     5498  nmod_mat_t FLINTMat, FLINTMatInv, FLINTC, FLINTK, null;
     5499#else
    53025500  mat_zz_p* NTLMat,*NTLC, NTLK;
     5501#endif
    53035502  CFListIterator j;
    53045503  CFArray buf;
     
    53245523    }
    53255524
     5525#ifdef HAVE_FLINT
     5526    convertFacCFMatrix2nmod_mat_t (FLINTMat, Mat);
     5527    nmod_mat_init (FLINTMatInv, nmod_mat_nrows (FLINTMat),
     5528                   nmod_mat_nrows (FLINTMat), getCharacteristic());
     5529    nmod_mat_inv (FLINTMatInv, FLINTMat);
     5530#else
    53265531    NTLMat= convertFacCFMatrix2NTLmat_zz_p (Mat);
    53275532    *NTLMat= inv (*NTLMat);
     5533#endif
    53285534
    53295535    if (GF)
     
    53625568                                     gamma, source, dest
    53635569                                    );
     5570#ifdef HAVE_FLINT
     5571              buf= getCoeffs (A[ii] [i], k, l, degMipo, gamma, 0, FLINTMatInv);
     5572#else
    53645573              buf= getCoeffs (A[ii] [i], k, l, degMipo, gamma, 0, *NTLMat);
     5574#endif
    53655575            }
    53665576            else
     
    53715581                                    gamma, source, dest
    53725582                                   );
     5583#ifdef HAVE_FLINT
     5584              buf= getCoeffs (A[ii] [i], k, l, degMipo, gamma, 0, FLINTMatInv);
     5585#else
    53735586              buf= getCoeffs (A[ii] [i], k, l, degMipo, gamma, 0, *NTLMat);
     5587#endif
    53745588            }
    53755589            writeInMatrix (C, buf, ii + 1, 0);
     
    53815595        if (GF)
    53825596          setCharacteristic(getCharacteristic());
     5597
     5598#ifdef HAVE_FLINT
     5599        convertFacCFMatrix2nmod_mat_t (FLINTC, C);
     5600        nmod_mat_init (FLINTK, nmod_mat_nrows (FLINTC), nmod_mat_ncols (FLINTN),
     5601                       getCharacteristic());
     5602        nmod_mat_mul (FLINTK, FLINTC, FLINTN);
     5603        nmod_mat_init (null, nmod_mat_ncols (FLINTK), nmod_mat_ncols (FLINTK),
     5604                       getCharacteristic());
     5605        rank= nmod_mat_nullspace (null, FLINTK);
     5606        nmod_mat_clear (FLINTK);
     5607        nmod_mat_window_init (FLINTK, null, 0, 0, nmod_mat_nrows(null), rank);
     5608        nmod_mat_clear (FLINTC);
     5609        nmod_mat_init_set (FLINTC, FLINTN);
     5610        nmod_mat_clear (FLINTN);
     5611        nmod_mat_init (FLINTN, nmod_mat_nrows (FLINTC), nmod_mat_ncols (FLINTK),
     5612                       getCharacteristic());
     5613        nmod_mat_mul (FLINTN, FLINTC, FLINTK); //no aliasing allowed!!
     5614
     5615        nmod_mat_clear (FLINTC);
     5616        nmod_mat_window_clear (FLINTK);
     5617        nmod_mat_clear (null);
     5618#else
    53835619        NTLC= convertFacCFMatrix2NTLmat_zz_p(C);
    53845620        NTLK= (*NTLC)*NTLN;
     
    53885624        NTLN *= NTLK;
    53895625        delete NTLC;
     5626#endif
     5627
    53905628        if (GF)
    53915629          setCharacteristic (getCharacteristic(), degMipo, info.getGFName());
    53925630
     5631#ifdef HAVE_FLINT
     5632        if (nmod_mat_ncols (FLINTN) == 1)
     5633#else
    53935634        if (NTLN.NumCols() == 1)
     5635#endif
    53945636        {
    53955637          irreducible= true;
     
    53985640      }
    53995641    }
     5642
     5643#ifdef HAVE_FLINT
     5644    nmod_mat_clear (FLINTMat);
     5645    nmod_mat_clear (FLINTMatInv);
     5646    if (nmod_mat_ncols (FLINTN) == 1)
     5647#else
    54005648    delete NTLMat;
    54015649    if (NTLN.NumCols() == 1)
     5650#endif
    54025651    {
    54035652      irreducible= true;
     
    54055654    }
    54065655
     5656    bufF= F;
     5657#ifdef HAVE_FLINT
     5658    int * zeroOneVecs= extractZeroOneVecs (FLINTN);
     5659    result= extReconstruction (bufF, bufFactors, zeroOneVecs, l, FLINTN, info,
     5660                               evaluation
     5661                              );
     5662#else
    54075663    int * zeroOneVecs= extractZeroOneVecs (NTLN);
    5408     bufF= F;
    54095664    result= extReconstruction (bufF, bufFactors, zeroOneVecs, l, NTLN, info,
    54105665                               evaluation
    54115666                              );
     5667#endif
    54125668    delete [] zeroOneVecs;
    54135669    if (result.length() > 0 && degree (bufF) + 1 + degree (LC (bufF, 1)) <= l)
     
    54195675    }
    54205676
     5677#ifdef HAVE_FLINT
     5678    if (isReduced (FLINTN))
     5679#else
    54215680    if (isReduced (NTLN))
     5681#endif
    54225682    {
    54235683      int factorsFound= 0;
    54245684      bufF= F;
     5685#ifdef HAVE_FLINT
     5686      int* factorsFoundIndex= new int [nmod_mat_ncols (FLINTN)];
     5687      for (long i= 0; i < nmod_mat_ncols (FLINTN); i++)
     5688#else
    54255689      int* factorsFoundIndex= new int [NTLN.NumCols()];
    54265690      for (long i= 0; i < NTLN.NumCols(); i++)
     5691#endif
    54275692        factorsFoundIndex[i]= 0;
     5693#ifdef HAVE_FLINT
     5694      if (l < degree (bufF) + 1 + degree (LCF))
     5695        extReconstructionTry (result, bufF, bufFactors, l, factorsFound,
     5696                              factorsFoundIndex, FLINTN, false, info, evaluation
     5697                             );
     5698      else
     5699        extReconstructionTry (result, bufF, bufFactors, degree (bufF) + 1 +
     5700                              degree (LCF), factorsFound, factorsFoundIndex,
     5701                              FLINTN, false, info, evaluation
     5702                             );
     5703      if (nmod_mat_ncols (FLINTN) == result.length())
     5704#else
    54285705      if (l < degree (bufF) + 1 + degree (LCF))
    54295706        extReconstructionTry (result, bufF, bufFactors, l, factorsFound,
     
    54365713                             );
    54375714      if (NTLN.NumCols() == result.length())
     5715#endif
    54385716      {
    54395717        delete [] A;
     
    61626440
    61636441//over field extension
     6442#ifdef HAVE_FLINT
     6443CFList
     6444extEarlyReconstructionAndLifting (const CanonicalForm& F, const nmod_mat_t N,
     6445                                  CanonicalForm& bufF, CFList& factors, int& l,
     6446                                  int& factorsFound, bool beenInThres, CFMatrix&
     6447                                  M, CFArray& Pi, CFList& diophant, const
     6448                                  ExtensionInfo& info, const CanonicalForm&
     6449                                  evaluation
     6450                                 )
     6451#else
    61646452CFList
    61656453extEarlyReconstructionAndLifting (const CanonicalForm& F, const mat_zz_p& N,
     
    61706458                                  evaluation
    61716459                                 )
     6460#endif
    61726461{
    61736462  int sizeOfLiftPre;
     
    61786467  CFList result;
    61796468  int smallFactorDeg= 11;
     6469#ifdef HAVE_FLINT
     6470  nmod_mat_t FLINTN;
     6471  nmod_mat_init_set (FLINTN, N);
     6472  int * factorsFoundIndex= new int [nmod_mat_ncols (FLINTN)];
     6473  for (long i= 0; i < nmod_mat_ncols (FLINTN); i++)
     6474#else
    61806475  mat_zz_p NTLN= N;
    61816476  int * factorsFoundIndex= new int [NTLN.NumCols()];
    61826477  for (long i= 0; i < NTLN.NumCols(); i++)
     6478#endif
    61836479    factorsFoundIndex [i]= 0;
    61846480
     
    61946490    }
    61956491    TIMING_START (fac_fq_reconstruction);
     6492#ifdef HAVE_FLINT
     6493    extReconstructionTry (result, bufF, factors, smallFactorDeg, factorsFound,
     6494                          factorsFoundIndex, FLINTN, beenInThres, info,
     6495                          evaluation
     6496                      );
     6497#else
    61966498    extReconstructionTry (result, bufF, factors, smallFactorDeg, factorsFound,
    61976499                          factorsFoundIndex, NTLN, beenInThres, info,
    61986500                          evaluation
    61996501                      );
     6502#endif
    62006503    TIMING_END_AND_PRINT (fac_fq_reconstruction, "time to reconstruct0: ");
     6504#ifdef HAVE_FLINT
     6505    if (result.length() == nmod_mat_ncols (FLINTN))
     6506    {
     6507      nmod_mat_clear (FLINTN);
     6508#else
    62016509    if (result.length() == NTLN.NumCols())
    62026510    {
     6511#endif
    62036512      delete [] liftPre;
    62046513      delete [] factorsFoundIndex;
     
    62286537      }
    62296538      TIMING_START (fac_fq_reconstruction);
     6539#ifdef HAVE_FLINT
     6540      extReconstructionTry (result, bufF, factors, l, factorsFound,
     6541                            factorsFoundIndex, FLINTN, beenInThres, info,
     6542                            evaluation
     6543                           );
     6544#else
    62306545      extReconstructionTry (result, bufF, factors, l, factorsFound,
    62316546                            factorsFoundIndex, NTLN, beenInThres, info,
    62326547                            evaluation
    62336548                           );
     6549#endif
    62346550      TIMING_END_AND_PRINT (fac_fq_reconstruction, "time to reconstruct1: ");
     6551#ifdef HAVE_FLINT
     6552      if (result.length() == nmod_mat_ncols (FLINTN))
     6553      {
     6554        nmod_mat_clear (FLINTN);
     6555#else
    62356556      if (result.length() == NTLN.NumCols())
    62366557      {
     6558#endif
    62376559        delete [] liftPre;
    62386560        delete [] factorsFoundIndex;
     
    62656587      }
    62666588      TIMING_START (fac_fq_reconstruction);
     6589#ifdef HAVE_FLINT
     6590      extReconstructionTry (result, bufF, factors, l, factorsFound,
     6591                            factorsFoundIndex, FLINTN, beenInThres, info,
     6592                            evaluation
     6593                           );
     6594#else
    62676595      extReconstructionTry (result, bufF, factors, l, factorsFound,
    62686596                            factorsFoundIndex, NTLN, beenInThres, info,
    62696597                            evaluation
    62706598                           );
     6599#endif
    62716600      TIMING_END_AND_PRINT (fac_fq_reconstruction, "time to reconstruct2: ");
     6601#ifdef HAVE_FLINT
     6602      if (result.length() == nmod_mat_ncols (FLINTN))
     6603      {
     6604        nmod_mat_clear (FLINTN);
     6605#else
    62726606      if (result.length() == NTLN.NumCols())
    62736607      {
     6608#endif
    62746609        delete [] liftPre;
    62756610        delete [] factorsFoundIndex;
     
    62806615  }
    62816616
     6617#ifdef HAVE_FLINT
     6618  nmod_mat_clear (FLINTN);
     6619#endif
    62826620  delete [] liftPre;
    62836621  delete [] factorsFoundIndex;
     
    73707708  int l= 1;
    73717709
     7710#ifdef HAVE_FLINT
     7711  nmod_mat_t FLINTN;
     7712  nmod_mat_init (FLINTN, bufUniFactors.length()-1, bufUniFactors.length()-1,
     7713                 getCharacteristic());
     7714  for (long i= bufUniFactors.length()-2; i >= 0; i--)
     7715    nmod_mat_entry (FLINTN, i, i)= 1;
     7716#else
    73727717  if (fac_NTL_char != getCharacteristic())
    73737718  {
     
    73797724
    73807725  ident (NTLN, bufUniFactors.length() - 1);
     7726#endif
    73817727  bool irreducible= false;
    73827728  CFArray bufQ= CFArray (bufUniFactors.length() - 1);
     
    73877733  {
    73887734    int start= 0;
     7735#ifdef HAVE_FLINT
     7736    oldL= extLiftAndComputeLattice (F, bounds, d, liftBound, minBound, start,
     7737                                    bufUniFactors, FLINTN, diophant,M, Pi, bufQ,
     7738                                    irreducible, evaluation, info2, source, dest
     7739                                   );
     7740#else
    73897741    oldL= extLiftAndComputeLattice (F, bounds, d, liftBound, minBound, start,
    73907742                                    bufUniFactors, NTLN, diophant, M, Pi, bufQ,
    73917743                                    irreducible, evaluation, info2, source, dest
    73927744                                   );
     7745#endif
    73937746  }
    73947747  else
    73957748  {
     7749#ifdef HAVE_FLINT
     7750    oldL= extLiftAndComputeLattice (F, bounds, d, liftBound, minBound,
     7751                                    minBound+1, bufUniFactors, FLINTN, diophant,
     7752                                    M, Pi, bufQ, irreducible, evaluation, info2,
     7753                                    source, dest
     7754                                   );
     7755#else
    73967756    oldL= extLiftAndComputeLattice (F, bounds, d, liftBound, minBound,
    73977757                                    minBound + 1, bufUniFactors, NTLN, diophant,
     
    73997759                                    source, dest
    74007760                                   );
     7761#endif
    74017762  }
    74027763  TIMING_END_AND_PRINT (fac_fq_till_reduced,
     
    74067767  if (oldL > liftBound)
    74077768  {
     7769#ifdef HAVE_FLINT
     7770    nmod_mat_clear (FLINTN);
     7771#endif
    74087772    delete [] bounds;
    74097773    return Union (smallFactors, extFactorRecombination
     
    74187782  if (irreducible)
    74197783  {
     7784#ifdef HAVE_FLINT
     7785    nmod_mat_clear (FLINTN);
     7786#endif
    74207787    delete [] bounds;
    74217788    CFList source, dest;
     
    74327799    int * factorsFoundIndex;
    74337800
     7801#ifdef HAVE_FLINT
     7802    factorsFoundIndex= new int [nmod_mat_ncols (FLINTN)];
     7803    for (long i= 0; i < nmod_mat_ncols (FLINTN); i++)
     7804#else
    74347805    factorsFoundIndex= new int [NTLN.NumCols()];
    74357806    for (long i= 0; i < NTLN.NumCols(); i++)
     7807#endif
    74367808      factorsFoundIndex[i]= 0;
    74377809
     
    74397811    CanonicalForm bufF= F;
    74407812
     7813#ifdef HAVE_FLINT
     7814    extReconstructionTry (result, bufF, bufUniFactors, degree (F) + 1,
     7815                          factorsFound, factorsFoundIndex, FLINTN, false, info,
     7816                          evaluation
     7817                         );
     7818
     7819    if (result.length() == nmod_mat_ncols (FLINTN))
     7820    {
     7821      nmod_mat_clear (FLINTN);
     7822#else
    74417823    extReconstructionTry (result, bufF, bufUniFactors, degree (F) + 1,
    74427824                          factorsFound, factorsFoundIndex, NTLN, false, info,
     
    74467828    if (result.length() == NTLN.NumCols())
    74477829    {
     7830#endif
    74487831      delete [] factorsFoundIndex;
    74497832      delete [] bounds;
     
    74567839  {
    74577840    int * factorsFoundIndex;
     7841#ifdef HAVE_FLINT
     7842    factorsFoundIndex= new int [nmod_mat_ncols (FLINTN)];
     7843    for (long i= 0; i < nmod_mat_ncols (FLINTN); i++)
     7844#else
    74587845    factorsFoundIndex= new int [NTLN.NumCols()];
    74597846    for (long i= 0; i < NTLN.NumCols(); i++)
     7847#endif
    74607848      factorsFoundIndex[i]= 0;
    74617849    CanonicalForm bufF= F;
    74627850    int factorsFound= 0;
    74637851
     7852#ifdef HAVE_FLINT
     7853    extReconstructionTry (result, bufF, bufUniFactors, degree (F) + 1,
     7854                          factorsFound, factorsFoundIndex, FLINTN, false,
     7855                          info, evaluation
     7856                         );
     7857
     7858    if (result.length() == nmod_mat_ncols (FLINTN))
     7859    {
     7860      nmod_mat_clear (FLINTN);
     7861#else
    74647862    extReconstructionTry (result, bufF, bufUniFactors, degree (F) + 1,
    74657863                          factorsFound, factorsFoundIndex, NTLN, false,
     
    74697867    if (result.length() == NTLN.NumCols())
    74707868    {
     7869#endif
    74717870      delete [] factorsFoundIndex;
    74727871      delete [] bounds;
     
    74797878  bool beenInThres= false;
    74807879  int thres= 100;
     7880#ifdef HAVE_FLINT
     7881  if (l <= thres && bufUniFactors.length() > nmod_mat_ncols (FLINTN))
     7882  {
     7883    refineAndRestartLift (F, FLINTN, 2*totaldegree (F)-1, l, bufUniFactors, M, Pi,
     7884                         diophant
     7885                        );
     7886#else
    74817887  if (l <= thres && bufUniFactors.length() > NTLN.NumCols())
    74827888  {
     
    74847890                         diophant
    74857891                        );
     7892#endif
    74867893    beenInThres= true;
    74877894  }
     
    74917898  int factorsFound= 0;
    74927899
     7900#ifdef HAVE_FLINT
     7901  result= extEarlyReconstructionAndLifting (F, FLINTN, bufF, bufUniFactors, l,
     7902                                            factorsFound, beenInThres, M, Pi,
     7903                                            diophant, info, evaluation
     7904                                           );
     7905
     7906  if (result.length() == nmod_mat_ncols (FLINTN))
     7907  {
     7908    nmod_mat_clear (FLINTN);
     7909#else
    74937910  result= extEarlyReconstructionAndLifting (F, NTLN, bufF, bufUniFactors, l,
    74947911                                            factorsFound, beenInThres, M, Pi,
     
    74987915  if (result.length() == NTLN.NumCols())
    74997916  {
     7917#endif
    75007918    delete [] bounds;
    75017919    return Union (result, smallFactors);
     
    75277945    else
    75287946    {
     7947#ifdef HAVE_FLINT
     7948      int * zeroOne= extractZeroOneVecs (FLINTN);
     7949#else
    75297950      int * zeroOne= extractZeroOneVecs (NTLN);
     7951#endif
    75307952      CFList bufBufUniFactors= bufUniFactors;
    75317953      CFListIterator iter, iter2;
    75327954      CanonicalForm buf;
    75337955      CFList factorsConsidered;
     7956#ifdef HAVE_FLINT
     7957      for (int i= 0; i < nmod_mat_ncols (FLINTN); i++)
     7958#else
    75347959      for (int i= 0; i < NTLN.NumCols(); i++)
     7960#endif
    75357961      {
    75367962        if (zeroOne [i] == 0)
     
    75397965        buf= 1;
    75407966        factorsConsidered= CFList();
     7967#ifdef HAVE_FLINT
     7968        for (int j= 0; j < nmod_mat_nrows (FLINTN); j++, iter++)
     7969        {
     7970          if (!(nmod_mat_entry (FLINTN, j, i) == 0))
     7971#else
    75417972        for (int j= 0; j < NTLN.NumRows(); j++, iter++)
    75427973        {
    75437974          if (!IsZero (NTLN (j + 1,i + 1)))
     7975#endif
    75447976          {
    75457977            factorsConsidered.append (iter.getItem());
     
    75677999    irreducible= false;
    75688000
     8001#ifdef HAVE_FLINT //TODO
     8002    oldNumCols= nmod_mat_ncols (FLINTN);
     8003    resultBufF= extIncreasePrecision (bufF, bufUniFactors, factorsFound,
     8004                                      oldNumCols, oldL, evaluation, info2,
     8005                                      source, dest, l
     8006                                     );
     8007    nmod_mat_clear (FLINTN);
     8008#else
    75698009    oldNumCols= NTLN.NumCols();
    75708010    resultBufF= extIncreasePrecision (bufF, bufUniFactors, factorsFound,
     
    75728012                                      source, dest, l
    75738013                                     );
    7574 
     8014#endif
    75758015    if (bufUniFactors.isEmpty() || degree (bufF) <= 0)
    75768016    {
     
    76058045  if (l/degMipo < liftBound)
    76068046  {
     8047#ifdef HAVE_FLINT
     8048    result=extIncreasePrecision (F, bufUniFactors, oldL, l, d, bounds, bufQ,
     8049                                 FLINTN, evaluation, info2, source, dest
     8050                                );
     8051
     8052    if (result.length()== nmod_mat_ncols (FLINTN))
     8053    {
     8054      nmod_mat_clear (FLINTN);
     8055#else
    76078056    result=extIncreasePrecision (F, bufUniFactors, oldL, l, d, bounds, bufQ,
    76088057                                 NTLN, evaluation, info2, source, dest
     
    76118060    if (result.length()== NTLN.NumCols())
    76128061    {
     8062#endif
    76138063      delete [] bounds;
    76148064      result= Union (result, smallFactors);
     
    76188068    if (result.isEmpty())
    76198069    {
     8070#ifdef HAVE_FLINT
     8071      result= extFurtherLiftingAndIncreasePrecision (F,bufUniFactors, l,
     8072                                                     liftBound, d,bounds,FLINTN,
     8073                                                     diophant, M, Pi, bufQ,
     8074                                                     evaluation, info2, source,
     8075                                                     dest
     8076                                                    );
     8077      if (result.length()== nmod_mat_ncols (FLINTN))
     8078      {
     8079        nmod_mat_clear (FLINTN);
     8080#else
    76208081      result= extFurtherLiftingAndIncreasePrecision (F,bufUniFactors, l,
    76218082                                                     liftBound, d, bounds, NTLN,
     
    76268087      if (result.length()== NTLN.NumCols())
    76278088      {
     8089#endif
    76288090        delete [] bounds;
    76298091        result= Union (result, smallFactors);
     
    76328094    }
    76338095  }
     8096
     8097#ifdef HAVE_FLINT
     8098  nmod_mat_clear (FLINTN);
     8099#endif
    76348100
    76358101  DEBOUTLN (cerr, "lattice recombination failed");
Note: See TracChangeset for help on using the changeset viewer.