[SCM] an open source computer algebra system branch, cleanedupstream, updated. 6125e540ca6d66c307958938a9d53b245507c323

Bernhard R. Link brlink at debian.org
Tue Apr 24 15:55:40 UTC 2012


The following commit has been merged in the cleanedupstream branch:
commit 5ea3ff994b1d647d4e52f05768abfbb6f1076f89
Author: Hans Schoenemann <hannes at mathematik.uni-kl.de>
Date:   Tue Apr 17 20:35:35 2012 +0200

    add: bigintmat and some basic ops with it

diff --git a/Singular/grammar.cc b/Singular/grammar.cc
index 8edaa0d..0a5423b 100644
--- a/Singular/grammar.cc
+++ b/Singular/grammar.cc
@@ -329,6 +329,7 @@
 #include <Singular/stype.h>
 #include <Singular/ipid.h>
 #include <kernel/intvec.h>
+#include <kernel/bigintmat.h>
 #include <kernel/febase.h>
 #include <kernel/matpol.h>
 #include <kernel/ring.h>
@@ -510,7 +511,7 @@ typedef int YYSTYPE;
 
 
 /* Line 214 of yacc.c.  */
-#line 514 "grammar.cc"
+#line 515 "grammar.cc"
 
 #if ! defined (yyoverflow) || YYERROR_VERBOSE
 
@@ -774,23 +775,23 @@ static const short int yyrhs[] =
 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
 static const unsigned short int yyrline[] =
 {
-       0,   359,   359,   361,   395,   396,   398,   400,   404,   409,
-     411,   462,   463,   464,   465,   466,   467,   468,   469,   473,
-     476,   477,   478,   479,   480,   481,   482,   483,   484,   487,
-     494,   499,   503,   507,   511,   515,   528,   556,   580,   586,
-     592,   599,   610,   616,   621,   622,   623,   627,   631,   635,
-     639,   643,   647,   651,   655,   659,   663,   667,   671,   675,
-     679,   683,   687,   691,   695,   699,   703,   707,   711,   715,
-     719,   723,   727,   731,   749,   748,   766,   774,   783,   787,
-     791,   795,   799,   803,   807,   811,   815,   819,   823,   827,
-     831,   838,   845,   846,   865,   866,   878,   883,   888,   892,
-     896,   929,   953,   974,   982,   986,   987,  1001,  1009,  1018,
-    1063,  1064,  1073,  1074,  1080,  1086,  1088,  1090,  1100,  1099,
-    1107,  1112,  1119,  1127,  1139,  1155,  1174,  1178,  1182,  1187,
-    1191,  1195,  1199,  1203,  1208,  1214,  1220,  1226,  1232,  1238,
-    1244,  1256,  1263,  1267,  1304,  1314,  1327,  1327,  1330,  1402,
-    1406,  1435,  1448,  1465,  1474,  1479,  1487,  1499,  1518,  1529,
-    1549,  1573,  1579,  1591,  1598
+       0,   360,   360,   362,   396,   397,   399,   401,   405,   410,
+     412,   463,   464,   465,   466,   467,   468,   469,   470,   474,
+     477,   478,   479,   480,   481,   482,   483,   484,   485,   488,
+     495,   500,   504,   508,   512,   516,   529,   557,   581,   587,
+     593,   600,   611,   617,   622,   623,   624,   628,   632,   636,
+     640,   644,   648,   652,   656,   660,   664,   668,   672,   676,
+     680,   684,   688,   692,   696,   700,   704,   708,   712,   716,
+     720,   724,   728,   732,   750,   749,   767,   775,   784,   788,
+     792,   796,   800,   804,   808,   812,   816,   820,   824,   828,
+     832,   839,   846,   847,   866,   867,   879,   884,   889,   893,
+     897,   937,   963,   984,   992,   996,   997,  1011,  1019,  1028,
+    1073,  1074,  1083,  1084,  1090,  1096,  1098,  1100,  1110,  1109,
+    1117,  1122,  1129,  1137,  1149,  1165,  1184,  1188,  1192,  1197,
+    1201,  1205,  1209,  1213,  1218,  1224,  1230,  1236,  1242,  1248,
+    1254,  1266,  1273,  1277,  1314,  1324,  1337,  1337,  1340,  1412,
+    1416,  1445,  1458,  1475,  1484,  1489,  1497,  1509,  1528,  1539,
+    1559,  1583,  1589,  1601,  1608
 };
 #endif
 
@@ -2037,7 +2038,7 @@ yyreduce:
   switch (yyn)
     {
         case 3:
-#line 362 "grammar.y"
+#line 363 "grammar.y"
     {
             if (timerv)
             {
@@ -2071,24 +2072,24 @@ yyreduce:
     break;
 
   case 5:
-#line 397 "grammar.y"
+#line 398 "grammar.y"
     {currentVoice->ifsw=0;;}
     break;
 
   case 6:
-#line 399 "grammar.y"
+#line 400 "grammar.y"
     { yyvsp[-1].lv.CleanUp(); currentVoice->ifsw=0;;}
     break;
 
   case 7:
-#line 401 "grammar.y"
+#line 402 "grammar.y"
     {
             YYACCEPT;
           ;}
     break;
 
   case 8:
-#line 405 "grammar.y"
+#line 406 "grammar.y"
     {
             currentVoice->ifsw=0;
             iiDebug();
@@ -2096,12 +2097,12 @@ yyreduce:
     break;
 
   case 9:
-#line 410 "grammar.y"
+#line 411 "grammar.y"
     {currentVoice->ifsw=0;;}
     break;
 
   case 10:
-#line 412 "grammar.y"
+#line 413 "grammar.y"
     {
             #ifdef SIQ
             siq=0;
@@ -2153,24 +2154,24 @@ yyreduce:
     break;
 
   case 18:
-#line 470 "grammar.y"
+#line 471 "grammar.y"
     {if (currentVoice!=NULL) currentVoice->ifsw=0;;}
     break;
 
   case 19:
-#line 473 "grammar.y"
+#line 474 "grammar.y"
     { omFree((ADDRESS)yyvsp[0].name); ;}
     break;
 
   case 29:
-#line 488 "grammar.y"
+#line 489 "grammar.y"
     {
             if(iiAssign(&yyvsp[-1].lv,&yyvsp[0].lv)) YYERROR;
           ;}
     break;
 
   case 30:
-#line 495 "grammar.y"
+#line 496 "grammar.y"
     {
             if (currRing==NULL) MYYERROR("no ring active");
             syMake(&yyval.lv,omStrDup(yyvsp[0].name));
@@ -2178,35 +2179,35 @@ yyreduce:
     break;
 
   case 31:
-#line 500 "grammar.y"
+#line 501 "grammar.y"
     {
             syMake(&yyval.lv,yyvsp[0].name);
           ;}
     break;
 
   case 32:
-#line 504 "grammar.y"
+#line 505 "grammar.y"
     {
             if(iiExprArith2(&yyval.lv, &yyvsp[-2].lv, COLONCOLON, &yyvsp[0].lv)) YYERROR;
           ;}
     break;
 
   case 33:
-#line 508 "grammar.y"
+#line 509 "grammar.y"
     {
             if(iiExprArith2(&yyval.lv, &yyvsp[-2].lv, '.', &yyvsp[0].lv)) YYERROR;
           ;}
     break;
 
   case 34:
-#line 512 "grammar.y"
+#line 513 "grammar.y"
     {
             if(iiExprArith1(&yyval.lv,&yyvsp[-2].lv,'(')) YYERROR;
           ;}
     break;
 
   case 35:
-#line 516 "grammar.y"
+#line 517 "grammar.y"
     {
             if (yyvsp[-3].lv.rtyp==UNKNOWN)
             { // for x(i)(j)
@@ -2222,7 +2223,7 @@ yyreduce:
     break;
 
   case 36:
-#line 529 "grammar.y"
+#line 530 "grammar.y"
     {
             if (currRingHdl==NULL) MYYERROR("no ring active");
             int j = 0;
@@ -2253,7 +2254,7 @@ yyreduce:
     break;
 
   case 37:
-#line 557 "grammar.y"
+#line 558 "grammar.y"
     {
             memset(&yyval.lv,0,sizeof(yyval.lv));
             int i = atoi(yyvsp[0].name);
@@ -2280,7 +2281,7 @@ yyreduce:
     break;
 
   case 38:
-#line 581 "grammar.y"
+#line 582 "grammar.y"
     {
             memset(&yyval.lv,0,sizeof(yyval.lv));
             yyval.lv.rtyp = yyvsp[0].i;
@@ -2289,7 +2290,7 @@ yyreduce:
     break;
 
   case 39:
-#line 587 "grammar.y"
+#line 588 "grammar.y"
     {
             memset(&yyval.lv,0,sizeof(yyval.lv));
             yyval.lv.rtyp  = STRING_CMD;
@@ -2298,14 +2299,14 @@ yyreduce:
     break;
 
   case 40:
-#line 593 "grammar.y"
+#line 594 "grammar.y"
     {
             if(iiExprArith1(&yyval.lv,&yyvsp[-1].lv,yyvsp[-3].i)) YYERROR;
           ;}
     break;
 
   case 41:
-#line 600 "grammar.y"
+#line 601 "grammar.y"
     {
             leftv v = &yyvsp[-2].lv;
             while (v->next!=NULL)
@@ -2319,14 +2320,14 @@ yyreduce:
     break;
 
   case 42:
-#line 611 "grammar.y"
+#line 612 "grammar.y"
     {
             yyval.lv = yyvsp[0].lv;
           ;}
     break;
 
   case 43:
-#line 617 "grammar.y"
+#line 618 "grammar.y"
     {
             /*if ($1.typ == eunknown) YYERROR;*/
             yyval.lv = yyvsp[0].lv;
@@ -2334,206 +2335,206 @@ yyreduce:
     break;
 
   case 44:
-#line 621 "grammar.y"
+#line 622 "grammar.y"
     { yyval.lv = yyvsp[0].lv; ;}
     break;
 
   case 45:
-#line 622 "grammar.y"
+#line 623 "grammar.y"
     { yyval.lv = yyvsp[-1].lv; ;}
     break;
 
   case 46:
-#line 624 "grammar.y"
+#line 625 "grammar.y"
     {
             if(iiExprArith3(&yyval.lv,'[',&yyvsp[-5].lv,&yyvsp[-3].lv,&yyvsp[-1].lv)) YYERROR;
           ;}
     break;
 
   case 47:
-#line 628 "grammar.y"
+#line 629 "grammar.y"
     {
             if(iiExprArith2(&yyval.lv,&yyvsp[-3].lv,'[',&yyvsp[-1].lv)) YYERROR;
           ;}
     break;
 
   case 48:
-#line 632 "grammar.y"
+#line 633 "grammar.y"
     {
             if(iiExprArith1(&yyval.lv,&yyvsp[-1].lv,yyvsp[-3].i)) YYERROR;
           ;}
     break;
 
   case 49:
-#line 636 "grammar.y"
+#line 637 "grammar.y"
     {
             if(iiExprArithM(&yyval.lv,&yyvsp[-1].lv,yyvsp[-3].i)) YYERROR;
           ;}
     break;
 
   case 50:
-#line 640 "grammar.y"
+#line 641 "grammar.y"
     {
             if(iiExprArithM(&yyval.lv,NULL,yyvsp[-2].i)) YYERROR;
           ;}
     break;
 
   case 51:
-#line 644 "grammar.y"
+#line 645 "grammar.y"
     {
             if(iiExprArith1(&yyval.lv,&yyvsp[-1].lv,yyvsp[-3].i)) YYERROR;
           ;}
     break;
 
   case 52:
-#line 648 "grammar.y"
+#line 649 "grammar.y"
     {
             if(iiExprArithM(&yyval.lv,&yyvsp[-1].lv,yyvsp[-3].i)) YYERROR;
           ;}
     break;
 
   case 53:
-#line 652 "grammar.y"
+#line 653 "grammar.y"
     {
             if(iiExprArithM(&yyval.lv,NULL,yyvsp[-2].i)) YYERROR;
           ;}
     break;
 
   case 54:
-#line 656 "grammar.y"
+#line 657 "grammar.y"
     {
             if(iiExprArith1(&yyval.lv,&yyvsp[-1].lv,yyvsp[-3].i)) YYERROR;
           ;}
     break;
 
   case 55:
-#line 660 "grammar.y"
+#line 661 "grammar.y"
     {
             if(iiExprArith2(&yyval.lv,&yyvsp[-3].lv,yyvsp[-5].i,&yyvsp[-1].lv,TRUE)) YYERROR;
           ;}
     break;
 
   case 56:
-#line 664 "grammar.y"
+#line 665 "grammar.y"
     {
             if(iiExprArith3(&yyval.lv,yyvsp[-7].i,&yyvsp[-5].lv,&yyvsp[-3].lv,&yyvsp[-1].lv)) YYERROR;
           ;}
     break;
 
   case 57:
-#line 668 "grammar.y"
+#line 669 "grammar.y"
     {
             if(iiExprArith2(&yyval.lv,&yyvsp[-3].lv,yyvsp[-5].i,&yyvsp[-1].lv,TRUE)) YYERROR;
           ;}
     break;
 
   case 58:
-#line 672 "grammar.y"
+#line 673 "grammar.y"
     {
             if(iiExprArith3(&yyval.lv,yyvsp[-7].i,&yyvsp[-5].lv,&yyvsp[-3].lv,&yyvsp[-1].lv)) YYERROR;
           ;}
     break;
 
   case 59:
-#line 676 "grammar.y"
+#line 677 "grammar.y"
     {
             if(iiExprArith1(&yyval.lv,&yyvsp[-1].lv,yyvsp[-3].i)) YYERROR;
           ;}
     break;
 
   case 60:
-#line 680 "grammar.y"
+#line 681 "grammar.y"
     {
             if(iiExprArith1(&yyval.lv,&yyvsp[-1].lv,yyvsp[-3].i)) YYERROR;
           ;}
     break;
 
   case 61:
-#line 684 "grammar.y"
+#line 685 "grammar.y"
     {
             if(iiExprArith2(&yyval.lv,&yyvsp[-3].lv,yyvsp[-5].i,&yyvsp[-1].lv,TRUE)) YYERROR;
           ;}
     break;
 
   case 62:
-#line 688 "grammar.y"
+#line 689 "grammar.y"
     {
             if(iiExprArith1(&yyval.lv,&yyvsp[-1].lv,yyvsp[-3].i)) YYERROR;
           ;}
     break;
 
   case 63:
-#line 692 "grammar.y"
+#line 693 "grammar.y"
     {
             if(iiExprArith2(&yyval.lv,&yyvsp[-3].lv,yyvsp[-5].i,&yyvsp[-1].lv,TRUE)) YYERROR;
           ;}
     break;
 
   case 64:
-#line 696 "grammar.y"
+#line 697 "grammar.y"
     {
             if(iiExprArith3(&yyval.lv,yyvsp[-7].i,&yyvsp[-5].lv,&yyvsp[-3].lv,&yyvsp[-1].lv)) YYERROR;
           ;}
     break;
 
   case 65:
-#line 700 "grammar.y"
+#line 701 "grammar.y"
     {
             if(iiExprArith3(&yyval.lv,yyvsp[-7].i,&yyvsp[-5].lv,&yyvsp[-3].lv,&yyvsp[-1].lv)) YYERROR;
           ;}
     break;
 
   case 66:
-#line 704 "grammar.y"
+#line 705 "grammar.y"
     {
             if(iiExprArithM(&yyval.lv,NULL,yyvsp[-2].i)) YYERROR;
           ;}
     break;
 
   case 67:
-#line 708 "grammar.y"
+#line 709 "grammar.y"
     {
             if(iiExprArithM(&yyval.lv,&yyvsp[-1].lv,yyvsp[-3].i)) YYERROR;
           ;}
     break;
 
   case 68:
-#line 712 "grammar.y"
+#line 713 "grammar.y"
     {
             if(iiExprArith3(&yyval.lv,yyvsp[-7].i,&yyvsp[-5].lv,&yyvsp[-3].lv,&yyvsp[-1].lv)) YYERROR;
           ;}
     break;
 
   case 69:
-#line 716 "grammar.y"
+#line 717 "grammar.y"
     {
             if(iiExprArith1(&yyval.lv,&yyvsp[-1].lv,yyvsp[-3].i)) YYERROR;
           ;}
     break;
 
   case 70:
-#line 720 "grammar.y"
+#line 721 "grammar.y"
     {
             if(iiExprArith3(&yyval.lv,RING_CMD,&yyvsp[-5].lv,&yyvsp[-3].lv,&yyvsp[-1].lv)) YYERROR;
           ;}
     break;
 
   case 71:
-#line 724 "grammar.y"
+#line 725 "grammar.y"
     {
             if(iiExprArith1(&yyval.lv,&yyvsp[-1].lv,RING_CMD)) YYERROR;
           ;}
     break;
 
   case 72:
-#line 728 "grammar.y"
+#line 729 "grammar.y"
     {
             yyval.lv=yyvsp[-1].lv;
           ;}
     break;
 
   case 73:
-#line 732 "grammar.y"
+#line 733 "grammar.y"
     {
             #ifdef SIQ
             siq++;
@@ -2553,7 +2554,7 @@ yyreduce:
     break;
 
   case 74:
-#line 749 "grammar.y"
+#line 750 "grammar.y"
     {
             #ifdef SIQ
             siq--;
@@ -2562,7 +2563,7 @@ yyreduce:
     break;
 
   case 75:
-#line 755 "grammar.y"
+#line 756 "grammar.y"
     {
             #ifdef SIQ
             if (siq<=0) yyvsp[-1].lv.Eval();
@@ -2575,7 +2576,7 @@ yyreduce:
     break;
 
   case 76:
-#line 767 "grammar.y"
+#line 768 "grammar.y"
     {
             #ifdef SIQ
             siq++;
@@ -2584,7 +2585,7 @@ yyreduce:
     break;
 
   case 77:
-#line 775 "grammar.y"
+#line 776 "grammar.y"
     {
             #ifdef SIQ
             siq--;
@@ -2593,91 +2594,91 @@ yyreduce:
     break;
 
   case 78:
-#line 784 "grammar.y"
+#line 785 "grammar.y"
     {
             if(iiExprArith1(&yyval.lv,&yyvsp[-1].lv,PLUSPLUS)) YYERROR;
           ;}
     break;
 
   case 79:
-#line 788 "grammar.y"
+#line 789 "grammar.y"
     {
             if(iiExprArith1(&yyval.lv,&yyvsp[-1].lv,MINUSMINUS)) YYERROR;
           ;}
     break;
 
   case 80:
-#line 792 "grammar.y"
+#line 793 "grammar.y"
     {
             if(iiExprArith2(&yyval.lv,&yyvsp[-2].lv,'+',&yyvsp[0].lv)) YYERROR;
           ;}
     break;
 
   case 81:
-#line 796 "grammar.y"
+#line 797 "grammar.y"
     {
             if(iiExprArith2(&yyval.lv,&yyvsp[-2].lv,'-',&yyvsp[0].lv)) YYERROR;
           ;}
     break;
 
   case 82:
-#line 800 "grammar.y"
+#line 801 "grammar.y"
     {
             if(iiExprArith2(&yyval.lv,&yyvsp[-2].lv,yyvsp[-1].i,&yyvsp[0].lv)) YYERROR;
           ;}
     break;
 
   case 83:
-#line 804 "grammar.y"
+#line 805 "grammar.y"
     {
             if(iiExprArith2(&yyval.lv,&yyvsp[-2].lv,'^',&yyvsp[0].lv)) YYERROR;
           ;}
     break;
 
   case 84:
-#line 808 "grammar.y"
+#line 809 "grammar.y"
     {
             if(iiExprArith2(&yyval.lv,&yyvsp[-2].lv,yyvsp[-1].i,&yyvsp[0].lv)) YYERROR;
           ;}
     break;
 
   case 85:
-#line 812 "grammar.y"
+#line 813 "grammar.y"
     {
             if(iiExprArith2(&yyval.lv,&yyvsp[-2].lv,yyvsp[-1].i,&yyvsp[0].lv)) YYERROR;
           ;}
     break;
 
   case 86:
-#line 816 "grammar.y"
+#line 817 "grammar.y"
     {
             if(iiExprArith2(&yyval.lv,&yyvsp[-2].lv,NOTEQUAL,&yyvsp[0].lv)) YYERROR;
           ;}
     break;
 
   case 87:
-#line 820 "grammar.y"
+#line 821 "grammar.y"
     {
             if(iiExprArith2(&yyval.lv,&yyvsp[-2].lv,EQUAL_EQUAL,&yyvsp[0].lv)) YYERROR;
           ;}
     break;
 
   case 88:
-#line 824 "grammar.y"
+#line 825 "grammar.y"
     {
             if(iiExprArith2(&yyval.lv,&yyvsp[-2].lv,DOTDOT,&yyvsp[0].lv)) YYERROR;
           ;}
     break;
 
   case 89:
-#line 828 "grammar.y"
+#line 829 "grammar.y"
     {
             if(iiExprArith2(&yyval.lv,&yyvsp[-2].lv,':',&yyvsp[0].lv)) YYERROR;
           ;}
     break;
 
   case 90:
-#line 832 "grammar.y"
+#line 833 "grammar.y"
     {
             memset(&yyval.lv,0,sizeof(yyval.lv));
             int i; TESTSETINT(yyvsp[0].lv,i);
@@ -2687,19 +2688,19 @@ yyreduce:
     break;
 
   case 91:
-#line 839 "grammar.y"
+#line 840 "grammar.y"
     {
             if(iiExprArith1(&yyval.lv,&yyvsp[0].lv,'-')) YYERROR;
           ;}
     break;
 
   case 92:
-#line 845 "grammar.y"
+#line 846 "grammar.y"
     { yyval.lv = yyvsp[-1].lv; ;}
     break;
 
   case 93:
-#line 847 "grammar.y"
+#line 848 "grammar.y"
     {
             if (yyvsp[-1].lv.rtyp==0)
             {
@@ -2717,7 +2718,7 @@ yyreduce:
     break;
 
   case 95:
-#line 867 "grammar.y"
+#line 868 "grammar.y"
     {
             if (yyvsp[-1].lv.Typ()!=STRING_CMD)
             {
@@ -2729,7 +2730,7 @@ yyreduce:
     break;
 
   case 96:
-#line 879 "grammar.y"
+#line 880 "grammar.y"
     {
             if (iiDeclCommand(&yyval.lv,&yyvsp[0].lv,myynest,yyvsp[-1].i,&(yyvsp[0].lv.req_packhdl->idroot)))
               YYERROR;
@@ -2737,7 +2738,7 @@ yyreduce:
     break;
 
   case 97:
-#line 884 "grammar.y"
+#line 885 "grammar.y"
     {
             if (iiDeclCommand(&yyval.lv,&yyvsp[0].lv,myynest,yyvsp[-1].i,&(yyvsp[0].lv.req_packhdl->idroot)))
               YYERROR;
@@ -2745,21 +2746,21 @@ yyreduce:
     break;
 
   case 98:
-#line 889 "grammar.y"
+#line 890 "grammar.y"
     {
             if (iiDeclCommand(&yyval.lv,&yyvsp[0].lv,myynest,yyvsp[-1].i,&(currRing->idroot), TRUE)) YYERROR;
           ;}
     break;
 
   case 99:
-#line 893 "grammar.y"
+#line 894 "grammar.y"
     {
             if (iiDeclCommand(&yyval.lv,&yyvsp[0].lv,myynest,yyvsp[-1].i,&(currRing->idroot), TRUE)) YYERROR;
           ;}
     break;
 
   case 100:
-#line 897 "grammar.y"
+#line 898 "grammar.y"
     {
             int r; TESTSETINT(yyvsp[-4].lv,r);
             int c; TESTSETINT(yyvsp[-1].lv,c);
@@ -2790,12 +2791,19 @@ yyreduce:
             }
             else /* BIGINTMAT_CMD */
             {
+              if (iiDeclCommand(&yyval.lv,&yyvsp[-6].lv,myynest,yyvsp[-7].i,&(yyvsp[-6].lv.req_packhdl->idroot)))
+                YYERROR;
+              v=&yyval.lv;
+              h=(idhdl)v->data;
+              delete IDBIMAT(h);
+              IDBIMAT(h) = new bigintmat(r,c);
+              if (IDBIMAT(h)==NULL) YYERROR;
             }
           ;}
     break;
 
   case 101:
-#line 930 "grammar.y"
+#line 938 "grammar.y"
     {
             if (yyvsp[-1].i == MATRIX_CMD)
             {
@@ -2817,12 +2825,14 @@ yyreduce:
             }
             else /* BIGINTMAT_CMD */
             {
+              if (iiDeclCommand(&yyval.lv,&yyvsp[0].lv,myynest,yyvsp[-1].i,&(yyvsp[0].lv.req_packhdl->idroot)))
+                YYERROR;
             }
           ;}
     break;
 
   case 102:
-#line 954 "grammar.y"
+#line 964 "grammar.y"
     {
             int t=yyvsp[-2].lv.Typ();
             sleftv r;
@@ -2846,7 +2856,7 @@ yyreduce:
     break;
 
   case 103:
-#line 975 "grammar.y"
+#line 985 "grammar.y"
     {
             if (iiDeclCommand(&yyval.lv,&yyvsp[0].lv,myynest,yyvsp[-1].i,&(yyvsp[0].lv.req_packhdl->idroot)))
               YYERROR;
@@ -2854,7 +2864,7 @@ yyreduce:
     break;
 
   case 106:
-#line 988 "grammar.y"
+#line 998 "grammar.y"
     {
             leftv v = &yyvsp[-3].lv;
             while (v->next!=NULL)
@@ -2868,7 +2878,7 @@ yyreduce:
     break;
 
   case 107:
-#line 1002 "grammar.y"
+#line 1012 "grammar.y"
     {
           // let rInit take care of any errors
           yyval.i=rOrderName(yyvsp[0].name);
@@ -2876,7 +2886,7 @@ yyreduce:
     break;
 
   case 108:
-#line 1010 "grammar.y"
+#line 1020 "grammar.y"
     {
             memset(&yyval.lv,0,sizeof(yyval.lv));
             intvec *iv = new intvec(2);
@@ -2888,7 +2898,7 @@ yyreduce:
     break;
 
   case 109:
-#line 1019 "grammar.y"
+#line 1029 "grammar.y"
     {
             memset(&yyval.lv,0,sizeof(yyval.lv));
             leftv sl = &yyvsp[-1].lv;
@@ -2933,7 +2943,7 @@ yyreduce:
     break;
 
   case 111:
-#line 1065 "grammar.y"
+#line 1075 "grammar.y"
     {
             yyval.lv = yyvsp[-2].lv;
             yyval.lv.next = (sleftv *)omAllocBin(sleftv_bin);
@@ -2942,47 +2952,47 @@ yyreduce:
     break;
 
   case 113:
-#line 1075 "grammar.y"
+#line 1085 "grammar.y"
     {
             yyval.lv = yyvsp[-1].lv;
           ;}
     break;
 
   case 114:
-#line 1081 "grammar.y"
+#line 1091 "grammar.y"
     {
             expected_parms = TRUE;
           ;}
     break;
 
   case 115:
-#line 1087 "grammar.y"
+#line 1097 "grammar.y"
     { yyval.i = yyvsp[0].i; ;}
     break;
 
   case 116:
-#line 1089 "grammar.y"
+#line 1099 "grammar.y"
     { yyval.i = yyvsp[0].i; ;}
     break;
 
   case 117:
-#line 1091 "grammar.y"
+#line 1101 "grammar.y"
     { yyval.i = yyvsp[0].i; ;}
     break;
 
   case 118:
-#line 1100 "grammar.y"
+#line 1110 "grammar.y"
     { if (yyvsp[-1].i != '<') YYERROR;
             if((feFilePending=feFopen(yyvsp[0].name,"r",NULL,TRUE))==NULL) YYERROR; ;}
     break;
 
   case 119:
-#line 1103 "grammar.y"
+#line 1113 "grammar.y"
     { newFile(yyvsp[-2].name,feFilePending); ;}
     break;
 
   case 120:
-#line 1108 "grammar.y"
+#line 1118 "grammar.y"
     {
             feHelp(yyvsp[-1].name);
             omFree((ADDRESS)yyvsp[-1].name);
@@ -2990,14 +3000,14 @@ yyreduce:
     break;
 
   case 121:
-#line 1113 "grammar.y"
+#line 1123 "grammar.y"
     {
             feHelp(NULL);
           ;}
     break;
 
   case 122:
-#line 1120 "grammar.y"
+#line 1130 "grammar.y"
     {
             singular_example(yyvsp[-1].name);
             omFree((ADDRESS)yyvsp[-1].name);
@@ -3005,7 +3015,7 @@ yyreduce:
     break;
 
   case 123:
-#line 1128 "grammar.y"
+#line 1138 "grammar.y"
     {
           if (basePack!=yyvsp[0].lv.req_packhdl)
           {
@@ -3017,7 +3027,7 @@ yyreduce:
     break;
 
   case 124:
-#line 1140 "grammar.y"
+#line 1150 "grammar.y"
     {
           leftv v=&yyvsp[0].lv;
           if (v->rtyp!=IDHDL)
@@ -3036,7 +3046,7 @@ yyreduce:
     break;
 
   case 125:
-#line 1156 "grammar.y"
+#line 1166 "grammar.y"
     {
           leftv v=&yyvsp[0].lv;
           if (v->rtyp!=IDHDL)
@@ -3055,21 +3065,21 @@ yyreduce:
     break;
 
   case 126:
-#line 1175 "grammar.y"
+#line 1185 "grammar.y"
     {
             list_cmd(yyvsp[-1].i,NULL,"// ",TRUE);
           ;}
     break;
 
   case 127:
-#line 1179 "grammar.y"
+#line 1189 "grammar.y"
     {
             list_cmd(yyvsp[-1].i,NULL,"// ",TRUE);
           ;}
     break;
 
   case 128:
-#line 1183 "grammar.y"
+#line 1193 "grammar.y"
     {
             if (yyvsp[-1].i==QRING_CMD) yyvsp[-1].i=RING_CMD;
             list_cmd(yyvsp[-1].i,NULL,"// ",TRUE);
@@ -3077,35 +3087,35 @@ yyreduce:
     break;
 
   case 129:
-#line 1188 "grammar.y"
+#line 1198 "grammar.y"
     {
             list_cmd(yyvsp[-1].i,NULL,"// ",TRUE);
           ;}
     break;
 
   case 130:
-#line 1192 "grammar.y"
+#line 1202 "grammar.y"
     {
             list_cmd(RING_CMD,NULL,"// ",TRUE);
           ;}
     break;
 
   case 131:
-#line 1196 "grammar.y"
+#line 1206 "grammar.y"
     {
             list_cmd(yyvsp[-1].i,NULL,"// ",TRUE);
            ;}
     break;
 
   case 132:
-#line 1200 "grammar.y"
+#line 1210 "grammar.y"
     {
             list_cmd(PROC_CMD,NULL,"// ",TRUE);
           ;}
     break;
 
   case 133:
-#line 1204 "grammar.y"
+#line 1214 "grammar.y"
     {
             list_cmd(0,yyvsp[-1].lv.Fullname(),"// ",TRUE);
             yyvsp[-1].lv.CleanUp();
@@ -3113,7 +3123,7 @@ yyreduce:
     break;
 
   case 134:
-#line 1209 "grammar.y"
+#line 1219 "grammar.y"
     {
             if(yyvsp[-3].lv.Typ() == PACKAGE_CMD)
               list_cmd(yyvsp[-1].i,NULL,"// ",TRUE);
@@ -3122,7 +3132,7 @@ yyreduce:
     break;
 
   case 135:
-#line 1215 "grammar.y"
+#line 1225 "grammar.y"
     {
             if(yyvsp[-3].lv.Typ() == PACKAGE_CMD)
               list_cmd(yyvsp[-1].i,NULL,"// ",TRUE);
@@ -3131,7 +3141,7 @@ yyreduce:
     break;
 
   case 136:
-#line 1221 "grammar.y"
+#line 1231 "grammar.y"
     {
             if(yyvsp[-3].lv.Typ() == PACKAGE_CMD)
               list_cmd(yyvsp[-1].i,NULL,"// ",TRUE);
@@ -3140,7 +3150,7 @@ yyreduce:
     break;
 
   case 137:
-#line 1227 "grammar.y"
+#line 1237 "grammar.y"
     {
             if(yyvsp[-3].lv.Typ() == PACKAGE_CMD)
               list_cmd(yyvsp[-1].i,NULL,"// ",TRUE);
@@ -3149,7 +3159,7 @@ yyreduce:
     break;
 
   case 138:
-#line 1233 "grammar.y"
+#line 1243 "grammar.y"
     {
             if(yyvsp[-3].lv.Typ() == PACKAGE_CMD)
               list_cmd(yyvsp[-1].i,NULL,"// ",TRUE);
@@ -3158,7 +3168,7 @@ yyreduce:
     break;
 
   case 139:
-#line 1239 "grammar.y"
+#line 1249 "grammar.y"
     {
             if(yyvsp[-3].lv.Typ() == PACKAGE_CMD)
               list_cmd(yyvsp[-1].i,NULL,"// ",TRUE);
@@ -3167,7 +3177,7 @@ yyreduce:
     break;
 
   case 140:
-#line 1245 "grammar.y"
+#line 1255 "grammar.y"
     {
             if(yyvsp[-3].lv.Typ() == PACKAGE_CMD)
               list_cmd(yyvsp[-1].i,NULL,"// ",TRUE);
@@ -3176,19 +3186,19 @@ yyreduce:
     break;
 
   case 141:
-#line 1257 "grammar.y"
+#line 1267 "grammar.y"
     {
             list_cmd(-1,NULL,"// ",TRUE);
           ;}
     break;
 
   case 142:
-#line 1263 "grammar.y"
+#line 1273 "grammar.y"
     { yyInRingConstruction = TRUE; ;}
     break;
 
   case 143:
-#line 1272 "grammar.y"
+#line 1282 "grammar.y"
     {
             const char *ring_name = yyvsp[-6].lv.name;
             ring b=
@@ -3224,7 +3234,7 @@ yyreduce:
     break;
 
   case 144:
-#line 1305 "grammar.y"
+#line 1315 "grammar.y"
     {
             const char *ring_name = yyvsp[0].lv.name;
             if (!inerror) rDefault(ring_name);
@@ -3234,7 +3244,7 @@ yyreduce:
     break;
 
   case 145:
-#line 1315 "grammar.y"
+#line 1325 "grammar.y"
     {
             if ((yyvsp[-1].i!=LIB_CMD)||(iiLibCmd(yyvsp[0].name,TRUE,TRUE,TRUE)))
             //if ($1==LIB_CMD)
@@ -3248,7 +3258,7 @@ yyreduce:
     break;
 
   case 148:
-#line 1331 "grammar.y"
+#line 1341 "grammar.y"
     {
             if ((yyvsp[-1].i==KEEPRING_CMD) && (myynest==0))
                MYYERROR("only inside a proc allowed");
@@ -3320,14 +3330,14 @@ yyreduce:
     break;
 
   case 149:
-#line 1403 "grammar.y"
+#line 1413 "grammar.y"
     {
             type_cmd(&(yyvsp[0].lv));
           ;}
     break;
 
   case 150:
-#line 1407 "grammar.y"
+#line 1417 "grammar.y"
     {
             //Print("typ is %d, rtyp:%d\n",$1.Typ(),$1.rtyp);
             #ifdef SIQ
@@ -3353,7 +3363,7 @@ yyreduce:
     break;
 
   case 151:
-#line 1436 "grammar.y"
+#line 1446 "grammar.y"
     {
             int i; TESTSETINT(yyvsp[-2].lv,i);
             if (i!=0)
@@ -3369,7 +3379,7 @@ yyreduce:
     break;
 
   case 152:
-#line 1449 "grammar.y"
+#line 1459 "grammar.y"
     {
             if (currentVoice->ifsw==1)
             {
@@ -3389,7 +3399,7 @@ yyreduce:
     break;
 
   case 153:
-#line 1466 "grammar.y"
+#line 1476 "grammar.y"
     {
             int i; TESTSETINT(yyvsp[-2].lv,i);
             if (i)
@@ -3401,7 +3411,7 @@ yyreduce:
     break;
 
   case 154:
-#line 1475 "grammar.y"
+#line 1485 "grammar.y"
     {
             if (exitBuffer(BT_break)) YYERROR;
             currentVoice->ifsw=0;
@@ -3409,7 +3419,7 @@ yyreduce:
     break;
 
   case 155:
-#line 1480 "grammar.y"
+#line 1490 "grammar.y"
     {
             if (contBuffer(BT_break)) YYERROR;
             currentVoice->ifsw=0;
@@ -3417,7 +3427,7 @@ yyreduce:
     break;
 
   case 156:
-#line 1488 "grammar.y"
+#line 1498 "grammar.y"
     {
             /* -> if(!$2) break; $3; continue;*/
             char * s = (char *)omAlloc( strlen(yyvsp[-1].name) + strlen(yyvsp[0].name) + 36);
@@ -3429,7 +3439,7 @@ yyreduce:
     break;
 
   case 157:
-#line 1500 "grammar.y"
+#line 1510 "grammar.y"
     {
             /* $2 */
             /* if (!$3) break; $5; $4; continue; */
@@ -3448,7 +3458,7 @@ yyreduce:
     break;
 
   case 158:
-#line 1519 "grammar.y"
+#line 1529 "grammar.y"
     {
             procinfov pi;
             idhdl h = enterid(yyvsp[-1].name,myynest,PROC_CMD,&IDROOT,TRUE);
@@ -3462,7 +3472,7 @@ yyreduce:
     break;
 
   case 159:
-#line 1530 "grammar.y"
+#line 1540 "grammar.y"
     {
             idhdl h = enterid(yyvsp[-2].name,myynest,PROC_CMD,&IDROOT,TRUE);
             if (h==NULL)
@@ -3485,7 +3495,7 @@ yyreduce:
     break;
 
   case 160:
-#line 1550 "grammar.y"
+#line 1560 "grammar.y"
     {
             omFree((ADDRESS)yyvsp[-1].name);
             idhdl h = enterid(yyvsp[-3].name,myynest,PROC_CMD,&IDROOT,TRUE);
@@ -3509,7 +3519,7 @@ yyreduce:
     break;
 
   case 161:
-#line 1574 "grammar.y"
+#line 1584 "grammar.y"
     {
             // decl. of type proc p(int i)
             if (yyvsp[-1].i==PARAMETER)  { if (iiParameter(&yyvsp[0].lv)) YYERROR; }
@@ -3518,7 +3528,7 @@ yyreduce:
     break;
 
   case 162:
-#line 1580 "grammar.y"
+#line 1590 "grammar.y"
     {
             // decl. of type proc p(i)
             sleftv tmp_expr;
@@ -3530,7 +3540,7 @@ yyreduce:
     break;
 
   case 163:
-#line 1592 "grammar.y"
+#line 1602 "grammar.y"
     {
             if(iiRETURNEXPR==NULL) YYERROR;
             iiRETURNEXPR[myynest].Copy(&yyvsp[-1].lv);
@@ -3540,7 +3550,7 @@ yyreduce:
     break;
 
   case 164:
-#line 1599 "grammar.y"
+#line 1609 "grammar.y"
     {
             if (yyvsp[-2].i==RETURN)
             {
@@ -3556,7 +3566,7 @@ yyreduce:
     }
 
 /* Line 1010 of yacc.c.  */
-#line 3560 "grammar.cc"
+#line 3570 "grammar.cc"
 
   yyvsp -= yylen;
   yyssp -= yylen;
diff --git a/Singular/grammar.y b/Singular/grammar.y
index 3cf05b9..18113c1 100644
--- a/Singular/grammar.y
+++ b/Singular/grammar.y
@@ -20,6 +20,7 @@
 #include <Singular/stype.h>
 #include <Singular/ipid.h>
 #include <kernel/intvec.h>
+#include <kernel/bigintmat.h>
 #include <kernel/febase.h>
 #include <kernel/matpol.h>
 #include <kernel/ring.h>
@@ -924,6 +925,13 @@ declare_ip_variable:
             }
             else /* BIGINTMAT_CMD */
             {
+              if (iiDeclCommand(&$$,&$2,myynest,$1,&($2.req_packhdl->idroot)))
+                YYERROR;
+              v=&$$;
+              h=(idhdl)v->data;
+              delete IDBIMAT(h);
+              IDBIMAT(h) = new bigintmat(r,c);
+              if (IDBIMAT(h)==NULL) YYERROR;
             }
           }
         | mat_cmd elemexpr
@@ -948,6 +956,8 @@ declare_ip_variable:
             }
             else /* BIGINTMAT_CMD */
             {
+              if (iiDeclCommand(&$$,&$2,myynest,$1,&($2.req_packhdl->idroot)))
+                YYERROR;
             }
           }
         | declare_ip_variable ',' elemexpr
diff --git a/Singular/iparith.cc b/Singular/iparith.cc
index 668be32..1de832b 100644
--- a/Singular/iparith.cc
+++ b/Singular/iparith.cc
@@ -17,6 +17,7 @@
 #include <kernel/options.h>
 #include <Singular/ipid.h>
 #include <kernel/intvec.h>
+#include <kernel/bigintmat.h>
 #include <omalloc/omalloc.h>
 #include <kernel/polys.h>
 #include <kernel/febase.h>
@@ -222,6 +223,38 @@ int iiTokType(int op)
 /* must be ordered: first operations for chars (infix ops),
  * then alphabetically */
 
+static BOOLEAN jjOP_BIM_I(leftv res, leftv u, leftv v)
+{
+  bigintmat* aa= (bigintmat *)u->CopyD(BIGINTMAT_CMD);
+  int bb = (int)(long)(v->Data());
+  if (errorreported) return TRUE;
+  switch (iiOp)
+  {
+    case '*': (*aa) *= bb; break;
+  }
+  res->data=(char *)aa;
+  return FALSE;
+}
+static BOOLEAN jjOP_I_BIM(leftv res, leftv u, leftv v)
+{
+  return jjOP_BIM_I(res, v, u);
+}
+static BOOLEAN jjOP_BIM_BI(leftv res, leftv u, leftv v)
+{
+  bigintmat* aa= (bigintmat *)u->CopyD(BIGINTMAT_CMD);
+  number bb = (number)(v->Data());
+  if (errorreported) return TRUE;
+  switch (iiOp)
+  {
+    case '*': (*aa) *= bb; break;
+  }
+  res->data=(char *)aa;
+  return FALSE;
+}
+static BOOLEAN jjOP_BI_BIM(leftv res, leftv u, leftv v)
+{
+  return jjOP_BIM_BI(res, v, u);
+}
 static BOOLEAN jjOP_IV_I(leftv res, leftv u, leftv v)
 {
   intvec* aa= (intvec *)u->CopyD(INTVEC_CMD);
@@ -310,6 +343,34 @@ static BOOLEAN jjCOMPARE_IV(leftv res, leftv u, leftv v)
   if(r==-2) { WerrorS("size incompatible"); return TRUE; }
   return FALSE;
 }
+static BOOLEAN jjCOMPARE_BIM(leftv res, leftv u, leftv v)
+{
+  bigintmat*    a = (bigintmat * )(u->Data());
+  bigintmat*    b = (bigintmat * )(v->Data());
+  int r=a->compare(b);
+  switch  (iiOp)
+  {
+    case '<':
+      res->data  = (char *) (r<0);
+      break;
+    case '>':
+      res->data  = (char *) (r>0);
+      break;
+    case LE:
+      res->data  = (char *) (r<=0);
+      break;
+    case GE:
+      res->data  = (char *) (r>=0);
+      break;
+    case EQUAL_EQUAL:
+    case NOTEQUAL: /* negation handled by jjEQUAL_REST */
+      res->data  = (char *) (r==0);
+      break;
+  }
+  jjEQUAL_REST(res,u,v);
+  if(r==-2) { WerrorS("size incompatible"); return TRUE; }
+  return FALSE;
+}
 static BOOLEAN jjCOMPARE_IV_I(leftv res, leftv u, leftv v)
 {
   intvec* a = (intvec * )(u->Data());
@@ -671,6 +732,16 @@ static BOOLEAN jjPLUS_IV(leftv res, leftv u, leftv v)
   }
   return jjPLUSMINUS_Gen(res,u,v);
 }
+static BOOLEAN jjPLUS_BIM(leftv res, leftv u, leftv v)
+{
+  res->data = (char *)bimAdd((bigintmat*)(u->Data()), (bigintmat*)(v->Data()));
+  if (res->data==NULL)
+  {
+    WerrorS("bigintmat size not compatible");
+    return TRUE;
+  }
+  return jjPLUSMINUS_Gen(res,u,v);
+}
 static BOOLEAN jjPLUS_MA(leftv res, leftv u, leftv v)
 {
   matrix A=(matrix)u->Data(); matrix B=(matrix)v->Data();
@@ -754,6 +825,16 @@ static BOOLEAN jjMINUS_IV(leftv res, leftv u, leftv v)
   }
   return jjPLUSMINUS_Gen(res,u,v);
 }
+static BOOLEAN jjMINUS_BIM(leftv res, leftv u, leftv v)
+{
+  res->data = (char *)bimSub((bigintmat*)(u->Data()), (bigintmat*)(v->Data()));
+  if (res->data==NULL)
+  {
+    WerrorS("bigintmat size not compatible");
+    return TRUE;
+  }
+  return jjPLUSMINUS_Gen(res,u,v);
+}
 static BOOLEAN jjMINUS_MA(leftv res, leftv u, leftv v)
 {
   matrix A=(matrix)u->Data(); matrix B=(matrix)v->Data();
@@ -870,6 +951,18 @@ static BOOLEAN jjTIMES_IV(leftv res, leftv u, leftv v)
     return jjOP_REST(res,u,v);
   return FALSE;
 }
+static BOOLEAN jjTIMES_BIM(leftv res, leftv u, leftv v)
+{
+  res->data = (char *)bimMult((bigintmat*)(u->Data()), (bigintmat*)(v->Data()));
+  if (res->data==NULL)
+  {
+    WerrorS("bigintmat size not compatible");
+    return TRUE;
+  }
+  if ((v->next!=NULL) || (u->next!=NULL))
+    return jjOP_REST(res,u,v);
+  return FALSE;
+}
 static BOOLEAN jjTIMES_MA_BI1(leftv res, leftv u, leftv v)
 {
   number n=nInit_bigint((number)v->Data());
@@ -3481,6 +3574,13 @@ static BOOLEAN jjUMINUS_IV(leftv res, leftv u)
   res->data = (char *)iv;
   return FALSE;
 }
+static BOOLEAN jjUMINUS_BIM(leftv res, leftv u)
+{
+  bigintmat *bim=(bigintmat *)u->CopyD(BIGINTMAT_CMD);
+  (*bim)*=(-1);
+  res->data = (char *)bim;
+  return FALSE;
+}
 static BOOLEAN jjPROC1(leftv res, leftv u)
 {
   return jjPROC(res,u,NULL);
@@ -5242,6 +5342,34 @@ static BOOLEAN jjBRACK_Im(leftv res, leftv u, leftv v,leftv w)
   }
   return FALSE;
 }
+static BOOLEAN jjBRACK_Bim(leftv res, leftv u, leftv v, leftv w)
+{
+  bigintmat *bim = (bigintmat *)u->Data();
+  int   r = (int)(long)v->Data();
+  int   c = (int)(long)w->Data();
+  if ((r<1)||(r>bim->rows())||(c<1)||(c>bim->cols()))
+  {
+    Werror("wrong range[%d,%d] in bigintmat %s(%d x %d)",
+           r,c,u->Fullname(),bim->rows(),bim->cols());
+    return TRUE;
+  }
+  res->data=u->data; u->data=NULL;
+  res->rtyp=u->rtyp; u->rtyp=0;
+  res->name=u->name; u->name=NULL;
+  Subexpr e=jjMakeSub(v);
+          e->next=jjMakeSub(w);
+  if (u->e==NULL)
+    res->e=e;
+  else
+  {
+    Subexpr h=u->e;
+    while (h->next!=NULL) h=h->next;
+    h->next=e;
+    res->e=u->e;
+    u->e=NULL;
+  }
+  return FALSE;
+}
 static BOOLEAN jjBRACK_Ma(leftv res, leftv u, leftv v,leftv w)
 {
   matrix m= (matrix)u->Data();
diff --git a/Singular/ipassign.cc b/Singular/ipassign.cc
index c209979..14722c4 100644
--- a/Singular/ipassign.cc
+++ b/Singular/ipassign.cc
@@ -17,6 +17,7 @@
 #include <Singular/ipid.h>
 #include <kernel/idrec.h>
 #include <kernel/intvec.h>
+#include <kernel/bigintmat.h>
 #include <omalloc/omalloc.h>
 #include <kernel/febase.h>
 #include <kernel/polys.h>
@@ -297,8 +298,40 @@ static BOOLEAN jiA_NUMBER(leftv res, leftv a, Subexpr e)
 static BOOLEAN jiA_BIGINT(leftv res, leftv a, Subexpr e)
 {
   number p=(number)a->CopyD(BIGINT_CMD);
-  if (res->data!=NULL) nlDelete((number *)&res->data,NULL);
-  res->data=(void *)p;
+  if (e==NULL)
+  {
+    if (res->data!=NULL) nlDelete((number *)&res->data,NULL);
+    res->data=(void *)p;
+  }
+  else
+  {
+    int i=e->start-1;
+    if (i<0)
+    {
+      Werror("index[%d] must be positive",i+1);
+      return TRUE;
+    }
+    bigintmat *iv=(bigintmat *)res->data;
+    if (e->next==NULL)
+    {
+      WerrorS("only one index given");
+      return TRUE;
+    }
+    else
+    {
+      int c=e->next->start;
+      if ((i>=iv->rows())||(c<1)||(c>iv->cols()))
+      {
+        Werror("wrong range [%d,%d] in bigintmat (%d,%d)",i+1,c,iv->rows(),iv->cols());
+        return TRUE;
+      }
+      else
+      {
+        nlDelete((number *)&BIMATELEM(*iv,i+1,c),NULL);
+        BIMATELEM(*iv,i+1,c) = p;
+      }
+    }
+  }
   jiAssignAttr(res,a);
   return FALSE;
 }
@@ -462,8 +495,17 @@ static BOOLEAN jiA_INTVEC(leftv res, leftv a, Subexpr e)
   //if ((res->data==NULL) || (res->Typ()==a->Typ()))
   {
     if (res->data!=NULL) delete ((intvec *)res->data);
-    res->data=(void *)a->CopyD(INTVEC_CMD);
-    jiAssignAttr(res,a);
+    switch (a->Typ())
+    {
+      case INTMAT_CMD:
+      case INTVEC_CMD:
+        res->data=(void *)a->CopyD(INTVEC_CMD);
+        jiAssignAttr(res,a);
+        break;
+      case BIGINTMAT_CMD:
+        res->data=(void *)bim2iv((bigintmat *)a->Data());
+        break;
+    }
     return FALSE;
   }
 #if 0
@@ -480,6 +522,21 @@ static BOOLEAN jiA_INTVEC(leftv res, leftv a, Subexpr e)
   }
 #endif
 }
+static BOOLEAN jiA_BIGINTMAT(leftv res, leftv a, Subexpr e)
+{
+  if (res->data!=NULL) delete ((bigintmat *)res->data);
+  switch (a->Typ())
+  {
+    case BIGINTMAT_CMD:
+      res->data=(void *)a->CopyD(BIGINTMAT_CMD);
+      jiAssignAttr(res,a);
+      break;
+    case INTMAT_CMD:
+      res->data=(void *)iv2bim((intvec *)a->Data());
+      break;
+  }
+  return FALSE;
+}
 static BOOLEAN jiA_IDEAL(leftv res, leftv a, Subexpr e)
 {
   if (res->data!=NULL) idDelete((ideal*)&res->data);
diff --git a/Singular/ipid.cc b/Singular/ipid.cc
index c256267..7e6e140 100644
--- a/Singular/ipid.cc
+++ b/Singular/ipid.cc
@@ -14,6 +14,7 @@
 #include <kernel/options.h>
 #include <Singular/ipshell.h>
 #include <kernel/intvec.h>
+#include <kernel/bigintmat.h>
 #include <kernel/febase.h>
 #include <kernel/numbers.h>
 #include <kernel/longrat.h>
@@ -122,6 +123,8 @@ void *idrecDataInit(int t)
     case INTVEC_CMD:
     case INTMAT_CMD:
       return (void *)new intvec();
+    case BIGINTMAT_CMD:
+      return (void *)new bigintmat();
     case NUMBER_CMD:
       return (void *) nInit(0);
     case BIGINT_CMD:
diff --git a/Singular/ipid.h b/Singular/ipid.h
index bf6142e..c5395fe 100644
--- a/Singular/ipid.h
+++ b/Singular/ipid.h
@@ -124,6 +124,7 @@ void ipListFlag(idhdl h);
 #define IDDATA(a)   ((a)->data.ustring)
 #define IDRING(a)   ((a)->data.uring)
 #define IDINTVEC(a) ((a)->data.iv)
+#define IDBIMAT(a)  ((a)->data.bim)
 #define IDPOLY(a)   ((a)->data.p)
 #define IDBIGINT(a) ((a)->data.n)
 #define IDNUMBER(a) ((a)->data.n)
diff --git a/Singular/ipshell.cc b/Singular/ipshell.cc
index b079f8b..d4d43da 100644
--- a/Singular/ipshell.cc
+++ b/Singular/ipshell.cc
@@ -16,6 +16,7 @@
 #include <kernel/options.h>
 #include <Singular/ipid.h>
 #include <kernel/intvec.h>
+#include <kernel/bigintmat.h>
 #include <omalloc/omalloc.h>
 #include <kernel/febase.h>
 #include <kernel/polys.h>
@@ -150,6 +151,8 @@ static void list1(const char* s, idhdl h,BOOLEAN c, BOOLEAN fullname)
     case INTVEC_CMD:Print(" (%d)",IDINTVEC(h)->length()); break;
     case INTMAT_CMD:Print(" %d x %d",IDINTVEC(h)->rows(),IDINTVEC(h)->cols());
                     break;
+    case BIGINTMAT_CMD:Print(" %d x %d",IDBIMAT(h)->rows(),IDBIMAT(h)->cols());
+                    break;
     case POLY_CMD:
     case VECTOR_CMD:if (c)
                     {
diff --git a/Singular/subexpr.cc b/Singular/subexpr.cc
index 2439ce3..dce9630 100644
--- a/Singular/subexpr.cc
+++ b/Singular/subexpr.cc
@@ -13,10 +13,10 @@
 
 #include <kernel/mod2.h>
 #include <kernel/intvec.h>
+#include <kernel/bigintmat.h>
 #include <Singular/tok.h>
 #include <kernel/options.h>
 #include <Singular/ipid.h>
-#include <kernel/intvec.h>
 #include <omalloc/omalloc.h>
 #include <kernel/febase.h>
 #include <kernel/polys.h>
@@ -115,6 +115,10 @@ void sleftv::Print(leftv store, int spaces)
         case INTMAT_CMD:
           ((intvec *)d)->show(t,spaces);
           break;
+        case BIGINTMAT_CMD:
+          ((bigintmat *)d)->print();
+         // PrintS(((bigintmat *)d)->prettyprint(spaces));
+          break;
         case RING_CMD:
         case QRING_CMD:
           PrintNSpaces(spaces);
@@ -372,6 +376,8 @@ static inline void * s_internalCopy(const int t,  void *d)
     case INTVEC_CMD:
     case INTMAT_CMD:
       return (void *)ivCopy((intvec *)d);
+    case BIGINTMAT_CMD:
+      return (void*)bimCopy((bigintmat *)d);
     case MATRIX_CMD:
       return (void *)mpCopy((matrix)d);
     case IDEAL_CMD:
@@ -442,6 +448,12 @@ void s_internalDelete(const int t,  void *d, const ring r)
       delete v;
       break;
     }
+    case BIGINTMAT_CMD:
+    {
+      bigintmat *v=(bigintmat*)d;
+      delete v;
+      break;
+    }
     case MAP_CMD:
     {
       map m=(map)d;
@@ -921,6 +933,9 @@ int  sleftv::Typ()
     case INTMAT_CMD:
       r=INT_CMD;
       break;
+    case BIGINTMAT_CMD:
+      r=BIGINT_CMD;
+      break;
     case IDEAL_CMD:
     case MATRIX_CMD:
     case MAP_CMD:
@@ -1091,6 +1106,22 @@ void * sleftv::Data()
         r=(char *)(IMATELEM((*iv),index,e->next->start));
       break;
     }
+    case BIGINTMAT_CMD:
+    {
+      bigintmat *m=(bigintmat *)d;
+      if ((index<1)
+         ||(index>m->rows())
+         ||(e->next->start<1)
+         ||(e->next->start>m->cols()))
+      {
+        if (!errorreported)
+        Werror("wrong range[%d,%d] in bigintmat(%dx%d)",index,e->next->start,
+                                                     m->rows(),m->cols());
+      }
+      else
+        r=(char *)(BIMATELEM((*m),index,e->next->start));
+      break;
+    }
     case IDEAL_CMD:
     case MODUL_CMD:
     case MAP_CMD:
diff --git a/Singular/table.h b/Singular/table.h
index 899a973..aad00ce 100644
--- a/Singular/table.h
+++ b/Singular/table.h
@@ -30,6 +30,7 @@ struct sValCmd1 dArith1[]=
 ,{D(jjUMINUS_MA),  '-',             MATRIX_CMD,     MATRIX_CMD    , ALLOW_PLURAL |ALLOW_RING}
 ,{D(jjUMINUS_IV),  '-',             INTVEC_CMD,     INTVEC_CMD    , ALLOW_PLURAL |ALLOW_RING}
 ,{D(jjUMINUS_IV),  '-',             INTMAT_CMD,     INTMAT_CMD    , ALLOW_PLURAL |ALLOW_RING}
+,{D(jjUMINUS_BIM), '-',             BIGINTMAT_CMD,  BIGINTMAT_CMD , ALLOW_PLURAL |ALLOW_RING}
 ,{D(jjPROC1),      '(',             ANY_TYPE/*set by p*/,PROC_CMD , ALLOW_PLURAL |ALLOW_RING}
 // and the procedures with 1 argument:
 ,{D(atATTRIB1),    ATTRIB_CMD,      NONE,           DEF_CMD       , ALLOW_PLURAL |ALLOW_RING}
@@ -42,6 +43,7 @@ struct sValCmd1 dArith1[]=
 ,{D(jjDUMMY),      BIGINT_CMD,      BIGINT_CMD,     BIGINT_CMD    , ALLOW_PLURAL |ALLOW_RING}
 ,{D(jjN2BI),       BIGINT_CMD,      BIGINT_CMD,     NUMBER_CMD    , ALLOW_PLURAL |ALLOW_RING}
 ,{D(jjP2BI),       BIGINT_CMD,      BIGINT_CMD,     POLY_CMD      , ALLOW_PLURAL |ALLOW_RING}
+,{D(jjDUMMY),      BIGINTMAT_CMD,   BIGINTMAT_CMD,  BIGINTMAT_CMD , ALLOW_PLURAL |ALLOW_RING}
 ,{D(jjCHAR),       CHARACTERISTIC_CMD, INT_CMD,     RING_CMD      , ALLOW_PLURAL |ALLOW_RING}
 ,{D(jjCHAR),       CHARACTERISTIC_CMD, INT_CMD,     QRING_CMD     , ALLOW_PLURAL |ALLOW_RING}
 #ifdef HAVE_FACTORY
@@ -307,6 +309,7 @@ struct sValCmd2 dArith2[]=
 ,{D(jjOP_I_IM),   '+',            INTMAT_CMD,     INT_CMD,    INTMAT_CMD, ALLOW_PLURAL | ALLOW_RING}
 ,{D(jjPLUS_IV),   '+',            INTVEC_CMD,     INTVEC_CMD, INTVEC_CMD, ALLOW_PLURAL | ALLOW_RING}
 ,{D(jjPLUS_IV),   '+',            INTMAT_CMD,     INTMAT_CMD, INTMAT_CMD, ALLOW_PLURAL | ALLOW_RING}
+,{D(jjPLUS_BIM),  '+',            BIGINTMAT_CMD,  BIGINTMAT_CMD, BIGINTMAT_CMD, ALLOW_PLURAL | ALLOW_RING}
 ,{D(lAdd),        '+',            LIST_CMD,       LIST_CMD,   LIST_CMD, ALLOW_PLURAL | ALLOW_RING}
 ,{D(jjRSUM),      '+',            RING_CMD,       RING_CMD,   RING_CMD, ALLOW_PLURAL | ALLOW_RING}
 ,{D(jjRSUM),      '+',            QRING_CMD,      QRING_CMD,  RING_CMD, ALLOW_PLURAL | ALLOW_RING}
@@ -323,6 +326,7 @@ struct sValCmd2 dArith2[]=
 ,{D(jjOP_IM_I),   '-',            INTMAT_CMD,     INTMAT_CMD, INT_CMD, ALLOW_PLURAL | ALLOW_RING}
 ,{D(jjMINUS_IV),  '-',            INTVEC_CMD,     INTVEC_CMD, INTVEC_CMD, ALLOW_PLURAL | ALLOW_RING}
 ,{D(jjMINUS_IV),  '-',            INTMAT_CMD,     INTMAT_CMD, INTMAT_CMD, ALLOW_PLURAL | ALLOW_RING}
+,{D(jjMINUS_BIM), '-',            BIGINTMAT_CMD,  BIGINTMAT_CMD, BIGINTMAT_CMD, ALLOW_PLURAL | ALLOW_RING}
 ,{  jjWRONG2 ,    '-',            NONE,           IDEAL_CMD,  IDEAL_CMD, ALLOW_PLURAL | ALLOW_RING}
 ,{  jjWRONG2 ,    '-',            NONE,           MODUL_CMD,  MODUL_CMD, ALLOW_PLURAL | ALLOW_RING}
 ,{D(jjTIMES_I),   '*',            INT_CMD,        INT_CMD,    INT_CMD, ALLOW_PLURAL | ALLOW_RING}
@@ -356,6 +360,11 @@ struct sValCmd2 dArith2[]=
 ,{D(jjTIMES_IV),  '*',            INTVEC_CMD,     INTMAT_CMD, INTVEC_CMD, ALLOW_PLURAL | ALLOW_RING}
 ,{D(jjTIMES_IV),  '*',            INTMAT_CMD,     INTMAT_CMD, INTMAT_CMD, ALLOW_PLURAL | ALLOW_RING}
 ,{D(jjTIMES_IV),  '*',            INTMAT_CMD,     INTVEC_CMD, INTMAT_CMD, ALLOW_PLURAL | ALLOW_RING}
+,{D(jjTIMES_BIM), '*',            BIGINTMAT_CMD,  BIGINTMAT_CMD, BIGINTMAT_CMD, ALLOW_PLURAL | ALLOW_RING}
+,{D(jjOP_BIM_I),  '*',            BIGINTMAT_CMD,  BIGINTMAT_CMD, INT_CMD, ALLOW_PLURAL | ALLOW_RING}
+,{D(jjOP_I_BIM),  '*',            BIGINTMAT_CMD,  INT_CMD, BIGINTMAT_CMD, ALLOW_PLURAL | ALLOW_RING}
+,{D(jjOP_BIM_BI),  '*',           BIGINTMAT_CMD,  BIGINTMAT_CMD, BIGINT_CMD, ALLOW_PLURAL | ALLOW_RING}
+,{D(jjOP_BI_BIM),  '*',           BIGINTMAT_CMD,  BIGINT_CMD, BIGINTMAT_CMD, ALLOW_PLURAL | ALLOW_RING}
 ,{D(jjDIV_N),     '/',            NUMBER_CMD,     NUMBER_CMD, NUMBER_CMD, ALLOW_PLURAL | ALLOW_RING}
 ,{D(jjDIV_P),     '/',            POLY_CMD,       POLY_CMD,   POLY_CMD, ALLOW_PLURAL | ALLOW_RING}
 ,{D(jjDIV_P),     '/',            VECTOR_CMD,     VECTOR_CMD, POLY_CMD, ALLOW_PLURAL | ALLOW_RING}
@@ -426,6 +435,7 @@ struct sValCmd2 dArith2[]=
 ,{D(jjCOMPARE_IV_I),EQUAL_EQUAL,  INT_CMD,        INTVEC_CMD, INT_CMD, ALLOW_PLURAL | ALLOW_RING}
 ,{D(jjCOMPARE_IV),EQUAL_EQUAL,    INT_CMD,        INTVEC_CMD, INTVEC_CMD, ALLOW_PLURAL | ALLOW_RING}
 ,{D(jjCOMPARE_IV),EQUAL_EQUAL,    INT_CMD,        INTMAT_CMD, INTMAT_CMD, ALLOW_PLURAL | ALLOW_RING}
+,{D(jjCOMPARE_BIM),EQUAL_EQUAL,   INT_CMD,        BIGINTMAT_CMD, BIGINTMAT_CMD, ALLOW_PLURAL | ALLOW_RING}
 ,{D(jjEQUAL_Ma),  EQUAL_EQUAL,    INT_CMD,        MATRIX_CMD, MATRIX_CMD, ALLOW_PLURAL | ALLOW_RING}
 ,{  jjWRONG2 ,    EQUAL_EQUAL,    0,              IDEAL_CMD,  IDEAL_CMD, ALLOW_PLURAL | ALLOW_RING}
 ,{  jjWRONG2 ,    EQUAL_EQUAL,    0,              MODUL_CMD,  MODUL_CMD, ALLOW_PLURAL | ALLOW_RING}
@@ -665,6 +675,7 @@ struct sValCmd3 dArith3[]=
 ,{D(jjBRACK_Ma_I_IV),  '[',        INT_CMD,    INTMAT_CMD, INT_CMD,    INTVEC_CMD, ALLOW_PLURAL |ALLOW_RING}
 ,{D(jjBRACK_Ma_IV_I),  '[',        INT_CMD,    INTMAT_CMD, INTVEC_CMD, INT_CMD, ALLOW_PLURAL |ALLOW_RING}
 ,{D(jjBRACK_Ma_IV_IV), '[',        INT_CMD,    INTMAT_CMD, INTVEC_CMD, INTVEC_CMD, ALLOW_PLURAL |ALLOW_RING}
+,{D(jjBRACK_Bim),      '[',        BIGINT_CMD, BIGINTMAT_CMD, INT_CMD, INT_CMD, ALLOW_PLURAL |ALLOW_RING}
 ,{D(jjBRACK_Ma),       '[',        POLY_CMD,   MATRIX_CMD, INT_CMD,    INT_CMD, ALLOW_PLURAL |ALLOW_RING}
 ,{D(jjBRACK_Ma_I_IV),  '[',        POLY_CMD,   MATRIX_CMD, INT_CMD,    INTVEC_CMD, ALLOW_PLURAL |ALLOW_RING}
 ,{D(jjBRACK_Ma_IV_I),  '[',        POLY_CMD,   MATRIX_CMD, INTVEC_CMD, INT_CMD, ALLOW_PLURAL |ALLOW_RING}
@@ -827,6 +838,7 @@ cmdnames cmds[] =
   { "bareiss",     0, BAREISS_CMD ,       CMD_13},
   { "betti",       0, BETTI_CMD ,         CMD_12},
   { "bigint",      0, BIGINT_CMD ,        ROOT_DECL},
+  { "bigintmat",   0, BIGINTMAT_CMD ,     BIGINTMAT_CMD},
   #ifdef HAVE_PLURAL
   { "bracket",     0, BRACKET_CMD ,       CMD_2},
   #endif
@@ -1174,6 +1186,9 @@ struct sValAssign dAssign[]=
 ,{D(jiA_INTVEC),   INTVEC_CMD,     INTVEC_CMD }
 ,{D(jiA_INTVEC),   INTMAT_CMD,     INTMAT_CMD }
 //,{D(jiA_INTVEC),   INTMAT_CMD,     INTVEC_CMD }
+,{D(jiA_INTVEC),   INTMAT_CMD,     BIGINTMAT_CMD}
+,{D(jiA_BIGINTMAT),BIGINTMAT_CMD,  BIGINTMAT_CMD}
+,{D(jiA_BIGINTMAT),BIGINTMAT_CMD,  INTMAT_CMD }
 ,{D(jiA_NUMBER),   NUMBER_CMD,     NUMBER_CMD }
 ,{D(jiA_BIGINT),   BIGINT_CMD,     BIGINT_CMD }
 ,{D(jiA_LIST_RES), LIST_CMD,       RESOLUTION_CMD }
diff --git a/kernel/Makefile.in b/kernel/Makefile.in
index 3d63281..adc9cd9 100644
--- a/kernel/Makefile.in
+++ b/kernel/Makefile.in
@@ -89,7 +89,7 @@ endif
 ###
 
 # normal C++ source files
-CXXSOURCES=clapconv.cc \
+CXXSOURCES=bigintmat.cc clapconv.cc \
     clapsing.cc \
     febase.cc feread.cc feResource.cc \
     ffields.cc hdegree.cc hilb.cc hutil.cc \
@@ -151,7 +151,7 @@ SOURCES=${CSOURCES} ${CXXSOURCES} \
 	p_kBucketSetLm__T.cc \
 	kInline.cc
 
-HEADERS=hutil.h idrec.h stairc.h ideals.h \
+HEADERS=bigintmat.h hutil.h idrec.h stairc.h ideals.h \
 	longalg.h structs.h intvec.h int64vec.h longrat.h \
 	numbers.h clapconv.h maps.h \
 	clapsing.h matpol.h polys.h p_polys.h syz.h \
diff --git a/kernel/bigintmat.cc b/kernel/bigintmat.cc
new file mode 100644
index 0000000..11ab3b1
--- /dev/null
+++ b/kernel/bigintmat.cc
@@ -0,0 +1,375 @@
+/* Probleme:
+3) Ausgabe als String fehlt noch
+5) Welche der eingebundenen Dateien werden wirklich benötigt?
+
+in Makefile.in
+Dateien eintragen, in /SIngular/ config.status ausführen
+
+table.h in /Singular/
+
+
+//spielwiese
+autogen.sh
+
+/libpoly/misc/Makefile.am
+*/
+/*****************************************
+*  Computer Algebra System SINGULAR      *
+*****************************************/
+/*
+* ABSTRACT: class bigintmat: matrizes of big integers
+*/
+#include <kernel/mod2.h>                     
+#include <kernel/febase.h>                     
+#include <kernel/options.h>                        
+#include <kernel/bigintmat.h>
+#include <omalloc/omalloc.h>                    
+#include <kernel/longrat.h>                   
+#include <kernel/intvec.h>  
+#include <math.h>        
+#include <string.h>        
+
+#define BIGIMATELEM(M,I,J) (M)[(I-1)*(M).cols()+J-1]
+
+// Beginnt bei [1,1]
+void bigintmat::set(int i, int j, number n)
+{
+  nlDelete(&(v[(i-1)*col+j-1]), NULL);
+  v[(i-1)*col+j-1] = nlCopy(n);
+}
+
+// Beginnt bei [0]
+void bigintmat::set(int i, number n)
+{
+  if (i<row*col)
+  {
+    nlDelete(&(v[i]), NULL);
+    v[i] = nlCopy(n);
+  }
+}
+
+number bigintmat::get(int i, int j)
+{
+  return nlCopy(v[(i-1)*col+j-1]);
+}
+
+number bigintmat::get(int i)
+{
+  return nlCopy(v[i]);
+}
+
+bigintmat::bigintmat(int r, int c)
+{
+  row = r;
+  col = c;
+  int l = r*c;
+  if (l>0) /*(r>0) && (c>0) */
+    v = (number *)omAlloc(sizeof(number)*l);
+  else
+    v = NULL;
+  for (int i=0; i<l; i++)
+  {
+    v[i] = nlInit(0, NULL);
+  }
+}
+
+// Überladener *=-Operator (für int und bigint)
+// Frage hier: *= verwenden oder lieber = und * einzeln?
+void bigintmat::operator*=(int intop)
+{
+  for (int i=0; i<row*col; i++)
+  {
+  	number iop = nlInit(intop, NULL);
+  	number prod = nlMult(v[i], iop);
+  	nlDelete(&(v[i]), NULL);
+  	nlDelete(&iop, NULL);
+  	v[i] = prod;
+  }
+}
+
+void bigintmat::operator*=(number bintop)
+{
+  for (int i=0; i<row*col; i++)
+  {
+  	number prod = nlMult(v[i], bintop);
+  	nlDelete(&(v[i]), NULL);
+  	v[i] = prod;
+  }
+}
+
+// Stimmen Parameter?
+// Welche der beiden Methoden?
+// Oder lieber eine comp-Funktion?
+
+bool operator==(bigintmat & lhr, bigintmat & rhr)
+{
+  if (&lhr == &rhr) { return true; }
+  if (lhr.cols() != rhr.cols()) { return false; }
+  if (lhr.rows() != rhr.rows()) { return false; }
+  for (int i=0; i<(lhr.rows())*(lhr.cols()); i++)
+  {
+    if (!nlEqual(lhr[i], rhr[i])) { return false; }  
+  }
+  return true;
+}
+
+bool operator!=(bigintmat & lhr, bigintmat & rhr)
+{
+  return !(lhr==rhr);
+}
+
+// Matrix-Add/-Sub/-Mult so oder mit operator+/-/* ?
+bigintmat * bimAdd(bigintmat * a, bigintmat * b)
+{
+  bigintmat * bim;
+  int mn, ma, i;
+  if (a->cols() != b->cols()) return NULL;
+  mn = si_min(a->rows(),b->rows());
+  ma = si_max(a->rows(),b->rows());
+  if (a->cols() == 1)
+  {
+    bim = new bigintmat(ma, 1);
+    for (i=0; i<mn; i++)
+    {
+      number n = nlAdd((*a)[i], (*b)[i]);
+      bim->set(i, n);
+      nlDelete(&n, NULL);
+    }
+    if (ma > mn)
+    {
+      if (ma == a->rows())
+      {
+        for(i=mn; i<ma; i++) 
+        {
+          bim->set(i, (*a)[i]);
+        }
+      }
+      else
+      {
+        for(i=mn; i<ma; i++)
+        {
+          bim->set(i, (*b)[i]);
+        }
+      }
+    }
+    return bim;
+  }
+  if (mn != ma) return NULL;
+  bim = new bigintmat(mn, a->cols());
+  for (i=0; i<mn*a->cols(); i++)
+  {
+    number n = nlAdd((*a)[i], (*b)[i]);
+    bim->set(i, n);
+    nlDelete(&n, NULL); 
+  }
+  return bim;
+}
+
+bigintmat * bimSub(bigintmat * a, bigintmat * b)
+{
+  bigintmat * bim;
+  int mn, ma, i;
+  if (a->cols() != b->cols()) return NULL;
+  mn = si_min(a->rows(),b->rows());
+  ma = si_max(a->rows(),b->rows());
+  if (a->cols() == 1)
+  {
+    bim = new bigintmat(ma, 1);
+    for (i=0; i<mn; i++)
+    {
+      number n = nlSub((*a)[i], (*b)[i]);
+      bim->set(i, n);
+      nlDelete(&n, NULL);
+    }
+    if (ma > mn)
+    {
+      if (ma == a->rows())
+      {
+        for(i=mn; i<ma; i++) 
+        {
+          bim->set(i, (*a)[i]);
+        }
+      }
+      else
+      {
+        for(i=mn; i<ma; i++)
+        {
+          bim->set(i, (*b)[i]);
+        }
+      }
+    }
+    return bim;
+  }
+  if (mn != ma) return NULL;
+  bim = new bigintmat(mn, a->cols());
+  for (i=0; i<mn*a->cols(); i++)
+  {
+    number n = nlSub((*a)[i], (*b)[i]);
+    bim->set(i, n);
+    nlDelete(&n, NULL);
+  }
+  return bim;
+}
+
+bigintmat * bimMult(bigintmat * a, bigintmat * b)
+{
+  int i, j, k,
+      ra = a->rows(), ca = a->cols(),
+      rb = b->rows(), cb = b->cols();
+  number sum;
+  bigintmat * bim;
+  if (ca != rb) return NULL;
+  bim = new bigintmat(ra, cb);
+  for (i=0; i<ra; i++)
+  {
+    for (j=0; j<cb; j++)
+    {
+      sum = nlInit(0, NULL);
+      for (k=0; k<ca; k++)
+      {
+        number prod = nlMult((*a)[i*ca+k], (*b)[k*cb+j]);
+        number sum2 = nlAdd(sum, prod);
+        nlDelete(&sum, NULL);
+        sum = sum2;
+        nlDelete(&prod, NULL);
+      }
+      bim->set(i+1, j+1, sum);
+      nlDelete(&sum, NULL);
+    }
+  }
+  return bim;
+}
+
+// Korrekt?
+
+intvec * bim2iv(bigintmat * b)
+{
+  intvec * iv;
+  iv = new intvec(b->rows(), b->cols(), 0);
+  for (int i=0; i<(b->rows())*(b->cols()); i++) { (*iv)[i] = nlInt((*b)[i], NULL); } // Geht das so?
+  return iv;
+}
+
+bigintmat * iv2bim(intvec * b)
+{
+  bigintmat * bim;
+  bim = new bigintmat(b->rows(), b->cols());
+  for (int i=0; i<(b->rows())*(b->cols()); i++)
+  {
+    number n = nlInit((*b)[i], NULL);
+    bim->set(i, n);
+    nlDelete(&n, NULL);
+  }
+  return bim;
+}
+
+int bigintmat::compare(const bigintmat* op) const
+{
+  if ((col!=1) ||(op->cols()!=1))
+  {
+    if((col!=op->cols())
+    || (row!=op->rows()))
+      return -2;
+  }
+  int i;
+  for (i=0; i<si_min(row*col,op->rows()*op->cols()); i++)
+  {
+    if (nlGreater(v[i], (*op)[i]))
+      return 1;
+    else if (!nlEqual(v[i], (*op)[i]))
+      return -1;
+  }
+
+  for (; i<row; i++)
+  {
+    if (nlGreaterZero(v[i]))
+      return 1;
+    else if (!nlIsZero(v[i]))
+      return -1;
+  }
+  for (; i<op->rows(); i++)
+  {
+    if (nlGreaterZero((*op)[i]))
+      return -1;
+    else if (!nlIsZero((*op)[i]))
+      return 1;
+  }
+  return 0;
+}
+
+
+bigintmat * bimCopy(const bigintmat * b)
+{
+  bigintmat * a=NULL;
+  if (b!=NULL)
+  {
+    a = new bigintmat(b->rows(), b->cols());
+    for (int i=0; i<(b->rows())*(b->cols()); i++)
+    {
+      a->set(i, (*b)[i]);
+    }
+  }
+  return a;
+}
+
+void bigintmat::print()
+{
+  StringSetS("");
+  for (int i=0; i<col*row; i++)
+  {
+    //int n = nlInt(v[i], NULL);
+    //char tmp[10];
+    //sprintf(tmp, "%d", n);
+    nlWrite(v[i], NULL);
+    //PrintS(tmp); //
+    if (i != col*row-1)
+    {
+      StringAppend(",");
+      if ((i+1)%col == 0)
+        StringAppend("\n");
+    }    
+  }
+  PrintS(StringAppend(""));
+}
+
+void bigintmat::prettyprint(int swid)
+{
+ // if (col*row == 0) return "";
+  int colwid = floor((swid-2*(col-1))/col); // Berechnung der Spaltenbreite (im Zweifel abrunden)
+  char * ps;
+  ps = (char*) omAlloc(sizeof(char)*(colwid*col+2*(col-1)+row-1));  //Reale Länge des Strings
+  int pos = 0;
+  for (int i=0; i<col*row; i++)
+  {
+    SPrintStart();
+    nlWrite(v[i], NULL);
+    char * ts = SPrintEnd();
+    int nl = strlen(ts); 
+    if (nl > colwid)  // Zu lange Zahl wird durch ### dargestellt
+    {
+      for (int j=0; j<colwid; j++)
+        ps[pos+j] = '#';
+    }
+    else  // Mit Leerzeichen auffüllen und zahl reinschreiben
+    {
+      for (int j=0; j<colwid-nl; j++)
+        ps[pos+j] = ' ';
+      for (int j=0; j<nl; j++)
+        ps[pos+colwid-nl+j] = ts[j];
+    }
+    
+    // ", " oder "\n" einfügen
+    if (((i+1)%col == 0) && (i != col*row))
+    {
+      ps[colwid] = '\n';
+      pos += colwid+1;
+    }
+    else
+    {
+      ps[colwid] = ',';
+      ps[colwid+1] = ' ';
+      pos += colwid+2;
+    }
+  // Hier ts zerstören
+  }
+}
diff --git a/kernel/bigintmat.h b/kernel/bigintmat.h
new file mode 100644
index 0000000..d4b4f40
--- /dev/null
+++ b/kernel/bigintmat.h
@@ -0,0 +1,99 @@
+#ifndef BIGINTMAT_H
+#define BIGINTMAT_H
+/****************************************
+*  Computer Algebra System SINGULAR     *
+****************************************/
+/*
+* ABSTRACT: class bigintmat: matrizes of big integers
+*/
+#include <string.h>
+#include <omalloc/omalloc.h>  
+#include <kernel/febase.h>    
+#include <kernel/longrat.h>   
+#include <kernel/intvec.h>    
+
+
+class bigintmat
+{
+private:
+  number *v;
+  int row;
+  int col;
+public:
+
+  bigintmat()
+  {
+    row = 1;
+    col = 0;
+    v = NULL;
+  }
+  bigintmat(int r, int c);
+
+  bigintmat(const bigintmat *m)
+  {
+    row = m->rows();
+    col = m->cols();
+    if (row*col>0)
+    {
+      v = (number *)omAlloc(sizeof(number)*row*col);
+      for (int i=row*col-1; i>=0; i--)
+      {
+        v[i] = nlCopy((*m)[i]);
+      }
+    }
+  }
+  
+  
+  inline number& operator[](int i)
+    {
+#ifndef NDEBUG
+      if((i<0)||(i>=row*col))
+      {
+        Werror("wrong bigintmat index:%d\n",i);
+      }
+#endif
+      return v[i];  // Hier sollte imho kein nlCopy rein...
+    }
+  inline const number& operator[](int i) const
+    {
+#ifndef NDEBUG
+      if((i<0)||(i>=row*col))
+      {
+        Werror("wrong bigintmat index:%d\n",i);
+      }
+#endif
+      return v[i];
+    }
+    
+#define BIMATELEM(M,I,J) (M)[(I-1)*(M).cols()+J-1]
+  void operator*=(int intop);
+  void operator*=(number bintop);
+  inline int  cols() const { return col; }
+  inline int  rows() const { return row; }
+  inline ~bigintmat()
+    {
+      if (v!=NULL)
+      {
+        for (int i=0; i<row*col; i++) { nlDelete(&(v[i]), NULL); }
+        omFreeSize((ADDRESS)v,sizeof(number)*row*col);
+        v=NULL;
+      }
+    }
+  number get(int i, int j);
+  number get(int i);
+  void set(int i, int j, number n);
+  void set(int i, number n);
+  void print();
+  void prettyprint(int swid);
+  int compare(const bigintmat* op) const;
+};
+bool operator==(bigintmat & lhr, bigintmat & rhr);
+bool operator!=(bigintmat & lhr, bigintmat & rhr);
+bigintmat * bimAdd(bigintmat * a, bigintmat * b);
+bigintmat * bimSub(bigintmat * a, bigintmat * b);
+bigintmat * bimMult(bigintmat * a, bigintmat * b);
+intvec * bim2iv(bigintmat * b);
+bigintmat * bimCopy(const bigintmat * b);
+
+bigintmat * iv2bim(intvec * b);
+#endif
diff --git a/kernel/idrec.h b/kernel/idrec.h
index 039e272..f15dea1 100644
--- a/kernel/idrec.h
+++ b/kernel/idrec.h
@@ -3,7 +3,6 @@
 /****************************************
 *  Computer Algebra System SINGULAR     *
 ****************************************/
-/* $Id$ */
 /*
 * ABSTRACT
 */
@@ -22,6 +21,7 @@ union uutypes
   matrix        umatrix;
   char *        ustring;
   intvec *      iv;
+  bigintmat *   bim;
   lists         l;
   si_link       li;
   package       pack;
diff --git a/kernel/structs.h b/kernel/structs.h
index 51ba1fb..5d78128 100644
--- a/kernel/structs.h
+++ b/kernel/structs.h
@@ -114,6 +114,7 @@ typedef number (*nMapFunc)(number a);
 #ifdef __cplusplus
 class ip_smatrix;
 class intvec;
+class bigintmat;
 class sleftv;
 class slists;
 class sattr;

-- 
an open source computer algebra system



More information about the debian-science-commits mailing list