<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Awhan Patnaik</title>
	<atom:link href="http://awhan.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://awhan.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Sat, 24 Dec 2011 04:05:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='awhan.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Awhan Patnaik</title>
		<link>http://awhan.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://awhan.wordpress.com/osd.xml" title="Awhan Patnaik" />
	<atom:link rel='hub' href='http://awhan.wordpress.com/?pushpress=hub'/>
		<item>
		<title>LAPACKE the Standard C language APIs for LAPACK</title>
		<link>http://awhan.wordpress.com/2011/07/24/lapacke-the-standard-c-language-apis-for-lapack/</link>
		<comments>http://awhan.wordpress.com/2011/07/24/lapacke-the-standard-c-language-apis-for-lapack/#comments</comments>
		<pubDate>Sun, 24 Jul 2011 00:18:46 +0000</pubDate>
		<dc:creator>awhan</dc:creator>
				<category><![CDATA[c++]]></category>
		<category><![CDATA[gsl]]></category>
		<category><![CDATA[lapack]]></category>
		<category><![CDATA[scientific programming]]></category>
		<category><![CDATA[gnu scientific library]]></category>
		<category><![CDATA[imkl]]></category>
		<category><![CDATA[intel math kernel library]]></category>
		<category><![CDATA[lapacke]]></category>
		<category><![CDATA[mkl]]></category>
		<category><![CDATA[scientific computing]]></category>

		<guid isPermaLink="false">http://awhan.wordpress.com/?p=395</guid>
		<description><![CDATA[to call a LAPACK routine from your C++ code i used to do the following the above code solves the system of linear equations . notice that in the code i had to store the matrices in column-major mode that is used by FORTRAN. i generally write helper routines to convert from row-major mode to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=awhan.wordpress.com&amp;blog=6706122&amp;post=395&amp;subd=awhan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>to call a <a href="//www.netlib.org/lapack/">LAPACK</a> routine from your C++ code i used to do the following<br />
<pre class="brush: cpp;">
extern &quot;C&quot;
{
  //http://www.netlib.org/lapack/double/dgesv.f
  void dgesv_(int* n, int *nrhs, double* a, int* lda, int* ipiv, double* b, int* ldb, int* info);
}

int main()
{
  int n = 2;
  int nrhs = 2;
  double a[] = {1,3,2,4}; //colum-major mode 
  int lda = n;
  int* ipiv = new int[n];
  double b[] = {19, 43, 22, 50}; //column-major mode
  int ldb = n;
  int info;
  
  dgesv_(&amp;n, &amp;nrhs, a, &amp;lda, ipiv, b, &amp;ldb, &amp;info);

  delete [] ipiv;
  return 0;
}
</pre><br />
the above code solves the system of linear equations <img src='http://s0.wp.com/latex.php?latex=%5Cbegin%7Bbmatrix%7D+1+%26+2+%5C%5C+3+%26+4+%5Cend%7Bbmatrix%7D%5Cmathbf%7BX%7D+%3D+%5Cbegin%7Bbmatrix%7D+19+%26+22+%5C%5C+43+%26+50+%5Cend%7Bbmatrix%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;begin{bmatrix} 1 &amp; 2 &#92;&#92; 3 &amp; 4 &#92;end{bmatrix}&#92;mathbf{X} = &#92;begin{bmatrix} 19 &amp; 22 &#92;&#92; 43 &amp; 50 &#92;end{bmatrix}' title='&#92;begin{bmatrix} 1 &amp; 2 &#92;&#92; 3 &amp; 4 &#92;end{bmatrix}&#92;mathbf{X} = &#92;begin{bmatrix} 19 &amp; 22 &#92;&#92; 43 &amp; 50 &#92;end{bmatrix}' class='latex' />. notice that in the code i had to store the matrices in <strong>column-major mode </strong> that is used by FORTRAN. i generally write helper routines to convert from row-major mode to column major mode before the subroutine call and then convert the results back to row-major mode after returning from the call. also one has to wrap the call to the subroutine in an <strong>extern &#8220;C&#8221; wrapper</strong>. both of these were annoyances that more or less kept me away from LAPACK, i could get most of my work done using GSL. while <a href="http://www.gnu.org/software/gsl/manual/html_node/GSL-BLAS-Interface.html">GSL provides a BLAS interface</a> it does not provide any LAPACK interface and i have always wished to be able to use LAPACK. </p>
<p>it turns out that <a href="http://software.intel.com/en-us/forums/showthread.php?t=61234">the guys at the intel math kernel library(imkl)</a> and lapack guys collaborated to bring <a href="http://www.netlib.org/lapack/#_standard_c_language_apis_for_lapack">a C language interface to lapack </a>. on <a href="http://aur.archlinux.org/packages.php?ID=46325">archlinux i obtained the lapacke package from the AUR</a>. below is the code using lapacke<br />
<pre class="brush: cpp;">
#include &lt;lapacke.h&gt; // &lt;--- header file
int main()
{
  double a[] = {1,2,3,4}; //NO need for column-major mode
  double b[] = {19, 22, 43, 50}; //NO need for column-major mode
  int n = 2;
  int nrhs = 2;
  int lda = n;
  int ipiv[n];
  int ldb = n;

  int info = LAPACKE_dgesv(LAPACK_ROW_MAJOR, n, nrhs, a, lda, ipiv, b, ldb);
 
  return 0;
}
</pre><br />
compile the above code using <strong>g++ main.cpp -llapacke</strong>. notice that by using <strong>LAPACK_ROW_MAJOR</strong> on <strong>LAPACK_COL_MAJOR</strong> one can specify the storage mode for matrices and therefore there is no need to preprocess the matrices before calling the routine. </p>
<p>i am aware of the CLAPACK project as well which is an f2c&#8217;d version of the fortran version but i always wanted a pure C version. this i thought would fill my needs. alas that is NOT the case. <strong>i will not be using lapacke because it is not c++0x compatible </strong> <img src='http://s0.wp.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' />  and i use a lot of c++0x. i wish GSL would provide a lapack interface as well! my search for a scientific computing library for C++ continues. </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/awhan.wordpress.com/395/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/awhan.wordpress.com/395/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/awhan.wordpress.com/395/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/awhan.wordpress.com/395/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/awhan.wordpress.com/395/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/awhan.wordpress.com/395/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/awhan.wordpress.com/395/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/awhan.wordpress.com/395/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/awhan.wordpress.com/395/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/awhan.wordpress.com/395/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/awhan.wordpress.com/395/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/awhan.wordpress.com/395/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/awhan.wordpress.com/395/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/awhan.wordpress.com/395/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=awhan.wordpress.com&amp;blog=6706122&amp;post=395&amp;subd=awhan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://awhan.wordpress.com/2011/07/24/lapacke-the-standard-c-language-apis-for-lapack/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/13bd5c4b43b158bb12be3d8f80ede75d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">awhan</media:title>
		</media:content>
	</item>
		<item>
		<title>column sums of a matrix</title>
		<link>http://awhan.wordpress.com/2011/06/10/column-sums-of-a-matrix/</link>
		<comments>http://awhan.wordpress.com/2011/06/10/column-sums-of-a-matrix/#comments</comments>
		<pubDate>Thu, 09 Jun 2011 21:40:32 +0000</pubDate>
		<dc:creator>awhan</dc:creator>
				<category><![CDATA[c++]]></category>
		<category><![CDATA[c++ lambda expressions]]></category>
		<category><![CDATA[c++ standard template library]]></category>
		<category><![CDATA[c++ stl]]></category>
		<category><![CDATA[c++0x]]></category>
		<category><![CDATA[numerical computing]]></category>
		<category><![CDATA[scientific computing]]></category>

		<guid isPermaLink="false">http://awhan.wordpress.com/?p=391</guid>
		<description><![CDATA[what a weird topic to talk about. i don&#8217;t even know if this piece of code is any good. it will probably serve to remind me of the usage of certain functions etc at a later date. may be it will scare somebody off and may be some kind stranger will correct my mistakes and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=awhan.wordpress.com&amp;blog=6706122&amp;post=391&amp;subd=awhan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>what a weird topic to talk about. i don&#8217;t even know if this piece<br />
of code is any good. it will probably serve to remind me of the<br />
usage of certain functions etc at a later date. may be it will<br />
scare somebody off and may be some kind stranger will correct my<br />
mistakes and point me to enlightened realms. all this does is to<br />
compute the column sums of a matrix. notice that we maintain our<br />
distance from the <strong>for</strong> and <strong>while</strong> loops. i have been admonished<br />
myriads of time for not using the standard library functions so i<br />
have avoided them here. what can i say i simply love the <strong>lambda<br />
functions</strong> over <strong>functors</strong>. although the compiler ultimately uses<br />
functors behind the scenes but i love how clean and separated the<br />
code looks. </p>
<p><pre class="brush: cpp;">
#include &lt;iostream&gt;
#include &lt;vector&gt;
#include &lt;algorithm&gt;
#include &lt;iterator&gt;
#include &lt;cstdlib&gt;

int main(){
  // matrix
  std::vector&lt;std::vector&lt;int&gt; &gt; a = {{0,0,0}, {0,0,0}, {0,0,0}};
// c++0x allows initialization lists

  // randomly initialize using lambda expressions
  std::for_each(a.begin(), a.end(), [](std::vector&lt;int&gt;&amp; i){
      std::generate(i.begin(), i.end(), [](){return rand()%10;});
    });

  // display using lamda expressions
  std::for_each(a.begin(), a.end(), [](std::vector&lt;int&gt;&amp; i){
      std::copy(i.begin(), i.end(), std::ostream_iterator&lt;int&gt;(std::cout, &quot;\t&quot;));
      std::cout &lt;&lt; std::endl;
    });

  // zero vector
  std::vector&lt;int&gt; zeros = {0,0,0};
  
  // column sums
  std::vector&lt;int&gt; csums = std::accumulate(a.begin(), a.end(), zeros, 
[](std::vector&lt;int&gt;&amp; i, std::vector&lt;int&gt;&amp; j)-&gt;std::vector&lt;int&gt;{
std::transform(i.begin(), i.end(), j.begin(), i.begin(), std::plus&lt;int&gt;());
return i;
});

  // display the column sums using ostream_iterators
  std::copy(csums.begin(), csums.end(), std::ostream_iterator&lt;int&gt;(std::cout, &quot;\t&quot;));

  return 0;
}
</pre></p>
<p>i now explain bits and parts of the mess</p>
<p><pre class="brush: cpp;">
  // randomly initialize
  std::for_each(a.begin(), a.end(), [](std::vector&lt;int&gt;&amp; i){
      std::generate(i.begin(), i.end(), [](){return rand()%10;});
    });
</pre></p>
<p>the above initializes the matrix a. since each element of a is itself a vector i use a lambda function that initializes the individual vectors. the lambda is as follows:<br />
<pre class="brush: cpp;">
[](std::vector&lt;int&gt;&amp; i){std::generate(i.begin(), i.end(), [](){return rand()%10;});}
</pre></p>
<p>the actual adding of columns is done using the std::accumulate() library function<br />
<pre class="brush: cpp;">
  // column sums
  std::vector&lt;int&gt; csums = std::accumulate(a.begin(), a.end(), zeros, 
[](std::vector&lt;int&gt;&amp; i, std::vector&lt;int&gt;&amp; j)-&gt;std::vector&lt;int&gt;{
std::transform(i.begin(), i.end(), j.begin(), i.begin(), std::plus&lt;int&gt;());
return i;
});
</pre></p>
<p>that uses the lamda<br />
<pre class="brush: cpp;">
[](std::vector&lt;int&gt;&amp; i, std::vector&lt;int&gt;&amp; j)-&gt;std::vector&lt;int&gt;{
std::transform(i.begin(), i.end(), j.begin(), i.begin(), std::plus&lt;int&gt;());
return i;
}
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/awhan.wordpress.com/391/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/awhan.wordpress.com/391/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/awhan.wordpress.com/391/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/awhan.wordpress.com/391/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/awhan.wordpress.com/391/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/awhan.wordpress.com/391/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/awhan.wordpress.com/391/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/awhan.wordpress.com/391/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/awhan.wordpress.com/391/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/awhan.wordpress.com/391/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/awhan.wordpress.com/391/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/awhan.wordpress.com/391/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/awhan.wordpress.com/391/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/awhan.wordpress.com/391/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=awhan.wordpress.com&amp;blog=6706122&amp;post=391&amp;subd=awhan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://awhan.wordpress.com/2011/06/10/column-sums-of-a-matrix/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/13bd5c4b43b158bb12be3d8f80ede75d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">awhan</media:title>
		</media:content>
	</item>
		<item>
		<title>find all mismatches using std::mismatch() stl c++</title>
		<link>http://awhan.wordpress.com/2011/04/22/find-all-mismatches-using-stdmismatch-stl-c/</link>
		<comments>http://awhan.wordpress.com/2011/04/22/find-all-mismatches-using-stdmismatch-stl-c/#comments</comments>
		<pubDate>Thu, 21 Apr 2011 20:07:32 +0000</pubDate>
		<dc:creator>awhan</dc:creator>
				<category><![CDATA[c++]]></category>
		<category><![CDATA[c++0x]]></category>
		<category><![CDATA[standard template library]]></category>
		<category><![CDATA[stl]]></category>

		<guid isPermaLink="false">http://awhan.wordpress.com/?p=376</guid>
		<description><![CDATA[whenever possible one should use the standard library tools provided. std::mismatch() returns a pair of iterators to the first mismatch. examples of this are abundant on the WWW but i wanted to find all the mismatches and could not find an example online, hence this post. i don&#8217;t think the code is elegant so please [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=awhan.wordpress.com&amp;blog=6706122&amp;post=376&amp;subd=awhan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>whenever possible one should use the standard library tools provided. std::mismatch() returns a pair of iterators to the first mismatch. examples of this are abundant on the WWW but i wanted to find all the mismatches and could not find an example online, hence this post. i don&#8217;t think the code is elegant so please let me know better versions of my code. </p>
<p><pre class="brush: cpp;">
#include &lt;iostream&gt;
#include &lt;vector&gt;
#include &lt;algorithm&gt;
 
int main()
{
  std::vector&lt;unsigned&gt; a = {1,2,3,4,5,6};
  std::vector&lt;unsigned&gt; b = {1,2,33,4,55,66};
 
  // find the first mismatch
  auto p = std::mismatch(a.begin(), a.end(), b.begin());

  while(p.first != a.end())
    {
      std::cout &lt;&lt; *p.first &lt;&lt; std::endl;
      std::cout &lt;&lt; *p.second &lt;&lt; std::endl;
      p = std::mismatch(++p.first, a.end(), ++p.second);
    }
 
return 0;
}
</pre></p>
<p>havent&#8217; tried the above on list container but i believe list iterators support the increment operator. </p>
<p>don&#8217;t forget to compile the above using <strong>-std=c++0x</strong></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/awhan.wordpress.com/376/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/awhan.wordpress.com/376/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/awhan.wordpress.com/376/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/awhan.wordpress.com/376/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/awhan.wordpress.com/376/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/awhan.wordpress.com/376/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/awhan.wordpress.com/376/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/awhan.wordpress.com/376/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/awhan.wordpress.com/376/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/awhan.wordpress.com/376/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/awhan.wordpress.com/376/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/awhan.wordpress.com/376/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/awhan.wordpress.com/376/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/awhan.wordpress.com/376/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=awhan.wordpress.com&amp;blog=6706122&amp;post=376&amp;subd=awhan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://awhan.wordpress.com/2011/04/22/find-all-mismatches-using-stdmismatch-stl-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/13bd5c4b43b158bb12be3d8f80ede75d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">awhan</media:title>
		</media:content>
	</item>
		<item>
		<title>weird tmux clearhist and standard input buffer interaction</title>
		<link>http://awhan.wordpress.com/2011/01/08/weird-tmux-clearhist-and-standard-input-buffer-interaction/</link>
		<comments>http://awhan.wordpress.com/2011/01/08/weird-tmux-clearhist-and-standard-input-buffer-interaction/#comments</comments>
		<pubDate>Sat, 08 Jan 2011 01:48:03 +0000</pubDate>
		<dc:creator>awhan</dc:creator>
				<category><![CDATA[c++]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[tmux]]></category>
		<category><![CDATA[stdin]]></category>

		<guid isPermaLink="false">http://awhan.wordpress.com/?p=370</guid>
		<description><![CDATA[guys when i run a code i get a lot of text dump on the console so i m in the habbit of issuing &#8220;tmux clearhist &#38;&#38; ./a.out&#8221; so that when i scroll back i only see dump pertaining to only the current execution of a.out . turns out that this interacts weirdly with the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=awhan.wordpress.com&amp;blog=6706122&amp;post=370&amp;subd=awhan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p> guys when i run a code i get a lot of text dump on the console so i m in the habbit of issuing  </p>
<blockquote><p>&#8220;tmux clearhist &amp;&amp; ./a.out&#8221; </p></blockquote>
<p>so that when i scroll back i only see dump pertaining to only the current execution of a.out . turns out that this interacts weirdly with the standard input buffer. for a simple code such as the follows:<br />
<pre class="brush: cpp;">
#include &lt;iostream&gt;
#include &lt;string&gt;
int main()
{
  std::string s;
  while(std::getline(std::cin,s))
    {
      std::cout &lt;&lt; s &lt;&lt; std::endl;
    }
return 0;
}
</pre><br />
does not work at all with &#8220;tmux clearhist &amp;&amp; ./a.out&#8221;. </p>
<p>by &#8220;does not work&#8221; i mean the program does not wait for any input and simply proceeds to completion. at first i thought that probably the standard input buffer has whitespaces or newlines sitting which i needed to clear before doing an input, but that did not work either. </p>
<p>so currently i have resorted to first clearing up history and then running my executable instead of chaining them together as one code. or one can use </p>
<blockquote><p>tmux clearhist &gt;/dev/null 2&gt;&amp;1 &lt;/dev/null &amp;&amp; ./a.out</p></blockquote>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/awhan.wordpress.com/370/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/awhan.wordpress.com/370/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/awhan.wordpress.com/370/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/awhan.wordpress.com/370/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/awhan.wordpress.com/370/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/awhan.wordpress.com/370/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/awhan.wordpress.com/370/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/awhan.wordpress.com/370/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/awhan.wordpress.com/370/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/awhan.wordpress.com/370/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/awhan.wordpress.com/370/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/awhan.wordpress.com/370/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/awhan.wordpress.com/370/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/awhan.wordpress.com/370/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=awhan.wordpress.com&amp;blog=6706122&amp;post=370&amp;subd=awhan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://awhan.wordpress.com/2011/01/08/weird-tmux-clearhist-and-standard-input-buffer-interaction/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/13bd5c4b43b158bb12be3d8f80ede75d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">awhan</media:title>
		</media:content>
	</item>
		<item>
		<title>emacs breaks indentation for C++0x angle brackets</title>
		<link>http://awhan.wordpress.com/2011/01/07/emacs-breaks-indentation-for-c0x-angle-brackets/</link>
		<comments>http://awhan.wordpress.com/2011/01/07/emacs-breaks-indentation-for-c0x-angle-brackets/#comments</comments>
		<pubDate>Thu, 06 Jan 2011 20:57:53 +0000</pubDate>
		<dc:creator>awhan</dc:creator>
				<category><![CDATA[c++]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[c++0x]]></category>
		<category><![CDATA[code indentation]]></category>

		<guid isPermaLink="false">http://awhan.wordpress.com/?p=363</guid>
		<description><![CDATA[i have always defined matrices of two dimensions as a vector of a vector container as follows however i recently learned that c++0x allows one to get rid of the extra space between the right angle brackets as in the following however emacs 23 breaks indentation when faced with this format i also use 3 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=awhan.wordpress.com&amp;blog=6706122&amp;post=363&amp;subd=awhan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>i have always defined matrices of two dimensions as a vector of a vector container as follows<br />
<pre class="brush: cpp;">
vector&lt; vector &lt;double&gt; &gt; v; // note the distance between the two right angle brakets just before v
</pre></p>
<p>however i recently learned that c++0x allows one to get rid of the extra space between the right angle brackets as in the following<br />
<pre class="brush: cpp;">
vector&lt; vector &lt;double&gt; &gt; v_old_style; 
vector&lt; vector &lt;double&gt;&gt; v_new_style; 
</pre></p>
<p>however emacs 23 breaks indentation when faced with this format<br />
<a href="http://awhan.files.wordpress.com/2011/01/emacsindentc0x.png"><img src="http://awhan.files.wordpress.com/2011/01/emacsindentc0x.png?w=500&#038;h=237" alt="" title="emacsIndentc++0x" width="500" height="237" class="aligncenter size-full wp-image-364" /></a></p>
<p>i also use 3 and 4 dimensional tensor like objects for which i would much like the following:<br />
<pre class="brush: cpp;">
vector &lt; vector &lt; vector &lt; vector &lt;double&gt; &gt; &gt; &gt; v1; // don't like it
vector&lt;vector&lt;vector&lt;vector&lt;double&gt;&gt;&gt;&gt; v2; // like this a lot 
</pre></p>
<p>for me at least the saving in horizontal space matters when i am comparing code side by side &#8230; also its quite easy to figure out the dimensionality of the tensor at one glance.</p>
<p>i don&#8217;t know how to fix this <img src='http://s0.wp.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' />  help me please</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/awhan.wordpress.com/363/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/awhan.wordpress.com/363/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/awhan.wordpress.com/363/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/awhan.wordpress.com/363/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/awhan.wordpress.com/363/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/awhan.wordpress.com/363/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/awhan.wordpress.com/363/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/awhan.wordpress.com/363/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/awhan.wordpress.com/363/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/awhan.wordpress.com/363/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/awhan.wordpress.com/363/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/awhan.wordpress.com/363/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/awhan.wordpress.com/363/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/awhan.wordpress.com/363/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=awhan.wordpress.com&amp;blog=6706122&amp;post=363&amp;subd=awhan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://awhan.wordpress.com/2011/01/07/emacs-breaks-indentation-for-c0x-angle-brackets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/13bd5c4b43b158bb12be3d8f80ede75d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">awhan</media:title>
		</media:content>

		<media:content url="http://awhan.files.wordpress.com/2011/01/emacsindentc0x.png" medium="image">
			<media:title type="html">emacsIndentc++0x</media:title>
		</media:content>
	</item>
		<item>
		<title>erase set_difference idiom stl c++</title>
		<link>http://awhan.wordpress.com/2011/01/01/erase-set_difference-idiom-stl-c/</link>
		<comments>http://awhan.wordpress.com/2011/01/01/erase-set_difference-idiom-stl-c/#comments</comments>
		<pubDate>Sat, 01 Jan 2011 08:17:51 +0000</pubDate>
		<dc:creator>awhan</dc:creator>
				<category><![CDATA[c++]]></category>
		<category><![CDATA[stl]]></category>

		<guid isPermaLink="false">http://awhan.wordpress.com/?p=356</guid>
		<description><![CDATA[[UPDATE] 03Jan2011 : Please note that the following works ONLY because a and b are &#8220;sorted&#8221; already say we have two sets a = [1,2,34] and b = [2,4] and i want to perform the set difference operation: a = a/b OR a = a-b that is remove from a the elements that are also [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=awhan.wordpress.com&amp;blog=6706122&amp;post=356&amp;subd=awhan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><span style="color:#ff0000;">[UPDATE] 03Jan2011 : Please note that the following works ONLY because a and b are &#8220;sorted&#8221; already</span></p>
<p>say we have two sets</p>
<blockquote><p>a = [1,2,34]</p></blockquote>
<p>and</p>
<blockquote><p>b = [2,4]</p></blockquote>
<p>and i want to perform the set difference operation:</p>
<blockquote><p>a = a/b OR a = a-b</p></blockquote>
<p>that is remove from a the elements that are also present in b.</p>
<p>then is the following c++ solution valid?</p>
<p><pre class="brush: cpp;">
 a.erase(set_difference(a.begin(), a.end(), b.begin(), b.end(), a.begin()), a.end());
</pre></p>
<p>i noticed that the following</p>
<p><pre class="brush: cpp;">
 set_difference(a.begin(), a.end(), b.begin(), b.end(), a.begin());
</pre></p>
<p>changed a in to</p>
<blockquote><p>[1,3,3,4]</p></blockquote>
<p>and returned an iterator to the 3 to the left of 4. this remined me of the <a href="https://secure.wikimedia.org/wikibooks/en/wiki/More_C%2B%2B_Idioms/Erase-Remove">erase-remove idiom</a> hence this post.</p>
<p>is it ok to do this?</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/awhan.wordpress.com/356/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/awhan.wordpress.com/356/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/awhan.wordpress.com/356/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/awhan.wordpress.com/356/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/awhan.wordpress.com/356/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/awhan.wordpress.com/356/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/awhan.wordpress.com/356/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/awhan.wordpress.com/356/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/awhan.wordpress.com/356/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/awhan.wordpress.com/356/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/awhan.wordpress.com/356/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/awhan.wordpress.com/356/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/awhan.wordpress.com/356/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/awhan.wordpress.com/356/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=awhan.wordpress.com&amp;blog=6706122&amp;post=356&amp;subd=awhan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://awhan.wordpress.com/2011/01/01/erase-set_difference-idiom-stl-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/13bd5c4b43b158bb12be3d8f80ede75d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">awhan</media:title>
		</media:content>
	</item>
		<item>
		<title>c++ coding style, where to put curly brace</title>
		<link>http://awhan.wordpress.com/2010/11/29/c-coding-style-where-to-put-curly-brace/</link>
		<comments>http://awhan.wordpress.com/2010/11/29/c-coding-style-where-to-put-curly-brace/#comments</comments>
		<pubDate>Mon, 29 Nov 2010 03:36:36 +0000</pubDate>
		<dc:creator>awhan</dc:creator>
				<category><![CDATA[c++]]></category>
		<category><![CDATA[coding style]]></category>

		<guid isPermaLink="false">http://awhan.wordpress.com/?p=353</guid>
		<description><![CDATA[i have always been writing my code as such notice how the curly brace is on the next line. however today it dawned upon me that this coding style is wasteful of vertical screen estate. an entire line is wasted. compare the above style to the following this decidedly looks ugly but may be useful [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=awhan.wordpress.com&amp;blog=6706122&amp;post=353&amp;subd=awhan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>i have always been writing my code as such<br />
<pre class="brush: cpp;">
if(condition)
{
foo();
}
else
{
bar();
}
</pre><br />
notice how the curly brace is on the next line.</p>
<p>however today it dawned upon me that this coding style is wasteful of vertical screen estate. an entire line is wasted. compare the above style to the following</p>
<p><pre class="brush: cpp;">
if(condition){
foo();}
else{
bar();}
</pre></p>
<p>this decidedly looks ugly but may be useful if screen estate is scanty. </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/awhan.wordpress.com/353/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/awhan.wordpress.com/353/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/awhan.wordpress.com/353/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/awhan.wordpress.com/353/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/awhan.wordpress.com/353/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/awhan.wordpress.com/353/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/awhan.wordpress.com/353/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/awhan.wordpress.com/353/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/awhan.wordpress.com/353/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/awhan.wordpress.com/353/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/awhan.wordpress.com/353/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/awhan.wordpress.com/353/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/awhan.wordpress.com/353/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/awhan.wordpress.com/353/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=awhan.wordpress.com&amp;blog=6706122&amp;post=353&amp;subd=awhan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://awhan.wordpress.com/2010/11/29/c-coding-style-where-to-put-curly-brace/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/13bd5c4b43b158bb12be3d8f80ede75d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">awhan</media:title>
		</media:content>
	</item>
		<item>
		<title>xtics ytics from data file in gnuplot</title>
		<link>http://awhan.wordpress.com/2010/11/09/xtics-ytics-from-data-file-in-gnuplot/</link>
		<comments>http://awhan.wordpress.com/2010/11/09/xtics-ytics-from-data-file-in-gnuplot/#comments</comments>
		<pubDate>Mon, 08 Nov 2010 19:03:01 +0000</pubDate>
		<dc:creator>awhan</dc:creator>
				<category><![CDATA[gnuplot]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[sed]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[plotting]]></category>
		<category><![CDATA[shell script]]></category>

		<guid isPermaLink="false">http://awhan.wordpress.com/?p=344</guid>
		<description><![CDATA[there have been some situations where i needed a custom grid on a 2-dimensional plot in gnuplot instead of a regularly placed grid. in order for me to set up a customized grid i have to first set up a customised xtics and/or ytics. gnuplot does provide a way of providing user preferred tics by [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=awhan.wordpress.com&amp;blog=6706122&amp;post=344&amp;subd=awhan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>there have been some situations where i needed a custom grid on a 2-dimensional plot in gnuplot instead of a regularly placed grid. in order for me to set up a customized grid i have to first set up a customised xtics and/or ytics. gnuplot does provide a way of providing user preferred tics by manually typing them in at the gnuplot command prompt:<br />
<pre class="brush: plain;">
gnuplot&gt; set xtics (1,2,3,4)
</pre><br />
however that might get too tiresome for your digits. naturally one would want to employ the powerful text processors and stream editors that GNU/Linux provides. this is how i went about it:</p>
<p>assume that the data file(data.out, say) is as follows:<br />
<pre class="brush: plain;">
# some comments and blank lines

#      #x1	#x2 	  #x3

1      1.1	3.9	  4.5
2      2.7	6.1	  5.6
3      3.9	2.3	  3.4
       
4      3.5	4.3	  34.0
5      12.1	3.4	  15.9
</pre></p>
<p>i want to set the xtics to the values in column 2 and ytics to the values in column 3 say. first i conjure up the following shell script (ttf.sh, say):<br />
<pre class="brush: plain;">
#!/usr/bin/env bash

# set tic levels from file at the gnuplot prompt
# examples:
# gnuplot&gt; `./tff.sh data.dat 1 xtics`
# gnuplot&gt; `./tff.sh data.dat 2 ytics`

# dataFile from which tic levels will be read
dataFile=$1

# which column to use
column=$2

# xtics OR ytics 
whichTics=$3

sed -e '/^#/d' $dataFile | \
    sed -e '/^$/d' | \
    cut -f $column | \
    tr '\n' ',' | \
    sed -e &quot;s/^/set $whichTics (/&quot; | \
    sed -e 's/,$/)\n/'
</pre></p>
<p>and then in gnuplot carry out the following sequence of commands:<br />
<pre class="brush: plain;">
gnuplot&gt; `./tff.sh data.out 2 xtics`
gnuplot&gt; `./tff.sh data.out 3 ytics`
gnuplot&gt; plot 'data.out' u 1:2 w p pt 13 ps 2
</pre><br />
to produce the following plot:<br />
<a href="http://awhan.files.wordpress.com/2010/11/tff.png"><img src="http://awhan.files.wordpress.com/2010/11/tff.png?w=500&#038;h=361" alt="" title="tics from data file" width="500" height="361" class="aligncenter size-full wp-image-347" /></a><br />
it should be noted that some of the grid lines are hidden due to alignment with borders. </p>
<p>the shell script needs 3 inputs</p>
<ol>
<li>datafile name</li>
<li>which column to pull from the datafile</li>
<li>which tics to set the values to</li>
</ol>
<p>then the whole command is sandwiched between couple of backtics which bring in the command substitution magic. one could very well do the following in bash:<br />
<pre class="brush: plain;">
$ ./tff.sh data.out 2 xtics &gt; tmp
</pre><br />
and then in gnuplot<br />
<pre class="brush: plain;">
gnuplot&gt; load 'tmp'
</pre><br />
but i prefer the backtics.</p>
<p>now the explanation of the wonderful sed magic. first we do a little bit of file cleaning/processing like removing comments and blank lines. these operations may not necessarily apply to your case or might need additional operations which is not that difficult a job. anyways on to the explanations now&#8230;<br />
<pre class="brush: plain;">
sed -e '/^#/d' $dataFile
</pre><br />
simply deletes all lines starting with the # symbol. of course if the comment character is different one should change the code appropriately. ^ stands for the beginning of all lines and ^# means all lines starting with a # symbol. the `d&#8217; command instructs sed to delete those lines. we then pipe (|) the output of this command to the next command </p>
<p><pre class="brush: plain;"> 
sed -e '/^$/d' 
</pre><br />
which simply deletes all blank lines. since ^ represents the beginning of all lines and $ represents the end of all lines, ^$ then represents those lines with nothing in between ^ and $ i.e. blank lines. as always the `d&#8217; command instructs sed to delete this line. </p>
<p><pre class="brush: plain;">
cut -f $column
</pre><br />
next we cut out the required column from the datafile using the cut command. we assume here that the field separater is a TAB character. if some other field separater is being used that can be specified with the -d switch. do a `man cut` to find out more. now comes the all important part of the entire exercise, what we want is to transform the vertical stack of values:<br />
<pre class="brush: plain;">
1
2
3
</pre><br />
to a horizontal comma separated list of values:<br />
<pre class="brush: plain;">
1,2,3,
</pre><br />
notice the comma after 3.<br />
we achieve this by using the tr command which we instruct to transform all the newline characters (`\n&#8217;) to the comma character (`,&#8217;). we do pick up an unwanted comma at the very end of the list which we get rid of and transformed to a right bracket ) like so:<br />
<pre class="brush: plain;">
sed -e 's/,$/)\n/'
</pre><br />
this time we are using the subsitute command `s&#8217; and asking sed to replace the last comma by a ). as you already know $ represents the end of the line so (,$) represents the last comma we substitute those with a right bracket ) and a newline character `\n&#8217;.<br />
of course we had to prepend the &#8220;set xtics (&#8221; to the beginning of the list and that bit is done by the following:<br />
<pre class="brush: plain;">
sed -e &quot;s/^/set $whichTics (/&quot;
</pre><br />
notice the double quotes instead of the single quotes. we use double quotes so that $whichTics is automatically expanded to the user supplied tics name. </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/awhan.wordpress.com/344/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/awhan.wordpress.com/344/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/awhan.wordpress.com/344/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/awhan.wordpress.com/344/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/awhan.wordpress.com/344/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/awhan.wordpress.com/344/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/awhan.wordpress.com/344/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/awhan.wordpress.com/344/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/awhan.wordpress.com/344/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/awhan.wordpress.com/344/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/awhan.wordpress.com/344/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/awhan.wordpress.com/344/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/awhan.wordpress.com/344/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/awhan.wordpress.com/344/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=awhan.wordpress.com&amp;blog=6706122&amp;post=344&amp;subd=awhan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://awhan.wordpress.com/2010/11/09/xtics-ytics-from-data-file-in-gnuplot/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/13bd5c4b43b158bb12be3d8f80ede75d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">awhan</media:title>
		</media:content>

		<media:content url="http://awhan.files.wordpress.com/2010/11/tff.png" medium="image">
			<media:title type="html">tics from data file</media:title>
		</media:content>
	</item>
		<item>
		<title>resize multidimensional stl vectors c++</title>
		<link>http://awhan.wordpress.com/2010/11/04/resize-multidimensional-stl-vectors-c/</link>
		<comments>http://awhan.wordpress.com/2010/11/04/resize-multidimensional-stl-vectors-c/#comments</comments>
		<pubDate>Wed, 03 Nov 2010 18:54:56 +0000</pubDate>
		<dc:creator>awhan</dc:creator>
				<category><![CDATA[c++]]></category>
		<category><![CDATA[numerical software]]></category>
		<category><![CDATA[numerical techniques]]></category>
		<category><![CDATA[stl]]></category>

		<guid isPermaLink="false">http://awhan.wordpress.com/?p=341</guid>
		<description><![CDATA[many numerical software and libraries handle multidimensional arrays as a single dimension array. i don&#8217;t know why but i don&#8217;t like to write instead of so i resort to using multidimensional versions of stl containers. i wonder why it is not used. this is how i store a matrix with 4 rows and 3 columns. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=awhan.wordpress.com&amp;blog=6706122&amp;post=341&amp;subd=awhan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>many numerical software and libraries handle multidimensional arrays as a single dimension array. i don&#8217;t know why but i don&#8217;t like to write<br />
<pre class="brush: plain;">
a[i*numCols+j]
</pre><br />
instead of<br />
<pre class="brush: plain;">
a[i][j]
</pre><br />
so i resort to using multidimensional versions of stl containers. i wonder why it is not used. </p>
<p>this is how i store a matrix with 4 rows and 3 columns.<br />
<pre class="brush: cpp;">
// declaration and memory allocation done together
std::vector &lt;std::vector &lt;double &gt; &gt; matrix(4, std::vector&lt;double&gt;(3));
</pre></p>
<p>that creates a vector of vector. </p>
<p>however one can also resize the vector later after an initial declaration. up until now i only resized one-dimensional vectors but here is how one can resize multi-dimensional vectors.<br />
<pre class="brush: cpp;">
// declaration alone
std::vector &lt;std::vector&lt;double&gt; &gt; matrix;
// blah blah
// 
//
// now for memory allocation
matrix.resize(4, std::vector&lt;double&gt;(3));
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/awhan.wordpress.com/341/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/awhan.wordpress.com/341/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/awhan.wordpress.com/341/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/awhan.wordpress.com/341/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/awhan.wordpress.com/341/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/awhan.wordpress.com/341/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/awhan.wordpress.com/341/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/awhan.wordpress.com/341/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/awhan.wordpress.com/341/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/awhan.wordpress.com/341/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/awhan.wordpress.com/341/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/awhan.wordpress.com/341/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/awhan.wordpress.com/341/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/awhan.wordpress.com/341/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=awhan.wordpress.com&amp;blog=6706122&amp;post=341&amp;subd=awhan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://awhan.wordpress.com/2010/11/04/resize-multidimensional-stl-vectors-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/13bd5c4b43b158bb12be3d8f80ede75d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">awhan</media:title>
		</media:content>
	</item>
		<item>
		<title>tile an image to make a tiled wallpaper</title>
		<link>http://awhan.wordpress.com/2010/10/23/tile-an-image-to-make-a-tiled-wallpaper/</link>
		<comments>http://awhan.wordpress.com/2010/10/23/tile-an-image-to-make-a-tiled-wallpaper/#comments</comments>
		<pubDate>Sat, 23 Oct 2010 03:02:12 +0000</pubDate>
		<dc:creator>awhan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[gdm]]></category>
		<category><![CDATA[gnome]]></category>
		<category><![CDATA[gnome display manager]]></category>
		<category><![CDATA[imagemagick]]></category>
		<category><![CDATA[wallpaper]]></category>

		<guid isPermaLink="false">http://awhan.wordpress.com/?p=337</guid>
		<description><![CDATA[say i have a small patch of an image. in order for me to use that was a desktop wall paper on a pc screen i would normally turn on the &#8220;tile&#8221; option when setting it as a wallpaper. the default background image used by GDM (/usr/share/pixmaps/backgrounds/gnome/background-default.jpg) is a horrible green leaf and i hate [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=awhan.wordpress.com&amp;blog=6706122&amp;post=337&amp;subd=awhan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>say i have a small patch of an image. in order for me to use that was a desktop wall paper on a pc screen i would normally turn on the &#8220;tile&#8221; option when setting it as a wallpaper. the default background image used by <a href="http://en.wikipedia.org/wiki/GNOME_Display_Manager">GDM</a> (/usr/share/pixmaps/backgrounds/gnome/background-default.jpg) is a horrible green leaf and i hate it so much. despite some modest searching i could not locate a minimalistic dark textured background.<br />
i found a small image of size 171&#215;206 pixels that was to my liking and taste. next i found out that the horrible background-default.jpg image of of size 3072&#215;2048 pixels. this is what i did to obtain my new GDM background image<br />
<pre class="brush: plain;">
composite -tile sample.jpg -size 3072x2048 xc:none background-default.jpg
</pre><br />
then simply overwrite the old image with the newly created image. composite is part of the wonderful and amazing <a href="http://www.imagemagick.org/script/index.php">ImageMagick</a> suite of tools. </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/awhan.wordpress.com/337/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/awhan.wordpress.com/337/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/awhan.wordpress.com/337/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/awhan.wordpress.com/337/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/awhan.wordpress.com/337/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/awhan.wordpress.com/337/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/awhan.wordpress.com/337/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/awhan.wordpress.com/337/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/awhan.wordpress.com/337/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/awhan.wordpress.com/337/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/awhan.wordpress.com/337/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/awhan.wordpress.com/337/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/awhan.wordpress.com/337/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/awhan.wordpress.com/337/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=awhan.wordpress.com&amp;blog=6706122&amp;post=337&amp;subd=awhan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://awhan.wordpress.com/2010/10/23/tile-an-image-to-make-a-tiled-wallpaper/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/13bd5c4b43b158bb12be3d8f80ede75d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">awhan</media:title>
		</media:content>
	</item>
	</channel>
</rss>
