/***/
/* var_ranceN.M: Rance-mode gradient shuffling for NUS data stored as 2D (Agilent/Varian) 
/*  nmrPipe -fn MAC -macro var_ranceN.M -var nShuf 1  (2D, 3D aqOrd 0, 4D aqOrd 0)
/*  nmrPipe -fn MAC -macro var_ranceN.M -var nShuf 2  (3D aqOrd 1)
/*  nmrPipe -fn MAC -macro var_ranceN.M -var nShuf 4  (4D aqOrd 1)
/***/

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) vvAdd( sumR, difR,  shufSize );
(void) vvAdd( sumI, difI,  shufSize );

(void) vvSub( difR, rdataN, shufSize );
(void) vvSub( difI, idataN, shufSize );

(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 );
