1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873
|
subroutine matops
c
c operations matricielles
c
c Copyright INRIA
include '../stack.h'
common /mtlbc/ mmode
integer op
c
double precision ddot,dlamch
double precision cstr,csti
integer vol,iadr,sadr
c
double precision sr,si,e1,st,e2,e1r,e1i,e2r,e2i,dn
double precision dasum
integer star,dstar,slash,bslash,dot,colon,quote
integer less,great,equal,et,ou,non
integer top0
data star/47/,dstar/62/,slash/48/
data bslash/49/,dot/51/,colon/44/,quote/53/
data less/59/,great/60/,equal/50/
data ou/57/,et/58/,non/61/
c
iadr(l)=l+l-1
sadr(l)=(l/2)+1
c
op=fin
c
if (ddt .eq. 4) then
write(buf(1:4),'(i4)') fin
call basout(io,wte,' matops op: '//buf(1:4))
endif
c
top0=top
lw=lstk(top+1)+1
it2=0
goto (04,03,02,01) rhs
if (op.eq.2) then
top=top0
fin=-fin
else
call error(39)
endif
return
c
01 il4=iadr(lstk(top))
if(istk(il4).lt.0) il4=iadr(istk(il4+1))
m4=istk(il4+1)
n4=istk(il4+2)
it4=istk(il4+3)
l4=sadr(il4+4)
mn4=m4*n4
top=top-1
c
02 il3=iadr(lstk(top))
if(istk(il3).lt.0) il3=iadr(istk(il3+1))
m3=istk(il3+1)
n3=istk(il3+2)
it3=istk(il3+3)
l3=sadr(il3+4)
mn3=m3*n3
top=top-1
c
03 il2=iadr(lstk(top))
if(istk(il2).lt.0) il2=iadr(istk(il2+1))
m2=istk(il2+1)
n2=istk(il2+2)
it2=istk(il2+3)
l2=sadr(il2+4)
mn2=m2*n2
top=top-1
c
04 il1=iadr(lstk(top))
if(istk(il1).lt.0) il1=iadr(istk(il1+1))
m1=istk(il1+1)
n1=istk(il1+2)
it1=istk(il1+3)
l1=sadr(il1+4)
mn1=m1*n1
top=top-1
c
c operations binaires et ternaires
c --------------------------------
c
top=top+1
itr=max(it1,it2)
c
fun = 0
c
c cconc extrac insert rconc
goto(75 , 95 , 78 ,76) op
c
c : + - * / \ = '
goto(50,07,08,10,20,25,130,06,06,70) op+1-colon
c
06 if(op.eq.dstar) goto 31
if(op.eq.quote+dot) goto 70
if(op.eq.dstar+dot) goto 30
if(op.ge.3*dot+star) goto 65
if(op.ge.2*dot+star) goto 120
if(op.ge.less+equal) goto 130
if(op.ge.dot+star) goto 55
if(op.eq.et.or.op.eq.ou.or.op.eq.non) goto 140
if(op.ge.less) goto 130
top=top0
fin=-fin
return
c
c addition
07 continue
if (mn1.eq.0) then
if (mmode.eq.1) then
c . Matlab like []+a=[]
else
c . []+a=a
call icopy(4,istk(il2),1,istk(il1),1)
call dcopy(mn2*(it2+1),stk(l2),1,stk(l1),1)
lstk(top+1)=l1+mn2*(it2+1)
endif
elseif (mn2.eq.0) then
if (mmode.eq.1) then
c . Matlab like a+[]=[]
istk(il1+1)=0
istk(il1+2)=0
istk(il1+3)=0
lstk(top+1)=sadr(il1+4)
else
c . a+[]=a
endif
elseif (m1 .lt. 0) then
c . eye+vector
go to 40
elseif (m2 .lt. 0) then
c . vector+eye
go to 41
elseif (mn2.eq.1) then
c . vector+const
call dadd(mn1,stk(l2),0,stk(l1),1)
if(it2+2*it1.eq.1) call dcopy(mn1,stk(l2+mn2),0,stk(l1+mn1),1)
if(it1*it2.eq.1) call dadd(mn1,stk(l2+mn2),0,stk(l1+mn1),1)
lstk(top+1)=l1+mn1*(itr+1)
istk(il1+3)=itr
elseif (mn1.eq.1) then
c . cst+vector
cstr=stk(l1)
csti=stk(l1+1)
call dcopy((it2+1)*mn2,stk(l2),1,stk(l1),1)
if(it1.eq.1.and.it2.eq.0) call dset(mn2,0.d0,stk(l1+mn2),1)
call dadd(mn2,cstr,0,stk(l1),1)
if(it1.eq.1) call dadd(mn2,csti,0,stk(l1+mn2),1)
lstk(top+1)=l1+mn2*(itr+1)
istk(il1+1)=m2
istk(il1+2)=n2
istk(il1+3)=itr
else
c . vector+vector
if (m1 .ne. m2.or.n1 .ne. n2) then
call error(8)
return
endif
call dadd(mn1,stk(l2),1,stk(l1),1)
if(it2+2*it1.eq.1) then
call dcopy(mn1,stk(l2+mn1),1,stk(l1+mn1),1)
endif
if(it1*it2.eq.1) then
call dadd(mn1,stk(l2+mn1),1,stk(l1+mn1),1)
endif
lstk(top+1)=l1+mn1*(itr+1)
istk(il1+3)=itr
endif
go to 999
c
c soustraction
08 if(rhs.eq.1) then
c . unary minus
if(mn1.gt.0) then
call dscal(mn1*(it1+1),-1.0d+0,stk(l1),1)
endif
elseif (mn1.eq.0) then
if (mmode.eq.1) then
c . Matlab like []-a=[]
else
c . []-a=-a
call icopy(4,istk(il2),1,istk(il1),1)
call dcopy(mn2*(it2+1),stk(l2),1,stk(l1),1)
call dscal(mn2*(it2+1),-1.0d0,stk(l1),1)
lstk(top+1)=l1+mn2*(it2+1)
endif
elseif(mn2.eq.0) then
if (mmode.eq.1) then
c . Matlab like a-[]=[]
istk(il1+1)=0
istk(il1+2)=0
istk(il1+3)=0
lstk(top+1)=sadr(il1+4)
else
c . a-[]=a
endif
elseif (m1 .lt. 0) then
c . a*eye-vector
go to 42
elseif (m2 .lt. 0) then
c . vector-a*eye
go to 45
elseif (mn2.eq.1) then
c . vector-const
call dadd(mn1,-stk(l2),0,stk(l1),1)
if(it2+2*it1.eq.1) call dcopy(mn1,-stk(l2+mn2),0,stk(l1+mn1),1)
if(it1*it2.eq.1) call dadd(mn1,-stk(l2+mn2),0,stk(l1+mn1),1)
lstk(top+1)=l1+mn1*(itr+1)
istk(il1+3)=itr
elseif (mn1.eq.1) then
c . cst-vector
cstr=stk(l1)
csti=stk(l1+1)
call dscal((it2+1)*mn2,-1.0d0,stk(l2),1)
call dcopy((it2+1)*mn2,stk(l2),1,stk(l1),1)
if(it1.eq.1.and.it2.eq.0) call dset(mn2,0.d0,stk(l1+mn2),1)
call dadd(mn2,cstr,0,stk(l1),1)
if(it1.eq.1) call dadd(mn2,csti,0,stk(l1+mn2),1)
lstk(top+1)=l1+mn2*(itr+1)
istk(il1+1)=m2
istk(il1+2)=n2
istk(il1+3)=itr
else
c . vector-vector
if (m1 .ne. m2.or.n1 .ne. n2) then
call error(9)
return
endif
call ddif(mn1,stk(l2),1,stk(l1),1)
if(itr.eq.0) goto 999
if(it1.eq.0) then
call dscal (mn1,-1.0d+0,stk(l2+mn1),1)
call dcopy(mn1,stk(l2+mn1),1,stk(l1+mn1),1)
endif
if(it1*it2.eq.1) call ddif(mn1,stk(l2+mn1),1,stk(l1+mn1),1)
lstk(top+1)=l1+mn1*(itr+1)
istk(il1+3)=itr
endif
go to 999
c
c multiplication
10 continue
if(mn1.eq.0.or.mn2.eq.0) then
c . []*a , a*[]
istk(il1+1)=0
istk(il1+2)=0
istk(il1+3)=0
lstk(top+1)=sadr(il1+4)
elseif (mn1 .eq. 1) then
c . cst*a
sr = stk(l1)
si=0.0d+0
if(it1.eq.1) si = stk(l1+1)
if (m1.lt.0.and.mn2.eq.1) then
c . eye*cst
istk(il1+1)=m1
istk(il1+2)=n1
istk(il1+3)=itr
else
istk(il1+1)=m2
istk(il1+2)=n2
istk(il1+3)=itr
endif
call dcopy(mn2*(it2+1),stk(l2),1,stk(l1),1)
it21=it2+2*it1
if(it21.eq.0) then
c . le scalaire et la matrice sont reel
call dscal(mn2,sr,stk(l1),1)
elseif(it21.eq.1) then
c . la matrice est complexe le scalaire est reel
call dscal(mn2,sr,stk(l1),1)
call dscal(mn2,sr,stk(l1+mn2),1)
elseif(it21.eq.2) then
c . la matrice est reelle, le scalaire est complexe
lstk(top+1)=l1+mn2*(itr+1)
err=lstk(top+1)-lstk(bot)
if(err.gt.0) then
call error(17)
return
endif
call dcopy(mn2,stk(l1),1,stk(l1+mn2),1)
call dscal(mn2,sr,stk(l1),1)
call dscal(mn2,si,stk(l1+mn2),1)
elseif(it21.eq.3) then
c . la matrice et le scalaire sont complexes
call wscal(mn2,sr,si,stk(l1),stk(l1+mn2),1)
endif
lstk(top+1)=l1+mn2*(itr+1)
elseif (mn2 .eq. 1) then
c . a*cst
it21=it2+2*it1
if(it21.eq.0) then
c . la matrice et le scalaire sont reel
call dscal(mn1,stk(l2),stk(l1),1)
elseif(it21.eq.1) then
c . la matrice est reelle le scalaire est complexe
sr = stk(l2)
si = stk(l2+1)
lstk(top+1)=l1+mn1*(itr+1)
err=lstk(top+1)-lstk(bot)
if(err.gt.0) then
call error(17)
return
endif
call dcopy(mn1,stk(l1),1,stk(l1+mn1),1)
call dscal(mn1,si,stk(l1+mn1),1)
call dscal(mn1,sr,stk(l1),1)
istk(il1+3)=itr
elseif(it21.eq.2) then
c . la matrice est complexe, le scalaire est reel
sr = stk(l2)
call dscal(mn1,sr,stk(l1),1)
call dscal(mn1,sr,stk(l1+mn1),1)
elseif(it21.eq.3) then
sr = stk(l2)
si = stk(l2+1)
c . la matrice et le scalaire sont complexes
call wscal(mn1,sr,si,stk(l1),stk(l1+mn1),1)
endif
else
c . matrix*matrix
if (n1 .ne. m2) then
call error(10)
return
endif
lr=l2+mn2*(it2+1)
err=lr+m1*n2*(itr+1)-lstk(bot)
if(err.gt.0) then
call error(17)
return
endif
if(it1*it2.ne.1) then
call dmmul(stk(l1),m1,stk(l2),m2,stk(lr),m1,m1,n1,n2)
if(it1.eq.1) call dmmul(stk(l1+mn1),m1,stk(l2),m2
$ ,stk(lr+m1*n2),m1,m1,n1,n2)
if(it2.eq.1) call dmmul(stk(l1),m1,stk(l2+mn2),m2
$ ,stk(lr+m1*n2),m1,m1,n1,n2)
else
c . a et a2 sont complexes
call wmmul(stk(l1),stk(l1+mn1),m1,stk(l2),stk(l2
$ +mn2),m2,stk(lr),stk(lr+m1*n2),m1,m1,n1,n2)
endif
call dcopy(m1*n2*(itr+1),stk(lr),1,stk(l1),1)
istk(il1+2)=n2
istk(il1+3)=itr
lstk(top+1)=l1+m1*n2*(itr+1)
endif
go to 999
c
c division a droite
20 continue
if (mn1.eq.0.or.mn2.eq.0) then
c . a/[] or []/a
istk(il1)=1
istk(il1+1)=0
istk(il1+2)=0
istk(il1+3)=0
lstk(top+1)=sadr(il1+4)
goto 999
endif
if (mn2 .ne. 1) then
if (m2 .eq. n2) fun = 1
if (m2 .ne. n2) fun = 4
fin = -1
top = top+1
rhs = 2
else
c . vector / cst
istk(il1+1)=m1
istk(il1+2)=n1
istk(il1+3)=itr
lstk(top+1)=l1+mn1*(itr+1)
c
err=lstk(top+1)-lstk(bot)
if(err.gt.0) then
call error(17)
return
endif
it21=it2+2*it1
if(it21.eq.0) then
c . real / real
call ddrdiv(stk(l1),1,stk(l2),0,stk(l1),1,mn1,ierr)
elseif(it21.eq.1) then
c . real / complex
sr=stk(l2)
si=stk(l2+1)
call dwrdiv(stk(l1),1,sr,si,0,stk(l1),stk(l1+mn1),1,
$ mn1,ierr)
elseif(it21.eq.2) then
c . complex / real
call wdrdiv(stk(l1),stk(l1+mn1),1,stk(l2),0,stk(l1)
$ ,stk(l1+mn1),1,mn1,ierr)
elseif(it21.eq.3) then
c . complex / complex
call wwrdiv(stk(l1),stk(l1+mn1),1,stk(l2),stk(l2+1)
$ ,0,stk(l1),stk(l1+mn1),1,mn1,ierr)
endif
if(ierr.ne.0) then
if(ieee.eq.0) then
call error(27)
return
elseif(ieee.eq.1) then
call msgs(63)
endif
endif
endif
go to 999
c
c division a gauche
25 continue
if (mn1.eq.0.or.mn2.eq.0) then
c . a\[] or []\a
istk(il1)=1
istk(il1+1)=0
istk(il1+2)=0
istk(il1+3)=0
lstk(top+1)=sadr(il1+4)
goto 999
endif
if (m1*n1 .ne. 1) then
if (m1 .eq. n1) fun = 1
if (m1 .ne. n1) fun = 4
top = top+1
fin = -2
rhs = 2
else
c . cst \ vector
istk(il1+1)=m2
istk(il1+2)=n2
istk(il1+3)=itr
lstk(top+1)=l1+mn2*(itr+1)
c
err=lstk(top+1)-lstk(bot)
if(err.gt.0) then
call error(17)
return
endif
sr=stk(l1)
it21=it2+2*it1
if(it21.eq.0) then
c . real \ real
call ddrdiv(stk(l2),1,sr,0,stk(l1),1,mn2,ierr)
elseif(it21.eq.1) then
c . real \ complex = complex/real
call wdrdiv(stk(l2),stk(l2+mn2),1,sr,0,stk(l2)
$ ,stk(l2+mn2),1,mn2,ierr)
call dcopy(2*mn2,stk(l2),1,stk(l1),1)
elseif(it21.eq.2) then
c . complex \ real =real / complex
si=stk(l1+1)
call dcopy(mn2,stk(l2),1,stk(l1),1)
call dwrdiv(stk(l1),1,sr,si,0,stk(l1),stk(l1+mn2),1
$ ,mn2,ierr)
elseif(it21.eq.3) then
c . complex \ complex
si=stk(l1+1)
call dcopy(2*mn2,stk(l2),1,stk(l1),1)
call wwrdiv(stk(l1),stk(l1+mn2),1,sr,si,0,stk(l1)
$ ,stk(l1+mn2),1,mn2,ierr)
endif
if(ierr.ne.0) then
if(ieee.eq.0) then
call error(27)
return
elseif(ieee.eq.1) then
call msgs(63)
endif
endif
endif
go to 999
c
c puissance element wise .^
30 continue
if (mn1.eq.0) then
return
endif
if (mn2.eq.0) then
istk(il1)=1
istk(il1+1)=0
istk(il1+2)=0
istk(il1+3)=0
lstk(top+1)=sadr(il1+4)
return
endif
if (mn2 .gt. 1) then
m=m2
n=n2
inc2=1
if (mn1 .eq.1) then
inc1=0
elseif(m1.eq.m2.and.n1.eq.n2) then
inc1=1
else
call error(30)
return
endif
else
inc2=0
inc1=1
m=m1
n=n1
endif
mn=m*n
err=lw+mn*2-lstk(bot)
if(err.gt.0) then
call error(17)
return
endif
itr=max(it1,it2)
if(it2.eq.0) then
if(it1.eq.0) then
call ddpow1(mn,stk(l1),inc1,stk(l2),inc2,
$ stk(lw),stk(lw+mn),1,err,itr)
else
call wdpow1(mn,stk(l1),stk(l1+mn1),inc1,stk(l2),inc2,
$ stk(lw),stk(lw+mn),1,err)
endif
else
if(it1.eq.0) then
call dwpow1(mn,stk(l1),inc1,stk(l2),stk(l2+mn2),inc2,
& stk(lw),stk(lw+mn),1,err)
else
call wwpow1(mn,stk(l1),stk(l1+mn1),inc1,stk(l2),stk(l2+mn2),
& inc2,stk(lw),stk(lw+mn),1,err)
endif
endif
if(err.eq.1) then
call error(30)
return
endif
if(err.eq.2) then
if(ieee.eq.0) then
call error(27)
return
elseif(ieee.eq.1) then
call msgs(63)
endif
err=0
endif
istk(il1+1)=m
istk(il1+2)=n
istk(il1+3)=itr
call dcopy(mn*(itr+1),stk(lw),1,stk(l1),1)
lstk(top+1)=l1+mn*(itr+1)
goto 999
c
c elevation d'une matrice carree a une puissance
31 continue
if(mn1.eq.0) then
return
endif
if(mn2.eq.0) then
istk(il1)=1
istk(il1+1)=0
istk(il1+2)=0
istk(il1+3)=0
lstk(top+1)=sadr(il1+4)
return
endif
if(mn1.eq.1) goto 30
if(mn2.gt.1) goto 39
if(m1.ne.n1) then
if(mn2.eq.1.and.(m1.eq.1.or.n1.eq.1)) goto 30
err=1
call error(20)
return
endif
nexp = nint(stk(l2))
if (it2 .ne. 0) go to 39
if (stk(l2) .ne. dble(nexp)) go to 39
if (nexp.eq.1) go to 999
if (nexp.eq.0) then
lw=l1+mn1*(it1+1)
ipvt=iadr(lw+m1*(it1+1))
err=sadr(ipvt+m1)-lstk(bot)
if(err.gt.0) then
call error(17)
return
endif
if (dasum(m1*n1*(it1+1),stk(l1),1).eq.0.0d0) then
call error(30)
return
endif
c if(it1.eq.0) then
c call dgeco(stk(l1),m1,m1,istk(ipvt),sr,stk(lw))
c else
c call wgeco(stk(l1),stk(l1+mn1),m1,m1,istk(ipvt),
c & sr,stk(lw),stk(lw+m1))
c endif
c if(1.0d+0+sr.eq.1.0d+0) then
c call error(19)
c return
c endif
call dset(mn1,0.0d+0,stk(l1),1)
call dset(m1,1.0d+0,stk(l1),m1+1)
istk(il1+3)=0
lstk(top+1)=l1+mn1
goto 999
endif
c
if (nexp.le.0) then
fun=10
fin=1
rhs=1
call matlu
if(err.gt.0) return
nexp=-nexp
fun=0
endif
l2=l1+mn1*(it1+1)
c
l3=l2+mn1*(itr+1)
err=l3+n1*(itr+1)-lstk(bot)
if(err.gt.0) then
call error(17)
return
endif
lstk(top+1)=l1+mn1*(itr+1)
istk(il1+3)=itr
c
call dcopy(mn1*(itr+1),stk(l1),1,stk(l2),1)
if(it1.eq.1) goto 35
c la matrice est reelle
do 34 kexp=2,nexp
do 33 j=1,n1
ls=l1+(j-1)*n1
call dcopy(n1,stk(ls),1,stk(l3),1)
do 32 i=1,n1
ls=l2+(i-1)
ll=l1+(i-1)+(j-1)*n1
stk(ll)=ddot(n1,stk(ls),n1,stk(l3),1)
32 continue
33 continue
34 continue
goto 999
c
35 continue
c la matrice est complexe
do 38 kexp=2,nexp
do 37 j=1,n1
ls=l1+(j-1)*n1
call dcopy(n1,stk(ls),1,stk(l3),1)
call dcopy(n1,stk(ls+mn1),1,stk(l3+n1),1)
do 36 i=1,n1
ls=l2+(i-1)
ll=l1+(i-1)+(j-1)*n1
stk(ll)=ddot(n1,stk(ls),n1,stk(l3),1)-
$ ddot(n1,stk(ls+mn1),n1,stk(l3+n1),1)
stk(ll+mn1)=ddot(n1,stk(ls),n1,stk(l3+n1),1)+
$ ddot(n1,stk(ls+mn1),n1,stk(l3),1)
36 continue
37 continue
38 continue
goto 999
c
c puissance non entiere ou non positive
39 fun = 6
fin = 29
rhs=2
top=top+1
go to 999
c
c
c
c addition et soustraction d'un scalaire fois l'identite
40 sr=stk(l1)
si=0.0d+0
if(it1.eq.1) si=stk(l1+1)
call dcopy(mn2*(it2+1),stk(l2),1,stk(l1),1)
m1=m2
n1=n2
m2=it2
it2=it1
it1=m2
mn1=mn2
goto 46
c
41 sr=stk(l2)
si=0.0d0
if(it2.eq.1) si = stk(l2+1)
goto 46
c
c soustraction a*eye-b
42 sr=stk(l1)
si=0.0d+0
if(it1.eq.1) si=stk(l1+1)
43 call dcopy(mn2*(it2+1),stk(l2),1,stk(l1),1)
call dscal(mn2*(it2+1),-1.0d+0,stk(l1),1)
mn1=mn2
m1=m2
n1=n2
m2=it2
it2=it1
it1=m2
goto 46
c
c soustraction a-eye*b
45 sr=-stk(l2)
si=0.0d+0
if(it2.eq.1) si =- stk(l2+1)
c
46 err=l1+mn1*(itr+1) - lstk(bot)
if(err.gt.0) then
call error(17)
return
endif
lstk(top+1)=l1+mn1*(itr+1)
istk(il1+1)=m1
istk(il1+2)=n1
istk(il1+3)=itr
c
if(itr.eq.1.and.it1.eq.0) call dset(mn1,0.0d+0,stk(l1+mn1),1)
m1=abs(m1)
n1=abs(n1)
do 47 i = 1, min(n1,m1)
ll = l1 + (i-1)*(m1+1)
stk(ll) = stk(ll)+sr
if(itr.ne.0) stk(ll+mn1) = stk(ll+mn1)+si
47 continue
go to 999
c
c boucle implicite
50 continue
if(mn1.ne.1) then
err=1
call cvname(ids(1,pt+1),''':''',0)
call error(204)
return
endif
e1 = stk(l1)
c
if(mn2.ne.1) then
err=2
call cvname(ids(1,pt+1),''':''',0)
call error(204)
return
endif
e2 = stk(l2)
c
if (rhs .eq. 3) then
if(mn3.ne.1) then
err=3
call cvname(ids(1,pt+1),''':''',0)
call error(204)
return
endif
e2=stk(l3)
st = stk(l2)
else
st = 1.0d+0
endif
if (st .eq. 0.0d+0) then
istk(il1+1)=1
istk(il1+1)=0
istk(il1+2)=0
istk(il1+3)=0
lstk(top+1)=l1
return
endif
c check for clause
if (rstk(pt-1) .eq. 801.or.rstk(pt).eq.611) go to 54
if(rstk(pt-1).eq.611.and.rstk(pt).eq.601) then
c : in compiled for, next line to differentiate from extraction
if(istk(pstk(pt)).eq.16) goto 54
endif
c
c floating point used to avoid integer overflow
e1r=dble(l1) + max(3.0d0,(e2-e1)/st) - dble(lstk(bot))
if (e1r .gt. 0.0d0) then
err=e1r
call error(17)
return
endif
c
n = 0
l=l1
52 if (st*(stk(l)-e2).gt.0.0d+0) then
if (abs(stk(l)-e2).lt.abs(st*dlamch('p'))) n=n+1
go to 53
endif
n = n+1
l = l+1
stk(l) = e1 + dble(n)*st
go to 52
53 continue
istk(il1+1)=1
if(n.eq.0) istk(il1+1)=0
istk(il1+2)=n
istk(il1+3)=0
lstk(top+1)=l1+n
go to 999
c
c for clause
54 stk(l1) = e1
stk(l1+1) = st
stk(l1+2) = e2
istk(il1+1)=-3
istk(il1+2)=-1
lstk(top+1)=l1+3
go to 999
c
c element wise operations
55 continue
i1=1
i2=1
op = op - dot
if(mn1.eq.0.or.mn2.eq.0) then
c [].*a a.*[] -->[]
istk(il1)=1
istk(il1+1)=0
istk(il1+2)=0
istk(il1+3)=0
lstk(top+1)=sadr(il1+4)
goto 999
endif
if(mn1.ne.1.and.mn2.ne.1) then
c check dimensions
if (m1.ne.m2 .or. n1.ne.n2) then
buf='inconsistent element-wise operation'
call error(9999)
return
endif
endif
lstk(top+1)=l1+max(mn1,mn2)*(itr+1)
err=lstk(top+1)-lstk(bot)
if(err.gt.0) then
call error(17)
return
endif
istk(il1+3)=itr
if(op.eq.star) then
c multiplication .*
if(mn1.eq.1.or.mn2.eq.1) goto 10
if(it1*it2.ne.1) then
if(it1.eq.1) call dvmul(mn1,stk(l2),i2,stk(l1
$ +mn1),i1)
if(it2.eq.1) call dvmul(mn1,stk(l1),i1,stk(l2
$ +mn2),i2)
call dvmul(mn1,stk(l2),i2,stk(l1),i1)
if(it2.eq.1) call dcopy(mn1,stk(l2+mn2),i2
$ ,stk(l1+mn1),i1)
else
call wvmul(mn1,stk(l2),stk(l2+mn2),i2,stk(l1)
$ ,stk(l1+mn1),i1)
endif
elseif(op.eq.slash) then
it21=it2+2*it1
if(mn2.eq.1) then
c . vector ./ cst
goto 20
elseif(mn1.eq.1) then
c . cst ./ vector
istk(il1+1)=m2
istk(il1+2)=n2
sr=stk(l1)
if(it21.eq.0) then
c . real ./ real
call ddrdiv(sr,0,stk(l2),1,stk(l1),1,mn2,ierr)
elseif(it21.eq.1) then
c . real ./ complex
call dcopy(2*mn2,stk(l2),1, stk(l1),1)
call dwrdiv(sr,0,stk(l1),stk(l1+mn2),1,stk(l1)
$ ,stk(l1+mn2),1,mn2,ierr)
elseif(it21.eq.2) then
c . complex ./ real
si=stk(l1+mn1)
call dcopy(mn2,stk(l2),1, stk(l1),1)
call wdrdiv(sr,si,0,stk(l1),1,stk(l1),stk(l1+mn2)
$ ,1,mn2,ierr)
elseif(it21.eq.3) then
c . complex ./ complex
si=stk(l1+mn1)
call dcopy(2*mn2,stk(l2),1, stk(l1),1)
call wwrdiv(sr,si,0,stk(l1),stk(l1+mn2),1,stk(l1)
$ ,stk(l1+mn2),1,mn2,ierr)
endif
else
c . vector ./ vector
if(it21.eq.0) then
c . real ./ real
call ddrdiv(stk(l1),1,stk(l2),1,stk(l1),1,mn2
$ ,ierr)
elseif(it21.eq.1) then
c . real ./ complex
call dwrdiv(stk(l1),1,stk(l2),stk(l2+mn1),1
$ ,stk(l1),stk(l2),1,mn2,ierr)
call dcopy(mn2,stk(l2),1,stk(l1+mn2),1)
elseif(it21.eq.2) then
c . complex ./ real
call wdrdiv(stk(l1),stk(l1+mn1),1,stk(l2),1
$ ,stk(l1),stk(l1+mn2),1,mn2,ierr)
elseif(it21.eq.3) then
c . complex ./ complex
call wwrdiv(stk(l1),stk(l1+mn1),1,stk(l2)
$ ,stk(l2+mn2),1,stk(l1),stk(l1+mn2),1,mn2,ierr)
endif
endif
if(ierr.ne.0) then
if(ieee.eq.0) then
call error(27)
return
elseif(ieee.eq.1) then
call msgs(63)
endif
endif
elseif(op.eq.bslash) then
it21=it2+2*it1
if(mn1.eq.1) then
c . cst .\ vector
goto 25
elseif(mn2.eq.1) then
c . vector .\ cst
sr=stk(l2)
if(it21.eq.0) then
c . real .\ real
call ddrdiv(sr,0,stk(l1),1,stk(l1),1,mn1,ierr)
elseif(it21.eq.2) then
c . complex .\ real
call dwrdiv(sr,0,stk(l1),stk(l1+mn1),1,stk(l1)
$ ,stk(l1+mn1),1,mn1,ierr)
elseif(it21.eq.1) then
c . real .\ complex
si=stk(l2+mn2)
call wdrdiv(sr,si,0,stk(l1),1,stk(l1),stk(l1+mn1),1
$ ,mn1,ierr)
elseif(it21.eq.3) then
c . complex .\ complex
si=stk(l2+mn2)
call wwrdiv(sr,si,0,stk(l1),stk(l1+mn1),1,stk(l1)
$ ,stk(l1+mn1),1,mn1,ierr)
endif
else
c . vector .\ vector
if(it21.eq.0) then
c . real .\ real
call ddrdiv(stk(l2),1,stk(l1),1,stk(l1),1,mn1
$ ,ierr)
elseif(it21.eq.2) then
c . complex .\ real
call dwrdiv(stk(l2),1,stk(l1),stk(l1+mn1),1
$ ,stk(l1),stk(l1+mn1),1,mn1,ierr)
elseif(it21.eq.1) then
c . real .\ complex = complex /. real
call wdrdiv(stk(l2),stk(l2+mn2),1,stk(l1),1
$ ,stk(l1),stk(l2),1,mn1,ierr)
call dcopy(mn1,stk(l2),1,stk(l1+mn1),1)
elseif(it21.eq.3) then
c . complex .\ complex
call wwrdiv(stk(l2),stk(l2+mn2),1,stk(l1)
$ ,stk(l1+mn1),1,stk(l1),stk(l1+mn1),1,mn1,ierr)
endif
endif
if(ierr.ne.0) then
if(ieee.eq.0) then
call error(27)
return
elseif(ieee.eq.1) then
call msgs(63)
endif
endif
endif
goto 999
c
c kronecker
65 fin = op - 3*dot - star + 19
fun = 6
top = top + 1
rhs = 2
go to 999
c
c
c transposition
70 if(mn1 .eq. 0.or.istk(il1).eq.0) then
goto 999
elseif(abs(m1).eq.1.or.abs(n1).eq.1) then
if(it1.eq.1.and.op.ne.quote+dot) then
call dscal(mn1,-1.0d0,stk(l1+mn1),1)
endif
else
vol=mn1*(it1+1)
ll = l1+vol
err = ll+vol - lstk(bot)
if (err .gt. 0) then
call error(17)
return
endif
call dcopy(vol,stk(l1),1,stk(ll),1)
call mtran(stk(ll),m1,stk(l1),n1,m1,n1)
if(it1.eq.1) then
call mtran(stk(ll+mn1),m1,stk(l1+mn1),n1,m1,n1)
if(op.ne.quote+dot) then
call dscal(mn1,-1.0d+0,stk(l1+mn1),1)
endif
endif
endif
istk(il1+1)=n1
istk(il1+2)=m1
goto 999
c
c concatenation [a b]
75 if(m1.lt.0.or.m2.lt.0) then
call error(14)
return
endif
if(m2.eq.0) then
return
elseif(m1.eq.0)then
call dcopy(lstk(top+2)-lstk(top+1),stk(lstk(top+1))
$ ,1,stk(lstk(top)),1)
lstk(top+1)=lstk(top)+lstk(top+2)-lstk(top+1)
return
elseif(m1.ne.m2) then
call error(5)
return
endif
c
if(itr.eq.0) then
call dcopy(mn2,stk(l2),1,stk(l1+mn1),1)
else
lw=l1+(itr+1)*(mn1+mn2)
if(lw.gt.l2) then
err=lw+mn2*(it2+1)-lstk(bot)
if(err.gt.0) then
call error(17)
return
endif
call dcopy(mn2*(it2+1),stk(l2),-1,stk(lw),-1)
l2=lw
endif
if(it1.eq.1) call dcopy(mn1,stk(l1+mn1),-1,stk(l1
$ +mn1+mn2),-1)
call dcopy(mn2,stk(l2),1,stk(l1+mn1),1)
if(it1.eq.0) then
call dset(mn1,0.0d+0,stk(l1+mn1+mn2),1)
call dcopy(mn2,stk(l2+mn2),1,stk(l1+2*mn1+mn2),1)
endif
if(it2.eq.0) then
call dset(mn2,0.0d+0,stk(l1+2*mn1+mn2),1)
else
call dcopy(mn2,stk(l2+mn2),1,stk(l1+2*mn1+mn2),1)
endif
endif
n=n1+n2
istk(il1+1)=m1
istk(il1+2)=n
istk(il1+3)=itr
lstk(top+1)=sadr(il1+4)+m1*n*(itr+1)
goto 999
c
c concatenation [a;b]
76 if(n1.lt.0.or.n2.lt.0) then
call error(14)
return
elseif(n2.eq.0) then
c . [a;[]]
goto 999
elseif(n1.eq.0)then
c . [[];b]
call dcopy(lstk(top+2)-lstk(top+1),stk(lstk(top+1))
$ ,1,stk(lstk(top)),1)
lstk(top+1)=lstk(top)+lstk(top+2)-lstk(top+1)
goto 999
elseif(n1.ne.n2) then
call error(6)
return
endif
m=m1+m2
mn=m*n1
if(n1.eq.1.and.itr.eq.0) then
call dcopy(mn2,stk(l2),1,stk(l1+mn1),1)
istk(il1+1)=m
istk(il1+3)=itr
lstk(top+1)=l1+mn*(itr+1)
goto 999
endif
c lw1=l1+(itr+1)*mn
lw1=max(lw,l1+(itr+1)*mn)
lw2=lw1+mn1*(it1+1)
err=lw2+mn2*(it2+1)-lstk(bot)
if(err.gt.0) then
call error(17)
return
endif
call dcopy(mn2*(it2+1),stk(l2),1,stk(lw2),1)
call dcopy(mn1*(it1+1),stk(l1),1,stk(lw1),1)
c
if(itr.eq.1) call dset(mn,0.0d+0,stk(l1+(mn1+mn2)),1)
call dmcopy(stk(lw1),m1,stk(l1),m,m1,n1)
if(it1.eq.1) call dmcopy(stk(lw1+mn1),m1,stk(l1+mn),m
$ ,m1,n1)
call dmcopy(stk(lw2),m2,stk(l1+m1),m,m2,n1)
if(it2.eq.1) call dmcopy(stk(lw2+mn2),m2,stk(l1+mn+m1)
$ ,m,m2,n1)
istk(il1+1)=m
istk(il1+2)=n1
istk(il1+3)=itr
lstk(top+1)=sadr(il1+4)+mn*(itr+1)
goto 999
c
c extraction
c
78 continue
if(rhs.gt.2) goto 82
c arg2(arg1)
if (istk(il1).eq.0) then
call error(220)
return
endif
if(istk(il2).eq.129) then
c implied polynomials vector extraction
top=top+1
call polops
goto 999
endif
if(mn2.eq.0) then
c . arg2=[]
il1=iadr(lstk(top))
istk(il1)=1
istk(il1+1)=0
istk(il1+2)=0
istk(il1+3)=0
lstk(top+1)=sadr(il1+4)
goto 999
elseif(m2.lt.0) then
c . arg2=eye
call error(14)
return
elseif(m1.lt.0) then
c . arg2(:), just reshape to column vector
il1=iadr(lstk(top))
istk(il1)=1
istk(il1+1)=mn2
istk(il1+2)=1
istk(il1+3)=istk(il2+3)
call dcopy(mn2*(it2+1),stk(l2),1,stk(l1),1)
lstk(top+1)=sadr(il1+4)+mn2*(it2+1)
goto 999
endif
c check and convert indices variable
call indxg(il1,mn2,ilr,mi,mx,lw,1)
if(err.gt.0) return
if(mx.gt.mn2) then
call error(21)
return
endif
79 if(mi.eq.0) then
c arg2([])
il1=iadr(lstk(top))
istk(il1)=1
istk(il1+1)=0
istk(il1+2)=0
istk(il1+3)=0
l1=sadr(il1+4)
lstk(top+1)=l1
goto 999
endif
c get memory for the result
il1=iadr(lstk(top))
l1=sadr(il1+4)
if(sadr(ilr-1).le.l1+(it2+1)*mi) then
lr=lw
lw=lr+(it2+1)*mi
err=lw-lstk(bot)
if(err.gt.0) then
call error(17)
return
endif
else
lr=l1
endif
c perform extraction
do 81 i = 0, mi-1
ind=istk(ilr+i)-1
stk(lr+i) = stk(l2+ind)
if(it2.eq.1) stk(lr+mi+i) = stk(l2+mn2+ind)
81 continue
c set output sizes
if (m2.eq.1.and.n2.eq.1.and.m1.gt.0) then
m = m1
n = min(n1,mi)
elseif (m2 .gt. 1.or.m1.lt.0) then
m = mi
n = 1
else
n = mi
m = 1
endif
c form resulting variable
istk(il1)=1
istk(il1+1)=m
istk(il1+2)=n
istk(il1+3)=it2
if(lr.ne.l1) call dcopy(mi*(it2+1),stk(lr),1,stk(l1),1)
lstk(top+1)=l1+mi*(it2+1)
go to 999
c
c arg3(arg1,arg2)
82 if(rhs.gt.3) then
call error(36)
return
endif
if(mn3.eq.0) then
c . arg3=[]
il1=iadr(lstk(top))
istk(il1)=1
istk(il1+1)=0
istk(il1+2)=0
istk(il1+3)=0
lstk(top+1)=sadr(il1+4)
goto 999
elseif(m3.lt.0) then
c .arg3=eye
call error(14)
return
endif
c check and convert indices variables
call indxg(il1,m3,ili,mi,mxi,lw,1)
if(err.gt.0) return
if(mxi.gt.m3) then
call error(21)
return
endif
call indxg(il2,n3,ilj,nj,mxj,lw,1)
if(err.gt.0) return
if(mxj.gt.n3) then
call error(21)
return
endif
c
90 mn=mi*nj
if(mn.eq.0) then
c . arg1=[] or arg2=[]
il1=iadr(lstk(top))
istk(il1)=1
istk(il1+1)=0
istk(il1+2)=0
istk(il1+3)=0
lstk(top+1)=sadr(il1+4)
goto 999
endif
c get memory for the result
il1=iadr(lstk(top))
l1=sadr(il1+4)
if(sadr(ili-1).le.l1+(it3+1)*mi*nj) then
lr=lw
lw=lr+(it3+1)*mi*nj
err=lw-lstk(bot)
if(err.gt.0) then
call error(17)
return
endif
else
c . the result may be installed at its final place
lr=l1
endif
c perform extraction
l=lr
do 94 j = 0, nj-1
do 93 i = 0, mi-1
ind=istk(ili+i)-1+(istk(ilj+j)-1)*m3
stk(l) = stk(l3+ind)
if(it3.eq.1) stk(l+mn) = stk(l3+mn3+ind)
l=l+1
93 continue
94 continue
c form the resulting variable
istk(il1)=1
istk(il1+1)=mi
istk(il1+2)=nj
istk(il1+3)=it3
if(lr.ne.l1) call dcopy(mn*(it3+1),stk(lr),1,stk(l1),1)
lstk(top+1)=l1+mn*(it3+1)
go to 999
c
c insertion
c
95 continue
if(rhs.eq.4) goto 100
c arg3(arg1)=arg2
c
if (istk(il2)*istk(il1).eq.0) then
call error(220)
return
endif
if (m2.eq.0) then
c . arg3(arg1)=[] -->[]
if(m1.eq.-1) then
c . arg3(:)=[]
istk(il1)=1
istk(il1+1)=0
istk(il1+2)=0
istk(il1+3)=0
lstk(top+1)=sadr(il1+4)
goto 999
elseif(m1.eq.0) then
c . arg3([])=[] --> arg3
call icopy(4,istk(il3),1,istk(il1),1)
l=sadr(il1+4)
call dcopy(mn3*(it3+1),stk(l3),1,stk(l),1)
lstk(top+1)=l+mn3*(it3+1)
goto 999
else
c . arg3(arg1)=[] -->arg3(compl(arg1),:)
call indxgc(il1,mn3,ilr,mi,mx,lw)
if(err.gt.0) return
l2=l3
n2=n3
m2=m3
mn2=m2*n2
it2=it3
c . call extraction
goto 79
endif
elseif(m2.lt.0.or.m3.lt.0) then
c . arg3=eye,arg2=eye
call error(14)
return
elseif(m1.lt.0) then
c . arg3(:)=arg2
if(mn2.eq.mn3) then
istk(il1)=1
istk(il1+1)=m3
istk(il1+2)=n3
istk(il1+3)=it2
l1=sadr(il1+4)
call dcopy((it2+1)*mn2,stk(l2),1,stk(l1),1)
lstk(top+1)=l1+mn2*(it2+1)
return
elseif(mn2.eq.1) then
istk(il1)=1
istk(il1+1)=m3
istk(il1+2)=n3
istk(il1+3)=it2
l1=sadr(il1+4)
call dset(mn3,stk(l2),stk(l1),1)
if(it2.eq.1) call dset(mn3,stk(l2+1),stk(l1+mn3),1)
lstk(top+1)=l1+mn3*(it2+1)
return
else
call error(15)
return
endif
endif
call indxg(il1,mn3,ili,mi,mxi,lw,1)
if(err.gt.0) return
if(mi.eq.0) then
c . arg3([])=arg2
if(mn2.eq.1) then
c . arg3([])=c --> arg3
call icopy(4,istk(il3),1,istk(il1),1)
l=sadr(il1+4)
call dcopy(mn3*(it3+1),stk(l3),1,stk(l),1)
lstk(top+1)=l+mn3*(it3+1)
goto 999
else
call error(15)
return
endif
endif
inc2=1
if(mi.ne.mn2) then
if(mn2.eq.1) then
inc2=0
else
call error(15)
return
endif
endif
c
if (n3.gt.1.and.m3.gt.1) then
c . arg3 is not a vector
if(n2.gt.1.and.m2.gt.1) then
call error(15)
return
endif
if(mxi.gt.m3*n3) then
call error(21)
return
endif
mr=m3
nr=n3
elseif (n3.le.1.and.n2.le.1) then
c . arg3 and arg2 are column vectors
mr=max(m3,mxi)
nr=max(n3,1)
elseif (m3.le.1.and.m2.le.1) then
c . row vectors
nr=max(n3,mxi)
mr=max(m3,1)
else
c . arg3 and arg2 dimensions dont agree
call error(15)
return
endif
lr=l3
mnr=mr*nr
itr=max(it2,it3)
if(mnr*(itr+1).ne.mn3*(it3+1) ) then
c . resulting matrix is bigger than original
lr=lw
lw=lr + mnr*(itr+1)
err = lw - lstk(bot)
if (err .gt. 0) then
call error(17)
return
endif
c . initialise result r to 0
call dset(mnr*(itr+1),0.0d+0,stk(lr),1)
c . write arg3 in r
if(mn3.ge.1) then
call dmcopy(stk(l3),m3,stk(lr),mr,m3,n3)
if(it3.eq.1) then
call dmcopy(stk(l3+mn3),m3,stk(lr+mnr),mr,m3,n3)
endif
endif
endif
c write arg2 in r
do 98 i = 0, mi-1
ll = lr+istk(ili+i) - 1
ls = l2+i*inc2
stk(ll) = stk(ls)
if(it2.eq.1) then
stk(ll+mnr)=stk(ls+mn2)
elseif(itr.eq.1) then
stk(ll+mnr)=0.0d0
endif
98 continue
c
if(lr.ne.l3) then
call dcopy(mnr*(itr+1),stk(lr),1,stk(l1),1)
istk(il1)=1
istk(il1+1)=mr
istk(il1+2)=nr
istk(il1+3)=itr
l1=sadr(il1+4)
lstk(top+1)=l1+mnr*(itr+1)
else
c la matrice a ete modifie sur place
k=istk(iadr(lstk(top0))+2)
istk(il1)=-1
istk(il1+1)=-1
istk(il1+2)=k
lstk(top+1)=lstk(top)+3
endif
goto 999
100 continue
c
c arg4(arg1,arg2)=arg3
if (istk(il3)*istk(il1)*istk(il2).eq.0) then
call error(220)
return
endif
if (m3.eq.0) then
c . arg4(arg1,arg2)=[]
if(m1.eq.-1.and.m2.eq.-1) then
c . arg4(:,:)=[] -->[]
istk(il1)=1
istk(il1+1)=0
istk(il1+2)=0
istk(il1+3)=0
lstk(top+1)=sadr(il1+4)
goto 999
elseif(m1.eq.0.or.m2.eq.0) then
c . arg4([],arg2)=[], arg4(arg1,[])=[] --> arg4
call icopy(4,istk(il4),1,istk(il1),1)
l=sadr(il1+4)
call dcopy(mn4*(it4+1),stk(l4),1,stk(l),1)
lstk(top+1)=l+mn4*(it4+1)
goto 999
elseif(m2.eq.-1) then
c . arg4(arg1,:)=[] --> arg4(compl(arg1),:)
call indxgc(il1,m4,ili,mi,mxi,lw)
if(err.gt.0) return
call indxg(il2,n4,ilj,nj,mxj,lw,1)
if(err.gt.0) return
l3=l4
n3=n4
m3=m4
mn3=m3*n3
it3=it4
c . call extraction
goto 90
elseif(m1.eq.-1) then
c . arg4(:,arg2)=[] --> arg4(:,compl(arg2))
call indxgc(il2,n4,ilj,nj,mxj,lw)
if(err.gt.0) return
call indxg(il1,m4,ili,mi,mxi,lw,1)
if(err.gt.0) return
l3=l4
n3=n4
m3=m4
mn3=m3*n3
it3=it4
c . call extraction
goto 90
else
c . arg4(arg1,arg2)=[]
lw1=lw
call indxgc(il2,n4,ilj,nj,mxj,lw)
if(err.gt.0) return
if(nj.eq.0) then
c . arg4(arg1,1:n4)=[]
lw2=lw
call indxgc(il1,m4,ili,mi,mxi,lw)
if(err.gt.0) return
if(mi.eq.0) then
c . arg4(1:m4,1:n4)=[]
istk(il1)=1
istk(il1+1)=0
istk(il1+2)=0
istk(il1+3)=0
lstk(top+1)=sadr(il1+4)
goto 999
else
c . arg4(arg1,1:n4)=[]
lw=lw2
call indxg(il2,n4,ilj,nj,mxj,lw,1)
if(err.gt.0) return
l3=l4
n3=n4
m3=m4
it3=it4
mn3=m3*n3
c . call extraction
goto 90
endif
else
call indxgc(il1,m4,ili,mi,mxi,lw)
if(err.gt.0) return
if(mi.eq.0) then
c . arg4(1:m4,arg2)=[]
call indxg(il1,m4,ili,mi,mxi,lw,1)
if(err.gt.0) return
l3=l4
n3=n4
m3=m4
it3=it4
mn3=m3*n3
c . call extraction
goto 90
else
call error(15)
return
endif
endif
endif
elseif(m3.lt.0.or.m4.lt.0) then
c . arg3=eye , arg4=eye
call error(14)
return
elseif(m1.eq.-1.and.m2.eq.-1) then
c . arg4(:,:)=arg3
if(mn3.eq.mn4) then
c . reshape arg3 according to arg4
istk(il1)=1
istk(il1+1)=m4
istk(il1+2)=n4
istk(il1+3)=it3
l1=sadr(il1+4)
call dcopy((it3+1)*mn4,stk(l3),1,stk(l1),1)
lstk(top+1)=l1+mn4*(it3+1)
return
elseif(mn3.eq.1) then
c . set all elements of arg4 to arg3
istk(il1)=1
istk(il1+1)=m4
istk(il1+2)=n4
istk(il1+3)=it3
l1=sadr(il1+4)
call dset(mn4,stk(l3),stk(l1),1)
if(it3.eq.1) call dset(mn4,stk(l3+1),stk(l1+mn4),1)
lstk(top+1)=l1+mn4*(it3+1)
return
else
call error(15)
return
endif
endif
call indxg(il1,m4,ili,mi,mxi,lw,1)
if(err.gt.0) return
call indxg(il2,n4,ilj,mj,mxj,lw,1)
if(err.gt.0) return
inc3=1
if(mi.ne.m3.or.mj.ne.n3) then
c . sizes of arg1 or arg2 dont agree with arg3 sizes
if(m3*n3.eq.1) then
if(mi.eq.0.or.mj.eq.0) then
call icopy(4,istk(il4),1,istk(il1),1)
l=sadr(il1+4)
call dcopy(mn4*(it4+1),stk(l4),1,stk(l),1)
lstk(top+1)=l+mn4*(it4+1)
goto 999
endif
inc3=0
else
call error(15)
return
endif
else
if(mi.eq.0.or.mj.eq.0) then
call error(15)
return
endif
endif
mr=max(m4,mxi)
nr=max(n4,mxj)
c
mnr=mr*nr
itr=max(it4,it3)
if(mnr*(itr+1).ne.mn4*(it4+1) ) then
lr=lw
lw=lr + mnr*(itr+1)
err = lw - lstk(bot)
if (err .gt. 0) then
call error(17)
return
endif
c . set result r to 0
call dset(mnr*(itr+1),0.0d+0,stk(lr),1)
c . copy arg4 in r
if(mn4.ge.1) then
call dmcopy(stk(l4),m4,stk(lr),mr,m4,n4)
if(it4.eq.1) then
call dmcopy(stk(l4+mn4),m4,stk(lr+mnr),mr,m4,n4)
endif
endif
else
lr=l4
endif
c
c copy arg3 elements in r
do 115 j = 0, mj-1
ljj = istk(ilj+j) - 1
do 114 i = 0, mi-1
ll = lr+istk(ili+i)-1+ljj*mr
ls = l3+(i+j*m3)*inc3
stk(ll) = stk(ls)
if(it3.eq.1) then
stk(ll+mnr)=stk(ls+mn3)
elseif(itr.eq.1) then
stk(ll+mnr)=0.0d0
endif
114 continue
115 continue
c
if(lr.ne.l4) then
call dcopy(mnr*(itr+1),stk(lr),1,stk(l1),1)
istk(il1)=1
istk(il1+1)=mr
istk(il1+2)=nr
istk(il1+3)=itr
l1=sadr(il1+4)
lstk(top+1)=l1+mnr*(itr+1)
else
c la matrice a ete modifie sur place
k=istk(iadr(lstk(top0))+2)
istk(il1)=-1
istk(il1+1)=-1
istk(il1+2)=k
lstk(top+1)=lstk(top)+3
endif
goto 999
c
c *. /. \.
120 fin=-fin
top=top+1
goto 999
c
130 continue
if(fin.eq.61) then
fin=-fin
top=top+1
goto 999
endif
c comparaisons
if(m1.eq.-1) then
c . eye op b
err=lw+mn2*(it1+1)-lstk(bot)
if(err.gt.0) then
call error(17)
return
endif
if(m2.eq.-1) then
m2=1
n2=1
elseif(mn2.gt.0) then
call dset(mn2,0.0d0,stk(lw),1)
call dset(min(m2,n2),stk(l1),stk(lw),m2+1)
if(it1.eq.1) then
call dset(mn2,0.0d0,stk(lw+mn2),1)
call dset(min(m2,n2),stk(l1+1),stk(lw+mn2),m2+1)
endif
l1=lw
endif
m1=m2
n1=n2
mn1=mn2
istk(il1+1)=m1
istk(il1+2)=n1
elseif(m2.eq.-1) then
err=lw+mn1*(it2+1)-lstk(bot)
if(err.gt.0) then
call error(17)
return
endif
call dset(mn1,0.0d0,stk(lw),1)
call dset(min(m1,n1),stk(l2),stk(lw),m1+1)
if(it1.eq.1) then
call dset(mn1,0.0d0,stk(lw+mn1),1)
call dset(min(m1,n1),stk(l2+1),stk(lw+mn1),m1+1)
endif
l2=lw
mn2=mn1
m2=m1
n2=n1
elseif(mn1.eq.1.and.mn2.gt.1) then
err=lw+mn2*(it1+1)-lstk(bot)
if(err.gt.0) then
call error(17)
return
endif
call dset(mn2,stk(l1),stk(lw),1)
if(it1.eq.1) call dset(mn2,stk(l1+1),stk(lw+mn2),1)
l1=lw
mn1=mn2
m1=m2
n1=n2
istk(il1+1)=m1
istk(il1+2)=n1
elseif(mn2.eq.1.and.mn1.gt.1) then
err=lw+mn1*(it2+1)-lstk(bot)
if(err.gt.0) then
call error(17)
return
endif
call dset(mn1,stk(l2),stk(lw),1)
if(it1.eq.1) call dset(mn1,stk(l2+1),stk(lw+mn1),1)
l2=lw
mn2=mn1
m2=m1
n2=n1
endif
if(mn2.eq.0.or.mn1.eq.0) then
if(op.eq.equal.or.op.eq.less+great) then
itrue=0
if(mn2.eq.0.and.mn1.eq.0) itrue=1
if(op.eq.less+great) itrue=1-itrue
istk(il1)=4
istk(il1+1)=1
istk(il1+2)=1
istk(il1+3)=itrue
lstk(top+1)=sadr(il1+4)
goto 999
else
if(mn1.eq.1.or.mn2.eq.1) then
istk(il1)=1
istk(il1+1)=0
istk(il1+2)=0
istk(il1+3)=0
lstk(top+1)=sadr(il1+4)
goto 999
else
call error(60)
return
endif
endif
endif
if(n1.ne.n2.or.m1.ne.m2) then
if(op.eq.equal.or.op.eq.less+great) then
istk(il1)=4
istk(il1+1)=1
istk(il1+2)=1
istk(il1+3)=0
if(op.eq.less+great) istk(il1+3)=1
lstk(top+1)=sadr(il1+4)
else
call error(60)
return
endif
else if(max(it1,it2).eq.1) then
if(op.ne.equal.and.op.ne.less+great) then
call error(57)
return
endif
itrue=1
if(op.eq.less+great) itrue=0
istk(il1)=4
do 131 i=0,mn1-1
e1r=stk(l1+i)
e2r=stk(l2+i)
e1i=0.0d+0
e2i=0.0d+0
if(it1.eq.1) e1i=stk(l1+mn1+i)
if(it2.eq.1) e2i=stk(l2+mn2+i)
if(e1r.eq.e2r.and.e1i.eq.e2i) then
istk(il1+3+i)=itrue
else
istk(il1+3+i)=1-itrue
endif
131 continue
lstk(top+1)=sadr(il1+3+mn1)
else
istk(il1)=4
if(mn1.eq.0) then
if(op.ne.equal.and.op.ne.less+great) then
call error(57)
else
istk(il1+1)=1
istk(il1+2)=1
istk(il1+3)=1
if(op.ne.equal) istk(il1+3)=0
lstk(top+1)=sadr(il1+4)
endif
return
endif
do 132 i=0,mn1-1
e1=stk(l1+i)
e2=stk(l2+i)
c for vc++ we add an explicit test for nan
if(isanan(e1).eq.1.and.isanan(e2).eq.1) then
if (op.eq.less+great) then
istk(il1+3+i)=1
else
istk(il1+3+i)=0
endif
elseif( (op.eq.equal .and. e1.eq.e2) .or.
& (op.eq.less+great .and. e1.ne.e2) .or.
& (op.eq.less .and. e1.lt.e2) .or.
& (op.eq.great .and. e1.gt.e2) .or.
& (op.eq.(less+equal) .and. e1.le.e2) .or.
& (op.eq.(great+equal) .and. e1.ge.e2) ) then
istk(il1+3+i)=1
else
istk(il1+3+i)=0
endif
132 continue
lstk(top+1)=sadr(il1+3+mn1)
endif
goto 999
c
140 continue
if((op.eq.non.and.mn1.eq.0).or.((op.eq.et.or.op.eq.ou)
& .and.(mn1.eq.0.or.mn2.eq.0))) then
istk(il1)=1
istk(il1+1)=0
istk(il1+2)=0
istk(il1+3)=0
lstk(top+1)=sadr(il1+4)
goto 999
else
top=top0
fin=-fin
return
endif
c
999 return
end
|