<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic To undo the permutations, you in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Reversed-solve-after-zgetrf/m-p/1080921#M22802</link>
    <description>&lt;P&gt;The simplest solution, if you can rearrange your work so that you factorize A&lt;SUP&gt;T&lt;/SUP&gt; instead of A, is to note that X A = B is the same as A&lt;SUP&gt;T&lt;/SUP&gt;X&lt;SUP&gt;T&lt;/SUP&gt; = B&lt;SUP&gt;T&lt;/SUP&gt;. The last equation can be solved by a single call to ZGESV.&lt;/P&gt;

&lt;P&gt;If, however, you wish to use the steps of #2, ...:&lt;/P&gt;

&lt;P&gt;To undo the permutations, you can do the corresponding row interchanges after obtaining Y in order to obtain X, or you can form and use the inverse of the permutation vector when printing the solution. Here is an example (needs more testing for correctness!). For input data, you can use the file&amp;nbsp;&lt;STRONG&gt;sgetrsx.d&lt;/STRONG&gt; in the MKL examples/lapack/data directory.&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;! Example program to illustrate solving X.A = B
!    1. Call ?GETRF to factorize A = P L U
!    2. Call ?TRSM  to solve Z U = B
!    3. Call ?TRSM  to solve Y L = Z
!    4. Apply inverse of P to retrieve X = Y inv(P)
!
! Ref.: software.intel.com/en-us/forums/intel-math-kernel-library/topic/702864
!
    program strsmx
       implicit none
       integer nin, nout
       parameter (nin=5, nout=6)
       integer nmax, lda, nrhmax, ldb
       parameter (nmax=8, lda=nmax, nrhmax=nmax, ldb=nrhmax)
!     .. Local Variables ..
       integer i, ifail, info, j, k, n, nrhs
       real a(lda, nmax), b(nrhmax, nmax), alpha
       integer ipiv(nmax), iipiv(nmax)
!     .. Executable Statements ..
       write (nout, *) 'STRSM Example Program Results'
!     Skip heading in data file
       read (nin, *)
       read (nin, *) n, nrhs
       if (n&amp;lt;=nmax .and. nrhs&amp;lt;=nrhmax) then
!
!        Read A and B from data file
!
          read (nin, *)((a(i,j),j=1,n), i=1, n)
          read (nin, *)((b(j,i),j=1,nrhs), i=1, n)
!
!        Factorize A
!
          call sgetrf(n, n, a, lda, ipiv, info)
!
          write (nout, *)
          if (info/=0) then
             write (nout, *) 'The matrix A is singular'
          end if
!
!           Compute solution
!
          alpha = 1.0
          call strsm('R', 'U', 'N', 'N', n, n, alpha, a, lda, b, ldb)
          call strsm('R', 'L', 'N', 'U', n, n, alpha, a, lda, b, ldb)
!
!        Form inverse of pivot array
!
          iipiv(1:n) = (/ (i,i=1,n) /)
          do i = n, 1, -1
             j = ipiv(i)
             if (j/=i) then
&amp;nbsp;               k = iipiv(i)
                iipiv(i) = iipiv(j)
                iipiv(j) = k
             end if
          end do
!
!           Print solution
!
          do i = 1, n
             write (*, '(10(2x,ES12.3))')(b(j,iipiv(i)), j=1, nrhs)
          end do
       end if
       stop
!
    end program strsmx&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 12 Nov 2016 13:57:00 GMT</pubDate>
    <dc:creator>mecej4</dc:creator>
    <dc:date>2016-11-12T13:57:00Z</dc:date>
    <item>
      <title>Reversed solve after zgetrf ?</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Reversed-solve-after-zgetrf/m-p/1080918#M22799</link>
      <description>&lt;P&gt;&lt;SPAN style="font-size: 1em; -webkit-text-size-adjust: 100%;"&gt;Hello,&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;I'm trying to implement a blocked LDL&lt;SUP&gt;T&lt;/SUP&gt;&amp;nbsp;factorization but i'm facing some problems with the blocked column update.&lt;/P&gt;

&lt;P&gt;Is there any way to solve the equation X.A=B instead of A.X=B (zgetrs) after a LU decomposition of A with zgetrf ?&lt;/P&gt;

&lt;P&gt;Thank you in advance,&lt;/P&gt;

&lt;P&gt;Pierre&lt;/P&gt;</description>
      <pubDate>Wed, 09 Nov 2016 15:41:26 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Reversed-solve-after-zgetrf/m-p/1080918#M22799</guid>
      <dc:creator>Pierre_B_</dc:creator>
      <dc:date>2016-11-09T15:41:26Z</dc:date>
    </item>
    <item>
      <title>Hi Pierre,</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Reversed-solve-after-zgetrf/m-p/1080919#M22800</link>
      <description>&lt;P&gt;Hi Pierre,&lt;/P&gt;

&lt;P&gt;That's possible. First, after ZGETRF we have A=P*L*U (where P is&amp;nbsp;row permutation storing in IPIV array).&lt;/P&gt;

&lt;P&gt;So, X*A=B&amp;nbsp; &amp;lt;=&amp;gt;&amp;nbsp; X*P*L*U=B&amp;nbsp; &amp;lt;=&amp;gt;&amp;nbsp; ((X*P)*L)*U=B.&amp;nbsp; Let Y=X*P&amp;nbsp;and &amp;nbsp;Z=Y*L.&amp;nbsp; In this case, you can solve:&lt;/P&gt;

&lt;P&gt;(1) Z*U = B&amp;nbsp; - find Z using ZTRSM routine&lt;/P&gt;

&lt;P&gt;(2) Y*L = Z - find Y using ZTRSM routine&lt;/P&gt;

&lt;P&gt;(3) X*P = Y&amp;nbsp; &amp;lt;=&amp;gt; X=Y*P^-1&amp;nbsp; - &amp;nbsp;find&amp;nbsp;X&amp;nbsp;applying inverse permutation P.&lt;/P&gt;

&lt;P&gt;Regards,&lt;/P&gt;

&lt;P&gt;Konstantin&lt;/P&gt;</description>
      <pubDate>Fri, 11 Nov 2016 04:43:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Reversed-solve-after-zgetrf/m-p/1080919#M22800</guid>
      <dc:creator>Konstantin_A_Intel</dc:creator>
      <dc:date>2016-11-11T04:43:00Z</dc:date>
    </item>
    <item>
      <title>Hello Konstantin,</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Reversed-solve-after-zgetrf/m-p/1080920#M22801</link>
      <description>&lt;P&gt;Hello Konstantin,&lt;/P&gt;

&lt;P&gt;Thank you very much for your answer. I did not know i could use ztrsm on the output of zgetrf.&lt;/P&gt;

&lt;P&gt;What i am supposed to do to apply the inverse permutation ? Is there a routine for that or what should I do ?&lt;/P&gt;

&lt;P&gt;Thank you,&lt;/P&gt;

&lt;P&gt;Pierre&lt;/P&gt;</description>
      <pubDate>Fri, 11 Nov 2016 16:59:43 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Reversed-solve-after-zgetrf/m-p/1080920#M22801</guid>
      <dc:creator>Pierre_B_</dc:creator>
      <dc:date>2016-11-11T16:59:43Z</dc:date>
    </item>
    <item>
      <title>To undo the permutations, you</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Reversed-solve-after-zgetrf/m-p/1080921#M22802</link>
      <description>&lt;P&gt;The simplest solution, if you can rearrange your work so that you factorize A&lt;SUP&gt;T&lt;/SUP&gt; instead of A, is to note that X A = B is the same as A&lt;SUP&gt;T&lt;/SUP&gt;X&lt;SUP&gt;T&lt;/SUP&gt; = B&lt;SUP&gt;T&lt;/SUP&gt;. The last equation can be solved by a single call to ZGESV.&lt;/P&gt;

&lt;P&gt;If, however, you wish to use the steps of #2, ...:&lt;/P&gt;

&lt;P&gt;To undo the permutations, you can do the corresponding row interchanges after obtaining Y in order to obtain X, or you can form and use the inverse of the permutation vector when printing the solution. Here is an example (needs more testing for correctness!). For input data, you can use the file&amp;nbsp;&lt;STRONG&gt;sgetrsx.d&lt;/STRONG&gt; in the MKL examples/lapack/data directory.&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;! Example program to illustrate solving X.A = B
!    1. Call ?GETRF to factorize A = P L U
!    2. Call ?TRSM  to solve Z U = B
!    3. Call ?TRSM  to solve Y L = Z
!    4. Apply inverse of P to retrieve X = Y inv(P)
!
! Ref.: software.intel.com/en-us/forums/intel-math-kernel-library/topic/702864
!
    program strsmx
       implicit none
       integer nin, nout
       parameter (nin=5, nout=6)
       integer nmax, lda, nrhmax, ldb
       parameter (nmax=8, lda=nmax, nrhmax=nmax, ldb=nrhmax)
!     .. Local Variables ..
       integer i, ifail, info, j, k, n, nrhs
       real a(lda, nmax), b(nrhmax, nmax), alpha
       integer ipiv(nmax), iipiv(nmax)
!     .. Executable Statements ..
       write (nout, *) 'STRSM Example Program Results'
!     Skip heading in data file
       read (nin, *)
       read (nin, *) n, nrhs
       if (n&amp;lt;=nmax .and. nrhs&amp;lt;=nrhmax) then
!
!        Read A and B from data file
!
          read (nin, *)((a(i,j),j=1,n), i=1, n)
          read (nin, *)((b(j,i),j=1,nrhs), i=1, n)
!
!        Factorize A
!
          call sgetrf(n, n, a, lda, ipiv, info)
!
          write (nout, *)
          if (info/=0) then
             write (nout, *) 'The matrix A is singular'
          end if
!
!           Compute solution
!
          alpha = 1.0
          call strsm('R', 'U', 'N', 'N', n, n, alpha, a, lda, b, ldb)
          call strsm('R', 'L', 'N', 'U', n, n, alpha, a, lda, b, ldb)
!
!        Form inverse of pivot array
!
          iipiv(1:n) = (/ (i,i=1,n) /)
          do i = n, 1, -1
             j = ipiv(i)
             if (j/=i) then
&amp;nbsp;               k = iipiv(i)
                iipiv(i) = iipiv(j)
                iipiv(j) = k
             end if
          end do
!
!           Print solution
!
          do i = 1, n
             write (*, '(10(2x,ES12.3))')(b(j,iipiv(i)), j=1, nrhs)
          end do
       end if
       stop
!
    end program strsmx&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 12 Nov 2016 13:57:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Reversed-solve-after-zgetrf/m-p/1080921#M22802</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2016-11-12T13:57:00Z</dc:date>
    </item>
  </channel>
</rss>

