<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Guy Rutenberg &#187; Errors</title>
	<atom:link href="http://www.guyrutenberg.com/tag/errors/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.guyrutenberg.com</link>
	<description>Keeping track of what I do</description>
	<lastBuildDate>Wed, 16 Jun 2010 19:53:40 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Python&#8217;s base64 Module Fails to Decode Unicode Strings</title>
		<link>http://www.guyrutenberg.com/2010/05/03/pythons-base64-module-fails-to-decode-unicode-strings/</link>
		<comments>http://www.guyrutenberg.com/2010/05/03/pythons-base64-module-fails-to-decode-unicode-strings/#comments</comments>
		<pubDate>Mon, 03 May 2010 18:18:24 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Errors]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/?p=672</guid>
		<description><![CDATA[If you&#8217;ve got a base64 string as a unicode object and you try to use Python&#8217;s base64 module with altchars set, it fails with the following error:

TypeError: character mapping must return integer, None or unicode

This is pretty unhelpful error message also occurs if you try any method that indirectly use altchars. For example:

base64.urlsafe_b64decode&#40;unicode&#40;'aass'&#41;&#41;
base64.b64decode&#40;unicode&#40;'aass'&#41;,'-_'&#41;

both fail while [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve got a <code>base64</code> string as a <code>unicode</code> object and you try to use Python&#8217;s <a href="http://docs.python.org/library/base64.html"><code>base64</code></a> module with <code>altchars</code> set, it fails with the following error:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">TypeError: character mapping must return integer, None or unicode</pre></div></div>

<p>This is pretty unhelpful error message also occurs if you try any method that indirectly use <code>altchars</code>. For example:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #dc143c;">base64</span>.<span style="color: black;">urlsafe_b64decode</span><span style="color: black;">&#40;</span><span style="color: #008000;">unicode</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'aass'</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
<span style="color: #dc143c;">base64</span>.<span style="color: black;">b64decode</span><span style="color: black;">&#40;</span><span style="color: #008000;">unicode</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'aass'</span><span style="color: black;">&#41;</span>,<span style="color: #483d8b;">'-_'</span><span style="color: black;">&#41;</span></pre></div></div>

<p>both fail while the following works:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #dc143c;">base64</span>.<span style="color: black;">urlsafe_b64decode</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'aass'</span><span style="color: black;">&#41;</span>
<span style="color: #dc143c;">base64</span>.<span style="color: black;">b64decode</span><span style="color: black;">&#40;</span><span style="color: #008000;">unicode</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'aass'</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>While it&#8217;s not complicated to fix it (just convert any <code>unicode</code> string to <code>ascii</code> string), it&#8217;s still annoying.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2010/05/03/pythons-base64-module-fails-to-decode-unicode-strings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NVidia driver fails to initialize after X restart</title>
		<link>http://www.guyrutenberg.com/2009/11/14/nvidia-driver-fails-to-initialize-after-x-restart/</link>
		<comments>http://www.guyrutenberg.com/2009/11/14/nvidia-driver-fails-to-initialize-after-x-restart/#comments</comments>
		<pubDate>Sat, 14 Nov 2009 15:19:14 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Errors]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/?p=589</guid>
		<description><![CDATA[This is mainly a note to myself. Sometimes when the X server is restart it complains that nvidia driver couldn&#8217;t be initialized and that no screens were found. This may be a result of a version mismatch between X11&#8217;s and the kernel&#8217;s nvidia module. The solution is to

modprobe -r nvidia

before restarting the X server.
]]></description>
			<content:encoded><![CDATA[<p>This is mainly a note to myself. Sometimes when the X server is restart it complains that <code>nvidia</code> driver couldn&#8217;t be initialized and that no screens were found. This may be a result of a version mismatch between X11&#8217;s and the kernel&#8217;s <code>nvidia</code> module. The solution is to</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">modprobe -r nvidia</pre></div></div>

<p>before restarting the X server.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2009/11/14/nvidia-driver-fails-to-initialize-after-x-restart/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>\lyxframeend Undefined when Using Beamer with Lyx</title>
		<link>http://www.guyrutenberg.com/2009/07/22/lyxframeend-undefined-when-using-beamer-with-lyx/</link>
		<comments>http://www.guyrutenberg.com/2009/07/22/lyxframeend-undefined-when-using-beamer-with-lyx/#comments</comments>
		<pubDate>Wed, 22 Jul 2009 14:40:14 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[LaTeX]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Beamer]]></category>
		<category><![CDATA[Errors]]></category>
		<category><![CDATA[LyX]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/?p=411</guid>
		<description><![CDATA[I&#8217;m using LyX for the first time with Beamer. Making the title page was smooth. But when I&#8217;ve tried adding a new frame (using BeginFrame) I was confronted with the following error

 \lyxframeend
                 {}\lyxframe{Outline}
The control sequence at the end [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m using LyX for the first time with Beamer. Making the title page was smooth. But when I&#8217;ve tried adding a new frame (using BeginFrame) I was confronted with the following error</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"> \lyxframeend
                 {}\lyxframe{Outline}
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.</pre></div></div>

<p>After comparing my document to example (working) beamer documents I&#8217;ve found out that you must have an EndFrame command after your last frame.Too bad it wasn&#8217;t documented anywhere I&#8217;ve found as this little thing drove me crazy.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2009/07/22/lyxframeend-undefined-when-using-beamer-with-lyx/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Kernel Configuration for acpid Issue</title>
		<link>http://www.guyrutenberg.com/2008/10/15/kernel-configuration-for-acpid-issue/</link>
		<comments>http://www.guyrutenberg.com/2008/10/15/kernel-configuration-for-acpid-issue/#comments</comments>
		<pubDate>Wed, 15 Oct 2008 12:55:58 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[acpid]]></category>
		<category><![CDATA[Errors]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/?p=135</guid>
		<description><![CDATA[I&#8217;ve installed acpid on my system some time ago (Gentoo package: sys-power/acpid. However each time I tried to start it it complained:

acpid: can't open /proc/acpi/event: No such file or directory

Apparently acpid requires you to enable ACPI_PROC_EVENT, which in it&#8217;s labels states &#8220;Deprecated /proc/acpi/event support&#8221;. I really wonder why such tool only support the deprecated way [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve installed <code>acpid</code> on my system some time ago (Gentoo package: <code>sys-power/acpid</code>. However each time I tried to start it it complained:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">acpid: can't open /proc/acpi/event: No such file or directory</pre></div></div>

<p>Apparently <code>acpid</code> requires you to enable <code>ACPI_PROC_EVENT</code>, which in it&#8217;s labels states &#8220;Deprecated /proc/acpi/event support&#8221;. I really wonder why such tool only support the deprecated way to receive the ACPI events.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2008/10/15/kernel-configuration-for-acpid-issue/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LaTeX Error: Command \textquotedbl unavailable in encoding HE8</title>
		<link>http://www.guyrutenberg.com/2008/10/12/latex-error-command-textquotedbl-unavailable-in-encoding-he8/</link>
		<comments>http://www.guyrutenberg.com/2008/10/12/latex-error-command-textquotedbl-unavailable-in-encoding-he8/#comments</comments>
		<pubDate>Sun, 12 Oct 2008 17:08:48 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[LaTeX]]></category>
		<category><![CDATA[Errors]]></category>
		<category><![CDATA[LyX]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/?p=115</guid>
		<description><![CDATA[I was testing today the SVN version of LyX 1.6.0 and 1.5.7. Due to a change in the way the double quotation mark (&#8220;) is handled, adding it to Hebrew text resulted in the following LaTeX error:

LaTeX Error: Command \textquotedbl unavailable in encoding HE8


This could be solved by adding the following line to your LaTeX [...]]]></description>
			<content:encoded><![CDATA[<p>I was testing today the SVN version of <a href="http://www.lyx.org">LyX</a> 1.6.0 and 1.5.7. Due to a change in the way the double quotation mark (&#8220;) is handled, adding it to Hebrew text resulted in the following LaTeX error:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">LaTeX Error: Command \textquotedbl unavailable in encoding HE8</pre></div></div>

<p><span id="more-115"></span></p>
<p>This could be solved by adding the following line to your LaTeX preamble:</p>

<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #800000; font-weight: normal;">\<span style="color: #800000; font-weight: bold;">let</span></span><span style="color: #800000; font-weight: normal;">\textquotedbl</span>=&quot;</pre></div></div>

<p>This line will define the <code>\textquotedb</code> to be the double quotation mark, and the document will compile look the same as it looked in older versions of LyX.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2008/10/12/latex-error-command-textquotedbl-unavailable-in-encoding-he8/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Alpha Channel Problems When Creating .ico Files Using ImageMagick</title>
		<link>http://www.guyrutenberg.com/2008/10/05/alpha-channel-problems-when-creating-ico-files-using-imagemagick/</link>
		<comments>http://www.guyrutenberg.com/2008/10/05/alpha-channel-problems-when-creating-ico-files-using-imagemagick/#comments</comments>
		<pubDate>Sun, 05 Oct 2008 15:30:42 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[Errors]]></category>
		<category><![CDATA[ImageMagick]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/?p=102</guid>
		<description><![CDATA[I&#8217;ve tried to use ImageMagick to create .ico files for Open Yahtzee, out of PNGs of various sizes. The command as it should have been:

convert openyahtzee16.png openyahtzee32.png openyahtzee64.png openyahtzee.ico

resulted in the alpha channel being reversed. I&#8217;ve used ImageMagick 6.4.0, and I didn&#8217;t remember this misbehavior happening in the previous versions.
While this annoyed, and was due [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve tried to use <a href="http://www.imagemagick.org/">ImageMagick</a> to create .ico files for <a href="http://www.openyahtzee.org/">Open Yahtzee</a>, out of PNGs of various sizes. The command as it should have been:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">convert openyahtzee16.png openyahtzee32.png openyahtzee64.png openyahtzee.ico</pre></div></div>

<p>resulted in the alpha channel being reversed. I&#8217;ve used ImageMagick 6.4.0, and I didn&#8217;t remember this misbehavior happening in the previous versions.</p>
<p>While this annoyed, and was due to no apparent reason, it could be easily solved using the ImageMagick switches to reverse the alpha channel:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">-channel Alpha -negate</pre></div></div>

<p> So the command that produces a correct .ico file was:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">convert openyahtzee16.png openyahtzee32.png openyahtzee64.png -channel Alpha -negate openyahtzee.ico</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2008/10/05/alpha-channel-problems-when-creating-ico-files-using-imagemagick/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>NVRM: not using NVAGP, kernel was compiled with GART_IOMMU support</title>
		<link>http://www.guyrutenberg.com/2008/08/02/nvrm-not-using-nvagp-kernel-was-compiled-with-gart_iommu-support/</link>
		<comments>http://www.guyrutenberg.com/2008/08/02/nvrm-not-using-nvagp-kernel-was-compiled-with-gart_iommu-support/#comments</comments>
		<pubDate>Sat, 02 Aug 2008 06:24:32 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Errors]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/?p=65</guid>
		<description><![CDATA[For the past several weeks I had a strange problem. Sometimes when I booted my computer, it would refuse to start the X server and would give the following error in dmesg:

NVRM: not using NVAGP, kernel was compiled with GART_IOMMU support!!
NVRM: failed to allocate stack!

The weird thing about it is that normally if I rebooted [...]]]></description>
			<content:encoded><![CDATA[<p>For the past several weeks I had a strange problem. Sometimes when I booted my computer, it would refuse to start the X server and would give the following error in <code>dmesg</code>:<br />
<code><br />
NVRM: not using NVAGP, kernel was compiled with GART_IOMMU support!!<br />
NVRM: failed to allocate stack!<br />
</code><br />
The weird thing about it is that normally if I rebooted the computer it would magically work again. So this error only showed up once-in a while and seemed to disappear at will. Today, it happened again,  so I decided to fix it.<br />
<span id="more-65"></span><br />
The first thing that I tried was disabling the GART_IOMMU option in the kernel. Unfortunately, it now embedded in AMD64, so it can&#8217;t be easily disabled. So I opened up <code>lynx</code> (as I said I had no X server) and googled around. Some other people experienced similar problems. In the NVIDIA forums someone suggested adding <code>iommu=noaperture</code> to the kernel options at startup, or enlarging the aperture size in the bios. Changing the aperture size was suggested for couple of other problem, and I remembered that is some point the <code>agppart</code> complained about the aperture size.</p>
<p>I decided to change the aperture size. To do so I entered the bios and pressed Ctrl+F1. This shows up some more advanced configuration options. The aperture size option was under &#8220;Advanced Chipset Options&#8221;, I changed it to 64MB and I rebooted the computer.</p>
<p>Now everything seems to work properly, I just hope it was really solved and no just accidentally work like at the past. The good thing I can&#8217;t see any errors from the NVIDIA driver in <code>dmesg</code> anymore. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2008/08/02/nvrm-not-using-nvagp-kernel-was-compiled-with-gart_iommu-support/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>usb 1-4: device descriptor read/64, error -71</title>
		<link>http://www.guyrutenberg.com/2008/06/26/usb-1-4-device-descriptor-read64-error-71/</link>
		<comments>http://www.guyrutenberg.com/2008/06/26/usb-1-4-device-descriptor-read64-error-71/#comments</comments>
		<pubDate>Thu, 26 Jun 2008 11:28:20 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Errors]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/?p=62</guid>
		<description><![CDATA[When I try to connect my Sansa Clip MP3 player to the linux box I see the following error in dmesg:

usb 1-4: device descriptor read/64, error -71

and the device recognition fails. The player&#8217;s battery gets reloaded but I can&#8217;t mount it and transfer songs.

The solution that worked for me was runnig as root

echo Y > [...]]]></description>
			<content:encoded><![CDATA[<p>When I try to connect my Sansa Clip MP3 player to the linux box I see the following error in <code>dmesg</code>:</p>
<pre>
usb 1-4: device descriptor read/64, error -71
</pre>
<p>and the device recognition fails. The player&#8217;s battery gets reloaded but I can&#8217;t mount it and transfer songs.<br />
<span id="more-62"></span><br />
The solution that worked for me was runnig as root</p>
<pre>
echo Y > /sys/module/usbcore/parameters/old_scheme_first
</pre>
<p>The general idea behind the solution is that there are two way to enumerate USB devices according to the standard. The method that is currently used by default in the <code>usbcore</code> module is similar to the one found in Windows. Apparently There are devices, and the Sansa Clip is among them, that require the other method to function properly. See <a href="http://www.linux-usb.org/FAQ.html#ts10">Linux USB FAQ</a> for more info.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2008/06/26/usb-1-4-device-descriptor-read64-error-71/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Notes About Using amsmath split Environment In Hebrew Documents</title>
		<link>http://www.guyrutenberg.com/2008/04/09/notes-about-using-amsmath-split-enviroment-in-hebrew-documents/</link>
		<comments>http://www.guyrutenberg.com/2008/04/09/notes-about-using-amsmath-split-enviroment-in-hebrew-documents/#comments</comments>
		<pubDate>Wed, 09 Apr 2008 04:25:19 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[LaTeX]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[amsmath]]></category>
		<category><![CDATA[Errors]]></category>
		<category><![CDATA[Hebrew]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/2008/04/09/notes-about-using-amsmath-split-enviroment-in-hebrew-documents/</guid>
		<description><![CDATA[Recently I&#8217;ve worked on a Hebrew document in LaTeX and wanted to use the split environment to typeset some multiline formula. The document which compiled just fine till that point, failed to compile with the following error:

Package amsmath Error: \begin{split} won't work here.


I was using LyX, so I&#8217;ve assumed that it would generate the correct [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I&#8217;ve worked on a Hebrew document in LaTeX and wanted to use the split environment to typeset some multiline formula. The document which compiled just fine till that point, failed to compile with the following error:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">Package amsmath Error: \begin{split} won't work here.</pre></div></div>

<p><span id="more-49"></span></p>
<p>I was using <a href="http://www.lyx.org/">LyX</a>, so I&#8217;ve assumed that it would generate the correct syntax for this environment. But the error clearly said that the <code>\begin{split}</code> was used wrong. I&#8217;ve went through the <a href="ftp://ftp.ams.org/pub/tex/doc/amsmath/amsldoc.pdf">user&#8217;s guide</a> for the <code>amsmath</code> package and rechecked the syntax. The document has a very handy section that contain common error messages and explanations. I was happy to find out that the error I got was documented there. Unfortunately, the explanation only confirmed that LyX generated the appropriated code for the <code>split</code> environment. </p>
<p>At this point, I&#8217;ve decided to export the document to a LaTeX file and manually tweak it till I find a solution. I&#8217;ve removed everything from the document apart from some Hebrew text and the <code>split</code> formula. I&#8217;ve suspected this error had to do with the Hebrew, as nobody else reported errors using <code>split</code> to the LyX mailing list. I&#8217;ve remembered that someone mentioned to me once that LaTex is very sensitive to the order the packages are added. So I&#8217;ve started to play with the order and moved the <code>\usepackage</code> statements around. When I&#8217;ve put the <code>\usepackage{babel}</code> above the <code>\usepackage{amsmath}</code> the document suddenly compiled fine.</p>
<p>Some further testing showed that in order for the <code>split</code> environment to work properly in an Hebrew document the <code>babel</code> package must be included before <code>amsmath</code> and any other package that depends on it (like <code>mathtools</code>).</p>
<p>Getting things to work back in LyX was a bit more tricky. LyX automatically adds the <code>babel</code> package after the LaTeX preamble, and by default it adds the <code>amsmath</code> when needed, but it does so before the LaTeX preamble. This, as you can see, results in the <code>\usepackage{amsmath}</code> appearing before the <code>\usepackage{babel}</code>. The solution had to override the placements of both statements.</p>
<p>The first step is to go to Document->Settings->Math Options and uncheck both &#8220;Use the AMS math package automatically&#8221; and &#8220;Use the AMS math package&#8221;. This won&#8217;t prevent you from using any to the <code>amsmath</code> package feature if you include it manually (like we will do). The next step is to go to Documents->Settings->LaTeX Preamble, and insert directly at the top of the preamble the following two lines:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">\usepackage{babel}
\usepackage{amsmath}</pre></div></div>

<p>Now the Hebrew document will compile fine even if you use the <code>amsmath</code>&#8217;s <code>split</code> environment. Note that LyX will add <code>\usepackage</code> statement for for <code>babel</code> after the preamble despite the fact you already have one. But don&#8217;t worry, LaTeX will ignore that second statement and no harm will be done.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2008/04/09/notes-about-using-amsmath-split-enviroment-in-hebrew-documents/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Resolution Problems in clock()</title>
		<link>http://www.guyrutenberg.com/2007/09/10/resolution-problems-in-clock/</link>
		<comments>http://www.guyrutenberg.com/2007/09/10/resolution-problems-in-clock/#comments</comments>
		<pubDate>Mon, 10 Sep 2007 19:50:38 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[C/C++]]></category>
		<category><![CDATA[Errors]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/2007/09/10/resolution-problems-in-clock/</guid>
		<description><![CDATA[While playing recently with clock() in order to time the performance of different kinds of code and algorithms, I found an annoying bug. clock() just can&#8217;t register work that has taken less than 0.01 seconds. This is pretty unexpected as clock() should return the processor time used by the program. The man page for clock() [...]]]></description>
			<content:encoded><![CDATA[<p>While playing recently with <code>clock()</code> in order to time the performance of different kinds of code and algorithms, I found an annoying bug. <code>clock()</code> just can&#8217;t register work that has taken less than 0.01 seconds. This is pretty unexpected as <code>clock()</code> should return the processor time used by the program. The <code>man</code> page for <code>clock()</code> states:</p>
<blockquote><p>
The clock() function returns an approximation of processor time used by the program.
</p></blockquote>
<p><span id="more-16"></span><br />
I thought that the word approximation was there because that the <code>CLOCKS_PER_SEC</code> should always be set to 1,000,000 according to the POSIX standard, and modern CPU tick on a much higher frequency so here goes the approximation, as the number of actual ticks needs to be adjusted, as the tick rate of <code>clock()</code> is a one million in a second ticks and not the actual hardware rate.</p>
<p>But the word &#8220;approximation&#8221;  is there for different reason. <code>clock()</code> just can&#8217;t register very short processor times. Let&#8217;s examine the following program:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#include &lt;stdio.h&gt;</span>
<span style="color: #339933;">#include &lt;time.h&gt;</span>
&nbsp;
<span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
        clock_t start<span style="color: #339933;">,</span> end<span style="color: #339933;">;</span>
        <span style="color: #993333;">int</span> temp<span style="color: #339933;">,</span>i<span style="color: #339933;">;</span>
        start <span style="color: #339933;">=</span> clock<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span><span style="color: #0000dd;">2500000</span> <span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
                temp<span style="color: #339933;">+=</span>temp<span style="color: #339933;">;</span>
        end <span style="color: #339933;">=</span> clock<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%i<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span>end<span style="color: #339933;">-</span>start<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>If I compile and run this program it prints <code>1000</code> that means that the <code>clock()</code> has done 1000 ticks, if we divide it by <code>CLOCKS_PER_SEC</code> we get that the processor time for computing the loop in the program was 0.01 seconds. </p>
<p>Now if I change a bit the loop and make it a bit shorter by changing the top limit from 2,500,000 to 2,000,000 and compile and run it, the output is <code>0</code>. Suddenly the loop doesn&#8217;t take any processor time! </p>
<p>That means that also <code>CLOCKS_PER_SEC</code> is set for 1,000,000 the actual resolution that one can depend on is less than 1000 ticks per second, which is pretty low. This disqualifies <code>clock()</code> from being used in any task that demands precision.</p>
<p>Possible alternatives for <code>clock()</code> that have higher resolution include <code>clock_gettime</code> and <code>gettimeofday()</code> (despite its name). Both functions provide high-resolution clocks that should give back the time in microseconds, which allows to use them in a much similar way (but hopefully more accurate) than <code>clock()</code> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2007/09/10/resolution-problems-in-clock/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.713 seconds -->
