No Such Blog or Diary
免許更新
- 2005-07-15 (Fri)
- 一般
視力の心配をしつつ今日しか行くタイミングが無いので更新に行って来た.予想通り右目が危険な感じだったが,上下左右の穴判定だったので無事通過.めでたく5年後までメガネを新調しなくてよさげ.
- Comments: 0
- TrackBack (Close): -
願書提出
- 2005-07-14 (Thu)
- 一般
大学の目の前の郵便局にて大学宛に書留で願書を郵送,830円なり.あほなことしてるなぁ…
- Comments: 0
- TrackBack (Close): -
そろそろ免許の更新をば
- 2005-07-12 (Tue)
- 一般
更新しなければならないが視力がやばそう.ためしに Web 上で見つけた Flashの視力測定できるやつで試してしると… 光度を落としているとはいえ,右目で0.3がはっきりしない.めがねを作るのもったいないしなぁ,どうにか一時的にでも視力回復しないもんだろうか? とりあえずブルーベリーでも食べとくか.
- Comments: 0
- TrackBack (Close): -
Minix本
- 2005-07-11 (Mon)
- 一般
輪読で読む<http://www.amazon.co.jp/exec/obidos/ASIN/4894710471/>Minix本がやっとこさ届いた.明日発表担当なのでさっさと読まねば.それにしても後ろほぼ半分がソースコードって… すげぇなぁ.
- Comments: 0
- TrackBack (Close): -
Template で覆面算
覆面算のすべての条件分岐を Template で処理してしまうプログラムを考えた.ソースを書くのが面倒なのでソースジェネレータを書いて生成することに.とりあえず,ジェネレータとできたソースをおいておくとして… Pen4 2.6C で8時間たってもコンパイルが終わらない… メモリもすでに 1G 食ってるし.このソースをコンパイルできる環境ってどこかにあるのだろうか? ちなみに,X*Y = ZZ という 4 進数での覆面算のプログラムは以下のとおり(答えなし)
#include <iostream> using namespace std; template <bool judge, typename T, typename F> struct Selector{ typedef T val; }; template <typename T, typename F> struct Selector<false, T, F>{ typedef F val; }; struct Nothing{ inline static void calc(){}}; template<unsigned int x, unsigned int y> struct Printer{ inline static void calc(){ cout << x << " * " << y << " = " << x * y << endl; cout << y << " * " << x << " = " << x * y << endl; } }; template<int x0, int y0> struct Judge{ const static bool val = ((x0==y0))&&((x0==y0))&& (x0!=0);}; template<int n, unsigned int x, unsigned int y, int x0, int x1, int x2, int x3> struct Perms{ inline static void calc(){}}; template<unsigned int x, unsigned int y, int x0, int x1, int x2, int x3> struct Perms<0, x, y, x0, x1, x2, x3>{ inline static void calc(){ Selector<true, Perms<1, x | (x0<< 0), y, x0, x1, x2, x3>, Nothing >::val::calc(); Selector<true, Perms<1, x | (x1<< 0), y, x1, x0, x2, x3>, Nothing >::val::calc(); Selector<true, Perms<1, x | (x2<< 0), y, x2, x1, x0, x3>, Nothing >::val::calc(); Selector<true, Perms<1, x | (x3<< 0), y, x3, x1, x2, x0>, Nothing >::val::calc(); } }; template<unsigned int x, unsigned int y, int x0, int x1, int x2, int x3> struct Perms<1, x, y, x0, x1, x2, x3>{ inline static void calc(){ Selector<(x0 > x1), Perms<2, x, y | (x1 << 0), x0, x1, x2, x3>, Nothing >::val::calc(); Selector<(x0 > x2), Perms<2, x, y | (x2 << 0), x0, x2, x1, x3>, Nothing >::val::calc(); Selector<(x0 > x3), Perms<2, x, y | (x3 << 0), x0, x3, x2, x1>, Nothing >::val::calc(); } }; template<unsigned int x, unsigned int y, int x0, int x1, int x2, int x3> struct Perms<2, x, y, x0, x1, x2, x3>{ inline static void calc(){ Selector<(((x*y) >> 0)& 0x3) == x2, Perms<3, x, y, x0, x1, x2, x3>, Nothing >::val::calc(); Selector<(((x*y) >> 0)& 0x3) == x3, Perms<3, x, y, x0, x1, x3, x2>, Nothing >::val::calc(); } }; template<unsigned int x, unsigned int y, int x0, int x1, int x2, int x3> struct Perms<3, x, y, x0, x1, x2, x3>{ inline static void calc(){ Selector<Judge<(((x*y)>>2)&0x3), x3>::val, Printer<x,y>,Nothing>::val::calc(); } }; int main(int argc, char *argv[]) { cout << hex; Perms< 0, 0, 0, 0, 1, 2, 3>::calc(); }
- Comments: 0
- TrackBack (Close): -