static unsafe int Main(string[] args) { int testResult = Pass; int testsCount = 21; string methodUnderTestName = nameof(Sse2.CompareUnorderedScalar); if (Sse2.IsSupported) { using (var doubleTable = TestTableScalarSse2 <double, double> .Create(testsCount)) { for (int i = 0; i < testsCount; i++) { (Vector128 <double>, Vector128 <double>)value = doubleTable[i]; Vector128 <double> result = Sse2.CompareUnorderedScalar(value.Item1, value.Item2); doubleTable.SetOutArray(result); } CheckMethodEight <double, double> checkDouble = (Span <double> x, Span <double> y, Span <double> z, Span <double> a) => { if (double.IsNaN(x[0]) || double.IsNaN(y[0])) { a[0] = BitConverter.Int64BitsToDouble(-1); a[1] = x[1]; } else { a[0] = 0; a[1] = x[1]; } return(BitConverter.DoubleToInt64Bits(a[0]) == BitConverter.DoubleToInt64Bits(z[0]) && BitConverter.DoubleToInt64Bits(a[1]) == BitConverter.DoubleToInt64Bits(z[1])); }; if (!doubleTable.CheckResult(checkDouble)) { PrintError(doubleTable, methodUnderTestName, "(Span<double> x, Span<double> y, Span<double> z, Span<double> a) => CompareUnorderedScalar", checkDouble); testResult = Fail; } } } else { Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}"); } return(testResult); }
static unsafe int Main(string[] args) { int testResult = Pass; int testsCount = 21; string methodUnderTestName = nameof(Sse2.SqrtScalar); if (Sse2.IsSupported) { using (var doubleTable = TestTableScalarSse2 <double, double> .Create(testsCount)) { for (int i = 0; i < testsCount; i++) { (Vector128 <double>, Vector128 <double>)value = doubleTable[i]; Vector128 <double> result = Sse2.SqrtScalar(value.Item1); doubleTable.SetOutArray(result); } CheckMethodEight <double, double> checkDouble = (Span <double> x, Span <double> y, Span <double> z, Span <double> a) => { a[0] = Math.Sqrt(x[0]); a[1] = x[1]; return(a[0] == z[0] && a[1] == z[1]); }; if (!doubleTable.CheckResult(checkDouble)) { PrintError(doubleTable, methodUnderTestName, "(Span<double> x, Span<double> y, Span<double> z, Span<double> a) => SqrtScalar", checkDouble); testResult = Fail; } } } else { Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}"); } return(testResult); }
static unsafe int Main(string[] args) { int testResult = Pass; int testsCount = 21; string methodUnderTestName = nameof(Sse2.MoveScalar); if (Sse2.IsSupported) { using (var longTable = TestTableScalarSse2 <long, long> .Create(testsCount)) { for (int i = 0; i < testsCount; i++) { (Vector128 <long>, Vector128 <long>)value = longTable[i]; Vector128 <long> result = Sse2.MoveScalar(value.Item1); longTable.SetOutArray(result, i); } CheckMethodEight <long, long> checkLong = (Span <long> x, Span <long> y, Span <long> z, Span <long> a) => { a[0] = x[0]; a[1] = 0; return(a[0] == z[0] && a[1] == z[1]); }; if (!longTable.CheckResult(checkLong)) { PrintError(longTable, methodUnderTestName, "(Span<long> x, Span<long> y, Span<long> z, Span<long> a) => MoveScalar", checkLong); testResult = Fail; } } } else { Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}"); } return(testResult); }