The correct answer is option (b). Here, the mat4 array will have 4 rows and 3 columns, which sum up to 12 elements.
- Apart from the standard method, which of the following methods can be used to multiply matrices in C?
- Strassen's Algorithm
- Fourier Transform
- Gaussian Elimination
- Dynamic Programming
Explanation:
The correct answer is option (a). The Strassen algorithm reduces the time complexity of the traditional method to O (n^3) - O(n^2.81), which makes it an optimized algorithm for matrix multiplication in C.
- What would be the best way to avoid using unintended variables when doing matrix multiplication in C?
- Always use dynamic allocation.
- Initialize matrices to zero.
- Use global variables.
- Avoid nested loops.
Explanation:
The correct answer is (b). Initializing matrices to zero helps ensure that all elements start from a known state, avoiding unpredictable results from uninitialized variables.
- How should the inner loop index be used to perform matrix multiplication?
- It should iterate over the rows of the first matrix.
- It should iterate over the columns of the second matrix.
- It should iterate over the rows of both matrices.
- It should iterate over the common dimension of both matrices.
Explanation:
The correct answer is option (d). The inner loop should iterate over the common dimension (columns of the first matrix and rows of the second matrix) to correctly compute the product.
- Which library function can be used for matrix operations in C?
- stdio.h
- string.h
- math.h
- There is no standard C library for matrix operations.
Explanation:
The right choice is alternative (d). The C standard libraries do not provide a specific library for matrix operations. Consequently, these operations need to be carried out either by hand or with the use of external libraries.
- If matrix A has dimensions of A2 and matrix B has dimensions of B3, the resultant matrix will have dimensions of 2 after multiplication.
Explanation:
The accurate solution is choice (b). The resultant matrix obtained by multiplying matrices XY by YZ will possess the dimensions of XZ, leading to a final matrix size of 24.