Changeset d6cb88 in git
- Timestamp:
- Nov 25, 2014, 11:13:45 AM (9 years ago)
- Branches:
- (u'spielwiese', 'e7cc1ebecb61be8b9ca6c18016352af89940b21a')
- Children:
- f0b1f9da89e5c7912542c2081fa3ad564386f01c
- Parents:
- cecb7ea8a22076db547d32bfdc5c879d5283420d
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/extra.cc
rcecb7e rd6cb88 943 943 if (h!=NULL) 944 944 { 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 957 1024 } 958 1025 else return TRUE; -
libpolys/polys/flintconv.cc
rcecb7e rd6cb88 50 50 51 51 52 bigintmat* singflint_LLL(bigintmat* m )52 bigintmat* singflint_LLL(bigintmat* m, bigintmat* T) 53 53 { 54 54 int r=m->rows(); 55 55 int c=m->cols(); 56 56 bigintmat* res=new bigintmat(r,c,m->basecoeffs()); 57 fmpz_mat_t M ;57 fmpz_mat_t M, Transf; 58 58 fmpz_mat_init(M, r, c); 59 if(T != NULL) 60 { 61 fmpz_mat_init(Transf, T->rows(), T->rows()); 62 } 59 63 fmpz_t dummy; 60 64 mpz_t n; … … 69 73 } 70 74 } 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 } 71 87 fmpz_lll_t fl; 72 88 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); 76 93 for(i=r;i>0;i--) 77 94 { 78 95 for(j=c;j>0;j--) 79 96 { 80 //printf("\nThis is here:\n");fmpz_print(fmpz_mat_entry(M, i-1, j-1));81 97 convFlintNSingN(n, fmpz_mat_entry(M, i-1, j-1)); 82 98 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 } 84 110 } 85 111 } … … 87 113 } 88 114 89 intvec* singflint_LLL(intvec* m )115 intvec* singflint_LLL(intvec* m, intvec* T) 90 116 { 91 117 int r=m->rows(); 92 118 int c=m->cols(); 93 119 intvec* res = new intvec(r,c,(int)0); 94 fmpz_mat_t M ;120 fmpz_mat_t M,Transf; 95 121 fmpz_mat_init(M, r, c); 122 if(T != NULL) 123 fmpz_mat_init(Transf, r, r); 96 124 fmpz_t dummy; 97 125 int i,j; … … 104 132 } 105 133 } 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 } 106 145 fmpz_lll_t fl; 107 146 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); 111 151 for(i=r;i>0;i--) 112 152 { 113 153 for(j=c;j>0;j--) 114 154 { 115 //printf("\nThis is here:\n");fmpz_print(fmpz_mat_entry(M, i-1, j-1));116 155 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 } 118 166 } 119 167 } -
libpolys/polys/flintconv.h
rcecb7e rd6cb88 27 27 28 28 // Have to define this when this code shall be used: 29 //#define FLINT_VER_2_4_529 #define FLINT_VER_2_4_5 30 30 #ifdef FLINT_VER_2_4_5 31 31 #include <polys/matpol.h> … … 46 46 void convFlintNSingN (mpz_t z, fmpz_t f); 47 47 void convSingNFlintN(fmpz_t f, mpz_t z); 48 bigintmat* singflint_LLL(bigintmat* A );49 intvec* singflint_LLL(intvec* A );48 bigintmat* singflint_LLL(bigintmat* A, bigintmat* T); 49 intvec* singflint_LLL(intvec* A, intvec* T); 50 50 #endif 51 51
Note: See TracChangeset
for help on using the changeset viewer.