vector_int.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #if !defined(_SPANDSP_VECTOR_INT_H_)
00029 #define _SPANDSP_VECTOR_INT_H_
00030
00031 #if defined(__cplusplus)
00032 extern "C"
00033 {
00034 #endif
00035
00036 static __inline__ void vec_copyi(int z[], const int x[], int n)
00037 {
00038 memcpy(z, x, n*sizeof(z[0]));
00039 }
00040
00041
00042 static __inline__ void vec_copyi16(int16_t z[], const int16_t x[], int n)
00043 {
00044 memcpy(z, x, n*sizeof(z[0]));
00045 }
00046
00047
00048 static __inline__ void vec_copyi32(int32_t z[], const int32_t x[], int n)
00049 {
00050 memcpy(z, x, n*sizeof(z[0]));
00051 }
00052
00053
00054 static __inline__ void vec_zeroi(int z[], int n)
00055 {
00056 memset(z, 0, n*sizeof(z[0]));
00057 }
00058
00059
00060 static __inline__ void vec_zeroi16(int16_t z[], int n)
00061 {
00062 memset(z, 0, n*sizeof(z[0]));
00063 }
00064
00065
00066 static __inline__ void vec_zeroi32(int32_t z[], int n)
00067 {
00068 memset(z, 0, n*sizeof(z[0]));
00069 }
00070
00071
00072 static __inline__ void vec_seti(int z[], int x, int n)
00073 {
00074 int i;
00075
00076 for (i = 0; i < n; i++)
00077 z[i] = x;
00078 }
00079
00080
00081 static __inline__ void vec_seti16(int16_t z[], int16_t x, int n)
00082 {
00083 int i;
00084
00085 for (i = 0; i < n; i++)
00086 z[i] = x;
00087 }
00088
00089
00090 static __inline__ void vec_seti32(int32_t z[], int32_t x, int n)
00091 {
00092 int i;
00093
00094 for (i = 0; i < n; i++)
00095 z[i] = x;
00096 }
00097
00098
00099
00100
00101
00102
00103
00104 int32_t vec_dot_prodi16(const int16_t x[], const int16_t y[], int n);
00105
00106
00107
00108
00109
00110
00111
00112
00113 int32_t vec_circular_dot_prodi16(const int16_t x[], const int16_t y[], int n, int pos);
00114
00115 void vec_lmsi16(const int16_t x[], int16_t y[], int n, int16_t error);
00116
00117 void vec_circular_lmsi16(const int16_t x[], int16_t y[], int n, int pos, int16_t error);
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128 int32_t vec_min_maxi16(const int16_t x[], int n, int16_t out[]);
00129
00130 static __inline__ int vec_norm2i16(const int16_t *vec, int len)
00131 {
00132 int i;
00133 int sum;
00134
00135 sum = 0;
00136 for (i = 0; i < len; i++)
00137 sum += vec[i]*vec[i];
00138 return sum;
00139 }
00140
00141
00142 static __inline__ void vec_sari16(int16_t *vec, int len, int shift)
00143 {
00144 int i;
00145
00146 for (i = 0; i < len; i++)
00147 vec[i] >>= shift;
00148 }
00149
00150
00151 static __inline__ int vec_max_bitsi16(const int16_t *vec, int len)
00152 {
00153 int i;
00154 int max;
00155 int v;
00156 int b;
00157
00158 max = 0;
00159 for (i = 0; i < len; i++)
00160 {
00161 v = abs(vec[i]);
00162 if (v > max)
00163 max = v;
00164 }
00165 b = 0;
00166 while (max != 0)
00167 {
00168 b++;
00169 max >>= 1;
00170 }
00171 return b;
00172 }
00173
00174
00175 #if defined(__cplusplus)
00176 }
00177 #endif
00178
00179 #endif
00180