import
java.io.*;
import
java.util.Scanner;
public
class
GFG {
public
static
void
main(String[] args)
{
System.out.println(
"Enter the size:"
);
Scanner sc =
new
Scanner(System.in);
int
n = sc.nextInt();
double
[][] input =
new
double
[n][n];
double
[][] realOut =
new
double
[n][n];
double
[][] imagOut =
new
double
[n][n];
System.out.println(
"Enter the elements:"
);
for
(
int
i =
0
; i < n; i++) {
for
(
int
j =
0
; j < n; j++) {
input[i][j] = sc.nextDouble();
}
}
discrete(input, realOut, imagOut);
sc.close();
}
static
void
discrete(
double
[][] input,
double
[][] realOut,
double
[][] imagOut)
{
int
height = input.length;
int
width = input[
0
].length;
for
(
int
y =
0
; y < height; y++) {
for
(
int
x =
0
; x < width; x++) {
for
(
int
y1 =
0
; y1 < height; y1++) {
for
(
int
x1 =
0
; x1 < width; x1++) {
realOut[y][x]
+= (input[y1][x1]
* Math.cos(
2
* Math.PI
* ((
1.0
* x * x1
/ width)
+ (
1.0
* y * y1
/ height))))
/ Math.sqrt(width * height);
imagOut[y][x]
-= (input[y1][x1]
* Math.sin(
2
* Math.PI
* ((
1.0
* x * x1
/ width)
+ (
1.0
* y * y1
/ height))))
/ Math.sqrt(width * height);
}
System.out.println(realOut[y][x] +
" +"
+ imagOut[y][x]
+
"i"
);
}
}
}
}
}