00001
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 #include "dsp.h"
00047
00048 #if defined(FORCE_ALL_GENERICS) || \
00049 defined(FORCE_GENERIC_OP16_POW) || \
00050 !defined(TARGET_SPECIFIC_OP16_POW)
00051
00052 dsp16_t dsp16_op_pow(dsp16_t x, dsp16_t y)
00053 {
00054 S32 res, temp;
00055 int k;
00056 extern S32 dsp16_op_ln_raw(dsp16_t num);
00057
00058 if (x < DSP16_Q(0.))
00059 return (dsp16_t) DSP_Q_MIN(DSP16_QA, DSP16_QB);
00060
00061 res = dsp16_op_ln_raw(x) >> (DSP16_QB >> 1);
00062
00063 res = (res*((S32) y)) >> ((DSP16_QB&1)?(DSP16_QB >> 1)+1:(DSP16_QB >> 1));
00064
00065
00066 if (res < ((S32) DSP_Q_MIN(DSP16_QA, DSP16_QB)))
00067 {
00068
00069 temp = res >> (DSP16_QB - 2);
00070 k = (S32) DSP_Q(32-DSP16_QB, DSP16_QB, 1./CST_LN_2) >> 2;
00071 k = ((temp*k) >> (DSP16_QB)) + 1;
00072
00073
00074 temp = DSP16_Q(CST_LN_2);
00075
00076 temp = ((S32) res) - temp*((S32) k);
00077
00078 res = dsp16_op_exp((dsp16_t) temp);
00079
00080 res >>= dsp16_op_abs(k);
00081
00082 return (dsp16_t) res;
00083 }
00084
00085 if (res > ((S32) DSP_Q_MAX(DSP16_QA, DSP16_QB)))
00086 res = DSP_Q_MAX(DSP16_QA, DSP16_QB);
00087
00088 return (dsp16_t) dsp16_op_exp(res);
00089 }
00090
00091 #endif
00092
00093 #if defined(FORCE_ALL_GENERICS) || \
00094 defined(FORCE_GENERIC_OP32_POW) || \
00095 !defined(TARGET_SPECIFIC_OP32_POW)
00096
00097 dsp32_t dsp32_op_pow(dsp32_t x, dsp32_t y)
00098 {
00099 S64 res, temp;
00100 int k;
00101 extern S64 dsp32_op_ln_raw(dsp32_t num);
00102
00103 if (x < DSP32_Q(0.))
00104 return (dsp32_t) DSP_Q_MIN(DSP32_QA, DSP32_QB);
00105
00106 res = dsp32_op_ln_raw(x) >> (DSP32_QB >> 1);
00107
00108 res = (res*((S64) y)) >> ((DSP32_QB&1)?(DSP32_QB >> 1)+1:(DSP32_QB >> 1));
00109
00110
00111 if (res < ((S64) DSP_Q_MIN(DSP32_QA, DSP32_QB)))
00112 {
00113
00114 temp = res >> (DSP32_QB - 2);
00115 k = (S64) ((1LL/CST_LN_2)*(1LL << (DSP32_QB - 2 )));
00116 k = ((temp*k) >> (DSP32_QB)) + 1;
00117
00118
00119 temp = DSP32_Q(CST_LN_2);
00120
00121 temp = ((S64) res) - temp*((S64) k);
00122
00123 res = dsp32_op_exp((dsp32_t) temp);
00124
00125 res >>= dsp32_op_abs(k);
00126
00127 return (dsp32_t) res;
00128 }
00129
00130 if (res > ((S64) DSP_Q_MAX(DSP32_QA, DSP32_QB)))
00131 res = DSP_Q_MAX(DSP32_QA, DSP32_QB);
00132
00133 return (dsp32_t) dsp32_op_exp(res);
00134 }
00135
00136 #endif