Changeset 4f80bb in git for Singular/ipassign.cc
- Timestamp:
- Sep 17, 2010, 2:57:28 PM (14 years ago)
- Branches:
- (u'spielwiese', '5b153614cbc72bfa198d75b1e9e33dab2645d9fe')
- Children:
- dce1e3bbf2389a71a367d500df527054c5d4459f
- Parents:
- 8e7db4cc8c23b1a45ca71f3217a02819e04d9c84
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/ipassign.cc
r8e7db4 r4f80bb 40 40 #include <Singular/ipshell.h> 41 41 #include <kernel/sca.h> 42 #include <Singular/Fan.h> 43 #include <Singular/Cone.h> 42 44 43 45 /*=================== proc =================*/ … … 319 321 return FALSE; 320 322 } 323 #ifdef HAVE_FANS 324 static BOOLEAN jiA_FAN(leftv res, leftv a, Subexpr e) 325 { 326 if (e != NULL) 327 { 328 WerrorS("unexpectedly encountered subexpression in jiA_FAN"); 329 return TRUE; 330 } 331 if (res->data!=NULL) 332 { 333 Fan* fff = (Fan*)res->data; 334 res->data = NULL; 335 delete fff; 336 } 337 Fan* fff = (Fan*)a->CopyD(FAN_CMD); 338 res->data=(void*)fff; 339 return FALSE; 340 } 341 static BOOLEAN jiA_CONE(leftv res, leftv a, Subexpr e) 342 { 343 if (e != NULL) 344 { 345 WerrorS("unexpectedly encountered subexpression in jiA_CONE"); 346 return TRUE; 347 } 348 if (res->data!=NULL) 349 { 350 Cone* ccc = (Cone*)res->data; 351 res->data = NULL; 352 delete ccc; 353 } 354 Cone* ccc = (Cone*)a->CopyD(CONE_CMD); 355 res->data=(void*)ccc; 356 return FALSE; 357 } 358 #endif /* HAVE_FANS */ 321 359 static BOOLEAN jiA_POLY(leftv res, leftv a,Subexpr e) 322 360 { … … 697 735 ,{jiA_LINK, LINK_CMD, STRING_CMD } 698 736 ,{jiA_LINK, LINK_CMD, LINK_CMD } 737 #ifdef HAVE_FANS 738 ,{jiA_FAN, FAN_CMD, FAN_CMD } 739 ,{jiA_CONE, CONE_CMD, CONE_CMD } 740 #endif /* HAVE_FANS */ 699 741 ,{jiA_PACKAGE, PACKAGE_CMD, PACKAGE_CMD } 700 742 ,{NULL, 0, 0 } … … 1346 1388 return b; 1347 1389 } 1390 #ifdef HAVE_FANS 1391 BOOLEAN jjAssignFan(leftv l, leftv r) 1392 { 1393 /* method for generating a fan; 1394 valid parametrizations: (intmat or 0, intmat or 0, intmat or 0), 1395 The intmat's capture the maximal rays, facet normals and the 1396 lineality space of the new fan. 1397 Any of the arguments may be the int 0. But either the 1st or 1398 2nd argument must be an intmat, thus not both simultaneously 1399 the int 0. 1400 Errors will be invoked in the following cases: 1401 - 1st and 2nd argument simultaneously the int 0, 1402 - numbers of rows in 1st, 2nd, and/or 3rd argument intmat 1403 disagree */ 1404 intvec* maxRays = NULL; /* maximal rays */ 1405 intvec* facetNs = NULL; /* facet normals */ 1406 intvec* linSpace = NULL; /* lineality space */ 1407 1408 leftv x = r; 1409 if (x->Typ() == INTMAT_CMD) maxRays = (intvec*)x->Data(); 1410 else if ((x->Typ() != INT_CMD) || 1411 ((x->Typ() == INT_CMD) && ((int)(long)x->Data() != 0))) 1412 { 1413 WerrorS("expected '0' or an intmat as 1st argument"); 1414 return TRUE; 1415 } 1416 x = x->next; 1417 if (x->Typ() == INTMAT_CMD) facetNs = (intvec*)x->Data(); 1418 else if ((x->Typ() != INT_CMD) || 1419 ((x->Typ() == INT_CMD) && ((int)(long)x->Data() != 0))) 1420 { 1421 WerrorS("expected '0' or an intmat as 2nd argument"); 1422 return TRUE; 1423 } 1424 if ((maxRays == NULL) && (facetNs == NULL)) 1425 { 1426 WerrorS("expected 1st or 2nd argument to be a valid intmat"); 1427 return TRUE; 1428 } 1429 x = x->next; 1430 if (x->Typ() == INTMAT_CMD) linSpace = (intvec*)x->Data(); 1431 else if ((x->Typ() != INT_CMD) || 1432 ((x->Typ() == INT_CMD) && ((int)(long)x->Data() != 0))) 1433 { 1434 WerrorS("expected '0' or an intmat as 3rd argument"); 1435 return TRUE; 1436 } 1437 if ((maxRays != NULL) && (facetNs != NULL) && 1438 (maxRays->rows() != facetNs->rows())) 1439 { 1440 WerrorS("vector space dims do not agree (1st vs. 2nd argument)"); 1441 return TRUE; 1442 } 1443 if ((maxRays != NULL) && (linSpace != NULL) && 1444 (maxRays->rows() != linSpace->rows())) 1445 { 1446 WerrorS("vector space dims do not agree (1st vs. 3rd argument)"); 1447 return TRUE; 1448 } 1449 if ((facetNs != NULL) && (linSpace != NULL) && 1450 (facetNs->rows() != linSpace->rows())) 1451 { 1452 WerrorS("vector space dims do not agree (2nd vs. 3rd argument)"); 1453 return TRUE; 1454 } 1455 1456 if (IDDATA((idhdl)l->data) != NULL) 1457 { 1458 Fan* fff = (Fan*)IDDATA((idhdl)l->data); 1459 delete fff; 1460 } 1461 Fan* fff = new Fan(maxRays, facetNs, linSpace); 1462 IDDATA((idhdl)l->data) = (char*)fff; 1463 return FALSE; 1464 } 1465 BOOLEAN jjAssignCone(leftv l, leftv r) 1466 { 1467 /* method for generating a cone; 1468 valid parametrizations: (fan, intvec or 0, intvec or 0), 1469 The intvec's capture indices of the maximal rays resp. 1470 facet normals of the given fan. 1471 2nd and 3rd argument may be the int 0, but not simultaneously. 1472 Errors will be invoked in the following cases: 1473 - 2nd and 3rd argument simultaneously the int 0, 1474 - invalid index for maximal row or facet normal */ 1475 Fan* fff = NULL; /* the Fan where maximal rays and/or 1476 facet normals are stored */ 1477 intvec* maxRays = NULL; /* indices of maximal rays */ 1478 intvec* facetNs = NULL; /* indices of facet normals */ 1479 1480 leftv x = r; 1481 if (x->Typ() != FAN_CMD) 1482 { 1483 WerrorS("expected a fan as 1st argument"); 1484 return TRUE; 1485 } 1486 else 1487 { 1488 fff = (Fan*)x->Data(); 1489 } 1490 x = x->next; 1491 if (x->Typ() == INTVEC_CMD) maxRays = (intvec*)x->Data(); 1492 else if ((x->Typ() != INT_CMD) || 1493 ((x->Typ() == INT_CMD) && ((int)(long)x->Data() != 0))) 1494 { 1495 WerrorS("expected '0' or an intvec as 2nd argument"); 1496 return TRUE; 1497 } 1498 x = x->next; 1499 if (x->Typ() == INTVEC_CMD) facetNs = (intvec*)x->Data(); 1500 else if ((x->Typ() != INT_CMD) || 1501 ((x->Typ() == INT_CMD) && ((int)(long)x->Data() != 0))) 1502 { 1503 WerrorS("expected '0' or an intvec as 3rd argument"); 1504 return TRUE; 1505 } 1506 if ((maxRays == NULL) && (facetNs == NULL)) 1507 { 1508 WerrorS("expected 2nd or 3rd argument to be a valid intvec"); 1509 return TRUE; 1510 } 1511 1512 int check = Cone::checkConeData(fff, maxRays, facetNs); 1513 if (check > 0) 1514 { 1515 Werror("invalid index %d for maximal ray at position %d", 1516 (int)(long)((*maxRays)[check - 1]), check); 1517 return TRUE; 1518 } 1519 else if (check < 0) 1520 { 1521 char h[150]; 1522 sprintf(h, "invalid index %d for facet normal at position %d", 1523 (int)(long)((*facetNs)[-check - 1]), -check); 1524 WerrorS(h); 1525 return TRUE; 1526 } 1527 1528 if (IDDATA((idhdl)l->data) != NULL) 1529 { 1530 Cone* ccc = (Cone*)IDDATA((idhdl)l->data); 1531 delete ccc; 1532 } 1533 Cone* ccc = new Cone(fff, maxRays, facetNs); 1534 IDDATA((idhdl)l->data) = (char*)ccc; 1535 return FALSE; 1536 } 1537 #endif /* HAVE_FANS */ 1348 1538 BOOLEAN iiAssign(leftv l, leftv r) 1349 1539 { … … 1466 1656 } 1467 1657 } 1658 #ifdef HAVE_FANS 1659 else if ((lt == FAN_CMD) && (rl == 3)) 1660 { 1661 return jjAssignFan(l, r); 1662 } 1663 else if ((lt == CONE_CMD) && (rl == 3)) 1664 { 1665 return jjAssignCone(l, r); 1666 } 1667 #endif /* HAVE_FANS */ 1468 1668 if (rt==NONE) rt=r->Typ(); 1469 1669 }
Note: See TracChangeset
for help on using the changeset viewer.