當前位置: 首頁>>代碼示例>>C#>>正文


C# Matrix.GetData方法代碼示例

本文整理匯總了C#中System.Matrix.GetData方法的典型用法代碼示例。如果您正苦於以下問題:C# Matrix.GetData方法的具體用法?C# Matrix.GetData怎麽用?C# Matrix.GetData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Matrix的用法示例。


在下文中一共展示了Matrix.GetData方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: TestConstructor

        public void TestConstructor()
        {
            int[,] matrix1 = new int[,]
            {
                {1, 2, -3},
                {2, 1, 3},
                {3, 1, 2}
            };

            Matrix<int> m1 = new Matrix<int>(matrix1);

            int[,] matrixContents = m1.GetData();

            CollectionAssert.AreEqual(matrix1, matrixContents);
        }
開發者ID:nikolaynikolov,項目名稱:Telerik,代碼行數:15,代碼來源:MatrixTest.cs

示例2: CallZgeev

        private unsafe void CallZgeev(Matrix m, out Matrix eigenvals, out Matrix eigenvecs)
        {
            char jobvl = 'N';
            char jobvr = 'V';

            int N = m.Rows;
            Complex[] A_array = m.GetData();
            int lda = N;
            Complex* W = stackalloc Complex[N];
            Complex* VL = stackalloc Complex[N];
            int ldvl = 1;
            Complex* VR = stackalloc Complex[N*N];
            int ldvr = N;
            int lwork = 4 * N;
            Complex* work = stackalloc Complex[lwork];
            double* rwork = stackalloc double[2*N];
            int info;

            fixed (Complex* A = A_array)
            {
                zgeev(ref jobvl, ref jobvr, ref N, ref A[0], ref lda, ref W[0],
                      ref VL[0], ref ldvl, ref VR[0], ref ldvr, ref work[0], ref lwork,
                      ref rwork[0], out info);
            }

            eigenvals = new Matrix(N, 1);
            for (int i = 0; i < N; i++)
            {
                eigenvals[i, 0] = W[i];
            }
            eigenvecs = new Matrix(N, N);

            for (int i = 0; i < N; i++)
            {
                for (int j = 0; j < N; j++)
                {
                    eigenvecs[i, j] = VR[i + j * N].Conjugate();
                }
            }
        }
開發者ID:eylvisaker,項目名稱:tbsuite,代碼行數:40,代碼來源:LaPack.cs

示例3: CallZheev

        unsafe void CallZheev(Matrix m, out Matrix eigenvals, out Matrix eigenvecs)
        {
            char jobz = 'V';
            char uplo = 'U';
            int N = m.Rows;
            int LDA = N;
            Complex[] A_array = m.GetData();
            double* W = stackalloc double[N];
            int lwork = 4 * N;
            Complex* Work = stackalloc Complex[lwork];
            double* rwork = stackalloc double[4 * N];
            int info;

            fixed (Complex* A = A_array)
            {
                zheev(ref jobz, ref uplo, ref N, ref A[0], ref LDA, ref W[0], ref Work[0], ref lwork, ref rwork[0], out info);
            }

            if (info != 0)
                throw new Exception("Error calling Lapack.  Info: " + info.ToString());

            eigenvals = new Matrix(m.Rows, 1);
            eigenvecs = new Matrix(m.Rows, m.Columns);

            for (int i = 0; i < N; i++)
            {
                eigenvals[i, 0] = W[i];
            }

            for (int i = 0; i < N; i++)
            {
                for (int j = 0; j < N; j++)
                {
                    eigenvecs[i, j] = A_array[i + j * N].Conjugate();
                }
            }
        }
開發者ID:eylvisaker,項目名稱:tbsuite,代碼行數:37,代碼來源:LaPack.cs


注:本文中的System.Matrix.GetData方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。