Changeset b6484c in git
- Timestamp:
- Jun 9, 1999, 1:53:12 PM (24 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
- Children:
- 3bf6849bf9f6ec5a2581bdf4b8e453a09cc12864
- Parents:
- 8ef5750b7a3298e63ae583dd8949e9ec89e70622
- Location:
- Singular
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/pcv.cc
r8ef575 rb6484c 2 2 * Computer Algebra System SINGULAR * 3 3 *****************************************/ 4 /* $Id: pcv.cc,v 1.2 0 1999-06-08 09:13:54mschulze Exp $ */4 /* $Id: pcv.cc,v 1.21 1999-06-09 11:53:12 mschulze Exp $ */ 5 5 /* 6 6 * ABSTRACT: conversion between polys and coef vectors … … 16 16 #include "numbers.h" 17 17 #include "polys.h" 18 #include "ideals.h" 18 19 #include "lists.h" 19 20 #include "matpol.h" … … 27 28 static unsigned** pcvIndex=NULL; 28 29 30 lists 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 55 lists 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 70 BOOLEAN 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 88 BOOLEAN 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 29 106 int pcvDeg(poly p) 30 107 { … … 63 140 } 64 141 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 94 142 BOOLEAN pcvMinDeg(leftv res,leftv h) 95 143 { … … 110 158 } 111 159 } 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"); 135 161 return TRUE; 136 162 } … … 288 314 if(h&&h->Typ()==LIST_CMD) 289 315 { 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 338 BOOLEAN pcvCV2P(leftv res,leftv h) 339 { 340 if(currRingHdl) 341 { 342 if(h&&h->Typ()==LIST_CMD) 343 { 290 344 lists pl=(lists)h->Data(); 291 345 h=h->next; … … 298 352 int d1=(int)h->Data(); 299 353 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); 329 355 return FALSE; 330 356 } … … 416 442 int d1=(int)h->Data(); 417 443 res->rtyp=LIST_CMD; 418 res->data= pcvBasis(d0,d1);444 res->data=(void*)pcvBasis(d0,d1); 419 445 return FALSE; 420 446 } -
Singular/pcv.h
r8ef575 rb6484c 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: pcv.h,v 1.1 1 1999-06-08 09:14:01mschulze Exp $ */4 /* $Id: pcv.h,v 1.12 1999-06-09 11:53:06 mschulze Exp $ */ 5 5 /* 6 6 * ABSTRACT: conversion between polys and coef vectors … … 10 10 #define PCV_H 11 11 12 lists pcvLAddL(lists l1,lists l2); 13 lists pcvPMulL(poly p,lists l1); 14 BOOLEAN pcvLAddL(leftv res,leftv h); 15 BOOLEAN pcvPMulL(leftv res,leftv h); 12 16 int pcvDeg(poly p); 13 17 int pcvMinDeg(poly p); 14 18 int pcvMinDeg(matrix m); 15 int pcvMaxDeg(poly p);16 int pcvMaxDeg(matrix m);17 19 BOOLEAN pcvMinDeg(leftv res,leftv h); 18 BOOLEAN pcvMaxDeg(leftv res,leftv h);19 20 void pcvInit(int d); 20 21 void pcvClean(); … … 22 23 poly pcvCV2P(poly cv,int d0,int d1); 23 24 lists pcvP2CV(lists pl,int d0,int d1); 25 ideal pcvP2CV(ideal p,int d0,int d1); 24 26 lists pcvCV2P(lists cvl,int d0,int d1); 27 ideal pcvCV2P(ideal cv,int d0,int d1); 25 28 BOOLEAN pcvP2CV(leftv res,leftv h); 26 29 BOOLEAN pcvCV2P(leftv res,leftv h);
Note: See TracChangeset
for help on using the changeset viewer.