Changeset 3fbf1f in git
- Timestamp:
- Feb 1, 2001, 4:54:46 PM (23 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- f8a4cbfad6cff1c94cf3ecfacd537154d034f209
- Parents:
- d971225b227656eaffcaef3076c2525f140cc411
- Location:
- Singular
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/units.cc
rd971225 r3fbf1f 2 2 * Computer Algebra System SINGULAR * 3 3 *****************************************/ 4 /* $Id: units.cc,v 1. 2 2001-02-01 15:14:21mschulze Exp $ */4 /* $Id: units.cc,v 1.3 2001-02-01 15:54:45 mschulze Exp $ */ 5 5 /* 6 6 * ABSTRACT: procedures to compute with units … … 37 37 BOOLEAN invunit(leftv res,leftv h) 38 38 { 39 if(h!=NULL )40 { 41 i f(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 } 53 53 res->rtyp=POLY_CMD; 54 res->data=(void*)invunit( pCopy(u),n);54 res->data=(void*)invunit(n,pCopy(u)); 55 55 return FALSE; 56 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(); 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 } 70 65 res->rtyp=MATRIX_CMD; 71 res->data=(void*)invunit( mpCopy(U),n);66 res->data=(void*)invunit(n,mpCopy(U)); 72 67 return FALSE; 73 68 } 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 75 poly pjet(int n,poly p) 81 76 { 82 77 poly p0=pJet(p,n); … … 85 80 } 86 81 87 poly invunit( poly u, int n)82 poly invunit(int n,poly u) 88 83 { 89 84 if(n<0) … … 94 89 if(n==0) 95 90 return v; 96 poly u1=pjet( pSub(pOne(),pMult_nn(u,u0)),n);91 poly u1=pjet(n,pSub(pOne(),pMult_nn(u,u0))); 97 92 if(u1==NULL) 98 93 return v; … … 101 96 for(int i=n/pTotaldegree(u1);i>1;i--) 102 97 { 103 v1=pjet( pMult(v1,pCopy(u1)),n);98 v1=pjet(n,pMult(v1,pCopy(u1))); 104 99 v=pAdd(v,pCopy(v1)); 105 100 } … … 109 104 } 110 105 111 matrix invunit( matrix U,int n)106 matrix invunit(int n,matrix U) 112 107 { 113 108 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)); 115 110 return U; 116 111 } … … 118 113 BOOLEAN series(leftv res,leftv h) 119 114 { 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(); 135 125 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(); 163 149 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 180 poly series(int n,poly p,poly u=NULL) 179 181 { 180 182 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))); 182 187 return p; 183 188 } 184 189 185 ideal series(i deal M,matrix U,int n)190 ideal series(int n,ideal M,matrix U=NULL) 186 191 { 187 192 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); 190 202 return M; 191 203 } … … 255 267 } 256 268 } 257 WerrorS("<ideal>,[<ideal> |<poly>][,<matrix>] expected");269 WerrorS("<ideal>,[<ideal>[,<matrix>]|<poly>[,<poly>]] expected"); 258 270 return TRUE; 259 271 } -
Singular/units.h
rd971225 r3fbf1f 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: units.h,v 1. 2 2001-02-01 15:14:21mschulze Exp $ */4 /* $Id: units.h,v 1.3 2001-02-01 15:54:46 mschulze Exp $ */ 5 5 /* 6 6 * ABSTRACT: procedures to compute with units … … 11 11 12 12 BOOLEAN invunit(leftv res,leftv h); 13 poly invunit( poly u,int n);14 matrix invunit( matrix U,int n);13 poly invunit(int n,poly u); 14 matrix invunit(int n,matrix U); 15 15 BOOLEAN series(leftv res,leftv h); 16 poly series( poly p,poly u,int n);17 ideal series(i deal M,matrix U,int n);16 poly series(int n,poly p,poly u=NULL); 17 ideal series(int n,ideal M,matrix U=NULL); 18 18 BOOLEAN rednf(leftv res,leftv h); 19 19 ideal rednf(ideal N,ideal M,matrix U=NULL);
Note: See TracChangeset
for help on using the changeset viewer.