<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Ananth's very own blog</title>
	
	<link>http://www.ananthonline.net</link>
	<description>of .C#, .NET, GPUs and other assorted knick-knacks.</description>
	<lastBuildDate>Thu, 12 Aug 2010 02:19:30 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/AnanthsBlog" /><feedburner:info uri="ananthsblog" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:browserFriendly></feedburner:browserFriendly><item>
		<title>OpenCL.Net published!</title>
		<link>http://www.ananthonline.net/blog/general/opencl-net-published</link>
		<comments>http://www.ananthonline.net/blog/general/opencl-net-published#comments</comments>
		<pubDate>Tue, 20 Jul 2010 13:20:00 +0000</pubDate>
		<dc:creator>ananth</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Blog]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[OpenCL]]></category>

		<guid isPermaLink="false">http://www.ananthonline.net/blog/general/opencl-net-published</guid>
		<description><![CDATA[<p>I just published my version of .NET bindings for OpenCL over on Codeplex last night. Why another, you ask? There’s already so many out there … Cloo, OpenCL.NET from hoopoe and another OpenCL.Net over at Sourceforge (and more?). Well, …</p>

Every API out there has an object-oriented version of the API that’s easily usable from .NET. Sure, <span style="color:#777"> . . . &#8594; Read More: <a href="http://www.ananthonline.net/blog/general/opencl-net-published">OpenCL.Net published!</a></span>]]></description>
			<content:encoded><![CDATA[<p>I just published my version of <a href="http://openclnet.codeplex.com/">.NET bindings for OpenCL</a> over on Codeplex last night. Why another, you ask? There’s already so many out there … <a href="http://www.opentk.com/project/cloo">Cloo</a>, <a href="http://www.hoopoe-cloud.com/Solutions/OpenCL.NET/Default.aspx">OpenCL.NET from hoopoe</a> and another <a href="http://sourceforge.net/projects/openclnet/">OpenCL.Net over at Sourceforge</a> (and more?). Well, …</p>
<ul>
<li>Every API out there has an object-oriented version of the API that’s easily usable from .NET. Sure, it’s easy … but looks very different from the raw OpenCL API if I wanted to use it, right? There’s reason #1 right there. I wanted a set of .NET bindings that look, feel and act like the C-style API so I (read: the users) could port existing samples or read books/tutorials and understand what’s going on.</li>
<li>Which brings us to our second question: Don’t all of the mentioned bindings also have the C-style API exposed? Sure, they do. But some of them mark the exposed API as unsafe, use of which would force users to mark their own projects as unsafe too. Secondly, every set of bindings I saw had raw translations of the API transliterating &lt;anything&gt;* to IntPtr (and others along those lines) meaning we have to use their OO abstractions to get anything done easily. I wanted something more .NET friendly at the API level, however.</li>
</ul>
<p>So I guess the reason I wrote my own bindings is: I wanted to strike the middle ground between OO + .NET friendly and raw API translation. You can find this over at <a href="http://openclnet.codeplex.com/">Codeplex</a>. The API isn’t complete yet, but some things I’m particularly happy about are:</p>
<ol>
<li>No unsafe code (yet).</li>
<li>Everything is .NET friendly AND you can use it as you would the raw API (overloads).</li>
<li>As little explicit marshaling as possible, in fact all the exposed methods that invoke the extern’d methods in OpenCL.dll are only one call/line.</li>
</ol>
<p>Initially, I started with these bindings for my project <a href="http://brahma.ananthonline.net">Brahma</a>, but decided it was a large enough effort to put up separately. I hope people find it useful alongside the other tools for OpenCL for .NET that are already available. I hope to have the API completed and released soon. Stay tuned.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ananthonline.net/blog/general/opencl-net-published/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Parsing command line arguments with C# &amp; LINQ</title>
		<link>http://www.ananthonline.net/blog/dotnet/parsing-command-line-arguments-with-c-linq</link>
		<comments>http://www.ananthonline.net/blog/dotnet/parsing-command-line-arguments-with-c-linq#comments</comments>
		<pubDate>Fri, 02 Jul 2010 01:39:00 +0000</pubDate>
		<dc:creator>ananth</dc:creator>
				<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">http://www.ananthonline.net/blog/dotnet/parsing-command-line-arguments-with-c-linq/</guid>
		<description><![CDATA[<p>Whenever I sit down to write an application (mostly a console application), I find myself wishing I had some code I could just drop in to parse command line arguments with. A friend of mine has authored the excellent ConsoleFX library, and it&#8217;s really good if you want to do heavy processing, validations and complex command <span style="color:#777"> . . . &#8594; Read More: <a href="http://www.ananthonline.net/blog/dotnet/parsing-command-line-arguments-with-c-linq">Parsing command line arguments with C# &#38; LINQ</a></span>]]></description>
			<content:encoded><![CDATA[<p>Whenever I sit down to write an application (mostly a console application), I find myself wishing I had some code I could just drop in to parse command line arguments with. A friend of mine has authored the excellent ConsoleFX library, and it&#8217;s really good if you want to do heavy processing, validations and complex command line argument structures with help. Most of the time, however, I don&#8217;t.</p>
<p>So I spent the better part of my evening writing something that I hope I will be able to carry around as a code snippet small enough to use anytime, anywhere in an elegant fashion.</p>
<pre class="csharp" style="background-color: #ffffff; font-family: consolas, monospace; font-size: small;">
<ol>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;"><span style="color: #008080;">#region CommandLine</span></div>
</li>
<li style="background-color: #f4f4f4;"></li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;"><span style="color: #0600ff; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">class</span> CommandLine</div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;"><span style="color: #008000;">{</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">	<span style="color: #0600ff; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> <span style="color: #0600ff; font-weight: bold;">Switch</span> <span style="font-style: italic; color: #008080;">// Class that encapsulates switch data. Not meant for direct use.</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">	<span style="color: #008000;">{</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="color: #0600ff; font-weight: bold;">public</span> <span style="color: #0600ff; font-weight: bold;">Switch</span><span style="color: #008000;">(</span><span style="color: #6666cc; font-weight: bold;">string</span> name, Action<span style="color: #008000;">&lt;</span>IEnumerable<span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&gt;&gt;</span> handler, <span style="color: #6666cc; font-weight: bold;">string</span> shortForm <span style="color: #008000;">=</span> <span style="color: #0600ff; font-weight: bold;">null</span><span style="color: #008000;">)</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="color: #008000;">{</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">			Name <span style="color: #008000;">=</span> name<span style="color: #008000;">;</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">			Handler <span style="color: #008000;">=</span> handler<span style="color: #008000;">;</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">			ShortForm <span style="color: #008000;">=</span> shortForm<span style="color: #008000;">;</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="color: #008000;">}</span></div>
</li>
<li style="font-color: #aaaaaa;"></li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="color: #0600ff; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> Name</div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="color: #008000;">{</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">			get<span style="color: #008000;">;</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">			<span style="color: #0600ff; font-weight: bold;">private</span> set<span style="color: #008000;">;</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="color: #008000;">}</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="color: #0600ff; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> ShortForm</div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="color: #008000;">{</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">			get<span style="color: #008000;">;</span> <span style="color: #0600ff; font-weight: bold;">private</span> set<span style="color: #008000;">;</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="color: #008000;">}</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="color: #0600ff; font-weight: bold;">public</span> Action<span style="color: #008000;">&lt;</span>IEnumerable<span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&gt;&gt;</span> Handler</div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="color: #008000;">{</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">			get<span style="color: #008000;">;</span> <span style="color: #0600ff; font-weight: bold;">private</span> set<span style="color: #008000;">;</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="color: #008000;">}</span></div>
</li>
<li style="font-color: #aaaaaa;"></li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="color: #0600ff; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> InvokeHandler<span style="color: #008000;">(</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">[</span><span style="color: #008000;">]</span> values<span style="color: #008000;">)</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="color: #008000;">{</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">			Handler<span style="color: #008000;">(</span>values<span style="color: #008000;">)</span><span style="color: #008000;">;</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">			<span style="color: #0600ff; font-weight: bold;">return</span> <span style="color: #ff0000;">1</span><span style="color: #008000;">;</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="color: #008000;">}</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">	<span style="color: #008000;">}</span></div>
</li>
<li style="background-color: #f4f4f4;"></li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">	<span style="font-style: italic; color: #008080;">// The regex that extracts names and comma-separated values for switches </span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">	<span style="font-style: italic; color: #008080;">// in the form (&lt;switch&gt;[:value,value,value])+</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">	<span style="color: #0600ff; font-weight: bold;">private</span> <span style="color: #0600ff; font-weight: bold;">static</span> <span style="color: #0600ff; font-weight: bold;">readonly</span> Regex _regex <span style="color: #008000;">=</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Regex<span style="color: #008000;">(</span><span style="color: #666666;">@"\s*(?&lt;switch&gt;(?&lt;name&gt;\w+)(:\s*(?&lt;value&gt;\w+(\s*,\s*\w+)*))?)"</span>,</div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">			RegexOptions<span style="color: #008000;">.</span><span style="color: #0000ff;">Compiled</span> <span style="color: #008000;">|</span> RegexOptions<span style="color: #008000;">.</span><span style="color: #0000ff;">CultureInvariant</span> <span style="color: #008000;">|</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">			RegexOptions<span style="color: #008000;">.</span><span style="color: #0000ff;">ExplicitCapture</span> <span style="color: #008000;">|</span> RegexOptions<span style="color: #008000;">.</span><span style="color: #0000ff;">IgnoreCase</span><span style="color: #008000;">)</span><span style="color: #008000;">;</span></div>
</li>
<li style="font-color: #aaaaaa;"></li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">	<span style="color: #0600ff; font-weight: bold;">private</span> <span style="color: #0600ff; font-weight: bold;">const</span> <span style="color: #6666cc; font-weight: bold;">string</span> NameGroup <span style="color: #008000;">=</span> <span style="color: #666666;">"name"</span><span style="color: #008000;">;</span> <span style="font-style: italic; color: #008080;">// Names of capture groups</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">	<span style="color: #0600ff; font-weight: bold;">private</span> <span style="color: #0600ff; font-weight: bold;">const</span> <span style="color: #6666cc; font-weight: bold;">string</span> ValueGroup <span style="color: #008000;">=</span> <span style="color: #666666;">"value"</span><span style="color: #008000;">;</span></div>
</li>
<li style="background-color: #f4f4f4;"></li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">	<span style="color: #0600ff; font-weight: bold;">public</span> <span style="color: #0600ff; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">void</span> Process<span style="color: #008000;">(</span><span style="color: #0600ff; font-weight: bold;">this</span> <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">[</span><span style="color: #008000;">]</span> args, Action printUsage, <span style="color: #0600ff; font-weight: bold;">params</span> <span style="color: #0600ff; font-weight: bold;">Switch</span><span style="color: #008000;">[</span><span style="color: #008000;">]</span> switches<span style="color: #008000;">)</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">	<span style="color: #008000;">{</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="font-style: italic; color: #008080;">// Run through all matches in the concatenated argument list and if any</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="font-style: italic; color: #008080;">// of the switches match, get the values and invoke the handler we were</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="font-style: italic; color: #008080;">// given. We do a Sum() here for 2 reasons; a) To actually run the handlers</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="font-style: italic; color: #008080;">// and b) see if any were invoked at all (each returns 1 if invoked).</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="font-style: italic; color: #008080;">// If none were invoked, we simply invoke the printUsage handler.</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="color: #0600ff; font-weight: bold;">if</span> <span style="color: #008000;">(</span><span style="color: #008000;">(</span><span style="color: #0600ff; font-weight: bold;">from</span> Match match <span style="color: #0600ff; font-weight: bold;">in</span> _regex<span style="color: #008000;">.</span><span style="color: #0000ff;">Matches</span><span style="color: #008000;">(</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000ff;">Join</span><span style="color: #008000;">(</span><span style="color: #666666;">" "</span>, args<span style="color: #008000;">)</span><span style="color: #008000;">)</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">			 <span style="color: #0600ff; font-weight: bold;">from</span> arg <span style="color: #0600ff; font-weight: bold;">in</span> switches</div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">			 <span style="color: #0600ff; font-weight: bold;">where</span> match<span style="color: #008000;">.</span><span style="color: #0000ff;">Success</span> <span style="color: #008000;">&amp;&amp;</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">				   <span style="color: #008000;">(</span><span style="color: #008000;">(</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000ff;">Compare</span><span style="color: #008000;">(</span>match<span style="color: #008000;">.</span><span style="color: #0000ff;">Groups</span><span style="color: #008000;">[</span>NameGroup<span style="color: #008000;">]</span><span style="color: #008000;">.</span><span style="color: #0000ff;">Value</span>, arg<span style="color: #008000;">.</span><span style="color: #0000ff;">Name</span>, <span style="color: #0600ff; font-weight: bold;">true</span><span style="color: #008000;">)</span> <span style="color: #008000;">==</span> <span style="color: #ff0000;">0</span><span style="color: #008000;">)</span> <span style="color: #008000;">||</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">					<span style="color: #008000;">(</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000ff;">Compare</span><span style="color: #008000;">(</span>match<span style="color: #008000;">.</span><span style="color: #0000ff;">Groups</span><span style="color: #008000;">[</span>NameGroup<span style="color: #008000;">]</span><span style="color: #008000;">.</span><span style="color: #0000ff;">Value</span>, arg<span style="color: #008000;">.</span><span style="color: #0000ff;">ShortForm</span>, <span style="color: #0600ff; font-weight: bold;">true</span><span style="color: #008000;">)</span> <span style="color: #008000;">==</span> <span style="color: #ff0000;">0</span><span style="color: #008000;">)</span><span style="color: #008000;">)</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">			 <span style="color: #0600ff; font-weight: bold;">select</span> arg<span style="color: #008000;">.</span><span style="color: #0000ff;">InvokeHandler</span><span style="color: #008000;">(</span>match<span style="color: #008000;">.</span><span style="color: #0000ff;">Groups</span><span style="color: #008000;">[</span>ValueGroup<span style="color: #008000;">]</span><span style="color: #008000;">.</span><span style="color: #0000ff;">Value</span><span style="color: #008000;">.</span><span style="color: #0000ff;">Split</span><span style="color: #008000;">(</span><span style="color: #666666;">','</span><span style="color: #008000;">)</span><span style="color: #008000;">)</span><span style="color: #008000;">)</span><span style="color: #008000;">.</span><span style="color: #0000ff;">Sum</span><span style="color: #008000;">(</span><span style="color: #008000;">)</span> <span style="color: #008000;">==</span> <span style="color: #ff0000;">0</span><span style="color: #008000;">)</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">			printUsage<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008000;">;</span> <span style="font-style: italic; color: #008080;">// We didn't find any switches</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">	<span style="color: #008000;">}</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;"><span style="color: #008000;">}</span></div>
</li>
<li style="font-color: #aaaaaa;"></li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;"><span style="color: #008080;">#endregion</span></div>
</li>
<li style="font-color: #aaaaaa;"></li>
</ol>
</pre>
<p>All of the magic happens inside the Process method, where the query tries to match the arguments against the ones we want to check for. The .Sum() aggregate method does two things.</p>
<ol>
<li>It enumerates the elements of the IQueryable, actually calling the handlers in the process. Nothing happens till then!</li>
<li>Each of the InvokeHandler calls returns 1, so the result of the .Sum() is 0 if there were no matches (which is when we call the supplied printUsage handler).</li>
</ol>
<p>Neat, huh? Using it is even simpler!</p>
<pre class="csharp" style="background-color: #ffffff; font-family: consolas, monospace; font-size: x-small;">
<ol>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">            args<span style="color: #008000;">.</span><span style="color: #0000ff;">Process</span><span style="color: #008000;">(</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">                <span style="color: #008000;">(</span><span style="color: #008000;">)</span> <span style="color: #008000;">=&gt;</span> Console<span style="color: #008000;">.</span><span style="color: #0000ff;">WriteLine</span><span style="color: #008000;">(</span><span style="color: #666666;">"Usage is switch0:value switch:value switch2"</span><span style="color: #008000;">)</span>,</div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">                <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> CommandLine<span style="color: #008000;">.</span><span style="color: #0600ff; font-weight: bold;">Switch</span><span style="color: #008000;">(</span><span style="color: #666666;">"switch0"</span>,</div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">                    val <span style="color: #008000;">=&gt;</span> Console<span style="color: #008000;">.</span><span style="color: #0000ff;">WriteLine</span><span style="color: #008000;">(</span><span style="color: #666666;">"switch 0 with value {0}"</span>,</div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">                        <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000ff;">Join</span><span style="color: #008000;">(</span><span style="color: #666666;">" "</span>, val<span style="color: #008000;">)</span><span style="color: #008000;">)</span><span style="color: #008000;">)</span>,</div>
</li>
<li style="background-color: #f4f4f4;"></li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">                <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> CommandLine<span style="color: #008000;">.</span><span style="color: #0600ff; font-weight: bold;">Switch</span><span style="color: #008000;">(</span><span style="color: #666666;">"switch1"</span>,</div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">                    val <span style="color: #008000;">=&gt;</span> Console<span style="color: #008000;">.</span><span style="color: #0000ff;">WriteLine</span><span style="color: #008000;">(</span><span style="color: #666666;">"switch 1 with value {0}"</span>,</div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">                        <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000ff;">Join</span><span style="color: #008000;">(</span><span style="color: #666666;">" "</span>, val<span style="color: #008000;">)</span><span style="color: #008000;">)</span>, <span style="color: #666666;">"s1"</span><span style="color: #008000;">)</span>,</div>
</li>
<li style="background-color: #f4f4f4;"></li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">                <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> CommandLine<span style="color: #008000;">.</span><span style="color: #0600ff; font-weight: bold;">Switch</span><span style="color: #008000;">(</span><span style="color: #666666;">"switch2"</span>,</div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">                    val <span style="color: #008000;">=&gt;</span> Console<span style="color: #008000;">.</span><span style="color: #0000ff;">WriteLine</span><span style="color: #008000;">(</span><span style="color: #666666;">"switch 2 with value {0}"</span>,</div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">                        <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000ff;">Join</span><span style="color: #008000;">(</span><span style="color: #666666;">" "</span>, val<span style="color: #008000;">)</span><span style="color: #008000;">)</span><span style="color: #008000;">)</span><span style="color: #008000;">)</span><span style="color: #008000;">;</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">        <span style="color: #008000;">}</span></div>
</li>
<li style="font-color: #aaaaaa;"></li>
</ol>
</pre>
<p>Any handlers you provide will be called for each switch or it&#8217;s shortform(if found, of course). Now get started writing those fantastic console applications.</p>
<p>Obligatory disclaimer and <a href="http://sam.zoy.org/wtfpl/">License</a>: The code above is for you to do whatever you want to. Even if it blows you up (like <a href="http://www.youtube.com/watch?v=OKTlkG5CdF4&amp;feature=related">Dr. Manhattan blows Rorschach up</a>), don&#8217;t come back from the dead to haunt me. I would, however appreciate it if you kept the comment attributing that code to me.</p>
<div id="scid:8eb9d37f-1541-4f29-b6f4-1eea890d4876:3e53c8a2-e654-480f-ae95-ad957ca154c8" class="wlWriterEditableSmartContent" style="margin: 0px; display: inline; float: none; padding: 0px;">
<div id="scid:8eb9d37f-1541-4f29-b6f4-1eea890d4876:3e53c8a2-e654-480f-ae95-ad957ca154c8" class="wlWriterSmartContent" style="margin: 0px; display: inline; float: none; padding: 0px;">
<p>Double Edit: Modified the Regex so it can accept quoted parameters (even filenames).</p>
<div id="scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:681f230e-9598-44dd-bdb7-aca9b5c7fcb1" class="wlWriterSmartContent" style="margin: 0px; display: inline; float: none; padding: 0px;">
<p>Download <a href="http://www.ananthonline.net/downloads/Parsingcommandlinearguments_13/cmdparser.snippet" target="_blank">cmdparser.snippet</a></p>
</div>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.ananthonline.net/blog/dotnet/parsing-command-line-arguments-with-c-linq/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Website upgrade</title>
		<link>http://www.ananthonline.net/blog/general/website-upgrade</link>
		<comments>http://www.ananthonline.net/blog/general/website-upgrade#comments</comments>
		<pubDate>Tue, 08 Jun 2010 13:07:00 +0000</pubDate>
		<dc:creator>ananth</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.ananthonline.net/blog/?p=50</guid>
		<description><![CDATA[<p>I recently had to upgrade the Wordpress installation on my website, and decided to do a bunch of housecleaning besides.    </p>
<p>I&#8217;d been looking for a good content management system that allows me to keep a blog, wiki(s) and forums (across different subdomains &#8211; brahma, blog, etc.) and I couldn&#8217;t find anything easy to <span style="color:#777"> . . . &#8594; Read More: <a href="http://www.ananthonline.net/blog/general/website-upgrade">Website upgrade</a></span>]]></description>
			<content:encoded><![CDATA[<p>I recently had to upgrade the Wordpress installation on my website, and decided to do a bunch of housecleaning besides.    </p>
<p>I&#8217;d been looking for a good content management system that allows me to keep a blog, wiki(s) and forums (across different subdomains &#8211; brahma, blog, etc.) and I couldn&#8217;t find anything easy to use and powerful at the same time. I&#8217;m a big stickler for themes and I hate having to manage and re-theme different applications to look the same. </p>
<p>After a lot of searching, I&#8217;ve decided to use Wordpress as my CMS and am going to be trying out these wonderful plugins:</p>
<ol>
<li><a href="http://wp-wiki.org/" target="_blank">Wordpress Wiki</a> &#8211; This looks interesting, although I have no idea how I&#8217;m going to integrate this into a subdomain.domain.net/wiki URL structure. If anyone has any ideas, I&#8217;ll be glad to hear them. </li>
<li><a href="http://simple-press.com/" target="_blank">Simple Press</a> &#8211; This is the other thing I wanted on my website, and I&#8217;m quite happy Wordpress has a plugin for it. </li>
</ol>
<p>Unfortunately, to do a lot of this, I might have to shuffle some URLs and pages around. I will do my best to keep the site as functional as possible (perhaps even resorting to the evil redirection trick), but if you can&#8217;t find anything or see a problem with the website, please contact me so I can fix the problem. Thanks!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ananthonline.net/blog/general/website-upgrade/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ATI Stream SDK on non-AMD machines</title>
		<link>http://www.ananthonline.net/blog/opencl/ati-stream-sdk-on-non-amd-machines</link>
		<comments>http://www.ananthonline.net/blog/opencl/ati-stream-sdk-on-non-amd-machines#comments</comments>
		<pubDate>Mon, 18 Jan 2010 02:15:00 +0000</pubDate>
		<dc:creator>ananth</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[OpenCL]]></category>

		<guid isPermaLink="false">http://blog.ananthonline.net/?p=43</guid>
		<description><![CDATA[<p>It seems the ATI stream SDK installer doesn&#8217;t install anything but the OpenCL profiler on machines with no AMD/ATI hardware. Running the MSI&#8217;s from &#8220;C:\C:\ATI\SUPPORT\streamsdk_2-0-0_XXXX\Packages\Apps\&#8221; folder seems to install OpenCL (CPU only, of course) support for me.</p>
<p>Note: I originally found this solution on geeks3d.com.</p>
<p>&#8211; Edit &#8212;
ATI/AMD have since fixed this, and everything installs with the latest <span style="color:#777"> . . . &#8594; Read More: <a href="http://www.ananthonline.net/blog/opencl/ati-stream-sdk-on-non-amd-machines">ATI Stream SDK on non-AMD machines</a></span>]]></description>
			<content:encoded><![CDATA[<p>It seems the ATI stream SDK installer doesn&#8217;t install anything but the OpenCL profiler on machines with no AMD/ATI hardware. Running the MSI&#8217;s from &#8220;C:\C:\ATI\SUPPORT\streamsdk_2-0-0_XXXX\Packages\Apps\&#8221; folder seems to install OpenCL (CPU only, of course) support for me.</p>
<p>Note: I originally found this solution on <a href="http://www.geeks3d.com/20091222/gpu-caps-viewer-1-8-1-updated-for-ati-stream-sdk-v2-0-0/comment-page-1/#comment-9142" target="_blank">geeks3d.com</a>.</p>
<p>&#8211; Edit &#8212;<br />
ATI/AMD have since fixed this, and everything installs with the latest version of the <a href="http://developer.amd.com/gpu/atistreamsdk/pages/default.aspx">Stream SDK</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ananthonline.net/blog/opencl/ati-stream-sdk-on-non-amd-machines/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Brahma and OpenCL</title>
		<link>http://www.ananthonline.net/blog/gpgpu/brahma-and-opencl</link>
		<comments>http://www.ananthonline.net/blog/gpgpu/brahma-and-opencl#comments</comments>
		<pubDate>Tue, 12 Jan 2010 03:48:37 +0000</pubDate>
		<dc:creator>ananth</dc:creator>
				<category><![CDATA[Brahma]]></category>
		<category><![CDATA[GPGPU]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[OpenCL]]></category>

		<guid isPermaLink="false">http://blog.ananthonline.net/?p=42</guid>
		<description><![CDATA[<p>Despite the lack of updates on this site, I have been hard at work on a new provider, Brahma.OpenCL. I am very excited at all the possibilities that OpenCL brings to the table. I will try to summarize some of the new features that OpenCL will bring to Brahma.</p>

Different memory pools &#8211; OpenCL supports the idea <span style="color:#777"> . . . &#8594; Read More: <a href="http://www.ananthonline.net/blog/gpgpu/brahma-and-opencl">Brahma and OpenCL</a></span>]]></description>
			<content:encoded><![CDATA[<p>Despite the lack of updates on this site, I have been hard at work on a new provider, Brahma.OpenCL. I am very excited at all the possibilities that OpenCL brings to the table. I will try to summarize some of the new features that OpenCL will bring to Brahma.</p>
<ol>
<li><strong>Different memory pools</strong> &#8211; OpenCL supports the idea of host memory, device memory and host-addressable memory. Brahma will allow the creation of DataParallelArrays in these memory pools and will allow host-addressable memory (and host memory) to maintain only one copy of the data. </li>
<li><strong>Asynchronous operations</strong> &#8211; OpenCL supports the idea of asynchronous operations (data-transfers, concurrent kernel execution) and now so does Brahma. Brahma will also allow the user to introduce &#8220;fences&#8221; in any command queue for fork-join parallelism. </li>
<li><strong>Free memory-layout</strong> &#8211; Because memory layouts vary across applications (Morton coding, bricking, overlapped bricks or other index based arbitrary data-structures), DataParallelArrays will now be independent of layout (with a layout manager YOU provide &#8211; or use a stock one). This means Data-ParallelArrays will now have arbitrary dimensionality. </li>
<li><strong>Arbitrary data</strong> &#8211; This is perhaps very exciting. DataParallelArrays can now contain any kind of <a href="http://msdn.microsoft.com/en-us/library/75dwhxf7.aspx">blittable struct</a>. So, if you&#8217;re working with an equation that requires two floats and an int called a, b and factor; you can create a struct with those members and use them in your calculations! </li>
</ol>
<p>And, to whet your appetite; here&#8217;s what Brahma.OpenCL code will look like.</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 138.74%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; height: 210px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #008000">// Create compiled, named query</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">CompiledQuery query = </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    _provider.Compile(<span style="color: #006080">&quot;q1&quot;</span>, (d1, d2) =&gt; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            from val1 <span style="color: #0000ff">in</span> d1</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            from val2 <span style="color: #0000ff">in</span> d2</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            select <span style="color: #0000ff">new</span> Coefficients </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            { </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">              a = val1.a + val2.a, </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">              b = 0f,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">              factor = a.factor++</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            });</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #008000">// Create a dataparallel array, and provide a</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #008000">// memory layout implementation, and a pool to use</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">var d1 = <span style="color: #0000ff">new</span> DataParallelArray&lt;Coefficients&gt;(</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    _provider, <span style="color: #0000ff">null</span>, length,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">new</span> LinearMemoryLayout(length), Pool.Shared);</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #008000">// Create a command that takes the array and </span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #008000">// a GetValues lambda</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #008000">// but - don't do anything just yet</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">var transferd1 += Command.Transfer(d1, </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    x =&gt; <span style="color: #0000ff">new</span> Coefficients</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">             {</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                 a = 0.0, </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                 b = 1.0, </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                 factor = 0</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">             });</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #008000">// Ditto for d2 - create ...</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">var d2 = <span style="color: #0000ff">new</span> DataParallelArray&lt;Coefficients&gt;(</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    _provider, <span style="color: #0000ff">null</span>, length,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">new</span> LinearMemoryLayout(length), Pool.Shared);</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #008000">// ... and create a transfer command</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">var transferd2 += Command.Transfer(d1, </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    x =&gt; <span style="color: #0000ff">new</span> Coefficients</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">             {</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                 a = 0.0, </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                 b = 1.0, </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                 factor = 0</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">             });</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #008000">// Queue 0 - add the transfer command</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">_provider.CommandQueues[0] += transferd1;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #008000">// Queue 1 - add the transfer </span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #008000">// and wait for transferd1</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">_provider.CommandQueues[1] += </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">new</span>[]</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        {</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            transferd2, </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            Command.Wait(transferd1)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        };</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #008000">// Begin running commands on queues 0 and 1</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">ResultSet results = _provider.Run(0, 1);</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #008000">// Access results from the result-set <img src='http://www.ananthonline.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">foreach</span> (Coefficient coeff <span style="color: #0000ff">in</span> results[<span style="color: #006080">&quot;q1&quot;</span>])</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    ...</pre>
<p><!--CRLF--></div>
</div>
<p>Hope that got you excited . I would love to hear comments and suggestions from everyone!</p>
<p><em>For those of you who have written to me and not received a reply, please write to me again, these past few months have been terribly hectic; settling down in a new job in a new country.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ananthonline.net/blog/gpgpu/brahma-and-opencl/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Brahma on Wikipedia</title>
		<link>http://www.ananthonline.net/blog/general/brahma-on-wikipedia</link>
		<comments>http://www.ananthonline.net/blog/general/brahma-on-wikipedia#comments</comments>
		<pubDate>Wed, 21 Oct 2009 14:33:00 +0000</pubDate>
		<dc:creator>ananth</dc:creator>
				<category><![CDATA[Brahma]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://blog.ananthonline.net/?p=41</guid>
		<description><![CDATA[<p>I just found out this morning that a link to the Brahma website has made it into Wikipedia (under the topic GPGPU). Cool!</p>
<p>The lack of updates on Brahma is because I have moved to the United States (early this month) and will be living and working here from now. It&#8217;s been crazy busy getting settled in. <span style="color:#777"> . . . &#8594; Read More: <a href="http://www.ananthonline.net/blog/general/brahma-on-wikipedia">Brahma on Wikipedia</a></span>]]></description>
			<content:encoded><![CDATA[<p>I just found out this morning that a <a href="http://en.wikipedia.org/wiki/GPGPU#See_also">link</a> to the Brahma website has made it into Wikipedia (under the topic GPGPU). Cool!</p>
<p>The lack of updates on Brahma is because I have moved to the United States (early this month) and will be living and working here from now. It&#8217;s been crazy busy getting settled in. I have been working on Brahma in my spare time, though. DataParallelArray3D will probably be the first feature out. Stay tuned.</p>
<p>My sincere apologies to anyone who emailed me in this past month, I will get around to responding to you real soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ananthonline.net/blog/general/brahma-on-wikipedia/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Interview up on DotNetRocks!</title>
		<link>http://www.ananthonline.net/blog/general/interview-up-on-dotnetrocks</link>
		<comments>http://www.ananthonline.net/blog/general/interview-up-on-dotnetrocks#comments</comments>
		<pubDate>Thu, 23 Jul 2009 13:50:00 +0000</pubDate>
		<dc:creator>ananth</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Brahma]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://blog.ananthonline.net/?p=40</guid>
		<description><![CDATA[<p>My interview about Brahma is up on DotNetRocks, you can find it here. I hope this helps Brahma&#8217;s popularity and remember, contributions are most welcome (samples, help getting Brahma to run on Mono on Linux)!</p>
<p>I&#8217;ve recently had a new idea, the concept of using user-defined types with Brahma. This should (hopefully) be out soon! <span style="color:#777"> . . . &#8594; Read More: <a href="http://www.ananthonline.net/blog/general/interview-up-on-dotnetrocks">Interview up on DotNetRocks!</a></span>]]></description>
			<content:encoded><![CDATA[<p>My interview about Brahma is up on DotNetRocks, you can find it <a href="http://www.dotnetrocks.com/default.aspx?showNum=466">here</a>. I hope this helps Brahma&#8217;s popularity and remember, contributions are most welcome (samples, help getting Brahma to run on Mono on Linux)!</p>
<p>I&#8217;ve recently had a new idea, the concept of using user-defined types with Brahma. This should (hopefully) be out soon! Look out!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ananthonline.net/blog/general/interview-up-on-dotnetrocks/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Brahma on DotNetRocks</title>
		<link>http://www.ananthonline.net/blog/general/brahma-on-dotnetrocks</link>
		<comments>http://www.ananthonline.net/blog/general/brahma-on-dotnetrocks#comments</comments>
		<pubDate>Wed, 08 Jul 2009 18:02:00 +0000</pubDate>
		<dc:creator>ananth</dc:creator>
				<category><![CDATA[Brahma]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://blog.ananthonline.net/?p=39</guid>
		<description><![CDATA[<p>We all know .NET rocks. Apparently, the guys over at www.dotnetrocks.com thought Brahma rocks, too! Carl Franklin, Richard Campbell and I had an hour long conversation about Brahma; how it works and what the future for it is like.</p>
<p>It&#8217;s going to be published on the 23rd of July 2009, so watch out <span style="color:#777"> . . . &#8594; Read More: <a href="http://www.ananthonline.net/blog/general/brahma-on-dotnetrocks">Brahma on DotNetRocks</a></span>]]></description>
			<content:encoded><![CDATA[<p>We all know .NET rocks. Apparently, the guys over at <a href="http://www.dotnetrocks.com">www.dotnetrocks.com</a> thought Brahma rocks, too! Carl Franklin, Richard Campbell and I had an hour long conversation about Brahma; how it works and what the future for it is like.</p>
<p>It&#8217;s going to be published on the 23rd of July 2009, so watch out for it!</p>
<p>Awesome!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ananthonline.net/blog/general/brahma-on-dotnetrocks/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pin and Un-pin items to/from the Windows 7 taskbar</title>
		<link>http://www.ananthonline.net/blog/dotnet/pin-and-un-pin-items-tofrom-the-windows-7-taskbar</link>
		<comments>http://www.ananthonline.net/blog/dotnet/pin-and-un-pin-items-tofrom-the-windows-7-taskbar#comments</comments>
		<pubDate>Wed, 17 Jun 2009 06:26:00 +0000</pubDate>
		<dc:creator>ananth</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Windows 7]]></category>

		<guid isPermaLink="false">http://blog.ananthonline.net/?p=37</guid>
		<description><![CDATA[<p>One of the things I wanted to do with Lyre (my Windows 7 taskbar-based MP3 player), was to</p>

Figure out if a given executable is pinned to the taskbar
Un-pin it from the taskbar
Pin it back to the taskbar

<p>During my searches, I found this blog post that says programmatic access to pinning and un-pinning has been disabled for <span style="color:#777"> . . . &#8594; Read More: <a href="http://www.ananthonline.net/blog/dotnet/pin-and-un-pin-items-tofrom-the-windows-7-taskbar">Pin and Un-pin items to/from the Windows 7 taskbar</a></span>]]></description>
			<content:encoded><![CDATA[<p>One of the things I wanted to do with <a href="http://blog.ananthonline.net/?p=36">Lyre</a> (my Windows 7 taskbar-based MP3 player), was to</p>
<ol>
<li>Figure out if a given executable is pinned to the taskbar</li>
<li>Un-pin it from the taskbar</li>
<li>Pin it back to the taskbar</li>
</ol>
<p>During my searches, I found <a href="http://blogs.technet.com/deploymentguys/archive/2009/04/08/pin-items-to-the-start-menu-or-windows-7-taskbar-via-script.aspx">this</a> blog post that says programmatic access to pinning and un-pinning has been disabled for a similar reason. I did find a couple of posts <a href="http://cs.axvius.com/blogs/aaron/archive/2009/02/19/script-to-pin-item-to-taskbar-or-start-menu-in-windows-7.aspx">here</a> and <a href="http://blogs.technet.com/deploymentguys/archive/2009/04/08/pin-items-to-the-start-menu-or-windows-7-taskbar-via-script.aspx">here</a>, showing how to use a small shell script to pin and un-pin items.</p>
<p>The idea is rather simple, really. The verbs &#8220;<em>Pin to Tas&amp;kbar</em>&#8221; and &#8220;<em>Unpin from Tas&amp;kbar</em>&#8221; (the ampersand is the shortcut, it is required to directly execute the verb) are available on a shell link object. Executing one or the other will pin/unpin the specified shortcut.</p>
<p>How do we find out if an item is pinned to the taskbar? For that, we need to look in &#8220;%appdata%\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\&#8221;, where these pinned &#8220;shortcuts&#8221; live. If we find a particular executable&#8217;s shortcut there, that means it&#8217;s pinned.</p>
<p>Now that we know what we need to do, the doing is quite simple, really.</p>
<h2></h2>
<h4>Tell if a shortcut is pinned to the taskbar</h4>
<ol>
<li>Examine each shortcut in the user&#8217;s pinned items path.</li>
<li>If the path (or filename?) matches the executable you&#8217;re looking for, return true.</li>
<li>Otherwise return false.</li>
</ol>
<h4 style="width: 279px; height: 19px">Pin/Unpin items to/from the taskbar</h4>
<ol>
<li>Create a temporary shortcut to the executable we want to pin/unpin</li>
<li>Create and execute a shell script that runs the appropriate verb (&#8220;<em>Pin to Tas&amp;kbar</em>&#8221; or &#8220;<em>Unpin from Tas&amp;kbar</em>&#8220;)</li>
<li>We&#8217;re done!</li>
</ol>
<p><a href="http://blog.ananthonline.net/wp-content/uploads/2009/06/windows7taskbarextensions.zip" title="Windows7TaskbarExtensions.zip">Attached</a> is a single .cs file that contains a class called Windows7TaskbarExtensions.cs.</p>
<h6><font color="#808080">Note: I&#8217;ve used the </font><a href="http://www.msjogren.net/dotnet/eng/samples/dotnet_shelllink.asp"><font color="#808080">ShellShortcut</font></a><font color="#808080"> classes by Mattias Sjögren </font></h6>
]]></content:encoded>
			<wfw:commentRss>http://www.ananthonline.net/blog/dotnet/pin-and-un-pin-items-tofrom-the-windows-7-taskbar/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Lyre – A Windows 7 music player</title>
		<link>http://www.ananthonline.net/blog/general/lyre-a-windows-7-music-player</link>
		<comments>http://www.ananthonline.net/blog/general/lyre-a-windows-7-music-player#comments</comments>
		<pubDate>Mon, 18 May 2009 13:35:24 +0000</pubDate>
		<dc:creator>ananth</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Windows 7]]></category>

		<guid isPermaLink="false">http://blog.ananthonline.net/?p=36</guid>
		<description><![CDATA[<p>What does Windows 7 have to do with music? Nothing, really. But I&#8217;ve noticed that no one has been enterprising enough to put the Window 7 taskbar features to REALLY good use and make an mp3 player that we can use while we work (WMP team, are you listening?). I mean, who doesn&#8217;t listen to music <span style="color:#777"> . . . &#8594; Read More: <a href="http://www.ananthonline.net/blog/general/lyre-a-windows-7-music-player">Lyre &#8211; A Windows 7 music player</a></span>]]></description>
			<content:encoded><![CDATA[<p>What does Windows 7 have to do with music? Nothing, really. But I&#8217;ve noticed that no one has been enterprising enough to put the Window 7 taskbar features to REALLY good use and make an mp3 player that we can use while we work (WMP team, are you listening?). I mean, who doesn&#8217;t listen to music while working? Everyone who raised their hands can leave the room now. Just kidding.</p>
<p>Onto the good stuff. Lyre sits in your taskbar, updates the application icon with the album art (if present), shows play progress on the taskbar button and provides all the basic play controls as thumb-buttons on the taskbar. There are no visualizations yet, but they should be easy enough to do if there&#8217;s enough demand for it. Here are some screenshots:</p>
<p><a href="http://blog.ananthonline.net/wp-content/uploads/2009/05/thumbnailcontrols.jpg"><img src="http://blog.ananthonline.net/wp-content/uploads/2009/05/thumbnailcontrols-thumb.jpg" style="border-width: 0px; display: inline" title="Thumbnail&amp;Controls" alt="Thumbnail&amp;Controls" border="0" height="244" width="232" /></a></p>
<p>Here&#8217;s the player with controls, progress and tag-reading.</p>
<p><a href="http://blog.ananthonline.net/wp-content/uploads/2009/05/jumplist.jpg"><img src="http://blog.ananthonline.net/wp-content/uploads/2009/05/jumplist-thumb.jpg" style="border-width: 0px; display: inline" title="Jumplist" alt="Jumplist" border="0" height="244" width="226" /></a></p>
<p>You can control the player by using it&#8217;s jump list.</p>
<p>True, this project only took me a week to complete (to this level), but there were a lot of unknowns and problems with the managed Windows7 integration wrapper. Well, I guess I should write a blog post on those later <img src='http://www.ananthonline.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Download it here, give it a whirl and let me know what you think.</p>
<p style="margin: 0px; padding: 0px; display: inline; float: none" id="scid:8eb9d37f-1541-4f29-b6f4-1eea890d4876:388c032c-fa4e-4155-bfd4-d807fb305896" class="wlWriterEditableSmartContent"><a href="http://blog.ananthonline.net/wp-content/uploads/2009/05/lyresetup.zip" target="_self">Lyre-setup.zip</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ananthonline.net/blog/general/lyre-a-windows-7-music-player/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
