资源描述:
《矩阵计算C语言源代码》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、//#include"matrix.h"#defineEX_TRUE(0)#defineEX_FALSE(1)#defineEX_MALLOC(2)typedefstructtagMatrix{unsignedcharucRow;unsignedcharucCol;unsignedshortusRev;float*pfDataAdd;}Matrix_s;externintInputRowColInfo(unsignedchar*pucRow,unsignedchar*pucCol);externintCreateMatrixM
2、em(void*pvData);externintInputMatrixData(void*pvData);externintPrintMatrixData(void*pvData);externintPrintInverseMatrixData(void*pvData);externintShow_matrix(Matrix_s*pstMatrixA,Matrix_s*pstMatrixB);//#include"operate_matrix.h"#defineEX_MATRIX_INIT(1)#defineEX_MATRI
3、X_UNINIT(0)typedefenum{EX_INPUT_MATRIX=1,EX_ADD_MATRIX,EX_SUBTRACT_MATRIX,EX_MULTIPLY_MATRIX,EX_INVERSE_MATRIX,EX_QUIT_MATRIX,EX_BOTTOM_MATRIX}Matrix_opcode_en;externintOperateMatrix(intiOpCode,Matrix_s*pstMatrixA,Matrix_s*pstMatrix);externintShowMatrixMenu();extern
4、intCheckMatrix(intiOpCode,Matrix_s*pstMatrixA,Matrix_s*pstMatrixB);externintAddMatrix(intiOpCode,Matrix_s*pstMatrixA,Matrix_s*pstMatrixB,Matrix_s*pstMatrixC);externintSubtractMatrix(intiOpCode,Matrix_s*pstMatrixA,Matrix_s*pstMatrixB,Matrix_s*pstMatrixC);externintMul
5、tiplyMatrix(intiOpCode,Matrix_s*pstMatrixA,Matrix_s*pstMatrixB,Matrix_s*pstMatrixC);externintCreateResultMatrix(unsignedcharucRow,unsignedcharucCol,void*pvData);externintInverseMatrix(floata[],intn);/*GuanlinLuoID:10529749*/#include#include#includ
6、e#include#include"matrix.h"/*Wehavealreadydonethisheader.*/#include"operate_matrix.h"/*Wehavealreadydonethisheader.*/charg_cFlag=EX_MATRIX_UNINIT;intmain(){intiInputOpCode;intiRet=EX_FALSE;Matrix_sstMatrixA,stMatrixB;memset(&stMatrixA,0,sizeof(stMa
7、trixA));memset(&stMatrixB,0,sizeof(stMatrixB));while(1){/*showmenu*/(void)ShowMatrixMenu();/*operetematrix*/scanf("%d",&iInputOpCode);iRet=OperateMatrix(iInputOpCode,&stMatrixA,&stMatrixB);if(EX_TRUE==iRet){if(EX_QUIT_MATRIX==iInputOpCode){break;}}}if(NULL!=stMatrix
8、A.pfDataAdd){free(stMatrixA.pfDataAdd);}if(NULL!=stMatrixB.pfDataAdd){free(stMatrixB.pfDataAdd);}returnEX_TRUE;}intShowMatrixMenu()/*choic