posts - 403, comments - 310, trackbacks - 0, articles - 7
            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

          1.閉包 Closure
          (1) 自反 reflexive
          對稱 symmetric
          傳遞 transitive
          (2) 其中,設(shè)R屬于A*A(A為非空集合),則r(R) = R與A上恒等關(guān)系的并,s(R) = R與R的逆的并,
          t(R) = R 并 R^2 并 R^3 并...并 R^l。
          (3) rs(R) = sr(R)
          rt(R) = tr(R)
          st(R) 屬于 ts(R)


          2. 等價關(guān)系和劃分
          (1) 設(shè)R屬于A*A,若R是自反的、對稱的和傳遞的,則稱R為A上的等價關(guān)系。
          (2) 令[x]R為x的關(guān)于R的等價類,在不引起混亂時可簡記為[x]。
          (3) 以關(guān)于R的全體不同的等價類為元素的集合稱為A關(guān)于R的商集,記作A/R。
          (4) 設(shè)A為非空集合,若存在A的一個子集族S滿足
          a. S中不包含空集元素
          b. 對于一切x,y屬于S,且x,y不相等,則x與y不相交的(disjoint)
          c. S中所有集合的并為A
          則稱S為A的一個劃分,S中元素稱為劃分塊。
          (5) 非空集合A上的等價關(guān)系與A的劃分是一一對應(yīng)的。
          (6) 第二類Stirling數(shù),表示將n個不同的球放入r個相同的盒子中的方案數(shù),可以由下列遞歸式計算:
          f(n, r) = r * f(n - 1, r) + f(n - 1, r - 1)
          很容易理解的一個遞歸式,其中初始狀態(tài)為
          f(n, 0) = 0, f(n, 1) = 1, f(n, 2) = 2^(n-1) - 1, f(n, n - 1) = C(n, 2), f(n, n) = 1
          (7) A上等價關(guān)系的數(shù)量可以通過Stiring數(shù)求出,以A={a,b,c,d}為例
          f(4,1) + f(4,2) + f(4,3) + f(4,4) = 15

          posted @ 2007-07-25 11:03 ZelluX 閱讀(377) | 評論 (0)編輯 收藏

          命令行下使用的程序,和vim整合的很好(回復(fù)、發(fā)帖都是通過調(diào)用vim完成的)
          具體配置可以參照/usr/share/doc/slrn/examples/slrn.rc.gz,第一次使用的時候需要
          slrn --create生成相應(yīng)的.jnewsrc文件。


          posted @ 2007-07-24 20:42 ZelluX 閱讀(307) | 評論 (0)編輯 收藏

          CLRS上第六章的習(xí)題,以前感覺挺難的,現(xiàn)在仔細(xì)想了發(fā)現(xiàn)其實和堆是一樣的。
          /* Min-Young tableaus on Page 143 */
          #include 
          <iostream>
          #include 
          <iomanip>
          using namespace std;

          template 
          <class Type>
          class YTable
          {
          private:
              Type
          ** data;
              
          int m, n;
              
          const static int INFINITY = 9999;
          public:
              YTable(
          int m = 10int n = 10);
              
          ~YTable();
              
          int Insert(Type x);
              
          int FloatUp(int x, int y);
              
          int Print();
              
          int Extract(int x, int y, Type value);
          };

          template 
          <class Type>
          YTable
          <Type>::YTable(int m, int n)
          {
              
          this->= m;
              
          this->= n;
              data 
          = new Type*[m];
              
          for (int i = 0; i < m; i++)
                  data[i] 
          = new Type[n];
              
          for (int i = 0; i < m; i++)
                  
          for (int j = 0; j < n; j++)
                      data[i][j] 
          = INFINITY;
          }

          template 
          <class Type>
          YTable
          <Type>::~YTable()
          {
              
          for (int i = 0; i < m; i++)
                  delete [] data[i];
              delete [] data;
          }

          template 
          <class Type>
          int YTable<Type>::Insert(Type x)
          {
              
          if (data[m - 1][n - 1!= INFINITY)
                  
          return 0;
              data[m 
          - 1][n - 1= x;
              FloatUp(m 
          - 1, n - 1);
              
          return 1;
          }

          template 
          <class Type>
          int YTable<Type>::FloatUp(int x, int y)
          {
              
          int maxX = x;
              
          int maxY = y;
              
          if (x > 0 && data[x - 1][y] > data[maxX][maxY])
              {
                  maxX 
          = x - 1;
                  maxY 
          = y;
              }
              
          if (y > 0 && data[x][y - 1> data[maxX][maxY])
              {
                  maxX 
          = x;
                  maxY 
          = y - 1;
              }
              
          if (maxX != x || maxY != y)
              {
                  swap(data[maxX][maxY], data[x][y]);
                  FloatUp(maxX, maxY);
              }
              
          return 1;
          }

          template 
          <class Type>
          int YTable<Type>::Print()
          {
              cout.setf(ios::
          fixed);
              
          for (int i = 0; i < m; i++)
              {
                  
          for (int j = 0; j < n; j++)
                      
          if (data[i][j] != INFINITY)
                          cout 
          << setw(3<< data[i][j];
                      
          else
                          cout 
          << " X ";
                  cout 
          << endl;
              }
              
          return 1;
          }

          template 
          <class Type>
          int YTable<Type>::Extract(int x, int y, Type value)
          {
              data[x][y] 
          = value;
              FloatUp(x, y);
              
          return 1;
          }

          int main()
          {
              YTable
          <int> myTable(44);
              
          int x[] = {91632481514127111015136};
              
          for (int i = 0; i < 16; i++)
                  myTable.Insert(x[i]);
              cout 
          << "Initial state:\n";
              myTable.Print();
              cout 
          << "\nNow change (4,3) to 5:\n";
              myTable.Extract(
          325);
              myTable.Print();
              
          return 0;
          }
              


          posted @ 2007-07-23 17:51 ZelluX 閱讀(422) | 評論 (0)編輯 收藏

          先用任意的linux啟動盤啟動,推薦tomsrcbt,一個只有一兩兆的發(fā)行版,不過我是從硬盤啟動了ubuntu7.04的desktop.iso
          如果非硬盤啟動可能還需要先掛載原linux分區(qū),接著使用chmod 755 /media/sda9/*修改該分區(qū)下的目錄權(quán)限
          重啟,使用正常的模式進(jìn)入ubuntu,結(jié)果發(fā)現(xiàn)無法在圖形界面下登錄,控制臺中使用telnet上bbs求助后才知道還需要開放/tmp的寫權(quán)限,用sudo chmod a=rwxt /tmp搞定。


          posted @ 2007-07-22 17:07 ZelluX 閱讀(313) | 評論 (0)編輯 收藏

          移植XP下字體到Ubuntu時,其中的命令

          sudo chmod 644 *

          被我打成了

          sudo chmod 644 /*

          然后就開始痛苦了。。。

          ls cd cat都不能用,firefox自動關(guān)閉,桌面圖標(biāo)全部變成叉,qterm里面的bbs列表也無法訪問了。

          最郁悶的是sudo這個命令也無法使用了,就像把鑰匙留在房間里然后關(guān)上了門。

          只能請教熊,貌似要用光盤才能恢復(fù)。。。

          posted @ 2007-07-22 01:24 ZelluX 閱讀(189) | 評論 (0)編輯 收藏

          書上的例子,計算行號的,但是書中對行的定義是
          line *.\n
          貌似不正確,flex無法解析,改成line (.)*\n就可以了。
          書上的樣例也沒有yywrap,寫了個空函數(shù)。
          %{
          /* a Lex program that adds line numbers
             to lines of text, printing the new text
             to the standard output
          */
          #include 
          <stdio.h>
          int lineno = 1;
          %}
          line (.)
          *\n 
          %%
          {line} { printf (
          "%5d %s", lineno++, yytext); }
          %%
          main()
          {
              yylex();
              
          return 0;
          }
          int yywrap()
          {
              
          return 0;
          }
          生成flex程序:flex linecount.lex
          編譯:gcc lex.yy.c
          利用管道輸入剛才的程序:cat linecount.lex | ./a.out


          posted @ 2007-07-20 15:46 ZelluX 閱讀(395) | 評論 (0)編輯 收藏

          1. 允許將字符放在引號中作為真正的字符匹配。

          例如要匹配\*可以寫成\\\*,也可以是"\*"

          2. 方括號中大多數(shù)元字符都可以無需引號直接引出。如("+"|"-")可以寫成[-+],但不能寫成[+-],因為-在中括號中可以作為表示范圍的連字符。

          3. 大括號可以指出正則表達(dá)式的名字,但不能遞歸調(diào)用。

          nat [0-9]+

          signedNat (+|-) ? {nat}

           

          posted @ 2007-07-20 14:35 ZelluX 閱讀(302) | 評論 (0)編輯 收藏

          from www.BrainBashers.com
          1. Intersection 橫斷,游戲一開始就使用的常見技巧。

          Sudoku Image  Sudoku Image

          2. Forced Moves 排除所有其他可能性后唯一的答案

          Sudoku Image  Sudoku Image

          3. Pinned Squares
          Intersection 的加強版,根據(jù)更多的情況確定某一個數(shù)字在該區(qū)域的唯一可能位置。
          Sudoku Image  Sudoku Image

          4. Locked Sets

          如圖一R5C1和R6C1只能填1或8,由此可排除與他們有關(guān)的域中的其他格填1和8的可能性,從而R6C2只能填5。

          Sudoku Image  Sudoku Image

          posted @ 2007-07-20 11:59 ZelluX 閱讀(5360) | 評論 (0)編輯 收藏

          裝了fcitx以后thunderbird罷工了。。。現(xiàn)在只能用Google groups上新聞組了,不過fcitx的確不錯的說。

          cs書上的一個習(xí)題,在執(zhí)行i=0這樣的命令時是用: xorl %edx, %edx
          為什么不用 movl $0, %edx呢?
          老大: 一般的說立即數(shù)的存取是內(nèi)存操作,而前一條指令是寄存器操作。所以Itanium上有專門的寄存器放0.
          SecretVan@smth.org: 可能跟標(biāo)志位有關(guān)系,如xor清零后緊跟一個條件跳轉(zhuǎn)。
          先把這些回答放這,以后在回過頭來看。

          posted @ 2007-07-19 23:41 ZelluX 閱讀(347) | 評論 (1)編輯 收藏

          看到匯編中的基本運算這一節(jié),想看看傳說中的編譯器把a*2優(yōu)化為a<<1是不是真的呢,寫了個函數(shù)試了下:
          int func(int x)
          {
              return x * 2;
          }
          用gcc -O2 -S test.c 編譯,發(fā)現(xiàn)優(yōu)化后是用了加法,而不是位移
          func:
                  pushl   %ebp
                  movl    %esp, %ebp
                  movl    8(%ebp), %eax
                  popl    %ebp
                  addl    %eax, %eax
                  ret
          BBS上問了,老大說一般加法不會慢。
          又試了一下把*2改成*3,仍然是使用leal    (%eax,%eax,2), %eax進(jìn)行加法操作完成的,而改成*4就使用位移了。
          其他回答:
          SecretVan@smth.org: CISC指令集上更傾向于選擇功能一樣而長度較短的指令,帶了立即數(shù)之后指令就長了,如果使用寄存器那更得不償失
          Nineveh@smth.org: 因為 add 的長度短于或等于 sal,速度快于或等于 sal,吞吐量大于或等于 sal。
          lib@rygh: 在P4里面我記得一條加法指令是0.5個cycle.移位指令撐死了也要0.5個cycle吧,沒聽說過有0.25cycle的指令。

          posted @ 2007-07-19 00:51 ZelluX 閱讀(373) | 評論 (0)編輯 收藏

          僅列出標(biāo)題
          共39頁: First 上一頁 19 20 21 22 23 24 25 26 27 下一頁 Last 
          主站蜘蛛池模板: 铁岭市| 来宾市| 循化| 睢宁县| 新沂市| 共和县| 全州县| 丹棱县| 焦作市| 招远市| 花莲县| 宜宾县| 木兰县| 通山县| 常山县| 高邑县| 鲁山县| 屏东市| 陵川县| 海阳市| 梧州市| 庆城县| 山西省| 永年县| 达拉特旗| 浏阳市| 东莞市| 静宁县| 德钦县| 韩城市| 都江堰市| 正宁县| 富顺县| 咸宁市| 平舆县| 浦江县| 丹凤县| 秭归县| 卢龙县| 永寿县| 牡丹江市|