|
Multiply matrix in C++
|
|
05-16-2010, 08:53 PM
(This post was last modified: 01-07-2011 04:03 AM by drdebcol.)
Post: #1
|
|||
|
|||
|
Multiply matrix in C++
This is program for mathematical matrix multiplication.
You have everything about that here : http://en.wikipedia.org/wiki/Matrix_multiplication And here is the program : Code: #include <iostream>There's a fine line between genius and insanity. I have erased this line. Oscar Levant There's a fine line between an administrator and black hat hacker. I have erased this line. Dr DEBCOL |
|||
|
05-17-2010, 06:32 AM
Post: #2
|
|||
|
|||
|
RE: Multiply matrix in C++
Very good work Drdebcol! Nice work with multidimensional arrays
"Character is determined more by the lack of certain experiences than by those one has had." Friedrich Nietzsche |
|||
|
01-06-2011, 03:13 PM
(This post was last modified: 01-06-2011 11:02 PM by Xupicor.)
Post: #3
|
|||
|
|||
|
RE: Multiply matrix in C++
Note that it is not Standard C++. To get dynamic array you either use non-standard compiler extension (this) or use a standard way of using a pointer and allocating memory by yourself:
Code: unsigned int n;You can also forget plain arrays and use a std::vector or any other smart container, as a good C++ programmer would do: Code: std::vector<int> array; |
|||
|
01-07-2011, 03:54 AM
Post: #4
|
|||
|
|||
|
RE: Multiply matrix in C++
Oh, yeah that is probably an error. I am going to fix that !
I know that way of declaring arrays can work in all functions except main. And yeah of course i know how to allocate a dynamic array using new and delete ! Good reply ! There's a fine line between genius and insanity. I have erased this line. Oscar Levant There's a fine line between an administrator and black hat hacker. I have erased this line. Dr DEBCOL |
|||
|
01-09-2011, 03:08 AM
(This post was last modified: 01-09-2011 03:13 AM by CrAzY-KiD.)
Post: #5
|
|||
|
|||
|
RE: Multiply matrix in C++
that was very confusing and complicated for me....
i m at initial level.... and i can't understand that things...
|
|||
|
01-09-2011, 03:25 AM
Post: #6
|
|||
|
|||
RE: Multiply matrix in C++
(01-09-2011 03:08 AM)CrAzY-KiD Wrote: that was very confusing and complicated for me....Well mathematically that is not so hard, multiplying matrix is a simple action. But when you look at the code, there are mostly simple things, except matrix allocation and pointers, which most beginners find hard ! There's a fine line between genius and insanity. I have erased this line. Oscar Levant There's a fine line between an administrator and black hat hacker. I have erased this line. Dr DEBCOL |
|||
|
01-09-2011, 12:04 PM
Post: #7
|
|||
|
|||
|
RE: Multiply matrix in C++
but my teacher gave me that question....
i almost solve it but when mulitdimension Multiply matrix in C++ for 3*3 using more loop can u guide me to make a good program with less loop ![]() |
|||
|
01-09-2011, 09:50 PM
Post: #8
|
|||
|
|||
|
RE: Multiply matrix in C++
The easiest way to multiply matrix is with 3 for loops (complexity O(n^3)). Every other way is harder to implement, though it has slightly better complexity.
So the easiest way to multiply two matrix-es a and b and get result c is : Code: for (int i=0;i<m;i++)a (m*n) b (n*p) c (m*p) where m,n,p are integers that user enters ! There's a fine line between genius and insanity. I have erased this line. Oscar Levant There's a fine line between an administrator and black hat hacker. I have erased this line. Dr DEBCOL |
|||
|
01-10-2011, 02:26 AM
(This post was last modified: 01-10-2011 02:44 AM by CrAzY-KiD.)
Post: #9
|
|||
|
|||
|
RE: Multiply matrix in C++
for 2*2...!!!
what should i do...! please write full code... so that i can understand batter
![]() |
|||
|
01-10-2011, 04:38 AM
Post: #10
|
|||
|
|||
|
RE: Multiply matrix in C++
Basically you need to understand concept of multiplication !
It doesn't matter if size is 2x2 or 3x3 etc. But if you which, here is the code for hand multiplication (without loops) for two matrices 2x2 : Code: #include <iostream>There's a fine line between genius and insanity. I have erased this line. Oscar Levant There's a fine line between an administrator and black hat hacker. I have erased this line. Dr DEBCOL |
|||
|
« Next Oldest | Next Newest »
|






![[Image: cazykid1.png]](http://img64.imageshack.us/img64/2841/cazykid1.png)