1 / 14

a =

a =. 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. 2 4 1 5. program mat_cal

jpartee
Télécharger la présentation

a =

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. a = 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. 2 4 1 5

  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(2i3,a))",a(i,1:2)," ",b(i,1:2)," ",n(i,1:2)," " end do endprogram mat_cal

  3. 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). -1 2 2 4 3 1 1 1 1 1 1 1 1 1 1 1 1 1 a= e=transpose(a) c=matmul(e,b) d=a+c b=

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

  5. program mat2 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 end do print*," " do i=1,3 print "(4(3i3,a))",a(i,1:3)," ",b(i,1:3)," ",c(i,1:3)," ",d(i,1:3) end do end program mat2

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

  7. program mat3 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 end do do i=1,5 print"(3(5i4))",a(i,1:5) end do endprogram mat3

  8. program home10 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 end do

  9. C=A+B D=5*A-3*B print*," Matrix A"," ","Matrix B" do i=1,5 print"(2(5i4,a))",A(i,1:5)," ",B(i,1:5) end do print*," " print*," Matrix C"," ","Matrix D" do i=1,5 print"(2(5i4,a))",C(i,1:5)," ",D(i,1:5) end do end program home10

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

  11. 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 "(i6,12i4)",i,x(1:12) end do end program multi_square

  12. program mat2 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 end do print*," " do i=1,3 print "(4(3i3,a))",a(i,1:3)," ",b(i,1:3)," ",c(i,1:3)," ",d(i,1:3) end do end program mat2

More Related