[0e1846] | 1 | /**************************************** |
---|
| 2 | * Computer Algebra System SINGULAR * |
---|
| 3 | ****************************************/ |
---|
[ba4d53] | 4 | /* $Id: ipassign.cc,v 1.63 2001-02-22 09:40:17 Singular Exp $ */ |
---|
[58bbda] | 5 | |
---|
[0e1846] | 6 | /* |
---|
| 7 | * ABSTRACT: interpreter: |
---|
| 8 | * assignment of expressions and lists to objects or lists |
---|
| 9 | */ |
---|
| 10 | |
---|
| 11 | #include <stdlib.h> |
---|
| 12 | #include <string.h> |
---|
| 13 | #include <ctype.h> |
---|
| 14 | |
---|
| 15 | #include "mod2.h" |
---|
| 16 | #include "tok.h" |
---|
| 17 | #include "ipid.h" |
---|
| 18 | #include "intvec.h" |
---|
[512a2b] | 19 | #include "omalloc.h" |
---|
[0e1846] | 20 | #include "febase.h" |
---|
| 21 | #include "polys.h" |
---|
| 22 | #include "ideals.h" |
---|
| 23 | #include "matpol.h" |
---|
| 24 | #include "kstd1.h" |
---|
| 25 | #include "timer.h" |
---|
| 26 | #include "ring.h" |
---|
| 27 | #include "subexpr.h" |
---|
| 28 | #include "numbers.h" |
---|
| 29 | #include "lists.h" |
---|
| 30 | #include "longalg.h" |
---|
| 31 | #include "stairc.h" |
---|
| 32 | #include "maps.h" |
---|
| 33 | #include "syz.h" |
---|
| 34 | #include "weight.h" |
---|
| 35 | #include "ipconv.h" |
---|
| 36 | #include "attrib.h" |
---|
| 37 | #include "silink.h" |
---|
| 38 | #include "ipshell.h" |
---|
| 39 | |
---|
| 40 | /*=================== proc =================*/ |
---|
| 41 | static BOOLEAN jjECHO(leftv res, leftv a) |
---|
| 42 | { |
---|
| 43 | si_echo=(int)a->Data(); |
---|
| 44 | return FALSE; |
---|
| 45 | } |
---|
| 46 | static BOOLEAN jjPAGELENGTH(leftv res, leftv a) |
---|
| 47 | { |
---|
| 48 | pagelength=(int)a->Data(); |
---|
| 49 | return FALSE; |
---|
| 50 | } |
---|
| 51 | static BOOLEAN jjPRINTLEVEL(leftv res, leftv a) |
---|
| 52 | { |
---|
| 53 | printlevel=(int)a->Data(); |
---|
| 54 | return FALSE; |
---|
| 55 | } |
---|
| 56 | static BOOLEAN jjCOLMAX(leftv res, leftv a) |
---|
| 57 | { |
---|
| 58 | colmax=(int)a->Data(); |
---|
| 59 | return FALSE; |
---|
| 60 | } |
---|
| 61 | static BOOLEAN jjTIMER(leftv res, leftv a) |
---|
| 62 | { |
---|
| 63 | timerv=(int)a->Data(); |
---|
| 64 | initTimer(); |
---|
| 65 | return FALSE; |
---|
| 66 | } |
---|
[34ab5de] | 67 | #ifdef HAVE_RTIMER |
---|
| 68 | static BOOLEAN jjRTIMER(leftv res, leftv a) |
---|
| 69 | { |
---|
| 70 | rtimerv=(int)a->Data(); |
---|
| 71 | initRTimer(); |
---|
| 72 | return FALSE; |
---|
| 73 | } |
---|
| 74 | #endif |
---|
[0e1846] | 75 | static BOOLEAN jjMAXDEG(leftv res, leftv a) |
---|
| 76 | { |
---|
| 77 | Kstd1_deg=(int)a->Data(); |
---|
| 78 | if (Kstd1_deg!=0) |
---|
| 79 | test |=Sy_bit(24); |
---|
| 80 | else |
---|
| 81 | test &=(~Sy_bit(24)); |
---|
| 82 | return FALSE; |
---|
| 83 | } |
---|
| 84 | static BOOLEAN jjMAXMULT(leftv res, leftv a) |
---|
| 85 | { |
---|
| 86 | Kstd1_mu=(int)a->Data(); |
---|
| 87 | if (Kstd1_mu!=0) |
---|
| 88 | test |=Sy_bit(23); |
---|
| 89 | else |
---|
| 90 | test &=(~Sy_bit(23)); |
---|
| 91 | return FALSE; |
---|
| 92 | } |
---|
| 93 | static BOOLEAN jjTRACE(leftv res, leftv a) |
---|
| 94 | { |
---|
| 95 | traceit=(int)a->Data(); |
---|
| 96 | return FALSE; |
---|
| 97 | } |
---|
| 98 | static BOOLEAN jjSHORTOUT(leftv res, leftv a) |
---|
| 99 | { |
---|
[c5f4b9] | 100 | if (currRing != NULL) |
---|
| 101 | { |
---|
| 102 | BOOLEAN shortOut = (BOOLEAN)a->Data(); |
---|
| 103 | #if HAVE_CAN_SHORT_OUT |
---|
| 104 | if (!shortOut) |
---|
| 105 | currRing->ShortOut = 0; |
---|
| 106 | else |
---|
| 107 | { |
---|
| 108 | if (currRing->CanShortOut) |
---|
| 109 | currRing->ShortOut = 1; |
---|
| 110 | } |
---|
| 111 | #else |
---|
| 112 | currRing->ShortOut = shortOut; |
---|
[0e1846] | 113 | #endif |
---|
[c5f4b9] | 114 | } |
---|
[0e1846] | 115 | return FALSE; |
---|
| 116 | } |
---|
| 117 | static BOOLEAN jjMINPOLY(leftv res, leftv a) |
---|
| 118 | { |
---|
[7acd5f] | 119 | number p=(number)a->CopyD(NUMBER_CMD); |
---|
| 120 | if (nIsZero(p)) |
---|
[0e1846] | 121 | { |
---|
[7acd5f] | 122 | currRing->minpoly=NULL; |
---|
| 123 | naMinimalPoly=NULL; |
---|
[0e1846] | 124 | } |
---|
[7acd5f] | 125 | else |
---|
[0e1846] | 126 | { |
---|
[7acd5f] | 127 | if ((rPar(currRing)!=1) |
---|
| 128 | || (rField_is_GF())) |
---|
| 129 | { |
---|
| 130 | WerrorS("no minpoly allowed"); |
---|
| 131 | return TRUE; |
---|
| 132 | } |
---|
| 133 | if (currRing->minpoly!=NULL) |
---|
| 134 | { |
---|
| 135 | WerrorS("minpoly already set"); |
---|
| 136 | return TRUE; |
---|
| 137 | } |
---|
[0e1846] | 138 | nNormalize(p); |
---|
| 139 | currRing->minpoly=p; |
---|
| 140 | naMinimalPoly=((lnumber)currRing->minpoly)->z; |
---|
| 141 | } |
---|
| 142 | return FALSE; |
---|
| 143 | } |
---|
| 144 | static BOOLEAN jjNOETHER(leftv res, leftv a) |
---|
| 145 | { |
---|
| 146 | poly p=(poly)a->CopyD(POLY_CMD); |
---|
| 147 | pDelete(&ppNoether); |
---|
| 148 | ppNoether=p; |
---|
| 149 | return FALSE; |
---|
| 150 | } |
---|
| 151 | /*=================== proc =================*/ |
---|
| 152 | static void jiAssignAttr(leftv l,leftv r) |
---|
| 153 | { |
---|
| 154 | // get the attribute of th right side |
---|
| 155 | // and set it to l |
---|
| 156 | leftv rv=r->LData(); |
---|
| 157 | if (rv!=NULL) |
---|
| 158 | { |
---|
| 159 | if (rv->e==NULL) |
---|
| 160 | { |
---|
| 161 | if (rv->attribute!=NULL) |
---|
| 162 | { |
---|
| 163 | attr la; |
---|
| 164 | if (r->rtyp!=IDHDL) |
---|
| 165 | { |
---|
| 166 | la=rv->attribute; |
---|
| 167 | rv->attribute=NULL; |
---|
| 168 | } |
---|
| 169 | else |
---|
| 170 | { |
---|
| 171 | la=rv->attribute->Copy(); |
---|
| 172 | } |
---|
| 173 | l->attribute=la; |
---|
| 174 | } |
---|
| 175 | l->flag=rv->flag; |
---|
| 176 | } |
---|
| 177 | } |
---|
| 178 | if (l->rtyp==IDHDL) |
---|
| 179 | { |
---|
| 180 | idhdl h=(idhdl)l->data; |
---|
| 181 | IDATTR(h)=l->attribute; |
---|
| 182 | IDFLAG(h)=l->flag; |
---|
| 183 | } |
---|
| 184 | } |
---|
| 185 | static BOOLEAN jiA_INT(leftv res, leftv a, Subexpr e) |
---|
| 186 | { |
---|
| 187 | if (e==NULL) |
---|
| 188 | { |
---|
| 189 | res->data=(void *)a->Data(); |
---|
| 190 | jiAssignAttr(res,a); |
---|
| 191 | } |
---|
| 192 | else |
---|
| 193 | { |
---|
| 194 | int i=e->start-1; |
---|
| 195 | if (i<0) |
---|
| 196 | { |
---|
| 197 | Werror("index[%d] must be positive",i+1); |
---|
| 198 | return TRUE; |
---|
| 199 | } |
---|
| 200 | intvec *iv=(intvec *)res->data; |
---|
| 201 | if (e->next==NULL) |
---|
| 202 | { |
---|
| 203 | if (i>=iv->length()) |
---|
| 204 | { |
---|
[c232af] | 205 | intvec *iv1=new intvec(i+1); |
---|
[0e1846] | 206 | (*iv1)[i]=(int)a->Data(); |
---|
| 207 | intvec *ivn=ivAdd(iv,iv1); |
---|
| 208 | delete iv; |
---|
| 209 | delete iv1; |
---|
| 210 | res->data=(void *)ivn; |
---|
| 211 | } |
---|
| 212 | else |
---|
| 213 | (*iv)[i]=(int)a->Data(); |
---|
| 214 | } |
---|
| 215 | else |
---|
| 216 | { |
---|
| 217 | int c=e->next->start; |
---|
| 218 | if ((i>=iv->rows())||(c<1)||(c>iv->cols())) |
---|
| 219 | { |
---|
| 220 | Werror("wrong range [%d,%d] in intmat (%d,%d)",i+1,c,iv->rows(),iv->cols()); |
---|
| 221 | return TRUE; |
---|
| 222 | } |
---|
| 223 | else |
---|
| 224 | IMATELEM(*iv,i+1,c) = (int)a->Data(); |
---|
| 225 | } |
---|
| 226 | } |
---|
| 227 | return FALSE; |
---|
| 228 | } |
---|
| 229 | static BOOLEAN jiA_NUMBER(leftv res, leftv a, Subexpr e) |
---|
| 230 | { |
---|
| 231 | number p=(number)a->CopyD(NUMBER_CMD); |
---|
| 232 | if (res->data!=NULL) nDelete((number *)&res->data); |
---|
| 233 | nNormalize(p); |
---|
| 234 | res->data=(void *)p; |
---|
| 235 | jiAssignAttr(res,a); |
---|
| 236 | return FALSE; |
---|
| 237 | } |
---|
[fca547] | 238 | static BOOLEAN jiA_LIST_RES(leftv res, leftv a,Subexpr e) |
---|
| 239 | { |
---|
[2166ad3] | 240 | syStrategy r=(syStrategy)a->CopyD(RESOLUTION_CMD); |
---|
[fca547] | 241 | if (res->data!=NULL) ((lists)res->data)->Clean(); |
---|
[c89df6] | 242 | res->data=(void *)syConvRes(r,TRUE); |
---|
[fca547] | 243 | //jiAssignAttr(res,a); |
---|
| 244 | return FALSE; |
---|
| 245 | } |
---|
[0e1846] | 246 | static BOOLEAN jiA_LIST(leftv res, leftv a,Subexpr e) |
---|
| 247 | { |
---|
[2166ad3] | 248 | lists l=(lists)a->CopyD(LIST_CMD); |
---|
[0e1846] | 249 | if (res->data!=NULL) ((lists)res->data)->Clean(); |
---|
| 250 | res->data=(void *)l; |
---|
| 251 | jiAssignAttr(res,a); |
---|
| 252 | return FALSE; |
---|
| 253 | } |
---|
| 254 | static BOOLEAN jiA_POLY(leftv res, leftv a,Subexpr e) |
---|
| 255 | { |
---|
| 256 | poly p=(poly)a->CopyD(POLY_CMD); |
---|
| 257 | pNormalize(p); |
---|
| 258 | if (e==NULL) |
---|
| 259 | { |
---|
| 260 | if (res->data!=NULL) pDelete((poly*)&res->data); |
---|
| 261 | res->data=(void*)p; |
---|
| 262 | jiAssignAttr(res,a); |
---|
| 263 | } |
---|
| 264 | else |
---|
| 265 | { |
---|
| 266 | int i,j; |
---|
| 267 | matrix m=(matrix)res->data; |
---|
| 268 | i=e->start; |
---|
| 269 | if (e->next==NULL) |
---|
| 270 | { |
---|
| 271 | j=i; i=1; |
---|
[ea476c] | 272 | // for all ideal like data types: check indices |
---|
| 273 | if (j>MATCOLS(m)) |
---|
[0e1846] | 274 | { |
---|
[ea476c] | 275 | pEnlargeSet(&(m->m),MATCOLS(m),j-MATCOLS(m)); |
---|
| 276 | MATCOLS(m)=j; |
---|
| 277 | } |
---|
| 278 | else if (j<=0) |
---|
| 279 | { |
---|
| 280 | Werror("index[%d] must be positive",j/*e->start*/); |
---|
| 281 | return TRUE; |
---|
[58bbda] | 282 | } |
---|
[0e1846] | 283 | } |
---|
| 284 | else |
---|
| 285 | { |
---|
| 286 | // for matrices: indices are correct (see ipExprArith3(..,'['..) ) |
---|
| 287 | j=e->next->start; |
---|
| 288 | } |
---|
| 289 | pDelete(&MATELEM(m,i,j)); |
---|
| 290 | MATELEM(m,i,j)=p; |
---|
| 291 | /* for module: update rank */ |
---|
| 292 | if ((p!=NULL) && (pGetComp(p)!=0)) |
---|
| 293 | { |
---|
| 294 | m->rank=max(m->rank,pMaxComp(p)); |
---|
| 295 | } |
---|
| 296 | } |
---|
| 297 | return FALSE; |
---|
| 298 | } |
---|
| 299 | static BOOLEAN jiA_1x1MATRIX(leftv res, leftv a,Subexpr e) |
---|
| 300 | { |
---|
| 301 | if ((res->rtyp!=MATRIX_CMD) /*|| (e!=NULL) - TRUE because of type poly */) |
---|
| 302 | return TRUE; |
---|
| 303 | matrix am=(matrix)a->CopyD(MATRIX_CMD); |
---|
| 304 | if ((MATROWS(am)!=1) || (MATCOLS(am)!=1)) |
---|
| 305 | { |
---|
| 306 | idDelete((ideal *)&am); |
---|
| 307 | return TRUE; |
---|
| 308 | } |
---|
| 309 | matrix m=(matrix)res->data; |
---|
| 310 | // indices are correct (see ipExprArith3(..,'['..) ) |
---|
| 311 | int i=e->start; |
---|
| 312 | int j=e->next->start; |
---|
| 313 | pDelete(&MATELEM(m,i,j)); |
---|
| 314 | pNormalize(MATELEM(am,1,1)); |
---|
| 315 | MATELEM(m,i,j)=MATELEM(am,1,1); |
---|
[805b06c] | 316 | MATELEM(am,1,1)=NULL; |
---|
| 317 | idDelete((ideal *)&am); |
---|
[0e1846] | 318 | return FALSE; |
---|
| 319 | } |
---|
| 320 | static BOOLEAN jiA_STRING(leftv res, leftv a, Subexpr e) |
---|
| 321 | { |
---|
| 322 | if (e==NULL) |
---|
| 323 | { |
---|
[c232af] | 324 | void* tmp = res->data; |
---|
[0e1846] | 325 | res->data=(void *)a->CopyD(STRING_CMD); |
---|
| 326 | jiAssignAttr(res,a); |
---|
[c232af] | 327 | omfree(tmp); |
---|
[0e1846] | 328 | } |
---|
| 329 | else |
---|
| 330 | { |
---|
| 331 | char *s=(char *)res->data; |
---|
| 332 | if ((e->start>0)&&(e->start<=(int)strlen(s))) |
---|
| 333 | s[e->start-1]=(char)(*((char *)a->Data())); |
---|
| 334 | else |
---|
| 335 | { |
---|
| 336 | Werror("string index %d out of range 1..%d",e->start,strlen(s)); |
---|
| 337 | return TRUE; |
---|
| 338 | } |
---|
| 339 | } |
---|
| 340 | return FALSE; |
---|
| 341 | } |
---|
[2ba9a6] | 342 | static BOOLEAN jiA_PROC(leftv res, leftv a, Subexpr e) |
---|
| 343 | { |
---|
| 344 | extern procinfo *iiInitSingularProcinfo(procinfo *pi, char *libname, |
---|
[b7f9da] | 345 | char *procname, int line, |
---|
| 346 | long pos, BOOLEAN pstatic=FALSE); |
---|
[2ba9a6] | 347 | extern void piCleanUp(procinfov pi); |
---|
| 348 | |
---|
| 349 | if(res->data!=NULL) piCleanUp((procinfo *)res->data); |
---|
[3a20c1] | 350 | if(a->rtyp==STRING_CMD) |
---|
| 351 | { |
---|
[c232af] | 352 | res->data = (void *)omAlloc0Bin(procinfo_bin); |
---|
[2ba9a6] | 353 | ((procinfo *)(res->data))->language=LANG_NONE; |
---|
| 354 | iiInitSingularProcinfo((procinfo *)res->data,"",res->name,0,0); |
---|
[ca7a56] | 355 | ((procinfo *)res->data)->data.s.body=(char *)a->CopyD(STRING_CMD); |
---|
[2ba9a6] | 356 | } |
---|
| 357 | else |
---|
| 358 | res->data=(void *)a->CopyD(PROC_CMD); |
---|
| 359 | jiAssignAttr(res,a); |
---|
| 360 | return FALSE; |
---|
| 361 | } |
---|
[0e1846] | 362 | static BOOLEAN jiA_INTVEC(leftv res, leftv a, Subexpr e) |
---|
| 363 | { |
---|
| 364 | if (res->data!=NULL) delete ((intvec *)res->data); |
---|
| 365 | res->data=(void *)a->CopyD(INTVEC_CMD); |
---|
| 366 | jiAssignAttr(res,a); |
---|
| 367 | return FALSE; |
---|
| 368 | } |
---|
| 369 | static BOOLEAN jiA_IDEAL(leftv res, leftv a, Subexpr e) |
---|
| 370 | { |
---|
| 371 | if (res->data!=NULL) idDelete((ideal*)&res->data); |
---|
| 372 | res->data=(void *)a->CopyD(MATRIX_CMD); |
---|
[ba4d53] | 373 | idNormalize((ideal)res->data); |
---|
[0e1846] | 374 | jiAssignAttr(res,a); |
---|
| 375 | return FALSE; |
---|
| 376 | } |
---|
[dfc6b54] | 377 | static BOOLEAN jiA_RESOLUTION(leftv res, leftv a, Subexpr e) |
---|
| 378 | { |
---|
| 379 | if (res->data!=NULL) syKillComputation((syStrategy)res->data); |
---|
| 380 | res->data=(void *)a->CopyD(RESOLUTION_CMD); |
---|
| 381 | jiAssignAttr(res,a); |
---|
| 382 | return FALSE; |
---|
| 383 | } |
---|
[32df82] | 384 | static BOOLEAN jiA_MODUL_P(leftv res, leftv a, Subexpr e) |
---|
| 385 | { |
---|
| 386 | if (res->data!=NULL) idDelete((ideal*)&res->data); |
---|
| 387 | ideal I=idInit(1,1); |
---|
[2166ad3] | 388 | I->m[0]=(poly)a->CopyD(POLY_CMD); |
---|
[d5af67] | 389 | if (I->m[0]!=NULL) pSetCompP(I->m[0],1); |
---|
[ba4d53] | 390 | pNormalize(I->m[0]); |
---|
[32df82] | 391 | res->data=(void *)I; |
---|
| 392 | return FALSE; |
---|
| 393 | } |
---|
[0e1846] | 394 | static BOOLEAN jiA_IDEAL_M(leftv res, leftv a, Subexpr e) |
---|
| 395 | { |
---|
| 396 | if (res->data!=NULL) idDelete((ideal*)&res->data); |
---|
| 397 | matrix m=(matrix)a->CopyD(MATRIX_CMD); |
---|
| 398 | IDELEMS((ideal)m)=MATROWS(m)*MATCOLS(m); |
---|
| 399 | ((ideal)m)->rank=1; |
---|
| 400 | MATROWS(m)=1; |
---|
[ba4d53] | 401 | idNormalize((ideal)m); |
---|
[0e1846] | 402 | res->data=(void *)m; |
---|
| 403 | return FALSE; |
---|
| 404 | } |
---|
| 405 | static BOOLEAN jiA_LINK(leftv res, leftv a, Subexpr e) |
---|
| 406 | { |
---|
| 407 | si_link l=(si_link)res->data; |
---|
[d754b7] | 408 | |
---|
[e6969d] | 409 | if (l!=NULL) slCleanUp(l); |
---|
[d754b7] | 410 | |
---|
[0e1846] | 411 | if (a->Typ() == STRING_CMD) |
---|
| 412 | { |
---|
[d754b7] | 413 | if (l == NULL) |
---|
| 414 | { |
---|
[c232af] | 415 | l = (si_link) omAlloc0Bin(sip_link_bin); |
---|
[d754b7] | 416 | res->data = (void *) l; |
---|
| 417 | } |
---|
[0e1846] | 418 | return slInit(l, (char *) a->Data()); |
---|
| 419 | } |
---|
[d754b7] | 420 | else if (a->Typ() == LINK_CMD) |
---|
| 421 | { |
---|
[c232af] | 422 | if (l != NULL) omFreeBin(l, sip_link_bin); |
---|
[d754b7] | 423 | res->data = slCopy((si_link)a->Data()); |
---|
| 424 | return FALSE; |
---|
| 425 | } |
---|
[0e1846] | 426 | return TRUE; |
---|
| 427 | } |
---|
[2166ad3] | 428 | // assign map -> map |
---|
[0e1846] | 429 | static BOOLEAN jiA_MAP(leftv res, leftv a, Subexpr e) |
---|
| 430 | { |
---|
| 431 | if (res->data!=NULL) |
---|
| 432 | { |
---|
[c232af] | 433 | omFree((ADDRESS)((map)res->data)->preimage); |
---|
[0e1846] | 434 | ((map)res->data)->preimage=NULL; |
---|
| 435 | idDelete((ideal*)&res->data); |
---|
| 436 | } |
---|
[2166ad3] | 437 | res->data=(void *)a->CopyD(MAP_CMD); |
---|
[0e1846] | 438 | jiAssignAttr(res,a); |
---|
| 439 | return FALSE; |
---|
| 440 | } |
---|
[2166ad3] | 441 | // assign ideal -> map |
---|
[0e1846] | 442 | static BOOLEAN jiA_MAP_ID(leftv res, leftv a, Subexpr e) |
---|
| 443 | { |
---|
| 444 | map f=(map)res->data; |
---|
| 445 | char *rn=f->preimage; // save the old/already assigned preimage ring name |
---|
| 446 | f->preimage=NULL; |
---|
| 447 | idDelete((ideal *)&f); |
---|
| 448 | res->data=(void *)a->CopyD(IDEAL_CMD); |
---|
| 449 | f=(map)res->data; |
---|
[ba4d53] | 450 | idNormalize((ideal)f); |
---|
[0e1846] | 451 | f->preimage = rn; |
---|
| 452 | return FALSE; |
---|
| 453 | } |
---|
| 454 | static BOOLEAN jiA_QRING(leftv res, leftv a,Subexpr e) |
---|
| 455 | { |
---|
[499bdc] | 456 | // the follwing can only happen, if: |
---|
| 457 | // - the left side is of type qring AND not an id |
---|
[0e1846] | 458 | if ((e!=NULL)||(res->rtyp!=IDHDL)) |
---|
| 459 | { |
---|
| 460 | WerrorS("qring_id expected"); |
---|
| 461 | return TRUE; |
---|
| 462 | } |
---|
| 463 | ring qr; |
---|
| 464 | int i,j; |
---|
| 465 | int *pi; |
---|
| 466 | |
---|
| 467 | assumeStdFlag(a); |
---|
| 468 | qr=(ring)res->Data(); |
---|
| 469 | ring qrr=rCopy(currRing); |
---|
| 470 | memcpy4(qr,qrr,sizeof(ip_sring)); |
---|
[c232af] | 471 | omFreeBin((ADDRESS)qrr, ip_sring_bin); |
---|
[0e1846] | 472 | if (qr->qideal!=NULL) idDelete(&qr->qideal); |
---|
| 473 | qr->qideal = (ideal)a->CopyD(IDEAL_CMD); |
---|
[4ad0d6] | 474 | //currRing=qr; |
---|
| 475 | //currRingHdl=(idhdl)res->data; |
---|
| 476 | //currQuotient=qr->qideal; |
---|
[cf42ab1] | 477 | rSetHdl((idhdl)res->data); |
---|
[0e1846] | 478 | return FALSE; |
---|
| 479 | } |
---|
| 480 | static BOOLEAN jiA_RING(leftv res, leftv a, Subexpr e) |
---|
| 481 | { |
---|
[b8fdd5] | 482 | BOOLEAN have_id=TRUE; |
---|
[0e1846] | 483 | if ((e!=NULL)||(res->rtyp!=IDHDL)) |
---|
| 484 | { |
---|
[b8fdd5] | 485 | //WerrorS("id expected"); |
---|
| 486 | //return TRUE; |
---|
| 487 | have_id=FALSE; |
---|
[0e1846] | 488 | } |
---|
| 489 | ring r=(ring)a->Data(); |
---|
[b8fdd5] | 490 | if (have_id) |
---|
| 491 | { |
---|
| 492 | idhdl rl=(idhdl)res->data; |
---|
| 493 | if (&IDRING(rl)!=NULL) rKill(rl); |
---|
| 494 | IDRING(rl)=r; |
---|
| 495 | if ((IDLEV((idhdl)a->data)!=myynest) && (r==currRing)) |
---|
| 496 | currRingHdl=(idhdl)res->data; |
---|
| 497 | } |
---|
| 498 | else |
---|
| 499 | { |
---|
| 500 | if (e==NULL) res->data=(char *)r; |
---|
| 501 | else |
---|
| 502 | { |
---|
| 503 | WerrorS("id expected"); |
---|
| 504 | return TRUE; |
---|
| 505 | } |
---|
| 506 | } |
---|
[0e1846] | 507 | r->ref++; |
---|
| 508 | return FALSE; |
---|
| 509 | } |
---|
[0a3ddd] | 510 | static BOOLEAN jiA_PACKAGE(leftv res, leftv a, Subexpr e) |
---|
| 511 | { |
---|
[daeb6d] | 512 | res->data=(void *)a->CopyD(PACKAGE_CMD); |
---|
| 513 | jiAssignAttr(res,a); |
---|
[0a3ddd] | 514 | return FALSE; |
---|
| 515 | } |
---|
[0e1846] | 516 | /*=================== table =================*/ |
---|
| 517 | struct sValAssign dAssign[]= |
---|
| 518 | { |
---|
| 519 | // proc res arg |
---|
| 520 | {jiA_IDEAL, IDEAL_CMD, IDEAL_CMD } |
---|
| 521 | ,{jiA_IDEAL_M, IDEAL_CMD, MATRIX_CMD } |
---|
[de47d79] | 522 | ,{jiA_RESOLUTION,RESOLUTION_CMD,RESOLUTION_CMD } |
---|
[0e1846] | 523 | ,{jiA_INT, INT_CMD, INT_CMD } |
---|
| 524 | ,{jiA_IDEAL, MATRIX_CMD, MATRIX_CMD } |
---|
| 525 | ,{jiA_MAP_ID, MAP_CMD, IDEAL_CMD } |
---|
| 526 | ,{jiA_MAP, MAP_CMD, MAP_CMD } |
---|
| 527 | ,{jiA_IDEAL, MODUL_CMD, MODUL_CMD } |
---|
[32df82] | 528 | ,{jiA_MODUL_P, MODUL_CMD, POLY_CMD } |
---|
[0e1846] | 529 | ,{jiA_POLY, POLY_CMD, POLY_CMD } |
---|
| 530 | ,{jiA_1x1MATRIX,POLY_CMD, MATRIX_CMD } |
---|
| 531 | ,{jiA_QRING, QRING_CMD, IDEAL_CMD } |
---|
| 532 | ,{jiA_RING, RING_CMD, RING_CMD } |
---|
| 533 | ,{jiA_RING, QRING_CMD, QRING_CMD } |
---|
| 534 | ,{jiA_STRING, STRING_CMD, STRING_CMD } |
---|
[2ba9a6] | 535 | ,{jiA_PROC, PROC_CMD, STRING_CMD } |
---|
| 536 | ,{jiA_PROC, PROC_CMD, PROC_CMD } |
---|
[0e1846] | 537 | ,{jiA_POLY, VECTOR_CMD, VECTOR_CMD } |
---|
| 538 | ,{jiA_INTVEC, INTVEC_CMD, INTVEC_CMD } |
---|
| 539 | ,{jiA_INTVEC, INTMAT_CMD, INTMAT_CMD } |
---|
| 540 | ,{jiA_NUMBER, NUMBER_CMD, NUMBER_CMD } |
---|
[fca547] | 541 | ,{jiA_LIST_RES, LIST_CMD, RESOLUTION_CMD } |
---|
[0e1846] | 542 | ,{jiA_LIST, LIST_CMD, LIST_CMD } |
---|
| 543 | ,{jiA_LINK, LINK_CMD, STRING_CMD } |
---|
[d754b7] | 544 | ,{jiA_LINK, LINK_CMD, LINK_CMD } |
---|
[0a3ddd] | 545 | ,{jiA_PACKAGE, PACKAGE_CMD, PACKAGE_CMD } |
---|
[0e1846] | 546 | ,{NULL, 0, 0 } |
---|
| 547 | }; |
---|
| 548 | struct sValAssign_sys dAssign_sys[]= |
---|
| 549 | { |
---|
| 550 | // sysvars: |
---|
| 551 | {jjECHO, VECHO, INT_CMD } |
---|
| 552 | ,{jjPAGELENGTH, VPAGELENGTH, INT_CMD } |
---|
| 553 | ,{jjPRINTLEVEL, VPRINTLEVEL, INT_CMD } |
---|
| 554 | ,{jjCOLMAX, VCOLMAX, INT_CMD } |
---|
| 555 | ,{jjTIMER, VTIMER, INT_CMD } |
---|
[34ab5de] | 556 | #ifdef HAVE_RTIMER |
---|
| 557 | ,{jjRTIMER, VRTIMER, INT_CMD } |
---|
[58bbda] | 558 | #endif |
---|
[0e1846] | 559 | ,{jjMAXDEG, VMAXDEG, INT_CMD } |
---|
| 560 | ,{jjMAXMULT, VMAXMULT, INT_CMD } |
---|
| 561 | ,{jjTRACE, TRACE, INT_CMD } |
---|
| 562 | ,{jjSHORTOUT, VSHORTOUT, INT_CMD } |
---|
| 563 | ,{jjMINPOLY, VMINPOLY, NUMBER_CMD } |
---|
| 564 | ,{jjNOETHER, VNOETHER, POLY_CMD } |
---|
| 565 | ,{NULL, 0, 0 } |
---|
| 566 | }; |
---|
| 567 | /*=================== operations ============================*/ |
---|
| 568 | /*2 |
---|
[58bbda] | 569 | * assign a = b |
---|
[0e1846] | 570 | */ |
---|
| 571 | static BOOLEAN jiAssign_1(leftv l, leftv r) |
---|
| 572 | { |
---|
| 573 | int rt=r->Typ(); |
---|
| 574 | if (rt==0) |
---|
| 575 | { |
---|
[0a3ddd] | 576 | if (!errorreported) Werror("`%s` is undefined",r->Fullname()); |
---|
[0e1846] | 577 | return TRUE; |
---|
| 578 | } |
---|
[58bbda] | 579 | |
---|
[0e1846] | 580 | int lt=l->Typ(); |
---|
[57eacd] | 581 | if((lt==0)/*&&(l->name!=NULL)*/) |
---|
[0e1846] | 582 | { |
---|
[0a3ddd] | 583 | if (!errorreported) Werror("left side `%s` is undefined",l->Fullname()); |
---|
[0e1846] | 584 | return TRUE; |
---|
| 585 | } |
---|
[6ae4f5] | 586 | if((rt==DEF_CMD)||(rt==NONE)) |
---|
| 587 | { |
---|
[3838a9] | 588 | WarnS("right side is not a datum, assignment ignored"); |
---|
| 589 | // if (!errorreported) |
---|
| 590 | // WerrorS("right side is not a datum"); |
---|
| 591 | //return TRUE; |
---|
| 592 | return FALSE; |
---|
[6ae4f5] | 593 | } |
---|
[58bbda] | 594 | |
---|
[0e1846] | 595 | int i=0; |
---|
| 596 | BOOLEAN nok=FALSE; |
---|
| 597 | |
---|
| 598 | if (lt==DEF_CMD) |
---|
| 599 | { |
---|
| 600 | if (l->rtyp==IDHDL) |
---|
| 601 | { |
---|
| 602 | IDTYP((idhdl)l->data)=rt; |
---|
| 603 | } |
---|
| 604 | else if (l->name!=NULL) |
---|
| 605 | { |
---|
| 606 | sleftv ll; |
---|
[46d09b] | 607 | iiDeclCommand(&ll,l,myynest,rt,&IDROOT); |
---|
[0e1846] | 608 | memcpy(l,&ll,sizeof(sleftv)); |
---|
| 609 | } |
---|
| 610 | else |
---|
| 611 | { |
---|
| 612 | l->rtyp=rt; |
---|
| 613 | } |
---|
| 614 | lt=rt; |
---|
| 615 | } |
---|
| 616 | else |
---|
| 617 | { |
---|
| 618 | if ((l->data==r->data)&&(l->e==NULL)&&(r->e==NULL)) |
---|
| 619 | return FALSE; |
---|
[58bbda] | 620 | } |
---|
| 621 | leftv ld=l; |
---|
| 622 | if ((l->rtyp==IDHDL)&&(lt!=QRING_CMD)&&(lt!=RING_CMD)) |
---|
| 623 | ld=(leftv)l->data; |
---|
[0e1846] | 624 | while (((dAssign[i].res!=lt) |
---|
| 625 | || (dAssign[i].arg!=rt)) |
---|
| 626 | && (dAssign[i].res!=0)) i++; |
---|
| 627 | if (dAssign[i].res!=0) |
---|
| 628 | { |
---|
| 629 | BOOLEAN b; |
---|
| 630 | b=dAssign[i].p(ld,r,l->e); |
---|
[58bbda] | 631 | if(l!=ld) /* i.e. l is IDHDL, l->data is ld */ |
---|
| 632 | { |
---|
| 633 | l->flag=ld->flag; |
---|
| 634 | l->attribute=ld->attribute; |
---|
| 635 | } |
---|
[0e1846] | 636 | return b; |
---|
| 637 | } |
---|
| 638 | // implicite type conversion ---------------------------------------------- |
---|
| 639 | if (dAssign[i].res==0) |
---|
| 640 | { |
---|
| 641 | int ri; |
---|
[c232af] | 642 | leftv rn = (leftv)omAlloc0Bin(sleftv_bin); |
---|
[0e1846] | 643 | BOOLEAN failed=FALSE; |
---|
| 644 | i=0; |
---|
| 645 | while ((dAssign[i].res!=lt) |
---|
| 646 | && (dAssign[i].res!=0)) i++; |
---|
| 647 | while (dAssign[i].res==lt) |
---|
| 648 | { |
---|
| 649 | if ((ri=iiTestConvert(rt,dAssign[i].arg))!=0) |
---|
| 650 | { |
---|
| 651 | failed= iiConvert(rt,dAssign[i].arg,ri,r,rn); |
---|
| 652 | if(!failed) |
---|
| 653 | { |
---|
[58bbda] | 654 | failed= dAssign[i].p(ld,rn,l->e); |
---|
| 655 | } |
---|
[0e1846] | 656 | // everything done, clean up temp. variables |
---|
| 657 | rn->CleanUp(); |
---|
[c232af] | 658 | omFreeBin((ADDRESS)rn, sleftv_bin); |
---|
[0e1846] | 659 | if (failed) |
---|
| 660 | { |
---|
| 661 | // leave loop, goto error handling |
---|
| 662 | break; |
---|
| 663 | } |
---|
| 664 | else |
---|
| 665 | { |
---|
[58bbda] | 666 | if(l!=ld) /* i.e. l is IDHDL, l->data is ld */ |
---|
| 667 | { |
---|
| 668 | l->flag=ld->flag; |
---|
| 669 | l->attribute=ld->attribute; |
---|
| 670 | } |
---|
[0e1846] | 671 | // everything ok, return |
---|
| 672 | return FALSE; |
---|
| 673 | } |
---|
| 674 | } |
---|
| 675 | i++; |
---|
| 676 | } |
---|
| 677 | // error handling --------------------------------------------------- |
---|
[07dacd] | 678 | if (!errorreported) |
---|
[0e1846] | 679 | { |
---|
[07dacd] | 680 | Werror("`%s` = `%s` is not supported" |
---|
| 681 | ,Tok2Cmdname(lt),Tok2Cmdname(rt)); |
---|
| 682 | if (BVERBOSE(V_SHOW_USE)) |
---|
[0e1846] | 683 | { |
---|
[07dacd] | 684 | i=0; |
---|
| 685 | while ((dAssign[i].res!=lt) |
---|
| 686 | && (dAssign[i].res!=0)) i++; |
---|
| 687 | while (dAssign[i].res==lt) |
---|
| 688 | { |
---|
| 689 | Werror("expected `%s` = `%s`" |
---|
| 690 | ,Tok2Cmdname(lt),Tok2Cmdname(dAssign[i].arg)); |
---|
| 691 | i++; |
---|
| 692 | } |
---|
[0e1846] | 693 | } |
---|
| 694 | } |
---|
| 695 | } |
---|
| 696 | return TRUE; |
---|
| 697 | } |
---|
| 698 | /*2 |
---|
| 699 | * assign sys_var = val |
---|
| 700 | */ |
---|
| 701 | static BOOLEAN iiAssign_sys(leftv l, leftv r) |
---|
| 702 | { |
---|
| 703 | int rt=r->Typ(); |
---|
| 704 | |
---|
| 705 | if (rt==0) |
---|
| 706 | { |
---|
[0a3ddd] | 707 | if (!errorreported) Werror("`%s` is undefined",r->Fullname()); |
---|
[0e1846] | 708 | return TRUE; |
---|
| 709 | } |
---|
| 710 | int i=0; |
---|
| 711 | int lt=l->rtyp; |
---|
| 712 | while (((dAssign_sys[i].res!=lt) |
---|
| 713 | || (dAssign_sys[i].arg!=rt)) |
---|
| 714 | && (dAssign_sys[i].res!=0)) i++; |
---|
| 715 | if (dAssign_sys[i].res!=0) |
---|
| 716 | { |
---|
| 717 | if (!dAssign_sys[i].p(l,r)) |
---|
| 718 | { |
---|
| 719 | // everything ok, clean up |
---|
| 720 | return FALSE; |
---|
| 721 | } |
---|
| 722 | } |
---|
| 723 | // implicite type conversion ---------------------------------------------- |
---|
| 724 | if (dAssign_sys[i].res==0) |
---|
| 725 | { |
---|
| 726 | int ri; |
---|
[c232af] | 727 | leftv rn = (leftv)omAlloc0Bin(sleftv_bin); |
---|
[0e1846] | 728 | BOOLEAN failed=FALSE; |
---|
| 729 | i=0; |
---|
| 730 | while ((dAssign_sys[i].res!=lt) |
---|
| 731 | && (dAssign_sys[i].res!=0)) i++; |
---|
| 732 | while (dAssign_sys[i].res==lt) |
---|
| 733 | { |
---|
| 734 | if ((ri=iiTestConvert(rt,dAssign_sys[i].arg))!=0) |
---|
| 735 | { |
---|
| 736 | failed= ((iiConvert(rt,dAssign_sys[i].arg,ri,r,rn)) |
---|
| 737 | || (dAssign_sys[i].p(l,rn))); |
---|
| 738 | // everything done, clean up temp. variables |
---|
| 739 | rn->CleanUp(); |
---|
[c232af] | 740 | omFreeBin((ADDRESS)rn, sleftv_bin); |
---|
[0e1846] | 741 | if (failed) |
---|
| 742 | { |
---|
| 743 | // leave loop, goto error handling |
---|
| 744 | break; |
---|
| 745 | } |
---|
| 746 | else |
---|
| 747 | { |
---|
| 748 | // everything ok, return |
---|
| 749 | return FALSE; |
---|
| 750 | } |
---|
| 751 | } |
---|
| 752 | i++; |
---|
| 753 | } |
---|
| 754 | // error handling --------------------------------------------------- |
---|
[07dacd] | 755 | if(!errorreported) |
---|
[0e1846] | 756 | { |
---|
[07dacd] | 757 | Werror("`%s` = `%s` is not supported" |
---|
| 758 | ,Tok2Cmdname(lt),Tok2Cmdname(rt)); |
---|
| 759 | if (BVERBOSE(V_SHOW_USE)) |
---|
[0e1846] | 760 | { |
---|
[07dacd] | 761 | i=0; |
---|
| 762 | while ((dAssign_sys[i].res!=lt) |
---|
| 763 | && (dAssign_sys[i].res!=0)) i++; |
---|
| 764 | while (dAssign_sys[i].res==lt) |
---|
| 765 | { |
---|
| 766 | Werror("expected `%s` = `%s`" |
---|
| 767 | ,Tok2Cmdname(lt),Tok2Cmdname(dAssign_sys[i].arg)); |
---|
| 768 | i++; |
---|
| 769 | } |
---|
[0e1846] | 770 | } |
---|
| 771 | } |
---|
| 772 | } |
---|
| 773 | return TRUE; |
---|
| 774 | } |
---|
| 775 | static BOOLEAN jiA_INTVEC_L(leftv l,leftv r) |
---|
| 776 | { |
---|
| 777 | /* right side is intvec, left side is list (of int)*/ |
---|
| 778 | BOOLEAN nok; |
---|
| 779 | int i=0; |
---|
| 780 | leftv l1=l; |
---|
| 781 | leftv h; |
---|
| 782 | sleftv t; |
---|
| 783 | intvec *iv=(intvec *)r->Data(); |
---|
| 784 | memset(&t,0,sizeof(sleftv)); |
---|
| 785 | t.rtyp=INT_CMD; |
---|
| 786 | while ((i<iv->length())&&(l!=NULL)) |
---|
| 787 | { |
---|
| 788 | t.data=(char *)(*iv)[i]; |
---|
| 789 | h=l->next; |
---|
| 790 | l->next=NULL; |
---|
| 791 | nok=jiAssign_1(l,&t); |
---|
| 792 | if (nok) return TRUE; |
---|
| 793 | i++; |
---|
| 794 | l=h; |
---|
| 795 | } |
---|
| 796 | l1->CleanUp(); |
---|
| 797 | r->CleanUp(); |
---|
| 798 | return FALSE; |
---|
| 799 | } |
---|
[499bdc] | 800 | static BOOLEAN jiA_VECTOR_L(leftv l,leftv r) |
---|
| 801 | { |
---|
| 802 | /* right side is vector, left side is list (of poly)*/ |
---|
| 803 | BOOLEAN nok; |
---|
| 804 | leftv l1=l; |
---|
| 805 | ideal I=idVec2Ideal((poly)r->Data()); |
---|
| 806 | leftv h; |
---|
| 807 | sleftv t; |
---|
| 808 | int i=0; |
---|
| 809 | while (l!=NULL) |
---|
| 810 | { |
---|
| 811 | memset(&t,0,sizeof(sleftv)); |
---|
| 812 | t.rtyp=POLY_CMD; |
---|
| 813 | if (i>=IDELEMS(I)) |
---|
| 814 | { |
---|
| 815 | t.data=NULL; |
---|
| 816 | } |
---|
| 817 | else |
---|
| 818 | { |
---|
| 819 | t.data=(char *)I->m[i]; |
---|
| 820 | I->m[i]=NULL; |
---|
| 821 | } |
---|
| 822 | h=l->next; |
---|
| 823 | l->next=NULL; |
---|
| 824 | nok=jiAssign_1(l,&t); |
---|
| 825 | t.CleanUp(); |
---|
| 826 | if (nok) |
---|
| 827 | { |
---|
| 828 | idDelete(&I); |
---|
| 829 | return TRUE; |
---|
| 830 | } |
---|
| 831 | i++; |
---|
| 832 | l=h; |
---|
| 833 | } |
---|
| 834 | idDelete(&I); |
---|
| 835 | l1->CleanUp(); |
---|
| 836 | r->CleanUp(); |
---|
| 837 | return FALSE; |
---|
| 838 | } |
---|
[0e1846] | 839 | static BOOLEAN jjA_L_LIST(leftv l, leftv r) |
---|
[14ca45] | 840 | /* left side: list, has to be a "real" variable |
---|
[0e1846] | 841 | * right side: expression list |
---|
| 842 | */ |
---|
| 843 | { |
---|
| 844 | int sl = r->listLength(); |
---|
[c232af] | 845 | lists L=(lists)omAllocBin(slists_bin); |
---|
[0c1144] | 846 | lists oldL; |
---|
[3e41e0] | 847 | leftv h=NULL,o_r=r; |
---|
[0e1846] | 848 | int i; |
---|
| 849 | int rt; |
---|
| 850 | |
---|
| 851 | L->Init(sl); |
---|
| 852 | for (i=0;i<sl;i++) |
---|
| 853 | { |
---|
| 854 | if (h!=NULL) { /* e.g. not in the first step: |
---|
| 855 | * h is the pointer to the old sleftv, |
---|
| 856 | * r is the pointer to the next sleftv |
---|
| 857 | * (in this moment) */ |
---|
| 858 | h->next=r; |
---|
| 859 | } |
---|
| 860 | h=r; |
---|
| 861 | r=r->next; |
---|
| 862 | h->next=NULL; |
---|
| 863 | rt=h->Typ(); |
---|
[24c186a] | 864 | if ((rt==0)||(rt==NONE)||(rt==DEF_CMD)) |
---|
[0e1846] | 865 | { |
---|
| 866 | L->Clean(); |
---|
[0a3ddd] | 867 | Werror("`%s` is undefined",h->Fullname()); |
---|
[14ca45] | 868 | goto err; |
---|
[0e1846] | 869 | } |
---|
[13e2da] | 870 | //if ((rt==RING_CMD)||(rt==QRING_CMD)) |
---|
| 871 | //{ |
---|
| 872 | // L->m[i].rtyp=rt; |
---|
| 873 | // L->m[i].data=h->Data(); |
---|
| 874 | // ((ring)L->m[i].data)->ref++; |
---|
| 875 | //} |
---|
| 876 | //else |
---|
[0e1846] | 877 | L->m[i].Copy(h); |
---|
[14ca45] | 878 | if(errorreported) |
---|
| 879 | { |
---|
| 880 | L->Clean(); |
---|
| 881 | goto err; |
---|
| 882 | } |
---|
[0e1846] | 883 | } |
---|
[0c1144] | 884 | oldL=(lists)l->Data(); oldL->Clean(); |
---|
| 885 | if (l->rtyp==IDHDL) |
---|
[0a3ddd] | 886 | { |
---|
[0c1144] | 887 | IDLIST((idhdl)l->data)=L; |
---|
| 888 | #ifdef HAVE_NAMESPACES |
---|
| 889 | if (l->req_packhdl != NULL) |
---|
| 890 | { |
---|
| 891 | //Print("jjA_L_LIST: -1 \n"); |
---|
| 892 | namespaceroot->push( IDPACKAGE(l->req_packhdl), IDID((idhdl)l)); |
---|
| 893 | ipMoveId((idhdl)l->data); |
---|
| 894 | namespaceroot->pop(); |
---|
| 895 | } |
---|
| 896 | else |
---|
| 897 | #endif /* HAVE_NAMESPACES */ |
---|
| 898 | ipMoveId((idhdl)l->data); |
---|
[0a3ddd] | 899 | } |
---|
| 900 | else |
---|
[0c1144] | 901 | { |
---|
| 902 | l->LData()->data=L; |
---|
| 903 | } |
---|
[6d5a210] | 904 | err: |
---|
[24c186a] | 905 | o_r->CleanUp(); |
---|
[14ca45] | 906 | return errorreported; |
---|
[0e1846] | 907 | } |
---|
| 908 | static BOOLEAN jjA_L_INTVEC(leftv l,leftv r,intvec *iv) |
---|
| 909 | { |
---|
| 910 | /* left side is intvec/intmat, right side is list (of int,intvec,intmat)*/ |
---|
| 911 | leftv hh=r; |
---|
| 912 | int i = 0; |
---|
| 913 | while (hh!=NULL) |
---|
| 914 | { |
---|
| 915 | if (i>=iv->length()) break; |
---|
| 916 | if (hh->Typ() == INT_CMD) |
---|
| 917 | { |
---|
| 918 | (*iv)[i++] = (int)(hh->Data()); |
---|
| 919 | } |
---|
| 920 | else if ((hh->Typ() == INTVEC_CMD) |
---|
| 921 | ||(hh->Typ() == INTMAT_CMD)) |
---|
| 922 | { |
---|
| 923 | intvec *ivv = (intvec *)(hh->Data()); |
---|
| 924 | int ll = 0,l = min(ivv->length(),iv->length()); |
---|
| 925 | for (; l>0; l--) |
---|
| 926 | { |
---|
| 927 | (*iv)[i++] = (*ivv)[ll++]; |
---|
| 928 | } |
---|
| 929 | } |
---|
| 930 | else |
---|
| 931 | { |
---|
| 932 | delete iv; |
---|
| 933 | return TRUE; |
---|
| 934 | } |
---|
| 935 | hh = hh->next; |
---|
| 936 | } |
---|
| 937 | if (IDINTVEC((idhdl)l->data)!=NULL) delete IDINTVEC((idhdl)l->data); |
---|
| 938 | IDINTVEC((idhdl)l->data)=iv; |
---|
| 939 | return FALSE; |
---|
| 940 | } |
---|
| 941 | static BOOLEAN jjA_L_STRING(leftv l,leftv r) |
---|
| 942 | { |
---|
| 943 | /* left side is string, right side is list of string*/ |
---|
| 944 | leftv hh=r; |
---|
| 945 | int sl = 1; |
---|
| 946 | char *s; |
---|
| 947 | char *t; |
---|
| 948 | int tl; |
---|
| 949 | /* find the length */ |
---|
| 950 | while (hh!=NULL) |
---|
| 951 | { |
---|
| 952 | if (hh->Typ()!= STRING_CMD) |
---|
| 953 | { |
---|
| 954 | return TRUE; |
---|
| 955 | } |
---|
| 956 | sl += strlen((char *)hh->Data()); |
---|
| 957 | hh = hh->next; |
---|
| 958 | } |
---|
[c232af] | 959 | s = (char * )omAlloc(sl); |
---|
[0e1846] | 960 | sl=0; |
---|
| 961 | hh = r; |
---|
| 962 | while (hh!=NULL) |
---|
| 963 | { |
---|
| 964 | t=(char *)hh->Data(); |
---|
| 965 | tl=strlen(t); |
---|
| 966 | memcpy(s+sl,t,tl); |
---|
| 967 | sl+=tl; |
---|
| 968 | hh = hh->next; |
---|
| 969 | } |
---|
| 970 | s[sl]='\0'; |
---|
[c232af] | 971 | omFree((ADDRESS)IDDATA((idhdl)(l->data))); |
---|
[0e1846] | 972 | IDDATA((idhdl)(l->data))=s; |
---|
| 973 | return FALSE; |
---|
| 974 | } |
---|
| 975 | static BOOLEAN jjA_LIST_L(leftv l,leftv r) |
---|
| 976 | { |
---|
| 977 | /*left side are something, right side are lists*/ |
---|
| 978 | /*e.g. a,b,c=l */ |
---|
| 979 | //int ll=l->listLength(); |
---|
| 980 | if (l->listLength()==1) return jiAssign_1(l,r); |
---|
| 981 | BOOLEAN nok; |
---|
| 982 | sleftv t; |
---|
| 983 | leftv h; |
---|
| 984 | lists L=(lists)r->Data(); |
---|
| 985 | int rl=L->nr; |
---|
| 986 | int i=0; |
---|
| 987 | |
---|
| 988 | memset(&t,0,sizeof(sleftv)); |
---|
| 989 | while ((i<=rl)&&(l!=NULL)) |
---|
| 990 | { |
---|
| 991 | memset(&t,0,sizeof(sleftv)); |
---|
| 992 | t.Copy(&L->m[i]); |
---|
| 993 | h=l->next; |
---|
| 994 | l->next=NULL; |
---|
| 995 | nok=jiAssign_1(l,&t); |
---|
| 996 | if (nok) return TRUE; |
---|
| 997 | i++; |
---|
| 998 | l=h; |
---|
| 999 | } |
---|
| 1000 | r->CleanUp(); |
---|
| 1001 | return FALSE; |
---|
| 1002 | } |
---|
| 1003 | static BOOLEAN jiA_MATRIX_L(leftv l,leftv r) |
---|
| 1004 | { |
---|
| 1005 | /* right side is matrix, left side is list (of poly)*/ |
---|
| 1006 | BOOLEAN nok=FALSE; |
---|
| 1007 | int i; |
---|
| 1008 | matrix m=(matrix)r->CopyD(MATRIX_CMD); |
---|
| 1009 | leftv h; |
---|
| 1010 | leftv ol=l; |
---|
[3e41e0] | 1011 | leftv o_r=r; |
---|
[0e1846] | 1012 | sleftv t; |
---|
| 1013 | memset(&t,0,sizeof(sleftv)); |
---|
| 1014 | t.rtyp=POLY_CMD; |
---|
| 1015 | loop |
---|
| 1016 | { |
---|
| 1017 | i=0; |
---|
| 1018 | while ((i<MATROWS(m)*MATCOLS(m))&&(l!=NULL)) |
---|
| 1019 | { |
---|
| 1020 | t.data=(char *)m->m[i]; |
---|
| 1021 | m->m[i]=NULL; |
---|
| 1022 | h=l->next; |
---|
| 1023 | l->next=NULL; |
---|
| 1024 | nok=jiAssign_1(l,&t); |
---|
| 1025 | l->next=h; |
---|
[58bbda] | 1026 | if (nok) |
---|
[0e1846] | 1027 | { |
---|
| 1028 | idDelete((ideal *)&m); |
---|
| 1029 | goto ende; |
---|
| 1030 | } |
---|
| 1031 | i++; |
---|
| 1032 | l=h; |
---|
| 1033 | } |
---|
| 1034 | idDelete((ideal *)&m); |
---|
| 1035 | h=r; |
---|
| 1036 | r=r->next; |
---|
| 1037 | if (l==NULL) |
---|
| 1038 | { |
---|
| 1039 | if (r!=NULL) |
---|
| 1040 | { |
---|
| 1041 | Warn("list length mismatch in assign (l>r)"); |
---|
| 1042 | nok=TRUE; |
---|
| 1043 | } |
---|
| 1044 | break; |
---|
| 1045 | } |
---|
| 1046 | else if (r==NULL) |
---|
| 1047 | { |
---|
| 1048 | Warn("list length mismatch in assign (l<r)"); |
---|
| 1049 | nok=TRUE; |
---|
| 1050 | break; |
---|
| 1051 | } |
---|
| 1052 | if ((r->Typ()==IDEAL_CMD)||(r->Typ()==MATRIX_CMD)) |
---|
| 1053 | m=(matrix)r->CopyD(MATRIX_CMD); |
---|
| 1054 | else if (r->Typ()==POLY_CMD) |
---|
| 1055 | { |
---|
| 1056 | m=mpNew(1,1); |
---|
| 1057 | MATELEM(m,1,1)=(poly)r->CopyD(POLY_CMD); |
---|
[ba4d53] | 1058 | pNormalize(MATELEM(m,1,1)); |
---|
[0e1846] | 1059 | } |
---|
| 1060 | else |
---|
| 1061 | { |
---|
| 1062 | nok=TRUE; |
---|
| 1063 | break; |
---|
[58bbda] | 1064 | } |
---|
[0e1846] | 1065 | } |
---|
[58bbda] | 1066 | ende: |
---|
[3e41e0] | 1067 | o_r->CleanUp(); |
---|
[0e1846] | 1068 | ol->CleanUp(); |
---|
| 1069 | return nok; |
---|
| 1070 | } |
---|
| 1071 | static BOOLEAN jiA_STRING_L(leftv l,leftv r) |
---|
| 1072 | { |
---|
| 1073 | /*left side are strings, right side is a string*/ |
---|
| 1074 | /*e.g. s[2..3]="12" */ |
---|
| 1075 | /*the case s=t[1..4] is handled in iiAssign, |
---|
| 1076 | * the case s[2..3]=t[3..4] is handled in iiAssgn_rec*/ |
---|
| 1077 | int ll=l->listLength(); |
---|
| 1078 | int rl=r->listLength(); |
---|
| 1079 | BOOLEAN nok=FALSE; |
---|
| 1080 | sleftv t; |
---|
| 1081 | leftv h,l1=l; |
---|
| 1082 | int i=0; |
---|
| 1083 | char *ss; |
---|
| 1084 | char *s=(char *)r->Data(); |
---|
| 1085 | int sl=strlen(s); |
---|
| 1086 | |
---|
| 1087 | memset(&t,0,sizeof(sleftv)); |
---|
| 1088 | t.rtyp=STRING_CMD; |
---|
| 1089 | while ((i<sl)&&(l!=NULL)) |
---|
| 1090 | { |
---|
[c232af] | 1091 | ss=(char *)omAlloc(2); |
---|
[0e1846] | 1092 | ss[1]='\0'; |
---|
| 1093 | ss[0]=s[i]; |
---|
| 1094 | t.data=ss; |
---|
| 1095 | h=l->next; |
---|
| 1096 | l->next=NULL; |
---|
| 1097 | nok=jiAssign_1(l,&t); |
---|
[58bbda] | 1098 | if (nok) |
---|
[0e1846] | 1099 | { |
---|
| 1100 | break; |
---|
| 1101 | } |
---|
| 1102 | i++; |
---|
| 1103 | l=h; |
---|
| 1104 | } |
---|
| 1105 | r->CleanUp(); |
---|
| 1106 | l1->CleanUp(); |
---|
| 1107 | return nok; |
---|
| 1108 | } |
---|
| 1109 | static BOOLEAN jiAssign_list(leftv l, leftv r) |
---|
| 1110 | { |
---|
| 1111 | int i=l->e->start-1; |
---|
| 1112 | if (i<0) |
---|
| 1113 | { |
---|
| 1114 | Werror("index[%d] must be positive",i+1); |
---|
| 1115 | return TRUE; |
---|
| 1116 | } |
---|
| 1117 | if(l->attribute!=NULL) |
---|
[577d19f] | 1118 | { |
---|
| 1119 | atKillAll((idhdl)l); |
---|
| 1120 | l->attribute=NULL; |
---|
[58bbda] | 1121 | } |
---|
[0e1846] | 1122 | l->flag=0; |
---|
| 1123 | lists li; |
---|
[58bbda] | 1124 | if (l->rtyp==IDHDL) |
---|
[0e1846] | 1125 | { |
---|
| 1126 | li=IDLIST((idhdl)l->data); |
---|
[58bbda] | 1127 | } |
---|
[0e1846] | 1128 | else |
---|
| 1129 | { |
---|
| 1130 | li=(lists)l->data; |
---|
| 1131 | } |
---|
| 1132 | if (i>li->nr) |
---|
| 1133 | { |
---|
[c232af] | 1134 | li->m=(leftv)omreallocSize(li->m,(li->nr+1)*sizeof(sleftv),(i+1)*sizeof(sleftv)); |
---|
[0e1846] | 1135 | memset(&(li->m[li->nr+1]),0,(i-li->nr)*sizeof(sleftv)); |
---|
| 1136 | int j=li->nr+1; |
---|
| 1137 | for(;j<=i;j++) |
---|
| 1138 | li->m[j].rtyp=DEF_CMD; |
---|
| 1139 | li->nr=i; |
---|
| 1140 | } |
---|
[577d19f] | 1141 | leftv ld=&(li->m[i]); |
---|
| 1142 | ld->e=l->e->next; |
---|
| 1143 | BOOLEAN b; |
---|
| 1144 | if ((ld->rtyp!=LIST_CMD) |
---|
| 1145 | &&(ld->e==NULL) |
---|
| 1146 | &&(ld->Typ()!=r->Typ())) |
---|
[0e1846] | 1147 | { |
---|
[577d19f] | 1148 | sleftv tmp; |
---|
| 1149 | memset(&tmp,0,sizeof(sleftv)); |
---|
| 1150 | tmp.rtyp=DEF_CMD; |
---|
| 1151 | b=iiAssign(&tmp,r); |
---|
[0e1846] | 1152 | ld->CleanUp(); |
---|
[577d19f] | 1153 | memcpy(ld,&tmp,sizeof(sleftv)); |
---|
[0e1846] | 1154 | } |
---|
| 1155 | else |
---|
| 1156 | { |
---|
[577d19f] | 1157 | b=iiAssign(ld,r); |
---|
| 1158 | l->e->next=ld->e; |
---|
[6d5a210] | 1159 | ld->e=NULL; |
---|
[58bbda] | 1160 | } |
---|
[0e1846] | 1161 | return b; |
---|
| 1162 | } |
---|
| 1163 | static BOOLEAN jiAssign_rec(leftv l, leftv r) |
---|
| 1164 | { |
---|
| 1165 | leftv l1=l; |
---|
| 1166 | leftv r1=r; |
---|
| 1167 | leftv lrest; |
---|
| 1168 | leftv rrest; |
---|
| 1169 | BOOLEAN b; |
---|
| 1170 | do |
---|
| 1171 | { |
---|
| 1172 | lrest=l->next; |
---|
| 1173 | rrest=r->next; |
---|
| 1174 | l->next=NULL; |
---|
| 1175 | r->next=NULL; |
---|
| 1176 | b=iiAssign(l,r); |
---|
| 1177 | l->next=lrest; |
---|
| 1178 | r->next=rrest; |
---|
| 1179 | l=lrest; |
---|
| 1180 | r=rrest; |
---|
| 1181 | } while ((!b)&&(l!=NULL)); |
---|
| 1182 | l1->CleanUp(); |
---|
| 1183 | r1->CleanUp(); |
---|
| 1184 | return b; |
---|
| 1185 | } |
---|
| 1186 | BOOLEAN iiAssign(leftv l, leftv r) |
---|
| 1187 | { |
---|
| 1188 | int ll=l->listLength(); |
---|
| 1189 | int rl; |
---|
| 1190 | int lt=l->Typ(); |
---|
| 1191 | int rt=NONE; |
---|
| 1192 | BOOLEAN b; |
---|
| 1193 | |
---|
| 1194 | if(l->attribute!=NULL) |
---|
| 1195 | { |
---|
[577d19f] | 1196 | if (l->rtyp==IDHDL) |
---|
| 1197 | { |
---|
| 1198 | atKillAll((idhdl)l->data); |
---|
| 1199 | l->attribute=NULL; |
---|
| 1200 | } |
---|
| 1201 | else |
---|
| 1202 | atKillAll((idhdl)l); |
---|
[0e1846] | 1203 | } |
---|
| 1204 | if(l->rtyp==IDHDL) |
---|
| 1205 | { |
---|
| 1206 | IDFLAG((idhdl)l->data)=0; |
---|
[58bbda] | 1207 | } |
---|
[0e1846] | 1208 | l->flag=0; |
---|
| 1209 | if (ll==1) |
---|
| 1210 | { |
---|
| 1211 | /* l[..] = ... */ |
---|
| 1212 | if((l->e!=NULL) |
---|
[577d19f] | 1213 | && (((l->rtyp==IDHDL) && (IDTYP((idhdl)l->data)==LIST_CMD)) |
---|
[58bbda] | 1214 | || (l->rtyp==LIST_CMD))) |
---|
[0e1846] | 1215 | { |
---|
[24c186a] | 1216 | b=jiAssign_list(l,r); |
---|
[6d5a210] | 1217 | if(!b) |
---|
[0e1846] | 1218 | { |
---|
[0a3ddd] | 1219 | //Print("jjA_L_LIST: - 2 \n"); |
---|
[6d5a210] | 1220 | if((l->rtyp==IDHDL) && (l->data!=NULL)) |
---|
| 1221 | { |
---|
[0a3ddd] | 1222 | #ifdef HAVE_NAMESPACES |
---|
| 1223 | //if (IDTYP((idhdl)l->data)==LIST_CMD) |
---|
| 1224 | if ((l->req_packhdl)!= NULL) |
---|
| 1225 | { |
---|
| 1226 | namespaceroot->push( IDPACKAGE(l->req_packhdl) , IDID(l->req_packhdl)); |
---|
| 1227 | ipMoveId((idhdl)l->data); |
---|
| 1228 | namespaceroot->pop(); |
---|
| 1229 | } |
---|
| 1230 | else |
---|
| 1231 | #endif /* HAVE_NAMESPACES */ |
---|
| 1232 | ipMoveId((idhdl)l->data); |
---|
[6d5a210] | 1233 | l->attribute=IDATTR((idhdl)l->data); |
---|
| 1234 | l->flag=IDFLAG((idhdl)l->data); |
---|
| 1235 | } |
---|
[58bbda] | 1236 | } |
---|
[0e1846] | 1237 | r->CleanUp(); |
---|
[577d19f] | 1238 | Subexpr h; |
---|
| 1239 | while (l->e!=NULL) |
---|
| 1240 | { |
---|
| 1241 | h=l->e->next; |
---|
[c232af] | 1242 | omFreeBin((ADDRESS)l->e, sSubexpr_bin); |
---|
[577d19f] | 1243 | l->e=h; |
---|
| 1244 | } |
---|
[0e1846] | 1245 | return b; |
---|
| 1246 | } |
---|
| 1247 | rl=r->listLength(); |
---|
| 1248 | if (rl==1) |
---|
| 1249 | { |
---|
| 1250 | /* system variables = ... */ |
---|
| 1251 | if(((l->rtyp>=VECHO)&&(l->rtyp<=VPRINTLEVEL)) |
---|
| 1252 | ||((l->rtyp>=VALTVARS)&&(l->rtyp<=VMINPOLY))) |
---|
| 1253 | { |
---|
[fca547] | 1254 | b=iiAssign_sys(l,r); |
---|
| 1255 | r->CleanUp(); |
---|
| 1256 | //l->CleanUp(); |
---|
| 1257 | return b; |
---|
[0e1846] | 1258 | } |
---|
| 1259 | rt=r->Typ(); |
---|
| 1260 | /* a = ... */ |
---|
| 1261 | if ((lt!=MATRIX_CMD) |
---|
| 1262 | &&(lt!=INTMAT_CMD) |
---|
| 1263 | &&((lt==rt)||(lt!=LIST_CMD))) |
---|
| 1264 | { |
---|
[fca547] | 1265 | b=jiAssign_1(l,r); |
---|
| 1266 | if (l->rtyp==IDHDL) |
---|
| 1267 | { |
---|
[0a3ddd] | 1268 | if ((lt==DEF_CMD)||(lt==LIST_CMD)) |
---|
| 1269 | { |
---|
| 1270 | #ifdef HAVE_NAMESPACES |
---|
| 1271 | //Print("jjA_L_LIST: - 3 \n"); |
---|
| 1272 | if (lt==LIST_CMD && (l->req_packhdl)!= NULL) |
---|
| 1273 | { |
---|
| 1274 | namespaceroot->push( IDPACKAGE(l->req_packhdl) , |
---|
| 1275 | IDID(l->req_packhdl)); |
---|
| 1276 | ipMoveId((idhdl)l->data); |
---|
| 1277 | namespaceroot->pop(); |
---|
| 1278 | } |
---|
| 1279 | else |
---|
| 1280 | #endif /* HAVE_NAMESPACES */ |
---|
| 1281 | ipMoveId((idhdl)l->data); |
---|
| 1282 | } |
---|
[fca547] | 1283 | l->attribute=IDATTR((idhdl)l->data); |
---|
| 1284 | l->flag=IDFLAG((idhdl)l->data); |
---|
| 1285 | l->CleanUp(); |
---|
| 1286 | } |
---|
| 1287 | r->CleanUp(); |
---|
| 1288 | return b; |
---|
[58bbda] | 1289 | } |
---|
[fca547] | 1290 | if (((lt!=LIST_CMD) |
---|
| 1291 | &&((rt==MATRIX_CMD) |
---|
| 1292 | ||(rt==INTMAT_CMD) |
---|
| 1293 | ||(rt==INTVEC_CMD) |
---|
| 1294 | ||(rt==MODUL_CMD))) |
---|
| 1295 | ||((lt==LIST_CMD) |
---|
| 1296 | &&(rt==RESOLUTION_CMD)) |
---|
| 1297 | ) |
---|
[58bbda] | 1298 | { |
---|
[fca547] | 1299 | b=jiAssign_1(l,r); |
---|
| 1300 | if((l->rtyp==IDHDL)&&(l->data!=NULL)) |
---|
| 1301 | { |
---|
[342716] | 1302 | if ((lt==DEF_CMD) || (lt==LIST_CMD)) |
---|
[0a3ddd] | 1303 | { |
---|
| 1304 | //Print("ipAssign - 3.0\n"); |
---|
| 1305 | #ifdef HAVE_NAMESPACES |
---|
| 1306 | //Print("jjA_L_LIST: - 4 \n"); |
---|
| 1307 | if (lt==LIST_CMD && (l->req_packhdl)!= NULL) |
---|
| 1308 | { |
---|
[6f83c3d] | 1309 | // Print("==========>ipAssign() - 3\n"); |
---|
[0a3ddd] | 1310 | namespaceroot->push( IDPACKAGE(l->req_packhdl) , |
---|
| 1311 | IDID(l->req_packhdl)); |
---|
| 1312 | ipMoveId((idhdl)l->data); |
---|
| 1313 | namespaceroot->pop(); |
---|
| 1314 | } |
---|
| 1315 | else |
---|
| 1316 | #endif /* HAVE_NAMESPACES */ |
---|
| 1317 | ipMoveId((idhdl)l->data); |
---|
| 1318 | } |
---|
[fca547] | 1319 | l->attribute=IDATTR((idhdl)l->data); |
---|
| 1320 | l->flag=IDFLAG((idhdl)l->data); |
---|
| 1321 | } |
---|
| 1322 | r->CleanUp(); |
---|
| 1323 | Subexpr h; |
---|
| 1324 | while (l->e!=NULL) |
---|
| 1325 | { |
---|
| 1326 | h=l->e->next; |
---|
[c232af] | 1327 | omFreeBin((ADDRESS)l->e, sSubexpr_bin); |
---|
[fca547] | 1328 | l->e=h; |
---|
| 1329 | } |
---|
| 1330 | return b; |
---|
[0e1846] | 1331 | } |
---|
| 1332 | } |
---|
| 1333 | if (rt==NONE) rt=r->Typ(); |
---|
| 1334 | } |
---|
| 1335 | else if (ll==(rl=r->listLength())) |
---|
| 1336 | { |
---|
| 1337 | b=jiAssign_rec(l,r); |
---|
| 1338 | return b; |
---|
| 1339 | } |
---|
| 1340 | else |
---|
| 1341 | { |
---|
| 1342 | if (rt==NONE) rt=r->Typ(); |
---|
| 1343 | if (rt==INTVEC_CMD) |
---|
| 1344 | return jiA_INTVEC_L(l,r); |
---|
[499bdc] | 1345 | else if (rt==VECTOR_CMD) |
---|
| 1346 | return jiA_VECTOR_L(l,r); |
---|
[0e1846] | 1347 | else if ((rt==IDEAL_CMD)||(rt==MATRIX_CMD)) |
---|
| 1348 | return jiA_MATRIX_L(l,r); |
---|
| 1349 | else if ((rt==STRING_CMD)&&(rl==1)) |
---|
| 1350 | return jiA_STRING_L(l,r); |
---|
| 1351 | Werror("length of lists in assignment does not match (l:%d,r:%d)", |
---|
| 1352 | ll,rl); |
---|
| 1353 | return TRUE; |
---|
| 1354 | } |
---|
| 1355 | |
---|
| 1356 | leftv hh=r; |
---|
| 1357 | BOOLEAN nok=FALSE; |
---|
| 1358 | BOOLEAN map_assign=FALSE; |
---|
| 1359 | switch (lt) |
---|
| 1360 | { |
---|
| 1361 | case INTVEC_CMD: |
---|
[c232af] | 1362 | nok=jjA_L_INTVEC(l,r,new intvec(exprlist_length(r))); |
---|
[0e1846] | 1363 | break; |
---|
| 1364 | case INTMAT_CMD: |
---|
| 1365 | { |
---|
[c232af] | 1366 | nok=jjA_L_INTVEC(l,r,new intvec(IDINTVEC((idhdl)l->data))); |
---|
[0e1846] | 1367 | break; |
---|
| 1368 | } |
---|
| 1369 | case MAP_CMD: |
---|
| 1370 | { |
---|
| 1371 | // first element in the list sl (r) must be a ring |
---|
| 1372 | if (((rt == RING_CMD)||(rt == QRING_CMD))&&(r->e==NULL)) |
---|
| 1373 | { |
---|
[c232af] | 1374 | omFree((ADDRESS)IDMAP((idhdl)l->data)->preimage); |
---|
| 1375 | IDMAP((idhdl)l->data)->preimage = omStrDup (r->Fullname()); |
---|
[0e1846] | 1376 | /* advance the expressionlist to get the next element after the ring */ |
---|
| 1377 | hh = r->next; |
---|
| 1378 | //r=hh; |
---|
| 1379 | } |
---|
| 1380 | else |
---|
| 1381 | { |
---|
[da97958] | 1382 | WerrorS("expected ring-name"); |
---|
[0e1846] | 1383 | nok=TRUE; |
---|
| 1384 | break; |
---|
| 1385 | } |
---|
| 1386 | if (hh==NULL) /* map-assign: map f=r; */ |
---|
| 1387 | { |
---|
[da97958] | 1388 | WerrorS("expected image ideal"); |
---|
[0e1846] | 1389 | nok=TRUE; |
---|
| 1390 | break; |
---|
| 1391 | } |
---|
| 1392 | if ((hh->next==NULL)&&(hh->Typ()==IDEAL_CMD)) |
---|
| 1393 | return jiAssign_1(l,hh); /* map-assign: map f=r,i; */ |
---|
| 1394 | //no break, handle the rest like an ideal: |
---|
| 1395 | map_assign=TRUE; |
---|
| 1396 | } |
---|
| 1397 | case MATRIX_CMD: |
---|
| 1398 | case IDEAL_CMD: |
---|
| 1399 | case MODUL_CMD: |
---|
| 1400 | { |
---|
| 1401 | sleftv t; |
---|
| 1402 | matrix olm = (matrix)l->Data(); |
---|
| 1403 | int rk=olm->rank; |
---|
| 1404 | char *pr=((map)olm)->preimage; |
---|
| 1405 | BOOLEAN module_assign=(/*l->Typ()*/ lt==MODUL_CMD); |
---|
| 1406 | matrix lm ; |
---|
| 1407 | int num; |
---|
| 1408 | int j,k; |
---|
| 1409 | int i=0; |
---|
| 1410 | int mtyp=MATRIX_CMD; /*Type of left side object*/ |
---|
| 1411 | int etyp=POLY_CMD; /*Type of elements of left side object*/ |
---|
| 1412 | |
---|
| 1413 | if (lt /*l->Typ()*/==MATRIX_CMD) |
---|
| 1414 | { |
---|
| 1415 | num=olm->cols()*olm->rows(); |
---|
| 1416 | lm=mpNew(olm->rows(),olm->cols()); |
---|
| 1417 | } |
---|
| 1418 | else /* IDEAL_CMD or MODUL_CMD */ |
---|
| 1419 | { |
---|
| 1420 | num=exprlist_length(hh); |
---|
| 1421 | lm=(matrix)idInit(num,1); |
---|
| 1422 | rk=1; |
---|
| 1423 | if (module_assign) |
---|
| 1424 | { |
---|
| 1425 | mtyp=MODUL_CMD; |
---|
| 1426 | etyp=VECTOR_CMD; |
---|
| 1427 | } |
---|
| 1428 | } |
---|
| 1429 | |
---|
| 1430 | int ht; |
---|
| 1431 | loop |
---|
| 1432 | { |
---|
| 1433 | if (hh==NULL) |
---|
| 1434 | break; |
---|
| 1435 | else |
---|
| 1436 | { |
---|
[0c1144] | 1437 | matrix rm; |
---|
[0e1846] | 1438 | ht=hh->Typ(); |
---|
| 1439 | if ((j=iiTestConvert(ht,etyp))!=0) |
---|
| 1440 | { |
---|
| 1441 | nok=iiConvert(ht,etyp,j,hh,&t); |
---|
| 1442 | hh->next=t.next; |
---|
| 1443 | if (nok) break; |
---|
| 1444 | lm->m[i]=(poly)t.CopyD(etyp); |
---|
[ba4d53] | 1445 | pNormalize(lm->m[i]); |
---|
[0e1846] | 1446 | if (module_assign) rk=max(rk,pMaxComp(lm->m[i])); |
---|
| 1447 | i++; |
---|
| 1448 | } |
---|
| 1449 | else |
---|
| 1450 | if ((j=iiTestConvert(ht,mtyp))!=0) |
---|
| 1451 | { |
---|
| 1452 | nok=iiConvert(ht,mtyp,j,hh,&t); |
---|
| 1453 | hh->next=t.next; |
---|
| 1454 | if (nok) break; |
---|
| 1455 | rm = (matrix)t.CopyD(mtyp); |
---|
| 1456 | if (module_assign) |
---|
| 1457 | { |
---|
| 1458 | j = min(num,rm->cols()); |
---|
| 1459 | rk=max(rk,rm->rank); |
---|
| 1460 | } |
---|
| 1461 | else |
---|
| 1462 | j = min(num-i,rm->rows() * rm->cols()); |
---|
| 1463 | for(k=0;k<j;k++,i++) |
---|
| 1464 | { |
---|
| 1465 | lm->m[i]=rm->m[k]; |
---|
[ba4d53] | 1466 | pNormalize(lm->m[i]); |
---|
[0e1846] | 1467 | rm->m[k]=NULL; |
---|
| 1468 | } |
---|
| 1469 | idDelete((ideal *)&rm); |
---|
| 1470 | } |
---|
| 1471 | else |
---|
| 1472 | { |
---|
| 1473 | nok=TRUE; |
---|
| 1474 | break; |
---|
| 1475 | } |
---|
| 1476 | t.next=NULL;t.CleanUp(); |
---|
| 1477 | if (i==num) break; |
---|
| 1478 | hh=hh->next; |
---|
| 1479 | } |
---|
| 1480 | } |
---|
| 1481 | if (nok) |
---|
| 1482 | idDelete((ideal *)&lm); |
---|
| 1483 | else |
---|
| 1484 | { |
---|
| 1485 | idDelete((ideal *)&olm); |
---|
| 1486 | if (module_assign) lm->rank=rk; |
---|
| 1487 | else if (map_assign) ((map)lm)->preimage=pr; |
---|
| 1488 | #ifdef DRING |
---|
| 1489 | else if (pDRING) |
---|
| 1490 | { |
---|
| 1491 | int i=IDELEMS(lm)-1; |
---|
| 1492 | while (i>=0) |
---|
| 1493 | { |
---|
[311499] | 1494 | pdSetDFlagP(lm->m[i],1); |
---|
[0e1846] | 1495 | i--; |
---|
| 1496 | } |
---|
| 1497 | } |
---|
| 1498 | #endif |
---|
| 1499 | l=l->LData(); |
---|
| 1500 | if (l->rtyp==IDHDL) |
---|
| 1501 | IDMATRIX((idhdl)l->data)=lm; |
---|
| 1502 | else |
---|
| 1503 | l->data=(char *)lm; |
---|
| 1504 | } |
---|
| 1505 | break; |
---|
| 1506 | } |
---|
| 1507 | case STRING_CMD: |
---|
| 1508 | nok=jjA_L_STRING(l,r); |
---|
| 1509 | break; |
---|
| 1510 | case LIST_CMD: |
---|
| 1511 | nok=jjA_L_LIST(l,r); |
---|
| 1512 | break; |
---|
| 1513 | case NONE: |
---|
| 1514 | case 0: |
---|
[0a3ddd] | 1515 | Werror("cannot assign to %s",l->Fullname()); |
---|
[0e1846] | 1516 | nok=TRUE; |
---|
| 1517 | break; |
---|
| 1518 | default: |
---|
| 1519 | WerrorS("assign not impl."); |
---|
| 1520 | nok=TRUE; |
---|
| 1521 | break; |
---|
| 1522 | } /* end switch: typ */ |
---|
[da97958] | 1523 | if (nok && (!errorreported)) WerrorS("incompatible type in list assignment"); |
---|
[0e1846] | 1524 | r->CleanUp(); |
---|
| 1525 | return nok; |
---|
| 1526 | } |
---|