<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.3.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: Creating Sparse Finite-Element Matrices in MATLAB</title>
	<link>http://blogs.mathworks.com/loren/2007/03/01/creating-sparse-finite-element-matrices-in-matlab/</link>
	<description>Loren Shure  works on design of the MATLAB language at &#60;a href="http://www.mathworks.com/"&#62;The MathWorks&#60;/a&#62;. She writes here about once a week on MATLAB programming and related topics. &#60;br&#62;&#60;br&#62;&#60;a href="/images/loren-full.jpg"&#62;&#60;img src="/images/loren.jpg"&#62;&#60;/a&#62;</description>
	<pubDate>Sun, 08 Nov 2009 06:02:39 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.1</generator>
		<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2007/03/01/creating-sparse-finite-element-matrices-in-matlab/#comment-30644</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Fri, 25 Sep 2009 17:05:20 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2007/03/01/creating-sparse-finite-element-matrices-in-matlab/#comment-30644</guid>
		<description>Aman-

From the help

"S = sparse(i,j,s,m,n,nzmax) uses vectors i, j, and s to generate an m-by-n sparse matrix such that S(i(k),j(k)) = s(k), with space allocated for nzmax nonzeros. Vectors i, j, and s are all the same length. Any elements of s that are zero are ignored, along with the corresponding values of i and j. Any elements of s that have duplicate values of i and j are added together. "

Values at repeated indices are summed together.

--Loren</description>
		<content:encoded><![CDATA[<p>Aman-</p>
<p>From the help</p>
<p>&#8220;S = sparse(i,j,s,m,n,nzmax) uses vectors i, j, and s to generate an m-by-n sparse matrix such that S(i(k),j(k)) = s(k), with space allocated for nzmax nonzeros. Vectors i, j, and s are all the same length. Any elements of s that are zero are ignored, along with the corresponding values of i and j. Any elements of s that have duplicate values of i and j are added together. &#8220;</p>
<p>Values at repeated indices are summed together.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aman P.V</title>
		<link>http://blogs.mathworks.com/loren/2007/03/01/creating-sparse-finite-element-matrices-in-matlab/#comment-30643</link>
		<dc:creator>Aman P.V</dc:creator>
		<pubDate>Fri, 25 Sep 2009 17:02:32 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2007/03/01/creating-sparse-finite-element-matrices-in-matlab/#comment-30643</guid>
		<description>Hi all,

I have a small doubt. If use sparse command with a repeated indices what will happen? will that sum up or just replace?
As all of you know for a same position in the Global stiffness matrix we;ll have contribution from different elements and we'll have to sum them up.
Any one please clarify my doubt.</description>
		<content:encoded><![CDATA[<p>Hi all,</p>
<p>I have a small doubt. If use sparse command with a repeated indices what will happen? will that sum up or just replace?<br />
As all of you know for a same position in the Global stiffness matrix we;ll have contribution from different elements and we&#8217;ll have to sum them up.<br />
Any one please clarify my doubt.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tim Davis</title>
		<link>http://blogs.mathworks.com/loren/2007/03/01/creating-sparse-finite-element-matrices-in-matlab/#comment-30550</link>
		<dc:creator>Tim Davis</dc:creator>
		<pubDate>Wed, 26 Aug 2009 14:41:35 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2007/03/01/creating-sparse-finite-element-matrices-in-matlab/#comment-30550</guid>
		<description>p.s.  If you are solving x=A\b where A comes from a circuit matrix, you'll be using UMFPACK (normally) or CHOLMOD (if A is symmetric positive definite.  Both of those are my codes.  A\b might also use MA57 (from Iain Duff) if it's symmetric indefinite, or a banded solver if A is a band matrix.

However, I also have another package that's specifically designed for circuit matrices.  It's much faster than x=A\b (UMFPACK, CHOLMOD, etc).  It's not a part of A\b in MATLAB.

See KLU, in SuiteSparse, at http://www.cise.ufl.edu/research/sparse (just download all of SuiteSparse; KLU is part of it).  Using KLU with x=klu(A,'\',b) can be many times faster than x=A\b for circuit matrices.</description>
		<content:encoded><![CDATA[<p>p.s.  If you are solving x=A\b where A comes from a circuit matrix, you&#8217;ll be using UMFPACK (normally) or CHOLMOD (if A is symmetric positive definite.  Both of those are my codes.  A\b might also use MA57 (from Iain Duff) if it&#8217;s symmetric indefinite, or a banded solver if A is a band matrix.</p>
<p>However, I also have another package that&#8217;s specifically designed for circuit matrices.  It&#8217;s much faster than x=A\b (UMFPACK, CHOLMOD, etc).  It&#8217;s not a part of A\b in MATLAB.</p>
<p>See KLU, in SuiteSparse, at <a href="http://www.cise.ufl.edu/research/sparse" rel="nofollow">http://www.cise.ufl.edu/research/sparse</a> (just download all of SuiteSparse; KLU is part of it).  Using KLU with x=klu(A,&#8217;\',b) can be many times faster than x=A\b for circuit matrices.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tim Davis</title>
		<link>http://blogs.mathworks.com/loren/2007/03/01/creating-sparse-finite-element-matrices-in-matlab/#comment-30549</link>
		<dc:creator>Tim Davis</dc:creator>
		<pubDate>Wed, 26 Aug 2009 14:34:16 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2007/03/01/creating-sparse-finite-element-matrices-in-matlab/#comment-30549</guid>
		<description>Reply to Xuexin Liu:  if you are changing just a few entries, then C(i,j)=C(i,j)+new_param is fine.  If you are changing a lot of entries, then create a matrix New_param (for example) with all the changes, using the method described here.  Then do C=C+New_param to make all the changes at once.  This method will be a lot faster than using the C(i,j)=C(i,j)+new_param inside a loop.</description>
		<content:encoded><![CDATA[<p>Reply to Xuexin Liu:  if you are changing just a few entries, then C(i,j)=C(i,j)+new_param is fine.  If you are changing a lot of entries, then create a matrix New_param (for example) with all the changes, using the method described here.  Then do C=C+New_param to make all the changes at once.  This method will be a lot faster than using the C(i,j)=C(i,j)+new_param inside a loop.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Xuexin Liu</title>
		<link>http://blogs.mathworks.com/loren/2007/03/01/creating-sparse-finite-element-matrices-in-matlab/#comment-30546</link>
		<dc:creator>Xuexin Liu</dc:creator>
		<pubDate>Tue, 25 Aug 2009 18:35:32 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2007/03/01/creating-sparse-finite-element-matrices-in-matlab/#comment-30546</guid>
		<description>Dear Madam,

Thank you for your posts! In this post, you gave us the advice "Moral: Do Not Abuse A(i,j)=... for Sparse A; Use sparse Instead". My question is that can we always finish our job without using A(i,j)=... ?

Thanks!

And below are the details of my questions:

In the formulation of a dynamic system equation (one example is a circuit containing resistors, capacitors, and inductors), the entries in the sparse matrix may be changed when a new device is loaded (the devices are loaded from a net list specified the interconnection of them). And after all the devices in the circuit are loaded, the program will solve the equation using the sparse matrix.

In this case, I haven't figured out a way without using assignment such as
    C(i,j) = C(i,j) + new_param;

What do you think? Thanks in advance for your advices!</description>
		<content:encoded><![CDATA[<p>Dear Madam,</p>
<p>Thank you for your posts! In this post, you gave us the advice &#8220;Moral: Do Not Abuse A(i,j)=&#8230; for Sparse A; Use sparse Instead&#8221;. My question is that can we always finish our job without using A(i,j)=&#8230; ?</p>
<p>Thanks!</p>
<p>And below are the details of my questions:</p>
<p>In the formulation of a dynamic system equation (one example is a circuit containing resistors, capacitors, and inductors), the entries in the sparse matrix may be changed when a new device is loaded (the devices are loaded from a net list specified the interconnection of them). And after all the devices in the circuit are loaded, the program will solve the equation using the sparse matrix.</p>
<p>In this case, I haven&#8217;t figured out a way without using assignment such as<br />
    C(i,j) = C(i,j) + new_param;</p>
<p>What do you think? Thanks in advance for your advices!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave</title>
		<link>http://blogs.mathworks.com/loren/2007/03/01/creating-sparse-finite-element-matrices-in-matlab/#comment-30181</link>
		<dc:creator>Dave</dc:creator>
		<pubDate>Thu, 02 Apr 2009 22:19:25 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2007/03/01/creating-sparse-finite-element-matrices-in-matlab/#comment-30181</guid>
		<description>Hi, 
Great stuff! Can anyone point me to something like sparse2 for a poor fortran (90) programmer...? In particular, I need a fast routine to convert a triplet form matrix to compressed sparse row format. 
I would greatly appreciate any suggestions!</description>
		<content:encoded><![CDATA[<p>Hi,<br />
Great stuff! Can anyone point me to something like sparse2 for a poor fortran (90) programmer&#8230;? In particular, I need a fast routine to convert a triplet form matrix to compressed sparse row format.<br />
I would greatly appreciate any suggestions!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pat Quillen</title>
		<link>http://blogs.mathworks.com/loren/2007/03/01/creating-sparse-finite-element-matrices-in-matlab/#comment-30100</link>
		<dc:creator>Pat Quillen</dc:creator>
		<pubDate>Tue, 10 Mar 2009 18:11:23 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2007/03/01/creating-sparse-finite-element-matrices-in-matlab/#comment-30100</guid>
		<description>Phil,

Requiring index vectors to be double is a throwback to the days of "everything in MATLAB is a double".  Indeed, our default type for all index vectors is double (take the output of find for example).  We'll take it as an enhancement request to allow sparse to take vectors of an integral type as inputs.</description>
		<content:encoded><![CDATA[<p>Phil,</p>
<p>Requiring index vectors to be double is a throwback to the days of &#8220;everything in MATLAB is a double&#8221;.  Indeed, our default type for all index vectors is double (take the output of find for example).  We&#8217;ll take it as an enhancement request to allow sparse to take vectors of an integral type as inputs.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Phil</title>
		<link>http://blogs.mathworks.com/loren/2007/03/01/creating-sparse-finite-element-matrices-in-matlab/#comment-30070</link>
		<dc:creator>Phil</dc:creator>
		<pubDate>Tue, 03 Mar 2009 20:21:33 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2007/03/01/creating-sparse-finite-element-matrices-in-matlab/#comment-30070</guid>
		<description>Echoing David Heintz in comment 11, why does sparse require the index vectors to be doubles?
On a 32 bit machine, this seems to cause the 2 index vectors and the entry vector to take (8 + 8 + 8)*n_entries bytes rather than (4 + 4 + 8)*n_entries bytes.  That's a 50% increase in memory usage!  Plus, sparse must be doing some kind of double to integer conversion anyway.</description>
		<content:encoded><![CDATA[<p>Echoing David Heintz in comment 11, why does sparse require the index vectors to be doubles?<br />
On a 32 bit machine, this seems to cause the 2 index vectors and the entry vector to take (8 + 8 + 8)*n_entries bytes rather than (4 + 4 + 8)*n_entries bytes.  That&#8217;s a 50% increase in memory usage!  Plus, sparse must be doing some kind of double to integer conversion anyway.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Etienne Non</title>
		<link>http://blogs.mathworks.com/loren/2007/03/01/creating-sparse-finite-element-matrices-in-matlab/#comment-29495</link>
		<dc:creator>Etienne Non</dc:creator>
		<pubDate>Thu, 12 Jun 2008 14:03:17 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2007/03/01/creating-sparse-finite-element-matrices-in-matlab/#comment-29495</guid>
		<description>Thanks guys!!</description>
		<content:encoded><![CDATA[<p>Thanks guys!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tim Davis</title>
		<link>http://blogs.mathworks.com/loren/2007/03/01/creating-sparse-finite-element-matrices-in-matlab/#comment-29453</link>
		<dc:creator>Tim Davis</dc:creator>
		<pubDate>Thu, 05 Jun 2008 16:27:14 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2007/03/01/creating-sparse-finite-element-matrices-in-matlab/#comment-29453</guid>
		<description>Etienne,

Cleve is correct.  Do not compare the numerical values of the two matrices.  To compare two matrices A and B, look at spones(A) and spones(B).  If they differ, the LU factorization can differ.

Even tiny changes in the pattern can make a huge difference.  Inside LU, backslash, chol, etc, is a heuristic that permutes the matrix to reduce fill-in.  It's a heuristic because to find the minimum fill is an NP-hard problem, and would take time exceeding the lifetime of the universe to solve exactly.  I think you want your answer before that....  The heursistic can go down a different "path" and find very different fill-in, even with small changes in pattern.

Even with an uncomputable, perfectly minimum fill ordering, tiny changes in the pattern can lead to huge changes in nnz(L+U).</description>
		<content:encoded><![CDATA[<p>Etienne,</p>
<p>Cleve is correct.  Do not compare the numerical values of the two matrices.  To compare two matrices A and B, look at spones(A) and spones(B).  If they differ, the LU factorization can differ.</p>
<p>Even tiny changes in the pattern can make a huge difference.  Inside LU, backslash, chol, etc, is a heuristic that permutes the matrix to reduce fill-in.  It&#8217;s a heuristic because to find the minimum fill is an NP-hard problem, and would take time exceeding the lifetime of the universe to solve exactly.  I think you want your answer before that&#8230;.  The heursistic can go down a different &#8220;path&#8221; and find very different fill-in, even with small changes in pattern.</p>
<p>Even with an uncomputable, perfectly minimum fill ordering, tiny changes in the pattern can lead to huge changes in nnz(L+U).</p>
]]></content:encoded>
	</item>
</channel>
</rss>
