Skip to content

Commit

Permalink
improvement(Wavelets): Runtime configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
NikitaChar committed Oct 30, 2023
1 parent d01dbdc commit a1dfb4d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
10 changes: 4 additions & 6 deletions Sources/Butterworth/WaveletsWrapper.mm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// WaveletsWrapper.cpp
//
//
//
// Created by Nikita Charushnikov on 01.08.23.
//
Expand All @@ -11,7 +11,7 @@

@implementation WaveletsWrapper

- (NSMutableArray<NSNumber *> *)stationaryWaveletTransformation: (double[]) signal :(int) signalSize :(NSString *) wavelet :(int) level {
- (void)stationaryWaveletTransformation: (double[]) signal :(double[]) result :(int) signalSize :(NSString *) wavelet :(int) level {

wave_object wave_obj;
wt_object wavelet_obj;
Expand All @@ -26,17 +26,15 @@ @implementation WaveletsWrapper

swt(wavelet_obj, signal);

NSMutableArray *waveletsOutput = [NSMutableArray array];

for (int i = 0; i < wavelet_obj->outlength; ++i) {
const double output = wavelet_obj->output[i];
[waveletsOutput addObject:[NSNumber numberWithDouble:output]];
result[i] = output;
}

wave_free(wave_obj);
wt_free(wavelet_obj);

return waveletsOutput;
}

@end

2 changes: 1 addition & 1 deletion Sources/Butterworth/include/WaveletsWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@

@interface WaveletsWrapper : NSObject

- (NSMutableArray<NSNumber *> *)stationaryWaveletTransformation: (double[]) signal :(int) signalSize :(NSString *) wavelet :(int) level;
- (void)stationaryWaveletTransformation: (double[]) signal :(double[]) result :(int) signalSize :(NSString *) wavelet :(int) level;

@end
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ class StationaryWaveletTransformation {
fatalError("For applying stationary wavelets transformation: signal.size% 2^^level == 0")
}

var inputSignal = [Double](signal)
let outputWaveletTransformationSize = signalSize * (level + 1)

let outputWaveletTransformationRaw = waveletsWrapper.stationaryWaveletTransformation(&inputSignal, Int32(signalSize), wavelet.rawValue, Int32(level))
var inputSignal = [Double](signal)
var outputWaveletTransformation = [Double].init(repeating: 0.0, count: outputWaveletTransformationSize)

let outputWaveletTransformation = outputWaveletTransformationRaw as! [Double]
waveletsWrapper.stationaryWaveletTransformation(&inputSignal, &outputWaveletTransformation, Int32(signalSize), wavelet.rawValue, Int32(level))


return extractCoefficients(waveletOutput: outputWaveletTransformation, level: level)
}

Expand Down

0 comments on commit a1dfb4d

Please sign in to comment.