/* **++ ** FACILITY: Sample facility 1 ** ** MODULE DESCRIPTION: ** ** This is a sample module used to show how to use LSE and SCA to create ** a detailed design. ** ** AUTHORS: ** ** Jane Smith ** ** CREATION DATE: June 27, 1991 ** ** DESIGN ISSUES: ** ** {@tbs@} ** ** KEYWORDS: ** ** Examples, sample design ** ** MODIFICATION HISTORY: ** ** {@tbs@}... **-- */ #include typedef int integer_matrix[10][10]; integer_matrix *matrix_multiply (integer_matrix *left, integer_matrix *right); /* **++ ** FUNCTIONAL DESCRIPTION: ** ** This function computes the matrix product of two integer matrices. ** ** It uses a simple, triple-nested loop, and does not do any checking to ** see if the matrices conform. ** ** FORMAL PARAMETERS: ** ** left: ** The left operand. ** ** right: ** The right operand. ** ** RETURN VALUE: ** ** The result of multiplying the two matrices. ** **-- */ integer_matrix *matrix_multiply (integer_matrix *left, integer_matrix *right) { integer_matrix *result_matrix; int i, j, k; /* ** Allocate and initialize the result matrix */ result_matrix = malloc (i*j); for (i = 1; i < 10; i++) { for (j = 1; j < 10; j++) { *result_matrix[i][j] = 0; } }; /* ** Loop over the rows of the left matrix */ for (i = 1; i < 10; i++) { /* ** Loop over the columns of the right matrix */ for (j = 1; j < 10; j++) { /* ** Compute the inner product of the current row and column */ for (k = 1; k < 10; k++) { *result_matrix[i][j] = *result_matrix[i][j] + *left[i][k] * *right[k][j]; } }; }; return result_matrix; }