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
|
subroutine lspops
c
c operations on boolean sparse matrices
c
c Copyright INRIA
include '../stack.h'
integer op
c
integer iadr,sadr
c
integer star,dstar,dot,colon
integer less,great,equal,ou,et,non
integer insert,extrac
integer top0
logical isany
c
data star/47/,dstar/62/,dot/51/,colon/44/
data less/59/,great/60/,equal/50/
data ou/57/,et/58/,non/61/
data insert/2/,extrac/3/
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,' lspops op: '//buf(1:4))
endif
c
top0=top
lw=lstk(top+1)+1
if(op.eq.extrac) goto 70
if(op.eq.insert) goto 80
it2=0
goto (04,03,02,01) rhs
call error(39)
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)
if(istk(il4).eq.6) then
nel4=istk(il4+4)
irc4=il4+5
l4=sadr(irc4+m4+nel4)
else
nel4=m4*n4
l4=sadr(il4+4)
endif
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)
if(istk(il3).eq.6) then
nel3=istk(il3+4)
irc3=il3+5
l3=sadr(irc3+m3+nel3)
else
l3=sadr(il3+4)
nel3=m3*n3
endif
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)
if(istk(il2).eq.6) then
nel2=istk(il2+4)
irc2=il2+5
l2=sadr(irc2+m2+nel2)
else
l2=sadr(il2+4)
nel2=m2*n2
endif
mn2=m2*n2
top=top-1
c
04 il1=iadr(lstk(top))
il1r=il1
if(istk(il1).lt.0) il1=iadr(istk(il1+1))
m1=istk(il1+1)
n1=istk(il1+2)
it1=istk(il1+3)
if(istk(il1).eq.6) then
nel1=istk(il1+4)
irc1=il1+5
l1=sadr(irc1+m1+nel1)
else
l1=sadr(il1+4)
nel1=m1*n1
endif
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 column concatenation
if(op.eq.1) goto 65
c row concatenation
if(op.eq.4) goto 66
c : + - * / \ = '
goto(07,07,07,07,07,07,130,05,05,60) op+1-colon
if(op.eq.ou.or.op.eq.et) goto 20
if(op.eq.non) goto 30
c
05 if(op.eq.dstar) goto 07
if(op.ge.3*dot+star) goto 07
if(op.ge.2*dot+star) goto 07
if(op.ge.less+equal) goto 130
if(op.ge.dot+star) goto 07
if(op.ge.less) goto 130
06 call error(43)
return
c
07 fin=-fin
top=top0
go to 999
c
c ou/et logique
20 if(istk(il1).ne.6.or.istk(il2).ne.6) then
fin=-fin
top=top0
go to 999
endif
if(mn1.eq.1.and.mn2.gt.1) then
top=top0
fin=-fin
return
elseif(mn2.eq.1.and.mn1.gt.1) then
top=top0
fin=-fin
return
else if (n1 .ne. n2.or.m1.ne.m2) then
call error(60)
return
endif
irc=iadr(lw)
nelmx=iadr(lstk(bot))-irc-m1-10
lw=sadr(irc+m1+nelmx)
err=lw-lstk(bot)
if(err.gt.0) then
call error(17)
return
endif
nel=nelmx
if(fin.eq.ou) then
call lspasp(m1,n1,nel1,istk(irc1),nel2,istk(irc2),nel,
$ istk(irc),ierr)
else
call lspxsp(m1,n1,nel1,istk(irc1),nel2,istk(irc2),nel,
$ istk(irc),ierr)
endif
if(ierr.ne.0) then
call error(17)
return
endif
istk(il1+3)=0
istk(il1+4)=nel
call icopy(m1+nel,istk(irc),1,istk(irc1),1)
l1=sadr(irc1+m1+nel)
lstk(top+1)=l1
go to 999
c NOT
30 continue
lw=iadr(lstk(top+1))
err=sadr(lw+m1*n1-nel1+m1)-lstk(bot)
if(err.gt.0) then
call error(17)
return
endif
istk(il1+4)=m1*n1-nel1
ij2=lw
ij1=irc1+m1
c may be improved
do 35 i=0,m1-1
do 31 j=1,n1
istk(ij2+j-1)=j
31 continue
do 32 j=1,istk(irc1+i)
istk(ij2+istk(ij1+j-1)-1)=0
32 continue
j1=0
do 33 j=1,n1
if(istk(ij2+j-1).ne.0) then
j1=j1+1
istk(ij2+j1-1)=istk(ij2+j-1)
endif
33 continue
ij2=ij2+j1
ij1=ij1+istk(irc1+i)
istk(irc1+i)=n1-istk(irc1+i)
35 continue
call icopy(ij2-lw,istk(lw),1,istk(irc1+m1),1)
lstk(top+1)=sadr(irc1+m1+ij2-lw)
goto 999
c
c
c transposition
60 istk(il1+1)=n1
istk(il1+2)=m1
if(nel1.eq.0) then
lw=sadr(il1+5+n1)
err=lw-lstk(bot)
if(err.gt.0) then
call error(17)
return
endif
call iset(n1,0,istk(il1+5),1)
lstk(top+1)=lw
goto 999
endif
ia=iadr(lw)
iat=ia+m1+1
irc=iat+n1+1
lw=sadr(irc+n1+nel1)
err=lw-lstk(bot)
if(err.gt.0) then
call error(17)
return
endif
istk(ia)=1
do 61 i=1,m1
istk(ia+i)=istk(ia+i-1)+istk(irc1+i-1)
61 continue
call lspt(m1,n1,nel1,istk(irc1),istk(ia),
$ istk(iat),istk(irc))
call icopy(n1+nel1,istk(irc),1,istk(irc1),1)
l1=sadr(irc1+n1+nel1)
lstk(top+1)=l1
goto 999
c
c concatenation [a b]
65 continue
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 icopy(5+m2+nel2,istk(il2),1,istk(il1),1)
l1=sadr(il1+5+m2+nel2)
lstk(top+1)=l1
return
elseif(m1.ne.m2) then
call error(5)
return
endif
if(istk(il1).ne.6.or.istk(il2).ne.6) then
top=top0
fin=-fin
return
endif
c
nelr=nel1+nel2
istk(il1+2)=n1+n2
istk(il1+3)=0
istk(il1+4)=nelr
irc=iadr(lw)
lw=sadr(irc+m1+nelr)
err=lw-lstk(bot)
if(err.gt.0) then
call error(17)
return
endif
call lspcsp(0,m1,n1,nel1,istk(irc1),
$ m2,n2,nel2,istk(irc2),
$ nelr,istk(irc))
call icopy(m1+nelr,istk(irc),1,istk(irc1),1)
l1=sadr(irc1+m1+nelr)
lstk(top+1)=l1
return
c
c concatenation [a;b]
66 continue
if(n1.lt.0.or.n2.lt.0) then
call error(14)
return
endif
if(n2.eq.0) then
goto 999
elseif(n1.eq.0)then
call icopy(5+m2+nel2,istk(il2),1,istk(il1),1)
l1=sadr(il1+5+m2+nel2)
lstk(top+1)=l1
goto 999
elseif(n1.ne.n2) then
call error(6)
return
endif
if(istk(il1).ne.6.or.istk(il2).ne.6) then
top=top0
fin=-fin
return
endif
nelr=nel1+nel2
istk(il1+1)=m1+m2
istk(il1+3)=0
istk(il1+4)=nelr
irc=iadr(lw)
lw=sadr(irc+m1+m2+nelr)
err=lw-lstk(bot)
if(err.gt.0) then
call error(17)
return
endif
call lspcsp(1,m1,n1,nel1,istk(irc1),
$ m2,n2,nel2,istk(irc2),
$ nelr,istk(irc))
call icopy(m1+m2+nelr,istk(irc),1,istk(irc1),1)
l1=sadr(irc1+m1+m2+nelr)
lstk(top+1)=l1
goto 999
c
c extraction
c
70 continue
if(rhs.gt.2) goto 75
c arg2(arg1)
c get arg2
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)
nel2=istk(il2+4)
irc2=il2+5
l2=sadr(irc2+m2+nel2)
mn2=m2*n2
top=top-1
c get arg1
il1=iadr(lstk(top))
ilrs=il1
if(istk(il1).lt.0) il1=iadr(istk(il1+1))
m1=istk(il1+1)
c
if(mn2.eq.0) then
c . arg2=[]
ilrs=iadr(lstk(top))
istk(ilrs)=1
istk(ilrs+1)=0
istk(ilrs+2)=0
istk(ilrs+3)=0
lstk(top+1)=sadr(ilrs+4)+1
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
if(n2.eq.1) then
call icopy(5+m2+nel2,istk(il2),1,istk(ilrs),1)
l1=sadr(ilrs+5+m2+nel2)
lstk(top+1)=l1
else
c . reshape to column vector
ilrs=iadr(lstk(top))
istk(ilrs)=6
istk(ilrs+1)=mn2
istk(ilrs+2)=1
istk(ilrs+3)=0
istk(ilrs+4)=nel2
irc1=ilrs+5
l1=sadr(ilrs+5+m2*n2+nel2)
ircr=iadr(lw)
iw=ircr+m2*n2+nel2
lw=sadr(iw+3*nel2)
err=lw-lstk(bot)
if(err.gt.0) then
call error(17)
return
endif
call lspmat(m2,n2,nel2,istk(irc2),m2*n2,istk(ircr),istk(iw))
call icopy(m2*n2+nel2,istk(ircr),1,istk(irc1),1)
lstk(top+1)=l1
endif
return
elseif(m2.gt.1.and.n2.gt.1) then
c . call macro coded operation
top=top0
fin=-fin
return
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
72 if(mi.eq.0) then
c arg2([])
ilrs=iadr(lstk(top))
istk(ilrs)=1
istk(ilrs+1)=0
istk(ilrs+2)=0
istk(ilrs+3)=0
lstk(top+1)=sadr(ilrs+4)+1
goto 999
endif
c set output sizes
if (m2 .gt. 1.or.m1.lt.0) then
c . column vector
m=mi
n=-1
mr = mi
nr = 1
else
c . row vector
m=-1
n=mi
nr = mi
mr = 1
endif
lptr=iadr(lw)
irc=lptr+m2+1
lw=sadr(irc+mr)
nelr=iadr(lstk(bot))-iadr(lw)
if(nelr.le.0) then
err=lw-lstk(bot)
call error(17)
return
endif
lw=sadr(irc+mr+nelr)
nel=nelr
call lspe2(m2,n2,nel2,istk(irc2),
$ istk(ilr),m,istk(ilr),n,mr,nr,
$ nelr,istk(irc),istk(lptr),ierr)
ilrs=iadr(lstk(top))
istk(ilrs)=6
istk(ilrs+1)=mr
istk(ilrs+2)=nr
istk(ilrs+3)=0
istk(ilrs+4)=nelr
call icopy(m+nelr,istk(irc),1,istk(ilrs+5),1)
l1=sadr(ilrs+5+mr+nelr)
lstk(top+1)=l1
go to 999
c
c arg3(arg1,arg2)
75 if(rhs.gt.3) then
call error(36)
return
endif
c get arg3
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)
nel3=istk(il3+4)
irc3=il3+5
l3=sadr(irc3+m3+nel3)
mn3=m3*n3
top=top-1
c get arg2
il2=iadr(lstk(top))
if(istk(il2).lt.0) il2=iadr(istk(il2+1))
m2=istk(il2+1)
top=top-1
c get arg1
il1=iadr(lstk(top))
ilrs=il1
if(istk(il1).lt.0) il1=iadr(istk(il1+1))
m1=istk(il1+1)
if(mn3.eq.0) then
c . arg3=[]
ilrs=iadr(lstk(top))
istk(ilrs)=1
istk(ilrs+1)=0
istk(ilrs+2)=0
istk(ilrs+3)=0
lstk(top+1)=sadr(ilrs+4)+1
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(mi.lt.0) then
mr=mxi
else
mr=mi
endif
call indxg(il2,n3,ilj,nj,mxj,lw,1)
if(err.gt.0) return
if(nj.lt.0) then
nr=mxj
else
nr=nj
endif
c
76 continue
mn=mr*nr
if(mn.eq.0) then
c . arg1=[] or arg2=[]
ilrs=iadr(lstk(top))
istk(ilrs)=1
istk(ilrs+1)=0
istk(ilrs+2)=0
istk(ilrs+3)=0
lstk(top+1)=sadr(ilrs+4)+1
goto 999
endif
lptr=iadr(lw)
irc=lptr+m3+1
lw=sadr(irc+mr)
nelr=iadr(lstk(bot))-iadr(lw)
if(nelr.le.0) then
err=lw-lstk(bot)
call error(17)
return
endif
lw=sadr(irc+mr+nelr)
nel=nelr
call lspe2(m3,n3,nel3,istk(irc3),istk(ili),mi,
$ istk(ilj),nj,mr,nr,nelr,istk(irc),istk(lptr),ierr)
ilrs=iadr(lstk(top))
istk(ilrs)=6
istk(ilrs+1)=mr
istk(ilrs+2)=nr
istk(ilrs+3)=0
istk(ilrs+4)=nelr
call icopy(mr+nelr,istk(irc),1,istk(ilrs+5),1)
l1=sadr(ilrs+5+mr+nelr)
lstk(top+1)=l1
go to 999
c
c insert
80 continue
if(rhs.eq.4) goto 90
c arg3(arg1)=arg2
c get arg3
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)
if(istk(il3).eq.6) then
nel3=istk(il3+4)
irc3=il3+5
l3=sadr(irc3+m3+nel3)
else
top=top0
fin=-fin
return
endif
mn3=m3*n3
c get arg2
top=top-1
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)
if(istk(il2).eq.6) then
nel2=istk(il2+4)
irc2=il2+5
l2=sadr(irc2+m2+nel2)
elseif(istk(il2).eq.4) then
l2=il2+3
nel2=m2*n2
elseif(istk(il2).eq.1.and.m2*n2.eq.0) then
l2=sadr(il2+4)
nel2=m2*n2
istk(il2)=4
l2=il2+3
else
top=top0
fin=-fin
return
endif
mn2=m2*n2
c get arg1
top=top-1
il1=iadr(lstk(top))
ilrs=il1
if(istk(il1).lt.0) il1=iadr(istk(il1+1))
if (istk(il1).eq.10.or.istk(il1).eq.15) then
top=top0
fin=-fin
return
endif
m1=istk(il1+1)
n1=istk(il1+2)
if (m2.eq.0) then
c . arg3(arg1)=[] -->[]
if(m1.eq.-1) then
c . arg3(:)=[]
ilrs=iadr(lstk(top))
istk(ilrs)=1
istk(ilrs+1)=0
istk(ilrs+2)=0
istk(ilrs+3)=0
lstk(top+1)=sadr(ilrs+4)+1
goto 999
elseif(m1.eq.0) then
c . arg3([])=[] --> arg3
call icopy(5+m3+nel3,istk(il3),1,istk(ilrs),1)
l=sadr(ilrs+5+m3+nel3)
lstk(top+1)=l
goto 999
else
c . arg3(arg1)=[]
if(istk(il1).eq.4.and.m3.eq.m1.and.n3.eq.n1) then
if(.not.isany(il1)) then
c . arg3([])=[] --> arg3
call icopy(5+m3+nel3,istk(il3),1,istk(ilrs),1)
l=sadr(ilrs+5+m3+nel3)
lstk(top+1)=l
goto 999
endif
endif
c . arg3(arg1)=[] -->arg3(compl(arg1),:)
if(m3.gt.1.and.n3.gt.1) then
c . call macro coded op to reshape and insert
top=top0
fin=-fin
return
else
call indxgc(il1,mn3,ilr,mi,mx,lw)
if(err.gt.0) return
l2=l3
n2=n3
m2=m3
mn2=m2*n2
it2=it3
nel2=nel3
irc2=irc3
c . call extraction
goto 72
endif
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 reshape arg2 according to arg3
if(mn2.ne.mn3) then
call error(15)
return
endif
if(m2.ne.m3) then
top=top0
fin=-fin
return
endif
ilrs=iadr(lstk(top))
istk(ilrs)=6
istk(ilrs+1)=m3
istk(ilrs+2)=n3
call icopy(2+m2+nel2,istk(il2+3),1,istk(ilrs+3),1)
l1=sadr(ilrs+5+m2+nel2)
lstk(top+1)=l1
return
elseif(m3.gt.1.and.n3.gt.1) then
c . arg3(arg1)=arg2 with arg3 not a vector
top=top0
fin=-fin
return
endif
call indxg(il1,mn3,ili,mi,mxi,lw,1)
if(err.gt.0) return
if(mi.eq.0) then
c . arg3([])=arg2
call error(15)
return
endif
if(mi.ne.mn2) then
call error(15)
return
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
c set output sizes
if (m3 .gt. 1.or.m1.lt.0) then
c . column vector
m=mi
n=-1
mr = mi
nr = 1
else
c . row vector
m=-1
n=mi
nr = mi
mr = 1
endif
c
lptr=iadr(lw)
irc=lptr+mr+1
nelr=iadr(lstk(bot))-irc-mr
if(nelr.le.0) then
err=lw-lstk(bot)
call error(17)
return
endif
lw=sadr(irc+mr+nelr)
nel=nelr
if(istk(il3).eq.6) then
if(istk(il2).eq.6) then
call lspisp(m3,n3,nel3,istk(irc3),istk(ili),m,istk(ili),n,m2
$ ,n2,nel2,istk(irc2),mr,nr,nelr,istk(irc),istk(lptr)
$ ,ierr)
elseif(istk(il2).eq.4) then
call lspis(m3,n3,nel3,istk(irc3),istk(ili),m,istk(ili),n,m2
$ ,n2,istk(l2),mr,nr,nelr,istk(irc),ierr)
endif
endif
if(ierr.ne.0) then
buf='not enough memory'
call error(9999)
return
endif
ilrs=iadr(lstk(top))
istk(ilrs)=6
istk(ilrs+1)=mr
istk(ilrs+2)=nr
istk(ilrs+3)=0
istk(ilrs+4)=nelr
call icopy(mr+nelr,istk(irc),1,istk(ilrs+5),1)
l1=sadr(ilrs+5+mr+nelr)
lstk(top+1)=l1
go to 999
c
90 continue
c arg4(arg1,arg2)=arg3
c get arg4
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)
if(istk(il4).eq.6) then
nel4=istk(il4+4)
irc4=il4+5
l4=sadr(irc4+m4+nel4)
else
top=top0
fin=-fin
return
endif
mn4=m4*n4
c get arg3
top=top-1
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)
if(istk(il3).eq.6) then
nel3=istk(il3+4)
irc3=il3+5
l3=sadr(irc3+m3+nel3)
elseif(istk(il3).eq.4) then
nel3=m3*n3
l3=il3+3
elseif(istk(il3).eq.1.and.m3*n3.eq.0) then
l3=sadr(il3+4)
nel3=m3*n3
istk(il3)=4
l3=il3+3
else
top=top0
fin=-fin
return
endif
mn3=m3*n3
c get arg2
top=top-1
il2=iadr(lstk(top))
if(istk(il2).lt.0) il2=iadr(istk(il2+1))
m2=istk(il2+1)
c get arg1
top=top-1
il1=iadr(lstk(top))
ilrs=il1
if(istk(il1).lt.0) il1=iadr(istk(il1+1))
m1=istk(il1+1)
if (m3.eq.0) then
c . arg4(arg1,arg2)=[]
if(m1.eq.-1.and.m2.eq.-1) then
c . arg4(:,:)=[] -->[]
ilrs=iadr(lstk(top))
istk(ilrs)=1
istk(ilrs+1)=0
istk(ilrs+2)=0
istk(ilrs+3)=0
lstk(top+1)=sadr(ilrs+4)+1
goto 999
elseif(m1.eq.0.or.m2.eq.0) then
c . arg4([],arg2)=[], arg4(arg1,[])=[] --> arg4
call icopy(5+m4+nel4,istk(il4),1,istk(ilrs),1)
l=sadr(ilrs+5+m4+nel4)
lstk(top+1)=l
goto 999
elseif(m2.eq.-1) then
c . arg3(arg1,:)=[] --> arg3(compl(arg1),:)
call indxgc(il1,m4,ili,mi,mxi,lw)
if(err.gt.0) return
mr=mi
call indxg(il2,n4,ilj,nj,mxj,lw,1)
if(err.gt.0) return
if(nj.lt.0) then
nr=mxj
else
nr=nj
endif
l3=l4
n3=n4
m3=m4
mn3=m3*n3
it3=it4
irc3=irc4
nel3=nel4
c . call extraction
goto 76
elseif(m1.eq.-1) then
c . arg3(:,arg2)=[] --> arg3(:,compl(arg2))
call indxgc(il2,n4,ilj,nj,mxj,lw)
if(err.gt.0) return
nr=nj
call indxg(il1,m4,ili,mi,mxi,lw,1)
if(err.gt.0) return
if(mi.lt.0) then
mr=mxi
else
mr=mi
endif
l3=l4
n3=n4
m3=m4
mn3=m3*n3
it3=it4
irc3=irc4
nel3=nel4
c . call extraction
goto 76
else
c . arg4(arg1,arg2)=[]
lw1=lw
call indxgc(il2,n4,ilj,nj,mxj,lw)
if(err.gt.0) return
nr=nj
if(nj.eq.0) then
c . arg4(arg1,1:n4)=[]
call indxgc(il1,m4,ili,mi,mxi,lw)
lw2=lw
if(err.gt.0) return
mr=mi
c . arg2=1:n4
if(mi.eq.0) then
c . arg4(1:m4,1:n4)=[]
ilrs=iadr(lstk(top))
istk(ilrs)=1
istk(ilrs+1)=0
istk(ilrs+2)=0
istk(ilrs+3)=0
lstk(top+1)=sadr(ilrs+4)+1
goto 999
else
c . arg4(arg1,1:n4)=[]
c . replace arg2 by ":"
il2=iadr(lw2)
istk(il2)=1
istk(il2+1)=-1
istk(il2+2)=-1
istk(il2+3)=0
c .
lw=lw2+2
call indxg(il2,n4,ilj,nj,mxj,lw,1)
if(err.gt.0) return
if(nj.lt.0) then
nr=mxj
else
nr=nj
endif
l3=l4
n3=n4
m3=m4
it3=it4
mn3=m3*n3
irc3=irc4
nel3=nel4
c . call extraction
goto 76
endif
else
lw=lw1
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
if(mi.lt.0) then
mr=mxi
else
mr=mi
endif
l3=l4
n3=n4
m3=m4
it3=it4
mn3=m3*n3
irc3=irc4
nel3=nel4
c . call extraction
goto 76
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.ne.mn4) then
call error(15)
return
endif
if(m3.ne.m4) then
top=top0
fin=-fin
return
endif
c . reshape arg3 according to arg4
ilrs=iadr(lstk(top))
istk(ilrs)=6
istk(ilrs+1)=m4
istk(ilrs+2)=n4
call icopy(2+m3+nel3,istk(il3+3),1,istk(ilrs+3),1)
l1=sadr(ilrs+5+m3+nel3)
lstk(top+1)=l1
return
endif
call indxg(il1,m4,ili,mi,mxi,lw,1)
if(err.gt.0) return
if(mi.lt.0) then
mr1=mxi
else
mr1=mi
endif
call indxg(il2,n4,ilj,mj,mxj,lw,1)
if(err.gt.0) return
if(mj.lt.0) then
nr1=mxj
else
nr1=mj
endif
if(mr1.eq.0.or.nr1.eq.0) then
call error(15)
return
endif
if(mr1.ne.m3.or.nr1.ne.n3) then
c . sizes of arg1 or arg2 dont agree with arg3 sizes
call error(15)
return
endif
mr=max(m4,mxi)
nr=max(n4,mxj)
c
lptr=iadr(lw)
irc=lptr+mr+1
nelr=iadr(lstk(bot))-irc-mr
if(nelr.le.0) then
err=lw-lstk(bot)
call error(17)
return
endif
lw=sadr(irc+mr+nelr)
nel=nelr
if(istk(il4).eq.6) then
if(istk(il3).eq.6) then
call lspisp(m4,n4,nel4,istk(irc4),istk(ili),mi,istk(ilj),mj,
$ m3,n3,nel3,istk(irc3),mr,nr,nelr,istk(irc),istk(lptr)
$ ,ierr)
elseif(istk(il3).eq.4) then
l3=il3+3
call lspis(m4,n4,nel4,istk(irc4),istk(ili),mi,istk(ilj),mj
$ ,m3,n3,istk(l3),mr,nr,nelr,istk(irc),ierr)
endif
endif
if(ierr.ne.0) then
buf='not enough memory'
call error(9999)
return
endif
ilrs=iadr(lstk(top))
istk(ilrs)=6
istk(ilrs+1)=mr
istk(ilrs+2)=nr
istk(ilrs+3)=0
istk(ilrs+4)=nelr
call icopy(mr+nelr,istk(irc),1,istk(ilrs+5),1)
l1=sadr(ilrs+5+mr+nelr)
lstk(top+1)=l1
go to 999
c
130 continue
c comparaisons
if(mn2.eq.0.and.mn1.eq.0) then
if(op.eq.equal.or.op.eq.less+great) then
il1=iadr(lstk(top))
istk(il1)=4
istk(il1+1)=1
istk(il1+2)=1
istk(il1+3)=1
if(op.eq.less+great) istk(il1+3)=0
lstk(top+1)=sadr(il1+4)
goto 999
else
call error(60)
return
endif
endif
if(mn1.ne.1.and.mn2.ne.1) then
if(n1.ne.n2.or.m1.ne.m2) then
if(op.eq.equal.or.op.eq.less+great) then
il1=iadr(lstk(top))
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)
return
else
call error(60)
return
endif
endif
endif
if(istk(il1).ne.4.and.istk(il1).ne.6.or.istk(il2).ne.4.and
$ .istk(il2).ne.6) then
top=top0
fin=-fin
return
endif
c
mr=m1
nr=n1
if(m1*n1.eq.1) then
mr=m2
nr=n2
endif
irc=iadr(lw)
nelmx=(iadr(lstk(bot))-irc-mr-10)
lw=sadr(irc+mr+nelmx)
err=lw-lstk(bot)
if(err.gt.0) then
call error(17)
return
endif
nel=nelmx
if(istk(il1).eq.4) then
l1=il1+3
call lsosp(op,m1,n1,istk(l1),m2,n2,nel2,istk(irc2),nel,istk(irc
$ ),ierr)
elseif(istk(il2).eq.4) then
l2=il2+3
call lspos(op,m1,n1,nel1,istk(irc1),
$ m2,n2,istk(l2),nel,istk(irc),ierr)
else
call lsposp(op,m1,n1,nel1,istk(irc1),
$ m2,n2,nel2,istk(irc2),
$ nel,istk(irc),ierr)
endif
if(ierr.ne.0) then
buf='not enough memory'
call error(9999)
return
endif
il1=iadr(lstk(top))
istk(il1)=6
istk(il1+1)=mr
istk(il1+2)=nr
istk(il1+3)=0
istk(il1+4)=nel
irc1=il1+5
call icopy(mr+nel,istk(irc),1,istk(irc1),1)
l1=sadr(irc1+mr+nel)
lstk(top+1)=l1
go to 999
c
999 return
end
|