<?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 Create a block diagonal matrix from a to-be-partitioned matrix in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Create-a-block-diagonal-matrix-from-a-to-be-partitioned-matrix/m-p/88392#M531</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Could someone please help me out?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a matrix A={1 1,1 2,2 1,2 2,2 3,3 1}. I would like to create a block diagonal matrix (B) such that B={1 1 0 0 0 0, 1 2 0 0 0 0, 0 0 2 1 0 0, 0 0 2 2 0 0, 0 0 2 3 0 0, 0 0 0 0 3 1}. I know of the block function but it does not work here (in its basic form at least). How can I do this in IML? Is it possible without looping because the number of rows in A can get very large (millions or more)? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Lots of thanks in advance for your help.&lt;/P&gt;&lt;P&gt;George&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 07 Oct 2012 02:13:06 GMT</pubDate>
    <dc:creator>KGeorge</dc:creator>
    <dc:date>2012-10-07T02:13:06Z</dc:date>
    <item>
      <title>Create a block diagonal matrix from a to-be-partitioned matrix</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Create-a-block-diagonal-matrix-from-a-to-be-partitioned-matrix/m-p/88392#M531</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Could someone please help me out?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a matrix A={1 1,1 2,2 1,2 2,2 3,3 1}. I would like to create a block diagonal matrix (B) such that B={1 1 0 0 0 0, 1 2 0 0 0 0, 0 0 2 1 0 0, 0 0 2 2 0 0, 0 0 2 3 0 0, 0 0 0 0 3 1}. I know of the block function but it does not work here (in its basic form at least). How can I do this in IML? Is it possible without looping because the number of rows in A can get very large (millions or more)? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Lots of thanks in advance for your help.&lt;/P&gt;&lt;P&gt;George&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 07 Oct 2012 02:13:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Create-a-block-diagonal-matrix-from-a-to-be-partitioned-matrix/m-p/88392#M531</guid>
      <dc:creator>KGeorge</dc:creator>
      <dc:date>2012-10-07T02:13:06Z</dc:date>
    </item>
    <item>
      <title>Re: Create a block diagonal matrix from a to-be-partitioned matrix</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Create-a-block-diagonal-matrix-from-a-to-be-partitioned-matrix/m-p/88393#M532</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You don't need to loop over rows of A; you can loop over the unique blocks defined by A.&amp;nbsp; Use the UNIQUE function on the first column of A to find out how many blocks there are. Then for each block, use the BLOCK function to iteratively build up the matrix.&amp;nbsp; For you example, the loop would have three iterations and be equivalent to the following statements:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;B = A[1:2,];&amp;nbsp; /* initialize outside loop */&lt;/P&gt;&lt;P&gt;/* do i = 2 to 3; */&lt;/P&gt;&lt;P&gt;B = block(B, A[3:5,]);&lt;/P&gt;&lt;P&gt;B = block(B, A[6,]);&lt;/P&gt;&lt;P&gt;/* end do */&lt;/P&gt;&lt;P&gt;print B;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 07 Oct 2012 09:46:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Create-a-block-diagonal-matrix-from-a-to-be-partitioned-matrix/m-p/88393#M532</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2012-10-07T09:46:04Z</dc:date>
    </item>
    <item>
      <title>Re: Create a block diagonal matrix from a to-be-partitioned matrix</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Create-a-block-diagonal-matrix-from-a-to-be-partitioned-matrix/m-p/88394#M533</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Rick&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Oct 2012 18:10:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Create-a-block-diagonal-matrix-from-a-to-be-partitioned-matrix/m-p/88394#M533</guid>
      <dc:creator>KGeorge</dc:creator>
      <dc:date>2012-10-11T18:10:23Z</dc:date>
    </item>
  </channel>
</rss>

