搜索此博客

2012年8月14日星期二

linux 打包 解压

  .tar
  解包:tar zxvf FileName.tar
  打包:tar czvf FileName.tar DirName
  ---------------------------------------------


ref: http://www.blogjava.net/jiangjf/archive/2007/07/29/133122.html

2012年7月22日星期日

Linux -Delete Directory

1. delete file
% rm test.txt

2. delete directory
% rm -r DIRECTORY

3. force delete directory
% rm -rf DIRECTORY_Name

2012年7月4日星期三

matlab矩阵按某一行的值排序


比如一个二维举证[1,3,2,5,9;8,6,7,1,3]
怎么实现按第一行降幂排序为[1,2,3,5,9;8,7,6,1,3]
问题补充:
已经知道怎么做了
operation 1: 
        A=[1,3,2,5,9;8,6,7,1,3]
RESULT: 
A =

     1     3     2     5     9
     8     6     7     1     3
operation 2: 
[A(1,:),B]=sort(A(1,:),2,'ascend');
RESULT:
A =

     1     2     3     5     9
     8     6     7     1     3


B =

     1     3     2     4     5    - changed A(1,:) 's corresponding index number 
operation 3:
        A(2,:)=A(2,B);
RESULT:
A =

     1     2     3     5     9
     8     7     6     1     3
ref:http://zhidao.baidu.com/question/129962854

2012年6月1日星期五

【转】C++ Timer Function

you can use function clock() in to measure the elapsed time since program startup, e.g. to measure elapsed time for a section of code


  1. time_t  start_time = clock();                              /*  get start time  */
  2. ........ code to measure
  3.     float time1 = (float) (clock() - start_time) / CLOCKS_PER_SEC; 
  4.     printf("time for code was %f seconds\n", time1);


the actual CPU time could well be different depending upon the number of processes running, etc....


reference:http://bytes.com/topic/c/answers/576635-there-timer-function-c

【转】C++ Tic Toc function

This needs to introduction. While drinking milk i finally figured out the holy grail of C++, possibly the most universal and useful function i have ever written in any language. It formulates itself in practically three lines of code. Put the following outside the main():



double tt_tic=0;
 
void tic(){
 tt_tic = getTickCount();
}
void toc(){
 double tt_toc = (getTickCount() - tt_tic)/(getTickFrequency());
 printf ("toc: %4.3f s\n", tt_toc);
}



seriously, if you Google for “tic toc c++” you will get people writing on for ages in which way you can do this, instead of just posting the code. So here it is.
TADAA! Matlab-style tictoc functionality! You request it in your code (duh) just by stating “tic();” and then “toc();”. Also, all my code is licenced under a Creative Commons licence. This code on the other hand I have licenced under a beerware licence (http://en.wikipedia.org/wiki/Beerware). Just so you know.


reference: http://www.timzaman.nl/?p=2246&lang=en

2012年5月3日星期四

LaTeX: centering a table wider than the text column


\documentclass{article}

% allows for temporary adjustment of side margins
\usepackage{chngpage}

% provides filler text
\usepackage{lipsum}

% just makes the table prettier (see \toprule, \bottomrule, etc. commands below)
\usepackage{booktabs}

\begin{document}

\lipsum[1]% just a paragraph of filler text

\medskip% adds some space before the table
\begin{adjustwidth}{-1in}{-1in}% adjust the L and R margins by 1 inch
  \begin{tabular}{ll}
    \toprule
    Sequence & Wide column \\
    \midrule
    First & Vestibulum porta ultricies felis. In nec mi. \\
    Second & Nam vestibulum auctor nibh. In eleifend, lacus id tristique ullamcorper, mauris urna convallis elit. \\
    Third & Ut luctus nisi quam lobortis magna. Aenean sit amet odio et sapien rutrum lobortis. \\ 
    Fourth & Integer dictum accumsan purus. Nullam erat ligula, dictum sed, feugiat nec, faucibus id, ipsum. \\
    \bottomrule
  \end{tabular}
\end{adjustwidth}
\medskip% adds some space after the table

\noindent\lipsum[2]% just a paragraph of filler text

\end{document}




Within an adjustwidth environment the left and right margins can be adjusted. The environment takes one optional argument and two required length arguments:
\begin{adjustwidth}[]{leftmargin}{rightmargin}
A positive length value will increase the relevant margin
(shortening the text lines) while a negative length value will decrease the margin (lengthening text lines). An empty length argument means no change to the margin. At the end of the environment the margins revert to their original values.
For example, to extend the text into the right margin:
\begin{adjustwidth}{}{-8em}
Any appearance of the optional argument (even just []) will cause the values of the margins to switch between odd and even pages.
If the document is being set twosided it might be advantageous to have any wider text extending into the outside margin. This could be done via the optional argument, as:
\begin{adjustwidth}[]{}{-8em}
To have the adjusted text horizontally centered with respect to any surrounding text, the margins should be adjusted equally:
\begin{adjustwidth}{-4em}{-4em}