<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title>melancholic afternoon</title>
<link>http://homepage1.nifty.com/herumi/diary/latest.html</link>
<description>With Wnz</description>
<language>ja</language>
<lastBuildDate>Sun, 08 Nov 2009 22:24:43 GMT</lastBuildDate>
<generator>tekito ver. 2.0</generator>
<item><title>11/8 float xに関するexp(x)の実...</title>
<link>http://homepage1.nifty.com/herumi/diary/0911.html#8</link>
<pubDate>Sun, 8 Nov 2009 14:59:59 GMT</pubDate>
<description><![CDATA[
float xに関するexp(x)の実装を考える(1)<br>
<ul>
	<li>
    e<sup>-x</sup> = 1 / e<sup>x</sup>だからx &gt;= 0とする.
	<li>
    e<sup>x</sup> = Σx<sup>i</sup> / i!を使うのだけど収束に時間がかかるのでx = n + d(n∈Z, d∈[0, 1))と分解しよう.
    e<sup>x</sup> = e<sup>n</sup> e<sup>d</sup>. n～128程度でfloatの最大値になるからそちらはテーブル引きすればいい.
    <li>
    その場合11!=39916800～4.0e7だから1e-7の精度を出すにはΣはi = 11ぐらいまでとる必要がある.
    これは大きすぎる. d &gt;= 0.5の場合はd = 0.5 + d1, d1∈[0, 0.5)と更に分解してみよう.
    e<sup>x</sup> = e<sup>n</sup> e<sup>0.5</sup> e<sup>d1</sup>
    <li>
    この場合0.5<sup>8</sup>/8!～1e-6ぐらい. うーん, まだ大きい.d1 = 0.25 + d2, d2∈[0, 0.25)ともう一つ分けるか.
    それでも0.25<sup>6</sup>/6!～3e-7. いまいち. 別の方法を考える.
    <li>
    d1, d2は要は2進分数なんだからそちらもテーブル引きすればよさそう.
    <li>
    x = n + (2進数8桁のd1) + (次の2進数8桁のd2) + ...として全部テーブル引きでいいか.
    なら級数展開は不要だなあ.
</ul>
]]></description>
</item>
<item><title>11/7 昔作ってたlogの計算を...</title>
<link>http://homepage1.nifty.com/herumi/diary/0911.html#7</link>
<pubDate>Sat, 7 Nov 2009 14:59:59 GMT</pubDate>
<description><![CDATA[
昔作ってた<a href="../adv/adv43.html#014">logの計算</a>をintrinsicでやってみた(<a href="../prog/src/log.cpp">log.cpp</a>).
とりあえずasmを焼き直しただけなので改良の余地は多々あるだろうがCore2Duo 1.8GHzでベンチ.
<table border=1 width="90%" summary="log bench">
<tr> <th> <th> 32bit VC9 <th> 32bit VC9 /fp:fast <th> 64bit VC <th> 32bit gcc 4.1.2 <th> 64bit gcc 4.1.2</tr>
<tr> <th> log <th> 0.687 <th> 0.375 <th> 0.188 <th> 0.48 <th> 0.330</tr>
<tr> <th> my_log <th> 0.156 <th> 0.125 <th> 0.130 <th> 0.110 <th> 0.100</tr>
</table>
計測がいいかげんなので有効数字2桁なさそうやけど32bitで概ね3～4倍. 64bitのVCのlogはがんばってるなあ.
昔はdivpsよりもrcpps+ニュートン補完が速かったんやけど今は違うのか?(要検証)
まあ, 昔の最適化が現在でもそれなりに意味はあると分かったので次はexpを考えたい.
]]></description>
</item>
<item><title>11/6 from_time_tの問題は1.41.0で...</title>
<link>http://homepage1.nifty.com/herumi/diary/0911.html#6</link>
<pubDate>Fri, 6 Nov 2009 14:59:59 GMT</pubDate>
<description><![CDATA[
from_time_tの問題は1.41.0で<a href="http://beta.boost.org/users/news/version_1_41_0">対応する</a>っぽい. と思ったらまだ駄目だった.
]]></description>
</item>
<item><title>11/5 ・第二回カーネル/VM探...</title>
<link>http://homepage1.nifty.com/herumi/diary/0911.html#5</link>
<pubDate>Thu, 5 Nov 2009 14:59:59 GMT</pubDate>
<description><![CDATA[
・<a href="http://atnd.org/events/1663">第二回カーネル/VM探検隊</a><br>
ほどほどに面白かった. ただ16時～20時半の長丁場は辛かった. 途中でおなか空きすぎて頭が半分回ってなかった.
MINIX SMPのところで66h, 67hをnopに置き換えてる理由がわからないと言ってはったので32bitモードで16bitコード生成したいからとちゃうって適当に答えてしまったが,
ソースのコメントに<a href="http://d.hatena.ne.jp/masami256/20090926">書いてあった</a>.<br>
・副都心線初めて乗った. 渋谷で上に出ようとして階段使ったら100段あった. なんて深いところにあるんや.
]]></description>
</item>
<item><title>11/4 ・CANS2009で発表するF212...</title>
<link>http://homepage1.nifty.com/herumi/diary/0911.html#4</link>
<pubDate>Wed, 4 Nov 2009 14:59:59 GMT</pubDate>
<description><![CDATA[
・CANS2009で発表するF<sub>2</sub><sup>1223</sup>, F<sub>3</sub><sup>509</sup>上のTateペアリングのソースコードが<a href="http://delta.cs.cinvestav.mx/~francisco/temp/Page-TatePairing2009/TatePairing-2009.html">公開された</a>.
私は途中参加だったのでC++ならもちっと楽できるんだけどなあと思いつつ郷に従う. なにはともあれ, こういう最速狙うコードで公開されてるのは殆ど無いのでめでたい.<br>
・下記のposix_time::from_time_tの件, <a href="http://archives.free.net.ph/message/20070215.160245.d6f19054.de.html">2007年に既に指摘されてる</a>のに直ってないということは直す気ないんやろか. trackが見えんでよう分からん.
こっちの人もfrom_time_tについて<a href="http://lists.boost.org/boost-users/2007/07/29567.php">何か言ってる</a>なあ. これも2年前だ.
]]></description>
</item>
<item><title>11/2 boost::posix_time::from_time_t...</title>
<link>http://homepage1.nifty.com/herumi/diary/0911.html#2</link>
<pubDate>Mon, 2 Nov 2009 14:59:59 GMT</pubDate>
<description><![CDATA[
boost::posix_time::from_time_t(time_t)は64bit用time_tに対応してないぽい(boost 1.40).
VC9@32bit, gcc 4.1@64bitで確認.
<pre class="box">
#include &lt;stdio.h&gt;
#include &lt;time.h&gt;
#include &lt;iostream&gt;
#include &lt;boost/date_time/posix_time/posix_time.hpp&gt;
#include &lt;boost/date_time/gregorian/gregorian.hpp&gt;

void Put(time_t t)
{
    struct tm tm;
    char buf[64];
#ifdef _WIN32
    _gmtime64_s(&amp;tm, &amp;t);
    asctime_s(buf, &amp;tm);
#else
    gmtime_r(&amp;t, &amp;tm);
    asctime_r(&amp;tm, buf);
#endif
    printf("time=&#37;s", buf);
}

int main()
{
    time_t t;
    boost::posix_time::ptime bt;

    time(&amp;t);
    printf("sizeof=&#37;d\n", sizeof(t));
    Put(t);
    bt = boost::posix_time::from_time_t(t);
    std::cout &lt;&lt; "boost:" &lt;&lt; bt &lt;&lt; std::endl;

    std::cout &lt;&lt; "boost:" &lt;&lt; (bt + boost::gregorian::years(29)) &lt;&lt; std::endl;

    t += 84600 * 365 * 29;

    Put(t);
    bt = boost::posix_time::from_time_t(t);
    std::cout &lt;&lt; "boost:" &lt;&lt; bt &lt;&lt; std::endl;

}

sizeof=8
time=Mon Nov 02 13:39:33 2009
boost:2009-Nov-02 13:39:33
boost:2038-Nov-02 13:39:33
time=Sat Mar 20 01:09:33 2038
boost:1902-Feb-11 18:41:17 ; おかしい
</pre>
sizeof(time_t) = 4な環境で駄目なのはしかたないけど, そうじゃない環境では対応しておいて欲しいなあ.
言ってみるか.
<pre class="box">
  ptime from_time_t(std::time_t t)
  {
    ptime start(gregorian::date(1970,1,1));
    return start + seconds(static_cast&lt;long&gt;(t));
  }
</pre>
longにキャストしてるからか? でも64-bit Linuxでも駄目なんだよなあ.
]]></description>
</item>
</channel></rss>
