Complete the C++ code below #include "std_lib_facilities.h" /*1. Define a function which calculates the outer product of two vectors. The function return is a matrix. */ vector> outerProduct(vector& A, vector& B) { //implement here } /*2. Define a function which transposes a matrix. */ vector> transpose(vector>& A) { //implementation } /*3. Define a function which calculates the multiplication of a matrix and it's transpose. */ vector> product(vector>& A) { // implementation } /*4. Define a print out function that will print out a matrix in the following format: Example: a 3 by 4 matrix should have the print out: 1 2 3 4 2 3 4 5 3 4 5 6 */ void printMatrix(vector>& A) { // implementation } int main() { // Define both vector A and vector B vector A = {1 ,2, 3, 4, 5}; vector B = {1, 2, 3}; /*Test outerProduct function, the expected output is: 1 2 3 2 4 6 3 6 9 4 8 12 5 10 15 */ vector> M = outerProduct(A, B); printMatrix(M); /*Test transpose function, the expected output is: 1 2 3 4 5 2 4 6 8 10 3 6 9 12 15 */ vector> tM = transpose(M); printMatrix(tM); /*Test product function, the expected output is: 14 28 42 56 70 28 56 84 112 140 42 84 126 168 210 56 112 168 224 280 70 140 210 280 350 */ vector> pM = product(M); printMatrix(pM); keep_window_open(); return 0; }

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Complete the C++ code below

#include "std_lib_facilities.h"

/*1. Define a function which calculates the outer product of two vectors. The function return is a matrix. */
vector<vector<int>> outerProduct(vector<int>& A, vector<int>& B)
{
//implement here
}

/*2. Define a function which transposes a matrix. */
vector<vector<int>> transpose(vector<vector<int>>& A)
{
//implementation
}

/*3. Define a function which calculates the multiplication of a matrix and it's transpose. */

vector<vector<int>> product(vector<vector<int>>& A)
{
// implementation
}

/*4. Define a print out function that will print out a matrix in the following format:
Example: a 3 by 4 matrix should have the print out:
1 2 3 4
2 3 4 5
3 4 5 6
*/
void printMatrix(vector<vector<int>>& A)
{
// implementation
}



int main()
{
// Define both vector A and vector B
vector<int> A = {1 ,2, 3, 4, 5};
vector<int> B = {1, 2, 3};

/*Test outerProduct function, the expected output is:
1 2 3
2 4 6
3 6 9
4 8 12
5 10 15
*/
vector<vector<int>> M = outerProduct(A, B);
printMatrix(M);

/*Test transpose function, the expected output is:
1 2 3 4 5
2 4 6 8 10
3 6 9 12 15
*/
vector<vector<int>> tM = transpose(M);
printMatrix(tM);

/*Test product function, the expected output is:
14 28 42 56 70
28 56 84 112 140
42 84 126 168 210
56 112 168 224 280
70 140 210 280 350
*/
vector<vector<int>> pM = product(M);
printMatrix(pM);

keep_window_open();
return 0;
}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY