comparison Matrix_Mult.h @ 0:c4b1849c05ef

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