use Array: all; use Numerical : all; use StdIO : all; use CommandLine: all; use String: {tochar,sscanf}; use Bits: all; /* Compiled by APEX Version: /home/apex/apex2003/wss/sac3002.dws2009-04-11 16:27:40.555 */ /* % 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)) inline bool eqIIB(int x, int y) { /* A=B on non-doubles */ return(toI(x) == toI(y)); } inline int plusBBI(bool x, bool y) { return(toI(x)+toI(y)); } inline bool[.,.] tranXBB(bool[.,.] y) { /* Transpose on rank-2 */ z = { [i,j] -> y[j,i] }; return(z); } inline int[.] rhoIII(int x, int y) { /* Scalar reshape scalar to vector) */ z = genarray([toi(x)], y); return(z); } inline bool[*] rhoIBB(int[.] x, bool[+] y) { /* APEX vector x reshape, with item reuse */ ix = toi(x); ry = comaXBB(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] <= .) : y; } : genarray( [ncopies], y); /* Now append the leftover bits */ z = comaXBB(z) ++ take([zxrho-(ncopies*yxrho)],ry); } return(reshape(ix,z)); } inline int[*] quadXII(int[*] y, int QUADpp, int QUADpw) { /* {quad}{<-} anything */ show(y); return(y); } inline int CommandLineArgvXBI(bool y) { /* Get Command-line argument element #y as integer scalar */ int z; junk, z = sscanf(argv(toi(y)), "%d"); return( z); } inline bool[+] ordotandBBBSTAR(bool[+]x, bool[+]y) { /* CDC STAR-100 APL Algorithm for inner product */ /* This computes, for z=x f.g y, * z[i;] = z[i;]f x[i;j]g y[j;] * Thus, it runs stride-1, and we only fetch left argument * elements once. It includes skipping a g row iteration and * an f row-reduce iteration when x[i;j] generates an identity for f. * R. Bernecky 2005-11-24 */ rowsx = drop([-1],shape(x)); colsx = shape(x)[[dim(x)-1]]; colsy = shape(y)[[dim(y)-1]]; Zrow = genarray([colsy],false); /* Parallel over rows of x */ z = with { (. <= row <= .) { Crow = Zrow; for (colx=0; colx1 */ z = reshape([prod(shape(y))],y); return(z); } inline int plusslXBIFOLD(bool[.] 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 bool andBBB(bool x, bool y) { return(to_bool(x)&to_bool(y)); } inline bool orBBB(bool x, bool y) { return(to_bool(x)|to_bool(y)); } inline bool[+] orBBB(bool x, bool[+] y) { /* SxA scalar function */ xel = toB(x); z = with { ( . <= iv <= .) { yel = toB(y[iv]); } : orBBB(xel,yel); } : genarray(shape(y), false); return(z); } inline bool[+] orBBB(bool[+] x, bool y) { /* AxS scalar function */ yel = toB(y); z = with { ( . <= iv <= .) { xel = toB(x[iv]); } : orBBB(xel,yel); } : genarray( shape(x), false); return(z); } inline int[.] DSFLenErrorCheck(int[.] sx, int[.] sy, char[.] whodunit) { /* Dyadic scalar fn length error check */ z = sx; #ifdef GENME /* SAC bug #306 - side effect kills fold! */ if (any(sx != sy)) { /* Check that shapes match */ show(tochar("APEX dyadic scalar function length error in function")); show(whodunit); show(sx); show(sy); } #endif return(z); } inline int ipbbXII(int siz) { /* ? */ A_26=rhoIII(2,siz); A_27=rhoIBB(A_26,[false,true,true,false,false,false]); m_0=( A_27); A_29=tranXBB( m_0); A_30=ordotandBBBSTAR(m_0,A_29); A_37=plusslXBIFOLD( A_30); A_41=plusslXIIFOLD( A_37); r_0=( A_41); return(r_0); } int main() { /* ? */ n=CommandLineArgvXBI( true); QUADio_0=toi(( false)); QUADct_0=( 1.0e-13); QUADpp_0=( 10); QUADpw_0=( 80); QUADrl_0=( 16807); QUADio_1=toi(( false)); QUADrl_1=( 16807); QUADpp_1=( 16); QUADpw_1=( 80); A_56=ipbbXII( n); r_0=( A_56); A_60=quadXII( r_0,QUADpp_1,QUADpw_1); /* dsf scalar(s) */ A_62=eqIIB(r_0,53334); /* dsf scalar(s) */ A_63=plusBBI(true,A_62); r_1=( A_63); A_67=quadXII( A_63,QUADpp_1,QUADpw_1); return(r_1); }