已知一个矩阵,想得到他的转置矩阵要如何得到?

解决方案 »

  1.   


     /// 矩阵的转置
             public bool MatrixInver(double[,] a, ref double[,] b)
             {
                 if (a.GetLength(0) != b.GetLength(1) || a.GetLength(1) != b.GetLength(0))
                     return false;
                 for (int i = 0; i < a.GetLength(1); i++)
                     for (int j = 0; j < a.GetLength(0); j++)
                         b[i, j] = a[j, i];             return true;
             }         /// 矩阵的逆
             public bool MatrixOpp(double[,] a, ref double[,] b)
             {
                 double X = MatrixSurplus(a);
                 if (X == 0) return false;
                 X = 1 / X;             double[,] B = new double[a.GetLength(0), a.GetLength(1)];
                 double[,] SP = new double[a.GetLength(0), a.GetLength(1)];
                 double[,] AB = new double[a.GetLength(0), a.GetLength(1)];             for (int i = 0; i < a.GetLength(0); i++)
                     for (int j = 0; j < a.GetLength(1); j++)
                     {
                         for (int m = 0; m < a.GetLength(0); m++)
                             for (int n = 0; n < a.GetLength(1); n++)
                                 B[m, n] = a[m, n];
                         {
                             for (int x = 0; x < a.GetLength(1); x++)
                                 B[i, x] = 0;
                             for (int y = 0; y < a.GetLength(0); y++)
                                 B[y, j] = 0;
                             B[i, j] = 1;
                             SP[i, j] = MatrixSurplus(B);
                             AB[i, j] = X * SP[i, j];
                         }
                     }     
                 MatrixInver(AB, ref b);
                  
                 return true;     
               }     
      

  2.   

    Matrix myMatrix = new Matrix(3, 5, 1, 2, 2, 4);
     myMatrix.Invert();
      

  3.   

    那如果我现在又一个二维矩阵,想用你说的这个Matrix类中的Invert()方法来求转置矩阵,应该怎么做?比如我的这个二维矩阵叫arr1,已经有值了。
    谢谢!
      

  4.   

    a[i,j]=a[j,i]
     这样就把数组转置了。