<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-20298197</id><updated>2012-01-24T11:54:11.275-05:00</updated><category term='UNIX'/><category term='C++'/><category term='Python'/><category term='Fortran'/><category term='Condor'/><category term='Debian'/><category term='Linux'/><category term='C'/><category term='Emacs'/><category term='Intel'/><category term='Computation'/><category term='REGEX'/><category term='R'/><title type='text'>Gong-Yi's Sandbox</title><subtitle type='html'>Random rants.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://gongyiliao.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20298197/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://gongyiliao.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Gong-Yi Liao</name><uri>http://www.blogger.com/profile/11302878591097519896</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_z6Jdlbxzyug/SpQsvBCZ5_I/AAAAAAAABvc/OqzYFfVOSZs/S220/emacs.png'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>7</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-20298197.post-3485750230705501360</id><published>2011-12-17T23:13:00.000-05:00</published><updated>2011-12-17T23:15:59.340-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='UNIX'/><category scheme='http://www.blogger.com/atom/ns#' term='REGEX'/><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><category scheme='http://www.blogger.com/atom/ns#' term='Debian'/><category scheme='http://www.blogger.com/atom/ns#' term='Emacs'/><title type='text'>Use kramdown + sed + syntaxhighlighter on Blogger.com</title><content type='html'>&lt;p&gt;if you use &lt;a href="http://kramdown.rubyforge.org"&gt;&lt;code&gt;kramdown&lt;/code&gt;&lt;/a&gt; and Blogger.com,&lt;br /&gt;
you may want to use the following &lt;code&gt;BASH&lt;/code&gt; script to get&lt;br /&gt;
&lt;a href="http://alexgorbatchev.com"&gt;&lt;code&gt;syntaxhighlighter&lt;/code&gt;&lt;/a&gt; works for your&lt;br /&gt;
&lt;code&gt;kramdown&lt;/code&gt; outputs:&lt;/p&gt;&lt;br /&gt;
&lt;pre class="brush:bash"&gt;#!/bin/sh
kramdown $1 | sed -e 's/^\(&amp;lt;pre class="brush:.*."&amp;gt;\)\(&amp;lt;code&amp;gt;\)/\1\n/g' | sed -e 's/^\(&amp;lt;\/code&amp;gt;\)\(&amp;lt;\/pre&amp;gt;\)/\2/g' 
&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20298197-3485750230705501360?l=gongyiliao.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gongyiliao.blogspot.com/feeds/3485750230705501360/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gongyiliao.blogspot.com/2011/12/use-kramdown-sed-syntaxhighlighter-on.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20298197/posts/default/3485750230705501360'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20298197/posts/default/3485750230705501360'/><link rel='alternate' type='text/html' href='http://gongyiliao.blogspot.com/2011/12/use-kramdown-sed-syntaxhighlighter-on.html' title='Use kramdown + sed + syntaxhighlighter on Blogger.com'/><author><name>Gong-Yi Liao</name><uri>http://www.blogger.com/profile/11302878591097519896</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_z6Jdlbxzyug/SpQsvBCZ5_I/AAAAAAAABvc/OqzYFfVOSZs/S220/emacs.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20298197.post-7758932458877684724</id><published>2011-12-17T22:14:00.000-05:00</published><updated>2011-12-17T22:16:41.076-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='UNIX'/><category scheme='http://www.blogger.com/atom/ns#' term='Condor'/><category scheme='http://www.blogger.com/atom/ns#' term='Computation'/><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><category scheme='http://www.blogger.com/atom/ns#' term='R'/><title type='text'>R + condor + git (1)</title><content type='html'>&lt;p&gt;For computational statisticians, putting codes to cluster sometimes becomes a frustrating task. &lt;/p&gt;&lt;br /&gt;
&lt;p&gt;For this situation, and, if you are a UNIX user, these tools might save you some time:&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;Here we use a &lt;a href="http://www.r-project.org"&gt;&lt;code&gt;R&lt;/code&gt;&lt;/a&gt; task on a &lt;a href="http://research.cs.wisc.edu/condor"&gt;&lt;code&gt;condor&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;&lt;code&gt;Rscipt&lt;/code&gt; file &lt;code&gt;test.R&lt;/code&gt;:&lt;/p&gt;&lt;br /&gt;
&lt;pre class="brush:r"&gt;#!/usr/bin/env Rscript
args = commandArgs()
load("funs.RData")
data.pros = load("data_file.RData")[[args[length(args)]]]
data.result = funct1(data.pros)
save(data.result, file=paste("output_RData_of_node_", 
                             args[length(args)]))           
&lt;/pre&gt;&lt;br /&gt;
&lt;p&gt;The condor file &lt;code&gt;test.condor&lt;/code&gt;:&lt;/p&gt;&lt;br /&gt;
&lt;pre class="brush:bash"&gt;executable = test.R
universe = vanilla
Requirements = ParallelSchedulingGroup == "stats group"
 
should_transfer_files = YES
when_to_transfer_output = ON_EXIT

arguments = $(Process) 
output    = cluster1-$(Process).Rout
error     = cluster1-$(Process).err
log       = cluster1.log

transfer_input_files = funs.Data, data_file.RData 

Queue 100
&lt;/pre&gt;&lt;br /&gt;
&lt;p&gt;In old days, we need to do the endless &lt;code&gt;write-&amp;gt;upload-&amp;gt;test-&amp;gt;modify-&amp;gt;upload-&amp;gt;test&lt;/code&gt; loops, now, with &lt;code&gt;git&lt;/code&gt;, we can have different fate.&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;First, you need to confirm the following conditions if all of them have been satisfied:&lt;/p&gt;&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;The cluster has &lt;code&gt;ssh&lt;/code&gt; installed on it;&lt;/li&gt;
&lt;li&gt;The cluster has &lt;code&gt;git&lt;/code&gt; installed on it;&lt;/li&gt;
&lt;li&gt;The cluster has &lt;code&gt;condor&lt;/code&gt; installed on it;&lt;/li&gt;
&lt;li&gt;Your account has sufficient disk quota on the cluster.&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;p&gt;Second, create a folder on the cluster, which well be used as the working directory of the condor task, and a directory as git repository:&lt;/p&gt;&lt;br /&gt;
&lt;pre class="brush:bash"&gt;ssh your_account@cluster "mkdir -p git_repos/$TASK_NAME.git"
ssh your_account@cluster "mkdir -p workspace/$TASK_NAME"
ssh your_account@cluster "cd git_repos/$TASK_NAME.git; git init --bare"
ssh your_account@clustre "cd git_repos/$TASK_NAME; git-init --bare" ## if you use old version of git
&lt;/pre&gt;&lt;br /&gt;
&lt;p&gt;On ocal machine, put the following three lines to your &lt;code&gt;$TASK_NAME/.git/config&lt;/code&gt;:&lt;/p&gt;&lt;br /&gt;
&lt;pre class="brush:bash"&gt;[remote "cluster"]
 url = ssh://cluster/home/your_account/git_repos/$TASK_NAME.git
 fetch = +refs/heads/*:refs/remotes/cluster/*
&lt;/pre&gt;&lt;br /&gt;
&lt;p&gt;On cluster, edit &lt;code&gt;git_repos/$TASK_NAME.git/hooks/post-receive&lt;/code&gt;:&lt;/p&gt;&lt;br /&gt;
&lt;pre class="brush:bash"&gt;export GIT_WORK_TREE=/home/your_account/workspace/$TASK_NAME
git checkout -f 
git-checkout -f ## if the cluster use older version of git 
&lt;/pre&gt;&lt;br /&gt;
&lt;p&gt;then, simply do:&lt;/p&gt;&lt;br /&gt;
&lt;pre class="brush:bash"&gt;git push cluster master
git-push cluster master ## if you use older version of git
ssh your_account@cluster "cd workspace/$TASK_NAME/; condor_submit test.condor"
&lt;/pre&gt;&lt;br /&gt;
&lt;p&gt;Then check your outputs.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20298197-7758932458877684724?l=gongyiliao.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gongyiliao.blogspot.com/feeds/7758932458877684724/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gongyiliao.blogspot.com/2011/12/r-condor-git-1.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20298197/posts/default/7758932458877684724'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20298197/posts/default/7758932458877684724'/><link rel='alternate' type='text/html' href='http://gongyiliao.blogspot.com/2011/12/r-condor-git-1.html' title='R + condor + git (1)'/><author><name>Gong-Yi Liao</name><uri>http://www.blogger.com/profile/11302878591097519896</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_z6Jdlbxzyug/SpQsvBCZ5_I/AAAAAAAABvc/OqzYFfVOSZs/S220/emacs.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20298197.post-7761733881000087914</id><published>2011-11-08T19:48:00.001-05:00</published><updated>2011-11-12T15:46:41.445-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='UNIX'/><category scheme='http://www.blogger.com/atom/ns#' term='C'/><category scheme='http://www.blogger.com/atom/ns#' term='Computation'/><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><category scheme='http://www.blogger.com/atom/ns#' term='Debian'/><category scheme='http://www.blogger.com/atom/ns#' term='Fortran'/><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><category scheme='http://www.blogger.com/atom/ns#' term='Python'/><category scheme='http://www.blogger.com/atom/ns#' term='Intel'/><category scheme='http://www.blogger.com/atom/ns#' term='R'/><title type='text'>MKL for Debian</title><content type='html'>&lt;p&gt;After testing the &lt;a href="http://www.blogger.com/blogger.g?blogID=20298197"&gt;Intel MKL&lt;/a&gt;, I found the way to make it works on 64-bit Debian-based Linux distribution:&lt;br /&gt;
&lt;script class="brush: bash" type="syntaxhighlighter"&gt;
&lt;![CDATA[
$ gfortran -L/opt/intel/mkl/lib/intel64 -lmkl_rt -lmkl_core -lmkl_gf_lp64 -lmkl_gnu_thread -lmkl_gf_ilp64 -lmkl_def -lgomp -lpthread -shared -Wl,-soname,libblas.so -o libblas.so.3gf.0
$ gfortran -L/opt/intel/mkl/lib/intel64 -lmkl_rt -lmkl_core -lmkl_gf_lp64 -lmkl_gnu_thread -lmkl_gf_ilp64 -lmkl_def -lgomp -lpthread -shared -Wl,-soname,liblapack.so -o liblapack.so.3gf.0
]]&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;br/&gt;&lt;br /&gt;
If you system is 32-bit:&lt;br /&gt;
&lt;script class="brush: bash" type="syntaxhighlighter"&gt;
&lt;![CDATA[
$ gfortran -L/opt/intel/mkl/lib/ia32 -lmkl_rt -lmkl_core -lmkl_gf -lmkl_gnu_thread -lmkl_def -lgomp -lpthread -shared -Wl,-soname,libblas.so -o libblas.so.3gf.0
$ gfortran -L/opt/intel/mkl/lib/ia32 -lmkl_rt -lmkl_core -lmkl_gf -lmkl_gnu_thread -lmkl_def -lgomp -lpthread -shared -Wl,-soname,liblapack.so -o liblapack.so.3gf.0
]]&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;/br&gt;&lt;br /&gt;
and then, you may do the following steps:&lt;br /&gt;
&lt;script class="brush: bash" type="syntaxhighlighter"&gt;
&lt;![CDATA[
$ sudo -s
$ mkdir /usr/local/lib/MKL
$ mv liblapack.so.3gf.0 libblas.so.3gf.0 /usr/local/lib/MKL
$ cd /usr/local/lib/MKL
$ touch /etc/ld.so.conf.d/mkl.conf
$ echo "/opt/intel/mkl/lib/ia32" &gt; /etc/ld.so.conf.d/mkl.conf 
$ echo "/usr/local/lib/MKL" &gt;&gt; /etc/ld.so.conf.d/mkl.conf 
$ ln -s libblas.so.3gf.0 libblas.so.3gf
$ ln -s liblapack.so.3gf.0 liblapack.so.3gf
$ ldconfig
$ update-alternatives --install /usr/lib/libblas.so.3gf libblas.so.3gf /usr/local/lib/MKL/libblas.so.3gf 90
$ update-alternatives --install /usr/lib/liblapack.so.3gf  liblapack.so.3gf /usr/local/lib/MKL/liblapack.so.3gf 90
$ update-alternatives --install /usr/lib/libblas.so libblas.so /usr/local/lib/MKL/libblas.so 90
$ update-alternatives --install /usr/lib/liblapack.so  liblapack.so /usr/local/lib/MKL/liblapack.so 90
$ ldconfig 
$ exit
]]&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;br/&gt;&lt;br /&gt;
Now you can use MKL with most Debian numerical packages on Debian-based systems without too many problems.&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20298197-7761733881000087914?l=gongyiliao.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gongyiliao.blogspot.com/feeds/7761733881000087914/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gongyiliao.blogspot.com/2011/11/mkl-for-debian.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20298197/posts/default/7761733881000087914'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20298197/posts/default/7761733881000087914'/><link rel='alternate' type='text/html' href='http://gongyiliao.blogspot.com/2011/11/mkl-for-debian.html' title='MKL for Debian'/><author><name>Gong-Yi Liao</name><uri>http://www.blogger.com/profile/11302878591097519896</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_z6Jdlbxzyug/SpQsvBCZ5_I/AAAAAAAABvc/OqzYFfVOSZs/S220/emacs.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20298197.post-5757465219568018275</id><published>2011-09-09T14:28:00.002-04:00</published><updated>2011-09-19T08:38:22.435-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='UNIX'/><category scheme='http://www.blogger.com/atom/ns#' term='Condor'/><category scheme='http://www.blogger.com/atom/ns#' term='R'/><title type='text'>Condor and R (1)</title><content type='html'>It is quite useful to use and &lt;a href="http://www.cs.wisc.edu/condor/"&gt;condor&lt;/a&gt; and &lt;a href="http://stat.ethz.ch/R-manual/R-patched/library/utils/html/Rscript.html"&gt;Rscript&lt;/a&gt; to compute some heavy &lt;code&gt;R&lt;/code&gt; tasks. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;del&gt;But, &lt;code&gt;condor&lt;/code&gt; dose not provided some easy mechanism to&lt;br /&gt;
transfer files over nodes.&lt;/del&gt; For example, you have a &lt;code&gt;.RData&lt;/code&gt;&lt;br /&gt;
file which contains the data frames and variables you need for the&lt;br /&gt;
computing tasks like the following setup:&lt;br /&gt;
\[&lt;br /&gt;
\boldsymbol y = \mathbf X_i + \boldsymbol\varepsilon_i&lt;br /&gt;
\]&lt;br /&gt;
where you have a moving window over $\mathbf X$ with size $w$.&lt;br /&gt;
For this purpose, you may want to use following &lt;code&gt;R&lt;/code&gt; code to&lt;br /&gt;
do it sequentially:&lt;br /&gt;
&lt;script class="brush: r" type="syntaxhighlighter"&gt;
&lt;![CDATA[
load("data_set_1.RData")
lm.objects &lt;- list()
for (i in 1:(ncol(X)-w+1))
   lm.objects[[i]] &lt;- lm(y ~ X[,i:(i+w-1)])
]]&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It's not a big problem if you run it sequentially or run it&lt;br /&gt;
parallelly on your local machine:&lt;br /&gt;
&lt;script class="brush: r" type="syntaxhighlighter"&gt;
&lt;![CDATA[
load("data_set_1.RData")
require(doMC)
registerdoMC()
lm.objects &lt;- foreach(i in 1:(ncol(X)-w+1)) %dopar%
                lm(y~X[,i:(i+w-1)])
]]&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The problem is doing it with &lt;code&gt;condor&lt;/code&gt;:&lt;br /&gt;
&lt;script class="brush: r" type="syntaxhighlighter"&gt;
&lt;![CDATA[
#!/usr/bin/env Rscript
load("data_set_1.RData")
cmd.args &lt;- commandArgs(TRUE)
i &lt;- as.numeric(cmd.args[2])
w &lt;- as.numeric(cmd.args[3])
rdata.file.name = paste(cmd.args[4], i, ".RData", sep="_")
save(lm(y ~ X[,i:(i+w-1)]), file=rdata.file.name)
]]&gt;
&lt;/script&gt;&lt;br /&gt;
with the &lt;code&gt;condor&lt;/code&gt; file: &lt;br /&gt;
&lt;script class="brush: bash" type="syntaxhighlighter"&gt;
&lt;![CDATA[ 
executable = test.R
universe = vanilla
Requirements = ParallelSchedulingGroup == "stats group"

should_transfer_files = YES
when_to_transfer_output = ON_EXIT

arguments = --args $(Process) 3 test_data_$(Process)
output    = test1_$(Process).Rout
error     = test1_$(Process).err
log       = test1_.log

Queue 1000
]]&gt;
&lt;/script&gt;&lt;br /&gt;
You will get some &lt;code&gt;condor&lt;/code&gt; error message like:&lt;br /&gt;
&lt;script class="brush: bash" type="syntaxhighlighter"&gt;
&lt;![CDATA[
ERROR: file "data_set_1.RData" could not be found. 
]]&gt;
&lt;/script&gt;&lt;br /&gt;
then how should we fix it ?&lt;br /&gt;
&lt;br /&gt;
Update: Just use:&lt;br /&gt;
&lt;script class="brush: bash" type="syntaxhighlighter"&gt;
&lt;![CDATA[
transfer_input_files = data_set_1.RData
]]&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20298197-5757465219568018275?l=gongyiliao.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gongyiliao.blogspot.com/feeds/5757465219568018275/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gongyiliao.blogspot.com/2011/09/condor-and-r-1.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20298197/posts/default/5757465219568018275'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20298197/posts/default/5757465219568018275'/><link rel='alternate' type='text/html' href='http://gongyiliao.blogspot.com/2011/09/condor-and-r-1.html' title='Condor and R (1)'/><author><name>Gong-Yi Liao</name><uri>http://www.blogger.com/profile/11302878591097519896</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_z6Jdlbxzyug/SpQsvBCZ5_I/AAAAAAAABvc/OqzYFfVOSZs/S220/emacs.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20298197.post-5673978727620477973</id><published>2011-09-08T03:47:00.001-04:00</published><updated>2011-09-08T03:59:31.574-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='R'/><title type='text'>RcppArmadillo's matrix allocation cost</title><content type='html'>&lt;p&gt;Let's see a simple example of &lt;a href="http://dirk.eddelbuettel.com/code/rcpp.armadillo.html"&gt;RcppArmadillo&lt;/a&gt;:&amp;nbsp; &lt;a href="http://en.wikipedia.org/wiki/Singular_value_decomposition"&gt;SVD&lt;/a&gt;.&lt;/p&gt;&lt;br /&gt;
&lt;script type="syntaxhighlighter" class="brush: r"&gt;&lt;![CDATA[
require(RcppArmadillo)
require(inline)

arma.code.1 &amp;lt;- '
  using namespace arma;
  mat A = randn&lt;mat&gt;(as&lt;int&gt; (nrow), as&lt;int&gt; (ncol));
  vec s = svd(A);
  return wrap(s);
'
rcppFun1 &amp;lt;- cxxfunction(signature(ncol="numeric",
                                  nrow="numeric"),
                        arma.code.1,
                        plugin="RcppArmadillo")

arma.code.2 &amp;lt;- '
  using namespace arma;
  mat A = randn&lt;mat&gt;(as&lt;int&gt; (nrow), as&lt;int&gt; (ncol));
  mat U;
  vec s;
  mat V;
  svd(U, s, V, A);
  return wrap(s);
'
rcppFun2 &amp;lt;- cxxfunction(signature(ncol="numeric",
                                  nrow="numeric"),
                        arma.code.2,
                        plugin="RcppArmadillo")
]]&gt;&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;p&gt;Then we can have a very simple comparison:&lt;/p&gt;&lt;script type="syntaxhighlighter" class="brush: r"&gt;&lt;![CDATA[
&gt; system.time(rcppFun1(1000, 1000))
   user  system elapsed 
  1.960   0.020   1.055 
&gt; system.time(rcppFun2(1000, 1000))
   user  system elapsed 
  4.790   0.050   2.688 
&gt; system.time(svd(matrix(rnorm(1e6), 1e3)))
   user  system elapsed 
  3.500   0.030   1.905 
]]&gt;&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;p&gt;It seems that &lt;code&gt;RcppArmadillo&lt;/code&gt; does not always outperform the vanilla &lt;code&gt;R&lt;/code&gt;. We can find that matrix allocation in &lt;code&gt;Armadillo&lt;/code&gt; costs some footprints in both memory (because call by value mechanism) and CPU time. I didn't ask &lt;code&gt;RcppArmadillo&lt;/code&gt; to return &lt;code&gt;U, V&lt;/code&gt; in &lt;code&gt;arma.code.2&lt;/code&gt;, but the benchmark results show that &lt;code&gt;RcppArmadillo&lt;/code&gt; spent more time on same SVD task than vanilla &lt;code&gt;R&lt;/code&gt;.&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;&lt;em&gt;p.s.: Thanks &lt;a href="http://yihui.name/en/2010/09/syntaxhighlighter-brush-for-the-r-language/"&gt;Yihui Xie's R brush&lt;/a&gt; for Syntaxhighlighter.&lt;/em&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20298197-5673978727620477973?l=gongyiliao.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gongyiliao.blogspot.com/feeds/5673978727620477973/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gongyiliao.blogspot.com/2011/09/rcpparmadillos-matrink-allocation-cost.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20298197/posts/default/5673978727620477973'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20298197/posts/default/5673978727620477973'/><link rel='alternate' type='text/html' href='http://gongyiliao.blogspot.com/2011/09/rcpparmadillos-matrink-allocation-cost.html' title='RcppArmadillo&apos;s matrix allocation cost'/><author><name>Gong-Yi Liao</name><uri>http://www.blogger.com/profile/11302878591097519896</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_z6Jdlbxzyug/SpQsvBCZ5_I/AAAAAAAABvc/OqzYFfVOSZs/S220/emacs.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20298197.post-8615237335892643770</id><published>2011-09-06T21:51:00.004-04:00</published><updated>2011-09-06T21:52:44.399-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='UNIX'/><category scheme='http://www.blogger.com/atom/ns#' term='Emacs'/><title type='text'>My .Emacs -- 2011 Sep 06</title><content type='html'>&lt;a href="http://dl.dropbox.com/u/1628592/dot_Emacs.zip"&gt;Here&lt;/a&gt; is my dot Emacs files, you can extract then put them under you home directory, just don't forget to rename dot.emacs(.d) as .emacs(.d).&lt;br /&gt;
&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20298197-8615237335892643770?l=gongyiliao.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gongyiliao.blogspot.com/feeds/8615237335892643770/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gongyiliao.blogspot.com/2011/09/my-emacs-2011-sep-06.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20298197/posts/default/8615237335892643770'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20298197/posts/default/8615237335892643770'/><link rel='alternate' type='text/html' href='http://gongyiliao.blogspot.com/2011/09/my-emacs-2011-sep-06.html' title='My .Emacs -- 2011 Sep 06'/><author><name>Gong-Yi Liao</name><uri>http://www.blogger.com/profile/11302878591097519896</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_z6Jdlbxzyug/SpQsvBCZ5_I/AAAAAAAABvc/OqzYFfVOSZs/S220/emacs.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20298197.post-6937614355026547716</id><published>2011-02-21T01:00:00.000-05:00</published><updated>2011-02-21T01:00:56.294-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='UNIX'/><category scheme='http://www.blogger.com/atom/ns#' term='R'/><title type='text'>Using Revolution R 4.2 in Ubuntu 10.10</title><content type='html'>This is a quick note for those who want to use &lt;a href="http://www.revolutionanalytics.com/"&gt;Revolution Analytics&lt;/a&gt;'s &lt;a href="http://www.revolutionanalytics.com/products/revolution-enterprise.php"&gt;Enterprise R 4.2&lt;/a&gt; in Ubuntu 10.10&lt;br /&gt;
&lt;br /&gt;Of course, the first thing you have to do is getting a copy of the software, you can purchase it by contacting &lt;a href="http://www.revolutionanalytics.com/"&gt;Revolution Analytics&lt;/a&gt; or download the version for academic.&lt;br /&gt;
&lt;br /&gt;
The biggest issue is that Enterprise R 4.2 only supports RHEL 5.5 or earlier. I have confirmed that the "aliened" rpms do not work in Ubuntu or Debian&amp;nbsp; (you can't find the executables, only the libraries),&amp;nbsp; thus.&amp;nbsp; An instance of working installed RHEL is required.&lt;br /&gt;
&lt;br /&gt;
Installing RHEL (or, CentOS) is not a big deal, the big deal is that you have to use the old version software without "optimized usability" shipped with RHEL, I think that definitely a nightmare for spoiled Ubuntu users. &lt;br /&gt;
&lt;br /&gt;
Thank KVM, we can reach the point we want: we can use the Ubuntu as the host and CentOS as the guest OS running on the virtual machine and commute them via ssh.&lt;br /&gt;
&lt;br /&gt;
The following steps are what I done to make Enterprise R 4.2 works for me:&lt;br /&gt;
&lt;br /&gt;
0. Download CentOS 5.5 installation CD image and Enterprise R's tar package &lt;br /&gt;
&lt;br /&gt;
1. In host Ubuntu:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="font-family: inherit;"&gt; &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;sudo apt-get install libvirt-bin qemu-kvm&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style="font-family: inherit;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;sudo service qemu-kvm start&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: inherit;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;sudo service libvirt-bin start&lt;/span&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style="font-family: inherit;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="font-family: inherit;"&gt;
&amp;nbsp;2. From main menu, choose&amp;nbsp; "System Tools-&amp;gt; Virtual Machine Manager" and add a new virtual machine using the CentOS image as the virtual cdrom, then install the CentOS in the virtual machine. I suggest that do not install the desktop environment. &lt;/div&gt;
&lt;div style="font-family: inherit;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="font-family: inherit;"&gt;
&amp;nbsp;3. In the installed guest CentOS, run the command "/sbin/ifconfig" to see the IP address of the guest CentOS, then use sftp to "upload" the Enterprise R tar package to the guest OS&lt;/div&gt;
&lt;div style="font-family: inherit;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="font-family: inherit;"&gt;
&amp;nbsp;4. In guest OS, run &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;yum install unixODBC&lt;/span&gt;&amp;nbsp; then untar the tar package, then &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;cd&lt;/span&gt; to the uncompressed Revo folder and execute&amp;nbsp; &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;./install.py&lt;/span&gt;&amp;nbsp;&amp;nbsp; &lt;/div&gt;
&lt;div style="font-family: inherit;"&gt;
&amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div style="font-family: inherit;"&gt;
&amp;nbsp;5. Now you can use the Enterprise R 4.2 in Ubuntu, with CentOS as the guest OS.&lt;/div&gt;
&lt;div style="font-family: inherit;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ESS can help you process the output of the R process running on the guest OS.&lt;/div&gt;
&lt;div style="font-family: inherit;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="font-family: inherit;"&gt;
&amp;nbsp;There are several things we need to keep in mind:&lt;/div&gt;
&lt;div style="font-family: inherit;"&gt;
&amp;nbsp;A. There are some performance penalty on the guest OS&lt;/div&gt;
&lt;div style="font-family: inherit;"&gt;
&amp;nbsp;B. You need to upload (or tell R the accessible path) the data files to the guest OS&lt;/div&gt;
&lt;div style="font-family: inherit;"&gt;
&amp;nbsp;C. You can not use other virtual machines (like virtualbox) at the same time&lt;/div&gt;
&lt;div style="font-family: inherit;"&gt;
&amp;nbsp;D. Enterprise R for RHEL does not provide the fancy IDE available on Win32(or Win64)&lt;/div&gt;
&lt;div style="font-family: inherit;"&gt;
 &lt;/div&gt;
&lt;div style="font-family: inherit;"&gt;
 &lt;/div&gt;
&lt;div style="font-family: inherit;"&gt;
 &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20298197-6937614355026547716?l=gongyiliao.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gongyiliao.blogspot.com/feeds/6937614355026547716/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gongyiliao.blogspot.com/2011/02/using-revolution-r-42-in-ubuntu-1010.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20298197/posts/default/6937614355026547716'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20298197/posts/default/6937614355026547716'/><link rel='alternate' type='text/html' href='http://gongyiliao.blogspot.com/2011/02/using-revolution-r-42-in-ubuntu-1010.html' title='Using Revolution R 4.2 in Ubuntu 10.10'/><author><name>Gong-Yi Liao</name><uri>http://www.blogger.com/profile/11302878591097519896</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_z6Jdlbxzyug/SpQsvBCZ5_I/AAAAAAAABvc/OqzYFfVOSZs/S220/emacs.png'/></author><thr:total>0</thr:total></entry></feed>
