Ejemplo n.º 1
0
_CODE_ACCESS void *memset(void *dst, int fill, size_t len)
{   
       char  *restrict dst1, *restrict dst2;
       int    pre_bytes, post_bytes, wfill, i;
       double dfill1, dfill2;

       dst1   = (char *)dst;

       /*--------------------------------------------------------------------*/
       /* Replicate the 8-bit value in fill into all 4 bytes of wfill        */
       /*--------------------------------------------------------------------*/
       wfill  = _pack2 (fill,  fill);
       wfill  = _packl4(wfill, wfill); 
       dfill1 = _itod  (wfill, wfill);
       dfill2 = _itod  (wfill, wfill);

       /*--------------------------------------------------------------------*/
       /* Calculate number of bytes to pre-copy to get to an alignment of 8  */
       /*--------------------------------------------------------------------*/
       pre_bytes = (8 - (int) dst) & 7;

       if (len > pre_bytes)
       {
           len -= pre_bytes;
           if (pre_bytes & 1) { *dst1        = fill;  dst1 += 1; }
           if (pre_bytes & 2) { _amem2(dst1) = wfill; dst1 += 2; }
           if (pre_bytes & 4) { _amem4(dst1) = wfill; dst1 += 4; }
       }

       /*--------------------------------------------------------------------*/
       /* Double word fills                                                  */
       /*--------------------------------------------------------------------*/
       post_bytes = len > 0 ? len : 0;   
       dst2       = dst1 + 8;

       if (len > 15)
         for (i = 0; i < len >> 4; i++)
         {
            _amemd8(dst1) = dfill1; dst1 += 16;
            _amemd8(dst2) = dfill2; dst2 += 16;
            post_bytes -= 16;
         }

       /*--------------------------------------------------------------------*/
       /* Finish transfer with 8, 4, 2 and/or 1-byte writes                  */
       /*--------------------------------------------------------------------*/
       if (post_bytes & 8) { _memd8(dst1) = dfill1; dst1 += 8; }
       if (post_bytes & 4) { _mem4 (dst1) = wfill;  dst1 += 4; }
       if (post_bytes & 2) {  dst1[0]     = wfill;  
                              dst1[1]     = wfill;  dst1 += 2; }
       if (post_bytes & 1) { *dst1        = fill;   dst1 += 1; }
       return dst;
}
Ejemplo n.º 2
0
double expdp_c(double a)
{


double Halfe = 0.5; //Zeroe = 0.0, Onee = 1.0,  ;

double Maxe  =    1.7976931348623157e+308 ;
double LnMaxe=  709.7827138470578 ;
double  a0e= 0.249999999999999993;
double  a1e= 0.694360001511792852e-2 ;
double  a2e= 0.165203300268279130e-4;
double  b0e= 0.5 ;
double  b1e= 0.555538666969001188e-1 ;
double  b2e= 0.495862884905441294e-3 ; 
double  c1e= 0.693359375  ;                /*  355/512      */
double  C2e=-2.1219444005469058277e-4 ;

double L2e = 1.4426950408889634074  ;      /* log (base  2) of e   */ 



double  Ye,Xe,We,Re,Se,Be,Ce,De;
int     Ne, upper; 


        Ye = a;

        
        Ce = Ye*L2e ;                     /* base e --> base 2 argument */           
        Ne = _dpint(Ce) ;                 /* get unbiased exponent as an int */
        Se = Ne ;                         /* double(int N) */ 
  
        Xe = (Ye - Se*c1e) - Se*C2e ;         /*  range reduction  */ 

        We = Xe*Xe ;

        Be = (b2e*We + b1e)*We + b0e ;                  /* denominator  */
        De = ((a2e*We + a1e)*We + a0e)*Xe ;             /* numerator  */
        Re = Halfe + divdpMod_ci5( De, (Be-De) ) ;
        upper = 1024 + Ne;
        upper = _extu(upper,20,0); 
        Se = _itod(upper,0x00000000);

        Ce = Re*Se ;                       /* scale by power of 2  */ 
		if (a > LnMaxe)  Ce = (Maxe)  ;  /* > LnMax returns MAX  */
        return (Ce) ;
}
  /* -------------------------------------------------------------------- */
  /*  Inform the compiler by _nasserts the following:                     */
  /*      a) The output array is word aligned                             */
  /*      b) The width is greater than or equal to 2                      */
  /*      c) The width is a multiple of 2.                                */
  /* -------------------------------------------------------------------- */
  _nassert((int) imgout_ptr % 4 == 0);  
  _nassert((int) width      % 2 == 0);
  _nassert((int) width          >= 2);
    
  /* -------------------------------------------------------------------- */
  /* The 1st two mask values of each row are loaded into one int          */
  /* Reverse order of mask coefficients for rotation.                     */
  /* -------------------------------------------------------------------- */
  mask_tmp = _memd8_const((void *) &mask_ptr[5]);
  mask3_0  = _itod(_packlh2(_lo(mask_tmp),_lo(mask_tmp)),
                   _packlh2(_hi(mask_tmp),_hi(mask_tmp)));

  mask_tmp = _memd8_const((void *) &mask_ptr[1]);
  mask7_4  = _itod(_packlh2(_lo(mask_tmp),_lo(mask_tmp)),
                   _packlh2(_hi(mask_tmp),_hi(mask_tmp)));

  /* -------------------------------------------------------------------- */
  /* The last mask values of each row are loaded into an int              */
  /* -------------------------------------------------------------------- */
  mask8   = mask_ptr[0];
  mask43  = _packlh2(_lo(mask7_4),_hi(mask3_0));

  /* -------------------------------------------------------------------- */
  /* mask2_88 contains the last mask of row 3 in its half words           */
  /* -------------------------------------------------------------------- */
  mask88  = _pack2(mask8,mask8);
Ejemplo n.º 4
0
double logdp_c(double a)
{


// double One=1.0 ;
double Zero = 0.0, Half = 0.5 ;
double srHalf= 0.70710678118654752440 ;         /*  sqrt(0.5)   */
double MIN   =    2.2250738585072014e-308 ;
double LnMin = -708.3964185322641 ;
double MAX   =    1.7976931348623157e+308 ;
double LnMax =  709.7827138470578 ;
double  a0 =-0.64124943423745581147e+2 ;
double  a1 = 0.16383943563021534222e+2 ;
double  a2 =-0.78956112887491257267e+0 ;
double  b0 =-0.76949932108494879777e+3 ;
double  b1 = 0.31203222091924532844e+3 ;
double  b2 =-0.35667977739034646171e+2 ; /*  Note b3 = 1.0        */
double  c1 = 0.693359375  ;       		 /*  355/512      */
double  c2 =-2.121944400546905827679e-4 ;

double  Y,Z,zn,zd,X,W,Rz,Sa,Bd,Cn,Da ;
int     N, exp, upper; 

        Y = a ;
        exp = _extu(_hi(Y),1,21);
       	N = exp - 1022;

 		upper = _clr(_hi(Y),20,31);
		upper = 0x3fe00000 | upper;
		Z = _itod(upper, _lo(Y));
		if (exp == 0) Z = 0;


        if (Z > srHalf)
                { zn=(Z-Half)-Half ; zd=Z*Half+Half  ; }
        else
                { zn=Z-Half; zd=zn*Half+Half ; N=N-1 ; }
        
        
        //X = zn/zd;
        X = divdpMod_clog(zn,zd);
        
        W = X*X ;
        Bd= ( (W+b2) * W + b1) * W + b0 ;
        Cn= (W*a2 + a1) * W + a0 ;
        Rz= W * divdpMod_clog(Cn,Bd);//Cn / Bd ;
        Sa = X + X*Rz ;
        Cn= N ;
        Da = (Cn*c2 + Sa) + Cn*c1 ;



		if (Y <= Zero) Da = 0;//{Z = setnmx(Y) ; Da = (Z) ; }
        if (Y < MIN)  Da = (LnMin)  ;
        if (Y > MAX)  Da = (LnMax)  ;




        return (Da) ;

}