0%

introduction

keywords

  • supervised learning
    Supervised learning, in the context of artificial intelligence (AI) and machine learning, is a type of system in which both input and desired output data are provided. Input and output data are labelled for classification to provide a learning basis for future data processing.

  • unsupervised learning
    opposite of supervised learning

  • classification
    Cases such as the digit recognition example, in which the aim is to assign each input vector to one of a finite number of discrete categories

  • reinforcement learning
    Reinforcement learning is where a system, or agent, tries to maximize some measure of reward while interacting with a dynamic environment. If an action is followed by an increase in the reward, then the system increases the tendency to produce that action.

  • regression
    If the desired output consists of one or more continuous variables, then the task is called regression

Read more »

推荐系统主要是用来解决信息过载的问题。疏通生产者和消费者之间的沟通障碍。一方面帮助用户发现对自己有价值的信息,另一方面让信息能够展现在对它感兴趣的用户面前,从而实现双赢。

搜索引擎满足了用户有明确目的时主动查找的需求,而推荐系统满足了用户在没有明确目的时帮助用户发现感兴趣内容的需求。推荐与搜索互补。同时推荐系统能更好的挖掘和处理长尾部分。

Read more »

Log Structured Merge Trees

LSM被设计来提供比传统的B+树或者ISAM更好的写操作吞吐量,通过消去随机的本地更新操作来达到这个目标。

磁盘随机操作慢,顺序读写快的老问题。这二种操作存在巨大的差距,无论是磁盘还是SSD

LSM 保持了日志文件写性能,以及微小的读操作性能损失。本质上就是让所有的操作顺序化,而不是像散弹枪一样随机读写。

很多树结构可以不用 update-in-place,最流行就是 append-only Btree,也称为 Copy-On-Write Tree。

通过顺序的在文件末尾重复写对结构来实现写操作,之前的树结构的相关部分,包括最顶层结点都会变成孤结点。尽管通过这种方法避免了本地更新,但是因为每个写操作都要重写树结构,放大了写操作,降低了写性能。

Read more »

linear-algebra

Solving Linear Equations

Rules:

  1. (AB)1=B1A1(AB)^{-1} = B^{-1}A^{-1}
  2. A1A=I=AA1A^{-1}A = I = AA^{-1}
  3. (AB)x=A(Bx)(AB)\mathbf x = A(B\mathbf x)
  4. A=LU=(lower triangular)(upper triangular)=LDUA = LU = (\text{lower triangular}) (\text{upper triangular}) = LDU

A = L U is “unsymmetric” because U has the pivots on its diagonal where L has l’s. This is easy to change. Divide U by a diagonal matrix D that contains the pivots. That leaves a new triangular matrix with l’s on the diagonal:
Split U into [d1d2dn][1u12/d1u13/d1.1u23/d2.1]\begin{bmatrix}d_1 & & & \\ & d_2 & & \\ & & \ddots & \\ & & & d_n \end{bmatrix}\begin{bmatrix} 1 & u_{12}/d_1 & u_{13}/d_1 & . \\ & 1 & u_{23}/d_2 & . \\ & & \ddots & \vdots \\ & & & 1\end{bmatrix}

  1. (AB)T=BTAT(AB)^T = B^TA^T
Read more »

Somke Simulation

ABSTRACT

In this project, we implemented a 2D smoke simulation using Three.js and WebGL. We extended upon a 2D fluid simulation based on the Navier Stokes equations by adding a buoyant force. The basis of the simulation is a Eulerian grid which we use to keep track of relevant forces, and a series of fragment shaders to manipulate these forces and visualize the resulting smoke. The simulation itself is interactive, and the settings can be manipulated by the user to achieve different results, as well as see the various components of the overall process. You can run our simulation here

APPROACH

Navier-Stokes

Our fluid simulation is based on the Navier-Stokes equations of fluid dynamics, assuming an incompressible, homogeneous fluid.

ut=(u)u1ρp+ν2u+F\frac{\partial\boldsymbol{u}}{\partial t} = -(\boldsymbol{u} \cdot \nabla)\boldsymbol{u} - \frac{1}{\rho}\nabla p+\nu \nabla^2\boldsymbol{u}+\boldsymbol{F}

u=0\nabla \cdot \boldsymbol{u} = 0

In these equations, u is the velocity field, ρ is density, p is pressure, v is viscosity, and F represents any additional forces. Viscosity is virtually zero where smoke is concerned, so we have left that respective shader out of our implementation. Instead, we include a buoyant force to simulate the rising nature of smoke, which is included within the F parameter.

We extract our shaders from this equation by solving for each individual term. Advection represents the first term. Divergence, the Jacobi iterations, and gradient subtraction represent the second term. Finally, the remaining shaders can be grouped into the F term. (Note that user inputted external forces operate slightly differently from other external forces).

Read more »

Cloth Simulation

Advanced Character Physics

Abstract

This paper explains the basic elements of an approach to physically-based modeling which is well suited for interactive use. It is simple, fast, and quite stable, and in its basic version the method does not require knowledge of advanced mathematical subjects (although it is based on a solid mathematical foundation). It allows for simulation of both cloth; soft and rigid bodies; and even articulated or constrained bodies using both forward and inverse kinematics.

The algorithms were developed for IO Interactive’s game Hitman: Codename 47. There, among other things, the physics system was responsible for the movement of cloth, plants, rigid bodies, and for making dead human bodies fall in unique ways depending on where they were hit, fully interacting with the environment (resulting in the press oxymoron “lifelike death animations”).

The article also deals with subtleties like penetration test optimization and friction handling.

Read more »

C++ Template

模板基础

函数模板

定义模板
1
template <typename T>
2
inline T const& tmax(T const& a, T const& b)
3
{
4
    return a < b ? b: a;
5
}
使用模板
1
max(32, 43);

通常而言,并不是把模板编译成一个可以处理任何类型的单一实体。
而是对于实例化模板参数的每种类型,都从模板产生一个不同的实体。
这种用具体类型代替模板参数的过程叫做实例化,它产生了一个模板的实例。

由此,我们可以得出一个结论:模板被编译了两次,分别发生在:

  1. 实例化之前,先检查模板代码本身,查看语法是否正确;在这里会发现错误的语法,如遗漏分号等。
  2. 在实例化期间,检查模板代码,查看是否所有的调用都有效。在这里会发现无效的调用,如该实例化类型不支持某些函数调用(该类型没有提供模板所需要使用到的操作)等。
实参的演绎(deduction)

模板实参不允许进行自动类型转换;每个T都必须正确地匹配。

1
max(4, 4.3); // Error:第1个参数类型是int,第2个参数类型是double
Read more »

C++ Operator Overload

转换函数 (Opetartor ())

operator用于类型转换函数

类型转换函数的一般形式为 :
operator 类型名() (const)
{实现转换的语句}
在函数名前面不能指定函数类型,函数没有参数.

类型转换函数的特征

  1. 型转换函数定义在源类中;
  2. 须由 operator 修饰,函数名称是目标类型名或目标类名
  3. 函数没有参数,没有返回值,但是有return 语句。
    在return语句中返回目标类型数据或调用目标类的构造函数。
1
#include <iostream>
2
using namespace std;
3
class my_class
4
{
5
public:
6
    operator int()//定义了一个将类转化为int的转换函数
7
    {
8
        cout << "convert_to_int" << endl;
9
        return 1;
10
    }
11
};
12
13
int main()
14
{
15
    my_class a;
16
    int i_a = (int)a;//第一次显式的转换
17
    cout << a << endl;//第二次隐式的转换
18
19
    return 0;
20
}
Read more »

C++ Virtual

Virtual Function

what’s virtual

The virtual specifier specifies that a non-static member function is virtual and supports dynamic dispatch. It may only appear in the decl-specifier-seq of the initial declaration of a non-static member function (i.e., when it is declared in the class definition).

Explanation

Virtual functions are member functions whose behavior can be overridden in derived classes. As opposed to non-virtual functions, the overridden behavior is preserved even if there is no compile-time information about the actual type of the class. If a derived class is handled using pointer or reference to the base class, a call to an overridden virtual function would invoke the behavior defined in the derived class. This behavior is suppressed if the function is selected using qualified name lookup (that is, if the function’s name appears to the right of the scope resolution operator :😃.

Read more »

C++11 新增特性

空指针 nullptr

nullptr 出现的目的是为了替代 NULL。

C++11之前官方标准对NULL、0没有严格的区分,更多的是取决于不同编译器的选择,有些编译器会将 NULL 定义为 ((void*)0),有些则会直接将其定义为 0。

C++ 不允许直接将 void * 隐式转换到其他类型,但如果 NULL 被定义为 ((void*)0),那么当编译char *ch = NULL;时,NULL 只好被定义为 0。

这显然会产生问题,导致了 C++ 中重载特性会发生混乱,如:

1
void foo(char *);
2
void foo(int);

如果 NULL 又被定义为了 0 那么 foo(NULL)将会去调用 foo(int),从而导致代码违反直观。

为了解决这个问题,C++11 引入了 nullptr 关键字,专门用来区分__空指针、0__。
nullptr 的类型为 nullptr_t,能够隐式的转换为任何指针或成员指针的类型,也能和他们进行相等或者不等运算。

当需要使用 NULL 时候,养成直接使用 nullptr 的习惯

Read more »