Google Translate

2014年11月6日星期四

MinGW w64 在Windows下的安装方法

1. 安装msys2

2. path: C:\msys64\usr\bin;
             C:\msys64\mingw64\bin

3. pacman -Syu


4. pacman -S git

    pacman -S make
    pacman -S mingw-w64-x86_64-gcc
    pacman -S mingw-w64-x86_64-gdb

2014年10月16日星期四

安装boost

Windows, In cmd:
1. Build bjam.exe

cd ###\boost_1_56_0\tools\build\src\engine\

build.bat gcc

And bjam.exe is ready in ###\boost_1_56_0\tools\build\src\engine\bin.ntx86\

copy bjam.exe to  ###\boost_1_56_0\

2. Build

bjam install --toolset=gcc --prefix="C:/Boost_1_56_0"




Linux: (??)

./build.sh

bjam install --toolset=gcc

2014年8月25日星期一

HMM实现 [<转载>]

C语言版:
1、 HTK(Hidden Markov Model Toolkit):
        HTK是英国剑桥大学开发的一套基于C语言的隐马尔科夫模型工具箱,主要应用于语音识别、语音合成的研究,也被用在其他领域,如字符识别和DNA排序等。HTK是重量级的HMM版本。
        HTK主页:http://htk.eng.cam.ac.uk/
2、 GHMM Library:
        The General Hidden Markov Model library (GHMM) is a freely available LGPL-ed C library implementing efficient data structures and algorithms for basic and extended HMMs.
        GHMM主页:http://www.ghmm.org/
3、 UMDHMM(Hidden Markov Model Toolkit):
        Hidden Markov Model (HMM) Software: Implementation of Forward-Backward, Viterbi, and Baum-Welch algorithms.
        这款属于轻量级的C语言HMM版本。
C++版:
        以上两个是C++版本的,但是实现的是离散型的HMM。
Java版:
        Jahmm Java Library (general-purpose Java library):
        Jahmm (pronounced “jam”), is a Java implementation of Hidden Markov Model (HMM) related algorithms. It’s been designed to be easy to use (e.g. simple things are simple to program) and general purpose.
        Jahmm主页:http://code.google.com/p/jahmm/
Python版:
Malab版:
        Hidden Markov Model (HMM) Toolbox for Matlab:
        This toolbox supports inference and learning for HMMs with discrete outputs (dhmm’s), Gaussian outputs (ghmm’s), or mixtures of Gaussians output (mhmm’s).
Common Lisp版:
        CL-HMM Library (HMM Library for Common Lisp):
        Simple Hidden Markov Model library for ANSI Common Lisp. Main structures and basic algorithms implemented. Performance speed comparable to C code. It’s licensed under LGPL.
Haskell版:
        The hmm package (A Haskell library for working with Hidden Markov Models):
        A simple library for working with Hidden Markov Models. Should be usable even by people who are not familiar with HMMs. Includes implementations of Viterbi’s algorithm and the forward algorithm.
        Haskell-HMM主页:http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hmm
        注:Haskell是一种纯函数式编程语言,它的命名源自美国数学家Haskell Brooks Curry,他在数学逻辑方面上的工作使得函数式编程语言有了广泛的基础。
CDHMM C++版:
        连续HMM的C++实现:http://download.csdn.net/detail/luxiaoxun/4417043
        注:这是网上找的,里面实现有个连续的HMM-GMM的实现,代码写的很好,有些地方需要根据自己的需求改动。

2014年8月2日星期六

zz 如何在DSM系统上安装迅雷离线!!

迅雷远程经过一段时间的完善,到目前一切都变得相当简单了。

一、准备文件

下载迅雷官方远程固件 Xware
此处插入固件下载地址 http://g.xunlei.com/forum-51-1.html
最新版查看地址:http://luyou.xunlei.com/forum-51-1.html

二、上传文件

  • 在 DSM 的"控制面板","终端机和SNMP"中,勾选"启动SSH功能"
  • 用 Putty SSH 登录到 DSM,(用户名:root,密码同 admin 帐号密码),切勿用 admin 登录,貌似会有问题。
  • 新建一个目录,用于存放迅雷远程固件 Xware,放到 DSM 官方程序的指定文件夹/volume1/@appstore/下,命令如下:
mkdir /volume1/@appstore/Thunder
  • 将解压后的 Xware 固件文件拷贝到 Thunder 目录,可以先把文件拷贝到共享文件夹,然后通过再 Putty 中运行如下命令,我是先把固件文件拷贝到一个叫 file 的共享文件夹。
cp /volume1/file/* /volume1/@appstore/Thunder
  • 设置 Thunder 文件夹权限,命令如下:
chmod -R 777 /volume1/@appstore/Thunder

三、安装固件

  • 运行固件安装命令:
/volume1/@appstore/Thunder/portal
在出现的回显中,有类似如下的语句:
THE ACTIVE CODE IS:XXXXXX
其中 XXXXXX 就是需要的激活码,先复制
  • 打开迅雷远程网页http://yuancheng.xunlei.com,选择NAS,然后填入刚才复制的激活码。
  • 迅雷默认会在本地创建路径为 /volume1/TDDOWNLOAD 的文件夹,用于存放下载文件,但是默认该文件夹不会显示,需要在 DSM 的共享文件夹中,赋予该文件夹 admin 帐号可读写的权限,因为之前是用 root 运行的迅雷,文件夹权限只赋予了 root。设置完成后,TDDOWNLOAD就可以正常显示出来了。
  • 可根据需要,在迅雷远程网页中可以配置设备的下载路径,不过最好不要设置成 /volume1/download,设置成 download 以后,偶尔download 这个共享文件夹的权限会消失,必须修复 admin 的共享文件夹权限。

四、设置任务计划

在 DSM 中添加任务计划,设置为每个小时运行一次,所有者选择root(若选admin,迅雷将不能正常启动)
/volume1/@appstore/Thunder/portal

2014年7月13日星期日

茶与咖啡因

茶的咖啡因含量大约是茶叶干重的2%左右(一般不超过5%) 红茶含量相对高,绿茶相对低。

加拿大政府推荐每日咖啡因摄入不超过400mg.

咖啡因主要由肝脏代谢,半衰期大约为3-4小时。当然因人而异。

咖啡因的提神效果也是因各人的咖啡因耐受性而异。

Personally, 多喝绿茶少喝红茶吧~~

2014年6月30日星期一

简明中国古代史 编年 (转载)

中国古代史,始于大约170万年前的元谋人,止于1840年的鸦片战争前,是中国原始社会、奴隶社会和封建社会的历史。
  中国近代史的时间为,从1840年鸦片战争到1949年中华人民共和国成立前,这也是中国半殖民地半封建社会的历史。中国近代史分为前后两个阶段,从1840年鸦片战争到1919年“五四”运动前夕,是旧民主主义革命阶段;从1919年“五四”运动到1949年中华人民共和国成立前夕,是新民主主义革命阶段。
  1949年10月1日中华人民共和国的成立,标志着中国进入了社会主义革命和建设时期。
    夏……………………………约公元前2070——约公元前1600
    商………………………………约公元前1600——公元前1046
    周………………………………… 公元前1046——公元前221
      ——西周…………………… 公元前1046——公元前771
      ——东周……………………………公元前770——前256
      ——春秋……………………………公元前770——前476
      ——战国……………………………公元前475——前221
    秦…………………………………………公元前221——前206
    汉………………………………………公元前202——公元220
      ——西汉………………………………公元前202—公元8
      ——东汉………………………………… 公元25——220
    三国……………………………………………公元220——280
      ——魏……………………………………公元220——265
      ——蜀……………………………………公元221——263
      ——吴……………………………………公元222——280
    晋………………………………………………公元265——420
      ——西晋…………………………………公元265——316
      ——东晋…………………………………公元317——420
    十六国…………………………………………公元304——439
    南北朝…………………………………………公元386——589
      ——北朝…………………………………公元386——581
      ——南朝…………………………………公元420——589
    隋………………………………………………公元581——618
    唐………………………………………………公元618——907
    五代十国………………………………………公元907——979
    宋…………………………………………… 公元960——1276
      ——北宋……………………………… 公元960——1127
      ——南宋………………………………公元1127——1276
    辽…………………………………………… 公元916——1125
    西夏…………………………………………公元1038——1227
    金……………………………………………公元1115——1234
    元……………………………………………公元1271——1368
    明……………………………………………公元1368——1644
    清……………………………………………公元1644——1911
    中华民国……………………………………公元1912——1949
    中华人民共和国………………………… 1949年10月1日成立
中国古代史,始于大约170万年前的元谋人,止于1840年的鸦片战争前,是中国原始社会、奴隶社会和封建社会的历史。

2014年6月13日星期五

Binary trees -- traversal, insertion, deletion, and balancing.

这一章比较纠结,可浅可深。既然是伪技术总结,就只提一提要点就好了。

1. Traversal

i) Breadth First: The key is to use a queue to maintain the traversal...two steps as follow.
a) Enqueue root.
b) while (queue != null)
        {
         qPointer = Dequeue;
         visit qPointer;
         Enqueue left and right children of the qPointer.
}

ii) Depth First: Inorder, Preorder and Post order.
L - Left sub tree; R- Right sub-tree; V = visit (access) the node;

Easy in using recursion,
Inorder = LVR.
Preorder = VLR.
Postorder = LRV.

A bit complicated in using non-recursive methods.
a) by maintaining a stack, traversal can be implemented using iterations.
b) using a threaded tree can avoid the stack.
c) Morris's algorithm can avoid both a) and b) to traversal a tree through tree transformation. (complicated...)

In general, recursive methods has better readable code with marginal cost of performance. However, for certain cases, e.g., ultimate performance to be achieve or suffering stack overflow, non-recursive methods or Morris's algorithms has to apply!!

2. Insertion in threaded tree and deletions.

i) insertion.
the key points are using two pointers, prev and p. Consider element el to be inserted. Keep going until these three stop criterion.

a) if (el < p -> el) prev = p and p go left (p = p -> left) until p == nullptr;
b) if (el > p -> el and thread indicator == 0) prev = p and go right until p == nullptr;
c) if (el > p -> el and thread indicator == 1) stop;

How to insert:
a) if (el < prev -> el) insertion is the left child of prev, successor of the child is prev.
b) else if (prev -> successor) means parent of the insertion is not the rightmost node, so, prev -> right = insertion. make parent's successor the insertion's successor.
c) else prev -> right = insertion. (prev is the rightmost node, just insert new node to the right side.)

This is important and very easy to make mistakes when assigning the successor indicator....


ii) deletion.
By merging or copying we could delete a node that has sub-trees on both of its left and right side.

Merging increases the tree depth significantly while copying method has to consider the balancing issue in those problems of many deletion and insertion operations.

3. Balancing
AVL and black-red trees are similar. Specifically, black-red tree is the underlying implementation of (sorted) map and set in STL in C++!!