Answered step by step
Verified Expert Solution
Question
1 Approved Answer
A 1 Using the header file Matrix.h and testMatrix.cpp ( given in the assignment fo Type the implementation file Matrix.cpp . Hint: the use of
A Using the header file Matrix.h and testMatrix.cpp given in the assignment fo
Type the implementation file Matrix.cpp
Hint: the use of the float data pointer for a matrix object can be understood with the help of the following empty
constructor function
Matrix.h #include
#include
using namespace std;
#ifndef MATRIXH
#define MATRIXH
class Matrix
friend ostream& operatorostream& out, const Matrix& srcMatrix;
public:
Matrix;
initialize Matrix class object with rowN colN and zero value
Matrixconst int rNconst int cN ;
initialize Matrix class object with row number rN col number cN and zero values
Matrixconst Matrix &srcMatrix ;
initialize Matrix class object with another Matrix class object
Matrixconst int rN const int cN const float srcPtr;
initialize Matrix class object with row number rN col number cN and a pointer to an
const float getDataconst;
create a temp pointer and copy the array values which data pointer points,
then returns temp.
int getRowNconst; returns rowN
int getColNconst; returns colN
void printconst; prints the Matrix object in rowNxcolN form
Matrix transpose; takes the transpose of the matrix
Matrix operatorconst Matrix &rhsMatrixconst;
operator which allows mm and returns a temp Matrix object
Matrix operatorconst Matrix &rhsMatrixconst;
operator which allows mm and returns a temp Matrix object
Matrix operatorconst Matrix &rhsMatrixconst;
operator which allows product of mm
elementwise and returns a temp Matrix object
float operatorconst int rconst int cconst;
operator which allows returning mrc
m is on the first row, first col
Matrix& operatorconst Matrix &rhsMatrix;
operator which allows mm and returns this pointer of m
Matrix& operatorconst Matrix &rhsMatrix;
operator which allows mm and returns this pointer of m
Matrix& operatorconst Matrix &rhsMatrix;
operator which allows mm and returns this pointer of m
Matrix& operatorconst Matrix &rhsMatrix;
operator which allows mmelementwise and returns this pointer of m
int operatorconst Matrix &rhsMatrixconst;
operator which returns if mm
int operator!const Matrix &rhsMatrixconst;
operator which returns if mm
private:
operator which allows returning mrc
m is on the first row,first col
int rowN, colN;
float data;
eg: if pointer data points an array of and the rowN and coln
matrix is actually
;
#endif
testMatrix.cpp #include "Matrix.h
#include
#include
using namespace std;
int main
float arr;
float arr;
Matrix m;
Matrix mm;
Matrix marr;
Matrix marr;
coutm
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