<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-gb" xmlns="http://www.w3.org/2005/Atom"><title type="text">me@here</title>
<subtitle type="text">... now what?</subtitle>
<link rel="self" href="http://egonelbre.com/atom/" />
<link rel="alternate" type="text/html" href="http://egonelbre.com/" />
<id>tag:egonelbre.com,2005:f07a0d4ea99479a0039694aa40953768</id>
<generator uri="http://textpattern.com/" version="4.2.0">Textpattern</generator>
<updated>2011-07-24T11:10:46Z</updated>
<author>
		<name>Egon Elbre</name>
		<email>&#101;&#103;&#111;&#110;&#64;&#101;&#103;&#111;&#110;&#101;&#108;&#98;&#114;&#101;&#46;&#99;&#111;&#109;</email>
		<uri>http://egonelbre.com/</uri>
</author>

<entry>
		<author>
			<name>Egon Elbre</name>
		</author>
		<published>2011-07-24T11:07:26Z</published>
		<updated>2011-07-24T11:10:46Z</updated>
		<title type="html">min2</title>
		<link rel="alternate" type="text/html" href="http://egonelbre.com/sb/min2" />
		<id>tag:egonelbre.com,2011-07-24:f07a0d4ea99479a0039694aa40953768/60b297b549c49b65ff2c02f6e745cf47</id>
		<category term="meaningful-labor" />
		
		<summary type="html">
<![CDATA[<p>Two bit packed number min,</p>

<pre><code>function min2(a,b){
    c = a &amp; b &amp; 0xAAAAAAAA;
    c = c | (c &gt;&gt; 1);
    c = ~c; // o
</code>
<code>    //an = ~(a^c);
    an = a ^ c;
    ax = an &amp; 0xAAAAAAAA
    an = an &amp; (ax | (ax &gt;&gt; 1));
</code>
<code>    //bn = ~(b^c);
    bn = b ^ c;
    bx = bn &amp; 0xAAAAAAAA;
    bn = bn &amp; (bx | (bx &gt;&gt; 1));
</code>
<code>    //return (~(an^c)) &amp; (~(bn^c));
    return (an^c) &amp; (bn^c)
} 
</code></pre>]]>
</summary>
</entry>
<entry>
		<author>
			<name>Egon Elbre</name>
		</author>
		<published>2011-02-19T19:32:37Z</published>
		<updated>2011-02-19T19:41:00Z</updated>
		<title type="html">jsfx</title>
		<link rel="alternate" type="text/html" href="http://egonelbre.com/dev/jsfx" />
		<id>tag:egonelbre.com,2011-02-19:f07a0d4ea99479a0039694aa40953768/8c385be53f48e72d1710819ca84ff962</id>
		<category term="meaningful-labor" />
		
		<summary type="html">
<![CDATA[<p>jsfx is a javascript library (with frontend) for sound effect generation. It needs <span class="caps">WAV</span> support from browser to work. Take a look, have fun and build on it. Free to use as you wish.</p>

	<p><a href="http://egonelbre.com/js/jsfx/">demo</a><br />
<a href="https://github.com/egonelbre/jsfx">github</a></p>

	<p>It has already gotten quite good feedback from people. Also I&#8217;ve found a nice sequencer that uses jsfx to generate the samples.</p>

	<p><a href="http://www11.plala.or.jp/sothicblue/html5drum-jsfx/">sequencer</a></p>

	<p>Hopefully I&#8217;ll figure out what to do next with jsfx.</p>]]>
</summary>
</entry>
<entry>
		<author>
			<name>Egon Elbre</name>
		</author>
		<published>2010-09-17T19:40:58Z</published>
		<updated>2010-09-18T17:18:51Z</updated>
		<title type="html">Getting started with rst</title>
		<link rel="alternate" type="text/html" href="http://egonelbre.com/articles/getting-started-with-rst" />
		<id>tag:egonelbre.com,2010-09-17:f07a0d4ea99479a0039694aa40953768/1270e35954d125cf950127809418c23b</id>
		<category term="meaningful-labor" />
		<category term="rst" />
		<summary type="html">
<![CDATA[<p>I find that using <span class="caps">WYSIWYG</span> interfaces for editing simple documents can be often quite uncomfortable and unnecessarily complex. Usually you just need some titles and paragraphs and sometimes to include some pictures.</p>

	<p>Here&#8217;s a simpler way of doing it. First download <a href="http://code.google.com/p/rst2pdf/">rst2pdf</a> and install it. (Or install it any means necessary.)</p>

	<p>Here are the basic things to get started. Write this into a &#8216;example.rst&#8217; file:</p>

<pre><code>================
 Document Title
================
----------
 Subtitle
----------
</code>
<code>Chapter 1
=========
</code>
<code>Section 1.1
-----------
</code>
<code>Subsection 1.1.1
~~~~~~~~~~~~~~~~
</code>
<code>Here is some very important
paragraph. Line breaks will be ignored.
A empty line begins a new paragraph.
</code>
<code>Section 1.2
-----------
</code>
<code>Here&#39;s the a paragraph.
</code>
<code>Here&#39;s the second paragraph.
</code></pre>

	<p>The syntax is quite intuitive. If you want a header just draw a double line under it. For sub-header use a single line. One important thing is that the line under/over the headers must be as long or longer than the header.</p>

	<p>If you want a new paragraph just add an empty line before it. Why doesn&#8217;t it just break the line there where I put the enter? Because then it wouldn&#8217;t automatically adjust to different layouts and page sizes.</p>

	<p>Let&#8217;s go on. Let&#8217;s say I want to include some lists and an image.</p>

<pre><code>Lists
==============
</code>
<code>This is our bullet list:
</code>
<code>* Hello
* Big
* World
</code>
<code>This is our number list:
</code>
<code>1. Hello
2. Big
3. World
</code>
<code>Nested lists are also simple:
</code>
<code>1. Hello
    a. Big
2. World
</code>
<code>Image
==============
</code>
<code>This is how to include an image:
</code>
<code>.. image :: hello.png
    :width: 3cm
    :align: left
</code></pre>

	<p>Now execute <strong>rst2pdf example.rst</strong> and here&#8217;s the <a href="http://egonelbre.com/file_download/5/rstPart1.pdf">example.pdf</a> that comes out. That&#8217;s all there is for the introduction.</p>]]>
</summary>
</entry>
<entry>
		<author>
			<name>Egon Elbre</name>
		</author>
		<published>2010-09-13T20:24:44Z</published>
		<updated>2010-09-14T13:27:21Z</updated>
		<title type="html">imprecision</title>
		<link rel="alternate" type="text/html" href="http://egonelbre.com/dev/imprecision" />
		<id>tag:egonelbre.com,2010-09-13:f07a0d4ea99479a0039694aa40953768/afbe14e50764b32d747b031a8d224c55</id>
		
		
		<summary type="html">
<![CDATA[<p>This header file provides macros for truncating floating point values in C/C++.</p>

	<p>I started thinking about this problem after reading Iñigo Quílez&#8217;s article <a href="http://www.iquilezles.org/www/articles/float4k/float4k.htm">storing floating point in 4k</a>. The problem is that using full floating point precision makes the code less compressable.</p>

	<p>For example 1.9f will be translated to hex 0&#215;3ff33333 whereas it would be much better to use 0&#215;3ff30000. If there are a lot of values ending with zeros then they can be compressed quite efficiently.</p>

	<p>Iñigo Quílez&#8217;s idea was to precalculate and define each value from 0.00 to 1.99 that give an exact hex number in a header file and then use the defined values. This method can get a little long when you would try this with more values.</p>

	<p>My idea was to do the calculation at compile time with macros.</p>

	<p>First thing idea I tried was the most obvious &#8211; convert the floating point value to it&#8217;s <span class="caps">IEEE</span> format, mask out the values and then convert it back. Unfortunately this ended with problems as gcc doesn&#8217;t let you convert float to int that easily. First I had to  get the address of the value then convert it to void, then to int pointer then to int and then mask it out &#8212; then get address, void, float pointer, float. Problem is that during compile-time we don&#8217;t know where the value is and therefore we have to use a temporary variable. Basically I didn&#8217;t find a way that compiler could optimize it out.</p>

	<p>Then the second thing I tried was using multiplication, masking and division:</p>

<pre><code>((float)((int)(x*256) &amp; ~((1 &lt;&lt; (ilog(x) - 1)) - 1) )/256.0f)
</code></pre>

	<p>Then tested to find a values that provide the least amount of errors and found out that this method is also easily modifiable for different sizes of imprecision. That means you can truncate different amount of nybbles quite easily.</p>

	<p>Anyway download the file <a href="http://egonelbre.com/file_download/3/imprecision.h">imprecision.h</a>.</p>

<pre><code>#define ilog(x) \
     x &lt; 2 ? 1 : x &lt; 4 ? 2 : x &lt; 8 ? 3 : \
     x &lt; 16 ? 4 : x &lt; 32 ? 8 : x &lt; 64 ? 9 : \
     x &lt; 128 ? 10 : x &lt; 256 ? 11 : \ 
     x &lt; 512 ? 12 : 13
#define _P(x,y) ((float)((int)(x*(int)y) &amp; \
                          ~((1 &lt;&lt; (ilog(x) - 1)) - 1) )/y);
#define P4(x) _P(x,256.0f)
#define P3(x) _P(x,16.0f)
#define P5(x) _P(x,4096.0f)
#define P(x) P4(x)
</code></pre>

	<p>P4 won&#8217;t use more than 4 nybbles of hex values and the same goes for the others. So it&#8217;s easy to use with different precisions.</p>]]>
</summary>
</entry>
<entry>
		<author>
			<name>Egon Elbre</name>
		</author>
		<published>2010-09-13T20:10:54Z</published>
		<updated>2010-09-14T12:04:04Z</updated>
		<title type="html">measus</title>
		<link rel="alternate" type="text/html" href="http://egonelbre.com/dev/measus" />
		<id>tag:egonelbre.com,2010-09-13:f07a0d4ea99479a0039694aa40953768/d65f11b9d729c7912731d6d729187e12</id>
		
		
		<summary type="html">
<![CDATA[<p>Measus is a perl script that automates speed testing multiple programs over different files and arguments.</p>

	<p>For example you have programs <em>brute-force</em>, <em>shift-or</em>, <em>kmp</em> and <em>grep</em>. You want to test pattern searching with patterns &#8220;aaaa&#8221;, &#8220;bbbb&#8221;, &#8220;ababba&#8221;. Also you want to test with differemt files &#8220;abc.txt&#8221; and &#8220;bbb.txt&#8221;. Also testing only one run is useless so you want to run each test 10 times. To do this testing you&#8217;ll need to create a setup file:</p>

<pre><code>$iterations = 10;
</code>
<code>@programs = (
    &quot;grep =&gt; grep -c PAT FILE&quot;,
    &quot;brute-force =&gt; ./bf PAT FILE&quot;,
    &quot;shift-or =&gt; ./sor PAT FILE&quot;,
    &quot;kmp =&gt; ./kmp PAT FILE&quot;,
);
</code>
<code>@patterns = (
    &quot;aaaa&quot;,
    &quot;bbbb&quot;,
    &quot;ababba&quot;,
);
</code>
<code>@files = (
    &quot;abc 16MB =&gt; ../data/abc.txt&quot;,
    &quot;b* 16MB =&gt; ../data/bbb.txt&quot;,
);
</code></pre>

	<p>Then you can run it with:</p>

<pre><code>./measus.pl log_tabdelim.pl setup.pl
</code></pre>

	<p>Download it from here: <a href="http://egonelbre.com/file_download/4/measus.zip">measus.zip</a></p>]]>
</summary>
</entry></feed>