<?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 Re: How to test the singularity of a matrix in IML? in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-test-the-singularity-of-a-matrix-in-IML/m-p/205477#M2160</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The problem you describe is equivalent to computing the "rank of a matrix."&amp;nbsp; A nonsingular matrix is a square matrix that has full rank. Because of finite-precision arithmetic, the rank problem is difficult.&amp;nbsp; As Ian points out, there are problems with trying to compare a floating-point computation (determinant, eigenvalue, singular value,...) with zero.&amp;nbsp; Stable rank-detecting algorithms use some variation of Gaussian elimination to determine whether there are linear dependencies in the rows or columns of a matrix.&amp;nbsp;&amp;nbsp; In SAS/IML, the standard way to detect rank is to compute the generalized inverse (which always exists) and then multiply it by the original matrix.&amp;nbsp; If you get the identity matrix, then the original matrix was full rank (nonsingular). Otherwise the original matrix is less than full rank.&amp;nbsp; So to detect singularity, I suggest the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 14pt; font-family: Courier New;"&gt;A = { /* your matrix to test */ };&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;matrixRank = round(trace(ginv(A)*A));&lt;/P&gt;&lt;P&gt;if matrixRank &amp;lt; nrow(A) then print "Singular";&lt;/P&gt;&lt;P&gt;else print "Nonsingular";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 19 Mar 2015 12:23:08 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2015-03-19T12:23:08Z</dc:date>
    <item>
      <title>How to test the singularity of a matrix in IML?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-test-the-singularity-of-a-matrix-in-IML/m-p/205475#M2158</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is there any function or algorithm to verity a matrix&amp;nbsp; is nonsingular in IML? I need if in a "if&amp;nbsp; then"statement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Mar 2015 06:30:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-test-the-singularity-of-a-matrix-in-IML/m-p/205475#M2158</guid>
      <dc:creator>ShufeGuoding</dc:creator>
      <dc:date>2015-03-19T06:30:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to test the singularity of a matrix in IML?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-test-the-singularity-of-a-matrix-in-IML/m-p/205476#M2159</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The function DET returns the determinant of a matrix,&amp;nbsp; so:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if det(x)^=0 then ......&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but you may want to exclude small determinants if whatever you want to do is likely to give stability problems with near-singular x, so something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if abs(det(x))&amp;gt;s&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where s is some suitable small value.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Mar 2015 07:15:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-test-the-singularity-of-a-matrix-in-IML/m-p/205476#M2159</guid>
      <dc:creator>IanWakeling</dc:creator>
      <dc:date>2015-03-19T07:15:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to test the singularity of a matrix in IML?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-test-the-singularity-of-a-matrix-in-IML/m-p/205477#M2160</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The problem you describe is equivalent to computing the "rank of a matrix."&amp;nbsp; A nonsingular matrix is a square matrix that has full rank. Because of finite-precision arithmetic, the rank problem is difficult.&amp;nbsp; As Ian points out, there are problems with trying to compare a floating-point computation (determinant, eigenvalue, singular value,...) with zero.&amp;nbsp; Stable rank-detecting algorithms use some variation of Gaussian elimination to determine whether there are linear dependencies in the rows or columns of a matrix.&amp;nbsp;&amp;nbsp; In SAS/IML, the standard way to detect rank is to compute the generalized inverse (which always exists) and then multiply it by the original matrix.&amp;nbsp; If you get the identity matrix, then the original matrix was full rank (nonsingular). Otherwise the original matrix is less than full rank.&amp;nbsp; So to detect singularity, I suggest the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 14pt; font-family: Courier New;"&gt;A = { /* your matrix to test */ };&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;matrixRank = round(trace(ginv(A)*A));&lt;/P&gt;&lt;P&gt;if matrixRank &amp;lt; nrow(A) then print "Singular";&lt;/P&gt;&lt;P&gt;else print "Nonsingular";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Mar 2015 12:23:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-to-test-the-singularity-of-a-matrix-in-IML/m-p/205477#M2160</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2015-03-19T12:23:08Z</dc:date>
    </item>
  </channel>
</rss>

