/***/
/* bruk_ranceN.M: Echo-AntiEcho-mode gradient shuffling for NUS data stored as 2D (Bruker) 
/*  nmrPipe -fn MAC -macro bruk_ranceN.M -var nShuf 1  (EA is inner loop)
/*  nmrPipe -fn MAC -macro bruk_ranceN.M -var nShuf 2  (3D, EA is outer loop)
/*  nmrPipe -fn MAC -macro bruk_ranceN.M -var nShuf 4  (4D, EA is outer loop)
/***/

if (sliceCode % (2*nShuf))
   {
    exit( 0 );
   };

shufSize = size*nShuf;

float sumR[shufSize], sumI[shufSize], difR[shufSize], difI[shufSize];
float rdataN[shufSize], idataN[shufSize];

(void) dReadB( inUnit, rdataN, wordLen*shufSize );
(void) dReadB( inUnit, idataN, wordLen*shufSize );
(void) dReadB( inUnit, difR,   wordLen*shufSize );
(void) dReadB( inUnit, difI,   wordLen*shufSize );

(void) vvCopy( sumR, rdataN, shufSize );
(void) vvCopy( sumI, idataN, shufSize );

(void) vvSub( sumR, difR, size );
(void) vvSub( sumI, difI, size );
(void) vvAdd( difR, rdata, size );
(void) vvAdd( difI, idata, size );

(void) vNeg( difI, shufSize );

(void) dWrite( outUnit, sumR, wordLen*shufSize );
(void) dWrite( outUnit, sumI, wordLen*shufSize );
(void) dWrite( outUnit, difI, wordLen*shufSize );
(void) dWrite( outUnit, difR, wordLen*shufSize );
