Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

DSPOp.cc

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

Generated on Tue Mar 2 19:46:43 2004 for libDSP by doxygen 1.3.6