Changeset 4879:3d39c745c8f7 in roaraudio


Ignore:
Timestamp:
04/26/11 14:36:32 (13 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added roar_math_diffpoly(), roar_math_intpoly() and roar_math_numintpoly()

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • include/libroardsp/poly.h

    r4708 r4879  
    5151float roar_math_cvpoly_4x4 (float * poly, float t); 
    5252 
     53int roar_math_diffpoly(float * poly, int len); 
     54int roar_math_intpoly(float * poly, int len, float c); 
     55 
     56float roar_math_numintpoly(float * poly, int len, float st, float et); 
     57 
    5358#endif 
    5459 
  • libroardsp/poly.c

    r4708 r4879  
    141141} 
    142142 
     143int roar_math_diffpoly(float * poly, int len) { 
     144 int i; 
     145 
     146 for (i = 1; i < len; i++) { 
     147  poly[i-1] = poly[i]*(i+1); 
     148 } 
     149 
     150 poly[len-1] = 0; 
     151 
     152 return 0; 
     153} 
     154 
     155int roar_math_intpoly(float * poly, int len, float c) { 
     156 int i; 
     157 
     158 for (i = len - 1; i > 0; i--) { 
     159  poly[i] = poly[i-1]/i; 
     160 } 
     161 
     162 poly[0] = c; 
     163 
     164 return 0; 
     165} 
     166 
     167float roar_math_numintpoly(float * poly, int len, float st, float et) { 
     168 float ipoly[8]; 
     169 float upper, lower; 
     170 
     171 if (len > 8) { 
     172  roar_err_set(ROAR_ERROR_RANGE); 
     173  return -1.; 
     174 } 
     175 
     176 memcpy(ipoly, poly, sizeof(float)*len); 
     177 roar_math_intpoly(ipoly, len, 0); 
     178 
     179 lower = roar_math_cvpoly(ipoly, st, len+1); 
     180 upper = roar_math_cvpoly(ipoly, et, len+1); 
     181 
     182 //printf("lower(%f)=%f, upper(%f)=%f\n", st, lower, et, upper); 
     183 
     184 return upper-lower; 
     185} 
     186 
    143187//ll 
Note: See TracChangeset for help on using the changeset viewer.