Design a class to perform various matrix operations. A matrix is a set of numbers arranged in rows and columns. Therefore, every element of a matrix has a row position and a column position. If A is a matrix of five rows and six columns, we say that the matrix A is of the size 5 X 6. Clearly, a convenient place to store a matrix is in a two-dimensional array. Two matrices can be added and subtracted if they have the same size. Suppose A = [a¡] and B = [b¡] and are two matrices of the same size m*n in which aj denotes the element of A in the i th row and the j th column, and so on. The sum and difference ofA and B are given by: A +B = [aj + bij] A -B = [aj - bij]

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Programming Language: C++

 

Performing Matrix Operations
Instructions
Design a class to perform various matrix operations. A matrix is a set of numbers arranged in rows
and columns. Therefore, every element of a matrix has a row position and a column position. If A is
a matrix of five rows and six columns, we say that the matrix A is of the size 5 X 6. Clearly, a
convenient place to store a matrix is in a two-dimensional array. Two matrices can be added and
subtracted if they have the same size. Suppose A = [aj] and B = [b] and are two matrices of the
same size m *n in which aj denotes the element of A in the i th row and the jth column, and so on.
The sum and difference of A and B are given by:
A + B = [aj + bij]
A -B = [aj - bj]
The multiplication of A and B (A * B) is defined only if the number of columns of A is the same as
the number of rows of B. If A is of the size m n and B is of the size n t, then A B = [c ik ] is of the size
mt and the element cik is given by the formula:
Cik = ajbik + ajzb2k + ... + ainbnk
Design and implement a class matrixType that can store a matrix of any size. Overload the
operators +, - , and * to perform the addition, subtraction, and multiplication operations,
respectively, and overload the operator << to output a matrix. Also, write a test program to test
various operations on the matrices.
Transcribed Image Text:Performing Matrix Operations Instructions Design a class to perform various matrix operations. A matrix is a set of numbers arranged in rows and columns. Therefore, every element of a matrix has a row position and a column position. If A is a matrix of five rows and six columns, we say that the matrix A is of the size 5 X 6. Clearly, a convenient place to store a matrix is in a two-dimensional array. Two matrices can be added and subtracted if they have the same size. Suppose A = [aj] and B = [b] and are two matrices of the same size m *n in which aj denotes the element of A in the i th row and the jth column, and so on. The sum and difference of A and B are given by: A + B = [aj + bij] A -B = [aj - bj] The multiplication of A and B (A * B) is defined only if the number of columns of A is the same as the number of rows of B. If A is of the size m n and B is of the size n t, then A B = [c ik ] is of the size mt and the element cik is given by the formula: Cik = ajbik + ajzb2k + ... + ainbnk Design and implement a class matrixType that can store a matrix of any size. Overload the operators +, - , and * to perform the addition, subtraction, and multiplication operations, respectively, and overload the operator << to output a matrix. Also, write a test program to test various operations on the matrices.
Test Case
Incomplete
Input / output test 1
Input
1 2 3 4
1 2 3 4
1 2 3 4
5 6 7 8
5 6 7 8
5 6 7 8
8 9
8 9
8 9
8 9
Expected Output O
80 80 | 80 90 | 90 | 90
Transcribed Image Text:Test Case Incomplete Input / output test 1 Input 1 2 3 4 1 2 3 4 1 2 3 4 5 6 7 8 5 6 7 8 5 6 7 8 8 9 8 9 8 9 8 9 Expected Output O 80 80 | 80 90 | 90 | 90
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 7 images

Blurred answer
Knowledge Booster
Introduction to computer system
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education