Esempio n. 1
0
        private void CreateBandedMatrix(double[] buffer, int m, int n, int kl, int ku)
        {
            Random rand        = new Random(Environment.TickCount);
            int    largestSize = m;

            if (largestSize < n)
            {
                largestSize = n;
            }

            for (int i = 0; i < largestSize; i++)
            {
                // Set main diagonal
                int index = _blas.GetIndexColumnMajor(i, i, m);
                if (i < m && i < n)
                {
                    buffer[index] = rand.Next(RandomMax) + 1;
                }

                // Set superdiagonal
                for (int si = 1; si <= ku; si++)
                {
                    int ni = i;
                    int nj = i + si;

                    if (ni >= 0 && ni < m && nj >= 0 && nj < n)
                    {
                        index         = _blas.GetIndexColumnMajor(ni, nj, m);
                        buffer[index] = rand.Next(RandomMax) + 1;;
                    }
                }

                // Set subdiagonal
                for (int si = 1; si <= kl; si++)
                {
                    int ni = i;
                    int nj = i - si;

                    if (ni >= 0 && ni < m && nj >= 0 && nj < n)
                    {
                        index         = _blas.GetIndexColumnMajor(ni, nj, m);
                        buffer[index] = rand.Next(RandomMax) + 1;;
                    }
                }
            }
            System.Threading.Thread.Sleep(rand.Next(50));
        }
Esempio n. 2
0
        private void CreateDiagonalMatrix(float[] buffer, int n)
        {
            Random rand = new Random(Environment.TickCount);

            for (int i = 0; i < n; i++)
            {
                buffer[_blas.GetIndexColumnMajor(i, i, n)] = rand.Next(256);

                if (buffer[_blas.GetIndexColumnMajor(i, i, n)] == 0)
                {
                    buffer[_blas.GetIndexColumnMajor(i, i, n)] = 100;
                }
            }

            System.Threading.Thread.Sleep(rand.Next(50));
        }