<?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/"
	>

<channel>
	<title>Next Door Hacker &#187; c++</title>
	<atom:link href="http://www.nextdoorhacker.com/tag/c/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.nextdoorhacker.com</link>
	<description>I&#039;m just your friendly neighborhood hacker</description>
	<lastBuildDate>Mon, 05 Apr 2010 09:44:47 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Smart double Matrix</title>
		<link>http://www.nextdoorhacker.com/2008/12/smart-double-matrix/</link>
		<comments>http://www.nextdoorhacker.com/2008/12/smart-double-matrix/#comments</comments>
		<pubDate>Thu, 11 Dec 2008 18:58:17 +0000</pubDate>
		<dc:creator>Prasanna</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[matrix]]></category>

		<guid isPermaLink="false">http://www.nextdoorhacker.com/2008/12/smart-double-matrix/</guid>
		<description><![CDATA[I just came across this rather smart double matrix allocation. I had been doing my double matrix allocation in a very simple allocation.. like this, pretty simple eh? right.


double** create_matrix(int size_x, int size_y)
{
double** matrix;
int i,j;
matrix = (double**)malloc(size_x* sizeof(double*));
for(i = 0;i&#60;size_x;i++) {
matrix[i] = (double*)malloc(size_y* sizeof(double));
}
for( i = 0;i&#60;size_x;i++) {
for( j = 0;j&#60;size_y;j++) {
matrix[i][j] = 0;
}
}

return matrix;
}

I [...]]]></description>
			<content:encoded><![CDATA[<p>I just came across this rather smart double matrix allocation. I had been doing my double matrix allocation in a very simple allocation.. like this, pretty simple eh? right.</p>
<pre class="brush: cpp;">

double** create_matrix(int size_x, int size_y)
{
double** matrix;
int i,j;
matrix = (double**)malloc(size_x* sizeof(double*));
for(i = 0;i&lt;size_x;i++) {
matrix[i] = (double*)malloc(size_y* sizeof(double));
}
for( i = 0;i&lt;size_x;i++) {
for( j = 0;j&lt;size_y;j++) {
matrix[i][j] = 0;
}
}

return matrix;
}
</pre>
<p>I can&#8217;t point out the merits or demerits about the code that&#8217;s below, I&#8217;ll update it as soon as I learn more. <img src='http://www.nextdoorhacker.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<pre class="brush: cpp;">
&lt;blockquote&gt;/*
* ===  FUNCTION  ======================================================================
*         Name:  calloc_double_matrix
*  Description:  Allocate a dynamic double-matrix of size rows*columns;
*                return a pointer.
* =====================================================================================
*/
double**
calloc_double_matrix ( int rows, int columns )
{
int      i;
double **m;
m     = calloc ( rows, sizeof(double*) );       /* allocate pointer array     */
assert( m != NULL);                             /* abort if allocation failed */
*m    = calloc ( rows*columns, sizeof(double) );/* allocate data array        */
assert(*m != NULL);                             /* abort if allocation failed */
for ( i=1; i&lt;rows; i+=1 )                       /* set pointers               */
m[i]  = m[i-1] + columns;
return m;
}  /* ----------  end of function calloc_double_matrix  ---------- */

/*
* ===  FUNCTION  ======================================================================
*         Name:  free_matrix_double
*  Description:  Free a dynamic double-matrix.
* =====================================================================================
*/
void
free_double_matrix ( double **m )
{
free(*m);                                       /* free data array            */
free( m);                                       /* free pointer array         */
return ;
}  /* ----------  end of function free_double_matrix  ---------- */&lt;/blockquote&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.nextdoorhacker.com/2008/12/smart-double-matrix/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
