<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2608877327656008144</id><updated>2011-07-30T12:30:46.122-07:00</updated><title type='text'>Sean's Technology Classroom</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://tech-sean.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2608877327656008144/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://tech-sean.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Sean</name><uri>http://www.blogger.com/profile/13677521856282707821</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>24</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2608877327656008144.post-1773956208708719394</id><published>2011-02-22T07:32:00.000-08:00</published><updated>2011-02-22T07:33:42.133-08:00</updated><title type='text'>const_cast, static_cast, dynamic_cast, reinterpret_cast</title><content type='html'>const_cast&lt;br /&gt;&lt;br /&gt;T const_cast&lt;t&gt; (object)&lt;br /&gt;&lt;br /&gt;The const_cast keyword can be used to remove the const or volatile property from an object.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2608877327656008144-1773956208708719394?l=tech-sean.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-sean.blogspot.com/feeds/1773956208708719394/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2608877327656008144&amp;postID=1773956208708719394' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2608877327656008144/posts/default/1773956208708719394'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2608877327656008144/posts/default/1773956208708719394'/><link rel='alternate' type='text/html' href='http://tech-sean.blogspot.com/2011/02/constcast-staticcast-dynamiccast.html' title='const_cast, static_cast, dynamic_cast, reinterpret_cast'/><author><name>Sean</name><uri>http://www.blogger.com/profile/13677521856282707821</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2608877327656008144.post-4239797615682236863</id><published>2010-01-11T11:45:00.000-08:00</published><updated>2010-01-11T11:49:23.222-08:00</updated><title type='text'>A good template function to cast string to numerical values</title><content type='html'>template &lt;class&gt;bool from_string(T&amp;amp; t, const std::string&amp;amp; s, std::ios_base&amp;amp; (*f)(std::ios_base&amp;amp;))&lt;br /&gt;{&lt;br /&gt;std::istringstream iss(s);&lt;br /&gt;return !(iss &gt;&gt; f &gt;&gt; t).fail();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;usage:&lt;br /&gt;&lt;br /&gt;float f;&lt;br /&gt;&lt;br /&gt;from_string&lt;float&gt;(f, std::string("123.456"), std::dec);&lt;br /&gt;&lt;br /&gt;output:&lt;br /&gt;f = 123.456&lt;br /&gt;&lt;br /&gt;need to #include sstream&lt;sstream&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2608877327656008144-4239797615682236863?l=tech-sean.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-sean.blogspot.com/feeds/4239797615682236863/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2608877327656008144&amp;postID=4239797615682236863' title='9 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2608877327656008144/posts/default/4239797615682236863'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2608877327656008144/posts/default/4239797615682236863'/><link rel='alternate' type='text/html' href='http://tech-sean.blogspot.com/2010/01/good-template-function-to-cast-string.html' title='A good template function to cast string to numerical values'/><author><name>Sean</name><uri>http://www.blogger.com/profile/13677521856282707821</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>9</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2608877327656008144.post-1911459987247166494</id><published>2008-11-13T09:37:00.000-08:00</published><updated>2008-11-13T09:38:01.827-08:00</updated><title type='text'>Clustering: Self-Organizing Map (SOM)</title><content type='html'>The Self-Organizing Map (SOM) is a clustering algorithm that is used to map a multi-dimensional dataset onto a (typically) two-dimensional surface. This surface (a map) is an ordered interpretation of the probability distribution of the available genes/samples of the input dataset. SOMs have been used extensively in many domains, including the exploratory data analysis of gene expression patterns.&lt;br /&gt;There are two particularly useful purposes for this: visualization and cluster analysis. Visualization has typically been a difficult matter for high-dimensional data. SOMs can be used to explore the groupings and relations within such data by projecting the data on to a two-dimensional image that clearly indicates regions of similarity. Even if visualization is not the goal of applying SOM to a dataset, the clustering ability of the SOM is very useful.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2608877327656008144-1911459987247166494?l=tech-sean.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-sean.blogspot.com/feeds/1911459987247166494/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2608877327656008144&amp;postID=1911459987247166494' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2608877327656008144/posts/default/1911459987247166494'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2608877327656008144/posts/default/1911459987247166494'/><link rel='alternate' type='text/html' href='http://tech-sean.blogspot.com/2008/11/clustering-self-organizing-map-som.html' title='Clustering: Self-Organizing Map (SOM)'/><author><name>Sean</name><uri>http://www.blogger.com/profile/13677521856282707821</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2608877327656008144.post-1961442932770660381</id><published>2008-08-05T03:18:00.000-07:00</published><updated>2008-08-05T03:20:48.115-07:00</updated><title type='text'>MPEG 7 Standard</title><content type='html'>MPEG-7, formally named “Multimedia Content Description Interface”, is a standard for describing the multimedia content  data that supports some degree of interpretation of the information’s meaning, which can be passed onto, or accessed by, a device or a computer code. MPEG-7 is not aimed at any one application in particular; rather, the elements that MPEG-7 standardizes support as broad a range of applications as possible.&lt;br /&gt;&lt;br /&gt;    The elements that MPEG-7 standardizes provide support to a broad range of applications (for example, multimedia digital libraries, broadcast media selection, multimedia editing, home entertainment devices, etc.). MPEG-7 will also make the web as searchable for multimedia content as it is searchable for text today. This would apply especially to large content archives, which are being made accessible to the public, as well as to multimedia catalogues enabling people to identify content for purchase.&lt;br /&gt;&lt;br /&gt;OBJECTIVES OF MPEG-7 STANDARD&lt;br /&gt;&lt;br /&gt;    The MPEG-7 standard aims at providing standardized core technologies allowing description of audiovisual data content in multimedia environments. Audiovisual data content that has MPEG-7 data associated with it, may include: still pictures, graphics, 3D models, audio, speech, video, and composition information about how these elements are combined in a multimedia presentation (scenarios). Special cases of these general data types may include facial expressions and personal characteristics .&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2608877327656008144-1961442932770660381?l=tech-sean.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-sean.blogspot.com/feeds/1961442932770660381/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2608877327656008144&amp;postID=1961442932770660381' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2608877327656008144/posts/default/1961442932770660381'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2608877327656008144/posts/default/1961442932770660381'/><link rel='alternate' type='text/html' href='http://tech-sean.blogspot.com/2008/08/mpeg-7-standard.html' title='MPEG 7 Standard'/><author><name>Sean</name><uri>http://www.blogger.com/profile/13677521856282707821</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2608877327656008144.post-4316655240889999924</id><published>2008-07-17T03:09:00.000-07:00</published><updated>2008-07-17T03:11:38.941-07:00</updated><title type='text'>Geometric meaning of SVD</title><content type='html'>&lt;h2&gt;&lt;span style="font-weight: normal;font-size:85%;" &gt;From Wikimedia&lt;/span&gt;&lt;br /&gt;&lt;span class="mw-headline"&gt;&lt;/span&gt;&lt;/h2&gt; &lt;p&gt;Because &lt;i&gt;U&lt;/i&gt; and &lt;i&gt;V&lt;/i&gt; are unitary, we know that the columns &lt;i&gt;u&lt;/i&gt;&lt;sub&gt;1&lt;/sub&gt;,...,&lt;i&gt;u&lt;sub&gt;m&lt;/sub&gt;&lt;/i&gt; of &lt;i&gt;U&lt;/i&gt; yield an &lt;a href="http://en.wikipedia.org/wiki/Orthonormal_basis" title="Orthonormal basis"&gt;orthonormal basis&lt;/a&gt; of &lt;i&gt;K&lt;/i&gt;&lt;sup&gt;&lt;i&gt;m&lt;/i&gt;&lt;/sup&gt; and the columns &lt;i&gt;v&lt;/i&gt;&lt;sub&gt;1&lt;/sub&gt;,...,&lt;i&gt;v&lt;sub&gt;n&lt;/sub&gt;&lt;/i&gt; of &lt;i&gt;V&lt;/i&gt; yield an orthonormal basis of &lt;i&gt;K&lt;/i&gt;&lt;sup&gt;&lt;i&gt;n&lt;/i&gt;&lt;/sup&gt; (with respect to the standard &lt;a href="http://en.wikipedia.org/wiki/Scalar_product" class="mw-redirect" title="Scalar product"&gt;scalar products&lt;/a&gt; on these spaces).&lt;/p&gt; &lt;p&gt;The &lt;a href="http://en.wikipedia.org/wiki/Linear_transformation" class="mw-redirect" title="Linear transformation"&gt;linear transformation&lt;/a&gt; &lt;i&gt;T&lt;/i&gt; :&lt;i&gt;K&lt;/i&gt;&lt;sup&gt;&lt;i&gt;n&lt;/i&gt;&lt;/sup&gt; → &lt;i&gt;K&lt;/i&gt;&lt;sup&gt;&lt;i&gt;m&lt;/i&gt;&lt;/sup&gt; that takes a vector &lt;i&gt;x&lt;/i&gt; to &lt;i&gt;Mx&lt;/i&gt; has a particularly simple description with respect to these orthonormal bases: we have &lt;i&gt;T&lt;/i&gt;(&lt;i&gt;v&lt;sub&gt;i&lt;/sub&gt;&lt;/i&gt;) = &lt;i&gt;σ&lt;sub&gt;i&lt;/sub&gt; u&lt;sub&gt;i&lt;/sub&gt;&lt;/i&gt;, for &lt;i&gt;i&lt;/i&gt; = 1,...,min(&lt;i&gt;m&lt;/i&gt;,&lt;i&gt;n&lt;/i&gt;), where &lt;i&gt;σ&lt;sub&gt;i&lt;/sub&gt;&lt;/i&gt; is the &lt;i&gt;i&lt;/i&gt;-th diagonal entry of Σ, and &lt;i&gt;T&lt;/i&gt;(&lt;i&gt;v&lt;/i&gt;&lt;sub&gt;&lt;i&gt;i&lt;/i&gt;&lt;/sub&gt;) = 0 for &lt;i&gt;i&lt;/i&gt; &gt; min(&lt;i&gt;m&lt;/i&gt;,&lt;i&gt;n&lt;/i&gt;).&lt;/p&gt; &lt;p&gt;The geometric content of the SVD theorem can thus be summarized as follows: for every linear map &lt;i&gt;T&lt;/i&gt; :&lt;i&gt;K&lt;/i&gt;&lt;sup&gt;&lt;i&gt;n&lt;/i&gt;&lt;/sup&gt; → &lt;i&gt;K&lt;/i&gt;&lt;sup&gt;&lt;i&gt;m&lt;/i&gt;&lt;/sup&gt; one can find orthonormal bases of &lt;i&gt;K&lt;/i&gt;&lt;sup&gt;&lt;i&gt;n&lt;/i&gt;&lt;/sup&gt; and &lt;i&gt;K&lt;/i&gt;&lt;sup&gt;&lt;i&gt;m&lt;/i&gt;&lt;/sup&gt; such that &lt;i&gt;T&lt;/i&gt; maps the &lt;i&gt;i&lt;/i&gt;-th basis vector of &lt;i&gt;K&lt;/i&gt;&lt;sup&gt;&lt;i&gt;n&lt;/i&gt;&lt;/sup&gt; to a non-negative multiple of the &lt;i&gt;i&lt;/i&gt;-th basis vector of &lt;i&gt;K&lt;/i&gt;&lt;sup&gt;&lt;i&gt;m&lt;/i&gt;&lt;/sup&gt;, and sends the left-over basis vectors to zero. With respect to these bases, the map &lt;i&gt;T&lt;/i&gt; is therefore represented by a diagonal matrix with non-negative real diagonal entries.&lt;/p&gt; &lt;p&gt;To get a more visual flavour of singular values and SVD decomposition —at least when working on real vector spaces— consider the sphere &lt;i&gt;S&lt;/i&gt; of radius one in &lt;b&gt;R&lt;/b&gt;&lt;sup&gt;&lt;i&gt;n&lt;/i&gt;&lt;/sup&gt;. The linear map &lt;i&gt;T&lt;/i&gt; maps this sphere onto an &lt;a href="http://en.wikipedia.org/wiki/Ellipsoid" title="Ellipsoid"&gt;ellipsoid&lt;/a&gt; in &lt;b&gt;R&lt;/b&gt;&lt;sup&gt;&lt;i&gt;m&lt;/i&gt;&lt;/sup&gt;. Non-zero singular values are simply the lengths of the &lt;a href="http://en.wikipedia.org/wiki/Semi-minor_axis" title="Semi-minor axis"&gt;semi-axes&lt;/a&gt; of this ellipsoid. Especially when &lt;i&gt;n&lt;/i&gt;=&lt;i&gt;m&lt;/i&gt;, and all the singular values are distinct and non-zero, the SVD decomposition of the linear map &lt;i&gt;T&lt;/i&gt; can be easily analysed as a succession of three consecutive moves : consider the ellipsoid &lt;i&gt;T&lt;/i&gt;(&lt;i&gt;S&lt;/i&gt;) and specifically its axes ; then consider the directions in &lt;b&gt;R&lt;/b&gt;&lt;sup&gt;&lt;i&gt;n&lt;/i&gt;&lt;/sup&gt; sent by &lt;i&gt;T&lt;/i&gt; onto these axes. These directions happen to be mutually orthogonal. Apply first an isometry &lt;i&gt;v*&lt;/i&gt; sending these directions to the coordinate axes of &lt;b&gt;R&lt;/b&gt;&lt;sup&gt;&lt;i&gt;n&lt;/i&gt;&lt;/sup&gt;. On a second move, apply an endomorphism &lt;i&gt;d&lt;/i&gt; diagonalized along the coordinate axes and stretching or shrinking in each direction, using the semi-axes lengths of &lt;i&gt;T&lt;/i&gt;(&lt;i&gt;S&lt;/i&gt;) as stretching coefficients. The composition &lt;i&gt;d&lt;/i&gt; &lt;small&gt;o&lt;/small&gt; &lt;i&gt;v*&lt;/i&gt; then sends the unit-sphere onto an ellipsoid isometric to &lt;i&gt;T&lt;/i&gt;(&lt;i&gt;S&lt;/i&gt;). To define the third and last move &lt;i&gt;u&lt;/i&gt;, just apply an isometry to this ellipsoid so as to carry it over &lt;i&gt;T&lt;/i&gt;(&lt;i&gt;S&lt;/i&gt;). As can be easily checked, the composition &lt;i&gt;u&lt;/i&gt; &lt;small&gt;o&lt;/small&gt; &lt;i&gt;d&lt;/i&gt; &lt;small&gt;o&lt;/small&gt; &lt;i&gt;v*&lt;/i&gt; coincides with &lt;i&gt;T&lt;/i&gt;.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2608877327656008144-4316655240889999924?l=tech-sean.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-sean.blogspot.com/feeds/4316655240889999924/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2608877327656008144&amp;postID=4316655240889999924' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2608877327656008144/posts/default/4316655240889999924'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2608877327656008144/posts/default/4316655240889999924'/><link rel='alternate' type='text/html' href='http://tech-sean.blogspot.com/2008/07/geometric-meaning-of-svd.html' title='Geometric meaning of SVD'/><author><name>Sean</name><uri>http://www.blogger.com/profile/13677521856282707821</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2608877327656008144.post-6785031093025212774</id><published>2008-07-17T03:03:00.000-07:00</published><updated>2008-07-17T03:05:17.168-07:00</updated><title type='text'>Endomorphism</title><content type='html'>From Wikipedia&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;Endomorphism&lt;/span&gt;&lt;br /&gt;&lt;p&gt;In &lt;a href="http://en.wikipedia.org/wiki/Mathematics" title="Mathematics"&gt;mathematics&lt;/a&gt;, an &lt;b&gt;endomorphism&lt;/b&gt; is a &lt;a href="http://en.wikipedia.org/wiki/Morphism" title="Morphism"&gt;morphism&lt;/a&gt; (or &lt;a href="http://en.wikipedia.org/wiki/Homomorphism" title="Homomorphism"&gt;homomorphism&lt;/a&gt;) from a mathematical object to itself. For example, an endomorphism of a &lt;a href="http://en.wikipedia.org/wiki/Vector_space" title="Vector space"&gt;vector space&lt;/a&gt; &lt;i&gt;V&lt;/i&gt; is a &lt;a href="http://en.wikipedia.org/wiki/Linear_map" title="Linear map"&gt;linear map&lt;/a&gt; ƒ: &lt;i&gt;V&lt;/i&gt; → &lt;i&gt;V&lt;/i&gt; and an endomorphism of a &lt;a href="http://en.wikipedia.org/wiki/Group_%28mathematics%29" title="Group (mathematics)"&gt;group&lt;/a&gt; &lt;i&gt;G&lt;/i&gt; is a &lt;a href="http://en.wikipedia.org/wiki/Group_homomorphism" title="Group homomorphism"&gt;group homomorphism&lt;/a&gt; ƒ: &lt;i&gt;G&lt;/i&gt; → &lt;i&gt;G&lt;/i&gt;, etc. In general, we can talk about endomorphisms in any &lt;a href="http://en.wikipedia.org/wiki/Category_theory" title="Category theory"&gt;category&lt;/a&gt;. In the category of &lt;a href="http://en.wikipedia.org/wiki/Set" title="Set"&gt;sets&lt;/a&gt;, endomorphisms are simply functions from a set &lt;i&gt;S&lt;/i&gt; into itself.&lt;/p&gt; &lt;p&gt;In any category, the &lt;a href="http://en.wikipedia.org/wiki/Function_composition" title="Function composition"&gt;composition&lt;/a&gt; of any two endomorphisms of &lt;i&gt;X&lt;/i&gt; is again an endomorphism of &lt;i&gt;X&lt;/i&gt;. It follows that the &lt;a href="http://en.wikipedia.org/wiki/Set" title="Set"&gt;set&lt;/a&gt; of all endomorphisms of &lt;i&gt;X&lt;/i&gt; forms a &lt;a href="http://en.wikipedia.org/wiki/Monoid" title="Monoid"&gt;monoid&lt;/a&gt;, denoted End(&lt;i&gt;X&lt;/i&gt;) (or End&lt;sub&gt;&lt;i&gt;C&lt;/i&gt;&lt;/sub&gt;(&lt;i&gt;X&lt;/i&gt;) to emphasize the category &lt;i&gt;C&lt;/i&gt;).&lt;/p&gt; &lt;p&gt;An &lt;a href="http://en.wikipedia.org/wiki/Inverse_element" title="Inverse element"&gt;invertible&lt;/a&gt; endomorphism of &lt;i&gt;X&lt;/i&gt; is called an &lt;a href="http://en.wikipedia.org/wiki/Automorphism" title="Automorphism"&gt;automorphism&lt;/a&gt;. The set of all automorphisms is a &lt;a href="http://en.wikipedia.org/wiki/Subgroup" title="Subgroup"&gt;subgroup&lt;/a&gt; of End(&lt;i&gt;X&lt;/i&gt;), called the &lt;a href="http://en.wikipedia.org/wiki/Automorphism_group" class="mw-redirect" title="Automorphism group"&gt;automorphism group&lt;/a&gt; of &lt;i&gt;X&lt;/i&gt; and denoted Aut(&lt;i&gt;X&lt;/i&gt;). In the following diagram, the arrows denote implication:&lt;/p&gt; &lt;table border="0"&gt; &lt;tbody&gt;&lt;tr&gt; &lt;td align="center" width="42%"&gt;&lt;a href="http://en.wikipedia.org/wiki/Automorphism" title="Automorphism"&gt;automorphism&lt;/a&gt;&lt;/td&gt; &lt;td align="center" width="16%"&gt;&lt;img class="tex" alt="\Rightarrow" src="http://upload.wikimedia.org/math/d/f/0/df09aea884019cb88a2957126faba316.png" /&gt;&lt;/td&gt; &lt;td align="center" width="42%"&gt;&lt;a href="http://en.wikipedia.org/wiki/Isomorphism" title="Isomorphism"&gt;isomorphism&lt;/a&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td align="center"&gt;&lt;img class="tex" alt="\Downarrow" src="http://upload.wikimedia.org/math/a/5/8/a5855048483c40e8ffeac0646476f178.png" /&gt;&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt; &lt;td align="center"&gt;&lt;img class="tex" alt="\Downarrow" src="http://upload.wikimedia.org/math/a/5/8/a5855048483c40e8ffeac0646476f178.png" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td align="center"&gt;endomorphism&lt;/td&gt; &lt;td align="center"&gt;&lt;img class="tex" alt="\Rightarrow" src="http://upload.wikimedia.org/math/d/f/0/df09aea884019cb88a2957126faba316.png" /&gt;&lt;/td&gt; &lt;td align="center"&gt;&lt;a href="http://en.wikipedia.org/wiki/Homomorphism" title="Homomorphism"&gt;(homo)morphism&lt;/a&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt; &lt;p&gt;Any two endomorphisms of an &lt;a href="http://en.wikipedia.org/wiki/Abelian_group" title="Abelian group"&gt;abelian group&lt;/a&gt; &lt;i&gt;A&lt;/i&gt; can be added together by the rule (ƒ + &lt;i&gt;g&lt;/i&gt;)(&lt;i&gt;a&lt;/i&gt;) = ƒ(&lt;i&gt;a&lt;/i&gt;) + &lt;i&gt;g&lt;/i&gt;(&lt;i&gt;a&lt;/i&gt;). Under this addition, the endomorphisms of an abelian group form a &lt;a href="http://en.wikipedia.org/wiki/Ring_%28mathematics%29" title="Ring (mathematics)"&gt;ring&lt;/a&gt; (the &lt;a href="http://en.wikipedia.org/wiki/Endomorphism_ring" title="Endomorphism ring"&gt;endomorphism ring&lt;/a&gt;). For example, the set of endomorphisms of &lt;b&gt;Z&lt;/b&gt;&lt;sup&gt;&lt;i&gt;n&lt;/i&gt;&lt;/sup&gt; is the ring of all &lt;i&gt;n&lt;/i&gt; × &lt;i&gt;n&lt;/i&gt; matrices with integer entries. The endomorphisms of a vector space, &lt;a href="http://en.wikipedia.org/wiki/Module_%28mathematics%29" title="Module (mathematics)"&gt;module&lt;/a&gt;, ring, or &lt;a href="http://en.wikipedia.org/wiki/Algebra_%28ring_theory%29" title="Algebra (ring theory)"&gt;algebra&lt;/a&gt; also form a ring, as do the endomorphisms of any object in a &lt;a href="http://en.wikipedia.org/wiki/Preadditive_category" title="Preadditive category"&gt;preadditive category&lt;/a&gt;. The endomorphisms of a nonabelian group generate an algebraic structure known as a &lt;a href="http://en.wikipedia.org/wiki/Nearring" title="Nearring"&gt;nearring&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;&lt;a name="Operator_theory" id="Operator_theory"&gt;&lt;/a&gt;&lt;/p&gt; &lt;h2&gt;&lt;span class="editsection"&gt;&lt;/span&gt;&lt;span style="font-weight: normal;font-size:130%;" &gt;&lt;span class="mw-headline"&gt;Operator theory&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt; &lt;p&gt;In any &lt;a href="http://en.wikipedia.org/wiki/Concrete_category" title="Concrete category"&gt;concrete category&lt;/a&gt;, especially for &lt;a href="http://en.wikipedia.org/wiki/Vector_space" title="Vector space"&gt;vector spaces&lt;/a&gt;, endomorphisms are maps from a set into itself, and may be interpreted as &lt;a href="http://en.wikipedia.org/wiki/Unary_operator" class="mw-redirect" title="Unary operator"&gt;unary operators&lt;/a&gt; on that set, &lt;a href="http://en.wikipedia.org/wiki/Action_%28group_theory%29" class="mw-redirect" title="Action (group theory)"&gt;acting&lt;/a&gt; on the elements, and allowing to define the notion of &lt;a href="http://en.wikipedia.org/wiki/Orbit_%28group_theory%29" class="mw-redirect" title="Orbit (group theory)"&gt;orbits&lt;/a&gt; of elements, etc.&lt;/p&gt; &lt;p&gt;Depending on the additional structure defined for the category at hand (&lt;a href="http://en.wikipedia.org/wiki/Topology" title="Topology"&gt;topology&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Metric_%28mathematics%29" title="Metric (mathematics)"&gt;metric&lt;/a&gt;, ...), such operators can have properties like &lt;a href="http://en.wikipedia.org/wiki/Continuous_function_%28topology%29" title="Continuous function (topology)"&gt;continuity&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Boundedness" title="Boundedness"&gt;boundedness&lt;/a&gt;, and so on. More details should be found in the article about &lt;a href="http://en.wikipedia.org/wiki/Operator_theory" title="Operator theory"&gt;operator theory&lt;/a&gt;.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2608877327656008144-6785031093025212774?l=tech-sean.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-sean.blogspot.com/feeds/6785031093025212774/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2608877327656008144&amp;postID=6785031093025212774' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2608877327656008144/posts/default/6785031093025212774'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2608877327656008144/posts/default/6785031093025212774'/><link rel='alternate' type='text/html' href='http://tech-sean.blogspot.com/2008/07/endomorphism.html' title='Endomorphism'/><author><name>Sean</name><uri>http://www.blogger.com/profile/13677521856282707821</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2608877327656008144.post-5787037921216092842</id><published>2008-07-17T02:59:00.000-07:00</published><updated>2008-07-17T03:00:08.419-07:00</updated><title type='text'>Isometry</title><content type='html'>&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;From Wikipedia&lt;br /&gt;&lt;/p&gt;&lt;p&gt;In &lt;a href="http://en.wikipedia.org/wiki/Mathematics" title="Mathematics"&gt;mathematics&lt;/a&gt;, an &lt;b&gt;isometry&lt;/b&gt;, &lt;b&gt;isometric isomorphism&lt;/b&gt; or &lt;b&gt;congruence mapping&lt;/b&gt; is a &lt;a href="http://en.wikipedia.org/wiki/Distance" title="Distance"&gt;distance&lt;/a&gt;-preserving &lt;a href="http://en.wikipedia.org/wiki/Isomorphism" title="Isomorphism"&gt;isomorphism&lt;/a&gt; between &lt;a href="http://en.wikipedia.org/wiki/Metric_spaces" class="mw-redirect" title="Metric spaces"&gt;metric spaces&lt;/a&gt;. Geometric figures which can be related by an isometry are called &lt;a href="http://en.wikipedia.org/wiki/Congruence_%28geometry%29" title="Congruence (geometry)"&gt;congruent&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;Isometries are often used in constructions where one space is &lt;a href="http://en.wikipedia.org/wiki/Embedding" title="Embedding"&gt;embedded&lt;/a&gt; in another space. For instance, the &lt;a href="http://en.wikipedia.org/wiki/Complete_space#Completion" class="mw-redirect" title="Complete space"&gt;completion&lt;/a&gt; of a metric space &lt;i&gt;M&lt;/i&gt; involves an isometry from &lt;i&gt;M&lt;/i&gt; into &lt;i&gt;M'&lt;/i&gt;, a &lt;a href="http://en.wikipedia.org/wiki/Quotient_set" class="mw-redirect" title="Quotient set"&gt;quotient set&lt;/a&gt; of the space of &lt;a href="http://en.wikipedia.org/wiki/Cauchy_sequence" title="Cauchy sequence"&gt;Cauchy sequences&lt;/a&gt; on &lt;i&gt;M&lt;/i&gt;. The original space &lt;i&gt;M&lt;/i&gt; is thus isometrically isomorphic to a subspace of a &lt;a href="http://en.wikipedia.org/wiki/Complete_metric_space" title="Complete metric space"&gt;complete metric space&lt;/a&gt;, and it is usually identified with this subspace. Other embedding constructions show that every metric space is isometrically isomorphic to a &lt;a href="http://en.wikipedia.org/wiki/Closed_set" title="Closed set"&gt;closed subset&lt;/a&gt; of some &lt;a href="http://en.wikipedia.org/wiki/Normed_vector_space" title="Normed vector space"&gt;normed vector space&lt;/a&gt; and that every complete metric space is isometrically isomorphic to a closed subset of some &lt;a href="http://en.wikipedia.org/wiki/Banach_space" title="Banach space"&gt;Banach space&lt;/a&gt;.&lt;/p&gt;&lt;h2&gt;&lt;span class="mw-headline"&gt;Definitions&lt;/span&gt;&lt;/h2&gt; &lt;p&gt;The notion of isometry comes in two main flavors: &lt;i&gt;global isometry&lt;/i&gt; and a weaker notion &lt;i&gt;path isometry&lt;/i&gt; or &lt;i&gt;arcwise isometry&lt;/i&gt;. Both are often called just &lt;i&gt;isometry&lt;/i&gt; and one should determine from context which one is intended.&lt;/p&gt; &lt;p&gt;Let &lt;i&gt;X&lt;/i&gt; and &lt;i&gt;Y&lt;/i&gt; be &lt;a href="http://en.wikipedia.org/wiki/Metric_space" title="Metric space"&gt;metric spaces&lt;/a&gt; with metrics &lt;i&gt;d&lt;/i&gt;&lt;sub&gt;&lt;i&gt;Y&lt;/i&gt;&lt;/sub&gt; and &lt;i&gt;d&lt;/i&gt;&lt;sub&gt;&lt;i&gt;X&lt;/i&gt;&lt;/sub&gt;. A &lt;a href="http://en.wikipedia.org/wiki/Function_%28mathematics%29" title="Function (mathematics)"&gt;map&lt;/a&gt; ƒ : &lt;i&gt;X&lt;/i&gt; → &lt;i&gt;Y&lt;/i&gt; is called &lt;b&gt;distance preserving&lt;/b&gt; if for any &lt;i&gt;x&lt;/i&gt;,&lt;i&gt;y&lt;/i&gt; ∈ &lt;i&gt;X&lt;/i&gt; one has&lt;/p&gt; &lt;dl&gt;&lt;dd&gt;&lt;img class="tex" alt="d_Y\left(f(x),f(y)\right)=d_X(x,y)." src="http://upload.wikimedia.org/math/9/6/c/96ce4024bb7fb8958dd2007eeb4f0f99.png" /&gt;&lt;/dd&gt;&lt;/dl&gt; &lt;p&gt;A distance preserving map is automatically &lt;a href="http://en.wikipedia.org/wiki/Injective" class="mw-redirect" title="Injective"&gt;injective&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;A &lt;b&gt;global isometry&lt;/b&gt; is a &lt;a href="http://en.wikipedia.org/wiki/Bijective" class="mw-redirect" title="Bijective"&gt;bijective&lt;/a&gt; distance preserving map. A &lt;b&gt;path isometry&lt;/b&gt; or &lt;b&gt;arcwise isometry&lt;/b&gt; is a map which preserves the &lt;a href="http://en.wikipedia.org/wiki/Curve" title="Curve"&gt;lengths of curves&lt;/a&gt; (not necessarily bijective).&lt;/p&gt; &lt;p&gt;Two metric spaces &lt;i&gt;X&lt;/i&gt; and &lt;i&gt;Y&lt;/i&gt; are called &lt;b&gt;isometric&lt;/b&gt; if there is an isometry from &lt;i&gt;X&lt;/i&gt; to &lt;i&gt;Y&lt;/i&gt;. The &lt;a href="http://en.wikipedia.org/wiki/Set" title="Set"&gt;set&lt;/a&gt; of isometries from a metric space to itself forms a &lt;a href="http://en.wikipedia.org/wiki/Group_%28mathematics%29" title="Group (mathematics)"&gt;group&lt;/a&gt; with respect to &lt;a href="http://en.wikipedia.org/wiki/Function_composition" title="Function composition"&gt;function composition&lt;/a&gt;, called the &lt;b&gt;&lt;a href="http://en.wikipedia.org/wiki/Isometry_group" title="Isometry group"&gt;isometry group&lt;/a&gt;&lt;/b&gt;.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2608877327656008144-5787037921216092842?l=tech-sean.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-sean.blogspot.com/feeds/5787037921216092842/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2608877327656008144&amp;postID=5787037921216092842' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2608877327656008144/posts/default/5787037921216092842'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2608877327656008144/posts/default/5787037921216092842'/><link rel='alternate' type='text/html' href='http://tech-sean.blogspot.com/2008/07/isometry.html' title='Isometry'/><author><name>Sean</name><uri>http://www.blogger.com/profile/13677521856282707821</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2608877327656008144.post-4952190359259497772</id><published>2008-07-15T02:10:00.000-07:00</published><updated>2008-07-15T02:15:21.822-07:00</updated><title type='text'>GOP (Group Of Pictures)</title><content type='html'>From Wikipedia&lt;br /&gt;&lt;br /&gt;In MPEG encoding, a group of pictures, or GOP, specifies the order in which intra-frames and inter frames are arranged.&lt;br /&gt;&lt;br /&gt;The GOP is a group of successive pictures within an MPEG-coded video stream. Each MPEG-coded video stream consists of successive GOPs. From the MPEG pictures contained in it the visible frames are generated.&lt;br /&gt;&lt;br /&gt;A GOP can contain the following picture types:&lt;br /&gt;&lt;br /&gt;I-picture or I-frame (intra coded picture) reference picture, corresponds to a fixed image and is independent of other picture types. Each GOP begins with this type of picture.&lt;br /&gt;P-picture or P-frame (predictive coded picture) contains motion-compensated difference information from the preceding I- or P-frame.&lt;br /&gt;B-picture or B-frame (bidirectionally predictive coded picture) contains difference information from the preceding and following I- or P-frame within a GOP.&lt;br /&gt;D-picture or D-frame (DC direct coded picture) serves the fast advance.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;A GOP always begins with an I-frame&lt;/strong&gt;. Afterwards several P-frames follow, in each case with some frames distance. In the remaining gaps are B-frames. With the next I-frame a new GOP begins.&lt;br /&gt;&lt;br /&gt;The GOP structure is often referred by two numbers, for example M=3, N=12. The first one tells the distance between two anchor frames (I or P). The second one tells the distance between two full images (I-frames), it is the &lt;strong&gt;GOP length&lt;/strong&gt;. For the above example, the GOP structure is IBBPBBPBBPBB. Instead of the M parameter one can use the maximal count of B-frames between two consecutive anchor frames.&lt;br /&gt;&lt;br /&gt;The more I-frames the MPEG stream has, the more it is editable. However, having more I-frames increases the stream size. In order to save bandwidth and disk space, videos prepared for internet broadcast often have only one I-frame per GOP.&lt;br /&gt;&lt;br /&gt;The I-frames contain the full image, they don't require any additional information to reconstruct the image. Therefore any errors in the streams are corrected by the next I-frame (an error in the I-frame propagates until the next I-frame). Errors in the P-frames propagate until the next anchor frame (I or P). B-frames do not propagate errors.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2608877327656008144-4952190359259497772?l=tech-sean.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-sean.blogspot.com/feeds/4952190359259497772/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2608877327656008144&amp;postID=4952190359259497772' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2608877327656008144/posts/default/4952190359259497772'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2608877327656008144/posts/default/4952190359259497772'/><link rel='alternate' type='text/html' href='http://tech-sean.blogspot.com/2008/07/gop-group-of-pictures.html' title='GOP (Group Of Pictures)'/><author><name>Sean</name><uri>http://www.blogger.com/profile/13677521856282707821</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2608877327656008144.post-800357374782191112</id><published>2008-07-14T06:08:00.000-07:00</published><updated>2008-07-14T06:11:31.235-07:00</updated><title type='text'>How to Write a Video Player in Less Than 1000 Lines</title><content type='html'>This is an amazing tutorial of how to use ffmpeg library and SDL to write your OWN video media player~ and it really works! Plus use QT, you may design your own graphic UI as beautiful as you can....&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.dranger.com/ffmpeg/"&gt;http://www.dranger.com/ffmpeg/&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2608877327656008144-800357374782191112?l=tech-sean.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-sean.blogspot.com/feeds/800357374782191112/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2608877327656008144&amp;postID=800357374782191112' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2608877327656008144/posts/default/800357374782191112'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2608877327656008144/posts/default/800357374782191112'/><link rel='alternate' type='text/html' href='http://tech-sean.blogspot.com/2008/07/ffmpeg-and-sdl-tutorial-or-how-to-write.html' title='How to Write a Video Player in Less Than 1000 Lines'/><author><name>Sean</name><uri>http://www.blogger.com/profile/13677521856282707821</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2608877327656008144.post-8142372267670451291</id><published>2008-07-11T06:44:00.000-07:00</published><updated>2008-07-11T06:52:56.074-07:00</updated><title type='text'>How to find median value of a given two-dimensional array??</title><content type='html'>Find median is a piece of cake in matlab, but a little bit tricky when comes to C++..&lt;br /&gt;&lt;br /&gt;Usually, you need to implement a sort algorithm then find the median as in the middle of the sorted array...&lt;br /&gt;&lt;br /&gt;I found the easiest way of doing it is using STL (Standard Template Library).&lt;br /&gt;&lt;br /&gt;Here is the method,&lt;br /&gt;&lt;br /&gt;for example, you have a two dimensional array&lt;br /&gt;&lt;br /&gt;double mydata[mb_width][mb_height];&lt;br /&gt;&lt;br /&gt;and you like to find the median value of this array..&lt;br /&gt;&lt;br /&gt;To use STL library, you first have to include the header file algorithm.h&lt;br /&gt;&lt;br /&gt;#include "algorithm.h"&lt;br /&gt;&lt;br /&gt;then define a vector mytheta:&lt;br /&gt;&lt;br /&gt;vector &lt;double&gt; mytheta;&lt;br /&gt;   &lt;br /&gt;pass value from mydata to mytheta;&lt;br /&gt;&lt;br /&gt;for (int i=0;i&lt; mb_width;i++){&lt;br /&gt;          for (int j=0;j&lt; mb_height;j++){&lt;br /&gt;         mytheta.push_back( mydata[i][j]);&lt;br /&gt;          }&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;Then you are free to use sort()&lt;br /&gt;&lt;br /&gt;sort(mytheta.begin(), mytheta.end());&lt;br /&gt;   &lt;br /&gt;And here is the median:&lt;br /&gt;&lt;br /&gt;median= *(mytheta.begin()+mytheta.size()/2);&lt;br /&gt;&lt;br /&gt;Easy, hr?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2608877327656008144-8142372267670451291?l=tech-sean.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-sean.blogspot.com/feeds/8142372267670451291/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2608877327656008144&amp;postID=8142372267670451291' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2608877327656008144/posts/default/8142372267670451291'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2608877327656008144/posts/default/8142372267670451291'/><link rel='alternate' type='text/html' href='http://tech-sean.blogspot.com/2008/07/how-to-find-median-value-of-given-two.html' title='How to find median value of a given two-dimensional array??'/><author><name>Sean</name><uri>http://www.blogger.com/profile/13677521856282707821</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2608877327656008144.post-7993845514787504715</id><published>2008-07-09T02:13:00.000-07:00</published><updated>2008-07-14T06:14:49.046-07:00</updated><title type='text'>SDL (Simple Directmedia Layer) Library</title><content type='html'>&lt;p&gt; Simple DirectMedia Layer is a cross-platform multimedia library designed to provide low level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL, and 2D video framebuffer. It is used by MPEG playback software, emulators, and many popular games, including the award winning Linux port of "Civilization: Call To Power." &lt;/p&gt;   &lt;p&gt; SDL supports Linux, Windows, Windows CE, BeOS, MacOS, Mac OS X, FreeBSD, NetBSD, OpenBSD, BSD/OS, Solaris, IRIX, and QNX. The code contains support for AmigaOS, Dreamcast, Atari, AIX, OSF/Tru64, RISC OS, SymbianOS, and OS/2, but these are not officially supported. &lt;/p&gt;   &lt;p&gt; SDL is written in C, but works with C++ natively, and has bindings to several other languages, including Ada, C#, D, Eiffel, Erlang, Euphoria, Guile, Haskell, Java, Lisp, Lua, ML, Objective C, Pascal, Perl, PHP, Pike, Pliant, Python, Ruby, Smalltalk, and Tcl. &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2608877327656008144-7993845514787504715?l=tech-sean.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-sean.blogspot.com/feeds/7993845514787504715/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2608877327656008144&amp;postID=7993845514787504715' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2608877327656008144/posts/default/7993845514787504715'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2608877327656008144/posts/default/7993845514787504715'/><link rel='alternate' type='text/html' href='http://tech-sean.blogspot.com/2008/07/sdl-simple-directmedia-layer.html' title='SDL (Simple Directmedia Layer) Library'/><author><name>Sean</name><uri>http://www.blogger.com/profile/13677521856282707821</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2608877327656008144.post-5173090060286211969</id><published>2008-07-08T10:12:00.000-07:00</published><updated>2008-07-08T10:31:02.310-07:00</updated><title type='text'>What a summary!!</title><content type='html'>Today I make a summary of all programs i wrote last month, which turned out&lt;br /&gt;to be a long list of files....feels good! :)&lt;br /&gt;&lt;br /&gt;*****************************************************************************************&lt;br /&gt;&lt;br /&gt;Experimental Summary (Under linux, using gcc, g++, and qt)&lt;br /&gt;&lt;br /&gt;*****************************************************************************************&lt;br /&gt;&lt;br /&gt;Excutable Program  C****** (****** main program)&lt;br /&gt;&lt;br /&gt;compiled by using&lt;br /&gt;&lt;br /&gt;g++ -o ******  ******.cpp ******.cpp ******.cpp ******.cpp ******.c ******.c -l***** -lav****t&lt;br /&gt;&lt;br /&gt;where **********.cpp calls 3 classes,&lt;br /&gt;&lt;br /&gt;class ****** has 2 files ( ******.cpp, ******.h)&lt;br /&gt;//class of Camera Motion Estimation, Motion Vector Extraction and drawing on frames,&lt;br /&gt;//saving frames to files.&lt;br /&gt;&lt;br /&gt;class ***** has 2 files (*****.cpp, *****.h)&lt;br /&gt;//class of adding captions to frame files, captions include camera motion information&lt;br /&gt;&lt;br /&gt;class ** has 2 files (**.cpp, **.h)&lt;br /&gt;//class of estimation minimum of a cost function based on Nelder_Mead algorithm.&lt;br /&gt;&lt;br /&gt;-l********:  library of *********, from*********&lt;br /&gt;-l********: library of *********, from*********&lt;br /&gt;&lt;br /&gt;***.c: define what font is to use, called by ***.&lt;br /&gt;****.c: define ppm file operations, like copy, read, write, called by ****.&lt;br /&gt;&lt;br /&gt;*****************************************************************************************&lt;br /&gt;&lt;br /&gt;*File_list*&lt;br /&gt;&lt;br /&gt;----------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;father folder: /**/****/***&lt;br /&gt;includes:&lt;br /&gt;&lt;br /&gt;----------------------------------------------------------------&lt;br /&gt;**folders:&lt;br /&gt;&lt;br /&gt;CameraPara: folder contains files containing estimated camera parameters.&lt;br /&gt;infile:     folder contains files of extracted raw frames from MPEG video.&lt;br /&gt;outfile:    folder contains files of output frames, which has motion vectors, as well as camera motion parameter displaying on them.&lt;br /&gt;result bake: bake folder contains past experimental results (Camera para, infile, outfile).&lt;br /&gt;----------------------------------------------------------------&lt;br /&gt;**source files:&lt;br /&gt;&lt;br /&gt;*********.cpp: main program to call other programs.&lt;br /&gt;*******.cpp: cpp file for class ****.&lt;br /&gt;***.h:   head file for class ****.&lt;br /&gt;***.h:   used by class **** for configuration.&lt;br /&gt;******.c: c file define fonts for class ***.&lt;br /&gt;*****.h: head file for *******.c.&lt;br /&gt;********.cpp:   test file to test for Camera Parameter Estimation using class&lt;br /&gt;          ***** and ****. (mannually define camera para);&lt;br /&gt;main1.cpp:  test file to test for Camera Parameter Estimation.&lt;br /&gt;****.h:   head file called by class ****.&lt;br /&gt;***.bdf: bdf file called by class ******.&lt;br /&gt;*****.cpp: cpp file for class ****.&lt;br /&gt;*****.h: head file for class *****.&lt;br /&gt;******.cpp: same as ******.cpp.&lt;br /&gt;****.h: same as ****.h.&lt;br /&gt;**.c: c file define operations of ppm file.&lt;br /&gt;**.h: head file for **.c&lt;br /&gt;*********.cpp: cpp file for class *********.&lt;br /&gt;*********.h:   head file for class **********.&lt;br /&gt;******.h: head file for using stl-vector class&lt;br /&gt;test.cpp: test file used for camera para display on frames.&lt;br /&gt;-----------------------------------------------------------------&lt;br /&gt;**Excutable files:&lt;br /&gt;&lt;br /&gt;CMotionEst: main program for camera motion estimation from videos,&lt;br /&gt;#usage: CMotionEst source_mpeg_file.&lt;br /&gt;#compile: g++ -o CMotionEst ******.cpp **.cpp ***.cpp *****.cpp *****.c ****.c -l*****c -l******&lt;br /&gt;&lt;br /&gt;nelder: main program for finding a minimum value of function of&lt;br /&gt;multiple variables.&lt;br /&gt;#usage: nelder ( will display a very simple function y=x[0]^2+x[1]^2+x[2]^2+x[3]^2.&lt;br /&gt;&lt;br /&gt;ppmaddcaption: main program for testing and display caption on one frame.&lt;br /&gt;#usage: ppmaddcaption&lt;br /&gt;&lt;br /&gt;CamEst: main program for testing and display camera motion.&lt;br /&gt;#usage: CamEst&lt;br /&gt;-------------------------------------------------------------------&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2608877327656008144-5173090060286211969?l=tech-sean.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-sean.blogspot.com/feeds/5173090060286211969/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2608877327656008144&amp;postID=5173090060286211969' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2608877327656008144/posts/default/5173090060286211969'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2608877327656008144/posts/default/5173090060286211969'/><link rel='alternate' type='text/html' href='http://tech-sean.blogspot.com/2008/07/what-summary.html' title='What a summary!!'/><author><name>Sean</name><uri>http://www.blogger.com/profile/13677521856282707821</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2608877327656008144.post-4589723097558078204</id><published>2008-07-02T02:54:00.000-07:00</published><updated>2008-07-02T03:19:14.124-07:00</updated><title type='text'>How to pass a multi-dimensional array as reference to a function??</title><content type='html'>If you have a multi-dimensional data, e.g. two-dimensional array, say&lt;br /&gt;&lt;br /&gt;int mydata[10][20];&lt;br /&gt;&lt;br /&gt;and you would like to pass it as reference to another function in C++, say&lt;br /&gt;&lt;br /&gt;int myfunc (int data[][])&lt;br /&gt;{&lt;br /&gt;//got mydata[10][20] here..&lt;br /&gt;//do whatever you like to mydata[10][20]&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;How can you do it? well, in C++, it is not easy to handle multi-dimensional array (Weired...why? I DON'T KNOW, but it is the TRUTH!). Well, you may always re-organize the data to a 1D array and simply pass pointer of that array...(which seems easier), but you have to remember the way you put them to 1D, and well, you have to re-organize back to multi-dimensional array after you passed inside the function....I don't prefer that....So, isn't there way that can pass multi-dimensional array as it was  to a function?&lt;br /&gt;&lt;br /&gt;Well, luckily we have STL, the standard template library. We may define a two-dimensional array by using the vector class in STL, e.g.&lt;br /&gt;&lt;br /&gt;&lt;vector&gt; &lt;vector&gt; &lt;vector&gt; &gt; my2Darray(10, vector&lt;int&gt;(20,0));&lt;br /&gt;//this will initialize an 2D array with initial values set to 0;&lt;br /&gt;&lt;br /&gt;and then you may pass the 2D array as reference to a function, like this,&lt;br /&gt;&lt;br /&gt;void myfunc (&lt;vector&gt;&lt;vector&gt; &lt;vector&gt; &gt;&amp;amp; anyname)&lt;br /&gt;{&lt;br /&gt; //well, the 2D array "anyname" is already passed inside!&lt;br /&gt; //you may do whatever on it...&lt;br /&gt; //e.g. print out one of its element...&lt;br /&gt; cout&lt;&lt;anyname[1][2]&gt;&lt;&lt;endl; then="" in="" your="" which="" call="" the="" function="" myfunc="" int=""&gt;&lt;vector&gt; my2Darray[1][2]&lt;&lt;endl; here="" is="" one="" complete="" int=""&gt;&lt;endl;&gt;&lt;int&gt;&lt;br /&gt;//firstly define a 2D array, or you may assign other values...&lt;br /&gt;&lt;br /&gt;&lt;vector&gt; &gt; my2Darray(10, vector&lt;int&gt;(20,0));&lt;br /&gt;&lt;br /&gt;//then call myfunc&lt;br /&gt;&lt;br /&gt;myfunc(my2Darray);&lt;br /&gt;&lt;br /&gt;return 0;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;You will see the output of print out of my2Darray[1][2];&lt;br /&gt;&lt;br /&gt;Bingo!&lt;br /&gt;&lt;br /&gt;&lt;/int&gt;&lt;/vector&gt;&lt;/int&gt;&lt;/endl;&gt;&lt;/endl;&gt;&lt;/vector&gt;&lt;/endl;&gt;&lt;/anyname[1][2]&gt;&lt;/vector&gt;&lt;/vector&gt;&lt;/vector&gt;&lt;/int&gt;&lt;/vector&gt;&lt;/vector&gt;&lt;/vector&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2608877327656008144-4589723097558078204?l=tech-sean.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-sean.blogspot.com/feeds/4589723097558078204/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2608877327656008144&amp;postID=4589723097558078204' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2608877327656008144/posts/default/4589723097558078204'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2608877327656008144/posts/default/4589723097558078204'/><link rel='alternate' type='text/html' href='http://tech-sean.blogspot.com/2008/07/how-to-pass-multi-dimensional-array-as.html' title='How to pass a multi-dimensional array as reference to a function??'/><author><name>Sean</name><uri>http://www.blogger.com/profile/13677521856282707821</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2608877327656008144.post-5523094113650266711</id><published>2008-07-01T02:16:00.000-07:00</published><updated>2008-07-01T03:55:21.248-07:00</updated><title type='text'>Dynamic Allocation of Multidimensional Array</title><content type='html'>I suddenly found that actually the method of dynamic allocation of one-dimensional array is easy, just need a new operation of dynamic allocation of array, but for multi-dimensional array (e.g. matrix, tensor), you CAN'T just use one new operation.&lt;br /&gt;&lt;br /&gt;Solutions:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;(1) Pre-define a template class which deal with array&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;#using a standard container to calling&lt;br /&gt;new [].&lt;br /&gt;&lt;br /&gt;#include &lt;iostream&gt;&lt;br /&gt;#include &lt;ostream&gt;&lt;br /&gt;#include &lt;iomanip&gt;&lt;br /&gt;#include &lt;vector&gt;&lt;br /&gt;&lt;br /&gt;template &lt;&gt;&lt;br /&gt;struct vector2d&lt;br /&gt;{&lt;br /&gt;vector2d(std::size_t n = 0) : m_Order(n), data( n * n ) {}&lt;br /&gt;void set_Order(std::size_t n) { data.resize(n * (m_Order = n)); }&lt;br /&gt;&lt;br /&gt;T *operator[](std::size_t off)&lt;br /&gt;{&lt;br /&gt;return &amp;amp;(data[off * m_Order]);&lt;br /&gt;}&lt;br /&gt;T const *operator[](std::size_t off) const&lt;br /&gt;{&lt;br /&gt;return &amp;amp;(data[off * m_Order]);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;private:&lt;br /&gt;&lt;br /&gt;std::size_t m_Order;&lt;br /&gt;std::vector&lt;&gt; data;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt;using namespace std;&lt;br /&gt;&lt;br /&gt;vector2d&lt;&gt; a(10);&lt;br /&gt;int i, j;&lt;br /&gt;&lt;br /&gt;for (i = 0; i &lt; j =" 0;" i =" 0;" j =" 0;" style="font-weight: bold;"&gt;&lt;br /&gt;&lt;br /&gt;(2) &lt;span style="font-weight: bold;"&gt;Use STL vector class, like std::vector, or std::valarray (recommanded!)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/vector&gt;&lt;/iomanip&gt;&lt;/ostream&gt;&lt;/iostream&gt;&lt;p&gt;       &lt;b&gt;Two / Three / Multi Dimensioned arrays using vector:&lt;/b&gt;       &lt;/p&gt;       &lt;p&gt; A two dimensional array is a vector of vectors.  The vector contructor can initialize the length of the array and set the initial value.        &lt;/p&gt;       &lt;p&gt;       &lt;/p&gt;        Example of a vector of vectors to represent a two dimensional array:                                                                          &lt;pre&gt;#include &lt;iostream&gt;&lt;br /&gt;#include &lt;vector&gt;&lt;br /&gt;&lt;br /&gt;using namespace std;&lt;br /&gt;&lt;br /&gt;main()&lt;br /&gt;{&lt;br /&gt;// Declare size of two dimensional array and initialize.&lt;br /&gt;vector&lt;&gt; &gt; vI2Matrix(3, vector&lt;int&gt;(2,0));&lt;br /&gt;&lt;br /&gt;vI2Matrix[0][0] = 0;&lt;br /&gt;vI2Matrix[0][1] = 1;&lt;br /&gt;vI2Matrix[1][0] = 10;&lt;br /&gt;vI2Matrix[1][1] = 11;&lt;br /&gt;vI2Matrix[2][0] = 20;&lt;br /&gt;vI2Matrix[2][1] = 21;&lt;br /&gt;&lt;br /&gt;cout &lt;&lt; "&lt;b&gt;Loop by index&lt;/b&gt;:" &lt;&lt; ii="0;" jj="0;"&gt;&lt;/int&gt;&lt;/vector&gt;&lt;/iostream&gt;&lt;/pre&gt;&lt;p&gt; A three dimensional vector would be declared as:        &lt;/p&gt;&lt;br /&gt;&lt;pre&gt;#include &lt;iostream&gt;&lt;br /&gt;#include &lt;vector&gt;&lt;br /&gt;&lt;br /&gt;using namespace std;&lt;br /&gt;&lt;br /&gt;main()&lt;br /&gt;{&lt;br /&gt;                           // Vector length of 3 initialized to 0&lt;br /&gt;vector&lt;int&gt; vI1Matrix(3,0);&lt;br /&gt;&lt;br /&gt;                           // Vector length of 4 initialized to hold another&lt;br /&gt;                           // vector vI1Matrix which has been initialized to 0&lt;br /&gt;vector&lt;&gt; &gt; vI2Matrix(4, vI1Matrix);&lt;br /&gt;&lt;br /&gt;                           // Vector of length 5 containing two dimensional vectors&lt;br /&gt;vector&lt;&gt; &gt; &gt; vI3Matrix(5, vI2Matrix);&lt;br /&gt;&lt;br /&gt;...&lt;/int&gt;&lt;/vector&gt;&lt;/iostream&gt;&lt;/pre&gt;&lt;p&gt;           &lt;b&gt;or declare all in one statement:&lt;/b&gt;&lt;/p&gt;                                                                          #include &lt;iostream&gt;&lt;br /&gt;#include &lt;vector&gt;&lt;br /&gt;&lt;br /&gt;using namespace std;&lt;br /&gt;&lt;br /&gt;main()&lt;br /&gt;{&lt;br /&gt;vector&lt;&gt; &gt; &gt; vI3Matrix(2, vector&lt;&gt; &gt; (3, vector&lt;int&gt;(4,0)) );&lt;br /&gt;&lt;br /&gt;for(int kk=0; kk&lt;4; jj="0;" ii="0;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Source above&lt;/span&gt; (http://www.yolinux.com/TUTORIALS/LinuxTutorialC++STL.html)&lt;br /&gt;&lt;iostream&gt;&lt;ostream&gt;&lt;iomanip&gt;&lt;vector&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;(3) &lt;/span&gt; define a one-dimensional array of pointers, each points to a one-dimensional array, so that's two dimensional!&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;(4)&lt;/span&gt;  convert you problem of multidimensional array to one-dimensional, and remember the way you put them to one-dimensional, then you may do whatever using new operation!&lt;br /&gt;&lt;br /&gt;Anyway, &lt;span style="font-weight: bold;"&gt;multidimensional array is actually one-dimensional array, the ONLY difference is they are put in different format!&lt;/span&gt;&lt;br /&gt;&lt;/vector&gt;&lt;/iomanip&gt;&lt;/ostream&gt;&lt;/iostream&gt;&lt;/int&gt;&lt;/vector&gt;&lt;/iostream&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2608877327656008144-5523094113650266711?l=tech-sean.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-sean.blogspot.com/feeds/5523094113650266711/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2608877327656008144&amp;postID=5523094113650266711' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2608877327656008144/posts/default/5523094113650266711'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2608877327656008144/posts/default/5523094113650266711'/><link rel='alternate' type='text/html' href='http://tech-sean.blogspot.com/2008/07/dynamic-allocation-of-multidimensional.html' title='Dynamic Allocation of Multidimensional Array'/><author><name>Sean</name><uri>http://www.blogger.com/profile/13677521856282707821</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2608877327656008144.post-883993134951675001</id><published>2008-07-01T01:32:00.000-07:00</published><updated>2008-07-01T01:34:50.648-07:00</updated><title type='text'>Dynamic Allocation of Array with varying sizes</title><content type='html'>&lt;h2&gt;&lt;span style="font-size:100%;"&gt;The problems with fixed size arrays&lt;/span&gt;&lt;/h2&gt; &lt;p&gt;Declaring an array with a fixed size like &lt;/p&gt; &lt;pre class="example"&gt;int a[100000];&lt;/pre&gt; &lt;p&gt;has two typical problems: &lt;/p&gt; &lt;ul&gt;&lt;li&gt;&lt;b&gt;Exceeding maximum&lt;/b&gt;.      Choosing a real maximum is often impossible because the programmer has     no control over the size of the data sets the user is interested in.     Erroneous assumptions that a maximum will never be exceeded are the     source of many programming bugs.     Declaring very large arrays can be extremely      wasteful of memory, and if there are many such arrays, may     prevent the program from running in some systems.&lt;/li&gt;&lt;li&gt;&lt;b&gt;No expansion&lt;/b&gt;. Using a small size may be more efficient for the typical data set,      but prevents the     program from running with larger data sets.  If array limits are     not checked, large data sets will run over the end of an array with     disastrous consequences.  Fixed size arrays can not expand as needed.     &lt;/li&gt;&lt;/ul&gt; &lt;p&gt;These problems can be avoided by dynamically allocating an array of the right size, or reallocating an array when it needs to expand.  Both of these are done by declaring an array as a  pointer and using the &lt;code&gt;&lt;b&gt;new&lt;/b&gt;&lt;/code&gt; operator to allocate memory, and &lt;code&gt;&lt;b&gt;delete&lt;/b&gt;&lt;/code&gt; to free memory that is no longer needed. &lt;/p&gt;  &lt;p&gt;This is exactly what is &lt;code&gt;&lt;a href="http://www.fredosaurus.com/notes-cpp/stl-containers/vector/vector.html"&gt;vector&lt;/a&gt;&lt;/code&gt; does, but let's see how it's done with an array.&lt;/p&gt;  &lt;h2&gt;&lt;span style="font-size:100%;"&gt;Declare array as a pointer, allocate with &lt;code&gt;new&lt;/code&gt;&lt;/span&gt;&lt;/h2&gt; &lt;p&gt;To create a variable that will point to a dynamically allocated array, declare it as a pointer to the element type. For example, &lt;/p&gt; &lt;pre class="example"&gt;int* a = NULL;  // pointer to an int, intiallly to nothing.&lt;br /&gt;&lt;/pre&gt; &lt;p&gt;A dynamically allocated array is declared as a pointer, and must not use the fixed array size declaration. The above declaration creates a pointer, but doesn't yet allocate any memory to it. &lt;/p&gt;  &lt;h2&gt;&lt;span style="font-size:100%;"&gt;Allocate an array with code&gt;new&lt;/span&gt;&lt;/h2&gt; &lt;p&gt;When the desired size of an array is known, allocate memory for it with the &lt;code&gt;&lt;b&gt;new&lt;/b&gt;&lt;/code&gt; operator and save the address of that memory in the pointer.  Remember: &lt;i&gt;Pointers may be subscripted just as arrays are.&lt;/i&gt; The example below reads in a number and allocates that size array. &lt;/p&gt;  &lt;pre class="example"&gt;&lt;span class="hilite"&gt;int* a&lt;/span&gt; = NULL;   // Pointer to int, initialize to nothing.&lt;br /&gt;int n;           // Size needed for array&lt;br /&gt;cin &gt;&gt; n;        // Read in the size&lt;br /&gt;&lt;span class="hilite"&gt;a = &lt;b&gt;new&lt;/b&gt; int[n]&lt;/span&gt;;  // Allocate n ints and save ptr in a.&lt;br /&gt;for (int i=0; i&lt;n; i++) {&lt;br /&gt;   a[i] = 0;    // Initialize all elements to zero.&lt;br /&gt;}&lt;br /&gt;. . .  // Use a as a normal array&lt;br /&gt;&lt;span class="hilite"&gt;delete [] a&lt;/span&gt;;  // When done, free memory pointed to by &lt;i&gt;a&lt;/i&gt;.&lt;br /&gt;a = NULL;     // Clear a to prevent using invalid memory reference.&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;     &lt;h2&gt;&lt;span style="font-size:100%;"&gt;Freeing memory with delete&lt;/span&gt;&lt;/h2&gt; &lt;p&gt;When you are finished with dynamically allocated memory, &lt;i&gt;free&lt;/i&gt; it with the &lt;b&gt;delete&lt;/b&gt; operator.  After memory is freed, it can be  reused by later &lt;code&gt;new&lt;/code&gt; requests.  Memory that your program didn't free will be freed when the program terminates.  Never free memory that wasn't dynamically allocated - the results are unpredictable. &lt;/p&gt; &lt;pre class="example"&gt;delete [] a;  // Free memory allocated for the &lt;i&gt;a&lt;/i&gt; array.&lt;br /&gt;a = NULL;     // Be sure the deallocated memory isn't used.&lt;br /&gt;&lt;/pre&gt;     &lt;h3&gt;&lt;span style="font-size:100%;"&gt;Use &lt;code&gt;[]&lt;/code&gt; when deleting arrays&lt;/span&gt;&lt;/h3&gt; &lt;p&gt;You must specify "&lt;code&gt;[]&lt;/code&gt;" when deleting an array, but not for a single value.  It isn't possible to delete only part of an array. &lt;/p&gt;  &lt;h3&gt;&lt;span style="font-size:100%;"&gt;Do you have to reset a pointer after delete?&lt;/span&gt;&lt;/h3&gt; &lt;p&gt;Following the &lt;code&gt;delete&lt;/code&gt; in these examples, I reset the pointer to &lt;code&gt;NULL&lt;/code&gt;. This isn't strictly necessary, but it's very good practice so that any use of the pointer will produce an error.  Attempts to use memory location 0, which is the normal default value of &lt;code&gt;NULL&lt;/code&gt;, will be blocked by the way most operating systems allocate memory. &lt;/p&gt; &lt;p&gt;Why doesn't &lt;code&gt;delete&lt;/code&gt; reset the pointer?  It does in some systems, but the language specification does not require it, so not all systems do it.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Source: http://www.fredosaurus.com/notes-cpp/newdelete/50dynamalloc.html&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2608877327656008144-883993134951675001?l=tech-sean.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-sean.blogspot.com/feeds/883993134951675001/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2608877327656008144&amp;postID=883993134951675001' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2608877327656008144/posts/default/883993134951675001'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2608877327656008144/posts/default/883993134951675001'/><link rel='alternate' type='text/html' href='http://tech-sean.blogspot.com/2008/07/dynamic-allocation-of-array-with.html' title='Dynamic Allocation of Array with varying sizes'/><author><name>Sean</name><uri>http://www.blogger.com/profile/13677521856282707821</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2608877327656008144.post-5606126835376517263</id><published>2008-06-30T09:20:00.000-07:00</published><updated>2008-06-30T09:28:03.284-07:00</updated><title type='text'>How to return multiple variables??</title><content type='html'>In C++, every function will have some return value, however, the number of permitted return value is one.&lt;br /&gt;&lt;br /&gt;For example,&lt;br /&gt;&lt;br /&gt;int myfunc()&lt;br /&gt;{ int a, b;&lt;br /&gt;&lt;br /&gt;  a=3; b=4;&lt;br /&gt;&lt;br /&gt;  return a,b;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;will cause trouble since the calling function will not know which value is returned...&lt;br /&gt;&lt;br /&gt;Then how we return multiple values like described above??&lt;br /&gt;&lt;br /&gt;We may define a structure data, for example,&lt;br /&gt;&lt;br /&gt;typedef struct Mystruct&lt;br /&gt;{ int a,&lt;br /&gt;  int b&lt;br /&gt;} MYSTRUCT;&lt;br /&gt;&lt;br /&gt;in the header file,&lt;br /&gt;&lt;br /&gt;then in the cpp file,&lt;br /&gt;&lt;br /&gt;we define the function as MYSTRUCT type:&lt;br /&gt;&lt;br /&gt;MYSTRUCT myfunc()&lt;br /&gt;{  &lt;br /&gt;MYSTRUCT mystruct;&lt;br /&gt;&lt;br /&gt;mystruct.a=3;&lt;br /&gt;mystruct.b=4;&lt;br /&gt;&lt;br /&gt;return mystruct;&lt;br /&gt;}&lt;br /&gt; &lt;br /&gt;Here we go!&lt;br /&gt;&lt;br /&gt;We may define another MYSTRUCT type data and the returned value would be transfered to that data by the calling function.&lt;br /&gt;&lt;br /&gt;Cheers!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2608877327656008144-5606126835376517263?l=tech-sean.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-sean.blogspot.com/feeds/5606126835376517263/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2608877327656008144&amp;postID=5606126835376517263' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2608877327656008144/posts/default/5606126835376517263'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2608877327656008144/posts/default/5606126835376517263'/><link rel='alternate' type='text/html' href='http://tech-sean.blogspot.com/2008/06/how-to-return-multiple-variables.html' title='How to return multiple variables??'/><author><name>Sean</name><uri>http://www.blogger.com/profile/13677521856282707821</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2608877327656008144.post-1441780116119293973</id><published>2008-06-30T03:39:00.000-07:00</published><updated>2008-06-30T03:40:18.819-07:00</updated><title type='text'>What's inline function in c++</title><content type='html'>When a function is declared inline, the function is expanded at the calling block. The function is not treated as a separate unit like other normal functions.&lt;br /&gt;But a compiler is free to decide, if a function qualifies to be an inline function. If the inline function is found to have larger chunk of code, it will not be treated as an inline function, but as like other normal functions.&lt;br /&gt;&lt;br /&gt;Inline functions are treated like macro definitions by the C++ compiler. They are declared with the keyword inline as follows.&lt;br /&gt;&lt;br /&gt;//Declaration for C++ Tutorial inline sample:&lt;br /&gt;int add(int x,int y);&lt;br /&gt;&lt;br /&gt;//Definition for C++ Tutorial inline sample:&lt;br /&gt;inline int add(int x,int y)&lt;br /&gt;{&lt;br /&gt;return x+y;&lt;br /&gt;}&lt;br /&gt;In fact, the keyword inline is not necessary. If the function is defined with its body directly and the function has a smaller block of code, it will be automatically treated as inline by the compiler.&lt;br /&gt;&lt;br /&gt;As implied, &lt;strong&gt;inline functions are meant to be used if there is a need to repetitively execute a small block of code, which is smaller. When such functions are treated inline, it might result in a significant performance difference.&lt;/strong&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2608877327656008144-1441780116119293973?l=tech-sean.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-sean.blogspot.com/feeds/1441780116119293973/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2608877327656008144&amp;postID=1441780116119293973' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2608877327656008144/posts/default/1441780116119293973'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2608877327656008144/posts/default/1441780116119293973'/><link rel='alternate' type='text/html' href='http://tech-sean.blogspot.com/2008/06/whats-inline-function-in-c.html' title='What&apos;s inline function in c++'/><author><name>Sean</name><uri>http://www.blogger.com/profile/13677521856282707821</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2608877327656008144.post-7319878128303898614</id><published>2008-06-30T03:28:00.000-07:00</published><updated>2008-06-30T03:33:52.562-07:00</updated><title type='text'>WhY Virtual Functions in C++??</title><content type='html'>C++ virtual function is a member function of a class, whose functionality can be over-ridden in its derived classes. The whole function body can be replaced with a new set of implementation in the &lt;a class="kLink" oncontextmenu="return false;" id="KonaLink0" onmouseover="adlinkMouseOver(event,this,0);" style="POSITION: static; TEXT-DECORATION: underline! important" onclick="adlinkMouseClick(event,this,0);" onmouseout="adlinkMouseOut(event,this,0);" href="http://www.codersource.net/cpp_virtual_functions.html#" target="_top"&gt;derived class&lt;/a&gt;. The concept of c++ virtual functions is different from &lt;a class="SideLinks" href="http://www.codersource.net/cpp_tutorial_function_overloading.html" rcbw7="0" fo8yi="0"&gt;C++ Function overloading&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;C++ Virtual Function - Properties:&lt;br /&gt;&lt;br /&gt;C++ virtual function is,&lt;br /&gt;A member function of a class&lt;br /&gt;Declared with virtual keyword&lt;br /&gt;&lt;br /&gt;Usually has a different functionality in the derived class&lt;br /&gt;A &lt;a class="kLink" oncontextmenu="return false;" id="KonaLink1" onmouseover="adlinkMouseOver(event,this,1);" style="POSITION: static; TEXT-DECORATION: underline! important" onclick="adlinkMouseClick(event,this,1);" onmouseout="adlinkMouseOut(event,this,1);" href="http://www.codersource.net/cpp_virtual_functions.html#" target="_top"&gt;function call&lt;/a&gt; is resolved at run-time&lt;br /&gt;  &lt;br /&gt;The difference between a non-virtual c++ member function and a virtual member function is, the non-virtual member functions are resolved at compile time. This mechanism is called &lt;strong&gt;static binding&lt;/strong&gt;. Where as the c++ virtual member functions are resolved during run-time. This mechanism is known as &lt;strong&gt;dynamic binding&lt;/strong&gt;.&lt;br /&gt;&lt;br /&gt;C++ Virtual Function - Reasons:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;The most prominent reason why a C++ virtual function will be used is to have a different functionality in the derived class.&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;For example a Create function in a &lt;a class="SideLinks" href="http://www.codersource.net/cpp_tutorial_class.html" rcbw7="0" fo8yi="0"&gt;class&lt;/a&gt; Window may have to create a window with &lt;a class="kLink" oncontextmenu="return false;" id="KonaLink2" onmouseover="adlinkMouseOver(event,this,2);" style="POSITION: static; TEXT-DECORATION: underline! important" onclick="adlinkMouseClick(event,this,2);" onmouseout="adlinkMouseOut(event,this,2);" href="http://www.codersource.net/cpp_virtual_functions.html#" target="_top"&gt;white background&lt;/a&gt;. But a class called CommandButton derived or &lt;a class="SideLinks" href="http://www.codersource.net/cpp_tutorial_inheritance.html" rcbw7="0" fo8yi="0"&gt;inherited&lt;/a&gt; from Window, may have to use a gray background and write a caption on the center. The Create function for CommandButton now should have a functionality different from the one at the class called Window.&lt;br /&gt;&lt;br /&gt;C++ Virtual function - Example:&lt;br /&gt;&lt;br /&gt;This article assumes a &lt;a class="kLink" oncontextmenu="return false;" id="KonaLink3" onmouseover="adlinkMouseOver(event,this,3);" style="POSITION: static; TEXT-DECORATION: underline! important" onclick="adlinkMouseClick(event,this,3);" onmouseout="adlinkMouseOut(event,this,3);" href="http://www.codersource.net/cpp_virtual_functions.html#" target="_top"&gt;base class&lt;/a&gt; named Window with a virtual member function named Create. The derived class name will be CommandButton, with our over ridden function Create.&lt;br /&gt;    &lt;br /&gt;class Window // Base class for C++ virtual function example    &lt;br /&gt;{       public:         &lt;br /&gt;         &lt;strong&gt;virtual&lt;/strong&gt; void Create() // virtual function for C++ virtual function example         &lt;br /&gt;        {  cout &lt;&lt;"Base class Window"&lt;&lt;endl;          }    };&lt;br /&gt;    &lt;br /&gt;&lt;br /&gt;class CommandButton : public Window    &lt;br /&gt;{       public:          void Create()         &lt;br /&gt;       {     cout&lt;&lt;"Derived class Command Button - Overridden C++ virtual function"&lt;&lt;endl;          }     };    &lt;br /&gt;&lt;br /&gt;void main()    &lt;br /&gt;{         Window  *x, *y;           &lt;br /&gt;            x = new Window();        &lt;br /&gt;            x-&gt;Create();        &lt;br /&gt;            y = new CommandButton();        &lt;br /&gt;            y-&gt;Create();     }  &lt;br /&gt;&lt;br /&gt;The output of the above program will be,                &lt;br /&gt;Base class Window               &lt;br /&gt;Derived class Command Button&lt;br /&gt;  &lt;br /&gt;&lt;strong&gt;If the function had not been declared virtual, then the base class function would have been called all the times. Because, the function address would have been statically bound during compile time. But now, as the function is declared virtual it is a candidate for run-time linking and the derived class function is being invoked.&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;C++ Virtual function - Call Mechanism:&lt;br /&gt;&lt;br /&gt;Whenever a program has a C++ virtual function declared, a v-table is constructed for the class. The v-table consists of addresses to the virtual functions for classes and pointers to the functions from each of the objects of the derived class. Whenever there is a function call made to the c++ virtual function, the v-table is used to resolve to the function address. This is how the Dynamic binding happens during a virtual function call.&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2608877327656008144-7319878128303898614?l=tech-sean.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-sean.blogspot.com/feeds/7319878128303898614/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2608877327656008144&amp;postID=7319878128303898614' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2608877327656008144/posts/default/7319878128303898614'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2608877327656008144/posts/default/7319878128303898614'/><link rel='alternate' type='text/html' href='http://tech-sean.blogspot.com/2008/06/why-virtual-functions-in-c.html' title='WhY Virtual Functions in C++??'/><author><name>Sean</name><uri>http://www.blogger.com/profile/13677521856282707821</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2608877327656008144.post-7673535750832398013</id><published>2008-06-27T02:15:00.001-07:00</published><updated>2008-06-27T02:15:52.200-07:00</updated><title type='text'>Gauss-Newton algorithm from wikimedia</title><content type='html'>The Gauss–Newton algorithm is a method used to solve &lt;a title="Non-linear least squares" href="http://en.wikipedia.org/wiki/Non-linear_least_squares"&gt;non-linear least squares&lt;/a&gt; problems. It can be seen as a modification of &lt;a title="Newton's method in optimization" href="http://en.wikipedia.org/wiki/Newton%27s_method_in_optimization"&gt;Newton's method&lt;/a&gt; for finding a &lt;a title="Maxima and minima" href="http://en.wikipedia.org/wiki/Maxima_and_minima"&gt;minimum&lt;/a&gt; of a &lt;a title="Function (mathematics)" href="http://en.wikipedia.org/wiki/Function_%28mathematics%29"&gt;function&lt;/a&gt;. Unlike Newton's method, the Gauss–Newton algorithm can only be used to minimize a sum of squared function values, but it has the advantage that second derivatives, which can be challenging to compute, are not required.&lt;br /&gt;Non-linear least squares problems arise for instance in &lt;a class="mw-redirect" title="Non-linear regression" href="http://en.wikipedia.org/wiki/Non-linear_regression"&gt;non-linear regression&lt;/a&gt;, where parameters in a model are sought such that the model is in good agreement with available observations.&lt;br /&gt;The method is due to the renowned mathematician &lt;a title="Carl Friedrich Gauss" href="http://en.wikipedia.org/wiki/Carl_Friedrich_Gauss"&gt;Carl Friedrich Gauss&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2608877327656008144-7673535750832398013?l=tech-sean.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-sean.blogspot.com/feeds/7673535750832398013/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2608877327656008144&amp;postID=7673535750832398013' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2608877327656008144/posts/default/7673535750832398013'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2608877327656008144/posts/default/7673535750832398013'/><link rel='alternate' type='text/html' href='http://tech-sean.blogspot.com/2008/06/gauss-newton-algorithm-from-wikimedia.html' title='Gauss-Newton algorithm from wikimedia'/><author><name>Sean</name><uri>http://www.blogger.com/profile/13677521856282707821</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2608877327656008144.post-894992691506406719</id><published>2008-06-26T04:28:00.000-07:00</published><updated>2008-06-26T04:52:30.982-07:00</updated><title type='text'>Conjugate Gradient Methods in Multidimensional non-linear Optimization</title><content type='html'>Use gradient information:&lt;br /&gt;&lt;br /&gt;f(x)~=c-b*x+1/2x*A*x.&lt;br /&gt;&lt;br /&gt;Steepest Descent algorithm....not so good.&lt;br /&gt;&lt;br /&gt;Solution: Conjugate Gradient Method.&lt;br /&gt;&lt;br /&gt;Minimizing the function&lt;br /&gt;&lt;br /&gt;f(x)=1/2 *x*A*x-b*x.&lt;br /&gt;&lt;br /&gt;The function is minimized when its gradient&lt;br /&gt;&lt;br /&gt;gradient(f)=A*x-b is zero.&lt;br /&gt;&lt;br /&gt;The conjugate gradient method can be used to solve not only linear algebraic equations by minimizing a quadratic form, but also minimizing a non-linear function.&lt;br /&gt;&lt;br /&gt;*Conjugate directions&lt;br /&gt;--"non-interfering" directions with special property that minimizing along one is not "spoiled" by subsequently minimizing along another.&lt;br /&gt;&lt;br /&gt;In conjugate gradient method, we want to find new gradient in a direction that is "conjugate" to the old gradient, and to all previous directions traversed.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2608877327656008144-894992691506406719?l=tech-sean.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-sean.blogspot.com/feeds/894992691506406719/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2608877327656008144&amp;postID=894992691506406719' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2608877327656008144/posts/default/894992691506406719'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2608877327656008144/posts/default/894992691506406719'/><link rel='alternate' type='text/html' href='http://tech-sean.blogspot.com/2008/06/conjugate-gradient-methods-in.html' title='Conjugate Gradient Methods in Multidimensional non-linear Optimization'/><author><name>Sean</name><uri>http://www.blogger.com/profile/13677521856282707821</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2608877327656008144.post-2097014871437731809</id><published>2008-06-26T04:20:00.000-07:00</published><updated>2008-06-26T04:25:21.759-07:00</updated><title type='text'>Powell's Quadratically Convergent Method</title><content type='html'>Powell first discovered a direction set method that does produce N mutually congugate directions.&lt;br /&gt;&lt;br /&gt;Here is how it goes:&lt;br /&gt;&lt;br /&gt;Initialize the set of directions u_i to the basis vectors,&lt;br /&gt;&lt;br /&gt;u_i=e_i, for i=1,...,N.&lt;br /&gt;&lt;br /&gt;Now repeat the following steps until your function stops decreasing:&lt;br /&gt;&lt;br /&gt;1. Save your start position as P_0&lt;br /&gt;2. For i=1,..,N. Move P_{i-1} to the minimum along direction u_i and call this point P_i.&lt;br /&gt;3. For i=1,...,N-1, set u_i&lt;-u_{i+1}.&lt;br /&gt;4. Set u_{N}&lt;-P_{N}-P_0&lt;br /&gt;5. Move P_{N} to the minimum along direction u_{N} and call this point P_0.&lt;br /&gt;&lt;br /&gt;Done!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2608877327656008144-2097014871437731809?l=tech-sean.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-sean.blogspot.com/feeds/2097014871437731809/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2608877327656008144&amp;postID=2097014871437731809' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2608877327656008144/posts/default/2097014871437731809'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2608877327656008144/posts/default/2097014871437731809'/><link rel='alternate' type='text/html' href='http://tech-sean.blogspot.com/2008/06/powells-quadratically-convergent-method.html' title='Powell&apos;s Quadratically Convergent Method'/><author><name>Sean</name><uri>http://www.blogger.com/profile/13677521856282707821</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2608877327656008144.post-4803648660297143371</id><published>2008-06-26T04:09:00.001-07:00</published><updated>2008-06-26T04:15:23.105-07:00</updated><title type='text'>Numerical solution to multidimensional non-linear optimization</title><content type='html'>Basic idea, start at a point P in N-dimensional space, and we proceed from there in some vector direction n, then any function of N variables f(P) can be minimized along the line n by our one-dimensional methods. So a multidimensional minimization methods can be transformed as sequences of line minimizations. Different methods differ only by how, at each stage, they choose the next direction n to try.&lt;br /&gt;&lt;br /&gt;The basic routine of line minimization is&lt;br /&gt;&lt;br /&gt;linmin: Given as input the vectors P and n, and the function f, find the scalar /lambda that minimizes f(P+\lambda*n).  Replace P by P+\lambda*n, replace n by \lambda*n. Done.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2608877327656008144-4803648660297143371?l=tech-sean.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-sean.blogspot.com/feeds/4803648660297143371/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2608877327656008144&amp;postID=4803648660297143371' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2608877327656008144/posts/default/4803648660297143371'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2608877327656008144/posts/default/4803648660297143371'/><link rel='alternate' type='text/html' href='http://tech-sean.blogspot.com/2008/06/numerical-solution-to-multidimensional.html' title='Numerical solution to multidimensional non-linear optimization'/><author><name>Sean</name><uri>http://www.blogger.com/profile/13677521856282707821</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2608877327656008144.post-8623554613347168023</id><published>2008-06-26T03:50:00.000-07:00</published><updated>2008-07-08T11:02:08.940-07:00</updated><title type='text'>G++ and qt in linux</title><content type='html'>Qt is really nice to develop graphic user interface under linux platform, just the same as in Visual C++..&lt;br /&gt;&lt;br /&gt;For me, I prefer gcc+Qt under linux, and Visual C++ under windows.&lt;br /&gt;&lt;br /&gt;Well, you can also use Qt under windows, but need to install MSYS and MinGW, which is really lots of extra work! But after that, basically you are able to run a window interface under windows using linux command line, as if you were programming under linux, isn't that cool?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2608877327656008144-8623554613347168023?l=tech-sean.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-sean.blogspot.com/feeds/8623554613347168023/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2608877327656008144&amp;postID=8623554613347168023' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2608877327656008144/posts/default/8623554613347168023'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2608877327656008144/posts/default/8623554613347168023'/><link rel='alternate' type='text/html' href='http://tech-sean.blogspot.com/2008/06/gcc-and-qt-in-linux.html' title='G++ and qt in linux'/><author><name>Sean</name><uri>http://www.blogger.com/profile/13677521856282707821</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2608877327656008144.post-5484477050653141584</id><published>2008-06-26T03:32:00.000-07:00</published><updated>2008-06-26T03:38:07.980-07:00</updated><title type='text'>A good book for numerical computation</title><content type='html'>"Numerical Recipes in C, the art of Scientific Computing", authored by W.H.Press, S.A. Teukolsky, W.T.Vetterling and B.P. Flannery.&lt;br /&gt;&lt;br /&gt;I really found this book very useful, since it covers almost all problems in numerical computation, like solution of linear algebraic equations, functions, sorting, minimizing and maximizing of functions, eigensystems..&lt;br /&gt;&lt;br /&gt;I read this book since I come to a multidimensional non-linear function minimization problem, and I search on the internet found that there is one very famous algorithm called the "Downhill Simplex Method" by Nelder and Mead.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2608877327656008144-5484477050653141584?l=tech-sean.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-sean.blogspot.com/feeds/5484477050653141584/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2608877327656008144&amp;postID=5484477050653141584' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2608877327656008144/posts/default/5484477050653141584'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2608877327656008144/posts/default/5484477050653141584'/><link rel='alternate' type='text/html' href='http://tech-sean.blogspot.com/2008/06/good-book-for-numerical-computation.html' title='A good book for numerical computation'/><author><name>Sean</name><uri>http://www.blogger.com/profile/13677521856282707821</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
