Changeset b6484c in git for Singular/pcv.cc


Ignore:
Timestamp:
Jun 9, 1999, 1:53:12 PM (25 years ago)
Author:
Mathias Schulze <mschulze@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
3bf6849bf9f6ec5a2581bdf4b8e453a09cc12864
Parents:
8ef5750b7a3298e63ae583dd8949e9ec89e70622
Message:
*** empty log message ***


git-svn-id: file:///usr/local/Singular/svn/trunk@3116 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/pcv.cc

    r8ef575 rb6484c  
    22*  Computer Algebra System SINGULAR      *
    33*****************************************/
    4 /* $Id: pcv.cc,v 1.20 1999-06-08 09:13:54 mschulze Exp $ */
     4/* $Id: pcv.cc,v 1.21 1999-06-09 11:53:12 mschulze Exp $ */
    55/*
    66* ABSTRACT: conversion between polys and coef vectors
     
    1616#include "numbers.h"
    1717#include "polys.h"
     18#include "ideals.h"
    1819#include "lists.h"
    1920#include "matpol.h"
     
    2728static unsigned** pcvIndex=NULL;
    2829
     30lists pcvLAddL(lists l1,lists l2)
     31{
     32  lists l0=(lists)Alloc(sizeof(slists));
     33  int i=l1->nr;
     34  if(l1->nr<l2->nr) i=l2->nr;
     35  l0->Init(i+1);
     36  for(;i>=0;i--)
     37  {
     38    if(i<=l1->nr&&(l1->m[i].rtyp==POLY_CMD||l1->m[i].rtyp==VECTOR_CMD))
     39    {
     40      l0->m[i].rtyp=l1->m[i].rtyp;
     41      l0->m[i].data=pCopy(l1->m[i].data);
     42      if(i<=l2->nr&&l2->m[i].rtyp==l1->m[i].rtyp)
     43        l0->m[i].data=pAdd(l0->m[i].data,pCopy(l2->m[i].data));
     44    }
     45    else
     46    if(i<=l2->nr&&(l2->m[i].rtyp==POLY_CMD||l2->m[i].rtyp==VECTOR_CMD))
     47    {
     48      l0->m[i].rtyp=l2->m[i].rtyp;
     49      l0->m[i].data=pCopy(l2->m[i].data);
     50    }
     51  }
     52  return(l0);
     53}
     54
     55lists pcvPMulL(poly p,lists l1)
     56{
     57  lists l0=(lists)Alloc(sizeof(slists));
     58  l0->Init(l1->nr+1);
     59  for(int i=l1->nr;i>=0;i--)
     60  {
     61    if(l1->m[i].rtyp==POLY_CMD)
     62    {
     63      l0->m[i].rtyp=POLY_CMD;
     64      l0->m[i].data=pMult(pCopy(p),pCopy(l1->m[i].data));
     65    }
     66  }
     67  return(l0);
     68}
     69
     70BOOLEAN pcvLAddL(leftv res,leftv h)
     71{
     72  if(h&&h->Typ()==LIST_CMD)
     73  {
     74    lists l1=(lists)h->Data();
     75    h=h->next;
     76    if(h&&h->Typ()==LIST_CMD)
     77    {
     78      lists l2=(lists)h->Data();
     79      res->rtyp=LIST_CMD;
     80      res->data=(void*)pcvLAddL(l1,l2);
     81      return FALSE;
     82    }
     83  }
     84  WerrorS("<list>,<list> expected");
     85  return TRUE;
     86}
     87
     88BOOLEAN pcvPMulL(leftv res,leftv h)
     89{
     90  if(h&&h->Typ()==POLY_CMD)
     91  {
     92    poly p=(poly)h->Data();
     93    h=h->next;
     94    if(h&&h->Typ()==LIST_CMD)
     95    {
     96      lists l=(lists)h->Data();
     97      res->rtyp=LIST_CMD;
     98      res->data=(void*)pcvPMulL(p,l);
     99      return FALSE;
     100    }
     101  }
     102  WerrorS("<poly>,<list> expected");
     103  return TRUE;
     104}
     105
    29106int pcvDeg(poly p)
    30107{
     
    63140}
    64141
    65 int pcvMaxDeg(poly p)
    66 {
    67   if(!p) return -1;
    68   int md=pcvDeg(p);
    69   pIter(p);
    70   while(p)
    71   {
    72     int d=pcvDeg(p);
    73     if(d>md) md=d;
    74     pIter(p);
    75   }
    76   return md;
    77 }
    78 
    79 int pcvMaxDeg(matrix m)
    80 {
    81   int i,j,d;
    82   int md=-1;
    83   for(i=1;i<=MATROWS(m);i++)
    84   {
    85     for(j=1;j<=MATCOLS(m);j++)
    86     {
    87       d=pcvMinDeg(MATELEM(m,i,j));
    88       if((d>=0&&md<d)||md==-1) md=d;
    89     }
    90   }
    91   return(md);
    92 }
    93 
    94142BOOLEAN pcvMinDeg(leftv res,leftv h)
    95143{
     
    110158    }
    111159  }
    112   WerrorS("<poly> or <matrix> expected");
    113   return TRUE;
    114 }
    115 
    116 BOOLEAN pcvMaxDeg(leftv res,leftv h)
    117 {
    118   if(h)
    119   {
    120     if(h->Typ()==POLY_CMD)
    121     {
    122       res->rtyp=INT_CMD;
    123       res->data=(void*)pcvMaxDeg((poly)h->Data());
    124       return FALSE;
    125     }
    126     else
    127     if(h->Typ()==MATRIX_CMD)
    128     {
    129       res->rtyp=INT_CMD;
    130       res->data=(void*)pcvMaxDeg((matrix)h->Data());     
    131       return FALSE;
    132     }
    133   }
    134   WerrorS("<poly> or <matrix> expected");
     160  WerrorS("<poly> expected");
    135161  return TRUE;
    136162}
     
    288314    if(h&&h->Typ()==LIST_CMD)
    289315    {
     316      lists p=(lists)h->Data();
     317      h=h->next;
     318      if(h&&h->Typ()==INT_CMD)
     319      {
     320        int d0=(int)h->Data();
     321        h=h->next;
     322        if(h&&h->Typ()==INT_CMD)
     323        {
     324          int d1=(int)h->Data();
     325          res->rtyp=LIST_CMD;
     326          res->data=(void*)pcvP2CV(p,d0,d1);
     327          return FALSE;
     328        }
     329      }
     330    }
     331    WerrorS("<list>,<int>,<int> expected");
     332    return TRUE;
     333  }
     334  WerrorS("no ring active");
     335  return TRUE;
     336}
     337
     338BOOLEAN pcvCV2P(leftv res,leftv h)
     339{
     340  if(currRingHdl)
     341  {
     342    if(h&&h->Typ()==LIST_CMD)
     343    {
    290344      lists pl=(lists)h->Data();
    291345      h=h->next;
     
    298352          int d1=(int)h->Data();
    299353          res->rtyp=LIST_CMD;
    300           res->data=pcvP2CV(pl,d0,d1);
    301           return FALSE;
    302         }
    303       }
    304     }
    305     WerrorS("<list>,<int>,<int> expected");
    306     return TRUE;
    307   }
    308   WerrorS("no ring active");
    309   return TRUE;
    310 }
    311 
    312 BOOLEAN pcvCV2P(leftv res,leftv h)
    313 {
    314   if(currRingHdl)
    315   {
    316     if(h&&h->Typ()==LIST_CMD)
    317     {
    318       lists pl=(lists)h->Data();
    319       h=h->next;
    320       if(h&&h->Typ()==INT_CMD)
    321       {
    322         int d0=(int)h->Data();
    323         h=h->next;
    324         if(h&&h->Typ()==INT_CMD)
    325         {
    326           int d1=(int)h->Data();
    327           res->rtyp=LIST_CMD;
    328           res->data=pcvCV2P(pl,d0,d1);
     354          res->data=(void*)pcvCV2P(pl,d0,d1);
    329355          return FALSE;
    330356        }
     
    416442        int d1=(int)h->Data();
    417443        res->rtyp=LIST_CMD;
    418         res->data=pcvBasis(d0,d1);
     444        res->data=(void*)pcvBasis(d0,d1);
    419445        return FALSE;
    420446      }
Note: See TracChangeset for help on using the changeset viewer.