| rev |
line source |
|
seanhalle@0
|
1 /*
|
|
seanhalle@0
|
2 * Copyright Oct 24, 2009 OpenSourceCodeStewardshipFoundation.org
|
|
seanhalle@0
|
3 * Licensed under GNU General Public License version 2
|
|
seanhalle@0
|
4 */
|
|
seanhalle@0
|
5
|
|
seanhalle@0
|
6 #ifndef MATRIX_MULT_H_
|
|
seanhalle@0
|
7 #define MATRIX_MULT_H_
|
|
seanhalle@0
|
8
|
|
seanhalle@0
|
9 #include <stdio.h>
|
|
seanhalle@0
|
10 #include <unistd.h>
|
|
seanhalle@0
|
11 #include <malloc.h>
|
|
seanhalle@0
|
12
|
|
seanhalle@0
|
13 #include "ParamHelper/Param.h"
|
|
seanhalle@0
|
14
|
|
seanhalle@0
|
15 //============================== Structures ==============================
|
|
seanhalle@0
|
16
|
|
seanhalle@0
|
17 typedef
|
|
seanhalle@0
|
18 struct
|
|
seanhalle@0
|
19 { int32 numRows;
|
|
seanhalle@0
|
20 int32 numCols;
|
|
seanhalle@0
|
21 float32 *array; //2D, but dynamically sized, so use addr arith
|
|
seanhalle@0
|
22 }
|
|
seanhalle@0
|
23 Matrix;
|
|
seanhalle@0
|
24
|
|
seanhalle@0
|
25 /* This is the "appSpecificPiece" that is carried inside a DKUPiece.
|
|
seanhalle@0
|
26 * In the DKUPiece data struc it is declared to be of type "void *". This
|
|
seanhalle@0
|
27 * allows the application to define any data structure it wants and put it
|
|
seanhalle@0
|
28 * into a DKUPiece.
|
|
seanhalle@0
|
29 * When the app specific info is used, it is in app code, so it is cast to
|
|
seanhalle@0
|
30 * the correct type to tell the compiler how to access fields.
|
|
seanhalle@0
|
31 * This keeps all app-specific things out of the DKU directory, as per the
|
|
seanhalle@0
|
32 * DKU standard. */
|
|
seanhalle@0
|
33 typedef
|
|
seanhalle@0
|
34 struct
|
|
seanhalle@0
|
35 {
|
|
seanhalle@0
|
36 // pointers to shared data.. the result matrix must be created when the
|
|
seanhalle@0
|
37 // left and right matrices are put into the root ancestor DKUPiece.
|
|
seanhalle@0
|
38 Matrix * leftMatrix;
|
|
seanhalle@0
|
39 Matrix * rightMatrix;
|
|
seanhalle@0
|
40 Matrix * resultMatrix;
|
|
seanhalle@0
|
41
|
|
seanhalle@0
|
42 // define the starting and ending boundaries for this piece of the
|
|
seanhalle@0
|
43 // result matrix. These are derivable from the left and right
|
|
seanhalle@0
|
44 // matrices, but included them for readability of code.
|
|
seanhalle@0
|
45 int prodStartRow, prodEndRow;
|
|
seanhalle@0
|
46 int prodStartCol, prodEndCol;
|
|
seanhalle@0
|
47 // Start and end of the portion of the left matrix that contributes to
|
|
seanhalle@0
|
48 // this piece of the product
|
|
seanhalle@0
|
49 int leftStartRow, leftEndRow;
|
|
seanhalle@0
|
50 int leftStartCol, leftEndCol;
|
|
seanhalle@0
|
51 // Start and end of the portion of the right matrix that contributes to
|
|
seanhalle@0
|
52 // this piece of the product
|
|
seanhalle@0
|
53 int rightStartRow, rightEndRow;
|
|
seanhalle@0
|
54 int rightStartCol, rightEndCol;
|
|
seanhalle@0
|
55 }
|
|
seanhalle@0
|
56 MatrixProdPiece;
|
|
seanhalle@0
|
57
|
|
seanhalle@0
|
58 //============================== Functions ================================
|
|
seanhalle@0
|
59 void readFile();
|
|
seanhalle@0
|
60
|
|
seanhalle@0
|
61 Matrix *makeMatrix( int32 numRows, int32 numCols );
|
|
seanhalle@0
|
62 Matrix *makeMatrix_Flat( int32 numRows, int32 numCols );
|
|
seanhalle@0
|
63 Matrix *makeMatrix_WithResMat( int32 numRows, int32 numCols );
|
|
seanhalle@0
|
64 void freeMatrix_Flat( Matrix * matrix );
|
|
seanhalle@0
|
65 void freeMatrix( Matrix * matrix );
|
|
seanhalle@0
|
66 void printMatrix( Matrix *matrix );
|
|
seanhalle@0
|
67
|
|
seanhalle@0
|
68 void read_Matrix_From_File( Matrix *matrixStruc, char *matrixFileName );
|
|
seanhalle@0
|
69
|
|
seanhalle@0
|
70 void
|
|
seanhalle@0
|
71 initialize_Input_Matrices_Via( Matrix **leftMatrix, Matrix **rightMatrix,
|
|
seanhalle@0
|
72 ParamBag *paramBag );
|
|
seanhalle@0
|
73
|
|
seanhalle@0
|
74 //===========================================================================
|
|
seanhalle@0
|
75
|
|
seanhalle@0
|
76 #endif /*MATRIX_MULT_H_*/
|