I only need the "functions" NOT the header file nor the main
implementation file JUST the implementations for the
functions
Please help, if its difficult to do the complete program I would
appreciate if you could do as much functions as you can especially
for the derived class.
I am a beginer so I am only using classes and pointers while
implementing everything using simple c++ commands
thank you in advanced
Question: Implement C++ Code to do multiple matrix operation (like us addition, subtraction, multiplication)
Answer:
(a) Implement two C++ class to do addition of two multi-dimensional Matrix
-- Need to introduce a 'source file' cpp file to do these operations.
Below is the sample simple C++ cpp code
create file 'add_two_matrix.cpp' and write the below code
$vim add_two_matrix.cpp
/*-- START OF CODE --*/
#include<iostream.h> //include needed header files
//declare 2nd matrix class
class matrix_2;
//define 1st matrix class
class matrix_1
{
//define member variables
//define two dimensional matrix with size of 10*10
int a[10][10];
//define m.n as the range - until which matrix to be loaded
int m,n;
//define member functions
public:
//define member function to get values from user
void getValuesForMatrix1();
//define memeber function to load selected values from user
void putValuesIntoMatrix1();
//friend function to do matrix add,matrix substract,matrix multiply
friend void add_matrix(matrix_1,matrix_2);
friend void substract_matrix(matrix_1,matrix_2);
friend void multiply_matrix(matrix_1,matrix_2);
};
void matrix_1::getValuesForMatrix1()
{
int i,j;
cout<<"Matrix 1 :\n"
cout<<"Enter Rows and Columns: ";
cin>>m>>n;
cout<<"Enter the Matrix_1 Elements :\n";
for(i=0:i<m;i++)
for(j=0;j<n;j++)
cin>>a[i][j];
}
void matrix_1::putValuesIntoMatrix1()
{
int i,j;
cout<<"Matrix 1 :\n"
for(i=0:i<m;i++)
{
for(j=0;j<n;j++)
{
cout<<a[i][j]<<" ";
}
cout<<endl;
}
//define 2nd matrix class
class matrix_2
{
//define member variables
//define two dimensional matrix with size of 10*10
int b[10][10];
//define m.n as the range - until which matrix to be loaded
int m,n;
//define member functions
public:
//define member function to get values from user
void getValuesForMatrix2();
//define memeber function to load selected values from user
void putValuesIntoMatrix2();
//friend function to do matrix add,matrix substract,matrix multiply
friend void add_matrix(matrix_1,matrix_2);
friend void substract_matrix(matrix_1,matrix_2);
friend void multiply_matrix(matrix_1,matrix_2);
};
void matrix_2::getValuesForMatrix2()
{
int i,j;
cout<<"Matrix 2 :\n"
cout<<"Enter Rows and Columns: ";
cin>>m>>n;
cout<<"Enter the Matrix_1 Elements :\n";
for(i=0:i<m;i++)
for(j=0;j<n;j++)
cin>>b[i][j];
}
void matrix_2::putValuesIntoMatrix2()
{
int i,j;
cout<<"Matrix 2 :\n"
for(i=0:i<m;i++)
{
for(j=0;j<n;j++)
{
cout<<b[i][j]<<" ";
}
cout<<endl;
}
void add_matrix(matrix_1 m1,matrix_2 m2)
{
int i,j;
if((m1.m == m2.m) && (m1.n == m2.n))
{
cout<<"SUM OF TWO MATRIX"<<endl;
for(i=0;i<m1.m;i++)
{
for(j=0;j<m1.n;j++)
{
cout<<m1.a[i][j] + m2.b[i][j]<<" ";
}
cout<<endl;
}
}
else
{
cout<<"Matrix Rows and Column Dimensions are wrong Cant do Sum of two matrixes"<<endl;
}
}
void substract_matrix(matrix_1 m1,matrix_2 m2)
{
int i,j;
if((m1.m == m2.m) && (m1.n == m2.n))
{
cout<<"SUBSTRACT OF TWO MATRIX"<<endl;
for(i=0;i<m1.m;i++)
{
for(j=0;j<m1.n;j++)
{
cout<<m1.a[i][j] - m2.b[i][j]<<" ";
}
cout<<endl;
}
}
else
{
cout<<"Matrix Rows and Column Dimensions are wrong Cant do Substract of two matrixes"<<endl;
}
}
void mulltiply_matrix(matrix_1 m1,matrix_2 m2)
{
int i,j;
if((m1.m == m2.m) && (m1.n == m2.n))
{
cout<<"MULTIPLY OF TWO MATRIX"<<endl;
for(i=0;i<m1.m;i++)
{
for(j=0;j<m1.n;j++)
{
cout<<m1.a[i][j] * m2.b[i][j]<<" ";
}
cout<<endl;
}
}
else
{
cout<<"Matrix Rows and Column Dimensions are wrong Cant do Multiply of two matrixes"<<endl;
}
}
//Implement main function to call all the implemented fucntions
int main()
{
//declare matrix_1 matrix_2 objects
matrix_1 obj1;
matrix_2 obj2;
//call all functions for matrix objects
obj1.getValuesForMatrix1();
obj1.putValuesIntoMatrix1();
obj2.getValuesForMatrix2();
obj2.putValuesIntoMatrix2();
//do matrix operations
add_matrix(obj1,obj2);
substract_matrix(obj1,obj2);
multiply_matrix(obj1,obj2);
}
/*-- END OF CODE --*/
-- run the code in g++/gcc compiler operating systems
-- Execute the code with different matrix vaues and check the output for all matrix operations.
I only need the "functions" NOT the header file nor the main implementation file JUST the impleme...
I need help modifying this program. How would I make sure that the methods is being called and checked in my main method? Here is what the program needs to run as: GDVEGTA GVCEKST The LCS has length 4 The LCS is GVET This is the error that I'm getting: The LCS has length 4 // I got this right The LCS is //the backtrace is not being called for some reason c++ code: the cpp class: /** * calculate...
Please do it carefully Using the header file ( MyArray.h ) Type the implementation file MyArray.cpp, and a test file to test the functionality of the class. Hint: read all the explanations in the header with attention. MyArray.h : #ifndef MYARRAY_H #define MYARRAY_H #include <iostream> using namespace std; class MyArray { friend ostream& operator<<( ostream & output, const MyArray & rhs); // to output the values of the array friend istream& operator>>( istream & input, MyArray & rhs); // to...
C++ assignment help! The instructions are below, i included the main driver, i just need help with calling the functions in the main function This assignment will access your skills using C++ strings and dynamic arrays. After completing this assignment you will be able to do the following: (1) allocate memory dynamically, (2) implement a default constructor, (3) insert and remove an item from an unsorted dynamic array of strings, (4) use the string class member functions, (5) implement a...
Please help me out with this assignment. Please read the requirements carefully. And in the main function please cout the matrix done by different operations! Thanks a lot! For this homework exercise you will be exploring the implementation of matrix multiplication using C++ There are third party libraries that provide matrix multiplication, but for this homework you will be implementing your own class object and overloading some C+ operators to achieve matrix multiplication. 1. 10pts] Create a custom class called...
C++ there is an issue with my if/else statements, I have tried several different ways to make it match the instructions but each time i get different errors. Need help geting this to match the instructions peoperly. *******************instructions***************************** Function: nextGeneration This function has no parameters. This function returns an int. The purpose of this function is to modify the grid to represent the next generation. Here's how you are supposed to do that for this assignment: Set each element of...
Using java : In this exercise, you need to implement a class that encapsulate a Grid. A grid is a useful concept in creating board-game applications. Later we will use this class to create a board game. A grid is a two-dimensional matrix (see example below) with the same number of rows and columns. You can create a grid of size 8, for example, it’s an 8x8 grid. There are 64 cells in this grid. A cell in the grid...
C++ must use header files and implementation files as separate files. I’ll need a header file, implementation file and the main program file at a minimum. Compress these files into one compressed file. Make sure you have adequate documentation. We like to manipulate some matrix operations. Design and implement a class named matrixMagic that can store a matrix of any size. 1. Overload the addition, subtraction, and multiplication operations. 2. Overload the extraction (>>) and insertion (<<) operators to read...
#ifndef __MATRIX__ #define __MATRIX__ #include "complex.h" namespace gtmath { class matrix { public: matrix(int , int ); //TODO: Add implementation here //TODO: Implement parenthesis operator complex& operator()(int, int) { return m_vals[rows][cols]; } friend std::ostream& operator<<(std::ostream& os, gtmath::matrix& m); int get_num_cols(); int get_num_rows(); private: complex** m_vals; int rows; int cols; }; } #include "matrix.h" #include <limits> namespace gtmath { //constructor & inlitilize dynamic array matrix::matrix(int rows, int cols) { this->cols = cols; this->rows = rows;...
In this assignment, you are asked to: 1. create a Matrix class that stores and operate on a dynamic two-dimensional array. The class has the following structure: Private member variables: - int ** mat; - int rows; - int cols; Public member functions: +Default constructor: sets both rows and cols to 3 and creates 3x3 matrix dynamically +Parameterized constructor: sets the rows and cols to the values passed to the constructor and create a matrix with the given dimensions. +Destructor:...
STRICT DOWNVOTE IF NOT DONE FULLY, WILL REPORT ALSO IF COPY PASTED OR MODIFIED ANSWER Develop a class, using templates, to provide functionality for a set of recursive functions. The functions specified as recursive must be written recursively (not iterativly). The UML class specifications are provided below. A main will be provided. Additionally, a make file will need to be developed and submitted. ● Recursion Set Class The recursion set template class will implement the template functions. recursionSet -length: int...