$OpenXM: OpenXM/src/R/r-packages/note.txt,v 1.11 2020/02/06 05:58:17 takayama Exp $ See also OpenXM/src/hgm/note.txt * R package build, reference pages. https://cran.r-project.org/bin/macosx/tools/ * Example Edit files in src/hgm cd R/r-packages make rsync R CMD INSTALL hgm Start R and library(hgm) hgm.ncso3() * C source codes. C sources and headers should be developed and edited in the directory OpenXM/src/hgm in order to provide a standalone mode without R in the OpenXM project. They are copied by rsync to hgm/src from OpenXM/src/hgm/ See the Makefile. * How to develope and tests. (1) Develope the system in OpenXM/src/hgm as a standalone system. See OpenXM/src/hgm/so3 as an example. (2) Add rsync-[projectname] to OpenXM/src/R/r-packages/Makefile See the example of the project so3. (3) Example in the case of hgm. R CMD check hgm It generates pdf documents and shared libraries. hgm.Rcheck/hgm-Ex.Rout contains the result of the execution of examples embedded in the documents in man. hgm.Rcheck/hgm-manual.pdf is the PDF manual. See also http://fe.math.kobe-u.ac.jp/Movies/oxvh, 2012-09-05-r-package[.mov] 2013-02-06-Ropenxm[.mov] R CMD INSTALL hgm R library(hgm) You can check hgm.ncso3 by hand. R CMD REMOVE hgm It is used to remove the test library. R --help (4) Binary build on Windows. R CMD INSTALL --build hgm ( Check R CMD INSTALL --help for details. ) or R CMD build --binary hgm (perhaps, obsolete style) (5) make copy-web-hgm hgm_x.yz.tar.gz [cran submit package] search ==> http://cran.r-project.org/submit.html * Notes. library.dynam() shows a list of shared libraries loaded. dyn.load("hgm.so") can be used to load shared library by hand. getwd() gets the current working directory. * Undocumented functions which are removed temporary fro NAMESPACE. 2015.03.24 export(hgm.so3nc) export(hgm.normalizingConstantOfFisherDistributionOnSO3) export(hgm.normalizingConstantOfOrthant) export(hgm.normalizingConstantOfBinghamDistribution) export(hgm.z.mleDemo) export(hgm.ssFB) * Check the memory leak by valgrind and by AddressSanitizer. 2015.04.01 ** Valgrind apt-get install valgrind cat >>~/.valgrindrc --leak-check=full --track-origins=yes ctrl-D make clean R CMD check hgm --use-valgrind more hgm.Rcheck/hgm-Ex.Rout Example of an error (Note that there is no error message in *.log) ==14813== Conditional jump or move depends on uninitialised value(s) ==14813== at 0xCA20170: mh_t (jack-n.c:1361) for (i=0; i<=M_m; i++) { -- snip serror = myabs((partial_sum[i]-partial_sum[i-1])/partial_sum[i-1]); } partial_sum[-1] is accessed! As to details, search "valgrind" in R-exts.pdf * R CMD check hgm --use-gct * Note on building R package: @s/2015/04/05-hgm-r-package-memo.txt ;; 2016.02.15 testdata. c<-hgm.p2wishart(m=4,n1=50,n2=100,beta=c(1,2,4,8),q0=0.5,q=30,autoplot=1); output is wrong. c<-hgm.p2wishart(m=4,n1=50,n2=100,beta=c(1,2,4,8),q0=0.5,q=30,err=c(1e-30,1e-10),mode=c(1,1,0)) output is correct. c<-hgm.p2wishart(m=4,n1=50,n2=100,beta=c(1,2,4,8),q0=0.5,q=30,err=c(1e-30,1e-10),autoplot=1) crashed, but by commented out todo in mh.c, it works. See @s/2016/02 ;; http://kbroman.org/pkg_primer/pages/cran.html R CMD check hgm --as-cran ;; 2020.02.06 Installing r-devel apt-get install subversion ccache apt-get install xorg-dev apt-get install libcurl4-openssl-dev pushd ~/this19/R (for example) svn co https://svn.r-project.org/R/trunk r-devel/R cd r-devel/R and follow the INSTALL ./configure --without-recommended-packages --prefix ~/this19/R make export PATH=~/this19/R/r-devel/R/bin:$PATH Valgrid can be used by valgrind ./a.out A sample: main() { int n; if (n>0) n=0; }