Hello! I have a question that I think might be simple to answer but I haven't found any documentation anywhere to confirm my suspicions. I pasted only the relevant portions of my code below to the question that I'm asking. My program is supposed to multiply two square matrices.
The question that I have is about an "error: incompatible types in assignment" that I get when I try to assign suba, subb, subc with the corresponding portions of a, b, and c. Is this because I'm using variables v and w? Also, just to make sure that I have the right concept, if I assign the top left corner of a matrix to a "submatrix" then I'm just assigning a pointer (such as subb) to that start at the specified position of the big matrix, right?
Thanks in advance for the help! It is IMMENSELY appreiciated
struct threads
{
pthread_t id; //The thread id to use in functions
int n; //size of block
float **suba; //Sub-matrix a
float **subb; //Sub-matrix b
float **subc; //Sub-matrix c
};
int main( int argc, char* argv[ ] )
{
int n; // dimension of the matrix
int p; // number of threads in the program
float *sa, *sb, *sc; // storage for matrix A, B, and C
float **a, **b, **c; // 2-d array to access matrix A, B, and C
int i, j;
struct threads* t;
t = ( struct threads* ) malloc( p * sizeof( struct threads ) );
int x = -1;
int z;
for( z = 0; z < p; z++ )
{
t[ z ].n = n / sqrt( p );
if( fmod( z, sqrt( p ) ) == 0 )
x++;
int w = ( int )( x * n / sqrt( p ) );
int v = ( int )( fmod( z, sqrt( p ) ) * n / sqrt( p ) );
t[z].suba = a[ w ][ v ];
t[z].subb = b[ w ][ v ];
t[z].subc = c[ w ][ v ];
//pthread_create( &t[ z ].id, 0, threadWork, &t[ z ] );
}
return 0;
}