Formatted with Google Java Formatter · primary-code-test/Java@ca2e207 · GitHub
Skip to content

Commit ca2e207

Browse files
github-actionsgithub-actions
authored andcommitted
Formatted with Google Java Formatter
1 parent 4264e0f commit ca2e207

5 files changed

Lines changed: 374 additions & 426 deletions

File tree

Maths/CircularConvolutionFFT.java

Lines changed: 39 additions & 42 deletions

Maths/Convolution.java

Lines changed: 31 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,43 +5,39 @@
55
*
66
* @author Ioannis Karavitsis
77
* @version 1.0
8-
* */
9-
public class Convolution
10-
{
11-
/**
12-
* Discrete linear convolution function. Both input signals and the output signal must start from 0.
13-
* If you have a signal that has values before 0 then shift it to start from 0.
14-
*
15-
* @param A The first discrete signal
16-
* @param B The second discrete signal
17-
* @return The convolved signal
18-
* */
19-
public static double[] convolution(double[] A, double[] B)
20-
{
21-
double[] convolved = new double[A.length + B.length - 1];
8+
*/
9+
public class Convolution {
10+
/**
11+
* Discrete linear convolution function. Both input signals and the output signal must start from
12+
* 0. If you have a signal that has values before 0 then shift it to start from 0.
13+
*
14+
* @param A The first discrete signal
15+
* @param B The second discrete signal
16+
* @return The convolved signal
17+
*/
18+
public static double[] convolution(double[] A, double[] B) {
19+
double[] convolved = new double[A.length + B.length - 1];
2220

23-
/*
24-
The discrete convolution of two signals A and B is defined as:
21+
/*
22+
The discrete convolution of two signals A and B is defined as:
2523
26-
A.length
27-
C[i] = Σ (A[k]*B[i-k])
28-
k=0
24+
A.length
25+
C[i] = Σ (A[k]*B[i-k])
26+
k=0
2927
30-
It's obvious that: 0 <= k <= A.length , 0 <= i <= A.length + B.length - 2 and 0 <= i-k <= B.length - 1
31-
From the last inequality we get that: i - B.length + 1 <= k <= i and thus we get the conditions below.
32-
*/
33-
for(int i = 0; i < convolved.length; i++)
34-
{
35-
convolved[i] = 0;
36-
int k = Math.max(i - B.length + 1, 0);
28+
It's obvious that: 0 <= k <= A.length , 0 <= i <= A.length + B.length - 2 and 0 <= i-k <= B.length - 1
29+
From the last inequality we get that: i - B.length + 1 <= k <= i and thus we get the conditions below.
30+
*/
31+
for (int i = 0; i < convolved.length; i++) {
32+
convolved[i] = 0;
33+
int k = Math.max(i - B.length + 1, 0);
3734

38-
while(k < i + 1 && k < A.length)
39-
{
40-
convolved[i] += A[k] * B[i - k];
41-
k++;
42-
}
43-
}
44-
45-
return convolved;
35+
while (k < i + 1 && k < A.length) {
36+
convolved[i] += A[k] * B[i - k];
37+
k++;
38+
}
4639
}
47-
}
40+
41+
return convolved;
42+
}
43+
}

Maths/ConvolutionFFT.java

Lines changed: 44 additions & 45 deletions

0 commit comments

Comments
 (0)