Emacs - Notmuch

Introduction

Notmuch is a mail system1. It can efficiently manage a fairly large number of emails. Particularly, it supports fast email searching and filtering based on tags, which is extremely similar to Gmail's tags whereby various virtual folders can be flexibly realized.

This post is composed just to summarize the basic installation and configuration of notmuch-based mail system.

[Read More]

C++ - Singleton

Singleton plays an important role in program architecturing for its global visibility. For instance, system parameters are usually structured as a singleton. What deserves to be noticed, a singleton can be realized in a variety of manners.

[Read More]

Gaussian Distribution

Probability density function

  • \(X \sim \mathcal{N}(\mu, \sigma^2)\) \[\begin{aligned} p(x) = \frac{1}{\sqrt{2\pi}\sigma} \exp\left[-\frac{(x-\mu)^2}{2\sigma^2}\right] \end{aligned}\]

Distribution function

  • Q-function

    • Definition \[\begin{aligned} Q(x) \triangleq \int_x^{\infty} \frac{1}{\sqrt{2\pi}}\exp\left(-\frac{x^2}{2}\right)dx \end{aligned}\]
    • Properties \[\begin{aligned} Q(-x) + Q(x) &= 1 \\ Q(0) &= \frac{1}{2} \end{aligned}\]
  • Error function and complementary error function

    • Definitions \[\begin{aligned} \text{erf}(x) &\triangleq \frac{2}{\sqrt{\pi}} \int_0^x \exp\left(-x^2\right)dx \\ \text{erfc}(x) &\triangleq \frac{2}{\sqrt{\pi}} \int_x^{\infty} \exp\left(-x^2\right)dx \end{aligned}\]
    • Properties \[\begin{aligned} \text{erf}(x) + \text{erfc}(x) &= 1 \\ \text{erf}(x) &= 1 - 2Q(\sqrt{2}x) \\ \text{erfc}(x) &= 2Q(\sqrt{2}x) \end{aligned}\]

Laplace Transform

Given a time domain continuous signal, it can be represented in the complex frequency domain by Laplace transform. It is essentially an extension of Continuous Fourier transform.

[Read More]

Z Transform

Given a time domain discrete signal, i.e., a sequence, it can be represented in the complex frequency domain by Z transform. It is essentially an extension of discrete time Fourier transform (DTFT).

[Read More]

Blog on GitHub

It has been quite a long time for me not to write and publish blog since Google blogspot and WordPress were blocked. Recently, I have built a new blog site on GitHub. This post is just written to summarize the procedure.

[Read More]

C++ - IT++

Introduction

IT++1 is a powerful C++ library, which is widely employed in the area of communication, esp. in simulation programming and computing. It has provided a variety of useful classes, e.g. vector, matrix. With the aid of IT++, programming in C++ is very similar to programming in MATLAB.

IT++ is released under GPL, and can work on all the platforms, including Unix/Linux, Windows an Mac OS X.

[Read More]

C++ - Multithread

背景

C++98/03不支持多线程编程, 所以必须借助第三方库或目标操作系统中的多线程API. 这使得编写跨平台的多线程程序很困难. C++11引入了标准的多线程库, 使得多线程程序跨平台更加容易. 目前的C++11标准仅针对CPU, 不支持GPU.

多线程编程的难点之一是将算法并行化, 这个过程和算法的类型高度相关. 此外, 要防止竞争条件和死锁, 并考虑缓存的一致性.

竞争条件
当多个线程要读/写共享内存位置时, 可能会发生竞争条件.
死锁
线程因为等待另一个阻塞线程锁定的资源而造成的无限阻塞.
撕裂
部分数据已写入内存, 但还有部分数据没有写入. 如果另一个线程在此时读取数据, 就会得到不一致的数据.
缓存的一致性
如果一个线程写入了一段数据, 该线程会立即看到新数据, 但这并不意味着所有线程都会立即看到新数据. 所以, 在读写多个线程时, 即使是最简单的数据类型, 也需要同步.
[Read More]