Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please use Networking for this problem. Problem: - private variable and member function: - Variables number of rows, number of columns, type_double pointer to pointer


Please use Networking for this problem.

Problem:

- private variable and member function:

- Variables number of rows, number of columns, type_double pointer to pointer m for the matrix (** m), you can use m[i_idx][j_idx]

- You can use int or uint_32_t (unsigned) for number of rows and columns

- Private member function:

- This function set up the Matrix and create dynamic array pointer in row and each row point array of columns

- Matrix(uint32_t rows, uint32_t cols) : rows(rows), cols(cols), m(new double*[rows]){

//Write your code here\

//loop each pointer rows[idx] and for each row create array of size columns\

}

- make the following functions

- Constructor that take #of rows and #of columns and initial value for all elements

- Copy constructor

- Assign operator = for copy constructor

- use swap(new_matrix, original_matrix)

- Deconstruct ~Matrix: loop inside each pointer and delete it

- Move constructor

- Overload () operator twice:

- first: return_type is double and member function is const

- second: return_type is reference double and member function is not const

- overload [] operator

- return_type double pointer

- Overload << operator to print out matrix similar to

- Read main.cpp comments for more details and how overload operatro are used in main()

main.cpp:

#include  using namespace std; // -------------- Design Matrix class here --------------- // ----------------------------------------------------------- // private variable and member function: // Variables number of rows, number of columns, type_double pointer to pointer m for the matrix (** m), you can use m[i_idx][j_idx] // You can use int or uint_32_t (unsigned) for number of rows and columns // Private member function, utility function: // This function set up the Matrix and create dynamic array pointer in row and each row point array of columns // Matrix(uint32_t rows, uint32_t cols) : rows(rows), cols(cols), m(new double*[rows]){ // Write the code here // loop each pointer rows[idx] and for each row create array of size columns // } // make the following functions // 1. Constructor that take #of rows and #of columns and initial value for all elements // Matrix G(2, 2, 0) ===> // index_0 index_1 // index_0 0 0 // index_1 0 0 // 2. Copy constructor // 3. Assign operator = for copy constructor // - use swap(new_matrix, original_matrix) // 4. Deconstruct ~Matrix: loop inside each pointer and delete it // 5. Move constructor // 6. Overload () operator twice: // - first: return_type is double and member function is const // - second: return_type is reference double and member function is not const // 7. overload [] operator // - return_type double pointer // 8. Overload << operator to print out matrix similar to: // 0 0 // 0 0 int main() { cout << "########" << endl; cout << "Main Problem" << endl; cout << "########" << endl; // Create matrix a with 4 rows and 3 columns filled with values in zero Matrix a(4, 3, 0.0); // print out the complete matrix cout << a << endl; // print out one element in the matrix // overload of () return const value cout << a(2,3) << endl; // change one element in a(2,2) equal 1.5 // overload of () assign reference to 1.5 a(2,2) = 1.5; // print out one element in the matrix cout << " " << a << endl; // change one element in a(2,1) using opesrator [] ==> a[2][1] equal 2.5 // Overload of [] a[2][1] = 2.5; a[2][2] = a[2][1]; cout << " " << a << endl; // Create b matrix and add it to a and save result inn matrix c Matrix b(4, 3, 1.0); Matrix c = a + b; cout << " " << c << ' '; cout << " "; cout << "====[ end ]====" << endl; cout << " " << endl; return 0; }

Step by Step Solution

3.58 Rating (155 Votes )

There are 3 Steps involved in it

Step: 1

include iostream include cstdint include stdexcept class Matrix private uint32t rows uint32t cols do... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Operating System questions

Question

2. In which brain areas do new neurons form in adultspg109

Answered: 1 week ago

Question

1. Which develops first, a neurons axon or its dendritespg109

Answered: 1 week ago