public void ZerosetTest() { const int length = 15; float[] v = (new float[length]).Select((_, idx) => (float)idx).ToArray(); float[] v2 = new float[length]; float[] v3 = (new float[length]).Select((_, idx) => idx < (float)(length - 1) ? 0 : (float)idx).ToArray(); float[] v4 = (new float[length]).Select((_, idx) => idx >= 3 && idx < (float)(length - 1) ? 0 : (float)idx).ToArray(); float[] v5 = new float[length]; AvxArray <float> arr = new AvxArray <float>(length); arr.Write(v, length); arr.Zeroset(); arr.Read(v5, length); CollectionAssert.AreEqual(v2, v5); arr.Write(v, length); arr.Zeroset(length - 1); arr.Read(v5, length); CollectionAssert.AreEqual(v3, v5); arr.Write(v, length); arr.Zeroset(3, length - 4); arr.Read(v5, length); CollectionAssert.AreEqual(v4, v5); }
public void CopyTest() { const int length = 15; float[] v = (new float[length]).Select((_, idx) => (float)idx).ToArray(); float[] v3 = (new float[length]).Select((_, idx) => idx < (float)(length - 1) ? (float)idx : 0).ToArray(); float[] v4 = (new float[length]).Select((_, idx) => idx >= 3 && idx < (float)(length - 1) ? (float)idx : 0).ToArray(); float[] v5 = (new float[length]).Select((_, idx) => idx >= 2 && idx < (float)(length - 2) ? (float)idx + 1 : 0).ToArray(); float[] v6 = new float[length]; AvxArray <float> arr = new AvxArray <float>(v); AvxArray <float> arr2 = new AvxArray <float>(length); arr2.Zeroset(); arr.CopyTo(arr2, arr.Length); arr2.Read(v6); CollectionAssert.AreEqual(v, v6); arr2.Zeroset(); arr.CopyTo(arr2, arr.Length - 1); arr2.Read(v6); CollectionAssert.AreEqual(v3, v6); arr2.Zeroset(); arr.CopyTo(3, arr2, 3, arr.Length - 4); arr2.Read(v6); CollectionAssert.AreEqual(v4, v6); arr2.Zeroset(); arr.CopyTo(3, arr2, 2, arr.Length - 4); arr2.Read(v6); CollectionAssert.AreEqual(v5, v6); }
public void InitializeTest() { const int length = 15; float[] v = new float[length]; AvxArray <float> arr = new AvxArray <float>(length); arr.Read(v); foreach (float f in v) { Assert.AreEqual(0.0f, f); } }
public void WriteReadTest() { const int length = 15; float[] v = (new float[length]).Select((_, idx) => (float)idx).ToArray(); float[] v2 = new float[length]; AvxArray <float> arr = new AvxArray <float>(length); AvxArray <float> arr2 = new AvxArray <float>(length); arr.Write(v); AvxArray <float> .Copy(arr, arr2, length); arr2.Read(v2); CollectionAssert.AreEqual(v, v2); }