0

two dimensional matrix using class

https://code.sololearn.com/ca22a9a15a9A All of the output is showing zero and idk why.Also how can I print the inverse function of type Matrix in the output?

4th May 2021, 8:57 AM
Ramisa Fariha
Ramisa Fariha - avatar
17 Respostas
+ 2
You only did M2.inverse(). But kt should be M2 = M2.inverse() because you did not modify the Matrix but rather made a new object.
4th May 2021, 11:57 AM
你知道規則,我也是
你知道規則,我也是 - avatar
+ 1
You didn't give anything to M2. All the default value in the constructor parameters are used, which is 0.
4th May 2021, 9:35 AM
你知道規則,我也是
你知道規則,我也是 - avatar
+ 1
Copy M1 to M2? But you use M1 = M2.
4th May 2021, 10:34 AM
你知道規則,我也是
你知道規則,我也是 - avatar
+ 1
M2 = M2.inverse();
4th May 2021, 10:58 AM
你知道規則,我也是
你知道規則,我也是 - avatar
+ 1
Replace the main() with this and try again. int main() { Matrix M1(2,3,4,5); Matrix M2; M2=M1; M2.print(); M2.det(); M2.printdet(); M2=M2.inverse(); M2.print(); M2.isSingular(); M2.printSingular(); return 0; }
4th May 2021, 1:02 PM
你知道規則,我也是
你知道規則,我也是 - avatar
4th May 2021, 2:31 PM
Ramisa Fariha
Ramisa Fariha - avatar
0
@Martin yes it is taken from that book...@Carrie I am trying to copy M1 through M2 using the copy constructor
4th May 2021, 10:31 AM
Ramisa Fariha
Ramisa Fariha - avatar
0
@Martin there was no array in the book so I didn't create one
4th May 2021, 10:32 AM
Ramisa Fariha
Ramisa Fariha - avatar
0
@Carrie ok now that's a mistake..let me edit it
4th May 2021, 10:35 AM
Ramisa Fariha
Ramisa Fariha - avatar
0
@Carrie it worked now..but what can I do about the inverse matrix..how can I show it?
4th May 2021, 10:36 AM
Ramisa Fariha
Ramisa Fariha - avatar
0
yes I did it @carrie but the output not shown..how can I do it like can you please check the inverse function..it's type is of class matrix
4th May 2021, 11:16 AM
Ramisa Fariha
Ramisa Fariha - avatar
0
ok I'll do it again
4th May 2021, 12:16 PM
Ramisa Fariha
Ramisa Fariha - avatar
0
@Carrie I did it still the inverse result not shown in the output..cout<<temp in the inverse function causes an error since it's a matrix kind..so how can I show it now?
4th May 2021, 12:28 PM
Ramisa Fariha
Ramisa Fariha - avatar
0
Did you print it with M2.print() after inverse()?
4th May 2021, 12:41 PM
你知道規則,我也是
你知道規則,我也是 - avatar
0
@Carrie I tried it at first in the print() but since it belongs to the type matrix it can't be done by using cout...and that's what I want to know like how to print an output value which is of class type you see it's not double inverse() or int type ..it is Matrix inverse and the temp is also written as Matrix temp..now How can I cout temp?
4th May 2021, 12:54 PM
Ramisa Fariha
Ramisa Fariha - avatar