use Array: all; use StdIO : all; use Numerical : all; use CommandLine: all; use String: {to_string,tochar,sscanf}; use ArrayFormat: all; use Bits: all; /* Compiled by APEX Version: /home/apex/apex3/wss/sac3012.dws2012-02-23 14:45:02.508 */ /* % This is the APEX stdlib.sis include file. % Standard equates and constants for APL compiler % Also standard coercion functions */ #define toB(x) to_bool((x)) #define toI(x) toi((x)) #define toD(x) tod((x)) #define toC(x) (x) #define toc(x) ((x)) #define BtoB(x) ((x)) #define ItoI(x) ((x)) #define DtoD(x) ((x)) #define CtoC(x) ((x)) #define BtoI(x) toi((x)) #define BtoD(x) tod((x)) #define ItoB(x) to_bool((x)) #define ItoD(x) tod((x)) #define DtoB(x) to_bool((x)) #define DtoI(x) toi((x)) inline int barIII(int x, int y) { return(ItoI(x)-ItoI(y)); } inline int plusIBI(int x, bool y) { return(ItoI(x)+BtoI(y)); } inline int plusIII(int x, int y) { return(ItoI(x)+ItoI(y)); } inline int minIII(int x, int y) { /* x min y */ return (min(ItoI(x),ItoI(y))); } inline bool eqIIB(int x, int y) { /* A=B on non-doubles */ return(ItoI(x) == ItoI(y)); } inline int barBBI(bool x, bool y) { return(BtoI(x)-BtoI(y)); } inline int[.] comaXII(int[+] y) { /* Ravel of anything with rank>1 */ z = reshape([prod(shape(y))],y); return(z); } inline int[*] rhoIII(int[.] x, int y) { /* Vector reshape scalar to matrix) */ zxrho = prod(toi(x)); /* Result element count */ z = genarray([zxrho], y); /* allocate result */ z = reshape(toi(x),z); return(z); } inline int[*] dropIII(int x, int[*] y) { /* Scalar drop non-scalar */ return(drop([toi(x)], y)); } inline int[.] iotaXII(int y, int QUADio) { /* Index generator on scalar */ /* HELP! Needs domain check for negative shp */ z = QUADio+iota(toi(y)); return( z); } inline int, int querXII(int y, int QUADio, int QUADrl) { /* Monadic query (roll) - scalar */ inty = toi(y); if (inty <= 0) print(tochar("roll domain error")); QUADrl = Lehmer(QUADrl); z = (tod(QUADrl) * tod(inty)) / tod(2147483647); return(toi(z) + QUADio, QUADrl); } inline int[.] rhoXII(int[+] y) { /* Shape of non-scalar */ return(shape(y)); } inline int[*] quadXII(int[*] y, int QUADpp, int QUADpw) { /* {quad}{<-} anything */ show(y); return(y); } inline int[2] comaIII(int x, int y) {/* SxS catenate first (or last) axis */ return([toI(x)]++[toI(y)]); } inline int[*] indr(int[+] X, int I) { /* X[scalarI;;;] */ /* Used only in conjunction with other indexing, e.g., * X[scalarI;;j;] */ z = X[[I]]; return(z); } inline int[+] inds00(int[+] X, int I0,int I1, int Yin) { /* X[;;nonscalarI;;;]<- scalarY */ z = ItoI(X); Y = Yin; z[[I0,I1]]=ItoI(Y); return(z); } inline int plusslXIIFOLD(int[.] y) { /* First/last axis fold-based reduction of vector */ lim = shape(y)[0]-1; z = with { (0*shape(y) <= iv < shape(y)) : toI(y[lim-iv]); } : fold( plusIII, toI(0)); return(z); } inline int[*] indrfr(int fr, int[+] X, int[+] I) { /* X[;;;I;;;], where I has fr (framerank) semicolons to its left */ /* This is actually "I from"fr X" */ frameshape = take([fr], shape(X)); cellshape = shape(I)++drop([fr+1], shape(X)); cell = genarray(cellshape, 0); z = with { (. <= iv <= .) : indrfr0(X[iv], I); } : genarray(frameshape, cell); return(z); } inline int[*] indrfr0(int[+] X, int[+] I) { /* X[I;;;] or I from X */ cellshape = drop([1], shape(X)); cell = genarray(cellshape, 0); z = with { (. <= iv <= .) : sel( I[iv], X); } : genarray(shape(I), cell); return(z); } inline int[*] indrfr(int fr, int[+] X, int I) { /* X[;;;I;;;], where I has fr (framerank) semicolons to its left */ /* This is actually "I from"fr X" */ frameshape = take([fr], shape(X)); cellshape = drop([1+fr],shape(X)); cell = genarray(cellshape,0); z = with { (. <= iv <= .) : sel( I, X[iv]); } : genarray(frameshape, cell); return(z); } inline int Lehmer(int qrl) { /* Lehmer's random number generator * CACM 1966-06, p. 432 */ val = tod(qrl)*16807.0; z = toi(sacmod(val, 2147483647.0)); return(z); } inline int ABC(int I, int Xshape) { /* (OLD) Array bounds check for indexed ref X[scalarI] & indexed assign */ z = I; return(z); } inline int[+] ABC(int[+] I, int Xshape) { /* (OLD) Array bounds check for indexed ref X[nonscalarI] & indexed assign */ z = I; return(z); } inline double sacmod(double x, double y) { /* SAC _mod_ for floats */ if ( 0.0 == y) { t = 1.0; } else { t = y; } t2 = floor(x/t); z = x - (y*t2); return(z); } inline int[.,.] MKO2XII(int n ) { /* ? */ QUADio_0=toI(( false)); /* dsf Scalar & clique */ A_50=barIII(2,2); A_51=comaIII(n,n); A_52=rhoIII(A_51,A_50); z_0=( A_52); QUADrl_0=( 16807); A_56=iotaXII( n,QUADio_0); A_CTR57_= 0; A_CTR57z_ = (shape(A_56)[[0]])-1; z_5=toI(z_0); QUADrl_3=toI(QUADrl_0); for(; A_CTR57_ <= A_CTR57z_; A_CTR57_++){ i_0 = A_56[[A_CTR57_]]; A_61= ABC(toi(i_0)-QUADio_0,shape(z_5)[0]); A_60= ABC(toi(i_0)-QUADio_0,shape(z_5)[1]); A_63=inds00(z_5,A_61,A_60,10000000); z_2=( A_63); A_66=iotaXII( n,QUADio_0); /* dsf scalar(s) */ A_67=plusIBI(i_0,true); A_68=dropIII(A_67,A_66); A_CTR69_= 0; A_CTR69z_ = (shape(A_68)[[0]])-1; z_5=toI(z_2); QUADrl_3=toI(QUADrl_3); for(; A_CTR69_ <= A_CTR69z_; A_CTR69_++){ j_0 = A_68[[A_CTR69_]]; A_75,QUADrl_3=querXII( 1000,QUADio_0,QUADrl_3); A_75 = A_75 + 1; v_0=( A_75); A_78= ABC(toi(i_0)-QUADio_0,shape(z_5)[0]); A_77= ABC(toi(j_0)-QUADio_0,shape(z_5)[1]); A_80=inds00(z_5,A_78,A_77,v_0); z_4=( A_80); A_83= ABC(toi(j_0)-QUADio_0,shape(z_4)[0]); A_82= ABC(toi(i_0)-QUADio_0,shape(z_4)[1]); A_85=inds00(z_4,A_83,A_82,v_0); z_5=( A_85); } } return(z_5); } inline int[.,.] floydXII(int[.,.] D ,int QUADio) { /* ? */ A_37=rhoXII( D); A_36= ABC(toi(false)-QUADio,shape(A_37)[0]); A_39=A_37[[A_36]]; A_41=iotaXII( A_39,QUADio); A_CTR42_= 0; A_CTR42z_ = (shape(A_41)[[0]])-1; D_3=toI(D); for(; A_CTR42_ <= A_CTR42z_; A_CTR42_++){ k_0 = A_41[[A_CTR42_]]; A_45=rhoXII( D_3); A_44= ABC(toi(false)-QUADio,shape(A_45)[0]); A_47=A_45[[A_44]]; A_49=iotaXII( A_47,QUADio); A_CTR50_= 0; A_CTR50z_ = (shape(A_49)[[0]])-1; D_3=toI(D_3); for(; A_CTR50_ <= A_CTR50z_; A_CTR50_++){ i_0 = A_49[[A_CTR50_]]; A_53=rhoXII( D_3); A_52= ABC(toi(true)-QUADio,shape(A_53)[0]); A_55=A_53[[A_52]]; A_57=iotaXII( A_55,QUADio); A_CTR58_= 0; A_CTR58z_ = (shape(A_57)[[0]])-1; D_3=toI(D_3); for(; A_CTR58_ <= A_CTR58z_; A_CTR58_++){ j_0 = A_57[[A_CTR58_]]; A_61= ABC(toi(i_0)-QUADio,shape(D_3)[0]); A_60= ABC(toi(j_0)-QUADio,shape(D_3)[1]); A_63=D_3[[A_61,A_60]]; A_65= ABC(toi(k_0)-QUADio,shape(D_3)[0]); A_64= ABC(toi(j_0)-QUADio,shape(D_3)[1]); A_67=D_3[[A_65,A_64]]; A_69= ABC(toi(i_0)-QUADio,shape(D_3)[0]); A_68= ABC(toi(k_0)-QUADio,shape(D_3)[1]); A_71=D_3[[A_69,A_68]]; /* dsf scalar(s) */ A_72=plusIII(A_71,A_67); /* dsf scalar(s) */ A_73=minIII(A_72,A_63); A_75= ABC(toi(i_0)-QUADio,shape(D_3)[0]); A_74= ABC(toi(j_0)-QUADio,shape(D_3)[1]); A_77=inds00(D_3,A_75,A_74,A_73); D_3=( A_77); } } } z_0=( D_3); return(z_0); } int main() { /* ? */ QUADio_0=toI(( false)); QUADct_0=( 1.0e-13); QUADpp_0=( 10); QUADpw_0=( 80); QUADrl_0=( 16807); A_48=MKO2XII( 200); arg_0=( A_48); A_51=floydXII( arg_0,QUADio_0); r_0=( A_51); A_53=comaXII( r_0); A_54=plusslXIIFOLD( A_53); r_1=( A_54); A_61=quadXII( r_1,QUADpp_0,QUADpw_0); /* dsf scalar(s) */ A_63=eqIIB(r_1,1032450); /* dsf scalar(s) */ A_64=barBBI(A_63,true); r_2=( A_64); return(r_2); }