Skip to content

Commit 33ca2e1

Browse files
committed
Added docs for the FloatArray Class
1 parent 98ba0a5 commit 33ca2e1

2 files changed

Lines changed: 366 additions & 35 deletions

File tree

LibSource/FloatArray.cpp

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,7 @@ void FloatArray::copyFrom(float* other, int length){
240240
memcpy((void *)getData(), (void *)other, length*sizeof(float));
241241
#endif /* ARM_CORTEX */
242242
}
243-
/*
244-
* Copies @samples samples starting from sample @sourceOffset of @source to @destinationOffset in the current FloatArray
245-
*/
243+
246244
void FloatArray::insert(FloatArray source, int sourceOffset, int destinationOffset, int samples){
247245
ASSERT(size >= destinationOffset+samples, "Array too small");
248246
ASSERT(source.size >= sourceOffset+samples, "Array too small");
@@ -252,16 +250,14 @@ void FloatArray::insert(FloatArray source, int sourceOffset, int destinationOffs
252250
memcpy((void*)(getData()+destinationOffset), (void*)(source.getData()+sourceOffset), samples*sizeof(float));
253251
#endif /* ARM_CORTEX */
254252
}
255-
/*
256-
* Copies @samples samples from the beginning of @source to @destinationOffset in the current FloatArray
257-
*/
253+
258254
void FloatArray::insert(FloatArray source, int destinationOffset, int samples){
259255
insert(source, 0, destinationOffset, samples);
260256
}
261257

262258
void FloatArray::move(int fromIndex, int toIndex, int samples){
263259
ASSERT(size >= toIndex+samples, "Array too small");
264-
memmove(data+toIndex, data+fromIndex, samples*sizeof(float));
260+
memmove(data+toIndex, data+fromIndex, samples*sizeof(float)); //TODO: evaluate if it is appropriate to use arm_copy_f32 for this method
265261
}
266262

267263
void FloatArray::setAll(float value){
@@ -376,10 +372,7 @@ void FloatArray::noise(float min, float max){
376372
}
377373
}
378374

379-
/**
380-
* Perform the convolution of this FloatArray with @operand2, putting the result in @destination.
381-
* @destination must have a minimum size of this+other-1.
382-
*/
375+
383376
void FloatArray::convolve(FloatArray operand2, FloatArray destination){
384377
ASSERT(destination.size >= size + operand2.size -1, "Destination array too small");
385378
#ifdef ARM_CORTEX
@@ -398,16 +391,14 @@ void FloatArray::convolve(FloatArray operand2, FloatArray destination){
398391
#endif /* ARM_CORTEX */
399392
}
400393

401-
/**
402-
* Perform partial convolution: start at @offset and compute @samples points
403-
*/
404394
void FloatArray::convolve(FloatArray operand2, FloatArray destination, int offset, int samples){
405-
ASSERT(destination.size >= samples, "Destination array too small");
395+
ASSERT(destination.size >= size + operand2.size -1, "Destination array too small"); //TODO: change this condition to the actual size being written(will be samples+ tail)
406396
#ifdef ARM_CORTEX
407397
//TODO: I suspect a bug in arm_conv_partial_f32
408398
//it seems that destination[n] is left unchanged for n<offset
409399
//and the result is actually stored from destination[offset] onwards
410-
//that is, in the same position where they would be if a full convolution was performerd
400+
//that is, in the same position where they would be if a full convolution was performed.
401+
//This requires (destination.size >= size + operand2.size -1). Ideally you would want destination to be smaller
411402
arm_conv_partial_f32(data, size, operand2.data, operand2.size, destination.getData(), offset, samples);
412403
#else
413404
//this implementations reproduces the (buggy?) behaviour of arm_conv_partial (see comment above and inline comments below)
@@ -427,17 +418,10 @@ void FloatArray::convolve(FloatArray operand2, FloatArray destination, int offse
427418
#endif /* ARM_CORTEX */
428419
}
429420

430-
/*
431-
* @destination must have a minimum size of 2*max(srcALen, srcBLen)-1.
432-
*/
433421
void FloatArray::correlate(FloatArray operand2, FloatArray destination){
434422
destination.setAll(0);
435423
correlateInitialized(operand2, destination);
436424
}
437-
/*
438-
* @destination must have a minimum size of 2*max(srcALen, srcBLen)-1.
439-
* @destination must have been initialized to 0
440-
*/
441425
void FloatArray::correlateInitialized(FloatArray operand2, FloatArray destination){
442426
ASSERT(destination.size >= size+operand2.size-1, "Destination array too small"); //TODO: change CMSIS docs, which state a different size
443427
#ifdef ARM_CORTEX
@@ -458,4 +442,4 @@ FloatArray FloatArray::create(int size){
458442

459443
void FloatArray::destroy(FloatArray array){
460444
delete array.data;
461-
}
445+
}

0 commit comments

Comments
 (0)