Month: May 2012

亡兵纪念日

缺乏常识的人总是容易学到新东西…于是今天又知道一个节日。

今天,也就是五月的最后一个周一,是Memorial Day,wiki上译作亡兵纪念日,是为了悼念在战争中阵亡的美国官兵而设立的一个节日。下午从实验室出来也没有看到什么悼念的活动。倒是因为多数人不用上班,草坪上满是躺着晒太阳的男女老少。也有人在河边钓鱼,和往常一样很多人在跑步。

上周看到的一个游行就是和这个节日有关的,挺有意思。

一组鼓号队
IMG_0279

这个都出了号了
IMG_0280

美国人民游行起来太随意了
IMG_0278

比较Q
IMG_0276

这是“历史纪念馆代表队”
IMG_0277

小朋友们
IMG_0275

IMG_0274

IMG_0273

IMG_0271

这老几位着装还比较统一
IMG_0269

IMG_0270

又一支鼓号队,还有电吉他
IMG_0265

不知道为啥车子都有警长的名字
IMG_0261

IMG_0260

IMG_0258

IMG_0251

IMG_0257

这是霍博肯的消防车,经常看得到
IMG_0248

IMG_0247

鼓号队很多
IMG_0249

IMG_0242

IMG_0236

SSE2 Vector Operation by Vlfeat

If you are writing something involving the math between vectors in C/C++, you may want to check out Vlfeat (http://vlfeat.org).

It is designed to be a library for Computer Vision related stuff, but it also bring you a wrapper for SSE2 acceleration for vector computation.

Say your original code for the calculation of vectors product looks like this:

float productOfVectors(const float *vecA, const float *vecB, const int dimension) {
   float value = 0.0f;
   for (int i = 0; i < dimension; i++)
   {
        value += (vecA[i] * vecB[i]);
   }
   return value;
}

It can save you time significantly by adding vlfeat to your project and replace it with this:

float productOfVectors(const float *vecA, const float *vecB, const int dimension) {
   float value = 0.0f;
   vl_eval_vector_comparison_on_all_pairs_f(&value, dimension, vecA, 1, vecB, 1, vl_get_vector_comparison_function_f(VlKernelL2));
   return value;
}

It's pretty easy but it really works. It takes use of the SSE2 instructions provided by your CPU which result in an non-trivial acceleration when you are doing large scale computation.

You can find more supported forms of calculation here, thanks for the developer's good job.