Esempio n. 1
0
        public static KrdLab.clapack.Complex[] matrix_Inverse(KrdLab.clapack.Complex[] matA, int n)
        {
            System.Diagnostics.Debug.Assert(matA.Length == (n * n));
            KrdLab.clapack.Complex[] matA_ = new KrdLab.clapack.Complex[n * n];
            matA.CopyTo(matA_, 0);
            KrdLab.clapack.Complex[] matB_ = new KrdLab.clapack.Complex[n * n];
            // 単位行列
            for (int i = 0; i < matB_.Length; i++)
            {
                matB_[i] = 0.0;
            }
            for (int i = 0; i < n; i++)
            {
                matB_[i + i * n] = 1.0;
            }
            // [A][X] = [B]
            //  [B]の内容が書き換えられるので、matXを新たに生成せず、matBを出力に指定している
            int x_row = 0;
            int x_col = 0;
            KrdLab.clapack.FunctionExt.zgesv(ref matB_, ref x_row, ref x_col, matA_, n, n, matB_, n, n);

            KrdLab.clapack.Complex[] matX = matB_;
            return matX;
        }