Re: [Rcpp-devel] r-forge error: undefined symbol: zgetri_

2010-08-21 Thread baptiste auguie
On 20 August 2010 22:33, Douglas Bates  wrote:
> On Fri, Aug 20, 2010 at 12:35 PM, baptiste auguie
>  wrote:
>> Hi,
>>
>> On 20 August 2010 19:09, Romain Francois  wrote:
>>> Le 20/08/10 16:07, Dirk Eddelbuettel a écrit :

 On 20 August 2010 at 09:41, baptiste auguie wrote:
 | Indeed, I had forgotten to rerun roxygen before my last commit, sorry.
 | It should be OK now.
 |
 | I've also put the source tarball from R CMD BUILD here,
 |
 | http://dl.dropbox.com/u/352834/cda_1.0.tar.gz

 This works for me on Ubuntu 10.4 / amd64 once I drop the Depends: on
 the package constants which is not on CRAN:

 e...@max:/tmp/cda$ R CMD INSTALL .
 * installing to library ‘/usr/local/lib/R/site-library’
 * installing *source* package ‘cda’ ...
 ** libs
 g++ -I/usr/share/R/include
 -I"/usr/local/lib/R/site-library/Rcpp/include"
 -I"/usr/local/lib/R/site-library/RcppArmadillo/include"   -fpic  -O3 -g0
 -Wall -pipe  -c cda.cpp -o cda.o
 cda.cpp: In function ‘int progress_bar(double, double)’:
 cda.cpp:36: warning: no return statement in function returning non-void
 cda.cpp: In function ‘Rcpp::List linearExtinction(const arma::mat&, const
 arma::cx_mat&, double)’:
 cda.cpp:285: warning: unused variable ‘pi’
 g++ -shared -o cda.so cda.o -L/usr/local/lib/R/site-library/Rcpp/lib
 -lRcpp -Wl,-rpath,/usr/local/lib/R/site-library/Rcpp/lib -llapack -lblas
 -lgfortran -lm -L/usr/lib64/R/lib -lR
 installing to /usr/local/lib/R/site-library/cda/libs
 ** R
 ** inst
 ** preparing package for lazy loading
 Loading required package: reshape
 Loading required package: plyr
 Loading required package: grid
 Loading required package: proto
 ** help
 *** installing help indices
 ** building package indices ...
 ** testing if installed package can be loaded

 * DONE (cda)
 e...@max:/tmp/cda$ r -lcda -e'cat("Hello cda world\n")'
 Hello cda world
 e...@max:/tmp/cda$

 FWIW on Debian and Ubuntu R uses external lapack and blas libraries.

 Dirk
>>>
>>> That is also why it works on OSX, because here we are using the vecLib
>>> framework for blas and lapack.
>>>
>>
>> Thank you all for investigating the matter.
>>
>>>
>>> So you are left with a few options :
>>> - don't call inv on your complex matrix
>>
>> i do need this, I feel it would be a waste to convert the matrix back
>> to R format, invert it with R facilities, and then convert it back for
>> Armadillo...
>
> On many occasions where people think that they need to calculate a
> matrix inverse they don't really need to do so.  For example you don't
> need to calculate the inverse explicitly if all you are going to do is
> to solve a linear system of equations.


True, on many occasions. In this particular case, I have to solve many
times (typically more than 400 times) the system Ax = b, with
different right-hand side b. I haven't checked objectively, but my
guess was that calculating the inverse once was to be more efficient
than solving the 400 linear systems. It may depend on the size of the
matrix, etc.

Best,

baptiste

>
>>> - negociate with R-core that they include missing lapack bits
>>
>> I wouldn't even know what's missing and where.
>>
>>> - write a package that supplies these bits
>>
>> Same here.
>>>
>>> I'm afraid there is nothing we can really do.
>>
>> That's OK, thankfully it works on the only platform(s) I use. A shame
>> that I can't easily share this work with others though.
>>
>> Thanks,
>>
>> baptiste
>>>
>>> Romain
>>>
>>> --
>>> Romain Francois
>>> Professional R Enthusiast
>>> +33(0) 6 28 91 30 30
>>> http://romainfrancois.blog.free.fr
>>> |- http://bit.ly/bzoWrs : Rcpp svn revision 2000
>>> |- http://bit.ly/b8VNE2 : Rcpp at LondonR, oct 5th
>>> `- http://bit.ly/aAyra4 : highlight 0.2-2
>>>
>>>
>>
>>
>>
>> --
>> 
>>
>> Dr. Baptiste Auguié
>>
>> Departamento de Química Física,
>> Universidade de Vigo,
>> Campus Universitario, 36310, Vigo, Spain
>>
>> tel: +34 9868 18617
>> http://webs.uvigo.es/coloides
>> 
>> ___
>> Rcpp-devel mailing list
>> Rcpp-devel@lists.r-forge.r-project.org
>> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
>>
>



-- 


Dr. Baptiste Auguié

Departamento de Química Física,
Universidade de Vigo,
Campus Universitario, 36310, Vigo, Spain

tel: +34 9868 18617
http://webs.uvigo.es/coloides

___
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel


[Rcpp-devel] [RcppExamples] -- would someone share the makefile?

2010-08-21 Thread Johannes Egner
Hi,

I am (slowly and carefully) learning about Rcpp, and thought that compiling
the code in the RcppExamples package could be a good start.

MSVC seems to be out of the game (at least as far as the compiler is
concerned; using it as an editor may be another story), and it seems I
cannot avoid using MinGW and those mysterious makefiles anymore. Would
anyone care to send me a makefile that was used to compile the mentioned
examples, please? (I know it needs modifying -- I'll use it as a template to
see what I need to learn about makefiles for now.)

Thanks, Jo
___
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel


Re: [Rcpp-devel] r-forge error: undefined symbol: zgetri_

2010-08-21 Thread Dirk Eddelbuettel

On 20 August 2010 at 19:35, baptiste auguie wrote:
| That's OK, thankfully it works on the only platform(s) I use. A shame
| that I can't easily share this work with others though.

You can!  You "merely" have to ensure folks have a full-blown LAPACK
installation at hand rather than the ones supplied by R as a fallback.

Dirk

-- 
Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.com
___
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel


Re: [Rcpp-devel] [RcppExamples] -- would someone share the makefile?

2010-08-21 Thread Dirk Eddelbuettel

On 21 August 2010 at 18:36, Johannes Egner wrote:
| Hi,
| 
| I am (slowly and carefully) learning about Rcpp, and thought that compiling
| the code in the RcppExamples package could be a good start.
| 
| MSVC seems to be out of the game (at least as far as the compiler is
| concerned; using it as an editor may be another story), and it seems I
| cannot avoid using MinGW and those mysterious makefiles anymore. Would
| anyone care to send me a makefile that was used to compile the mentioned
| examples, please? (I know it needs modifying -- I'll use it as a template to
| see what I need to learn about makefiles for now.)

There are no Makefiles. 

It all works through the magic of the R package system. Witmess:

e...@max:/tmp$ 
e...@max:/tmp$ 
e...@max:/tmp$ wget 
http://cran.us.r-project.org/src/contrib/RcppExamples_0.1.1.tar.gz
--2010-08-21 12:40:24--  
http://cran.us.r-project.org/src/contrib/RcppExamples_0.1.1.tar.gz
Resolving cran.us.r-project.org... 140.107.3.21
Connecting to cran.us.r-project.org|140.107.3.21|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 14446 (14K) [application/x-gzip]
Saving to: `RcppExamples_0.1.1.tar.gz'

100%[==>] 14,446  74.5K/s   in 0.2s

2010-08-21 12:40:24 (74.5 KB/s) - `RcppExamples_0.1.1.tar.gz' saved 
[14446/14446]

e...@max:/tmp$ R CMD INSTALL RcppExamples_0.1.1.tar.gz 
* installing to library ‘/usr/local/lib/R/site-library’
* installing *source* package ‘RcppExamples’ ...
** libs
g++ -I/usr/share/R/include   -I"/usr/local/lib/R/site-library/Rcpp/include"   
-fpic  -O3 -g0 -Wall -pipe  -c RcppDateExample.cpp -o RcppDateExample.o
g++ -I/usr/share/R/include   -I"/usr/local/lib/R/site-library/Rcpp/include"   
-fpic  -O3 -g0 -Wall -pipe  -c RcppExample.cpp -o RcppExample.o
g++ -I/usr/share/R/include   -I"/usr/local/lib/R/site-library/Rcpp/include"   
-fpic  -O3 -g0 -Wall -pipe  -c RcppMatrixExample.cpp -o RcppMatrixExample.o
g++ -I/usr/share/R/include   -I"/usr/local/lib/R/site-library/Rcpp/include"   
-fpic  -O3 -g0 -Wall -pipe  -c RcppParamsExample.cpp -o RcppParamsExample.o
g++ -I/usr/share/R/include   -I"/usr/local/lib/R/site-library/Rcpp/include"   
-fpic  -O3 -g0 -Wall -pipe  -c RcppStringVectorExample.cpp -o 
RcppStringVectorExample.o
g++ -I/usr/share/R/include   -I"/usr/local/lib/R/site-library/Rcpp/include"   
-fpic  -O3 -g0 -Wall -pipe  -c RcppVectorExample.cpp -o RcppVectorExample.o
g++ -shared -o RcppExamples.so RcppDateExample.o RcppExample.o 
RcppMatrixExample.o RcppParamsExample.o RcppStringVectorExample.o 
RcppVectorExample.o -L/usr/local/lib/R/site-library/Rcpp/lib -lRcpp 
-Wl,-rpath,/usr/local/lib/R/site-library/Rcpp/lib -L/usr/lib64/R/lib -lR
installing to /usr/local/lib/R/site-library/RcppExamples/libs
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices ...
** testing if installed package can be loaded

* DONE (RcppExamples)
e...@max:/tmp$ 
e...@max:/tmp$ 

Those two commands would be identical for you on Windows (provided you
installed wget and of course the Rtools needed to compile R packages).

We have a vignette Rcpp-package that has more on how to use Rcpp et al in
your package.  You can of course also just copy RcppExamples and start from
there.  And/or use Rcpp.package.skeleton().

Hope this helps,  Dirk

-- 
Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.com
___
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel


Re: [Rcpp-devel] [RcppExamples] -- would someone share the makefile?

2010-08-21 Thread Romain Francois

Le 21/08/10 19:36, Johannes Egner a écrit :

Hi,

I am (slowly and carefully) learning about Rcpp


Great. Welcome here.


and thought that
compiling the code in the RcppExamples package could be a good start.


Perhaps. Also see Rcpp.package.skeleton to make a small package. The 
Rcpp-package vignette will certainly help you (please tell us if it does 
not).



MSVC seems to be out of the game (at least as far as the compiler is
concerned; using it as an editor may be another story), and it seems I
cannot avoid using MinGW and those mysterious makefiles anymore.


Although we have received a patch going in the MSVC direction, this is 
not supported. You would have to first find how to build R with MSVC, 
and it appears you cannot.



Would
anyone care to send me a makefile that was used to compile the mentioned
examples, please? (I know it needs modifying -- I'll use it as a
template to see what I need to learn about makefiles for now.)

Thanks, Jo


There is no need for a Makefile. Just start with :

> require( Rcpp )
> Rcpp.package.skeleton( "wonderland" )

and then :

$ R CMD INSTALL wonderland

This should all work fine if you have Rtools installed, which you can 
get from : http://www.murdoch-sutherland.com/Rtools/


Romain

--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://bit.ly/bzoWrs : Rcpp svn revision 2000
|- http://bit.ly/b8VNE2 : Rcpp at LondonR, oct 5th
`- http://bit.ly/aAyra4 : highlight 0.2-2

___
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel


Re: [Rcpp-devel] On mailing list defaults, and suggested patch submission

2010-08-21 Thread Romain Francois

Dominick,

I've commited a variation of your patch in Rcpp now. Let me know if that 
works for you.


I've put the new headers in inst/include/Rcpp/msvc instead of 
inst/include/msvc to lower chances of clashes with other software.


I've also modified msvcmath.cpp so that when this is not used in MSVC, 
there is some dummy symbol compiled, otherwise R CMD INSTALL complains. 
I'm surprised you did not see that when you tested it.


Not that I care, but I'm slightly surprised at the implementation of 
log1p :


double log1p(double x) {
if(x <= -1.0)
throw std::range_error("log1p: arg <= -1");
if(fabs(x) > 1.e-4)
return log(1.0 + x);
return (-0.5*x + 1.0)*x;
}

specifically that it throws an exception

Romain

Le 20/08/10 17:38, Dominick Samperi a écrit :

On Fri, Aug 20, 2010 at 2:27 AM, Romain Francois
mailto:rom...@r-enthusiasts.com>> wrote:

I have not seen any of these files. But note that, as Dirk said
before, please send patches rather than full copy of modified files.

 >From some directory of your modified Rcpp tree, just do :

$ svn diff > mypatch.diff

and send that file, that should be ok.

If you want to add files with this mechanism, you can. Just do

$ svn add whatever/file
$ svn diff > mypatch.diff

The only thing you cannot do is svn commit.


The diff file msvc.patch.txt is attached, along with the three new .h
files that
should go into Rcpp/inst/include/msvc (or something else if you prefer).

While I could 'svn add Rcpp/src/msvcmath.cpp' I could not do this
for the .h files because the directory Rcpp/inst/include/msvc does not
exist,
and I couldn't create it.

These changes will permit compilation with Visual C++. The warning level
needs to be changed from the default to prevent a large number of
warning messages. The main purpose would be to check that the
C++ code is portable. If these changes are added you probably want to
note that MSVC is not officially (or even unofficially) supported.

On the tags/branches question, it appears that all projects on R-Forge are
laid out without the usual tags and branches subdirectories.Is this due to
restrictions at R-Forge? I guess the way to fetch files corresponding to
a particular CRAN release is to get versions that were current at the
time that the CRAN release happened, right?

Thanks,
Dominick


--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://bit.ly/bzoWrs : Rcpp svn revision 2000
|- http://bit.ly/b8VNE2 : Rcpp at LondonR, oct 5th
`- http://bit.ly/aAyra4 : highlight 0.2-2

___
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel


Re: [Rcpp-devel] [RcppExamples] -- would someone share the makefile?

2010-08-21 Thread Johannes Egner
Dirk, Romain,

thanks for your replies.

I suspect I should have been more verbose. Here's what I was trying to do:

(1) The convolve function is the standard example for using .Call or .C; and
it is easy (using MinGW or even cl.exe in MSVC) to produce a DLL that one
can call from R (possibly modulo name mangling): 5 minutes, tops. Most
importantly: up to the point where R loads the DLL, I know precisely what
was going on.

(2) This is a reassuring result, and I want to achieve the same thing with
Rcpp. Ok, let's read your article "Rcpp: Seamless R and C++ integration".
Page 2 has the code. I didn't expect it to work, but nonetheless tried MinGW
(because you were pretty clear on MSVC...) on this simple example. (Let's
forget about a header file that may be necessary to expose the function, or
any trap related to calling conventions for the moment.)

(3) MinGW needs the header files from Rcpp (0.8.5, WinBinary -- I don't
think 0.7.1 is any different, although I should have used this). Rcpp.h is
needed, which I find in Rcpp/include and place it in the root of the
"project folder" (a folder just containing the cpp-file). Ok, this isn't
working -- it needs to be #include "Rcpp.h", and not #include ,
because I have no environment variables set for MinGW, and the compiler
apparently does not look at the root of the folder (which MSVC would do).

(4) Having changed that, MinGW wants to see RcppCommon.h (ok, my mistake --
I should have had a look into Rcpp.h!). Same bracket vs quote thing. Next
are various header files from Rcpp/include/Rcpp and Rcpp/classic -- each
time with the same bracket/quote issue.

(5) I must be on the wrong track -- changing the header files cannot be the
intented solution. I now suspect a makefile could be the solution -- maybe
it defines where to look for all those header files. (Hoping it also might
give me some indication how I can later compile code from many different
files.) Because I don't know (yet) how to make such a makefile, I have
looked into RcppExamples, and then written my first mail to the list.

Now using Rcpp.package.skeleton is indeed a step forward -- it passes R CMD,
becomes a tarball, and I can build a zip file with the DLL in it. (Which
correctly exposes the function rcpp_hello_world). It seems R CMD build
miraculously knows how to feed the right arguments to the compiler (and lets
it know where all the headers are). As convenient as this is, it is a bit
too opaque for me. I suspect I'd struggle to develop "realistic code"
(several files, links to static/dynamic libraries,...) just relying on R's
package building mechanism.

Long story short: something as in (1), i.e. a simple, but %working% piece of
code where all "mechanics" (dependencies, compiler arguments, etc) are
transparent is what I'm after. I would imagine that this could be done by
explaining what happens behind the stages when R CMD build is called, and
that these mechanics are best scaled to code projects of realistic sizes by
the mentioned makefiles -- but I might of course be wrong.

Best wishes, Jo
___
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel


[Rcpp-devel] Filling NumericMatrix with NumericVectors with apply by row/column?

2010-08-21 Thread Christian Gunning
Dear list,

I'm amazed at the ability to use the apply family in Rcpp.  Yet I'm still
unsure of the best way to assign NumericVector objects into
NumericMatrix objects.  Must this be done element-by-element, or is
there something equivalent to R's MyMatrix[,1] = MyColVector?
(As an aside, are both mymatrix[i,j] and mymatrix(i,j) equivalent?  It
seems that I've seen them used interchangably on the list.)

A simple example of what I'm aiming for:
Make an n*n matrix, and use sapply to perform a vector operation by
row, here constructing a vector of length n full of zeros.

// a simple vector-returning function
NumericVector zeros( int n){
 NumericVector ret(n);
 ret = 0;
 return ret;
}

// sapply version, doesn't work but is easy to read
SEXP foo( int n ){
 NumericVector x(n);
 x = n;
 NumericMatrix xx(n,n) ;
 // possible to assign by row or column?
 xx = sapply( x, zeros ) ;
 return(xx);
}

// the looped version, where xx[,i] is not syntactically valid
SEXP foo1( int n ){
 NumericVector x(n);
 int i;
 NumericMatrix xx(n,n) ;
 // possible to assign by row or column?
 for (i =0; i___
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel