[Ktechlab-devel] Matrix permutation problem:

Alan Grimes agrimes at speakeasy.net
Fri Jul 3 18:12:24 UTC 2009


I was playing with my diode test circuit again and found that one of the
underlying issues is the simple row permutation algorithm I used in the
LU decomposition class. The matrix is so sparse that it really is a
problem. =( There probably is a textbook solution but I"m too lazy to go
into my library in the other room right now. =P

Here's the permutation algorithm from matrix.cpp:

		// do row permutations;
		if(k >= max_k) {
			double max = std::abs(m_mat->at(k,k));
			unsigned int row = k;
			for(unsigned int j = k + 1; j < n; j++) {
				double val = std::abs(m_mat->at(j,k));
				if(val > max) {
					max = val;
					row = j;
				}
			}

			if(row != k) swapRows(k,row);
		}


It doesn't work because one of the diagonal entries ended up being zero.
=( (see cell 9H on the spreadsheet).

The code would work if it were smart enough to know that it should have
swapped row 3 and row 8... (see attached).

If we can fix this, we can remove the expensive assertion checks from
the code which will make it really fly!!!

-- 
New president: Here we go again...
Chemistry.com: A total rip-off.
Powers are not rights.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: badPermute.ods
Type: application/vnd.oasis.opendocument.spreadsheet
Size: 9942 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/ktechlab-devel/attachments/20090703/1fa1d00f/attachment.ods>


More information about the Ktechlab-devel mailing list