martaczaska

arni

May 2nd, 2020
906
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.94 KB | None | 0 0
  1. void sint(int* i, unsigned int e, const int s){
  2.        const long a1=12868;
  3.        const long a3=21167;
  4.        const long a5=10445;
  5.        const long a7=2455;
  6.        int czy_ujemne;
  7.        signed int x = 0;
  8.        signed int y;
  9.        int j;
  10.  
  11.        i[0] = 0;
  12.        for(j=1; j < e; j++)
  13.        {
  14.            x=x+s;
  15.            if(x<0){
  16.                czy_ujemne = 1;
  17.            }
  18.            else{
  19.                czy_ujemne = 0;
  20.            }
  21.  
  22.            y = x < 0 ? -x : x;
  23.            if (y > 16384){
  24.                y=32767-y;
  25.            }
  26.  
  27.            int z = _smpy(y,y);
  28.            int b = _smpy(z,y); //y^3 Q15
  29.            int c = _smpy(z,b);//y^5
  30.            int d = _smpy(z,c);//y^7
  31.  
  32.            long szeregtay = a1*y-a3*b+a5*c-a7*d;
  33.  
  34.  
  35.            if (czy_ujemne == 1){
  36.                i[j] = -(int)((szeregtay+(1<<11))>>12);
  37.            }
  38.            else{
  39.                i[j] = (int)((szeregtay+(1<<11))>>12);
  40.            }
  41.        }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment