Changeset 4d9dc5 in git
- Timestamp:
- Jun 8, 1999, 11:15:20 AM (24 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
- Children:
- 559d1ee5651bb2aab60891dce7d68b2348256ca7
- Parents:
- bb21e33b4dde3d1a2778e90aee11ade770bea780
- Location:
- Singular
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/jordan.lib
rbb21e3 r4d9dc5 1 1 /////////////////////////////////////////////////////////////////////////////// 2 2 3 version="$Id: jordan.lib,v 1. 9 1999-02-18 19:29:01mschulze Exp $";3 version="$Id: jordan.lib,v 1.10 1999-06-08 09:15:20 mschulze Exp $"; 4 4 info=" 5 5 LIBRARY: jordan.lib PROCEDURES TO COMPUTE THE JORDAN NORMAL FORM 6 6 AUTHOR: Mathias Schulze, email: mschulze@mathematik.uni-kl.de 7 7 8 jordan(M[,opt]); eigenvalues, Jordan block sizes, transformation matrixof M8 jordan(M[,opt]); eigenvalues, Jordan block sizes, Jordan transformation of M 9 9 jordanmatrix(l); Jordan matrix with eigenvalues l[1], Jordan block sizes l[2] 10 10 jordanform(M); Jordan normal form of constant square matrix M 11 inv ersemat(M);inverse matrix of invertible constant matrix M11 invmat(M); inverse matrix of invertible constant matrix M 12 12 "; 13 13 … … 16 16 17 17 proc jordan(matrix M,list #) 18 "USAGE: jordan(M[,opt]); M constant square matrix, opt integer 19 ASSUME: the eigenvalues of M are in the coefficient field 20 RETURN: a list l with 3 entries of type ideal, list of intvecs, matrix with 21 l[1] : eigenvalues of M 22 l[2][i][j] : size of j-th Jordan block with eigenvalue l[1][i] 23 l[3] : transformation matrix U with U^(-1)*M*U in Jordan normal form 24 which entries of l are computed depends on opt: 25 opt=-1 : compute l[1] 26 opt= 0 : compute l[1] and l[2] (default) 27 opt= 1 : compute l[1],l[2] and l[3] 28 opt= 2 : compute l[1] and l[3] 29 NOTE: a non constant polynomial matrix M is replaced by its constant part 30 EXAMPLE: example jordan; shows an example 18 "USAGE: jordan(M[,opt]); with M constant square matrix and opt integer. 19 ASSUME: The eigenvalues of M are in the coefficient field. 20 RETURN: The procedure returns a list l with 3 entries of type 21 ideal, list of intvecs, matrix with 22 l[1] eigenvalues of M, 23 l[2][i][j] size of j-th Jordan block with eigenvalue l[1][i], and 24 l[3]^(-1)*M*l[3] in Jordan normal form. 25 Depending on opt, only certain entries of l are computed. 26 If opt=-1, l[1] is computed, 27 if opt= 0, l[1] and l[2] are computed, 28 if opt= 1, l[1],l[2], and l[3] are computed, and, 29 if opt= 2, l[1] and l[3] are computed. 30 By default, opt=0. 31 NOTE: A non constant polynomial matrix M is replaced by its constant part. 32 EXAMPLE: example jordan; shows an example. 31 33 " 32 34 { 33 // test if square matrix35 // test if M is a square matrix 34 36 int n=nrows(M); 35 37 if(n!=ncols(M)) 36 38 { 37 "//no square matrix"; 38 return(); 39 } 40 41 // get constant part 39 print("//no square matrix"); 40 return(list()); 41 } 42 43 // replace M by its constant part 44 M=jet(M,0); 45 46 // change to polynomial ring for factorization 42 47 def br=basering; 43 map zero=br,0;44 M=zero(M);45 kill zero;46 47 // change to polynomial ring for factorization48 48 changeord("pr","dp"); 49 49 matrix M=imap(br,M); 50 50 51 // factorize characteristic polynomial 51 // factorize characteristic polynomial of M 52 52 list l=factorize(det(M-var(1)*freemodule(n)),2); 53 53 54 // get multiplicities mM 54 // get multiplicities mM of M 55 55 def eM,mM=l[1..2]; 56 56 kill l; 57 57 58 // test if eigenvalues in the coefficient field58 // test if eigenvalues of M are in the coefficient field 59 59 int i; 60 60 for(i=size(eM);i>=1;i--) … … 62 62 if(deg(eM[i])>1) 63 63 { 64 print("//eigenvalues not in the coefficient field"); 65 setring br; 64 66 kill pr; 65 "//eigenvalues not in the coefficient field"; 66 return(); 67 } 68 } 69 70 // get eigenvalues eM 67 return(list()); 68 } 69 } 70 71 // get eigenvalues eM of M 71 72 map inv=pr,-var(1); 72 eM= simplify(inv(eM),1);73 eM=jet(simplify(inv(eM),1),0); 73 74 setring br; 74 map zero=pr,0; 75 ideal eM=zero(eM); 75 ideal eM=fetch(pr,eM); 76 76 kill pr; 77 77 78 // sort eigenvalues 78 // sort eigenvalues eM 79 79 int j; 80 80 poly e; … … 97 97 kill e,m; 98 98 99 // get option parameter99 // get optional parameter opt 100 100 int opt=0; 101 101 if(size(#)>0) … … 111 111 } 112 112 113 // define neededvariables113 // define variables 114 114 int k,l; 115 115 matrix E=freemodule(n); … … 128 128 } 129 129 130 // do the followingfor all eigenvalues eM[i]130 // do for all eigenvalues eM[i] 131 131 for(i=ncols(eM);i>=1;i--) 132 132 { … … 143 143 if(opt<=1) 144 144 { 145 // compute Jordan block size vector corresponding to eigenvalue eM[i]145 // compute Jordan block size vector bMi corresponding to eigenvalue eM[i] 146 146 bMi=0; 147 147 bMi[size(K[2])]=0; … … 158 158 if(opt>=1) 159 159 { 160 // compute generating vectors for Jordan basis vectors corresponding to 161 // eigenvalue eM[i] 160 // compute Jordan basis vectors K corresponding to eigenvalue eM[i] 162 161 if(size(K)>1) 163 162 { … … 170 169 K[j]=interred(reduce(K[j],std(K1))); 171 170 } 172 173 // compute Jordan basis vectors corresponding to eigenvalue eM[i] from174 // generating vectors175 171 for(j=size(K);j>=2;j--) 176 172 { … … 189 185 kill l; 190 186 191 // create return list 187 // create return list l 192 188 list l=eM; 193 189 if(opt<=1) … … 212 208 213 209 proc jordanmatrix(list l) 214 "USAGE: jordanmatrix(l); l list of ideal and list of intvecs 215 RETURN: the Jordan matrix J defined by l: 216 l[1] : eigenvalues of J 217 l[2][i][j] : size of j-th Jordan block with eigenvalue l[1][i] 218 EXAMPLE: example jordanmatrix; shows an example 210 "USAGE: jordanmatrix(l); with l list of ideal and list of intvecs. 211 RETURN: The procedure returns the Jordan matrix J with eigenvalues l[1] and 212 size l[2][i][j] of j-th Jordan block with eigenvalue l[1][i]. 213 EXAMPLE: example jordanmatrix; shows an example. 219 214 " 220 215 { … … 222 217 if(size(l)<2) 223 218 { 224 "//not enough entries in argument list"; 225 return(); 219 print("//not enough entries in argument list"); 220 matrix J[1][0]; 221 return(J); 226 222 } 227 223 def eJ,bJ=l[1..2]; … … 229 225 if(typeof(eJ)!="ideal") 230 226 { 231 "//first entry in argument list not an ideal"; 232 return(); 227 print("//first entry in argument list not an ideal"); 228 matrix J[1][0]; 229 return(J); 233 230 } 234 231 if(typeof(bJ)!="list") 235 232 { 236 "//second entry in argument list not a list"; 237 return(); 233 print("//second entry in argument list not a list"); 234 matrix J[1][0]; 235 return(J); 238 236 } 239 237 if(size(eJ)<size(bJ)) … … 252 250 if(typeof(bJ[i])!="intvec") 253 251 { 254 "//second entry in argument list not a list of integer vectors"; 255 return(); 252 print("//second entry in argument list not a list of intvecs"); 253 matrix J[1][0]; 254 return(J); 256 255 } 257 256 else … … 267 266 } 268 267 } 269 matrix J[n][n];270 268 271 269 // create Jordan matrix 272 270 int l; 271 matrix J[n][n]; 273 272 for(i,l=1,1;i<=s;i++) 274 273 { … … 303 302 304 303 proc jordanform(matrix M) 305 "USAGE: jordanform(M); M constant square matrix306 ASSUME: the eigenvalues of M are in the coefficient field307 RETURN: the Jordan normal form of M308 NOTE: a non constant polynomial matrix M is replaced by its constant part309 EXAMPLE: example jordanform; shows an example 304 "USAGE: jordanform(M); with M constant square matrix. 305 ASSUME: The eigenvalues of M are in the coefficient field. 306 RETURN: The procedure returns the Jordan normal form of M. 307 NOTE: A non constant polynomial matrix M is replaced by its constant part. 308 EXAMPLE: example jordanform; shows an example. 310 309 " 311 310 { … … 321 320 /////////////////////////////////////////////////////////////////////////////// 322 321 323 proc inv ersemat(matrix M)324 "USAGE: inv ersemat(M); M constant square matrix325 ASSUME: M is invertible 326 RETURN: the inverse matrix of M327 NOTE: a non constant polynomial matrix M is replaced by its constant part328 EXAMPLE: example inv ersemat; shows an example322 proc invmat(matrix M) 323 "USAGE: invmat(M); with M constant square matrix. 324 ASSUME: M is invertible. 325 RETURN: The procedure returns the inverse matrix of M. 326 NOTE: A non constant polynomial matrix M is replaced by its constant part. 327 EXAMPLE: example invmat; shows an example. 329 328 " 330 329 { 331 // test if square matrix 332 int n=nrows(M); 333 if(n!=ncols(M)) 334 { 335 "//no square matrix"; 336 return(); 337 } 338 339 // get constant part 340 def br=basering; 341 map zero=br,0; 342 M=zero(M); 343 344 // compute inverse 345 return(lift(M,freemodule(n))); 330 if(nrows(M)==ncols(M)) 331 { 332 matrix invM=lift(jet(M,0),freemodule(nrows(M))); 333 } 334 else 335 { 336 print("//no square matrix"); 337 matrix[1][0]=invM; 338 } 339 return(invM); 346 340 } 347 341 example … … 350 344 matrix M[3][3]=3,2,1,0,2,1,0,0,3; 351 345 print(M); 352 print(inversemat(M)); 353 } 354 /////////////////////////////////////////////////////////////////////////////// 355 346 print(invmat(M)); 347 } 348 /////////////////////////////////////////////////////////////////////////////// -
Singular/pcv.cc
rbb21e3 r4d9dc5 2 2 * Computer Algebra System SINGULAR * 3 3 *****************************************/ 4 /* $Id: pcv.cc,v 1. 19 1999-04-29 15:09:32 SingularExp $ */4 /* $Id: pcv.cc,v 1.20 1999-06-08 09:13:54 mschulze Exp $ */ 5 5 /* 6 6 * ABSTRACT: conversion between polys and coef vectors … … 8 8 9 9 #include "mod2.h" 10 10 11 #ifdef HAVE_PCV 11 12 #if !defined(HAVE_DYNAMIC_LOADING) || defined(BUILD_MODULE) … … 16 17 #include "polys.h" 17 18 #include "lists.h" 19 #include "matpol.h" 18 20 #include "febase.h" 19 21 #include "pcv.h" 20 22 21 static int pcv DegBound;23 static int pcvMaxDegree; 22 24 static int pcvTableSize; 23 25 static int pcvIndexSize; … … 25 27 static unsigned** pcvIndex=NULL; 26 28 27 #ifndef HAVE_DYNAMIC_LOADING 28 /* Without dynamic-loading we need to provides following functions */ 29 int pcvDeg(poly p) 30 { 31 int d=0; 32 for(int i=pVariables;i>=1;i--) d+=pGetExp(p,i); 33 return d; 34 } 35 36 int pcvMinDeg(poly p) 37 { 38 if(!p) return -1; 39 int md=pcvDeg(p); 40 pIter(p); 41 while(p) 42 { 43 int d=pcvDeg(p); 44 if(d<md) md=d; 45 pIter(p); 46 } 47 return md; 48 } 49 50 int pcvMinDeg(matrix m) 51 { 52 int i,j,d; 53 int md=-1; 54 for(i=1;i<=MATROWS(m);i++) 55 { 56 for(j=1;j<=MATCOLS(m);j++) 57 { 58 d=pcvMinDeg(MATELEM(m,i,j)); 59 if((d>=0&&md>d)||md==-1) md=d; 60 } 61 } 62 return(md); 63 } 64 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 } 29 93 30 94 BOOLEAN pcvMinDeg(leftv res,leftv h) … … 38 102 return FALSE; 39 103 } 40 } 41 WerrorS("<poly> expected"); 104 else 105 if(h->Typ()==MATRIX_CMD) 106 { 107 res->rtyp=INT_CMD; 108 res->data=(void*)pcvMinDeg((matrix)h->Data()); 109 return FALSE; 110 } 111 } 112 WerrorS("<poly> or <matrix> expected"); 42 113 return TRUE; 43 114 } … … 53 124 return FALSE; 54 125 } 55 } 56 WerrorS("<poly> expected"); 57 return TRUE; 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"); 135 return TRUE; 136 } 137 138 void pcvInit(int d) 139 { 140 if(d<0) d=0; 141 pcvMaxDegree=d; 142 pcvTableSize=pVariables*pcvMaxDegree*sizeof(unsigned); 143 pcvTable=(unsigned*)Alloc0(pcvTableSize); 144 pcvIndexSize=pVariables*sizeof(unsigned*); 145 pcvIndex=(unsigned**)Alloc(pcvIndexSize); 146 for(int i=0;i<pVariables;i++) 147 pcvIndex[i]=pcvTable+i*pcvMaxDegree; 148 for(int i=0;i<pcvMaxDegree;i++) 149 pcvIndex[0][i]=i; 150 for(int i=1;i<pVariables;i++) 151 { 152 unsigned x=0; 153 for(int j=0;j<pcvMaxDegree;j++) 154 { 155 x+=pcvIndex[i-1][j]; 156 pcvIndex[i][j]=x; 157 } 158 } 159 } 160 161 void pcvClean() 162 { 163 if(pcvTable) 164 { 165 Free(pcvTable,pcvTableSize); 166 pcvTable=NULL; 167 } 168 if(pcvIndex) 169 { 170 Free(pcvIndex,pcvIndexSize); 171 pcvIndex=NULL; 172 } 173 } 174 175 int pcvM2N(poly m) 176 { 177 unsigned n=0,d=0; 178 for(int i=0;i<pVariables;i++) 179 { 180 d+=pGetExp(m,i+1); 181 n+=pcvIndex[i][d]; 182 } 183 return n+1; 184 } 185 186 poly pcvN2M(int n) 187 { 188 n--; 189 poly m=pOne(); 190 int i,j,k; 191 for(i=pVariables-1;i>=0;i--) 192 { 193 k=j; 194 for(j=0;j<pcvMaxDegree&&pcvIndex[i][j]<=n;j++); 195 j--; 196 n-=pcvIndex[i][j]; 197 if(i<pVariables-1) pSetExp(m,i+2,k-j); 198 } 199 if(n==0) 200 { 201 pSetExp(m,1,j); 202 pSetm(m); 203 return m; 204 } 205 else 206 { 207 pDelete1(&m); 208 return NULL; 209 } 210 } 211 212 poly pcvP2CV(poly p,int d0,int d1) 213 { 214 poly cv=NULL; 215 while(p) 216 { 217 int d=pcvDeg(p); 218 if(d0<=d&&d<d1) 219 { 220 poly c=pOne(); 221 pSetComp(c,pcvM2N(p)); 222 pSetCoeff(c,nCopy(pGetCoeff(p))); 223 cv=pAdd(cv,c); 224 } 225 pIter(p); 226 } 227 return cv; 228 } 229 230 poly pcvCV2P(poly cv,int d0,int d1) 231 { 232 poly p=NULL; 233 while(cv) 234 { 235 poly m=pcvN2M(pGetComp(cv)); 236 if(m) 237 { 238 int d=pcvDeg(m); 239 if(d0<=d&&d<d1) 240 { 241 pSetCoeff(m,nCopy(pGetCoeff(cv))); 242 p=pAdd(p,m); 243 } 244 } 245 pIter(cv); 246 } 247 return p; 248 } 249 250 lists pcvP2CV(lists pl,int d0,int d1) 251 { 252 lists cvl=(lists)Alloc(sizeof(slists)); 253 cvl->Init(pl->nr+1); 254 pcvInit(d1); 255 for(int i=pl->nr;i>=0;i--) 256 { 257 if(pl->m[i].rtyp==POLY_CMD) 258 { 259 cvl->m[i].rtyp=VECTOR_CMD; 260 cvl->m[i].data=pcvP2CV((poly)pl->m[i].data,d0,d1); 261 } 262 } 263 pcvClean(); 264 return cvl; 265 } 266 267 lists pcvCV2P(lists cvl,int d0,int d1) 268 { 269 lists pl=(lists)Alloc(sizeof(slists)); 270 pl->Init(cvl->nr+1); 271 pcvInit(d1); 272 for(int i=cvl->nr;i>=0;i--) 273 { 274 if(cvl->m[i].rtyp==VECTOR_CMD) 275 { 276 pl->m[i].rtyp=POLY_CMD; 277 pl->m[i].data=pcvCV2P((poly)cvl->m[i].data,d0,d1); 278 } 279 } 280 pcvClean(); 281 return pl; 58 282 } 59 283 … … 114 338 } 115 339 340 int pcvDim(int d0,int d1) 341 { 342 if(d0<0) d0=0; 343 if(d1<0) d1=0; 344 pcvInit(d1+1); 345 int d=pcvIndex[pVariables-1][d1]-pcvIndex[pVariables-1][d0]; 346 pcvClean(); 347 return d; 348 } 349 116 350 BOOLEAN pcvDim(leftv res,leftv h) 117 351 { … … 137 371 } 138 372 373 int pcvBasis(lists b,int i,poly m,int d,int n) 374 { 375 if(n<pVariables) 376 { 377 for(int k=0,l=d;k<=l;k++,d--) 378 { 379 pSetExp(m,n,k); 380 i=pcvBasis(b,i,m,d,n+1); 381 } 382 } 383 else 384 { 385 pSetExp(m,n,d); 386 pSetm(m); 387 b->m[i].rtyp=POLY_CMD; 388 b->m[i++].data=pCopy(m); 389 } 390 return i; 391 } 392 393 lists pcvBasis(int d0,int d1) 394 { 395 if(d0<0) d0=0; 396 if(d1<0) d1=0; 397 lists b=(lists)Alloc(sizeof(slists)); 398 b->Init(pcvDim(d0,d1)); 399 poly m=pOne(); 400 for(int d=d0,i=0;d<d1;d++) 401 i=pcvBasis(b,i,m,d,1); 402 pDelete1(&m); 403 return b; 404 } 405 139 406 BOOLEAN pcvBasis(leftv res,leftv h) 140 407 { … … 160 427 } 161 428 162 #endif /* HAVE_DYNAMIC_LOADING */163 164 int pcvDeg(poly p)165 {166 int dp=0;167 for(int i=1;i<=pVariables;i++) dp+=pGetExp(p,i);168 return dp;169 }170 171 int pcvMinDeg(poly p)172 {173 if(!p) return 0;174 int md=pcvDeg(p);175 pIter(p);176 while(p)177 {178 int d=pcvDeg(p);179 if(d<md) md=d;180 pIter(p);181 }182 return md;183 }184 185 int pcvMaxDeg(poly p)186 {187 if(!p) return 0;188 int md=pcvDeg(p);189 pIter(p);190 while(p)191 {192 int d=pcvDeg(p);193 if(d>md) md=d;194 pIter(p);195 }196 return md;197 }198 199 void pcvInit(int d)200 {201 if(d<0) d=0;202 pcvDegBound=d;203 pcvTableSize=pVariables*pcvDegBound*sizeof(unsigned);204 pcvTable=(unsigned*)Alloc0(pcvTableSize);205 pcvIndexSize=pVariables*sizeof(unsigned*);206 pcvIndex=(unsigned**)Alloc(pcvIndexSize);207 int i;208 for(i=0;i<pVariables;i++)209 pcvIndex[i]=pcvTable+i*pcvDegBound;210 for(i=0;i<pcvDegBound;i++)211 pcvIndex[0][i]=i;212 for(i=1;i<pVariables;i++)213 {214 unsigned x=0;215 for(int j=0;j<pcvDegBound;j++)216 {217 x+=pcvIndex[i-1][j];218 pcvIndex[i][j]=x;219 }220 }221 }222 223 void pcvClean()224 {225 if(pcvTable)226 {227 Free(pcvTable,pcvTableSize);228 pcvTable=NULL;229 }230 if(pcvIndex)231 {232 Free(pcvIndex,pcvIndexSize);233 pcvIndex=NULL;234 }235 }236 237 int pcvM2N(poly m)238 {239 unsigned n=0,d=0;240 for(int i=0;i<pVariables;i++)241 {242 d+=pGetExp(m,i+1);243 n+=pcvIndex[i][d];244 }245 return n+1;246 }247 248 poly pcvN2M(int n)249 {250 n--;251 poly m=pOne();252 int i,j,k;253 for(i=pVariables-1;i>=0;i--)254 {255 k=j;256 for(j=0;j<pcvDegBound&& ((int)pcvIndex[i][j])<=n;j++);257 j--;258 n-=pcvIndex[i][j];259 if(i<pVariables-1) pSetExp(m,i+2,k-j);260 }261 if(n==0)262 {263 pSetExp(m,1,j);264 pSetm(m);265 return m;266 }267 else268 {269 pDelete1(&m);270 return NULL;271 }272 }273 274 poly pcvP2CV(poly p,int d0,int d1)275 {276 poly cv=NULL;277 while(p)278 {279 int d=pcvDeg(p);280 if(d0<=d&&d<d1)281 {282 poly c=pOne();283 pSetComp(c,pcvM2N(p));284 pSetCoeff(c,nCopy(pGetCoeff(p)));285 cv=pAdd(cv,c);286 }287 pIter(p);288 }289 return cv;290 }291 292 poly pcvCV2P(poly cv,int d0,int d1)293 {294 poly p=NULL;295 while(cv)296 {297 poly m=pcvN2M(pGetComp(cv));298 if(m)299 {300 int d=pcvDeg(m);301 if(d0<=d&&d<d1)302 {303 pSetCoeff(m,nCopy(pGetCoeff(cv)));304 p=pAdd(p,m);305 }306 }307 pIter(cv);308 }309 return p;310 }311 312 lists pcvP2CV(lists pl,int d0,int d1)313 {314 lists cvl=(lists)Alloc(sizeof(slists));315 cvl->Init(pl->nr+1);316 pcvInit(d1);317 for(int i=pl->nr;i>=0;i--)318 {319 if(pl->m[i].rtyp==POLY_CMD)320 {321 cvl->m[i].rtyp=VECTOR_CMD;322 cvl->m[i].data=pcvP2CV((poly)pl->m[i].data,d0,d1);323 }324 }325 pcvClean();326 return cvl;327 }328 329 lists pcvCV2P(lists cvl,int d0,int d1)330 {331 lists pl=(lists)Alloc(sizeof(slists));332 pl->Init(cvl->nr+1);333 pcvInit(d1);334 for(int i=cvl->nr;i>=0;i--)335 {336 if(cvl->m[i].rtyp==VECTOR_CMD)337 {338 pl->m[i].rtyp=POLY_CMD;339 pl->m[i].data=pcvCV2P((poly)cvl->m[i].data,d0,d1);340 }341 }342 pcvClean();343 return pl;344 }345 346 int pcvDim(int d0,int d1)347 {348 if(d0<0) d0=0;349 if(d1<0) d1=0;350 pcvInit(d1+1);351 int d=pcvIndex[pVariables-1][d1]-pcvIndex[pVariables-1][d0];352 pcvClean();353 return d;354 }355 356 int pcvBasis(lists b,int i,poly m,int d,int n)357 {358 if(n<pVariables)359 {360 for(int k=0,l=d;k<=l;k++,d--)361 {362 pSetExp(m,n,k);363 i=pcvBasis(b,i,m,d,n+1);364 }365 }366 else367 {368 pSetExp(m,n,d);369 pSetm(m);370 b->m[i].rtyp=POLY_CMD;371 b->m[i++].data=pCopy(m);372 }373 return i;374 }375 376 lists pcvBasis(int d0,int d1)377 {378 if(d0<0) d0=0;379 if(d1<0) d1=0;380 lists b=(lists)Alloc(sizeof(slists));381 b->Init(pcvDim(d0,d1));382 poly m=pOne();383 for(int d=d0,i=0;d<d1;d++)384 i=pcvBasis(b,i,m,d,1);385 pDelete1(&m);386 return b;387 }388 389 429 #endif /* !defined(HAVE_DYNAMIC_LOADING) || defined(BUILD_MODULE) */ 390 430 #endif /* HAVE_PCV */ -
Singular/pcv.h
rbb21e3 r4d9dc5 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: pcv.h,v 1.1 0 1998-12-21 10:54:59mschulze Exp $ */4 /* $Id: pcv.h,v 1.11 1999-06-08 09:14:01 mschulze Exp $ */ 5 5 /* 6 6 * ABSTRACT: conversion between polys and coef vectors … … 12 12 int pcvDeg(poly p); 13 13 int pcvMinDeg(poly p); 14 int pcvMinDeg(matrix m); 14 15 int pcvMaxDeg(poly p); 16 int pcvMaxDeg(matrix m); 15 17 BOOLEAN pcvMinDeg(leftv res,leftv h); 16 18 BOOLEAN pcvMaxDeg(leftv res,leftv h);
Note: See TracChangeset
for help on using the changeset viewer.