<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://micro.stanford.edu/mediawiki/index.php?action=history&amp;feed=atom&amp;title=Standard_Tcl_Library</id>
	<title>Standard Tcl Library - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://micro.stanford.edu/mediawiki/index.php?action=history&amp;feed=atom&amp;title=Standard_Tcl_Library"/>
	<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=Standard_Tcl_Library&amp;action=history"/>
	<updated>2026-07-05T11:50:06Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.7</generator>
	<entry>
		<id>http://micro.stanford.edu/mediawiki/index.php?title=Standard_Tcl_Library&amp;diff=3247&amp;oldid=prev</id>
		<title>Kwkang at 09:03, 1 March 2009</title>
		<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=Standard_Tcl_Library&amp;diff=3247&amp;oldid=prev"/>
		<updated>2009-03-01T09:03:07Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 09:03, 1 March 2009&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;If you&#039;ve used Tcl, sometimes you may feel that Tcl would be more convenient if it can support some matrix operations such as matrix summation, transpose, dot/cross product, norm, etc. I introduce Tcl standard library that can &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;alleviate&lt;/del&gt; our &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;burdens&lt;/del&gt;.&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;If you&#039;ve used Tcl, sometimes you may feel that Tcl would be more convenient if it can support some&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; vector or&lt;/ins&gt; matrix operations such as matrix summation, transpose, dot/cross product, norm, etc. I introduce Tcl standard library&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;, &#039;&#039;&#039;Tcllib&#039;&#039;&#039;&lt;/ins&gt; that can &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;resolve&lt;/ins&gt; our &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;troubles&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Install&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;==&lt;/ins&gt;Install&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;==&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Download Tcllib from http://www.tcl.tk/software/tcllib/ and install it&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Download Tcllib from http://www.tcl.tk/software/tcllib/ and install it&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 11:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 11:&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; # ./installer.tcl&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; # ./installer.tcl&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Usage&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;==&lt;/ins&gt;Usage&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;==&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;There are on-line documentations at http://tcllib.sourceforge.net/doc/ . Below is shown a sample Tcl script, &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;matrix&lt;/del&gt;.tcl to show how &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;we can&lt;/del&gt; use&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; Tcl&lt;/del&gt; linear algebra library.&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;There are on-line documentations at http://tcllib.sourceforge.net/doc/ . Below is shown a sample Tcl script, &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Media:Matrix&lt;/ins&gt;.tcl&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;  | Matrix.tcl]]&lt;/ins&gt; to show how &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;to&lt;/ins&gt; use linear algebra library&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; in Tcl&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 82:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 82:&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;set AtA [::math::linearalgebra::matmul $At $A]&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;set AtA [::math::linearalgebra::matmul $At $A]&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;puts &quot;[::math::linearalgebra::show $AtA ]&quot;&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;puts &quot;[::math::linearalgebra::show $AtA ]&quot;&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-deleted&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-deleted&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Is a given matrix symmetric?&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-deleted&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;puts &quot;isSymmetric( At * A ) = [::math::linearalgebra::symmetric $AtA]&quot;&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Matrix determinant&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Matrix determinant&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 110:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 113:&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;If you run the script, the result will look like the following.&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;If you run the script, the result will look like the following.&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;$ ./&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;matrix&lt;/del&gt;.tcl &lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;$ ./&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Matrix&lt;/ins&gt;.tcl &lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Tcl script name: ./&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;matrix&lt;/del&gt;.tcl, with 0 arguments&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Tcl script name: ./&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Matrix&lt;/ins&gt;.tcl, with 0 arguments&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Durer&#039;s magic square&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Durer&#039;s magic square&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 138:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 141:&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;360.0000 206.0000 212.0000 378.0000 &lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;360.0000 206.0000 212.0000 378.0000 &lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-deleted&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;isSymmetric( At * A ) = 1&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;det(A) = 0.&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;det(A) = 0.&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Kwkang</name></author>
	</entry>
	<entry>
		<id>http://micro.stanford.edu/mediawiki/index.php?title=Standard_Tcl_Library&amp;diff=3246&amp;oldid=prev</id>
		<title>Kwkang: New page: If you&#039;ve used Tcl, sometimes you may feel that Tcl would be more convenient if it can support some matrix operations such as matrix summation, transpose, dot/cross product, norm, etc. I i...</title>
		<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=Standard_Tcl_Library&amp;diff=3246&amp;oldid=prev"/>
		<updated>2009-03-01T08:36:55Z</updated>

		<summary type="html">&lt;p&gt;New page: If you&amp;#039;ve used Tcl, sometimes you may feel that Tcl would be more convenient if it can support some matrix operations such as matrix summation, transpose, dot/cross product, norm, etc. I i...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;If you&amp;#039;ve used Tcl, sometimes you may feel that Tcl would be more convenient if it can support some matrix operations such as matrix summation, transpose, dot/cross product, norm, etc. I introduce Tcl standard library that can alleviate our burdens.&lt;br /&gt;
&lt;br /&gt;
Install&lt;br /&gt;
&lt;br /&gt;
Download Tcllib from http://www.tcl.tk/software/tcllib/ and install it&lt;br /&gt;
&lt;br /&gt;
 # mv tcllib-1.11.1.tar.gz /usr/local/src/&lt;br /&gt;
 # cd /usr/local/src/&lt;br /&gt;
 # tar -zxvf tcllib-1.11.1.tar.gz&lt;br /&gt;
 # cd tcllib-1.11.1&lt;br /&gt;
 # ./installer.tcl&lt;br /&gt;
&lt;br /&gt;
Usage&lt;br /&gt;
&lt;br /&gt;
There are on-line documentations at http://tcllib.sourceforge.net/doc/ . Below is shown a sample Tcl script, matrix.tcl to show how we can use Tcl linear algebra library.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
# the next line is executed by /bin/sh, but not tcl \&lt;br /&gt;
echo Tcl script name: $0, with $# arguments; echo ; exec tclsh &amp;quot;$0&amp;quot; &amp;quot;$@&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Call necessary pacakges&lt;br /&gt;
#*******************************************&lt;br /&gt;
package require math::linearalgebra&lt;br /&gt;
&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Definition of procedures&lt;br /&gt;
#*******************************************&lt;br /&gt;
proc det matrix {&lt;br /&gt;
    if {[llength $matrix] != [llength [lindex $matrix 0]]} {&lt;br /&gt;
       error &amp;quot;non-square matrix&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
    switch [llength $matrix] {&lt;br /&gt;
       2 {&lt;br /&gt;
           foreach {a b c d} [join $matrix] break&lt;br /&gt;
           expr {$a*$d - $b*$c}&lt;br /&gt;
       } default {&lt;br /&gt;
           set i 0&lt;br /&gt;
           set mat2 [lrange $matrix 1 end]&lt;br /&gt;
           set res 0&lt;br /&gt;
           foreach element [lindex $matrix 0] {&lt;br /&gt;
              if $element {&lt;br /&gt;
                 set sign [expr {$i%2? -1: 1}]&lt;br /&gt;
                 set res [expr {$res + $sign*$element* [det [cancelcol $i $mat2]]}]&lt;br /&gt;
              }&lt;br /&gt;
              incr i&lt;br /&gt;
           }&lt;br /&gt;
           set res&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
 }&lt;br /&gt;
proc cancelcol {n matrix} {&lt;br /&gt;
    set res {}&lt;br /&gt;
    foreach row $matrix {&lt;br /&gt;
        lappend res [lreplace $row $n $n]&lt;br /&gt;
    }&lt;br /&gt;
    set res&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
#*******************************************&lt;br /&gt;
# Main program starts here&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Durer&amp;#039;s magic square&lt;br /&gt;
puts &amp;quot;Durer&amp;#039;s magic square&amp;quot;&lt;br /&gt;
set A {{16 3 2 13} {5 10 11 8} {9 6 7 12} {4 15 14 1}}&lt;br /&gt;
puts &amp;quot;A = \n[::math::linearalgebra::show $A %2d]&amp;quot; &lt;br /&gt;
&lt;br /&gt;
# Transpose the matrix A&lt;br /&gt;
puts &amp;quot;Transpose of the matrix A, At =&amp;quot;&lt;br /&gt;
set At [::math::linearalgebra::transpose $A]&lt;br /&gt;
puts &amp;quot;[::math::linearalgebra::show $At %2d]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Matrix Summation&lt;br /&gt;
puts &amp;quot;A + At =&amp;quot;&lt;br /&gt;
puts &amp;quot;[::math::linearalgebra::show \&lt;br /&gt;
      [::math::linearalgebra::add $A $At] %2d]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Matrix multiplication&lt;br /&gt;
puts &amp;quot;At * A =&amp;quot;&lt;br /&gt;
set AtA [::math::linearalgebra::matmul $At $A]&lt;br /&gt;
puts &amp;quot;[::math::linearalgebra::show $AtA ]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Matrix determinant&lt;br /&gt;
set detA [det $A]&lt;br /&gt;
puts &amp;quot;det(A) = $detA.\n&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Create a 3X3 matrix O whose elements are all zeros. &lt;br /&gt;
puts &amp;quot;Create a 3X3 matrix O whose elements are all zeros.&amp;quot;&lt;br /&gt;
set O [::math::linearalgebra::mkMatrix 3 3 0]&lt;br /&gt;
puts &amp;quot;O = \n[::math::linearalgebra::show $O]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Create a 3X3 identity matrix I&lt;br /&gt;
puts &amp;quot;Create a 3X3 identity matrix I.&amp;quot;&lt;br /&gt;
set I [::math::linearalgebra::mkIdentity 3]&lt;br /&gt;
puts &amp;quot;I = \n[::math::linearalgebra::show $I]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Create a 3X3 random matrix R&lt;br /&gt;
puts &amp;quot;Create a 3X3 random matrix R.&amp;quot;&lt;br /&gt;
set R [::math::linearalgebra::mkRandom 3]&lt;br /&gt;
puts &amp;quot;R = \n[::math::linearalgebra::show $R]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Get the 2nd column from the matrix R.&lt;br /&gt;
puts &amp;quot;Get the 2nd column from the matrix R.&amp;quot;&lt;br /&gt;
set c2 [::math::linearalgebra::getcol $R 1]&lt;br /&gt;
puts &amp;quot;c2 = \n[::math::linearalgebra::show $c2]&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you run the script, the result will look like the following.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ./matrix.tcl &lt;br /&gt;
Tcl script name: ./matrix.tcl, with 0 arguments&lt;br /&gt;
&lt;br /&gt;
Durer&amp;#039;s magic square&lt;br /&gt;
A = &lt;br /&gt;
16  3  2 13 &lt;br /&gt;
 5 10 11  8 &lt;br /&gt;
 9  6  7 12 &lt;br /&gt;
 4 15 14  1 &lt;br /&gt;
&lt;br /&gt;
Transpose of the matrix A, At =&lt;br /&gt;
16  5  9  4 &lt;br /&gt;
 3 10  6 15 &lt;br /&gt;
 2 11  7 14 &lt;br /&gt;
13  8 12  1 &lt;br /&gt;
&lt;br /&gt;
A + At =&lt;br /&gt;
32  8 11 17 &lt;br /&gt;
 8 20 17 23 &lt;br /&gt;
11 17 14 26 &lt;br /&gt;
17 23 26  2 &lt;br /&gt;
&lt;br /&gt;
At * A =&lt;br /&gt;
378.0000 212.0000 206.0000 360.0000 &lt;br /&gt;
212.0000 370.0000 368.0000 206.0000 &lt;br /&gt;
206.0000 368.0000 370.0000 212.0000 &lt;br /&gt;
360.0000 206.0000 212.0000 378.0000 &lt;br /&gt;
&lt;br /&gt;
det(A) = 0.&lt;br /&gt;
&lt;br /&gt;
Create a 3X3 matrix O whose elements are all zeros.&lt;br /&gt;
O = &lt;br /&gt;
0.0000 0.0000 0.0000 &lt;br /&gt;
0.0000 0.0000 0.0000 &lt;br /&gt;
0.0000 0.0000 0.0000 &lt;br /&gt;
&lt;br /&gt;
Create a 3X3 identity matrix I.&lt;br /&gt;
I = &lt;br /&gt;
1.0000 0.0000 0.0000 &lt;br /&gt;
0.0000 1.0000 0.0000 &lt;br /&gt;
0.0000 0.0000 1.0000 &lt;br /&gt;
&lt;br /&gt;
Create a 3X3 random matrix R.&lt;br /&gt;
R = &lt;br /&gt;
0.3562 0.3277 0.0830 &lt;br /&gt;
0.6627 0.9329 0.0609 &lt;br /&gt;
0.9916 0.1730 0.3524 &lt;br /&gt;
&lt;br /&gt;
Get the 2nd column from the matrix R.&lt;br /&gt;
c2 = &lt;br /&gt;
0.3277&lt;br /&gt;
0.9329&lt;br /&gt;
0.1730&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Tcl library can do more than what is explained here. Refer its documentation.&lt;/div&gt;</summary>
		<author><name>Kwkang</name></author>
	</entry>
</feed>