Matrix Multiplication in C | My Assignment Tutor

COMP26020 Part 1– Assignment 1:Matrix Multiplication in CThe goal of this assignment is to write a C program performing a matrix multiplication operation. The programtakes 3 command line parameters that are M, N and seed, and is launched as follows:./mat-mult The program generates 2 matrixes matrix 1 and matrix 2. Matrix 1 has a size of MxN and matrix 2 has a sizeof NxM. Both are filled with random integer numbers – each taking a value between 0 and 99 – with agenerator initialized with seed. Both matrixes are printed on the standard output. Then the programmultiplies A by B and prints the resulting matrix on the standard output. The program also measures theexecution time of the multiplication operation and prints it, in seconds, on the standard output after theresult matrix.Here is a complete execution over one example:./mat-mult 5 3 0MATRIX 1:83 86 7715 93 3586 92 4921 62 2790 59 63MATRIX 2:26 40 26 72 3611 68 67 29 8230 62 23 67 35RESULT:5414 13942 9691 13629 127352463 9094 7426 6122 93914718 12734 9527 12143 123552038 6730 5321 5119 67854879 11518 7742 12412 10283EXECUTION TIME: 0.000004Once your C program is written and functional, use the execution time reported to produce a graphcomparing the performance of your C code versus the Python implementation for matrixes of sizes 5×5,50×50, and 500×500. An example of such graph is presented on the next page.The requirements for this assignment are as follows:• Given the variable size of the matrixes, they should be stored in memory using dynamic memoryallocation, i.e. within buffers allocated through malloc;• The code should be in a single source file, well organized within multiple functions, correctlyindented, and should compile without warnings. When marking, good C programming practicesmentioned in the course will be taken into account such as proper memory management, code style,etc.;• Using a wrong number of command line arguments, or incorrect values for these arguments shouldlead to a graceful exit and not a crash;• This assignment will be graded in part using automated methods and as such it is crucial that theoutput format described above is respected to the letter.The exercise will be marked out of 10, using the following marking scheme:• The program is functional, subject requirements are respected /4.5;• The program follows the good C programming practices covered in the course regarding dynamic;memory allocation, parameter management, code style /4.5;• The graph is meaningful and readable /1.


Leave a Reply

Your email address will not be published. Required fields are marked *