## Transpose a matrix.

Given an*m*×

*n*matrix

**A**= (

*a*) the transpose of

_{ij}**A**is the

*n*×

*m*matrix

**B**= (

*b*) where

_{ij}*b*=

_{ij}*a*for all

_{ji}*i,j*.

The routine for transposing an arbitrary

*m*×

*n*real matrix of type

*double*is called

*Transpose_Matrix()*, the routine for transposing a square

*n*×

*n*real matrix of type

*double*is called

*Transpose_Square_Matrix()*, the routine for transposing an arbitrary

*m*×

*n*complex matrix of type

*double complex*is called

*Transpose_CMatrix()*, and the routine for transposing a square

*n*×

*n*complex matrix of type

*double complex*is called

*Transpose_Square_CMatrix()*.

There are 2 versions of the

*Transpose_Matrix()*routine and 2 versions of the

*Transpose_Square_Matrix()*routine. For both routines, the

*Transpose_Matrix()*routine and the

*Transpose_Square_Matrix()*routine, 1 version is written in

*C*, and 1 version is written in

*NASM*assembly language.

There is 1 version of the

*Transpose_CMatrix()*routine and 1 version of the

*Transpose_Square_Matrix()*routine, both versions are written in

*C*.

### Function List

- void Transpose_Matrix( double *At, double *A, int nrows, int ncols)

Take the transpose of the*nrows × ncols*matrix*A*and store in the*ncols × nrows*matrix*At*, i.e.*At = A*. The matrix^{T}*At*should be declared as double*At[ncols][nrows]*in the calling routine, and the matrix*A*declared as double*A[nrows][ncols]*. In general,*At*and*A*should be disjoint i.e. their memory locations should be distinct.

- void Transpose_Square_Matrix( double *A, int n )

Take the transpose of the*n × n*matrix*A*and store in place.

- void Transpose_CMatrix( double complex *At, double complex *A, int nrows, int ncols)

Take the transpose of the*nrows × ncols*complex matrix*A*and store in the*ncols × nrows*complex matrix*At*, i.e.*At = A*. The matrix^{T}*At*should be declared as double complex*At[ncols][nrows]*in the calling routine, and the matrix*A*declared as double complex*A[nrows][ncols]*. In general,*At*and*A*should be disjoint i.e. their memory locations should be distinct.

- void Transpose_Square_CMatrix( double complex *A, int n )

Take the transpose of the*n × n*complex matrix*A*and store in place.

*C* Source Code

- The file,transpose_matrix.c, contains the version of Transpose_Matrix() written in
*C*.

- The file,transpose_square_matrix.c, contains the version of Transpose_Square_Matrix() written in
*C*.

- The file,transpose_cmatrix.c, contains the version of Transpose_CMatrix() written in
*C*.

- The file,transpose_square_cmatrix.c, contains the version of Transpose_Square_CMatrix() written in
*C*.

*NASM* Source Code

For Linux gcc Users

- The file,transpose_matrix.asm, contains the version of Transpose_Matrix() written in
*NASM*.

- The file,transpose_square_matrix.asm, contains the version of Transpose_Square_Matrix() written in
*NASM*.

*C* Test Code, Test Results, and Build Shell Script

- The file, testtransposematrix.c, contains a test program of Transpose_Matrix( ) in the file
*transpose_matrix.c*. This test program requires the file*transpose_matrix.c*listed above.

- The file, TransposeMatrixTest.txt, contains the results of the test program testtransposematrix.c.

- The file, testtransposematrix.sh, contains the shell script used to compile, link, and execute the test program ttesttransposematrix.c.

- The file, testtransposesqmatrix.c, contains a test program of Transpose_Square_Matrix( ) in the file
*transpose_square_matrix.c*. This test program requires the file*transpose_square_matrix.c*listed above.

- The file, TransposeSquareMatrixTest.txt, contains the results of the test program ttesttransposesqmatrix.c.

- The file, testtransposesqmatrix.sh, contains the shell script used to compile, link, and execute the test program testtransposesqmatrix.c.

- The file, testtransposecmatrix.c, contains a test program of Transpose_CMatrix( ) in the file
*transpose_cmatrix.c*. This test program requires the file*transpose_cmatrix.c*listed above.

- The file, TransposeCMatrixTest.txt, contains the results of the test program testtransposecmatrix.c.

- The file, testtransposecmatrix.sh, contains the shell script used to compile, link, and execute the test program testtransposecmatrix.c.

- The file, testtransposesqcmatrix.c, contains a test program of Transpose_Square_CMatrix( ) in the file
*transpose_square_cmatrix.c*. This test program requires the file*transpose_square_cmatrix.c*listed above.

- The file, TransposeSquareCMatrixTest.txt, contains the results of the test program testtransposesqcmatrix.c.

- The file, testtransposesqcmatrix.sh, contains the shell script used to compile, link, and execute the test program testtransposesqcmatrix.c.