Example #1
0
        private static void TestDgemv()
        {
            Skip.IfNot(TestSettings.TestMkl, TestSettings.MessageWhenSkippingMKL);

            CBLAS_LAYOUT    layout = CBLAS_LAYOUT.CblasColMajor;
            CBLAS_TRANSPOSE transA = CBLAS_TRANSPOSE.CblasNoTrans;
            double          alpha  = 1.0;
            double          beta   = 0.0;
            int             incX   = 1;
            int             incY   = 1;
            int             m      = RectangularFullRank10by5.NumRows;
            int             n      = RectangularFullRank10by5.NumCols;
            int             ldA    = m;

            double[] A = Conversions.Array2DToFullColMajor(RectangularFullRank10by5.Matrix);
            double[] X = RectangularFullRank10by5.Lhs5;
            double[] Y = new double[m];
            LapackePInvokes.Dgemv(layout, transA, m, n, alpha, A, ldA, X, incX, beta, Y, incY);

            comparer.AssertEqual(RectangularFullRank10by5.Rhs10, Y);
        }
 public static extern void Dgemv(CBLAS_LAYOUT layout, CBLAS_TRANSPOSE transA, int m, int n,
                                 double alpha, double[] A, int ldA, double[] X, int incX, double beta, double[] Y, int incY); // CBLAS, rather than LAPACKE
Example #3
0
        private static void RunComputeNetExample()
        {
            Skip.IfNot(TestSettings.TestMkl, TestSettings.MessageWhenSkippingMKL);

            //Variable typeA is not used and it triggers a warning
#pragma warning disable CS0219

            const int GENERAL_MATRIX = 0;
            const int UPPER_MATRIX   = 1;
            const int LOWER_MATRIX   = -1;

            int          m = 3, n = 2, i, j;
            int          lda = 3, ldb = 3, ldc = 3;
            int          rmaxa, cmaxa, rmaxb, cmaxb, rmaxc, cmaxc;
            float        alpha = 0.5f, beta = 2.0f;
            float[]      a, b, c;
            CBLAS_LAYOUT layout = CBLAS_LAYOUT.CblasRowMajor;
            CBLAS_SIDE   side   = CBLAS_SIDE.CblasLeft;
            CBLAS_UPLO   uplo   = CBLAS_UPLO.CblasUpper;

            int ma, na, typeA;
            if (side == CBLAS_SIDE.CblasLeft)
            {
                rmaxa = m + 1;
                cmaxa = m;
                ma    = m;
                na    = m;
            }
            else
            {
                rmaxa = n + 1;
                cmaxa = n;
                ma    = n;
                na    = n;
            }
            rmaxb = m + 1;
            cmaxb = n;
            rmaxc = m + 1;
            cmaxc = n;
            a     = new float[rmaxa * cmaxa];
            b     = new float[rmaxb * cmaxb];
            c     = new float[rmaxc * cmaxc];
            if (layout == CBLAS_LAYOUT.CblasRowMajor)
            {
                lda = cmaxa;
                ldb = cmaxb;
                ldc = cmaxc;
            }
            else
            {
                lda = rmaxa;
                ldb = rmaxb;
                ldc = rmaxc;
            }
            if (uplo == CBLAS_UPLO.CblasUpper)
            {
                typeA = UPPER_MATRIX;
            }
            else
            {
                typeA = LOWER_MATRIX;
            }
            for (i = 0; i < m; i++)
            {
                for (j = 0; j < m; j++)
                {
                    a[i + j * lda] = 1.0f;
                }
            }
            for (i = 0; i < m; i++)
            {
                for (j = 0; j < n; j++)
                {
                    c[i + j * ldc] = 1.0f;
                    b[i + j * ldb] = 2.0f;
                }
            }
            CBlas.Ssymm(layout, side, uplo, m, n, alpha, ref a[0], lda, ref b[0], ldb, beta, ref c[0], ldc);
        }
Example #4
0
 private static extern void cblas_dgemm(CBLAS_LAYOUT Layout, CBLAS_TRANSPOSE TransA, CBLAS_TRANSPOSE TransB, int m, int n, int k, double alpha, double* A,
          int lda, double* B, int ldb, double beta, double* C, int ldc);
Example #5
0
 private static extern void cblas_sgemm(CBLAS_LAYOUT Layout, CBLAS_TRANSPOSE TransA,CBLAS_TRANSPOSE TransB, int m, int n,int k, float alpha, float* A,
          int lda, float* B, int ldb, float beta, float* C, int ldc);
Example #6
0
        public void CanRunBlasExample1()
        {
            int   m = 3, n = 2, i, j;
            int   lda = 3, ldb = 3, ldc = 3;
            int   rmaxa, cmaxa, rmaxb, cmaxb, rmaxc, cmaxc;
            float alpha = 0.5f, beta = 2.0f;

            float[]      a, b, c;
            CBLAS_LAYOUT layout = CBLAS_LAYOUT.CblasRowMajor;
            CBLAS_SIDE   side = CBLAS_SIDE.CblasLeft;
            CBLAS_UPLO   uplo = CBLAS_UPLO.CblasUpper;
            int          ma, na, typeA;

            if (side == CBLAS_SIDE.CblasLeft)
            {
                rmaxa = m + 1;
                cmaxa = m;
                ma    = m;
                na    = m;
            }
            else
            {
                rmaxa = n + 1;
                cmaxa = n;
                ma    = n;
                na    = n;
            }
            rmaxb = m + 1;
            cmaxb = n;
            rmaxc = m + 1;
            cmaxc = n;
            a     = new float[rmaxa * cmaxa];
            b     = new float[rmaxb * cmaxb];
            c     = new float[rmaxc * cmaxc];
            if (layout == CBLAS_LAYOUT.CblasRowMajor)
            {
                lda = cmaxa;
                ldb = cmaxb;
                ldc = cmaxc;
            }
            else
            {
                lda = rmaxa;
                ldb = rmaxb;
                ldc = rmaxc;
            }
            if (uplo == CBLAS_UPLO.CblasUpper)
            {
                typeA = UPPER_MATRIX;
            }
            else
            {
                typeA = LOWER_MATRIX;
            }
            for (i = 0; i < m; i++)
            {
                for (j = 0; j < m; j++)
                {
                    a[i + j * lda] = 1.0f;
                }
            }
            for (i = 0; i < m; i++)
            {
                for (j = 0; j < n; j++)
                {
                    c[i + j * ldc] = 1.0f;
                    b[i + j * ldb] = 2.0f;
                }
            }
            CBlas.Ssymm(layout, side, uplo, m, n, alpha, ref a[0], lda, ref b[0], ldb, beta, ref c[0], ldc);
        }