Changeset d6cb88 in git


Ignore:
Timestamp:
Nov 25, 2014, 11:13:45 AM (9 years ago)
Author:
Adi Popescu <adi_popescum@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '38dfc5131670d387a89455159ed1e071997eec94')
Children:
f0b1f9da89e5c7912542c2081fa3ad564386f01c
Parents:
cecb7ea8a22076db547d32bfdc5c879d5283420d
Message:
add LLL_Flint feature: if called system(LLL_Flint, l, 1) will return
                       as a second entry also the transformation matrix
                       if called system(LLL_Flint, l, 0) will return
                       just the matrix - as system(LLL_Flint, l)
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • Singular/extra.cc

    rcecb7e rd6cb88  
    943943      if (h!=NULL)
    944944      {
    945         res->rtyp=h->Typ();
    946         if (h->Typ()==BIGINTMAT_CMD)
    947         {
    948           res->data=(char *)singflint_LLL((bigintmat*)h->Data());
    949           return FALSE;
    950         }
    951         else if (h->Typ()==INTMAT_CMD)
    952         {
    953           res->data=(char *)singflint_LLL((intvec*)h->Data());
    954           return FALSE;
    955         }
    956         else return TRUE;
     945        if(h->next == NULL)
     946        {
     947            res->rtyp=h->Typ();
     948            if (h->Typ()==BIGINTMAT_CMD)
     949            {
     950              res->data=(char *)singflint_LLL((bigintmat*)h->Data(), NULL);
     951              return FALSE;
     952            }
     953            else if (h->Typ()==INTMAT_CMD)
     954            {
     955              res->data=(char *)singflint_LLL((intvec*)h->Data(), NULL);
     956              return FALSE;
     957            }
     958            else return TRUE;
     959        }
     960        if(h->next->Typ()!= INT_CMD)
     961        {
     962            WerrorS("matrix,int or bigint,int expected");
     963            return TRUE;
     964        }
     965        if(h->next->Typ()== INT_CMD)
     966        {
     967            if(((int)((long)(h->next->Data())) != 0) && (int)((long)(h->next->Data()) != 1))
     968            {
     969                WerrorS("int is different from 0, 1");
     970                return TRUE;
     971            }
     972            res->rtyp=h->Typ();
     973            if((long)(h->next->Data()) == 0)
     974            {
     975                if (h->Typ()==BIGINTMAT_CMD)
     976                {
     977                  res->data=(char *)singflint_LLL((bigintmat*)h->Data(), NULL);
     978                  return FALSE;
     979                }
     980                else if (h->Typ()==INTMAT_CMD)
     981                {
     982                  res->data=(char *)singflint_LLL((intvec*)h->Data(), NULL);
     983                  return FALSE;
     984                }
     985                else return TRUE;
     986            }
     987            // This will give also the transformation matrix U s.t. res = U * m
     988            if((long)(h->next->Data()) == 1)
     989            {
     990                if (h->Typ()==BIGINTMAT_CMD)
     991                {
     992                  bigintmat* m = (bigintmat*)h->Data();
     993                  bigintmat* T = new bigintmat(m->rows(),m->rows(),m->basecoeffs());
     994                  for(int i = 1; i<=m->rows(); i++)
     995                    BIMATELEM(*T,i,i)=n_Init(1, m->basecoeffs());
     996                  m = singflint_LLL(m,T);
     997                  lists L = (lists)omAllocBin(slists_bin);
     998                  L->Init(2);
     999                  L->m[0].rtyp = BIGINTMAT_CMD;  L->m[0].data = (void*)m;
     1000                  L->m[1].rtyp = BIGINTMAT_CMD;  L->m[1].data = (void*)T;
     1001                  res->data=L;
     1002                  res->rtyp=LIST_CMD;
     1003                  return FALSE;
     1004                }
     1005                else if (h->Typ()==INTMAT_CMD)
     1006                {
     1007                  intvec* m = (intvec*)h->Data();
     1008                  intvec* T = new intvec(m->rows(),m->rows(),(int)0);
     1009                  for(int i = 1; i<=m->rows(); i++)
     1010                    IMATELEM(*T,i,i)=1;
     1011                  m = singflint_LLL(m,T);
     1012                  lists L = (lists)omAllocBin(slists_bin);
     1013                  L->Init(2);
     1014                  L->m[0].rtyp = INTMAT_CMD;  L->m[0].data = (void*)m;
     1015                  L->m[1].rtyp = INTMAT_CMD;  L->m[1].data = (void*)T;
     1016                  res->data=L;
     1017                  res->rtyp=LIST_CMD;
     1018                  return FALSE;
     1019                }
     1020                else return TRUE;
     1021            }
     1022        }
     1023       
    9571024      }
    9581025      else return TRUE;
  • libpolys/polys/flintconv.cc

    rcecb7e rd6cb88  
    5050
    5151
    52 bigintmat* singflint_LLL(bigintmat*  m)
     52bigintmat* singflint_LLL(bigintmat*  m, bigintmat* T)
    5353{
    5454  int r=m->rows();
    5555  int c=m->cols();
    5656  bigintmat* res=new bigintmat(r,c,m->basecoeffs());
    57   fmpz_mat_t M;
     57  fmpz_mat_t M, Transf;
    5858  fmpz_mat_init(M, r, c);
     59  if(T != NULL)
     60  {
     61    fmpz_mat_init(Transf, T->rows(), T->rows());
     62  }
    5963  fmpz_t dummy;
    6064  mpz_t n;
     
    6973    }
    7074  }
     75  if(T != NULL)
     76  {
     77    for(i=T->rows();i>0;i--)
     78    {
     79      for(j=T->rows();j>0;j--)
     80      {
     81        n_MPZ(n, BIMATELEM(*T, i, j),T->basecoeffs());
     82        convSingNFlintN(dummy,n);
     83        fmpz_set(fmpz_mat_entry(Transf, i-1, j-1), dummy);
     84      }
     85    }
     86  }
    7187  fmpz_lll_t fl;
    7288  fmpz_lll_context_init_default(fl);
    73   //printf("\nBefore LLL (in Flint)\n");fmpz_mat_print(M);
    74   fmpz_lll(M, NULL, fl);
    75   //printf("\nAfter LLL (in Flint)\n");fmpz_mat_print(M);printf("\n\n");
     89  if(T != NULL)
     90    fmpz_lll(M, Transf, fl);
     91  else
     92    fmpz_lll(M, NULL, fl);
    7693  for(i=r;i>0;i--)
    7794  {
    7895    for(j=c;j>0;j--)
    7996    {
    80       //printf("\nThis is here:\n");fmpz_print(fmpz_mat_entry(M, i-1, j-1));
    8197      convFlintNSingN(n, fmpz_mat_entry(M, i-1, j-1));
    8298      BIMATELEM(*res,i,j)=n_InitMPZ(n,m->basecoeffs());
    83       //printf("\nThis is res[%i] = %i\n", i+j, *res[i+j]);
     99    }
     100  }
     101  if(T != NULL)
     102  {
     103    for(i=T->rows();i>0;i--)
     104    {
     105      for(j=T->cols();j>0;j--)
     106      {
     107        convFlintNSingN(n, fmpz_mat_entry(Transf, i-1, j-1));
     108        BIMATELEM(*T,i,j)=n_InitMPZ(n,m->basecoeffs());
     109      }
    84110    }
    85111  }
     
    87113}
    88114
    89 intvec* singflint_LLL(intvec*  m)
     115intvec* singflint_LLL(intvec*  m, intvec* T)
    90116{
    91117  int r=m->rows();
    92118  int c=m->cols();
    93119  intvec* res = new intvec(r,c,(int)0);
    94   fmpz_mat_t M;
     120  fmpz_mat_t M,Transf;
    95121  fmpz_mat_init(M, r, c);
     122  if(T != NULL)
     123    fmpz_mat_init(Transf, r, r);
    96124  fmpz_t dummy;
    97125  int i,j;
     
    104132    }
    105133  }
     134  if(T != NULL)
     135  {
     136    for(i=T->rows();i>0;i--)
     137    {
     138      for(j=T->rows();j>0;j--)
     139      {
     140        convSingIFlintI(dummy,IMATELEM(*T,i,j));
     141        fmpz_set(fmpz_mat_entry(Transf, i-1, j-1), dummy);
     142      }
     143    }
     144  }
    106145  fmpz_lll_t fl;
    107146  fmpz_lll_context_init_default(fl);
    108   //printf("\nBefore LLL (in Flint)\n");fmpz_mat_print(M);
    109   fmpz_lll(M, NULL, fl);
    110   //printf("\nAfter LLL (in Flint)\n");fmpz_mat_print(M);printf("\n\n");
     147  if(T != NULL)
     148    fmpz_lll(M, Transf, fl);
     149  else
     150    fmpz_lll(M, NULL, fl);
    111151  for(i=r;i>0;i--)
    112152  {
    113153    for(j=c;j>0;j--)
    114154    {
    115       //printf("\nThis is here:\n");fmpz_print(fmpz_mat_entry(M, i-1, j-1));
    116155      IMATELEM(*res,i,j)=convFlintISingI(fmpz_mat_entry(M, i-1, j-1));
    117       //printf("\nThis is res[%i] = %i\n", i+j, *res[i+j]);
     156    }
     157  }
     158  if(T != NULL)
     159  {
     160    for(i=Transf->r;i>0;i--)
     161    {
     162      for(j=Transf->r;j>0;j--)
     163      {
     164        IMATELEM(*T,i,j)=convFlintISingI(fmpz_mat_entry(Transf, i-1, j-1));
     165      }
    118166    }
    119167  }
  • libpolys/polys/flintconv.h

    rcecb7e rd6cb88  
    2727
    2828//  Have to define this when this code shall be used:
    29 //#define FLINT_VER_2_4_5
     29#define FLINT_VER_2_4_5
    3030#ifdef FLINT_VER_2_4_5
    3131#include <polys/matpol.h>
     
    4646void convFlintNSingN (mpz_t z, fmpz_t f);
    4747void convSingNFlintN(fmpz_t f, mpz_t z);
    48 bigintmat*  singflint_LLL(bigintmat* A);
    49 intvec* singflint_LLL(intvec* A);
     48bigintmat*  singflint_LLL(bigintmat* A, bigintmat* T);
     49intvec* singflint_LLL(intvec* A, intvec* T);
    5050#endif
    5151
Note: See TracChangeset for help on using the changeset viewer.