예제 #1
0
        public void PerformaceBitmapSimulation()
        {
            var npRealWorldBitmap = new NDArrayGeneric <byte>();

            //npRealWorldBitmap.ARange(2081 * 2531);
            npRealWorldBitmap.reshape(2531, 2081);
        }
예제 #2
0
        public void ReshapeNegative()
        {
            var np = new NDArrayGeneric <int>();

            np.arange(12);
            np.reshape(-1, 2);
            Assert.IsTrue(np.Shape.Shapes[0] == 6);
            Assert.IsTrue(np.Shape.Shapes[1] == 2);

            np.arange(12);
            np.reshape(2, -1);
            Assert.IsTrue(np.Shape.Shapes[0] == 2);
            Assert.IsTrue(np.Shape.Shapes[1] == 6);

            np.arange(12);
            np.reshape(1, 3, 4);
            np.reshape(-1, 3);
            Assert.IsTrue(np.Shape.Shapes[0] == 4);
            Assert.IsTrue(np.Shape.Shapes[1] == 3);

            np.arange(12);
            np.reshape(1, 3, 4);
            np.reshape(3, -1);
            Assert.IsTrue(np.Shape.Shapes[0] == 3);
            Assert.IsTrue(np.Shape.Shapes[1] == 4);

            np.arange(100 * 100 * 3);
            np.reshape(100, 100, 3);
            np.reshape(-1, 3);
            Assert.IsTrue(np.Shape.Shapes[0] == 10000);
            Assert.IsTrue(np.Shape.Shapes[1] == 3);

            np.arange(15801033);
            np.reshape(2531, 2081, 3);
            np.reshape(-1, 3);
            Assert.IsTrue(np.Shape.Shapes[0] == 5267011);
            Assert.IsTrue(np.Shape.Shapes[1] == 3);
        }
예제 #3
0
        public static NDArrayGeneric <double> Zeros(this NDArrayGeneric <double> np, params int[] shape)
        {
            int length = 1;

            for (int i = 0; i < shape.Length; i++)
            {
                length *= shape[i];
            }

            np.Data = Enumerable.Range(0, length).Select(x => 0.0).ToArray();
            np.reshape(shape);

            return(np);
        }