• 2022-06-04
    矩阵表示与转置的实现
  • /*矩阵数据结构的设计*/#define M 10//矩阵最大行数#define N 10//矩阵最大列数typedef int ElemType;typedef struct matrix{ElemType data[M][N];int rows;int cols;}Matrix;/*矩阵转置的算法*/void transport(Matrix m1,Matrix* m2){int i,j;for(i=0;i<m1.rows;i++){for(j=0;j<m1.cols;j++){m2->data[j][i]=m1.data[i][j];}}m2->cols=m1.rows;m2->rows=m1.cols;}/*测试*/int main(){int m=2,n=3;//m表示矩阵行,n表示矩阵列Matrix matr1,matr2;//初始化matr1为一个2*3的矩阵(值为0到m*n-1)matr1.cols=3;matr1.rows=2;for(int i=0;i<matr1.rows;i++){for(int j=0;j<matr1.cols;j++){matr1.data[i][j]=i*matr1.cols+j;}} transport(matr1,&matr2);//将matr1转置为matr2//输出matr2for(int i=0;i<matr2.rows;i++){for(int j=0;j<matr2.cols;j++){printf("%d ",matr2.data[i][j]);}printf("\n");}}[/i][/i][/i][/i]

    内容

    • 0

      矩阵A与矩阵A的转置矩阵具有相同的行列式和特征值。

    • 1

      A的转置矩阵乘以A是单位矩阵,A的转置矩阵一定是A的逆矩阵吗?

    • 2

      转置矩阵

    • 3

      矩阵转置从键盘输入一个3*4的矩阵,要求输出转置后的矩阵。转置的概念:即把矩阵的行变为列,列变为行即可,比如矩阵为3行4列,那么转置后的矩阵为4行3列。

    • 4

      矩阵转置是矩阵的运算。