genMatrixTranspose
in GenMath.lib

Matrix Functions        Function List by Category        Alphabetical Function List

Sample Code

int genMatrixTranspose(
                                            float *Matrix,                // pointer to matrix A
                                            int     dimM,                   // rows of A
                                            int     dimN,                    // columns of A
                                            float *Transpose)
           // pointer to store transpose Matrix

This function transposes an mxn matrix:

c(i,j) = a(j,i)

There is no array bounds checking performed within the function; the user must ensure that Matrix
and Transpose are of proper size.  Specifically, the Matrix array should be mxn, and the Transpose
array array should be nxm.

The return code is errno, defined in the C standard library (math.h).  This is an integer value
for math errors.

 
Sample Application:
/////////// splMTrn.c for genMatrixTranspose Library Function ////////
//								    //
//	For this sample, a 2x3 matrix is transposed.  		    //
//								    //
//////////////////////////////////////////////////////////////////////

//////////////////////////// INCLUDES ////////////////////////////////

#include "stdio.h"
#include "genMath.h"

////////////////////////////// MAIN //////////////////////////////////
void main()
{

	//local declarations
	//integers
	int i;			// i dimension counter for result
	int j;			// j dimension counter for result display
	int retcode;		// return code for call to genMatrixTranspose

	//floats
	float a[2][3];		// matrix A
	float c[3][2];		// resultant matrix, C

	//character strings
	char  ch;		//input string to exit

	//intialize the A and B matrices
	a[0][0] = (float)1.234;
	a[0][1] = (float)-.678;
	a[0][2] = (float)10.3;
	a[1][0] = (float)14.004;
	a[1][1] = (float)5.332;
	a[1][2] = (float)0.004;
	a[2][0] = (float)-23.400;
	a[2][1] = (float)0.067;
	a[2][2] = (float)-3.882;

	//transpose the matrix
	retcode = genMatrixTranspose(a,2,3,c);
	
	//display the result
	
	printf("%s", "Resultant Matrix Elements: \n\n");

	for(i=0;i<3;++i){
	
		for(j=0; j < 2; ++j){
			printf("%s%d%s%d%s%f%s", "c[",i,"][",j,"] = ", 
				c[i],"\n");
		}
	
	}

	//display closing message and wait for <enter> before exiting
	printf("\nPress <Enter> to end");
	scanf("%c", &ch);

} // End Main

/////////////////////////////// End splMTrn.c ///////////////////////