Changeset 899d4c in git for factory/NTLconvert.cc


Ignore:
Timestamp:
May 21, 2010, 5:50:29 PM (14 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
24794e7b9df4f3be9431292795117f890eef2558
Parents:
76d3d6fb320d88ec7de6603328f5f6c6fe2caa07
Message:
NTL::mat_ZZ

git-svn-id: file:///usr/local/Singular/svn/trunk@12809 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • factory/NTLconvert.cc

    r76d3d6 r899d4c  
    3737#include <NTL/GF2EXFactoring.h>
    3838#include <NTL/tools.h>
     39#include <NTL/mat_ZZ.h>
    3940#include "int_int.h"
    4041#include <limits.h>
     
    655656////////////////////////////////////////////////////////////////////////////////
    656657
     658ZZ convertFacCF2NTLZZ(const CanonicalForm f)
     659{
     660  ZZ temp;
     661  if (f.isImm()) temp=f.intval();
     662  else
     663  {
     664    //Coefficient is a gmp-number
     665    mpz_t gmp_val;
     666    char* stringtemp;
     667
     668    gmp_val[0]=getmpi(f.getval());
     669    int l=mpz_sizeinbase(gmp_val,10)+2;
     670    stringtemp=(char*)Alloc(l);
     671    stringtemp=mpz_get_str(stringtemp,10,gmp_val);
     672    mpz_clear(gmp_val);
     673    conv(temp,stringtemp);
     674    Free(stringtemp,l);
     675  }
     676  return temp;
     677}
     678
    657679ZZX convertFacCF2NTLZZX(CanonicalForm f)
    658680{
     
    678700      NTLcurrentExp=i.exp();
    679701
    680       if (!i.coeff().isImm())
    681       {
    682         //Coefficient is a gmp-number
    683         mpz_t gmp_val;
    684         ZZ temp;
    685         char* stringtemp;
    686 
    687         gmp_val[0]=getmpi(i.coeff().getval());
    688         int l=mpz_sizeinbase(gmp_val,10)+2;
    689         stringtemp=(char*)Alloc(l);
    690         stringtemp=mpz_get_str(stringtemp,10,gmp_val);
    691         mpz_clear(gmp_val);
    692         conv(temp,stringtemp);
    693         Free(stringtemp,l);
    694 
    695         //set the computed coefficient
    696         SetCoeff(ntl_poly,NTLcurrentExp,temp);
    697       }
    698       else
    699       {
    700         //Coefficient is immediate --> use its value
    701         SetCoeff(ntl_poly,NTLcurrentExp,i.coeff().intval());
    702       }
     702      //Coefficient is a gmp-number
     703      ZZ temp=convertFacCF2NTLZZ(i.coeff());
     704
     705      //set the computed coefficient
     706      SetCoeff(ntl_poly,NTLcurrentExp,temp);
    703707
    704708      NTLcurrentExp--;
     
    10881092  }
    10891093}
     1094//----------------------------------------------------------------------
     1095mat_ZZ* convertFacCFMatrix2NTLmat_ZZ(CFMatrix &m)
     1096{
     1097  mat_ZZ *res=new mat_ZZ;
     1098  res->SetDims(m.rows(),m.columns());
     1099
     1100  int i,j;
     1101  for(i=m.rows();i>0;i--)
     1102  {
     1103    for(j=m.columns();j>0;j--)
     1104    {
     1105      (*res)(i,j)=convertFacCF2NTLZZ(m(i,j));
     1106    }
     1107  }
     1108  return res;
     1109}
     1110CFMatrix* convertNTLmat_ZZ2FacCFMatrix(mat_ZZ &m)
     1111{
     1112  CFMatrix *res=new CFMatrix(m.NumRows(),m.NumCols());
     1113  int i,j;
     1114  for(i=res->rows();i>0;i--)
     1115  {
     1116    for(j=res->columns();j>0;j--)
     1117    {
     1118      (*res)(i,j)=convertZZ2CF(m(i,j));
     1119    }
     1120  }
     1121  return res;
     1122}
     1123
    10901124#endif
Note: See TracChangeset for help on using the changeset viewer.