在linux字符系统中安装以下软件

1. 安装python +numpy+scipy+matplotlib(enthought成功)

2.安装 R(成功)

3. 安装gnuplot(安装成功)

4. 安装GSL

1.的安装文件

epd_free-7.3-2-rh5-x86_64.sh

安装成功的测试脚本

 

#-*-coding:gbk-*-
#########################################################################
#   Copyright (C) 2013 All rights reserved.
#
#   文件名称:a.py
#   创 建 者:刘禹 finallyly

#   创建日期:2013年01月27日
#   描    述:
#
#   备    注:
#
#########################################################################
#!/usr/bin/python
# please add your code here!
import matplotlib
matplotlib.use('Agg') # Must be before importing matplotlib.pyplot or pylab!
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
x=np.linspace(0,10,100);
plt.plot(x,np.sin(x));
fig.hold();
x=np.linspace(0,10,100);
plt.plot(x,0.5*np.cos(2*x));
plt.title("A matplotlib plot");
plt.text(1,-0.8,"cos func");
plt.ylim(-1.1,1.1);
fig.savefig('temp.png')

运行: liuyu: ~/MyTars/epd_free-7.3-2-rh5-x86_64/bin/Workbench$ ../python2.7 a.py

2.的安装参加http://blog.sina.com.cn/s/blog_61f013b80100yhef.html,我安装的版本是 R-2.15.2

2安装成功运行

 

3. 安装的版本是gsl-1.9,安装的位置是liuyu: ~/GSL
4. 安装完上述四个开源库后我的.bashrc内容如下
 

export PATH=$PATH:/home/liuyu/MyTars/epd_free-7.3-2-rh5-x86_64/bin                
export PATH=$PATH:/home/liuyu/MyTars/R-2.15.2/bin                                 
export R_HOME=/home/liuyu/MyTars/R-2.15.2/bin/R
export R_LIBS=/search/liuyu/MyTars/R-2.15.2/library
export LD_LIBRARY_PATH=${R_HOME}/lib:${LD_LIBRARY_PATH}
export LD_LIBRARY_PATH=/usr/local/lib:${LD_LIBRARY_PATH}  
export LD_LIBRARY_PATH=/home/liuyu/GSL/lib:${LD_LIBRARY_PATH} 

5. 源码安装软件的方式

tar -xzvf source.tar.gz

cd source

./configure --prefix=dir//指定安装目录

make

make install

卸载 make uninstall

6.程序调用GSL库(使用automake做编译)

Makefile.am的内容

 include $(top_srcdir)/common.mk
 
 bin_PROGRAMS=
 lib_LIBRARIES=
  ib_LTLIBRARIES=
  
  bin_PROGRAMS+=test
  INCLUDES=-I /search/liuyu/GSL/include
  test_SOURCES=test.cpp                                                                                         
 test_LDADD=  /home/liuyu/GSL/lib/libgsl.so /home/liuyu/GSL/li
    b/libgslcblas.so 
 test_LDFLAGS=-static-libtool-libs

test.cpp的源码

===============================================================
*   Copyright (C) 2013 All rights reserved.
*   
*   文件名称:a.cpp
*   创 建 者:刘禹 finallyly 
*   创建日期:2013年01月27日
*   描    述:
*   备    注: 
*   更新日志:
*
================================================================*/
 
// please add your code here!
#include<stdio.h>
#include "gsl/gsl_vector.h"
#include "gsl/gsl_matrix.h"
#include "gsl/gsl_blas.h"
#include "gsl/gsl_linalg.h"
int main()
{
    double r;
    gsl_vector *a,*b,*s,*t;
    gsl_matrix *m,*v;
    a=gsl_vector_alloc(2);
    b=gsl_vector_alloc(2);
    gsl_vector_set(a,0,1.0);
    gsl_vector_set(a,1,2.0);
    gsl_vector_set(b,0,3.0);
    gsl_vector_set(b,1,6.0);
    gsl_vector_add(a,b);
    gsl_vector_fprintf(stdout,a,"%f");
    gsl_blas_ddot(a,b,&r);
    fprintf(stdout,"%f\n",r);
    s=gsl_vector_alloc(2);
    t=gsl_vector_alloc(2);
    m=gsl_matrix_alloc(2,2);
    v=gsl_matrix_alloc(2,2);
    gsl_matrix_set(m,0,0,1.0);
    gsl_matrix_set(m,0,1,2.0);
    gsl_matrix_set(m,1,0,0.0);
    gsl_matrix_set(m,1,1,3.0);
    gsl_linalg_SV_decomp(m,v,s,t);
    gsl_vector_fprintf(stdout,s,"%f");
    gsl_vector_free(a);
    gsl_vector_free(b);
    gsl_vector_free(s);
    gsl_vector_free(t);
    gsl_matrix_free(m);
    gsl_matrix_free(v);
    return 0;
}

 运行结果:

 

 
gnuplot安装
1. 下载wxGTK-2.8.12-i486-1alien.tgz,解压后将libwx_gtk2u_richtext-2.8.so.0.8.0拷贝至/usr/local/lib(之所以放在这里是因为/etc/ld.so.conf中指定了这个目录为动态链接库的功能目录)
2. 然后 进入源码,以root身份安装我的gnuplot源码为gnuplot-4.6.rc1.tar.gz
3. 之后配置bashrc中的path export PATH=$PATH:gnuplot的安装目录
4.调用 文件名plot.gp中有以下内容
1 plot sin(x)                                                                                                                 
  2 set grid
  3 set xlabel "X"
  4 set ylabel "Y"
  5 set terminal png
  6 set output "plot.png"
  7 replot
gnuplot plog.gp
会在当前路径下产生plot.png
 
f=scan(file="f3.txt"); quantile(f,0.01); #png(file="myplot2.png", bg="transparent"); #boxplot(f); fivenum(f); summary(f);
posted on 2013-01-27 18:22  finallyly  阅读(1291)  评论(0编辑  收藏  举报