Changeset 1442 for applications/pmsm
- Timestamp:
- 03/27/12 11:55:36 (13 years ago)
- Location:
- applications/pmsm/simulator_zdenek/ekf_example
- Files:
-
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
applications/pmsm/simulator_zdenek/ekf_example/mpf_double.cpp
r1440 r1442 1 #include "mpf_double.h"2 1 #include "math.h" 3 2 #include <stdio.h> 3 #include "fast_exp.h" 4 #include "fastexp.h" 5 #include "mpf_double.h" 4 6 #include "RArandn.h" 5 #include "fast_exp.h"6 7 7 8 static floatx om[N]; … … 18 19 static floatx qom; 19 20 static floatx r; 21 static floatx rinv; 20 22 21 23 … … 151 153 zeta = *Pt_i/ ( r+*Pt_i*CC ); 152 154 oCC = ( 1-zeta*CC ); 153 ro = oCC /r;155 ro = oCC*rinv; 154 156 155 157 Kd = *Pt_i*Cd*ro; … … 168 170 169 171 //lwi[i] = 0.5* ( log ( detRy ) + ( ydC*ydC*zeta -(ydiffd*ydiffd+ydiffq*ydiffq) ) /r ) ; 170 lwi[i] = 0.5*( ydC*ydC*zeta -(ydiffd*ydiffd+ydiffq*ydiffq) ) /r;172 lwi[i] = 0.5*( ydC*ydC*zeta -(ydiffd*ydiffd+ydiffq*ydiffq) ) *rinv ; 171 173 172 174 *isdm_i=isd; … … 192 194 for ( i=0;i<N;i++,lw_i++,w_i++ ) { 193 195 // *lw_i-=maxlwi; 194 (*w_i)= EXP( *lw_i ); // always resample -> wmin=1/n;196 (*w_i)=fasterexp ( *lw_i ); // always resample -> wmin=1/n; 195 197 } 196 198 … … 213 215 int i; 214 216 r=r0; 217 rinv = 1.0/r; 215 218 qth=qth0; 216 219 qom=qom0; … … 303 306 zeta = Pt/ ( r+Pt*CC ); 304 307 oCC = ( 1-zeta*CC ); 305 ro = oCC /r;308 ro = oCC*rinv; 306 309 307 310 Kd = Pt*Cd*ro; … … 313 316 ypq = Cq*om; 314 317 315 detRy = ro /r;318 detRy = ro*rinv; 316 319 om = om + Kd* ( difid - ypd ) +Kq* ( difiq-ypq ); 317 320 ydiffd = ( ypd-difid ); -
applications/pmsm/simulator_zdenek/ekf_example/test_exp.c
r1440 r1442 1 #include "fast _exp.h"1 #include "fastexp.h" 2 2 #include <stdio.h> 3 3 int main(){ 4 4 double d; 5 5 for (d=-1; d<1; d+=0.01) 6 printf("exp: %f, fast_exp: %f\n", exp(d), EXP(d) );6 printf("exp: %f, fast_exp: %f\n", exp(d), fasterexp(d) ); 7 7 return 0; 8 8 }