![]() |
pl-nk v0.4.5
Plonk|Plink|Plank are a set of cross-platform C/C++ frameworks for audio software development
|
00001 /* 00002 ------------------------------------------------------------------------------- 00003 This file is part of the Plink, Plonk, Plank libraries 00004 by Martin Robinson 00005 00006 http://code.google.com/p/pl-nk/ 00007 00008 Copyright University of the West of England, Bristol 2011-14 00009 All rights reserved. 00010 00011 Redistribution and use in source and binary forms, with or without 00012 modification, are permitted provided that the following conditions are met: 00013 00014 * Redistributions of source code must retain the above copyright 00015 notice, this list of conditions and the following disclaimer. 00016 * Redistributions in binary form must reproduce the above copyright 00017 notice, this list of conditions and the following disclaimer in the 00018 documentation and/or other materials provided with the distribution. 00019 * Neither the name of University of the West of England, Bristol nor 00020 the names of its contributors may be used to endorse or promote products 00021 derived from this software without specific prior written permission. 00022 00023 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 00024 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00025 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00026 DISCLAIMED. IN NO EVENT SHALL UNIVERSITY OF THE WEST OF ENGLAND, BRISTOL BE 00027 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00028 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 00029 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00030 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00031 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 00032 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00033 00034 This software makes use of third party libraries. For more information see: 00035 doc/license.txt included in the distribution. 00036 ------------------------------------------------------------------------------- 00037 */ 00038 00039 #ifndef PLANK_VDSP_H 00040 #define PLANK_VDSP_H 00041 00042 #if !DOXYGEN 00043 00044 #ifdef PLANK_VEC_CUSTOM 00045 #error only one custom vectorised libary may be specified 00046 #endif 00047 00048 #define PLANK_VEC_CUSTOM 00049 #include <Accelerate/Accelerate.h> 00050 00051 #define PLANK_SIMDF_LENGTH 4 // vector 4 floats 00052 #define PLANK_SIMDF_SIZE 16 00053 #define PLANK_SIMDF_SHIFT 2 // divide by 4 for length 00054 #define PLANK_SIMDF_MASK 3 // remainder mask for non-multiples of 4 00055 typedef vFloat PlankVF; 00056 00057 #define PLANK_SIMDD_LENGTH 2 // vector 2 doubles 00058 #define PLANK_SIMDD_SIZE 16 00059 #define PLANK_SIMDD_SHIFT 1 // divide by 2 for length 00060 #define PLANK_SIMDD_MASK 1 // remainder mask for non-even lengths 00061 typedef vDouble PlankVD; 00062 00063 #define PLANK_SIMDI_LENGTH 4 // vector 4 ints 00064 #define PLANK_SIMDI_SIZE 16 00065 #define PLANK_SIMDI_SHIFT 2 // divide by 4 for length 00066 #define PLANK_SIMDI_MASK 3 // remainder mask for non-multiples of 4 00067 typedef vSInt32 PlankVI; 00068 00069 #define PLANK_SIMDS_LENGTH 8 // vector 8 shorts 00070 #define PLANK_SIMDS_SIZE 16 00071 #define PLANK_SIMDS_SHIFT 3 // divide by 8 for length 00072 #define PLANK_SIMDS_MASK 7 // remainder mask for non-multiples of 8 00073 typedef vSInt16 PlankVS; 00074 00075 #if PLANK_ARM || PLANK_PPC // no 64-bit int SIMD 00076 #define PLANK_SIMDLL_LENGTH 1 // vector 1 LongLong 00077 #define PLANK_SIMDLL_SIZE 8 00078 #define PLANK_SIMDLL_SHIFT 0 // no shift 00079 #define PLANK_SIMDLL_MASK 0 // no remainder 00080 typedef PlankLL PlankVLL; 00081 #else 00082 #define PLANK_SIMDLL_LENGTH 2 // vector 2 LongLongs 00083 #define PLANK_SIMDLL_SIZE 16 00084 #define PLANK_SIMDLL_SHIFT 1 // divide by 2 for length 00085 #define PLANK_SIMDLL_MASK 1 // remainder mask for non-even lengths 00086 typedef vSInt64 PlankVLL; 00087 #endif 00088 00089 00090 00091 //------------------------------- float ---------------------------------------- 00092 00093 static inline void pl_VectorFillF_N1 (float *result, float a, PlankUL N) 00094 { 00095 vDSP_vfill (&a, result, 1, N); 00096 } 00097 00098 static inline void pl_VectorClearF_N (float *result, PlankUL N) 00099 { 00100 vDSP_vclr (result, 1, N); 00101 } 00102 00103 static inline void pl_VectorRampF_N11 (float *result, float a, float b, PlankUL N) 00104 { 00105 vDSP_vramp (&a, &b, result, 1, N); 00106 } 00107 00108 static inline void pl_VectorLineF_N11 (float *result, float a, float b, PlankUL N) 00109 { 00110 vDSP_vgen (&a, &b, result, 1, N); 00111 } 00112 00113 static inline void pl_VectorMoveF_NN (float *result, const float* a, PlankUL N) 00114 { 00115 vDSP_mmov ((float*)a, result, N, 1, N, N); 00116 } 00117 00118 static inline void pl_VectorIncF_NN (float *result, const float* a, PlankUL N) 00119 { 00120 float one = 1.f; 00121 vDSP_vsadd ((float*)a, 1, &one, result, 1, N); 00122 } 00123 00124 static inline void pl_VectorDecF_NN (float *result, const float* a, PlankUL N) 00125 { 00126 float mone = -1.f; 00127 vDSP_vsadd ((float*)a, 1, &mone, result, 1, N); 00128 } 00129 00130 static inline void pl_VectorNegF_NN (float *result, const float* a, PlankUL N) 00131 { 00132 vDSP_vneg ((float*)a, 1, result, 1, N); 00133 } 00134 00135 static inline void pl_VectorAbsF_NN (float *result, const float* a, PlankUL N) 00136 { 00137 vDSP_vabs ((float*)a, 1, result, 1, N); 00138 } 00139 00140 00141 //#ifdef PLANK_IOS 00143 //static inline void pl_VectorReciprocalF_NN (float *result, const float* a, PlankUL N) 00144 //{ 00145 // float one = 1.f; 00146 // vDSP_vfill (&one, result, 1, N); 00147 // vDSP_vdiv (result, 1, (float*)a, 1, result, 1, N); 00148 //} 00149 // 00150 //PLANK_VECTORUNARYOP_DEFINE(Log2,F) 00151 //PLANK_VECTORUNARYOP_DEFINE(Sin,F) 00152 //PLANK_VECTORUNARYOP_DEFINE(Cos,F) 00153 //PLANK_VECTORUNARYOP_DEFINE(Tan,F) 00154 //PLANK_VECTORUNARYOP_DEFINE(Asin,F) 00155 //PLANK_VECTORUNARYOP_DEFINE(Acos,F) 00156 //PLANK_VECTORUNARYOP_DEFINE(Atan,F) 00157 //PLANK_VECTORUNARYOP_DEFINE(Sinh,F) 00158 //PLANK_VECTORUNARYOP_DEFINE(Cosh,F) 00159 //PLANK_VECTORUNARYOP_DEFINE(Tanh,F) 00160 //PLANK_VECTORUNARYOP_DEFINE(Sqrt,F) 00161 //PLANK_VECTORUNARYOP_DEFINE(Log,F) 00162 //PLANK_VECTORUNARYOP_DEFINE(Log10,F) 00163 //PLANK_VECTORUNARYOP_DEFINE(Exp,F) 00164 //PLANK_VECTORUNARYOP_DEFINE(Ceil,F) 00165 //PLANK_VECTORUNARYOP_DEFINE(Floor,F) 00166 // 00167 //PLANK_VECTORBINARYOP_DEFINE(Pow,F) 00168 //PLANK_VECTORBINARYOP_DEFINE(Atan2,F) 00169 //#else 00171 00172 // vForce on MacOS and iOS as of iOS5 00173 00174 static inline void pl_VectorReciprocalF_NN (float *result, const float* a, PlankUL N) { const int n = (int)N; vvrecf (result, a, &n); } 00175 PLANK_VECTORUNARYOP_DEFINE(Log2,F) 00176 static inline void pl_VectorSinF_NN (float *result, const float* a, PlankUL N) { const int n = (int)N; vvsinf (result, a, &n); } 00177 static inline void pl_VectorCosF_NN (float *result, const float* a, PlankUL N) { const int n = (int)N; vvcosf (result, a, &n); } 00178 static inline void pl_VectorTanF_NN (float *result, const float* a, PlankUL N) { const int n = (int)N; vvtanf (result, a, &n); } 00179 static inline void pl_VectorAsinF_NN (float *result, const float* a, PlankUL N) { const int n = (int)N; vvasinf (result, a, &n); } 00180 static inline void pl_VectorAcosF_NN (float *result, const float* a, PlankUL N) { const int n = (int)N; vvacosf (result, a, &n); } 00181 static inline void pl_VectorAtanF_NN (float *result, const float* a, PlankUL N) { const int n = (int)N; vvatanf (result, a, &n); } 00182 static inline void pl_VectorSinhF_NN (float *result, const float* a, PlankUL N) { const int n = (int)N; vvsinhf (result, a, &n); } 00183 static inline void pl_VectorCoshF_NN (float *result, const float* a, PlankUL N) { const int n = (int)N; vvcoshf (result, a, &n); } 00184 static inline void pl_VectorTanhF_NN (float *result, const float* a, PlankUL N) { const int n = (int)N; vvtanhf (result, a, &n); } 00185 static inline void pl_VectorSqrtF_NN (float *result, const float* a, PlankUL N) { const int n = (int)N; vvsqrtf (result, a, &n); } 00186 static inline void pl_VectorLogF_NN (float *result, const float* a, PlankUL N) { const int n = (int)N; vvlogf (result, a, &n); } 00187 static inline void pl_VectorLog10F_NN (float *result, const float* a, PlankUL N) { const int n = (int)N; vvlog10f (result, a, &n); } 00188 static inline void pl_VectorExpF_NN (float *result, const float* a, PlankUL N) { const int n = (int)N; vvexpf (result, a, &n); } 00189 static inline void pl_VectorCeilF_NN (float *result, const float* a, PlankUL N) { const int n = (int)N; vvceilf (result, a, &n); } 00190 static inline void pl_VectorFloorF_NN (float *result, const float* a, PlankUL N) { const int n = (int)N; vvfloorf (result, a, &n); } 00191 00192 static inline void pl_VectorPowF_NNN (float *result, const float* a, const float *b, PlankUL N) 00193 { 00194 const int n = (int)N; 00195 vvpowf (result, b, a, &n); 00196 } 00197 00198 static inline void pl_VectorPowF_NN1 (float *result, const float* a, float b, PlankUL N) 00199 { 00200 const int n = (int)N; 00201 vDSP_vfill (&b, result, 1, N); 00202 vvpowf (result, result, a, &n); 00203 } 00204 00205 static inline void pl_VectorPowF_N1N (float *result, float a, const float* b, PlankUL N) 00206 { 00207 const int n = (int)N; 00208 vDSP_vfill (&a, result, 1, N); 00209 vvpowf (result, b, result, &n); 00210 } 00211 00212 static inline void pl_VectorAtan2F_NNN (float *result, const float* a, const float *b, PlankUL N) 00213 { 00214 const int n = (int)N; 00215 vvatan2f (result, a, b, &n); 00216 } 00217 00218 static inline void pl_VectorAtan2F_NN1 (float *result, const float* a, float b, PlankUL N) 00219 { 00220 const int n = (int)N; 00221 vDSP_vfill (&b, result, 1, N); 00222 vvatan2f (result, a, result, &n); 00223 } 00224 00225 static inline void pl_VectorAtan2F_N1N (float *result, float a, const float* b, PlankUL N) 00226 { 00227 const int n = (int)N; 00228 vDSP_vfill (&a, result, 1, N); 00229 vvatan2f (result, result, b, &n); 00230 } 00231 //#endif 00232 00233 PLANK_VECTORBINARYOP_DEFINE(IsEqualTo,F) 00234 PLANK_VECTORBINARYOP_DEFINE(IsNotEqualTo,F) 00235 PLANK_VECTORBINARYOP_DEFINE(IsGreaterThan,F) 00236 PLANK_VECTORBINARYOP_DEFINE(IsGreaterThanOrEqualTo,F) 00237 PLANK_VECTORBINARYOP_DEFINE(IsLessThan,F) 00238 PLANK_VECTORBINARYOP_DEFINE(IsLessThanOrEqualTo,F) 00239 00240 static inline void pl_VectorSumSqrF_NNN (float *result, const float* a, const float* b, PlankUL N) 00241 { 00242 vDSP_vmma ((float*)a, 1, (float*)a, 1, (float*)b, 1, (float*)b, 1, result, 1, N); 00243 } 00244 00245 static inline void pl_VectorSumSqrF_NN1 (float *result, const float* a, float b, PlankUL N) 00246 { 00247 vDSP_vfill (&b, result, 1, N); 00248 vDSP_vmma ((float*)a, 1, (float*)a, 1, result, 1, result, 1, result, 1, N); 00249 } 00250 00251 static inline void pl_VectorSumSqrF_N1N (float *result, float a, const float* b, PlankUL N) 00252 { 00253 vDSP_vfill (&a, result, 1, N); 00254 vDSP_vmma (result, 1, result, 1, (float*)b, 1, (float*)b, 1, result, 1, N); 00255 } 00256 00257 static inline void pl_VectorDifSqrF_NNN (float *result, const float* a, const float* b, PlankUL N) 00258 { 00259 vDSP_vmmsb ((float*)a, 1, (float*)a, 1, (float*)b, 1, (float*)b, 1, result, 1, N); 00260 } 00261 00262 static inline void pl_VectorDifSqrF_NN1 (float *result, const float* a, float b, PlankUL N) 00263 { 00264 vDSP_vfill (&b, result, 1, N); 00265 vDSP_vmmsb ((float*)a, 1, (float*)a, 1, result, 1, result, 1, result, 1, N); 00266 } 00267 00268 static inline void pl_VectorDifSqrF_N1N (float *result, float a, const float* b, PlankUL N) 00269 { 00270 vDSP_vfill (&a, result, 1, N); 00271 vDSP_vmmsb (result, 1, result, 1, (float*)b, 1, (float*)b, 1, result, 1, N); 00272 } 00273 00274 static inline void pl_VectorSqrSumF_NNN (float *result, const float* a, const float* b, PlankUL N) 00275 { 00276 vDSP_vadd (a, 1, b, 1, result, 1, N); 00277 vDSP_vsq (result, 1, result, 1, N); 00278 } 00279 00280 static inline void pl_VectorSqrSumF_NN1 (float *result, const float* a, float b, PlankUL N) 00281 { 00282 vDSP_vsadd ((float*)a, 1, &b, result, 1, N); 00283 vDSP_vsq (result, 1, result, 1, N); 00284 } 00285 00286 static inline void pl_VectorSqrSumF_N1N (float *result, float a, const float* b, PlankUL N) 00287 { 00288 vDSP_vsadd ((float*)b, 1, &a, result, 1, N); 00289 vDSP_vsq (result, 1, result, 1, N); 00290 } 00291 00292 static inline void pl_VectorSqrDifF_NNN (float *result, const float* a, const float* b, PlankUL N) 00293 { 00294 float mone = -1.f; 00295 vDSP_vsmul ((float*)b, 1, &mone, result, 1, N); 00296 vDSP_vadd ((float*)a, 1, result, 1, result, 1, N); 00297 vDSP_vsq (result, 1, result, 1, N); 00298 } 00299 00300 static inline void pl_VectorSqrDifF_NN1 (float *result, const float* a, float b, PlankUL N) 00301 { 00302 float nb = -b; 00303 vDSP_vsadd ((float*)a, 1, &nb, result, 1, N); 00304 vDSP_vsq (result, 1, result, 1, N); 00305 } 00306 00307 static inline void pl_VectorSqrDifF_N1N (float *result, float a, const float* b, PlankUL N) 00308 { 00309 float na = -a; 00310 vDSP_vsadd ((float*)b, 1, &na, result, 1, N); 00311 vDSP_vsq (result, 1, result, 1, N); 00312 } 00313 00314 static inline void pl_VectorAbsDifF_NNN (float *result, const float* a, const float* b, PlankUL N) 00315 { 00316 float mone = -1.f; 00317 vDSP_vsmul ((float*)b, 1, &mone, result, 1, N); 00318 vDSP_vadd ((float*)a, 1, result, 1, result, 1, N); 00319 vDSP_vabs (result, 1, result, 1, N); 00320 } 00321 00322 static inline void pl_VectorAbsDifF_NN1 (float *result, const float* a, float b, PlankUL N) 00323 { 00324 float nb = -b; 00325 vDSP_vsadd ((float*)a, 1, &nb, result, 1, N); 00326 vDSP_vabs (result, 1, result, 1, N); 00327 } 00328 00329 static inline void pl_VectorAbsDifF_N1N (float *result, float a, const float* b, PlankUL N) 00330 { 00331 float na = -a; 00332 vDSP_vsadd ((float*)b, 1, &na, result, 1, N); 00333 vDSP_vabs (result, 1, result, 1, N); 00334 } 00335 00336 PLANK_VECTORBINARYOPVECTOR_DEFINE(Thresh,F) 00337 static inline void pl_VectorThreshF_NN1 (float *result, const float* a, float b, PlankUL N) 00338 { 00339 vDSP_vthres ((float*)a, 1, &b, result, 1, N); 00340 } 00341 PLANK_SCALARBINARYOPVECTOR_DEFINE(Thresh,F) 00342 00343 static inline void pl_VectorSquaredF_NN (float *result, const float* a, PlankUL N) 00344 { 00345 vDSP_vsq ((float*)a, 1, result, 1, N); 00346 } 00347 00348 static inline void pl_VectorCubedF_NN (float *result, const float* a, PlankUL N) 00349 { 00350 vDSP_vsq ((float*)a, 1, result, 1, N); 00351 vDSP_vmul ((float*)a, 1, result, 1, result, 1, N); 00352 } 00353 00354 static inline void pl_VectorFracF_NN (float *result, const float* a, PlankUL N) 00355 { 00356 vDSP_vfrac ((float*)a, 1, result, 1, N); 00357 } 00358 00359 PLANK_VECTORUNARYOP_DEFINE(Sign,F) 00360 00361 static inline void pl_VectorM2FF_NN (float *result, const float* a, PlankUL N) 00362 { 00363 float m69 = -69.f; 00364 float twelve = 12.f; 00365 float a440 = 440.f; 00366 int i; 00367 00368 PLANK_ALIGN (PLANK_SIMDF_LENGTH * sizeof (float)) 00369 float temp[PLANK_SIMDF_LENGTH]; 00370 PlankUL Nsimd = N >> PLANK_SIMDF_SHIFT; 00371 PlankUL Nremain = N & PLANK_SIMDF_MASK; 00372 00373 for (i = 0; i < Nsimd; ++i, result += PLANK_SIMDF_LENGTH, a += PLANK_SIMDF_LENGTH) 00374 { 00375 vDSP_vsadd ((float*)a, 1, &m69, result, 1, PLANK_SIMDF_LENGTH); 00376 vDSP_vsdiv (result, 1, &twelve, temp, 1, PLANK_SIMDF_LENGTH); 00377 pl_VectorPowF_N1N (result, 2.f, temp, PLANK_SIMDF_LENGTH); 00378 vDSP_vsmul (result, 1, &a440, result, 1, PLANK_SIMDF_LENGTH); 00379 } 00380 00381 if (Nremain) 00382 { 00383 vDSP_vsadd ((float*)a, 1, &m69, result, 1, Nremain); 00384 vDSP_vsdiv (result, 1, &twelve, temp, 1, Nremain); 00385 pl_VectorPowF_N1N (result, 2.f, temp, Nremain); 00386 vDSP_vsmul (result, 1, &a440, result, 1, Nremain); 00387 } 00388 } 00389 00390 PLANK_VECTORUNARYOP_DEFINE(F2M,F) 00391 00392 static inline void pl_VectorA2dBF_NN (float *result, const float* a, PlankUL N) 00393 { 00394 float one = 1.f; 00395 vDSP_vdbcon ((float*)a, 1, &one, result, 1, N, 1); 00396 } 00397 00398 static inline void pl_VectordB2AF_NN (float *result, const float* a, PlankUL N) 00399 { 00400 float twenty = 20.f; 00401 int i; 00402 00403 PLANK_ALIGN (PLANK_SIMDF_LENGTH * sizeof (float)) 00404 float temp[PLANK_SIMDF_LENGTH]; 00405 PlankUL Nsimd = N >> PLANK_SIMDF_SHIFT; 00406 PlankUL Nremain = N & PLANK_SIMDF_MASK; 00407 00408 for (i = 0; i < Nsimd; ++i, result += PLANK_SIMDF_LENGTH, a += PLANK_SIMDF_LENGTH) 00409 { 00410 vDSP_vsdiv ((float*)a, 1, &twenty, temp, 1, PLANK_SIMDF_LENGTH); 00411 pl_VectorPowF_N1N (result, 10.f, temp, PLANK_SIMDF_LENGTH); 00412 } 00413 00414 if (Nremain) 00415 { 00416 vDSP_vsdiv ((float*)a, 1, &twenty, temp, 1, Nremain); 00417 pl_VectorPowF_N1N (result, 10.f, temp, Nremain); 00418 } 00419 } 00420 00421 PLANK_VECTORUNARYOP_DEFINE(D2R,F) 00422 PLANK_VECTORUNARYOP_DEFINE(R2D,F) 00423 PLANK_VECTORUNARYOP_DEFINE(Distort,F) 00424 PLANK_VECTORUNARYOP_DEFINE(Zap,F) 00425 00426 00427 static inline void pl_VectorAddF_NNN (float *result, const float* a, const float* b, PlankUL N) 00428 { 00429 vDSP_vadd ((float*)a, 1, (float*)b, 1, result, 1, N); 00430 } 00431 00432 static inline void pl_VectorAddF_NN1 (float *result, const float* a, float b, PlankUL N) 00433 { 00434 vDSP_vsadd ((float*)a, 1, &b, result, 1, N); 00435 } 00436 00437 static inline void pl_VectorAddF_N1N (float *result, float a, const float* b, PlankUL N) 00438 { 00439 vDSP_vsadd ((float*)b, 1, &a, result, 1, N); 00440 } 00441 00442 static inline void pl_VectorSubF_NNN (float *result, const float* a, const float* b, PlankUL N) 00443 { 00444 // due to ancient bug in vDSP_vsub 00445 float mone = -1.f; 00446 vDSP_vsmul ((float*)b, 1, &mone, result, 1, N); 00447 vDSP_vadd ((float*)a, 1, result, 1, result, 1, N); 00448 } 00449 00450 static inline void pl_VectorSubF_NN1 (float *result, const float* a, float b, PlankUL N) 00451 { 00452 float nb = -b; 00453 vDSP_vsadd ((float*)a, 1, &nb, result, 1, N); 00454 } 00455 00456 static inline void pl_VectorSubF_N1N (float *result, float a, const float* b, PlankUL N) 00457 { 00458 float mone = -1.f; 00459 vDSP_vsmul ((float*)b, 1, &mone, result, 1, N); 00460 vDSP_vsadd (result, 1, &a, result, 1, N); 00461 } 00462 00463 static inline void pl_VectorMulF_NNN (float *result, const float* a, const float* b, PlankUL N) 00464 { 00465 vDSP_vmul ((float*)a, 1, (float*)b, 1, result, 1, N); 00466 } 00467 00468 static inline void pl_VectorMulF_NN1 (float *result, const float* a, float b, PlankUL N) 00469 { 00470 vDSP_vsmul ((float*)a, 1, &b, result, 1, N); 00471 } 00472 00473 static inline void pl_VectorMulF_N1N (float *result, float a, const float* b, PlankUL N) 00474 { 00475 vDSP_vsmul ((float*)b, 1, &a, result, 1, N); 00476 } 00477 00478 static inline void pl_VectorDivF_NNN (float *result, const float* a, const float* b, PlankUL N) 00479 { 00480 vDSP_vdiv ((float*)b, 1, (float*)a, 1, result, 1, N); // documented as a and b reversed 00481 } 00482 00483 static inline void pl_VectorDivF_NN1 (float *result, const float* a, float b, PlankUL N) 00484 { 00485 vDSP_vsdiv ((float*)a, 1, &b, result, 1, N); 00486 } 00487 00488 static inline void pl_VectorDivF_N1N (float *result, float a, const float* b, PlankUL N) 00489 { 00490 float ra = 1.f / a; 00491 vDSP_vsmul ((float*)b, 1, &ra, result, 1, N); 00492 } 00493 00494 PLANK_VECTORBINARYOP_DEFINE(Mod,F) 00495 00496 static inline void pl_VectorMinF_NNN (float *result, const float* a, const float* b, PlankUL N) 00497 { 00498 vDSP_vmin ((float*)a, 1, (float*)b, 1, result, 1, N); 00499 } 00500 00501 static inline void pl_VectorMinF_NN1 (float *result, const float* a, float b, PlankUL N) 00502 { 00503 vDSP_vfill (&b, result, 1, N); 00504 vDSP_vmin ((float*)a, 1, result, 1, result, 1, N); 00505 } 00506 00507 static inline void pl_VectorMinF_N1N (float *result, float a, const float* b, PlankUL N) 00508 { 00509 vDSP_vfill (&a, result, 1, N); 00510 vDSP_vmin ((float*)b, 1, result, 1, result, 1, N); 00511 } 00512 00513 static inline void pl_VectorMaxF_NNN (float *result, const float* a, const float* b, PlankUL N) 00514 { 00515 vDSP_vmax ((float*)a, 1, (float*)b, 1, result, 1, N); 00516 } 00517 00518 static inline void pl_VectorMaxF_NN1 (float *result, const float* a, float b, PlankUL N) 00519 { 00520 vDSP_vfill (&b, result, 1, N); 00521 vDSP_vmax ((float*)a, 1, result, 1, result, 1, N); 00522 } 00523 00524 static inline void pl_VectorMaxF_N1N (float *result, float a, const float* b, PlankUL N) 00525 { 00526 vDSP_vfill (&a, result, 1, N); 00527 vDSP_vmax ((float*)b, 1, result, 1, result, 1, N); 00528 } 00529 00530 static inline void pl_VectorHypotF_NNN (float *result, const float* a, const float* b, PlankUL N) 00531 { 00532 vDSP_vdist ((float*)a, 1, (float*)b, 1, result, 1, N); 00533 } 00534 00535 static inline void pl_VectorHypotF_NN1 (float *result, const float* a, float b, PlankUL N) 00536 { 00537 vDSP_vfill (&b, result, 1, N); 00538 vDSP_vdist ((float*)a, 1, result, 1, result, 1, N); 00539 } 00540 00541 static inline void pl_VectorHypotF_N1N (float *result, float a, const float* b, PlankUL N) 00542 { 00543 vDSP_vfill (&a, result, 1, N); 00544 vDSP_vdist ((float*)b, 1, result, 1, result, 1, N); 00545 } 00546 00547 static inline void pl_VectorMulAddF_NNNN (float *result, const float* input, const float* a, const float* b, PlankUL N) 00548 { 00549 vDSP_vma ((float*)input, 1, (float*)a, 1, (float*)b, 1, (float*)result, 1, N); 00550 } 00551 00552 static inline void pl_VectorMulAddF_NNN (float *io, const float* a, const float* b, PlankUL N) 00553 { 00554 vDSP_vma ((float*)io, 1, (float*)a, 1, (float*)b, 1, (float*)io, 1, N); 00555 } 00556 00557 static inline void pl_VectorMulAddF_NNN1 (float *result, const float* input, const float* a, float b, PlankUL N) 00558 { 00559 vDSP_vmsa ((float*)input, 1, (float*)a, 1, &b, result, 1, N); 00560 } 00561 00562 static inline void pl_VectorMulAddF_NN11 (float *result, const float* input, float a, float b, PlankUL N) 00563 { 00564 vDSP_vsmsa ((float*)input, 1, &a, &b, result, 1, N); 00565 } 00566 00567 static inline void pl_VectorMulAddF_NN1N (float *result, const float* input, float a, const float* b, PlankUL N) 00568 { 00569 vDSP_vsma (input, 1, &a, b, 1, result, 1, N); 00570 } 00571 00572 static inline void pl_VectorAddMulF_1NN (float *result, const float* a, const float* b, PlankUL N) 00573 { 00574 vDSP_dotpr (a, 1, b, 1, result, N); 00575 } 00576 00577 static inline void pl_VectorZMulF_ZNNNNN (float *resultReal, float *resultImag, 00578 const float* leftReal, const float* leftImag, 00579 const float* rightReal, const float* rightImag, 00580 PlankUL N) 00581 { 00582 DSPSplitComplex result, left, right; 00583 result.realp = resultReal; 00584 result.imagp = resultImag; 00585 left.realp = (float*)leftReal; 00586 left.imagp = (float*)leftImag; 00587 right.realp = (float*)rightReal; 00588 right.imagp = (float*)rightImag; 00589 vDSP_zvmul (&left, 1, &right, 1, &result, 1, N, 1); 00590 } 00591 00592 00593 // works as documented but seems useless as it interpolates thr "wrong" two samples 00594 // fixed in 10.7.2 but is that seems to be the runtime lib so would still 00595 // be dangerous to use without some runtime checking 00596 //static inline void pl_VectorLookupF_NnN (float *result, const float* table, PlankUL n, const float* index, PlankUL N) 00597 //{ 00598 // float mul = 1.f; 00599 // float add = 0.f; 00600 // vDSP_vtabi ((float*)index, 1, &mul, &add, (float*)table, n, result, 1, N); 00601 //} 00602 PLANK_VECTORLOOKUP_DEFINE(F) 00603 00604 00605 //------------------------------- double --------------------------------------- 00606 00607 00608 //PLANK_VECTOR_OPS(D) 00609 00610 static inline void pl_VectorFillD_N1 (double *result, double a, PlankUL N) 00611 { 00612 vDSP_vfillD (&a, result, 1, N); 00613 } 00614 00615 static inline void pl_VectorClearD_N (double *result, PlankUL N) 00616 { 00617 vDSP_vclrD (result, 1, N); 00618 } 00619 00620 static inline void pl_VectorRampD_N11 (double *result, double a, double b, PlankUL N) 00621 { 00622 vDSP_vrampD (&a, &b, result, 1, N); 00623 } 00624 00625 static inline void pl_VectorLineD_N11 (double *result, double a, double b, PlankUL N) 00626 { 00627 vDSP_vgenD (&a, &b, result, 1, N); 00628 } 00629 00630 static inline void pl_VectorMoveD_NN (double *result, const double* a, PlankUL N) 00631 { 00632 vDSP_mmovD ((double*)a, result, N, 1, N, N); 00633 } 00634 00635 static inline void pl_VectorIncD_NN (double *result, const double* a, PlankUL N) 00636 { 00637 double one = 1.0; 00638 vDSP_vsaddD ((double*)a, 1, &one, result, 1, N); 00639 } 00640 00641 static inline void pl_VectorDecD_NN (double *result, const double* a, PlankUL N) 00642 { 00643 double mone = -1.0; 00644 vDSP_vsaddD ((double*)a, 1, &mone, result, 1, N); 00645 } 00646 00647 static inline void pl_VectorNegD_NN (double *result, const double* a, PlankUL N) 00648 { 00649 vDSP_vnegD ((double*)a, 1, result, 1, N); 00650 } 00651 00652 static inline void pl_VectorAbsD_NN (double *result, const double* a, PlankUL N) 00653 { 00654 vDSP_vabsD ((double*)a, 1, result, 1, N); 00655 } 00656 00657 00658 //#ifdef PLANK_IOS 00660 //static inline void pl_VectorReciprocalD_NN (double *result, const double* a, PlankUL N) 00661 //{ 00662 // double one = 1.0; 00663 // vDSP_vfillD (&one, result, 1, N); 00664 // vDSP_vdivD (result, 1, (double*)a, 1, result, 1, N); 00665 //} 00666 // 00667 //PLANK_VECTORUNARYOP_DEFINE(Log2,D) 00668 //PLANK_VECTORUNARYOP_DEFINE(Sin,D) 00669 //PLANK_VECTORUNARYOP_DEFINE(Cos,D) 00670 //PLANK_VECTORUNARYOP_DEFINE(Tan,D) 00671 //PLANK_VECTORUNARYOP_DEFINE(Asin,D) 00672 //PLANK_VECTORUNARYOP_DEFINE(Acos,D) 00673 //PLANK_VECTORUNARYOP_DEFINE(Atan,D) 00674 //PLANK_VECTORUNARYOP_DEFINE(Sinh,D) 00675 //PLANK_VECTORUNARYOP_DEFINE(Cosh,D) 00676 //PLANK_VECTORUNARYOP_DEFINE(Tanh,D) 00677 //PLANK_VECTORUNARYOP_DEFINE(Sqrt,D) 00678 //PLANK_VECTORUNARYOP_DEFINE(Log,D) 00679 //PLANK_VECTORUNARYOP_DEFINE(Log10,D) 00680 //PLANK_VECTORUNARYOP_DEFINE(Exp,D) 00681 //PLANK_VECTORUNARYOP_DEFINE(Ceil,D) 00682 //PLANK_VECTORUNARYOP_DEFINE(Floor,D) 00683 // 00684 //PLANK_VECTORBINARYOP_DEFINE(Pow,D) 00685 //PLANK_VECTORBINARYOP_DEFINE(Atan2,D) 00686 //#else 00688 00689 // vForce on MacOS and iPhone as of iOS5 00690 00691 static inline void pl_VectorReciprocalD_NN (double *result, const double* a, PlankUL N) { const int n = (int)N; vvrec (result, a, &n); } 00692 PLANK_VECTORUNARYOP_DEFINE(Log2,D) 00693 static inline void pl_VectorSinD_NN (double *result, const double* a, PlankUL N) { const int n = (int)N; vvsin (result, a, &n); } 00694 static inline void pl_VectorCosD_NN (double *result, const double* a, PlankUL N) { const int n = (int)N; vvcos (result, a, &n); } 00695 static inline void pl_VectorTanD_NN (double *result, const double* a, PlankUL N) { const int n = (int)N; vvtan (result, a, &n); } 00696 static inline void pl_VectorAsinD_NN (double *result, const double* a, PlankUL N) { const int n = (int)N; vvasin (result, a, &n); } 00697 static inline void pl_VectorAcosD_NN (double *result, const double* a, PlankUL N) { const int n = (int)N; vvacos (result, a, &n); } 00698 static inline void pl_VectorAtanD_NN (double *result, const double* a, PlankUL N) { const int n = (int)N; vvatan (result, a, &n); } 00699 static inline void pl_VectorSinhD_NN (double *result, const double* a, PlankUL N) { const int n = (int)N; vvsinh (result, a, &n); } 00700 static inline void pl_VectorCoshD_NN (double *result, const double* a, PlankUL N) { const int n = (int)N; vvcosh (result, a, &n); } 00701 static inline void pl_VectorTanhD_NN (double *result, const double* a, PlankUL N) { const int n = (int)N; vvtanh (result, a, &n); } 00702 static inline void pl_VectorSqrtD_NN (double *result, const double* a, PlankUL N) { const int n = (int)N; vvsqrt (result, a, &n); } 00703 static inline void pl_VectorLogD_NN (double *result, const double* a, PlankUL N) { const int n = (int)N; vvlog (result, a, &n); } 00704 static inline void pl_VectorLog10D_NN (double *result, const double* a, PlankUL N) { const int n = (int)N; vvlog10 (result, a, &n); } 00705 static inline void pl_VectorExpD_NN (double *result, const double* a, PlankUL N) { const int n = (int)N; vvexp (result, a, &n); } 00706 static inline void pl_VectorCeilD_NN (double *result, const double* a, PlankUL N) { const int n = (int)N; vvceil (result, a, &n); } 00707 static inline void pl_VectorFloorD_NN (double *result, const double* a, PlankUL N) { const int n = (int)N; vvfloor (result, a, &n); } 00708 00709 static inline void pl_VectorPowD_NNN (double *result, const double* a, const double *b, PlankUL N) 00710 { 00711 const int n = (int)N; 00712 vvpow (result, b, a, &n); 00713 } 00714 00715 static inline void pl_VectorPowD_NN1 (double *result, const double* a, double b, PlankUL N) 00716 { 00717 const int n = (int)N; 00718 vDSP_vfillD (&b, result, 1, N); 00719 vvpow (result, result, a, &n); 00720 } 00721 00722 static inline void pl_VectorPowD_N1N (double *result, double a, const double* b, PlankUL N) 00723 { 00724 const int n = (int)N; 00725 vDSP_vfillD (&a, result, 1, N); 00726 vvpow (result, b, result, &n); 00727 } 00728 00729 static inline void pl_VectorAtan2D_NNN (double *result, const double* a, const double *b, PlankUL N) 00730 { 00731 const int n = (int)N; 00732 vvatan2 (result, a, b, &n); 00733 } 00734 00735 static inline void pl_VectorAtan2D_NN1 (double *result, const double* a, double b, PlankUL N) 00736 { 00737 const int n = (int)N; 00738 vDSP_vfillD (&b, result, 1, N); 00739 vvatan2 (result, a, result, &n); 00740 } 00741 00742 static inline void pl_VectorAtan2D_N1N (double *result, double a, const double* b, PlankUL N) 00743 { 00744 const int n = (int)N; 00745 vDSP_vfillD (&a, result, 1, N); 00746 vvatan2 (result, result, b, &n); 00747 } 00748 //#endif 00749 00750 PLANK_VECTORBINARYOP_DEFINE(IsEqualTo,D) 00751 PLANK_VECTORBINARYOP_DEFINE(IsNotEqualTo,D) 00752 PLANK_VECTORBINARYOP_DEFINE(IsGreaterThan,D) 00753 PLANK_VECTORBINARYOP_DEFINE(IsGreaterThanOrEqualTo,D) 00754 PLANK_VECTORBINARYOP_DEFINE(IsLessThan,D) 00755 PLANK_VECTORBINARYOP_DEFINE(IsLessThanOrEqualTo,D) 00756 PLANK_VECTORBINARYOP_DEFINE(SumSqr,D) 00757 PLANK_VECTORBINARYOP_DEFINE(DifSqr,D) 00758 PLANK_VECTORBINARYOP_DEFINE(SqrSum,D) 00759 PLANK_VECTORBINARYOP_DEFINE(SqrDif,D) 00760 PLANK_VECTORBINARYOP_DEFINE(AbsDif,D) 00761 00762 PLANK_VECTORBINARYOPVECTOR_DEFINE(Thresh,D) 00763 static inline void pl_VectorThreshD_NN1 (double *result, const double* a, double b, PlankUL N) 00764 { 00765 vDSP_vthresD ((double*)a, 1, &b, result, 1, N); 00766 } 00767 PLANK_SCALARBINARYOPVECTOR_DEFINE(Thresh,D) 00768 00769 static inline void pl_VectorSquaredD_NN (double *result, const double* a, PlankUL N) 00770 { 00771 vDSP_vsqD ((double*)a, 1, result, 1, N); 00772 } 00773 00774 static inline void pl_VectorCubedD_NN (double *result, const double* a, PlankUL N) 00775 { 00776 vDSP_vsqD ((double*)a, 1, result, 1, N); 00777 vDSP_vmulD ((double*)a, 1, result, 1, result, 1, N); 00778 } 00779 00780 PLANK_VECTORUNARYOP_DEFINE(Frac,D) 00781 PLANK_VECTORUNARYOP_DEFINE(Sign,D) 00782 PLANK_VECTORUNARYOP_DEFINE(M2F,D) 00783 PLANK_VECTORUNARYOP_DEFINE(F2M,D) 00784 PLANK_VECTORUNARYOP_DEFINE(A2dB,D) 00785 PLANK_VECTORUNARYOP_DEFINE(dB2A,D) 00786 PLANK_VECTORUNARYOP_DEFINE(D2R,D) 00787 PLANK_VECTORUNARYOP_DEFINE(R2D,D) 00788 PLANK_VECTORUNARYOP_DEFINE(Distort,D) 00789 PLANK_VECTORUNARYOP_DEFINE(Zap,D) 00790 00791 00792 static inline void pl_VectorAddD_NNN (double *result, const double* a, const double* b, PlankUL N) 00793 { 00794 vDSP_vaddD ((double*)a, 1, (double*)b, 1, result, 1, N); 00795 } 00796 00797 static inline void pl_VectorAddD_NN1 (double *result, const double* a, double b, PlankUL N) 00798 { 00799 vDSP_vsaddD ((double*)a, 1, &b, result, 1, N); 00800 } 00801 00802 static inline void pl_VectorAddD_N1N (double *result, double a, const double* b, PlankUL N) 00803 { 00804 vDSP_vsaddD ((double*)b, 1, &a, result, 1, N); 00805 } 00806 00807 static inline void pl_VectorSubD_NNN (double *result, const double* a, const double* b, PlankUL N) 00808 { 00809 // due to bug in vDSP_vsub 00810 double mone = -1.0; 00811 vDSP_vsmulD ((double*)b, 1, &mone, result, 1, N); 00812 vDSP_vaddD ((double*)a, 1, result, 1, result, 1, N); 00813 } 00814 00815 static inline void pl_VectorSubD_NN1 (double *result, const double* a, double b, PlankUL N) 00816 { 00817 double nb = -b; 00818 vDSP_vsaddD ((double*)a, 1, &nb, result, 1, N); 00819 } 00820 00821 static inline void pl_VectorSubD_N1N (double *result, double a, const double* b, PlankUL N) 00822 { 00823 double mone = -1.0; 00824 vDSP_vsmulD ((double*)b, 1, &mone, result, 1, N); 00825 vDSP_vsaddD (result, 1, &a, result, 1, N); 00826 } 00827 00828 static inline void pl_VectorMulD_NNN (double *result, const double* a, const double* b, PlankUL N) 00829 { 00830 vDSP_vmulD ((double*)a, 1, (double*)b, 1, result, 1, N); 00831 } 00832 00833 static inline void pl_VectorMulD_NN1 (double *result, const double* a, double b, PlankUL N) 00834 { 00835 vDSP_vsmulD ((double*)a, 1, &b, result, 1, N); 00836 } 00837 00838 static inline void pl_VectorMulD_N1N (double *result, double a, const double* b, PlankUL N) 00839 { 00840 vDSP_vsmulD ((double*)b, 1, &a, result, 1, N); 00841 } 00842 00843 static inline void pl_VectorDivD_NNN (double *result, const double* a, const double* b, PlankUL N) 00844 { 00845 vDSP_vdivD ((double*)b, 1, (double*)a, 1, result, 1, N); // documented as a and b reversed 00846 } 00847 00848 static inline void pl_VectorDivD_NN1 (double *result, const double* a, double b, PlankUL N) 00849 { 00850 vDSP_vsdivD ((double*)a, 1, &b, result, 1, N); 00851 } 00852 00853 static inline void pl_VectorDivD_N1N (double *result, double a, const double* b, PlankUL N) 00854 { 00855 double ra = 1.0 / a; 00856 vDSP_vsmulD ((double*)b, 1, &ra, result, 1, N); 00857 } 00858 00859 PLANK_VECTORBINARYOP_DEFINE(Mod,D) 00860 00861 static inline void pl_VectorMinD_NNN (double *result, const double* a, const double* b, PlankUL N) 00862 { 00863 vDSP_vminD ((double*)a, 1, (double*)b, 1, result, 1, N); 00864 } 00865 00866 static inline void pl_VectorMinD_NN1 (double *result, const double* a, double b, PlankUL N) 00867 { 00868 vDSP_vfillD (&b, result, 1, N); 00869 vDSP_vminD ((double*)a, 1, result, 1, result, 1, N); 00870 } 00871 00872 static inline void pl_VectorMinD_N1N (double *result, double a, const double* b, PlankUL N) 00873 { 00874 vDSP_vfillD (&a, result, 1, N); 00875 vDSP_vminD ((double*)b, 1, result, 1, result, 1, N); 00876 } 00877 00878 static inline void pl_VectorMaxD_NNN (double *result, const double* a, const double* b, PlankUL N) 00879 { 00880 vDSP_vmaxD ((double*)a, 1, (double*)b, 1, result, 1, N); 00881 } 00882 00883 static inline void pl_VectorMaxD_NN1 (double *result, const double* a, double b, PlankUL N) 00884 { 00885 vDSP_vfillD (&b, result, 1, N); 00886 vDSP_vmaxD ((double*)a, 1, result, 1, result, 1, N); 00887 } 00888 00889 static inline void pl_VectorMaxD_N1N (double *result, double a, const double* b, PlankUL N) 00890 { 00891 vDSP_vfillD (&a, result, 1, N); 00892 vDSP_vmaxD ((double*)b, 1, result, 1, result, 1, N); 00893 } 00894 00895 static inline void pl_VectorHypotD_NNN (double *result, const double* a, const double* b, PlankUL N) 00896 { 00897 vDSP_vdistD ((double*)a, 1, (double*)b, 1, result, 1, N); 00898 } 00899 00900 static inline void pl_VectorHypotD_NN1 (double *result, const double* a, double b, PlankUL N) 00901 { 00902 vDSP_vfillD (&b, result, 1, N); 00903 vDSP_vdistD ((double*)a, 1, result, 1, result, 1, N); 00904 } 00905 00906 static inline void pl_VectorHypotD_N1N (double *result, double a, const double* b, PlankUL N) 00907 { 00908 vDSP_vfillD (&a, result, 1, N); 00909 vDSP_vdistD ((double*)b, 1, result, 1, result, 1, N); 00910 } 00911 00912 static inline void pl_VectorMulAddD_NNNN (double *result, const double* input, const double* a, const double* b, PlankUL N) 00913 { 00914 vDSP_vmaD ((double*)input, 1, (double*)a, 1, (double*)b, 1, (double*)result, 1, N); 00915 } 00916 00917 static inline void pl_VectorMulAddD_NNN (double *io, const double* a, const double* b, PlankUL N) 00918 { 00919 vDSP_vmaD ((double*)io, 1, (double*)a, 1, (double*)b, 1, (double*)io, 1, N); 00920 } 00921 00922 static inline void pl_VectorMulAddD_NNN1 (double *result, const double* input, const double* a, double b, PlankUL N) 00923 { 00924 vDSP_vmsaD ((double*)input, 1, (double*)a, 1, &b, result, 1, N); 00925 } 00926 00927 static inline void pl_VectorMulAddD_NN11 (double *result, const double* input, double a, double b, PlankUL N) 00928 { 00929 vDSP_vsmsaD ((double*)input, 1, &a, &b, result, 1, N); 00930 } 00931 00932 static inline void pl_VectorMulAddD_NN1N (double *result, const double* input, double a, const double* b, PlankUL N) 00933 { 00934 vDSP_vsmaD (input, 1, &a, b, 1, result, 1, N); 00935 } 00936 00937 static inline void pl_VectorZMulD_ZNNNNN (double *resultReal, double *resultImag, 00938 const double* leftReal, const double* leftImag, 00939 const double* rightReal, const double* rightImag, 00940 PlankUL N) 00941 { 00942 DSPDoubleSplitComplex result, left, right; 00943 result.realp = resultReal; 00944 result.imagp = resultImag; 00945 left.realp = (double*)leftReal; 00946 left.imagp = (double*)leftImag; 00947 right.realp = (double*)rightReal; 00948 right.imagp = (double*)rightImag; 00949 vDSP_zvmulD (&left, 1, &right, 1, &result, 1, N, 1); 00950 } 00951 00952 // works as documented but seems useless as it interpolates thr "wrong" two samples 00953 // fixed in 10.7.2 but is that seems to be the runtime lib so would still 00954 // be dangerous to use without some runtime checking 00955 //static inline void pl_VectorLookupD_NnN (double *result, const double* table, PlankUL n, const double* index, PlankUL N) 00956 //{ 00957 // double mul = 1.0; 00958 // double add = 0.0; 00959 // vDSP_vtabiD ((double*)index, 1, &mul, &add, (double*)table, n, result, 1, N); 00960 //} 00961 PLANK_VECTORLOOKUP_DEFINE(D) 00962 00963 00964 00965 #undef I 00966 00967 00968 static inline void pl_VectorConvertD2F_NN (float *result, const double* input, PlankUL N) 00969 { 00970 vDSP_vdpsp ((double*)input, 1, result, 1, N); 00971 } 00972 00973 static inline void pl_VectorConvertC2F_NN (float *result, const char* input, PlankUL N) 00974 { 00975 vDSP_vflt8 ((char*)input, 1, result, 1, N); 00976 } 00977 00978 static inline void pl_VectorConvertI2F_NN (float *result, const int* input, PlankUL N) 00979 { 00980 vDSP_vflt32 ((int*)input, 1, result, 1, N); 00981 } 00982 00983 static inline void pl_VectorConvertS2F_NN (float *result, const short* input, PlankUL N) 00984 { 00985 vDSP_vflt16 ((short*)input, 1, result, 1, N); 00986 } 00987 00988 static inline void pl_VectorConvertF2D_NN (double *result, const float* input, PlankUL N) 00989 { 00990 vDSP_vspdp ((float*)input, 1, result, 1, N); 00991 } 00992 00993 static inline void pl_VectorConvertC2D_NN (double *result, const char* input, PlankUL N) 00994 { 00995 vDSP_vflt8D ((char*)input, 1, result, 1, N); 00996 } 00997 00998 static inline void pl_VectorConvertI2D_NN (double *result, const int* input, PlankUL N) 00999 { 01000 vDSP_vflt32D ((int*)input, 1, result, 1, N); 01001 } 01002 01003 static inline void pl_VectorConvertS2D_NN (double *result, const short* input, PlankUL N) 01004 { 01005 vDSP_vflt16D ((short*)input, 1, result, 1, N); 01006 } 01007 01008 static inline void pl_VectorConvertF2C_NN (char *result, const float* input, PlankUL N) 01009 { 01010 vDSP_vfix8 ((float*)input, 1, result, 1, N); 01011 } 01012 01013 static inline void pl_VectorConvertD2C_NN (char *result, const double* input, PlankUL N) 01014 { 01015 vDSP_vfix8D ((double*)input, 1, result, 1, N); 01016 } 01017 01018 PLANK_VECTORCONVERT_DEFINE(C,I) 01019 PLANK_VECTORCONVERT_DEFINE(C,S) 01020 01021 static inline void pl_VectorConvertF2I_NN (int *result, const float* input, PlankUL N) 01022 { 01023 vDSP_vfix32 ((float*)input, 1, result, 1, N); 01024 } 01025 01026 static inline void pl_VectorConvertD2I_NN (int *result, const double* input, PlankUL N) 01027 { 01028 vDSP_vfix32D ((double*)input, 1, result, 1, N); 01029 } 01030 01031 PLANK_VECTORCONVERT_DEFINE(I,C) 01032 PLANK_VECTORCONVERT_DEFINE(I,S) 01033 01034 static inline void pl_VectorConvertF2S_NN (short *result, const float* input, PlankUL N) 01035 { 01036 vDSP_vfix16 ((float*)input, 1, result, 1, N); 01037 } 01038 01039 static inline void pl_VectorConvertD2S_NN (short *result, const double* input, PlankUL N) 01040 { 01041 vDSP_vfix16D ((double*)input, 1, result, 1, N); 01042 } 01043 01044 PLANK_VECTORCONVERT_DEFINE(S,C) 01045 PLANK_VECTORCONVERT_DEFINE(S,I) 01046 01047 PLANK_VECTORCONVERT_DEFINE(LL,C) 01048 PLANK_VECTORCONVERT_DEFINE(LL,I) 01049 PLANK_VECTORCONVERT_DEFINE(LL,S) 01050 PLANK_VECTORCONVERT_DEFINE(LL,F) 01051 PLANK_VECTORCONVERT_DEFINE(LL,D) 01052 PLANK_VECTORCONVERT_DEFINE(C,LL) 01053 PLANK_VECTORCONVERT_DEFINE(I,LL) 01054 PLANK_VECTORCONVERT_DEFINE(S,LL) 01055 PLANK_VECTORCONVERT_DEFINE(F,LL) 01056 PLANK_VECTORCONVERT_DEFINE(D,LL) 01057 01058 01059 PLANK_VECTORCONVERTROUNDF_DEFINE(C) 01060 PLANK_VECTORCONVERTROUNDF_DEFINE(I) 01061 PLANK_VECTORCONVERTROUNDF_DEFINE(S) 01062 PLANK_VECTORCONVERTROUNDF_DEFINE(LL) 01063 PLANK_VECTORCONVERTROUNDD_DEFINE(C) 01064 PLANK_VECTORCONVERTROUNDD_DEFINE(I) 01065 PLANK_VECTORCONVERTROUNDD_DEFINE(S) 01066 PLANK_VECTORCONVERTROUNDD_DEFINE(LL) 01067 01068 01069 // short 01070 PLANK_VECTOR_OPS_COMMON(S) 01071 01072 // int 01073 PLANK_VECTORFILL_DEFINE(I) 01074 PLANK_VECTORCLEAR_DEFINE(I) 01075 PLANK_VECTORRAMP_DEFINE(I) 01076 PLANK_VECTORLINE_DEFINE(I) 01077 01078 PLANK_VECTORUNARYOP_DEFINE(Move,I) 01079 PLANK_VECTORUNARYOP_DEFINE(Inc,I) 01080 PLANK_VECTORUNARYOP_DEFINE(Dec,I) 01081 PLANK_VECTORUNARYOP_DEFINE(Neg,I) 01082 PLANK_VECTORUNARYOP_DEFINE(Abs,I) 01083 PLANK_VECTORUNARYOP_DEFINE(Squared,I) 01084 PLANK_VECTORUNARYOP_DEFINE(Cubed,I) 01085 PLANK_VECTORUNARYOP_DEFINE(Sign,I) 01086 01087 static inline void pl_VectorAddI_NNN (int *result, const int* a, const int* b, PlankUL N) 01088 { 01089 PlankUL vN, Nr, i; 01090 PlankVI* vResult; 01091 PlankVI* vA; 01092 PlankVI* vB; 01093 01094 vN = N >> PLANK_SIMDI_SHIFT; 01095 Nr = N & PLANK_SIMDI_MASK; 01096 01097 vResult = (PlankVI*)result; 01098 vA = (PlankVI*)a; 01099 vB = (PlankVI*)b; 01100 01101 for (i = 0; i < vN; ++i) 01102 *vResult++ = *vA++ + *vB++; 01103 01104 if (Nr) 01105 { 01106 result = (int*)vResult; 01107 a = (int*)vA; 01108 b = (int*)vB; 01109 01110 for (i = 0; i < Nr; ++i) 01111 *result++ = *a++ + *b++; 01112 } 01113 } 01114 01115 static inline void pl_VectorAddI_NN1 (int *result, const int* a, int b, PlankUL N) 01116 { 01117 PlankVI vB; 01118 PlankUL vN, Nr, i; 01119 PlankVI* vResult; 01120 PlankVI* vA; 01121 01122 vN = N >> PLANK_SIMDI_SHIFT; 01123 Nr = N & PLANK_SIMDI_MASK; 01124 01125 vResult = (PlankVI*)result; 01126 vA = (PlankVI*)a; 01127 01128 for (i = 0; i < PLANK_SIMDI_LENGTH; ++i) 01129 ((int*)&vB)[i] = b; 01130 01131 for (i = 0; i < vN; ++i) 01132 *vResult++ = *vA++ + vB; 01133 01134 if (Nr) 01135 { 01136 result = (int*)vResult; 01137 a = (int*)vA; 01138 01139 for (i = 0; i < Nr; ++i) 01140 *result++ = *a++ + b; 01141 } 01142 } 01143 01144 static inline void pl_VectorAddI_N1N (int *result, int a, const int* b, PlankUL N) 01145 { 01146 PlankVI vA; 01147 PlankUL vN, Nr, i; 01148 PlankVI* vResult; 01149 PlankVI* vB; 01150 01151 vN = N >> PLANK_SIMDI_SHIFT; 01152 Nr = N & PLANK_SIMDI_MASK; 01153 01154 vResult = (PlankVI*)result; 01155 vB = (PlankVI*)b; 01156 01157 for (i = 0; i < PLANK_SIMDI_LENGTH; ++i) 01158 ((int*)&vA)[i] = a; 01159 01160 for (i = 0; i < vN; ++i) 01161 *vResult++ = vA + *vB++; 01162 01163 if (Nr) 01164 { 01165 result = (int*)vResult; 01166 b = (int*)vB; 01167 01168 for (i = 0; i < Nr; ++i) 01169 *result++ = a + *b++; 01170 } 01171 } 01172 01173 01174 PLANK_VECTORBINARYOP_DEFINE(Sub,I) 01175 PLANK_VECTORBINARYOP_DEFINE(Mul,I) 01176 PLANK_VECTORBINARYOP_DEFINE(Div,I) 01177 PLANK_VECTORBINARYOP_DEFINE(Mod,I) 01178 PLANK_VECTORBINARYOP_DEFINE(Min,I) 01179 PLANK_VECTORBINARYOP_DEFINE(Max,I) 01180 01181 PLANK_VECTORBINARYOP_DEFINE(IsEqualTo,I) 01182 PLANK_VECTORBINARYOP_DEFINE(IsNotEqualTo,I) 01183 PLANK_VECTORBINARYOP_DEFINE(IsGreaterThan,I) 01184 PLANK_VECTORBINARYOP_DEFINE(IsGreaterThanOrEqualTo,I) 01185 PLANK_VECTORBINARYOP_DEFINE(IsLessThan,I) 01186 PLANK_VECTORBINARYOP_DEFINE(IsLessThanOrEqualTo,I) 01187 01188 PLANK_VECTORBINARYOP_DEFINE(SumSqr,I) 01189 PLANK_VECTORBINARYOP_DEFINE(DifSqr,I) 01190 PLANK_VECTORBINARYOP_DEFINE(SqrSum,I) 01191 PLANK_VECTORBINARYOP_DEFINE(SqrDif,I) 01192 PLANK_VECTORBINARYOP_DEFINE(AbsDif,I) 01193 PLANK_VECTORBINARYOP_DEFINE(Thresh,I) 01194 01195 PLANK_VECTORMULADD_DEFINE(I) 01196 PLANK_VECTORMULADDINPLACE_DEFINE(I) 01197 PLANK_VECTORMULSCALARADD_DEFINE(I) 01198 PLANK_VECTORSCALARMULSCALARADD_DEFINE(I) 01199 PLANK_VECTORSCALARMULADD_DEFINE(I) 01200 01201 PLANK_VECTORLOOKUP_DEFINE(I) 01202 01203 // longlong 01204 PLANK_VECTOR_OPS_COMMON(LL) 01205 01206 01207 01208 #endif // !DOXYGEN 01209 #endif // PLANK_VDSP_H 01210