<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>To compile the fortran you need to use the following on cobra</p>
    <p>gfortran ztest.f -llapack -lblas<br>
      <br>
    </p>
    <div class="moz-cite-prefix">On 11/14/23 10:14, Andrew J. Pounds
      wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:add3d96f-38d9-389f-59e7-3ee39081b16e@mercer.edu">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <p>And here is a way to solve problem 2 on the homework using
        Fortran and the LAPACK library.</p>
      <p>     program ztest<br>
        <br>
              parameter (N=10)<br>
        <br>
              double complex A(N,N), B(N,N), C(N,N)<br>
        <br>
              double precision pi<br>
              integer ipiv(N), info<br>
              double complex work(64*N), sum<br>
              double complex alpha, beta<br>
              double precision gamma<br>
        <br>
              alpha = dcmplx(1.0D0,0.0D0)<br>
              beta  = dcmplx(0.0D0,0.0D0)<br>
        <br>
              pi = dacos(-1.0D0)<br>
        <br>
              do 10 i = 1, N<br>
                 do 20 j = 1, N<br>
                   gamma = dsqrt(dcos(dble(i**2*j)*pi/dble(N**3))**2+<br>
             +                  
        dsin(2.0D0*dble(i**2*j)*pi/dble(N**3))**2)<br>
                   A(j,i) = dcmplx(<br>
             +                    
        dcos(dble(i**2*j)*pi/dble(N**3))/gamma,<br>
             +                    
        dsin(2.0D0*dble(i**2*j)*pi/dble(N**3))/gamma)<br>
                   B(j,i) = A(j,i)<br>
        20       continue<br>
        10    continue<br>
        <br>
              call ZGETRF( N, N, B, N, IPIV, INFO )<br>
              call ZGETRI( N, B, N, IPIV, WORK, -1, INFO )<br>
              LWORK = int(dble(work(1)))<br>
              call ZGETRI( N, B, N, IPIV, WORK, LWORK, INFO )<br>
        <br>
              call ZGEMM ( 'N', 'N',  N, N, N,  alpha,  A,  N,<br>
             +              B,  N, beta, C, N)<br>
        <br>
              sum = dcmplx(0.0D0,0.0D0)<br>
              do 30 i = 1, N<br>
                  sum = sum + c(i,i)<br>
        30    continue<br>
        <br>
              print *, sum<br>
        <br>
        <br>
              end<br>
        <br>
        <br>
        <br>
      </p>
      <div class="moz-signature">-- <br>
        <b>Andrew J. Pounds, Ph.D.</b><br>
        <i>Professor of Chemistry and Computer Science</i><br>
        <i>Director of the Computational Science Program</i><br>
        <i>Mercer University, Macon, GA, 31207 (478) 301-5627 </i></div>
    </blockquote>
    <div class="moz-signature">-- <br>
      <b>Andrew J. Pounds, Ph.D.</b><br>
      <i>Professor of Chemistry and Computer Science</i><br>
      <i>Director of the Computational Science Program</i><br>
      <i>Mercer University, Macon, GA, 31207 (478) 301-5627 </i></div>
  </body>
</html>