Implement a class to represent a matrix

Assignment Help C/C++ Programming
Reference no: EM13164475

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

Reference no: EM13164475

Questions Cloud

State the normal boiling point of ethanol : The normal boiling point of ethanol (C2H5OH) is 78.3 °C and its molar enthalpy of vaporization is 38.56 kJ/mol. What is the change in entropy in the system in J/K when 62.2 grams of ethanol
Design, write, and test a program : Design, write, and test a program that represents some of the aspects of a student
Programmer does not have to use the def statement : Unlike Z+-, the programmer does not have to use the DEF statement to create a variable. Instead, the programmer can simply use the variable. The first use of the variable creates it and initializes it to 0.
State the complete eigen-function of the molecule : Before the collision what is the complete Eigen-function of the molecule? assuming the surface is located at x=0, and V (x =0)=0 and tha tthe molecule is located at a position X>>0. which means the molecule can be treated as a free mass in the re..
Implement a class to represent a matrix : 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.
A lock variable not a good solution for mutual exclusion : why is busy waiting on a lock variable not a good solution for mutual exclusion?
Linear-time algorithm for computing the strong component : On the basis of a linear-time algorithm for computing the strong component containing a given vertex v, describe a simple quadratic-time algorithm for computing the strong components of a digraph.
Deliverable is to design an algorithm : Deliverable is to design an algorithm for a function that accepts an integer array as an argument and returns the total of values in the array. this is algorithm
What are the maturities on intel''s long-term debt : What are the maturities on Intel's Long-term debt and what are Intel's projected obligations on Long-Term Debt and Payments due by period?

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create a website that would allow users to enter and submit

Create a Website that would allow users to enter and submit survey

  Program to generate 100,000 prime numbers

Write a POSIX C/C++ program to generate 100,000 prime numbers. Assume that the program will be run on a computer with 5 CPUs and that your goal is to have this program finish as quickly as possible.

  Write a program that reads in a list of integer numbers and

Write a program that reads in a list of integer numbers and print out the sum of all numbers, the average, the lowest and the highest value entered. The first input number indicates how many numbers the program is attempting to read. For example, if ..

  C program that compare the time required

Write a C program that compare the time required to compute the product of two 10,000 x 10,000 matrices with and without optimization for locality.

  Skills required by personnel working in information security

What skills are required by personnel working in information security? Write down some job titles in the field and come up with some required qualifications and some desirable qualifications.

  Draws a pyramid consisting of bricks

Write a C program that draws a pyramid consisting of bricks arranged in horizontal rows, so that the number of bricks in each row decreases by one as you move up the pyramid.

  50 element array of integers with random numbers

write a java code to instantiate and initialize a 50 element array of integers with random numbers in the range of 45 through 256 inclusive.

  A linked list of your song structure in cd

The CD object should have a data member that is a linked list of your song structure that you have in CD.  The CD class needs a function that allows it to add a song to the object, that function would then append the song to that instance of the link..

  Write program to count occurrences of each word in text

Write down C++ program to read following text. Count occurrences of each word in text and keep this count in list of elements containing (word, occurrence count) pairs.

  Sort an array of elements using the quick sort algorithm

Sort an array of 10,000 elements using the quick sort algorithm as follows: sort the array using pivot as the middle element of the array

  Write c program to add two integers and prints out average

Write a C program that prompts for a variable number of integers, adds them up, and prints out the average. The user will enter either an integer to be averaged.

  Two for loops that will calculate the sum of all even number

Write a program using two for loops that will calculate the sum of all even numbers between 2 and 100,

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd