<?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>boyfarrell.com &#187; Learning Curve</title>
	<atom:link href="http://www.boyfarrell.com/category/learning-curve/feed" rel="self" type="application/rss+xml" />
	<link>http://www.boyfarrell.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Mon, 10 Aug 2009 22:52:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>NSOperation meets the graphics card?</title>
		<link>http://www.boyfarrell.com/learning-curve/nsoperation-meets-the-graphics-card</link>
		<comments>http://www.boyfarrell.com/learning-curve/nsoperation-meets-the-graphics-card#comments</comments>
		<pubDate>Tue, 10 Jun 2008 07:22:38 +0000</pubDate>
		<dc:creator>boyfarrell</dc:creator>
				<category><![CDATA[Learning Curve]]></category>

		<guid isPermaLink="false">http://www.boyfarrell.com/learning-curve/nsoperation-meets-the-graphics-card</guid>
		<description><![CDATA[Details released from the WWDC yesterday mention OpenCL (Open Compute Library) as a technology in Leopard: Another powerful Snow Leopard technology, OpenCL (Open Compute Library), makes it possible for developers to efficiently tap the vast gigaflops of computing power currently locked up in the graphics processing unit (GPU). With GPUs approaching processing speeds of a [...]]]></description>
			<content:encoded><![CDATA[<p>Details released from the WWDC yesterday mention <a href="http://www.apple.com/macosx/snowleopard/"> OpenCL (Open Compute Library)</a> as a technology in Leopard:</p>
<p><quote><i>Another powerful Snow Leopard technology, OpenCL (Open Compute Library), makes it possible for developers to efficiently tap the vast gigaflops of computing power currently locked up in the graphics processing unit (GPU). With GPUs approaching processing speeds of a trillion operations per second, they’re capable of considerably more than just drawing pictures. OpenCL takes that power and redirects it for general-purpose computing.</i></quote></p>
<p>As a matter of interest the <a hef="http://opencl.sourceforge.net/">Open Source Cryptographic Library</a> &#8212; previous holder of the OpenCL name &#8212; has recently changed to <a hef="http://botan.randombit.net/">Botan</a>. Is this possibly at the request of Apple?</p>
<p>Also, an interesting link from <a href="http://www.macresearch.org/cuda-every-mac">MacResearch.org</a> references <a href="a quote from the http://news.cnet.com/8301-13579_3-9962117-37.html?part=rss&#038;subj=news&#038;tag=2547-1040_3-0-5">Nvidia CEO, Jen-Hsun Huang</a> stating <quote>Apple knows alot about CUDA</quote> are we going to see Apple writing a higher level API on top of CUDA? NSOperation meets the graphics card.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.boyfarrell.com/learning-curve/nsoperation-meets-the-graphics-card/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GNU Scientific Library and XCode 3.1</title>
		<link>http://www.boyfarrell.com/learning-curve/gnu-scientific-library-and-xcode-31</link>
		<comments>http://www.boyfarrell.com/learning-curve/gnu-scientific-library-and-xcode-31#comments</comments>
		<pubDate>Fri, 04 Apr 2008 15:30:22 +0000</pubDate>
		<dc:creator>boyfarrell</dc:creator>
				<category><![CDATA[Learning Curve]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.boyfarrell.com/uncategorised/gnu-scientific-library-and-xcode-31</guid>
		<description><![CDATA[Update notice: 8th September 2008 This post has become quite popular with those using Xcode and GSL, so you might be interested in this other post, Making XCode Templates for GNU Scientific Library. Once you have a functioning project (once you have done this tutorial) that post will tell you how to add it to [...]]]></description>
			<content:encoded><![CDATA[<div class="notice">Update notice: 8th September 2008<br />
This post has become quite popular with those using Xcode and GSL, so you might be interested in this other post, <a href="http://www.boyfarrell.com/tutorials/making-xcode-templates-for-gnu-scientific-library">Making XCode Templates for GNU Scientific Library</a>. Once you have a functioning project (once you have done this tutorial) that post will tell you how to add it to the XCode template list. E.g. In the future you only ever have to select &#8216;Cocoa Application + GSL&#8217; when you want a GSL based project.</div>
<p>Assuming you have a working installation of GNU Scientific Library either from source, Fink or MacPorts, this tutorial will show you how to getting a working XCode project. I am currently using XCode 3.1 but this process hasn&#8217;t changed much over the last few years, so will work on older systems.</p>
<p>Download a GSL Example project ready for your own code:<br />
<a href="http://www.boyfarrell.com/files/GSL-Project-Xcode-3.0.zip"> XCode 3.0+ GSL Example Project</a><br />
<a href="http://www.boyfarrell.com/files/GSL-Project-Xcode-2.4.zip"> XCode 2.4+ GSL Example Project</a></p>
<ol>
<li>
Create a new project, I called mine, &#8216;GSL Project&#8217;.<br />
<a class="imagelink" href="http://www.boyfarrell.com/wordpress/wp-content/uploads/2008/04/picture-1.png" title="Create project"><img id="image86" src="http://www.boyfarrell.com/wordpress/wp-content/uploads/2008/04/picture-1.thumbnail.png" alt="Create project" /></a></p>
</li>
<li> Choose a default template, New Cocoa application will do nicely.<br />
<a class="imagelink" href="http://www.boyfarrell.com/wordpress/wp-content/uploads/2008/04/picture-2.png" title="Template"><img id="image87" src="http://www.boyfarrell.com/wordpress/wp-content/uploads/2008/04/picture-2.thumbnail.png" alt="Template" /></a></p>
</li>
<li>
Select get info on the project icon. As we need to tell xcode where GSL is.<br />
<a class="imagelink" href="http://www.boyfarrell.com/wordpress/wp-content/uploads/2008/04/picture-4.png" title="Get info"><img id="image88" src="http://www.boyfarrell.com/wordpress/wp-content/uploads/2008/04/picture-4.thumbnail.png" alt="Get info" /></a></p>
</li>
<li> Select the native option in the architectures list. Xcode can build dual binaries (DBs), however, GSL is only compiled for the native machine, so otherwise <del datetime="2009-08-10T22:50:09+00:00">it it tried to make a DB is</del> this step will FAIL!<br />
<a class="imagelink" href="http://www.boyfarrell.com/wordpress/wp-content/uploads/2008/04/picture-5.png" title="native"><img id="image89" src="http://www.boyfarrell.com/wordpress/wp-content/uploads/2008/04/picture-5.thumbnail.png" alt="native" /></a></p>
</li>
<li> Type header search paths into the search box. Editing the &#8216;Header Search Paths&#8217; field, add the following paths.
<p><a class="imagelink" href="http://www.boyfarrell.com/wordpress/wp-content/uploads/2008/04/picture-6.png" title="hsp"><img id="image90" src="http://www.boyfarrell.com/wordpress/wp-content/uploads/2008/04/picture-6.thumbnail.png" alt="hsp" /></a><br />
<a class="imagelink" href="http://www.boyfarrell.com/wordpress/wp-content/uploads/2008/04/picture-7.png" title="hsp fields"><img id="image91" src="http://www.boyfarrell.com/wordpress/wp-content/uploads/2008/04/picture-7.thumbnail.png" alt="hsp fields" /></a></p>
</li>
<li> Next we will do the same process as but for the &#8216;Library search paths&#8217;,
<p><a class="imagelink" href="http://www.boyfarrell.com/wordpress/wp-content/uploads/2008/04/picture-8.png" title="lsp"><img id="image92" src="http://www.boyfarrell.com/wordpress/wp-content/uploads/2008/04/picture-8.thumbnail.png" alt="lsp" /></a><a class="imagelink" href="http://www.boyfarrell.com/wordpress/wp-content/uploads/2008/04/picture-9.png" title="lsp fields"><img id="image93" src="http://www.boyfarrell.com/wordpress/wp-content/uploads/2008/04/picture-9.thumbnail.png" alt="lsp fields" /></a></p>
</li>
<li> Now search for &#8216;other linker flags&#8217; and set the following values,<br />
<a class="imagelink" href="http://www.boyfarrell.com/wordpress/wp-content/uploads/2008/04/picture-11.png" title="olf"><img id="image94" src="http://www.boyfarrell.com/wordpress/wp-content/uploads/2008/04/picture-11.thumbnail.png" alt="olf" /></a><br />
<a class="imagelink" href="http://www.boyfarrell.com/wordpress/wp-content/uploads/2008/04/picture-12.png" title="olf field"><img id="image95" src="http://www.boyfarrell.com/wordpress/wp-content/uploads/2008/04/picture-12.thumbnail.png" alt="olf field" /></a></p>
</li>
<li> We are done, but let&#8217;s do a test program. Select the main.m file in the File &#038; Groups list. You may need to press the &#8216;Editor&#8217; button in the button menu to see the contents of the file,<br />
<a class="imagelink" href="http://www.boyfarrell.com/wordpress/wp-content/uploads/2008/04/picture-13.png" title="main.m cocoa"><img id="image96" src="http://www.boyfarrell.com/wordpress/wp-content/uploads/2008/04/picture-13.thumbnail.png" alt="main.m cocoa" /></a> </p>
</li>
<li>
Try this test code (<a href="http://www.network-theory.co.uk/docs/gslref/Exampleprogramsforvectors.html">slightly modified from the code here</a>):<br />
<script src='http://pastie.org/381201.js'></script><br />
Build and run.<br />
<a class="imagelink" href="http://www.boyfarrell.com/wordpress/wp-content/uploads/2008/04/picture-15.png" title="main.m gsl"><img id="image97" src="http://www.boyfarrell.com/wordpress/wp-content/uploads/2008/04/picture-15.thumbnail.png" alt="main.m gsl" /></a></p>
</li>
</ol>
<p>Make sure that you have the DEBUG build settings active. Have your project in RELEASE mode  won&#8217;t work (thanks for point that out Paul).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.boyfarrell.com/learning-curve/gnu-scientific-library-and-xcode-31/feed</wfw:commentRss>
		<slash:comments>39</slash:comments>
		</item>
		<item>
		<title>Gnuplot Blue-Green-Red PM3D Colourmap</title>
		<link>http://www.boyfarrell.com/learning-curve/gnuplot-blue-green-red-pm3d-colourmap</link>
		<comments>http://www.boyfarrell.com/learning-curve/gnuplot-blue-green-red-pm3d-colourmap#comments</comments>
		<pubDate>Sun, 17 Feb 2008 23:49:33 +0000</pubDate>
		<dc:creator>boyfarrell</dc:creator>
				<category><![CDATA[Learning Curve]]></category>

		<guid isPermaLink="false">http://www.boyfarrell.com/learning-curve/gnuplot-blue-green-red-pm3d-colourmap</guid>
		<description><![CDATA[set palette model RGB set palette rgbformulae 30,-13,-23 This code will produce a MATLAB like colormap with the default &#8216;jet&#8217; setting.]]></description>
			<content:encoded><![CDATA[<p><code><br />
set palette model RGB<br />
set palette rgbformulae 30,-13,-23<br />
</code><br />
This code will produce a MATLAB like colormap with the <a href="http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/ref/colormap.html&#038;http://www.mathworks.com/access/helpdesk/help/techdoc/ref/colormap.html#f19-356665">default &#8216;jet&#8217; </a>setting.</p>
<p><a class="imagelink" href="http://www.boyfarrell.com/wordpress/wp-content/uploads/2008/02/jet-colourmap.png" title="gnuplot with pm3d jet settings (30, -13, -23)"><img id="image83" src="http://www.boyfarrell.com/wordpress/wp-content/uploads/2008/02/jet-colourmap.png" alt="gnuplot with pm3d jet settings (30, -13, -23)" width="500"/></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.boyfarrell.com/learning-curve/gnuplot-blue-green-red-pm3d-colourmap/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>ChocPlot: First Results</title>
		<link>http://www.boyfarrell.com/learning-curve/chocplot-first-results</link>
		<comments>http://www.boyfarrell.com/learning-curve/chocplot-first-results#comments</comments>
		<pubDate>Mon, 14 Jan 2008 22:01:39 +0000</pubDate>
		<dc:creator>boyfarrell</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Learning Curve]]></category>

		<guid isPermaLink="false">http://www.boyfarrell.com/code/chocplot-first-results</guid>
		<description><![CDATA[It has been quite slow going with the plotting framework as of late; the trouble with being in the fourth year of a three year PhD! I have decided to rely on Cocoa for as much as possible for the plot above (under the advice of Wil Shipley). I am using NSBezierPath to draw the [...]]]></description>
			<content:encoded><![CDATA[<p><img id="image79" src="http://www.boyfarrell.com/wordpress/wp-content/uploads/2008/01/cocoa-plot-view.jpg" alt="Cocoa Plot View" /></p>
<p>It has been quite slow going with the plotting framework as of late; the trouble with being in the fourth year of a three year PhD! I have decided to rely on Cocoa for as much as possible for the plot above (<a href="http://www.wilshipley.com/blog/2007/05/pimp-my-code-part-14-be-inflexible.html">under the advice of Wil Shipley</a>). I am using NSBezierPath to draw the red dashed line and the filled the circles. NSAffineTransform is used to convert data points from data to screen/view coordinates.</p>
<h2>A lot for free</h2>
<p>Using NSAffineTransform makes it very easy to position and also alter the points (which themselves are drawn with NSBezierPath) in the view, e.g. rotation of the data points by 23 degrees in the example below. One just needs to specify a &#8216;data&#8217; coordinate rectangle which is made from the min, max and range of the experimental data set in x and y. A NSAffineTransform is made such that the &#8216;data&#8217; rectangle is first translated and then scaled to fit into the view bounds. Hmmm I lke &#8216;tiny code&#8217; &#8230;</p>
<p><img id="image81" src="http://www.boyfarrell.com/wordpress/wp-content/uploads/2008/01/cocoa-plot-view-crosses.jpg" alt="Cocoa Plot View with crosses" /></p>
<p>Drawing lines is made very easy, using NSBezierPath&#8217;s <code>setLineDash:count:phase:</code> method. Also, drawing oval/circles comes for free with <code>bezierPathWithOvalInRect:</code> method. So the only really work I have actually done is added <code>bezierPathWithCrossInRect:</code> extension to aid drawing of crosses (shown above)!</p>
<h2>Next step&#8230;</h2>
<p>Next I will add a points-lines plotting style. This will be similar to drawing a dashed lines but will have ovals or crosses, and regular points along it&#8217;s length. A nice touch would be to have the rotation of the points follow the gradient of the line; think of the way loops in chain would rotate as of a chain changes direction. </p>
<p>Also, we will implement the code from the <a href="http://www.boyfarrell.com/learning-curve/chocplot-mutable-axis-model">first few chocplot plots</a> and have nicley spaced axis labels on the plot.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.boyfarrell.com/learning-curve/chocplot-first-results/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ChocPlot: Mutable Axis Model</title>
		<link>http://www.boyfarrell.com/learning-curve/chocplot-mutable-axis-model</link>
		<comments>http://www.boyfarrell.com/learning-curve/chocplot-mutable-axis-model#comments</comments>
		<pubDate>Tue, 04 Sep 2007 21:33:17 +0000</pubDate>
		<dc:creator>boyfarrell</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Learning Curve]]></category>

		<guid isPermaLink="false">http://www.boyfarrell.com/learning-curve/chocplot-mutable-axis-model</guid>
		<description><![CDATA[The original AxisModel was quite limited in it&#8217;s abilities; it just did everything automatically. Here I introduce the mutable subclass of AxisModel; MutableAxisModel As this is a subclass it still responds to the same methods defined in AxisModel; -interval, -spacing, -start, -stop, -representation, -description MutableAxisModel adds additional methods designed to give the user some control [...]]]></description>
			<content:encoded><![CDATA[<p>The original <a href="http://www.boyfarrell.com/code/chocplot/doc/v1-1/interface_axis_model.html">AxisModel</a> was quite limited in it&#8217;s abilities; it just did everything automatically. Here I introduce the mutable subclass of <a href="http://www.boyfarrell.com/code/chocplot/doc/v1-1/interface_axis_model.html">AxisModel</a>; <a href="http://www.boyfarrell.com/code/chocplot/doc/v1-1/interface_mutable_axis_model.html">MutableAxisModel</a></p>
<p>As this is a subclass it still responds to the same methods defined in <a href="http://www.boyfarrell.com/code/chocplot/doc/v1-1/interface_axis_model.html">AxisModel</a>; <code>-interval, -spacing, -start, -stop, -representation, -description</code></p>
<p><a href="http://www.boyfarrell.com/code/chocplot/doc/v1-1/interface_mutable_axis_model.html">MutableAxisModel</a> adds additional methods designed to give the user some control over the axis properties. These new methods are: <code>-setStart:, -setStop:, -moreIntervals, -fewerIntervals</code></p>
<p>As one might expect these allow the start and stop to be set exactly; these values will not be rounded like the -initWithStart:stop: values are with <a href="http://www.boyfarrell.com/code/chocplot/doc/v1-1/interface_axis_model.html">AxisModel</a>. The interval positions are still placed at nice rounded intervals but <b>inside</b> these end-points. Using the last two methods in the list allows the number of axis interval (tic marks) can be increased or decreased. </p>
<p>The actual number of intervals afterwards is determined by <a href="http://www.boyfarrell.com/code/chocplot/doc/v1-1/interface_mutable_axis_model.html">MutableAxisModel</a>, if it thinks that you have too many (such that adding more would just looked cluttered), it won&#8217;t add anymore! The same is true for the opposite case; having to fewer intervals.</p>
<p>There are a few more model classes left before moving on to the Graphical objects. The next post will be about <b>LinkedAxisModel</b>; a subclass of mutable axis model that uses a transform to display the same data but it different units.</p>
<p><a href="http://www.boyfarrell.com/code/chocplot/src/AxisModel-1.1.tar.gz">Source Code with Documentation (104kB)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.boyfarrell.com/learning-curve/chocplot-mutable-axis-model/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Overview of axis rounding</title>
		<link>http://www.boyfarrell.com/learning-curve/overview-of-axis-rounding</link>
		<comments>http://www.boyfarrell.com/learning-curve/overview-of-axis-rounding#comments</comments>
		<pubDate>Mon, 03 Sep 2007 20:00:41 +0000</pubDate>
		<dc:creator>boyfarrell</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Learning Curve]]></category>

		<guid isPermaLink="false">http://www.boyfarrell.com/learning-curve/overview-of-axis-rounding</guid>
		<description><![CDATA[(A pdf version of this discussion with equations, and source code with documentation are available. Alternatively, just the documentation is available on-line.) Update There were some problems with the original code, but they are all solved now. There were just silly bugs: one variable was a unsigned and should have been an int etc. I [...]]]></description>
			<content:encoded><![CDATA[<p>(A <a id="p69" href="http://www.boyfarrell.com/wordpress/wp-content/uploads/2007/09/rounding-algorithms.pdf" title="Rounding Algorithm Discussion">pdf version of this discussion</a> with equations, and <a id="p70" href="http://www.boyfarrell.com/wordpress/download-manager.php?id=9"> source code with documentation</a> are available. Alternatively, just the <a href="http://www.boyfarrell.com/code/axis-rounding/Documentation/html/_axis_rounding_8c.html">documentation is available on-line</a>.)</p>
<p><b>Update</b> There were some problems with the original code, but they are all solved now. There were just silly bugs: one variable was a unsigned and should have been an int etc.</p>
<p>I have been quite bored recently so in a search for something to do that was potential useful I &#8216;wrote up&#8217; some of my recent experiments with rounding axis values. The main problem to solve is how to place tic marks at nice interval along the axis, if your axis doesn&#8217;t start with nice rounded numbers. The solution, I hear you say, is to round the the axis start and top values. However this can only be done once the axis spacing is known! Moreover, we cannot find out how to round the axis start and stop values with out knowledge of how we have rounded them!</p>
<h2>Axis Definitions</h2>
<p>Before we continue let&#8217;s make some definitions:</p>
<p><img id="image64" src="http://www.boyfarrell.com/wordpress/wp-content/uploads/2007/09/axis-defintions-3.jpg" alt="Axis Definitions" /></p>
<p>The range is clearly the end minus the start value, <b>NB</b> this is assumed to always be positive, so start must always be less than stop. The spacing is the separation, in axis units, between tic marks. The interval is the number of tic marks placed along the axis.</p>
<p>We can then generate equations which describe; the axis spacing as a function of the range and interval number; and the number of intervals as a function of range and spacing. This is the interdependency that I refereed to previously.</p>
<h2>Rounding</h2>
<p>The example axis above is fortunate because we started with rounded values. However, what happens if the start value was 0.2 and the stop value was 3.7? We would still want exactly the same spacing. That is, we would want 0.2 to rounded down to 0 and 3.7 to be rounded up to 4.</p>
<p>This can be achieved using ceil() and floor() functions from math.h, along with a guess value for the axis spacing.</p>
<h2>Algorithm to find spacing</h2>
<p>The number of axis intervals should be some manageable mount, a number less than 4 is too few, while more than 11 is overkill. The basis for finding the rounded axis spacing is to try a few guess spacing and see which one produce intervals in the desired range. There are also a few clues that we can use to quickly find the spacing, and when this is done it takes no more than 6 iteration to acquire the result.</p>
<h2>AxisRounding Source Code</h2>
<p>The above algorithm is used below in the function <a href="http://www.boyfarrell.com/code/axis-rounding/Documentation/html/_axis_rounding_8c.html">MakeSpacing()</a>. Here we get clues for the guess value from looking at the decade of the axis range,</p>
<p><img id="image66" src="http://www.boyfarrell.com/wordpress/wp-content/uploads/2007/09/picture-1.png" alt="MakeSpacing Function" /></p>
<p>Now we set the guess values. The trick is to scale the guess values to the same range as the axis. The axis decade has been rounded down using floor() and as such we start our search in the lower decade and then more through to the higher one. This range will cover all possible solutions that fall into our tic mark range.</p>
<p><img id="image67" src="http://www.boyfarrell.com/wordpress/wp-content/uploads/2007/09/picture-2.png" alt="MakeSpacing Functions" /></p>
<p>Finally, calculate the number of intervals for the current guess spacing. If this falls into the our desired range for the number of intervals, we return the value.</p>
<p><img id="image68" src="http://www.boyfarrell.com/wordpress/wp-content/uploads/2007/09/picture-3.png" alt="MakeSpacing Function" /></p>
<p>Please find the source code and documentation of how to use the axis spacing functions in the links above.</p>
<h3>Example Use</h3>
<p><code>double start = 400;<br />
  double stop = 800;<br />
  double spacing  = MakeSpacing(start, stop);<br />
  unsigned interval = MakeInterval(start, stop);<br />
  PrintDescription(start, stop, spacing, interval);</p>
<p>  /*<br />
  Axis Description:<br />
  start = 400<br />
  stop  = 800<br />
  spacing   = 50<br />
  interval = 9<br />
  (400, 450, 500, 550, 600, 650, 700, 750, 800)<br />
 */<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.boyfarrell.com/learning-curve/overview-of-axis-rounding/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ChocPlot 1: Axis Model</title>
		<link>http://www.boyfarrell.com/learning-curve/chocplot-1-axis-model</link>
		<comments>http://www.boyfarrell.com/learning-curve/chocplot-1-axis-model#comments</comments>
		<pubDate>Thu, 16 Aug 2007 17:45:33 +0000</pubDate>
		<dc:creator>boyfarrell</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Learning Curve]]></category>

		<guid isPermaLink="false">http://www.boyfarrell.com/learning-curve/chocplot-1-axis-model</guid>
		<description><![CDATA[ChocPlot is my very poorly named framework/application for plotting using Cocoa. It is still very much a work in progress, so far I have written a class called AxisModel. It can be used to generate nicely spacing axis tic marks from just two variables; the start and stop values of the axis. Please read the [...]]]></description>
			<content:encoded><![CDATA[<p>ChocPlot is my very poorly named framework/application for plotting using Cocoa. It is still very much a work in progress, so far I have written a class called AxisModel. It can be used to generate nicely spacing axis tic marks from just two variables; the start and stop values of the axis.</p>
<p>Please read the <a href="http://www.boyfarrell.com/code/chocplot/doc/v1-1/index.html">on-line documentation</a> and get the <a href="http://www.boyfarrell.com/code/chocplot/src/AxisModel.1.0.tar.gz">source </a>. Alternatively, download the whole <a href="http://www.boyfarrell.com/code/chocplot/src/ChocPlot-1.0.zip">XCode Project</a>.</p>
<h2>Example</h2>
<p><code lang="objc"><br />
/*<br />
axis with automatically positioned tic marks but with the number supplied by the user<br />
*/<br />
CPAxisModel *axis = [CPAxisModel axisWithStart:1 stop:10];<br />
NSLog([axis description]);<br />
// (0, 2, 4, 6, 8, 10)<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.boyfarrell.com/learning-curve/chocplot-1-axis-model/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Determining Line-Endings</title>
		<link>http://www.boyfarrell.com/learning-curve/determining-line-endings</link>
		<comments>http://www.boyfarrell.com/learning-curve/determining-line-endings#comments</comments>
		<pubDate>Fri, 03 Aug 2007 18:52:25 +0000</pubDate>
		<dc:creator>boyfarrell</dc:creator>
				<category><![CDATA[Learning Curve]]></category>

		<guid isPermaLink="false">http://www.boyfarrell.com/uncategorised/determining-line-endings</guid>
		<description><![CDATA[If you need to find the line endings of a particular text file from inside a Objective-C or Cocoa application have a look the example code here: Line-Endings Xcode Project (24kb) Un-zip the package on you Desktop, (I have hard coded the link to the test file relative to the users desktop), open the xcode [...]]]></description>
			<content:encoded><![CDATA[<p>If you need to find the line endings of a particular text file from inside a Objective-C or Cocoa application have a look the example code here:</p>
<p><a href="http://www.boyfarrell.com/wordpress/download-manager.php?id=3"> Line-Endings Xcode Project (24kb)</a></p>
<p><img src="http://www.boyfarrell.com/pictures/posts/determining-line-endings-1.jpg" alt="Screen shot of Xcode, showing example use of cocoa code to determing the line endings of a test file." /></p>
<p>Un-zip the package on you Desktop, (I have hard coded the link to the test file relative to the users desktop), open the xcode project then build and run.</p>
<p>The code uses a <a href="http://www.cocoadev.com/index.pl?NSStringCategory">CocoaDev.com NSStringCategory</a> method, -occurencesOfSubstring:, to find the number of line-endings in the file. The file is read using standard NSString methods, queried for the number of times the UNIX, Mac and DOS line-endings occur and the data stored. The line-endings that occur the most is thought to be representative of the whole file and returned.<br />
<strong><br />
If you find this useful, please post a comment. Or if you have a better way (simpler way) let me know too!</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.boyfarrell.com/learning-curve/determining-line-endings/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using NSDictionary to store custom classes</title>
		<link>http://www.boyfarrell.com/learning-curve/using-nsdictionary-to-store-custom-classes</link>
		<comments>http://www.boyfarrell.com/learning-curve/using-nsdictionary-to-store-custom-classes#comments</comments>
		<pubDate>Sun, 27 May 2007 22:18:29 +0000</pubDate>
		<dc:creator>boyfarrell</dc:creator>
				<category><![CDATA[Learning Curve]]></category>

		<guid isPermaLink="false">http://www.boyfarrell.com/learning-curve/using-nsdictionary-to-store-custom-classes</guid>
		<description><![CDATA[If you want to integrate your code with Cocoa, you will sooner or later find yourself wanting to store your objects; or use them as keys, in a NSDictionary. Before they can be use in this way you must first implement two methods that cocoa collection classes expect; -(unsigned) hash; and -(BOOL)isEqual:. Hashing is a [...]]]></description>
			<content:encoded><![CDATA[<p>If you want to integrate your code with Cocoa, you will sooner or later find yourself wanting to store your objects; or use them as keys, in a <code>NSDictionary</code>. Before they can be use in this way you must first implement two methods that cocoa collection classes expect; </p>
<p><code>-(unsigned) hash;</code> and </p>
<p><code>-(BOOL)isEqual:</code>. </p>
<p>Hashing is a method of increasing the efficiency of lookups for data in collections; this method is used by <code>NSDictionary</code>. The check for equality is also required as it is closely related to the value of the hash. Cocoa assumes that if two objects have the same hash then they must be equal.</p>
<p>In searching the net <a href="http://www.cocoadev.com/index.pl?HashingAndEquality">CocoaDev has a nice page on implementing hash and isEqual</a> which will also point you in the direction of <a href="http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaObjects/chapter_3_section_7.html">Apple&#8217;s original documentaion on the matter</a>.</p>
<p>The basic premise of the above articles is to add 3 methods to your class; <code>hash</code> and <code>isEqual</code> which are overridden inherited methods and <code>isEqualToYourClass:</code>, which it your custom method specific to the class which will be called by the previous method. <B>NB</B> &#8211; obviously replace &#8216;&#8230;YourClass:&#8217; with the name of your your class when naming this method!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.boyfarrell.com/learning-curve/using-nsdictionary-to-store-custom-classes/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Implementing Object Copy</title>
		<link>http://www.boyfarrell.com/learning-curve/implementing-object-copy</link>
		<comments>http://www.boyfarrell.com/learning-curve/implementing-object-copy#comments</comments>
		<pubDate>Thu, 26 Apr 2007 16:39:52 +0000</pubDate>
		<dc:creator>boyfarrell</dc:creator>
				<category><![CDATA[Learning Curve]]></category>

		<guid isPermaLink="false">http://www.boyfarrell.com/learning-curve/implementing-object-copy</guid>
		<description><![CDATA[Found a handy little reference today (click link below) about conforming to the NSCoding Protocol: Apple Conceptual Cocoa Documentation If you want your objects to be become part of NSDictionary classes then you will need to add the -copyWithZone: method in your class. If your objects only contain primative types such as double, int, BOOL [...]]]></description>
			<content:encoded><![CDATA[<p>Found a handy little reference today (click link below) about conforming to the <code>NSCoding</code> Protocol:</p>
<p><a href="http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/Tasks/ImplementCopy.html"> Apple Conceptual Cocoa Documentation </a></p>
<p>If you want your objects to be become part of <code>NSDictionary</code> classes then you will need to add the <code>-copyWithZone:</code> method in your class. If your objects only contain primative types such as double, int, BOOL etc. then the copying is fairly straight forward. Override <code>-copyWithZone:</code> method in which you create a new object inside assign the current variables and return it. </p>
<p>However, it is more common to have objects in ones classes in this situation there are different &#8216;levels&#8217; of copying; &#8216;shallow&#8217; and &#8216;deep&#8217;. Both require that you return an new object. The difference arrives from how the instance variables are linked to the copy.</p>
<p>In a shallow copy one simply copies the pointers to the original object. This has the consequence of making the data shared.</p>
<p>A deep refers to the process of giving the copy allocating new copies for all (even those inherited) instance variables the object has. This technique is more a &#8216;snap-shot&#8217; of the state of the object at that particular point in time.</p>
<h2>Example Class</h2>
<p>If I have an object representing a point in 3D space with primative data types,</p>
<p><code><br />
@interface DJFPoint : NSObject {<br />
	unsigned int x,y,z;<br />
}<br />
- (unsigned int) x;<br />
- (unsigned int) y;<br />
- (unsigned int) z;</p>
<p>- (void) setX: (unsigned int) newX;<br />
- (void) setY: (unsigned int) newY;<br />
- (void) setZ: (unsigned int) newZ;<br />
</code></p>
<p>the most sensible copy is by value.</p>
<h2>Override -copyWithZone:</h2>
<p><code>- (id) copyWithZone:(NSZone*) zone{<br />
DJFPoint *copy = [[DJFPoint alloc] init];<br />
[copy setX:[self x]];<br />
[copy setY:[self y]];<br />
[copy setZ:[self z]];</p>
<p>return copy;<br />
}</code></p>
<p>See the apple article for lots of useful examples on this.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.boyfarrell.com/learning-curve/implementing-object-copy/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
