<?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>Jeff Mather's Dispatches &#187; C</title>
	<atom:link href="http://jeffmatherphotography.com/dispatches/category/c/feed/" rel="self" type="application/rss+xml" />
	<link>http://jeffmatherphotography.com/dispatches</link>
	<description>The 9 to 5 Life of an International Playboy</description>
	<lastBuildDate>Fri, 30 Jul 2010 18:48:55 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Buckshot o&#8217; Links &#8211; Software Development Edition</title>
		<link>http://jeffmatherphotography.com/dispatches/2010/04/buckshot-o-links-software-development-edition/</link>
		<comments>http://jeffmatherphotography.com/dispatches/2010/04/buckshot-o-links-software-development-edition/#comments</comments>
		<pubDate>Fri, 16 Apr 2010 19:56:58 +0000</pubDate>
		<dc:creator>Jeff Mather</dc:creator>
				<category><![CDATA[C]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Fodder for Techno-weenies]]></category>
		<category><![CDATA[Hoarding]]></category>
		<category><![CDATA[Software Engineering]]></category>

		<guid isPermaLink="false">http://jeffmatherphotography.com/dispatches/?p=701</guid>
		<description><![CDATA[I&#8217;m a hoarder.  I may not have lived through the Great Depression like my grandmother did, but I seem to have inherited the gene that led her to keep dozens of plastic Cool Whip tubs in her attic &#8220;just in case she needed them.&#8221;  My grandfather kept used bolts and nails for reuse. [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m a hoarder.  I may not have lived through the Great Depression like my grandmother did, but I seem to have inherited the gene that led her to keep dozens of plastic Cool Whip tubs in her attic &#8220;just in case she needed them.&#8221;  My grandfather kept used bolts and nails for reuse.  Me, I keep articles about things I think I should know some day.  From smart people on Twitter and e-mail lists and coworkers I gather links to articles, <a href="http://ilovecharts.tumblr.com/post/450388944/brownpau-everytime-you-make-a-powerpoint">PowerPoint presentations</a>, blog posts, and videos.  And they hang out in my browser tabs &mdash; forever.</p>
<p>It&#8217;s time to clear some of them out.  Here are some daytime-themed links.  (If I had a Tumblr account, I&#8217;d just post there.  But I don&#8217;t need another website no one reads.)</p>
<p><b>Parallel Computing</b><br clear="all" />James Reinders of Intel TBB fame estimates that datasets (images, videos, etc.) <a href="http://softtalkblog.wordpress.com/2010/04/13/intel-software-conference-2010-our-obsession-with-data-is-driving-parallelism/">have grown 10x larger</a> over the last five years.  Sequential systems are just too dang slow to process this amount of data.  In the near future, &#8220;parallel programming&#8221; will just become &#8220;programming.&#8221;  (I&#8217;m still hoping for better language support so that state synchronization and multicore memory issues are as easy to get right as the sequential aspects of programming are now.)</p>
<p>New memory models would certainly help.  A new paper, <i><a href="http://uwnews.org/relatedcontent/2010/March/rc_parentID56284_thisID56367.pdf">DMP: Deterministic Shared Memory Multiprocessing</a></i> by Joseph Devietti, Brandon Lucia, Luis Ceze, and Mark Oskin presents some of the problems with the current memory model and provides one possible solution.</p>
<p>Another post on SoftTalk (sponsored by Intel) describes some of the ways that <a href="http://softtalkblog.wordpress.com/2010/04/13/intel-software-conference-2010-intel-software-roadmap-for-2010/">Intel plans to make parallel programming easier this year</a>: Parallel Studio 2010, a Cilk-based offering for task parallelism, &#8220;a data-parallel centric model with safety guarantee,&#8221; new SIMD instructions, and new array notations.</p>
<p>You might also want a <a href="http://softtalkblog.wordpress.com/2010/04/15/intel-software-conference-2010-which-tools-are-right-for-my-program/">high-level view of how Intel&#8217;s offerings work together</a>.</p>
<p>Herb Sutter, who really knows his stuff, wrote an article for Dr. Dobbs a couple years ago about <a href="http://www.drdobbs.com/cpp/211800538">understanding parallel performance</a>.  It&#8217;s one of a series of articles about multicore/multithreaded programming, and this helps set expectations about what&#8217;s possible and gives pointers on where to start making changes.</p>
<p><b>Miscellaneous</b><br clear="all" />Visual Studio + Time Machine = <a href="http://www.drdobbs.com/blog/archives/2010/04/visual_studio_2_3.html">IntelliTrace</a>.  Don&#8217;t just move up and down the call stack; now you can move forward and backward in time, too.</p>
<p>Everything you ever wanted to know about floating-point representation: <a href="http://floating-point-gui.de/">Floating Point Guide</a>.  (Everything, that is, unless you work where I do.  Then you just have to go down the hall to get that last 2%.  Of course, you&#8217;ll be drinking from the fire hose.&nbsp;.&nbsp;.&nbsp;.)</p>
<p>What does Microsoft think are the <a href="http://blogs.msdn.com/somasegar/archive/2010/02/23/key-software-development-trends.aspx">key trends in software development</a>? Cloud computing, the web as a platform, parallel computing, proliferation of devices (with their own capabilities, IO paradigms, etc.), agile development processes, distributed development.  Nothing terribly futuristic here, and comments want to know why &#8220;mobility&#8221; (i.e., phones) isn&#8217;t on the list.</p>
<p>The <a href="http://www.justsoftwaresolutions.co.uk/cplusplus/c++0x-now-at-fcd.html">C++0x &#8220;final draft&#8221; revision</a> is ready for &#8220;final&#8221; comments.  Here&#8217;s your chance to see the significant changes to C++ that will be part of the standard next year (they hope).</p>
]]></content:encoded>
			<wfw:commentRss>http://jeffmatherphotography.com/dispatches/2010/04/buckshot-o-links-software-development-edition/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Surveying Quality in Object-Oriented Design</title>
		<link>http://jeffmatherphotography.com/dispatches/2008/11/surveying-quality-in-object-oriented-design/</link>
		<comments>http://jeffmatherphotography.com/dispatches/2008/11/surveying-quality-in-object-oriented-design/#comments</comments>
		<pubDate>Thu, 27 Nov 2008 02:51:48 +0000</pubDate>
		<dc:creator>Jeff Mather</dc:creator>
				<category><![CDATA[C]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[From the Yellow Notepad]]></category>
		<category><![CDATA[Software Engineering]]></category>

		<guid isPermaLink="false">http://jeffmatherphotography.com/dispatches/2008/11/surveying-quality-in-object-oriented-design/</guid>
		<description><![CDATA[Just a short post informing you about a survey paper I wrote for my object-oriented (OO) design class: Surveying Quality in Object-Oriented Design.  In it, I look at the major books and articles concerning best practices for OO design.  If you do OO programming, you&#8217;ll probably find something interesting.  (It&#8217;s language-neutral, too.)

The [...]]]></description>
			<content:encoded><![CDATA[<p>Just a short post informing you about a survey paper I wrote for my object-oriented (OO) design class: <a href="/misc/oo_heuristics.pdf">Surveying Quality in Object-Oriented Design</a>.  In it, I look at the major books and articles concerning best practices for OO design.  If you do OO programming, you&#8217;ll probably find something interesting.  (It&#8217;s language-neutral, too.)</p>
<blockquote>
<p>The major goals of using object-oriented design are to facilitate the maintenance and extension of software systems by reducing the complexity of software at the class and system level.  Successful OO designs are resilient to change, largely because they manage interclass dependencies.  In such a system, changes to one part of the system are localized and do not cause a chain of modifications through the system.</p>
<p>The major techniques that OO designers have at their disposal are abstraction, encapsulation, inheritance, polymorphism, and composition.  But how does an engineer apply these techniques to create a good design?  What are the main ways that sets of classes can be structured and interact to maximize the chance of a successful design?  Over the last twenty years, numerous OO practitioners have developed a mature set of rules-of-thumb and best practices to use when constructing and evaluating OO design.</p>
</blockquote>
<p>If you celebrate it, enjoy your Thanksgiving tomorrow.  Don&#8217;t do any homework if you can help it.  I won&#8217;t!</p>
]]></content:encoded>
			<wfw:commentRss>http://jeffmatherphotography.com/dispatches/2008/11/surveying-quality-in-object-oriented-design/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using C++ iterators on MATLAB mxArrays</title>
		<link>http://jeffmatherphotography.com/dispatches/2008/08/using-c-iterators-on-matlab-mxarrays/</link>
		<comments>http://jeffmatherphotography.com/dispatches/2008/08/using-c-iterators-on-matlab-mxarrays/#comments</comments>
		<pubDate>Fri, 15 Aug 2008 19:48:01 +0000</pubDate>
		<dc:creator>Jeff Mather</dc:creator>
				<category><![CDATA[C]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[MATLAB]]></category>

		<guid isPermaLink="false">http://jeffmatherphotography.com/dispatches/2008/08/using-c-iterators-on-matlab-mxarrays/</guid>
		<description><![CDATA[Here&#8217;s a little something for the MATLAB lovers out there who also program in C++.  The code sample at the end of this post shows how to add a C++ iterator to an mxArray, which is the basic datatype for MATLAB arrays.  This makes it harder to walk off the end of an [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a little something for the MATLAB lovers out there who also program in C++.  The code sample at the end of this post shows how to add a C++ iterator to an mxArray, which is the basic datatype for MATLAB arrays.  This makes it harder to walk off the end of an mxArray during linear traversal of all of the elements in an array and (hopefully) improves the readability of code that accesses the data stored inside mxArrays.  The code gives a couple simple-minded examples of element-wise traversal (provided the MATLAB array you give it is a UINT8 array).</p>
<p>If you&#8217;re familiar with the C++ Standard Library, you can start to use your wrapped mxArray <b>like</b> an STL container.  I use the term &#8220;like&#8221; advisedly, since it&#8217;s not actually a container.  To reduce memory overhead, I don&#8217;t make a copy of the data that gets put into <tt>ArrayWrapper</tt>.  Consequently, it doesn&#8217;t model the <tt>container</tt> concept that element lifetimes are the same as the &#8220;container&#8221; lifetime.  You&#8217;re shouldn&#8217;t count on being able to use <tt>ArrayWrapper</tt> with any ole STL function.  But then again, you might be able to use it with some; I haven&#8217;t tried.</p>
<pre>
#include "mex.h"
#include &lt;cstddef&gt;

// Treat an mxArray like a container.
// (See Josuttis. "The C++ Standard Library." 1999. p. 219-220)
template&lt;class T&gt;
class ArrayWrapper {
  private:
    T      *v;
    mwSize thesize; 

  public:
    // Type definitions
    typedef T         value_type;
    typedef T*        iterator;
    typedef const T*  const_iterator;
    typedef T&#038;        reference;
    typedef const T&#038;  const_reference;
    typedef mwSize    size_type;
    typedef ptrdiff_t difference_type;

    // Constructor
    ArrayWrapper(const mxArray *theArray)
    {
        v = static_cast&lt;T*&gt;(mxGetData(theArray));
        thesize = mxGetNumberOfElements(theArray);
    }

    // Iterator support
    iterator begin() { return v; }
    const_iterator begin() const { return v; }
    iterator end() { return v + thesize; }
    const_iterator end() const { return v + thesize; }

    // Direct element access
    reference operator[](size_type i) { return v[i]; }
    const_reference operator[](size_type i) const { return v[i]; }

    // Size is constant
    size_type size() const { return thesize; }
    size_type max_size() const { return thesize; }
};

void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
    const mxArray *inputArray = prhs[0];

    ArrayWrapper&lt;uint8_T&gt; inData(inputArray);

    // 1- Count the number of samples in the image.
    mwSize count = 0;
    ArrayWrapper&lt;uint8_T&gt;::const_iterator i = inData.begin();
    while (i++ != inData.end())
    {
        count++;
    }

    mexPrintf("The image has %ld samples.\n", count);

    // 2 - Halve the image values.
    mxArray *outputArray = mxDuplicateArray(prhs[0]);
    ArrayWrapper&lt;uint8_T&gt; outData(outputArray);

    i = inData.begin();
    ArrayWrapper&lt;uint8_T&gt;::iterator j = outData.begin();
    while (i != inData.end())
    {
        *(j++) = *(i++) * 0.5;
    }

    plhs[0] = outputArray;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://jeffmatherphotography.com/dispatches/2008/08/using-c-iterators-on-matlab-mxarrays/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>From the Yellow Notepad: C</title>
		<link>http://jeffmatherphotography.com/dispatches/2008/05/from-the-yellow-notepad-c/</link>
		<comments>http://jeffmatherphotography.com/dispatches/2008/05/from-the-yellow-notepad-c/#comments</comments>
		<pubDate>Tue, 27 May 2008 20:20:44 +0000</pubDate>
		<dc:creator>Jeff Mather</dc:creator>
				<category><![CDATA[C]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[From the Yellow Notepad]]></category>
		<category><![CDATA[Software Engineering]]></category>

		<guid isPermaLink="false">http://jeffmatherphotography.com/dispatches/2008/05/from-the-yellow-notepad-c/</guid>
		<description><![CDATA[ Here are a few notes from the yellow notepad I&#8217;ve been using for school over the last six months.  This first installment touches on C.  Later I&#8217;ll add some UNIX programming and C++ notes.  Basically these are the things that struck me as I was quickly reading the &#8220;refresher&#8221; material for [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.amazon.com/Book-C-Programming-4th/dp/0201183994/"><img src="http://ecx.images-amazon.com/images/I/41KTXSSGSNL._SL160_AA115_.jpg" alt="Amazon.com - A Book on C" align="left" /></a> Here are a few notes from the yellow notepad I&#8217;ve been using for school over the last six months.  This first installment touches on C.  Later I&#8217;ll add some UNIX programming and C++ notes.  Basically these are the things that struck me as I was quickly reading the &#8220;refresher&#8221; material for my spring class: &#8220;Advanced C Programming for UNIX.&#8221;  After more than a decade with C, I feel I know the core language pretty well; and here are the things that struck me as worth noting.</p>
<p>Is there a portable way to refer precisely to datatypes of a particular size?  Yes, in C99 <tt>#include &lt;stdint.h&gt;</tt>.</p>
<p>Use signed integer types larger than <tt>char</tt> with <tt>getc()</tt> or <tt>getchar()</tt> to accomodate EOF (-1).</p>
<p>A good running average is <tt>avg += (x - avg) / n;</tt>  It reduces the chance of overflow, is fast, and doesn&#8217;t require you to keep track of all values.</p>
<p>Each comment collapses to a single blank character during parsing.</p>
<p>Many system names start with an underscore ( &#8220;_&#8221; ).  Avoid creating new identifiers that start that way.</p>
<p>All functions have <tt>extern</tt> storage, just like variables defined outside of a function.</p>
<p>Use <tt>volatile</tt> when it&#8217;s possible that the variable&#8217;s value will change from outside the normal flow of control.  Technically this prevents compiler and processor instruction reordering optimizations around the use of the variable.</p>
<p>The <tt>register</tt> storage class is for small, fast-changing variables like loop indices (not for bigger things like arrays).  And you can&#8217;t do <tt>&#038;variable</tt> for <tt>register</tt>-declared storage.</p>
<p>Array names are <tt>const</tt> pointers, so an array name is not a valid l-value.</p>
<p>It&#8217;s not possible to take an address of a literal value, like <tt>3.14</tt> or <tt>"I am the very model of a modern major general."</tt>.  So .&nbsp;.&nbsp;.</p>
<p>Because C-strings are either arrays (<tt>char s[]</tt>) or pointers to memory areas (<tt>char *s</tt>), it&#8217;s illegal to reassign a value to a string variable directly (e.g., <tt>s = "new string";  /* won't compile */</tt>).</p>
<p>When passing multidimensional arrays to a function, the function&#8217;s argument list must give the size of all but the slowest changing dimension.</p>
<p>Function pointers: <tt>int (*f)(int, double)</tt> is the same as <tt>int f(int, double)</tt>.  The parentheses are necessary to ensure the * binds to <tt>f</tt> and not <tt>int</tt>.  To use the function pointer <tt>f</tt> either of these is acceptable: <tt>(*f)(37, 3.14)</tt> or <tt>f(37, 3.14)</tt>.  (This is &#8220;declaration follows usage.&#8221;)</p>
<p><tt>const int *p</tt> is a pointer to a constant int.<br />
<tt>int const *p</tt> is a constant pointer to an int.</p>
<p>&#8220;LP64&#8243; scheme means <tt>long int</tt>s and pointers are 64-bit values.</p>
<p>Some compilers use precompiled headers to speed up compilation.  This can make the inclusion order of header files significant.  Also, some compilers (like Xcode) use &#8220;prefix headers,&#8221; which are always included in a project.</p>
<p>Defining <tt>NDEBUG</tt> turns the <tt>assert()</tt> macro into a no-op.</p>
]]></content:encoded>
			<wfw:commentRss>http://jeffmatherphotography.com/dispatches/2008/05/from-the-yellow-notepad-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
