-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConverter.cs
More file actions
59 lines (57 loc) · 1.53 KB
/
Copy pathConverter.cs
File metadata and controls
59 lines (57 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System;
using System.Numerics;
namespace FFT
{
/// <summary>
/// For converting any values
/// </summary>
public static class Converter
{
/// <summary>
/// Converts Complex array to int array
/// </summary>
public static int[] ComplexToInt(Complex[] input, double multipler = 1, bool abs = false)
{
int N = input.Length;
int[] result = new int[N];
if (abs)
{
for (int i = 0; i < N; i++)
{
result[i] = Math.Abs((int)(input[i].Real * multipler));
}
}
else
{
for (int i = 0; i < N; i++)
{
result[i] = (int)input[i].Real;
}
}
return result;
}
/// <summary>
/// Converts Double array to int array
/// </summary>
public static int[] DoubleToInt(double[] input, double multipler=1, bool abs = false)
{
int N = input.Length;
int[] result = new int[N];
if (abs)
{
for (int i = 0; i < N; i++)
{
result[i] = Math.Abs((int)(input[i] * multipler));
}
}
else
{
for (int i = 0; i < N; i++)
{
result[i] = (int)(input[i] * multipler);
}
}
return result;
}
}
}