Skip to content

Commit

Permalink
Updated the JNI stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
berndporr committed Feb 15, 2021
1 parent a65b47f commit ee2ecbd
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 15 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.1.0)

project(kiss-fft VERSION 1.1.0 LANGUAGES CXX)
project(kiss-fft VERSION 1.2.0 LANGUAGES CXX)

set (CMAKE_CXX_STANDARD 11)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
Expand Down
6 changes: 3 additions & 3 deletions jnifft/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ android {
defaultConfig {
minSdkVersion 16
targetSdkVersion 30
versionCode 2
versionName "1.1.0"
versionCode 3
versionName "1.2.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
Expand All @@ -29,7 +29,7 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
testImplementation 'junit:junit:4.13.1'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation group: 'org.apache.commons', name: 'commons-math3', version: '3.6.1'
Expand Down
Binary file added jnifft/build/outputs/aar/jnifft-debug.aar
Binary file not shown.
Binary file added jnifft/build/outputs/aar/jnifft-release.aar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,23 @@
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class BenchTest {
public class BenchmarkTest {

final String TAG = BenchmarkTest.class.getSimpleName();

private void doFFTandIFFTCommons() {
FastFourierTransformer fastFourierTransformer = new FastFourierTransformer(DftNormalization.STANDARD);

final int testsize = 65536;
Complex[] indata = new Complex[testsize];
for (int i = 0; i < testsize; i++) indata[i] = new Complex(Math.random() - 0.5);
Log.d("FFTTest", "start FFTCommons");
Log.d(TAG, "start FFTCommons");
for(int i=0;i<20;i++) {
Log.d("FFTTest", ""+i);
Log.d(TAG, ""+i);
Complex[] indata2 = fastFourierTransformer.transform(indata, TransformType.FORWARD);
indata = fastFourierTransformer.transform(indata2, TransformType.INVERSE);
}
Log.d("FFTTest", "stop FFTCommons");
Log.d(TAG, "stop FFTCommons");
}


Expand All @@ -41,13 +42,13 @@ private void doFFTandIFFTKISS() {
final int testsize = 65536;
Complex[] indata = new Complex[testsize];
for (int i = 0; i < testsize; i++) indata[i] = new Complex(Math.random() - 0.5);
Log.d("FFTTest", "start FFT KISS");
Log.d(TAG, "start FFT KISS");
for(int i=0;i<20;i++) {
Log.d("FFTTest", ""+i);
Log.d(TAG, ""+i);
Complex[] indata2 = kissfastFourierTransformer.transform(indata,TransformType.FORWARD);
indata = kissfastFourierTransformer.transform(indata2,TransformType.INVERSE);
}
Log.d("FFTTest", "stop FFT KISS");
Log.d(TAG, "stop FFT KISS");
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public class FFTRTest {

private KISSFastFourierTransformer kissFastFourierTransformer;

final String TAG = FFTRTest.class.getSimpleName();

@Test
public void compareWithMathCommons() {
kissFastFourierTransformer = new KISSFastFourierTransformer();
Expand All @@ -40,7 +42,7 @@ public void compareWithMathCommons() {
Complex[] outdata2 = fastFourierTransformer.transform(indata, TransformType.FORWARD);
for (int i = 0; i < outdata1.length; i++) {
double err = outdata1[i].subtract(outdata2[i]).abs();
Log.d("FFTTest", "" + i +
Log.d(TAG, "" + i +
" (" + outdata1[i].getReal() + "," + outdata1[i].getImaginary() + ") -- " +
" (" + outdata2[i].getReal() + "," + outdata2[i].getImaginary() + ") = " + err);
assertTrue(err < 1E-10);
Expand All @@ -59,7 +61,7 @@ public void doFFTandIFFT() {
double[] outdata2 = kissFastFourierTransformer.transformRealOptimisedInverse(outdata1);
for (int i = 0; i < testsize; i++) {
double err = Math.abs(indata[i] - outdata2[i]);
Log.d("FFTTest", "" + i +
Log.d(TAG, "" + i +
" (" + indata[i] + ",0) -- " +
" (" + outdata2[i] + "0) = " + err);
assertTrue(err < 1E-15);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
@RunWith(AndroidJUnit4.class)
public class FFTTest {

final String TAG = FFTTest.class.getSimpleName();

private KISSFastFourierTransformer kissFastFourierTransformer;

@Test
Expand All @@ -40,7 +42,7 @@ public void compareWithMathCommons() {
Complex[] outdata2 = fastFourierTransformer.transform(indata, TransformType.FORWARD);
for (int i = 0; i < testsize; i++) {
double err = outdata1[i].subtract(outdata2[i]).abs();
Log.d("FFTTest", "" + i +
Log.d(TAG, "" + i +
" (" + outdata1[i].getReal() + "," + outdata1[i].getImaginary() + ") -- " +
" (" + outdata2[i].getReal() + "," + outdata2[i].getImaginary() + ") = " + err);
assertTrue(err < 1E-10);
Expand All @@ -59,7 +61,7 @@ public void doFFTandIFFT() {
Complex[] outdata2 = kissFastFourierTransformer.transform(outdata1, TransformType.INVERSE);
for (int i = 0; i < testsize; i++) {
double err = Math.abs(indata[i] - outdata2[i].getReal());
Log.d("FFTTest", "" + i +
Log.d(TAG, "" + i +
" (" + indata[i] + ",0) -- " +
" (" + outdata2[i].getReal() + "," + outdata2[i].getImaginary() + ") = " + err);
assertTrue(err < 1E-15);
Expand Down

0 comments on commit ee2ecbd

Please sign in to comment.