Skip to content

Commit f299f5f

Browse files
author
mars
committed
Merge branch 'master' of github.com:pingdynasty/OwlProgram
2 parents 9c676f7 + 16fb7a2 commit f299f5f

8 files changed

Lines changed: 378 additions & 65 deletions

File tree

LibSource/ComplexFloatArray.cpp

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
float ComplexFloatArray::mag(const int i){
66
float result;
7+
/// @note When built for ARM Cortex-M processor series, this method uses the optimized <a href="http://www.keil.com/pack/doc/CMSIS/General/html/index.html">CMSIS library</a>
78
#ifdef ARM_CORTEX
89
arm_cmplx_mag_f32((float*)&(data[i]), &result,1);
910
#else
@@ -12,18 +13,20 @@ float ComplexFloatArray::mag(const int i){
1213
return result;
1314
}
1415

15-
void ComplexFloatArray::getMagnitudeValues(FloatArray& dest){
16+
void ComplexFloatArray::getMagnitudeValues(FloatArray& destination){
17+
/// @note When built for ARM Cortex-M processor series, this method uses the optimized <a href="http://www.keil.com/pack/doc/CMSIS/General/html/index.html">CMSIS library</a>
1618
#ifdef ARM_CORTEX
17-
arm_cmplx_mag_f32((float*)data, (float*)dest, size);
19+
arm_cmplx_mag_f32((float*)data, (float*)destination, size);
1820
#else
1921
for(int i=0; i<size; i++){
20-
dest[i]=mag(i);
22+
destination[i]=mag(i);
2123
}
2224
#endif
2325
}
2426

2527
float ComplexFloatArray::mag2(const int i){
2628
float result;
29+
/// @note When built for ARM Cortex-M processor series, this method uses the optimized <a href="http://www.keil.com/pack/doc/CMSIS/General/html/index.html">CMSIS library</a>
2730
#ifdef ARM_CORTEX
2831
arm_cmplx_mag_squared_f32((float*)&(data[i]), &result, 1);
2932
#else
@@ -34,17 +37,19 @@ float ComplexFloatArray::mag2(const int i){
3437
return result;
3538
}
3639

37-
void ComplexFloatArray::getMagnitudeSquaredValues(FloatArray& dest){
40+
void ComplexFloatArray::getMagnitudeSquaredValues(FloatArray& destination){
41+
/// @note When built for ARM Cortex-M processor series, this method uses the optimized <a href="http://www.keil.com/pack/doc/CMSIS/General/html/index.html">CMSIS library</a>
3842
#ifdef ARM_CORTEX
39-
arm_cmplx_mag_squared_f32((float*)data, (float*)dest, size);
43+
arm_cmplx_mag_squared_f32((float*)data, (float*)destination, size);
4044
#else
4145
for(int i=0; i<size; i++){
42-
dest[i]=mag2(i);
46+
destination[i]=mag2(i);
4347
}
4448
#endif
4549
}
4650

4751
void ComplexFloatArray::complexDotProduct(ComplexFloatArray& operand2, ComplexFloat& result){
52+
/// @note When built for ARM Cortex-M processor series, this method uses the optimized <a href="http://www.keil.com/pack/doc/CMSIS/General/html/index.html">CMSIS library</a>
4853
#ifdef ARM_CORTEX
4954
arm_cmplx_dot_prod_f32 ( (float*)data, (float*)operand2, size, &(result.re), &(result.im) );
5055
#else
@@ -62,27 +67,29 @@ void ComplexFloatArray::complexDotProduct(ComplexFloatArray& operand2, ComplexFl
6267
}
6368

6469
void ComplexFloatArray::complexByComplexMultiplication(ComplexFloatArray& operand2, ComplexFloatArray& result){
65-
int minSize=min(size,operand2.getSize()); //TODO: shall we take this out and allow it to segfault?
70+
ASSERT(size==operand2.getSize(), "Wrong size");
71+
/// @note When built for ARM Cortex-M processor series, this method uses the optimized <a href="http://www.keil.com/pack/doc/CMSIS/General/html/index.html">CMSIS library</a>
6672
#ifdef ARM_CORTEX
67-
arm_cmplx_mult_cmplx_f32 ( (float*)data, (float*)operand2, (float*)result, minSize );
73+
arm_cmplx_mult_cmplx_f32 ( (float*)data, (float*)operand2, (float*)result, size );
6874
#else
6975
float *pSrcA=(float*)data;
7076
float *pSrcB=(float*)operand2;
7177
float *pDst=(float*)result;
72-
for(int n=0; n<minSize; n++) {
78+
for(int n=0; n<size; n++) {
7379
pDst[(2*n)+0] = pSrcA[(2*n)+0] * pSrcB[(2*n)+0] - pSrcA[(2*n)+1] * pSrcB[(2*n)+1];
7480
pDst[(2*n)+1] = pSrcA[(2*n)+0] * pSrcB[(2*n)+1] + pSrcA[(2*n)+1] * pSrcB[(2*n)+0];
7581
}
7682
#endif
7783
}
7884

79-
void ComplexFloatArray::getComplexConjugateValues(ComplexFloatArray& buf){
80-
int minSize= min(size,buf.getSize()); //TODO: shall we take this out and allow it to segfault?
85+
void ComplexFloatArray::getComplexConjugateValues(ComplexFloatArray& destination){
86+
ASSERT(size==destination.getSize(), "Wrong size");
87+
/// @note When built for ARM Cortex-M processor series, this method uses the optimized <a href="http://www.keil.com/pack/doc/CMSIS/General/html/index.html">CMSIS library</a>
8188
#ifdef ARM_CORTEX
82-
arm_cmplx_conj_f32( (float*)data, (float*)buf, minSize );
89+
arm_cmplx_conj_f32( (float*)data, (float*)destination, size );
8390
#else
8491
float *pSrc=(float*)data;
85-
float *pDst=(float *)buf;
92+
float *pDst=(float *)destination;
8693
for(int n=0; n<size; n++) {
8794
pDst[(2*n)+0] = pSrc[(2*n)+0]; // real part
8895
pDst[(2*n)+1] = -pSrc[(2*n)+1]; // imag part
@@ -91,9 +98,10 @@ void ComplexFloatArray::getComplexConjugateValues(ComplexFloatArray& buf){
9198
}
9299

93100
void ComplexFloatArray::complexByRealMultiplication(FloatArray& operand2, ComplexFloatArray& result){
94-
int minSize= min(size,operand2.getSize()); //TODO: shall we take this out and allow it to segfault?
101+
ASSERT(size==operand2.getSize(), "Wrong size");
102+
/// @note When built for ARM Cortex-M processor series, this method uses the optimized <a href="http://www.keil.com/pack/doc/CMSIS/General/html/index.html">CMSIS library</a>
95103
#ifdef ARM_CORTEX
96-
arm_cmplx_mult_real_f32 ( (float*)data, (float*)operand2, (float*)result, minSize );
104+
arm_cmplx_mult_real_f32 ( (float*)data, (float*)operand2, (float*)result, size );
97105
#else
98106
float *pSrcCmplx=(float*)data;
99107
float *pSrcReal=(float*)operand2;
@@ -148,8 +156,9 @@ void ComplexFloatArray::getImaginaryValues(FloatArray& buf){
148156
}
149157

150158
void ComplexFloatArray::scale(float factor){
159+
/// @note When built for ARM Cortex-M processor series, this method uses the optimized <a href="http://www.keil.com/pack/doc/CMSIS/General/html/index.html">CMSIS library</a>
151160
#ifdef ARM_CORTEX
152-
arm_scale_f32((float*)data, factor, (float*)data, size*2);
161+
arm_scale_f32((float*)data, factor, (float*)data, size*2); //the *2 accounts for the fact that both real and imaginary parts are scaled
153162
#else
154163
for(int n=0; n<size; n++){
155164
data[n].re *= factor;
@@ -193,6 +202,7 @@ void ComplexFloatArray::copyFrom(ComplexFloatArray source){
193202

194203
void ComplexFloatArray::copyTo(ComplexFloat* other, int length){
195204
ASSERT(size >= length, "Array too small");
205+
/// @note When built for ARM Cortex-M processor series, this method uses the optimized <a href="http://www.keil.com/pack/doc/CMSIS/General/html/index.html">CMSIS library</a>
196206
#ifdef ARM_CORTEX
197207
arm_copy_f32((float *)data, (float *)other, length*sizeof(ComplexFloat)/sizeof(float));
198208
#else
@@ -205,6 +215,7 @@ void ComplexFloatArray::copyTo(ComplexFloat* other, int length){
205215

206216
void ComplexFloatArray::copyFrom(ComplexFloat* other, int length){
207217
ASSERT(size >= length, "Array too small");
218+
/// @note When built for ARM Cortex-M processor series, this method uses the optimized <a href="http://www.keil.com/pack/doc/CMSIS/General/html/index.html">CMSIS library</a>
208219
#ifdef ARM_CORTEX
209220
arm_copy_f32((float *)other, (float *)data, length*sizeof(ComplexFloat)/sizeof(float)); //note the *2 multiplier which accounts for real and imaginary parts
210221
#else
@@ -214,7 +225,9 @@ void ComplexFloatArray::copyFrom(ComplexFloat* other, int length){
214225
}
215226
#endif /* ARM_CORTEX */
216227
}
228+
217229
void ComplexFloatArray::setAll(float value){
230+
/// @note When built for ARM Cortex-M processor series, this method uses the optimized <a href="http://www.keil.com/pack/doc/CMSIS/General/html/index.html">CMSIS library</a>
218231
#ifdef ARM_CORTEX
219232
arm_fill_f32(value, (float *)data, size *2 ); //note the *2 multiplier which accounts for real and imaginary parts
220233
#else
@@ -225,12 +238,14 @@ void ComplexFloatArray::setAll(float value){
225238
#endif /* ARM_CORTEX */
226239
}
227240
/*END -- methods copied and adapted from ComplexFloatArray.cpp*/
241+
228242
void ComplexFloatArray::setAll(ComplexFloat value){
229243
for(int n=0; n<size; n++){
230244
data[n].re=value.re;
231245
data[n].im=value.im;
232246
}
233247
}
248+
234249
void ComplexFloatArray::setAll(float valueRe, float valueIm){
235250
ComplexFloat value;
236251
value.re=valueRe;
@@ -280,4 +295,4 @@ void ComplexFloatArray::setMagnitude(FloatArray magnitude, int offset, int count
280295
for(int n=offset; n<count+offset; n++){
281296
destination.getData()[n].setPolar(magnitude[n], getData()[n].getPhase());
282297
}
283-
}
298+
}

0 commit comments

Comments
 (0)