Exemple #1
0
        public void CheckChangeTensorLayout2D()
        {
            var strg2DCpy = (ArrayStorage)strg2D.Clone();

            Assert.IsTrue(Enumerable.SequenceEqual(strg2DCpy.Shape.Dimensions, new int[] { 3, 3 }));
            Assert.IsTrue(Enumerable.SequenceEqual(strg2DCpy.GetData <long>(), new long[] { 0, 3, 6, 1, 4, 7, 2, 5, 8 }));

            Assert.IsTrue(Enumerable.SequenceEqual(strg2DCpy.Shape.Dimensions, new int[] { 3, 3 }));
            Assert.IsTrue(Enumerable.SequenceEqual(strg2DCpy.GetData <long>(), strg2D.GetData <long>()));

            strg2DCpy = (ArrayStorage)strg2DNonFull.Clone();

            Assert.IsTrue(Enumerable.SequenceEqual(strg2DCpy.Shape.Dimensions, new int[] { 5, 2 }));
            Assert.IsTrue(Enumerable.SequenceEqual(strg2DCpy.GetData <long>(), new long[] { 0, 5, 1, 6, 2, 7, 3, 8, 4, 9 }));

            Assert.IsTrue(Enumerable.SequenceEqual(strg2DCpy.Shape.Dimensions, new int[] { 5, 2 }));
            Assert.IsTrue(Enumerable.SequenceEqual(strg2DCpy.GetData <long>(), strg2DNonFull.GetData <long>()));

            strg2DCpy = new ArrayStorage(typeof(long));
            strg2DCpy.Allocate(new Shape(5, 2));

            strg2DCpy.SetData(strg2DNonFull.GetData());

            Assert.IsTrue(Enumerable.SequenceEqual(strg2DCpy.GetData <long>(), new long[] { 0, 2, 4, 6, 8, 1, 3, 5, 7, 9 }));
        }
Exemple #2
0
        public void CloneCheck()
        {
            var strg1DCpy = (ArrayStorage)strg1D.Clone();

            Assert.IsTrue(strg1DCpy.DType == strg1DCpy.GetData().GetType().GetElementType());
            Assert.IsFalse(strg1D.GetData() == strg1DCpy.GetData());
            Assert.IsTrue(strg1D.GetData().Length == strg1DCpy.GetData().Length);

            Assert.IsTrue(Enumerable.SequenceEqual(strg1DCpy.GetData <double>(), strg1D.GetData <double>()));
        }