Changeset 75f10d in git


Ignore:
Timestamp:
May 10, 2012, 1:59:15 PM (11 years ago)
Author:
Hans Schoenemann <hannes@…>
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
Message:
add: bigintmat stuff from master
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • Singular/iparith.cc

    rc8302b r75f10d  
    1515
    1616#include "config.h"
     17#include <coeffs/bigintmat.h>
    1718#include <kernel/mod2.h>
    1819#include <Singular/tok.h>
     
    236237 * then alphabetically */
    237238
     239static 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}
     254static BOOLEAN jjOP_I_BIM(leftv res, leftv u, leftv v)
     255{
     256  return jjOP_BIM_I(res, v, u);
     257}
     258static 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}
     271static BOOLEAN jjOP_BI_BIM(leftv res, leftv u, leftv v)
     272{
     273  return jjOP_BIM_BI(res, v, u);
     274}
    238275static BOOLEAN jjOP_IV_I(leftv res, leftv u, leftv v)
    239276{
     
    300337  intvec*    a = (intvec * )(u->Data());
    301338  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}
     363static BOOLEAN jjCOMPARE_BIM(leftv res, leftv u, leftv v)
     364{
     365  bigintmat*    a = (bigintmat * )(u->Data());
     366  bigintmat*    b = (bigintmat * )(v->Data());
    302367  int r=a->compare(b);
    303368  switch  (iiOp)
     
    684749  return jjPLUSMINUS_Gen(res,u,v);
    685750}
     751static 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}
    686761static BOOLEAN jjPLUS_MA(leftv res, leftv u, leftv v)
    687762{
     
    767842  return jjPLUSMINUS_Gen(res,u,v);
    768843}
     844static 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}
    769854static BOOLEAN jjMINUS_MA(leftv res, leftv u, leftv v)
    770855{
     
    877962     WerrorS("intmat size not compatible");
    878963     return TRUE;
     964  }
     965  if ((v->next!=NULL) || (u->next!=NULL))
     966    return jjOP_REST(res,u,v);
     967  return FALSE;
     968}
     969static 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;
    879976  }
    880977  if ((v->next!=NULL) || (u->next!=NULL))
     
    34973594  (*iv)*=(-1);
    34983595  res->data = (char *)iv;
     3596  return FALSE;
     3597}
     3598static BOOLEAN jjUMINUS_BIM(leftv res, leftv u)
     3599{
     3600  bigintmat *bim=(bigintmat *)u->CopyD(BIGINTMAT_CMD);
     3601  (*bim)*=(-1);
     3602  res->data = (char *)bim;
    34993603  return FALSE;
    35003604}
     
    52235327          e->next=jjMakeSub(w);
    52245328  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}
     5339static 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;
    52255357  else
    52265358  {
  • Singular/ipassign.cc

    rc8302b r75f10d  
    2525#include <coeffs/numbers.h>
    2626#include <coeffs/longrat.h>
     27#include <coeffs/bigintmat.h>
    2728
    2829
     
    247248
    248249  n_Normalize(p, currRing->cf);
    249    
     250
    250251  assume( currRing->cf->extRing->qideal == NULL );
    251252
     
    383384{
    384385  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  }
    387420  jiAssignAttr(res,a);
    388421  return FALSE;
     
    565598  }
    566599#endif
     600}
     601static 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;
    567607}
    568608static BOOLEAN jiA_IDEAL(leftv res, leftv a, Subexpr e)
     
    11651205  return FALSE;
    11661206}
     1207static 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}
    11671255static BOOLEAN jjA_L_STRING(leftv l,leftv r)
    11681256{
     
    15541642    {
    15551643      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)));
    15561649      break;
    15571650    }
  • Singular/ipconv.cc

    rc8302b r75f10d  
    1919#include <coeffs/numbers.h>
    2020#include <coeffs/coeffs.h>
     21#include <coeffs/bigintmat.h>
    2122//#include <polys/ext_fields/longalg.h>
    2223#ifdef HAVE_RINGS
     
    185186  delete iv;
    186187  return (void *)m;
     188}
     189
     190static void * iiIm2Bim(void *data)
     191{
     192  return (void *)iv2bim((intvec*)data,coeffs_BIGINT);
     193}
     194
     195static void * iiBim2Im(void *data)
     196{
     197  return (void *)bim2iv((bigintmat*)data);
    187198}
    188199
  • Singular/ipid.cc

    rc8302b r75f10d  
    1818#include <kernel/febase.h>
    1919#include <coeffs/numbers.h>
     20#include <coeffs/bigintmat.h>
    2021#include <kernel/longrat.h>
    2122#include <kernel/polys.h>
     
    126127    case INTMAT_CMD:
    127128      return (void *)new intvec();
     129    case BIGINTMAT_CMD:
     130      return (void *)new bigintmat();
    128131    case NUMBER_CMD:
    129132      return (void *) nInit(0);
  • Singular/subexpr.cc

    rc8302b r75f10d  
    2323#include <coeffs/ffields.h>
    2424#include <coeffs/numbers.h>
     25#include <coeffs/bigintmat.h>
    2526
    2627#include <polys/monomials/maps.h>
     
    123124        case INTMAT_CMD:
    124125          ((intvec *)d)->show(t,spaces);
     126          break;
     127        case BIGINTMAT_CMD:
     128          ((bigintmat *)d)->pprint(80);
    125129          break;
    126130        case RING_CMD:
     
    384388    case INTMAT_CMD:
    385389      return (void *)ivCopy((intvec *)d);
     390    case BIGINTMAT_CMD:
     391      return (void*)bimCopy((bigintmat *)d);
    386392    case MATRIX_CMD:
    387393      return (void *)mp_Copy((matrix)d, currRing);
     
    454460      break;
    455461    }
     462    case BIGINTMAT_CMD:
     463    {
     464      bigintmat *v=(bigintmat*)d;
     465      delete v;
     466      break;
     467    }
    456468    case MAP_CMD:
    457469    {
     
    821833            return s;
    822834        }
     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        }
    823849
    824850        case RING_CMD:
     
    942968      r=INT_CMD;
    943969      break;
     970    case BIGINTMAT_CMD:
     971      r=BIGINT_CMD;
     972      break;
    944973    case IDEAL_CMD:
    945974    case MATRIX_CMD:
     
    11181147      else
    11191148        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));
    11201165      break;
    11211166    }
  • Singular/table.h

    rc8302b r75f10d  
    3131,{D(jjUMINUS_IV),  '-',             INTVEC_CMD,     INTVEC_CMD    , ALLOW_PLURAL |ALLOW_RING}
    3232,{D(jjUMINUS_IV),  '-',             INTMAT_CMD,     INTMAT_CMD    , ALLOW_PLURAL |ALLOW_RING}
     33,{D(jjUMINUS_BIM), '-',             BIGINTMAT_CMD,  BIGINTMAT_CMD , ALLOW_PLURAL |ALLOW_RING}
    3334,{D(jjPROC1),      '(',             ANY_TYPE/*set by p*/,PROC_CMD , ALLOW_PLURAL |ALLOW_RING}
    3435// and the procedures with 1 argument:
     
    4344,{D(jjN2BI),       BIGINT_CMD,      BIGINT_CMD,     NUMBER_CMD    , ALLOW_PLURAL |ALLOW_RING}
    4445,{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}
    4547,{D(jjCHAR),       CHARACTERISTIC_CMD, INT_CMD,     RING_CMD      , ALLOW_PLURAL |ALLOW_RING}
    4648,{D(jjCHAR),       CHARACTERISTIC_CMD, INT_CMD,     QRING_CMD     , ALLOW_PLURAL |ALLOW_RING}
     
    305307,{D(jjPLUS_IV),   '+',            INTVEC_CMD,     INTVEC_CMD, INTVEC_CMD, ALLOW_PLURAL | ALLOW_RING}
    306308,{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}
    307314,{D(lAdd),        '+',            LIST_CMD,       LIST_CMD,   LIST_CMD, ALLOW_PLURAL | ALLOW_RING}
    308315,{D(jjRSUM),      '+',            RING_CMD,       RING_CMD,   RING_CMD, ALLOW_PLURAL | ALLOW_RING}
     
    321328,{D(jjMINUS_IV),  '-',            INTVEC_CMD,     INTVEC_CMD, INTVEC_CMD, ALLOW_PLURAL | ALLOW_RING}
    322329,{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}
    323335,{  jjWRONG2 ,    '-',            NONE,           IDEAL_CMD,  IDEAL_CMD, ALLOW_PLURAL | ALLOW_RING}
    324336,{  jjWRONG2 ,    '-',            NONE,           MODUL_CMD,  MODUL_CMD, ALLOW_PLURAL | ALLOW_RING}
     
    354366,{D(jjTIMES_IV),  '*',            INTMAT_CMD,     INTMAT_CMD, INTMAT_CMD, ALLOW_PLURAL | ALLOW_RING}
    355367,{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}
    356373,{D(jjDIV_N),     '/',            NUMBER_CMD,     NUMBER_CMD, NUMBER_CMD, ALLOW_PLURAL | ALLOW_RING}
    357374,{D(jjDIV_P),     '/',            POLY_CMD,       POLY_CMD,   POLY_CMD, ALLOW_PLURAL | ALLOW_RING}
     
    424441,{D(jjCOMPARE_IV),EQUAL_EQUAL,    INT_CMD,        INTVEC_CMD, INTVEC_CMD, ALLOW_PLURAL | ALLOW_RING}
    425442,{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}
    426444,{D(jjEQUAL_Ma),  EQUAL_EQUAL,    INT_CMD,        MATRIX_CMD, MATRIX_CMD, ALLOW_PLURAL | ALLOW_RING}
    427445,{  jjWRONG2 ,    EQUAL_EQUAL,    0,              IDEAL_CMD,  IDEAL_CMD, ALLOW_PLURAL | ALLOW_RING}
     
    663681,{D(jjBRACK_Ma_IV_I),  '[',        INT_CMD,    INTMAT_CMD, INTVEC_CMD, INT_CMD, ALLOW_PLURAL |ALLOW_RING}
    664682,{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}
    665684,{D(jjBRACK_Ma),       '[',        POLY_CMD,   MATRIX_CMD, INT_CMD,    INT_CMD, ALLOW_PLURAL |ALLOW_RING}
    666685,{D(jjBRACK_Ma_I_IV),  '[',        POLY_CMD,   MATRIX_CMD, INT_CMD,    INTVEC_CMD, ALLOW_PLURAL |ALLOW_RING}
     
    825844  { "betti",       0, BETTI_CMD ,         CMD_12},
    826845  { "bigint",      0, BIGINT_CMD ,        ROOT_DECL},
     846  { "bigintmat",   0, BIGINTMAT_CMD ,     BIGINTMAT_CMD},
    827847  #ifdef HAVE_PLURAL
    828848  { "bracket",     0, BRACKET_CMD ,       CMD_2},
     
    847867  { "degree",      0, DEGREE_CMD ,        CMD_1},
    848868  { "delete",      0, DELETE_CMD ,        CMD_2},
    849   { "denominator", 0, DENOMINATOR_CMD ,   CMD_1}, 
     869  { "denominator", 0, DENOMINATOR_CMD ,   CMD_1},
    850870  { "det",         0, DET_CMD ,           CMD_1},
    851871  { "diff",        0, DIFF_CMD ,          CMD_2},
     
    11101130//  intmat -> matrix
    11111131   { 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 },
    11121136//  number -> poly
    11131137   { NUMBER_CMD,      POLY_CMD,       D(iiN2P)  , NULL },
     
    11741198,{D(jiA_INTVEC),   INTMAT_CMD,     INTMAT_CMD }
    11751199//,{D(jiA_INTVEC),   INTMAT_CMD,     INTVEC_CMD }
     1200,{D(jiA_BIGINTMAT),BIGINTMAT_CMD,  BIGINTMAT_CMD}
    11761201,{D(jiA_NUMBER),   NUMBER_CMD,     NUMBER_CMD }
    11771202,{D(jiA_BIGINT),   BIGINT_CMD,     BIGINT_CMD }
  • libpolys/coeffs/bigintmat.cc

    rc8302b r75f10d  
    3232  assume (i > 0 && j > 0);
    3333  assume (i <= rows() && j <= cols());
    34  
     34
    3535  set(index(i, j), n, C);
    3636}
     
    4040  assume (i >= 0);
    4141  assume (i<rows()*cols());
    42  
     42
    4343  return n_Copy(v[i], basecoeffs());
    4444}
     
    4848  assume (i > 0 && j > 0);
    4949  assume (i <= rows() && j <= cols());
    50  
     50
    5151  return get(index(i, j));
    5252}
     
    5757{
    5858  number iop = n_Init(intop, basecoeffs());
    59  
     59
    6060  inpMult(iop, basecoeffs());
    61  
     61
    6262  n_Delete(&iop, basecoeffs());
    6363}
     
    6666{
    6767  assume (C == NULL || C == basecoeffs());
    68  
     68
    6969  const int l = rows() * cols();
    7070
     
    8585
    8686  const int l = (lhr.rows())*(lhr.cols());
    87  
     87
    8888  for (int i=0; i < l; i++)
    8989  {
    9090    if (!n_Equal(lhr[i], rhr[i], lhr.basecoeffs())) { return false; }
    9191  }
    92  
     92
    9393  return true;
    9494}
     
    104104  if (a->cols() != b->cols()) return NULL;
    105105  if (a->basecoeffs() != b->basecoeffs()) { return NULL; }
    106  
     106
    107107  const int mn = si_min(a->rows(),b->rows());
    108108  const int ma = si_max(a->rows(),b->rows());
    109109
    110110  const coeffs basecoeffs = a->basecoeffs();
    111  
     111
    112112  int i;
    113113
     
    115115  {
    116116    bigintmat * bim = new bigintmat(ma, 1, basecoeffs);
    117    
     117
    118118    for (i=0; i<mn; i++)
    119119      bim->rawset(i, n_Add((*a)[i], (*b)[i], basecoeffs), basecoeffs);
    120    
     120
    121121    if (ma > mn)
    122122    {
     
    130130    return bim;
    131131  }
    132  
     132
    133133  if (mn != ma) return NULL;
    134134
    135135  bigintmat * bim = new bigintmat(mn, a->cols(), basecoeffs);
    136  
     136
    137137  for (i=0; i<mn*a->cols(); i++)
    138138    bim->rawset(i, n_Add((*a)[i], (*b)[i], basecoeffs), basecoeffs);
    139  
     139
     140  return bim;
     141}
     142bigintmat * 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);
    140158  return bim;
    141159}
     
    156174  {
    157175    bigintmat * bim = new bigintmat(ma, 1, basecoeffs);
    158    
     176
    159177    for (i=0; i<mn; i++)
    160178      bim->rawset(i, n_Sub((*a)[i], (*b)[i], basecoeffs), basecoeffs);
     
    177195    return bim;
    178196  }
    179  
     197
    180198  if (mn != ma) return NULL;
    181  
     199
    182200  bigintmat * bim = new bigintmat(mn, a->cols(), basecoeffs);
    183  
     201
    184202  for (i=0; i<mn*a->cols(); i++)
    185203    bim->rawset(i, n_Sub((*a)[i], (*b)[i], basecoeffs), basecoeffs);
    186  
     204
     205  return bim;
     206}
     207
     208bigintmat * 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);
    187224  return bim;
    188225}
     
    195232  const int ra = a->rows();
    196233  const int rb = b->rows();
    197  
     234
    198235  if (ca != rb)
    199236  {
     
    203240    return NULL;
    204241  }
    205  
     242
    206243  assume (ca == rb);
    207  
     244
    208245  if (a->basecoeffs() != b->basecoeffs()) { return NULL; }
    209  
     246
    210247  const coeffs basecoeffs = a->basecoeffs();
    211248
    212249  int i, j, k;
    213  
     250
    214251  number sum;
    215  
     252
    216253  bigintmat * bim = new bigintmat(ra, cb, basecoeffs);
    217  
     254
    218255  for (i=0; i<ra; i++)
    219256    for (j=0; j<cb; j++)
    220257    {
    221258      sum = n_Init(0, basecoeffs);
    222      
     259
    223260      for (k=0; k<ca; k++)
    224261      {
    225262        number prod = n_Mult( BIMATELEM(*a, i, k), BIMATELEM(*b, k, j), basecoeffs);
    226        
     263
    227264        number sum2 = n_Add(sum, prod, basecoeffs); // no inplace add :(
    228        
     265
    229266        n_Delete(&sum, basecoeffs); n_Delete(&prod, basecoeffs);
    230        
     267
    231268        sum = sum2;
    232269      }
    233270      bim->rawset(i+1, j+1, sum, basecoeffs);
    234271    }
     272  return bim;
     273}
     274
     275bigintmat * 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
     294bigintmat * 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
    235309  return bim;
    236310}
     
    251325  const int l = (b->rows())*(b->cols());
    252326  bigintmat * bim = new bigintmat(b->rows(), b->cols(), C);
    253  
     327
    254328  for (int i=0; i < l; i++)
    255329    bim->rawset(i, n_Init((*b)[i], C), C);
    256  
     330
    257331  return bim;
    258332}
     
    307381  if (b == NULL)
    308382    return NULL;
    309    
     383
    310384  return new bigintmat(b);
    311385}
     
    434508{
    435509  const coeffs basecoeffs = bimat->basecoeffs();
    436  
     510
    437511  number tgcd, m;
    438512  int i=bimat->cols();
  • libpolys/coeffs/bigintmat.h

    rc8302b r75f10d  
    9191      return v[i];
    9292    }
     93#define BIMATELEM(M,I,J) (M)[(I-1)*(M).cols()+J-1]
    9394
    9495    /// UEberladener *=-Operator (fuer int und bigint)
    9596    /// Frage hier: *= verwenden oder lieber = und * einzeln?
    9697    void operator*=(int intop);
    97    
     98
    9899    void inpMult(number bintop, const coeffs C = NULL);
    99100
     
    115116    {
    116117      assume (rows() >= 0 && cols() >= 0);
    117      
     118
    118119      assume (r > 0 && c > 0);
    119120      assume (r <= rows() && r <= cols());
     
    134135    /// NOTE: starts at [1,1]
    135136    void set(int i, int j, number n, const coeffs C = NULL);
    136    
     137
    137138    /// replace an entry with a copy (delete old + copy new!).
    138139    /// NOTE: starts at [0]
     
    152153      {
    153154        n_Delete(&(v[i]), basecoeffs()); v[i] = n;
    154       } else
    155       {
     155      }
    156156#ifndef NDEBUG
     157      else
     158      {
    157159        Werror("wrong bigintmat index:%d\n",i);
     160      }
    158161#endif
    159       }
    160     }
    161    
     162    }
     163
    162164    inline void rawset(int i, int j, number n, const coeffs C = NULL)
    163165    {
     
    177179/// NOTE: NULL as a result means an error (non-compatible matrices?)
    178180bigintmat * bimAdd(bigintmat * a, bigintmat * b);
     181bigintmat * bimAdd(bigintmat * a, int b);
    179182bigintmat * bimSub(bigintmat * a, bigintmat * b);
     183bigintmat * bimSub(bigintmat * a, int b);
    180184bigintmat * bimMult(bigintmat * a, bigintmat * b);
     185bigintmat * bimMult(bigintmat * a, int b);
     186bigintmat * bimMult(bigintmat * a, number b, const coeffs cf);
    181187bigintmat * bimCopy(const bigintmat * b);
    182188
Note: See TracChangeset for help on using the changeset viewer.