Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

There is lab07_functions.h Using C++,thanks. #ifndef MATRIX_TYPE #define MATRIX_TYPE #include using std::string; #include using std::vector; /* very convenient. If you want to change the type

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

There is lab07_functions.h Using C++,thanks.
#ifndef MATRIX_TYPE #define MATRIX_TYPE #include using std::string; #include using std::vector; /* very convenient. If you want to change the type stored in the matrix, you only have to change the single template type in matrix_row */ using matrix_row = vector; using matrix = vector; /* nicely print a matrix. Should have row/column alignment converts it to a string (doesn't print to cout!!!) uses width to space elements (setw). Default is 3 */ string matrix_to_str(const matrix &m1, size_t width=3); /* true if the two matrices have the same shape false otherwise */ bool same_size(matrix &m1, matrix &m2); /* matrices must not be empty and must be the same shape: - if true, return a new matrix that adds m1+m2 - if false, return an empty matrix (no elements) */ matrix add(matrix &m1, matrix &m2); /* matrix must not be empty: - if true, multiply T scalar value by m - if false, return empty matrix (no elements) */ matrix scalar_multiply(matrix &m, long val); #endif
The Problem We are going to work on 2D vectors 2D vector as a matrix You remember matrices, don't you? We are going to do some simple manipulation ofa matrix, namely: adding two matrices and multiplying a matrix by a scalar. You watched the 2D vector video, right? RIGHT??? Matrix A matrix is a 2-dimensional (rows and columns) data structure. It has a shape indicated by the number of rows and the number of columns. Though I suppose a matrix could have uneven sized rows, this doesn't usually happen in practice so a matrix is always rectangular, potentially square (based on its shape)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Transact SQL Cookbook Help For Database Programmers

Authors: Ales Spetic, Jonathan Gennick

1st Edition

1565927567, 978-1565927568

More Books

Students also viewed these Databases questions

Question

What are the three major ways of disposing of a plant asset?

Answered: 1 week ago

Question

What is conservative approach ?

Answered: 1 week ago

Question

Are these written ground rules?

Answered: 1 week ago

Question

Have ground rules been established for the team?

Answered: 1 week ago