Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Implement a class to represent a matrix. While doing this exercise, you are allo

ID: 3555620 • Letter: I

Question

Implement a class to represent a matrix. While doing this exercise, you are allowed only to use C++ primitive types and arrays. You may not use STL in your Matrix definition. You must use dynamic memory.

class Matrix {

friend ostream &operator << (ostream &os, const Matrix &);
friend istream &operator >> (istream &is, Matrix &);
public:

Matrix(); // 1x1 matrix with its element = 0
   Matrix(int r, int c); // rxc matrix with all elements = 0
   Matrix(int r, int c, int *values[]) // initialize matrix with specific values
   Matrix(const Matrix &other); // copy ctor
   ~Matrix(); // destructor
   Matrix &operator(const Matrix &other);    // assignment operator
   int getElement(int r, int c) const;
   void setElement (int r, int c, int val);
   Matrix operator + (const Matrix &other) const;
   Matrix &operator += (const Matrix &other);
   Matrix transpose() const;
   int getNumRows() const;
   int getNumCols() const;
   bool isSymmetric() const;
private:
   int **data;
   int rows, cols;
};

You should throw and exception under illegal conditions (e.g., negative rows or cols, adding matrices with different sizes, etc.). For input and output matrices will be formatted as:


5 3

1 2 3

0 0 0

4 5 3

9 0 9

1 1 1

I need the program written in C++ and python.

Explanation / Answer

#include #include using namespace std; class Matrix { private: vector Mat; Matrix() {}; public: Matrix(vector mat): Mat(mat) {cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote