No Such Blog or Diary

«Prev || 1 | 2 | 3 |...| 1284 | 1285 | 1286 |...| 1320 | 1321 | 1322 || Next»

免許更新

視力の心配をしつつ今日しか行くタイミングが無いので更新に行って来た.予想通り右目が危険な感じだったが,上下左右の穴判定だったので無事通過.めでたく5年後までメガネを新調しなくてよさげ.

願書提出

大学の目の前の郵便局にて大学宛に書留で願書を郵送,830円なり.あほなことしてるなぁ…

続Template

友人曰く,gcc はテンプレート展開が遅いとのことで,VC++のコンパイラにて挑戦.しかし,なにやら何かがオーバーフローしたとかでコンパイルに失敗.しょうがないからインスタンス化されるTemplateのかずを減らすように全体を書き直し.

とりあえずジェネレータできたやつ.これでも5時間1.3Gメモリで終わらない… やっぱTemplateでやるのは無謀だったのだろうか? 問題解決のひとつの方法は,最下位桁で分けて分割コンパイルすればいいのだけど… 何かそれも負けだよなぁと考える今日この頃.

そろそろ免許の更新をば

更新しなければならないが視力がやばそう.ためしに Web 上で見つけた Flashの視力測定できるやつで試してしると… 光度を落としているとはいえ,右目で0.3がはっきりしない.めがねを作るのもったいないしなぁ,どうにか一時的にでも視力回復しないもんだろうか? とりあえずブルーベリーでも食べとくか.

Minix本

輪読で読む<http://www.amazon.co.jp/exec/obidos/ASIN/4894710471/>Minix本がやっとこさ届いた.明日発表担当なのでさっさと読まねば.それにしても後ろほぼ半分がソースコードって… すげぇなぁ.

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();
}
«Prev || 1 | 2 | 3 |...| 1284 | 1285 | 1286 |...| 1320 | 1321 | 1322 || Next»
Search
Feeds

Page Top