73 lines
2.6 KiB
C#
73 lines
2.6 KiB
C#
using System;
|
|
using System.Linq;
|
|
using Skeleton.Constants;
|
|
using Skeleton.Samples;
|
|
using Skeleton.Utils;
|
|
using Skeleton.Utils.Helpers;
|
|
|
|
namespace SkeletonTest.tests;
|
|
|
|
public static class UnitaryTest
|
|
{
|
|
[DatapointSource]
|
|
public static readonly (((U2, U3), U4),((U2, U3), U4))[] DataSource =
|
|
20.ScaleSamples(-1, 1).U2FixSamples()
|
|
.Zip(20.ScaleSamples(-1, 1).U3FixSamples())
|
|
.Zip(20.ScaleSamples(-1, 1).U4FixSamples())
|
|
.ShuffleZip()
|
|
.ToArray();
|
|
|
|
private static readonly Action<(((U2, U3), U4), ((U2, U3), U4))> OnFail = data =>
|
|
{
|
|
Console.WriteLine("U2a");
|
|
Console.WriteLine(data.Item1.Item1.Item1.CSharpRepresentation);
|
|
Console.WriteLine("U2b");
|
|
Console.WriteLine(data.Item2.Item1.Item1.CSharpRepresentation);
|
|
|
|
Console.WriteLine("U3a");
|
|
Console.WriteLine(data.Item1.Item1.Item2.CSharpRepresentation);
|
|
Console.WriteLine("U3b");
|
|
Console.WriteLine(data.Item2.Item1.Item2.CSharpRepresentation);
|
|
|
|
Console.WriteLine("U4a");
|
|
Console.WriteLine(data.Item1.Item2.CSharpRepresentation);
|
|
Console.WriteLine("U4b");
|
|
Console.WriteLine(data.Item2.Item2.CSharpRepresentation);
|
|
};
|
|
[Theory]
|
|
public static void UnitarySumTest((((U2, U3), U4),((U2, U3), U4)) data)
|
|
{
|
|
Action<(((U2, U3), U4),((U2, U3), U4))> RawTest = x =>
|
|
{
|
|
U2 u2a = x.Item1.Item1.Item1;
|
|
U2 u2b = x.Item2.Item1.Item1;
|
|
U3 u3a = x.Item1.Item1.Item2;
|
|
U3 u3b = x.Item2.Item1.Item2;
|
|
U4 u4a = x.Item1.Item2;
|
|
U4 u4b = x.Item2.Item2;
|
|
|
|
C22 usum2 = (u2a + u2b) / 2;
|
|
C33 usum3 = (u3a + u3b) / 2;
|
|
C44 usum4 = (u4a + u4b) / 2;
|
|
|
|
};
|
|
RawTest.OnFail(OnFail)(data);
|
|
}
|
|
|
|
[Test]
|
|
public static void TestCase1()
|
|
{
|
|
U2 a =
|
|
new U2(0.0062267406142450105 + 0.20498679086126248 * AlgebraConstant.I,
|
|
-0.6788633254166565 + 0.7050434232570095 * AlgebraConstant.I,
|
|
0.291888812926916 + 0.9342069172093728 * AlgebraConstant.I,
|
|
0.09724224588774737 - 0.18056107648378417 * AlgebraConstant.I);
|
|
U2 b =
|
|
new U2(-0.1507802507678838 + 0.6503988948104069 * AlgebraConstant.I,
|
|
0.6289570055207475 - 0.39832107503137504 * AlgebraConstant.I,
|
|
0.12334244229189144 - 0.7341888282569051 * AlgebraConstant.I,
|
|
0.5410827924876593 - 0.3911301804591161 * AlgebraConstant.I);
|
|
C22 j = (a + b)/2;
|
|
Console.WriteLine((j * j.Hermitian()).Representation);
|
|
}
|
|
} |