zoukankan      html  css  js  c++  java
  • 开方运算的DSP实现

    1. //===============================================   
    2.       
    3. //函数名:VSqrt3  
    4. //功能:  实现对32位定点数的开方  
    5. //性能:  60M主频28015硬件下运行时间小于10us 
    6. //转自:http://read.pudn.com/downloads180/sourcecode/mpi/840129/sqrt.c__.htm 
    7.  
    8. unsigned long VSqrt3(unsigned long x )    
    9. {   
    10.     unsigned long x1;   
    11.     int s=1;   
    12.     unsigned long g0,g1;   
    13.    
    14.     if(x<=1)  return x;   
    15.    
    16.     x1=x-1;   
    17.     if(x1>65535)   
    18.               {   
    19.               s+=8;   
    20.               x1>>=16;   
    21.               }   
    22.     if(x1>255)   
    23.               {   
    24.               s+=4;   
    25.               x1>>=8;   
    26.               }   
    27.     if(x1>15)   
    28.               {   
    29.               s+=2;   
    30.               x1>>=4;   
    31.               }   
    32.     if(x1>3)   
    33.               {   
    34.               s+=1;   
    35.               }   
    36.     g0=1;   
    37.     g0=g0<<s;   
    38.     g1 =(g0 +(x>>s))>>1;   
    39.    
    40.     while(g1
    41.              {   
    42.              g0=g1;   
    43.              g1=(g0+x/g0)>>1;   
    44.              }   
    45.     return g0;   
    46. }   
    47.    
    48. //=============================================== 
  • 相关阅读:
    terminator shortcut
    支付宝集成错误
    null与DBNULL
    linode接连出问题,我也没看懂英文
    ruby 日期 好函数
    ruby datetime
    act as tree插件
    ruby 时间
    ruby规则引擎
    on ,type等关键词,使用
  • 原文地址:https://www.cnblogs.com/eaglediao/p/7136497.html
Copyright © 2011-2022 走看看