Exemplo n.º 1
0
        public void Allocation()
        {
            var m1 = new ColumnWiseMatrix(10, 5, 2, MemorySpace.Device, MathDomain.Int);

            m1.Print();
            DeviceManager.CheckDeviceSanity();

            var m2 = new ColumnWiseMatrix(10, 5, 1.234f, MemorySpace.Device, MathDomain.Float);

            m2.Print();
            DeviceManager.CheckDeviceSanity();

            var m3 = new ColumnWiseMatrix(10, 5, 1.2345, MemorySpace.Device, MathDomain.Double);

            m3.Print();
            DeviceManager.CheckDeviceSanity();

            var m4 = new ColumnWiseMatrix(10, 5, 1, MemorySpace.Host, MathDomain.Int);

            m4.Print();
            DeviceManager.CheckDeviceSanity();

            var m5 = new ColumnWiseMatrix(10, 5, 1.234f, MemorySpace.Host, MathDomain.Float);

            m5.Print();
            DeviceManager.CheckDeviceSanity();

            var m6 = new ColumnWiseMatrix(10, 5, 1.2345, MemorySpace.Host, MathDomain.Double);

            m6.Print();
            DeviceManager.CheckDeviceSanity();
        }
Exemplo n.º 2
0
        public void Copy()
        {
            var m1 = new ColumnWiseMatrix(10, 5, 1, MemorySpace.Device, MathDomain.Int);

            m1.Print();
            var m1Copy = new ColumnWiseMatrix(m1);

            DeviceManager.CheckDeviceSanity();
            m1Copy.Print();
            Assert.AreEqual(m1, m1Copy);

            var m2 = new ColumnWiseMatrix(10, 5, 1.234f, MemorySpace.Device, MathDomain.Float);

            m2.Print();
            var m2Copy = new ColumnWiseMatrix(m2);

            DeviceManager.CheckDeviceSanity();
            m2Copy.Print();
            Assert.AreEqual(m2, m2Copy);

            var m3 = new ColumnWiseMatrix(10, 5, 1.2345, MemorySpace.Device, MathDomain.Double);

            m3.Print();
            var m3Copy = new ColumnWiseMatrix(m3);

            DeviceManager.CheckDeviceSanity();
            m3Copy.Print();
            Assert.AreEqual(m3, m3Copy);

            var m4 = new ColumnWiseMatrix(10, 5, 1, MemorySpace.Host, MathDomain.Int);

            m4.Print();
            var m4Copy = new ColumnWiseMatrix(m4);

            DeviceManager.CheckDeviceSanity();
            m4Copy.Print();
            Assert.AreEqual(m4, m4Copy);

            var m5 = new ColumnWiseMatrix(10, 5, 1.234f, MemorySpace.Host, MathDomain.Float);

            m5.Print();
            var m5Copy = new ColumnWiseMatrix(m5);

            DeviceManager.CheckDeviceSanity();
            m5Copy.Print();
            Assert.AreEqual(m5, m5Copy);

            var m6 = new ColumnWiseMatrix(10, 5, 1.2345, MemorySpace.Host, MathDomain.Double);

            m6.Print();
            var m6Copy = new ColumnWiseMatrix(m6);

            DeviceManager.CheckDeviceSanity();
            m6Copy.Print();
            Assert.AreEqual(m6, m6Copy);
        }
Exemplo n.º 3
0
        public void GetColumn()
        {
            var m1 = new ColumnWiseMatrix(10, 5, 1.2345f);

            m1.Print();
            DeviceManager.CheckDeviceSanity();

            for (int j = 0; j < m1.nCols; ++j)
            {
                var col = m1.Get <float>(j);
                DeviceManager.CheckDeviceSanity();

                Assert.AreEqual(col.Count, m1.nRows);
                for (int i = 0; i < m1.nRows; ++i)
                {
                    Assert.IsTrue(Math.Abs(col[i] - 1.2345f) <= 1e-7);
                }
            }
        }
Exemplo n.º 4
0
        public void SetColumn()
        {
            var m1 = new ColumnWiseMatrix(10, 5, 1.2345f);

            m1.Print();
            DeviceManager.CheckDeviceSanity();
            var _m1 = m1.Get <float>();

            var v1 = new Vector(10, 2.3456f);

            v1.Print();
            DeviceManager.CheckDeviceSanity();
            var _v1 = v1.Get <float>();

            m1.Set(v1, 3);

            for (int j = 0; j < m1.nCols; ++j)
            {
                var col = m1.Get <float>(j);
                DeviceManager.CheckDeviceSanity();

                Assert.AreEqual(col.Count, m1.nRows);
                if (j != 3)
                {
                    for (int i = 0; i < m1.nRows; ++i)
                    {
                        Assert.IsTrue(Math.Abs(col[i] - _m1[i + m1.nRows * j]) <= 1e-7);
                    }
                }
                else
                {
                    for (int i = 0; i < m1.nRows; ++i)
                    {
                        Assert.IsTrue(Math.Abs(col[i] - _v1[i]) <= 1e-7);
                    }
                }
            }
        }