-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
48 lines (46 loc) · 1.65 KB
/
Copy pathProgram.cs
File metadata and controls
48 lines (46 loc) · 1.65 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
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.MemoryMappedFiles;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
namespace GigaFFT2RealMagnitude
{
class Program
{
static void Main(string[] args)
{
string path = @"d:\Temp\0e189873-9e52-43cc-be03-247c70cbe03f-1";
MemoryMappedFile file = MemoryMappedFile.CreateFromFile(path, FileMode.Open);
long bytesCount = new System.IO.FileInfo(path).Length;
long structCount = (bytesCount / 16) / 2;
long bin = 0;
double inverseSqrtN = 1 / Math.Sqrt(structCount * 2);
double minM = double.MaxValue;
double maxM = double.MinValue;
for (int index = 0; index < structCount / 4096; index++)
{
Complex[] array = new Complex[4096];
using (MemoryMappedViewAccessor accessor = file.CreateViewAccessor(index * 4096 * 16L, 4096 * 16L))
{
accessor.ReadArray<Complex>(0, array, 0, array.Length);
}
for (int i = 0; i < array.Length; i++)
{
double x = inverseSqrtN * array[i].Real;
minM = Math.Min(minM, x);
maxM = Math.Max(maxM, x);
bin++;
if ((bin % (4 * 1024)) == 0)
{
Console.WriteLine(minM + "," + maxM);
minM = double.MaxValue;
maxM = double.MinValue;
}
}
}
}
}
}