Assignment 5
40 points
Due: November 23rd
Write a menu driven Fortan 95 program that provides five options for
the user:
- Compute square root of an entered number
- Matrix Multiplication (Matrix 1 x Matrix 2)
- Dot product of two vectors (Vector 1 x Vector 2)
- Circular shift of array elements (as the user how many to shift by)
- Transpose a matrix (rows -> cols) (ask the user which one to transpose)
For the purposes of this assignment, define two 10x10 matrices and two
20 element vectors and initialize them:
- Vector 1: 1, 2, ..., 20
- Vector 2: 3, 6, 9, ..., 60
- Matrix 1: 1+1+V2(1), 1+2+V2(2), ... 1+10+V2(10),
- 2+1+V2(1), 2+2+V2(2), ..., ..., 10+10+V2(10)
| 5 | 9 | 13 | 17 | 21 | 25 | 29 | 33 | 37 | 41 |
| 6 | 10 | 14 | 18 | 22 | 26 | 30 | 34 | 38 | 42 |
| 7 | 11 | 15 | 19 | 23 | 27 | 31 | 35 | 39 | 43 |
| 8 | 12 | 16 | 20 | 24 | 28 | 32 | 36 | 40 | 44 |
| 9 | 13 | 17 | 21 | 25 | 29 | 33 | 37 | 41 | 45 |
| 10 | 14 | 18 | 22 | 26 | 30 | 34 | 38 | 42 | 46 |
| 11 | 15 | 19 | 23 | 27 | 31 | 35 | 39 | 43 | 47 |
| 12 | 16 | 20 | 24 | 28 | 32 | 36 | 40 | 44 | 48 |
| 13 | 17 | 21 | 25 | 29 | 33 | 37 | 41 | 45 | 49 |
| 14 | 18 | 22 | 26 | 30 | 34 | 38 | 42 | 46 | 50 |
- Matrix 2: 1*1*V1(1), 1*2*V1(2), ... 1*10*V1(10),
- 2*1*V1(1), 2*2*V1(2), ..., ..., 10*10*V1(10)
| 1 | 4 | 9 | 16 | 25 | 36 | 49 | 64 | 81 | 100 |
| 2 | 8 | 18 | 32 | 50 | 72 | 98 | 128 | 162 | 200 |
| 3 | 12 | 27 | 48 | 75 | 108 | 147 | 192 | 243 | 300 |
| 4 | 16 | 36 | 64 | 100 | 144 | 196 | 256 | 324 | 400 |
| 5 | 20 | 45 | 80 | 125 | 180 | 245 | 320 | 405 | 500 |
| 6 | 24 | 54 | 96 | 150 | 216 | 294 | 384 | 486 | 600 |
| 7 | 28 | 63 | 112 | 175 | 252 | 343 | 448 | 567 | 700 |
| 8 | 32 | 72 | 128 | 200 | 288 | 392 | 512 | 648 | 800 |
| 9 | 36 | 81 | 144 | 225 | 324 | 441 | 576 | 729 | 900 |
| 10 | 40 | 90 | 160 | 250 | 360 | 490 | 640 | 810 | 1000 |
For option 1, use the iterative technique as shown on the fortran sample
For options 4 and 5, the user is to select the Matrix/Vector to operate on.
To hand in this assignment, issue the following commands:
- script
- cat as7.f
- gfortran as7.f
- ./a.out
- Select option 1 with 43
- Select option 1 with 21
- Select option 2
- Select option 3
- Select option 4 with Vector 1 and a shift of4
- Select option 5 with matrix 2
- exit
- lpr -PAT224 typescript