Skip to content

Commit 13adcc3

Browse files
author
mars
committed
always pass FloatArray and ComplexFloatArray by value, not reference
1 parent 80ad4eb commit 13adcc3

5 files changed

Lines changed: 27 additions & 27 deletions

File tree

LibSource/ComplexFloatArray.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ float ComplexFloatArray::mag(const int i){
1313
return result;
1414
}
1515

16-
void ComplexFloatArray::getMagnitudeValues(FloatArray& destination){
16+
void ComplexFloatArray::getMagnitudeValues(FloatArray destination){
1717
/// @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>
1818
#ifdef ARM_CORTEX
1919
arm_cmplx_mag_f32((float*)data, (float*)destination, size);
@@ -37,7 +37,7 @@ float ComplexFloatArray::mag2(const int i){
3737
return result;
3838
}
3939

40-
void ComplexFloatArray::getMagnitudeSquaredValues(FloatArray& destination){
40+
void ComplexFloatArray::getMagnitudeSquaredValues(FloatArray destination){
4141
/// @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>
4242
#ifdef ARM_CORTEX
4343
arm_cmplx_mag_squared_f32((float*)data, (float*)destination, size);
@@ -48,7 +48,7 @@ void ComplexFloatArray::getMagnitudeSquaredValues(FloatArray& destination){
4848
#endif
4949
}
5050

51-
void ComplexFloatArray::complexDotProduct(ComplexFloatArray& operand2, ComplexFloat& result){
51+
void ComplexFloatArray::complexDotProduct(ComplexFloatArray operand2, ComplexFloat& result){
5252
/// @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>
5353
#ifdef ARM_CORTEX
5454
arm_cmplx_dot_prod_f32 ( (float*)data, (float*)operand2, size, &(result.re), &(result.im) );
@@ -66,7 +66,7 @@ void ComplexFloatArray::complexDotProduct(ComplexFloatArray& operand2, ComplexFl
6666
#endif
6767
}
6868

69-
void ComplexFloatArray::complexByComplexMultiplication(ComplexFloatArray& operand2, ComplexFloatArray& result){
69+
void ComplexFloatArray::complexByComplexMultiplication(ComplexFloatArray operand2, ComplexFloatArray result){
7070
ASSERT(operand2.size == size && result.size >= size, "Arrays size mismatch");
7171
/// @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>
7272
#ifdef ARM_CORTEX
@@ -114,7 +114,7 @@ void ComplexFloatArray::subtract(ComplexFloatArray operand2){
114114
subtract(operand2, *this);
115115
}
116116

117-
void ComplexFloatArray::getComplexConjugateValues(ComplexFloatArray& destination){
117+
void ComplexFloatArray::getComplexConjugateValues(ComplexFloatArray destination){
118118
ASSERT(size==destination.getSize(), "Wrong array size");
119119
/// @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>
120120
#ifdef ARM_CORTEX
@@ -129,7 +129,7 @@ void ComplexFloatArray::getComplexConjugateValues(ComplexFloatArray& destination
129129
#endif
130130
}
131131

132-
void ComplexFloatArray::complexByRealMultiplication(FloatArray& operand2, ComplexFloatArray& result){
132+
void ComplexFloatArray::complexByRealMultiplication(FloatArray operand2, ComplexFloatArray result){
133133
ASSERT(size==operand2.getSize(), "Wrong size");
134134
/// @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>
135135
#ifdef ARM_CORTEX
@@ -175,13 +175,13 @@ float ComplexFloatArray::getMaxMagnitudeValue(){ //this is probably slower than
175175
return maxMag;
176176
}
177177

178-
void ComplexFloatArray::getRealValues(FloatArray& buf){
178+
void ComplexFloatArray::getRealValues(FloatArray buf){
179179
for(int n=0; n<size; n++){
180180
buf[n]=data[n].re;
181181
}
182182
}
183183

184-
void ComplexFloatArray::getImaginaryValues(FloatArray& buf){
184+
void ComplexFloatArray::getImaginaryValues(FloatArray buf){
185185
for(int n=0; n<size; n++){
186186
buf[n]=data[n].im;
187187
}

LibSource/ComplexFloatArray.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ class ComplexFloatArray {
122122
The magnitudes of the elements of the array.
123123
@param[out] destination The array where the magnitude values will be stored.
124124
*/
125-
void getMagnitudeValues(FloatArray& destination);
125+
void getMagnitudeValues(FloatArray destination);
126126

127127
/**
128128
The magnitude squared of an element of the array.
@@ -135,34 +135,34 @@ class ComplexFloatArray {
135135
The squared magnitudes of the elements of the array.
136136
@param[out] destination The array where the magnitude squared values will be stored.
137137
*/
138-
void getMagnitudeSquaredValues(FloatArray& destination);
138+
void getMagnitudeSquaredValues(FloatArray destination);
139139

140140
/**
141141
The complex conjugate values of the element of the array.
142142
@param[out] destination The array where the complex conjugate values will be stored.
143143
*/
144-
void getComplexConjugateValues(ComplexFloatArray& destination);
144+
void getComplexConjugateValues(ComplexFloatArray destination);
145145

146146
/**
147147
Complex dot product between arrays.
148148
@param[in] operand2 The second operand of the dot product
149149
@param[out] result The array where the result of the dot product is stored
150150
*/
151-
void complexDotProduct(ComplexFloatArray& operand2, ComplexFloat& result);
151+
void complexDotProduct(ComplexFloatArray operand2, ComplexFloat& result);
152152

153153
/**
154154
Complex by complex multiplication between arrays.
155155
@param[in] operand2 The second operand of the multiplication
156156
@param[out] result The array where the result of the multiplication is stored
157157
*/
158-
void complexByComplexMultiplication(ComplexFloatArray& operand2, ComplexFloatArray& result);
158+
void complexByComplexMultiplication(ComplexFloatArray operand2, ComplexFloatArray result);
159159

160160
/**
161161
Complex by real multiplication between arrays.
162162
@param[in] operand2 The second operand of the multiplication
163163
@param[out] result The array where the result of the multiplication is stored
164164
*/
165-
void complexByRealMultiplication(FloatArray& operand2, ComplexFloatArray& result);
165+
void complexByRealMultiplication(FloatArray operand2, ComplexFloatArray result);
166166

167167
/**
168168
* Element-wise sum between complex arrays.
@@ -226,12 +226,12 @@ class ComplexFloatArray {
226226
/** Get the real part of the elements of the array.
227227
* @param[out] buf The array where the real part will be stored.
228228
*/
229-
void getRealValues(FloatArray& buf);
229+
void getRealValues(FloatArray buf);
230230

231231
/** Get the imaginary part of the elements of the array.
232232
* @param[out] buf The array where the imaginary part will be stored.
233233
*/
234-
void getImaginaryValues(FloatArray& buf);
234+
void getImaginaryValues(FloatArray buf);
235235

236236
/** Array by scalar multiplication.
237237
* @param factor The value by which all the elements of the array are multiplied.
@@ -297,7 +297,7 @@ class ComplexFloatArray {
297297
* @return <code>true</code> if the arrays have the same size and the value of each of the elements of the one
298298
* match the value of the corresponding element of the other, or <code>false</code> otherwise.
299299
*/
300-
bool equals(const ComplexFloatArray& other) const{
300+
bool equals(const ComplexFloatArray other) const{
301301
if(size!=other.getSize()){
302302
return false;
303303
}

LibSource/ComplexFourierTransform.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ class ComplexFourierTransform {
2020
getProgramVector()->serviceCall(OWL_SERVICE_ARM_CFFT_INIT_F32, args, 2);
2121
// Supported FFT Lengths are 32, 64, 128, 256, 512, 1024, 2048, 4096.
2222
}
23-
void fft(ComplexFloatArray& inout){
23+
void fft(ComplexFloatArray inout){
2424
ASSERT(inout.getSize() >= getSize(), "Input array too small");
2525
arm_cfft_f32(&instance, (float*)inout, 0, 1); //forward
2626
}
27-
void ifft(ComplexFloatArray& inout){
27+
void ifft(ComplexFloatArray inout){
2828
ASSERT(inout.getSize() >= getSize(), "Input array too small");
2929
arm_cfft_f32(&instance, (float*)inout, 1, 1); //inverse
3030
}
@@ -55,12 +55,12 @@ class ComplexFourierTransform {
5555
cfgifft = kiss_fft_alloc(len, 1,0, 0);
5656
temp = ComplexFloatArray::create(getSize());
5757
}
58-
void fft(ComplexFloatArray& inout){
58+
void fft(ComplexFloatArray inout){
5959
ASSERT(inout.getSize() >= getSize(), "Input array too small");
6060
kiss_fft(cfgfft, (kiss_fft_cpx*)(float*)inout.getData(), (kiss_fft_cpx*)(float*)temp.getData());
6161
inout.copyFrom(temp);
6262
}
63-
void ifft(ComplexFloatArray& inout){
63+
void ifft(ComplexFloatArray inout){
6464
ASSERT(inout.getSize() >= getSize(), "Input array too small");
6565
kiss_fft(cfgifft, (kiss_fft_cpx*)(float*)inout, (kiss_fft_cpx*)(float*)temp.getData());
6666
temp.scale(1.0f/getSize());

LibSource/FastFourierTransform.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ void FastFourierTransform::init(int len){
2020
// Supported FFT Lengths are 32, 64, 128, 256, 512, 1024, 2048, 4096.
2121
}
2222

23-
void FastFourierTransform::fft(FloatArray& in, ComplexFloatArray& out){
23+
void FastFourierTransform::fft(FloatArray in, ComplexFloatArray out){
2424
ASSERT(in.getSize() >= getSize(), "Input array too small");
2525
ASSERT(out.getSize() >= getSize(), "Output array too small");
2626
arm_rfft_fast_f32(&instance, (float*)in, (float*)out, 0);
2727
}
2828

29-
void FastFourierTransform::ifft(ComplexFloatArray& in, FloatArray& out){
29+
void FastFourierTransform::ifft(ComplexFloatArray in, FloatArray out){
3030
ASSERT(in.getSize() >= getSize(), "Input array too small");
3131
ASSERT(out.getSize() >= getSize(), "Output array too small");
3232
arm_rfft_fast_f32(&instance, (float*)in, (float*)out, 1);
@@ -55,7 +55,7 @@ void FastFourierTransform::init(int aSize){
5555
temp = ComplexFloatArray::create(getSize());
5656
}
5757

58-
void FastFourierTransform::fft(FloatArray& input, ComplexFloatArray& output){
58+
void FastFourierTransform::fft(FloatArray input, ComplexFloatArray output){
5959
ASSERT(input.getSize() >= getSize(), "Input array too small");
6060
ASSERT(output.getSize() >= getSize(), "Output array too small");
6161
for(int n=0; n<getSize(); n++){
@@ -65,7 +65,7 @@ void FastFourierTransform::fft(FloatArray& input, ComplexFloatArray& output){
6565
kiss_fft(cfgfft, (kiss_fft_cpx*)(float*)temp.getData(), (kiss_fft_cpx*)(float*)output);
6666
}
6767

68-
void FastFourierTransform::ifft(ComplexFloatArray& input, FloatArray& output){
68+
void FastFourierTransform::ifft(ComplexFloatArray input, FloatArray output){
6969
ASSERT(input.getSize() >= getSize(), "Input array too small");
7070
ASSERT(output.getSize() >= getSize(), "Output array too small");
7171
kiss_fft(cfgifft, (kiss_fft_cpx*)(float*)input, (kiss_fft_cpx*)(float*)temp.getData());

LibSource/FastFourierTransform.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class FastFourierTransform {
5353
* @remarks Calling this method will mess up the content of the **input** array.
5454
* @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>
5555
*/
56-
void fft(FloatArray& input, ComplexFloatArray& output);
56+
void fft(FloatArray input, ComplexFloatArray output);
5757

5858
/**
5959
* Perform the inverse FFT.
@@ -64,7 +64,7 @@ class FastFourierTransform {
6464
* @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>
6565
*
6666
*/
67-
void ifft(ComplexFloatArray& input, FloatArray& output);
67+
void ifft(ComplexFloatArray input, FloatArray output);
6868

6969
/**
7070
* Get the size of the FFT

0 commit comments

Comments
 (0)