How Does Matrix Multiplication Work in C Programming?

AI Thread Summary
Matrix multiplication in C programming involves multiplying two matrices, represented as two-dimensional arrays, and storing the result in a third array. The multiplication process requires multiplying each element in a row of the first matrix by each element in a column of the second matrix and summing the products to find the corresponding element in the result matrix. Specifically, for matrices A (m x n) and B (n x p), the resulting matrix C will have dimensions m x p. The implementation typically uses nested loops to iterate through the rows of matrix A and the columns of matrix B, with an additional loop for the element-wise multiplication and summation. Understanding this process is crucial for correctly implementing matrix multiplication in C.
tandoorichicken
Messages
245
Reaction score
0
For a computer program, I have to multiply:
a[][] * b[]
and store it in c[]

how does the math for this work out on paper? What exactly am I multiplying?
 
Physics news on Phys.org
This is what you're trying to do:

c_{i} = \sum_{j = 1}^{N}a_{i, j}b_{j}
 


Matrix multiplication in C involves multiplying two matrices, represented as two-dimensional arrays, and storing the result in a third array. In this case, we are multiplying a matrix represented by the array a[][] with another matrix represented by the array b[][], and storing the result in a third array c[].

On paper, matrix multiplication involves multiplying each element in a row of the first matrix with each element in a column of the second matrix and adding the products. For example, if we have a matrix A with dimensions m x n and a matrix B with dimensions n x p, the resulting matrix C will have dimensions m x p. To find the element at position (i,j) in matrix C, we multiply the elements in the i-th row of matrix A with the elements in the j-th column of matrix B and add the products.

In the case of the computer program, we will use nested loops to iterate through the rows and columns of the matrices and perform the necessary calculations to populate the elements in matrix C. The first loop will iterate through the rows of matrix A, and the second loop will iterate through the columns of matrix B. Within these loops, we will use a third loop to multiply the corresponding elements and add them to the result. This process will continue until all elements in matrix C have been calculated and stored.

In summary, matrix multiplication in C involves performing a series of calculations on corresponding elements in two matrices and storing the result in a third matrix. This process can be easily understood by breaking it down into smaller steps and using nested loops to perform the necessary operations.
 
I multiplied the values first without the error limit. Got 19.38. rounded it off to 2 significant figures since the given data has 2 significant figures. So = 19. For error I used the above formula. It comes out about 1.48. Now my question is. Should I write the answer as 19±1.5 (rounding 1.48 to 2 significant figures) OR should I write it as 19±1. So in short, should the error have same number of significant figures as the mean value or should it have the same number of decimal places as...
Thread 'A cylinder connected to a hanging mass'
Let's declare that for the cylinder, mass = M = 10 kg Radius = R = 4 m For the wall and the floor, Friction coeff = ##\mu## = 0.5 For the hanging mass, mass = m = 11 kg First, we divide the force according to their respective plane (x and y thing, correct me if I'm wrong) and according to which, cylinder or the hanging mass, they're working on. Force on the hanging mass $$mg - T = ma$$ Force(Cylinder) on y $$N_f + f_w - Mg = 0$$ Force(Cylinder) on x $$T + f_f - N_w = Ma$$ There's also...
Back
Top