{"id":207,"date":"2017-09-13T11:13:36","date_gmt":"2017-09-13T14:13:36","guid":{"rendered":"http:\/\/www.professores.uff.br\/diomarcesarlobao\/?page_id=207"},"modified":"2017-09-13T11:13:36","modified_gmt":"2017-09-13T14:13:36","slug":"lin1-f","status":"publish","type":"page","link":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/lin1-f\/","title":{"rendered":"lin1.f"},"content":{"rendered":"<pre>      program linsolve\r\n      real      a(6,6),at(6,6),b(6),bt(6),bc(6)\r\n      integer ipiv(6)\r\nc\r\nc    Driver program to test linear equation solvers\r\nc    Sets up a 6x6 system of linear equations\r\nc    This is more specific than might be desired.  A better form\r\nc    would declare these arrays to be allocatable.\r\nc\r\nc\r\nc    a  -  the array (2-dimensional)of linear equation coefficients\r\nc          the first index gives equation number\r\nc          the second index gives the unknown number\r\nc\r\nc    at -  array to keep a copy of a\r\nc\r\nc    b  -  array (1-dimensional) containing the right hand sides\r\nc          of the linear equations\r\nc\r\nc    bt -  array to keep a copy of bt, in the end it contains the solutions\r\nc          to the equations.\r\nc\r\nc    bc -  an array that should match the original right hand side array\r\nc          generated by multiplying the solutions times the appropriate\r\nc          coefficients\r\nc\r\nc    ipiv- special \"pivoting\" array used to provide an improved solution\r\nc          in the Gauss Elimination\r\nc\r\nc\r\nc    Set up the A matrix and Right Hand Side Generation\r\nc\r\nc    We start by loading a desired solution in the bt array\r\nc    and creating a matrix \"a\" with random element values\r\nc\r\n      do 20 i=1,6\r\n         bt(i)=float(i)\r\n        do 20 j=1,6\r\nc         \ta(i,j)=float(i+j-(i*j)\/7*4+1)\r\n      \t   a(i,j)=rand()\r\n 20   continue\r\nc\r\nc     Generate the RHS\r\nc\r\n      do 30 i=1,6\r\n      \tb(i)=0.\r\n      \tdo 30 j=1,6\r\n 30   \t   b(i)=b(i)+a(i,j)*bt(j)\r\n      write(6,*) 'Right Hand Side of the linear equation Ax=b'\r\n      write(6,2000)(b(i),i=1,6)\r\n      write(6,*) ' Matrix A'\r\n      write(6,2000)((a(i,j),j=1,6),i=1,6)\r\n 2000 format(1x,6f10.4)\r\nc\r\nc     LINPACK or LAPACK ROUTINES overwrite the A matrix and b array\r\nc     If you need them again make a copy\r\nc\r\n      do 40 i=1,6\r\n      \tbt(i)=b(i)\r\n      \tdo 40 j=1,6\r\n   40\t   at(i,j)=a(i,j)\t\r\nc\r\nc    Insert calls to LINPACK or LAPACK routines here\r\nc\r\n      call sgefa(at,6,6,ipiv,info)\r\nc\r\nc     Check status by writing the info variable from the LU routine\r\nc\r\n      write(6,*) ' INFO = ',info\r\n      call sgesl(at,6,6,ipiv,bt,0)\r\nc\r\nc    Write out the solution   (this assumes you used bt in the last LINPACK\r\nc    call.\r\nc\r\n      write(6,*) ' Solution of the Linear System:'\r\n      write(6,2000) (bt(i),i=1,6)\r\nc\r\nc     Check Solution by Multipling Ax\r\nc\r\n      do 50 i=1,6\r\n         bc(i)=0.\r\n         do 50 j=1,6\r\n            bc(i)=bc(i)+a(i,j)*bt(j)\r\n   50 continue\r\n      write(6,*)' Ax = '\r\n      write(6,2000) (bc(i),i=1,6)\r\n      stop\r\n      end<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>program linsolve real a(6,6),at(6,6),b(6),bt(6),bc(6) integer ipiv(6) c c Driver program to test linear equation solvers c Sets up a 6&#215;6 system of linear equations c This is more specific than might be desired. A better form c would declare these arrays to be allocatable. c c c a &#8211; the array (2-dimensional)of linear equation coefficients [&hellip;]<\/p>\n","protected":false},"author":22,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[],"tags":[],"class_list":["post-207","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/207","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/users\/22"}],"replies":[{"embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/comments?post=207"}],"version-history":[{"count":1,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/207\/revisions"}],"predecessor-version":[{"id":208,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/207\/revisions\/208"}],"wp:attachment":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/media?parent=207"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/categories?post=207"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/tags?post=207"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}