<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://mediawiki.zeropage.org/index.php?action=history&amp;feed=atom&amp;title=CubicSpline%2F1002%2FTriDiagonal.py</id>
	<title>CubicSpline/1002/TriDiagonal.py - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://mediawiki.zeropage.org/index.php?action=history&amp;feed=atom&amp;title=CubicSpline%2F1002%2FTriDiagonal.py"/>
	<link rel="alternate" type="text/html" href="https://mediawiki.zeropage.org/index.php?title=CubicSpline/1002/TriDiagonal.py&amp;action=history"/>
	<updated>2026-05-16T22:35:22Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.8</generator>
	<entry>
		<id>https://mediawiki.zeropage.org/index.php?title=CubicSpline/1002/TriDiagonal.py&amp;diff=31025&amp;oldid=prev</id>
		<title>imported&gt;Unknown at 05:23, 7 February 2021</title>
		<link rel="alternate" type="text/html" href="https://mediawiki.zeropage.org/index.php?title=CubicSpline/1002/TriDiagonal.py&amp;diff=31025&amp;oldid=prev"/>
		<updated>2021-02-07T05:23:03Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt; &lt;br /&gt;
 from LuDecomposition import *&lt;br /&gt;
 from Numeric import *&lt;br /&gt;
 from ArrayPrinter import *&lt;br /&gt;
 import pdb&lt;br /&gt;
 &lt;br /&gt;
 def getMatrixY(aMatrixLower, b):&lt;br /&gt;
 	matrixY = makeEmptyMatrix(len(b),1)&lt;br /&gt;
 	for n in range(len(b)):&lt;br /&gt;
 		matrixY[n][0] = float(b[n][0] - _minusForGetMatrixY(n, aMatrixLower, matrixY)) / float(aMatrixLower[n][n])&lt;br /&gt;
 	return matrixY&lt;br /&gt;
 &lt;br /&gt;
 def getMatrixX(aMatrixUpper, y):&lt;br /&gt;
 	limitedMatrix = len(y)&lt;br /&gt;
 	matrixX = makeEmptyMatrix(limitedMatrix,1)&lt;br /&gt;
 	for n in range(limitedMatrix-1, -1,-1):&lt;br /&gt;
 		matrixX[n][0] = float(y[n][0] - _minusForGetMatrixX(n, aMatrixUpper, matrixX)) / float(aMatrixUpper[n][n])&lt;br /&gt;
 		#print &amp;quot;x[%d]: y[%d][0] - minus:[%f] / u[%d][%d]:%f : %f&amp;quot;% (n,n,_minusForGetMatrixX(n, aMatrixUpper, matrixX),n,n, aMatrixUpper[n][n], matrixX[n][0])&lt;br /&gt;
 	return matrixX&lt;br /&gt;
 &lt;br /&gt;
 def _minusForGetMatrixX(n, aUpperMatrix, aMatrixX):&lt;br /&gt;
 	totalMinus = 0&lt;br /&gt;
 	limitedMatrix = len(aMatrixX)&lt;br /&gt;
 	for t in range(n+1,limitedMatrix):&lt;br /&gt;
 		totalMinus += aUpperMatrix[n][t] * aMatrixX[t][0]&lt;br /&gt;
 	return totalMinus&lt;br /&gt;
 &lt;br /&gt;
 def _minusForGetMatrixY(n, aLowerMatrix, aMatrixY):&lt;br /&gt;
 	totalMinus = 0&lt;br /&gt;
 	for t in range(n):&lt;br /&gt;
 		totalMinus += aLowerMatrix[n][t] * aMatrixY[t][0]&lt;br /&gt;
 	return totalMinus&lt;br /&gt;
 	&lt;br /&gt;
 &lt;br /&gt;
 def makeEmptyMatrix(aRow, aCol):&lt;br /&gt;
 	emptyMatrix = []&lt;br /&gt;
 	for i in range(0,aRow):&lt;br /&gt;
 		emptyRow = []&lt;br /&gt;
 		for j in range(0,aCol):&lt;br /&gt;
 			emptyRow.append(0.0)&lt;br /&gt;
 		emptyMatrix.append(emptyRow)&lt;br /&gt;
 	return emptyMatrix&lt;br /&gt;
 &lt;br /&gt;
 def prettyPrintMatrix(aMatrix):&lt;br /&gt;
 	print array2string(array(aMatrix))&lt;br /&gt;
 def printSeparator():&lt;br /&gt;
 	print &amp;quot;*-&amp;quot; * 35&lt;br /&gt;
 &lt;br /&gt;
 if __name__==&amp;quot;__main__&amp;quot;:&lt;br /&gt;
 	a =	[[4.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],&lt;br /&gt;
 			[1.0, 4.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],&lt;br /&gt;
 			[0.0, 1.0, 4.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0],&lt;br /&gt;
 			[0.0, 0.0, 1.0, 4.0, 1.0, 0.0, 0.0, 0.0, 0.0],&lt;br /&gt;
 			[0.0, 0.0, 0.0, 1.0, 4.0, 1.0, 0.0, 0.0, 0.0],&lt;br /&gt;
 			[0.0, 0.0, 0.0, 0.0, 1.0, 4.0, 1.0, 0.0, 0.0],&lt;br /&gt;
 			[0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 4.0, 1.0, 0.0],&lt;br /&gt;
 			[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 4.0, 1.0],&lt;br /&gt;
 			[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 4.0]]&lt;br /&gt;
 	b = [[5.0], [6.0], [6.0], [6.0], [6.0], [6.0], [6.0], [6.0], [5.0]]&lt;br /&gt;
 	l, u = LuDecomposition(a).perform()&lt;br /&gt;
 	printSeparator()&lt;br /&gt;
 	print &amp;quot;LuDecomposition - Matrix L:&amp;quot;&lt;br /&gt;
 	prettyPrintMatrix(l)&lt;br /&gt;
 	#pdb.set_trace()&lt;br /&gt;
 	printSeparator()&lt;br /&gt;
 	matrixY = getMatrixY(l, b)&lt;br /&gt;
 	print &amp;quot;Calculated - Matrix Y&amp;quot;&lt;br /&gt;
 	prettyPrintMatrix(matrixY)&lt;br /&gt;
 	printSeparator()&lt;br /&gt;
 	print &amp;quot;LuDecomposition - Matrix U:&amp;quot;&lt;br /&gt;
 	prettyPrintMatrix(u)&lt;br /&gt;
 	printSeparator()&lt;br /&gt;
 	print &amp;quot;Final - Matrix X&amp;quot;&lt;br /&gt;
 	matrixX = getMatrixX(u, matrixY)&lt;br /&gt;
 	prettyPrintMatrix(matrixX)&lt;/div&gt;</summary>
		<author><name>imported&gt;Unknown</name></author>
	</entry>
</feed>