Purchase Solution

Dealing with Matrices in C++

Not what you're looking for?

Ask Custom Question

Write a C++ program that uses class Matrix for dealing with the square matrices (n x n tables of integers). The class constructor has to create a dynamic nxn matrix for n passed as a parameter. Supply the class with a copy constructor. Two overloaded operators + and * have to be implemented for adding and multiplying two matrices, respectively. The sum and product of two matrices A and B are square matrices with the entries defined as follows:
Cij = Aij + Bij, i=1,...,n, j=1,...,n
Cij = Ai1*B1j + Ai2*B2j + ... + Ain*Bnj

Where Aij is the matrix entry at the intersection of the i-th row and j-th column with rows numbered from top to bottom (and similarly for the matrices B and C).

The matrix elements have to be initialized by the method setMatrix() that reads the matrix elements from the standard input from a file by using the redirection of input. The file have to contain 2·n2 matrix elements (for two nxn matrices) separated by spaces corresponding to the row-by-row scan of each matrix. The program must figure out the matrix dimension n automatically (n must not be a part of input).

Purchase this Solution

Solution Summary

This solution provides a C++ program that uses a class matrix for dealing with the square matrices.

Purchase this Solution


Free BrainMass Quizzes
Excel Introductory Quiz

This quiz tests your knowledge of basics of MS-Excel.

Javscript Basics

Quiz on basics of javascript programming language.

Inserting and deleting in a linked list

This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.

Word 2010: Table of Contents

Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.

C# variables and classes

This quiz contains questions about C# classes and variables.