seanhalle@0: /* seanhalle@0: * Copyright Oct 24, 2009 OpenSourceCodeStewardshipFoundation.org seanhalle@0: * Licensed under GNU General Public License version 2 seanhalle@0: */ seanhalle@0: seanhalle@0: #ifndef MATRIX_MULT_H_ seanhalle@0: #define MATRIX_MULT_H_ seanhalle@0: seanhalle@0: #include seanhalle@0: #include seanhalle@0: #include seanhalle@0: seanhalle@1: #include seanhalle@0: #include "ParamHelper/Param.h" seanhalle@0: seanhalle@0: //============================== Structures ============================== seanhalle@0: seanhalle@0: typedef seanhalle@0: struct seanhalle@0: { int32 numRows; seanhalle@0: int32 numCols; seanhalle@0: float32 *array; //2D, but dynamically sized, so use addr arith seanhalle@0: } seanhalle@0: Matrix; seanhalle@0: seanhalle@0: /* This is the "appSpecificPiece" that is carried inside a DKUPiece. seanhalle@0: * In the DKUPiece data struc it is declared to be of type "void *". This seanhalle@0: * allows the application to define any data structure it wants and put it seanhalle@0: * into a DKUPiece. seanhalle@0: * When the app specific info is used, it is in app code, so it is cast to seanhalle@0: * the correct type to tell the compiler how to access fields. seanhalle@0: * This keeps all app-specific things out of the DKU directory, as per the seanhalle@0: * DKU standard. */ seanhalle@0: typedef seanhalle@0: struct seanhalle@0: { seanhalle@0: // pointers to shared data.. the result matrix must be created when the seanhalle@0: // left and right matrices are put into the root ancestor DKUPiece. seanhalle@0: Matrix * leftMatrix; seanhalle@0: Matrix * rightMatrix; seanhalle@0: Matrix * resultMatrix; seanhalle@0: seanhalle@0: // define the starting and ending boundaries for this piece of the seanhalle@0: // result matrix. These are derivable from the left and right seanhalle@0: // matrices, but included them for readability of code. seanhalle@1: int resStartRow, resEndRow; seanhalle@1: int resStartCol, resEndCol; seanhalle@0: // Start and end of the portion of the left matrix that contributes to seanhalle@0: // this piece of the product seanhalle@0: int leftStartRow, leftEndRow; seanhalle@0: int leftStartCol, leftEndCol; seanhalle@0: // Start and end of the portion of the right matrix that contributes to seanhalle@0: // this piece of the product seanhalle@0: int rightStartRow, rightEndRow; seanhalle@0: int rightStartCol, rightEndCol; seanhalle@0: } seanhalle@0: MatrixProdPiece; seanhalle@0: seanhalle@0: //============================== Functions ================================ seanhalle@0: void readFile(); seanhalle@0: seanhalle@0: Matrix *makeMatrix( int32 numRows, int32 numCols ); seanhalle@0: Matrix *makeMatrix_Flat( int32 numRows, int32 numCols ); seanhalle@0: Matrix *makeMatrix_WithResMat( int32 numRows, int32 numCols ); seanhalle@0: void freeMatrix_Flat( Matrix * matrix ); seanhalle@0: void freeMatrix( Matrix * matrix ); seanhalle@0: void printMatrix( Matrix *matrix ); seanhalle@0: seanhalle@0: void read_Matrix_From_File( Matrix *matrixStruc, char *matrixFileName ); seanhalle@0: seanhalle@0: void seanhalle@0: initialize_Input_Matrices_Via( Matrix **leftMatrix, Matrix **rightMatrix, seanhalle@0: ParamBag *paramBag ); seanhalle@0: seanhalle@0: //=========================================================================== seanhalle@0: seanhalle@0: #endif /*MATRIX_MULT_H_*/