Matrix a is given as follows Write a

  • Slides: 14
Download presentation
Matrix a is given as follows. Write a program calculate Matrix b as transpose

Matrix a is given as follows. Write a program calculate Matrix b as transpose of matrix a and matrix n as multiplication of matrices a and b. a= 2 4 1 5

program mat_cal integer, dimension(2, 2): : a, b, n integer: : i a(1, 1)=2

program mat_cal integer, dimension(2, 2): : a, b, n integer: : i a(1, 1)=2 a(1, 2)=4 a(2, 1)=1 a(2, 2)=5 b=transpose (a) n=matmul(a, b) print*, "Martix_a=", a, "Matrix_b=", b, "Matrix_n=", n do i=1, 2 print "(3(2 i 3, a))", a(i, 1: 2), " end do endprogram mat_cal ", b(i, 1: 2), " ", n(i, 1: 2), " "

Matrix a and b are given as follows. Write a program calculate and print

Matrix a and b are given as follows. Write a program calculate and print Matrix a, b, c and d. (Write same program using reshape function also). a= -1 2 2 4 3 1 1 b= 1 1 1 1 1 e=transpose(a) c=matmul(e, b) d=a+c

program mat 1 a(3, 3)=1 integer, dimension(3, 3): : a, b, c, d, e

program mat 1 a(3, 3)=1 integer, dimension(3, 3): : a, b, c, d, e do i=1, 3 integer: : i, j do j=1, 3 a(1, 1)=-1 b(i, j)=1 a(1, 2)=2 e=transpose(a) a(1, 3)=2 c=matmul(e, b) a(2, 1)=4 print*, " " d=a+c a(2, 2)=3 do i=1, 3 end do a(2, 3)=1 print "(4(3 i 3, a))", a(i, 1: 3), " a(1, 3)=2 end do a(3, 1)=1 a(3, 2)=1 end do ", b(i, 1: 3), " ", c(i, 1: 3), " ", d(i, 1: 3) print*, "a=", a, " b=", b, " c=", c, " d=", d end program mat 1

program mat 2 integer, dimension(3, 3): : a, b, c, d, e integer: :

program mat 2 integer, dimension(3, 3): : a, b, c, d, e integer: : i, j a=reshape((/-1, 4, 1, 2, 3, 1, 2, 1, 1/), (/3, 3/)) do i=1, 3 do j=1, 3 b(i, j)=1 e=transpose(a) c=matmul(e, b) d=a+c end do print*, " " do i=1, 3 print "(4(3 i 3, a))", a(i, 1: 3), " ", b(i, 1: 3), " ", c(i, 1: 3), " ", d(i, 1: 3) end do end program mat 2

Write down a program that calculates and print the elements of given matrix using

Write down a program that calculates and print the elements of given matrix using do loop.

program mat 3 integer, dimension(5, 5): : a integer: : i, j do i=1,

program mat 3 integer, dimension(5, 5): : a integer: : i, j do i=1, 5 do j=1, 5 if (i==j) then a(i, j)=i**2 else a(i, j)=(i+j)-1 end if end do do i=1, 5 print"(3(5 i 4))", a(i, 1: 5) end do end program mat 3

program home 10 integer, dimension(5, 5): : A, B, C, D integer: : i,

program home 10 integer, dimension(5, 5): : A, B, C, D integer: : i, j A=reshape((/1, 2, 3, 4, 5, 2, 4, 4, 5, 6, 3, 4, 9, 6, 7, 4, 5, 6, 16, 8, 5, 6, 7, 8, 25/), (/5, 5/)) do i=1, 5 do j=1, 5 if (i==j)then B(i, j)=7 else B(i, j)=0 end if end do

C=A+B D=5*A-3*B print*, " Matrix A", "Matrix B" do i=1, 5 print"(2(5 i 4,

C=A+B D=5*A-3*B print*, " Matrix A", "Matrix B" do i=1, 5 print"(2(5 i 4, a))", A(i, 1: 5), " ", B(i, 1: 5) end do print*, " " print*, " Matrix C", "Matrix D" do i=1, 5 print"(2(5 i 4, a))", C(i, 1: 5), " ", D(i, 1: 5) end do end program home 10

Write down a program that writes the results of the multiplication table as following.

Write down a program that writes the results of the multiplication table as following.

program multi_square !------------------------------!This program shows the multipication square. !------------------------------!variable declerations integer: : i, j

program multi_square !------------------------------!This program shows the multipication square. !------------------------------!variable declerations integer: : i, j integer, dimension(12): : x print*, " 1 2 3 4 5 6 7 8 9 10 11 12" print*, " x" !make the calculations do i=1, 12 do j=1, 12 x(j)=i*j end do !print the outputs print "(i 6, 12 i 4)", i, x(1: 12) end do end program multi_square

program mat 2 integer, dimension(3, 3): : a, b, c, d, e integer: :

program mat 2 integer, dimension(3, 3): : a, b, c, d, e integer: : i, j a=reshape((/-1, 4, 1, 2, 3, 1, 2, 1, 1/), (/3, 3/)) do i=1, 3 do j=1, 3 b(i, j)=1 e=transpose(a) c=matmul(e, b) d=a+c end do print*, " " do i=1, 3 print "(4(3 i 3, a))", a(i, 1: 3), " ", b(i, 1: 3), " ", c(i, 1: 3), " ", d(i, 1: 3) end do end program mat 2