Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab07 functions.h here, 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

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

Lab07 functions.h here, 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
Command Line Process Management (&, bg/fg) So far, we've been teaching you how to run programs at the command line. Running the program and waiting for it to finish works okay for short/fast programs, but if you have a program that takes minutes or hours to finish, you don't want to have to wait that long to do other things at the terminal. Instead, there is a way to run the program in the background, so that it is running but not blocking your access to the terminal Executing a Background Job Let us say we have a long-running program called a.out. Normally you would run the program like so ./a.out But if you did that your terminal would be blocked until it finished. No commands can be executed until it is done. If instead you add a ampersand (&) after the command, the execution is run in the background ./a.out& The job, a.out, will now run but the terminal is freed for your commands What jobs do I have? You can run the command jobs to see the status of your suspended (and running) jobs It reports it in the following way (I have a job called top running in background) jobs 1+ Stopped top The [1] is your local job number. We will use that in a minute Suspending a Running Job and Running in the Background Lets say you already were running a.out in the foreground (without the ampersand). You already know about CTRL-C to kill a running program. Here's a new one, CRTL-Z CNTRL-Z doesn't kill a program, but instead suspends it (pauses it), giving you back control of your terminal. Whatever was running is now stopped, but can be restarted. After suspending a job, you can have the suspended job run in background using the command bg Command Line Process Management (&, bg/fg) So far, we've been teaching you how to run programs at the command line. Running the program and waiting for it to finish works okay for short/fast programs, but if you have a program that takes minutes or hours to finish, you don't want to have to wait that long to do other things at the terminal. Instead, there is a way to run the program in the background, so that it is running but not blocking your access to the terminal Executing a Background Job Let us say we have a long-running program called a.out. Normally you would run the program like so ./a.out But if you did that your terminal would be blocked until it finished. No commands can be executed until it is done. If instead you add a ampersand (&) after the command, the execution is run in the background ./a.out& The job, a.out, will now run but the terminal is freed for your commands What jobs do I have? You can run the command jobs to see the status of your suspended (and running) jobs It reports it in the following way (I have a job called top running in background) jobs 1+ Stopped top The [1] is your local job number. We will use that in a minute Suspending a Running Job and Running in the Background Lets say you already were running a.out in the foreground (without the ampersand). You already know about CTRL-C to kill a running program. Here's a new one, CRTL-Z CNTRL-Z doesn't kill a program, but instead suspends it (pauses it), giving you back control of your terminal. Whatever was running is now stopped, but can be restarted. After suspending a job, you can have the suspended job run in background using the command bg

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

Records And Database Management

Authors: Jeffrey R Stewart Ed D, Judith S Greene, Judith A Hickey

4th Edition

0070614741, 9780070614741

More Books

Students also viewed these Databases questions

Question

What are Electrophoresis?

Answered: 1 week ago