Answered step by step
Verified Expert Solution
Question
1 Approved Answer
A matrix is rectangular array of items laid out in rows and columns. The dimensions, or size, of a matrix can be expressed as m
A matrix is rectangular array of items laid out in rows and columns. The dimensions, or size, of a matrix can be expressed as m x n or m-by-n, where m is the number of rows in the matrix and n is the number of columns in the matrix For example, consider A, which is the following 2 x 4 matrix The individual elements in A can be expressed as a where i (the row) is a number from 1 to m and j (the column) is a number from 1 to n. For example, the value at element a1 3 is 2 Write a program (called matrix.cpp) that does that following 1. Implement a class called Matrix that Contains private member fields for the number rows and columns of the matrix Contains a public member field to contain the matrix elements o This should be a 2D array of integers that is implemented dynamically Contains five public functions add function, that adds two same sized matrices together and returns a new matrix with the result subtract function, that subtracts two same sized matrices together and returns a new matrix with the result multiply function, that performs proper matrix multiplication and returns a new matrix with the result scalar function, that performs scalar multiplication with an integer value and a matrix, and returns a new matrix with the result print function, that outputs the contents of the matrix in tabular form that matches the dimensions of the matrix o o o o o Contains a non-default constructor o Constructor that accepts size information, and dynamically creates the matrix Contains a destructor That properly handles discarding the dynamically created 2D array (using delete and setting the member field to null o 2. Prompts the user for . The dimensions of a first matrix . The contents of the first matrix, which is then filled into the newly created matrix object instance . The dimensions of a second matrix . The contents of the second matrix, which is used to fill the newly created matrix instance Sample prompts with appropriate user responses A matrix is rectangular array of items laid out in rows and columns. The dimensions, or size, of a matrix can be expressed as m x n or m-by-n, where m is the number of rows in the matrix and n is the number of columns in the matrix For example, consider A, which is the following 2 x 4 matrix The individual elements in A can be expressed as a where i (the row) is a number from 1 to m and j (the column) is a number from 1 to n. For example, the value at element a1 3 is 2 Write a program (called matrix.cpp) that does that following 1. Implement a class called Matrix that Contains private member fields for the number rows and columns of the matrix Contains a public member field to contain the matrix elements o This should be a 2D array of integers that is implemented dynamically Contains five public functions add function, that adds two same sized matrices together and returns a new matrix with the result subtract function, that subtracts two same sized matrices together and returns a new matrix with the result multiply function, that performs proper matrix multiplication and returns a new matrix with the result scalar function, that performs scalar multiplication with an integer value and a matrix, and returns a new matrix with the result print function, that outputs the contents of the matrix in tabular form that matches the dimensions of the matrix o o o o o Contains a non-default constructor o Constructor that accepts size information, and dynamically creates the matrix Contains a destructor That properly handles discarding the dynamically created 2D array (using delete and setting the member field to null o 2. Prompts the user for . The dimensions of a first matrix . The contents of the first matrix, which is then filled into the newly created matrix object instance . The dimensions of a second matrix . The contents of the second matrix, which is used to fill the newly created matrix instance Sample prompts with appropriate user responses
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started