Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Matrix: 50 Points File: matrix.cpp In this problem you will implement arbitrary sized matrix that can hold elements of type double. You will create

1. Matrix: 50 Points File: matrix.cpp In this problem you will implement arbitrary sized matrix that can hold elements of type double. You will create a class Matrix which has two constructors Matrix() (creates 0 by 0 matrix) and Matrix(int m, int n) (creates m by n matrix). The destructor ~Matrix() needs to deallocate the memory which holds matrix elements. Apply rule of three, i.e., add a copy constructor and an assignment operator. Additionally, you need to implement following operators:

operator* (multiplies two matrices and returns new matrix), operator+ (adds two matrices and returns new matrix), operator[] (returns an element addressed with one index. Assume we have a 3x4 matrix, the index 4 will return second row, first column element of the matrix), operator() (returns an element addressed with two indices, first index represents row and second index represents column), operator<< (sends a matrix to ostream; do not use std::cout in the operator), and operator>> (reads a matrix).

As usual, the input will contain the number of cases and for each case the operation to perform and the two matrices. Each matrix is specified by two numbers (m - number of rows and n - number of columns) and followed by its elements. After performing the specified operation you need to print the resulting matrix. All inputs will be valid, so there is no need to check if the inputs are numbers or that the matrix sizes are compatible. Example Input 3 multiply 2 3 1 2 3 5 6 7 3 5 -9 8 7 6 5 4 3 2 1 0 1 0 0 1 3 add 2 2 1 0 0 1 2 2 5 2 3 4 add 1 3 10 9 -98 1 3 10 0 99 Example Output Case 0: 2 2 14 11 11 14 -14 58 47 43 46 Case 1: 6 2 3 5 Case 2: 20 9 1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Machine Performance Modeling Methodologies And Evaluation Strategies Lncs 257

Authors: Francesca Cesarini ,Silvio Salza

1st Edition

3540179429, 978-3540179429

More Books

Students also viewed these Databases questions

Question

What is operatiing system?

Answered: 1 week ago

Question

12-5 How will MIS help my career?

Answered: 1 week ago