public void Dist2Test(string mode, string test, Dictionary <string, string> environmentVariables) { RemoteExecutor.RemoteInvoke((arg0, arg1) => { CheckProperFlag(arg0); float[] src = (float[])_testArrays[int.Parse(arg1)].Clone(); float[] dst = (float[])src.Clone(); // Ensures src and dst are different arrays for (int i = 0; i < dst.Length; i++) { dst[i] += 1; } float expected = 0; for (int i = 0; i < dst.Length; i++) { float distance = src[i] - dst[i]; expected += distance * distance; } var actual = CpuMathUtils.L2DistSquared(src, dst, dst.Length); Assert.Equal(expected, actual, 0); return(RemoteExecutor.SuccessExitCode); }, mode, test, new RemoteInvokeOptions(environmentVariables)); }
private static Float L2DiffSquaredDense(Float[] valuesA, Float[] valuesB, int length) { Contracts.AssertValueOrNull(valuesA); Contracts.AssertValueOrNull(valuesB); Contracts.Assert(0 <= length && length <= Utils.Size(valuesA)); Contracts.Assert(0 <= length && length <= Utils.Size(valuesB)); if (length == 0) { return(0); } return(CpuMathUtils.L2DistSquared(valuesA, valuesB, length)); }
public void Dist2Test(int test, float expected) { float[] src = (float[])testArrays[test].Clone(); float[] dst = (float[])src.Clone(); // Ensures src and dst are different arrays for (int i = 0; i < dst.Length; i++) { dst[i] += 1; } var actual = CpuMathUtils.L2DistSquared(src, dst, dst.Length); Assert.Equal(expected, actual, 0); }
public float Dist2() => CpuMathUtils.L2DistSquared(src, dst, _smallInputLength);
public float ManagedDist2Perf() => CpuMathUtils.L2DistSquared(src, dst, LEN);