Question
//********************************************************************************************************* //This is matChainMul.c #include #include #include #include unsigned int cost ( unsigned int matrixCount, unsigned int* rowSizes, unsigned int* colSizes ) { if (
//********************************************************************************************************* //This is matChainMul.c #include #include #include #include unsigned int cost ( unsigned int matrixCount, unsigned int* rowSizes, unsigned int* colSizes ) { if ( matrixCount==1 ) { // Base case. return 0; // No multplication to be done. } else { unsigned int numPossibleSplits = matrixCount-1; // Think: if there are two matrices to multiply, there is one way to split. // AB: (A)(B) // ABC: (A)(BC) and (AB)(C) unsigned int costs[numPossibleSplits]; for ( unsigned int split=0; split #include #include #include size_t mulOpCount = 0; bool set = false; void printLog ( void ) { FILE *fp = fopen("mul_op_count.txt", "w"); fprintf(fp, "%ld", mulOpCount); fclose(fp); } unsigned int mul ( unsigned int multiplier, unsigned int multiplicand ) { if (!set) { atexit(printLog); set = true; } mulOpCount++; return multiplier * multiplicand; } void matMul ( unsigned int l, unsigned int m, unsigned int n, int** matrix_a, int** matrix_b, int** matMulProduct ) { // printf("l=%d ", l); // printf("m=%d ", m); // printf("n=%d ", n); for ( unsigned int i=0; i
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started