![]() |
|
#1
|
|||
|
|||
Matrix Multiplyhi
please help!!! how to count the number of multiplications of matrix which are multiply as A1xA2xA3.....(AiXAi+1)XA........An |
|
#2
|
|||
|
|||
Re: Matrix MultiplyQuote:
1. If you are given the sizes of the matrices and the number of matrices, then you can use pencil and paper and brain to count the number of multiplications. 2. If you are given the sizes of the matrices and the number of matrices, then you can write a program that creates and multiplies the matrices and put a counter that is incremented each time a multiplication is performed. 3. If you are looking for a general answer, then you can do something like this: Consider square matrices for starters. Count the number of multiplications in forming the product of two matrices. Then if there are N such things you have a total of N-1 products and you know how many multiplications there are in forming the product of N 2x2 matrices. Try it again with 3x3 matrices. Look for a pattern that would allow you to generalize the result for the product of N matrices, each of which is nxn. I'll start: It's hard to make something look like a matrix without some graphics or typography beyond my willingness to spend the time for now, so if I show some kind of layout that looks square, consider it to be a matrix. So here is a representation of the product of two 2x2 matrices: Code:
If we use the definition of matrix multiplication, each of the four elements of the product requires two multiplications (and one addition), right? That is, Code:
Try it for 3x3. I'm thinking that each of the nine elements of the product requires three multiplications (and two additions). See if you reach the same conclusion. What do you think will be required for the product of two nxn matrices? Now, if the matrices aren't all square, you have to know what the number of rows and columns are for each one as well as the number of matrices to be multiplied. The steps of each multiplication are the same. (Note that the "naive" method of directly applying the definition to two nxn matrices is not the optimal solution in terms of number of multiplications required. There have been some "improvements" based on special properties of 2x2 matrices to reduce the total number of multiplications. I'll leave it to you to perform further research, if you are interested.) Regards, Dave |
|
#3
|
|||
|
|||
Re: Matrix Multiplythank you for your replay
the size and the number of the matrice are as follow size 1)11X13 2)13X17 3)17X19 4)19X23 5)23X29 6)29X11 7)11X13 9)17X19 i tried to write the code of the program without success . I would appreciate your advice with the subject |
|
#4
|
|||
|
|||
Re: Matrix MultiplyQuote:
Are you trying to multiply the matrices or just to count the number of multiplications? Your first post indicated that you wanted to count the number of multiplications. If you want to count the number multiplications, then take the matrices two at a time and add up the number of operations for each step. Since matrix multiplications are associative, it doesn't matter whether you go left-to-right or right-to-left --- just do them two at a time. If you want to generalize it for the product of, say an nxk matrix times a kxm matrix, use the same principles that I showed for square ones. If you actually want a program to form the product: 1. Make a C function that multiplies an nxk matrix by a kxm matrix (giving an nxm matrix). 2. Test the function with a main program that creates and multiplies two (small) matrices for which you can verify the answers. Try it with square matrices. Try it for non-square matrices. Make sure that nothing in the function depends on any particular size or any other special properties of your test cases. 3. Incorporate the function into a program that creates the matrices and calls the function repeatedly to multiply them two at a time. Regards, Dave |
Recent GIDBlog
Writing a book by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| debugging multi-dimensional vector/ matrix class | counterflow | C++ Forum | 1 | 15-Mar-2006 13:14 |
| Combining Vectors and References | Frankg | C++ Forum | 7 | 14-Jan-2006 07:17 |
| Array of arrays (matrix) | aie0 | MS Visual C++ / MFC Forum | 3 | 08-Jun-2005 13:11 |
| saving matrix from file to array | amina17 | C Programming Language | 5 | 03-Jun-2005 13:04 |
| Free Web Hosting at Matrix Web | Chatter | Free Web Hosting | 0 | 18-May-2005 10:00 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The