26 October, 2010

compress to multi volumes: rar a -v15000

rar a -v15000

rar a -v15000 -m0 -vn -rr -ep

24 October, 2010

Eigen Solvers

Eigen Solver:

PARPACK
Trilinos/Anasazi
JDBSYM
LOBPCG
PRIMME

Current Eigensolvers

Unlike ARPACK, which provides a single eigensolver, Anasazi provides a framework capable of describing a wide variety of eigenproblems and algorithms for solving them. Anasazi can currently solve complex and real, Hermitian and non-Hermitian, eigenvalue problems, via the following included methods:

* Block Krylov-Schur method, a block extension of A Krylov-Schur Algorithm for Large Eigenproblems, G. W. Stewart, SIAM J. Matrix Anal. Appl., 23, pp. 601-614 (2000).
* Block Davidson method described in A Comparison of Eigensolvers for Large-scale 3D Modal Analysis Using AMG-Preconditioned Iterative Methods, P. Arbenz, U. L. Hetmaniuk, R. B. Lehoucq, R. S. Tuminaro, Internat. J. for Numer. Methods Engrg., 64, pp. 204-236 (2005)
* LOBPCG, a stable implementation of Toward the optimal preconditioned eigensolver: Locally optimal block preconditioned conjugate gradient method, SIAM J. Sci. Comput., 23 (2001), pp. 517-541, as described in Basis selection in LOBPCG, U. L. Hetmaniuk and R. B. Lehoucq, J. Comput. Physics, 218, pp. 324-332 (2006)
* IRTR, an implicit version of the Riemannian Trust-Region Eigensolver, orginally described in A truncated-CG style method for symmetric generalized eigenvalue problems, P.-A. Absil, C. G. Baker, and K. A. Gallivan, J. Computational and Applied Mathematics, 189, pp. 274-285 (2006).

09 October, 2010

openGL libs on mac os x

LDFLAGS += -dylib_file \
/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:\
/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib \
-framework Cocoa -framework OpenGL -framework Carbon -framework IOKit 

26 April, 2010

Matplot-python [FROM http://www.kunli.info/2009/02/08/matplot-python-manual/]

【FROM http://www.kunli.info/2009/02/08/matplot-python-manual/】

本文是给自己的Matplot-python用法速查列表,并非任何正式文章,如果看不明白不用奇怪,不感兴趣的朋友直接跳过。
最近上Data Mining课作业老要求画图,反正都是用python做,实在厌倦了Gnuplot,所以决定完全投身Matplot怀抱。但因为使用频率不高,每次要 用的时候就感觉忘了,查manual太累,放狗搜又没有什么好的中文教程,所以把一些常用方法记录在这里,主要是几种常画图的典型例子。以后多接触一种, 就添加一种,随时更新。
顺便提一句,如果是pythoner,坚决推荐用matplot画图,方便程度仅次于matlab,但与python无缝接合。
典型的Matplot例子:

import numpy as np
import matplotlib.pyplot as plt

def f(t):
return np.exp(-t) * np.cos(2*np.pi*t)
t1 = np.arange(0.0, 5.0, 0.1)
t2 = np.arange(0.0, 5.0, 0.02)
plt.figure(1)
plt.subplot(211)
plt.plot(t1, f(t1), ‘bo’, t2, f(t2), ‘k’)
plt.subplot(212)
plt.plot(t2, np.cos(2*np.pi*t2), ‘r–’)
题目,坐标轴设置
最简单的就是通过title,xlabel和ylabel设置,比如
xlabel(”xxxx”, fontsize=18, color=”red”)
这里title是某个axis的title,如果希望整个figure有title,那么需要用suptitle() 函数,用法和title是一样的。
x和y轴的范围设定是通过
plt.axis([0, 6, 0, 20])
这就是表示x轴是0到6,y轴是0到20。也可以用xlim和ylim单独控制,比如
ylim( ymin, ymax )
当然还可以用yscale和xscale指定坐标轴的scale类型,分别是‘linear’ | ‘log’ | ‘symlog’,比如
xscale("log")
还可以通过yaxis.grid和xaxis.grid控制怎么显示网格,是否显示网格。grid的函数是这样的
grid(self, b=None, which=’major’, **kwargs)
Set the axis grid on or off; b is a boolean use which =
‘major’ | ‘minor’ to set the grid for major or minor ticks
如果用yaxis.grid (false),就表示不用显示y轴方向的网格。
有时候我们需要在坐标轴上放文字,比如在x轴上放置月份名称之类,这就需要xticks函数。其用法是比如
xticks( arange(5), ('Tom', 'Dick', 'Harry', 'Sally', 'Sue') )
这里,第一个参数表示放置位置,第二个是放置内容。
设置曲线特征
lines = plt.plot(x1, y1, x2, y2)
# use keyword args
plt.setp(lines, color='r', linewidth=2.0)
# or matlab style string value pairs
plt.setp(lines, 'color', 'r', 'linewidth', 2.0)
如果希望知道有哪些属性可以指定,可以传递对象给setp()函数,比如
In [69]: lines = plt.plot([1,2,3])
In [70]: plt.setp(lines)
alpha: float
animated: [True | False]
antialiased or aa: [True | False]
…snip
具体能控制的属性参见这 里。
文字处理
text()命令可以被用来放置文字在绝对坐标轴上,用法是
text(60, .025, r'$\mu=100,\ \sigma=15$', horizontalalignment='left', verticalalignment='top')
放置的东西前面加个r表示包括数学公式。具体能控制的属性可以参见属 性列表。具体的数学公式和符号的表达方式参见这 里。
这只是放置文字,还有一种需求是要求放置文字标注比如这种图:
这时候就要用到anotate()函数了,用法大概是这样的,
plt.annotate('local max', xy=(2, 1), xytext=(3, 1.5), arrowprops=dict(facecolor='black', shrink=0.05), )
第一个参数是要放置的文字,第二个参数是要指向的坐标,第三个是放置文字的坐标,最后一个是箭头属性。相关属性设置参见这 里。
对于经常写公式的人来讲,可能latex的格式会感觉更加常用一点。这时候,可以在放置text之前先用
rc('text', usetex=True)
然后与文字有关的地方都用r”"来引用,比如
title(r"\TeX\ is Number $\displaystyle\sum_{n=1}^\infty\frac{-e^{i\pi}}{2^n}$!",
fontsize=16, color='r')
画函数
plt.plot最简单的形式就是take一组列表数据
plt.plot([1,2,3])
此时plot自动将其认为是y轴的数据,x轴数据自动分配,相当于是
plt.plot([0,1,2],[1,2,3])
也就是说,对于plot,标准形式是
plt.plot([1,2,3,4], [1,4,9,16])
当然,后面可以跟控制表示形式的参数,比如
plt.plot([1,2,3,4], [1,4,9,16], 'ro')
就表示用红色点表示,而不是直线。参数默认是’b-’,表示蓝色直线。
plot还支持同时在一张图里面绘制多个图形,比如

import matplotlib.pyplot as plt
plt.plot(x1, y1, 'r--', x2, y2, 'bs', x3, y3, 'g^')
就可以用不同的形式绘制三条曲线。
画子图
用plt.subplot(xxx),第一个数字表示numrows,第二个表示numcols,第三个表示fignum。fignum的数量最高 也就是numrows乘以numcols。
如果是想产生多个图,每个图包含几个子图,那用figure()来控制图的数量。
画直方图
用函数
hist(x, bins=10, range=None, normed=False, cumulative=False,
bottom=None, histtype='bar', align='mid',
orientation='vertical', rwidth=None, log=False, **kwargs)
具体用法参加这 里。
画分布图
函数
scatter(x, y, s=20, c='b', marker='o', cmap=None, norm=None,
vmin=None, vmax=None, alpha=1.0, linewidths=None,
verts=None, **kwargs)
具体参数看这 里,唯一一个不是很确定的是s的取值,我曾经估计是s值要和x和y的列表长度一样,也就是大概是点的个数?但具体画的时候发现不是这样,点的个数 取决于x和y的列表长度。有待研究。
画Box Plot图
用matplot画Box Plot不知道有多方便,直接用函数
boxplot(x, notch=0, sym='+', vert=1, whis=1.5,
positions=None, widths=None)
你直接把一组数用x送进去,出来就是Box图。如果你想一个图表示多个Box,也很简单,让xappend多个list,出来的就是这些list的 box图。一个例子如下
for attribute in iris[type].keys():
list = iris[type][attribute]
data.append(list)
subplot(2,2,count)
title("Boxplot of %s" % type, fontsize=18, color="red")
xticks(arange(5),("","Sepal len","Sepal wid","Petal len","Petal wid"))
ylabel("Value")
boxplot(data,0,'gd')

详细的属性控制参见这 里。
画幂函数图
例子
from matplotlib.matlab import *
x = linspace(-4, 4, 200)
f1 = power(10, x)
f2 = power(e, x)
f3 = power(2, x)

plot(x, f1, 'r', x, f2, 'b', x, f3, 'g', linewidth=2)
axis([-4, 4, -0.5, 8])
text(1, 7.5, r'$10^x$', fontsize=16)
text(2.2, 7.5, r'$e^x$', fontsize=16)
text(3.2, 7.5, r'$2^x$', fonsize=16)
title('A simple example', fontsize=16)

savefig('power.png', dpi=75)
show()

显示图形中的数学公式
Matplotlib 可以支持一部分 TeX 的排版指令,因此用户在绘制含有数学公式的图形时会感到很方便并且可以得到比较满意的显示效果,所需要的仅仅是一些 TeX 的排版知识。下面的这个例子显示了如何在图形的不同位置上, 如坐标轴标签,图形的标题以及图形中适当的位置处,显示数学公式。相应的 Python 程序如下:
from matplotlib.matlab import *
def f(x, c):
m1 = sin(2*pi*x)
m2 = exp(-c*x)
return multiply(m1, m2)
x = linspace(0, 4, 100)
sigma = 0.5
plot(x, f(x, sigma), 'r', linewidth=2)
xlabel(r'$\rm{time} \ t$', fontsize=16)
ylabel(r'$\rm{Amplitude} \ f(x)$', fontsize=16)
title(r'$f(x) \ \rm{is \ damping \ with} \ x$', fontsize=16)
text(2.0, 0.5, r'$f(x) = \rm{sin}(2 \pi x^2) e^{\sigma x}$', fontsize=20)
savefig('latex.png', dpi=75)
show()

build gnuplot on Mac OS X

gnuplot on Mac OS X

./configure –with-readline=bsd –x-include=/usr/include/X11 –x-libraries=/usr/X11/lib

make && make install

Fink on Mac OS X

【FROM http://www.kunli.info/2009/12/11/mac-install-pink/】

苹果上自带的Unix其实是很少的,像gcc,make,gnuplot,unrar啊这种杀人越货必备武器都默认没有的。gcc这帮工具好说,安装xcode就行了,其他东西以前用Mac的时候都是用MacPort来搞,但是这次的新Mac在安装Unix工具的时候,上网搜了一下,发现Fink这个更好的工具。

Fink工程的目的和MacPort一样,通过修改 Unix 软件来port到Mac OS X 上,然后提供某种下载安装机制供大家使用。在Fink里面你可以像Ubuntu中那样用apt这套工具直接安装二进制包,也可以直接使用Fink来通过源代码编译安装。一般直接用Fink比较好,因为里面的东西比较新。


Fink 的所有文件几乎都安装在 /sw (或你选择安装的地方)。因此,如果你想删除 Fink,输入下面的命令:

sudo rm -rf /sw

升级fink自身

fink selfupdate
fink selfupdate-rsync
fink index -f
fink selfupdate

安装

fink install xxx

卸载

fink remove xxx

如果想把依赖包也一起卸载,加-r。如果想配置文件一并卸载,用

fink purge

类似与ubuntu里面的remove –purge

更新所有已安装包

fink update-all

查看可安装包

fink list xxx 或者 fink apropos xxx

也支持正泽表达式

fink list “xxx*”

查看相关包的描述

fink info

如果不小心删除了某个包的文件,想重新安装整个包

fink reinstall

显示某个包的依赖关系

fink show-deps xxx

23 April, 2010

开源科学计算 open source sci

linpack

* 软件名称 Linear Algebra Package
* 程序设计语言 Fortran 77
* 发布日期 1980
* 资源网址 http://www.netlib.org/linpack
* 下载专栏 Linpack压缩包
* 功能概述 解线性方程和线性最小二乘问题的子程序包(各项性能已经被lapack超过)

lapack

* 软件名称 Linear Algebra Package
* 程序设计语言 Fortran 77
* 发布日期 Version 3.0, 1999,9,30 (1999, 10, 31发布升级包)
* 资源网址 http://www.netlib.org/lapack
* 下载专栏 Lapack压缩包 ,Lapack升级包,Lapack Quick Reference
* 功能概述 线性代数计算子程序包

lapack++

* 软件名称 Linear Algebra Package in c++
* 程序设计语言 c++
* 资源网址 http://math.nist.gov/lapack++/
* 功能概述 c++版的线性代数计算子程序包

BLAS

* 软件名称 Basic Linear Algebra Subroutines
* 程序设计语言 Fortran 77
* 版本信息 V1.0, 1999,3,1
* 主要开发者 Kagstrom B. ,Ling P. ,Van Loan C.
* 资源网址 http://www.netlib.org/blas
* 下载专栏 Blas完整包 :Blas1压缩包 ,Blas2压缩包 ,Blas3压缩包 ,Blas Quick Reference
* 功能概述 Blas是执行向量和矩阵运算的子程序集合。

gsl

* 软件名称 GNU Scientific Library
* 当前版本号 gsl-1.5 was released in June 2004.
* 程序设计语言 C , C++ compable
* 资源网址 http://www.gnu.org/software/gsl/
* 下载专栏 ftp://ftp.gnu.org/gnu/gsl/
* 手册 http://www.gnu.org/software/gsl/manual/gsl-ref_toc.html
* 功能概述 范围广泛, 包括数值分析的常见内容

CXML

* 软件名称 C the Extended Math Library
* 当前版本号 CXML Version 5.2.0 for Alpha LINUX -- Released 10/01/2002.
* 程序设计语言 C
* 资源网址 http://www.hp.com/techservers/software/cxml.html
* 下载专栏 http://h18000.www1.hp.com/math/download/index.html
* 功能概述 包括四个库: Blas, lapack, Sparse, Signal processing

CXML is a collection of mathematical routines optimized for Alpha systems. These subroutines perform numerically intensive operations that occur frequently in engineering and scientific computing, such as linear algebra and signal processing. CXML can help reduce the cost of computation, enhance portability, and improve productivity.
IMSL

* 软件名称 IMSL C Numerical Library
* 当前版本号 5.5
* 程序设计语言 C, Forton
* 资源网址 http://www.vni.com/ http://www.vni.com/products/imsl/c/imslc.html
* 功能概述 分为统计库和数学库两部分. 数学库包含应用数学和特殊函数.IMSL 程序库 - 已成为数值分析解决方案的工业标准。 IMSL 程序库提供最完整与最值得信赖的函数库。 IMSL 数值程序库提供目前世界上最广泛被使用的 IMSL 算法,有超过 370 验证过、最正确与 thread-safe 的数学与统计程序。 IMSL FORTRAN 程序库提供新一代以 FORTRAN 90 为程序库基础的程序,能展现出最佳化的演算法能力应用于多处理器与其它高效能运算系统。

其中应用数学部分解决以下问题:

* 线性代数方程,最小平方差问题等.
* 特征值与系统等问题
* 内差法与逼近法之各种应用计算
* 数值积分与微分
* 常微分方程组初值与边值问题,二三维之典型Poisson方程.
* 正反Fourier与Laplace变换
* 实复系数函数或非线性方程组零根求解等问题
* 不设限或简单设限数理规划最优化等各种问题
* 基本线性代数各种运算所需程序(BLAS)
* 打印,排序,计时随即数,简易绘图等各种工具

统计部分包括

* 基本统计
* 回归
* 相关
* 变异数分析
* 类别及离散资料分析
* 无母数统计
* 适合度及随机性检定
* 时间序列分析及预测
* 共变异结构与因子分析
* 区别分析
* 抽样
* 生存分析
* 多维标度
* 密度及危险估计
* 标率分布及其反函数

特殊函数部分包括

* 指数对数等基本函数
* 正反三角函数及双曲等函数
* 积分函数如: Exponential, integral等
* Gamma函数
* 误差函数
* Bessel 函数
* Kelvin函数
* Airy函数
* 积分函数
* 椭圆函数
* 几率分布函数和其反函数
* Mathieu函数
* 其它如正文多项式运算等.

deal.II

* 软件名称 A Finite Element Differential Equations Analysis Library
* 当前版本号 Release 5.0.0
* 程序设计语言 C++
* 资源网址 http://gaia.iwr.uni-heidelberg.de/~deal/
* 功能概述 a C++ program library targeted at adaptive finite elements and error estimation. It uses state-of-the-art programming techniques of the C++ programming language to offer you a modern interface to the complex data structures and algorithms required for adaptivity and enables you to use a variety of finite elements in one, two, and three space dimensions, as well as time-dependent problems.

SCALAPACK

* 软件名称 Scalible Linear Algebra Package
* 版本信息 1.5 (1.5+ 升级版),1997,11,15
* 程序设计语言 Fortran 77
* 资源网址 http://www.netlib.org/scalapack
* 下载专栏 ScaLapack压缩包 ,ScaLapack升级包,ScaLapack Quick Reference
* 功能概述 多机线性代数计算子程序包

MPI

* 软件名称 Message-Passing Interface
* 版本信息 version 2.0, 1997
* 程序设计语言 Fortran 77
* 资源网址 http://www-unix.mcs.anl.gov/mpi/index.html
* 下载专栏 MPI自由应用的版本:mpich-1.1.2 ,mpich-1.2
* 功能概述 消息传递通讯库

PVM

* 软件名称 Parallel Virtual Machine
* 当前版本号 3.4.3, 2000, 2, 18
* 程序设计语言 Fortran 77
* 资源网址 http://www.epm.ornl.gov/pvm/pvm_home.html
* 下载专栏 PVM 3.4.0,PVM 3.4.3
* 功能概述 从网络模拟大型并行机的通讯库

PETSc

* 软件名称 Portable, Extensible Toolkit for Scientific Computation
* 当前版本号 2.2.1
* 程序设计语言 C, C++, and Fortran.
* 资源网址 http://www-unix.mcs.anl.gov/petsc/petsc-2/
* 功能概述 PETSc is a suite of data structures and routines for the scalable (parallel) solution of scientific applications modeled by partial differential equations. It employs the MPI standard for all message-passing communication.