+ 2

[Challenge :] Write a program which performs addition, subtraction, multiplication, division of matrices.

The dimensions of both the matrices would be specified by the user (dynamic memory allocation required). Use of structure or a class to define the matrix would be a good idea. The difficulty relies on the fact that you need to implement the inverse matrix to perform division (A/B = A*B^(-1)).

18th Oct 2017, 11:39 AM
Nikos And
Nikos And - avatar
3 Réponses
+ 5
https://code.sololearn.com/cq24J951TxgI/?ref=app A class, if you want it. Can even operate on complex numbers, with its separate class provided in the same. Since the class is so big, you will have to run a new cpp file, including this class via a header containing the program above. https://code.sololearn.com/csoxnSZt3tiG/?ref=app Here is the example. Just how the main would look if you use the class.
9th Oct 2017, 1:43 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 2
My try on c++. User gives the dimensions of each matrix and chooses the arithmetic operation to be applied. For some unknown reason, for division it does not returns the resultant matrix (although in codeblocks it works correctly!) The difficult part was to create the inverse matrix for the division. If matrices dimensions are not equal, then in the matrix with the smaller ones is performed zero padding in order to make them have the same dimensions. To see yourself that division works correctly you can c/p the code and run it elsewhere (e.g. on codeblocks) My code: https://code.sololearn.com/c7RXD4dD1GH1/#cpp
15th Oct 2017, 8:12 PM
Nikos And
Nikos And - avatar
+ 1
https://code.sololearn.com/cxt8WCAx0oGf/?ref=app This calculator is without a class. It can perform all operations,after you provide input correctly...
9th Oct 2017, 1:23 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar