Changeset 75f10d in git
- Timestamp:
- May 10, 2012, 1:59:15 PM (11 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
- Children:
- 6f0279ecd605db3872247f2211d8efd1ac65d42a
- Parents:
- c8302bb70ef743b5705287005391184566e69b06
- git-author:
- Hans Schoenemann <hannes@mathematik.uni-kl.de>2012-05-10 13:59:15+02:00
- git-committer:
- Hans Schoenemann <hannes@mathematik.uni-kl.de>2012-05-10 13:59:37+02:00
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/iparith.cc
rc8302b r75f10d 15 15 16 16 #include "config.h" 17 #include <coeffs/bigintmat.h> 17 18 #include <kernel/mod2.h> 18 19 #include <Singular/tok.h> … … 236 237 * then alphabetically */ 237 238 239 static BOOLEAN jjOP_BIM_I(leftv res, leftv u, leftv v) 240 { 241 bigintmat* aa= (bigintmat *)u->Data(); 242 int bb = (int)(long)(v->Data()); 243 if (errorreported) return TRUE; 244 bigintmat *cc=NULL; 245 switch (iiOp) 246 { 247 case '+': cc=bimAdd(aa,bb); break; 248 case '-': cc=bimSub(aa,bb); break; 249 case '*': cc=bimMult(aa,bb); break; 250 } 251 res->data=(char *)cc; 252 return cc==NULL; 253 } 254 static BOOLEAN jjOP_I_BIM(leftv res, leftv u, leftv v) 255 { 256 return jjOP_BIM_I(res, v, u); 257 } 258 static BOOLEAN jjOP_BIM_BI(leftv res, leftv u, leftv v) 259 { 260 bigintmat* aa= (bigintmat *)u->Data(); 261 number bb = (number)(v->Data()); 262 if (errorreported) return TRUE; 263 bigintmat *cc=NULL; 264 switch (iiOp) 265 { 266 case '*': cc=bimMult(aa,bb,coeffs_BIGINT); break; 267 } 268 res->data=(char *)cc; 269 return cc==NULL; 270 } 271 static BOOLEAN jjOP_BI_BIM(leftv res, leftv u, leftv v) 272 { 273 return jjOP_BIM_BI(res, v, u); 274 } 238 275 static BOOLEAN jjOP_IV_I(leftv res, leftv u, leftv v) 239 276 { … … 300 337 intvec* a = (intvec * )(u->Data()); 301 338 intvec* b = (intvec * )(v->Data()); 339 int r=a->compare(b); 340 switch (iiOp) 341 { 342 case '<': 343 res->data = (char *) (r<0); 344 break; 345 case '>': 346 res->data = (char *) (r>0); 347 break; 348 case LE: 349 res->data = (char *) (r<=0); 350 break; 351 case GE: 352 res->data = (char *) (r>=0); 353 break; 354 case EQUAL_EQUAL: 355 case NOTEQUAL: /* negation handled by jjEQUAL_REST */ 356 res->data = (char *) (r==0); 357 break; 358 } 359 jjEQUAL_REST(res,u,v); 360 if(r==-2) { WerrorS("size incompatible"); return TRUE; } 361 return FALSE; 362 } 363 static BOOLEAN jjCOMPARE_BIM(leftv res, leftv u, leftv v) 364 { 365 bigintmat* a = (bigintmat * )(u->Data()); 366 bigintmat* b = (bigintmat * )(v->Data()); 302 367 int r=a->compare(b); 303 368 switch (iiOp) … … 684 749 return jjPLUSMINUS_Gen(res,u,v); 685 750 } 751 static BOOLEAN jjPLUS_BIM(leftv res, leftv u, leftv v) 752 { 753 res->data = (char *)bimAdd((bigintmat*)(u->Data()), (bigintmat*)(v->Data())); 754 if (res->data==NULL) 755 { 756 WerrorS("bigintmat size not compatible"); 757 return TRUE; 758 } 759 return jjPLUSMINUS_Gen(res,u,v); 760 } 686 761 static BOOLEAN jjPLUS_MA(leftv res, leftv u, leftv v) 687 762 { … … 767 842 return jjPLUSMINUS_Gen(res,u,v); 768 843 } 844 static BOOLEAN jjMINUS_BIM(leftv res, leftv u, leftv v) 845 { 846 res->data = (char *)bimSub((bigintmat*)(u->Data()), (bigintmat*)(v->Data())); 847 if (res->data==NULL) 848 { 849 WerrorS("bigintmat size not compatible"); 850 return TRUE; 851 } 852 return jjPLUSMINUS_Gen(res,u,v); 853 } 769 854 static BOOLEAN jjMINUS_MA(leftv res, leftv u, leftv v) 770 855 { … … 877 962 WerrorS("intmat size not compatible"); 878 963 return TRUE; 964 } 965 if ((v->next!=NULL) || (u->next!=NULL)) 966 return jjOP_REST(res,u,v); 967 return FALSE; 968 } 969 static BOOLEAN jjTIMES_BIM(leftv res, leftv u, leftv v) 970 { 971 res->data = (char *)bimMult((bigintmat*)(u->Data()), (bigintmat*)(v->Data())); 972 if (res->data==NULL) 973 { 974 WerrorS("bigintmat size not compatible"); 975 return TRUE; 879 976 } 880 977 if ((v->next!=NULL) || (u->next!=NULL)) … … 3497 3594 (*iv)*=(-1); 3498 3595 res->data = (char *)iv; 3596 return FALSE; 3597 } 3598 static BOOLEAN jjUMINUS_BIM(leftv res, leftv u) 3599 { 3600 bigintmat *bim=(bigintmat *)u->CopyD(BIGINTMAT_CMD); 3601 (*bim)*=(-1); 3602 res->data = (char *)bim; 3499 3603 return FALSE; 3500 3604 } … … 5223 5327 e->next=jjMakeSub(w); 5224 5328 if (u->e==NULL) res->e=e; 5329 else 5330 { 5331 Subexpr h=u->e; 5332 while (h->next!=NULL) h=h->next; 5333 h->next=e; 5334 res->e=u->e; 5335 u->e=NULL; 5336 } 5337 return FALSE; 5338 } 5339 static BOOLEAN jjBRACK_Bim(leftv res, leftv u, leftv v, leftv w) 5340 { 5341 bigintmat *bim = (bigintmat *)u->Data(); 5342 int r = (int)(long)v->Data(); 5343 int c = (int)(long)w->Data(); 5344 if ((r<1)||(r>bim->rows())||(c<1)||(c>bim->cols())) 5345 { 5346 Werror("wrong range[%d,%d] in bigintmat %s(%d x %d)", 5347 r,c,u->Fullname(),bim->rows(),bim->cols()); 5348 return TRUE; 5349 } 5350 res->data=u->data; u->data=NULL; 5351 res->rtyp=u->rtyp; u->rtyp=0; 5352 res->name=u->name; u->name=NULL; 5353 Subexpr e=jjMakeSub(v); 5354 e->next=jjMakeSub(w); 5355 if (u->e==NULL) 5356 res->e=e; 5225 5357 else 5226 5358 { -
Singular/ipassign.cc
rc8302b r75f10d 25 25 #include <coeffs/numbers.h> 26 26 #include <coeffs/longrat.h> 27 #include <coeffs/bigintmat.h> 27 28 28 29 … … 247 248 248 249 n_Normalize(p, currRing->cf); 249 250 250 251 assume( currRing->cf->extRing->qideal == NULL ); 251 252 … … 383 384 { 384 385 number p=(number)a->CopyD(BIGINT_CMD); 385 if (res->data!=NULL) n_Delete((number *)&res->data,coeffs_BIGINT); 386 res->data=(void *)p; 386 if (e==NULL) 387 { 388 if (res->data!=NULL) n_Delete((number *)&res->data,coeffs_BIGINT); 389 res->data=(void *)p; 390 } 391 else 392 { 393 int i=e->start-1; 394 if (i<0) 395 { 396 Werror("index[%d] must be positive",i+1); 397 return TRUE; 398 } 399 bigintmat *iv=(bigintmat *)res->data; 400 if (e->next==NULL) 401 { 402 WerrorS("only one index given"); 403 return TRUE; 404 } 405 else 406 { 407 int c=e->next->start; 408 if ((i>=iv->rows())||(c<1)||(c>iv->cols())) 409 { 410 Werror("wrong range [%d,%d] in bigintmat (%d,%d)",i+1,c,iv->rows(),iv->cols()); 411 return TRUE; 412 } 413 else 414 { 415 n_Delete((number *)&BIMATELEM(*iv,i+1,c),iv->basecoeffs()); 416 BIMATELEM(*iv,i+1,c) = p; 417 } 418 } 419 } 387 420 jiAssignAttr(res,a); 388 421 return FALSE; … … 565 598 } 566 599 #endif 600 } 601 static BOOLEAN jiA_BIGINTMAT(leftv res, leftv a, Subexpr e) 602 { 603 if (res->data!=NULL) delete ((bigintmat *)res->data); 604 res->data=(void *)a->CopyD(BIGINTMAT_CMD); 605 jiAssignAttr(res,a); 606 return FALSE; 567 607 } 568 608 static BOOLEAN jiA_IDEAL(leftv res, leftv a, Subexpr e) … … 1165 1205 return FALSE; 1166 1206 } 1207 static BOOLEAN jjA_L_BIGINTMAT(leftv l,leftv r,bigintmat *bim) 1208 { 1209 /* left side is bigintmat, right side is list (of int,intvec,intmat)*/ 1210 leftv hh=r; 1211 int i = 0; 1212 while (hh!=NULL) 1213 { 1214 if (i>=bim->cols()*bim->rows()) 1215 { 1216 if (TEST_V_ALLWARN) 1217 { 1218 Warn("expression list length(%d) does not match bigintmat size(%d x %d)", 1219 exprlist_length(hh),bim->rows(),bim->cols()); 1220 } 1221 break; 1222 } 1223 if (hh->Typ() == INT_CMD) 1224 { 1225 number tp = n_Init((int)((long)(hh->Data())), coeffs_BIGINT); 1226 bim->set(i++, tp); 1227 n_Delete(&tp, coeffs_BIGINT); 1228 } 1229 else if (hh->Typ() == BIGINT_CMD) 1230 { 1231 bim->set(i++, (number)(hh->Data())); 1232 } 1233 /* 1234 ((hh->Typ() == INTVEC_CMD) 1235 ||(hh->Typ() == INTMAT_CMD)) 1236 { 1237 intvec *ivv = (intvec *)(hh->Data()); 1238 int ll = 0,l = si_min(ivv->length(),iv->length()); 1239 for (; l>0; l--) 1240 { 1241 (*iv)[i++] = (*ivv)[ll++]; 1242 } 1243 }*/ 1244 else 1245 { 1246 delete bim; 1247 return TRUE; 1248 } 1249 hh = hh->next; 1250 } 1251 if (IDBIMAT((idhdl)l->data)!=NULL) delete IDBIMAT((idhdl)l->data); 1252 IDBIMAT((idhdl)l->data)=bim; 1253 return FALSE; 1254 } 1167 1255 static BOOLEAN jjA_L_STRING(leftv l,leftv r) 1168 1256 { … … 1554 1642 { 1555 1643 nok=jjA_L_INTVEC(l,r,new intvec(IDINTVEC((idhdl)l->data))); 1644 break; 1645 } 1646 case BIGINTMAT_CMD: 1647 { 1648 nok=jjA_L_BIGINTMAT(l, r, new bigintmat(IDBIMAT((idhdl)l->data))); 1556 1649 break; 1557 1650 } -
Singular/ipconv.cc
rc8302b r75f10d 19 19 #include <coeffs/numbers.h> 20 20 #include <coeffs/coeffs.h> 21 #include <coeffs/bigintmat.h> 21 22 //#include <polys/ext_fields/longalg.h> 22 23 #ifdef HAVE_RINGS … … 185 186 delete iv; 186 187 return (void *)m; 188 } 189 190 static void * iiIm2Bim(void *data) 191 { 192 return (void *)iv2bim((intvec*)data,coeffs_BIGINT); 193 } 194 195 static void * iiBim2Im(void *data) 196 { 197 return (void *)bim2iv((bigintmat*)data); 187 198 } 188 199 -
Singular/ipid.cc
rc8302b r75f10d 18 18 #include <kernel/febase.h> 19 19 #include <coeffs/numbers.h> 20 #include <coeffs/bigintmat.h> 20 21 #include <kernel/longrat.h> 21 22 #include <kernel/polys.h> … … 126 127 case INTMAT_CMD: 127 128 return (void *)new intvec(); 129 case BIGINTMAT_CMD: 130 return (void *)new bigintmat(); 128 131 case NUMBER_CMD: 129 132 return (void *) nInit(0); -
Singular/subexpr.cc
rc8302b r75f10d 23 23 #include <coeffs/ffields.h> 24 24 #include <coeffs/numbers.h> 25 #include <coeffs/bigintmat.h> 25 26 26 27 #include <polys/monomials/maps.h> … … 123 124 case INTMAT_CMD: 124 125 ((intvec *)d)->show(t,spaces); 126 break; 127 case BIGINTMAT_CMD: 128 ((bigintmat *)d)->pprint(80); 125 129 break; 126 130 case RING_CMD: … … 384 388 case INTMAT_CMD: 385 389 return (void *)ivCopy((intvec *)d); 390 case BIGINTMAT_CMD: 391 return (void*)bimCopy((bigintmat *)d); 386 392 case MATRIX_CMD: 387 393 return (void *)mp_Copy((matrix)d, currRing); … … 454 460 break; 455 461 } 462 case BIGINTMAT_CMD: 463 { 464 bigintmat *v=(bigintmat*)d; 465 delete v; 466 break; 467 } 456 468 case MAP_CMD: 457 469 { … … 821 833 return s; 822 834 } 835 case BIGINTMAT_CMD: 836 { 837 bigintmat *bim=(bigintmat*)d; 838 s = bim->String(); 839 if (typed) 840 { 841 char* ns = (char*) omAlloc0(strlen(s) + 40); 842 sprintf(ns, "bigintmat(bigintvec(%s),%d,%d)", s, bim->rows(), bim->cols()); 843 omCheckAddr(ns); 844 return ns; 845 } 846 else 847 return omStrDup(s); 848 } 823 849 824 850 case RING_CMD: … … 942 968 r=INT_CMD; 943 969 break; 970 case BIGINTMAT_CMD: 971 r=BIGINT_CMD; 972 break; 944 973 case IDEAL_CMD: 945 974 case MATRIX_CMD: … … 1118 1147 else 1119 1148 r=(char *)(IMATELEM((*iv),index,e->next->start)); 1149 break; 1150 } 1151 case BIGINTMAT_CMD: 1152 { 1153 bigintmat *m=(bigintmat *)d; 1154 if ((index<1) 1155 ||(index>m->rows()) 1156 ||(e->next->start<1) 1157 ||(e->next->start>m->cols())) 1158 { 1159 if (!errorreported) 1160 Werror("wrong range[%d,%d] in bigintmat(%dx%d)",index,e->next->start, 1161 m->rows(),m->cols()); 1162 } 1163 else 1164 r=(char *)(BIMATELEM((*m),index,e->next->start)); 1120 1165 break; 1121 1166 } -
Singular/table.h
rc8302b r75f10d 31 31 ,{D(jjUMINUS_IV), '-', INTVEC_CMD, INTVEC_CMD , ALLOW_PLURAL |ALLOW_RING} 32 32 ,{D(jjUMINUS_IV), '-', INTMAT_CMD, INTMAT_CMD , ALLOW_PLURAL |ALLOW_RING} 33 ,{D(jjUMINUS_BIM), '-', BIGINTMAT_CMD, BIGINTMAT_CMD , ALLOW_PLURAL |ALLOW_RING} 33 34 ,{D(jjPROC1), '(', ANY_TYPE/*set by p*/,PROC_CMD , ALLOW_PLURAL |ALLOW_RING} 34 35 // and the procedures with 1 argument: … … 43 44 ,{D(jjN2BI), BIGINT_CMD, BIGINT_CMD, NUMBER_CMD , ALLOW_PLURAL |ALLOW_RING} 44 45 ,{D(jjP2BI), BIGINT_CMD, BIGINT_CMD, POLY_CMD , ALLOW_PLURAL |ALLOW_RING} 46 ,{D(jjDUMMY), BIGINTMAT_CMD, BIGINTMAT_CMD, BIGINTMAT_CMD , ALLOW_PLURAL |ALLOW_RING} 45 47 ,{D(jjCHAR), CHARACTERISTIC_CMD, INT_CMD, RING_CMD , ALLOW_PLURAL |ALLOW_RING} 46 48 ,{D(jjCHAR), CHARACTERISTIC_CMD, INT_CMD, QRING_CMD , ALLOW_PLURAL |ALLOW_RING} … … 305 307 ,{D(jjPLUS_IV), '+', INTVEC_CMD, INTVEC_CMD, INTVEC_CMD, ALLOW_PLURAL | ALLOW_RING} 306 308 ,{D(jjPLUS_IV), '+', INTMAT_CMD, INTMAT_CMD, INTMAT_CMD, ALLOW_PLURAL | ALLOW_RING} 309 ,{D(jjPLUS_BIM), '+', BIGINTMAT_CMD, BIGINTMAT_CMD, BIGINTMAT_CMD, ALLOW_PLURAL | ALLOW_RING} 310 ,{D(jjOP_BIM_I), '+', BIGINTMAT_CMD, BIGINTMAT_CMD, INT_CMD, ALLOW_PLURAL | ALLOW_RING} 311 ,{D(jjOP_I_BIM), '+', BIGINTMAT_CMD, INT_CMD, BIGINTMAT_CMD, ALLOW_PLURAL | ALLOW_RING} 312 ,{D(jjOP_BIM_BI), '+', BIGINTMAT_CMD, BIGINTMAT_CMD, BIGINT_CMD, ALLOW_PLURAL | ALLOW_RING} 313 ,{D(jjOP_BI_BIM), '+', BIGINTMAT_CMD, BIGINT_CMD, BIGINTMAT_CMD, ALLOW_PLURAL | ALLOW_RING} 307 314 ,{D(lAdd), '+', LIST_CMD, LIST_CMD, LIST_CMD, ALLOW_PLURAL | ALLOW_RING} 308 315 ,{D(jjRSUM), '+', RING_CMD, RING_CMD, RING_CMD, ALLOW_PLURAL | ALLOW_RING} … … 321 328 ,{D(jjMINUS_IV), '-', INTVEC_CMD, INTVEC_CMD, INTVEC_CMD, ALLOW_PLURAL | ALLOW_RING} 322 329 ,{D(jjMINUS_IV), '-', INTMAT_CMD, INTMAT_CMD, INTMAT_CMD, ALLOW_PLURAL | ALLOW_RING} 330 ,{D(jjMINUS_BIM), '-', BIGINTMAT_CMD, BIGINTMAT_CMD, BIGINTMAT_CMD, ALLOW_PLURAL | ALLOW_RING} 331 ,{D(jjOP_BIM_I), '-', BIGINTMAT_CMD, BIGINTMAT_CMD, INT_CMD, ALLOW_PLURAL | ALLOW_RING} 332 ,{D(jjOP_I_BIM), '-', BIGINTMAT_CMD, INT_CMD, BIGINTMAT_CMD, ALLOW_PLURAL | ALLOW_RING} 333 ,{D(jjOP_BIM_BI), '-', BIGINTMAT_CMD, BIGINTMAT_CMD, BIGINT_CMD, ALLOW_PLURAL | ALLOW_RING} 334 ,{D(jjOP_BI_BIM), '-', BIGINTMAT_CMD, BIGINT_CMD, BIGINTMAT_CMD, ALLOW_PLURAL | ALLOW_RING} 323 335 ,{ jjWRONG2 , '-', NONE, IDEAL_CMD, IDEAL_CMD, ALLOW_PLURAL | ALLOW_RING} 324 336 ,{ jjWRONG2 , '-', NONE, MODUL_CMD, MODUL_CMD, ALLOW_PLURAL | ALLOW_RING} … … 354 366 ,{D(jjTIMES_IV), '*', INTMAT_CMD, INTMAT_CMD, INTMAT_CMD, ALLOW_PLURAL | ALLOW_RING} 355 367 ,{D(jjTIMES_IV), '*', INTMAT_CMD, INTVEC_CMD, INTMAT_CMD, ALLOW_PLURAL | ALLOW_RING} 368 ,{D(jjTIMES_BIM), '*', BIGINTMAT_CMD, BIGINTMAT_CMD, BIGINTMAT_CMD, ALLOW_PLURAL | ALLOW_RING} 369 ,{D(jjOP_BIM_I), '*', BIGINTMAT_CMD, BIGINTMAT_CMD, INT_CMD, ALLOW_PLURAL | ALLOW_RING} 370 ,{D(jjOP_I_BIM), '*', BIGINTMAT_CMD, INT_CMD, BIGINTMAT_CMD, ALLOW_PLURAL | ALLOW_RING} 371 ,{D(jjOP_BIM_BI), '*', BIGINTMAT_CMD, BIGINTMAT_CMD, BIGINT_CMD, ALLOW_PLURAL | ALLOW_RING} 372 ,{D(jjOP_BI_BIM), '*', BIGINTMAT_CMD, BIGINT_CMD, BIGINTMAT_CMD, ALLOW_PLURAL | ALLOW_RING} 356 373 ,{D(jjDIV_N), '/', NUMBER_CMD, NUMBER_CMD, NUMBER_CMD, ALLOW_PLURAL | ALLOW_RING} 357 374 ,{D(jjDIV_P), '/', POLY_CMD, POLY_CMD, POLY_CMD, ALLOW_PLURAL | ALLOW_RING} … … 424 441 ,{D(jjCOMPARE_IV),EQUAL_EQUAL, INT_CMD, INTVEC_CMD, INTVEC_CMD, ALLOW_PLURAL | ALLOW_RING} 425 442 ,{D(jjCOMPARE_IV),EQUAL_EQUAL, INT_CMD, INTMAT_CMD, INTMAT_CMD, ALLOW_PLURAL | ALLOW_RING} 443 ,{D(jjCOMPARE_BIM),EQUAL_EQUAL, INT_CMD, BIGINTMAT_CMD, BIGINTMAT_CMD, ALLOW_PLURAL | ALLOW_RING} 426 444 ,{D(jjEQUAL_Ma), EQUAL_EQUAL, INT_CMD, MATRIX_CMD, MATRIX_CMD, ALLOW_PLURAL | ALLOW_RING} 427 445 ,{ jjWRONG2 , EQUAL_EQUAL, 0, IDEAL_CMD, IDEAL_CMD, ALLOW_PLURAL | ALLOW_RING} … … 663 681 ,{D(jjBRACK_Ma_IV_I), '[', INT_CMD, INTMAT_CMD, INTVEC_CMD, INT_CMD, ALLOW_PLURAL |ALLOW_RING} 664 682 ,{D(jjBRACK_Ma_IV_IV), '[', INT_CMD, INTMAT_CMD, INTVEC_CMD, INTVEC_CMD, ALLOW_PLURAL |ALLOW_RING} 683 ,{D(jjBRACK_Bim), '[', BIGINT_CMD, BIGINTMAT_CMD, INT_CMD, INT_CMD, ALLOW_PLURAL |ALLOW_RING} 665 684 ,{D(jjBRACK_Ma), '[', POLY_CMD, MATRIX_CMD, INT_CMD, INT_CMD, ALLOW_PLURAL |ALLOW_RING} 666 685 ,{D(jjBRACK_Ma_I_IV), '[', POLY_CMD, MATRIX_CMD, INT_CMD, INTVEC_CMD, ALLOW_PLURAL |ALLOW_RING} … … 825 844 { "betti", 0, BETTI_CMD , CMD_12}, 826 845 { "bigint", 0, BIGINT_CMD , ROOT_DECL}, 846 { "bigintmat", 0, BIGINTMAT_CMD , BIGINTMAT_CMD}, 827 847 #ifdef HAVE_PLURAL 828 848 { "bracket", 0, BRACKET_CMD , CMD_2}, … … 847 867 { "degree", 0, DEGREE_CMD , CMD_1}, 848 868 { "delete", 0, DELETE_CMD , CMD_2}, 849 { "denominator", 0, DENOMINATOR_CMD , CMD_1}, 869 { "denominator", 0, DENOMINATOR_CMD , CMD_1}, 850 870 { "det", 0, DET_CMD , CMD_1}, 851 871 { "diff", 0, DIFF_CMD , CMD_2}, … … 1110 1130 // intmat -> matrix 1111 1131 { INTMAT_CMD, MATRIX_CMD, D(iiIm2Ma) , NULL }, 1132 // intmat -> bigintmat 1133 { INTMAT_CMD, BIGINTMAT_CMD, D(iiIm2Bim) , NULL }, 1134 // bigintmat -> intmat 1135 { BIGINTMAT_CMD, INTMAT_CMD, D(iiBim2Im) , NULL }, 1112 1136 // number -> poly 1113 1137 { NUMBER_CMD, POLY_CMD, D(iiN2P) , NULL }, … … 1174 1198 ,{D(jiA_INTVEC), INTMAT_CMD, INTMAT_CMD } 1175 1199 //,{D(jiA_INTVEC), INTMAT_CMD, INTVEC_CMD } 1200 ,{D(jiA_BIGINTMAT),BIGINTMAT_CMD, BIGINTMAT_CMD} 1176 1201 ,{D(jiA_NUMBER), NUMBER_CMD, NUMBER_CMD } 1177 1202 ,{D(jiA_BIGINT), BIGINT_CMD, BIGINT_CMD } -
libpolys/coeffs/bigintmat.cc
rc8302b r75f10d 32 32 assume (i > 0 && j > 0); 33 33 assume (i <= rows() && j <= cols()); 34 34 35 35 set(index(i, j), n, C); 36 36 } … … 40 40 assume (i >= 0); 41 41 assume (i<rows()*cols()); 42 42 43 43 return n_Copy(v[i], basecoeffs()); 44 44 } … … 48 48 assume (i > 0 && j > 0); 49 49 assume (i <= rows() && j <= cols()); 50 50 51 51 return get(index(i, j)); 52 52 } … … 57 57 { 58 58 number iop = n_Init(intop, basecoeffs()); 59 59 60 60 inpMult(iop, basecoeffs()); 61 61 62 62 n_Delete(&iop, basecoeffs()); 63 63 } … … 66 66 { 67 67 assume (C == NULL || C == basecoeffs()); 68 68 69 69 const int l = rows() * cols(); 70 70 … … 85 85 86 86 const int l = (lhr.rows())*(lhr.cols()); 87 87 88 88 for (int i=0; i < l; i++) 89 89 { 90 90 if (!n_Equal(lhr[i], rhr[i], lhr.basecoeffs())) { return false; } 91 91 } 92 92 93 93 return true; 94 94 } … … 104 104 if (a->cols() != b->cols()) return NULL; 105 105 if (a->basecoeffs() != b->basecoeffs()) { return NULL; } 106 106 107 107 const int mn = si_min(a->rows(),b->rows()); 108 108 const int ma = si_max(a->rows(),b->rows()); 109 109 110 110 const coeffs basecoeffs = a->basecoeffs(); 111 111 112 112 int i; 113 113 … … 115 115 { 116 116 bigintmat * bim = new bigintmat(ma, 1, basecoeffs); 117 117 118 118 for (i=0; i<mn; i++) 119 119 bim->rawset(i, n_Add((*a)[i], (*b)[i], basecoeffs), basecoeffs); 120 120 121 121 if (ma > mn) 122 122 { … … 130 130 return bim; 131 131 } 132 132 133 133 if (mn != ma) return NULL; 134 134 135 135 bigintmat * bim = new bigintmat(mn, a->cols(), basecoeffs); 136 136 137 137 for (i=0; i<mn*a->cols(); i++) 138 138 bim->rawset(i, n_Add((*a)[i], (*b)[i], basecoeffs), basecoeffs); 139 139 140 return bim; 141 } 142 bigintmat * bimAdd(bigintmat * a, int b) 143 { 144 145 const int mn = a->rows()*a->cols(); 146 147 const coeffs basecoeffs = a->basecoeffs(); 148 number bb=n_Init(b,basecoeffs); 149 150 int i; 151 152 bigintmat * bim = new bigintmat(a->rows(),a->cols() , basecoeffs); 153 154 for (i=0; i<mn; i++) 155 bim->rawset(i, n_Add((*a)[i], bb, basecoeffs), basecoeffs); 156 157 n_Delete(&bb,basecoeffs); 140 158 return bim; 141 159 } … … 156 174 { 157 175 bigintmat * bim = new bigintmat(ma, 1, basecoeffs); 158 176 159 177 for (i=0; i<mn; i++) 160 178 bim->rawset(i, n_Sub((*a)[i], (*b)[i], basecoeffs), basecoeffs); … … 177 195 return bim; 178 196 } 179 197 180 198 if (mn != ma) return NULL; 181 199 182 200 bigintmat * bim = new bigintmat(mn, a->cols(), basecoeffs); 183 201 184 202 for (i=0; i<mn*a->cols(); i++) 185 203 bim->rawset(i, n_Sub((*a)[i], (*b)[i], basecoeffs), basecoeffs); 186 204 205 return bim; 206 } 207 208 bigintmat * bimSub(bigintmat * a, int b) 209 { 210 211 const int mn = a->rows()*a->cols(); 212 213 const coeffs basecoeffs = a->basecoeffs(); 214 number bb=n_Init(b,basecoeffs); 215 216 int i; 217 218 bigintmat * bim = new bigintmat(a->rows(),a->cols() , basecoeffs); 219 220 for (i=0; i<mn; i++) 221 bim->rawset(i, n_Sub((*a)[i], bb, basecoeffs), basecoeffs); 222 223 n_Delete(&bb,basecoeffs); 187 224 return bim; 188 225 } … … 195 232 const int ra = a->rows(); 196 233 const int rb = b->rows(); 197 234 198 235 if (ca != rb) 199 236 { … … 203 240 return NULL; 204 241 } 205 242 206 243 assume (ca == rb); 207 244 208 245 if (a->basecoeffs() != b->basecoeffs()) { return NULL; } 209 246 210 247 const coeffs basecoeffs = a->basecoeffs(); 211 248 212 249 int i, j, k; 213 250 214 251 number sum; 215 252 216 253 bigintmat * bim = new bigintmat(ra, cb, basecoeffs); 217 254 218 255 for (i=0; i<ra; i++) 219 256 for (j=0; j<cb; j++) 220 257 { 221 258 sum = n_Init(0, basecoeffs); 222 259 223 260 for (k=0; k<ca; k++) 224 261 { 225 262 number prod = n_Mult( BIMATELEM(*a, i, k), BIMATELEM(*b, k, j), basecoeffs); 226 263 227 264 number sum2 = n_Add(sum, prod, basecoeffs); // no inplace add :( 228 265 229 266 n_Delete(&sum, basecoeffs); n_Delete(&prod, basecoeffs); 230 267 231 268 sum = sum2; 232 269 } 233 270 bim->rawset(i+1, j+1, sum, basecoeffs); 234 271 } 272 return bim; 273 } 274 275 bigintmat * bimMult(bigintmat * a, int b) 276 { 277 278 const int mn = a->rows()*a->cols(); 279 280 const coeffs basecoeffs = a->basecoeffs(); 281 number bb=n_Init(b,basecoeffs); 282 283 int i; 284 285 bigintmat * bim = new bigintmat(a->rows(),a->cols() , basecoeffs); 286 287 for (i=0; i<mn; i++) 288 bim->rawset(i, n_Mult((*a)[i], bb, basecoeffs), basecoeffs); 289 290 n_Delete(&bb,basecoeffs); 291 return bim; 292 } 293 294 bigintmat * bimMult(bigintmat * a, number b, const coeffs cf) 295 { 296 if (cf!=a->basecoeffs()) return NULL; 297 298 const int mn = a->rows()*a->cols(); 299 300 const coeffs basecoeffs = a->basecoeffs(); 301 302 int i; 303 304 bigintmat * bim = new bigintmat(a->rows(),a->cols() , basecoeffs); 305 306 for (i=0; i<mn; i++) 307 bim->rawset(i, n_Mult((*a)[i], b, basecoeffs), basecoeffs); 308 235 309 return bim; 236 310 } … … 251 325 const int l = (b->rows())*(b->cols()); 252 326 bigintmat * bim = new bigintmat(b->rows(), b->cols(), C); 253 327 254 328 for (int i=0; i < l; i++) 255 329 bim->rawset(i, n_Init((*b)[i], C), C); 256 330 257 331 return bim; 258 332 } … … 307 381 if (b == NULL) 308 382 return NULL; 309 383 310 384 return new bigintmat(b); 311 385 } … … 434 508 { 435 509 const coeffs basecoeffs = bimat->basecoeffs(); 436 510 437 511 number tgcd, m; 438 512 int i=bimat->cols(); -
libpolys/coeffs/bigintmat.h
rc8302b r75f10d 91 91 return v[i]; 92 92 } 93 #define BIMATELEM(M,I,J) (M)[(I-1)*(M).cols()+J-1] 93 94 94 95 /// UEberladener *=-Operator (fuer int und bigint) 95 96 /// Frage hier: *= verwenden oder lieber = und * einzeln? 96 97 void operator*=(int intop); 97 98 98 99 void inpMult(number bintop, const coeffs C = NULL); 99 100 … … 115 116 { 116 117 assume (rows() >= 0 && cols() >= 0); 117 118 118 119 assume (r > 0 && c > 0); 119 120 assume (r <= rows() && r <= cols()); … … 134 135 /// NOTE: starts at [1,1] 135 136 void set(int i, int j, number n, const coeffs C = NULL); 136 137 137 138 /// replace an entry with a copy (delete old + copy new!). 138 139 /// NOTE: starts at [0] … … 152 153 { 153 154 n_Delete(&(v[i]), basecoeffs()); v[i] = n; 154 } else 155 { 155 } 156 156 #ifndef NDEBUG 157 else 158 { 157 159 Werror("wrong bigintmat index:%d\n",i); 160 } 158 161 #endif 159 } 160 } 161 162 } 163 162 164 inline void rawset(int i, int j, number n, const coeffs C = NULL) 163 165 { … … 177 179 /// NOTE: NULL as a result means an error (non-compatible matrices?) 178 180 bigintmat * bimAdd(bigintmat * a, bigintmat * b); 181 bigintmat * bimAdd(bigintmat * a, int b); 179 182 bigintmat * bimSub(bigintmat * a, bigintmat * b); 183 bigintmat * bimSub(bigintmat * a, int b); 180 184 bigintmat * bimMult(bigintmat * a, bigintmat * b); 185 bigintmat * bimMult(bigintmat * a, int b); 186 bigintmat * bimMult(bigintmat * a, number b, const coeffs cf); 181 187 bigintmat * bimCopy(const bigintmat * b); 182 188
Note: See TracChangeset
for help on using the changeset viewer.