Changeset 3fbf1f in git


Ignore:
Timestamp:
Feb 1, 2001, 4:54:46 PM (23 years ago)
Author:
Mathias Schulze <mschulze@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
f8a4cbfad6cff1c94cf3ecfacd537154d034f209
Parents:
d971225b227656eaffcaef3076c2525f140cc411
Message:
*mschulze: changed syntax


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

Legend:

Unmodified
Added
Removed
  • Singular/units.cc

    rd971225 r3fbf1f  
    22*  Computer Algebra System SINGULAR      *
    33*****************************************/
    4 /* $Id: units.cc,v 1.2 2001-02-01 15:14:21 mschulze Exp $ */
     4/* $Id: units.cc,v 1.3 2001-02-01 15:54:45 mschulze Exp $ */
    55/*
    66* ABSTRACT: procedures to compute with units
     
    3737BOOLEAN invunit(leftv res,leftv h)
    3838{
    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();
     39  if(h!=NULL&&h->Typ()==INT_CMD)
     40  {
     41    int n=(int)h->Data();
     42    h=h->next;
     43    if(h!=NULL)
     44    {
     45      if(h->Typ()==POLY_CMD)
     46      {
     47        poly u=(poly)h->Data();
     48        if(!isunit(u))
     49        {
     50          WerrorS("unit expected");
     51          return TRUE;
     52        }
    5353        res->rtyp=POLY_CMD;
    54         res->data=(void*)invunit(pCopy(u),n);
     54        res->data=(void*)invunit(n,pCopy(u));
    5555        return FALSE;
    5656      }
    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();
     57      if(h->Typ()==MATRIX_CMD)
     58      {
     59        matrix U=(matrix)h->Data();
     60        if(!isunit(U))
     61        {
     62          WerrorS("diagonal matrix of units expected");
     63          return TRUE;
     64        }
    7065        res->rtyp=MATRIX_CMD;
    71         res->data=(void*)invunit(mpCopy(U),n);
     66        res->data=(void*)invunit(n,mpCopy(U));
    7267        return FALSE;
    7368      }
    74     }
    75   }
    76   WerrorS("[<poly>|<matrix>],<int> expected");
    77   return TRUE;
    78 }
    79 
    80 poly pjet(poly p,int n)
     69    } 
     70 }
     71  WerrorS("<int>,[<poly>|<matrix>] expected");
     72  return TRUE;
     73}
     74
     75poly pjet(int n,poly p)
    8176{
    8277  poly p0=pJet(p,n);
     
    8580}
    8681
    87 poly invunit(poly u, int n)
     82poly invunit(int n,poly u)
    8883{
    8984  if(n<0)
     
    9489  if(n==0)
    9590    return v;
    96   poly u1=pjet(pSub(pOne(),pMult_nn(u,u0)),n);
     91  poly u1=pjet(n,pSub(pOne(),pMult_nn(u,u0)));
    9792  if(u1==NULL)
    9893    return v;
     
    10196  for(int i=n/pTotaldegree(u1);i>1;i--)
    10297  {
    103     v1=pjet(pMult(v1,pCopy(u1)),n);
     98    v1=pjet(n,pMult(v1,pCopy(u1)));
    10499    v=pAdd(v,pCopy(v1));
    105100  }
     
    109104}
    110105
    111 matrix invunit(matrix U,int n)
     106matrix invunit(int n,matrix U)
    112107{
    113108  for(int i=MATCOLS(U);i>=1;i--)
    114     MATELEM(U,i,i)=invunit(MATELEM(U,i,i),n);
     109    MATELEM(U,i,i)=invunit(n,MATELEM(U,i,i));
    115110  return U;
    116111}
     
    118113BOOLEAN series(leftv res,leftv h)
    119114{
    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         }
     115  if(h!=NULL&&h->Typ()==INT_CMD)
     116  {
     117    int n=(int)h->Data();
     118    h=h->next;
     119    if(h!=NULL)
     120    {
     121      if(h->Typ()==POLY_CMD||h->Typ()==VECTOR_CMD)
     122      {
     123        int typ=h->Typ();
     124        poly p=(poly)h->Data();
    135125        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         }
     126        if(h==NULL)
     127        {
     128          res->rtyp=typ;
     129          res->data=(void*)series(n,pCopy(p));
     130          return FALSE;
     131        }
     132        if(h->Typ()==POLY_CMD)
     133        {
     134          poly u=(poly)h->Data();
     135          if(!isunit(u))
     136          {
     137            WerrorS("unit expected");
     138            return TRUE;
     139          }
     140          res->rtyp=typ;
     141          res->data=(void*)series(n,pCopy(p),pCopy(u));
     142          return FALSE;
     143        }
     144      }
     145      if(h->Typ()==IDEAL_CMD||h->Typ()==MODUL_CMD)
     146      {
     147        int typ=h->Typ();
     148        ideal M=(ideal)h->Data();
    163149        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         }
    171       }
    172     }
    173   }
    174   WerrorS("[<poly>,<poly>|<ideal>,<matrix>],<int> expected");
    175   return TRUE;
    176 }
    177 
    178 poly series(poly p,poly u,int n)
     150        if(h==NULL)
     151        {
     152          res->rtyp=typ;
     153          res->data=(void*)series(n,idCopy(M));
     154          return FALSE;
     155        }
     156        if(h->Typ()==MATRIX_CMD)
     157        {
     158          matrix U=(matrix)h->Data();
     159          if(!isunit(U))
     160          {
     161            WerrorS("diagonal matrix of units expected");
     162            return TRUE;
     163          }
     164          if(IDELEMS(M)!=MATROWS(U))
     165          {
     166            WerrorS("incompatible matrix size");
     167            return TRUE;
     168          }
     169          res->rtyp=typ;
     170          res->data=(void*)series(n,idCopy(M),mpCopy(U));
     171          return FALSE;
     172        }
     173      }
     174    }
     175  }
     176  WerrorS("<int>,[<poly>[,<poly>]|<ideal>[,<matrix>]] expected");
     177  return TRUE;
     178}
     179
     180poly series(int n,poly p,poly u=NULL)
    179181{
    180182  if(p!=NULL)
    181     p=pjet(pMult(p,invunit(u,n-pTotaldegree(p))),n);
     183    if(u==NULL)
     184      p=pjet(n,p);
     185    else
     186      p=pjet(n,pMult(p,invunit(n-pTotaldegree(p),u)));
    182187  return p;
    183188}
    184189
    185 ideal series(ideal M,matrix U,int n)
     190ideal series(int n,ideal M,matrix U=NULL)
    186191{
    187192  for(int i=IDELEMS(M)-1;i>=0;i--)
    188     M->m[i]=series(M->m[i],pCopy(MATELEM(U,i+1,i+1)),n);
    189   idDelete((ideal*)&U);
     193    if(U==NULL)
     194      M->m[i]=series(n,M->m[i]);
     195    else
     196    {
     197      M->m[i]=series(n,M->m[i],MATELEM(U,i+1,i+1));
     198      MATELEM(U,i+1,i+1)=NULL;
     199    }
     200  if(U!=NULL)
     201    idDelete((ideal*)&U);
    190202  return M;
    191203}
     
    255267    }
    256268  }
    257   WerrorS("<ideal>,[<ideal>|<poly>][,<matrix>] expected");
     269  WerrorS("<ideal>,[<ideal>[,<matrix>]|<poly>[,<poly>]] expected");
    258270  return TRUE;
    259271}
  • Singular/units.h

    rd971225 r3fbf1f  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: units.h,v 1.2 2001-02-01 15:14:21 mschulze Exp $ */
     4/* $Id: units.h,v 1.3 2001-02-01 15:54:46 mschulze Exp $ */
    55/*
    66* ABSTRACT: procedures to compute with units
     
    1111
    1212BOOLEAN invunit(leftv res,leftv h);
    13 poly invunit(poly u,int n);
    14 matrix invunit(matrix U,int n);
     13poly invunit(int n,poly u);
     14matrix invunit(int n,matrix U);
    1515BOOLEAN series(leftv res,leftv h);
    16 poly series(poly p,poly u,int n);
    17 ideal series(ideal M,matrix U,int n);
     16poly series(int n,poly p,poly u=NULL);
     17ideal series(int n,ideal M,matrix U=NULL);
    1818BOOLEAN rednf(leftv res,leftv h);
    1919ideal rednf(ideal N,ideal M,matrix U=NULL);
Note: See TracChangeset for help on using the changeset viewer.