Example #1
0
        public void TestSparseMatrixMultiplication()
        {
            // https://en.wikipedia.org/wiki/Sparse_matrix
            var aDense = new float[]
            {
                0, 0, 0, 0,
                5, 8, 0, 0,
                0, 0, 3, 0,
                0, 6, 0, 0
            };

            var a  = new float[] { 5, 8, 3, 6 };
            var ja = new int[] { 0, 1, 2, 1 };
            var ia = new int[] { 0, 0, 2, 3, 4 };

            var bDense = new float[]
            {
                1, 2, 0, 0, 0, 0,
                0, 3, 0, 4, 0, 0,
                0, 0, 5, 6, 7, 0,
                0, 0, 0, 0, 0, 8,
            };

            var cDense = new float[4 * 6];
            var c      = new float[4 * 6];

            Provider.sgemm(Order.RowMajor, Transpose.NoTrans, Transpose.NoTrans, 4, 6, 4, 1, aDense, 0, 4, bDense, 0, 6, 0, cDense, 0, 6);
            Provider.scsrmm(Transpose.NoTrans, 4, 6, 4, 1, a, 0, ja, 0, ia, 0, bDense, 0, 6, 0, c, 0, 6);

            AssertArray.AreEqual(cDense, c);
        }
Example #2
0
 public static void csrmm(Transpose TransA, int m, int n, int k,
                          float alpha,
                          float[] val, int offsetval,
                          int[] indx, int offsetindx,
                          int[] pntrb, int offsetpntrb,
                          //int[] pntre, int offsetpntre,
                          float[] b, int offsetb, int ldb,
                          float beta,
                          float[] c, int offsetc, int ldc)
 {
     Provider.scsrmm(TransA, m, n, k, alpha, val, offsetval, indx, offsetindx, pntrb, offsetpntrb, b, offsetb, ldb, beta, c, offsetc, ldc);
 }