Changeset d971225 in git


Ignore:
Timestamp:
Feb 1, 2001, 4:14:21 PM (23 years ago)
Author:
Mathias Schulze <mschulze@…>
Branches:
(u'spielwiese', '4a9821a93ffdc22a6696668bd4f6b8c9de3e6c5f')
Children:
3fbf1f3f889ac534254e78555c2960c8e2b251e8
Parents:
d5b766919f7e3cfae6c40187879aeee7e632377d
Message:
*mschulze: added rednf(<ideal>,<poly>[,<poly>])


git-svn-id: file:///usr/local/Singular/svn/trunk@5164 2c84dea3-7e68-4137-9b89-c4e89433aadc
Location:
Singular
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • Singular/units.cc

    rd5b766 rd971225  
    22*  Computer Algebra System SINGULAR      *
    33*****************************************/
    4 /* $Id: units.cc,v 1.1 2001-02-01 13:20:06 mschulze Exp $ */
     4/* $Id: units.cc,v 1.2 2001-02-01 15:14:21 mschulze Exp $ */
    55/*
    66* ABSTRACT: procedures to compute with units
     
    3737BOOLEAN invunit(leftv res,leftv h)
    3838{
    39   if(h!=NULL&&h->Typ()==POLY_CMD)
    40   {
    41     poly u=(poly)h->Data();
    42     if(!isunit(u))
    43     {
    44       WerrorS("unit expected");
    45       return TRUE;
    46     }
    47     h=h->next;
    48     if(h&&h->Typ()==INT_CMD)
    49     {
    50       int n=(int)h->Data();
    51       res->rtyp=POLY_CMD;
    52       res->data=(void*)invunit(pCopy(u),n);
    53       return FALSE;
    54     }
    55   }
    56   if(h!=NULL&&h->Typ()==MATRIX_CMD)
    57   {
    58     matrix U=(matrix)h->Data();
    59     if(!isunit(U))
    60     {
    61       WerrorS("diagonal matrix of units expected");
    62       return TRUE;
    63     }
    64     h=h->next;
    65     if(h&&h->Typ()==INT_CMD)
    66     {
    67       int n=(int)h->Data();
    68       res->rtyp=MATRIX_CMD;
    69       res->data=(void*)invunit(mpCopy(U),n);
    70       return FALSE;
     39  if(h!=NULL)
     40  {
     41    if(h->Typ()==POLY_CMD)
     42    {
     43      poly u=(poly)h->Data();
     44      if(!isunit(u))
     45      {
     46        WerrorS("unit expected");
     47        return TRUE;
     48      }
     49      h=h->next;
     50      if(h!=NULL&&h->Typ()==INT_CMD)
     51      {
     52        int n=(int)h->Data();
     53        res->rtyp=POLY_CMD;
     54        res->data=(void*)invunit(pCopy(u),n);
     55        return FALSE;
     56      }
     57    }
     58    if(h->Typ()==MATRIX_CMD)
     59    {
     60      matrix U=(matrix)h->Data();
     61      if(!isunit(U))
     62      {
     63        WerrorS("diagonal matrix of units expected");
     64        return TRUE;
     65      }
     66      h=h->next;
     67      if(h!=NULL&&h->Typ()==INT_CMD)
     68      {
     69        int n=(int)h->Data();
     70        res->rtyp=MATRIX_CMD;
     71        res->data=(void*)invunit(mpCopy(U),n);
     72        return FALSE;
     73      }
    7174    }
    7275  }
     
    115118BOOLEAN series(leftv res,leftv h)
    116119{
    117   if(h!=NULL&&(h->Typ()==POLY_CMD||h->Typ()==VECTOR_CMD))
    118   {
    119     int typ=h->Typ();
    120     poly p=(poly)h->Data();
    121     h=h->next;
    122     if(h&&h->Typ()==POLY_CMD)
    123     {
    124       poly u=(poly)h->Data();
    125       if(!isunit(u))
    126       {
    127         WerrorS("unit expected");
    128         return TRUE;
    129       }
    130       h=h->next;
    131       if(h&&h->Typ()==INT_CMD)
    132       {
    133         int n=(int)h->Data();
    134         res->rtyp=typ;
    135         res->data=(void*)series(pCopy(p),pCopy(u),n);
    136         return FALSE;
    137       }
    138     }
    139   }
    140   if(h!=NULL&&(h->Typ()==IDEAL_CMD||h->Typ()==MODUL_CMD))
    141   {
    142     int typ=h->Typ();
    143     ideal M=(ideal)h->Data();
    144     h=h->next;
    145     if(h&&h->Typ()==MATRIX_CMD)
    146     {
    147       matrix U=(matrix)h->Data();
    148       if(!isunit(U))
    149       {
    150         WerrorS("diagonal matrix of units expected");
    151         return TRUE;
    152       }
    153       if(IDELEMS(M)!=MATROWS(U))
    154       {
    155         WerrorS("matrix size not compatible");
    156         return TRUE;
    157       }
    158       h=h->next;
    159       if(h&&h->Typ()==INT_CMD)
    160       {
    161         int n=(int)h->Data();
    162         res->rtyp=typ;
    163         res->data=(void*)series(idCopy(M),mpCopy(U),n);
    164         return FALSE;
     120  if(h!=NULL)
     121  {
     122    if(h->Typ()==POLY_CMD||h->Typ()==VECTOR_CMD)
     123    {
     124      int typ=h->Typ();
     125      poly p=(poly)h->Data();
     126      h=h->next;
     127      if(h!=NULL&&h->Typ()==POLY_CMD)
     128      {
     129        poly u=(poly)h->Data();
     130        if(!isunit(u))
     131        {
     132          WerrorS("unit expected");
     133          return TRUE;
     134        }
     135        h=h->next;
     136        if(h!=NULL&&h->Typ()==INT_CMD)
     137        {
     138          int n=(int)h->Data();
     139          res->rtyp=typ;
     140          res->data=(void*)series(pCopy(p),pCopy(u),n);
     141          return FALSE;
     142        }
     143      }
     144    }
     145    if(h->Typ()==IDEAL_CMD||h->Typ()==MODUL_CMD)
     146    {
     147      int typ=h->Typ();
     148      ideal M=(ideal)h->Data();
     149      h=h->next;
     150      if(h!=NULL&&h->Typ()==MATRIX_CMD)
     151      {
     152        matrix U=(matrix)h->Data();
     153        if(!isunit(U))
     154        {
     155          WerrorS("diagonal matrix of units expected");
     156          return TRUE;
     157        }
     158        if(IDELEMS(M)!=MATROWS(U))
     159        {
     160          WerrorS("incompatible matrix size");
     161          return TRUE;
     162        }
     163        h=h->next;
     164        if(h!=NULL&&h->Typ()==INT_CMD)
     165        {
     166          int n=(int)h->Data();
     167          res->rtyp=typ;
     168          res->data=(void*)series(idCopy(M),mpCopy(U),n);
     169          return FALSE;
     170        }
    165171      }
    166172    }
     
    187193BOOLEAN rednf(leftv res,leftv h)
    188194{
    189   if(h!=NULL&&(h->Typ()==IDEAL_CMD||h->Typ()==MODUL_CMD))
    190   {
    191     int typ=h->Typ();
    192     ideal N=(ideal)h->Data();
    193     h=h->next;
    194     if(h&&h->Typ()==typ)
    195     {
    196       ideal M=(ideal)h->Data();
    197       h=h->next;
    198       matrix U;
    199       if(h&&h->Typ()==MATRIX_CMD)
    200       {
    201         U=(matrix)h->Data();
    202         if(!isunit(U))
    203         {
    204           WerrorS("diagonal matrix of units expected");
    205           return TRUE;
    206         }
    207         if(IDELEMS(M)!=MATROWS(U))
    208         {
    209           WerrorS("matrix size not compatible");
    210           return TRUE;
    211         }
    212       }
    213       res->rtyp=typ;
    214       res->data=(void*)rednf(idCopy(N),idCopy(M),mpCopy(U));
    215       return FALSE;
    216     }
    217   }
    218   WerrorS("<ideal>,<ideal>[,<matrix>] expected");
     195  if(h!=NULL)
     196  {
     197    if(h->Typ()==IDEAL_CMD||h->Typ()==MODUL_CMD)
     198    {
     199      int typ=h->Typ();
     200      ideal N=(ideal)h->Data();
     201      h=h->next;
     202      if(h!=NULL&&h->Typ()==typ)
     203      {
     204        ideal M=(ideal)h->Data();
     205        h=h->next;
     206        if(h==NULL)
     207        {
     208          res->rtyp=typ;
     209          res->data=(void*)rednf(idCopy(N),idCopy(M));
     210          return FALSE;
     211        }
     212        if(h->Typ()==MATRIX_CMD)
     213        {
     214          matrix U=(matrix)h->Data();
     215          if(!isunit(U))
     216          {
     217            WerrorS("diagonal matrix of units expected");
     218            return TRUE;
     219          }
     220          if(IDELEMS(M)!=MATROWS(U))
     221          {
     222            WerrorS("incompatible matrix size");
     223            return TRUE;
     224          }
     225          res->rtyp=typ;
     226          res->data=(void*)rednf(idCopy(N),idCopy(M),mpCopy(U));
     227          return FALSE;
     228        }
     229      }
     230      if(typ==IDEAL_CMD&&h->Typ()==POLY_CMD||
     231         typ==MODUL_CMD&&h->Typ()==VECTOR_CMD)
     232      {
     233        typ=h->Typ();
     234        poly p=(poly)h->Data();
     235        h=h->next;
     236        if(h==NULL)
     237        {
     238          res->rtyp=typ;
     239          res->data=(void*)rednf(idCopy(N),pCopy(p));
     240          return FALSE;
     241        }
     242        if(h->Typ()==POLY_CMD)
     243        {
     244          poly u=(poly)h->Data();
     245          if(!isunit(u))
     246          {
     247            WerrorS("unit expected");
     248            return TRUE;
     249          }
     250          res->rtyp=typ;
     251          res->data=(void*)rednf(idCopy(N),pCopy(p),pCopy(u));
     252          return FALSE;
     253        }
     254      }
     255    }
     256  }
     257  WerrorS("<ideal>,[<ideal>|<poly>][,<matrix>] expected");
    219258  return TRUE;
    220259}
     
    257296  return M0;
    258297}
     298
     299poly rednf(ideal N,poly p,poly u=NULL)
     300{
     301  ideal M=idInit(1,pGetComp(p));
     302  M->m[0]=p;
     303  ideal M0;
     304  if(u==NULL)
     305    M0=rednf(N,M);
     306  else
     307  {
     308    matrix U=mpInitI(1,1,NULL);
     309    MATELEM(U,1,1)=u;
     310    M0=rednf(N,M,U);
     311  }
     312  poly p0=M0->m[0];
     313  M0->m[0]=NULL;
     314  idDelete(&M0);
     315  return p0;
     316}
  • Singular/units.h

    rd5b766 rd971225  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: units.h,v 1.1 2001-02-01 13:11:15 mschulze Exp $ */
     4/* $Id: units.h,v 1.2 2001-02-01 15:14:21 mschulze Exp $ */
    55/*
    66* ABSTRACT: procedures to compute with units
     
    1818BOOLEAN rednf(leftv res,leftv h);
    1919ideal rednf(ideal N,ideal M,matrix U=NULL);
     20poly rednf(ideal N,poly p,poly u=NULL);
    2021
    2122#endif
Note: See TracChangeset for help on using the changeset viewer.