ГОСТ Р ИСО/МЭК 10373-6—2015
// Update %’alues
lor (.-0;i<(4*nuc._poi); --•)
1
real[il-newreal[i];
imag[ 1-new_imag(1];
newreal[i]~0;
r.ew_imag[t]—0;
t
I
lor (y-Q; y<i2«num_pOl); y-»*)
i
vector:2«y —i»ag
у’,г
vector’2«y*i:-reai‘y*;
1
Iree (new_imag);
tree (new_real);
free (imag);
tree (real);
return (ve c to r);
I
I I
Part. ol l lie c a lc u la tio n ol the butt.erworth c o e f ls .
d o u d e « b u t te r d c o e lfs ( d o u D le Ire q l, double lreq2)
I
int b u tter_ o rd er-2;
int m aex-C ;
double th e ta -
0
;
aouble cp-0;
double *ve c _ r-
0
;
aouble ’v e c _ t- 0 ;
double ’d c o e f l-0?
aouble pole_any-0;
double d iv ia o r-0 ;
// M_PI *(£req2-£reql)/2.0
// cosine ol phi
// 2’-2 coelhctents
I t
2a-1 coelflcients
t j
d coeff.cients
I t
pole angle
op - cos(M _P I*(lreq 2»f r e q l ) / 2 .0 );
theta - M _ P I*(lre q 2 -fre q l)/2 .0 ;
vec_r-(ao u b le
v e c t - ( d o u b le
* ) c a llo c (
2
’b u t t e r _ o r d e r ,s i
2
eo£(d ou b le));
* > c a llo c (2’b u tte r ord er, s is e o l(d o u b le ));
tor(maex-0;maex<butter oraer;ninaex)
0
2
2
2
0
\
pole ang-X_El*(double)(2*index-I)/(double)(2«butter_order);
divisor-s-n(2*theta)»s-n{poleang)*
1
. ?
vec_i’».ndex -cos(".heta)/divisor;
vec_i!2’index*l’-s.n(2»theta)«cos(poleang)/divisor;
vec_t‘».ndex — 2.0’cp*(cos(theta)*sm(theta)«am(pole_ang))/divisor;
vec_t#2«lndex*l’--
2
. »cp«sln(theta)«cos(pole ang)/d.visor;
l
acoe£l-mult_poli(butter^order,veot,vec_r);
1
acoetf (1J-dcoellJ1Jjr
dcoefl|3i-dcoefl[31;
acoell[2J-acoeff[b);
dcoefl[ 1-dcoefl[71;
65