00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <stdio.h>
00024 #include <stdlib.h>
00025 #include <limits.h>
00026 #ifdef USE_INTEL_MATH
00027 #include <mathimf.h>
00028 #else
00029 #include <math.h>
00030 #endif
00031 #include <float.h>
00032 #ifdef DSP_IPP
00033 #include <ipp.h>
00034 #endif
00035
00036 #include "Compilers.hh"
00037 #include "dsp/DSPOp.hh"
00038 #ifdef DSP_X86
00039 #include "dsp/X86.h"
00040 #endif
00041
00042
00043 #ifdef DSP_X86
00044 bool bHave3DNow = false;
00045 bool bHaveSSE = false;
00046 #endif
00047
00048
00049 extern "C"
00050 {
00051
00052 INLINE int FloatCompare (const void *vpValue1, const void *vpValue2)
00053 {
00054 if (*(float *)vpValue1 == *(float *)vpValue2)
00055 {
00056 return 0;
00057 }
00058 if (*(float *)vpValue1 < *(float *)vpValue2)
00059 {
00060 return -1;
00061 }
00062 else
00063 {
00064 return 1;
00065 }
00066 }
00067
00068
00069 INLINE int DoubleCompare (const void *vpValue1, const void *vpValue2)
00070 {
00071 if (*(double *)vpValue1 == *(double *)vpValue2)
00072 {
00073 return 0;
00074 }
00075 if (*(double *)vpValue1 < *(double *)vpValue2)
00076 {
00077 return -1;
00078 }
00079 else
00080 {
00081 return 1;
00082 }
00083 }
00084
00085
00086 INLINE int LongCompare (const void *vpValue1, const void *vpValue2)
00087 {
00088 if (*(long *)vpValue1 == *(long *)vpValue2)
00089 {
00090 return 0;
00091 }
00092 if (*(long *)vpValue1 < *(long *)vpValue2)
00093 {
00094 return -1;
00095 }
00096 else
00097 {
00098 return 1;
00099 }
00100 }
00101
00102 }
00103
00104
00105 signed long clDSPOp::Round (float fValue)
00106 {
00107 signed long slTemp;
00108
00109
00110 #if defined(USE_INTEL_MATH)
00111 slTemp = lrintf(fValue);
00112 #elif defined(_ISOC9X_SOURCE)
00113 slTemp = (signed long) nearbyintf(fValue);
00114 #else
00115 slTemp = (fValue >= 0.0F) ?
00116 ((signed long) (fValue + 0.5F)) : ((signed long) (fValue - 0.5F));
00117 #endif
00118 return slTemp;
00119 }
00120
00121
00122 signed long clDSPOp::Round (double dValue)
00123 {
00124 signed long slTemp;
00125
00126
00127 #if defined(USE_INTEL_MATH)
00128 slTemp = lrint(dValue);
00129 #elif defined(_ISOC9X_SOURCE)
00130 slTemp = (signed long) nearbyint(dValue);
00131 #else
00132 slTemp = (dValue >= 0.0) ?
00133 ((signed long) (dValue + 0.5)) : ((signed long) (dValue - 0.5));
00134 #endif
00135 return slTemp;
00136 }
00137
00138
00139 INLINE void clDSPOp::Cart2Polar (float *fpMagn, float *fpPhase,
00140 float fReal, float fImag)
00141 {
00142 #ifndef _ISOC9X_SOURCE
00143 *fpMagn = sqrtf(fReal * fReal + fImag * fImag);
00144 #else
00145 *fpMagn = hypotf(fReal, fImag);
00146 #endif
00147 *fpPhase = atan2f(fImag, fReal);
00148 }
00149
00150
00151 INLINE void clDSPOp::Cart2Polar (double *dpMagn, double *dpPhase,
00152 double dReal, double dImag)
00153 {
00154 #ifndef _ISOC9X_SOURCE
00155 *dpMagn = sqrt(dReal * dReal + dImag * dImag);
00156 #else
00157 *dpMagn = hypot(dReal, dImag);
00158 #endif
00159 *dpPhase = atan2(dImag, dReal);
00160 }
00161
00162
00163 INLINE void clDSPOp::Cart2Polar (float *fpMagn, float *fpPhase,
00164 const stpSCplx spCplx)
00165 {
00166 #ifndef _ISOC9X_SOURCE
00167 *fpMagn = sqrtf(spCplx->R * spCplx->R + spCplx->I * spCplx->I);
00168 #else
00169 *fpMagn = hypotf(spCplx->R, spCplx->I);
00170 #endif
00171 *fpPhase = atan2f(spCplx->I, spCplx->R);
00172 }
00173
00174
00175 INLINE void clDSPOp::Cart2Polar (double *dpMagn, double *dpPhase,
00176 const stpDCplx spCplx)
00177 {
00178 #ifndef _ISOC9X_SOURCE
00179 *dpMagn = sqrt(spCplx->R * spCplx->R + spCplx->I * spCplx->I);
00180 #else
00181 *dpMagn = hypot(spCplx->R, spCplx->I);
00182 #endif
00183 *dpPhase = atan2(spCplx->I, spCplx->R);
00184 }
00185
00186
00187 INLINE void clDSPOp::Cart2Polar (stpSPolar spPolar, const stpSCplx spCplx)
00188 {
00189 #ifndef _ISOC9X_SOURCE
00190 spPolar->M = sqrtf(spCplx->R * spCplx->R + spCplx->I * spCplx->I);
00191 #else
00192 spPolar->M = hypotf(spCplx->R, spCplx->I);
00193 #endif
00194 spPolar->P = atan2f(spCplx->I, spCplx->R);
00195 }
00196
00197
00198 INLINE void clDSPOp::Cart2Polar (stpDPolar spPolar, const stpDCplx spCplx)
00199 {
00200 #ifndef _ISOC9X_SOURCE
00201 spPolar->M = sqrt(spCplx->R * spCplx->R + spCplx->I * spCplx->I);
00202 #else
00203 spPolar->M = hypot(spCplx->R, spCplx->I);
00204 #endif
00205 spPolar->P = atan2(spCplx->I, spCplx->R);
00206 }
00207
00208
00209 INLINE void clDSPOp::Cart2Polar (utpSCoord upCoord)
00210 {
00211 #ifndef _ISOC9X_SOURCE
00212 upCoord->P.M = sqrtf(upCoord->C.R * upCoord->C.R +
00213 upCoord->C.I * upCoord->C.I);
00214 #else
00215 upCoord->P.M = hypotf(upCoord->C.R, upCoord->C.I);
00216 #endif
00217 upCoord->P.P = atan2f(upCoord->C.I, upCoord->C.R);
00218 }
00219
00220
00221 INLINE void clDSPOp::Cart2Polar (utpDCoord upCoord)
00222 {
00223 #ifndef _ISOC9X_SOURCE
00224 upCoord->P.M = sqrt(upCoord->C.R * upCoord->C.R +
00225 upCoord->C.I * upCoord->C.I);
00226 #else
00227 upCoord->P.M = hypot(upCoord->C.R, upCoord->C.I);
00228 #endif
00229 upCoord->P.P = atan2(upCoord->C.I, upCoord->C.R);
00230 }
00231
00232
00233 INLINE void clDSPOp::Polar2Cart (float *fpReal, float *fpImag,
00234 float fMagn, float fPhase)
00235 {
00236 #ifndef _GNU_SOURCE
00237 *fpReal = fMagn * cosf(fPhase);
00238 *fpImag = fMagn * sinf(fPhase);
00239 #else
00240 sincosf(fPhase, fpImag, fpReal);
00241 *fpReal *= fMagn;
00242 *fpImag *= fMagn;
00243 #endif
00244 }
00245
00246
00247 INLINE void clDSPOp::Polar2Cart (double *dpReal, double *dpImag,
00248 double dMagn, double dPhase)
00249 {
00250 #ifndef _GNU_SOURCE
00251 *dpReal = dMagn * cos(dPhase);
00252 *dpImag = dMagn * sin(dPhase);
00253 #else
00254 sincos(dPhase, dpImag, dpReal);
00255 *dpReal *= dMagn;
00256 *dpImag *= dMagn;
00257 #endif
00258 }
00259
00260
00261 INLINE void clDSPOp::Polar2Cart (stpSCplx spCplx, float fMagn, float fPhase)
00262 {
00263 #ifndef _GNU_SOURCE
00264 spCplx->R = fMagn * cosf(fPhase);
00265 spCplx->I = fMagn * sinf(fPhase);
00266 #else
00267 sincosf(fPhase, &spCplx->I, &spCplx->R);
00268 spCplx->R *= fMagn;
00269 spCplx->I *= fMagn;
00270 #endif
00271 }
00272
00273
00274 INLINE void clDSPOp::Polar2Cart (stpDCplx spCplx, double dMagn, double dPhase)
00275 {
00276 #ifndef _GNU_SOURCE
00277 spCplx->R = dMagn * cos(dPhase);
00278 spCplx->I = dMagn * sin(dPhase);
00279 #else
00280 sincos(dPhase, &spCplx->I, &spCplx->R);
00281 spCplx->R *= dMagn;
00282 spCplx->I *= dMagn;
00283 #endif
00284 }
00285
00286
00287 INLINE void clDSPOp::Polar2Cart (stpSCplx spCplx, const stpSPolar spPolar)
00288 {
00289 #ifndef _GNU_SOURCE
00290 spCplx->R = spPolar->M * cosf(spPolar->P);
00291 spCplx->I = spPolar->M * sinf(spPolar->P);
00292 #else
00293 sincosf(spPolar->P, &spCplx->I, &spCplx->R);
00294 spCplx->R *= spPolar->M;
00295 spCplx->I *= spPolar->M;
00296 #endif
00297 }
00298
00299
00300 INLINE void clDSPOp::Polar2Cart (stpDCplx spCplx, const stpDPolar spPolar)
00301 {
00302 #ifndef _GNU_SOURCE
00303 spCplx->R = spPolar->M * cos(spPolar->P);
00304 spCplx->I = spPolar->M * sin(spPolar->P);
00305 #else
00306 sincos(spPolar->P, &spCplx->I, &spCplx->R);
00307 spCplx->R *= spPolar->M;
00308 spCplx->I *= spPolar->M;
00309 #endif
00310 }
00311
00312
00313 INLINE void clDSPOp::Polar2Cart (utpSCoord upCoord)
00314 {
00315 #ifndef _GNU_SOURCE
00316 upCoord->C.R = upCoord->P.M * cosf(upCoord->P.P);
00317 upCoord->C.I = upCoord->P.M * sinf(upCoord->P.P);
00318 #else
00319 float fReal;
00320 float fImag;
00321
00322 sincosf(upCoord->P.P, &fImag, &fReal);
00323 upCoord->C.R = upCoord->P.M * fReal;
00324 upCoord->C.I = upCoord->P.M * fImag;
00325 #endif
00326 }
00327
00328
00329 INLINE void clDSPOp::Polar2Cart (utpDCoord upCoord)
00330 {
00331 #ifndef _GNU_SOURCE
00332 upCoord->C.R = upCoord->P.M * cos(upCoord->P.P);
00333 upCoord->C.I = upCoord->P.M * sin(upCoord->P.P);
00334 #else
00335 double dReal;
00336 double dImag;
00337
00338 sincos(upCoord->P.P, &dImag, &dReal);
00339 upCoord->C.R = upCoord->P.M * dReal;
00340 upCoord->C.I = upCoord->P.M * dImag;
00341 #endif
00342 }
00343
00344
00345 INLINE void clDSPOp::CplxAdd (stpSCplx spCplxDest, const stpSCplx spCplxSrc)
00346 {
00347 spCplxDest->R += spCplxSrc->R;
00348 spCplxDest->I += spCplxSrc->I;
00349 }
00350
00351
00352 INLINE void clDSPOp::CplxAdd (stpDCplx spCplxDest, const stpDCplx spCplxSrc)
00353 {
00354 spCplxDest->R += spCplxSrc->R;
00355 spCplxDest->I += spCplxSrc->I;
00356 }
00357
00358
00359 INLINE void clDSPOp::CplxAdd (stpSCplx spCplxDest, const stpSCplx spCplxSrc1,
00360 const stpSCplx spCplxSrc2)
00361 {
00362 spCplxDest->R = spCplxSrc1->R + spCplxSrc2->R;
00363 spCplxDest->I = spCplxSrc1->I + spCplxSrc2->I;
00364 }
00365
00366
00367 INLINE void clDSPOp::CplxAdd (stpDCplx spCplxDest, const stpDCplx spCplxSrc1,
00368 const stpDCplx spCplxSrc2)
00369 {
00370 spCplxDest->R = spCplxSrc1->R + spCplxSrc2->R;
00371 spCplxDest->I = spCplxSrc1->I + spCplxSrc2->I;
00372 }
00373
00374
00375 INLINE void clDSPOp::CplxSub (stpSCplx spCplxDest, const stpSCplx spCplxSrc)
00376 {
00377 spCplxDest->R -= spCplxSrc->R;
00378 spCplxDest->I -= spCplxSrc->I;
00379 }
00380
00381
00382 INLINE void clDSPOp::CplxSub (stpDCplx spCplxDest, const stpDCplx spCplxSrc)
00383 {
00384 spCplxDest->R -= spCplxSrc->R;
00385 spCplxDest->I -= spCplxSrc->I;
00386 }
00387
00388
00389 INLINE void clDSPOp::CplxSub (stpSCplx spCplxDest, const stpSCplx spCplxSrc1,
00390 const stpSCplx spCplxSrc2)
00391 {
00392 spCplxDest->R = spCplxSrc1->R - spCplxSrc2->R;
00393 spCplxDest->I = spCplxSrc1->I - spCplxSrc2->I;
00394 }
00395
00396
00397 INLINE void clDSPOp::CplxSub (stpDCplx spCplxDest, const stpDCplx spCplxSrc1,
00398 const stpDCplx spCplxSrc2)
00399 {
00400 spCplxDest->R = spCplxSrc1->R - spCplxSrc2->R;
00401 spCplxDest->I = spCplxSrc1->I - spCplxSrc2->I;
00402 }
00403
00404
00405 INLINE void clDSPOp::CplxMul (stpSCplx spCplxDest, float fSrc)
00406 {
00407 spCplxDest->R *= fSrc;
00408 spCplxDest->I *= fSrc;
00409 }
00410
00411
00412 INLINE void clDSPOp::CplxMul (stpDCplx spCplxDest, double dSrc)
00413 {
00414 spCplxDest->R *= dSrc;
00415 spCplxDest->I *= dSrc;
00416 }
00417
00418
00419 INLINE void clDSPOp::CplxMul (stpSCplx spCplxDest, const stpSCplx spCplxSrc)
00420 {
00421 float fReal;
00422 float fImag;
00423
00424 fReal = spCplxDest->R * spCplxSrc->R - spCplxDest->I * spCplxSrc->I;
00425 fImag = spCplxDest->R * spCplxSrc->I + spCplxDest->I * spCplxSrc->R;
00426 spCplxDest->R = fReal;
00427 spCplxDest->I = fImag;
00428 }
00429
00430
00431 INLINE void clDSPOp::CplxMul (stpDCplx spCplxDest, const stpDCplx spCplxSrc)
00432 {
00433 double dReal;
00434 double dImag;
00435
00436 dReal = spCplxDest->R * spCplxSrc->R - spCplxDest->I * spCplxSrc->I;
00437 dImag = spCplxDest->R * spCplxSrc->I + spCplxDest->I * spCplxSrc->R;
00438 spCplxDest->R = dReal;
00439 spCplxDest->I = dImag;
00440 }
00441
00442
00443 INLINE void clDSPOp::CplxMul (stpSCplx spCplxDest, const stpSCplx spCplxSrc1,
00444 const stpSCplx spCplxSrc2)
00445 {
00446 spCplxDest->R =
00447 spCplxSrc1->R * spCplxSrc2->R - spCplxSrc1->I * spCplxSrc2->I;
00448 spCplxDest->I =
00449 spCplxSrc1->R * spCplxSrc2->I + spCplxSrc1->I * spCplxSrc2->R;
00450 }
00451
00452
00453 INLINE void clDSPOp::CplxMul (stpDCplx spCplxDest, const stpDCplx spCplxSrc1,
00454 const stpDCplx spCplxSrc2)
00455 {
00456 spCplxDest->R =
00457 spCplxSrc1->R * spCplxSrc2->R - spCplxSrc1->I * spCplxSrc2->I;
00458 spCplxDest->I =
00459 spCplxSrc1->R * spCplxSrc2->I + spCplxSrc1->I * spCplxSrc2->R;
00460 }
00461
00462
00463 INLINE void clDSPOp::CplxMulC (stpSCplx spCplxDest, const stpSCplx spCplxSrc)
00464 {
00465 float fReal;
00466 float fImag;
00467
00468 fReal = spCplxDest->R * spCplxSrc->R - spCplxDest->I * (-spCplxSrc->I);
00469 fImag = spCplxDest->R * (-spCplxSrc->I) + spCplxDest->I * spCplxSrc->R;
00470 spCplxDest->R = fReal;
00471 spCplxDest->I = fImag;
00472 }
00473
00474
00475 INLINE void clDSPOp::CplxMulC (stpDCplx spCplxDest, const stpDCplx spCplxSrc)
00476 {
00477 double dReal;
00478 double dImag;
00479
00480 dReal = spCplxDest->R * spCplxSrc->R - spCplxDest->I * (-spCplxSrc->I);
00481 dImag = spCplxDest->R * (-spCplxSrc->I) + spCplxDest->I * spCplxSrc->R;
00482 spCplxDest->R = dReal;
00483 spCplxDest->I = dImag;
00484 }
00485
00486
00487 INLINE void clDSPOp::CplxMulC (stpSCplx spCplxDest, const stpSCplx spCplxSrc1,
00488 const stpSCplx spCplxSrc2)
00489 {
00490 spCplxDest->R =
00491 spCplxSrc1->R * spCplxSrc2->R - spCplxSrc1->I * (-spCplxSrc2->I);
00492 spCplxDest->I =
00493 spCplxSrc1->R * (-spCplxSrc2->I) + spCplxSrc1->I * spCplxSrc2->R;
00494 }
00495
00496
00497 INLINE void clDSPOp::CplxMulC (stpDCplx spCplxDest, const stpDCplx spCplxSrc1,
00498 const stpDCplx spCplxSrc2)
00499 {
00500 spCplxDest->R =
00501 spCplxSrc1->R * spCplxSrc2->R - spCplxSrc1->I * (-spCplxSrc2->I);
00502 spCplxDest->I =
00503 spCplxSrc1->R * (-spCplxSrc2->I) + spCplxSrc1->I * spCplxSrc2->R;
00504 }
00505
00506
00507 INLINE void clDSPOp::CplxDiv (stpSCplx spCplxDest, const stpSCplx spCplxSrc)
00508 {
00509 float fReal;
00510 float fImag;
00511
00512 fReal = (spCplxDest->R * spCplxSrc->R + spCplxDest->I * spCplxSrc->I) /
00513 (spCplxSrc->R * spCplxSrc->R + spCplxSrc->I * spCplxSrc->I);
00514 fImag = (spCplxDest->I * spCplxSrc->R - spCplxDest->R * spCplxSrc->I) /
00515 (spCplxSrc->R * spCplxSrc->R + spCplxSrc->I * spCplxSrc->I);
00516 spCplxDest->R = fReal;
00517 spCplxDest->I = fImag;
00518 }
00519
00520
00521 INLINE void clDSPOp::CplxDiv (stpDCplx spCplxDest, const stpDCplx spCplxSrc)
00522 {
00523 double dReal;
00524 double dImag;
00525
00526 dReal = (spCplxDest->R * spCplxSrc->R + spCplxDest->I * spCplxSrc->I) /
00527 (spCplxSrc->R * spCplxSrc->R + spCplxSrc->I * spCplxSrc->I);
00528 dImag = (spCplxDest->I * spCplxSrc->R - spCplxDest->R * spCplxSrc->I) /
00529 (spCplxSrc->R * spCplxSrc->R + spCplxSrc->I * spCplxSrc->I);
00530 spCplxDest->R = dReal;
00531 spCplxDest->I = dImag;
00532 }
00533
00534
00535 INLINE void clDSPOp::CplxDiv (stpSCplx spCplxDest, const stpSCplx spCplxSrc1,
00536 const stpSCplx spCplxSrc2)
00537 {
00538 spCplxDest->R =
00539 (spCplxSrc1->R * spCplxSrc2->R + spCplxSrc1->I * spCplxSrc2->I) /
00540 (spCplxSrc2->R * spCplxSrc2->R + spCplxSrc2->I * spCplxSrc2->I);
00541 spCplxDest->I =
00542 (spCplxSrc1->I * spCplxSrc2->R - spCplxSrc1->R * spCplxSrc2->I) /
00543 (spCplxSrc2->R * spCplxSrc2->R + spCplxSrc2->I * spCplxSrc2->I);
00544 }
00545
00546
00547 INLINE void clDSPOp::CplxDiv (stpDCplx spCplxDest, const stpDCplx spCplxSrc1,
00548 const stpDCplx spCplxSrc2)
00549 {
00550 spCplxDest->R =
00551 (spCplxSrc1->R * spCplxSrc2->R + spCplxSrc1->I * spCplxSrc2->I) /
00552 (spCplxSrc2->R * spCplxSrc2->R + spCplxSrc2->I * spCplxSrc2->I);
00553 spCplxDest->I =
00554 (spCplxSrc1->I * spCplxSrc2->R - spCplxSrc1->R * spCplxSrc2->I) /
00555 (spCplxSrc2->R * spCplxSrc2->R + spCplxSrc2->I * spCplxSrc2->I);
00556 }
00557
00558
00559 INLINE void clDSPOp::CplxExp (stpSCplx spCplxDest, const stpSCplx spCplxSrc)
00560 {
00561 float fRealExp;
00562
00563 fRealExp = expf(spCplxSrc->R);
00564 #ifndef _GNU_SOURCE
00565 spCplxDest->R = fRealExp * cosf(spCplxSrc->I);
00566 spCplxDest->I = fRealExp * sinf(spCplxSrc->I);
00567 #else
00568 sincosf(spCplxSrc->I, &spCplxDest->I, &spCplxDest->R);
00569 spCplxDest->R *= fRealExp;
00570 spCplxDest->I *= fRealExp;
00571 #endif
00572 }
00573
00574
00575 INLINE void clDSPOp::CplxExp (stpDCplx spCplxDest, const stpDCplx spCplxSrc)
00576 {
00577 double dRealExp;
00578
00579 dRealExp = exp(spCplxSrc->R);
00580 #ifndef _GNU_SOURCE
00581 spCplxDest->R = dRealExp * cos(spCplxSrc->I);
00582 spCplxDest->I = dRealExp * sin(spCplxSrc->I);
00583 #else
00584 sincos(spCplxSrc->I, &spCplxDest->I, &spCplxDest->R);
00585 spCplxDest->R *= dRealExp;
00586 spCplxDest->I *= dRealExp;
00587 #endif
00588 }
00589
00590
00591 INLINE void clDSPOp::CplxLog (stpSCplx spCplxDest, const stpSCplx spCplxSrc)
00592 {
00593 Cart2Polar(&spCplxDest->R, &spCplxDest->I, spCplxSrc->R, spCplxSrc->I);
00594 spCplxDest->R = logf(spCplxDest->R);
00595 }
00596
00597
00598 INLINE void clDSPOp::CplxLog (stpDCplx spCplxDest, const stpDCplx spCplxSrc)
00599 {
00600 Cart2Polar(&spCplxDest->R, &spCplxDest->I, spCplxSrc->R, spCplxSrc->I);
00601 spCplxDest->R = log(spCplxDest->R);
00602 }
00603
00604
00605 INLINE void clDSPOp::CplxLog10 (stpSCplx spCplxDest, const stpSCplx spCplxSrc)
00606 {
00607 Cart2Polar(&spCplxDest->R, &spCplxDest->I, spCplxSrc->R, spCplxSrc->I);
00608 spCplxDest->R = log10f(spCplxDest->R);
00609 }
00610
00611
00612 INLINE void clDSPOp::CplxLog10 (stpDCplx spCplxDest, const stpDCplx spCplxSrc)
00613 {
00614 Cart2Polar(&spCplxDest->R, &spCplxDest->I, spCplxSrc->R, spCplxSrc->I);
00615 spCplxDest->R = log10(spCplxDest->R);
00616 }
00617
00618
00619 INLINE void clDSPOp::CplxPow (stpSCplx spCplxDest, const stpSCplx spCplxSrc,
00620 const stpSCplx spCplxExp)
00621 {
00622 stSCplx sCplxTemp;
00623
00624 CplxLog(&sCplxTemp, spCplxSrc);
00625 CplxMul(&sCplxTemp, spCplxExp);
00626 CplxExp(spCplxDest, &sCplxTemp);
00627 }
00628
00629
00630 INLINE void clDSPOp::CplxPow (stpDCplx spCplxDest, const stpDCplx spCplxSrc,
00631 const stpDCplx spCplxExp)
00632 {
00633 stDCplx sCplxTemp;
00634
00635 CplxLog(&sCplxTemp, spCplxSrc);
00636 CplxMul(&sCplxTemp, spCplxExp);
00637 CplxExp(spCplxDest, &sCplxTemp);
00638 }
00639
00640
00641 INLINE void clDSPOp::CplxRoot (stpSCplx spCplxDest, const stpSCplx spCplxSrc,
00642 const stpSCplx spCplxRoot)
00643 {
00644 stSCplx sCplxExp;
00645
00646 sCplxExp.R = 1.0F;
00647 sCplxExp.I = 0.0F;
00648 CplxDiv(&sCplxExp, spCplxRoot);
00649 CplxPow(spCplxDest, spCplxSrc, &sCplxExp);
00650 }
00651
00652
00653 INLINE void clDSPOp::CplxRoot (stpDCplx spCplxDest, const stpDCplx spCplxSrc,
00654 const stpDCplx spCplxRoot)
00655 {
00656 stDCplx sCplxExp;
00657
00658 sCplxExp.R = 1.0;
00659 sCplxExp.I = 0.0;
00660 CplxDiv(&sCplxExp, spCplxRoot);
00661 CplxPow(spCplxDest, spCplxSrc, &sCplxExp);
00662 }
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677 INLINE void clDSPOp::CplxConj (stpSCplx spCplxDest, const stpSCplx spCplxSrc)
00678 {
00679 spCplxDest->R = spCplxSrc->R;
00680 spCplxDest->I = -(spCplxSrc->I);
00681 }
00682
00683
00684 INLINE void clDSPOp::CplxConj (stpDCplx spCplxDest, const stpDCplx spCplxSrc)
00685 {
00686 spCplxDest->R = spCplxSrc->R;
00687 spCplxDest->I = -(spCplxSrc->I);
00688 }
00689
00690
00691 INLINE double clDSPOp::Multiple (long lValue)
00692 {
00693 long lLoopCntr;
00694 double dMult = 1.0;
00695
00696 for (lLoopCntr = 1L; lLoopCntr <= lValue; lLoopCntr++)
00697 {
00698 dMult *= (double) lLoopCntr;
00699 }
00700 return dMult;
00701 }
00702
00703
00704 INLINE float clDSPOp::ModZeroBessel (float fValue)
00705 {
00706 long lLoopCntr;
00707 float fMZBessel = 0.0F;
00708 float fHalfValue;
00709
00710 fHalfValue = fValue / 2.0F;
00711 for (lLoopCntr = 0L; lLoopCntr <= DSP_MAXBESSEL; lLoopCntr++)
00712 {
00713 fMZBessel += (float) pow(
00714 pow(fHalfValue, lLoopCntr) / Multiple(lLoopCntr), 2.0);
00715 }
00716 return fMZBessel;
00717 }
00718
00719
00720 INLINE double clDSPOp::ModZeroBessel (double dValue)
00721 {
00722 long lLoopCntr;
00723 double dMZBessel = 0.0;
00724 double dHalfValue;
00725
00726 dHalfValue = dValue / 2.0;
00727 for (lLoopCntr = 0L; lLoopCntr <= DSP_MAXBESSEL; lLoopCntr++)
00728 {
00729 dMZBessel += pow(
00730 pow(dHalfValue, lLoopCntr) / Multiple(lLoopCntr), 2.0);
00731 }
00732 return dMZBessel;
00733 }
00734
00735
00736 float clDSPOp::ChebyshevPolynom (float fOrder, float fValue)
00737 {
00738 if (fabsf(fValue) <= 1.0F)
00739 {
00740 return cosf(fOrder * acosf(fValue));
00741 }
00742 else
00743 {
00744 return coshf(fOrder * acoshf(fValue));
00745 }
00746 }
00747
00748
00749 double clDSPOp::ChebyshevPolynom (double dOrder, double dValue)
00750 {
00751 if (fabs(dValue) <= 1.0)
00752 {
00753 return cos(dOrder * acos(dValue));
00754 }
00755 else
00756 {
00757 return cosh(dOrder * acosh(dValue));
00758 }
00759 }
00760
00761
00762 clDSPOp::clDSPOp()
00763 {
00764 #ifdef DSP_X86
00765 bHave3DNow = (dsp_x86_have_e3dnow()) ? true : false;
00766 bHaveSSE = (dsp_x86_have_sse2()) ? true : false;
00767 #endif
00768 lPrevSrcCount = 0;
00769 lPrevDestCount = 0;
00770
00771 #ifdef _ISOC9X_SOURCE
00772 fPI = (float) acosl(-1.0);
00773 dPI = (double) acosl(-1.0);
00774 #else
00775 fPI = (float) acos(-1.0);
00776 dPI = acos(-1.0);
00777 #endif
00778 bFFTInitialized = false;
00779 lpSBitRevWork = NULL;
00780 lpDBitRevWork = NULL;
00781 fpCosSinTable = NULL;
00782 dpCosSinTable = NULL;
00783 }
00784
00785
00786 clDSPOp::~clDSPOp()
00787 {
00788 if (bFFTInitialized)
00789 {
00790 FFTUninitialize();
00791 }
00792 }
00793
00794
00795 void clDSPOp::Add (float *fpDest, float fSrc, long lCount)
00796 {
00797 #ifdef DSP_IPP
00798 ippsAddC_32f_I(fSrc, fpDest, lCount);
00799 #else
00800 long lLoopCntr;
00801
00802 #ifdef DSP_X86
00803 if (bHave3DNow)
00804 {
00805 dsp_x86_3dnow_addf(fpDest, fSrc, lCount);
00806 }
00807 else
00808 #endif
00809 {
00810 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
00811 {
00812 fpDest[lLoopCntr] += fSrc;
00813 }
00814 }
00815 #endif
00816 }
00817
00818
00819 void clDSPOp::Add (double *dpDest, double dSrc, long lCount)
00820 {
00821 #ifdef DSP_IPP
00822 ippsAddC_64f_I(dSrc, dpDest, lCount);
00823 #else
00824 long lLoopCntr;
00825
00826 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
00827 {
00828 dpDest[lLoopCntr] += dSrc;
00829 }
00830 #endif
00831 }
00832
00833
00834 void clDSPOp::Add (stpSCplx spCplxDest, stSCplx sCplxSrc, long lCount)
00835 {
00836 #ifdef DSP_IPP
00837 ippsAddC_32fc_I(*((Ipp32fc *) &sCplxSrc), (Ipp32fc *) spCplxDest, lCount);
00838 #else
00839 long lLoopCntr;
00840
00841 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
00842 {
00843 CplxAdd(&spCplxDest[lLoopCntr], &sCplxSrc);
00844 }
00845 #endif
00846 }
00847
00848
00849 void clDSPOp::Add (stpDCplx spCplxDest, stDCplx sCplxSrc, long lCount)
00850 {
00851 #ifdef DSP_IPP
00852 ippsAddC_64fc_I(*((Ipp64fc *) &sCplxSrc), (Ipp64fc *) spCplxDest, lCount);
00853 #else
00854 long lLoopCntr;
00855
00856 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
00857 {
00858 CplxAdd(&spCplxDest[lLoopCntr], &sCplxSrc);
00859 }
00860 #endif
00861 }
00862
00863
00864 void clDSPOp::Add (float *fpDest, const float *fpSrc, long lCount)
00865 {
00866 #ifdef DSP_IPP
00867 ippsAdd_32f_I(fpSrc, fpDest, lCount);
00868 #else
00869 long lLoopCntr;
00870
00871 #ifdef DSP_X86
00872 if (bHave3DNow)
00873 {
00874 dsp_x86_3dnow_add2f(fpDest, fpSrc, lCount);
00875 }
00876 else
00877 #endif
00878 {
00879 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
00880 {
00881 fpDest[lLoopCntr] += fpSrc[lLoopCntr];
00882 }
00883 }
00884 #endif
00885 }
00886
00887
00888 void clDSPOp::Add (double *dpDest, const double *dpSrc, long lCount)
00889 {
00890 #ifdef DSP_IPP
00891 ippsAdd_64f_I(dpSrc, dpDest, lCount);
00892 #else
00893 long lLoopCntr;
00894
00895 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
00896 {
00897 dpDest[lLoopCntr] += dpSrc[lLoopCntr];
00898 }
00899 #endif
00900 }
00901
00902
00903 void clDSPOp::Add (stpSCplx spCplxDest, const stpSCplx spCplxSrc, long lCount)
00904 {
00905 #ifdef DSP_IPP
00906 ippsAdd_32fc_I((Ipp32fc *) spCplxSrc, (Ipp32fc *) spCplxDest, lCount);
00907 #else
00908 long lLoopCntr;
00909
00910 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
00911 {
00912 CplxAdd(&spCplxDest[lLoopCntr], &spCplxSrc[lLoopCntr]);
00913 }
00914 #endif
00915 }
00916
00917
00918 void clDSPOp::Add (stpDCplx spCplxDest, const stpDCplx spCplxSrc, long lCount)
00919 {
00920 #ifdef DSP_IPP
00921 ippsAdd_64fc_I((Ipp64fc *) spCplxSrc, (Ipp64fc *) spCplxDest, lCount);
00922 #else
00923 long lLoopCntr;
00924
00925 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
00926 {
00927 CplxAdd(&spCplxDest[lLoopCntr], &spCplxSrc[lLoopCntr]);
00928 }
00929 #endif
00930 }
00931
00932
00933 void clDSPOp::Add (float *fpDest, const float *fpSrc1, const float *fpSrc2,
00934 long lCount)
00935 {
00936 #ifdef DSP_IPP
00937 ippsAdd_32f(fpSrc1, fpSrc2, fpDest, lCount);
00938 #else
00939 long lLoopCntr;
00940
00941 #ifdef DSP_X86
00942 if (bHave3DNow)
00943 {
00944 dsp_x86_3dnow_add3f(fpDest, fpSrc1, fpSrc2, lCount);
00945 }
00946 else
00947 #endif
00948 {
00949 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
00950 {
00951 fpDest[lLoopCntr] = fpSrc1[lLoopCntr] + fpSrc2[lLoopCntr];
00952 }
00953 }
00954 #endif
00955 }
00956
00957
00958 void clDSPOp::Add (double *dpDest, const double *dpSrc1, const double *dpSrc2,
00959 long lCount)
00960 {
00961 #ifdef DSP_IPP
00962 ippsAdd_64f(dpSrc1, dpSrc2, dpDest, lCount);
00963 #else
00964 long lLoopCntr;
00965
00966 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
00967 {
00968 dpDest[lLoopCntr] = dpSrc1[lLoopCntr] + dpSrc2[lLoopCntr];
00969 }
00970 #endif
00971 }
00972
00973
00974 void clDSPOp::Add (stpSCplx spCplxDest, const stpSCplx spCplxSrc1,
00975 const stpSCplx spCplxSrc2, long lCount)
00976 {
00977 #ifdef DSP_IPP
00978 ippsAdd_32fc((Ipp32fc *) spCplxSrc1, (Ipp32fc *) spCplxSrc2,
00979 (Ipp32fc *) spCplxDest, lCount);
00980 #else
00981 long lLoopCntr;
00982
00983 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
00984 {
00985 CplxAdd(&spCplxDest[lLoopCntr], &spCplxSrc1[lLoopCntr],
00986 &spCplxSrc2[lLoopCntr]);
00987 }
00988 #endif
00989 }
00990
00991
00992 void clDSPOp::Add (stpDCplx spCplxDest, const stpDCplx spCplxSrc1,
00993 const stpDCplx spCplxSrc2, long lCount)
00994 {
00995 #ifdef DSP_IPP
00996 ippsAdd_64fc((Ipp64fc *) spCplxSrc1, (Ipp64fc *) spCplxSrc2,
00997 (Ipp64fc *) spCplxDest, lCount);
00998 #else
00999 long lLoopCntr;
01000
01001 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01002 {
01003 CplxAdd(&spCplxDest[lLoopCntr], &spCplxSrc1[lLoopCntr],
01004 &spCplxSrc2[lLoopCntr]);
01005 }
01006 #endif
01007 }
01008
01009
01010 void clDSPOp::Sub (float *fpDest, float fSrc, long lCount)
01011 {
01012 #ifdef DSP_IPP
01013 ippsSubC_32f_I(fSrc, fpDest, lCount);
01014 #else
01015 long lLoopCntr;
01016
01017 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01018 {
01019 fpDest[lLoopCntr] -= fSrc;
01020 }
01021 #endif
01022 }
01023
01024
01025 void clDSPOp::Sub (double *dpDest, double dSrc, long lCount)
01026 {
01027 #ifdef DSP_IPP
01028 ippsSubC_64f_I(dSrc, dpDest, lCount);
01029 #else
01030 long lLoopCntr;
01031
01032 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01033 {
01034 dpDest[lLoopCntr] -= dSrc;
01035 }
01036 #endif
01037 }
01038
01039
01040 void clDSPOp::Sub (stpSCplx spCplxDest, stSCplx sCplxSrc, long lCount)
01041 {
01042 #ifdef DSP_IPP
01043 ippsSubC_32fc_I(*((Ipp32fc *) &sCplxSrc), (Ipp32fc *) spCplxDest, lCount);
01044 #else
01045 long lLoopCntr;
01046
01047 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01048 {
01049 CplxSub(&spCplxDest[lLoopCntr], &sCplxSrc);
01050 }
01051 #endif
01052 }
01053
01054
01055 void clDSPOp::Sub (stpDCplx spCplxDest, stDCplx sCplxSrc, long lCount)
01056 {
01057 #ifdef DSP_IPP
01058 ippsSubC_64fc_I(*((Ipp64fc *) &sCplxSrc), (Ipp64fc *) spCplxDest, lCount);
01059 #else
01060 long lLoopCntr;
01061
01062 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01063 {
01064 CplxSub(&spCplxDest[lLoopCntr], &sCplxSrc);
01065 }
01066 #endif
01067 }
01068
01069
01070 void clDSPOp::Sub (float *fpDest, const float *fpSrc, long lCount)
01071 {
01072 #ifdef DSP_IPP
01073 ippsSub_32f_I(fpSrc, fpDest, lCount);
01074 #else
01075 long lLoopCntr;
01076
01077 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01078 {
01079 fpDest[lLoopCntr] -= fpSrc[lLoopCntr];
01080 }
01081 #endif
01082 }
01083
01084
01085 void clDSPOp::Sub (double *dpDest, const double *dpSrc, long lCount)
01086 {
01087 #ifdef DSP_IPP
01088 ippsSub_64f_I(dpSrc, dpDest, lCount);
01089 #else
01090 long lLoopCntr;
01091
01092 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01093 {
01094 dpDest[lLoopCntr] -= dpSrc[lLoopCntr];
01095 }
01096 #endif
01097 }
01098
01099
01100 void clDSPOp::Sub (stpSCplx spCplxDest, const stpSCplx spCplxSrc, long lCount)
01101 {
01102 #ifdef DSP_IPP
01103 ippsSub_32fc_I((Ipp32fc *) spCplxSrc, (Ipp32fc *) spCplxDest, lCount);
01104 #else
01105 long lLoopCntr;
01106
01107 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01108 {
01109 CplxSub(&spCplxDest[lLoopCntr], &spCplxSrc[lLoopCntr]);
01110 }
01111 #endif
01112 }
01113
01114
01115 void clDSPOp::Sub (stpDCplx spCplxDest, const stpDCplx spCplxSrc, long lCount)
01116 {
01117 #ifdef DSP_IPP
01118 ippsSub_64fc_I((Ipp64fc *) spCplxSrc, (Ipp64fc *) spCplxDest, lCount);
01119 #else
01120 long lLoopCntr;
01121
01122 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01123 {
01124 CplxSub(&spCplxDest[lLoopCntr], &spCplxSrc[lLoopCntr]);
01125 }
01126 #endif
01127 }
01128
01129
01130 void clDSPOp::Sub (float *fpDest, const float *fpSrc1, const float *fpSrc2,
01131 long lCount)
01132 {
01133 #ifdef DSP_IPP
01134 ippsSub_32f(fpSrc1, fpSrc2, fpDest, lCount);
01135 #else
01136 long lLoopCntr;
01137
01138 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01139 {
01140 fpDest[lLoopCntr] = fpSrc1[lLoopCntr] - fpSrc2[lLoopCntr];
01141 }
01142 #endif
01143 }
01144
01145
01146 void clDSPOp::Sub (double *dpDest, const double *dpSrc1, const double *dpSrc2,
01147 long lCount)
01148 {
01149 #ifdef DSP_IPP
01150 ippsSub_64f(dpSrc1, dpSrc2, dpDest, lCount);
01151 #else
01152 long lLoopCntr;
01153
01154 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01155 {
01156 dpDest[lLoopCntr] = dpSrc1[lLoopCntr] - dpSrc2[lLoopCntr];
01157 }
01158 #endif
01159 }
01160
01161
01162 void clDSPOp::Sub (stpSCplx spCplxDest, const stpSCplx spCplxSrc1,
01163 const stpSCplx spCplxSrc2, long lCount)
01164 {
01165 #ifdef DSP_IPP
01166 ippsSub_32fc((Ipp32fc *) spCplxSrc1, (Ipp32fc *) spCplxSrc2,
01167 (Ipp32fc *) spCplxDest, lCount);
01168 #else
01169 long lLoopCntr;
01170
01171 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01172 {
01173 CplxSub(&spCplxDest[lLoopCntr], &spCplxSrc1[lLoopCntr],
01174 &spCplxSrc2[lLoopCntr]);
01175 }
01176 #endif
01177 }
01178
01179
01180 void clDSPOp::Sub (stpDCplx spCplxDest, const stpDCplx spCplxSrc1,
01181 const stpDCplx spCplxSrc2, long lCount)
01182 {
01183 #ifdef DSP_IPP
01184 ippsSub_64fc((Ipp64fc *) spCplxSrc1, (Ipp64fc *) spCplxSrc2,
01185 (Ipp64fc *) spCplxDest, lCount);
01186 #else
01187 long lLoopCntr;
01188
01189 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01190 {
01191 CplxSub(&spCplxDest[lLoopCntr], &spCplxSrc1[lLoopCntr],
01192 &spCplxSrc2[lLoopCntr]);
01193 }
01194 #endif
01195 }
01196
01197
01198
01199 void clDSPOp::Mul (float *fpVect, float fSrc, long lCount)
01200 {
01201 #ifdef DSP_IPP
01202 ippsMulC_32f_I(fSrc, fpVect, lCount);
01203 #else
01204 long lLoopCntr;
01205
01206 #ifdef DSP_X86
01207 if (bHave3DNow)
01208 {
01209 dsp_x86_3dnow_mulf(fpVect, fSrc, lCount);
01210 }
01211 else
01212 #endif
01213 {
01214 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01215 {
01216 fpVect[lLoopCntr] *= fSrc;
01217 }
01218 }
01219 #endif
01220 }
01221
01222
01223 void clDSPOp::Mul (double *dpVect, double dSrc, long lCount)
01224 {
01225 #ifdef DSP_IPP
01226 ippsMulC_64f_I(dSrc, dpVect, lCount);
01227 #else
01228 long lLoopCntr;
01229
01230 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01231 {
01232 dpVect[lLoopCntr] *= dSrc;
01233 }
01234 #endif
01235 }
01236
01237
01238 void clDSPOp::Mul (stpSCplx spCplxDest, float fSrc, long lCount)
01239 {
01240 long lLoopCntr;
01241
01242 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01243 {
01244 CplxMul(&spCplxDest[lLoopCntr], fSrc);
01245 }
01246 }
01247
01248
01249 void clDSPOp::Mul (stpDCplx spCplxDest, double dSrc, long lCount)
01250 {
01251 long lLoopCntr;
01252
01253 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01254 {
01255 CplxMul(&spCplxDest[lLoopCntr], dSrc);
01256 }
01257 }
01258
01259
01260 void clDSPOp::Mul (stpSCplx spCplxDest, stSCplx sCplxSrc, long lCount)
01261 {
01262 #ifdef DSP_IPP
01263 ippsMulC_32fc_I(*((Ipp32fc *) &sCplxSrc), (Ipp32fc *) spCplxDest, lCount);
01264 #else
01265 long lLoopCntr;
01266
01267 #ifdef DSP_X86
01268 if (bHave3DNow)
01269 {
01270 dsp_x86_3dnow_cmulf((float *) spCplxDest,
01271 (const float *) &sCplxSrc, lCount);
01272 }
01273 else
01274 #endif
01275 {
01276 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01277 {
01278 CplxMul(&spCplxDest[lLoopCntr], &sCplxSrc);
01279 }
01280 }
01281 #endif
01282 }
01283
01284
01285 void clDSPOp::Mul (stpDCplx spCplxDest, stDCplx sCplxSrc, long lCount)
01286 {
01287 #ifdef DSP_IPP
01288 ippsMulC_64fc_I(*((Ipp64fc *) &sCplxSrc), (Ipp64fc *) spCplxDest, lCount);
01289 #else
01290 long lLoopCntr;
01291
01292 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01293 {
01294 CplxMul(&spCplxDest[lLoopCntr], &sCplxSrc);
01295 }
01296 #endif
01297 }
01298
01299
01300 void clDSPOp::Mul (float *fpDest, const float *fpSrc1, float fSrc2,
01301 long lCount)
01302 {
01303 #ifdef DSP_IPP
01304 ippsMulC_32f(fpSrc1, fSrc2, fpDest, lCount);
01305 #else
01306 long lLoopCntr;
01307
01308 #ifdef DSP_X86
01309 if (bHave3DNow)
01310 {
01311 dsp_x86_3dnow_mulf_nip(fpDest, fpSrc1, fSrc2, lCount);
01312 }
01313 else
01314 #endif
01315 {
01316 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01317 {
01318 fpDest[lLoopCntr] = fpSrc1[lLoopCntr] * fSrc2;
01319 }
01320 }
01321 #endif
01322 }
01323
01324
01325 void clDSPOp::Mul (double *dpDest, const double *dpSrc1, double dSrc2,
01326 long lCount)
01327 {
01328 #ifdef DSP_IPP
01329 ippsMulC_64f(dpSrc1, dSrc2, dpDest, lCount);
01330 #else
01331 long lLoopCntr;
01332
01333 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01334 {
01335 dpDest[lLoopCntr] = dpSrc1[lLoopCntr] * dSrc2;
01336 }
01337 #endif
01338 }
01339
01340
01341 void clDSPOp::Mul (float *fpDest, const float *fpSrc, long lCount)
01342 {
01343 #ifdef DSP_IPP
01344 ippsMul_32f_I(fpSrc, fpDest, lCount);
01345 #else
01346 long lLoopCntr;
01347
01348 #ifdef DSP_X86
01349 if (bHave3DNow)
01350 {
01351 dsp_x86_3dnow_mul2f(fpDest, fpSrc, lCount);
01352 }
01353 else
01354 #endif
01355 {
01356 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01357 {
01358 fpDest[lLoopCntr] *= fpSrc[lLoopCntr];
01359 }
01360 }
01361 #endif
01362 }
01363
01364
01365 void clDSPOp::Mul (double *dpDest, const double *dpSrc, long lCount)
01366 {
01367 #ifdef DSP_IPP
01368 ippsMul_64f_I(dpSrc, dpDest, lCount);
01369 #else
01370 long lLoopCntr;
01371
01372 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01373 {
01374 dpDest[lLoopCntr] *= dpSrc[lLoopCntr];
01375 }
01376 #endif
01377 }
01378
01379
01380 void clDSPOp::Mul (stpSCplx spCplxDest, const float *fpSrc, long lCount)
01381 {
01382 long lLoopCntr;
01383
01384 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01385 {
01386 CplxMul(&spCplxDest[lLoopCntr], fpSrc[lLoopCntr]);
01387 }
01388 }
01389
01390
01391 void clDSPOp::Mul (stpDCplx spCplxDest, const double *dpSrc, long lCount)
01392 {
01393 long lLoopCntr;
01394
01395 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01396 {
01397 CplxMul(&spCplxDest[lLoopCntr], dpSrc[lLoopCntr]);
01398 }
01399 }
01400
01401
01402 void clDSPOp::Mul (stpSCplx spCplxDest, const stpSCplx spCplxSrc, long lCount)
01403 {
01404 #ifdef DSP_IPP
01405 ippsMul_32fc_I((Ipp32fc *) spCplxSrc, (Ipp32fc *) spCplxDest, lCount);
01406 #else
01407 long lLoopCntr;
01408
01409 #ifdef DSP_X86
01410 if (bHave3DNow)
01411 {
01412 dsp_x86_3dnow_cmul2f((float *) spCplxDest, (const float *) spCplxSrc,
01413 lCount);
01414 }
01415 else
01416 #endif
01417 {
01418 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01419 {
01420 CplxMul(&spCplxDest[lLoopCntr], &spCplxSrc[lLoopCntr]);
01421 }
01422 }
01423 #endif
01424 }
01425
01426
01427 void clDSPOp::Mul (stpDCplx spCplxDest, const stpDCplx spCplxSrc, long lCount)
01428 {
01429 #ifdef DSP_IPP
01430 ippsMul_64fc_I((Ipp64fc *) spCplxSrc, (Ipp64fc *) spCplxDest, lCount);
01431 #else
01432 long lLoopCntr;
01433
01434 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01435 {
01436 CplxMul(&spCplxDest[lLoopCntr], &spCplxSrc[lLoopCntr]);
01437 }
01438 #endif
01439 }
01440
01441
01442 void clDSPOp::Mul (float *fpDest, const float *fpSrc1,
01443 const float *fpSrc2, long lCount)
01444 {
01445 #ifdef DSP_IPP
01446 ippsMul_32f(fpSrc1, fpSrc2, fpDest, lCount);
01447 #else
01448 long lLoopCntr;
01449
01450 #ifdef DSP_X86
01451 if (bHave3DNow)
01452 {
01453 dsp_x86_3dnow_mul3f(fpDest, fpSrc1, fpSrc2, lCount);
01454 }
01455 else
01456 #endif
01457 {
01458 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01459 {
01460 fpDest[lLoopCntr] = fpSrc1[lLoopCntr] * fpSrc2[lLoopCntr];
01461 }
01462 }
01463 #endif
01464 }
01465
01466
01467 void clDSPOp::Mul (double *dpDest, const double *dpSrc1,
01468 const double *dpSrc2, long lCount)
01469 {
01470 #ifdef DSP_IPP
01471 ippsMul_64f(dpSrc1, dpSrc2, dpDest, lCount);
01472 #else
01473 long lLoopCntr;
01474
01475 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01476 {
01477 dpDest[lLoopCntr] = dpSrc1[lLoopCntr] * dpSrc2[lLoopCntr];
01478 }
01479 #endif
01480 }
01481
01482
01483 void clDSPOp::Mul (stpSCplx spCplxDest, const stpSCplx spCplxSrc1,
01484 const stpSCplx spCplxSrc2, long lCount)
01485 {
01486 #ifdef DSP_IPP
01487 ippsMul_64fc((Ipp64fc *) spCplxSrc1, (Ipp64fc *) spCplxSrc2,
01488 (Ipp64fc *) spCplxDest, lCount);
01489 #else
01490 long lLoopCntr;
01491
01492 #ifdef DSP_X86
01493 if (bHave3DNow)
01494 {
01495 dsp_x86_3dnow_cmul3f((float *) spCplxDest,
01496 (const float *) spCplxSrc1,
01497 (const float *) spCplxSrc2,
01498 lCount);
01499 }
01500 else
01501 #endif
01502 {
01503 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01504 {
01505 CplxMul(&spCplxDest[lLoopCntr], &spCplxSrc1[lLoopCntr],
01506 &spCplxSrc2[lLoopCntr]);
01507 }
01508 }
01509 #endif
01510 }
01511
01512
01513 void clDSPOp::Mul (stpDCplx spCplxDest, const stpDCplx spCplxSrc1,
01514 const stpDCplx spCplxSrc2, long lCount)
01515 {
01516 #ifdef DSP_IPP
01517 ippsMul_64fc((Ipp64fc *) spCplxSrc1, (Ipp64fc *) spCplxSrc2,
01518 (Ipp64fc *) spCplxDest, lCount);
01519 #else
01520 long lLoopCntr;
01521
01522 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01523 {
01524 CplxMul(&spCplxDest[lLoopCntr], &spCplxSrc1[lLoopCntr],
01525 &spCplxSrc2[lLoopCntr]);
01526 }
01527 #endif
01528 }
01529
01530
01531 void clDSPOp::MulC (stpSCplx spCplxDest, const stpSCplx spCplxSrc, long lCount)
01532 {
01533 long lLoopCntr;
01534
01535 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01536 {
01537 CplxMulC(&spCplxDest[lLoopCntr], &spCplxSrc[lLoopCntr]);
01538 }
01539 }
01540
01541
01542 void clDSPOp::MulC (stpDCplx spCplxDest, const stpDCplx spCplxSrc, long lCount)
01543 {
01544 long lLoopCntr;
01545
01546 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01547 {
01548 CplxMulC(&spCplxDest[lLoopCntr], &spCplxSrc[lLoopCntr]);
01549 }
01550 }
01551
01552
01553 void clDSPOp::MulC (stpSCplx spCplxDest, const stpSCplx spCplxSrc1,
01554 const stpSCplx spCplxSrc2, long lCount)
01555 {
01556 long lLoopCntr;
01557
01558 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01559 {
01560 CplxMulC(&spCplxDest[lLoopCntr], &spCplxSrc1[lLoopCntr],
01561 &spCplxSrc2[lLoopCntr]);
01562 }
01563 }
01564
01565
01566 void clDSPOp::MulC (stpDCplx spCplxDest, const stpDCplx spCplxSrc1,
01567 const stpDCplx spCplxSrc2, long lCount)
01568 {
01569 long lLoopCntr;
01570
01571 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01572 {
01573 CplxMulC(&spCplxDest[lLoopCntr], &spCplxSrc1[lLoopCntr],
01574 &spCplxSrc2[lLoopCntr]);
01575 }
01576 }
01577
01578
01579 void clDSPOp::Mul2 (float *fpDst1, float *fpDst2, const float *fpSrc,
01580 long lCount)
01581 {
01582 long lLoopCntr;
01583
01584 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01585 {
01586 fpDst1[lLoopCntr] *= fpSrc[lLoopCntr];
01587 fpDst2[lLoopCntr] *= fpSrc[lLoopCntr];
01588 }
01589 }
01590
01591
01592 void clDSPOp::Mul2 (double *dpDst1, double *dpDst2, const double *dpSrc,
01593 long lCount)
01594 {
01595 long lLoopCntr;
01596
01597 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01598 {
01599 dpDst1[lLoopCntr] *= dpSrc[lLoopCntr];
01600 dpDst2[lLoopCntr] *= dpSrc[lLoopCntr];
01601 }
01602 }
01603
01604
01605 void clDSPOp::Mul2 (float *fpDst1, float *fpDst2, const float *fpSrc1,
01606 const float *fpSrc2, const float *fpMul, long lCount)
01607 {
01608 long lLoopCntr;
01609
01610 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01611 {
01612 fpDst1[lLoopCntr] = fpSrc1[lLoopCntr] * fpMul[lLoopCntr];
01613 fpDst2[lLoopCntr] = fpSrc2[lLoopCntr] * fpMul[lLoopCntr];
01614 }
01615 }
01616
01617
01618 void clDSPOp::Mul2 (double *dpDst1, double *dpDst2, const double *dpSrc1,
01619 const double *dpSrc2, const double *dpMul, long lCount)
01620 {
01621 long lLoopCntr;
01622
01623 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01624 {
01625 dpDst1[lLoopCntr] = dpSrc1[lLoopCntr] * dpMul[lLoopCntr];
01626 dpDst2[lLoopCntr] = dpSrc2[lLoopCntr] * dpMul[lLoopCntr];
01627 }
01628 }
01629
01630
01631 void clDSPOp::Div (float *fpVect, float fSrc, long lCount)
01632 {
01633 #ifdef DSP_IPP
01634 ippsDivC_32f_I(fSrc, fpVect, lCount);
01635 #else
01636 long lLoopCntr;
01637
01638 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01639 {
01640 fpVect[lLoopCntr] /= fSrc;
01641 }
01642 #endif
01643 }
01644
01645
01646 void clDSPOp::Div (double *dpVect, double dSrc, long lCount)
01647 {
01648 #ifdef DSP_IPP
01649 ippsDivC_64f_I(dSrc, dpVect, lCount);
01650 #else
01651 long lLoopCntr;
01652
01653 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01654 {
01655 dpVect[lLoopCntr] /= dSrc;
01656 }
01657 #endif
01658 }
01659
01660
01661 void clDSPOp::Div (stpSCplx spCplxDest, stSCplx sCplxSrc, long lCount)
01662 {
01663 #ifdef DSP_IPP
01664 ippsDivC_32fc_I(*((Ipp32fc *) &sCplxSrc), (Ipp32fc *) spCplxDest, lCount);
01665 #else
01666 long lLoopCntr;
01667
01668 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01669 {
01670 CplxDiv(&spCplxDest[lLoopCntr], &sCplxSrc);
01671 }
01672 #endif
01673 }
01674
01675
01676 void clDSPOp::Div (stpDCplx spCplxDest, stDCplx sCplxSrc, long lCount)
01677 {
01678 #ifdef DSP_IPP
01679 ippsDivC_64fc_I(*((Ipp64fc *) &sCplxSrc), (Ipp64fc *) spCplxDest, lCount);
01680 #else
01681 long lLoopCntr;
01682
01683 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01684 {
01685 CplxDiv(&spCplxDest[lLoopCntr], &sCplxSrc);
01686 }
01687 #endif
01688 }
01689
01690
01691 void clDSPOp::Div (float *fpDest, const float *fpSrc, long lCount)
01692 {
01693 #ifdef DSP_IPP
01694 ippsDiv_32f_I(fpSrc, fpDest, lCount);
01695 #else
01696 long lLoopCntr;
01697
01698 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01699 {
01700 fpDest[lLoopCntr] /= fpSrc[lLoopCntr];
01701 }
01702 #endif
01703 }
01704
01705
01706 void clDSPOp::Div (double *dpDest, const double *dpSrc, long lCount)
01707 {
01708 #ifdef DSP_IPP
01709 ippsDiv_64f_I(dpSrc, dpDest, lCount);
01710 #else
01711 long lLoopCntr;
01712
01713 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01714 {
01715 dpDest[lLoopCntr] /= dpSrc[lLoopCntr];
01716 }
01717 #endif
01718 }
01719
01720
01721 void clDSPOp::Div (stpSCplx spCplxDest, const stpSCplx spCplxSrc, long lCount)
01722 {
01723 #ifdef DSP_IPP
01724 ippsDiv_32fc_I((Ipp32fc *) spCplxSrc, (Ipp32fc *) spCplxDest, lCount);
01725 #else
01726 long lLoopCntr;
01727
01728 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01729 {
01730 CplxDiv(&spCplxDest[lLoopCntr], &spCplxSrc[lLoopCntr]);
01731 }
01732 #endif
01733 }
01734
01735
01736 void clDSPOp::Div (stpDCplx spCplxDest, const stpDCplx spCplxSrc, long lCount)
01737 {
01738 #ifdef DSP_IPP
01739 ippsDiv_64fc_I((Ipp64fc *) spCplxSrc, (Ipp64fc *) spCplxDest, lCount);
01740 #else
01741 long lLoopCntr;
01742
01743 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01744 {
01745 CplxDiv(&spCplxDest[lLoopCntr], &spCplxSrc[lLoopCntr]);
01746 }
01747 #endif
01748 }
01749
01750
01751 void clDSPOp::Div (float *fpDest, const float *fpSrc1, const float *fpSrc2,
01752 long lCount)
01753 {
01754 #ifdef DSP_IPP
01755 ippsDiv_32f(fpSrc1, fpSrc2, fpDest, lCount);
01756 #else
01757 long lLoopCntr;
01758
01759 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01760 {
01761 fpDest[lLoopCntr] = fpSrc1[lLoopCntr] / fpSrc2[lLoopCntr];
01762 }
01763 #endif
01764 }
01765
01766
01767 void clDSPOp::Div (double *dpDest, const double *dpSrc1, const double *dpSrc2,
01768 long lCount)
01769 {
01770 #ifdef DSP_IPP
01771 ippsDiv_64f(dpSrc1, dpSrc2, dpDest, lCount);
01772 #else
01773 long lLoopCntr;
01774
01775 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01776 {
01777 dpDest[lLoopCntr] = dpSrc1[lLoopCntr] / dpSrc2[lLoopCntr];
01778 }
01779 #endif
01780 }
01781
01782
01783 void clDSPOp::Div (stpSCplx spCplxDest, const stpSCplx spCplxSrc1,
01784 const stpSCplx spCplxSrc2, long lCount)
01785 {
01786 #ifdef DSP_IPP
01787 ippsDiv_32fc((Ipp32fc *) spCplxSrc1, (Ipp32fc *) spCplxSrc2,
01788 (Ipp32fc *) spCplxDest, lCount);
01789 #else
01790 long lLoopCntr;
01791
01792 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01793 {
01794 CplxDiv(&spCplxDest[lLoopCntr], &spCplxSrc1[lLoopCntr],
01795 &spCplxSrc2[lLoopCntr]);
01796 }
01797 #endif
01798 }
01799
01800
01801 void clDSPOp::Div (stpDCplx spCplxDest, const stpDCplx spCplxSrc1,
01802 const stpDCplx spCplxSrc2, long lCount)
01803 {
01804 #ifdef DSP_IPP
01805 ippsDiv_64fc((Ipp64fc *) spCplxSrc1, (Ipp64fc *) spCplxSrc2,
01806 (Ipp64fc *) spCplxDest, lCount);
01807 #else
01808 long lLoopCntr;
01809
01810 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01811 {
01812 CplxDiv(&spCplxDest[lLoopCntr], &spCplxSrc1[lLoopCntr],
01813 &spCplxSrc2[lLoopCntr]);
01814 }
01815 #endif
01816 }
01817
01818
01819 void clDSPOp::Div1x (float *fpVect, long lCount)
01820 {
01821 long lLoopCntr;
01822
01823 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01824 {
01825 fpVect[lLoopCntr] = 1.0F / fpVect[lLoopCntr];
01826 }
01827 }
01828
01829
01830 void clDSPOp::Div1x (double *dpVect, long lCount)
01831 {
01832 long lLoopCntr;
01833
01834 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01835 {
01836 dpVect[lLoopCntr] = 1.0 / dpVect[lLoopCntr];
01837 }
01838 }
01839
01840
01841 void clDSPOp::Div1x (float *fpDest, const float *fpSrc, long lCount)
01842 {
01843 long lLoopCntr;
01844
01845 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01846 {
01847 fpDest[lLoopCntr] = 1.0F / fpSrc[lLoopCntr];
01848 }
01849 }
01850
01851
01852 void clDSPOp::Div1x (double *dpDest, const double *dpSrc, long lCount)
01853 {
01854 long lLoopCntr;
01855
01856 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01857 {
01858 dpDest[lLoopCntr] = 1.0 / dpSrc[lLoopCntr];
01859 }
01860 }
01861
01862
01863 void clDSPOp::MulAdd (float *fpVect, float fMul, float fAdd, long lCount)
01864 {
01865 long lLoopCntr;
01866
01867 #ifdef DSP_X86
01868 if (bHave3DNow)
01869 {
01870 dsp_x86_3dnow_maf(fpVect, fMul, fAdd, lCount);
01871 }
01872 else
01873 #endif
01874 {
01875 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01876 {
01877 fpVect[lLoopCntr] = fpVect[lLoopCntr] * fMul + fAdd;
01878 }
01879 }
01880 }
01881
01882
01883 void clDSPOp::MulAdd (double *dpVect, double dMul, double dAdd, long lCount)
01884 {
01885 long lLoopCntr;
01886
01887 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01888 {
01889 dpVect[lLoopCntr] = dpVect[lLoopCntr] * dMul + dAdd;
01890 }
01891 }
01892
01893
01894 void clDSPOp::MulAdd (float *fpDest, const float *fpSrc,
01895 float fMul, float fAdd, long lCount)
01896 {
01897 long lLoopCntr;
01898
01899 #ifdef DSP_X86
01900 if (bHave3DNow)
01901 {
01902 dsp_x86_3dnow_ma2f(fpDest, fpSrc, fMul, fAdd, lCount);
01903 }
01904 else
01905 #endif
01906 {
01907 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01908 {
01909 fpDest[lLoopCntr] = fpSrc[lLoopCntr] * fMul + fAdd;
01910 }
01911 }
01912 }
01913
01914
01915 void clDSPOp::MulAdd (double *dpDest, const double *dpSrc,
01916 double dMul, double dAdd, long lCount)
01917 {
01918 long lLoopCntr;
01919
01920 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01921 {
01922 dpDest[lLoopCntr] = dpSrc[lLoopCntr] * dMul + dAdd;
01923 }
01924 }
01925
01926
01927 void clDSPOp::Abs (float *fpVect, long lCount)
01928 {
01929 #ifdef DSP_IPP
01930 ippsAbs_32f_I(fpVect, lCount);
01931 #else
01932 long lLoopCntr;
01933
01934 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01935 {
01936 fpVect[lLoopCntr] = fabsf(fpVect[lLoopCntr]);
01937 }
01938 #endif
01939 }
01940
01941
01942 void clDSPOp::Abs (double *dpVect, long lCount)
01943 {
01944 #ifdef DSP_IPP
01945 ippsAbs_64f_I(dpVect, lCount);
01946 #else
01947 long lLoopCntr;
01948
01949 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01950 {
01951 dpVect[lLoopCntr] = fabs(dpVect[lLoopCntr]);
01952 }
01953 #endif
01954 }
01955
01956
01957 void clDSPOp::Abs (float *fpDest, const float *fpSrc, long lCount)
01958 {
01959 #ifdef DSP_IPP
01960 ippsAbs_32f(fpSrc, fpDest, lCount);
01961 #else
01962 long lLoopCntr;
01963
01964 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01965 {
01966 fpDest[lLoopCntr] = fabsf(fpSrc[lLoopCntr]);
01967 }
01968 #endif
01969 }
01970
01971
01972 void clDSPOp::Abs (double *dpDest, const double *dpSrc, long lCount)
01973 {
01974 #ifdef DSP_IPP
01975 ippsAbs_64f(dpSrc, dpDest, lCount);
01976 #else
01977 long lLoopCntr;
01978
01979 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01980 {
01981 dpDest[lLoopCntr] = fabs(dpSrc[lLoopCntr]);
01982 }
01983 #endif
01984 }
01985
01986
01987 void clDSPOp::Sqrt (float *fpVect, long lCount)
01988 {
01989 #ifdef DSP_IPP
01990 ippsSqrt_32f_I(fpVect, lCount);
01991 #else
01992 long lLoopCntr;
01993
01994 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
01995 {
01996 fpVect[lLoopCntr] = sqrtf(fpVect[lLoopCntr]);
01997 }
01998 #endif
01999 }
02000
02001
02002 void clDSPOp::Sqrt (double *dpVect, long lCount)
02003 {
02004 #ifdef DSP_IPP
02005 ippsSqrt_64f_I(dpVect, lCount);
02006 #else
02007 long lLoopCntr;
02008
02009 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
02010 {
02011 dpVect[lLoopCntr] = sqrt(dpVect[lLoopCntr]);
02012 }
02013 #endif
02014 }
02015
02016
02017 void clDSPOp::Sqrt (float *fpDest, const float *fpSrc, long lCount)
02018 {
02019 #ifdef DSP_IPP
02020 ippsSqrt_32f(fpSrc, fpDest, lCount);
02021 #else
02022 long lLoopCntr;
02023
02024 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
02025 {
02026 fpDest[lLoopCntr] = sqrtf(fpSrc[lLoopCntr]);
02027 }
02028 #endif
02029 }
02030
02031
02032 void clDSPOp::Sqrt (double *dpDest, const double *dpSrc, long lCount)
02033 {
02034 #ifdef DSP_IPP
02035 ippsSqrt_64f(dpSrc, dpDest, lCount);
02036 #else
02037 long lLoopCntr;
02038
02039 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
02040 {
02041 dpDest[lLoopCntr] = sqrt(dpSrc[lLoopCntr]);
02042 }
02043 #endif
02044 }
02045
02046
02047 void clDSPOp::Zero (float *fpDest, long lCount)
02048 {
02049 #ifdef DSP_IPP
02050 ippsZero_32f(fpDest, lCount);
02051 #else
02052 long lLoopCntr;
02053
02054 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
02055 {
02056 fpDest[lLoopCntr] = 0.0F;
02057 }
02058 #endif
02059 }
02060
02061
02062 void clDSPOp::Zero (double *dpDest, long lCount)
02063 {
02064 #ifdef DSP_IPP
02065 ippsZero_64f(dpDest, lCount);
02066 #else
02067 long lLoopCntr;
02068
02069 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
02070 {
02071 dpDest[lLoopCntr] = 0.0;
02072 }
02073 #endif
02074 }
02075
02076
02077 void clDSPOp::Zero (stpSCplx spCplxDest, long lCount)
02078 {
02079 #ifdef DSP_IPP
02080 ippsZero_32fc((Ipp32fc *) spCplxDest, lCount);
02081 #else
02082 long lLoopCntr;
02083
02084 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
02085 {
02086 spCplxDest[lLoopCntr].R = 0.0F;
02087 spCplxDest[lLoopCntr].I = 0.0F;
02088 }
02089 #endif
02090 }
02091
02092
02093 void clDSPOp::Zero (stpDCplx spCplxDest, long lCount)
02094 {
02095 #ifdef DSP_IPP
02096 ippsZero_64fc((Ipp64fc *) spCplxDest, lCount);
02097 #else
02098 long lLoopCntr;
02099
02100 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
02101 {
02102 spCplxDest[lLoopCntr].R = 0.0;
02103 spCplxDest[lLoopCntr].I = 0.0;
02104 }
02105 #endif
02106 }
02107
02108
02109 void clDSPOp::Set (float *fpDest, float fSrc, long lCount)
02110 {
02111 #ifdef DSP_IPP
02112 ippsSet_32f(fSrc, fpDest, lCount);
02113 #else
02114 long lLoopCntr;
02115
02116 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
02117 {
02118 fpDest[lLoopCntr] = fSrc;
02119 }
02120 #endif
02121 }
02122
02123
02124 void clDSPOp::Set (double *dpDest, double dSrc, long lCount)
02125 {
02126 #ifdef DSP_IPP
02127 ippsSet_64f(dSrc, dpDest, lCount);
02128 #else
02129 long lLoopCntr;
02130
02131 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
02132 {
02133 dpDest[lLoopCntr] = dSrc;
02134 }
02135 #endif
02136 }
02137
02138
02139 void clDSPOp::Set (stpSCplx spCplxDest, stSCplx sCplxSrc, long lCount)
02140 {
02141 #ifdef DSP_IPP
02142 ippsSet_32fc(*((Ipp32fc *) &sCplxSrc), (Ipp32fc *) spCplxDest, lCount);
02143 #else
02144 long lLoopCntr;
02145
02146 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
02147 {
02148 spCplxDest[lLoopCntr].R = sCplxSrc.R;
02149 spCplxDest[lLoopCntr].I = sCplxSrc.I;
02150 }
02151 #endif
02152 }
02153
02154
02155 void clDSPOp::Set (stpDCplx spCplxDest, stDCplx sCplxSrc, long lCount)
02156 {
02157 #ifdef DSP_IPP
02158 ippsSet_64fc(*((Ipp64fc *) &sCplxSrc), (Ipp64fc *) spCplxDest, lCount);
02159 #else
02160 long lLoopCntr;
02161
02162 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
02163 {
02164 spCplxDest[lLoopCntr].R = sCplxSrc.R;
02165 spCplxDest[lLoopCntr].I = sCplxSrc.I;
02166 }
02167 #endif
02168 }
02169
02170
02171 void clDSPOp::Set (float *fpDest, float fSrc, long lStart, long lCount,
02172 long lLength)
02173 {
02174 #ifdef DSP_IPP
02175 ippsSet_32f(fSrc, &fpDest[lStart],
02176 ((lStart + lCount) > lLength) ? lLength - lStart : lCount);
02177 #else
02178 long lLoopCntr;
02179 long lEnd;
02180
02181 lEnd = ((lStart + lCount) > lLength) ? lLength : (lStart + lCount);
02182 for (lLoopCntr = 0L; lLoopCntr < lEnd; lLoopCntr++)
02183 {
02184 fpDest[lLoopCntr] = fSrc;
02185 }
02186 #endif
02187 }
02188
02189
02190 void clDSPOp::Set (double *dpDest, double dSrc, long lStart, long lCount,
02191 long lLength)
02192 {
02193 #ifdef DSP_IPP
02194 ippsSet_64f(dSrc, &dpDest[lStart],
02195 ((lStart + lCount) > lLength) ? lLength - lStart : lCount);
02196 #else
02197 long lLoopCntr;
02198 long lEnd;
02199
02200 lEnd = ((lStart + lCount) > lLength) ? lLength : (lStart + lCount);
02201 for (lLoopCntr = 0L; lLoopCntr < lEnd; lLoopCntr++)
02202 {
02203 dpDest[lLoopCntr] = dSrc;
02204 }
02205 #endif
02206 }
02207
02208
02209 void clDSPOp::Set (stpSCplx spCplxDest, stSCplx sCplxSrc, long lStart,
02210 long lCount, long lLength)
02211 {
02212 #ifdef DSP_IPP
02213 ippsSet_32fc(*((Ipp32fc *) &sCplxSrc), (Ipp32fc *) spCplxDest,
02214 ((lStart + lCount) > lLength) ? lLength - lStart : lCount);
02215 #else
02216 long lLoopCntr;
02217 long lEnd;
02218
02219 lEnd = ((lStart + lCount) > lLength) ? lLength : (lStart + lCount);
02220 for (lLoopCntr = 0L; lLoopCntr < lEnd; lLoopCntr++)
02221 {
02222 spCplxDest[lLoopCntr].R = sCplxSrc.R;
02223 spCplxDest[lLoopCntr].I = sCplxSrc.I;
02224 }
02225 #endif
02226 }
02227
02228
02229 void clDSPOp::Set (stpDCplx spCplxDest, stDCplx sCplxSrc, long lStart,
02230 long lCount, long lLength)
02231 {
02232 #ifdef DSP_IPP
02233 ippsSet_64fc(*((Ipp64fc *) &sCplxSrc), (Ipp64fc *) spCplxDest,
02234 ((lStart + lCount) > lLength) ? lLength - lStart : lCount);
02235 #else
02236 long lLoopCntr;
02237 long lEnd;
02238
02239 lEnd = ((lStart + lCount) > lLength) ? lLength : (lStart + lCount);
02240 for (lLoopCntr = 0L; lLoopCntr < lEnd; lLoopCntr++)
02241 {
02242 spCplxDest[lLoopCntr].R = sCplxSrc.R;
02243 spCplxDest[lLoopCntr].I = sCplxSrc.I;
02244 }
02245 #endif
02246 }
02247
02248
02249 void clDSPOp::Clip (float *fpVect, float fValue, long lCount)
02250 {
02251 #ifdef DSP_IPP
02252 ippsThreshold_GT_32f_I(fpVect, lCount, fValue);
02253 #else
02254 long lLoopCntr;
02255
02256 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
02257 {
02258 #if (!defined(_ISOC9X_SOURCE) || ((__GNUC__ == 3) && (__GNUC_MINOR__ < 1)))
02259 if (fpVect[lLoopCntr] > fValue)
02260 {
02261 fpVect[lLoopCntr] = fValue;
02262 }
02263 #else
02264 if (isgreater(fpVect[lLoopCntr], fValue))
02265 {
02266 fpVect[lLoopCntr] = fValue;
02267 }
02268 #endif
02269 }
02270 #endif
02271 }
02272
02273
02274 void clDSPOp::Clip (double *dpVect, double dValue, long lCount)
02275 {
02276 #ifdef DSP_IPP
02277 ippsThreshold_GT_64f_I(dpVect, lCount, dValue);
02278 #else
02279 long lLoopCntr;
02280
02281 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
02282 {
02283 #if (!defined(_ISOC9X_SOURCE) || ((__GNUC__ == 3) && (__GNUC_MINOR__ < 1)))
02284 if (dpVect[lLoopCntr] > dValue)
02285 {
02286 dpVect[lLoopCntr] = dValue;
02287 }
02288 #else
02289 if (isgreater(dpVect[lLoopCntr], dValue))
02290 {
02291 dpVect[lLoopCntr] = dValue;
02292 }
02293 #endif
02294 }
02295 #endif
02296 }
02297
02298
02299 void clDSPOp::Clip (float *fpDest, const float *fpSrc, float fValue,
02300 long lCount)
02301 {
02302 #ifdef DSP_IPP
02303 ippsThreshold_GT_32f(fpSrc, fpDest, lCount, fValue);
02304 #else
02305 long lLoopCntr;
02306
02307 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
02308 {
02309 #if (!defined(_ISOC9X_SOURCE) || ((__GNUC__ == 3) && (__GNUC_MINOR__ < 1)))
02310 fpDest[lLoopCntr] = (fpSrc[lLoopCntr] > fValue) ?
02311 fValue : fpSrc[lLoopCntr];
02312 #else
02313 fpDest[lLoopCntr] = (isgreater(fpSrc[lLoopCntr], fValue)) ?
02314 fValue : fpSrc[lLoopCntr];
02315 #endif
02316 }
02317 #endif
02318 }
02319
02320
02321 void clDSPOp::Clip (double *dpDest, const double *dpSrc, double dValue,
02322 long lCount)
02323 {
02324 #ifdef DSP_IPP
02325 ippsThreshold_GT_64f(dpSrc, dpDest, lCount, dValue);
02326 #else
02327 long lLoopCntr;
02328
02329 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
02330 {
02331 #if (!defined(_ISOC9X_SOURCE) || ((__GNUC__ == 3) && (__GNUC_MINOR__ < 1)))
02332 dpDest[lLoopCntr] = (dpSrc[lLoopCntr] > dValue) ?
02333 dValue : dpSrc[lLoopCntr];
02334 #else
02335 dpDest[lLoopCntr] = (isgreater(dpSrc[lLoopCntr], dValue)) ?
02336 dValue : dpSrc[lLoopCntr];
02337 #endif
02338 }
02339 #endif
02340 }
02341
02342
02343 void clDSPOp::Clip (float *fpVect, float fMin, float fMax, long lCount)
02344 {
02345 #ifdef DSP_IPP
02346 ippsThreshold_LT_32f_I(fpVect, lCount, fMin);
02347 ippsThreshold_GT_32f_I(fpVect, lCount, fMax);
02348 #else
02349 long lLoopCntr;
02350
02351 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
02352 {
02353 #if (!defined(_ISOC9X_SOURCE) || ((__GNUC__ == 3) && (__GNUC_MINOR__ < 1)))
02354 if (fpVect[lLoopCntr] < fMin)
02355 {
02356 fpVect[lLoopCntr] = fMin;
02357 }
02358 else if (fpVect[lLoopCntr] > fMax)
02359 {
02360 fpVect[lLoopCntr] = fMax;
02361 }
02362 #else
02363 if (isless(fpVect[lLoopCntr], fMin))
02364 {
02365 fpVect[lLoopCntr] = fMin;
02366 }
02367 else if (isgreater(fpVect[lLoopCntr], fMax))
02368 {
02369 fpVect[lLoopCntr] = fMax;
02370 }
02371 #endif
02372 }
02373 #endif
02374 }
02375
02376
02377 void clDSPOp::Clip (double *dpVect, double dMin, double dMax, long lCount)
02378 {
02379 #ifdef DSP_IPP
02380 ippsThreshold_LT_64f_I(dpVect, lCount, dMin);
02381 ippsThreshold_GT_64f_I(dpVect, lCount, dMax);
02382 #else
02383 long lLoopCntr;
02384
02385 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
02386 {
02387 #if (!defined(_ISOC9X_SOURCE) || ((__GNUC__ == 3) && (__GNUC_MINOR__ < 1)))
02388 if (dpVect[lLoopCntr] < dMin)
02389 {
02390 dpVect[lLoopCntr] = dMin;
02391 }
02392 else if (dpVect[lLoopCntr] > dMax)
02393 {
02394 dpVect[lLoopCntr] = dMax;
02395 }
02396 #else
02397 if (isless(dpVect[lLoopCntr], dMin))
02398 {
02399 dpVect[lLoopCntr] = dMin;
02400 }
02401 else if (isgreater(dpVect[lLoopCntr], dMax))
02402 {
02403 dpVect[lLoopCntr] = dMax;
02404 }
02405 #endif
02406 }
02407 #endif
02408 }
02409
02410
02411 void clDSPOp::Clip (float *fpDest, const float *fpSrc, float fMin,
02412 float fMax, long lCount)
02413 {
02414 #ifdef DSP_IPP
02415 ippsThreshold_LT_32f(fpSrc, fpDest, lCount, fMin);
02416 ippsThreshold_GT_32f_I(fpDest, lCount, fMax);
02417 #else
02418 long lLoopCntr;
02419
02420 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
02421 {
02422 #if (!defined(_ISOC9X_SOURCE) || ((__GNUC__ == 3) && (__GNUC_MINOR__ < 1)))
02423 if (fpSrc[lLoopCntr] < fMin)
02424 {
02425 fpDest[lLoopCntr] = fMin;
02426 }
02427 else if (fpSrc[lLoopCntr] > fMax)
02428 {
02429 fpDest[lLoopCntr] = fMax;
02430 }
02431 else
02432 {
02433 fpDest[lLoopCntr] = fpSrc[lLoopCntr];
02434 }
02435 #else
02436 if (isless(fpSrc[lLoopCntr], fMin))
02437 {
02438 fpDest[lLoopCntr] = fMin;
02439 }
02440 else if (isgreater(fpSrc[lLoopCntr], fMax))
02441 {
02442 fpDest[lLoopCntr] = fMax;
02443 }
02444 else
02445 {
02446 fpDest[lLoopCntr] = fpSrc[lLoopCntr];
02447 }
02448 #endif
02449 }
02450 #endif
02451 }
02452
02453
02454 void clDSPOp::Clip (double *dpDest, const double *dpSrc, double dMin,
02455 double dMax, long lCount)
02456 {
02457 #ifdef DSP_IPP
02458 ippsThreshold_LT_64f(dpSrc, dpDest, lCount, dMin);
02459 ippsThreshold_GT_64f_I(dpDest, lCount, dMin);
02460 #else
02461 long lLoopCntr;
02462
02463 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
02464 {
02465 #if (!defined(_ISOC9X_SOURCE) || ((__GNUC__ == 3) && (__GNUC_MINOR__ < 1)))
02466 if (dpSrc[lLoopCntr] < dMin)
02467 {
02468 dpDest[lLoopCntr] = dMin;
02469 }
02470 else if (dpSrc[lLoopCntr] > dMax)
02471 {
02472 dpDest[lLoopCntr] = dMax;
02473 }
02474 else
02475 {
02476 dpDest[lLoopCntr] = dpSrc[lLoopCntr];
02477 }
02478 #else
02479 if (isless(dpSrc[lLoopCntr], dMin))
02480 {
02481 dpDest[lLoopCntr] = dMin;
02482 }
02483 else if (isgreater(dpSrc[lLoopCntr], dMax))
02484 {
02485 dpDest[lLoopCntr] = dMax;
02486 }
02487 else
02488 {
02489 dpDest[lLoopCntr] = dpSrc[lLoopCntr];
02490 }
02491 #endif
02492 }
02493 #endif
02494 }
02495
02496
02497 void clDSPOp::ClipZero (float *fpVect, long lCount)
02498 {
02499 #ifdef DSP_IPP
02500 ippsThreshold_LT_32f_I(fpVect, lCount, 0.0f);
02501 #else
02502 long lLoopCntr;
02503
02504 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
02505 {
02506 #if (!defined(_ISOC9X_SOURCE) || ((__GNUC__ == 3) && (__GNUC_MINOR__ < 1)))
02507 if (fpVect[lLoopCntr] < 0.0F)
02508 {
02509 fpVect[lLoopCntr] = 0.0F;
02510 }
02511 #else
02512 if (isless(fpVect[lLoopCntr], 0.0F))
02513 {
02514 fpVect[lLoopCntr] = 0.0F;
02515 }
02516 #endif
02517 }
02518 #endif
02519 }
02520
02521
02522 void clDSPOp::ClipZero (double *dpVect, long lCount)
02523 {
02524 #ifdef DSP_IPP
02525 ippsThreshold_LT_64f_I(dpVect, lCount, 0.0);
02526 #else
02527 long lLoopCntr;
02528
02529 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
02530 {
02531 #if (!defined(_ISOC9X_SOURCE) || ((__GNUC__ == 3) && (__GNUC_MINOR__ < 1)))
02532 if (dpVect[lLoopCntr] < 0.0)
02533 {
02534 dpVect[lLoopCntr] = 0.0;
02535 }
02536 #else
02537 if (isless(dpVect[lLoopCntr], 0.0))
02538 {
02539 dpVect[lLoopCntr] = 0.0;
02540 }
02541 #endif
02542 }
02543 #endif
02544 }
02545
02546
02547 void clDSPOp::ClipZero (float *fpDest, const float *fpSrc, long lCount)
02548 {
02549 #ifdef DSP_IPP
02550 ippsThreshold_LT_32f(fpSrc, fpDest, lCount, 0.0f);
02551 #else
02552 long lLoopCntr;
02553
02554 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
02555 {
02556 #if (!defined(_ISOC9X_SOURCE) || ((__GNUC__ == 3) && (__GNUC_MINOR__ < 1)))
02557 fpDest[lLoopCntr] = (fpSrc[lLoopCntr] < 0.0F) ?
02558 0.0F : fpSrc[lLoopCntr];
02559 #else
02560 fpDest[lLoopCntr] = (isless(fpSrc[lLoopCntr], 0.0F)) ?
02561 0.0F : fpSrc[lLoopCntr];
02562 #endif
02563 }
02564 #endif
02565 }
02566
02567
02568 void clDSPOp::ClipZero (double *dpDest, const double *dpSrc, long lCount)
02569 {
02570 #ifdef DSP_IPP
02571 ippsThreshold_LT_64f(dpSrc, dpDest, lCount, 0.0);
02572 #else
02573 long lLoopCntr;
02574
02575 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
02576 {
02577 #if (!defined(_ISOC9X_SOURCE) || ((__GNUC__ == 3) && (__GNUC_MINOR__ < 1)))
02578 dpDest[lLoopCntr] = (dpSrc[lLoopCntr] < 0.0) ?
02579 0.0 : dpSrc[lLoopCntr];
02580 #else
02581 dpDest[lLoopCntr] = (isless(dpSrc[lLoopCntr], 0.0)) ?
02582 0.0 : dpSrc[lLoopCntr];
02583 #endif
02584 }
02585 #endif
02586 }
02587
02588
02589 void clDSPOp::Copy (float *fpDest, const float *fpSrc, long lCount)
02590 {
02591 #ifdef DSP_IPP
02592 ippsMove_32f(fpSrc, fpDest, lCount);
02593 #else
02594 #ifndef USE_MEMMOVE
02595 long lLoopCntr;
02596
02597 #ifdef DSP_X86
02598 if (bHave3DNow)
02599 {
02600 dsp_x86_3dnow_copyf(fpDest, fpSrc, lCount);
02601 }
02602 else
02603 #endif
02604 {
02605 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
02606 {
02607 fpDest[lLoopCntr] = fpSrc[lLoopCntr];
02608 }
02609 }
02610 #else
02611 #ifndef DSP_X86
02612 memmove(fpDest, fpSrc, lCount * sizeof(float));
02613 #else
02614 memmove(fpDest, fpSrc, (lCount << 2));
02615 #endif
02616 #endif
02617 #endif
02618 }
02619
02620
02621 void clDSPOp::Copy (double *dpDest, const double *dpSrc, long lCount)
02622 {
02623 #ifdef DSP_IPP
02624 ippsMove_64f(dpSrc, dpDest, lCount);
02625 #else
02626 #ifndef USE_MEMMOVE
02627 long lLoopCntr;
02628
02629 #ifdef DSP_X86
02630 if (bHave3DNow)
02631 {
02632 dsp_x86_3dnow_copyd(dpDest, dpSrc, lCount);
02633 }
02634 else
02635 #endif
02636 {
02637 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
02638 {
02639 dpDest[lLoopCntr] = dpSrc[lLoopCntr];
02640 }
02641 }
02642 #else
02643 #ifndef DSP_X86
02644 memmove(dpDest, dpSrc, lCount * sizeof(double));
02645 #else
02646 memmove(dpDest, dpSrc, (lCount << 3));
02647 #endif
02648 #endif
02649 #endif
02650 }
02651
02652
02653 void clDSPOp::Copy (stpSCplx spCplxDest, const stpSCplx spCplxSrc, long lCount)
02654 {
02655 #ifdef DSP_IPP
02656 ippsMove_32fc((Ipp32fc *) spCplxSrc, (Ipp32fc *) spCplxDest, lCount);
02657 #else
02658 #ifndef USE_MEMMOVE
02659 long lLoopCntr;
02660
02661 #ifdef DSP_X86
02662 if (bHave3DNow)
02663 {
02664 dsp_x86_3dnow_copyf((float *) spCplxDest,
02665 (const float *) spCplxSrc, (lCount << 1));
02666 }
02667 else
02668 #endif
02669 {
02670 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
02671 {
02672 spCplxDest[lLoopCntr].R = spCplxSrc[lLoopCntr].R;
02673 spCplxDest[lLoopCntr].I = spCplxSrc[lLoopCntr].I;
02674 }
02675 }
02676 #else
02677 memmove(spCplxDest, spCplxSrc, lCount * sizeof(stSCplx));
02678 #endif
02679 #endif
02680 }
02681
02682
02683 void clDSPOp::Copy (stpDCplx spCplxDest, const stpDCplx spCplxSrc, long lCount)
02684 {
02685 #ifdef DSP_IPP
02686 ippsMove_64fc((Ipp64fc *) spCplxSrc, (Ipp64fc *) spCplxDest, lCount);
02687 #else
02688 #ifndef USE_MEMMOVE
02689 long lLoopCntr;
02690
02691 #ifdef DSP_X86
02692 if (bHave3DNow)
02693 {
02694 dsp_x86_3dnow_copyd((double *) spCplxDest,
02695 (const double *) spCplxSrc, (lCount << 1));
02696 }
02697 else
02698 #endif
02699 {
02700 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
02701 {
02702 spCplxDest[lLoopCntr].R = spCplxSrc[lLoopCntr].R;
02703 spCplxDest[lLoopCntr].I = spCplxSrc[lLoopCntr].I;
02704 }
02705 }
02706 #else
02707 memmove(spCplxDest, spCplxSrc, lCount * sizeof(stDCplx));
02708 #endif
02709 #endif
02710 }
02711
02712
02713 void clDSPOp::Copy (float *fpDest1, float *fpDest2, const float *fpSrc,
02714 long lCount)
02715 {
02716 #ifdef DSP_IPP
02717 ippsMove_32f(fpSrc, fpDest1, lCount);
02718 ippsMove_32f(fpSrc, fpDest2, lCount);
02719 #else
02720 long lLoopCntr;
02721
02722 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
02723 {
02724 fpDest1[lLoopCntr] = fpDest2[lLoopCntr] = fpSrc[lLoopCntr];
02725 }
02726 #endif
02727 }
02728
02729
02730 void clDSPOp::Copy (double *dpDest1, double *dpDest2, const double *dpSrc,
02731 long lCount)
02732 {
02733 #ifdef DSP_IPP
02734 ippsMove_64f(dpSrc, dpDest1, lCount);
02735 ippsMove_64f(dpSrc, dpDest2, lCount);
02736 #else
02737 long lLoopCntr;
02738
02739 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
02740 {
02741 dpDest1[lLoopCntr] = dpDest2[lLoopCntr] = dpSrc[lLoopCntr];
02742 }
02743 #endif
02744 }
02745
02746
02747 float clDSPOp::Convolve (const float *fpSrc1, const float *fpSrc2,
02748 long lCount)
02749 {
02750 long lLoopCntr;
02751 long lMax;
02752 float fConv = 0.0F;
02753
02754 lMax = lCount - 1L;
02755 for (lLoopCntr = 0L; lLoopCntr <= lMax; lLoopCntr++)
02756 {
02757 #ifndef _ISOC9X_SOURCE
02758 fConv += fpSrc1[lLoopCntr] * fpSrc2[lMax - lLoopCntr];
02759 #else
02760 fConv = fmaf(fpSrc1[lLoopCntr], fpSrc2[lMax - lLoopCntr], fConv);
02761 #endif
02762 }
02763 return fConv;
02764 }
02765
02766
02767 double clDSPOp::Convolve (const double *dpSrc1, const double *dpSrc2,
02768 long lCount)
02769 {
02770 long lLoopCntr;
02771 long lMax;
02772 double dConv = 0.0;
02773
02774 lMax = lCount - 1L;
02775 for (lLoopCntr = 0L; lLoopCntr <= lMax; lLoopCntr++)
02776 {
02777 #ifndef _ISOC9X_SOURCE
02778 dConv += dpSrc1[lLoopCntr] * dpSrc2[lMax - lLoopCntr];
02779 #else
02780 dConv = fma(dpSrc1[lLoopCntr], dpSrc2[lMax - lLoopCntr], dConv);
02781 #endif
02782 }
02783 return dConv;
02784 }
02785
02786
02787 void clDSPOp::Convolve (float *fpDest, const float *fpSrc1,
02788 const float *fpSrc2, long lCount)
02789 {
02790 long lLoopDest;
02791 long lLoopConv;
02792 long lIdx;
02793 long lMax;
02794 float fConv;
02795
02796 lMax = lCount - 1L;
02797 for (lLoopDest = 0L; lLoopDest < lCount; lLoopDest++)
02798 {
02799 fConv = 0.0F;
02800 for (lLoopConv = 0L; lLoopConv <= lMax; lLoopConv++)
02801 {
02802 lIdx = ((lLoopConv - lLoopDest) < 0L) ?
02803 (lLoopConv - lLoopDest + lMax) : (lLoopConv - lLoopDest);
02804 #ifndef _ISOC9X_SOURCE
02805 fConv += fpSrc1[lMax - lIdx] * fpSrc2[lIdx];
02806 #else
02807 fConv = fmaf(fpSrc1[lMax - lIdx], fpSrc2[lIdx], fConv);
02808 #endif
02809 }
02810 fpDest[lLoopDest] = fConv;
02811 }
02812 }
02813
02814
02815 void clDSPOp::Convolve (double *dpDest, const double *dpSrc1,
02816 const double *dpSrc2, long lCount)
02817 {
02818 long lLoopDest;
02819 long lLoopConv;
02820 long lIdx;
02821 long lMax;
02822 double dConv;
02823
02824 lMax = lCount - 1L;
02825 for (lLoopDest = 0L; lLoopDest < lCount; lLoopDest++)
02826 {
02827 dConv = 0.0;
02828 for (lLoopConv = 0L; lLoopConv <= lMax; lLoopConv++)
02829 {
02830 lIdx = ((lLoopConv - lLoopDest) < 0L) ?
02831 (lLoopConv - lLoopDest + lMax) : (lLoopConv - lLoopDest);
02832 #ifndef _ISOC9X_SOURCE
02833 dConv += dpSrc1[lMax - lIdx] * dpSrc2[lIdx];
02834 #else
02835 dConv = fma(dpSrc1[lMax - lIdx], dpSrc2[lIdx], dConv);
02836 #endif
02837 }
02838 dpDest[lLoopDest] = dConv;
02839 }
02840 }
02841
02842
02843 float clDSPOp::Correlate (const float *fpSrc1, const float *fpSrc2,
02844 long lCount)
02845 {
02846 long lLoopCntr;
02847 float fCorr = 0.0F;
02848
02849 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
02850 {
02851 #ifndef _ISOC9X_SOURCE
02852 fCorr += fpSrc1[lLoopCntr] * fpSrc2[lLoopCntr];
02853 #else
02854 fCorr = fmaf(fpSrc1[lLoopCntr], fpSrc2[lLoopCntr], fCorr);
02855 #endif
02856 }
02857 fCorr /= (float) lCount;
02858 return fCorr;
02859 }
02860
02861
02862 double clDSPOp::Correlate (const double *dpSrc1, const double *dpSrc2,
02863 long lCount)
02864 {
02865 long lLoopCntr;
02866 double dCorr = 0.0;
02867
02868 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
02869 {
02870 #ifndef _ISOC9X_SOURCE
02871 dCorr += dpSrc1[lLoopCntr] * dpSrc2[lLoopCntr];
02872 #else
02873 dCorr = fma(dpSrc1[lLoopCntr], dpSrc2[lLoopCntr], dCorr);
02874 #endif
02875 }
02876 dCorr /= (double) lCount;
02877 return dCorr;
02878 }
02879
02880
02881 void clDSPOp::Correlate (float *fpDest, const float *fpSrc1,
02882 const float *fpSrc2, long lCount)
02883 {
02884 long lLoopDest;
02885 long lLoopCorr;
02886 long lMax;
02887 long lIdx;
02888 float fCorr;
02889
02890 lMax = lCount - 1L;
02891 for (lLoopDest = 0L; lLoopDest <= lMax; lLoopDest++)
02892 {
02893 fCorr = 0.0F;
02894 for (lLoopCorr = 0L; lLoopCorr <= lMax; lLoopCorr++)
02895 {
02896 lIdx = ((lLoopCorr + lLoopDest) > lMax) ?
02897 (lLoopCorr + lLoopDest - lMax) : (lLoopCorr + lLoopDest);
02898 #ifndef _ISOC9X_SOURCE
02899 fCorr += fpSrc1[lLoopCorr] * fpSrc2[lIdx];
02900 #else
02901 fCorr = fmaf(fpSrc1[lLoopCorr], fpSrc2[lIdx], fCorr);
02902 #endif
02903 }
02904 fpDest[lLoopDest] = fCorr / (float) lCount;
02905 }
02906 }
02907
02908
02909 void clDSPOp::Correlate (double *dpDest, const double *dpSrc1,
02910 const double *dpSrc2, long lCount)
02911 {
02912 long lLoopDest;
02913 long lLoopCorr;
02914 long lMax;
02915 long lIdx;
02916 double dCorr;
02917
02918 lMax = lCount - 1L;
02919 for (lLoopDest = 0L; lLoopDest <= lMax; lLoopDest++)
02920 {
02921 dCorr = 0.0;
02922 for (lLoopCorr = 0L; lLoopCorr <= lMax; lLoopCorr++)
02923 {
02924 lIdx = ((lLoopCorr + lLoopDest) > lMax) ?
02925 (lLoopCorr + lLoopDest - lMax) : (lLoopCorr + lLoopDest);
02926 #ifndef _ISOC9X_SOURCE
02927 dCorr += dpSrc1[lLoopCorr] * dpSrc2[lIdx];
02928 #else
02929 dCorr = fma(dpSrc1[lLoopCorr], dpSrc2[lIdx], dCorr);
02930 #endif
02931 }
02932 dpDest[lLoopDest] = dCorr / (double) lCount;
02933 }
02934 }
02935
02936
02937 float clDSPOp::AutoCorrelate (const float *fpSrc, long lCount)
02938 {
02939 long lLoopCntr;
02940 float fAutoCorr = 0.0F;
02941
02942 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
02943 {
02944 #ifndef _ISOC9X_SOURCE
02945 fAutoCorr += fpSrc[lLoopCntr] * fpSrc[lLoopCntr];
02946 #else
02947 fAutoCorr = fmaf(fpSrc[lLoopCntr], fpSrc[lLoopCntr], fAutoCorr);
02948 #endif
02949 }
02950 fAutoCorr /= (float) lCount;
02951 return fAutoCorr;
02952 }
02953
02954
02955 double clDSPOp::AutoCorrelate (const double *dpSrc, long lCount)
02956 {
02957 long lLoopCntr;
02958 double dAutoCorr = 0.0;
02959
02960 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
02961 {
02962 #ifndef _ISOC9X_SOURCE
02963 dAutoCorr += dpSrc[lLoopCntr] * dpSrc[lLoopCntr];
02964 #else
02965 dAutoCorr = fma(dpSrc[lLoopCntr], dpSrc[lLoopCntr], dAutoCorr);
02966 #endif
02967 }
02968 dAutoCorr /= (double) lCount;
02969 return dAutoCorr;
02970 }
02971
02972
02973 void clDSPOp::AutoCorrelate (float *fpDest, const float *fpSrc, long lCount)
02974 {
02975 long lLoopDest;
02976 long lLoopCorr;
02977 long lMax;
02978 long lIdx;
02979 float fAutoCorr;
02980
02981 lMax = lCount - 1L;
02982 for (lLoopDest = 0L; lLoopDest <= lMax; lLoopDest++)
02983 {
02984 fAutoCorr = 0.0F;
02985 for (lLoopCorr = 0L; lLoopCorr <= lMax; lLoopCorr++)
02986 {
02987 lIdx = ((lLoopCorr + lLoopDest) > lMax) ?
02988 (lLoopCorr + lLoopDest - lCount) : (lLoopCorr + lLoopDest);
02989 #ifndef _ISOC9X_SOURCE
02990 fAutoCorr += fpSrc[lLoopCorr] * fpSrc[lIdx];
02991 #else
02992 fAutoCorr = fmaf(fpSrc[lLoopCorr], fpSrc[lIdx], fAutoCorr);
02993 #endif
02994 }
02995 fpDest[lLoopDest] = fAutoCorr / (float) lCount;
02996 }
02997 }
02998
02999
03000 void clDSPOp::AutoCorrelate (double *dpDest, const double *dpSrc, long lCount)
03001 {
03002 long lLoopDest;
03003 long lLoopCorr;
03004 long lMax;
03005 long lIdx;
03006 double dAutoCorr;
03007
03008 lMax = lCount - 1L;
03009 for (lLoopDest = 0L; lLoopDest <= lMax; lLoopDest++)
03010 {
03011 dAutoCorr = 0.0;
03012 for (lLoopCorr = 0L; lLoopCorr <= lMax; lLoopCorr++)
03013 {
03014 lIdx = ((lLoopCorr + lLoopDest) > lMax) ?
03015 (lLoopCorr + lLoopDest - lCount) : (lLoopCorr + lLoopDest);
03016 #ifndef _ISOC9X_SOURCE
03017 dAutoCorr += dpSrc[lLoopCorr] * dpSrc[lIdx];
03018 #else
03019 dAutoCorr = fma(dpSrc[lLoopCorr], dpSrc[lIdx], dAutoCorr);
03020 #endif
03021 }
03022 dpDest[lLoopDest] = dAutoCorr / (double) lCount;
03023 }
03024 }
03025
03026
03027 float clDSPOp::DotProduct (const float *fpSrc1, const float *fpSrc2,
03028 long lCount)
03029 {
03030 #ifdef DSP_IPP
03031 float fDotProd;
03032
03033 ippsDotProd_32f(fpSrc1, fpSrc2, lCount, &fDotProd);
03034 #else
03035 long lLoopCntr;
03036 float fDotProd = 0.0F;
03037
03038 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
03039 {
03040 #ifndef _ISOC9X_SOURCE
03041 fDotProd += fpSrc1[lLoopCntr] * fpSrc2[lLoopCntr];
03042 #else
03043 fDotProd = fmaf(fpSrc1[lLoopCntr], fpSrc2[lLoopCntr], fDotProd);
03044 #endif
03045 }
03046 #endif
03047 return fDotProd;
03048 }
03049
03050
03051 double clDSPOp::DotProduct (const double *dpSrc1, const double *dpSrc2,
03052 long lCount)
03053 {
03054 #ifdef DSP_IPP
03055 double dDotProd;
03056
03057 ippsDotProd_64f(dpSrc1, dpSrc2, lCount, &dDotProd);
03058 #else
03059 long lLoopCntr;
03060 double dDotProd = 0.0;
03061
03062 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
03063 {
03064 #ifndef _ISOC9X_SOURCE
03065 dDotProd += dpSrc1[lLoopCntr] * dpSrc2[lLoopCntr];
03066 #else
03067 dDotProd = fma(dpSrc1[lLoopCntr], dpSrc2[lLoopCntr], dDotProd);
03068 #endif
03069 }
03070 #endif
03071 return dDotProd;
03072 }
03073
03074
03075 void clDSPOp::MinMax (float *fpMin, float *fpMax, const float *fpSrc,
03076 long lCount)
03077 {
03078 #ifdef DSP_IPP
03079 ippsMin_32f(fpSrc, lCount, fpMin);
03080 ippsMax_32f(fpSrc, lCount, fpMax);
03081 #else
03082 long lLoopCntr;
03083 float fTempVal;
03084 float fTempMin = FLT_MAX;
03085 float fTempMax = -FLT_MAX;
03086
03087 #ifdef DSP_X86
03088 if (bHave3DNow)
03089 {
03090 dsp_x86_3dnow_minmaxf(fpMin, fpMax, fpSrc, lCount);
03091 }
03092 else
03093 #endif
03094 {
03095 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
03096 {
03097 fTempVal = fpSrc[lLoopCntr];
03098 #ifndef _ISOC9X_SOURCE
03099 if (fTempVal < fTempMin)
03100 {
03101 fTempMin = fTempVal;
03102 }
03103 if (fTempVal > fTempMax)
03104 {
03105 fTempMax = fTempVal;
03106 }
03107 #else
03108 fTempMin = fminf(fTempVal, fTempMin);
03109 fTempMax = fmaxf(fTempVal, fTempMax);
03110 #endif
03111 }
03112 *fpMin = fTempMin;
03113 *fpMax = fTempMax;
03114 }
03115 #endif
03116 }
03117
03118
03119 void clDSPOp::MinMax (double *dpMin, double *dpMax, const double *dpSrc,
03120 long lCount)
03121 {
03122 #ifdef DSP_IPP
03123 ippsMin_64f(dpSrc, lCount, dpMin);
03124 ippsMax_64f(dpSrc, lCount, dpMax);
03125 #else
03126 long lLoopCntr;
03127 double dTempVal;
03128 double dTempMin = DBL_MAX;
03129 double dTempMax = -DBL_MAX;
03130
03131 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
03132 {
03133 dTempVal = dpSrc[lLoopCntr];
03134 #ifndef _ISOC9X_SOURCE
03135 if (dTempVal < dTempMin)
03136 {
03137 dTempMin = dTempVal;
03138 }
03139 if (dTempVal > dTempMax)
03140 {
03141 dTempMax = dTempVal;
03142 }
03143 #else
03144 dTempMin = fmin(dTempVal, dTempMin);
03145 dTempMax = fmax(dTempVal, dTempMax);
03146 #endif
03147 }
03148 *dpMin = dTempMin;
03149 *dpMax = dTempMax;
03150 #endif
03151 }
03152
03153
03154 float clDSPOp::Mean (const float *fpSrc, long lCount)
03155 {
03156 #ifdef DSP_IPP
03157 float fMean;
03158
03159 ippsMean_32f(fpSrc, lCount, &fMean, ippAlgHintFast);
03160 #else
03161 long lLoopCntr;
03162 float fMean = 0.0F;
03163
03164 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
03165 {
03166 fMean += fpSrc[lLoopCntr];
03167 }
03168 fMean /= (float) lCount;
03169 #endif
03170 return fMean;
03171 }
03172
03173
03174 double clDSPOp::Mean (const double *dpSrc, long lCount)
03175 {
03176 #ifdef DSP_IPP
03177 double dMean;
03178
03179 ippsMean_64f(dpSrc, lCount, &dMean);
03180 #else
03181 long lLoopCntr;
03182 double dMean = 0.0;
03183
03184 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
03185 {
03186 dMean += dpSrc[lLoopCntr];
03187 }
03188 dMean /= (double) lCount;
03189 #endif
03190 return dMean;
03191 }
03192
03193
03194 float clDSPOp::Median (const float *fpSrc, long lCount)
03195 {
03196 long lMax;
03197 float fMedian = 0.0F;
03198 float *fpTemp;
03199 clDSPAlloc Temp(lCount * sizeof(float));
03200
03201 fpTemp = Temp;
03202 lMax = lCount - 1L;
03203 if (fpTemp != NULL)
03204 {
03205 #ifdef DSP_IPP
03206 ippsCopy_32f(fpSrc, fpTemp, lCount);
03207 ippsSortAscend_32f_I(fpTemp, lCount);
03208 #else
03209 Copy(fpTemp, fpSrc, lCount);
03210 Sort(fpTemp, lCount);
03211 #endif
03212 fMedian = ((lCount % 2L) != 0L) ?
03213 fpTemp[lMax / 2L] :
03214 (0.5F * (fpTemp[lCount / 2L - 1L] + fpTemp[lCount / 2L]));
03215 }
03216 return fMedian;
03217 }
03218
03219
03220 double clDSPOp::Median (const double *dpSrc, long lCount)
03221 {
03222 long lMax;
03223 double dMedian = 0.0;
03224 double *dpTemp;
03225 clDSPAlloc Temp(lCount * sizeof(double));
03226
03227 dpTemp = Temp;
03228 lMax = lCount - 1L;
03229 if (dpTemp != NULL)
03230 {
03231 #ifdef DSP_IPP
03232 ippsCopy_64f(dpSrc, dpTemp, lCount);
03233 ippsSortAscend_64f_I(dpTemp, lCount);
03234 #else
03235 Copy(dpTemp, dpSrc, lCount);
03236 Sort(dpTemp, lCount);
03237 #endif
03238 dMedian = ((lCount % 2L) != 0L) ?
03239 dpTemp[lMax / 2L] :
03240 (0.5 * (dpTemp[lCount / 2L - 1L] + dpTemp[lCount / 2L]));
03241 }
03242 return dMedian;
03243 }
03244
03245
03246 void clDSPOp::Negate (float *fpVect, long lCount)
03247 {
03248 long lLoopCntr;
03249
03250 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
03251 {
03252 fpVect[lLoopCntr] = -(fpVect[lLoopCntr]);
03253 }
03254 }
03255
03256
03257 void clDSPOp::Negate (double *dpVect, long lCount)
03258 {
03259 long lLoopCntr;
03260
03261 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
03262 {
03263 dpVect[lLoopCntr] = -(dpVect[lLoopCntr]);
03264 }
03265 }
03266
03267
03268 void clDSPOp::Negate (float *fpDest, const float *fpSrc, long lCount)
03269 {
03270 long lLoopCntr;
03271
03272 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
03273 {
03274 fpDest[lLoopCntr] = -(fpSrc[lLoopCntr]);
03275 }
03276 }
03277
03278
03279 void clDSPOp::Negate (double *dpDest, const double *dpSrc, long lCount)
03280 {
03281 long lLoopCntr;
03282
03283 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
03284 {
03285 dpDest[lLoopCntr] = -(dpSrc[lLoopCntr]);
03286 }
03287 }
03288
03289
03290 void clDSPOp::Normalize (float *fpVect, long lCount)
03291 {
03292 long lLoopCntr;
03293 float fMean;
03294 float fStdDev;
03295
03296 StdDev(&fStdDev, &fMean, fpVect, lCount);
03297 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
03298 {
03299 fpVect[lLoopCntr] = (fpVect[lLoopCntr] - fMean) / fStdDev;
03300 }
03301 }
03302
03303
03304 void clDSPOp::Normalize (double *dpVect, long lCount)
03305 {
03306 long lLoopCntr;
03307 double dMean;
03308 double dStdDev;
03309
03310 StdDev(&dStdDev, &dMean, dpVect, lCount);
03311 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
03312 {
03313 dpVect[lLoopCntr] = (dpVect[lLoopCntr] - dMean) / dStdDev;
03314 }
03315 }
03316
03317
03318 void clDSPOp::Normalize (float *fpDest, const float *fpSrc, long lCount)
03319 {
03320 long lLoopCntr;
03321 float fMean;
03322 float fStdDev;
03323
03324 StdDev(&fStdDev, &fMean, fpSrc, lCount);
03325 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
03326 {
03327 fpDest[lLoopCntr] = (fpSrc[lLoopCntr] - fMean) / fStdDev;
03328 }
03329 }
03330
03331
03332 void clDSPOp::Normalize (double *dpDest, const double *dpSrc, long lCount)
03333 {
03334 long lLoopCntr;
03335 double dMean;
03336 double dStdDev;
03337
03338 StdDev(&dStdDev, &dMean, dpSrc, lCount);
03339 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
03340 {
03341 dpDest[lLoopCntr] = (dpSrc[lLoopCntr] - dMean) / dStdDev;
03342 }
03343 }
03344
03345
03346 float clDSPOp::Product (const float *fpSrc, long lCount)
03347 {
03348 long lLoopCntr;
03349 float fProd = 1.0F;
03350
03351 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
03352 {
03353 fProd *= fpSrc[lLoopCntr];
03354 }
03355 return fProd;
03356 }
03357
03358
03359 double clDSPOp::Product (const double *dpSrc, long lCount)
03360 {
03361 long lLoopCntr;
03362 double dProd = 1.0;
03363
03364 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
03365 {
03366 dProd *= dpSrc[lLoopCntr];
03367 }
03368 return dProd;
03369 }
03370
03371
03372 void clDSPOp::Reverse (float *fpVect, long lCount)
03373 {
03374 #ifdef DSP_IPP
03375 ippsFlip_32f_I(fpVect, lCount);
03376 #else
03377 long lFwdIdx;
03378 long lRevIdx;
03379 long lMax;
03380 float fTemp1;
03381 float fTemp2;
03382
03383 lMax = (lCount >> 1);
03384 lFwdIdx = 0;
03385 lRevIdx = lCount;
03386 while (lFwdIdx < lMax)
03387 {
03388 lRevIdx--;
03389 fTemp1 = fpVect[lFwdIdx];
03390 fTemp2 = fpVect[lRevIdx];
03391 fpVect[lFwdIdx] = fTemp2;
03392 fpVect[lRevIdx] = fTemp1;
03393 lFwdIdx++;
03394 }
03395 #endif
03396 }
03397
03398
03399 void clDSPOp::Reverse (double *dpVect, long lCount)
03400 {
03401 #ifdef DSP_IPP
03402 ippsFlip_64f_I(dpVect, lCount);
03403 #else
03404 long lFwdIdx;
03405 long lRevIdx;
03406 long lMax;
03407 double dTemp1;
03408 double dTemp2;
03409
03410 lMax = (lCount >> 1);
03411 lFwdIdx = 0;
03412 lRevIdx = lCount;
03413 while (lFwdIdx < lMax)
03414 {
03415 lRevIdx--;
03416 dTemp1 = dpVect[lFwdIdx];
03417 dTemp2 = dpVect[lRevIdx];
03418 dpVect[lFwdIdx] = dTemp2;
03419 dpVect[lRevIdx] = dTemp1;
03420 lFwdIdx++;
03421 }
03422 #endif
03423 }
03424
03425
03426 void clDSPOp::Reverse (stpSCplx spVect, long lCount)
03427 {
03428 #ifdef DSP_IPP
03429 Ipp32fc *spTemp;
03430
03431 spTemp = ippsMalloc_32fc(lCount);
03432 ippsConjFlip_32fc((Ipp32fc *) spVect, spTemp, lCount);
03433 ippsCopy_32fc(spTemp, (Ipp32fc *) spVect, lCount);
03434 ippsFree(spTemp);
03435 #else
03436 long lFwdIdx;
03437 long lRevIdx;
03438 long lMax;
03439 stSCplx sTemp1;
03440 stSCplx sTemp2;
03441
03442 lMax = (lCount >> 1);
03443 lFwdIdx = 0;
03444 lRevIdx = lCount;
03445 while (lFwdIdx < lMax)
03446 {
03447 lRevIdx--;
03448 sTemp1.R = spVect[lFwdIdx].R;
03449 sTemp1.I = spVect[lFwdIdx].I;
03450 sTemp2.R = spVect[lRevIdx].R;
03451 sTemp2.I = spVect[lRevIdx].I;
03452 CplxConj(&sTemp1);
03453 CplxConj(&sTemp2);
03454 spVect[lFwdIdx].R = sTemp2.R;
03455 spVect[lFwdIdx].I = sTemp2.I;
03456 spVect[lRevIdx].R = sTemp1.R;
03457 spVect[lRevIdx].I = sTemp1.I;
03458 lFwdIdx++;
03459 }
03460 #endif
03461 }
03462
03463
03464 void clDSPOp::Reverse (stpDCplx spVect, long lCount)
03465 {
03466 #ifdef DSP_IPP
03467 Ipp64fc *spTemp;
03468
03469 spTemp = ippsMalloc_64fc(lCount);
03470 ippsConjFlip_64fc((Ipp64fc *) spVect, spTemp, lCount);
03471 ippsCopy_64fc(spTemp, (Ipp64fc *) spVect, lCount);
03472 ippsFree(spTemp);
03473 #else
03474 long lFwdIdx;
03475 long lRevIdx;
03476 long lMax;
03477 stDCplx sTemp1;
03478 stDCplx sTemp2;
03479
03480 lMax = (lCount >> 1);
03481 lFwdIdx = 0;
03482 lRevIdx = lCount;
03483 while (lFwdIdx < lMax)
03484 {
03485 lRevIdx--;
03486 sTemp1.R = spVect[lFwdIdx].R;
03487 sTemp1.I = spVect[lFwdIdx].I;
03488 sTemp2.R = spVect[lRevIdx].R;
03489 sTemp2.I = spVect[lRevIdx].I;
03490 CplxConj(&sTemp1);
03491 CplxConj(&sTemp2);
03492 spVect[lFwdIdx].R = sTemp2.R;
03493 spVect[lFwdIdx].I = sTemp2.I;
03494 spVect[lRevIdx].R = sTemp1.R;
03495 spVect[lRevIdx].I = sTemp1.I;
03496 lFwdIdx++;
03497 }
03498 #endif
03499 }
03500
03501
03502 void clDSPOp::Reverse (float *fpDest, const float *fpSrc, long lCount)
03503 {
03504 #ifdef DSP_IPP
03505 ippsFlip_32f(fpSrc, fpDest, lCount);
03506 #else
03507 long lLoopCntr;
03508 long lMax;
03509
03510 lMax = lCount - 1L;
03511 for (lLoopCntr = 0L; lLoopCntr <= lMax; lLoopCntr++)
03512 {
03513 fpDest[lLoopCntr] = fpSrc[lMax - lLoopCntr];
03514 }
03515 #endif
03516 }
03517
03518
03519 void clDSPOp::Reverse (double *dpDest, const double *dpSrc, long lCount)
03520 {
03521 #ifdef DSP_IPP
03522 ippsFlip_64f(dpSrc, dpDest, lCount);
03523 #else
03524 long lLoopCntr;
03525 long lMax;
03526
03527 lMax = lCount - 1L;
03528 for (lLoopCntr = 0L; lLoopCntr <= lMax; lLoopCntr++)
03529 {
03530 dpDest[lLoopCntr] = dpSrc[lMax - lLoopCntr];
03531 }
03532 #endif
03533 }
03534
03535
03536 void clDSPOp::Reverse (stpSCplx spDest, const stpSCplx spSrc, long lCount)
03537 {
03538 #ifdef DSP_IPP
03539 ippsConjFlip_32fc((Ipp32fc *) spSrc, (Ipp32fc *) spDest, lCount);
03540 #else
03541 long lLoopCntr;
03542 long lMax;
03543
03544 lMax = lCount - 1L;
03545 for (lLoopCntr = 0L; lLoopCntr <= lMax; lLoopCntr++)
03546 {
03547 CplxConj(&spDest[lLoopCntr], &spSrc[lMax - lLoopCntr]);
03548 }
03549 #endif
03550 }
03551
03552
03553 void clDSPOp::Reverse (stpDCplx spDest, const stpDCplx spSrc, long lCount)
03554 {
03555 #ifdef DSP_IPP
03556 ippsConjFlip_64fc((Ipp64fc *) spSrc, (Ipp64fc *) spDest, lCount);
03557 #else
03558 long lLoopCntr;
03559 long lMax;
03560
03561 lMax = lCount - 1L;
03562 for (lLoopCntr = 0L; lLoopCntr <= lMax; lLoopCntr++)
03563 {
03564 CplxConj(&spDest[lLoopCntr], &spSrc[lMax - lLoopCntr]);
03565 }
03566 #endif
03567 }
03568
03569
03570 void clDSPOp::Scale (float *fpVect, long lCount)
03571 {
03572 #ifdef DSP_IPP
03573 float fMin;
03574 float fMax;
03575
03576 ippsMin_32f(fpVect, lCount, &fMin);
03577 ippsMax_32f(fpVect, lCount, &fMax);
03578 ippsNormalize_32f(fpVect, fpVect, lCount, fMin, (fMax - fMin) * 0.5F);
03579 ippsAddC_32f_I(-1.0F, fpVect, lCount);
03580 #else
03581 long lLoopCntr;
03582 float fMin;
03583 float fMax;
03584 float fScale;
03585 float fOffset;
03586
03587 MinMax(&fMin, &fMax, fpVect, lCount);
03588 fScale = 2.0F / (fMax - fMin);
03589 fOffset = 1.0F - fMax * fScale;
03590 #ifdef DSP_X86
03591 if (bHave3DNow)
03592 {
03593 dsp_x86_3dnow_maf(fpVect, fScale, fOffset, lCount);
03594 }
03595 else
03596 #endif
03597 {
03598 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
03599 {
03600 #ifndef _ISOC9X_SOURCE
03601 fpVect[lLoopCntr] = fpVect[lLoopCntr] * fScale + fOffset;
03602 #else
03603 fpVect[lLoopCntr] =
03604 fmaf(fpVect[lLoopCntr], fScale, fOffset);
03605 #endif
03606 }
03607 }
03608 #endif
03609 }
03610
03611
03612 void clDSPOp::Scale (double *dpVect, long lCount)
03613 {
03614 #ifdef DSP_IPP
03615 double dMin;
03616 double dMax;
03617
03618 ippsMin_64f(dpVect, lCount, &dMin);
03619 ippsMax_64f(dpVect, lCount, &dMax);
03620 ippsNormalize_64f(dpVect, dpVect, lCount, dMin, (dMax - dMin) * 0.5);
03621 ippsAddC_64f_I(-1.0, dpVect, lCount);
03622 #else
03623 long lLoopCntr;
03624 double dMin;
03625 double dMax;
03626 double dScale;
03627 double dOffset;
03628
03629 MinMax(&dMin, &dMax, dpVect, lCount);
03630 dScale = 2.0 / (dMax - dMin);
03631 dOffset = 1.0 - dMax * dScale;
03632 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
03633 {
03634 #ifndef _ISOC9X_SOURCE
03635 dpVect[lLoopCntr] = dpVect[lLoopCntr] * dScale + dOffset;
03636 #else
03637 dpVect[lLoopCntr] =
03638 fma(dpVect[lLoopCntr], dScale, dOffset);
03639 #endif
03640 }
03641 #endif
03642 }
03643
03644
03645 void clDSPOp::Scale (float *fpDest, const float *fpSrc, long lCount)
03646 {
03647 #ifdef DSP_IPP
03648 float fMin;
03649 float fMax;
03650
03651 ippsMin_32f(fpSrc, lCount, &fMin);
03652 ippsMax_32f(fpSrc, lCount, &fMax);
03653 ippsNormalize_32f(fpSrc, fpDest, lCount, fMin, (fMax - fMin) * 0.5F);
03654 ippsAddC_32f_I(1.0F, fpDest, lCount);
03655 #else
03656 long lLoopCntr;
03657 float fMin;
03658 float fMax;
03659 float fScale;
03660 float fOffset;
03661
03662 MinMax(&fMin, &fMax, fpSrc, lCount);
03663 fScale = 2.0F / (fMax - fMin);
03664 fOffset = 1.0F - fMax * fScale;
03665 #ifdef DSP_X86
03666 if (bHave3DNow)
03667 {
03668 dsp_x86_3dnow_ma2f(fpDest, fpSrc, fScale, fOffset, lCount);
03669 }
03670 else
03671 #endif
03672 {
03673 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
03674 {
03675 #ifndef _ISOC9X_SOURCE
03676 fpDest[lLoopCntr] = fpSrc[lLoopCntr] * fScale + fOffset;
03677 #else
03678 fpDest[lLoopCntr] =
03679 fmaf(fpSrc[lLoopCntr], fScale, fOffset);
03680 #endif
03681 }
03682 }
03683 #endif
03684 }
03685
03686
03687 void clDSPOp::Scale (double *dpDest, const double *dpSrc, long lCount)
03688 {
03689 #ifdef DSP_IPP
03690 double dMin;
03691 double dMax;
03692
03693 ippsMin_64f(dpSrc, lCount, &dMin);
03694 ippsMax_64f(dpSrc, lCount, &dMax);
03695 ippsNormalize_64f(dpSrc, dpDest, lCount, dMin, (dMax - dMin) * 0.5);
03696 ippsAddC_64f_I(-1.0, dpDest, lCount);
03697 #else
03698 long lLoopCntr;
03699 double dMin;
03700 double dMax;
03701 double dScale;
03702 double dOffset;
03703
03704 MinMax(&dMin, &dMax, dpSrc, lCount);
03705 dScale = 2.0 / (dMax - dMin);
03706 dOffset = 1.0 - dMax * dScale;
03707 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
03708 {
03709 #ifndef _ISOC9X_SOURCE
03710 dpDest[lLoopCntr] = dpSrc[lLoopCntr] * dScale + dOffset;
03711 #else
03712 dpDest[lLoopCntr] =
03713 fma(dpSrc[lLoopCntr], dScale, dOffset);
03714 #endif
03715 }
03716 #endif
03717 }
03718
03719
03720 void clDSPOp::Scale01 (float *fpVect, long lCount)
03721 {
03722 #ifdef DSP_IPP
03723 float fMin;
03724 float fMax;
03725
03726 ippsMin_32f(fpVect, lCount, &fMin);
03727 ippsMax_32f(fpVect, lCount, &fMax);
03728 ippsNormalize_32f(fpVect, fpVect, lCount, fMin, fMax - fMin);
03729 #else
03730 long lLoopCntr;
03731 float fMin;
03732 float fMax;
03733 float fScale;
03734 float fOffset;
03735
03736 MinMax(&fMin, &fMax, fpVect, lCount);
03737 fScale = 1.0F / (fMax - fMin);
03738 fOffset = -fMin * fScale;
03739 #ifdef DSP_X86
03740 if (bHave3DNow)
03741 {
03742 dsp_x86_3dnow_maf(fpVect, fScale, fOffset, lCount);
03743 }
03744 else
03745 #endif
03746 {
03747 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
03748 {
03749 #ifndef _ISOC9X_SOURCE
03750 fpVect[lLoopCntr] = fpVect[lLoopCntr] * fScale + fOffset;
03751 #else
03752 fpVect[lLoopCntr] = fmaf(fpVect[lLoopCntr], fScale, fOffset);
03753 #endif
03754 }
03755 }
03756 #endif
03757 }
03758
03759
03760 void clDSPOp::Scale01 (double *dpVect, long lCount)
03761 {
03762 #ifdef DSP_IPP
03763 double dMin;
03764 double dMax;
03765
03766 ippsMin_64f(dpVect, lCount, &dMin);
03767 ippsMax_64f(dpVect, lCount, &dMax);
03768 ippsNormalize_64f(dpVect, dpVect, lCount, dMin, dMax - dMin);
03769 #else
03770 long lLoopCntr;
03771 double dMin;
03772 double dMax;
03773 double dScale;
03774 double dOffset;
03775
03776 MinMax(&dMin, &dMax, dpVect, lCount);
03777 dScale = 1.0 / (dMax - dMin);
03778 dOffset = -dMin * dScale;
03779 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
03780 {
03781 #ifndef _ISOC9X_SOURCE
03782 dpVect[lLoopCntr] = dpVect[lLoopCntr] * dScale + dOffset;
03783 #else
03784 dpVect[lLoopCntr] = fma(dpVect[lLoopCntr], dScale, dOffset);
03785 #endif
03786 }
03787 #endif
03788 }
03789
03790
03791 void clDSPOp::Scale01 (float *fpDest, const float *fpSrc, long lCount)
03792 {
03793 #ifdef DSP_IPP
03794 float fMin;
03795 float fMax;
03796
03797 ippsMin_32f(fpSrc, lCount, &fMin);
03798 ippsMax_32f(fpSrc, lCount, &fMax);
03799 ippsNormalize_32f(fpSrc, fpDest, lCount, fMin, fMax - fMin);
03800 #else
03801 long lLoopCntr;
03802 float fMin;
03803 float fMax;
03804 float fScale;
03805 float fOffset;
03806
03807 MinMax(&fMin, &fMax, fpSrc, lCount);
03808 fScale = 1.0F / (fMax - fMin);
03809 fOffset = -fMin * fScale;
03810 #ifdef DSP_X86
03811 if (bHave3DNow)
03812 {
03813 dsp_x86_3dnow_ma2f(fpDest, fpSrc, fScale, fOffset, lCount);
03814 }
03815 else
03816 #endif
03817 {
03818 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
03819 {
03820 #ifndef _ISOC9X_SOURCE
03821 fpDest[lLoopCntr] = fpSrc[lLoopCntr] * fScale + fOffset;
03822 #else
03823 fpDest[lLoopCntr] = fmaf(fpSrc[lLoopCntr], fScale, fOffset);
03824 #endif
03825 }
03826 }
03827 #endif
03828 }
03829
03830
03831 void clDSPOp::Scale01 (double *dpDest, const double *dpSrc, long lCount)
03832 {
03833 #ifdef DSP_IPP
03834 double dMin;
03835 double dMax;
03836
03837 ippsMin_64f(dpSrc, lCount, &dMin);
03838 ippsMax_64f(dpSrc, lCount, &dMax);
03839 ippsNormalize_64f(dpSrc, dpDest, lCount, dMin, dMax - dMin);
03840 #else
03841 long lLoopCntr;
03842 double dMin;
03843 double dMax;
03844 double dScale;
03845 double dOffset;
03846
03847 MinMax(&dMin, &dMax, dpSrc, lCount);
03848 dScale = 1.0 / (dMax - dMin);
03849 dOffset = -dMin * dScale;
03850 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
03851 {
03852 #ifndef _ISOC9X_SOURCE
03853 dpDest[lLoopCntr] = dpSrc[lLoopCntr] * dScale + dOffset;
03854 #else
03855 dpDest[lLoopCntr] = fma(dpSrc[lLoopCntr], dScale, dOffset);
03856 #endif
03857 }
03858 #endif
03859 }
03860
03861
03862 void clDSPOp::Sort (float *fpVect, long lCount)
03863 {
03864 #ifdef DSP_IPP
03865 ippsSortAscend_32f_I(fpVect, lCount);
03866 #else
03867 qsort(fpVect, (size_t) lCount, sizeof(float), FloatCompare);
03868 #endif
03869 }
03870
03871
03872 void clDSPOp::Sort (double *dpVect, long lCount)
03873 {
03874 #ifdef DSP_IPP
03875 ippsSortAscend_64f_I(dpVect, lCount);
03876 #else
03877 qsort(dpVect, (size_t) lCount, sizeof(double), DoubleCompare);
03878 #endif
03879 }
03880
03881
03882 void clDSPOp::Sort (long *lpVect, long lCount)
03883 {
03884 #ifdef DSP_IPP
03885 ippsSortAscend_32s_I((Ipp32s *) lpVect, lCount);
03886 #else
03887 qsort(lpVect, (size_t) lCount, sizeof(long), LongCompare);
03888 #endif
03889 }
03890
03891
03892 void clDSPOp::StdDev (float *fpStdDev, float *fpMean, const float *fpSrc,
03893 long lCount)
03894 {
03895 #ifdef DSP_IPP
03896 ippsStdDev_32f(fpSrc, lCount, fpStdDev, ippAlgHintFast);
03897 ippsMean_32f(fpSrc, lCount, fpMean, ippAlgHintFast);
03898 #else
03899 long lLoopCntr;
03900 float fMean = 0.0F;
03901 float fTempVal;
03902 float fTemp = 0.0F;
03903 float fStdDev;
03904
03905 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
03906 {
03907 fMean += fpSrc[lLoopCntr];
03908 }
03909 fMean /= (float) lCount;
03910 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
03911 {
03912 fTempVal = fpSrc[lLoopCntr] - fMean;
03913 #ifndef _ISOC9X_SOURCE
03914 fTemp += fTempVal * fTempVal;
03915 #else
03916 fTemp = fmaf(fTempVal, fTempVal, fTemp);
03917 #endif
03918 }
03919 fStdDev = sqrtf(fTemp / (float) lCount);
03920 *fpStdDev = fStdDev;
03921 *fpMean = fMean;
03922 #endif
03923 }
03924
03925
03926 void clDSPOp::StdDev (double *dpStdDev, double *dpMean, const double *dpSrc,
03927 long lCount)
03928 {
03929 #ifdef DSP_IPP
03930 ippsStdDev_64f(dpSrc, lCount, dpStdDev);
03931 ippsStdDev_64f(dpSrc, lCount, dpMean);
03932 #else
03933 long lLoopCntr;
03934 double dMean = 0.0;
03935 double dTempVal;
03936 double dTemp = 0.0;
03937 double dStdDev;
03938
03939 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
03940 {
03941 dMean += dpSrc[lLoopCntr];
03942 }
03943 dMean /= (double) lCount;
03944 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
03945 {
03946 dTempVal = dpSrc[lLoopCntr] - dMean;
03947 #ifndef _ISOC9X_SOURCE
03948 dTemp += dTempVal * dTempVal;
03949 #else
03950 dTemp = fma(dTempVal, dTempVal, dTemp);
03951 #endif
03952 }
03953 dStdDev = sqrt(dTemp / (double) lCount);
03954 *dpStdDev = dStdDev;
03955 *dpMean = dMean;
03956 #endif
03957 }
03958
03959
03960 float clDSPOp::Sum (const float *fpSrc, long lCount)
03961 {
03962 #ifdef DSP_IPP
03963 float fSum;
03964
03965 ippsSum_32f(fpSrc, lCount, &fSum, ippAlgHintFast);
03966 #else
03967 long lLoopCntr;
03968 float fSum = 0.0F;
03969
03970 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
03971 {
03972 fSum += fpSrc[lLoopCntr];
03973 }
03974 #endif
03975 return fSum;
03976 }
03977
03978
03979 double clDSPOp::Sum (const double *dpSrc, long lCount)
03980 {
03981 #ifdef DSP_IPP
03982 double dSum;
03983
03984 ippsSum_64f(dpSrc, lCount, &dSum);
03985 #else
03986 long lLoopCntr;
03987 double dSum = 0.0;
03988
03989 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
03990 {
03991 dSum += dpSrc[lLoopCntr];
03992 }
03993 #endif
03994 return dSum;
03995 }
03996
03997
03998 void clDSPOp::Square (float *fpVect, long lCount)
03999 {
04000 #ifdef DSP_IPP
04001 ippsSqr_32f_I(fpVect, lCount);
04002 #else
04003 long lLoopCntr;
04004
04005 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
04006 {
04007 fpVect[lLoopCntr] *= fpVect[lLoopCntr];
04008 }
04009 #endif
04010 }
04011
04012
04013 void clDSPOp::Square (double *dpVect, long lCount)
04014 {
04015 #ifdef DSP_IPP
04016 ippsSqr_64f_I(dpVect, lCount);
04017 #else
04018 long lLoopCntr;
04019
04020 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
04021 {
04022 dpVect[lLoopCntr] *= dpVect[lLoopCntr];
04023 }
04024 #endif
04025 }
04026
04027
04028 void clDSPOp::Square (float *fpDest, const float *fpSrc, long lCount)
04029 {
04030 #ifdef DSP_IPP
04031 ippsSqr_32f(fpSrc, fpDest, lCount);
04032 #else
04033 long lLoopCntr;
04034
04035 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
04036 {
04037 fpDest[lLoopCntr] = fpSrc[lLoopCntr] * fpSrc[lLoopCntr];
04038 }
04039 #endif
04040 }
04041
04042
04043 void clDSPOp::Square (double *dpDest, const double *dpSrc, long lCount)
04044 {
04045 #ifdef DSP_IPP
04046 ippsSqr_64f(dpSrc, dpDest, lCount);
04047 #else
04048 long lLoopCntr;
04049
04050 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
04051 {
04052 dpDest[lLoopCntr] = dpSrc[lLoopCntr] * dpSrc[lLoopCntr];
04053 }
04054 #endif
04055 }
04056
04057
04058 void clDSPOp::Convert (float *fpDest, const unsigned char *ucpSrc, long lCount)
04059 {
04060 long lLoopCntr;
04061 float fMult;
04062
04063 fMult = 1.0F / (float) UCHAR_MAX;
04064 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
04065 {
04066 fpDest[lLoopCntr] = (ucpSrc[lLoopCntr] * fMult - 0.5F) * 2.0F;
04067 }
04068 }
04069
04070
04071 void clDSPOp::Convert (float *fpDest, const signed short *sspSrc, long lCount,
04072 bool b12bit)
04073 {
04074 #ifdef DSP_IPP
04075 ippsConvert_16s32f_Sfs(sspSrc, fpDest, lCount,
04076 (b12bit) ? 11 : 15);
04077 #else
04078 long lLoopCntr;
04079 float fMult;
04080
04081 #ifdef DSP_X86
04082 if (bHave3DNow)
04083 {
04084 dsp_x86_3dnow_i16tof(fpDest, sspSrc, lCount,
04085 ((b12bit) ? 0x1000 : SHRT_MAX));
04086 }
04087 else
04088 #endif
04089 {
04090 fMult = (b12bit) ? (1.0F / (float) 0x1000) : (1.0F / (float) SHRT_MAX);
04091 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
04092 {
04093 fpDest[lLoopCntr] = sspSrc[lLoopCntr] * fMult;
04094 }
04095 }
04096 #endif
04097 }
04098
04099
04100 void clDSPOp::Convert (float *fpDest, const signed int *sipSrc, long lCount,
04101 bool b24bit)
04102 {
04103 #ifdef DSP_IPP
04104 ippsConvert_32s32f_Sfs(sipSrc, fpDest, lCount, 31);
04105 ippsMulC_32f_I((float) 0x7fffffff / (float) 0x7fffff00, fpDest, lCount);
04106 #else
04107 long lLoopCntr;
04108 float fMult;
04109
04110 #ifdef DSP_X86
04111 if (bHave3DNow)
04112 {
04113 dsp_x86_3dnow_i32tof(fpDest, sipSrc, lCount,
04114 ((b24bit) ? 0x7fffff00 : INT_MAX));
04115 }
04116 else
04117 #endif
04118 {
04119 fMult = (b24bit) ?
04120 (1.0F / (float) 0x7fffff00) :
04121 (1.0F / (float) INT_MAX);
04122 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
04123 {
04124 fpDest[lLoopCntr] = sipSrc[lLoopCntr] * fMult;
04125 }
04126 }
04127 #endif
04128 }
04129
04130
04131 void clDSPOp::Convert (float *fpDest, const double *dpSrc, long lCount)
04132 {
04133 #ifdef DSP_IPP
04134 ippsConvert_64f32f(dpSrc, fpDest, lCount);
04135 #else
04136 long lLoopCntr;
04137
04138 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
04139 {
04140 fpDest[lLoopCntr] = (float) dpSrc[lLoopCntr];
04141 }
04142 #endif
04143 }
04144
04145
04146 void clDSPOp::Convert (double *dpDest, const unsigned char *ucpSrc,
04147 long lCount)
04148 {
04149 long lLoopCntr;
04150 double dMult;
04151
04152 dMult = 1.0 / (double) UCHAR_MAX;
04153 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
04154 {
04155 dpDest[lLoopCntr] = (ucpSrc[lLoopCntr] * dMult - 0.5) * 2.0;
04156 }
04157 }
04158
04159
04160 void clDSPOp::Convert (double *dpDest, const signed short *sspSrc, long lCount,
04161 bool b12bit)
04162 {
04163 #ifdef DSP_IPP
04164 ippsConvert_16s64f_Sfs(sspSrc, dpDest, lCount,
04165 (b12bit) ? 11 : 15);
04166 #else
04167 long lLoopCntr;
04168 double dMult;
04169
04170 dMult = (b12bit) ? (1.0 / (double) 0x1000) : (1.0 / (double) SHRT_MAX);
04171 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
04172 {
04173 dpDest[lLoopCntr] = sspSrc[lLoopCntr] * dMult;
04174 }
04175 #endif
04176 }
04177
04178
04179 void clDSPOp::Convert (double *dpDest, const signed int *sipSrc, long lCount,
04180 bool b24bit)
04181 {
04182 #ifdef DSP_IPP
04183 ippsConvert_32s64f_Sfs(sipSrc, dpDest, lCount, 31);
04184 ippsMulC_64f_I((double) 0x7fffffff / (double) 0x7fffff00, dpDest, lCount);
04185 #else
04186 long lLoopCntr;
04187 double dMult;
04188
04189 dMult = (b24bit) ?
04190 (1.0 / (double) 0x7fffff00) :
04191 (1.0 / (double) INT_MAX);
04192 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
04193 {
04194 dpDest[lLoopCntr] = sipSrc[lLoopCntr] * dMult;
04195 }
04196 #endif
04197 }
04198
04199
04200 void clDSPOp::Convert (double *dpDest, const float *fpSrc, long lCount)
04201 {
04202 #ifdef DSP_IPP
04203 ippsConvert_32f64f(fpSrc, dpDest, lCount);
04204 #else
04205 long lLoopCntr;
04206
04207 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
04208 {
04209 dpDest[lLoopCntr] = (double) fpSrc[lLoopCntr];
04210 }
04211 #endif
04212 }
04213
04214
04215 void clDSPOp::Convert (unsigned char *ucpDest, const float *fpSrc, long lCount)
04216 {
04217 long lLoopCntr;
04218
04219 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
04220 {
04221 ucpDest[lLoopCntr] = (unsigned char)
04222 Round((fpSrc[lLoopCntr] + 1.0F) / 2.0F * (float) UCHAR_MAX);
04223 }
04224 }
04225
04226
04227 void clDSPOp::Convert (unsigned char *ucpDest, const double *dpSrc,
04228 long lCount)
04229 {
04230 long lLoopCntr;
04231
04232 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
04233 {
04234 ucpDest[lLoopCntr] = (unsigned char)
04235 Round((dpSrc[lLoopCntr] + 1.0) / 2.0 * (double) UCHAR_MAX);
04236 }
04237 }
04238
04239
04240 void clDSPOp::Convert (signed short *sspDest, const float *fpSrc, long lCount,
04241 bool b12bit)
04242 {
04243 #ifdef DSP_IPP
04244 ippsConvert_32f16s_Sfs(fpSrc, sspDest, lCount, ippRndNear,
04245 (b12bit) ? -11 : -15);
04246 #else
04247 long lLoopCntr;
04248 float fMult;
04249
04250 fMult = (b12bit) ? (float) 0x1000 : (float) SHRT_MAX;
04251 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
04252 {
04253 sspDest[lLoopCntr] = (signed short)
04254 Round(fpSrc[lLoopCntr] * fMult);
04255 }
04256 #endif
04257 }
04258
04259
04260 void clDSPOp::Convert (signed short *sspDest, const double *dpSrc, long lCount,
04261 bool b12bit)
04262 {
04263 long lLoopCntr;
04264 double dMult;
04265
04266 dMult = (b12bit) ? (double) 0x1000 : (double) SHRT_MAX;
04267 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
04268 {
04269 sspDest[lLoopCntr] = (signed short)
04270 Round(dpSrc[lLoopCntr] * dMult);
04271 }
04272 }
04273
04274
04275 void clDSPOp::Convert (signed int *sipDest, const float *fpSrc, long lCount,
04276 bool b24bit)
04277 {
04278 #ifdef DSP_IPP
04279 ippsConvert_32f32s_Sfs(fpSrc, sipDest, lCount, ippRndNear, -31);
04280 #else
04281 long lLoopCntr;
04282 float fMult;
04283
04284 fMult = (b24bit) ? ((float) 0x7fffff00) : ((float) INT_MAX);
04285 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
04286 {
04287 sipDest[lLoopCntr] = (signed int)
04288 Round(fpSrc[lLoopCntr] * fMult);
04289 }
04290 #endif
04291 }
04292
04293
04294 void clDSPOp::Convert (signed int *sipDest, const double *dpSrc, long lCount,
04295 bool b24bit)
04296 {
04297 #ifdef DSP_IPP
04298 ippsConvert_64f32s_Sfs(dpSrc, sipDest, lCount, ippRndNear, -31);
04299 #else
04300 long lLoopCntr;
04301 double dMult;
04302
04303 dMult = (b24bit) ? ((double) 0x7fffff00) : ((double) INT_MAX);
04304 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
04305 {
04306 sipDest[lLoopCntr] = (signed int)
04307 Round(dpSrc[lLoopCntr] * dMult);
04308 }
04309 #endif
04310 }
04311
04312
04313 void clDSPOp::CartToPolar (float *fpMagn, float *fpPhase,
04314 const float *fpReal, const float *fpImag, long lCount)
04315 {
04316 #ifdef DSP_IPP
04317 ippsCartToPolar_32f(fpReal, fpImag, fpMagn, fpPhase, lCount);
04318 #else
04319 long lLoopCntr;
04320
04321 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
04322 {
04323 Cart2Polar(&fpMagn[lLoopCntr], &fpPhase[lLoopCntr],
04324 fpReal[lLoopCntr], fpImag[lLoopCntr]);
04325 }
04326 #endif
04327 }
04328
04329
04330 void clDSPOp::CartToPolar (double *dpMagn, double *dpPhase,
04331 const double *dpReal, const double *dpImag, long lCount)
04332 {
04333 #ifdef DSP_IPP
04334 ippsCartToPolar_64f(dpReal, dpImag, dpMagn, dpPhase, lCount);
04335 #else
04336 long lLoopCntr;
04337
04338 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
04339 {
04340 Cart2Polar(&dpMagn[lLoopCntr], &dpPhase[lLoopCntr],
04341 dpReal[lLoopCntr], dpImag[lLoopCntr]);
04342 }
04343 #endif
04344 }
04345
04346
04347 void clDSPOp::CartToPolar (float *fpMagn, float *fpPhase,
04348 const stpSCplx spCart, long lCount)
04349 {
04350 #ifdef DSP_IPP
04351 ippsCartToPolar_32fc((Ipp32fc *) spCart, fpMagn, fpPhase, lCount);
04352 #else
04353 long lLoopCntr;
04354
04355 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
04356 {
04357 Cart2Polar(&fpMagn[lLoopCntr], &fpPhase[lLoopCntr],
04358 &spCart[lLoopCntr]);
04359 }
04360 #endif
04361 }
04362
04363
04364 void clDSPOp::CartToPolar (double *dpMagn, double *dpPhase,
04365 const stpDCplx spCart, long lCount)
04366 {
04367 #ifdef DSP_IPP
04368 ippsCartToPolar_64fc((Ipp64fc *) spCart, dpMagn, dpPhase, lCount);
04369 #else
04370 long lLoopCntr;
04371
04372 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
04373 {
04374 Cart2Polar(&dpMagn[lLoopCntr], &dpPhase[lLoopCntr],
04375 &spCart[lLoopCntr]);
04376 }
04377 #endif
04378 }
04379
04380
04381 void clDSPOp::CartToPolar (stpSPolar spPolar, const stpSCplx spCart,
04382 long lCount)
04383 {
04384 long lLoopCntr;
04385
04386 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
04387 {
04388 Cart2Polar(&spPolar[lLoopCntr], &spCart[lLoopCntr]);
04389 }
04390 }
04391
04392
04393 void clDSPOp::CartToPolar (stpDPolar spPolar, const stpDCplx spCart,
04394 long lCount)
04395 {
04396 long lLoopCntr;
04397
04398 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
04399 {
04400 Cart2Polar(&spPolar[lLoopCntr], &spCart[lLoopCntr]);
04401 }
04402 }
04403
04404
04405 void clDSPOp::CartToPolar (utpSCoord upCoord, long lCount)
04406 {
04407 long lLoopCntr;
04408
04409 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
04410 {
04411 Cart2Polar(&upCoord[lLoopCntr]);
04412 }
04413 }
04414
04415
04416 void clDSPOp::CartToPolar (utpDCoord upCoord, long lCount)
04417 {
04418 long lLoopCntr;
04419
04420 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
04421 {
04422 Cart2Polar(&upCoord[lLoopCntr]);
04423 }
04424 }
04425
04426
04427 void clDSPOp::PolarToCart (float *fpReal, float *fpImag,
04428 const float *fpMagn, const float *fpPhase, long lCount)
04429 {
04430 #ifdef DSP_IPP
04431 ippsPolarToCart_32f(fpMagn, fpPhase, fpReal, fpImag, lCount);
04432 #else
04433 long lLoopCntr;
04434
04435 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
04436 {
04437 Polar2Cart(&fpReal[lLoopCntr], &fpImag[lLoopCntr],
04438 fpMagn[lLoopCntr], fpPhase[lLoopCntr]);
04439 }
04440 #endif
04441 }
04442
04443
04444 void clDSPOp::PolarToCart (double *dpReal, double *dpImag,
04445 const double *dpMagn, const double *dpPhase, long lCount)
04446 {
04447 #ifdef DSP_IPP
04448 ippsPolarToCart_64f(dpMagn, dpPhase, dpReal, dpImag, lCount);
04449 #else
04450 long lLoopCntr;
04451
04452 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
04453 {
04454 Polar2Cart(&dpReal[lLoopCntr], &dpImag[lLoopCntr],
04455 dpMagn[lLoopCntr], dpPhase[lLoopCntr]);
04456 }
04457 #endif
04458 }
04459
04460
04461 void clDSPOp::PolarToCart (stpSCplx spCart, const float *fpMagn,
04462 const float *fpPhase, long lCount)
04463 {
04464 #ifdef DSP_IPP
04465 ippsPolarToCart_32fc(fpMagn, fpPhase, (Ipp32fc *) spCart, lCount);
04466 #else
04467 long lLoopCntr;
04468
04469 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
04470 {
04471 Polar2Cart(&spCart[lLoopCntr], fpMagn[lLoopCntr], fpPhase[lLoopCntr]);
04472 }
04473 #endif
04474 }
04475
04476
04477 void clDSPOp::PolarToCart (stpDCplx spCart, const double *dpMagn,
04478 const double *dpPhase, long lCount)
04479 {
04480 #ifdef DSP_IPP
04481 ippsPolarToCart_64fc(dpMagn, dpPhase, (Ipp64fc *) spCart, lCount);
04482 #else
04483 long lLoopCntr;
04484
04485 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
04486 {
04487 Polar2Cart(&spCart[lLoopCntr], dpMagn[lLoopCntr], dpPhase[lLoopCntr]);
04488 }
04489 #endif
04490 }
04491
04492
04493 void clDSPOp::PolarToCart (stpSCplx spCart, const stpSPolar spPolar,
04494 long lCount)
04495 {
04496 long lLoopCntr;
04497
04498 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
04499 {
04500 Polar2Cart(&spCart[lLoopCntr], &spPolar[lLoopCntr]);
04501 }
04502 }
04503
04504
04505 void clDSPOp::PolarToCart (stpDCplx spCart, const stpDPolar spPolar,
04506 long lCount)
04507 {
04508 long lLoopCntr;
04509
04510 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
04511 {
04512 Polar2Cart(&spCart[lLoopCntr], &spPolar[lLoopCntr]);
04513 }
04514 }
04515
04516
04517 void clDSPOp::PolarToCart (utpSCoord upCoord, long lCount)
04518 {
04519 long lLoopCntr;
04520
04521 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
04522 {
04523 Polar2Cart(&upCoord[lLoopCntr]);
04524 }
04525 }
04526
04527
04528 void clDSPOp::PolarToCart (utpDCoord upCoord, long lCount)
04529 {
04530 long lLoopCntr;
04531
04532 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
04533 {
04534 Polar2Cart(&upCoord[lLoopCntr]);
04535 }
04536 }
04537
04538
04539 float clDSPOp::CrossCorr (const float *fpSrc1, const float *fpSrc2,
04540 long lCount)
04541 {
04542 long lLoopCntr;
04543 #ifndef DSP_EXTPREC
04544 float fScale;
04545 float fNormFact;
04546 float fProdSum = 0.0F;
04547 float fSqSum1 = 0.0F;
04548 float fSqSum2 = 0.0F;
04549 #else
04550 double fScale;
04551 double fNormFact;
04552 double fProdSum = 0.0;
04553 double fSqSum1 = 0.0;
04554 double fSqSum2 = 0.0;
04555 #endif
04556
04557 #ifdef DSP_X86
04558 if (bHave3DNow)
04559 {
04560 return dsp_x86_3dnow_crosscorrf(fpSrc1, fpSrc2, lCount);
04561 }
04562 else
04563 #endif
04564 {
04565 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
04566 {
04567 #ifndef _ISOC9X_SOURCE
04568 fProdSum += fpSrc1[lLoopCntr] * fpSrc2[lLoopCntr];
04569 fSqSum1 += fpSrc1[lLoopCntr] * fpSrc1[lLoopCntr];
04570 fSqSum2 += fpSrc2[lLoopCntr] * fpSrc2[lLoopCntr];
04571 #else
04572 #ifndef DSP_EXTPREC
04573 fProdSum = fmaf(fpSrc1[lLoopCntr], fpSrc2[lLoopCntr], fProdSum);
04574 fSqSum1 = fmaf(fpSrc1[lLoopCntr], fpSrc1[lLoopCntr], fSqSum1);
04575 fSqSum2 = fmaf(fpSrc2[lLoopCntr], fpSrc2[lLoopCntr], fSqSum2);
04576 #else
04577 fProdSum = fma(fpSrc1[lLoopCntr], fpSrc2[lLoopCntr], fProdSum);
04578 fSqSum1 = fma(fpSrc1[lLoopCntr], fpSrc1[lLoopCntr], fSqSum1);
04579 fSqSum2 = fma(fpSrc2[lLoopCntr], fpSrc2[lLoopCntr], fSqSum2);
04580 #endif
04581 #endif
04582 }
04583 #ifndef DSP_EXTPREC
04584 fScale = 1.0F / lCount;
04585 fNormFact = sqrtf(fSqSum1 * fSqSum2) * fScale;
04586 #else
04587 fScale = 1.0 / lCount;
04588 fNormFact = sqrt(fSqSum1 * fSqSum2) * fScale;
04589 #endif
04590 return ((fProdSum * fScale) / fNormFact);
04591 }
04592 }
04593
04594
04595 double clDSPOp::CrossCorr (const double *dpSrc1, const double *dpSrc2,
04596 long lCount)
04597 {
04598 long lLoopCntr;
04599 #ifndef DSP_EXTPREC
04600 double dScale;
04601 double dNormFact;
04602 double dProdSum = 0.0;
04603 double dSqSum1 = 0.0;
04604 double dSqSum2 = 0.0;
04605 #else
04606 long double dScale;
04607 long double dNormFact;
04608 long double dProdSum = 0.0L;
04609 long double dSqSum1 = 0.0L;
04610 long double dSqSum2 = 0.0L;
04611 #endif
04612
04613 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
04614 {
04615 #ifndef _ISOC9X_SOURCE
04616 dProdSum += dpSrc1[lLoopCntr] * dpSrc2[lLoopCntr];
04617 dSqSum1 += dpSrc1[lLoopCntr] * dpSrc1[lLoopCntr];
04618 dSqSum2 += dpSrc2[lLoopCntr] * dpSrc2[lLoopCntr];
04619 #else
04620 #ifndef DSP_EXTPREC
04621 dProdSum = fma(dpSrc1[lLoopCntr], dpSrc2[lLoopCntr], dProdSum);
04622 dSqSum1 = fma(dpSrc1[lLoopCntr], dpSrc1[lLoopCntr], dSqSum1);
04623 dSqSum2 = fma(dpSrc2[lLoopCntr], dpSrc2[lLoopCntr], dSqSum2);
04624 #else
04625 dProdSum = fmal(dpSrc1[lLoopCntr], dpSrc2[lLoopCntr], dProdSum);
04626 dSqSum1 = fmal(dpSrc1[lLoopCntr], dpSrc1[lLoopCntr], dSqSum1);
04627 dSqSum2 = fmal(dpSrc2[lLoopCntr], dpSrc2[lLoopCntr], dSqSum2);
04628 #endif
04629 #endif
04630 }
04631 #ifndef DSP_EXTPREC
04632 dScale = 1.0 / lCount;
04633 dNormFact = sqrt(dSqSum1 * dSqSum2) * dScale;
04634 #else
04635 dScale = 1.0L / lCount;
04636 dNormFact = sqrtl(dSqSum1 * dSqSum2) * dScale;
04637 #endif
04638 return ((dProdSum * dScale) / dNormFact);
04639 }
04640
04641
04642 float clDSPOp::DelCrossCorr (const float *fpSrc1, const float *fpSrc2,
04643 long lDelay, long lCount)
04644 {
04645 long lLoopCntr;
04646 long lMax;
04647 long lIdx2;
04648 float fScale;
04649 float fNormFact;
04650 float fProdSum = 0.0F;
04651 float fSqSum1 = 0.0F;
04652 float fSqSum2 = 0.0F;
04653
04654 lMax = lCount - lDelay;
04655 #ifdef DSP_X86
04656 if (bHave3DNow)
04657 {
04658 return dsp_x86_3dnow_crosscorrf(fpSrc1, &fpSrc2[lDelay], lMax);
04659 }
04660 else
04661 #endif
04662 {
04663 for (lLoopCntr = 0L; lLoopCntr < lMax; lLoopCntr++)
04664 {
04665 lIdx2 = lLoopCntr + lDelay;
04666 #ifndef _ISOC9X_SOURCE
04667 fProdSum += fpSrc1[lLoopCntr] * fpSrc2[lIdx2];
04668 fSqSum1 += fpSrc1[lLoopCntr] * fpSrc1[lLoopCntr];
04669 fSqSum2 += fpSrc2[lIdx2] * fpSrc2[lIdx2];
04670 #else
04671 fProdSum = fmaf(fpSrc1[lLoopCntr], fpSrc2[lIdx2], fProdSum);
04672 fSqSum1 = fmaf(fpSrc1[lLoopCntr], fpSrc1[lLoopCntr], fSqSum1);
04673 fSqSum2 = fmaf(fpSrc2[lIdx2], fpSrc2[lIdx2], fSqSum2);
04674 #endif
04675 }
04676 fScale = 1.0F / (float) lMax;
04677 fNormFact = sqrtf(fSqSum1 * fSqSum2) * fScale;
04678 return ((fProdSum * fScale) / fNormFact);
04679 }
04680 }
04681
04682
04683 double clDSPOp::DelCrossCorr (const double *dpSrc1, const double *dpSrc2,
04684 long lDelay, long lCount)
04685 {
04686 long lLoopCntr;
04687 long lMax;
04688 long lIdx2;
04689 double dScale;
04690 double dNormFact;
04691 double dProdSum = 0.0;
04692 double dSqSum1 = 0.0;
04693 double dSqSum2 = 0.0;
04694
04695 lMax = lCount - lDelay;
04696 for (lLoopCntr = 0L; lLoopCntr < lMax; lLoopCntr++)
04697 {
04698 lIdx2 = lLoopCntr + lDelay;
04699 #ifndef _ISOC9X_SOURCE
04700 dProdSum += dpSrc1[lLoopCntr] * dpSrc2[lIdx2];
04701 dSqSum1 += dpSrc1[lLoopCntr] * dpSrc1[lLoopCntr];
04702 dSqSum2 += dpSrc2[lIdx2] * dpSrc2[lIdx2];
04703 #else
04704 dProdSum = fma(dpSrc1[lLoopCntr], dpSrc2[lIdx2], dProdSum);
04705 dSqSum1 = fma(dpSrc1[lLoopCntr], dpSrc1[lLoopCntr], dSqSum1);
04706 dSqSum2 = fma(dpSrc2[lIdx2], dpSrc2[lIdx2], dSqSum2);
04707 #endif
04708 }
04709 dScale = 1.0 / (double) lMax;
04710 dNormFact = sqrt(dSqSum1 * dSqSum2) * dScale;
04711 return ((dProdSum * dScale) / dNormFact);
04712 }
04713
04714
04715 void clDSPOp::DelCrossCorr (float *fpDest, const float *fpSrc1,
04716 const float *fpSrc2, long lCount, const long *lpDelay, long lDelayCount)
04717 {
04718 long lLoopDelay;
04719 long lLoopCorr;
04720 long lDelay;
04721 long lMax;
04722 long lIdx2;
04723 float fScale;
04724 float fNormFact;
04725 float fProdSum;
04726 float fSqSum1;
04727 float fSqSum2;
04728
04729 for (lLoopDelay = 0L; lLoopDelay < lDelayCount; lLoopDelay++)
04730 {
04731 fProdSum = 0.0F;
04732 fSqSum1 = 0.0F;
04733 fSqSum2 = 0.0F;
04734 lDelay = lpDelay[lLoopDelay];
04735 lMax = lCount - lDelay;
04736 for (lLoopCorr = 0L; lLoopCorr < lMax; lLoopCorr++)
04737 {
04738 lIdx2 = lLoopCorr + lDelay;
04739 #ifndef _ISOC9X_SOURCE
04740 fProdSum += fpSrc1[lLoopCorr] * fpSrc2[lIdx2];
04741 fSqSum1 += fpSrc1[lLoopCorr] * fpSrc1[lLoopCorr];
04742 fSqSum2 += fpSrc2[lIdx2] * fpSrc2[lIdx2];
04743 #else
04744 fProdSum = fmaf(fpSrc1[lLoopCorr], fpSrc2[lIdx2], fProdSum);
04745 fSqSum1 = fmaf(fpSrc1[lLoopCorr], fpSrc1[lLoopCorr], fSqSum1);
04746 fSqSum2 = fmaf(fpSrc2[lIdx2], fpSrc2[lIdx2], fSqSum2);
04747 #endif
04748 }
04749 fScale = 1.0F / (float) lMax;
04750 fNormFact = sqrtf(fSqSum1 * fSqSum2) * fScale;
04751 fpDest[lLoopDelay] = (fProdSum * fScale) / fNormFact;
04752 }
04753 }
04754
04755
04756 void clDSPOp::DelCrossCorr (double *dpDest, const double *dpSrc1,
04757 const double *dpSrc2, long lCount, const long *lpDelay, long lDelayCount)
04758 {
04759 long lLoopDelay;
04760 long lLoopCorr;
04761 long lDelay;
04762 long lMax;
04763 long lIdx2;
04764 double dScale;
04765 double dNormFact;
04766 double dProdSum;
04767 double dSqSum1;
04768 double dSqSum2;
04769
04770 for (lLoopDelay = 0L; lLoopDelay < lDelayCount; lLoopDelay++)
04771 {
04772 dProdSum = 0.0;
04773 dSqSum1 = 0.0;
04774 dSqSum2 = 0.0;
04775 lDelay = lpDelay[lLoopDelay];
04776 lMax = lCount - lDelay;
04777 for (lLoopCorr = 0L; lLoopCorr < lMax; lLoopCorr++)
04778 {
04779 lIdx2 = lLoopCorr + lDelay;
04780 #ifndef _ISOC9X_SOURCE
04781 dProdSum += dpSrc1[lLoopCorr] * dpSrc2[lIdx2];
04782 dSqSum1 += dpSrc1[lLoopCorr] * dpSrc1[lLoopCorr];
04783 dSqSum2 += dpSrc2[lIdx2] * dpSrc2[lIdx2];
04784 #else
04785 dProdSum = fma(dpSrc1[lLoopCorr], dpSrc2[lIdx2], dProdSum);
04786 dSqSum1 = fma(dpSrc1[lLoopCorr], dpSrc1[lLoopCorr], dSqSum1);
04787 dSqSum2 = fma(dpSrc2[lIdx2], dpSrc2[lIdx2], dSqSum2);
04788 #endif
04789 }
04790 dScale = 1.0 / (double) lMax;
04791 dNormFact = sqrt(dSqSum1 * dSqSum2) * dScale;
04792 dpDest[lLoopDelay] = (dProdSum * dScale) / dNormFact;
04793 }
04794 }
04795
04796
04797 float clDSPOp::Energy (const float *fpSrc, long lCount)
04798 {
04799 long lLoopCntr;
04800 float fEnergy = 0.0F;
04801
04802 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
04803 {
04804 #ifndef _ISOC9X_SOURCE
04805 fEnergy += fpSrc[lLoopCntr] * fpSrc[lLoopCntr];
04806 #else
04807 fEnergy = fmaf(fpSrc[lLoopCntr], fpSrc[lLoopCntr], fEnergy);
04808 #endif
04809 }
04810 return fEnergy;
04811 }
04812
04813
04814 double clDSPOp::Energy (const double *dpSrc, long lCount)
04815 {
04816 long lLoopCntr;
04817 double dEnergy = 0.0;
04818
04819 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
04820 {
04821 #ifndef _ISOC9X_SOURCE
04822 dEnergy += dpSrc[lLoopCntr] * dpSrc[lLoopCntr];
04823 #else
04824 dEnergy = fma(dpSrc[lLoopCntr], dpSrc[lLoopCntr], dEnergy);
04825 #endif
04826 }
04827 return dEnergy;
04828 }
04829
04830
04831 void clDSPOp::Magnitude (float *fpMagn, const stpSCplx spCplx, long lCount)
04832 {
04833 #ifdef DSP_IPP
04834 ippsMagnitude_32fc((Ipp32fc *) spCplx, fpMagn, lCount);
04835 #else
04836 long lLoopCntr;
04837
04838 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
04839 {
04840 #ifndef _ISOC9X_SOURCE
04841 fpMagn[lLoopCntr] = sqrtf(
04842 spCplx[lLoopCntr].R * spCplx[lLoopCntr].R +
04843 spCplx[lLoopCntr].I * spCplx[lLoopCntr].I);
04844 #else
04845 fpMagn[lLoopCntr] =
04846 hypotf(spCplx[lLoopCntr].R, spCplx[lLoopCntr].I);
04847 #endif
04848 }
04849 #endif
04850 }
04851
04852
04853 void clDSPOp::Magnitude (double *dpMagn, const stpDCplx spCplx, long lCount)
04854 {
04855 #ifdef DSP_IPP
04856 ippsMagnitude_64fc((Ipp64fc *) spCplx, dpMagn, lCount);
04857 #else
04858 long lLoopCntr;
04859
04860 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
04861 {
04862 #ifndef _ISOC9X_SOURCE
04863 dpMagn[lLoopCntr] = sqrt(
04864 spCplx[lLoopCntr].R * spCplx[lLoopCntr].R +
04865 spCplx[lLoopCntr].I * spCplx[lLoopCntr].I);
04866 #else
04867 dpMagn[lLoopCntr] =
04868 hypot(spCplx[lLoopCntr].R, spCplx[lLoopCntr].I);
04869 #endif
04870 }
04871 #endif
04872 }
04873
04874
04875 void clDSPOp::Power (float *fpPower, const stpSCplx spCplx, long lCount)
04876 {
04877 long lLoopCntr;
04878
04879 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
04880 {
04881 #ifndef _ISOC9X_SOURCE
04882 fpPower[lLoopCntr] = 20.0F * log10f(sqrtf(
04883 spCplx[lLoopCntr].R * spCplx[lLoopCntr].R +
04884 spCplx[lLoopCntr].I * spCplx[lLoopCntr].I));
04885 #else
04886 fpPower[lLoopCntr] = 20.0F * log10f(
04887 hypotf(spCplx[lLoopCntr].R, spCplx[lLoopCntr].I));
04888 #endif
04889 }
04890 }
04891
04892
04893 void clDSPOp::Power (double *dpPower, const stpDCplx spCplx, long lCount)
04894 {
04895 long lLoopCntr;
04896
04897 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
04898 {
04899 #ifndef _ISOC9X_SOURCE
04900 dpPower[lLoopCntr] = 20.0 * log10(sqrt(
04901 spCplx[lLoopCntr].R * spCplx[lLoopCntr].R +
04902 spCplx[lLoopCntr].I * spCplx[lLoopCntr].I));
04903 #else
04904 dpPower[lLoopCntr] = 20.0 * log10(
04905 hypot(spCplx[lLoopCntr].R, spCplx[lLoopCntr].I));
04906 #endif
04907 }
04908 }
04909
04910
04911 void clDSPOp::Phase (float *fpPhase, const stpSCplx spCplx, long lCount)
04912 {
04913 #ifdef DSP_IPP
04914 ippsPhase_32fc((Ipp32fc *) spCplx, fpPhase, lCount);
04915 #else
04916 long lLoopCntr;
04917
04918 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
04919 {
04920 fpPhase[lLoopCntr] =
04921 atan2f(spCplx[lLoopCntr].I, spCplx[lLoopCntr].R);
04922 }
04923 #endif
04924 }
04925
04926
04927 void clDSPOp::Phase (double *dpPhase, const stpDCplx spCplx, long lCount)
04928 {
04929 #ifdef DSP_IPP
04930 ippsPhase_64fc((Ipp64fc *) spCplx, dpPhase, lCount);
04931 #else
04932 long lLoopCntr;
04933
04934 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
04935 {
04936 dpPhase[lLoopCntr] =
04937 atan2(spCplx[lLoopCntr].I, spCplx[lLoopCntr].R);
04938 }
04939 #endif
04940 }
04941
04942
04943
04944 void clDSPOp::PowerPhase (float *fpPower, float *fpPhase,
04945 const stpSCplx spCplx, long lCount)
04946 {
04947 long lLoopCntr;
04948 float fReal;
04949 float fImag;
04950
04951 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
04952 {
04953 fReal = spCplx[lLoopCntr].R;
04954 fImag = spCplx[lLoopCntr].I;
04955 #ifndef _ISOC9X_SOURCE
04956 fpPower[lLoopCntr] =
04957 20.0F * log10f(sqrtf(fReal * fReal + fImag * fImag));
04958 #else
04959 fpPower[lLoopCntr] =
04960 20.0F * log10f(hypotf(fReal, fImag));
04961 #endif
04962 fpPhase[lLoopCntr] = atan2f(fImag, fReal);
04963 }
04964 }
04965
04966
04967 void clDSPOp::PowerPhase (double *dpPower, double *dpPhase,
04968 const stpDCplx spCplx, long lCount)
04969 {
04970 long lLoopCntr;
04971 double dReal;
04972 double dImag;
04973
04974 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
04975 {
04976 dReal = spCplx[lLoopCntr].R;
04977 dImag = spCplx[lLoopCntr].I;
04978 #ifndef _ISOC9X_SOURCE
04979 dpPower[lLoopCntr] =
04980 20.0 * log10(sqrt(dReal * dReal + dImag * dImag));
04981 #else
04982 dpPower[lLoopCntr] =
04983 20.0 * log10(hypot(dReal, dImag));
04984 #endif
04985 dpPhase[lLoopCntr] = atan2(dImag, dReal);
04986 }
04987 }
04988
04989
04990 void clDSPOp::Decimate (float *fpDest, const float *fpSrc, long lFactor,
04991 long lCount)
04992 {
04993 #ifdef DSP_IPP
04994 int iDestCount = lCount / lFactor;
04995 int iPhase = 0;
04996
04997 ippsSampleDown_32f(fpSrc, lCount, fpDest, &iDestCount, lFactor, &iPhase);
04998 #else
04999 long lLoopCntr;
05000 long lMax;
05001
05002 lMax = lCount / lFactor;
05003 for (lLoopCntr = 0L; lLoopCntr < lMax; lLoopCntr++)
05004 {
05005 fpDest[lLoopCntr] = fpSrc[lLoopCntr * lFactor];
05006 }
05007 #endif
05008 }
05009
05010
05011 void clDSPOp::Decimate (double *dpDest, const double *dpSrc, long lFactor,
05012 long lCount)
05013 {
05014 #ifdef DSP_IPP
05015 int iDestCount = lCount / lFactor;
05016 int iPhase = 0;
05017
05018 ippsSampleDown_64f(dpSrc, lCount, dpDest, &iDestCount, lFactor, &iPhase);
05019 #else
05020 long lLoopCntr;
05021 long lMax;
05022
05023 lMax = lCount / lFactor;
05024 for (lLoopCntr = 0L; lLoopCntr < lMax; lLoopCntr++)
05025 {
05026 dpDest[lLoopCntr] = dpSrc[lLoopCntr * lFactor];
05027 }
05028 #endif
05029 }
05030
05031
05032 void clDSPOp::DecimateAvg (float *fpDest, const float *fpSrc, long lFactor,
05033 long lCount)
05034 {
05035 long lLoopDest;
05036 long lLoopAvg;
05037 long lMax;
05038 float fAvg;
05039
05040 lMax = lCount / lFactor;
05041 for (lLoopDest = 0L; lLoopDest < lMax; lLoopDest++)
05042 {
05043 fAvg = 0.0F;
05044 for (lLoopAvg = 0L; lLoopAvg < lFactor; lLoopAvg++)
05045 {
05046 fAvg += fpSrc[lLoopDest * lFactor + lLoopAvg];
05047 }
05048 fpDest[lLoopDest] = fAvg / (float) lFactor;
05049 }
05050 }
05051
05052
05053 void clDSPOp::DecimateAvg (double *dpDest, const double *dpSrc, long lFactor,
05054 long lCount)
05055 {
05056 long lLoopDest;
05057 long lLoopAvg;
05058 long lMax;
05059 double dAvg;
05060
05061 lMax = lCount / lFactor;
05062 for (lLoopDest = 0L; lLoopDest < lMax; lLoopDest++)
05063 {
05064 dAvg = 0.0;
05065 for (lLoopAvg = 0L; lLoopAvg < lFactor; lLoopAvg++)
05066 {
05067 dAvg += dpSrc[lLoopDest * lFactor + lLoopAvg];
05068 }
05069 dpDest[lLoopDest] = dAvg / (double) lFactor;
05070 }
05071 }
05072
05073
05074 void clDSPOp::Interpolate (float *fpDest, const float *fpSrc, long lFactor,
05075 long lCount)
05076 {
05077 #ifdef DSP_IPP
05078 int iDestCount = lCount * lFactor;
05079 int iPhase = 0;
05080
05081 ippsSampleUp_32f(fpSrc, lCount, fpDest, &iDestCount, lFactor, &iPhase);
05082 #else
05083 long lLoopSrc;
05084 long lLoopInt;
05085
05086 for (lLoopSrc = 0L; lLoopSrc < lCount; lLoopSrc++)
05087 {
05088 fpDest[lLoopSrc * lFactor] = fpSrc[lLoopSrc];
05089 for (lLoopInt = 1L; lLoopInt < lFactor; lLoopInt++)
05090 {
05091 fpDest[lLoopSrc * lFactor + lLoopInt] = 0.0F;
05092 }
05093 }
05094 #endif
05095 }
05096
05097
05098 void clDSPOp::Interpolate (double *dpDest, const double *dpSrc, long lFactor,
05099 long lCount)
05100 {
05101 #ifdef DSP_IPP
05102 int iDestCount = lCount * lFactor;
05103 int iPhase = 0;
05104
05105 ippsSampleUp_64f(dpSrc, lCount, dpDest, &iDestCount, lFactor, &iPhase);
05106 #else
05107 long lLoopSrc;
05108 long lLoopInt;
05109
05110 for (lLoopSrc = 0L; lLoopSrc < lCount; lLoopSrc++)
05111 {
05112 dpDest[lLoopSrc * lFactor] = dpSrc[lLoopSrc];
05113 for (lLoopInt = 1L; lLoopInt < lFactor; lLoopInt++)
05114 {
05115 dpDest[lLoopSrc * lFactor + lLoopInt] = 0.0;
05116 }
05117 }
05118 #endif
05119 }
05120
05121
05122 void clDSPOp::InterpolateAvg (float *fpDest, const float *fpSrc,
05123 long lFactor, long lCount)
05124 {
05125 long lSrcCntr;
05126 long lIntCntr;
05127 long lX;
05128 long lX0;
05129 long lX1;
05130 float fF0;
05131 float fF1;
05132 float fL0;
05133 float fL1;
05134 float fP1;
05135
05136 for (lSrcCntr = 0L; lSrcCntr < lCount; lSrcCntr++)
05137 {
05138 lX0 = lSrcCntr * lFactor;
05139 lX1 = (lSrcCntr + 1L) * lFactor;
05140 if (lSrcCntr != (lCount - 1L))
05141 {
05142 fF0 = fpSrc[lSrcCntr];
05143 fF1 = fpSrc[lSrcCntr + 1L];
05144 }
05145 else
05146 {
05147 fF0 = fpSrc[lSrcCntr];
05148 fF1 = fpSrc[lSrcCntr] - (fpSrc[lSrcCntr - 1L] - fpSrc[lSrcCntr]);
05149 }
05150 fpDest[lSrcCntr * lFactor] = fF0;
05151 for (lIntCntr = 1L; lIntCntr < lFactor; lIntCntr++)
05152 {
05153 lX = lSrcCntr * lFactor + lIntCntr;
05154 fL0 = (float) (lX - lX1) / (float) (lX0 - lX1);
05155 fL1 = (float) (lX - lX0) / (float) (lX1 - lX0);
05156 fP1 = fL0 * fF0 + fL1 * fF1;
05157 fpDest[lX] = fP1;
05158 }
05159 }
05160 }
05161
05162
05163 void clDSPOp::InterpolateAvg (double *dpDest, const double *dpSrc,
05164 long lFactor, long lCount)
05165 {
05166 long lSrcCntr;
05167 long lIntCntr;
05168 long lX;
05169 long lX0;
05170 long lX1;
05171 double dF0;
05172 double dF1;
05173 double dL0;
05174 double dL1;
05175 double dP1;
05176
05177 for (lSrcCntr = 0L; lSrcCntr < lCount; lSrcCntr++)
05178 {
05179 lX0 = lSrcCntr * lFactor;
05180 lX1 = (lSrcCntr + 1L) * lFactor;
05181 if (lSrcCntr != (lCount - 1L))
05182 {
05183 dF0 = dpSrc[lSrcCntr];
05184 dF1 = dpSrc[lSrcCntr + 1L];
05185 }
05186 else
05187 {
05188 dF0 = dpSrc[lSrcCntr];
05189 dF1 = dpSrc[lSrcCntr] - (dpSrc[lSrcCntr - 1L] - dpSrc[lSrcCntr]);
05190 }
05191 dpDest[lSrcCntr * lFactor] = dF0;
05192 for (lIntCntr = 1L; lIntCntr < lFactor; lIntCntr++)
05193 {
05194 lX = lSrcCntr * lFactor + lIntCntr;
05195 dL0 = (double) (lX - lX1) / (double) (lX0 - lX1);
05196 dL1 = (double) (lX - lX0) / (double) (lX1 - lX0);
05197 dP1 = dL0 * dF0 + dL1 * dF1;
05198 dpDest[lX] = dP1;
05199 }
05200 }
05201 }
05202
05203
05204 void clDSPOp::Resample (float *fpDest, long lDestCount,
05205 const float *fpSrc, long lSrcCount)
05206 {
05207 long lDestCntr;
05208 long lSrcIdx;
05209 float fScale;
05210
05211 fScale = (float) lSrcCount / (float) lDestCount;
05212 for (lDestCntr = 0; lDestCntr < lDestCount; lDestCntr++)
05213 {
05214 lSrcIdx = (long) ((float) lDestCntr * fScale + 0.5F);
05215 if (unlikely(lSrcIdx >= lSrcCount))
05216 lSrcIdx = lSrcCount - 1;
05217 fpDest[lDestCntr] = fpSrc[lSrcIdx];
05218 }
05219 }
05220
05221
05222 void clDSPOp::Resample (double *dpDest, long lDestCount,
05223 const double *dpSrc, long lSrcCount)
05224 {
05225 long lDestCntr;
05226 long lSrcIdx;
05227 double dScale;
05228
05229 dScale = (double) lSrcCount / (double) lDestCount;
05230 for (lDestCntr = 0; lDestCntr < lDestCount; lDestCntr++)
05231 {
05232 lSrcIdx = (long) ((double) lDestCntr * dScale + 0.5);
05233 if (unlikely(lSrcIdx >= lSrcCount))
05234 lSrcIdx = lSrcCount - 1;
05235 dpDest[lDestCntr] = dpSrc[lSrcIdx];
05236 }
05237 }
05238
05239
05240 void clDSPOp::ResampleAvg (float *fpDest, long lDestCount,
05241 const float *fpSrc, long lSrcCount)
05242 {
05243 long lDestCntr;
05244 long lSrcCntr;
05245 long lSrcIdx1;
05246 long lSrcIdx2;
05247 long lDist;
05248 float fScale;
05249 float fValue;
05250
05251 fScale = (float) lSrcCount / (float) lDestCount;
05252 if (lDestCount < lSrcCount)
05253 {
05254 for (lDestCntr = 0; lDestCntr < lDestCount; lDestCntr++)
05255 {
05256 lSrcIdx1 = (long) ((float) lDestCntr * fScale + 0.5F);
05257 lSrcIdx2 = (long) ((float) (lDestCntr + 1) * fScale + 0.5F);
05258 if (unlikely(lSrcIdx1 >= lSrcCount))
05259 lSrcIdx1 = lSrcCount - 1;
05260 if (unlikely(lSrcIdx2 >= lSrcCount))
05261 lSrcIdx2 = lSrcCount - 1;
05262 lDist = lSrcIdx2 - lSrcIdx1;
05263 if (lDist > 0)
05264 {
05265 fValue = 0.0f;
05266 for (lSrcCntr = lSrcIdx1; lSrcCntr < lSrcIdx2; lSrcCntr++)
05267 fValue += fpSrc[lSrcCntr];
05268 fValue /= (float) lDist;
05269 }
05270 else fValue = fpSrc[lSrcIdx1];
05271 fpDest[lDestCntr] = fValue;
05272 }
05273 }
05274 else if (lDestCount > lSrcCount)
05275 {
05276 fpDest[0] = fpSrc[0];
05277 for (lDestCntr = 1; lDestCntr < lDestCount; lDestCntr++)
05278 {
05279 lSrcIdx1 = (long) ((float) lDestCntr * fScale + 0.5F);
05280 lSrcIdx2 = (long) ((float) (lDestCntr + 1) * fScale + 0.5F);
05281 if (unlikely(lSrcIdx1 >= lSrcCount))
05282 lSrcIdx1 = lSrcCount - 1;
05283 if (unlikely(lSrcIdx2 >= lSrcCount))
05284 lSrcIdx2 = lSrcCount - 1;
05285 fpDest[lDestCntr] = fpSrc[lSrcIdx1] +
05286 ((fpSrc[lSrcIdx2] - fpSrc[lSrcIdx1]) * fScale);
05287 }
05288 }
05289 else Copy(fpDest, fpSrc, lDestCount);
05290 }
05291
05292
05293 void clDSPOp::ResampleAvg (double *dpDest, long lDestCount,
05294 const double *dpSrc, long lSrcCount)
05295 {
05296 long lDestCntr;
05297 long lSrcCntr;
05298 long lSrcIdx1;
05299 long lSrcIdx2;
05300 long lDist;
05301 double dScale;
05302 double dValue;
05303
05304 dScale = (double) lSrcCount / (double) lDestCount;
05305 if (lDestCount < lSrcCount)
05306 {
05307 for (lDestCntr = 0; lDestCntr < lDestCount; lDestCntr++)
05308 {
05309 lSrcIdx1 = (long) ((double) lDestCntr * dScale + 0.5);
05310 lSrcIdx2 = (long) ((double) (lDestCntr + 1) * dScale + 0.5);
05311 if (unlikely(lSrcIdx1 >= lSrcCount))
05312 lSrcIdx1 = lSrcCount - 1;
05313 if (unlikely(lSrcIdx2 >= lSrcCount))
05314 lSrcIdx2 = lSrcCount - 1;
05315 lDist = lSrcIdx2 - lSrcIdx1;
05316 if (lDist > 0)
05317 {
05318 dValue = 0.0;
05319 for (lSrcCntr = lSrcIdx1; lSrcCntr < lSrcIdx2; lSrcCntr++)
05320 dValue += dpSrc[lSrcCntr];
05321 dValue /= (double) lDist;
05322 }
05323 else dValue = dpSrc[lSrcIdx1];
05324 dpDest[lDestCntr] = dValue;
05325 }
05326 }
05327 else if (lDestCount > lSrcCount)
05328 {
05329 dpDest[0] = dpSrc[0];
05330 for (lDestCntr = 1; lDestCntr < lDestCount; lDestCntr++)
05331 {
05332 lSrcIdx1 = (long) ((double) lDestCntr * dScale + 0.5);
05333 lSrcIdx2 = (long) ((double) (lDestCntr + 1) * dScale + 0.5);
05334 if (unlikely(lSrcIdx1 >= lSrcCount))
05335 lSrcIdx1 = lSrcCount - 1;
05336 if (unlikely(lSrcIdx2 >= lSrcCount))
05337 lSrcIdx2 = lSrcCount - 1;
05338 dpDest[lDestCntr] = dpSrc[lSrcIdx1] +
05339 ((dpSrc[lSrcIdx2] - dpSrc[lSrcIdx1]) * dScale);
05340 }
05341 }
05342 else Copy(dpDest, dpSrc, lDestCount);
05343 }
05344
05345
05346 float clDSPOp::RMS (const float *fpSrc, long lCount)
05347 {
05348 long lLoopCntr;
05349 float fSqSum = 0.0F;
05350
05351 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
05352 {
05353 #ifndef _ISOC9X_SOURCE
05354 fSqSum += fpSrc[lLoopCntr] * fpSrc[lLoopCntr];
05355 #else
05356 fSqSum = fmaf(fpSrc[lLoopCntr], fpSrc[lLoopCntr], fSqSum);
05357 #endif
05358 }
05359 return ((float) sqrtf(fSqSum / (float) lCount));
05360 }
05361
05362
05363 double clDSPOp::RMS (const double *dpSrc, long lCount)
05364 {
05365 long lLoopCntr;
05366 double dSqSum = 0.0;
05367
05368 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
05369 {
05370 #ifndef _ISOC9X_SOURCE
05371 dSqSum += dpSrc[lLoopCntr] * dpSrc[lLoopCntr];
05372 #else
05373 dSqSum = fma(dpSrc[lLoopCntr], dpSrc[lLoopCntr], dSqSum);
05374 #endif
05375 }
05376 return (sqrt(dSqSum / (double) lCount));
05377 }
05378
05379
05380 float clDSPOp::Variance (float *fpVariance, float *fpMean,
05381 const float *fpSrc, long lCount)
05382 {
05383 long lLoopCntr;
05384 float fMean = 0.0F;
05385 float fVariance = 0.0F;
05386
05387 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
05388 {
05389 fMean += fpSrc[lLoopCntr];
05390 }
05391 fMean /= (float) lCount;
05392 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
05393 {
05394 fVariance += (float) powf(fpSrc[lLoopCntr] - fMean, 2.0F);
05395 }
05396 fVariance /= (float) lCount;
05397 if (fpVariance != NULL)
05398 {
05399 *fpVariance = fVariance;
05400 }
05401 if (fpMean != NULL)
05402 {
05403 *fpMean = fMean;
05404 }
05405 return fVariance;
05406 }
05407
05408
05409 double clDSPOp::Variance (double *dpVariance, double *dpMean,
05410 const double *dpSrc, long lCount)
05411 {
05412 long lLoopCntr;
05413 double dMean = 0.0;
05414 double dVariance = 0.0;
05415
05416 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
05417 {
05418 dMean += dpSrc[lLoopCntr];
05419 }
05420 dMean /= (double) lCount;
05421 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
05422 {
05423 dVariance += (double) pow(dpSrc[lLoopCntr] - dMean, 2.0);
05424 }
05425 dVariance /= (double) lCount;
05426 if (dpVariance != NULL)
05427 {
05428 *dpVariance = dVariance;
05429 }
05430 if (dpMean != NULL)
05431 {
05432 *dpMean = dMean;
05433 }
05434 return dVariance;
05435 }
05436
05437
05438 float clDSPOp::PeakLevel (const float *fpSrc, long lSize)
05439 {
05440 float fMin;
05441 float fMax;
05442 float fLinMax;
05443
05444 MinMax(&fMin, &fMax, fpSrc, lSize);
05445 fMin = fabsf(fMin);
05446 fMax = fabsf(fMax);
05447 #ifndef _ISOC9X_SOURCE
05448 fLinMax = (fMax >= fMin) ? fMax : fMin;
05449 #else
05450 fLinMax = fmaxf(fMin, fMax);
05451 #endif
05452 return (20.0F * log10f(fLinMax));
05453 }
05454
05455
05456 double clDSPOp::PeakLevel (const double *dpSrc, long lSize)
05457 {
05458 double dMin;
05459 double dMax;
05460 double dLinMax;
05461
05462 MinMax(&dMin, &dMax, dpSrc, lSize);
05463 dMin = fabs(dMin);
05464 dMax = fabs(dMax);
05465 #ifndef _ISOC9X_SOURCE
05466 dLinMax = (dMax >= dMin) ? dMax : dMin;
05467 #else
05468 dLinMax = fmax(dMin, dMax);
05469 #endif
05470 return (20.0 * log10(dLinMax));
05471 }
05472
05473
05474 void clDSPOp::WinBartlett (float *fpDest, long lSize)
05475 {
05476 #ifdef DSP_IPP
05477 ippsSet_32f(1.0F, fpDest, lSize);
05478 ippsWinBartlett_32f_I(fpDest, lSize);
05479 #else
05480 long lLoopCntr;
05481
05482 for (lLoopCntr = 0L; lLoopCntr <= ((lSize - 1L) / 2L); lLoopCntr++)
05483 {
05484 fpDest[lLoopCntr] = 2.0F * (float) lLoopCntr / (float) (lSize - 1L);
05485 }
05486 for (lLoopCntr = ((lSize - 1L) / 2L + 1L); lLoopCntr < lSize; lLoopCntr++)
05487 {
05488 fpDest[lLoopCntr] =
05489 2.0F - 2.0F * (float) lLoopCntr / (float) (lSize - 1L);
05490 }
05491 #endif
05492 }
05493
05494
05495 void clDSPOp::WinBartlett (double *dpDest, long lSize)
05496 {
05497 #ifdef DSP_IPP
05498 ippsSet_64f(1.0, dpDest, lSize);
05499 ippsWinBartlett_64f_I(dpDest, lSize);
05500 #else
05501 long lLoopCntr;
05502
05503 for (lLoopCntr = 0L; lLoopCntr <= ((lSize - 1L) / 2L); lLoopCntr++)
05504 {
05505 dpDest[lLoopCntr] = 2.0 * (double) lLoopCntr / (double) (lSize - 1L);
05506 }
05507 for (lLoopCntr = ((lSize - 1L) / 2L + 1L); lLoopCntr < lSize; lLoopCntr++)
05508 {
05509 dpDest[lLoopCntr] =
05510 2.0 - 2.0 * (double) lLoopCntr / (double) (lSize - 1L);
05511 }
05512 #endif
05513 }
05514
05515
05516 void clDSPOp::WinBlackman (float *fpDest, long lSize)
05517 {
05518 #ifdef DSP_IPP
05519 ippsSet_32f(1.0F, fpDest, lSize);
05520 ippsWinBlackmanStd_32f_I(fpDest, lSize);
05521 #else
05522 long lLoopCntr;
05523
05524 for (lLoopCntr = 0L; lLoopCntr < lSize; lLoopCntr++)
05525 {
05526 fpDest[lLoopCntr] = 0.42F -
05527 0.5F * cos((2.0F * fPI * (float) lLoopCntr) / (float) lSize) +
05528 0.08F * cos((4.0F * fPI * (float) lLoopCntr) / (float) lSize);
05529 }
05530 #endif
05531 }
05532
05533
05534 void clDSPOp::WinBlackman (double *dpDest, long lSize)
05535 {
05536 #ifdef DSP_IPP
05537 ippsSet_64f(1.0, dpDest, lSize);
05538 ippsWinBlackmanStd_64f_I(dpDest, lSize);
05539 #else
05540 long lLoopCntr;
05541
05542 for (lLoopCntr = 0L; lLoopCntr < lSize; lLoopCntr++)
05543 {
05544 dpDest[lLoopCntr] = 0.42 -
05545 0.5 * cos((2.0 * dPI * (double) lLoopCntr) / (double) lSize) +
05546 0.08 * cos((4.0 * dPI * (double) lLoopCntr) / (double) lSize);
05547 }
05548 #endif
05549 }
05550
05551
05552 void clDSPOp::WinBlackman (float *fpDest, long lSize, float fAlphaP)
05553 {
05554 #ifdef DSP_IPP
05555 ippsSet_32f(1.0F, fpDest, lSize);
05556 if (fAlphaP != 0.0F)
05557 ippsWinBlackman_32f_I(fpDest, lSize, fAlphaP);
05558 else
05559 ippsWinBlackmanOpt_32f_I(fpDest, lSize);
05560 #else
05561 long lLoopCntr;
05562 float fAlpha;
05563
05564 fAlpha = (fAlphaP != 0.0F) ?
05565 fAlphaP :
05566 (0.5F / (1.0F + cos((2.0F * fPI) / (float) (lSize - 1))));
05567 for (lLoopCntr = 0L; lLoopCntr < lSize; lLoopCntr++)
05568 {
05569 fpDest[lLoopCntr] = ((fAlpha + 1.0F) / 2.0F) - 0.5F *
05570 cos((2.0F * fPI * (float) lLoopCntr) / ((float) (lSize - 1))) -
05571 (fAlpha / 2.0F) *
05572 cos((4.0F * fPI * (float) lLoopCntr) / ((float) (lSize - 1)));
05573 }
05574 #endif
05575 }
05576
05577
05578 void clDSPOp::WinBlackman (double *dpDest, long lSize, double dAlphaP)
05579 {
05580 #ifdef DSP_IPP
05581 ippsSet_64f(1.0, dpDest, lSize);
05582 if (dAlphaP != 0.0)
05583 ippsWinBlackman_64f_I(dpDest, lSize, dAlphaP);
05584 else
05585 ippsWinBlackmanOpt_64f_I(dpDest, lSize);
05586 #else
05587 long lLoopCntr;
05588 double dAlpha;
05589
05590 dAlpha = (dAlphaP != 0.0) ?
05591 dAlphaP :
05592 (0.5 / (1.0 + cos((2.0 * dPI) / (double) (lSize - 1))));
05593 for (lLoopCntr = 0L; lLoopCntr < lSize; lLoopCntr++)
05594 {
05595 dpDest[lLoopCntr] = ((dAlpha + 1.0) / 2.0) - 0.5 *
05596 cos((2.0 * dPI * (double) lLoopCntr) / ((double) (lSize - 1))) -
05597 (dAlpha / 2.0) *
05598 cos((4.0 * dPI * (double) lLoopCntr) / ((double) (lSize - 1)));
05599 }
05600 #endif
05601 }
05602
05603
05604 void clDSPOp::WinBlackmanHarris (float *fpDest, long lSize)
05605 {
05606 long lLoopCntr;
05607
05608 for (lLoopCntr = 0L; lLoopCntr < lSize; lLoopCntr++)
05609 {
05610 fpDest[lLoopCntr] = 0.42323F -
05611 0.49855F *
05612 cos((2.0F * fPI * (float) lLoopCntr) / (float) lSize) +
05613 0.07922F *
05614 cos((4.0F * fPI * (float) lLoopCntr) / (float) lSize);
05615 }
05616 }
05617
05618
05619 void clDSPOp::WinBlackmanHarris (double *dpDest, long lSize)
05620 {
05621 long lLoopCntr;
05622
05623 for (lLoopCntr = 0L; lLoopCntr < lSize; lLoopCntr++)
05624 {
05625 dpDest[lLoopCntr] = 0.42323 -
05626 0.49855 *
05627 cos((2.0 * dPI * (double) lLoopCntr) / (double) lSize) +
05628 0.07922 *
05629 cos((4.0 * dPI * (double) lLoopCntr) / (double) lSize);
05630 }
05631 }
05632
05633
05634 void clDSPOp::WinCosTapered (float *fpDest, long lSize)
05635 {
05636 long lLoopCntr;
05637 long lM;
05638
05639 lM = Round((float) lSize / 10.0F);
05640 for (lLoopCntr = 0L; lLoopCntr < lSize; lLoopCntr++)
05641 {
05642 if ((lLoopCntr < lM) || (lLoopCntr > (lSize - lM - 1L)))
05643 {
05644 fpDest[lLoopCntr] = 0.5F * (1.0F -
05645 cos((2.0F * fPI * (float) lLoopCntr) / (float) lSize));
05646 }
05647 else
05648 {
05649 fpDest[lLoopCntr] = 1.0F;
05650 }
05651 }
05652 }
05653
05654
05655 void clDSPOp::WinCosTapered (double *dpDest, long lSize)
05656 {
05657 long lLoopCntr;
05658 long lM;
05659
05660 lM = Round((double) lSize / 10.0);
05661 for (lLoopCntr = 0L; lLoopCntr < lSize; lLoopCntr++)
05662 {
05663 if ((lLoopCntr < lM) || (lLoopCntr > (lSize - lM - 1L)))
05664 {
05665 dpDest[lLoopCntr] = 0.5 * (1.0 -
05666 cos((2.0 * dPI * (double) lLoopCntr) / (double) lSize));
05667 }
05668 else
05669 {
05670 dpDest[lLoopCntr] = 1.0;
05671 }
05672 }
05673 }
05674
05675
05676 void clDSPOp::WinCosTaperedA (float *fpVect, long lSize)
05677 {
05678 long lLoopCntr;
05679 long lM;
05680
05681 lM = Round((float) lSize / 10.0F);
05682 for (lLoopCntr = 0L; lLoopCntr < lM; lLoopCntr++)
05683 {
05684 fpVect[lLoopCntr] = 0.5F * fpVect[lLoopCntr] *
05685 (1.0F - cos((2.0F * fPI * (float) lLoopCntr) / (float) lSize));
05686 }
05687 for (lLoopCntr = (lSize - lM); lLoopCntr < lSize; lLoopCntr++)
05688 {
05689 fpVect[lLoopCntr] = 0.5F * fpVect[lLoopCntr] *
05690 (1.0F - cos((2.0F * fPI * (float) lLoopCntr) / (float) lSize));
05691 }
05692 }
05693
05694
05695 void clDSPOp::WinCosTaperedA (double *dpVect, long lSize)
05696 {
05697 long lLoopCntr;
05698 long lM;
05699
05700 lM = Round((double) lSize / 10.0);
05701 for (lLoopCntr = 0L; lLoopCntr < lM; lLoopCntr++)
05702 {
05703 dpVect[lLoopCntr] = 0.5 * dpVect[lLoopCntr] *
05704 (1.0 - cos((2.0 * dPI * (double) lLoopCntr) / (double) lSize));
05705 }
05706 for (lLoopCntr = (lSize - lM); lLoopCntr < lSize; lLoopCntr++)
05707 {
05708 dpVect[lLoopCntr] = 0.5 * dpVect[lLoopCntr] *
05709 (1.0 - cos((2.0 * dPI * (double) lLoopCntr) / (double) lSize));
05710 }
05711 }
05712
05713
05714 void clDSPOp::WinCosTaperedA (float *fpDest, const float *fpSrc, long lSize)
05715 {
05716 long lLoopCntr;
05717 long lM;
05718
05719 lM = Round((float) lSize / 10.0F);
05720 for (lLoopCntr = 0L; lLoopCntr < lSize; lLoopCntr++)
05721 {
05722 if ((lLoopCntr < lM) || (lLoopCntr > (lSize - lM)))
05723 {
05724 fpDest[lLoopCntr] = 0.5F * fpSrc[lLoopCntr] * (1.0F -
05725 cos((2.0F * fPI * (float) lLoopCntr) / (float) lSize));
05726 }
05727 else
05728 {
05729 fpDest[lLoopCntr] = fpSrc[lLoopCntr];
05730 }
05731 }
05732 }
05733
05734
05735 void clDSPOp::WinCosTaperedA (double *dpDest, const double *dpSrc, long lSize)
05736 {
05737 long lLoopCntr;
05738 long lM;
05739
05740 lM = Round((double) lSize / 10.0);
05741 for (lLoopCntr = 0L; lLoopCntr < lSize; lLoopCntr++)
05742 {
05743 if ((lLoopCntr < lM) || (lLoopCntr > (lSize - lM)))
05744 {
05745 dpDest[lLoopCntr] = 0.5 * dpSrc[lLoopCntr] * (1.0 -
05746 cos((2.0 * dPI * (double) lLoopCntr) / (double) lSize));
05747 }
05748 else
05749 {
05750 dpDest[lLoopCntr] = dpSrc[lLoopCntr];
05751 }
05752 }
05753 }
05754
05755
05756 void clDSPOp::WinExactBlackman (float *fpDest, long lSize)
05757 {
05758 long lLoopCntr;
05759 float fA0;
05760 float fA1;
05761 float fA2;
05762
05763 fA0 = 7938.0F / 18608.0F;
05764 fA1 = 9240.0F / 18608.0F;
05765 fA2 = 1430.0F / 18608.0F;
05766 for (lLoopCntr = 0L; lLoopCntr < lSize; lLoopCntr++)
05767 {
05768 fpDest[lLoopCntr] = fA0 -
05769 fA1 * cos((2.0F * fPI * (float) lLoopCntr) / (float) lSize) +
05770 fA2 * cos((4.0F * fPI * (float) lLoopCntr) / (float) lSize);
05771 }
05772 }
05773
05774
05775 void clDSPOp::WinExactBlackman (double *dpDest, long lSize)
05776 {
05777 long lLoopCntr;
05778 double dA0;
05779 double dA1;
05780 double dA2;
05781
05782 dA0 = 7938.0 / 18608.0;
05783 dA1 = 9240.0 / 18608.0;
05784 dA2 = 1430.0 / 18608.0;
05785 for (lLoopCntr = 0L; lLoopCntr < lSize; lLoopCntr++)
05786 {
05787 dpDest[lLoopCntr] = dA0 -
05788 dA1 * cos((2.0 * dPI * (double) lLoopCntr) / (double) lSize) +
05789 dA2 * cos((4.0 * dPI * (double) lLoopCntr) / (double) lSize);
05790 }
05791 }
05792
05793
05794 void clDSPOp::WinExp (float *fpDest, float fFinal, long lSize)
05795 {
05796 long lLoopCntr;
05797 float fA;
05798
05799 fA = log(fFinal + 1.0F) / ((float) lSize / 2.0F);
05800 for (lLoopCntr = 0L; lLoopCntr < (lSize / 2L + 1L); lLoopCntr++)
05801 {
05802 fpDest[lLoopCntr] = fpDest[lSize - lLoopCntr - 1L] =
05803 exp(fA * (float) lLoopCntr) - 1.0F;
05804 }
05805 }
05806
05807
05808 void clDSPOp::WinExp (double *dpDest, double dFinal, long lSize)
05809 {
05810 long lLoopCntr;
05811 double dA;
05812
05813 dA = log(dFinal + 1.0) / ((double) lSize / 2.0);
05814 for (lLoopCntr = 0L; lLoopCntr < (lSize / 2L + 1L); lLoopCntr++)
05815 {
05816 dpDest[lLoopCntr] = dpDest[lSize - lLoopCntr - 1L] =
05817 exp(dA * (double) lLoopCntr) - 1.0;
05818 }
05819 }
05820
05821
05822 void clDSPOp::WinFlatTop (float *fpDest, long lSize)
05823 {
05824 long lLoopCntr;
05825
05826 for (lLoopCntr = 0L; lLoopCntr < lSize; lLoopCntr++)
05827 {
05828 fpDest[lLoopCntr] = 0.2810639F -
05829 0.5208972F *
05830 cos((2.0F * fPI * (float) lLoopCntr) / (float) lSize) +
05831 0.1980399F *
05832 cos((4.0F * fPI * (float) lLoopCntr) / (float) lSize);
05833 }
05834 }
05835
05836
05837 void clDSPOp::WinFlatTop (double *dpDest, long lSize)
05838 {
05839 long lLoopCntr;
05840
05841 for (lLoopCntr = 0L; lLoopCntr < lSize; lLoopCntr++)
05842 {
05843 dpDest[lLoopCntr] = 0.2810639 -
05844 0.5208972 *
05845 cos((2.0 * dPI * (double) lLoopCntr) / (double) lSize) +
05846 0.1980399 *
05847 cos((4.0 * dPI * (double) lLoopCntr) / (double) lSize);
05848 }
05849 }
05850
05851
05852 void clDSPOp::WinGenericCos (float *fpDest, long lSize,
05853 const float *fpCoeff, long lCoeffCount)
05854 {
05855 long lLoopWin;
05856 long lLoopCoeff;
05857 float fWinCoeff;
05858
05859 for (lLoopWin = 0L; lLoopWin < lSize; lLoopWin++)
05860 {
05861 fWinCoeff = 0.0F;
05862 for (lLoopCoeff = 0L; lLoopCoeff < lCoeffCount; lLoopCoeff++)
05863 {
05864 fWinCoeff += pow(-1.0F, (float) lLoopCoeff) *
05865 fpCoeff[lLoopCoeff] * cos(
05866 (2.0F * fPI * (float) lLoopCoeff * (float) lLoopWin) /
05867 (float) lSize);
05868 }
05869 fpDest[lLoopWin] = fWinCoeff;
05870 }
05871 }
05872
05873
05874 void clDSPOp::WinGenericCos (double *dpDest, long lSize,
05875 const double *dpCoeff, long lCoeffCount)
05876 {
05877 long lLoopWin;
05878 long lLoopCoeff;
05879 double dWinCoeff;
05880
05881 for (lLoopWin = 0L; lLoopWin < lSize; lLoopWin++)
05882 {
05883 dWinCoeff = 0.0;
05884 for (lLoopCoeff = 0L; lLoopCoeff < lCoeffCount; lLoopCoeff++)
05885 {
05886 dWinCoeff += pow(-1.0, (double) lLoopCoeff) *
05887 dpCoeff[lLoopCoeff] * cos(
05888 (2.0 * dPI * (double) lLoopCoeff * (double) lLoopWin) /
05889 (double) lSize);
05890 }
05891 dpDest[lLoopWin] = dWinCoeff;
05892 }
05893 }
05894
05895
05896 void clDSPOp::WinHamming (float *fpDest, long lSize)
05897 {
05898 #ifdef DSP_IPP
05899 ippsSet_32f(1.0F, fpDest, lSize);
05900 ippsWinHamming_32f_I(fpDest, lSize);
05901 #else
05902 long lLoopCntr;
05903
05904 for (lLoopCntr = 0L; lLoopCntr < lSize; lLoopCntr++)
05905 {
05906 fpDest[lLoopCntr] = 0.54F -
05907 0.46F * cos((2.0F * fPI * (float) lLoopCntr) / (float) lSize);
05908 }
05909 #endif
05910 }
05911
05912
05913 void clDSPOp::WinHamming (double *dpDest, long lSize)
05914 {
05915 #ifdef DSP_IPP
05916 ippsSet_64f(1.0, dpDest, lSize);
05917 ippsWinHamming_64f_I(dpDest, lSize);
05918 #else
05919 long lLoopCntr;
05920
05921 for (lLoopCntr = 0L; lLoopCntr < lSize; lLoopCntr++)
05922 {
05923 dpDest[lLoopCntr] = 0.54 -
05924 0.46 * cos((2.0 * dPI * (double) lLoopCntr) / (double) lSize);
05925 }
05926 #endif
05927 }
05928
05929
05930 void clDSPOp::WinHanning (float *fpDest, long lSize)
05931 {
05932 #ifdef DSP_IPP
05933 ippsSet_32f(1.0F, fpDest, lSize);
05934 ippsWinHann_32f_I(fpDest, lSize);
05935 #else
05936 long lLoopCntr;
05937
05938 for (lLoopCntr = 0L; lLoopCntr < lSize; lLoopCntr++)
05939 {
05940 fpDest[lLoopCntr] = 0.5F -
05941 0.5F * cos((2.0F * fPI * (float) lLoopCntr) / (float) lSize);
05942 }
05943 #endif
05944 }
05945
05946
05947 void clDSPOp::WinHanning (double *dpDest, long lSize)
05948 {
05949 #ifdef DPS_IPP
05950 ippsSet_64f(1.0, dpDest, lSize);
05951 ippsWinHann_64f_I(dpDest, lSize);
05952 #else
05953 long lLoopCntr;
05954
05955 for (lLoopCntr = 0L; lLoopCntr < lSize; lLoopCntr++)
05956 {
05957 dpDest[lLoopCntr] = 0.5 -
05958 0.5 * cos((2.0 * dPI * (double) lLoopCntr) / (double) lSize);
05959 }
05960 #endif
05961 }
05962
05963
05964 void clDSPOp::WinKaiser (float *fpDest, float fBeta, long lSize)
05965 {
05966 #ifdef DSP_IPP
05967 ippsSet_32f(1.0F, fpDest, lSize);
05968 ippsWinKaiser_32f_I(fpDest, lSize,
05969 fBeta * (1.0f / ((float) (lSize - 1) / 2.0f)));
05970 #else
05971 long lLoopCntr;
05972 float fA;
05973
05974 for (lLoopCntr = 0L; lLoopCntr < lSize; lLoopCntr++)
05975 {
05976 fA = fabs(1.0F - (2.0F * (float) lLoopCntr) / (float) lSize);
05977 fpDest[lLoopCntr] =
05978 ModZeroBessel(fBeta * sqrt(1.0F - fA * fA)) /
05979 ModZeroBessel(fBeta);
05980 }
05981 #endif
05982 }
05983
05984
05985 void clDSPOp::WinKaiser (double *dpDest, double dBeta, long lSize)
05986 {
05987 #ifdef DSP_IPP
05988 ippsSet_64f(1.0, dpDest, lSize);
05989 ippsWinKaiser_64f_I(dpDest, lSize,
05990 dBeta * (1.0 / ((double) (lSize - 1) / 2.0)));
05991 #else
05992 long lLoopCntr;
05993 double dA;
05994
05995 for (lLoopCntr = 0L; lLoopCntr < lSize; lLoopCntr++)
05996 {
05997 dA = fabs(1.0 - (2.0 * (double) lLoopCntr) / (double) lSize);
05998 dpDest[lLoopCntr] =
05999 ModZeroBessel(dBeta * sqrt(1.0 - dA * dA)) /
06000 ModZeroBessel(dBeta);
06001 }
06002 #endif
06003 }
06004
06005
06006 void clDSPOp::WinKaiserBessel (float *fpDest, float fAlpha, long lSize)
06007 {
06008 long lLoopCntr;
06009 float fHalfN;
06010 float fPiAlpha;
06011
06012 fHalfN = (float) lSize / 2.0F;
06013 fPiAlpha = fPI * fAlpha;
06014 for (lLoopCntr = 0L; lLoopCntr < lSize; lLoopCntr++)
06015 {
06016 fpDest[lLoopCntr] =
06017 ModZeroBessel(fPiAlpha *
06018 sqrt(1.0F - pow(((float) lLoopCntr - fHalfN) / fHalfN, 2.0F))) /
06019 ModZeroBessel(fPiAlpha);
06020 }
06021 }
06022
06023
06024 void clDSPOp::WinKaiserBessel (double *dpDest, double dAlpha, long lSize)
06025 {
06026 long lLoopCntr;
06027 double dHalfN;
06028 double dPiAlpha;
06029
06030 dHalfN = (double) lSize / 2.0;
06031 dPiAlpha = dPI * dAlpha;
06032 for (lLoopCntr = 0L; lLoopCntr < lSize; lLoopCntr++)
06033 {
06034 dpDest[lLoopCntr] =
06035 ModZeroBessel(dPiAlpha *
06036 sqrt(1.0 - pow(((double) lLoopCntr - dHalfN) / dHalfN, 2.0))) /
06037 ModZeroBessel(dPiAlpha);
06038 }
06039 }
06040
06041
06042 void clDSPOp::WinTukey (float *fpDest, long lSize)
06043 {
06044 long lLoopCntr;
06045 long lHalfSize;
06046
06047 lHalfSize = lSize / 2L;
06048 for (lLoopCntr = 0L; lLoopCntr < lSize; lLoopCntr++)
06049 {
06050 fpDest[lLoopCntr] = 0.5F *
06051 (1.0F + cos((float) (lLoopCntr - lHalfSize) * fPI / lHalfSize));
06052 }
06053 }
06054
06055
06056 void clDSPOp::WinTukey (double *dpDest, long lSize)
06057 {
06058 long lLoopCntr;
06059 long lHalfSize;
06060
06061 lHalfSize = lSize / 2L;
06062 for (lLoopCntr = 0L; lLoopCntr < lSize; lLoopCntr++)
06063 {
06064 dpDest[lLoopCntr] = 0.5 *
06065 (1.0 + cos((float) (lLoopCntr - lHalfSize) * dPI / lHalfSize));
06066 }
06067 }
06068
06069
06070 void clDSPOp::WinDolphChebyshev (float *fpDest, float fGamma, long lSize)
06071 {
06072 long lHalfSize;
06073 long lLoopCntr;
06074 long lSumCntr;
06075 float fScale;
06076 float fInvGamma;
06077 float fX0;
06078 float fThetaS;
06079 float fChebyshevSum;
06080 float fTheta;
06081 float fTheta2;
06082 float fMin;
06083 float fMax;
06084
06085 lHalfSize = lSize / 2L;
06086 fScale = 1.0F / (float) lSize;
06087 fInvGamma = 1.0F / fGamma;
06088 fX0 = coshf((1.0F / (float) (lSize - 1)) * acoshf(fInvGamma));
06089 fThetaS = 2.0F * acosf(1.0F / fX0);
06090 for (lLoopCntr = 0L; lLoopCntr < lSize; lLoopCntr++)
06091 {
06092 fChebyshevSum = 0.0F;
06093 for (lSumCntr = 1L; lSumCntr <= lHalfSize; lSumCntr++)
06094 {
06095 fTheta = (2.0F * fPI * (float) lSumCntr) / (float) lSize;
06096 fTheta2 = (fPI * (float) (2L * lLoopCntr - lSize + 1L)) /
06097 (float) lSize;
06098 fChebyshevSum +=
06099 ChebyshevPolynom((float) (lSize - 1L),
06100 (float) (fX0 * cosf(fTheta / 2.0F))) *
06101 cosf((float) lSumCntr * fTheta2);
06102 }
06103 fpDest[lLoopCntr] = fScale *
06104 (1.0F + 2.0F * fGamma * fChebyshevSum);
06105 }
06106
06107 MinMax(&fMin, &fMax, fpDest, lSize);
06108 fScale = 1.0F / fMax;
06109 Mul(fpDest, fScale, lSize);
06110 }
06111
06112
06113 void clDSPOp::WinDolphChebyshev (double *dpDest, double dGamma, long lSize)
06114 {
06115 long lHalfSize;
06116 long lLoopCntr;
06117 long lSumCntr;
06118 double dScale;
06119 double dInvGamma;
06120 double dX0;
06121 double dThetaS;
06122 double dChebyshevSum;
06123 double dTheta;
06124 double dTheta2;
06125 double dMin;
06126 double dMax;
06127
06128 lHalfSize = lSize / 2L;
06129 dScale = 1.0F / (double) lSize;
06130 dInvGamma = 1.0F / dGamma;
06131 dX0 = cosh((1.0 / (double) (lSize - 1)) * acosh(dInvGamma));
06132 dThetaS = 2.0 * acos(1.0 / dX0);
06133 for (lLoopCntr = 0L; lLoopCntr < lSize; lLoopCntr++)
06134 {
06135 dChebyshevSum = 0.0;
06136 for (lSumCntr = 1L; lSumCntr <= lHalfSize; lSumCntr++)
06137 {
06138 dTheta = (2.0 * dPI * (double) lSumCntr) / (double) lSize;
06139 dTheta2 = (dPI * (double) (2L * lLoopCntr - lSize + 1L)) /
06140 (double) lSize;
06141 dChebyshevSum +=
06142 ChebyshevPolynom((double) (lSize - 1L),
06143 dX0 * cos(dTheta / 2.0)) *
06144 cos((double) lSumCntr * dTheta2);
06145 }
06146 dpDest[lLoopCntr] = dScale *
06147 (1.0 + 2.0 * dGamma * dChebyshevSum);
06148 }
06149
06150 MinMax(&dMin, &dMax, dpDest, lSize);
06151 dScale = 1.0 / dMax;
06152 Mul(dpDest, dScale, lSize);
06153 }
06154
06155
06156 void clDSPOp::Mix (float *fpDest, const float *fpSrc, long lCount)
06157 {
06158 long lLoopCntr;
06159 long lSrcIdx;
06160
06161 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
06162 {
06163 lSrcIdx = lLoopCntr << 1;
06164 fpDest[lLoopCntr] = (fpSrc[lSrcIdx] + fpSrc[lSrcIdx + 1L]) * 0.5F;
06165 }
06166 }
06167
06168
06169 void clDSPOp::Mix (double *dpDest, const double *dpSrc, long lCount)
06170 {
06171 long lLoopCntr;
06172 long lSrcIdx;
06173
06174 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
06175 {
06176 lSrcIdx = lLoopCntr << 1;
06177 dpDest[lLoopCntr] = (dpSrc[lSrcIdx] + dpSrc[lSrcIdx + 1L]) * 0.5;
06178 }
06179 }
06180
06181
06182 void clDSPOp::Mix (float *fpDest, const float *fpSrc1, const float *fpSrc2,
06183 long lCount)
06184 {
06185 long lLoopCntr;
06186
06187 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
06188 {
06189 fpDest[lLoopCntr] = (fpSrc1[lLoopCntr] + fpSrc2[lLoopCntr]) * 0.5F;
06190 }
06191 }
06192
06193
06194 void clDSPOp::Mix (double *dpDest, const double *dpSrc1, const double *dpSrc2,
06195 long lCount)
06196 {
06197 long lLoopCntr;
06198
06199 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
06200 {
06201 dpDest[lLoopCntr] = (dpSrc1[lLoopCntr] + dpSrc2[lLoopCntr]) * 0.5;
06202 }
06203 }
06204
06205
06206 void clDSPOp::Mix (float *fpDest, const float *fpSrc, long lChCount,
06207 long lDestCount)
06208 {
06209 long lDestCntr;
06210 long lSrcCntr;
06211 long lSrcMax;
06212 float fMix;
06213 float fScaler;
06214
06215 fScaler = 1.0F / (float) lChCount;
06216 for (lDestCntr = 0L; lDestCntr < lDestCount; lDestCntr++)
06217 {
06218 fMix = 0.0F;
06219 lSrcMax = lDestCntr * lChCount + lChCount;
06220 for (lSrcCntr = lDestCntr * lChCount; lSrcCntr < lSrcMax; lSrcCntr++)
06221 {
06222 fMix += fpSrc[lSrcCntr];
06223 }
06224 fpDest[lDestCntr] = fMix * fScaler;
06225 }
06226 }
06227
06228
06229 void clDSPOp::Mix (double *dpDest, const double *dpSrc, long lChCount,
06230 long lDestCount)
06231 {
06232 long lDestCntr;
06233 long lSrcCntr;
06234 long lSrcMax;
06235 double dMix;
06236 double dScaler;
06237
06238 dScaler = 1.0 / (double) lChCount;
06239 for (lDestCntr = 0L; lDestCntr < lDestCount; lDestCntr++)
06240 {
06241 dMix = 0.0;
06242 lSrcMax = lDestCntr * lChCount + lChCount;
06243 for (lSrcCntr = lDestCntr * lChCount; lSrcCntr < lSrcMax; lSrcCntr++)
06244 {
06245 dMix += dpSrc[lSrcCntr];
06246 }
06247 dpDest[lDestCntr] = dMix * dScaler;
06248 }
06249 }
06250
06251
06252 void clDSPOp::Spatialize (float *fpDest1, float *fpDest2,
06253 const float *fpSrc, long lCount)
06254 {
06255 long lLoopCntr;
06256 float fTemp;
06257
06258 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
06259 {
06260 fTemp = fpSrc[lLoopCntr];
06261 fpDest1[lLoopCntr] = fTemp;
06262 fpDest2[lLoopCntr] = -fTemp;
06263 }
06264 }
06265
06266
06267 void clDSPOp::Spatialize (double *dpDest1, double *dpDest2,
06268 const double *dpSrc, long lCount)
06269 {
06270 long lLoopCntr;
06271 double dTemp;
06272
06273 for (lLoopCntr = 0L; lLoopCntr < lCount; lLoopCntr++)
06274 {
06275 dTemp = dpSrc[lLoopCntr];
06276 dpDest1[lLoopCntr] = dTemp;
06277 dpDest2[lLoopCntr] = -dTemp;
06278 }
06279 }
06280
06281
06282 void clDSPOp::Spatialize (float *fpDest, const float *fpSrc, long lCount)
06283 {
06284 long lSrcCntr;
06285 long lDestIdx;
06286 float fTemp;
06287
06288 for (lSrcCntr = 0L; lSrcCntr < lCount; lSrcCntr++)
06289 {
06290 fTemp = fpSrc[lSrcCntr];
06291 lDestIdx = lSrcCntr << 1;
06292 fpDest[lDestIdx] = fTemp;
06293 fpDest[lDestIdx + 1L] = -fTemp;
06294 }
06295 }
06296
06297
06298 void clDSPOp::Spatialize (double *dpDest, const double *dpSrc, long lCount)
06299 {
06300 long lSrcCntr;
06301 long lDestIdx;
06302 double dTemp;
06303
06304 for (lSrcCntr = 0L; lSrcCntr < lCount; lSrcCntr++)
06305 {
06306 dTemp = dpSrc[lSrcCntr];
06307 lDestIdx = lSrcCntr << 1;
06308 dpDest[lDestIdx] = dTemp;
06309 dpDest[lDestIdx + 1L] = -dTemp;
06310 }
06311 }
06312
06313
06314 void clDSPOp::Extract (float *fpDest, const float *fpSrc, long lChannel,
06315 long lChCount, long lSrcLength)
06316 {
06317 long lLoopCntr;
06318 long lMax;
06319
06320 lMax = lSrcLength / lChCount;
06321 for (lLoopCntr = 0; lLoopCntr < lMax; lLoopCntr++)
06322 {
06323 fpDest[lLoopCntr] = fpSrc[lLoopCntr * lChCount + lChannel];
06324 }
06325 }
06326
06327
06328 void clDSPOp::Extract (double *dpDest, const double *dpSrc, long lChannel,
06329 long lChCount, long lSrcLength)
06330 {
06331 long lLoopCntr;
06332 long lMax;
06333
06334 lMax = lSrcLength / lChCount;
06335 for (lLoopCntr = 0; lLoopCntr < lMax; lLoopCntr++)
06336 {
06337 dpDest[lLoopCntr] = dpSrc[lLoopCntr * lChCount + lChannel];
06338 }
06339 }
06340
06341
06342 void clDSPOp::Pack (float *fpDest, const float *fpSrc, long lChannel,
06343 long lChCount, long lSrcLength)
06344 {
06345 long lLoopCntr;
06346
06347 for (lLoopCntr = 0; lLoopCntr < lSrcLength; lLoopCntr++)
06348 {
06349 fpDest[lLoopCntr * lChCount + lChannel] = fpSrc[lLoopCntr];
06350 }
06351 }
06352
06353
06354 void clDSPOp::Pack (double *dpDest, const double *dpSrc, long lChannel,
06355 long lChCount, long lSrcLength)
06356 {
06357 long lLoopCntr;
06358
06359 for (lLoopCntr = 0; lLoopCntr < lSrcLength; lLoopCntr++)
06360 {
06361 dpDest[lLoopCntr * lChCount + lChannel] = dpSrc[lLoopCntr];
06362 }
06363 }
06364
06365
06366 long clDSPOp::ReBuffer (float *fpDest, const float *fpSrc, long lDestSize,
06367 long lSrcSize)
06368 {
06369 long lDestCount;
06370 long lSrcCount;
06371 long lCopyCount;
06372
06373 lDestCount = lDestSize - lPrevDestCount;
06374 lSrcCount = lSrcSize - lPrevSrcCount;
06375 lCopyCount = (lDestCount < lSrcCount) ? lDestCount : lSrcCount;
06376 Copy(&fpDest[lPrevDestCount], &fpSrc[lPrevSrcCount], lCopyCount);
06377 lPrevDestCount += lCopyCount;
06378 lPrevSrcCount += lCopyCount;
06379 if ((lPrevDestCount == lDestSize) && (lPrevSrcCount == lSrcSize))
06380 {
06381 lPrevDestCount = 0L;
06382 lPrevSrcCount = 0L;
06383 return 1;
06384 }
06385 else if (lPrevDestCount == lDestSize)
06386 {
06387 lPrevDestCount = 0L;
06388 return 2;
06389 }
06390 else if (lPrevSrcCount == lSrcSize)
06391 {
06392 lPrevSrcCount = 0L;
06393 return 0;
06394 }
06395 else
06396 {
06397 fprintf(stderr, "clDSPOp::ReBuffer(): Fatal error; bug found\n");
06398 }
06399 return 0;
06400 }
06401
06402
06403 long clDSPOp::ReBuffer (double *dpDest, const double *dpSrc, long lDestSize,
06404 long lSrcSize)
06405 {
06406 long lDestCount;
06407 long lSrcCount;
06408 long lCopyCount;
06409
06410 lDestCount = lDestSize - lPrevDestCount;
06411 lSrcCount = lSrcSize - lPrevSrcCount;
06412 lCopyCount = (lDestCount < lSrcCount) ? lDestCount : lSrcCount;
06413 Copy(&dpDest[lPrevDestCount], &dpSrc[lPrevSrcCount], lCopyCount);
06414 lPrevDestCount += lCopyCount;
06415 lPrevSrcCount += lCopyCount;
06416 if (lPrevDestCount == lDestSize && lPrevSrcCount == lSrcSize)
06417 {
06418 lPrevDestCount = 0L;
06419 lPrevSrcCount = 0L;
06420 return 1;
06421 }
06422 else if (lPrevDestCount == lDestSize)
06423 {
06424 lPrevDestCount = 0L;
06425 return 2;
06426 }
06427 else if (lPrevSrcCount == lSrcSize)
06428 {
06429 lPrevSrcCount = 0L;
06430 return 0;
06431 }
06432 else
06433 {
06434 fprintf(stderr, "clDSPOp::ReBuffer(): Fatal error; bug found\n");
06435 }
06436 return 0;
06437 }
06438
06439
06440
06441
06442
06443 void clDSPOp::FIRAllocate (const float *fpCoeff, long lCount)
06444 {
06445 #ifdef DSP_IPP
06446 iFIRDlyIdx = 0;
06447 lFIRLength = lCount;
06448 FIRCoeff.Size(lCount * sizeof(float));
06449 FIRBuf.Size(lCount * 2 * sizeof(float));
06450 Copy((float *) FIRCoeff, fpCoeff, lCount);
06451 Zero((float *) FIRBuf, lCount * 2);
06452 #else
06453 lFIRLength = lCount;
06454 FIRCoeff.Size(lCount * sizeof(float));
06455 FIRBuf.Size(lCount * sizeof(float));
06456 Copy((float *) FIRCoeff, fpCoeff, lCount);
06457 Zero((float *) FIRBuf, lCount);
06458 #endif
06459 }
06460
06461
06462 void clDSPOp::FIRAllocate (const double *dpCoeff, long lCount)
06463 {
06464 #ifdef DSP_IPP
06465 iFIRDlyIdx = 0;
06466 lFIRLength = lCount;
06467 FIRCoeff.Size(lCount * sizeof(double));
06468 FIRBuf.Size(lCount * 2 * sizeof(double));
06469 Copy((double *) FIRCoeff, dpCoeff, lCount);
06470 Zero((double *) FIRBuf, lCount * 2);
06471 #else
06472 lFIRLength = lCount;
06473 FIRCoeff.Size(lCount * sizeof(double));
06474 FIRBuf.Size(lCount * sizeof(double));
06475 Copy((double *) FIRCoeff, dpCoeff, lCount);
06476 Zero((double *) FIRBuf, lCount);
06477 #endif
06478 }
06479
06480
06481 void clDSPOp::FIRFilter (float *fpVect, long lCount)
06482 {
06483 #ifdef DSP_IPP
06484 ippsFIR_Direct_32f_I(fpVect, lCount, FIRCoeff, lFIRLength,
06485 FIRBuf, &iFIRDlyIdx);
06486 #else
06487 long lSrcCntr;
06488 long lConvCntr;
06489 long lDestCntr;
06490 long lMax;
06491 float fTempVal;
06492 float *fpFIRCoeff = FIRCoeff;
06493 float *fpFIRBuf = FIRBuf;
06494 float *fpFIRWork;
06495
06496 fpFIRWork = (float *) FIRWork.Size((lCount + lFIRLength) * sizeof(float));
06497 Copy(fpFIRWork, fpFIRBuf, lFIRLength);
06498 Copy(&fpFIRWork[lFIRLength], fpVect, lCount);
06499 lMax = lCount + lFIRLength;
06500 #ifdef DSP_X86
06501 if (bHave3DNow)
06502 {
06503 dsp_x86_3dnow_firf(fpVect, fpFIRWork, lCount,
06504 fpFIRCoeff, lFIRLength);
06505 }
06506 else
06507 #endif
06508 {
06509 lDestCntr = 0L;
06510 for (lSrcCntr = lFIRLength; lSrcCntr < lMax; lSrcCntr++)
06511 {
06512 fTempVal = 0.0F;
06513 for (lConvCntr = 0L; lConvCntr < lFIRLength; lConvCntr++)
06514 {
06515 #ifndef _ISOC9X_SOURCE
06516 fTempVal += fpFIRCoeff[lConvCntr] *
06517 fpFIRWork[lSrcCntr - lConvCntr];
06518 #else
06519 fTempVal = fmaf(fpFIRCoeff[lConvCntr],
06520 fpFIRWork[lSrcCntr - lConvCntr], fTempVal);
06521 #endif
06522 }
06523 fpVect[lDestCntr++] = fTempVal;
06524 }
06525 }
06526 Copy(fpFIRBuf, &fpFIRWork[lMax - lFIRLength], lFIRLength);
06527 #endif
06528 }
06529
06530
06531 void clDSPOp::FIRFilter (double *dpVect, long lCount)
06532 {
06533 #ifdef DSP_IPP
06534 ippsFIR_Direct_64f_I(dpVect, lCount, FIRCoeff, lFIRLength,
06535 FIRBuf, &iFIRDlyIdx);
06536 #else
06537 long lSrcCntr;
06538 long lConvCntr;
06539 long lDestCntr;
06540 long lMax;
06541 double dTempVal;
06542 double *dpFIRCoeff = FIRCoeff;
06543 double *dpFIRBuf = FIRBuf;
06544 double *dpFIRWork;
06545
06546 dpFIRWork = (double *) FIRWork.Size((lCount + lFIRLength) * sizeof(double));
06547 Copy(dpFIRWork, dpFIRBuf, lFIRLength);
06548 Copy(&dpFIRWork[lFIRLength], dpVect, lCount);
06549 lDestCntr = 0L;
06550 lMax = lCount + lFIRLength;
06551 for (lSrcCntr = lFIRLength; lSrcCntr < lMax; lSrcCntr++)
06552 {
06553 dTempVal = 0.0;
06554 for (lConvCntr = 0L; lConvCntr < lFIRLength; lConvCntr++)
06555 {
06556 #ifndef _ISOC9X_SOURCE
06557 dTempVal += dpFIRCoeff[lConvCntr] *
06558 dpFIRWork[lSrcCntr - lConvCntr];
06559 #else
06560 dTempVal = fma(dpFIRCoeff[lConvCntr],
06561 dpFIRWork[lSrcCntr - lConvCntr], dTempVal);
06562 #endif
06563 }
06564 dpVect[lDestCntr++] = dTempVal;
06565 }
06566 Copy(dpFIRBuf, &dpFIRWork[lMax - lFIRLength], lFIRLength);
06567 #endif
06568 }
06569
06570
06571 void clDSPOp::FIRFilter (float *fpDest, const float *fpSrc, long lCount)
06572 {
06573 #ifdef DSP_IPP
06574 ippsFIR_Direct_32f(fpSrc, fpDest, lCount, FIRCoeff, lFIRLength,
06575 FIRBuf, &iFIRDlyIdx);
06576 #else
06577 long lSrcCntr;
06578 long lConvCntr;
06579 long lDestCntr;
06580 long lMax;
06581 float fTempVal;
06582 float *fpFIRCoeff = FIRCoeff;
06583 float *fpFIRBuf = FIRBuf;
06584 float *fpFIRWork;
06585
06586 fpFIRWork = (float *) FIRWork.Size((lCount + lFIRLength) * sizeof(float));
06587 Copy(fpFIRWork, fpFIRBuf, lFIRLength);
06588 Copy(&fpFIRWork[lFIRLength], fpSrc, lCount);
06589 lMax = lCount + lFIRLength;
06590 #ifdef DSP_X86
06591 if (bHave3DNow)
06592 {
06593 dsp_x86_3dnow_firf(fpDest, fpFIRWork, lCount,
06594 fpFIRCoeff, lFIRLength);
06595 }
06596 else
06597 #endif
06598 {
06599 lDestCntr = 0L;
06600 for (lSrcCntr = lFIRLength; lSrcCntr < lMax; lSrcCntr++)
06601 {
06602 fTempVal = 0.0F;
06603 for (lConvCntr = 0L; lConvCntr < lFIRLength; lConvCntr++)
06604 {
06605 #ifndef _ISOC9X_SOURCE
06606 fTempVal += fpFIRCoeff[lConvCntr] *
06607 fpFIRWork[lSrcCntr - lConvCntr];
06608 #else
06609 fTempVal = fmaf(fpFIRCoeff[lConvCntr],
06610 fpFIRWork[lSrcCntr - lConvCntr], fTempVal);
06611 #endif
06612 }
06613 fpDest[lDestCntr++] = fTempVal;
06614 }
06615 }
06616 Copy(fpFIRBuf, &fpFIRWork[lMax - lFIRLength], lFIRLength);
06617 #endif
06618 }
06619
06620
06621 void clDSPOp::FIRFilter (double *dpDest, const double *dpSrc, long lCount)
06622 {
06623 #ifdef DSP_IPP
06624 ippsFIR_Direct_64f(dpSrc, dpDest, lCount, FIRCoeff, lFIRLength,
06625 FIRBuf, &iFIRDlyIdx);
06626 #else
06627 long lSrcCntr;
06628 long lConvCntr;
06629 long lDestCntr;
06630 long lMax;
06631 double dTempVal;
06632 double *dpFIRCoeff = FIRCoeff;
06633 double *dpFIRBuf = FIRBuf;
06634 double *dpFIRWork;
06635
06636 dpFIRWork = (double *) FIRWork.Size((lCount + lFIRLength) * sizeof(double));
06637 Copy(dpFIRWork, dpFIRBuf, lFIRLength);
06638 Copy(&dpFIRWork[lFIRLength], dpSrc, lCount);
06639 lDestCntr = 0L;
06640 lMax = lCount + lFIRLength;
06641 for (lSrcCntr = lFIRLength; lSrcCntr < lMax; lSrcCntr++)
06642 {
06643 dTempVal = 0.0;
06644 for (lConvCntr = 0L; lConvCntr < lFIRLength; lConvCntr++)
06645 {
06646 #ifndef _ISOC9X_SOURCE
06647 dTempVal += dpFIRCoeff[lConvCntr] *
06648 dpFIRWork[lSrcCntr - lConvCntr];
06649 #else
06650 dTempVal = fma(dpFIRCoeff[lConvCntr],
06651 dpFIRWork[lSrcCntr - lConvCntr], dTempVal);
06652 #endif
06653 }
06654 dpDest[lDestCntr++] = dTempVal;
06655 }
06656 Copy(dpFIRBuf, &dpFIRWork[lMax - lFIRLength], lFIRLength);
06657 #endif
06658 }
06659
06660
06661 void clDSPOp::FIRFilterF (float *fpDest, float *fpSrc, long lCount)
06662 {
06663 long lSrcCntr;
06664 long lConvCntr;
06665 long lDestCntr;
06666 long lMax;
06667 float fTempVal;
06668 float *fpFIRCoeff = FIRCoeff;
06669
06670 lDestCntr = 0L;
06671 lMax = lCount + lFIRLength;
06672 for (lSrcCntr = lFIRLength; lSrcCntr < lMax; lSrcCntr++)
06673 {
06674 fTempVal = 0.0F;
06675 for (lConvCntr = 0L; lConvCntr < lFIRLength; lConvCntr++)
06676 {
06677 #ifndef _ISOC9X_SOURCE
06678 fTempVal += fpFIRCoeff[lConvCntr] *
06679 fpSrc[lSrcCntr - lConvCntr];
06680 #else
06681 fTempVal = fmaf(fpFIRCoeff[lConvCntr],
06682 fpSrc[lSrcCntr - lConvCntr], fTempVal);
06683 #endif
06684 }
06685 fpDest[lDestCntr++] = fTempVal;
06686 }
06687 Copy(fpSrc, &fpSrc[lMax - lFIRLength], lFIRLength);
06688 }
06689
06690
06691 void clDSPOp::FIRFilterF (double *dpDest, double *dpSrc, long lCount)
06692 {
06693 long lSrcCntr;
06694 long lConvCntr;
06695 long lDestCntr;
06696 long lMax;
06697 double dTempVal;
06698 double *dpFIRCoeff = FIRCoeff;
06699
06700 lDestCntr = 0L;
06701 lMax = lCount + lFIRLength;
06702 for (lSrcCntr = lFIRLength; lSrcCntr < lMax; lSrcCntr++)
06703 {
06704 dTempVal = 0.0;
06705 for (lConvCntr = 0L; lConvCntr < lFIRLength; lConvCntr++)
06706 {
06707 #ifndef _ISOC9X_SOURCE
06708 dTempVal += dpFIRCoeff[lConvCntr] *
06709 dpSrc[lSrcCntr - lConvCntr];
06710 #else
06711 dTempVal = fma(dpFIRCoeff[lConvCntr],
06712 dpSrc[lSrcCntr - lConvCntr], dTempVal);
06713 #endif
06714 }
06715 dpDest[lDestCntr++] = dTempVal;
06716 }
06717 Copy(dpSrc, &dpSrc[lMax - lFIRLength], lFIRLength);
06718 }
06719
06720
06721 void clDSPOp::FIRFree ()
06722 {
06723 FIRCoeff.Free();
06724 FIRBuf.Free();
06725 }
06726
06727
06728 void clDSPOp::IIRInitialize (const float *fpCoeffs)
06729 {
06730 Copy(fpIIR_C, fpCoeffs, 5);
06731 }
06732
06733
06734 void clDSPOp::IIRInitialize (const double *dpCoeffs)
06735 {
06736 Copy(dpIIR_C, dpCoeffs, 5);
06737 }
06738
06739
06740 void clDSPOp::IIRFilter (float *fpVect, long lCount)
06741 {
06742 long lLoopCntr;
06743 float fBXk;
06744 float fAYk;
06745
06746 #ifdef DSP_X86
06747 if (bHave3DNow)
06748 {
06749 dsp_x86_3dnow_iirf(fpVect, lCount, fpIIR_C, fpIIR_X, fpIIR_Y);
06750 }
06751 else
06752 #endif
06753 {
06754 for (lLoopCntr = 0; lLoopCntr < lCount; lLoopCntr++)
06755 {
06756 fpIIR_X[0] = fpIIR_X[1];
06757 fpIIR_X[1] = fpIIR_X[2];
06758 fpIIR_X[2] = fpVect[lLoopCntr];
06759 fBXk =
06760 fpIIR_C[0] * fpIIR_X[2] +
06761 fpIIR_C[1] * fpIIR_X[1] +
06762 fpIIR_C[2] * fpIIR_X[0];
06763 fAYk =
06764 fpIIR_C[3] * fpIIR_Y[1] +
06765 fpIIR_C[4] * fpIIR_Y[0];
06766 fpVect[lLoopCntr] = fAYk + fBXk;
06767 fpIIR_Y[0] = fpIIR_Y[1];
06768 fpIIR_Y[1] = fpVect[lLoopCntr];
06769 }
06770 }
06771 }
06772
06773
06774 void clDSPOp::IIRFilter (double *dpVect, long lCount)
06775 {
06776 long lLoopCntr;
06777 double dBXk;
06778 double dAYk;
06779
06780 for (lLoopCntr = 0; lLoopCntr < lCount; lLoopCntr++)
06781 {
06782 dpIIR_X[0] = dpIIR_X[1];
06783 dpIIR_X[1] = dpIIR_X[2];
06784 dpIIR_X[2] = dpVect[lLoopCntr];
06785 dBXk =
06786 dpIIR_C[0] * dpIIR_X[2] +
06787 dpIIR_C[1] * dpIIR_X[1] +
06788 dpIIR_C[2] * dpIIR_X[0];
06789 dAYk =
06790 dpIIR_C[3] * dpIIR_Y[1] +
06791 dpIIR_C[4] * dpIIR_Y[0];
06792 dpVect[lLoopCntr] = dAYk + dBXk;
06793 dpIIR_Y[0] = dpIIR_Y[1];
06794 dpIIR_Y[1] = dpVect[lLoopCntr];
06795 }
06796 }
06797
06798
06799 void clDSPOp::IIRFilter (float *fpDest, const float *fpSrc, long lCount)
06800 {
06801 long lLoopCntr;
06802 float fBXk;
06803 float fAYk;
06804
06805 #ifdef DSP_X86
06806 if (bHave3DNow)
06807 {
06808 dsp_x86_3dnow_iirf_nip(fpDest, fpSrc, lCount,
06809 fpIIR_C, fpIIR_X, fpIIR_Y);
06810 }
06811 else
06812 #endif
06813 {
06814 for (lLoopCntr = 0; lLoopCntr < lCount; lLoopCntr++)
06815 {
06816 fpIIR_X[0] = fpIIR_X[1];
06817 fpIIR_X[1] = fpIIR_X[2];
06818 fpIIR_X[2] = fpSrc[lLoopCntr];
06819 fBXk =
06820 fpIIR_C[0] * fpIIR_X[2] +
06821 fpIIR_C[1] * fpIIR_X[1] +
06822 fpIIR_C[2] * fpIIR_X[0];
06823 fAYk =
06824 fpIIR_C[3] * fpIIR_Y[1] +
06825 fpIIR_C[4] * fpIIR_Y[0];
06826 fpDest[lLoopCntr] = fAYk + fBXk;
06827 fpIIR_Y[0] = fpIIR_Y[1];
06828 fpIIR_Y[1] = fpDest[lLoopCntr];
06829 }
06830 }
06831 }
06832
06833
06834 void clDSPOp::IIRFilter (double *dpDest, const double *dpSrc, long lCount)
06835 {
06836 long lLoopCntr;
06837 double dBXk;
06838 double dAYk;
06839
06840 for (lLoopCntr = 0; lLoopCntr < lCount; lLoopCntr++)
06841 {
06842 dpIIR_X[0] = dpIIR_X[1];
06843 dpIIR_X[1] = dpIIR_X[2];
06844 dpIIR_X[2] = dpSrc[lLoopCntr];
06845 dBXk =
06846 dpIIR_C[0] * dpIIR_X[2] +
06847 dpIIR_C[1] * dpIIR_X[1] +
06848 dpIIR_C[2] * dpIIR_X[0];
06849 dAYk =
06850 dpIIR_C[3] * dpIIR_Y[1] +
06851 dpIIR_C[4] * dpIIR_Y[0];
06852 dpDest[lLoopCntr] = dAYk + dBXk;
06853 dpIIR_Y[0] = dpIIR_Y[1];
06854 dpIIR_Y[1] = dpDest[lLoopCntr];
06855 }
06856 }
06857
06858
06859 void clDSPOp::IIRClear ()
06860 {
06861 Zero(fpIIR_X, 3);
06862 Zero(fpIIR_Y, 2);
06863 Zero(dpIIR_X, 3);
06864 Zero(dpIIR_Y, 2);
06865 }
06866
06867
06868 void clDSPOp::FFTInitialize(long lSize, bool bIsReal)
06869 {
06870 #if defined(DSP_IPP)
06871 int iSWorkSize;
06872 int iDWorkSize;
06873 int iOrder;
06874
06875 iOrder = (int) (log((double) lSize) / log(2.0) + 0.5);
06876 if (bIsReal)
06877 {
06878 IppsFFTSpec_R_32f *pSFFTSpec;
06879 IppsFFTSpec_R_64f *pDFFTSpec;
06880 ippsFFTInitAlloc_R_32f(&pSFFTSpec, iOrder, IPP_FFT_DIV_FWD_BY_N,
06881 ippAlgHintFast);
06882 ippsFFTInitAlloc_R_64f(&pDFFTSpec, iOrder, IPP_FFT_DIV_FWD_BY_N,
06883 ippAlgHintFast);
06884 ippsFFTGetBufSize_R_32f(pSFFTSpec, &iSWorkSize);
06885 ippsFFTGetBufSize_R_64f(pDFFTSpec, &iDWorkSize);
06886 SBitRevWork.Size(iSWorkSize);
06887 DBitRevWork.Size(iDWorkSize);
06888 vpSTfrm = (void *) pSFFTSpec;
06889 vpDTfrm = (void *) pDFFTSpec;
06890 }
06891 else
06892 {
06893 IppsFFTSpec_C_32fc *pSFFTSpec;
06894 IppsFFTSpec_C_64fc *pDFFTSpec;
06895 ippsFFTInitAlloc_C_32fc(&pSFFTSpec, iOrder, IPP_FFT_DIV_FWD_BY_N,
06896 ippAlgHintFast);
06897 ippsFFTInitAlloc_C_64fc(&pDFFTSpec, iOrder, IPP_FFT_DIV_FWD_BY_N,
06898 ippAlgHintFast);
06899 ippsFFTGetBufSize_C_32fc(pSFFTSpec, &iSWorkSize);
06900 ippsFFTGetBufSize_C_64fc(pDFFTSpec, &iDWorkSize);
06901 SBitRevWork.Size(iSWorkSize);
06902 DBitRevWork.Size(iDWorkSize);
06903 vpSTfrm = (void *) pSFFTSpec;
06904 vpDTfrm = (void *) pDFFTSpec;
06905 }
06906 #elif defined(DSP_USE_FFTW)
06907 if (bIsReal)
06908 {
06909 clDSPAlloc FFTBufS(lSize * sizeof(float));
06910 clDSPAlloc FFTBufD(lSize * sizeof(double));
06911 clDSPAlloc FFTBufSC((lSize / 2 + 1) * sizeof(fftwf_complex));
06912 clDSPAlloc FFTBufDC((lSize / 2 + 1) * sizeof(fftw_complex));
06913 fftwpSPlan = fftwf_plan_dft_r2c_1d(lSize, FFTBufS, FFTBufSC,
06914 FFTW_ESTIMATE|FFTW_PRESERVE_INPUT|FFTW_UNALIGNED);
06915 fftwpSIPlan = fftwf_plan_dft_c2r_1d(lSize, FFTBufSC, FFTBufS,
06916 FFTW_ESTIMATE|FFTW_PRESERVE_INPUT|FFTW_UNALIGNED);
06917 fftwpDPlan = fftw_plan_dft_r2c_1d(lSize, FFTBufD, FFTBufDC,
06918 FFTW_ESTIMATE|FFTW_PRESERVE_INPUT|FFTW_UNALIGNED);
06919 fftwpDIPlan = fftw_plan_dft_c2r_1d(lSize, FFTBufDC, FFTBufD,
06920 FFTW_ESTIMATE|FFTW_PRESERVE_INPUT|FFTW_UNALIGNED);
06921 FFTBuf.Size(lSize * sizeof(double));
06922 }
06923 else
06924 {
06925 clDSPAlloc FFTBufSI(lSize * sizeof(fftwf_complex));
06926 clDSPAlloc FFTBufSO(lSize * sizeof(fftwf_complex));
06927 clDSPAlloc FFTBufDI(lSize * sizeof(fftw_complex));
06928 clDSPAlloc FFTBufDO(lSize * sizeof(fftw_complex));
06929
06930 fftwpSPlan = fftwf_plan_dft_1d(lSize, FFTBufSI, FFTBufSO,
06931 FFTW_FORWARD, FFTW_ESTIMATE|FFTW_PRESERVE_INPUT|FFTW_UNALIGNED);
06932 fftwpSIPlan = fftwf_plan_dft_1d(lSize, FFTBufSO, FFTBufSI,
06933 FFTW_BACKWARD, FFTW_ESTIMATE|FFTW_PRESERVE_INPUT|FFTW_UNALIGNED);
06934 fftwpDPlan = fftw_plan_dft_1d(lSize, FFTBufDI, FFTBufDO,
06935 FFTW_FORWARD, FFTW_ESTIMATE|FFTW_PRESERVE_INPUT|FFTW_UNALIGNED);
06936 fftwpDIPlan = fftw_plan_dft_1d(lSize, FFTBufDO, FFTBufDI,
06937 FFTW_BACKWARD, FFTW_ESTIMATE|FFTW_PRESERVE_INPUT|FFTW_UNALIGNED);
06938 FFTBuf.Size(lSize * 2 * sizeof(double));
06939 }
06940 fFFTScale = 1.0F / (float) lSize;
06941 dFFTScale = 1.0 / (double) lSize;
06942 #else
06943 float *fpFFTBuf;
06944 double *dpFFTBuf;
06945 clDSPAlloc FFTBufS(lSize * 2 * sizeof(float));
06946 clDSPAlloc FFTBufD(lSize * 2 * sizeof(double));
06947
06948 fpFFTBuf = FFTBufS;
06949 dpFFTBuf = FFTBufD;
06950 if (bIsReal)
06951 {
06952 fFFTScale = 2.0F / (float) lSize;
06953 dFFTScale = 2.0 / (double) lSize;
06954 }
06955 else
06956 {
06957 fFFTScale = 1.0F / (float) lSize;
06958 dFFTScale = 1.0 / (double) lSize;
06959 }
06960 lpSBitRevWork = (long *)
06961 SBitRevWork.Size(((size_t) ceil(2.0 + sqrt(lSize))) * sizeof(long));
06962 lpDBitRevWork = (long *)
06963 DBitRevWork.Size(((size_t) ceil(2.0 + sqrt(lSize))) * sizeof(long));
06964 fpCosSinTable = (float *)
06965 SCosSinTable.Size((lSize / 2 + 1) * sizeof(float));
06966 dpCosSinTable = (double *)
06967 DCosSinTable.Size((lSize / 2 + 1) * sizeof(double));
06968 lpSBitRevWork[0] = 0;
06969 lpSBitRevWork[1] = 0;
06970 lpDBitRevWork[0] = 0;
06971 lpDBitRevWork[1] = 0;
06972 if (bIsReal)
06973 {
06974 Tfrm.rdft(lSize, 1, fpFFTBuf, lpSBitRevWork, fpCosSinTable);
06975 Tfrm.rdft(lSize, 1, dpFFTBuf, lpDBitRevWork, dpCosSinTable);
06976 FFTBuf.Size(lSize * sizeof(double));
06977 }
06978 else
06979 {
06980 Tfrm.cdft(lSize * 2, 1, fpFFTBuf, lpSBitRevWork, fpCosSinTable);
06981 Tfrm.cdft(lSize * 2, 1, dpFFTBuf, lpDBitRevWork, dpCosSinTable);
06982 FFTBuf.Size(lSize * 2 * sizeof(double));
06983 }
06984 #endif
06985 bFFTInitialized = true;
06986 bRealTransform = bIsReal;
06987 lFFTLength = lSize;
06988 }
06989
06990
06991 void clDSPOp::FFTUninitialize()
06992 {
06993 #if defined(DSP_IPP)
06994 if (bFFTInitialized)
06995 {
06996 if (bRealTransform)
06997 {
06998 ippsFFTFree_R_32f((IppsFFTSpec_R_32f *) vpSTfrm);
06999 ippsFFTFree_R_64f((IppsFFTSpec_R_64f *) vpDTfrm);
07000 }
07001 else
07002 {
07003 ippsFFTFree_C_32f((IppsFFTSpec_C_32f *) vpSTfrm);
07004 ippsFFTFree_C_64f((IppsFFTSpec_C_64f *) vpDTfrm);
07005 }
07006 }
07007 #elif defined(DSP_USE_FFTW)
07008 if (bFFTInitialized)
07009 {
07010 fftwf_destroy_plan(fftwpSPlan);
07011 fftwf_destroy_plan(fftwpSIPlan);
07012 fftw_destroy_plan(fftwpDPlan);
07013 fftw_destroy_plan(fftwpDIPlan);
07014 }
07015 #else
07016
07017 #endif
07018 SBitRevWork.Free();
07019 DBitRevWork.Free();
07020 SCosSinTable.Free();
07021 DCosSinTable.Free();
07022 FFTBuf.Free();
07023 bFFTInitialized = false;
07024 }
07025
07026
07027 void clDSPOp::FFTi(stpSCplx spDest, float *fpSrc)
07028 {
07029 #if defined(DSP_IPP)
07030 ippsFFTFwd_RToCCS_32f(fpSrc, (Ipp32f *) spDest,
07031 (IppsFFTSpec_R_32f *) vpSTfrm, SBitRevWork);
07032 #elif defined(DSP_USE_FFTW)
07033 Mul(fpSrc, fFFTScale, lFFTLength);
07034 fftwf_execute_dft_r2c(fftwpSPlan, fpSrc, (fftwf_complex *) spDest);
07035 #else
07036 long lLoopCntr;
07037 long lMax;
07038
07039 Mul(fpSrc, fFFTScale, lFFTLength);
07040 Tfrm.rdft(lFFTLength, 1, fpSrc, lpSBitRevWork, fpCosSinTable);
07041 lMax = lFFTLength / 2 - 1;
07042 spDest[0].R = fpSrc[0];
07043 spDest[0].I = 0.0F;
07044 for (lLoopCntr = 1; lLoopCntr <= lMax; lLoopCntr++)
07045 {
07046 spDest[lLoopCntr].R = fpSrc[lLoopCntr * 2];
07047 spDest[lLoopCntr].I = fpSrc[lLoopCntr * 2 + 1];
07048 }
07049 spDest[lMax + 1].R = fpSrc[1];
07050 spDest[lMax + 1].I = 0.0F;
07051 #endif
07052 }
07053
07054
07055 void clDSPOp::FFTi(stpDCplx spDest, double *dpSrc)
07056 {
07057 #if defined(DSP_IPP)
07058 ippsFFTFwd_RToCCS_64f(dpSrc, (Ipp64f *) spDest,
07059 (IppsFFTSpec_R_64f *) vpDTfrm, DBitRevWork);
07060 #elif defined(DSP_USE_FFTW)
07061 Mul(dpSrc, dFFTScale, lFFTLength);
07062 fftw_execute_dft_r2c(fftwpDPlan, dpSrc, (fftw_complex *) spDest);
07063 #else
07064 long lLoopCntr;
07065 long lMax;
07066
07067 Mul(dpSrc, dFFTScale, lFFTLength);
07068 Tfrm.rdft(lFFTLength, 1, dpSrc, lpDBitRevWork, dpCosSinTable);
07069 lMax = lFFTLength / 2 - 1;
07070 spDest[0].R = dpSrc[0];
07071 spDest[0].I = 0.0;
07072 for (lLoopCntr = 1; lLoopCntr <= lMax; lLoopCntr++)
07073 {
07074 spDest[lLoopCntr].R = dpSrc[lLoopCntr * 2];
07075 spDest[lLoopCntr].I = dpSrc[lLoopCntr * 2 + 1];
07076 }
07077 spDest[lMax + 1].R = dpSrc[1];
07078 spDest[lMax + 1].I = 0.0;
07079 #endif
07080 }
07081
07082
07083 void clDSPOp::FFTo(stpSCplx spDest, const float *fpSrc)
07084 {
07085 #if defined(DSP_IPP)
07086 ippsFFTFwd_RToCCS_32f(fpSrc, (Ipp32f *) spDest,
07087 (IppsFFTSpec_R_32f *) vpSTfrm, SBitRevWork);
07088 #elif defined(DSP_USE_FFTW)
07089 float *fpFFTBuf;
07090
07091 fpFFTBuf = FFTBuf;
07092 Mul(fpFFTBuf, fpSrc, fFFTScale, lFFTLength);
07093 fftwf_execute_dft_r2c(fftwpSPlan, fpFFTBuf, (fftwf_complex *) spDest);
07094 #else
07095 long lLoopCntr;
07096 long lMax;
07097 float *fpFFTBuf;
07098
07099 fpFFTBuf = FFTBuf;
07100 Mul(fpFFTBuf, fpSrc, fFFTScale, lFFTLength);
07101 Tfrm.rdft(lFFTLength, 1, fpFFTBuf, lpSBitRevWork, fpCosSinTable);
07102 lMax = lFFTLength / 2 - 1;
07103 spDest[0].R = fpFFTBuf[0];
07104 spDest[0].I = 0.0F;
07105 for (lLoopCntr = 1; lLoopCntr <= lMax; lLoopCntr++)
07106 {
07107 spDest[lLoopCntr].R = fpFFTBuf[lLoopCntr * 2];
07108 spDest[lLoopCntr].I = fpFFTBuf[lLoopCntr * 2 + 1];
07109 }
07110 spDest[lMax + 1].R = fpFFTBuf[1];
07111 spDest[lMax + 1].I = 0.0F;
07112 #endif
07113 }
07114
07115
07116 void clDSPOp::FFTo(stpDCplx spDest, const double *dpSrc)
07117 {
07118 #if defined(DSP_IPP)
07119 ippsFFTFwd_RToCCS_64f(dpSrc, (Ipp64f *) spDest,
07120 (IppsFFTSpec_R_64f *) vpDTfrm, DBitRevWork);
07121 #elif defined(DSP_USE_FFTW)
07122 double *dpFFTBuf;
07123
07124 dpFFTBuf = FFTBuf;
07125 Mul(dpFFTBuf, dpSrc, dFFTScale, lFFTLength);
07126 fftw_execute_dft_r2c(fftwpDPlan, dpFFTBuf, (fftw_complex *) spDest);
07127 #else
07128 long lLoopCntr;
07129 long lMax;
07130 double *dpFFTBuf;
07131
07132 dpFFTBuf = FFTBuf;
07133 Mul(dpFFTBuf, dpSrc, dFFTScale, lFFTLength);
07134 Tfrm.rdft(lFFTLength, 1, dpFFTBuf, lpDBitRevWork, dpCosSinTable);
07135 lMax = lFFTLength / 2 - 1;
07136 spDest[0].R = dpFFTBuf[0];
07137 spDest[0].I = 0.0;
07138 for (lLoopCntr = 1; lLoopCntr <= lMax; lLoopCntr++)
07139 {
07140 spDest[lLoopCntr].R = dpFFTBuf[lLoopCntr * 2];
07141 spDest[lLoopCntr].I = dpFFTBuf[lLoopCntr * 2 + 1];
07142 }
07143 spDest[lMax + 1].R = dpFFTBuf[1];
07144 spDest[lMax + 1].I = 0.0;
07145 #endif
07146 }
07147
07148
07149 void clDSPOp::FFTo(stpSCplx spDest, const stpSCplx spSrc)
07150 {
07151 #if defined(DSP_IPP)
07152 ippsFFTFwd_CToC_32fc((Ipp32fc *) spSrc, (Ipp32fc *) spDest,
07153 (IppsFFTSpec_C_32fc *) vpSTfrm, SBitRevWork);
07154 #elif defined(DSP_USE_FFTW)
07155 Mul((float *) FFTBuf, (const float *) spSrc, fFFTScale, lFFTLength * 2);
07156 fftwf_execute_dft(fftwpSPlan, FFTBuf, (fftwf_complex *) spDest);
07157 #else
07158 long lLoopCntr;
07159 float *fpFFTBuf;
07160
07161 fpFFTBuf = FFTBuf;
07162 for (lLoopCntr = 0; lLoopCntr < lFFTLength; lLoopCntr++)
07163 {
07164 fpFFTBuf[lLoopCntr * 2] = spSrc[lLoopCntr].R;
07165 fpFFTBuf[lLoopCntr * 2 + 1] = spSrc[lLoopCntr].I;
07166 }
07167 Mul(fpFFTBuf, fFFTScale, lFFTLength * 2);
07168 Tfrm.cdft(lFFTLength * 2, 1, fpFFTBuf, lpSBitRevWork, fpCosSinTable);
07169 for (lLoopCntr = 0; lLoopCntr < lFFTLength; lLoopCntr++)
07170 {
07171 spDest[lLoopCntr].R = fpFFTBuf[lLoopCntr * 2];
07172 spDest[lLoopCntr].I = fpFFTBuf[lLoopCntr * 2 + 1];
07173 }
07174 #endif
07175 }
07176
07177
07178 void clDSPOp::FFTo(stpDCplx spDest, const stpDCplx spSrc)
07179 {
07180 #if defined(DSP_IPP)
07181 ippsFFTFwd_CToC_64fc((Ipp64fc *) spSrc, (Ipp64fc *) spDest,
07182 (IppsFFTSpec_C_64fc *) vpDTfrm, DBitRevWork);
07183 #elif defined(DSP_USE_FFTW)
07184 Mul((double *) FFTBuf, (const double *) spSrc, dFFTScale, lFFTLength * 2);
07185 fftw_execute_dft(fftwpDPlan, FFTBuf, (fftw_complex *) spDest);
07186 #else
07187 long lLoopCntr;
07188 double *dpFFTBuf;
07189
07190 dpFFTBuf = FFTBuf;
07191 for (lLoopCntr = 0; lLoopCntr < lFFTLength; lLoopCntr++)
07192 {
07193 dpFFTBuf[lLoopCntr * 2] = spSrc[lLoopCntr].R;
07194 dpFFTBuf[lLoopCntr * 2 + 1] = spSrc[lLoopCntr].I;
07195 }
07196 Mul(dpFFTBuf, dFFTScale, lFFTLength * 2);
07197 Tfrm.cdft(lFFTLength * 2, 1, dpFFTBuf, lpDBitRevWork, dpCosSinTable);
07198 for (lLoopCntr = 0; lLoopCntr < lFFTLength; lLoopCntr++)
07199 {
07200 spDest[lLoopCntr].R = dpFFTBuf[lLoopCntr * 2];
07201 spDest[lLoopCntr].I = dpFFTBuf[lLoopCntr * 2 + 1];
07202 }
07203 #endif
07204 }
07205
07206
07207 void clDSPOp::IFFTo(float *fpDest, const stpSCplx spSrc)
07208 {
07209 #if defined(DSP_IPP)
07210 ippsFFTInv_CCSToR_32f((Ipp32f *) spSrc, fpDest,
07211 (IppsFFTSpec_R_32f *) vpSTfrm, SBitRevWork);
07212 #elif defined(DSP_USE_FFTW)
07213 fftwf_execute_dft_c2r(fftwpSIPlan, (fftwf_complex *) spSrc, fpDest);
07214 #else
07215 long lLoopCntr;
07216 long lMax;
07217
07218 lMax = lFFTLength / 2 - 1;
07219 fpDest[0] = spSrc[0].R;
07220 for (lLoopCntr = 1; lLoopCntr <= lMax; lLoopCntr++)
07221 {
07222 fpDest[lLoopCntr * 2] = spSrc[lLoopCntr].R;
07223 fpDest[lLoopCntr * 2 + 1] = spSrc[lLoopCntr].I;
07224 }
07225 fpDest[1] = spSrc[lMax + 1].R;
07226 Tfrm.rdft(lFFTLength, -1, fpDest, lpSBitRevWork, fpCosSinTable);
07227 #endif
07228 }
07229
07230
07231 void clDSPOp::IFFTo(double *dpDest, const stpDCplx spSrc)
07232 {
07233 #if defined(DSP_IPP)
07234 ippsFFTInv_CCSToR_64f((Ipp64f *) spSrc, dpDest,
07235 (IppsFFTSpec_R_64f *) vpDTfrm, DBitRevWork);
07236 #elif defined(DSP_USE_FFTW)
07237 fftw_execute_dft_c2r(fftwpDIPlan, (fftw_complex *) spSrc, dpDest);
07238 #else
07239 long lLoopCntr;
07240 long lMax;
07241
07242 lMax = lFFTLength / 2 - 1;
07243 dpDest[0] = spSrc[0].R;
07244 for (lLoopCntr = 1; lLoopCntr <= lMax; lLoopCntr++)
07245 {
07246 dpDest[lLoopCntr * 2] = spSrc[lLoopCntr].R;
07247 dpDest[lLoopCntr * 2 + 1] = spSrc[lLoopCntr].I;
07248 }
07249 dpDest[1] = spSrc[lMax + 1].R;
07250 Tfrm.rdft(lFFTLength, -1, dpDest, lpDBitRevWork, dpCosSinTable);
07251 #endif
07252 }
07253
07254
07255 void clDSPOp::IFFTo(stpSCplx spDest, const stpSCplx spSrc)
07256 {
07257 #if defined(DSP_IPP)
07258 ippsFFTInv_CToC_32fc((Ipp32fc *) spSrc, (Ipp32fc *) spDest,
07259 (IppsFFTSpec_C_32fc *) vpSTfrm, SBitRevWork);
07260 #elif defined(DSP_USE_FFTW)
07261 fftwf_execute_dft(fftwpSIPlan, (fftwf_complex *) spSrc,
07262 (fftwf_complex *) spDest);
07263 #else
07264 long lLoopCntr;
07265 float fScale;
07266 float *fpFFTBuf;
07267
07268 fpFFTBuf = FFTBuf;
07269 for (lLoopCntr = 0; lLoopCntr < lFFTLength; lLoopCntr++)
07270 {
07271 fpFFTBuf[lLoopCntr * 2] = spSrc[lLoopCntr].R;
07272 fpFFTBuf[lLoopCntr * 2 + 1] = spSrc[lLoopCntr].I;
07273 }
07274 Tfrm.cdft(lFFTLength * 2, -1, fpFFTBuf, lpSBitRevWork, fpCosSinTable);
07275 fScale = 1.0F / (float) lFFTLength;
07276 for (lLoopCntr = 0; lLoopCntr < lFFTLength; lLoopCntr++)
07277 {
07278 spDest[lLoopCntr].R = fpFFTBuf[lLoopCntr * 2] * fScale;
07279 spDest[lLoopCntr].I = fpFFTBuf[lLoopCntr * 2 + 1] * fScale;
07280 }
07281 #endif
07282 }
07283
07284
07285 void clDSPOp::IFFTo(stpDCplx spDest, const stpDCplx spSrc)
07286 {
07287 #if defined(DSP_IPP)
07288 ippsFFTInv_CToC_64fc((Ipp64fc *) spSrc, (Ipp64fc *) spDest,
07289 (IppsFFTSpec_C_64fc *) vpDTfrm, DBitRevWork);
07290 #elif defined(DSP_USE_FFTW)
07291 fftw_execute_dft(fftwpDIPlan, (fftw_complex *) spSrc,
07292 (fftw_complex *) spDest);
07293 #else
07294 long lLoopCntr;
07295 double dScale;
07296 double *dpFFTBuf;
07297
07298 dpFFTBuf = FFTBuf;
07299 for (lLoopCntr = 0; lLoopCntr < lFFTLength; lLoopCntr++)
07300 {
07301 dpFFTBuf[lLoopCntr * 2] = spSrc[lLoopCntr].R;
07302 dpFFTBuf[lLoopCntr * 2 + 1] = spSrc[lLoopCntr].I;
07303 }
07304 Tfrm.cdft(lFFTLength * 2, -1, dpFFTBuf, lpDBitRevWork, dpCosSinTable);
07305 dScale = 1.0 / (double) lFFTLength;
07306 for (lLoopCntr = 0; lLoopCntr < lFFTLength; lLoopCntr++)
07307 {
07308 spDest[lLoopCntr].R = dpFFTBuf[lLoopCntr * 2] * dScale;
07309 spDest[lLoopCntr].I = dpFFTBuf[lLoopCntr * 2 + 1] * dScale;
07310 }
07311 #endif
07312 }
07313
07314
07315 void clDSPOp::FFTWConvert(stpSCplx spDest, const float *fpSrc, long lLength)
07316 {
07317 long lLoopCntr;
07318 long lMax;
07319
07320 lMax = lLength / 2;
07321 spDest[0].R = fpSrc[0];
07322 spDest[0].I = 0.0F;
07323 for (lLoopCntr = 1; lLoopCntr < lMax; lLoopCntr++)
07324 {
07325 spDest[lLoopCntr].R = fpSrc[lLoopCntr];
07326 spDest[lLoopCntr].I = fpSrc[lLength - lLoopCntr];
07327 }
07328 spDest[lMax].R = fpSrc[lMax];
07329 spDest[lMax].I = 0.0F;
07330 }
07331
07332
07333 void clDSPOp::FFTWConvert(stpDCplx spDest, const float *fpSrc, long lLength)
07334 {
07335 long lLoopCntr;
07336 long lMax;
07337
07338 lMax = lLength / 2;
07339 spDest[0].R = fpSrc[0];
07340 spDest[0].I = 0.0;
07341 for (lLoopCntr = 1; lLoopCntr < lMax; lLoopCntr++)
07342 {
07343 spDest[lLoopCntr].R = fpSrc[lLoopCntr];
07344 spDest[lLoopCntr].I = fpSrc[lLength - lLoopCntr];
07345 }
07346 spDest[lMax].R = fpSrc[lMax];
07347 spDest[lMax].I = 0.0;
07348 }
07349
07350
07351 void clDSPOp::FFTWConvert(stpSCplx spDest, const double *dpSrc, long lLength)
07352 {
07353 long lLoopCntr;
07354 long lMax;
07355
07356 lMax = lLength / 2;
07357 spDest[0].R = dpSrc[0];
07358 spDest[0].I = 0.0F;
07359 for (lLoopCntr = 1; lLoopCntr < lMax; lLoopCntr++)
07360 {
07361 spDest[lLoopCntr].R = dpSrc[lLoopCntr];
07362 spDest[lLoopCntr].I = dpSrc[lLength - lLoopCntr];
07363 }
07364 spDest[lMax].R = dpSrc[lMax];
07365 spDest[lMax].I = 0.0F;
07366 }
07367
07368
07369 void clDSPOp::FFTWConvert(stpDCplx spDest, const double *dpSrc, long lLength)
07370 {
07371 long lLoopCntr;
07372 long lMax;
07373
07374 lMax = lLength / 2;
07375 spDest[0].R = dpSrc[0];
07376 spDest[0].I = 0.0;
07377 for (lLoopCntr = 1; lLoopCntr < lMax; lLoopCntr++)
07378 {
07379 spDest[lLoopCntr].R = dpSrc[lLoopCntr];
07380 spDest[lLoopCntr].I = dpSrc[lLength - lLoopCntr];
07381 }
07382 spDest[lMax].R = dpSrc[lMax];
07383 spDest[lMax].I = 0.0;
07384 }
07385
07386
07387 void clDSPOp::FFTWConvert(float *fpDest, const stpSCplx spSrc, long lLength)
07388 {
07389 long lLoopCntr;
07390 long lMax;
07391
07392 lMax = lLength / 2;
07393 fpDest[0] = spSrc[0].R;
07394 for (lLoopCntr = 1; lLoopCntr < lMax; lLoopCntr++)
07395 {
07396 fpDest[lLoopCntr] = spSrc[lLoopCntr].R;
07397 fpDest[lLength - lLoopCntr] = spSrc[lLoopCntr].I;
07398 }
07399 fpDest[lMax] = spSrc[lMax].R;
07400 }
07401
07402
07403 void clDSPOp::FFTWConvert(float *fpDest, const stpDCplx spSrc, long lLength)
07404 {
07405 long lLoopCntr;
07406 long lMax;
07407
07408 lMax = lLength / 2;
07409 fpDest[0] = spSrc[0].R;
07410 for (lLoopCntr = 1; lLoopCntr < lMax; lLoopCntr++)
07411 {
07412 fpDest[lLoopCntr] = spSrc[lLoopCntr].R;
07413 fpDest[lLength - lLoopCntr] = spSrc[lLoopCntr].I;
07414 }
07415 fpDest[lMax] = spSrc[lMax].R;
07416 }
07417
07418
07419 void clDSPOp::FFTWConvert(double *dpDest, const stpSCplx spSrc, long lLength)
07420 {
07421 long lLoopCntr;
07422 long lMax;
07423
07424 lMax = lLength / 2;
07425 dpDest[0] = spSrc[0].R;
07426 for (lLoopCntr = 1; lLoopCntr < lMax; lLoopCntr++)
07427 {
07428 dpDest[lLoopCntr] = spSrc[lLoopCntr].R;
07429 dpDest[lLength - lLoopCntr] = spSrc[lLoopCntr].I;
07430 }
07431 dpDest[lMax] = spSrc[lMax].R;
07432 }
07433
07434
07435 void clDSPOp::FFTWConvert(double *dpDest, const stpDCplx spSrc, long lLength)
07436 {
07437 long lLoopCntr;
07438 long lMax;
07439
07440 lMax = lLength / 2;
07441 dpDest[0] = spSrc[0].R;
07442 for (lLoopCntr = 1; lLoopCntr < lMax; lLoopCntr++)
07443 {
07444 dpDest[lLoopCntr] = spSrc[lLoopCntr].R;
07445 dpDest[lLength - lLoopCntr] = spSrc[lLoopCntr].I;
07446 }
07447 dpDest[lMax] = spSrc[lMax].R;
07448 }
07449
07450
07451
07452
07453
07454
07455
07456
07457
07458
07459
07460
07461