use Array: all; use Numerical : all; use StdIO : all; use CommandLine: all; use String: {tochar,sscanf}; use ArrayFormat: all; use Bits: all; /* Compiled by APEX Version: /home/apex/apex2003/wss/sac3004.dws2009-05-04 14:03:18.675 */ /* % This is the APEX stdlib.sis include file. % Standard equates and constants for APL compiler % Also standard coercion functions */ #define toB(x) tob((x)) #define toI(x) toi((x)) #define toD(x) tod((x)) #define toC(x) (x) #define toc(x) ((x)) inline int plusBBI(bool x, bool y) { return(toI(x)+toI(y)); } inline int[+] plusIII(int x, int[+] y) { /* SxA scalar function */ xel = toI(x); z = with { ( . <= iv <= .) { yel = toI(y[iv]); } : plusIII(xel,yel); } : genarray(shape(y), 0); return(z); } inline bool[.] comaXBB(bool y) { /* Ravel of scalar */ return([y]); } inline int[*] rhoIII(int[.] x, int[+] y) { /* APEX vector x reshape, with item reuse */ ix = toi(x); ry = comaXII(y); zxrho = prod(ix); /* THIS NEEDS XRHO FOR CODE SAFETY!! */ yxrho = shape(ry)[[0]]; if( zxrho <= yxrho) { /* No element resuse case */ z = take([zxrho],ry); } else { ncopies = zxrho/yxrho; /* # complete copies of y. */ /* FIXME: y empty case !*/ z = with { (. <= [i] <= .) : ry; } : genarray( [ncopies], ry); /* Now append the leftover bits */ z = comaXII(z) ++ take([zxrho-(ncopies*yxrho)],ry); } return(reshape(ix,z)); } inline bool[*] rhoIBB(int[.] x, bool 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[.] 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[.] iotaXBI(bool y, int QUADio) { /* Index generator on scalar */ /* HELP! Needs domain check for negative shp */ z = QUADio+iota(toi(y)); return( z); } inline bool[*] quadXBB(bool[*] y, int QUADpp, int QUADpw) { /* {quad}{<-} anything */ show(y); return(y); } inline int[*] quadXII(int[*] y, int QUADpp, int QUADpw) { /* {quad}{<-} anything */ show(y); return(y); } inline bool[2] comaBBB(bool x, bool y) {/* SxS catenate first (or last) axis */ return([toB(x)]++[toB(y)]); } inline bool[.] comaBBB(bool[.] x, bool y) {/* VxS catenate first (or last) axis */ return(toB(x)++[toB(y)]); } inline int[.] comaIII(int[.] x, int[.] y) { /* VxV catenate first or last axis */ return(toI(x)++toI(y)); } inline bool sameBIB(bool[+] x, int[+] y) { /* Non-scalar match non-scalar */ return(match(toI(x),toI(y))); } inline bool sameBBB(bool[+] x, bool[+] y) { /* Non-scalar match non-scalar */ return(match(toB(x),toB(y))); } inline bool sameIBB(int[+] x, bool[+] y) { /* Non-scalar match non-scalar */ return(match(toI(x),toI(y))); } inline bool sameIIB(int[+] x, int[+] y) { /* Non-scalar match non-scalar */ return(match(toI(x),toI(y))); } inline bool[.] slBBBONEEL(bool x, bool y) { /* Scalar replicate scalar */ z = with { (. <= iv <= .) : y; } : genarray([toi(x)]); return(z); } inline bool[+] slBBBONEEL(bool x, bool[+] y) { /* Scalar compress non-scalar */ sy = shape(y); if (true == tob(x)) z = y; else z = genarray(drop([-1],sy)++[0],false); return(z); } inline int[+] slBIIONEEL(bool x, int[+] y) { /* Scalar compress non-scalar */ sy = shape(y); if (true == tob(x)) z = y; else z = genarray(drop([-1],sy)++[0],0); return(z); } inline bool[.] slBBB(bool[.] x, bool y) { /* Vector compress/replicate scalar */ shpz = sum(toi(x)); z = genarray([shpz],y); return(z); } inline bool[.] slBBB(bool[.] x, bool[.] y) {/* vector compress/replicate vector */ /* HELP! non-boolean left argument needs a range check */ intx = toi(x); zxrho = sum(intx); z = genarray([zxrho], false); zi = 0; for(i=0; i1 */ z = reshape([prod(shape(y))],y); return(z); } inline int[+] TRANSPOSE(int[+] y) { /* Generic monadic transpose */ z = with { ( . <= iv <= .) : y[reverse( iv)]; }: genarray( reverse( shape(y)), 0); return(z); } int main() { /* ? */ QUADio_0=toi(( false)); QUADct_0=( 1.0e-13); QUADpp_0=( 10); QUADpw_0=( 80); QUADrl_0=( 16807); S0_0=( false); S1_0=( true); A_110=comaXBB( true); V1_0=( A_110); A_112=comaXBB( false); V0_0=( A_112); V1011_0=( [true,false,true,true]); A_116=iotaXII( 24,QUADio_0); A_117=rhoIII([2, 3, 4],A_116); M234_0=( A_117); A_120=iotaXBI( false,QUADio_0); A_121=slBBBONEEL(S0_0,S0_0); A_123=sameBIB(A_121,A_120); r_0=( A_123); A_125=comaXBB( S0_0); A_126=slBBBONEEL(S1_0,S0_0); A_128=sameBBB(A_126,A_125); A_129=comaBBB(r_0,A_128); r_1=( A_129); A_131=comaXBB( S1_0); A_132=slBBBONEEL(S1_0,S1_0); A_134=sameBBB(A_132,A_131); A_135=comaBBB(r_1,A_134); r_2=( A_135); A_138=iotaXBI( false,QUADio_0); A_139=slBBBONEEL(S0_0,V1_0); A_141=sameBIB(A_139,A_138); A_142=comaBBB(r_2,A_141); r_3=( A_142); A_144=slBBBONEEL(S1_0,V1_0); A_146=sameBBB(A_144,V1_0); A_147=comaBBB(r_3,A_146); r_4=( A_147); A_149=rhoIBB([2, 3, 0],false); A_150=slBIIONEEL(S0_0,M234_0); A_152=sameIBB(A_150,A_149); A_153=comaBBB(r_4,A_152); r_5=( A_153); A_155=slBIIONEEL(S1_0,M234_0); A_157=sameIIB(A_155,M234_0); A_158=comaBBB(r_5,A_157); r_6=( A_158); A_161=iotaXBI( false,QUADio_0); A_162=slBBB(V0_0,S0_0); A_164=sameBIB(A_162,A_161); A_165=comaBBB(r_6,A_164); r_7=( A_165); A_167=comaXBB( S0_0); A_168=slBBB(V1_0,S0_0); A_170=sameBBB(A_168,A_167); A_171=comaBBB(r_7,A_170); r_8=( A_171); A_174=iotaXBI( false,QUADio_0); A_175=slBBB(V0_0,V0_0); A_177=sameBIB(A_175,A_174); A_178=comaBBB(r_8,A_177); r_9=( A_178); A_180=slBBB(V1_0,V0_0); A_182=sameBBB(A_180,V0_0); A_183=comaBBB(r_9,A_182); r_10=( A_183); A_185=rhoIBB([2, 3, 0],false); A_186=slBII(V0_0,M234_0); A_188=sameIBB(A_186,A_185); A_189=comaBBB(r_10,A_188); r_11=( A_189); A_191=slBII(V1_0,M234_0); A_193=sameIIB(A_191,M234_0); A_194=comaBBB(r_11,A_193); r_12=( A_194); A_196=comaIII([16, 18, 19],[20, 22, 23]); A_197=comaIII([12, 14, 15],A_196); A_198=comaIII([8, 10, 11],A_197); A_199=comaIII([4, 6, 7],A_198); A_200=comaIII([0, 2, 3],A_199); A_201=rhoIII([2, 3, 3],A_200); A_202=slBII(V1011_0,M234_0); A_204=sameIIB(A_202,A_201); A_205=comaBBB(r_12,A_204); r_13=( A_205); A_208=iotaXII( 4,QUADio_0); A_209=slBII(V1011_0,A_208); A_211=sameIIB(A_209,[0, 2, 3]); A_212=comaBBB(r_13,A_211); r_14=( A_212); A_215=iotaXBI( false,QUADio_0); A_216=sl1BBBONEEL(S0_0,S0_0); A_218=sameBIB(A_216,A_215); A_219=comaBBB(r_14,A_218); r_15=( A_219); A_221=comaXBB( S0_0); A_222=sl1BBBONEEL(S1_0,S0_0); A_224=sameBBB(A_222,A_221); A_225=comaBBB(r_15,A_224); r_16=( A_225); A_227=comaXBB( S1_0); A_228=sl1BBBONEEL(S1_0,S1_0); A_230=sameBBB(A_228,A_227); A_231=comaBBB(r_16,A_230); r_17=( A_231); A_234=iotaXBI( false,QUADio_0); A_235=sl1BBBONEEL(S0_0,V1_0); A_237=sameBIB(A_235,A_234); A_238=comaBBB(r_17,A_237); r_18=( A_238); A_240=sl1BBBONEEL(S1_0,V1_0); A_242=sameBBB(A_240,V1_0); A_243=comaBBB(r_18,A_242); r_19=( A_243); A_245=rhoIBB([0, 3, 4],false); A_246=sl1BIIONEEL(S0_0,M234_0); A_248=sameIBB(A_246,A_245); A_249=comaBBB(r_19,A_248); r_20=( A_249); A_251=sl1BIIONEEL(S1_0,M234_0); A_253=sameIIB(A_251,M234_0); A_254=comaBBB(r_20,A_253); r_21=( A_254); A_257=iotaXBI( false,QUADio_0); A_258=sl1BBB(V0_0,S0_0); A_260=sameBIB(A_258,A_257); A_261=comaBBB(r_21,A_260); r_22=( A_261); A_263=comaXBB( S0_0); A_264=sl1BBB(V1_0,S0_0); A_266=sameBBB(A_264,A_263); A_267=comaBBB(r_22,A_266); r_23=( A_267); A_270=iotaXBI( false,QUADio_0); A_271=sl1BBB(V0_0,V0_0); A_273=sameBIB(A_271,A_270); A_274=comaBBB(r_23,A_273); r_24=( A_274); A_276=sl1BBB(V1_0,V0_0); A_278=sameBBB(A_276,V0_0); A_279=comaBBB(r_24,A_278); r_25=( A_279); A_281=rhoIBB([0, 3, 4],false); A_282=sl1BII(V0_0,M234_0); A_284=sameIBB(A_282,A_281); A_285=comaBBB(r_25,A_284); r_26=( A_285); A_287=sl1BII(V1_0,M234_0); A_289=sameIIB(A_287,M234_0); A_290=comaBBB(r_26,A_289); r_27=( A_290); A_293=iotaXII( 12,QUADio_0); /* dsf scalar(s) */ A_294=plusIII(12,A_293); A_295=rhoIII([1, 3, 4],A_294); A_296=sl1BII([false,true],M234_0); A_298=sameIIB(A_296,A_295); A_299=comaBBB(r_27,A_298); r_28=( A_299); A_302=iotaXII( 12,QUADio_0); A_303=rhoIII([1, 3, 4],A_302); A_304=sl1BII([true,false],M234_0); A_306=sameIIB(A_304,A_303); A_307=comaBBB(r_28,A_306); r_29=( A_307); A_311=quadXBB( r_29,QUADpp_0,QUADpw_0); A_312=andslXBBQUICKSTOP( r_29); /* dsf scalar(s) */ A_316=plusBBI(true,A_312); r_30=( A_316); A_320=quadXII( A_316,QUADpp_0,QUADpw_0); return(r_30); }