This program should emphasize the use of 2D vectors.
Recalling the simplistic group activity where a composite erosion factor was used against an entire area, you decide to enhance it a bit to be a little more realistic.
To be more accurate, you'll have to have a less often used, but still-extant matrix multiplication form known as element-wise multiplication. This is similar to matrix addition and subtraction in design. Here is an example:
-- -- -- -- -- -- | 4 3 1 | | 2 4 8 | | 8 12 8 | | 2 2 7 | | 1 5 2 | | 2 10 14 | | 1 2 1 | * | 3 5 2 | = | 3 10 2 | | 3 6 3 | | 1 2 3 | | 3 12 9 | | 4 5 2 | | 4 1 4 | | 16 5 8 | -- -- -- -- -- --
Use functions to make your task easier: 2D matrix entry, 2D element-wise matrix multiply, 2D matrix display, etc.
Place any matrix functions you develop into a matrix library.
As an example the program interaction might look something like (the parts in blue are typed by the user):
$ erosion.out Welcome to the Erosion Program!!! Please enter the size of your area: 40x50 I'm sorry, that area is too deep for this program...please reduce the depth... Please enter the size of your area: 4x500 I'm sorry, that area is too broad for this program...please reduce the width... Please enter the size of your area: 4x5 Thank you, now enter the heights within your area (row by row): 10 20 40 20 10 10 10 30 10 30 20 20 40 20 10 20 10 20 10 10 Please enter your erosion factors (row by row): 1.1 1.3 0.7 0.6 0.5 1.0 1.2 0.7 1.1 0.6 1.0 1.3 0.7 0.7 0.6 0.8 1.0 0.8 0.7 0.7 Thank you...applying erosion factors to your area... Your area after erosion: 11 26 28 12 5 10 12 21 11 18 20 26 28 14 6 16 10 16 7 7 Would you like to erode again? no Thank you for using the MMP!! Endeavor to have a compactive day! $
This assignment is (Level 3.5).
Add (Level 2) to combine this matrix library with your one from the matrix multiplication lab. (Thought-provoker: Would your element-wise multiplication routine overload your standard matrix multiplication function?)
Add (Level 1) to give the user the option of choosing between a pre-counted entry (as above) or an end-detected entry. (Hint: You can detect the end of a row by looking for the '\n' after the last row value. This need only be done for the first row. You can detect the end of the matrix by a blank row being entered -- one with no numbers -- immediately ending in a '\n'.) (Thought-provoker: Does the erosion matrix need such end-detected entry? Why/Why not?)
Add (Level 1) to make the preceeding option automatic instead of by user choice. In other words, you detect from their input whether they are entering the size first or using end-detected entry. (Hint: The size has an 'x' between the values where-as two matrix elements have only space.) (Warning: if their detected row is only one element long, there will be a '\n' instead of an 'x' and it will need to not only discover the entry method but set the row length.)