Skip to content

Commit

Permalink
Fix DumpMachine parsing in DumpUnitary
Browse files Browse the repository at this point in the history
  • Loading branch information
ironyman committed Oct 29, 2019
1 parent 37e4554 commit 1d6e835
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions utilities/DumpUnitary/Driver.cs
Expand Up @@ -29,11 +29,18 @@ static void Main(string[] args)
for (int row = 0; row < size; ++row) {
// skip the first line of the file (header)
string line = fileContent[row + 1];
// split the line into 3 space-separated elements: index, real part and complex part

// The complex number that represents the amplitude is tab-separated from the rest of the fields,
// and the real and imaginary components within are separated with spaces.
string[] parts = line.Split('\t');
// drop the index and store real and complex parts
string real = parts[1];
string complex = parts[2];
string amplitude = parts[1];
string[] amplitude_parts = amplitude.split(' ');
string real = amplitude_parts[0];
string imag_sign = amplitude_parts[1];
string imag = amplitude_parts[2];
string complex = imag_sign + imag;

// write the number to the matrix as a string "(real, complex)"
unitary[row, column] = $"({real}, {complex})";
// for a pattern, convert real and complex parts into doubles and add them up
Expand Down

0 comments on commit 1d6e835

Please sign in to comment.