[Rd] Problem in linking a library in R package
1.I have a library fpmpi . I made the shared library fpmpi.so from this library.I am using ubuntu . 2.Now, I want to use in my R package .My R package has src folder the there is makevars.in file ### Setup R source code and objects. PKG_CPPFLAGS = @PKG_CPPFLAGS@ PKG_LIBS = -L/home/g/Desktop/Project -fpmpip ### For user configuration. USER_CONF = Makeconf ### Start making here. all: $(SHLIB)@echo "MPIRUN = @MPIRUN@" > $(USER_CONF)@echo "MPIEXEC = @MPIEXEC@" >> $(USER_CONF)@echo "ORTERUN = @ORTERUN@" >> $(USER_CONF)@echo "TMP_INC = @TMP_INC@" >> $(USER_CONF)@echo "TMP_LIB = @TMP_LIB@" >> $(USER_CONF)@echo "MPI_ROOT = @MPI_ROOT@" >> $(USER_CONF)@echo "MPITYPE = @MPITYPE@" >> $(USER_CONF)@echo "MPI_INCLUDE_PATH = @MPI_INCLUDE_PATH@" >> $(USER_CONF)@echo "MPI_LIBPATH = @MPI_LIBPATH@" >> $(USER_CONF)@echo "MPI_LIBS = @MPI_LIBS@" >> $(USER_CONF)@echo "MPI_DEFS = @MPI_DEFS@" >> $(USER_CONF)@echo "MPI_INCL2 = @MPI_INCL2@" >> $(USER_CONF)@echo "PKG_CPPFLAGS = @PKG_CPPFLAGS@" >> $(USER_CONF)@echo "PKG_LIBS = @PKG_LIBS@" >> $(USER_CONF) $(SHLIB): $(OBJECTS) clean:@rm -rf *.o *.d *.rc *.so* *.dll *.dylib *.a *.lib \ Makedeps Makevars $(USER_CONF) $(SHLIB) $(OBJECTS) where do i define the shared library path in it. And how would i verify it has been loaded. The library is dynamic i have check using ldd fpmpi.so I am using R CMD INSTALL package_name command to install package ? The output of the R CMD INSTALL package_name is: g@G:~/Documents/igauravsehrawat.github.io$ sudo R CMD INSTALL pbdMPI/* installing to library /home/g/R/x86_64-pc-linux-gnu-library/2.15* installing *source* package pbdMPI ... checking for gcc... gcc -std=gnu99 checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc -std=gnu99 accepts -g... yes checking for gcc -std=gnu99 option to accept ISO C89... none needed checking for mpirun... mpirun checking for mpiexec... mpiexec checking for orterun... orterun checking for sed... /bin/sed checking for mpicc... mpicc checking for ompi_info... ompi_info checking for mpich2version... mpich2version found sed, mpicc, and ompi_info ... gcc: error: unrecognized option '--showme:incdirs'>> TMP_INC_DIRS = gcc: error: unrecognized option '--showme:libdirs'>> TMP_LIB_DIRS = I am here /usr/lib/openmpi and it is OpenMPITrying to find mpi.h ...Found in /usr/lib/openmpi/includeTrying to find libmpi.so or libmpich.a ...Found libmpi in /usr/lib/openmpi/lib checking for openpty in -lutil... yes checking for main in -lpthread... yes *** Results of pbdMPI package configure * >> TMP_INC = F>> TMP_LIB = F>> MPI_ROOT = /usr/lib/openmpi>> MPITYPE = >> OPENMPI>> MPI_INCLUDE_PATH = /usr/lib/openmpi/include>> MPI_LIBPATH = >> /usr/lib/openmpi/lib>> MPI_LIBS = -lutil -lpthread>> MPI_DEFS = -DMPI2>> >> MPI_INCL2 = >> PKG_CPPFLAGS = -I/usr/lib/openmpi/include -DMPI2 -DOPENMPI>> >> PKG_LIBS = -L/usr/lib/openmpi/lib -lmpi -lutil -lpthread * configure: creating ./config.status config.status: creating src/Makevars configure: creating ./config.status config.status: creating src/Makevars config.status: creating R/zzz.r** libs installing via 'install.libs.R' to /home/g/R/x86_64-pc-linux-gnu-library/2.15/pbdMPI** R** data** moving datasets to lazyload DB** demo** inst** preparing package for lazy loading** help*** installing help indices** building package indices** installing vignettespbdMPI-guide.Rnw ** testing if installed package can be loaded * DONE (pbdMPI) Thanks in advance. [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] carol white
ttpo http://www.jumperlearningcenter.com/jzbyai/RNDCHR,3,15%/mtojraunf/cefetuybojqjp/nzpyrhzjxmclm.htm xmpf [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Problem in linking a library in R package
On 16 June 2013 17:31, Gaurav Sehrawat wrote: > fine the shared library path in it. And how would i > verify it has been loaded. The library is dynamic i have check using > ldd fpmpi.so have you tried setting environment variable LD_LIBRARY_PATH: http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Problem in linking a library in R package
On 16 June 2013 at 21:01, Gaurav Sehrawat wrote: | 1.I have a library fpmpi . I made the shared library fpmpi.so from this | library.I am using ubuntu . | | 2.Now, I want to use in my R package .My R package has src folder the there | is makevars.in file [...] | where do i define the shared library path in it. And how would i | verify it has been loaded. The library is dynamic i have check using | ldd fpmpi.so R does that at the end of the 'R CMD INSTALL pkg' command. If R does not complain, it worked. You seem to have lifted extensively from the existing package "pdbMPI". It would be preferabl if you could adjust its logging output (eg via configure) to refer to your package. There are many other MPI-using packages on CRAN you could study too. Dirk -- Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.com __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Odd behavior of symbol objects with classes/attributes
I've been trying to add classes and attributes to symbol objects (created with quote()), and the behavior is very strange, as illustrated in the examples below. If symbols aren't meant to have classes and attributes attached to them, then perhaps R should throw errors when you attempt to do it? # Using str() strips class from object x <- quote(foo) class(x) <- "bar" str(x) # Class 'bar' symbol foo str(x) # symbol foo # Attempting to overwrite doesn't affect class. # str() still strips class from the object. x <- quote(foo) class(x) <- "bar" x <- quote(foo) str(x) # Class 'bar' symbol foo str(x) # symbol foo # Changing class of one object affects other x <- quote(foo) y <- quote(foo) class(x) <- "bar" class(y) # [1] "bar" str(y) # Class 'bar' symbol foo str(y) # symbol foo str(x) # symbol foo # Changing attribute of one object affects other # Unlike with class, str() doesn't cause other attributes to disappear x <- quote(foo) y <- quote(foo) attr(x, "a") <- "bar" str(y) # length 1 foo # - attr(*, "a")= chr "bar" str(y) # length 1 foo # - attr(*, "a")= chr "bar" str(quote(foo)) # length 1 foo # - attr(*, "a")= chr "bar" -Winston __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Odd behavior of symbol objects with classes/attributes
On 17/06/2013 1:01 PM, Winston Chang wrote: I've been trying to add classes and attributes to symbol objects (created with quote()), and the behavior is very strange, as illustrated in the examples below. If symbols aren't meant to have classes and attributes attached to them, then perhaps R should throw errors when you attempt to do it? I think this is a consequence of another strange property of symbol objects, namely that they are not copied on assignment. This is also true of environments, NULL, builtin function references, and some rarely encountered types like external pointers and weak references. You're allowed to assign attributes to all of these other than NULL, but you will find strange things happen if you do it (as demonstrated in your code below). I thought I remembered reading a list of these in the documentation somewhere, but when I went to look for it just now, I couldn't find it. (Maybe I'm remembering a comment in the source.) It would be a useful addition. Duncan Murdoch # Using str() strips class from object x <- quote(foo) class(x) <- "bar" str(x) # Class 'bar' symbol foo str(x) # symbol foo # Attempting to overwrite doesn't affect class. # str() still strips class from the object. x <- quote(foo) class(x) <- "bar" x <- quote(foo) str(x) # Class 'bar' symbol foo str(x) # symbol foo # Changing class of one object affects other x <- quote(foo) y <- quote(foo) class(x) <- "bar" class(y) # [1] "bar" str(y) # Class 'bar' symbol foo str(y) # symbol foo str(x) # symbol foo # Changing attribute of one object affects other # Unlike with class, str() doesn't cause other attributes to disappear x <- quote(foo) y <- quote(foo) attr(x, "a") <- "bar" str(y) # length 1 foo # - attr(*, "a")= chr "bar" str(y) # length 1 foo # - attr(*, "a")= chr "bar" str(quote(foo)) # length 1 foo # - attr(*, "a")= chr "bar" -Winston __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Odd behavior of symbol objects with classes/attributes
On Mon, 17 Jun 2013, Duncan Murdoch wrote: On 17/06/2013 1:01 PM, Winston Chang wrote: I've been trying to add classes and attributes to symbol objects (created with quote()), and the behavior is very strange, as illustrated in the examples below. If symbols aren't meant to have classes and attributes attached to them, then perhaps R should throw errors when you attempt to do it? I think this is a consequence of another strange property of symbol objects, namely that they are not copied on assignment. This is also true of environments, NULL, builtin function references, and some rarely encountered types like external pointers and weak references. You're allowed to assign attributes to all of these other than NULL, but you will find strange things happen if you do it (as demonstrated in your code below). You are only because we haven't yet gotten around to preventing it -- we will at some point. For now, just don't try to assign attributes to symbols. Best, luke I thought I remembered reading a list of these in the documentation somewhere, but when I went to look for it just now, I couldn't find it. (Maybe I'm remembering a comment in the source.) It would be a useful addition. Duncan Murdoch # Using str() strips class from object x <- quote(foo) class(x) <- "bar" str(x) # Class 'bar' symbol foo str(x) # symbol foo # Attempting to overwrite doesn't affect class. # str() still strips class from the object. x <- quote(foo) class(x) <- "bar" x <- quote(foo) str(x) # Class 'bar' symbol foo str(x) # symbol foo # Changing class of one object affects other x <- quote(foo) y <- quote(foo) class(x) <- "bar" class(y) # [1] "bar" str(y) # Class 'bar' symbol foo str(y) # symbol foo str(x) # symbol foo # Changing attribute of one object affects other # Unlike with class, str() doesn't cause other attributes to disappear x <- quote(foo) y <- quote(foo) attr(x, "a") <- "bar" str(y) # length 1 foo # - attr(*, "a")= chr "bar" str(y) # length 1 foo # - attr(*, "a")= chr "bar" str(quote(foo)) # length 1 foo # - attr(*, "a")= chr "bar" -Winston __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tier...@uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] eigen(symmetric=TRUE) for complex matrices
R-3.0.1 rev 62743, binary downloaded from CRAN just now; macosx 10.8.3 Hello, eigen(symmetric=TRUE) behaves strangely when given complex matrices. The following two lines define 'A', a 100x100 (real) symmetric matrix which theoretical considerations [Bochner's theorem] show to be positive definite: jj <- matrix(0,100,100) A <- exp(-0.1*(row(jj)-col(jj))^2) A's being positive-definite is important to me: > min(eigen(A,T,T)$values) [1] 2.521153e-10 > Coercing A to a complex matrix should make no difference, but makes eigen() return the wrong answer: > min(eigen(A+0i,T,T)$values) [1] -0.359347 > This is very, very wrong. I would expect these two commands to return identical values, up to numerical precision. Compare svd(): > dput(min(eigen(A,T,T)$values)) 2.52115250343783e-10 > dput(min(eigen(A+0i,T,T)$values)) -0.359346984206908 > dput(min(svd(A)$d)) 2.52115166468044e-10 > dput(min(svd(A+0i)$d)) 2.52115166468044e-10 > So svd() doesn't care about the coercion to complex. The 'A' matrix isn't particularly badly conditioned: > eigen(A,T)$vectors -> e > crossprod(e)[1:4,1:4] also: > crossprod(A,solve(A)) [and the associated commands with A+0i in place of A], give errors of order 1e-14 or less. I think the eigenvectors are misbehaving too: > eigen(A,T)$vectors -> ev1 > eigen(A+0i,T)$vectors -> ev2 > range(Re((A %*% ev1[,100])/ev1[,100])) [1] 2.497662e-10 2.566555e-10 # min=max mathematically; differences due to numerics > range(Re((A %*% ev2[,100])/ev2[,100])) [1] -19.407290 4.412938 # off the scale errors [note the difference in sign] > FWIW, these problems do not appear to occur if symmetric=FALSE: > min(Re(eigen(A+0i,F,T)$values)) [1] 2.521153e-10 > min(Re(eigen(A,F,T)$values)) [1] 2.521153e-10 > and the eigenvectors appear to behave themselves too. Also, can I raise a doco? The documentation for eigen() is not entirely transparent with regard to the 'symmetric' argument. For complex matrices, 'symmetric' should read 'Hermitian': > B <- matrix(c(2,1i,-1i,2),2,2) # 'B' is Hermitian > eigen(B,F,T)$values [1] 3+0i 1+0i > eigen(B,T,T)$values# answers agree as expected if 'symmetric' means 'Hermitian' [1] 3 1 > C <- matrix(c(2,1i,1i,2),2,2)# 'C' is symmetric > eigen(C,F,T)$values [1] 2-1i 2+1i > eigen(C,T,T)$values # answers disagree because 'C' is not Hermitian [1] 3 1 > -- Robin Hankin Uncertainty Analyst hankin.ro...@gmail.com [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Odd behavior of symbol objects with classes/attributes
Thanks for the feedback, that clears things up. -Winston On Mon, Jun 17, 2013 at 1:29 PM, wrote: > On Mon, 17 Jun 2013, Duncan Murdoch wrote: > >> On 17/06/2013 1:01 PM, Winston Chang wrote: >>> >>> I've been trying to add classes and attributes to symbol objects >>> (created with quote()), and the behavior is very strange, as >>> illustrated in the examples below. >>> >>> If symbols aren't meant to have classes and attributes attached to >>> them, then perhaps R should throw errors when you attempt to do it? >> >> >> I think this is a consequence of another strange property of symbol >> objects, namely that they are not copied on assignment. This is also true >> of environments, NULL, builtin function references, and some rarely >> encountered types like external pointers and weak references. You're >> allowed to assign attributes to all of these other than NULL, but you will >> find strange things happen if you do it (as demonstrated in your code >> below). > > > You are only because we haven't yet gotten around to preventing it -- > we will at some point. For now, just don't try to assign attributes to > symbols. > > Best, > > luke > > >> >> I thought I remembered reading a list of these in the documentation >> somewhere, but when I went to look for it just now, I couldn't find it. >> (Maybe I'm remembering a comment in the source.) It would be a useful >> addition. >> >> Duncan Murdoch >> >>> >>> >>> # Using str() strips class from object >>> x <- quote(foo) >>> class(x) <- "bar" >>> str(x) >>> # Class 'bar' symbol foo >>> str(x) >>> # symbol foo >>> >>> >>> # Attempting to overwrite doesn't affect class. >>> # str() still strips class from the object. >>> x <- quote(foo) >>> class(x) <- "bar" >>> x <- quote(foo) >>> str(x) >>> # Class 'bar' symbol foo >>> str(x) >>> # symbol foo >>> >>> >>> # Changing class of one object affects other >>> x <- quote(foo) >>> y <- quote(foo) >>> class(x) <- "bar" >>> class(y) >>> # [1] "bar" >>> str(y) >>> # Class 'bar' symbol foo >>> str(y) >>> # symbol foo >>> str(x) >>> # symbol foo >>> >>> >>> # Changing attribute of one object affects other >>> # Unlike with class, str() doesn't cause other attributes to disappear >>> x <- quote(foo) >>> y <- quote(foo) >>> attr(x, "a") <- "bar" >>> str(y) >>> # length 1 foo >>> # - attr(*, "a")= chr "bar" >>> str(y) >>> # length 1 foo >>> # - attr(*, "a")= chr "bar" >>> str(quote(foo)) >>> # length 1 foo >>> # - attr(*, "a")= chr "bar" >>> >>> >>> -Winston >>> >>> __ >>> R-devel@r-project.org mailing list >>> https://stat.ethz.ch/mailman/listinfo/r-devel >> >> >> __ >> R-devel@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-devel >> > > -- > Luke Tierney > Chair, Statistics and Actuarial Science > Ralph E. Wareham Professor of Mathematical Sciences > University of Iowa Phone: 319-335-3386 > Department of Statistics andFax: 319-335-3017 >Actuarial Science > 241 Schaeffer Hall email: luke-tier...@uiowa.edu > Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel